@react-stately/searchfield 3.0.0-nightly-641446f65-240905
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/import.mjs +17 -0
- package/dist/main.js +22 -0
- package/dist/main.js.map +1 -0
- package/dist/module.js +17 -0
- package/dist/module.js.map +1 -0
- package/dist/types.d.ts +14 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/useSearchFieldState.main.js +33 -0
- package/dist/useSearchFieldState.main.js.map +1 -0
- package/dist/useSearchFieldState.mjs +28 -0
- package/dist/useSearchFieldState.module.js +28 -0
- package/dist/useSearchFieldState.module.js.map +1 -0
- package/package.json +36 -0
- package/src/index.ts +16 -0
- package/src/useSearchFieldState.ts +42 -0
package/README.md
ADDED
package/dist/import.mjs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {useSearchFieldState as $0b2218c4e3fe7d7e$export$3f8be18b0f41eaf2} from "./useSearchFieldState.mjs";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export {$0b2218c4e3fe7d7e$export$3f8be18b0f41eaf2 as useSearchFieldState};
|
|
17
|
+
//# sourceMappingURL=module.js.map
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
var $1fa0a0eef7fd0825$exports = require("./useSearchFieldState.main.js");
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
function $parcel$export(e, n, v, s) {
|
|
5
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
$parcel$export(module.exports, "useSearchFieldState", () => $1fa0a0eef7fd0825$exports.useSearchFieldState);
|
|
9
|
+
/*
|
|
10
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
11
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
13
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
16
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
17
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
18
|
+
* governing permissions and limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/searchfield/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useSearchFieldState} from './useSearchFieldState';\n\nexport type {SearchFieldProps} from '@react-types/searchfield';\nexport type {SearchFieldState} from './useSearchFieldState';\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {useSearchFieldState as $0b2218c4e3fe7d7e$export$3f8be18b0f41eaf2} from "./useSearchFieldState.module.js";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export {$0b2218c4e3fe7d7e$export$3f8be18b0f41eaf2 as useSearchFieldState};
|
|
17
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/searchfield/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useSearchFieldState} from './useSearchFieldState';\n\nexport type {SearchFieldProps} from '@react-types/searchfield';\nexport type {SearchFieldState} from './useSearchFieldState';\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SearchFieldProps } from "@react-types/searchfield";
|
|
2
|
+
export interface SearchFieldState {
|
|
3
|
+
/** The current value of the search field. */
|
|
4
|
+
readonly value: string;
|
|
5
|
+
/** Sets the value of the search field. */
|
|
6
|
+
setValue(value: string): void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Provides state management for a search field.
|
|
10
|
+
*/
|
|
11
|
+
export function useSearchFieldState(props: SearchFieldProps): SearchFieldState;
|
|
12
|
+
export type { SearchFieldProps } from '@react-types/searchfield';
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";AAeA;IACE,6CAA6C;IAC7C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,0CAA0C;IAC1C,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAC9B;AAED;;GAEG;AACH,oCAAoC,KAAK,EAAE,gBAAgB,GAAG,gBAAgB,CAO7E;ACnBD,YAAY,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC","sources":["packages/@react-stately/searchfield/src/packages/@react-stately/searchfield/src/useSearchFieldState.ts","packages/@react-stately/searchfield/src/packages/@react-stately/searchfield/src/index.ts","packages/@react-stately/searchfield/src/index.ts"],"sourcesContent":[null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useSearchFieldState} from './useSearchFieldState';\n\nexport type {SearchFieldProps} from '@react-types/searchfield';\nexport type {SearchFieldState} from './useSearchFieldState';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var $5voL7$reactstatelyutils = require("@react-stately/utils");
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
function $parcel$export(e, n, v, s) {
|
|
5
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
$parcel$export(module.exports, "useSearchFieldState", () => $1fa0a0eef7fd0825$export$3f8be18b0f41eaf2);
|
|
9
|
+
/*
|
|
10
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
11
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
13
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
16
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
17
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
18
|
+
* governing permissions and limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
function $1fa0a0eef7fd0825$export$3f8be18b0f41eaf2(props) {
|
|
21
|
+
let [value, setValue] = (0, $5voL7$reactstatelyutils.useControlledState)($1fa0a0eef7fd0825$var$toString(props.value), $1fa0a0eef7fd0825$var$toString(props.defaultValue) || '', props.onChange);
|
|
22
|
+
return {
|
|
23
|
+
value: value,
|
|
24
|
+
setValue: setValue
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function $1fa0a0eef7fd0825$var$toString(val) {
|
|
28
|
+
if (val == null) return;
|
|
29
|
+
return val.toString();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=useSearchFieldState.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAgBM,SAAS,0CAAoB,KAAuB;IACzD,IAAI,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,2CAAiB,EAAE,+BAAS,MAAM,KAAK,GAAG,+BAAS,MAAM,YAAY,KAAK,IAAI,MAAM,QAAQ;IAEpH,OAAO;eACL;kBACA;IACF;AACF;AAEA,SAAS,+BAAS,GAAG;IACnB,IAAI,OAAO,MACT;IAGF,OAAO,IAAI,QAAQ;AACrB","sources":["packages/@react-stately/searchfield/src/useSearchFieldState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {SearchFieldProps} from '@react-types/searchfield';\nimport {useControlledState} from '@react-stately/utils';\n\nexport interface SearchFieldState {\n /** The current value of the search field. */\n readonly value: string,\n\n /** Sets the value of the search field. */\n setValue(value: string): void\n}\n\n/**\n * Provides state management for a search field.\n */\nexport function useSearchFieldState(props: SearchFieldProps): SearchFieldState {\n let [value, setValue] = useControlledState(toString(props.value), toString(props.defaultValue) || '', props.onChange);\n\n return {\n value,\n setValue\n };\n}\n\nfunction toString(val) {\n if (val == null) {\n return;\n }\n\n return val.toString();\n}\n"],"names":[],"version":3,"file":"useSearchFieldState.main.js.map"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {useControlledState as $58ylH$useControlledState} from "@react-stately/utils";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
function $0b2218c4e3fe7d7e$export$3f8be18b0f41eaf2(props) {
|
|
15
|
+
let [value, setValue] = (0, $58ylH$useControlledState)($0b2218c4e3fe7d7e$var$toString(props.value), $0b2218c4e3fe7d7e$var$toString(props.defaultValue) || '', props.onChange);
|
|
16
|
+
return {
|
|
17
|
+
value: value,
|
|
18
|
+
setValue: setValue
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function $0b2218c4e3fe7d7e$var$toString(val) {
|
|
22
|
+
if (val == null) return;
|
|
23
|
+
return val.toString();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
export {$0b2218c4e3fe7d7e$export$3f8be18b0f41eaf2 as useSearchFieldState};
|
|
28
|
+
//# sourceMappingURL=useSearchFieldState.module.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {useControlledState as $58ylH$useControlledState} from "@react-stately/utils";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
function $0b2218c4e3fe7d7e$export$3f8be18b0f41eaf2(props) {
|
|
15
|
+
let [value, setValue] = (0, $58ylH$useControlledState)($0b2218c4e3fe7d7e$var$toString(props.value), $0b2218c4e3fe7d7e$var$toString(props.defaultValue) || '', props.onChange);
|
|
16
|
+
return {
|
|
17
|
+
value: value,
|
|
18
|
+
setValue: setValue
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function $0b2218c4e3fe7d7e$var$toString(val) {
|
|
22
|
+
if (val == null) return;
|
|
23
|
+
return val.toString();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
export {$0b2218c4e3fe7d7e$export$3f8be18b0f41eaf2 as useSearchFieldState};
|
|
28
|
+
//# sourceMappingURL=useSearchFieldState.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;AAAA;;;;;;;;;;CAUC;AAgBM,SAAS,0CAAoB,KAAuB;IACzD,IAAI,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,yBAAiB,EAAE,+BAAS,MAAM,KAAK,GAAG,+BAAS,MAAM,YAAY,KAAK,IAAI,MAAM,QAAQ;IAEpH,OAAO;eACL;kBACA;IACF;AACF;AAEA,SAAS,+BAAS,GAAG;IACnB,IAAI,OAAO,MACT;IAGF,OAAO,IAAI,QAAQ;AACrB","sources":["packages/@react-stately/searchfield/src/useSearchFieldState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {SearchFieldProps} from '@react-types/searchfield';\nimport {useControlledState} from '@react-stately/utils';\n\nexport interface SearchFieldState {\n /** The current value of the search field. */\n readonly value: string,\n\n /** Sets the value of the search field. */\n setValue(value: string): void\n}\n\n/**\n * Provides state management for a search field.\n */\nexport function useSearchFieldState(props: SearchFieldProps): SearchFieldState {\n let [value, setValue] = useControlledState(toString(props.value), toString(props.defaultValue) || '', props.onChange);\n\n return {\n value,\n setValue\n };\n}\n\nfunction toString(val) {\n if (val == null) {\n return;\n }\n\n return val.toString();\n}\n"],"names":[],"version":3,"file":"useSearchFieldState.module.js.map"}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-stately/searchfield",
|
|
3
|
+
"version": "3.0.0-nightly-641446f65-240905",
|
|
4
|
+
"description": "Spectrum UI components in React",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"main": "dist/main.js",
|
|
7
|
+
"module": "dist/module.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
"types": "./dist/types.d.ts",
|
|
10
|
+
"import": "./dist/import.mjs",
|
|
11
|
+
"require": "./dist/main.js"
|
|
12
|
+
},
|
|
13
|
+
"types": "dist/types.d.ts",
|
|
14
|
+
"source": "src/index.ts",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"src"
|
|
18
|
+
],
|
|
19
|
+
"sideEffects": false,
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/adobe/react-spectrum"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@react-stately/utils": "^3.0.0-nightly-641446f65-240905",
|
|
26
|
+
"@react-types/searchfield": "^3.0.0-nightly-641446f65-240905",
|
|
27
|
+
"@swc/helpers": "^0.5.0"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"stableVersion": "3.5.6"
|
|
36
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export {useSearchFieldState} from './useSearchFieldState';
|
|
14
|
+
|
|
15
|
+
export type {SearchFieldProps} from '@react-types/searchfield';
|
|
16
|
+
export type {SearchFieldState} from './useSearchFieldState';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {SearchFieldProps} from '@react-types/searchfield';
|
|
14
|
+
import {useControlledState} from '@react-stately/utils';
|
|
15
|
+
|
|
16
|
+
export interface SearchFieldState {
|
|
17
|
+
/** The current value of the search field. */
|
|
18
|
+
readonly value: string,
|
|
19
|
+
|
|
20
|
+
/** Sets the value of the search field. */
|
|
21
|
+
setValue(value: string): void
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Provides state management for a search field.
|
|
26
|
+
*/
|
|
27
|
+
export function useSearchFieldState(props: SearchFieldProps): SearchFieldState {
|
|
28
|
+
let [value, setValue] = useControlledState(toString(props.value), toString(props.defaultValue) || '', props.onChange);
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
value,
|
|
32
|
+
setValue
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function toString(val) {
|
|
37
|
+
if (val == null) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return val.toString();
|
|
42
|
+
}
|