Skip to content

Commit e1bc853

Browse files
committed
Disabled control for __experimentalValidateInput. Update type document.
1 parent 03420cc commit e1bc853

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

packages/components/src/form-token-field/stories/index.tsx

+1-13
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const meta: ComponentMeta< typeof FormTokenField > = {
2121
control: { type: null },
2222
},
2323
__experimentalValidateInput: {
24-
control: { type: 'boolean' },
24+
control: { type: null },
2525
},
2626
},
2727
parameters: {
@@ -43,7 +43,6 @@ const continents = [
4343
];
4444

4545
const DefaultTemplate: ComponentStory< typeof FormTokenField > = ( {
46-
__experimentalValidateInput,
4746
...args
4847
} ) => {
4948
const [ selectedContinents, setSelectedContinents ] = useState<
@@ -55,11 +54,6 @@ const DefaultTemplate: ComponentStory< typeof FormTokenField > = ( {
5554
{ ...args }
5655
value={ selectedContinents }
5756
onChange={ ( tokens ) => setSelectedContinents( tokens ) }
58-
__experimentalValidateInput={
59-
__experimentalValidateInput
60-
? ( newValue ) => continents.includes( newValue )
61-
: () => true
62-
}
6357
/>
6458
);
6559
};
@@ -73,7 +67,6 @@ Default.args = {
7367
};
7468

7569
export const Async: ComponentStory< typeof FormTokenField > = ( {
76-
__experimentalValidateInput,
7770
suggestions,
7871
...args
7972
} ) => {
@@ -102,11 +95,6 @@ export const Async: ComponentStory< typeof FormTokenField > = ( {
10295
suggestions={ availableContinents }
10396
onChange={ ( tokens ) => setSelectedContinents( tokens ) }
10497
onInputChange={ searchContinents }
105-
__experimentalValidateInput={
106-
__experimentalValidateInput
107-
? ( newValue ) => continents.includes( newValue )
108-
: () => true
109-
}
11098
/>
11199
);
112100
};

packages/components/src/form-token-field/types.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,15 @@ export interface FormTokenFieldProps
7676
* - otherwise entities like `&` in tag names are double-encoded like `&amp;`,
7777
* once by the REST API and once by React).
7878
*/
79-
displayTransform?: ( suggestion: string ) => string;
79+
displayTransform?: ( token: string ) => string;
8080
/**
8181
* Function to call to transform tokens for saving. The default is to trim the token value.
8282
* This function is also applied when matching suggestions against the current value
8383
* so that matching works correctly with leading or trailing spaces. (In the editor,
8484
* this is needed to remove leading and trailing spaces from tag names, like wp-admin does.
8585
* Otherwise the REST API won't save them.)
8686
*
87+
* @default ( token: string ) => token.trim()
8788
*/
8889
saveTransform?: ( token: string ) => string;
8990
/**
@@ -136,6 +137,8 @@ export interface FormTokenFieldProps
136137
__experimentalExpandOnFocus?: boolean;
137138
/**
138139
* If passed, all introduced values will be validated before being added as tokens.
140+
*
141+
* @default () => true
139142
*/
140143
__experimentalValidateInput?: ( token: string ) => boolean;
141144
/**

0 commit comments

Comments
 (0)