@evoke-platform/ui-components 1.6.0-dev.24 → 1.6.0-dev.26

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 () => {
@@ -0,0 +1,19 @@
1
+ import { EvokeForm, ObjectInstance } from '@evoke-platform/context';
2
+ import React, { ComponentType } from 'react';
3
+ import { FieldErrors, FieldValues } from 'react-hook-form';
4
+ import { BaseProps, DocumentInstance, SimpleEditorProps } from './components/types';
5
+ export type FormProps = BaseProps & {
6
+ richTextEditor?: ComponentType<SimpleEditorProps>;
7
+ hideButtons?: boolean;
8
+ value?: FieldValues;
9
+ onSubmit?: (data: FieldValues) => void;
10
+ fieldHeight?: 'small' | 'medium';
11
+ stickyFooter?: boolean;
12
+ onCancel?: () => void;
13
+ form: EvokeForm;
14
+ instance?: ObjectInstance | DocumentInstance;
15
+ onChange: (id: string, value: unknown) => void;
16
+ onValidationChange?: (errors: FieldErrors) => void;
17
+ };
18
+ declare function FormRenderer(props: FormProps): React.JSX.Element;
19
+ export default FormRenderer;
@@ -0,0 +1,183 @@
1
+ import { useObject } from '@evoke-platform/context';
2
+ import { isEqual } from 'lodash';
3
+ import React, { useEffect, useMemo, useState } from 'react';
4
+ import { useForm } from 'react-hook-form';
5
+ import { useResponsive } from '../../../theme';
6
+ import { Button, Skeleton, Typography } from '../../core';
7
+ import { Box } from '../../layout';
8
+ import ActionButtons from './components/ActionButtons';
9
+ import { FormContext } from './components/FormContext';
10
+ import { RecursiveEntryRenderer } from './components/RecursiveEntryRenderer';
11
+ import { convertDocToParameters, convertPropertiesToParams } from './components/utils';
12
+ import { handleValidation } from './components/ValidationFiles/Validation';
13
+ import ValidationErrorDisplay from './components/ValidationFiles/ValidationErrorDisplay';
14
+ function FormRenderer(props) {
15
+ const { onSubmit, value, fieldHeight, richTextEditor, hideButtons, stickyFooter, onCancel, form, instance, onChange, onValidationChange, } = props;
16
+ const { entries, name: title, objectId, actionId, display } = form;
17
+ const { register, unregister, setValue, reset, handleSubmit, formState: { errors, isSubmitted }, getValues, } = useForm({
18
+ defaultValues: value,
19
+ });
20
+ const hasSections = entries.some((entry) => entry.type === 'sections');
21
+ const isModal = !!document.querySelector('.MuiDialog-container');
22
+ const { isSm, isXs, smallerThan } = useResponsive();
23
+ const isSmallerThanMd = smallerThan('md');
24
+ const objectStore = useObject(objectId);
25
+ const [expandedSections, setExpandedSections] = useState([]);
26
+ const [fetchedOptions, setFetchedOptions] = useState({});
27
+ const [expandAll, setExpandAll] = useState();
28
+ const [action, setAction] = useState();
29
+ const [object, setObject] = useState();
30
+ const [triggerFieldReset, setTriggerFieldReset] = useState(false);
31
+ const updateFetchedOptions = (newData) => {
32
+ setFetchedOptions((prev) => ({
33
+ ...prev,
34
+ ...newData,
35
+ }));
36
+ };
37
+ function handleExpandAll() {
38
+ setExpandAll(true);
39
+ }
40
+ function handleCollapseAll() {
41
+ setExpandAll(false);
42
+ }
43
+ useEffect(() => {
44
+ (async () => {
45
+ try {
46
+ const object = await objectStore.get({ sanitized: true });
47
+ setObject(object);
48
+ if (actionId) {
49
+ const action = object?.actions?.find((a) => a.id === actionId);
50
+ setAction(action);
51
+ }
52
+ }
53
+ catch (error) {
54
+ console.error('Failed to fetch object or action:', error);
55
+ }
56
+ })();
57
+ }, [objectStore, actionId]);
58
+ useEffect(() => {
59
+ const currentValues = getValues();
60
+ if (value) {
61
+ for (const key of Object.keys(currentValues)) {
62
+ if (!isEqual(currentValues[key], value[key])) {
63
+ setValue(key, value[key], { shouldValidate: true });
64
+ }
65
+ }
66
+ if (triggerFieldReset === true) {
67
+ setTriggerFieldReset(false);
68
+ }
69
+ }
70
+ }, [value]);
71
+ useEffect(() => {
72
+ if (onValidationChange) {
73
+ onValidationChange(errors);
74
+ }
75
+ }, [errors, onValidationChange]);
76
+ const handleReset = () => {
77
+ if (onCancel) {
78
+ onCancel();
79
+ }
80
+ else {
81
+ reset(instance); // clears react-hook-form state back to default values
82
+ }
83
+ setTriggerFieldReset(true);
84
+ };
85
+ const parameters = useMemo(() => {
86
+ if (form.id === 'documentForm') {
87
+ return convertDocToParameters(instance);
88
+ }
89
+ else if (action?.parameters) {
90
+ return action.parameters;
91
+ }
92
+ else if (object) {
93
+ // if forms actionId is synced with object properties
94
+ return convertPropertiesToParams(object);
95
+ }
96
+ }, [form.id, action?.parameters, object, instance]);
97
+ useEffect(() => {
98
+ handleValidation(entries, register, getValues(), action?.parameters, instance);
99
+ }, []);
100
+ if (entries && parameters && (!actionId || action)) {
101
+ return (React.createElement(React.Fragment, null,
102
+ React.createElement(Box, { sx: {
103
+ paddingX: isSmallerThanMd ? 2 : 3,
104
+ paddingTop: '0px',
105
+ borderBottom: '2px solid #F4F6F8',
106
+ } },
107
+ React.createElement(Box, { sx: {
108
+ display: 'flex',
109
+ justifyContent: 'space-between',
110
+ alignItems: 'center',
111
+ flexWrap: 'wrap',
112
+ paddingY: isSm || isXs ? 2 : 3,
113
+ } },
114
+ React.createElement(Typography, { sx: {
115
+ fontSize: '20px',
116
+ lineHeight: '30px',
117
+ fontWeight: 700,
118
+ flexGrow: '1',
119
+ } }, title),
120
+ isSmallerThanMd && hasSections && (React.createElement(Box, { sx: {
121
+ display: 'flex',
122
+ alignItems: 'center',
123
+ maxHeight: '22px',
124
+ } },
125
+ React.createElement(Button, { variant: "text", size: "small", disableRipple: true, disabled: expandedSections.every((section) => section.expanded === true), sx: {
126
+ color: '#212B36',
127
+ borderRight: '1px solid #e5e8eb',
128
+ borderRadius: '0px',
129
+ '&:hover': {
130
+ backgroundColor: 'transparent',
131
+ },
132
+ fontWeight: 400,
133
+ fontSize: '14px',
134
+ }, onClick: handleExpandAll }, "Expand all"),
135
+ React.createElement(Button, { variant: "text", size: "small", disableRipple: true, disabled: expandedSections.every((section) => section.expanded === false), sx: {
136
+ color: '#212B36',
137
+ '&:hover': {
138
+ backgroundColor: 'transparent',
139
+ },
140
+ fontWeight: 400,
141
+ fontSize: '14px',
142
+ }, onClick: handleCollapseAll }, "Collapse all")))),
143
+ React.createElement(ValidationErrorDisplay, { errors: errors, show: !!(isSubmitted && errors), formId: form.id, title: title })),
144
+ React.createElement(FormContext.Provider, { value: {
145
+ fetchedOptions,
146
+ setFetchedOptions: updateFetchedOptions,
147
+ getValues,
148
+ stickyFooter,
149
+ object,
150
+ } },
151
+ React.createElement(Box, { sx: {
152
+ padding: isModal ? '0px' : isSm || isXs ? 2 : 3,
153
+ paddingBottom: '0px',
154
+ paddingTop: !hasSections ? undefined : '0px',
155
+ } },
156
+ entries.map((entry, index) => (React.createElement(RecursiveEntryRenderer, { fieldHeight: fieldHeight, key: index, entry: entry, handleChange: onChange, errors: errors, showSubmitError: !!(isSubmitted && errors), instance: instance, richTextEditor: richTextEditor, expandedSections: expandedSections, setExpandedSections: setExpandedSections, expandAll: expandAll, setExpandAll: setExpandAll, triggerFieldReset: triggerFieldReset, parameters: parameters }))),
157
+ !hideButtons && (actionId || form.id === 'documentForm') && onSubmit && (React.createElement(Box, { sx: {
158
+ ...(stickyFooter === false ? { position: 'static' } : { position: 'sticky' }),
159
+ bottom: isModal ? -5 : isSmallerThanMd ? 0 : 24,
160
+ zIndex: 1000,
161
+ borderTop: action?.type !== 'delete' ? '1px solid #f4f6f8' : 'none',
162
+ backgroundColor: '#fff',
163
+ paddingY: isSmallerThanMd ? '16px' : '20px',
164
+ paddingX: isSmallerThanMd ? '16px' : '20px',
165
+ display: 'flex',
166
+ justifyContent: isXs ? 'center' : 'flex-end',
167
+ alignItems: 'center',
168
+ marginX: isSmallerThanMd ? -2 : -3,
169
+ marginBottom: '1px',
170
+ borderRadius: '0px 0px 6px 6px',
171
+ } },
172
+ React.createElement(ActionButtons, { onSubmit: onSubmit, handleSubmit: handleSubmit, isModal: isModal, actionType: action?.type, submitButtonLabel: display?.submitLabel, onReset: handleReset, errors: errors, unregister: unregister, entries: entries, setValue: setValue, formId: form.id, instance: instance })))))));
173
+ }
174
+ else {
175
+ return (React.createElement(Box, { p: 2 },
176
+ React.createElement(Skeleton, null),
177
+ React.createElement(Skeleton, null),
178
+ React.createElement(Skeleton, null),
179
+ React.createElement(Skeleton, null),
180
+ React.createElement(Skeleton, null)));
181
+ }
182
+ }
183
+ export default FormRenderer;
@@ -36,7 +36,7 @@ const styles = {
36
36
  },
37
37
  };
