@dartech/arsenal-ui 1.3.84 → 1.3.85
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/index.js +15 -5
- package/package.json +1 -1
- package/src/lib/Forms/ControlAutocomplete.d.ts +2 -1
- package/src/lib/Property/UpsertProperty/PropertyValueField/BooleanValueField.d.ts +1 -0
- package/src/lib/Property/UpsertProperty/PropertyValueField/DateTimeValueField.d.ts +1 -0
- package/src/lib/Property/UpsertProperty/PropertyValueField/DateValueField.d.ts +1 -0
- package/src/lib/Property/UpsertProperty/PropertyValueField/JsonValueField.d.ts +1 -0
- package/src/lib/Property/UpsertProperty/PropertyValueField/TimeValueField.d.ts +1 -0
- package/src/lib/Property/ViewProperty/PropertyItem.d.ts +1 -0
package/index.js
CHANGED
@@ -709,9 +709,10 @@ const ControlAutocomplete = _a => {
|
|
709
709
|
options = [],
|
710
710
|
multiple,
|
711
711
|
textFieldProps = {},
|
712
|
-
disableCloseOnSelect
|
712
|
+
disableCloseOnSelect,
|
713
|
+
useStringValue
|
713
714
|
} = _a,
|
714
|
-
autocompleteProps = __rest(_a, ["control", "validate", "name", "label", "required", "defaultValue", "disabled", "hideErrorMessage", "onChange", "labelKey", "valueKey", "options", "multiple", "textFieldProps", "disableCloseOnSelect"]);
|
715
|
+
autocompleteProps = __rest(_a, ["control", "validate", "name", "label", "required", "defaultValue", "disabled", "hideErrorMessage", "onChange", "labelKey", "valueKey", "options", "multiple", "textFieldProps", "disableCloseOnSelect", "useStringValue"]);
|
715
716
|
const _b = useController({
|
716
717
|
name,
|
717
718
|
control,
|
@@ -724,14 +725,16 @@ const ControlAutocomplete = _a => {
|
|
724
725
|
_c = _b.field,
|
725
726
|
{
|
726
727
|
ref,
|
727
|
-
onChange
|
728
|
+
onChange,
|
729
|
+
value
|
728
730
|
} = _c,
|
729
|
-
fieldProps = __rest(_c, ["ref", "onChange"]),
|
731
|
+
fieldProps = __rest(_c, ["ref", "onChange", "value"]),
|
730
732
|
{
|
731
733
|
fieldState: {
|
732
734
|
error
|
733
735
|
}
|
734
736
|
} = _b;
|
737
|
+
const [localValue, setLocalValue] = useState();
|
735
738
|
const {
|
736
739
|
getOptionLabel,
|
737
740
|
isOptionEqualToValue,
|
@@ -741,9 +744,16 @@ const ControlAutocomplete = _a => {
|
|
741
744
|
labelKey
|
742
745
|
});
|
743
746
|
const handleChange = (_, value) => {
|
744
|
-
onChange(value);
|
747
|
+
onChange(useStringValue ? value[valueKey] : value);
|
748
|
+
setLocalValue(value);
|
745
749
|
};
|
750
|
+
useEffect(() => {
|
751
|
+
if (typeof value === 'string' && valueKey && useStringValue && !localValue && options.length && !!options[0] && typeof options[0] === 'object') {
|
752
|
+
setLocalValue(options.find(el => el[valueKey] === value));
|
753
|
+
}
|
754
|
+
}, [localValue, options, useStringValue, value, valueKey]);
|
746
755
|
return jsx(Autocomplete, Object.assign({}, fieldProps, {
|
756
|
+
value: useStringValue ? localValue !== null && localValue !== void 0 ? localValue : null : value,
|
747
757
|
fullWidth: true,
|
748
758
|
disablePortal: true,
|
749
759
|
size: "small",
|
package/package.json
CHANGED
@@ -60,10 +60,11 @@ export type ControlAutocompleteProps = Omit<AutocompleteProps<unknown, boolean,
|
|
60
60
|
*/
|
61
61
|
options: string[] | unknown[];
|
62
62
|
textFieldProps?: TextFieldProps;
|
63
|
+
useStringValue?: boolean;
|
63
64
|
};
|
64
65
|
/**
|
65
66
|
* Material UI `Autocomplete` controlled component. Used with react-hook-form
|
66
67
|
* @category Forms
|
67
68
|
*/
|
68
|
-
export declare const ControlAutocomplete: ({ control, validate, name, label, required, defaultValue, disabled, hideErrorMessage, onChange: customOnChange, labelKey, valueKey, options, multiple, textFieldProps, disableCloseOnSelect, ...autocompleteProps }: ControlAutocompleteProps) => JSX.Element;
|
69
|
+
export declare const ControlAutocomplete: ({ control, validate, name, label, required, defaultValue, disabled, hideErrorMessage, onChange: customOnChange, labelKey, valueKey, options, multiple, textFieldProps, disableCloseOnSelect, useStringValue, ...autocompleteProps }: ControlAutocompleteProps) => JSX.Element;
|
69
70
|
export default ControlAutocomplete;
|