@evoke-platform/ui-components 1.0.0-dev.170 → 1.0.0-dev.172
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.
@@ -147,15 +147,7 @@ const CriteriaBuilder = (props) => {
|
|
147
147
|
return Object.assign(Object.assign({}, rule), { value: propertyType === 'array' ||
|
148
148
|
(propertyType === 'string' && rule.operator === 'in') ||
|
149
149
|
rule.operator === 'notIn'
|
150
|
-
? (_b = rule.value) === null || _b === void 0 ? void 0 : _b.split(',')
|
151
|
-
return {
|
152
|
-
label: item,
|
153
|
-
value: {
|
154
|
-
name: item,
|
155
|
-
label: item,
|
156
|
-
},
|
157
|
-
};
|
158
|
-
})
|
150
|
+
? (_b = rule.value) === null || _b === void 0 ? void 0 : _b.split(',')
|
159
151
|
: rule.value });
|
160
152
|
}) }));
|
161
153
|
}
|
@@ -164,14 +156,8 @@ const CriteriaBuilder = (props) => {
|
|
164
156
|
}
|
165
157
|
}, []);
|
166
158
|
const handleQueryChange = (q) => {
|
167
|
-
const updatedQuery = Object.assign(Object.assign({}, q), { rules: q.rules.map((rule) => {
|
168
|
-
var _a;
|
169
|
-
return Object.assign(Object.assign({}, rule), { value: Array.isArray(rule.value) && !!((_a = rule.value[0]) === null || _a === void 0 ? void 0 : _a.label)
|
170
|
-
? rule.value.map((item) => item.label)
|
171
|
-
: rule.value });
|
172
|
-
}) });
|
173
159
|
setQuery(q);
|
174
|
-
const newCriteria = JSON.parse(formatQuery(
|
160
|
+
const newCriteria = JSON.parse(formatQuery(q, 'mongodb'));
|
175
161
|
if (isEmpty(difference(newCriteria, { $and: [{ $expr: true }] }))) {
|
176
162
|
setCriteria(undefined);
|
177
163
|
}
|
@@ -23,7 +23,7 @@ const ValueEditor = (props) => {
|
|
23
23
|
const [openPresetValues, setOpenPresetValues] = useState(false);
|
24
24
|
const disabled = ['null', 'notNull'].includes(operator);
|
25
25
|
const presetValues = (_a = context.presetValues) !== null && _a !== void 0 ? _a : [];
|
26
|
-
const isPresetValue = (value) => (value === null || value === void 0 ? void 0 : value.
|
26
|
+
const isPresetValue = (value) => (value === null || value === void 0 ? void 0 : value.startsWith('{{{')) && (value === null || value === void 0 ? void 0 : value.endsWith('}}}'));
|
27
27
|
const isPresetValueSelected = presetValues && typeof value === 'string' && isPresetValue(value);
|
28
28
|
const presetDisplayValue = (_c = (_b = presetValues === null || presetValues === void 0 ? void 0 : presetValues.find((option) => option.value.name === value)) === null || _b === void 0 ? void 0 : _b.label) !== null && _c !== void 0 ? _c : '';
|
29
29
|
const onClick = (e) => {
|
@@ -52,6 +52,9 @@ const ValueEditor = (props) => {
|
|
52
52
|
if (isPresetValueSelected) {
|
53
53
|
return;
|
54
54
|
}
|
55
|
+
if (disabled) {
|
56
|
+
return React.createElement(React.Fragment, null);
|
57
|
+
}
|
55
58
|
if (inputType === 'date') {
|
56
59
|
// date editor
|
57
60
|
return (React.createElement(LocalizationProvider, null,
|
@@ -90,27 +93,32 @@ const ValueEditor = (props) => {
|
|
90
93
|
...((_a = values === null || values === void 0 ? void 0 : values.sort((a, b) => a.label.localeCompare(b.name))) !== null && _a !== void 0 ? _a : []),
|
91
94
|
...((_b = presetValues === null || presetValues === void 0 ? void 0 : presetValues.sort((a, b) => a.label.localeCompare(b.label))) !== null && _b !== void 0 ? _b : [])
|
92
95
|
];
|
93
|
-
const getValue = () => {
|
94
|
-
if (isMultiple) {
|
95
|
-
return Array.isArray(value) && !disabled ? value : [];
|
96
|
-
}
|
97
|
-
else {
|
98
|
-
return disabled ? value : '';
|
99
|
-
}
|
100
|
-
};
|
101
96
|
if (isMultiple || (values === null || values === void 0 ? void 0 : values.length)) {
|
102
|
-
return (React.createElement(Autocomplete, { freeSolo: inputType !== 'array' && inputType !== 'select', multiple: isMultiple, options: options, value:
|
97
|
+
return (React.createElement(Autocomplete, { freeSolo: inputType !== 'array' && inputType !== 'select', multiple: isMultiple, options: options, value: isMultiple ? (Array.isArray(value) ? value : []) : value, onChange: (event, newValue) => {
|
103
98
|
var _a, _b, _c;
|
104
99
|
let value;
|
105
100
|
if (isMultiple) {
|
106
|
-
|
101
|
+
const values = newValue.map((item) => { var _a; return item.name || ((_a = item.value) === null || _a === void 0 ? void 0 : _a.name) || item; });
|
102
|
+
value = Array.from(new Set(values));
|
107
103
|
}
|
108
104
|
else {
|
109
|
-
value = (_c = (_b = newValue === null || newValue === void 0 ? void 0 : newValue.value) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : '';
|
105
|
+
value = (_c = (_a = newValue === null || newValue === void 0 ? void 0 : newValue.name) !== null && _a !== void 0 ? _a : (_b = newValue === null || newValue === void 0 ? void 0 : newValue.value) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : '';
|
110
106
|
}
|
111
107
|
handleOnChange(value);
|
112
|
-
}, renderInput: (params) => (React.createElement(TextField, Object.assign({ inputRef: inputRef, label: params === null || params === void 0 ? void 0 : params.label }, params, { size: "small" }))),
|
113
|
-
|
108
|
+
}, renderInput: (params) => (React.createElement(TextField, Object.assign({ inputRef: inputRef, label: params === null || params === void 0 ? void 0 : params.label }, params, { size: "small" }))), getOptionLabel: (option) => {
|
109
|
+
var _a;
|
110
|
+
if (typeof option === 'string') {
|
111
|
+
return ((_a = options.find((o) => { var _a; return option === o.name || option == ((_a = o.value) === null || _a === void 0 ? void 0 : _a.name); })) === null || _a === void 0 ? void 0 : _a.label) || '';
|
112
|
+
}
|
113
|
+
return option === null || option === void 0 ? void 0 : option.label;
|
114
|
+
}, isOptionEqualToValue: (option, value) => {
|
115
|
+
var _a;
|
116
|
+
if (typeof value === 'string') {
|
117
|
+
return (option === null || option === void 0 ? void 0 : option.name) === value || ((_a = option === null || option === void 0 ? void 0 : option.value) === null || _a === void 0 ? void 0 : _a.name) === value;
|
118
|
+
}
|
119
|
+
else {
|
120
|
+
return (option === null || option === void 0 ? void 0 : option.label) === (value === null || value === void 0 ? void 0 : value.label);
|
121
|
+
}
|
114
122
|
}, groupBy: (option) => { var _a; return isPresetValue((_a = option.value) === null || _a === void 0 ? void 0 : _a.name) ? context.presetGroupLabel || 'Preset Values' : 'Options'; }, renderGroup: groupRenderGroup, sortBy: 'NONE', sx: { width: '33%' } }));
|
115
123
|
}
|
116
124
|
else {
|