@sonardigital/carbon-ui 1.2.28 → 1.2.30
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sonardigital/carbon-ui",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.30",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"files": [
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"@mui/material": "^7.3.2",
|
|
60
60
|
"@mui/x-date-pickers": "^8.12.0",
|
|
61
61
|
"@sonardigital/cli": "^1.6.4",
|
|
62
|
+
"@sonardigital/hooks": "^1.1.6",
|
|
62
63
|
"dayjs": "^1.11.18",
|
|
63
64
|
"eslint-plugin-react": "^7.34.3",
|
|
64
65
|
"eslint-plugin-storybook": "^0.8.0",
|
|
@@ -3,6 +3,8 @@ import { Controller } from 'react-hook-form';
|
|
|
3
3
|
import { FormLabel } from '../layout';
|
|
4
4
|
import { FormError } from '../layout/FormError';
|
|
5
5
|
import { SelectAutocomplete } from '../../inputs';
|
|
6
|
+
import { useDebounce } from '@sonardigital/hooks';
|
|
7
|
+
import { useState } from 'react';
|
|
6
8
|
|
|
7
9
|
// eslint-disable-next-line
|
|
8
10
|
interface SelectAutocompleteProps extends Omit<
|
|
@@ -16,6 +18,7 @@ interface SelectAutocompleteProps extends Omit<
|
|
|
16
18
|
> {
|
|
17
19
|
name: string;
|
|
18
20
|
label: string;
|
|
21
|
+
onDebounce?: (value: string) => void;
|
|
19
22
|
placeholder?: string;
|
|
20
23
|
options?: { label: string; value: string | number }[];
|
|
21
24
|
helperText?: string;
|
|
@@ -27,8 +30,16 @@ export function FormSelect({
|
|
|
27
30
|
label,
|
|
28
31
|
options,
|
|
29
32
|
helperText,
|
|
33
|
+
onDebounce,
|
|
30
34
|
...rest
|
|
31
35
|
}: SelectAutocompleteProps): React.ReactElement {
|
|
36
|
+
const [search, setSearch] = useState('');
|
|
37
|
+
|
|
38
|
+
useDebounce(search, 500, debounced => {
|
|
39
|
+
setSearch('');
|
|
40
|
+
onDebounce?.(debounced);
|
|
41
|
+
});
|
|
42
|
+
|
|
32
43
|
return (
|
|
33
44
|
<Controller
|
|
34
45
|
name={name}
|
|
@@ -42,6 +53,12 @@ export function FormSelect({
|
|
|
42
53
|
{...rest}
|
|
43
54
|
options={options}
|
|
44
55
|
value={value}
|
|
56
|
+
loading={search !== '' || rest.loading}
|
|
57
|
+
onInputChange={value =>
|
|
58
|
+
setSearch(
|
|
59
|
+
(value?.target as HTMLInputElement)?.value ?? '',
|
|
60
|
+
)
|
|
61
|
+
}
|
|
45
62
|
onChange={onChange}
|
|
46
63
|
/>
|
|
47
64
|
{fieldState.error && (
|