@evoke-platform/ui-components 1.0.0-dev.232 → 1.0.0-dev.233

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.
@@ -22,7 +22,6 @@ export declare type CriteriaInputProps = {
22
22
  disabled?: boolean;
23
23
  hideBorder?: boolean;
24
24
  presetGroupLabel?: string;
25
- freeSolo?: boolean;
26
25
  };
27
26
  export declare const valueEditor: (props: ValueEditorProps) => JSX.Element;
28
27
  declare const CriteriaBuilder: (props: CriteriaInputProps) => JSX.Element;
@@ -84,9 +84,8 @@ const customSelector = (props) => {
84
84
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
85
85
  const rule = props.rule;
86
86
  let width = '90px';
87
- let displayedValue = value;
87
+ let val = value;
88
88
  let opts = options;
89
- const isFreeSoloEnabled = context.freeSolo && title === 'Fields';
90
89
  let readOnly = false;
91
90
  if (context.disabledCriteria) {
92
91
  readOnly =
@@ -103,32 +102,23 @@ const customSelector = (props) => {
103
102
  opts = options
104
103
  .filter((option) => ['null', 'notNull', 'in', 'notIn'].includes(option.name))
105
104
  .map((option) => ({ name: option.name, label: option.label }));
106
- displayedValue =
107
- value === '='
108
- ? ''
109
- : options.find((option) => option.name === displayedValue).name;
105
+ val = val === '=' ? '' : options.find((option) => option.name === val).name;
110
106
  }
111
107
  else if (props.fieldData?.inputType === 'document') {
112
108
  opts = options
113
109
  .filter((option) => ['null', 'notNull'].includes(option.name))
114
110
  .map((option) => ({ name: option.name, label: option.label }));
115
- displayedValue =
116
- value === '='
117
- ? ''
118
- : options.find((option) => option.name === displayedValue).name;
111
+ val = val === '=' ? '' : options.find((option) => option.name === val).name;
119
112
  }
120
113
  break;
121
114
  case 'Fields':
122
115
  width = '33%';
123
- displayedValue = options.find((option) => option.name === displayedValue)?.label;
124
- if (isFreeSoloEnabled && !displayedValue) {
125
- displayedValue = value;
126
- }
116
+ val = options.find((option) => option.name === val)?.name;
127
117
  break;
128
118
  }
129
- return (React.createElement(Autocomplete, { options: opts, value: displayedValue ?? null, getOptionLabel: (option) => {
119
+ return (React.createElement(Autocomplete, { options: opts, value: val ?? null, getOptionLabel: (option) => {
130
120
  if (typeof option === 'string') {
131
- return option;
121
+ return opts.find((o) => option === o.name)?.label || '';
132
122
  }
133
123
  return option.label;
134
124
  }, isOptionEqualToValue: (option, value) => {
@@ -137,11 +127,7 @@ const customSelector = (props) => {
137
127
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
138
128
  onChange: (event, newValue) => {
139
129
  handleOnChange(newValue?.value.name);
140
- }, onInputChange: (event, value) => {
141
- if (isFreeSoloEnabled) {
142
- handleOnChange(value);
143
- }
144
- }, renderInput: (params) => React.createElement(TextField, { ...params, size: "small", name: title }), sx: { width: width, maxWidth: title === 'Operators' ? '200px' : 'none' }, disableClearable: true, readOnly: readOnly }));
130
+ }, renderInput: (params) => React.createElement(TextField, { ...params, size: "small" }), sx: { width: width, maxWidth: title === 'Operators' ? '200px' : 'none' }, disableClearable: true, readOnly: readOnly }));
145
131
  };
146
132
  const customCombinator = (props) => {
147
133
  const { options, value, handleOnChange, context, level } = props;
@@ -188,7 +174,7 @@ export const valueEditor = (props) => {
188
174
  return ValueEditor(props);
189
175
  };
190
176
  const CriteriaBuilder = (props) => {
191
- const { properties, criteria, setCriteria, originalCriteria, enablePresetValues, presetValues, operators, dynamicContentInput, disabled, disabledCriteria, hideBorder, presetGroupLabel, freeSolo, } = props;
177
+ const { properties, criteria, setCriteria, originalCriteria, enablePresetValues, presetValues, operators, dynamicContentInput, disabled, disabledCriteria, hideBorder, presetGroupLabel, } = props;
192
178
  const [query, setQuery] = useState(undefined);
193
179
  useEffect(() => {
194
180
  if (criteria || originalCriteria) {
@@ -293,7 +279,6 @@ const CriteriaBuilder = (props) => {
293
279
  enablePresetValues,
294
280
  presetGroupLabel,
295
281
  disabledCriteria,
296
- freeSolo,
297
282
  }, controlClassnames: {
298
283
  queryBuilder: 'queryBuilder-branches',
299
284
  ruleGroup: 'container',
@@ -4,6 +4,5 @@ import { CriteriaInputProps } from '../components/custom/CriteriaBuilder/Criteri
4
4
  declare const _default: ComponentMeta<(props: CriteriaInputProps) => JSX.Element>;
5
5
  export default _default;
6
6
  export declare const CriteriaBuilder: ComponentStory<(props: CriteriaInputProps) => JSX.Element>;
7
- export declare const FreeSolo: ComponentStory<(props: CriteriaInputProps) => JSX.Element>;
8
7
  export declare const CriteriaBuilderPresetUserID: ComponentStory<(props: CriteriaInputProps) => JSX.Element>;
9
8
  export declare const CriteriaBuilderGroupedPresetValues: ComponentStory<(props: CriteriaInputProps) => JSX.Element>;
@@ -109,27 +109,6 @@ CriteriaBuilder.args = {
109
109
  },
110
110
  enablePresetValues: false,
111
111
  };
112
- export const FreeSolo = CriteriaBuilderTemplate.bind({});
113
- FreeSolo.args = {
114
- ...CriteriaBuilder.args,
115
- criteria: {
116
- $or: [
117
- {
118
- 'person.license.name': 'bert',
119
- },
120
- {
121
- licensedFor: { $in: ['hot dogs', 'amusements', 'entertainment'] },
122
- },
123
- {
124
- licenseNumber: '123456',
125
- },
126
- {
127
- issueDate: '2023-03-16',
128
- },
129
- ],
130
- },
131
- freeSolo: true,
132
- };
133
112
  export const CriteriaBuilderPresetUserID = CriteriaBuilderTemplate.bind({});
134
113
  CriteriaBuilderPresetUserID.args = {
135
114
  properties: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evoke-platform/ui-components",
3
- "version": "1.0.0-dev.232",
3
+ "version": "1.0.0-dev.233",
4
4
  "description": "",
5
5
  "main": "dist/published/index.js",
6
6
  "module": "dist/published/index.js",
@@ -72,7 +72,6 @@
72
72
  "eslint-plugin-prettier": "^5.1.2",
73
73
  "eslint-plugin-testing-library": "^6.2.0",
74
74
  "husky": "^8.0.3",
75
- "identity-obj-proxy": "^3.0.0",
76
75
  "is-ci": "^3.0.1",
77
76
  "jest": "^28.1.2",
78
77
  "jest-environment-jsdom": "^28.1.2",
@@ -144,9 +143,6 @@
144
143
  "jest": {
145
144
  "verbose": true,
146
145
  "testEnvironment": "jsdom",
147
- "moduleNameMapper": {
148
- "\\.(css|less|scss|sass)$": "identity-obj-proxy"
149
- },
150
146
  "testPathIgnorePatterns": [
151
147
  "/node_modules/",
152
148
  "<rootDir>/dist/"
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom/extend-expect';
@@ -1,44 +0,0 @@
1
- import React from 'react';
2
- import { render, screen } from '@testing-library/react';
3
- import userEvent from '@testing-library/user-event';
4
- import '@testing-library/jest-dom/extend-expect';
5
- import CriteriaBuilder from './CriteriaBuilder';
6
- const mockProperties = [
7
- { id: 'name', name: 'name', type: 'string', required: true },
8
- { id: 'licenseNumber', name: 'license number', type: 'string', required: true },
9
- { id: 'issueDate', name: 'issue date', type: 'date', required: false },
10
- ];
11
- describe('CriteriaBuilder', () => {
12
- test('allows selection of a property and clears value input when selected', async () => {
13
- const user = userEvent.setup();
14
- render(React.createElement(CriteriaBuilder, { properties: mockProperties, criteria: {
15
- $or: [
16
- {
17
- name: 'test value',
18
- },
19
- ],
20
- }, setCriteria: jest.fn(), freeSolo: true }));
21
- const field = await screen.findByDisplayValue(/name/);
22
- const value = await screen.findByDisplayValue(/test value/);
23
- await user.click(field);
24
- const option = await screen.findByRole('option', { name: /license number/ });
25
- await user.click(option);
26
- expect(field).toHaveValue('license number');
27
- expect(value).toHaveValue('');
28
- });
29
- test('allows free solo input when freeSolo is true, clears value input when entered', async () => {
30
- const user = userEvent.setup();
31
- render(React.createElement(CriteriaBuilder, { properties: mockProperties, criteria: {
32
- $or: [
33
- {
34
- name: 'test value',
35
- },
36
- ],
37
- }, setCriteria: jest.fn(), freeSolo: true }));
38
- const field = await screen.findByDisplayValue(/name/);
39
- const value = await screen.findByDisplayValue(/test value/);
40
- await user.type(field, 'person.license.name');
41
- expect(field).toHaveValue('person.license.name');
42
- expect(value).toHaveValue('');
43
- });
44
- });