@evoke-platform/ui-components 1.0.0-dev.1.10.9 → 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 }))));
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
2
2
  import { Autocomplete, TextField } from '../../../core';
3
3
  import InputFieldComponent from '../InputFieldComponent/InputFieldComponent';
4
4
  const BooleanSelect = (props) => {
5
- const { property, defaultValue, error, errorMessage, readOnly, size, placeholder } = props;
5
+ const { property, defaultValue, error, errorMessage, readOnly, size, placeholder, onBlur } = props;
6
6
  const [value, setValue] = useState(defaultValue);
7
7
  const id = property.id;
8
8
  useEffect(() => {
@@ -22,6 +22,6 @@ const BooleanSelect = (props) => {
22
22
  value: false,
23
23
  },
24
24
  ];
25
- return readOnly ? (React.createElement(InputFieldComponent, Object.assign({}, props))) : (React.createElement(Autocomplete, { id: id, renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { value: value, error: error, errorMessage: errorMessage, fullWidth: true, style: { background: 'white' }, size: size !== null && size !== void 0 ? size : 'medium', placeholder: placeholder }))), value: value, onChange: handleChange, inputValue: value, options: booleanOptions, disableClearable: true, style: { background: 'white', borderRadius: '8px' } }));
25
+ return readOnly ? (React.createElement(InputFieldComponent, Object.assign({}, props))) : (React.createElement(Autocomplete, { id: id, renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { value: value, error: error, errorMessage: errorMessage, onBlur: onBlur, fullWidth: true, style: { background: 'white' }, size: size !== null && size !== void 0 ? size : 'medium', placeholder: placeholder }))), value: value, onChange: handleChange, inputValue: value, options: booleanOptions, disableClearable: true, style: { background: 'white', borderRadius: '8px' } }));
26
26
  };
27
27
  export default BooleanSelect;
@@ -26,7 +26,7 @@ const asMonthDayYearFormat = (date) => {
26
26
  }
27
27
  };
28
28
  const DatePickerSelect = (props) => {
29
- const { property, defaultValue, error, errorMessage, readOnly, required, size } = props;
29
+ const { property, defaultValue, error, errorMessage, readOnly, required, size, onBlur } = props;
30
30
  const [value, setValue] = useState(asCalendarDate(defaultValue));
31
31
  const id = property.id;
32
32
  useEffect(() => {
@@ -37,6 +37,6 @@ const DatePickerSelect = (props) => {
37
37
  props.onChange(id, date, property);
38
38
  };
39
39
  return readOnly ? (React.createElement(InputFieldComponent, Object.assign({}, Object.assign(Object.assign({}, props), { defaultValue: asMonthDayYearFormat(value) })))) : (React.createElement(LocalizationProvider, null,
40
- React.createElement(DatePicker, { value: value, onChange: handleChange, inputFormat: "MM/dd/yyyy", renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { id: id, error: error, errorMessage: errorMessage, fullWidth: true, required: required, style: { background: 'white', borderRadius: '8px' }, size: size !== null && size !== void 0 ? size : 'medium' }))) })));
40
+ React.createElement(DatePicker, { value: value, onChange: handleChange, inputFormat: "MM/dd/yyyy", renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { id: id, error: error, errorMessage: errorMessage, onBlur: onBlur, fullWidth: true, required: required, style: { background: 'white', borderRadius: '8px' }, size: size !== null && size !== void 0 ? size : 'medium' }))) })));
41
41
  };
42
42
  export default DatePickerSelect;
