@evoke-platform/ui-components 1.6.0-testing.12 → 1.6.0-testing.13

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,11 +1,10 @@
1
- import { Property } from '@evoke-platform/context';
2
1
  import React from 'react';
3
2
  import 'react-querybuilder/dist/query-builder.css';
4
3
  import { EvokeObject } from '../../../types';
5
- import { Operator, PresetValue, TreeViewObject } from './types';
4
+ import { ObjectProperty, Operator, PresetValue, TreeViewObject } from './types';
6
5
  import { ValueEditorProps } from './ValueEditor';
7
6
  export type CriteriaInputProps = {
8
- properties: Property[];
7
+ properties: ObjectProperty[];
9
8
  setCriteria: (criteria?: Record<string, unknown> | undefined) => void;
10
9
  criteria?: Record<string, unknown>;
11
10
  originalCriteria?: Record<string, unknown>;
@@ -8,7 +8,7 @@ import AddressFieldComponent from './addressFieldComponent';
8
8
  const addressProperty = {
9
9
  id: 'addressLine1',
10
10
  name: 'Line 1',
11
- type: 'string',
11
+ type: 'text',
12
12
  };
13
13
  it('displays matching addresses', async () => {
14
14
  const user = userEvent.setup();
@@ -1,10 +1,11 @@
1
- import { Property, SelectOption } from '@evoke-platform/context';
1
+ import { SelectOption } from '@evoke-platform/context';
2
2
  import React, { FocusEventHandler, ReactNode } from 'react';
3
+ import { ObjectProperty } from '../../../types';
3
4
  import { AutocompleteOption } from '../../core';
4
5
  import { Address } from './AddressFieldComponent/addressFieldComponent';
5
6
  export type FormFieldProps = {
6
7
  id?: string;
7
- property: Property;
8
+ property: ObjectProperty;
8
9
  onChange?: Function;
9
10
  onBlur?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
10
11
  defaultValue?: unknown;
@@ -11,28 +11,23 @@ describe('Single select', () => {
11
11
  const choiceProperty = {
12
12
  id: 'selectOptions',
13
13
  name: 'Select Options',
14
- type: 'string',
14
+ type: 'choices',
15
15
  };
16
16
  it('returns selected option', async () => {
17
17
  const onChangeMock = vi.fn((name, value, property) => { });
18
18
  const user = userEvent.setup();
19
19
  const options = ['option 1', 'option 2', 'option 3'];
20
- render(React.createElement(Select, { id: "testSelect", property: { ...choiceProperty, enum: options }, selectOptions: options, onChange: onChangeMock }));
20
+ render(React.createElement(Select, { id: "testSelect", property: choiceProperty, selectOptions: options, onChange: onChangeMock }));
21
21
  const input = screen.getByRole('combobox');
22
22
  await user.click(input);
23
23
  const option2 = await screen.findByRole('option', { name: 'option 2' });
24
24
  await user.click(option2);
25
- expect(onChangeMock).toBeCalledWith('selectOptions', expect.objectContaining({ label: 'option 2', value: 'option 2' }), {
26
- id: 'selectOptions',
27
- name: 'Select Options',
28
- type: 'string',
29
- enum: ['option 1', 'option 2', 'option 3'],
30
- });
25
+ expect(onChangeMock).toBeCalledWith('selectOptions', expect.objectContaining({ label: 'option 2', value: 'option 2' }), choiceProperty);
31
26
  });
32
27
  it('displays matching options', async () => {
33
28
  const user = userEvent.setup();
34
29
  const options = ['option 1', 'option 2', 'something different'];
35
- render(React.createElement(Select, { id: "testSelect", property: { ...choiceProperty, enum: options }, selectOptions: options, onChange: () => { } }));
30
+ render(React.createElement(Select, { id: "testSelect", property: choiceProperty, selectOptions: options, onChange: () => { } }));
36
31
  const input = screen.getByRole('combobox');
37
32
  await user.type(input, 'option');
38
33
  await screen.findByRole('option', { name: 'option 1' });
@@ -45,7 +40,7 @@ describe('Single select', () => {
45
40
  { sortBy: 'DESC', expectedValues: ['option 3', 'option 2', 'option 1'] },
46
41
  ])('shows options in $sortBy order as dropdown display', async ({ sortBy, expectedValues }) => {
47
42
  const options = ['option 2', 'option 1', 'option 3'];
48
- render(React.createElement(Select, { id: "testSelect", property: { ...choiceProperty, enum: options }, selectOptions: options, displayOption: 'dropdown', sortBy: sortBy, onChange: vi.fn() }));
43
+ render(React.createElement(Select, { id: "testSelect", property: choiceProperty, selectOptions: options, displayOption: 'dropdown', sortBy: sortBy, onChange: vi.fn() }));
49
44
  const user = userEvent.setup();
50
45
  const input = screen.getByRole('combobox');
51
46
  await user.click(input);
@@ -57,7 +52,7 @@ describe('Single select', () => {
57
52
  const onChangeMock = vi.fn((name, value, property) => { });
58
53
  const user = userEvent.setup();
59
54
  const options = ['option 1', 'option 2', 'option 3'];
60
- render(React.createElement(Select, { id: "testSelect", property: { ...choiceProperty, enum: options }, selectOptions: options, onChange: onChangeMock, isCombobox: true }));
55
+ render(React.createElement(Select, { id: "testSelect", property: choiceProperty, selectOptions: options, onChange: onChangeMock, isCombobox: true }));
61
56
  const input = screen.getByRole('combobox');
62
57
  await user.click(input);
63
58
  // Verify the instruction text for a combobox displays as the sub-header of the combobox.
@@ -66,12 +61,7 @@ describe('Single select', () => {
66
61
  // Verify the option to add the custom value is displayed as an available option in the dropdown.
67
62
  const customOption = await screen.findByRole('option', { name: 'Add "custom option"' });
68
63
  await user.click(customOption);
69
- expect(onChangeMock).toBeCalledWith('selectOptions', expect.objectContaining({ label: 'Add "custom option"', value: 'custom option' }), {
70
- id: 'selectOptions',
71
- name: 'Select Options',
72
- type: 'string',
73
- enum: ['option 1', 'option 2', 'option 3'],
74
- });
64
+ expect(onChangeMock).toBeCalledWith('selectOptions', expect.objectContaining({ label: 'Add "custom option"', value: 'custom option' }), choiceProperty);
75
65
  });
76
66
  });
77
67
  describe('Multi select', () => {
@@ -86,7 +76,7 @@ describe('Multi select', () => {
86
76
  const user = userEvent.setup();
87
77
  const onChangeMock = vi.fn((name, value, property) => { });
88
78
  const options = ['option 1', 'option 2', 'option 3'];
89
- render(React.createElement(Select, { id: "testSelect", property: { ...multiChoiceProperty, enum: options }, selectOptions: options, onChange: onChangeMock }));
79
+ render(React.createElement(Select, { id: "testSelect", property: multiChoiceProperty, selectOptions: options, onChange: onChangeMock }));
90
80
  const input = screen.getByRole('combobox');
91
81
  await user.click(input);
92
82
  const option2 = await screen.findByRole('option', { name: 'option 2' });
@@ -96,18 +86,13 @@ describe('Multi select', () => {
96
86
  const option3 = await screen.findByRole('option', { name: 'option 3' });
97
87
  await user.click(option3);
98
88
  expect(onChangeMock).toBeCalledTimes(2);
99
- expect(onChangeMock).lastCalledWith('multiSelect', ['option 2', 'option 3'], {
100
- id: 'multiSelect',
101
- name: 'Select Multiple',
102
- type: 'array',
103
- enum: ['option 1', 'option 2', 'option 3'],
104
- });
89
+ expect(onChangeMock).lastCalledWith('multiSelect', ['option 2', 'option 3'], multiChoiceProperty);
105
90
  });
106
91
  it('allows the user to enter custom values if it is combobox component', async () => {
107
92
  const onChangeMock = vi.fn((name, value, property) => { });
108
93
  const user = userEvent.setup();
109
94
  const options = ['option 1', 'option 2', 'option 3'];
110
- render(React.createElement(Select, { id: "multiSelect", property: { ...multiChoiceProperty, enum: options }, selectOptions: options, onChange: onChangeMock, isCombobox: true }));
95
+ render(React.createElement(Select, { id: "multiSelect", property: multiChoiceProperty, selectOptions: options, onChange: onChangeMock, isCombobox: true }));
111
96
  const input = screen.getByRole('combobox');
112
97
  await user.click(input);
113
98
  // Verify the instruction text for a combobox displays as the sub-header of the combobox.
@@ -119,18 +104,13 @@ describe('Multi select', () => {
119
104
  const customOption2 = await screen.findByRole('option', { name: 'Add "custom option 2"' });
120
105
  await user.click(customOption2);
121
106
  expect(onChangeMock).toBeCalledTimes(2);
122
- expect(onChangeMock).lastCalledWith('multiSelect', ['custom option 1', 'custom option 2'], {
123
- id: 'multiSelect',
124
- name: 'Select Multiple',
125
- type: 'array',
126
- enum: ['option 1', 'option 2', 'option 3'],
127
- });
107
+ expect(onChangeMock).lastCalledWith('multiSelect', ['custom option 1', 'custom option 2'], multiChoiceProperty);
128
108
  });
129
109
  it('allows the user to enter custom values in conjunction with the predefined options if it is combobox component', async () => {
130
110
  const onChangeMock = vi.fn((name, value, property) => { });
131
111
  const user = userEvent.setup();
132
112
  const options = ['option 1', 'option 2', 'option 3'];
133
- render(React.createElement(Select, { id: "multiSelect", property: { ...multiChoiceProperty, enum: options }, selectOptions: options, onChange: onChangeMock, isCombobox: true }));
113
+ render(React.createElement(Select, { id: "multiSelect", property: multiChoiceProperty, selectOptions: options, onChange: onChangeMock, isCombobox: true }));
134
114
  const input = screen.getByRole('combobox');
135
115
  await user.click(input);
136
116
  // Verify the instruction text for a combobox displays as the sub-header of the combobox.
@@ -142,19 +122,14 @@ describe('Multi select', () => {
142
122
  const option1 = await screen.findByRole('option', { name: 'option 1' });
143
123
  await user.click(option1);
144
124
  expect(onChangeMock).toBeCalledTimes(2);
145
- expect(onChangeMock).lastCalledWith('multiSelect', ['custom option 1', 'option 1'], {
146
- id: 'multiSelect',
147
- name: 'Select Multiple',
148
- type: 'array',
149
- enum: ['option 1', 'option 2', 'option 3'],
150
- });
125
+ expect(onChangeMock).lastCalledWith('multiSelect', ['custom option 1', 'option 1'], multiChoiceProperty);
151
126
  });
152
127
  });
153
128
  describe('Radio Single select', () => {
154
129
  const choiceProperty = {
155
130
  id: 'selectOptions',
156
131
  name: 'Select Options',
157
- type: 'string',
132
+ type: 'choices',
158
133
  };
159
134
  it('returns selected radio option', async () => {
160
135
  const user = userEvent.setup();
@@ -171,7 +146,7 @@ describe('Radio Single select', () => {
171
146
  { sortBy: 'DESC', expectedValues: ['option 3', 'option 2', 'option 1'] },
172
147
  ])('shows options in $sortBy order as radio display', async ({ sortBy, expectedValues }) => {
173
148
  const options = ['option 2', 'option 1', 'option 3'];
174
- render(React.createElement(Select, { id: "testSelect", property: { ...choiceProperty, enum: options }, selectOptions: options, displayOption: 'radioButton', sortBy: sortBy, onChange: vi.fn() }));
149
+ render(React.createElement(Select, { id: "testSelect", property: choiceProperty, selectOptions: options, displayOption: 'radioButton', sortBy: sortBy, onChange: vi.fn() }));
175
150
  const radioButtons = screen.getAllByRole('radio');
176
151
  const radioValues = radioButtons.map((radioButton) => radioButton.value);
177
152
  expect(radioValues).toEqual(expectedValues);
@@ -179,7 +154,7 @@ describe('Radio Single select', () => {
179
154
  it('renders an "Other" option in the radio group if the component is configured to support a custom value', async () => {
180
155
  const onChangeMock = vi.fn((name, value, property) => { });
181
156
  const options = ['option 1', 'option 2', 'option 3'];
182
- render(React.createElement(Select, { id: "testSelect", property: { ...choiceProperty, enum: options }, selectOptions: options, displayOption: 'radioButton', sortBy: 'ASC', onChange: onChangeMock, isCombobox: true }));
157
+ render(React.createElement(Select, { id: "testSelect", property: choiceProperty, selectOptions: options, displayOption: 'radioButton', sortBy: 'ASC', onChange: onChangeMock, isCombobox: true }));
183
158
  await screen.findByRole('radio', { name: 'Other' });
184
159
  });
185
160
  it('renders a text field for a custom option if the "Other" option is selected', async () => {
@@ -10,7 +10,8 @@ InputField.args = {
10
10
  property: {
11
11
  id: 'fullName',
12
12
  name: 'Full Name',
13
- type: 'string',
13
+ type: 'text',
14
+ // enum?: string[],
14
15
  required: true,
15
16
  },
16
17
  onChange: (id, value) => console.log('id= ', id, 'Value= ', value),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evoke-platform/ui-components",
3
- "version": "1.6.0-testing.12",
3
+ "version": "1.6.0-testing.13",
4
4
  "description": "",
5
5
  "main": "dist/published/index.js",
6
6
  "module": "dist/published/index.js",