@evoke-platform/ui-components 1.0.0-dev.153 → 1.0.0-dev.155
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.
@@ -21,6 +21,14 @@ declare type CriteriaInputProps = {
|
|
21
21
|
setCriteria: Function;
|
22
22
|
criteria?: Record<string, any>;
|
23
23
|
enablePresetValues?: boolean;
|
24
|
+
presetValues?: {
|
25
|
+
label: string;
|
26
|
+
value: {
|
27
|
+
name: string;
|
28
|
+
label: string;
|
29
|
+
sublabel?: string;
|
30
|
+
};
|
31
|
+
}[];
|
24
32
|
dynamicContentInput?: {
|
25
33
|
component: React.ElementType;
|
26
34
|
previousSteps: unknown[];
|
@@ -94,30 +94,32 @@ const customDelete = (props) => {
|
|
94
94
|
React.createElement(RemoveCircleOutline, null)));
|
95
95
|
};
|
96
96
|
export const customValueEditorWithPresets = (props) => {
|
97
|
+
var _a;
|
97
98
|
const { handleOnChange, value } = props;
|
99
|
+
const presetValues = (_a = props.context) === null || _a === void 0 ? void 0 : _a.presetValues;
|
98
100
|
const valueEditor = (React.createElement(Autocomplete, { freeSolo: true, value: ['null', 'notNull'].includes(props.operator) ? '' : value, onChange: (event, newValue) => {
|
99
101
|
var _a;
|
100
102
|
handleOnChange((_a = newValue === null || newValue === void 0 ? void 0 : newValue.value.name) !== null && _a !== void 0 ? _a : '');
|
101
|
-
}, options: [
|
103
|
+
}, options: presetValues !== null && presetValues !== void 0 ? presetValues : [
|
102
104
|
{
|
103
105
|
label: 'User ID',
|
104
|
-
value: { name: '{{user.id}}', label: 'UserId', sublabel: 'Currently logged in user' },
|
106
|
+
value: { name: '{{{user.id}}}', label: 'UserId', sublabel: 'Currently logged in user' },
|
105
107
|
},
|
106
108
|
], isOptionEqualToValue: (option, value) => {
|
107
109
|
return option === value;
|
108
110
|
}, getOptionLabel: (option) => {
|
109
111
|
var _a;
|
110
|
-
if (option === '{{user.id}}')
|
112
|
+
if (option === '{{{user.id}}}')
|
111
113
|
return 'User ID';
|
112
114
|
return (_a = option.label) !== null && _a !== void 0 ? _a : option;
|
113
|
-
}, disabled: ['null', 'notNull'].includes(props.operator), renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { size: "small", placeholder: 'Value', readOnly: value
|
115
|
+
}, disabled: ['null', 'notNull'].includes(props.operator), renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { size: "small", placeholder: 'Value', readOnly: value.includes('{{{') && value.includes('}}}'), onChange: (event) => {
|
114
116
|
handleOnChange(event.target.value);
|
115
117
|
} }))), renderOption: (props, option) => {
|
116
118
|
return (React.createElement(MenuItem, Object.assign({}, props, { sx: { padding: '0px 8px' } }),
|
117
119
|
React.createElement(Box, { padding: 0, margin: 0 },
|
118
120
|
React.createElement(Typography, { fontSize: '14px', fontWeight: 500 }, option.label),
|
119
|
-
React.createElement(Typography, { fontSize: '14px', fontWeight: 500, color: 'rgba(145, 158, 171, 1)' }, option.value.sublabel))));
|
120
|
-
}, componentsProps: { popper: { style: { width: 'fit-content' } } }, sx: { width: '33%' } }));
|
121
|
+
option.value.sublabel && React.createElement(Typography, { fontSize: '14px', fontWeight: 500, color: 'rgba(145, 158, 171, 1)' }, option.value.sublabel))));
|
122
|
+
}, componentsProps: { popper: { style: { minWidth: '200px', width: 'fit-content' } } }, sx: { width: '33%' } }));
|
121
123
|
return determineValueEditor(valueEditor, props);
|
122
124
|
};
|
123
125
|
export const customValueEditor = (props) => {
|
@@ -249,7 +251,7 @@ const determineValueEditor = (baseValueEditor, props) => {
|
|
249
251
|
return valueEditor;
|
250
252
|
};
|
251
253
|
const CriteriaBuilder = (props) => {
|
252
|
-
const { properties, criteria, setCriteria, enablePresetValues, operators, dynamicContentInput, disabled } = props;
|
254
|
+
const { properties, criteria, setCriteria, enablePresetValues, presetValues, operators, dynamicContentInput, disabled } = props;
|
253
255
|
const [query, setQuery] = useState(undefined);
|
254
256
|
useEffect(() => {
|
255
257
|
if (criteria) {
|
@@ -325,7 +327,7 @@ const CriteriaBuilder = (props) => {
|
|
325
327
|
: dynamicContentInput
|
326
328
|
? dynamicContentInputEditor
|
327
329
|
: customValueEditor,
|
328
|
-
}, context: { dynamicContentInput: dynamicContentInput }, controlClassnames: {
|
330
|
+
}, context: { dynamicContentInput: dynamicContentInput, presetValues }, controlClassnames: {
|
329
331
|
queryBuilder: 'queryBuilder-branches',
|
330
332
|
ruleGroup: 'container',
|
331
333
|
}, operators: operators
|
@@ -5,6 +5,14 @@ declare const _default: ComponentMeta<(props: {
|
|
5
5
|
setCriteria: Function;
|
6
6
|
criteria?: Record<string, any> | undefined;
|
7
7
|
enablePresetValues?: boolean | undefined;
|
8
|
+
presetValues?: {
|
9
|
+
label: string;
|
10
|
+
value: {
|
11
|
+
name: string;
|
12
|
+
label: string;
|
13
|
+
sublabel?: string | undefined;
|
14
|
+
};
|
15
|
+
}[] | undefined;
|
8
16
|
dynamicContentInput?: {
|
9
17
|
component: React.ElementType<any>;
|
10
18
|
previousSteps: unknown[];
|
@@ -19,6 +27,14 @@ export declare const CriteriaBuilder: ComponentStory<(props: {
|
|
19
27
|
setCriteria: Function;
|
20
28
|
criteria?: Record<string, any> | undefined;
|
21
29
|
enablePresetValues?: boolean | undefined;
|
30
|
+
presetValues?: {
|
31
|
+
label: string;
|
32
|
+
value: {
|
33
|
+
name: string;
|
34
|
+
label: string;
|
35
|
+
sublabel?: string | undefined;
|
36
|
+
};
|
37
|
+
}[] | undefined;
|
22
38
|
dynamicContentInput?: {
|
23
39
|
component: React.ElementType<any>;
|
24
40
|
previousSteps: unknown[];
|
@@ -32,6 +48,14 @@ export declare const CriteriaBuilderPresetValues: ComponentStory<(props: {
|
|
32
48
|
setCriteria: Function;
|
33
49
|
criteria?: Record<string, any> | undefined;
|
34
50
|
enablePresetValues?: boolean | undefined;
|
51
|
+
presetValues?: {
|
52
|
+
label: string;
|
53
|
+
value: {
|
54
|
+
name: string;
|
55
|
+
label: string;
|
56
|
+
sublabel?: string | undefined;
|
57
|
+
};
|
58
|
+
}[] | undefined;
|
35
59
|
dynamicContentInput?: {
|
36
60
|
component: React.ElementType<any>;
|
37
61
|
previousSteps: unknown[];
|