@@ -1,11 +1,14 @@
1
1
  export declare type FormFieldProps = {
2
2
  property: ObjectProperty;
3
3
  onChange: Function;
4
+ onBlur?: Function;
4
5
  defaultValue?: unknown;
5
6
  error?: boolean;
6
7
  errorMessage?: string;
7
8
  required?: boolean;
8
9
  readOnly?: boolean;
10
+ min?: number;
11
+ max?: number;
9
12
  selectOptions?: Array<string>;
10
13
  locale?: string;
11
14
  size?: 'small' | 'medium';
@@ -5,13 +5,14 @@ import FileUploadControl from './FileUpload/FileUpload';
5
5
  import InputFieldComponent from './InputFieldComponent/InputFieldComponent';
6
6
  import Select from './Select/Select';
7
7
  const FormField = (props) => {
8
- const { defaultValue, error, onChange, property, readOnly, selectOptions, required, size, placeholder, errorMessage, mask } = props;
8
+ const { defaultValue, error, onChange, property, readOnly, selectOptions, required, size, placeholder, errorMessage, onBlur, mask, max, min } = props;
9
9
  const id = property.id;
10
10
  let control;
11
11
  const commonProps = {
12
12
  id,
13
13
  property,
14
14
  onChange,
15
+ onBlur,
15
16
  error,
16
17
  errorMessage,
17
18
  readOnly,
@@ -20,6 +21,8 @@ const FormField = (props) => {
20
21
  required,
21
22
  size,
22
23
  placeholder,
24
+ min,
25
+ max
23
26
  };
24
27
  switch (property.type) {
25
28
  case 'boolean':
@@ -23,11 +23,11 @@ const NumericFormat = (props) => {
23
23
  value: values.floatValue,
24
24
  },
25
25
  });
26
- }, thousandSeparator: true, isNumericString: true, fixedDecimalScale: true, allowNegative: false })));
26
+ }, isNumericString: true, fixedDecimalScale: true, allowNegative: false })));
27
27
  };
28
28
  const InputFieldComponent = (props) => {
29
29
  var _a;
30
- const { property, defaultValue, error, errorMessage, readOnly, required, size, placeholder, mask } = props;
30
+ const { property, defaultValue, error, errorMessage, onBlur, readOnly, required, size, placeholder, mask, min, max } = props;
31
31
  const [value, setValue] = useState(defaultValue !== null && defaultValue !== void 0 ? defaultValue : '');
32
32
  const [inputValue, setInputValue] = useState('');
33
33
  const id = property.id;
@@ -47,11 +47,9 @@ const InputFieldComponent = (props) => {
47
47
  setInputValue(selectValue);
48
48
  };
49
49
  const InputProps = property.type === 'number'
50
- ? {
51
- inputComponent: NumericFormat,
52
- }
50
+ ? { inputComponent: NumericFormat, min, max }
53
51
  : property.type === 'integer'
54
- ? { inputProps: { min: 0 } }
52
+ ? { inputProps: { min, max } }
55
53
  : null;
56
54
  const selectOptions = (_a = property.enum) !== null && _a !== void 0 ? _a : [];
57
55
  if (property.enum && !property.enum.includes(value)) {
@@ -60,7 +58,7 @@ const InputFieldComponent = (props) => {
60
58
  //widgets had it like this, as strings w/isOptionEqualToValue
61
59
  selectOptions.push(value);
62
60
  }
63
- return property.enum && !readOnly ? (React.createElement(Autocomplete, { id: id, options: selectOptions, onChange: handleSelectChange, renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { value: value, error: error, errorMessage: errorMessage, fullWidth: true, size: size !== null && size !== void 0 ? size : 'medium', placeholder: placeholder }))), disableClearable: true, value: value, isOptionEqualToValue: (option, value) => {
61
+ return property.enum && !readOnly ? (React.createElement(Autocomplete, { id: id, options: selectOptions, onChange: handleSelectChange, renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { value: value, error: error, errorMessage: errorMessage, fullWidth: true, onBlur: onBlur, size: size !== null && size !== void 0 ? size : 'medium', placeholder: placeholder }))), disableClearable: true, value: value, isOptionEqualToValue: (option, value) => {
64
62
  return option.value === value;
65
63
  }, error: error, required: required, inputValue: inputValue !== null && inputValue !== void 0 ? inputValue : '', onInputChange: handleInputValueChange })) : !mask ? (React.createElement(TextField, { id: id, sx: readOnly
66
64
  ? {
@@ -72,7 +70,7 @@ const InputFieldComponent = (props) => {
72
70
  backgroundColor: '#f4f6f8',
73
71
  },
74
72
  }
75
- : undefined, error: error, errorMessage: errorMessage, value: value, onChange: !readOnly ? handleChange : undefined, InputProps: Object.assign(Object.assign({}, InputProps), { readOnly: readOnly }), required: required, fullWidth: true, 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, alwaysShowMask: true },
76
74
  React.createElement(TextField, { id: id, sx: readOnly
77
75
  ? {
78
76
  '& .MuiOutlinedInput-notchedOutline': {
@@ -83,6 +81,6 @@ const InputFieldComponent = (props) => {
83
81
  backgroundColor: '#f4f6f8',
84
82
  },
85
83
  }
86
- : undefined, error: error, InputProps: Object.assign(Object.assign({}, InputProps), { readOnly: readOnly }), fullWidth: true, type: property.type === 'integer' ? 'number' : 'text' })));
84
+ : undefined, error: error, errorMessage: errorMessage, onBlur: onBlur, InputProps: Object.assign(Object.assign({}, InputProps), { readOnly: readOnly }), fullWidth: true, type: property.type === 'integer' ? 'number' : 'text' })));
87
85
  };
