@evoke-platform/ui-components 1.0.0-dev.100 → 1.0.0-dev.101

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,4 +1,4 @@
1
- /// <reference types="react" />
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) {
@@ -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 }))));
@@ -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>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evoke-platform/ui-components",
3
- "version": "1.0.0-dev.100",
3
+ "version": "1.0.0-dev.101",
4
4
  "description": "",
5
5
  "main": "dist/published/index.js",
6
6
  "module": "dist/published/index.js",