@trackunit/custom-field-components 0.0.110 → 0.0.112
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/DropdownCustomField.d.ts +0 -4
- package/index.js +11 -11
- package/package.json +2 -2
package/DropdownCustomField.d.ts
CHANGED
|
@@ -90,9 +90,5 @@ export interface DropdownCustomFieldProps extends FormGroupExposedProps {
|
|
|
90
90
|
}
|
|
91
91
|
declare type OnChange = (event?: React.ChangeEvent<HTMLInputElement>) => void;
|
|
92
92
|
declare type OnBlur = (event: React.FocusEvent<HTMLDivElement>) => void;
|
|
93
|
-
export declare type SelectValue = {
|
|
94
|
-
label: string;
|
|
95
|
-
value: string;
|
|
96
|
-
};
|
|
97
93
|
export declare const DropdownCustomField: ({ defaultValue, dataTestId, onChange, onBlur, id, disabled, allValues, multiSelect, register, validationRules, setValue, label, tip, errorMessage, helpText, isInvalid, helpAddon, }: DropdownCustomFieldProps) => JSX.Element;
|
|
98
94
|
export {};
|
package/index.js
CHANGED
|
@@ -1890,15 +1890,16 @@ const DropdownCustomField = ({
|
|
|
1890
1890
|
}) => {
|
|
1891
1891
|
const renderAsInvalid = isInvalid || Boolean(errorMessage);
|
|
1892
1892
|
const [selectedValue, setSelectedValue] = React.useState(defaultValue ? defaultValue.map(convertToValueFormat) : []);
|
|
1893
|
-
const onChangeHandler = React.useCallback(
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1893
|
+
const onChangeHandler = React.useCallback(selected => {
|
|
1894
|
+
if (selected) {
|
|
1895
|
+
const values = Array.isArray(selected) ? selected : [selected];
|
|
1896
|
+
setSelectedValue(values);
|
|
1897
|
+
setValue && setValue(id, values);
|
|
1898
|
+
} else {
|
|
1899
|
+
setSelectedValue([]);
|
|
1900
|
+
setValue && setValue(id, []);
|
|
1901
|
+
}
|
|
1898
1902
|
}, [onChange]);
|
|
1899
|
-
const onBlurHandler = React.useCallback(e => {
|
|
1900
|
-
onBlur && onBlur(e);
|
|
1901
|
-
}, [onBlur]);
|
|
1902
1903
|
const options = React.useMemo(() => {
|
|
1903
1904
|
return allValues ? allValues.map(convertToValueFormat) : [];
|
|
1904
1905
|
}, [allValues]);
|
|
@@ -1916,12 +1917,11 @@ const DropdownCustomField = ({
|
|
|
1916
1917
|
dataTestId: `${dataTestId}-FormGroup`
|
|
1917
1918
|
}, {
|
|
1918
1919
|
children: jsx(Select, {
|
|
1919
|
-
|
|
1920
|
+
disabled: _disabled,
|
|
1920
1921
|
dataTestId: dataTestId,
|
|
1921
1922
|
onChange: onChangeHandler,
|
|
1922
|
-
|
|
1923
|
+
hasError: renderAsInvalid,
|
|
1923
1924
|
options: options,
|
|
1924
|
-
onBlur: onBlurHandler,
|
|
1925
1925
|
value: selectedValue,
|
|
1926
1926
|
isMulti: _multiSelect,
|
|
1927
1927
|
isClearable: true
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/custom-field-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.112",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@trackunit/react-core-contexts-test": "0.0.33",
|
|
8
|
-
"@trackunit/react-components": "0.0.
|
|
8
|
+
"@trackunit/react-components": "0.0.126",
|
|
9
9
|
"react": "17.0.1",
|
|
10
10
|
"react-hook-form": "^7.29.0",
|
|
11
11
|
"@trackunit/iris-app-runtime-core": "0.0.63",
|