@evoke-platform/ui-components 1.0.0-dev.100 → 1.0.0-dev.102
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 +5 -1
- package/dist/published/components/custom/CriteriaBuilder/CriteriaBuilder.js +15 -5
- package/dist/published/components/custom/FormField/InputFieldComponent/InputFieldComponent.js +2 -2
- package/dist/published/stories/CriteriaBuilder.stories.d.ts +13 -1
- package/package.json +1 -1
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
import React from 'react';
|
2
2
|
import { ValueEditorProps } from 'react-querybuilder';
|
3
3
|
import 'react-querybuilder/dist/query-builder.css';
|
4
4
|
import { AutocompleteOption } from '../../core';
|
@@ -21,6 +21,10 @@ declare type CriteriaInputProps = {
|
|
21
21
|
setCriteria: Function;
|
22
22
|
criteria?: Record<string, any>;
|
23
23
|
enablePresetValues?: boolean;
|
24
|
+
dynamicContentInput?: {
|
25
|
+
component: React.ElementType;
|
26
|
+
previousSteps: unknown[];
|
27
|
+
};
|
24
28
|
operators?: Operator[];
|
25
29
|
};
|
26
30
|
export declare const customValueEditorWithPresets: (props: CustomValueEditorProps) => JSX.Element;
|
@@ -126,6 +126,16 @@ export const customValueEditor = (props) => {
|
|
126
126
|
}, placeholder: "Value", size: "small", sx: { width: '33%' } }));
|
127
127
|
return determineValueEditor(valueEditor, props);
|
128
128
|
};
|
129
|
+
const dynamicContentInputEditor = (props) => {
|
130
|
+
var _a, _b, _c;
|
131
|
+
const { operator, value, handleOnChange } = props;
|
132
|
+
const DynamicContentInput = (_a = props.context) === null || _a === void 0 ? void 0 : _a.dynamicContentInput.component;
|
133
|
+
let valueEditor;
|
134
|
+
if (DynamicContentInput) {
|
135
|
+
valueEditor = (React.createElement(DynamicContentInput, { values: ['null', 'notNull'].includes(operator) ? '' : value, setValues: handleOnChange, disabled: ['null', 'notNull'].includes(operator), isSingleValue: true, size: 'small', previousSteps: (_c = (_b = props.context) === null || _b === void 0 ? void 0 : _b.previousSteps) !== null && _c !== void 0 ? _c : [] }));
|
136
|
+
}
|
137
|
+
return determineValueEditor(valueEditor, props);
|
138
|
+
};
|
129
139
|
const determineValueEditor = (baseValueEditor, props) => {
|
130
140
|
const { handleOnChange, value, values, type, operator, inputType } = props;
|
131
141
|
const disabled = ['null', 'notNull'].includes(operator);
|
@@ -170,7 +180,7 @@ const determineValueEditor = (baseValueEditor, props) => {
|
|
170
180
|
return valueEditor;
|
171
181
|
};
|
172
182
|
const CriteriaBuilder = (props) => {
|
173
|
-
const { properties, criteria, setCriteria, enablePresetValues, operators } = props;
|
183
|
+
const { properties, criteria, setCriteria, enablePresetValues, operators, dynamicContentInput } = props;
|
174
184
|
const [query, setQuery] = useState(undefined);
|
175
185
|
useEffect(() => {
|
176
186
|
if (criteria) {
|
@@ -208,7 +218,7 @@ const CriteriaBuilder = (props) => {
|
|
208
218
|
};
|
209
219
|
const fields = useMemo(() => {
|
210
220
|
return properties.map((property) => {
|
211
|
-
return Object.assign({ name: property.id, label: property.name, inputType: property.type }, (property.enum && {
|
221
|
+
return Object.assign({ name: property.type === 'object' ? `${property.id}.id` : property.id, label: property.name, inputType: property.type }, (property.enum && {
|
212
222
|
valueEditorType: property.type === 'array' ? 'multiselect' : 'select',
|
213
223
|
values: property.enum.map((item) => ({ name: item, label: item })),
|
214
224
|
}));
|
@@ -231,7 +241,7 @@ const CriteriaBuilder = (props) => {
|
|
231
241
|
},
|
232
242
|
} },
|
233
243
|
React.createElement(QueryBuilderMaterial, null,
|
234
|
-
React.createElement(QueryBuilder, { query: query, fields: fields, onQueryChange: (q) => {
|
244
|
+
React.createElement(QueryBuilder, { query: !criteria ? { combinator: 'and', rules: [] } : query, fields: fields, onQueryChange: (q) => {
|
235
245
|
handleQueryChange(q);
|
236
246
|
}, showCombinatorsBetweenRules: true, listsAsArrays: true, controlElements: {
|
237
247
|
combinatorSelector: customCombinator,
|
@@ -241,8 +251,8 @@ const CriteriaBuilder = (props) => {
|
|
241
251
|
addRuleAction: customButton,
|
242
252
|
removeGroupAction: customDelete,
|
243
253
|
removeRuleAction: customDelete,
|
244
|
-
valueEditor: enablePresetValues ? customValueEditorWithPresets : customValueEditor,
|
245
|
-
}, controlClassnames: {
|
254
|
+
valueEditor: enablePresetValues ? customValueEditorWithPresets : dynamicContentInput ? dynamicContentInputEditor : customValueEditor,
|
255
|
+
}, context: { dynamicContentInput: dynamicContentInput }, controlClassnames: {
|
246
256
|
queryBuilder: 'queryBuilder-branches',
|
247
257
|
ruleGroup: 'container',
|
248
258
|
}, operators: operators ? ALL_OPERATORS.filter((o) => operators.includes(o.name)) : ALL_OPERATORS }))));
|
package/dist/published/components/custom/FormField/InputFieldComponent/InputFieldComponent.js
CHANGED
@@ -70,7 +70,7 @@ const InputFieldComponent = (props) => {
|
|
70
70
|
backgroundColor: '#f4f6f8',
|
71
71
|
},
|
72
72
|
}
|
73
|
-
: undefined, error: error, errorMessage: errorMessage, value: value, onChange: !readOnly ? handleChange : undefined, InputProps: Object.assign(Object.assign({}, InputProps), { readOnly: readOnly }), required: required, fullWidth: true, onBlur: onBlur, placeholder: placeholder, style: { background: 'white', borderRadius: '8px' }, size: size !== null && size !== void 0 ? size : 'medium', type: property.type === 'integer' ? 'number' : 'text', multiline: property.type === 'string' && !!readOnly })) : (React.createElement(InputMask, { mask: mask, value: value, onChange: !readOnly ? handleChange : undefined, alwaysShowMask: true },
|
73
|
+
: undefined, error: error, errorMessage: errorMessage, value: value, onChange: !readOnly ? handleChange : undefined, InputProps: Object.assign(Object.assign({}, InputProps), { readOnly: readOnly }), required: required, fullWidth: true, onBlur: onBlur, placeholder: placeholder, style: { background: 'white', borderRadius: '8px' }, size: size !== null && size !== void 0 ? size : 'medium', type: property.type === 'integer' ? 'number' : 'text', multiline: property.type === 'string' && !!readOnly })) : (React.createElement(InputMask, { mask: mask, value: value, onChange: !readOnly ? handleChange : undefined, onBlur: onBlur, alwaysShowMask: true },
|
74
74
|
React.createElement(TextField, { id: id, sx: readOnly
|
75
75
|
? {
|
76
76
|
'& .MuiOutlinedInput-notchedOutline': {
|
@@ -81,6 +81,6 @@ const InputFieldComponent = (props) => {
|
|
81
81
|
backgroundColor: '#f4f6f8',
|
82
82
|
},
|
83
83
|
}
|
84
|
-
: undefined, error: error, errorMessage: errorMessage,
|
84
|
+
: undefined, error: error, errorMessage: errorMessage, InputProps: Object.assign(Object.assign({}, InputProps), { readOnly: readOnly }), fullWidth: true, type: property.type === 'integer' ? 'number' : 'text' })));
|
85
85
|
};
|
86
86
|
export default InputFieldComponent;
|
@@ -1,10 +1,14 @@
|
|
1
|
-
/// <reference types="react" />
|
2
1
|
import { ComponentMeta, ComponentStory } from '@storybook/react';
|
2
|
+
import React from 'react';
|
3
3
|
declare const _default: ComponentMeta<(props: {
|
4
4
|
properties: import("../components/custom/CriteriaBuilder/CriteriaBuilder").ObjectProperty[];
|
5
5
|
setCriteria: Function;
|
6
6
|
criteria?: Record<string, any> | undefined;
|
7
7
|
enablePresetValues?: boolean | undefined;
|
8
|
+
dynamicContentInput?: {
|
9
|
+
component: React.ElementType<any>;
|
10
|
+
previousSteps: unknown[];
|
11
|
+
} | undefined;
|
8
12
|
operators?: ("endsWith" | "in" | "=" | "=!" | "<" | ">" | "<=" | ">=" | "contains" | "beginsWith" | "doesNotContain" | "doesNotBeginWith" | "doesNotEndWith" | "null" | "notNull" | "notIn" | "between" | "notBetween")[] | undefined;
|
9
13
|
}) => JSX.Element>;
|
10
14
|
export default _default;
|
@@ -13,6 +17,10 @@ export declare const CriteriaBuilder: ComponentStory<(props: {
|
|
13
17
|
setCriteria: Function;
|
14
18
|
criteria?: Record<string, any> | undefined;
|
15
19
|
enablePresetValues?: boolean | undefined;
|
20
|
+
dynamicContentInput?: {
|
21
|
+
component: React.ElementType<any>;
|
22
|
+
previousSteps: unknown[];
|
23
|
+
} | undefined;
|
16
24
|
operators?: ("endsWith" | "in" | "=" | "=!" | "<" | ">" | "<=" | ">=" | "contains" | "beginsWith" | "doesNotContain" | "doesNotBeginWith" | "doesNotEndWith" | "null" | "notNull" | "notIn" | "between" | "notBetween")[] | undefined;
|
17
25
|
}) => JSX.Element>;
|
18
26
|
export declare const CriteriaBuilderPresetValues: ComponentStory<(props: {
|
@@ -20,5 +28,9 @@ export declare const CriteriaBuilderPresetValues: ComponentStory<(props: {
|
|
20
28
|
setCriteria: Function;
|
21
29
|
criteria?: Record<string, any> | undefined;
|
22
30
|
enablePresetValues?: boolean | undefined;
|
31
|
+
dynamicContentInput?: {
|
32
|
+
component: React.ElementType<any>;
|
33
|
+
previousSteps: unknown[];
|
34
|
+
} | undefined;
|
23
35
|
operators?: ("endsWith" | "in" | "=" | "=!" | "<" | ">" | "<=" | ">=" | "contains" | "beginsWith" | "doesNotContain" | "doesNotBeginWith" | "doesNotEndWith" | "null" | "notNull" | "notIn" | "between" | "notBetween")[] | undefined;
|
24
36
|
}) => JSX.Element>;
|