88
86
  export default InputFieldComponent;
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
2
2
  import { Autocomplete, TextField } from '../../../core';
3
3
  import InputFieldComponent from '../InputFieldComponent/InputFieldComponent';
4
4
  const Select = (props) => {
5
- const { property, defaultValue, error, errorMessage, readOnly, selectOptions, required, size } = props;
5
+ const { property, defaultValue, error, errorMessage, onBlur, readOnly, selectOptions, required, size } = props;
6
6
  const [value, setValue] = useState(defaultValue);
7
7
  const [inputValue, setInputValue] = useState('');
8
8
  useEffect(() => {
@@ -27,6 +27,6 @@ const Select = (props) => {
27
27
  setInputValue(selectValue);
28
28
  }
29
29
  };
30
- return readOnly ? (React.createElement(InputFieldComponent, Object.assign({}, props))) : (React.createElement(Autocomplete, { multiple: (property === null || property === void 0 ? void 0 : property.type) === 'array' ? true : false, id: id, renderInput: (params) => React.createElement(TextField, Object.assign({}, params, { value: value, fullWidth: true })), value: value, onChange: handleChange, options: (property === null || property === void 0 ? void 0 : property.type) === 'array' ? property === null || property === void 0 ? void 0 : property.enum : selectOptions, disableClearable: true, inputValue: inputValue !== null && inputValue !== void 0 ? inputValue : '', error: error, errorMessage: errorMessage, required: required, onInputChange: handleInputValueChange, filterOptions: (option) => { var _a; return (property === null || property === void 0 ? void 0 : property.type) === 'array' ? (_a = property === null || property === void 0 ? void 0 : property.enum) === null || _a === void 0 ? void 0 : _a.filter((item) => item !== option.value) : option; }, size: size }));
30
+ return readOnly ? (React.createElement(InputFieldComponent, Object.assign({}, props))) : (React.createElement(Autocomplete, { multiple: (property === null || property === void 0 ? void 0 : property.type) === 'array' ? true : false, id: id, renderInput: (params) => React.createElement(TextField, Object.assign({}, params, { value: value, fullWidth: true, onBlur: onBlur })), value: value, onChange: handleChange, options: (property === null || property === void 0 ? void 0 : property.type) === 'array' ? property === null || property === void 0 ? void 0 : property.enum : selectOptions, disableClearable: true, inputValue: inputValue !== null && inputValue !== void 0 ? inputValue : '', error: error, errorMessage: errorMessage, required: required, onInputChange: handleInputValueChange, filterOptions: (option) => { var _a; return (property === null || property === void 0 ? void 0 : property.type) === 'array' ? (_a = property === null || property === void 0 ? void 0 : property.enum) === null || _a === void 0 ? void 0 : _a.filter((item) => item !== option.value) : option; }, size: size }));
31
31
  };
32
32
  export default Select;
@@ -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.1.10.9",
3
+ "version": "1.0.0-dev.101",
4
4
  "description": "",
5
5
  "main": "dist/published/index.js",
6
6
  "module": "dist/published/index.js",