@evoke-platform/ui-components 1.6.0-testing.13 → 1.6.0-testing.14
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.
- package/dist/published/components/custom/FormField/AddressFieldComponent/addressFieldComponent.js +1 -1
- package/dist/published/components/custom/FormField/BooleanSelect/BooleanSelect.js +3 -3
- package/dist/published/components/custom/FormField/DatePickerSelect/DatePickerSelect.js +7 -1
- package/dist/published/components/custom/FormField/DateTimePickerSelect/DateTimePickerSelect.js +7 -1
- package/dist/published/components/custom/FormField/InputFieldComponent/InputFieldComponent.js +6 -3
- package/dist/published/components/custom/FormField/TimePickerSelect/TimePickerSelect.js +13 -3
- package/dist/published/components/custom/FormV2/FormRenderer.d.ts +19 -0
- package/dist/published/components/custom/FormV2/FormRenderer.js +183 -0
- package/dist/published/components/custom/FormV2/components/AccordionSections.d.ts +4 -0
- package/dist/published/components/custom/FormV2/components/AccordionSections.js +131 -0
- package/dist/published/components/custom/FormV2/components/ActionButtons.d.ts +19 -0
- package/dist/published/components/custom/FormV2/components/ActionButtons.js +106 -0
- package/dist/published/components/custom/FormV2/components/FieldWrapper.d.ts +24 -0
- package/dist/published/components/custom/FormV2/components/FieldWrapper.js +100 -0
- package/dist/published/components/custom/FormV2/components/FormContext.d.ts +12 -0
- package/dist/published/components/custom/FormV2/components/FormContext.js +8 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/AddressFields.d.ts +17 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/AddressFields.js +50 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/ActionDialog.d.ts +14 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/ActionDialog.js +88 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/DocumentViewerCell.d.ts +13 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/DocumentViewerCell.js +140 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/DropdownRepeatableField.d.ts +17 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/DropdownRepeatableField.js +233 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/DropdownRepeatableFieldInput.d.ts +40 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/DropdownRepeatableFieldInput.js +95 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/RepeatableField.d.ts +12 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/RepeatableField.js +526 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/Criteria.d.ts +12 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/Criteria.js +93 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/DocumentFiles/Document.d.ts +16 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/DocumentFiles/Document.js +73 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/DocumentFiles/DocumentList.d.ts +13 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/DocumentFiles/DocumentList.js +179 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/Image.d.ts +12 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/Image.js +108 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/UserProperty.d.ts +16 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/UserProperty.js +129 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/relatedObjectFiles/InstanceLookup.d.ts +15 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/relatedObjectFiles/InstanceLookup.js +226 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/relatedObjectFiles/ObjectPropertyInput.d.ts +4 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/relatedObjectFiles/ObjectPropertyInput.js +439 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/relatedObjectFiles/RelatedObjectInstance.d.ts +29 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/relatedObjectFiles/RelatedObjectInstance.js +74 -0
- package/dist/published/components/custom/FormV2/components/FormSections.d.ts +4 -0
- package/dist/published/components/custom/FormV2/components/FormSections.js +104 -0
- package/dist/published/components/custom/FormV2/components/RecursiveEntryRenderer.d.ts +2 -0
- package/dist/published/components/custom/FormV2/components/RecursiveEntryRenderer.js +209 -0
- package/dist/published/components/custom/FormV2/components/TabNav.d.ts +10 -0
- package/dist/published/components/custom/FormV2/components/TabNav.js +23 -0
- package/dist/published/components/custom/FormV2/components/ValidationFiles/Validation.d.ts +3 -0
- package/dist/published/components/custom/FormV2/components/ValidationFiles/Validation.js +176 -0
- package/dist/published/components/custom/FormV2/components/ValidationFiles/ValidationErrorDisplay.d.ts +10 -0
- package/dist/published/components/custom/FormV2/components/ValidationFiles/ValidationErrorDisplay.js +45 -0
- package/dist/published/components/custom/FormV2/components/types.d.ts +131 -0
- package/dist/published/components/custom/FormV2/components/types.js +1 -0
- package/dist/published/components/custom/FormV2/components/utils.d.ts +47 -0
- package/dist/published/components/custom/FormV2/components/utils.js +434 -0
- package/dist/published/components/custom/FormV2/index.d.ts +1 -0
- package/dist/published/components/custom/FormV2/index.js +1 -0
- package/dist/published/components/custom/index.d.ts +1 -0
- package/dist/published/components/custom/index.js +1 -0
- package/dist/published/index.d.ts +2 -2
- package/dist/published/index.js +2 -2
- package/dist/published/theme/hooks.d.ts +7 -0
- package/dist/published/theme/hooks.js +9 -0
- package/package.json +4 -2
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
import { LocalDateTime } from '@js-joda/core';
|
|
2
|
+
import jsonLogic from 'json-logic-js';
|
|
3
|
+
import { get, isArray, isObject, omit, startCase, transform } from 'lodash';
|
|
4
|
+
import { DateTime } from 'luxon';
|
|
5
|
+
import Handlebars from 'no-eval-handlebars';
|
|
6
|
+
import { defaultRuleProcessorMongoDB, formatQuery, parseMongoDB } from 'react-querybuilder';
|
|
7
|
+
export const scrollIntoViewWithOffset = (el, offset, container) => {
|
|
8
|
+
const elementRect = el.getBoundingClientRect();
|
|
9
|
+
const containerRect = container ? container.getBoundingClientRect() : document.body.getBoundingClientRect();
|
|
10
|
+
const topPosition = elementRect.top - containerRect.top + (container?.scrollTop || 0) - offset;
|
|
11
|
+
if (container) {
|
|
12
|
+
container.scrollTo({
|
|
13
|
+
behavior: 'smooth',
|
|
14
|
+
top: topPosition,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
window.scrollTo({
|
|
19
|
+
behavior: 'smooth',
|
|
20
|
+
top: topPosition,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
export const normalizeDateTime = (dateTime) => new Date(dateTime.toString()).toISOString();
|
|
25
|
+
const evaluateCondition = (condition, formValues, instance) => {
|
|
26
|
+
if (typeof condition !== 'object') {
|
|
27
|
+
console.error('Invalid condition format: ', condition);
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
if (isArray(condition)) {
|
|
31
|
+
const firstCondition = condition[0];
|
|
32
|
+
const { property, value, operator } = firstCondition;
|
|
33
|
+
let fieldValue = firstCondition.isInstanceProperty ? get(instance, property) : get(formValues, property);
|
|
34
|
+
if (typeof fieldValue === 'object' && fieldValue !== null) {
|
|
35
|
+
if (fieldValue instanceof LocalDateTime) {
|
|
36
|
+
fieldValue = normalizeDateTime(fieldValue);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
fieldValue = Object.values(fieldValue).includes(value)
|
|
40
|
+
? value
|
|
41
|
+
: Object.values(fieldValue).find((val) => val !== undefined && val !== null);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
switch (operator) {
|
|
45
|
+
case 'ne':
|
|
46
|
+
return fieldValue != value;
|
|
47
|
+
case 'eq':
|
|
48
|
+
return fieldValue == value;
|
|
49
|
+
default:
|
|
50
|
+
console.error(`Unsupported operator: ${operator}`);
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// Handling custom JSON logic
|
|
55
|
+
else {
|
|
56
|
+
const data = {
|
|
57
|
+
data: formValues,
|
|
58
|
+
instance: instance,
|
|
59
|
+
};
|
|
60
|
+
const result = jsonLogic.apply(condition, data);
|
|
61
|
+
return result === true;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
export function isAddressProperty(key) {
|
|
65
|
+
return /\.line1|\.line2|\.city|\.county|\.state|\.zipCode$/.test(key);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Determine if a form entry is visible or not.
|
|
69
|
+
*/
|
|
70
|
+
export const entryIsVisible = (entry, formValues, instance) => {
|
|
71
|
+
const display = 'display' in entry ? entry.display : undefined;
|
|
72
|
+
const { visibility } = display ?? ('visibility' in entry ? entry : {});
|
|
73
|
+
if (isObject(visibility) && 'conditions' in visibility && isArray(visibility.conditions)) {
|
|
74
|
+
// visibility is a simple condition
|
|
75
|
+
const { conditions } = visibility;
|
|
76
|
+
return evaluateCondition(conditions, formValues, instance);
|
|
77
|
+
}
|
|
78
|
+
else if (visibility) {
|
|
79
|
+
// visibility is a JSONlogic condition
|
|
80
|
+
return evaluateCondition(visibility, formValues, instance);
|
|
81
|
+
}
|
|
82
|
+
return true;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Recursively retrieves all parameter IDs from a given entry of type Sections or Columns.
|
|
86
|
+
*
|
|
87
|
+
* @param {Sections | Columns} entry - The entry object, which can be of type Sections or Columns.
|
|
88
|
+
* @returns {string[]} - An array of parameter IDs found within the entry.
|
|
89
|
+
*/
|
|
90
|
+
export const getNestedParameterIds = (entry) => {
|
|
91
|
+
const parameterIds = [];
|
|
92
|
+
const entries = entry.type === 'columns'
|
|
93
|
+
? entry.columns.flatMap((column) => column.entries ?? [])
|
|
94
|
+
: entry.sections.flatMap((section) => section.entries ?? []);
|
|
95
|
+
for (const subEntry of entries) {
|
|
96
|
+
if (subEntry.type === 'columns' || subEntry.type === 'sections') {
|
|
97
|
+
parameterIds.push(...getNestedParameterIds(subEntry));
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
const paramId = getEntryId(subEntry);
|
|
101
|
+
if (paramId && paramId !== 'collection') {
|
|
102
|
+
parameterIds.push(paramId);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return parameterIds;
|
|
107
|
+
};
|
|
108
|
+
export const getEntryId = (entry) => {
|
|
109
|
+
return entry.type === 'input'
|
|
110
|
+
? entry.parameterId
|
|
111
|
+
: entry.type === 'readonlyField'
|
|
112
|
+
? entry.propertyId
|
|
113
|
+
: entry.type === 'inputField'
|
|
114
|
+
? entry.input.id
|
|
115
|
+
: undefined;
|
|
116
|
+
};
|
|
117
|
+
export function getPrefixedUrl(url) {
|
|
118
|
+
const wcsMatchers = ['/apps', '/pages', '/widgets'];
|
|
119
|
+
const dataMatchers = ['/objects', '/correspondenceTemplates', '/documents', '/payments', '/locations'];
|
|
120
|
+
const signalrMatchers = ['/hubs'];
|
|
121
|
+
const accessManagementMatchers = ['/users'];
|
|
122
|
+
const workflowMatchers = ['/workflows'];
|
|
123
|
+
if (wcsMatchers.some((endpoint) => url.startsWith(endpoint)))
|
|
124
|
+
return `/webContent${url}`;
|
|
125
|
+
if (dataMatchers.some((endpoint) => url.startsWith(endpoint)))
|
|
126
|
+
return `/data${url}`;
|
|
127
|
+
if (signalrMatchers.some((endpoint) => url.startsWith(endpoint)))
|
|
128
|
+
return `/signalr${url}`;
|
|
129
|
+
if (accessManagementMatchers.some((endpoint) => url.startsWith(endpoint)))
|
|
130
|
+
return `/accessManagement${url}`;
|
|
131
|
+
if (workflowMatchers.some((endpoint) => url.startsWith(endpoint)))
|
|
132
|
+
return `/workflow${url}`;
|
|
133
|
+
console.error('Invalid URL');
|
|
134
|
+
return url;
|
|
135
|
+
}
|
|
136
|
+
export const isOptionEqualToValue = (option, value) => {
|
|
137
|
+
if (typeof option === 'string') {
|
|
138
|
+
return option === value;
|
|
139
|
+
}
|
|
140
|
+
return option.value === value;
|
|
141
|
+
};
|
|
142
|
+
export function addressProperties(addressProperty) {
|
|
143
|
+
return [
|
|
144
|
+
{
|
|
145
|
+
id: `${addressProperty.id}.line1`,
|
|
146
|
+
name: `${addressProperty.name} Line 1`,
|
|
147
|
+
type: 'string',
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
id: `${addressProperty.id}.line2`,
|
|
151
|
+
name: `${addressProperty.name} Line 2`,
|
|
152
|
+
type: 'string',
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
id: `${addressProperty.id}.city`,
|
|
156
|
+
name: `${addressProperty.name} City`,
|
|
157
|
+
type: 'string',
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
id: `${addressProperty.id}.county`,
|
|
161
|
+
name: `${addressProperty.name} County`,
|
|
162
|
+
type: 'string',
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
id: `${addressProperty.id}.state`,
|
|
166
|
+
name: `${addressProperty.name} State`,
|
|
167
|
+
type: 'string',
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
id: `${addressProperty.id}.zipCode`,
|
|
171
|
+
name: `${addressProperty.name} Zip Code`,
|
|
172
|
+
type: 'string',
|
|
173
|
+
},
|
|
174
|
+
];
|
|
175
|
+
}
|
|
176
|
+
export const normalizeDates = (instance, evokeObject) => {
|
|
177
|
+
const dateProps = ['date', 'date-time', 'time'];
|
|
178
|
+
const properties = evokeObject?.properties
|
|
179
|
+
?.filter((property) => dateProps.includes(property.type))
|
|
180
|
+
.reduce((agg, property) => Object.assign(agg, { [property.id]: property.type }), {}) ?? {};
|
|
181
|
+
const propKeys = Object.keys(properties);
|
|
182
|
+
const updatedInstance = { ...instance };
|
|
183
|
+
Object.keys(instance).forEach((key) => {
|
|
184
|
+
// Ignore non-datelike and empty fields.
|
|
185
|
+
if (!propKeys.includes(key) || !instance[key]) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
switch (properties[key]) {
|
|
189
|
+
case 'date':
|
|
190
|
+
// Casting here is valid because the value has already been
|
|
191
|
+
// determined to be a datelike field that is non-empty.
|
|
192
|
+
updatedInstance[key] = DateTime.fromISO(instance[key]).toLocaleString(DateTime.DATE_SHORT);
|
|
193
|
+
break;
|
|
194
|
+
case 'date-time':
|
|
195
|
+
// Casting here is valid because the value has already been
|
|
196
|
+
// determined to be a datelike field that is non-empty.
|
|
197
|
+
updatedInstance[key] = DateTime.fromISO(instance[key]).toLocaleString(DateTime.DATETIME_SHORT);
|
|
198
|
+
break;
|
|
199
|
+
case 'time':
|
|
200
|
+
// Casting here is valid because the value has already been
|
|
201
|
+
// determined to be a datelike field that is non-empty.
|
|
202
|
+
updatedInstance[key] = DateTime.fromISO(instance[key]).toLocaleString(DateTime.TIME_SIMPLE);
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
return updatedInstance;
|
|
207
|
+
};
|
|
208
|
+
const OPERATOR_MAP = {
|
|
209
|
+
$and: 'and',
|
|
210
|
+
$or: 'or',
|
|
211
|
+
$eq: 'eq',
|
|
212
|
+
$ne: 'neq',
|
|
213
|
+
$lt: 'lt',
|
|
214
|
+
$lte: 'lte',
|
|
215
|
+
$gt: 'gt',
|
|
216
|
+
$gte: 'gte',
|
|
217
|
+
$in: 'inq',
|
|
218
|
+
$nin: 'nin',
|
|
219
|
+
$regex: 'regexp',
|
|
220
|
+
$exists: 'exists',
|
|
221
|
+
$not: 'not',
|
|
222
|
+
};
|
|
223
|
+
export const transformToWhere = (mongoQuery) => {
|
|
224
|
+
return transform(mongoQuery, (result, value, key) => {
|
|
225
|
+
const newKey = typeof key === 'string' && key.startsWith('$') ? OPERATOR_MAP[key] : key;
|
|
226
|
+
if (newKey === undefined) {
|
|
227
|
+
throw new Error(`Unsupported operator ${key}`);
|
|
228
|
+
}
|
|
229
|
+
result[newKey] = isObject(value) ? transformToWhere(value) : value;
|
|
230
|
+
});
|
|
231
|
+
};
|
|
232
|
+
export const getMiddleObject = (fieldDefinition, endObjectId, endObjectName, instance) => {
|
|
233
|
+
if (fieldDefinition.relatedPropertyId && fieldDefinition.manyToManyPropertyId) {
|
|
234
|
+
const middleObject = {
|
|
235
|
+
[fieldDefinition.relatedPropertyId]: {
|
|
236
|
+
id: instance?.id,
|
|
237
|
+
name: instance?.name,
|
|
238
|
+
},
|
|
239
|
+
[fieldDefinition.manyToManyPropertyId]: {
|
|
240
|
+
id: endObjectId,
|
|
241
|
+
name: endObjectName,
|
|
242
|
+
},
|
|
243
|
+
};
|
|
244
|
+
return middleObject;
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
export const getMiddleObjectFilter = (fieldDefinition, instanceId) => {
|
|
248
|
+
const filterProperty = `${fieldDefinition.relatedPropertyId}.id`;
|
|
249
|
+
const filter = { where: { [filterProperty]: instanceId } };
|
|
250
|
+
return filter;
|
|
251
|
+
};
|
|
252
|
+
export const encodePageSlug = (slug) => {
|
|
253
|
+
return encodeURIComponent(encodeURIComponent(slug));
|
|
254
|
+
};
|
|
255
|
+
export async function getDefaultPages(parameters, defaultPages, findDefaultPageSlugFor) {
|
|
256
|
+
let foundDefaultPages = defaultPages;
|
|
257
|
+
const relatedObjectProperties = parameters?.filter((param) => param.type === 'object');
|
|
258
|
+
if (relatedObjectProperties) {
|
|
259
|
+
foundDefaultPages = await relatedObjectProperties.reduce(async (acc, parameter) => {
|
|
260
|
+
const result = await acc;
|
|
261
|
+
if (parameter.objectId && defaultPages && defaultPages[parameter.objectId]) {
|
|
262
|
+
const slug = await findDefaultPageSlugFor(parameter.objectId);
|
|
263
|
+
if (slug) {
|
|
264
|
+
return { ...result, [parameter.objectId]: slug };
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return result;
|
|
268
|
+
}, Promise.resolve({}));
|
|
269
|
+
}
|
|
270
|
+
return { ...defaultPages, ...foundDefaultPages };
|
|
271
|
+
}
|
|
272
|
+
function compileQueryValues(query, data) {
|
|
273
|
+
if ('rules' in query && Array.isArray(query.rules)) {
|
|
274
|
+
const updatedRules = query.rules
|
|
275
|
+
.map((item) => compileQueryValues(item, data))
|
|
276
|
+
.filter((item) => item !== undefined);
|
|
277
|
+
if (updatedRules?.length) {
|
|
278
|
+
return {
|
|
279
|
+
...query,
|
|
280
|
+
rules: updatedRules,
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
return undefined;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
if ('value' in query && typeof query.value === 'string') {
|
|
289
|
+
const template = Handlebars.compileAST(query.value);
|
|
290
|
+
const result = template(data);
|
|
291
|
+
if (result !== '') {
|
|
292
|
+
return {
|
|
293
|
+
...query,
|
|
294
|
+
value: result,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
return undefined;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return query;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
export function updateCriteriaInputs(criteria, data, user) {
|
|
305
|
+
const dataSet = {
|
|
306
|
+
input: {
|
|
307
|
+
...data,
|
|
308
|
+
},
|
|
309
|
+
user: user,
|
|
310
|
+
};
|
|
311
|
+
const compiledQuery = compileQueryValues(parseMongoDB(criteria), dataSet);
|
|
312
|
+
// The "compiledQueryValues" function filters out rules that have a value of "undefined".
|
|
313
|
+
// If "compiledQuery" is "undefined", that means that all rules and nested rules have a value of "undefined".
|
|
314
|
+
// Therefore, the resulting query is empty.
|
|
315
|
+
return !compiledQuery
|
|
316
|
+
? {}
|
|
317
|
+
: JSON.parse(formatQuery(compiledQuery, {
|
|
318
|
+
format: 'mongodb',
|
|
319
|
+
ruleProcessor: (rule, options) => {
|
|
320
|
+
let updatedRule = rule;
|
|
321
|
+
if (['contains', 'beginsWith', 'endsWith'].includes(rule.operator)) {
|
|
322
|
+
updatedRule = { ...rule, value: escape(rule.value) };
|
|
323
|
+
}
|
|
324
|
+
return defaultRuleProcessorMongoDB(updatedRule, options);
|
|
325
|
+
},
|
|
326
|
+
}));
|
|
327
|
+
}
|
|
328
|
+
export async function fetchCollectionData(apiServices, fieldDefinition, setFetchedOptions, instanceId, fetchedOptions, initialMiddleObjectInstances) {
|
|
329
|
+
try {
|
|
330
|
+
if ((fetchedOptions && !fetchedOptions[`${fieldDefinition.id}MiddleObject`]) || !fetchedOptions) {
|
|
331
|
+
const fetchedMiddleObject = await apiServices.get(getPrefixedUrl(`/objects/${fieldDefinition.objectId}/effective?sanitizedVersion=true`), {
|
|
332
|
+
params: {
|
|
333
|
+
filter: { fields: ['properties', 'actions', 'rootObjectId'] },
|
|
334
|
+
},
|
|
335
|
+
});
|
|
336
|
+
setFetchedOptions({ [`${fieldDefinition.id}MiddleObject`]: fetchedMiddleObject });
|
|
337
|
+
}
|
|
338
|
+
// Fetch the initial middle object instances
|
|
339
|
+
const filter = instanceId ? getMiddleObjectFilter(fieldDefinition, instanceId) : {};
|
|
340
|
+
if (!isArray(initialMiddleObjectInstances)) {
|
|
341
|
+
const fetchedInitialMiddleObjectInstances = await apiServices.get(getPrefixedUrl(`/objects/${fieldDefinition.objectId}/instances`), {
|
|
342
|
+
params: { filter: JSON.stringify(filter) },
|
|
343
|
+
});
|
|
344
|
+
setFetchedOptions({
|
|
345
|
+
[`${fieldDefinition.id}InitialMiddleObjectInstances`]: fetchedInitialMiddleObjectInstances,
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
catch (error) {
|
|
350
|
+
console.error('Error fetching collection data:', error);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
export const getErrorCountForSection = (section, errors) => {
|
|
354
|
+
const entries = section.entries || [];
|
|
355
|
+
return isArray(section.entries)
|
|
356
|
+
? entries.reduce((count, entry) => {
|
|
357
|
+
if (get(errors, entry.type === 'input' ? entry.parameterId : entry.type === 'inputField' ? entry.input.id : '')) {
|
|
358
|
+
count += 1;
|
|
359
|
+
}
|
|
360
|
+
else if (entry.type === 'sections') {
|
|
361
|
+
count += entry.sections.reduce((subCount, subSection) => {
|
|
362
|
+
return subCount + getErrorCountForSection(subSection, errors);
|
|
363
|
+
}, 0);
|
|
364
|
+
}
|
|
365
|
+
else if (entry.type === 'columns') {
|
|
366
|
+
count += entry.columns.reduce((colCount, column) => {
|
|
367
|
+
return colCount + getErrorCountForSection(column, errors);
|
|
368
|
+
}, 0);
|
|
369
|
+
}
|
|
370
|
+
return count;
|
|
371
|
+
}, 0)
|
|
372
|
+
: 0;
|
|
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';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { ClickAwayListener, createTheme, darken, lighten, styled, Toolbar } from '@mui/material';
|
|
1
|
+
export { ClickAwayListener, createTheme, darken, lighten, styled, Toolbar, useMediaQuery, useTheme, } from '@mui/material';
|
|
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';
|
package/dist/published/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { ClickAwayListener, createTheme, darken, lighten, styled, Toolbar } from '@mui/material';
|
|
1
|
+
export { ClickAwayListener, createTheme, darken, lighten, styled, Toolbar, useMediaQuery, useTheme, } from '@mui/material';
|
|
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';
|
|
@@ -107,3 +107,10 @@ export declare const useWidgetSize: (options?: {
|
|
|
107
107
|
resize?: boolean;
|
|
108
108
|
}) => WidgetSizeInfo;
|
|
109
109
|
export default useWidgetSize;
|
|
110
|
+
export declare function useFormContext(): {
|
|
111
|
+
fetchedOptions: import("react-hook-form").FieldValues;
|
|
112
|
+
setFetchedOptions: (newData: import("react-hook-form").FieldValues) => void;
|
|
113
|
+
getValues: import("react-hook-form").UseFormGetValues<import("react-hook-form").FieldValues>;
|
|
114
|
+
stickyFooter?: boolean | undefined;
|
|
115
|
+
object?: import("@evoke-platform/context").Obj | undefined;
|
|
116
|
+
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { useTheme } from '@mui/material';
|
|
2
2
|
import useMediaQuery from '@mui/material/useMediaQuery';
|
|
3
|
+
import { useContext } from 'react';
|
|
3
4
|
import useMeasure from 'react-use-measure';
|
|
5
|
+
import { FormContext } from '../components/custom/FormV2/components/FormContext';
|
|
4
6
|
/**
|
|
5
7
|
* Custom hook for responsive design breakpoints using size terminology.
|
|
6
8
|
* Breakpoints based on MUI default theme:
|
|
@@ -98,3 +100,10 @@ export const useWidgetSize = (options) => {
|
|
|
98
100
|
};
|
|
99
101
|
};
|
|
100
102
|
export default useWidgetSize;
|
|
103
|
+
export function useFormContext() {
|
|
104
|
+
const context = useContext(FormContext);
|
|
105
|
+
if (!context) {
|
|
106
|
+
throw new Error('useFormContext must be used within a FormContext.Provider');
|
|
107
|
+
}
|
|
108
|
+
return context;
|
|
109
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evoke-platform/ui-components",
|
|
3
|
-
"version": "1.6.0-testing.
|
|
3
|
+
"version": "1.6.0-testing.14",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/published/index.js",
|
|
6
6
|
"module": "dist/published/index.js",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"@testing-library/user-event": "^14.5.2",
|
|
55
55
|
"@types/flat": "^5.0.5",
|
|
56
56
|
"@types/jest": "^28.1.4",
|
|
57
|
+
"@types/json-logic-js": "^2.0.8",
|
|
57
58
|
"@types/luxon": "^3.4.2",
|
|
58
59
|
"@types/nanoid-dictionary": "^4.2.3",
|
|
59
60
|
"@types/node": "^18.0.0",
|
|
@@ -86,7 +87,7 @@
|
|
|
86
87
|
"yalc": "^1.0.0-pre.53"
|
|
87
88
|
},
|
|
88
89
|
"peerDependencies": {
|
|
89
|
-
"@evoke-platform/context": "^1.3.0-
|
|
90
|
+
"@evoke-platform/context": "^1.3.0-dev.6",
|
|
90
91
|
"react": "^18.1.0",
|
|
91
92
|
"react-dom": "^18.1.0"
|
|
92
93
|
},
|
|
@@ -125,6 +126,7 @@
|
|
|
125
126
|
"pluralize": "^8.0.0",
|
|
126
127
|
"pretty-bytes": "^6.1.1",
|
|
127
128
|
"react-dropzone": "^14.2.2",
|
|
129
|
+
"react-hook-form": "^7.60.0",
|
|
128
130
|
"react-input-mask": "^2.0.4",
|
|
129
131
|
"react-number-format": "^4.9.3",
|
|
130
132
|
"react-querybuilder": "^6.0.2",
|