@evoke-platform/ui-components 1.0.0-dev.167 → 1.0.0-dev.169
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/dist/published/components/custom/CriteriaBuilder/CriteriaBuilder.d.ts +1 -0
- package/dist/published/components/custom/CriteriaBuilder/CriteriaBuilder.js +5 -4
- package/dist/published/components/custom/CriteriaBuilder/ValueEditor.js +13 -3
- package/dist/published/components/custom/MultiSelect/MultiSelect.js +23 -6
- package/dist/published/stories/CriteriaBuilder.stories.d.ts +2 -1
- package/dist/published/stories/CriteriaBuilder.stories.js +77 -2
- package/package.json +1 -1
@@ -16,6 +16,7 @@ export declare type CriteriaInputProps = {
|
|
16
16
|
operators?: Operator[];
|
17
17
|
disabled?: boolean;
|
18
18
|
hideBorder?: boolean;
|
19
|
+
presetGroupLabel?: string;
|
19
20
|
};
|
20
21
|
export declare const valueEditor: (props: ValueEditorProps) => JSX.Element;
|
21
22
|
declare const CriteriaBuilder: (props: CriteriaInputProps) => JSX.Element;
|
@@ -103,7 +103,7 @@ const customSelector = (props) => {
|
|
103
103
|
return option === value;
|
104
104
|
}, onChange: (event, newValue) => {
|
105
105
|
handleOnChange(newValue === null || newValue === void 0 ? void 0 : newValue.value.name);
|
106
|
-
}, renderInput: (params) => React.createElement(TextField, Object.assign({}, params, { size: "small" })), sx: { width: width }, disableClearable: true }));
|
106
|
+
}, renderInput: (params) => React.createElement(TextField, Object.assign({}, params, { size: "small" })), sx: { width: width, maxWidth: title === 'Operators' ? '200px' : 'none' }, disableClearable: true }));
|
107
107
|
};
|
108
108
|
const customCombinator = (props) => {
|
109
109
|
const { options, value, handleOnChange } = props;
|
@@ -136,7 +136,7 @@ export const valueEditor = (props) => {
|
|
136
136
|
return ValueEditor(props);
|
137
137
|
};
|
138
138
|
const CriteriaBuilder = (props) => {
|
139
|
-
const { properties, criteria, setCriteria, enablePresetValues, presetValues, operators, dynamicContentInput, disabled, hideBorder, } = props;
|
139
|
+
const { properties, criteria, setCriteria, enablePresetValues, presetValues, operators, dynamicContentInput, disabled, hideBorder, presetGroupLabel, } = props;
|
140
140
|
const [query, setQuery] = useState(undefined);
|
141
141
|
useEffect(() => {
|
142
142
|
if (criteria) {
|
@@ -165,7 +165,8 @@ const CriteriaBuilder = (props) => {
|
|
165
165
|
}, []);
|
166
166
|
const handleQueryChange = (q) => {
|
167
167
|
const updatedQuery = Object.assign(Object.assign({}, q), { rules: q.rules.map((rule) => {
|
168
|
-
|
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)
|
169
170
|
? rule.value.map((item) => item.label)
|
170
171
|
: rule.value });
|
171
172
|
}) });
|
@@ -227,7 +228,7 @@ const CriteriaBuilder = (props) => {
|
|
227
228
|
removeGroupAction: customDelete,
|
228
229
|
removeRuleAction: customDelete,
|
229
230
|
valueEditor: valueEditor
|
230
|
-
}, context: { dynamicContentInput, presetValues, enablePresetValues }, controlClassnames: {
|
231
|
+
}, context: { dynamicContentInput, presetValues, enablePresetValues, presetGroupLabel }, controlClassnames: {
|
231
232
|
queryBuilder: 'queryBuilder-branches',
|
232
233
|
ruleGroup: 'container',
|
233
234
|
}, operators: operators
|
@@ -68,7 +68,7 @@ const ValueEditor = (props) => {
|
|
68
68
|
return (React.createElement(Autocomplete, { freeSolo: true, multiple: true, options: options, getOptionLabel: (option) => (option.label ? option.label : option), value: Array.isArray(value) ? (disabled ? [] : value) : [], disabled: disabled, onChange: (event, newValue) => {
|
69
69
|
const uniqueSelections = newValue.map((item) => { var _a; return (_a = item.value) !== null && _a !== void 0 ? _a : Number(item); });
|
70
70
|
handleOnChange(uniqueSelections.length ? uniqueSelections : '');
|
71
|
-
}, isOptionEqualToValue: (option, value) => option === value, renderInput: (params) => React.createElement(TextField, Object.assign({ label: params.label }, params, { size: "small" })), groupBy: (option) => { var _a; return
|
71
|
+
}, isOptionEqualToValue: (option, value) => option === value, renderInput: (params) => React.createElement(TextField, Object.assign({ label: params.label }, params, { size: "small" })), groupBy: (option) => { var _a; return isPresetValue((_a = option.value) === null || _a === void 0 ? void 0 : _a.name) ? context.presetGroupLabel || 'Preset Values' : 'Options'; }, renderGroup: groupRenderGroup, sx: { width: '33%' } }));
|
72
72
|
}
|
73
73
|
else {
|
74
74
|
return (React.createElement(TextField, Object.assign({ inputRef: inputRef, value: ['null', 'notNull'].includes(operator) ? '' : value, disabled: ['null', 'notNull'].includes(operator), onChange: (e) => {
|
@@ -90,8 +90,16 @@ const ValueEditor = (props) => {
|
|
90
90
|
...((_a = values === null || values === void 0 ? void 0 : values.sort((a, b) => a.label.localeCompare(b.name))) !== null && _a !== void 0 ? _a : []),
|
91
91
|
...((_b = presetValues === null || presetValues === void 0 ? void 0 : presetValues.sort((a, b) => a.label.localeCompare(b.label))) !== null && _b !== void 0 ? _b : [])
|
92
92
|
];
|
93
|
+
const getValue = () => {
|
94
|
+
if (isMultiple) {
|
95
|
+
return Array.isArray(value) && !disabled ? value : [];
|
96
|
+
}
|
97
|
+
else {
|
98
|
+
return disabled ? value : '';
|
99
|
+
}
|
100
|
+
};
|
93
101
|
if (isMultiple || (values === null || values === void 0 ? void 0 : values.length)) {
|
94
|
-
return (React.createElement(Autocomplete, { freeSolo: inputType !== 'array' && inputType !== 'select', multiple: isMultiple, options: options, value:
|
102
|
+
return (React.createElement(Autocomplete, { freeSolo: inputType !== 'array' && inputType !== 'select', multiple: isMultiple, options: options, value: getValue(), disabled: disabled, onChange: (event, newValue) => {
|
95
103
|
var _a, _b, _c;
|
96
104
|
let value;
|
97
105
|
if (isMultiple) {
|
@@ -101,7 +109,9 @@ const ValueEditor = (props) => {
|
|
101
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 : '';
|
102
110
|
}
|
103
111
|
handleOnChange(value);
|
104
|
-
}, renderInput: (params) => (React.createElement(TextField, Object.assign({ inputRef: inputRef, label: params
|
112
|
+
}, renderInput: (params) => (React.createElement(TextField, Object.assign({ inputRef: inputRef, label: params === null || params === void 0 ? void 0 : params.label }, params, { size: "small" }))), isOptionEqualToValue: (option, value) => {
|
113
|
+
return (option === null || option === void 0 ? void 0 : option.label) === (value === null || value === void 0 ? void 0 : value.label);
|
114
|
+
}, 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%' } }));
|
105
115
|
}
|
106
116
|
else {
|
107
117
|
return (React.createElement(TextField, { inputRef: inputRef, value: ['null', 'notNull'].includes(operator) ? '' : value, disabled: ['null', 'notNull'].includes(operator), onChange: (e) => handleOnChange(e.target.value), onClick: onClick, placeholder: "Value", size: "small", sx: { width: '33%' } }));
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
2
|
-
import { Box,
|
2
|
+
import { Box, Grid, InputAdornment, Switch, TextField, Typography, IconButton, Button } from '@mui/material';
|
3
3
|
import { Search, DragHandleOutlined } from '@mui/icons-material';
|
4
4
|
import UIThemeProvider from '../../../theme';
|
5
5
|
import { sortBy } from 'lodash';
|
@@ -7,6 +7,7 @@ import { DndContext, closestCenter, KeyboardSensor, PointerSensor, useSensor, us
|
|
7
7
|
import { SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy } from '@dnd-kit/sortable';
|
8
8
|
import { restrictToVerticalAxis, restrictToWindowEdges } from '@dnd-kit/modifiers';
|
9
9
|
import { SortableItem } from './SortableItem';
|
10
|
+
import { Tooltip } from '../../core';
|
10
11
|
const styles = {
|
11
12
|
textField: {
|
12
13
|
borderRadius: '8px',
|
@@ -39,6 +40,11 @@ const styles = {
|
|
39
40
|
pointerEvents: 'auto',
|
40
41
|
},
|
41
42
|
},
|
43
|
+
button: {
|
44
|
+
fontWeight: '400',
|
45
|
+
textTransform: 'uppercase',
|
46
|
+
'&:hover': { backgroundColor: 'transparent' },
|
47
|
+
},
|
42
48
|
};
|
43
49
|
export default function MultiSelect(props) {
|
44
50
|
const { options, onChange, maxHeight, isSortable } = props;
|
@@ -72,15 +78,22 @@ export default function MultiSelect(props) {
|
|
72
78
|
onChange(allOptions);
|
73
79
|
setOptions(newOptions);
|
74
80
|
};
|
75
|
-
const
|
76
|
-
setSelectAll(event.target.checked);
|
81
|
+
const updateOptions = (value) => {
|
77
82
|
const newOptions = optionsArray.map((option) => {
|
78
|
-
option.value =
|
83
|
+
option.value = value;
|
79
84
|
return option;
|
80
85
|
});
|
81
86
|
onChange(newOptions);
|
82
87
|
setOptions(newOptions);
|
83
88
|
};
|
89
|
+
const handleSelectAllChange = (event) => {
|
90
|
+
updateOptions(true);
|
91
|
+
setSelectAll(true);
|
92
|
+
};
|
93
|
+
const handleClearAll = (event) => {
|
94
|
+
updateOptions(false);
|
95
|
+
setSelectAll(false);
|
96
|
+
};
|
84
97
|
const filterItems = (event) => {
|
85
98
|
setSearchText(event.target.value);
|
86
99
|
const keyword = event.target.value.toLowerCase();
|
@@ -122,8 +135,12 @@ export default function MultiSelect(props) {
|
|
122
135
|
startAdornment: (React.createElement(InputAdornment, { position: "start" },
|
123
136
|
React.createElement(Search, null))),
|
124
137
|
}, fullWidth: true, sx: styles.textField, value: searchText, onChange: filterItems }))),
|
125
|
-
(optionsArray === null || optionsArray === void 0 ? void 0 : optionsArray.length) > 1 && (React.createElement(Grid, {
|
126
|
-
React.createElement(
|
138
|
+
(optionsArray === null || optionsArray === void 0 ? void 0 : optionsArray.length) > 1 && (React.createElement(Grid, { container: true },
|
139
|
+
React.createElement(Grid, null,
|
140
|
+
React.createElement(Button, { sx: styles.button, variant: "text", onClick: (e) => handleSelectAllChange(e), disabled: optionsArray.every((option) => option.disabled === true || selectAll) }, "Select All")),
|
141
|
+
React.createElement(Grid, { item: true, xs: 6 },
|
142
|
+
React.createElement(Button, { sx: Object.assign({}, styles.button), variant: "text", onClick: (e) => handleClearAll(e), disabled: optionsArray.every((option) => option.disabled === true) ||
|
143
|
+
optionsArray.every((option) => option.value === false) }, "Clear All")))),
|
127
144
|
React.createElement(Box, { sx: Object.assign(Object.assign({}, styles.list), { maxHeight: maxHeight !== null && maxHeight !== void 0 ? maxHeight : 'auto' }) }, !!isSortable ? (React.createElement(DndContext, { sensors: sensors, collisionDetection: closestCenter, onDragEnd: handleDragEnd, modifiers: [restrictToVerticalAxis, restrictToWindowEdges] },
|
128
145
|
React.createElement(SortableContext, { items: optionsArray, strategy: verticalListSortingStrategy }, optionsArray.map((option) => {
|
129
146
|
var _a, _b;
|
@@ -3,4 +3,5 @@ import { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
3
3
|
declare const _default: ComponentMeta<(props: import("../components/custom/CriteriaBuilder/CriteriaBuilder").CriteriaInputProps) => JSX.Element>;
|
4
4
|
export default _default;
|
5
5
|
export declare const CriteriaBuilder: ComponentStory<(props: import("../components/custom/CriteriaBuilder/CriteriaBuilder").CriteriaInputProps) => JSX.Element>;
|
6
|
-
export declare const
|
6
|
+
export declare const CriteriaBuilderPresetUserID: ComponentStory<(props: import("../components/custom/CriteriaBuilder/CriteriaBuilder").CriteriaInputProps) => JSX.Element>;
|
7
|
+
export declare const CriteriaBuilderGroupedPresetValues: ComponentStory<(props: import("../components/custom/CriteriaBuilder/CriteriaBuilder").CriteriaInputProps) => JSX.Element>;
|
@@ -109,8 +109,8 @@ CriteriaBuilder.args = {
|
|
109
109
|
},
|
110
110
|
enablePresetValues: false,
|
111
111
|
};
|
112
|
-
export const
|
113
|
-
|
112
|
+
export const CriteriaBuilderPresetUserID = CriteriaBuilderTemplate.bind({});
|
113
|
+
CriteriaBuilderPresetUserID.args = {
|
114
114
|
properties: [
|
115
115
|
{
|
116
116
|
id: 'name',
|
@@ -204,3 +204,78 @@ CriteriaBuilderPresetValues.args = {
|
|
204
204
|
},
|
205
205
|
enablePresetValues: true,
|
206
206
|
};
|
207
|
+
export const CriteriaBuilderGroupedPresetValues = CriteriaBuilderTemplate.bind({});
|
208
|
+
CriteriaBuilderGroupedPresetValues.args = {
|
209
|
+
properties: [
|
210
|
+
{
|
211
|
+
id: 'name',
|
212
|
+
name: 'name',
|
213
|
+
type: 'string',
|
214
|
+
required: true,
|
215
|
+
},
|
216
|
+
{
|
217
|
+
id: 'issueDate',
|
218
|
+
name: 'issue date',
|
219
|
+
type: 'date',
|
220
|
+
required: false,
|
221
|
+
objectId: '',
|
222
|
+
},
|
223
|
+
{
|
224
|
+
id: 'status',
|
225
|
+
name: 'status',
|
226
|
+
type: 'string',
|
227
|
+
enum: ['active', 'expired', 'pending approval'],
|
228
|
+
required: false,
|
229
|
+
objectId: '',
|
230
|
+
},
|
231
|
+
{
|
232
|
+
id: 'licensedFor',
|
233
|
+
name: 'licensed for',
|
234
|
+
type: 'array',
|
235
|
+
enum: [
|
236
|
+
'amusements',
|
237
|
+
'food and beverage',
|
238
|
+
'entertainment',
|
239
|
+
'transportation',
|
240
|
+
'hot dogs',
|
241
|
+
'swimming pools',
|
242
|
+
'ferris wheels',
|
243
|
+
'bungee jumping',
|
244
|
+
],
|
245
|
+
required: true,
|
246
|
+
searchable: false,
|
247
|
+
},
|
248
|
+
{
|
249
|
+
id: 'inState',
|
250
|
+
name: 'In State',
|
251
|
+
type: 'string',
|
252
|
+
enum: ['Yes', 'No'],
|
253
|
+
required: false,
|
254
|
+
searchable: false,
|
255
|
+
},
|
256
|
+
],
|
257
|
+
setCriteria: (criteria) => console.log('criteria= ', criteria),
|
258
|
+
criteria: {
|
259
|
+
$or: [
|
260
|
+
{
|
261
|
+
name: '',
|
262
|
+
},
|
263
|
+
],
|
264
|
+
},
|
265
|
+
presetValues: [
|
266
|
+
{
|
267
|
+
label: 'Preset 1',
|
268
|
+
value: { name: '{{{1}}}', label: 'thing1', sublabel: 'thing1' },
|
269
|
+
},
|
270
|
+
{
|
271
|
+
label: 'Preset 2',
|
272
|
+
value: { name: '{{{2}}}', label: 'thing2', sublabel: 'thing2' },
|
273
|
+
},
|
274
|
+
{
|
275
|
+
label: 'Preset 3',
|
276
|
+
value: { name: '{{{3}}}', label: 'thing3', sublabel: 'thing3' },
|
277
|
+
},
|
278
|
+
],
|
279
|
+
presetGroupLabel: 'Parameter Values',
|
280
|
+
enablePresetValues: true,
|
281
|
+
};
|