38
38
  export const ActionDialog = (props) => {
39
- const { open, onClose, action, object, instanceId, relatedForm } = props;
39
+ const { open, onClose, action, object, instanceId, relatedForm, instanceInput } = props;
40
40
  const [loading, setLoading] = useState(false);
41
41
  const [hasAccess, setHasAccess] = useState();
42
42
  const [form, setForm] = useState();
@@ -62,7 +62,12 @@ export const ActionDialog = (props) => {
62
62
  ? {
63
63
  id: '',
64
64
  name: '',
65
- entries: [],
65
+ entries: [
66
+ {
67
+ type: 'content',
68
+ html: `<p>You are about to delete ${instanceInput?.name}. Deleted records can't be restored. Are you sure you want to continue?</p>`,
69
+ },
70
+ ],
66
71
  objectId: object.id,
67
72
  actionId: '_delete',
68
73
  display: {
@@ -120,3 +120,12 @@ export type SectionsProps = {
120
120
  triggerFieldReset?: boolean;
121
121
  showSubmitError?: boolean;
122
122
  };
123
+ export type DocumentInstance = {
124
+ id: string;
125
+ name: string;
126
+ contentType: string;
127
+ size: number;
128
+ uploadedDate: string;
129
+ metadata?: Record<string, string>;
130
+ versionId: string;
131
+ };
@@ -2,6 +2,7 @@ import { ApiServices, Column, Columns, FormEntry, InputParameter, Obj, ObjectIns
2
2
  import { LocalDateTime } from '@js-joda/core';
3
3
  import { FieldErrors, FieldValues } from 'react-hook-form';
4
4
  import { AutocompleteOption } from '../../../core';
5
+ import { DocumentInstance } from './types';
5
6
  export declare const scrollIntoViewWithOffset: (el: HTMLElement, offset: number, container?: HTMLElement) => void;
6
7
  export declare const normalizeDateTime: (dateTime: LocalDateTime) => string;
7
8
  export declare function isAddressProperty(key: string): boolean;
@@ -40,3 +41,7 @@ export declare function getDefaultPages(parameters: InputParameter[], defaultPag
40
41
  export declare function updateCriteriaInputs(criteria: Record<string, unknown>, data: Record<string, unknown>, user?: UserAccount): Record<string, unknown>;
41
42
  export declare function fetchCollectionData(apiServices: ApiServices, fieldDefinition: InputParameter | Property, setFetchedOptions: (newData: FieldValues) => void, instanceId?: string, fetchedOptions?: Record<string, unknown>, initialMiddleObjectInstances?: ObjectInstance[]): Promise<void>;
42
43
  export declare const getErrorCountForSection: (section: Section | Column, errors: FieldErrors) => number;
44
+ export declare const convertDocToParameters: (obj: DocumentInstance) => InputParameter[];
45
+ export declare const propertyToParameter: (property: Property) => InputParameter;
46
+ export declare const propertyValidationToParameterValidation: (property: Property) => InputParameter['validation'];
47
+ export declare const convertPropertiesToParams: (object: Obj) => InputParameter[] | undefined;
@@ -1,6 +1,6 @@
1
1
  import { LocalDateTime } from '@js-joda/core';
2
2
  import jsonLogic from 'json-logic-js';
3
- import { get, isArray, isObject, transform } from 'lodash';
3
+ import { get, isArray, isObject, omit, startCase, transform } from 'lodash';
4
4
  import { DateTime } from 'luxon';
5
5
  import Handlebars from 'no-eval-handlebars';
6
6
  import { defaultRuleProcessorMongoDB, formatQuery, parseMongoDB } from 'react-querybuilder';
@@ -371,3 +371,64 @@ export const getErrorCountForSection = (section, errors) => {
371
371
  }, 0)
372
372
  : 0;
373
373
  };
374
+ // to convert the properties of the current instances doc into a mappable object
375
+ export const convertDocToParameters = (obj) => {
376
+ return Object.entries(obj).flatMap(([key, value]) => {
377
+ if (key === 'metadata') {
378
+ return [
379
+ {
380
+ id: 'type',
381
+ name: 'Type',
382
+ type: 'string',
383
+ },
384
+ {
385
+ id: 'view_permission',
386
+ name: 'View Permission',
387
+ type: 'string',
388
+ enum: ['Public', 'Private', 'Portal'],
389
+ },
390
+ ];
391
+ }
392
+ return [
393
+ {
394
+ id: key,
395
+ name: startCase(key),
396
+ type: 'string',
397
+ },
398
+ ];
399
+ });
400
+ };
401
+ export const propertyToParameter = (property) => {
402
+ return {
403
+ ...omit(property, ['searchable', 'formula', 'formulaType', 'mask', 'textTransform']),
404
+ validation: property.validation ? propertyValidationToParameterValidation(property) : undefined,
405
+ };
406
+ };
407
+ export const propertyValidationToParameterValidation = (property) => {
408
+ if (property.validation) {
409
+ if ('from' in property.validation || 'to' in property.validation) {
410
+ return undefined;
411
+ }
412
+ return { ...property.validation };
413
+ }
414
+ return undefined;
415
+ };
416
+ export const convertPropertiesToParams = (object) => {
417
+ return object.properties
418
+ ?.reduce((acc, property) => {
419
+ return property.type === 'address'
420
+ ? [
421
+ ...acc,
422
+ ...['city', 'county', 'state', 'line1', 'line2', 'zipCode'].map((field) => ({
423
+ id: `${property.id}.${field}`,
424
+ name: `${property.name} ${startCase(field)}`,
425
+ type: 'string',
426
+ })),
427
+ ]
428
+ : [...acc, property];
429
+ }, [])
430
+ .filter(({ id, type }) => type !== 'collection')
431
+ .flat()
432
+ .sort((a, b) => a.name.localeCompare(b.name))
433
+ .map(propertyToParameter);
434
+ };
@@ -0,0 +1 @@
1
+ export { default as FormRenderer } from './FormRenderer';
@@ -0,0 +1 @@
1
+ export { default as FormRenderer } from './FormRenderer';
@@ -5,6 +5,7 @@ export { ErrorComponent } from './ErrorComponent';
5
5
  export { Form } from './Form';
6
6
  export type { FormRef } from './Form';
7
7
  export { FormField } from './FormField';
8
+ export { FormRenderer } from './FormV2';
8
9
  export { HistoryLog } from './HistoryLog';
9
10
  export { MenuBar } from './Menubar';
10
11
  export { MultiSelect } from './MultiSelect';
@@ -4,6 +4,7 @@ export { DataGrid } from './DataGrid';
4
4
  export { ErrorComponent } from './ErrorComponent';
5
5
  export { Form } from './Form';
6
6
  export { FormField } from './FormField';
7
+ export { FormRenderer } from './FormV2';
7
8
  export { HistoryLog } from './HistoryLog';
8
9
  export { MenuBar } from './Menubar';
9
10
  export { MultiSelect } from './MultiSelect';
@@ -2,7 +2,7 @@ export { ClickAwayListener, createTheme, darken, lighten, styled, Toolbar, useMe
2
2
  export { CalendarPicker, DateTimePicker, MonthPicker, PickersDay, StaticDateTimePicker, StaticTimePicker, TimePicker, YearPicker, } from '@mui/x-date-pickers';
3
3
  export * from './colors';
4
4
  export * from './components/core';
5
- export { BuilderGrid, CriteriaBuilder, DataGrid, ErrorComponent, Form, FormField, getReadableQuery, HistoryLog, MenuBar, MultiSelect, RepeatableField, ResponsiveOverflow, RichTextViewer, UserAvatar, } from './components/custom';
5
+ export { BuilderGrid, CriteriaBuilder, DataGrid, ErrorComponent, Form, FormField, FormRenderer, getReadableQuery, HistoryLog, MenuBar, MultiSelect, RepeatableField, ResponsiveOverflow, RichTextViewer, UserAvatar, } from './components/custom';
6
6
  export type { FormRef } from './components/custom';
7
7
  export { NumericFormat } from './components/custom/FormField/InputFieldComponent';
8
8
  export { Box, Container, Grid, Stack } from './components/layout';
@@ -2,7 +2,7 @@ export { ClickAwayListener, createTheme, darken, lighten, styled, Toolbar, useMe
2
2
  export { CalendarPicker, DateTimePicker, MonthPicker, PickersDay, StaticDateTimePicker, StaticTimePicker, TimePicker, YearPicker, } from '@mui/x-date-pickers';
3
3
  export * from './colors';
4
4
  export * from './components/core';
5
- export { BuilderGrid, CriteriaBuilder, DataGrid, ErrorComponent, Form, FormField, getReadableQuery, HistoryLog, MenuBar, MultiSelect, RepeatableField, ResponsiveOverflow, RichTextViewer, UserAvatar, } from './components/custom';
5
+ export { BuilderGrid, CriteriaBuilder, DataGrid, ErrorComponent, Form, FormField, FormRenderer, getReadableQuery, HistoryLog, MenuBar, MultiSelect, RepeatableField, ResponsiveOverflow, RichTextViewer, UserAvatar, } from './components/custom';
6
6
  export { NumericFormat } from './components/custom/FormField/InputFieldComponent';
7
7
  export { Box, Container, Grid, Stack } from './components/layout';
8
8
  export * from './theme';
@@ -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-dev.24",
3
+ "version": "1.6.0-dev.26",
4
4
  "description": "",
5
5
  "main": "dist/published/index.js",
6
6
  "module": "dist/published/index.js",