@evoke-platform/ui-components 1.0.1-dev.4 → 1.0.1-dev.6
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.
@@ -17,7 +17,7 @@ const GroupHeader = styled('div')(({ theme }) => ({
|
|
17
17
|
}));
|
18
18
|
const GroupItems = styled('ul')({ padding: 0 });
|
19
19
|
const ValueEditor = (props) => {
|
20
|
-
const { handleOnChange, value, operator, context, level, rule } = props;
|
20
|
+
const { handleOnChange, value, operator, context, level, rule, fieldData } = props;
|
21
21
|
let inputType = props.inputType;
|
22
22
|
let values = props.values;
|
23
23
|
const property = context.propertyTreeMap[rule.field];
|
@@ -33,6 +33,8 @@ const ValueEditor = (props) => {
|
|
33
33
|
}
|
34
34
|
const inputRef = useRef(null);
|
35
35
|
const [openPresetValues, setOpenPresetValues] = useState(false);
|
36
|
+
// Manages input value for Autocomplete when using 'in/not in' operators, ensuring correct handling on blur.
|
37
|
+
const [inputValue, setInputValue] = useState('');
|
36
38
|
const disabled = ['null', 'notNull'].includes(operator);
|
37
39
|
const presetValues = context.presetValues ?? [];
|
38
40
|
const isPresetValue = (value) => value?.startsWith('{{{') && value?.endsWith('}}}');
|
@@ -108,14 +110,22 @@ const ValueEditor = (props) => {
|
|
108
110
|
}
|
109
111
|
}
|
110
112
|
else {
|
111
|
-
const [inputValue, setInputValue] = useState('');
|
112
113
|
const isMultiple = inputType === 'array' || ['in', 'notIn'].includes(operator);
|
114
|
+
const isSelectType = fieldData.valueEditorType === 'select';
|
113
115
|
const options = [
|
114
116
|
...(values?.sort((a, b) => a.label.localeCompare(b.label)) ?? []),
|
115
117
|
...(presetValues?.sort((a, b) => a.label.localeCompare(b.label)) ?? []),
|
116
118
|
];
|
117
119
|
if (isMultiple || values?.length) {
|
118
|
-
return (React.createElement(Autocomplete, { freeSolo: inputType !== 'array' &&
|
120
|
+
return (React.createElement(Autocomplete, { freeSolo: inputType !== 'array' && !isSelectType, multiple: isMultiple, options: options, value: isMultiple
|
121
|
+
? Array.isArray(value)
|
122
|
+
? value
|
123
|
+
: isSelectType && value && typeof value === 'string'
|
124
|
+
? [value]
|
125
|
+
: []
|
126
|
+
: Array.isArray(value)
|
127
|
+
? value.join(',')
|
128
|
+
: value,
|
119
129
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
120
130
|
onChange: (event, newValue) => {
|
121
131
|
let value;
|