@trackunit/custom-field-components 0.0.109 → 0.0.111
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 +21 -13
- package/package.json +5 -5
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
|
|
@@ -2447,7 +2447,7 @@ const getPhoneNumberValidationRules = definition => {
|
|
|
2447
2447
|
};
|
|
2448
2448
|
|
|
2449
2449
|
const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldId) => {
|
|
2450
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1
|
|
2450
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
|
|
2451
2451
|
|
|
2452
2452
|
if ((field === null || field === void 0 ? void 0 : field.definition) === undefined || ((_a = field === null || field === void 0 ? void 0 : field.definition) === null || _a === void 0 ? void 0 : _a.type) === undefined) {
|
|
2453
2453
|
return null;
|
|
@@ -2600,10 +2600,18 @@ const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldI
|
|
|
2600
2600
|
const typedDefinition = field.definition;
|
|
2601
2601
|
const typedValue = field.value;
|
|
2602
2602
|
const rules = getDateValidationRules();
|
|
2603
|
+
let defaultValue;
|
|
2604
|
+
|
|
2605
|
+
if (typedValue.dateValue !== undefined && typedValue.dateValue !== null && typedValue.dateValue !== "") {
|
|
2606
|
+
defaultValue = new Date(typedValue.dateValue);
|
|
2607
|
+
} else if (typedDefinition.defaultDateValue !== undefined && typedDefinition.defaultDateValue !== null && typedDefinition.defaultDateValue !== "") {
|
|
2608
|
+
defaultValue = new Date(typedDefinition.defaultDateValue);
|
|
2609
|
+
}
|
|
2610
|
+
|
|
2603
2611
|
return jsx(DateCustomField, {
|
|
2604
2612
|
dataTestId: "dateField",
|
|
2605
2613
|
id: key || "date-field",
|
|
2606
|
-
defaultValue:
|
|
2614
|
+
defaultValue: defaultValue,
|
|
2607
2615
|
readOnly: !typedDefinition.uiEditable,
|
|
2608
2616
|
register: validation.register,
|
|
2609
2617
|
label: typedDefinition.title || "",
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/custom-field-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.111",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@trackunit/react-core-contexts-test": "0.0.
|
|
8
|
-
"@trackunit/react-components": "0.0.
|
|
7
|
+
"@trackunit/react-core-contexts-test": "0.0.33",
|
|
8
|
+
"@trackunit/react-components": "0.0.125",
|
|
9
9
|
"react": "17.0.1",
|
|
10
10
|
"react-hook-form": "^7.29.0",
|
|
11
|
-
"@trackunit/iris-app-runtime-core": "0.0.
|
|
12
|
-
"@trackunit/iris-app-runtime-core-api": "0.0.
|
|
11
|
+
"@trackunit/iris-app-runtime-core": "0.0.63",
|
|
12
|
+
"@trackunit/iris-app-runtime-core-api": "0.0.61",
|
|
13
13
|
"react-select": "^5.4.0",
|
|
14
14
|
"libphonenumber-js": "^1.10.7"
|
|
15
15
|
},
|