@evoke-platform/ui-components 1.0.0-dev.154 → 1.0.0-dev.156
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.
@@ -1,7 +1,7 @@
|
|
1
1
|
import { RemoveCircleOutline } from '@mui/icons-material';
|
2
2
|
import { QueryBuilderMaterial } from '@react-querybuilder/material';
|
3
3
|
import React, { useEffect, useMemo, useState } from 'react';
|
4
|
-
import { QueryBuilder, formatQuery, parseMongoDB, } from 'react-querybuilder';
|
4
|
+
import { QueryBuilder, formatQuery, parseMongoDB, useRuleGroup, TestID, RuleGroupBodyComponents, RuleGroupHeaderComponents, } from 'react-querybuilder';
|
5
5
|
import 'react-querybuilder/dist/query-builder.css';
|
6
6
|
import { Autocomplete, Button, DatePicker, IconButton, LocalizationProvider, MenuItem, TextField, Typography, } from '../../core';
|
7
7
|
import { Box } from '../../layout';
|
@@ -26,6 +26,43 @@ const ALL_OPERATORS = [
|
|
26
26
|
{ name: 'between', label: 'between' },
|
27
27
|
{ name: 'notBetween', label: 'not between' },
|
28
28
|
];
|
29
|
+
const CustomRuleGroup = (props) => {
|
30
|
+
const rg = Object.assign(Object.assign({}, props), useRuleGroup(props));
|
31
|
+
const [addRule, addGroup, cloneGroup, toggleLockGroup, removeGroup] = [
|
32
|
+
rg.addRule,
|
33
|
+
rg.addGroup,
|
34
|
+
rg.cloneGroup,
|
35
|
+
rg.toggleLockGroup,
|
36
|
+
rg.removeGroup,
|
37
|
+
].map(f => (event, context) => {
|
38
|
+
event.preventDefault();
|
39
|
+
event.stopPropagation();
|
40
|
+
f(event, context);
|
41
|
+
});
|
42
|
+
const subComponentProps = Object.assign(Object.assign({}, rg), { addRule,
|
43
|
+
addGroup,
|
44
|
+
cloneGroup,
|
45
|
+
toggleLockGroup,
|
46
|
+
removeGroup });
|
47
|
+
return (React.createElement("div", { ref: rg.previewRef, className: rg.outerClassName, "data-testid": TestID.ruleGroup, "data-dragmonitorid": rg.dragMonitorId, "data-dropmonitorid": rg.dropMonitorId, "data-rule-group-id": rg.id, "data-level": rg.path.length, "data-path": JSON.stringify(rg.path) },
|
48
|
+
React.createElement("div", { className: rg.classNames.body },
|
49
|
+
React.createElement(RuleGroupBodyComponents, Object.assign({}, subComponentProps))),
|
50
|
+
React.createElement("div", { ref: rg.dropRef, className: rg.classNames.header },
|
51
|
+
React.createElement(RuleGroupHeaderComponents, Object.assign({}, subComponentProps, { schema: Object.assign(Object.assign({}, subComponentProps.schema), { controls: Object.assign({}, subComponentProps.schema.controls) }) })))));
|
52
|
+
};
|
53
|
+
const customButton = (props) => {
|
54
|
+
const { title, handleOnClick, label } = props;
|
55
|
+
let buttonLabel = label;
|
56
|
+
switch (title) {
|
57
|
+
case 'Add group':
|
58
|
+
buttonLabel = '+ Condition Group';
|
59
|
+
break;
|
60
|
+
case 'Add rule':
|
61
|
+
buttonLabel = '+ Condition';
|
62
|
+
break;
|
63
|
+
}
|
64
|
+
return (React.createElement(Button, { variant: "contained", onClick: handleOnClick, size: "small", sx: { backgroundColor: '#ebf4f8', color: '#0678a9', boxShadow: 'none' } }, buttonLabel));
|
65
|
+
};
|
29
66
|
const customSelector = (props) => {
|
30
67
|
var _a, _b;
|
31
68
|
const { options, value, handleOnChange, title } = props;
|
@@ -75,19 +112,6 @@ const customCombinator = (props) => {
|
|
75
112
|
},
|
76
113
|
}, disableClearable: true }));
|
77
114
|
};
|
78
|
-
const customButton = (props) => {
|
79
|
-
const { title, handleOnClick, label } = props;
|
80
|
-
let buttonLabel = label;
|
81
|
-
switch (title) {
|
82
|
-
case 'Add group':
|
83
|
-
buttonLabel = '+ Condition Group';
|
84
|
-
break;
|
85
|
-
case 'Add rule':
|
86
|
-
buttonLabel = '+ Condition';
|
87
|
-
break;
|
88
|
-
}
|
89
|
-
return (React.createElement(Button, { variant: "contained", onClick: handleOnClick, size: "small", sx: { backgroundColor: '#ebf4f8', color: '#0678a9', boxShadow: 'none' } }, buttonLabel));
|
90
|
-
};
|
91
115
|
const customDelete = (props) => {
|
92
116
|
const { handleOnClick } = props;
|
93
117
|
return (React.createElement(IconButton, { onClick: handleOnClick, size: "small" },
|
@@ -103,23 +127,23 @@ export const customValueEditorWithPresets = (props) => {
|
|
103
127
|
}, options: presetValues !== null && presetValues !== void 0 ? presetValues : [
|
104
128
|
{
|
105
129
|
label: 'User ID',
|
106
|
-
value: { name: '{{user.id}}', label: 'UserId', sublabel: 'Currently logged in user' },
|
130
|
+
value: { name: '{{{user.id}}}', label: 'UserId', sublabel: 'Currently logged in user' },
|
107
131
|
},
|
108
132
|
], isOptionEqualToValue: (option, value) => {
|
109
133
|
return option === value;
|
110
134
|
}, getOptionLabel: (option) => {
|
111
135
|
var _a;
|
112
|
-
if (option === '{{user.id}}')
|
136
|
+
if (option === '{{{user.id}}}')
|
113
137
|
return 'User ID';
|
114
138
|
return (_a = option.label) !== null && _a !== void 0 ? _a : option;
|
115
|
-
}, disabled: ['null', 'notNull'].includes(props.operator), renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { size: "small", placeholder: 'Value', readOnly: value.
|
139
|
+
}, 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) => {
|
116
140
|
handleOnChange(event.target.value);
|
117
141
|
} }))), renderOption: (props, option) => {
|
118
142
|
return (React.createElement(MenuItem, Object.assign({}, props, { sx: { padding: '0px 8px' } }),
|
119
143
|
React.createElement(Box, { padding: 0, margin: 0 },
|
120
144
|
React.createElement(Typography, { fontSize: '14px', fontWeight: 500 }, option.label),
|
121
145
|
option.value.sublabel && React.createElement(Typography, { fontSize: '14px', fontWeight: 500, color: 'rgba(145, 158, 171, 1)' }, option.value.sublabel))));
|
122
|
-
}, componentsProps: { popper: { style: { width: 'fit-content' } } }, sx: { width: '33%' } }));
|
146
|
+
}, componentsProps: { popper: { style: { minWidth: '200px', width: 'fit-content' } } }, sx: { width: '33%' } }));
|
123
147
|
return determineValueEditor(valueEditor, props);
|
124
148
|
};
|
125
149
|
export const customValueEditor = (props) => {
|
@@ -320,6 +344,7 @@ const CriteriaBuilder = (props) => {
|
|
320
344
|
operatorSelector: customSelector,
|
321
345
|
addGroupAction: customButton,
|
322
346
|
addRuleAction: customButton,
|
347
|
+
ruleGroup: CustomRuleGroup,
|
323
348
|
removeGroupAction: customDelete,
|
324
349
|
removeRuleAction: customDelete,
|
325
350
|
valueEditor: enablePresetValues
|
package/package.json
CHANGED
File without changes
|
File without changes
|