@react-typed-forms/schemas 15.2.0 → 16.0.0

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/lib/index.js CHANGED
@@ -1,545 +1,9 @@
1
- import { newControl, getElementIndex, ensureMetaValue, ControlChange, useControl, useComputed, useRefState, SubscriptionTracker, addAfterChangesCallback, trackedValue, collectChanges, useCalculatedControl, useValueChangeEffect, useValidator, useComponentTracking, useControlEffect, removeElement, RenderArrayElements, addElement } from '@react-typed-forms/core';
2
- import { useRef, useMemo, useCallback, useEffect } from 'react';
1
+ import { isCompoundField, findField, getTagParam, SchemaTags, ControlDefinitionType, isScalarField, DataRenderType, isDataControl, isGroupControl, createSchemaTree, relativePath, isCompoundNode, fieldPathForDefinition, schemaForFieldPath, isCheckEntryClasses, isGridRenderer, isAutoCompleteClasses, getGroupRendererOptions, ValidatorType, ControlAdornmentType, DisplayDataType, DynamicPropertyType, ExpressionType, GroupRenderType, mergeFields, resolveSchemas, isActionControl, ActionStyle, isDisplayControl, AdornmentPlacement, lookupDataNode, defaultSchemaInterface, createFormState, legacyFormNode, createSchemaDataNode } from '@astroapps/forms-core';
2
+ export * from '@astroapps/forms-core';
3
+ import { useRef, useMemo, useState, useEffect, useCallback } from 'react';
3
4
  import clsx from 'clsx';
4
- import jsonata from 'jsonata';
5
- import { v4 } from 'uuid';
6
- import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
7
-
8
- /**
9
- * Enum representing the various field types.
10
- */
11
- var FieldType;
12
- (function (FieldType) {
13
- FieldType["String"] = "String";
14
- FieldType["Bool"] = "Bool";
15
- FieldType["Int"] = "Int";
16
- FieldType["Date"] = "Date";
17
- FieldType["DateTime"] = "DateTime";
18
- FieldType["Time"] = "Time";
19
- FieldType["Double"] = "Double";
20
- FieldType["EntityRef"] = "EntityRef";
21
- FieldType["Compound"] = "Compound";
22
- FieldType["AutoId"] = "AutoId";
23
- FieldType["Image"] = "Image";
24
- FieldType["Any"] = "Any";
25
- })(FieldType || (FieldType = {}));
26
- /**
27
- * Enum representing the various validation message types.
28
- */
29
- var ValidationMessageType;
30
- (function (ValidationMessageType) {
31
- ValidationMessageType["NotEmpty"] = "NotEmpty";
32
- ValidationMessageType["MinLength"] = "MinLength";
33
- ValidationMessageType["MaxLength"] = "MaxLength";
34
- ValidationMessageType["NotAfterDate"] = "NotAfterDate";
35
- ValidationMessageType["NotBeforeDate"] = "NotBeforeDate";
36
- })(ValidationMessageType || (ValidationMessageType = {}));
37
- function findField(fields, field) {
38
- return fields.find(x => x.field === field);
39
- }
40
- function isScalarField(sf) {
41
- return !isCompoundField(sf);
42
- }
43
- function isCompoundField(sf) {
44
- return sf.type === FieldType.Compound;
45
- }
46
- function missingField(field) {
47
- return {
48
- field: "__missing",
49
- type: FieldType.Any,
50
- displayName: field
51
- };
52
- }
53
- function nodeForSchema(field, lookup, parent) {
54
- const node = {
55
- id: parent ? parent.id + "/" + field.field : field.field,
56
- field,
57
- getSchema: lookup.getSchema,
58
- parent,
59
- getChildNode,
60
- getChildNodes
61
- };
62
- return node;
63
- function getChildNode(fieldName) {
64
- if (isCompoundField(field) && !field.schemaRef && !field.treeChildren) {
65
- const childField = field.children.find(x => x.field === fieldName);
66
- return childField ? nodeForSchema(childField, lookup, node) : undefined;
67
- }
68
- return getChildNodes(false, node).find(x => x.field.field === fieldName);
69
- }
70
- function getChildNodes(noRecurse, withParent) {
71
- if (isCompoundField(field)) {
72
- if (field.treeChildren) {
73
- return noRecurse ? [] : parent.getChildNodes(false, withParent != null ? withParent : node);
74
- }
75
- const otherRef = field.schemaRef && lookup.getSchema(field.schemaRef);
76
- if (otherRef) return otherRef.getChildNodes(false, withParent != null ? withParent : node);
77
- return field.children.map(x => nodeForSchema(x, lookup, withParent != null ? withParent : node));
78
- }
79
- return [];
80
- }
81
- }
82
- function createSchemaLookup(schemaMap) {
83
- const lookup = {
84
- getSchema
85
- };
86
- return lookup;
87
- function getSchema(schemaId) {
88
- const fields = schemaMap[schemaId];
89
- if (fields) {
90
- return rootSchemaNode(fields, lookup);
91
- }
92
- return undefined;
93
- }
94
- }
95
- function makeSchemaDataNode(schema, control, parent, elementIndex) {
96
- const indexId = typeof elementIndex === "number" ? "/" + elementIndex : "";
97
- const dataNode = {
98
- id: (parent ? parent.id + "/" + schema.field.field : schema.field.field) + indexId,
99
- schema,
100
- control,
101
- parent,
102
- elementIndex,
103
- getChild,
104
- getChildElement
105
- };
106
- return dataNode;
107
- function getChild(childNode) {
108
- const objControl = control;
109
- if (objControl && objControl.current.isNull) {
110
- objControl.value = {};
111
- }
112
- return makeSchemaDataNode(childNode, objControl == null ? void 0 : objControl.fields[childNode.field.field], dataNode);
113
- }
114
- function getChildElement(elementIndex) {
115
- var _control$elements;
116
- return makeSchemaDataNode(schema, control == null || (_control$elements = control.elements) == null ? void 0 : _control$elements[elementIndex], dataNode, elementIndex);
117
- }
118
- }
119
- function schemaDataForFieldRef(fieldRef, schema) {
120
- var _fieldRef$split;
121
- return schemaDataForFieldPath((_fieldRef$split = fieldRef == null ? void 0 : fieldRef.split("/")) != null ? _fieldRef$split : [], schema);
122
- }
123
- function schemaForFieldRef(fieldRef, schema) {
124
- var _fieldRef$split2;
125
- return schemaForFieldPath((_fieldRef$split2 = fieldRef == null ? void 0 : fieldRef.split("/")) != null ? _fieldRef$split2 : [], schema);
126
- }
127
- function traverseSchemaPath(fieldPath, schema, acc, next) {
128
- let i = 0;
129
- while (i < fieldPath.length) {
130
- const nextField = fieldPath[i];
131
- let childNode = nextField === ".." ? schema.parent : schema.getChildNode(nextField);
132
- if (!childNode) {
133
- childNode = nodeForSchema(missingField(nextField), schema, schema);
134
- }
135
- acc = next(acc, childNode);
136
- schema = childNode;
137
- i++;
138
- }
139
- return acc;
140
- }
141
- function traverseData(fieldPath, root, data) {
142
- return traverseSchemaPath(fieldPath, root, data, (acc, n) => acc == null ? void 0 : acc[n.field.field]);
143
- }
144
- function schemaDataForFieldPath(fieldPath, dataNode) {
145
- let i = 0;
146
- while (i < fieldPath.length) {
147
- var _nextNode;
148
- const nextField = fieldPath[i];
149
- let nextNode = nextField === ".." ? dataNode.parent : lookupField(nextField);
150
- (_nextNode = nextNode) != null ? _nextNode : nextNode = makeSchemaDataNode(nodeForSchema(missingField(nextField), dataNode.schema, dataNode.schema), newControl(undefined));
151
- dataNode = nextNode;
152
- i++;
153
- }
154
- return dataNode;
155
- function lookupField(field) {
156
- const childNode = dataNode.schema.getChildNode(field);
157
- if (childNode) {
158
- return dataNode.getChild(childNode);
159
- }
160
- return undefined;
161
- }
162
- }
163
- function schemaForFieldPath(fieldPath, schema) {
164
- let i = 0;
165
- while (i < fieldPath.length) {
166
- const nextField = fieldPath[i];
167
- let childNode = nextField === ".." ? schema.parent : schema.getChildNode(nextField);
168
- if (!childNode) {
169
- childNode = nodeForSchema(missingField(nextField), schema, schema);
170
- }
171
- schema = childNode;
172
- i++;
173
- }
174
- return schema;
175
- }
176
- function rootSchemaNode(fields, lookup = {
177
- getSchema(schemaId) {
178
- return undefined;
179
- }
180
- }) {
181
- return nodeForSchema({
182
- type: FieldType.Compound,
183
- field: "",
184
- children: fields
185
- }, lookup, undefined);
186
- }
187
- function getSchemaNodePath(node) {
188
- const paths = [];
189
- let curNode = node;
190
- while (curNode) {
191
- paths.push(curNode.field.field);
192
- curNode = curNode.parent;
193
- }
194
- return paths.reverse();
195
- }
196
- function isCompoundNode(node) {
197
- return isCompoundField(node.field);
198
- }
199
- /**
200
- * Returns the relative path from a parent node to a child node.
201
- * @param parent
202
- * @param child
203
- */
204
- function relativePath(parent, child) {
205
- // return the path from child to parent
206
- if (parent.id === child.id) return "";
207
- const parentPath = getSchemaNodePath(parent);
208
- const childPath = getSchemaNodePath(child);
209
- let i = 0;
210
- while (i < parentPath.length && i < childPath.length && parentPath[i] === childPath[i]) {
211
- i++;
212
- }
213
- const upLevels = parentPath.length - i;
214
- const downPath = childPath.slice(i).join("/");
215
- return "../".repeat(upLevels) + downPath;
216
- }
217
- var SchemaTags;
218
- (function (SchemaTags) {
219
- SchemaTags["NoControl"] = "_NoControl";
220
- SchemaTags["HtmlEditor"] = "_HtmlEditor";
221
- SchemaTags["ControlGroup"] = "_ControlGroup:";
222
- SchemaTags["ControlRef"] = "_ControlRef:";
223
- SchemaTags["IdField"] = "_IdField:";
224
- })(SchemaTags || (SchemaTags = {}));
225
- function getTagParam(field, tag) {
226
- var _field$tags;
227
- return (_field$tags = field.tags) == null || (_field$tags = _field$tags.find(x => x.startsWith(tag))) == null ? void 0 : _field$tags.substring(tag.length);
228
- }
229
- function makeParamTag(tag, value) {
230
- return `${tag}${value}`;
231
- }
232
-
233
- var ControlDefinitionType;
234
- (function (ControlDefinitionType) {
235
- ControlDefinitionType["Data"] = "Data";
236
- ControlDefinitionType["Group"] = "Group";
237
- ControlDefinitionType["Display"] = "Display";
238
- ControlDefinitionType["Action"] = "Action";
239
- })(ControlDefinitionType || (ControlDefinitionType = {}));
240
- var DynamicPropertyType;
241
- (function (DynamicPropertyType) {
242
- DynamicPropertyType["Visible"] = "Visible";
243
- DynamicPropertyType["DefaultValue"] = "DefaultValue";
244
- DynamicPropertyType["Readonly"] = "Readonly";
245
- DynamicPropertyType["Disabled"] = "Disabled";
246
- DynamicPropertyType["Display"] = "Display";
247
- DynamicPropertyType["Style"] = "Style";
248
- DynamicPropertyType["LayoutStyle"] = "LayoutStyle";
249
- DynamicPropertyType["AllowedOptions"] = "AllowedOptions";
250
- DynamicPropertyType["Label"] = "Label";
251
- DynamicPropertyType["ActionData"] = "ActionData";
252
- })(DynamicPropertyType || (DynamicPropertyType = {}));
253
- var AdornmentPlacement;
254
- (function (AdornmentPlacement) {
255
- AdornmentPlacement["ControlStart"] = "ControlStart";
256
- AdornmentPlacement["ControlEnd"] = "ControlEnd";
257
- AdornmentPlacement["LabelStart"] = "LabelStart";
258
- AdornmentPlacement["LabelEnd"] = "LabelEnd";
259
- })(AdornmentPlacement || (AdornmentPlacement = {}));
260
- var ControlAdornmentType;
261
- (function (ControlAdornmentType) {
262
- ControlAdornmentType["Tooltip"] = "Tooltip";
263
- ControlAdornmentType["Accordion"] = "Accordion";
264
- ControlAdornmentType["HelpText"] = "HelpText";
265
- ControlAdornmentType["Icon"] = "Icon";
266
- ControlAdornmentType["SetField"] = "SetField";
267
- ControlAdornmentType["Optional"] = "Optional";
268
- })(ControlAdornmentType || (ControlAdornmentType = {}));
269
- var DataRenderType;
270
- (function (DataRenderType) {
271
- DataRenderType["Standard"] = "Standard";
272
- DataRenderType["Textfield"] = "Textfield";
273
- DataRenderType["Radio"] = "Radio";
274
- DataRenderType["HtmlEditor"] = "HtmlEditor";
275
- DataRenderType["IconList"] = "IconList";
276
- DataRenderType["CheckList"] = "CheckList";
277
- DataRenderType["UserSelection"] = "UserSelection";
278
- DataRenderType["Synchronised"] = "Synchronised";
279
- DataRenderType["IconSelector"] = "IconSelector";
280
- DataRenderType["DateTime"] = "DateTime";
281
- DataRenderType["Checkbox"] = "Checkbox";
282
- DataRenderType["Dropdown"] = "Dropdown";
283
- DataRenderType["DisplayOnly"] = "DisplayOnly";
284
- DataRenderType["Group"] = "Group";
285
- DataRenderType["NullToggle"] = "NullToggle";
286
- DataRenderType["Autocomplete"] = "Autocomplete";
287
- DataRenderType["Jsonata"] = "Jsonata";
288
- DataRenderType["Array"] = "Array";
289
- DataRenderType["ArrayElement"] = "ArrayElement";
290
- })(DataRenderType || (DataRenderType = {}));
291
- var SyncTextType;
292
- (function (SyncTextType) {
293
- SyncTextType["Camel"] = "Camel";
294
- SyncTextType["Snake"] = "Snake";
295
- SyncTextType["Pascal"] = "Pascal";
296
- })(SyncTextType || (SyncTextType = {}));
297
- var GroupRenderType;
298
- (function (GroupRenderType) {
299
- GroupRenderType["Standard"] = "Standard";
300
- GroupRenderType["Grid"] = "Grid";
301
- GroupRenderType["Flex"] = "Flex";
302
- GroupRenderType["Tabs"] = "Tabs";
303
- GroupRenderType["GroupElement"] = "GroupElement";
304
- GroupRenderType["SelectChild"] = "SelectChild";
305
- })(GroupRenderType || (GroupRenderType = {}));
306
- var DisplayDataType;
307
- (function (DisplayDataType) {
308
- DisplayDataType["Text"] = "Text";
309
- DisplayDataType["Html"] = "Html";
310
- DisplayDataType["Icon"] = "Icon";
311
- DisplayDataType["Custom"] = "Custom";
312
- })(DisplayDataType || (DisplayDataType = {}));
313
- function visitControlDefinition(x, visitor, defaultValue) {
314
- switch (x.type) {
315
- case ControlDefinitionType.Action:
316
- return visitor.action(x);
317
- case ControlDefinitionType.Data:
318
- return visitor.data(x);
319
- case ControlDefinitionType.Display:
320
- return visitor.display(x);
321
- case ControlDefinitionType.Group:
322
- return visitor.group(x);
323
- default:
324
- return defaultValue(x);
325
- }
326
- }
327
- function isGridRenderer(options) {
328
- return options.type === GroupRenderType.Grid;
329
- }
330
- function isSelectChildRenderer(options) {
331
- return options.type === GroupRenderType.SelectChild;
332
- }
333
- function isTabsRenderer(options) {
334
- return options.type === GroupRenderType.Tabs;
335
- }
336
- function isFlexRenderer(options) {
337
- return options.type === GroupRenderType.Flex;
338
- }
339
- function isDisplayOnlyRenderer(options) {
340
- return options.type === DataRenderType.DisplayOnly;
341
- }
342
- function isTextfieldRenderer(options) {
343
- return options.type === DataRenderType.Textfield;
344
- }
345
- function isDateTimeRenderer(options) {
346
- return options.type === DataRenderType.DateTime;
347
- }
348
- function isAutocompleteRenderer(options) {
349
- return options.type === DataRenderType.Autocomplete;
350
- }
351
- function isAutoCompleteClasses(options) {
352
- switch (options == null ? void 0 : options.type) {
353
- case DataRenderType.Autocomplete:
354
- return true;
355
- default:
356
- return false;
357
- }
358
- }
359
- function isDataGroupRenderer(options) {
360
- return (options == null ? void 0 : options.type) === DataRenderType.Group;
361
- }
362
- function isArrayRenderer(options) {
363
- return options.type === DataRenderType.Array;
364
- }
365
- function isDataControl(c) {
366
- return c.type === ControlDefinitionType.Data;
367
- }
368
- function isGroupControl(c) {
369
- return c.type === ControlDefinitionType.Group;
370
- }
371
- function isActionControl(c) {
372
- return c.type === ControlDefinitionType.Action;
373
- }
374
- function isDisplayControl(c) {
375
- return c.type === ControlDefinitionType.Display;
376
- }
377
- function isCheckEntryClasses(options) {
378
- switch (options == null ? void 0 : options.type) {
379
- case DataRenderType.Radio:
380
- case DataRenderType.CheckList:
381
- return true;
382
- default:
383
- return false;
384
- }
385
- }
386
- class FormNodeImpl {
387
- constructor(id, definition, tree, parent) {
388
- this.id = void 0;
389
- this.definition = void 0;
390
- this.tree = void 0;
391
- this.parent = void 0;
392
- this.children = [];
393
- this.id = id;
394
- this.definition = definition;
395
- this.tree = tree;
396
- this.parent = parent;
397
- }
398
- getChildNodes() {
399
- return this.children;
400
- }
401
- }
402
- class FormTree {
403
- createTempNode(id, definition, children, parent) {
404
- const tempNode = {
405
- id,
406
- definition,
407
- tree: this,
408
- parent,
409
- getChildNodes: () => children != null ? children : this.createChildNodes(tempNode, definition.children)
410
- };
411
- return tempNode;
412
- }
413
- createChildNodes(parent, definitions) {
414
- var _definitions$map;
415
- return (_definitions$map = definitions == null ? void 0 : definitions.map((x, i) => this.createTempNode(parent.id + "_" + i, x, undefined, parent))) != null ? _definitions$map : [];
416
- }
417
- }
418
- class FormTreeImpl extends FormTree {
419
- constructor(forms) {
420
- super();
421
- this.forms = void 0;
422
- this.controlMap = {};
423
- this.rootNode = void 0;
424
- this.idCount = 1;
425
- this.forms = forms;
426
- this.rootNode = new FormNodeImpl("", {
427
- type: "Group"
428
- }, this);
429
- }
430
- getByRefId(id) {
431
- return this.controlMap[id];
432
- }
433
- register(node) {
434
- this.controlMap[node.id] = node;
435
- node.getChildNodes().forEach(x => this.register(x));
436
- }
437
- addChild(parent, control) {
438
- var _control$children;
439
- const node = new FormNodeImpl(control.id ? control.id : "c" + this.idCount++, control, this, parent);
440
- (_control$children = control.children) == null || _control$children.forEach(x => this.addChild(node, x));
441
- parent.getChildNodes().push(node);
442
- this.register(node);
443
- return node;
444
- }
445
- getForm(formId) {
446
- return this.forms.getForm(formId);
447
- }
448
- }
449
- function legacyFormNode(definition) {
450
- return createFormTree([definition]).rootNode.getChildNodes()[0];
451
- }
452
- function createFormTree(controls, getForm = {
453
- getForm: () => undefined
454
- }) {
455
- const tree = new FormTreeImpl(getForm);
456
- controls.forEach(x => tree.addChild(tree.rootNode, x));
457
- return tree;
458
- }
459
- function createFormLookup(formMap) {
460
- const lookup = {
461
- getForm
462
- };
463
- const forms = Object.fromEntries(Object.entries(formMap).map(([k, v]) => [k, createFormTree(v, lookup)]));
464
- return lookup;
465
- function getForm(formId) {
466
- return forms[formId];
467
- }
468
- }
469
- function fieldPathForDefinition(c) {
470
- const fieldName = isGroupControl(c) ? c.compoundField : isDataControl(c) ? c.field : undefined;
471
- return fieldName == null ? void 0 : fieldName.split("/");
472
- }
473
- function lookupDataNode(c, parentNode) {
474
- const fieldNamePath = fieldPathForDefinition(c);
475
- return fieldNamePath ? schemaDataForFieldPath(fieldNamePath, parentNode) : undefined;
476
- }
477
- function traverseParents(current, get, until) {
478
- let outArray = [];
479
- while (current && !(until != null && until(current))) {
480
- outArray.push(get(current));
481
- current = current.parent;
482
- }
483
- return outArray.reverse();
484
- }
485
- function getRootDataNode(dataNode) {
486
- while (dataNode.parent) {
487
- dataNode = dataNode.parent;
488
- }
489
- return dataNode;
490
- }
491
- function getJsonPath(dataNode) {
492
- return traverseParents(dataNode, d => d.elementIndex == null ? d.schema.field.field : d.elementIndex, x => !x.parent);
493
- }
494
- function getSchemaPath(schemaNode) {
495
- return traverseParents(schemaNode, d => d.field, x => !x.parent);
496
- }
497
- function getSchemaFieldList(schema) {
498
- return schema.getChildNodes().map(x => x.field);
499
- }
500
- /**
501
- * @deprecated use visitFormNodeData instead
502
- */
503
- function visitControlDataArray(controls, context, cb) {
504
- if (!controls) return undefined;
505
- for (const c of controls) {
506
- const r = visitControlData(c, context, cb);
507
- if (r !== undefined) return r;
508
- }
509
- return undefined;
510
- }
511
- /**
512
- * @deprecated use visitFormDataInContext instead
513
- */
514
- function visitControlData(definition, ctx, cb) {
515
- return visitFormDataInContext(ctx, legacyFormNode(definition), (n, d) => cb(d, n));
516
- }
517
- function visitFormData(node, dataNode, cb, notSelf) {
518
- const def = node.definition;
519
- const result = !notSelf && isDataControl(def) ? cb(dataNode, def) : undefined;
520
- if (result !== undefined) return result;
521
- if (dataNode.elementIndex == null && dataNode.schema.field.collection) {
522
- const _l = dataNode.control.elements.length;
523
- for (let i = 0; i < _l; i++) {
524
- const elemChild = dataNode.getChildElement(i);
525
- const elemResult = visitFormData(node, elemChild, cb);
526
- if (elemResult !== undefined) return elemResult;
527
- }
528
- return undefined;
529
- }
530
- if (dataNode.control.isNull) return undefined;
531
- const children = node.getChildNodes();
532
- const l = children.length;
533
- for (let i = 0; i < l; i++) {
534
- const elemResult = visitFormDataInContext(dataNode, children[i], cb);
535
- if (elemResult !== undefined) return elemResult;
536
- }
537
- return undefined;
538
- }
539
- function visitFormDataInContext(parentContext, node, cb) {
540
- const dataNode = lookupDataNode(node.definition, parentContext);
541
- return visitFormData(node, dataNode != null ? dataNode : parentContext, cb, !dataNode);
542
- }
5
+ import { getElementIndex, ensureMetaValue, newControl, ControlChange, useControl, createScopedEffect, removeElement, RenderArrayElements, addElement, useComponentTracking } from '@react-typed-forms/core';
6
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
543
7
 
544
8
  function _extends() {
545
9
  return _extends = Object.assign ? Object.assign.bind() : function (n) {
@@ -560,143 +24,6 @@ function _objectWithoutPropertiesLoose(r, e) {
560
24
  return t;
561
25
  }
562
26
 
563
- function buildSchema(def) {
564
- return Object.entries(def).map(x => x[1](x[0]));
565
- }
566
- function stringField(displayName, options) {
567
- return makeScalarField(_extends({
568
- type: FieldType.String,
569
- displayName
570
- }, options));
571
- }
572
- function stringOptionsField(displayName, ...options) {
573
- return makeScalarField({
574
- type: FieldType.String,
575
- displayName,
576
- options
577
- });
578
- }
579
- function withScalarOptions(options, v) {
580
- return n => _extends({}, v(n), options);
581
- }
582
- function makeScalarField(options) {
583
- return n => _extends({}, defaultScalarField(n, n), options);
584
- }
585
- function makeCompoundField(options) {
586
- return n => _extends({}, defaultCompoundField(n, n, false), options);
587
- }
588
- function intField(displayName, options) {
589
- return makeScalarField(_extends({
590
- type: FieldType.Int,
591
- displayName
592
- }, options));
593
- }
594
- function doubleField(displayName, options) {
595
- return makeScalarField(_extends({
596
- type: FieldType.Double,
597
- displayName
598
- }, options));
599
- }
600
- function dateField(displayName, options) {
601
- return makeScalarField(_extends({
602
- type: FieldType.Date,
603
- displayName
604
- }, options));
605
- }
606
- function timeField(displayName, options) {
607
- return makeScalarField(_extends({
608
- type: FieldType.Time,
609
- displayName
610
- }, options));
611
- }
612
- function dateTimeField(displayName, options) {
613
- return makeScalarField(_extends({
614
- type: FieldType.DateTime,
615
- displayName
616
- }, options));
617
- }
618
- function boolField(displayName, options) {
619
- return makeScalarField(_extends({
620
- type: FieldType.Bool,
621
- displayName
622
- }, options));
623
- }
624
- function compoundField(displayName, fields, other) {
625
- return field => _extends({}, defaultCompoundField(field, displayName, false), other, {
626
- children: fields
627
- });
628
- }
629
- function defaultScalarField(field, displayName) {
630
- return {
631
- field,
632
- displayName,
633
- type: FieldType.String
634
- };
635
- }
636
- function defaultCompoundField(field, displayName, collection) {
637
- return {
638
- field,
639
- displayName,
640
- type: FieldType.Compound,
641
- collection,
642
- children: []
643
- };
644
- }
645
- function mergeField(field, mergeInto) {
646
- const existing = mergeInto.find(x => x.field === field.field);
647
- if (existing) {
648
- return mergeInto.map(x => x !== existing ? x : _extends({}, x, {
649
- onlyForTypes: mergeTypes(x.onlyForTypes, field.onlyForTypes)
650
- }));
651
- }
652
- return [...mergeInto, field];
653
- function mergeTypes(f, s) {
654
- if (!f) return s;
655
- if (!s) return f;
656
- const extras = s.filter(x => !f.includes(x));
657
- return extras.length ? [...f, ...extras] : f;
658
- }
659
- }
660
- function mergeFields(fields, name, value, newFields) {
661
- const withType = fields.map(x => x.isTypeField ? addFieldOption(x, name, value) : x);
662
- return newFields.map(x => _extends({}, x, {
663
- onlyForTypes: [value]
664
- })).reduce((af, x) => mergeField(x, af), withType);
665
- }
666
- function addFieldOption(typeField, name, value) {
667
- var _typeField$options;
668
- const options = (_typeField$options = typeField.options) != null ? _typeField$options : [];
669
- if (options.some(x => x.value === value)) return typeField;
670
- return _extends({}, typeField, {
671
- options: [...options, {
672
- name,
673
- value
674
- }]
675
- });
676
- }
677
- function resolveSchemas(schemaMap) {
678
- const out = {};
679
- function resolveSchemaType(type) {
680
- if (type in out) {
681
- return out[type];
682
- }
683
- const resolvedFields = [];
684
- out[type] = resolvedFields;
685
- schemaMap[type].forEach(x => {
686
- if (isCompoundField(x) && x.schemaRef) {
687
- resolvedFields.push(_extends({}, x, {
688
- children: resolveSchemaType(x.schemaRef)
689
- }));
690
- } else {
691
- resolvedFields.push(x);
692
- }
693
- });
694
- return resolvedFields;
695
- }
696
- Object.keys(schemaMap).forEach(resolveSchemaType);
697
- return out;
698
- }
699
-
700
27
  /**
701
28
  * Applies default values to the given record based on the provided schema fields.
702
29
  * @param v - The record to apply default values to.
@@ -756,7 +83,8 @@ function defaultValueForField(sf, required) {
756
83
  const isRequired = !!(required || sf.required);
757
84
  if (isCompoundField(sf)) {
758
85
  if (isRequired) {
759
- const childValue = defaultValueForFields(sf.children);
86
+ var _sf$children;
87
+ const childValue = defaultValueForFields((_sf$children = sf.children) != null ? _sf$children : []);
760
88
  return sf.collection ? [childValue] : childValue;
761
89
  }
762
90
  return sf.notNullable ? sf.collection ? [] : {} : undefined;
@@ -773,7 +101,8 @@ function defaultValueForField(sf, required) {
773
101
  */
774
102
  function elementValueForField(sf) {
775
103
  if (isCompoundField(sf)) {
776
- return defaultValueForFields(sf.children);
104
+ var _sf$children2;
105
+ return defaultValueForFields((_sf$children2 = sf.children) != null ? _sf$children2 : []);
777
106
  }
778
107
  return sf.defaultValue;
779
108
  }
@@ -884,34 +213,7 @@ function findNonDataGroups(controls) {
884
213
  * @returns The control definitions with missing controls added.
885
214
  */
886
215
  function addMissingControls(fields, controls, warning) {
887
- return addMissingControlsForSchema(rootSchemaNode(fields), controls, warning);
888
- }
889
- function registerSchemaEntries(formNode, parentSchema) {
890
- const formToSchema = {};
891
- const schemaToForm = {};
892
- function register(node, parentSchema) {
893
- const c = node.definition;
894
- const controlPath = fieldPathForDefinition(c);
895
- let dataSchema = controlPath ? schemaForFieldPath(controlPath, parentSchema) : undefined;
896
- if (isGroupControl(c) && dataSchema == null) dataSchema = parentSchema;
897
- if (dataSchema) {
898
- var _schemaToForm$dataSch;
899
- formToSchema[node.id] = dataSchema;
900
- const formNodes = (_schemaToForm$dataSch = schemaToForm[dataSchema.id]) != null ? _schemaToForm$dataSch : [];
901
- formNodes.push(node);
902
- schemaToForm[dataSchema.id] = formNodes;
903
- }
904
- node.getChildNodes().forEach(x => {
905
- var _dataSchema;
906
- return register(x, (_dataSchema = dataSchema) != null ? _dataSchema : parentSchema);
907
- });
908
- }
909
- register(formNode, parentSchema);
910
- return {
911
- formToSchema,
912
- schemaToForm,
913
- register
914
- };
216
+ return addMissingControlsForSchema(createSchemaTree(fields).rootNode, controls, warning);
915
217
  }
916
218
  /**
917
219
  * Adds missing controls to the provided control definitions based on the schema fields.
@@ -921,60 +223,51 @@ function registerSchemaEntries(formNode, parentSchema) {
921
223
  * @returns The control definitions with missing controls added.
922
224
  */
923
225
  function addMissingControlsForSchema(schema, controls, warning) {
924
- var _toDefinition$childre;
925
- const tree = createFormTree(controls);
926
- addMissingControlsToForm(schema, tree, warning);
927
- return (_toDefinition$childre = toDefinition(tree.rootNode).children) != null ? _toDefinition$childre : [];
226
+ const controlMap = {};
227
+ const schemaControlMap = {};
228
+ const rootControls = controls.map(c => toControlAndSchema(c, schema));
229
+ const rootSchema = {
230
+ schema,
231
+ children: rootControls
232
+ };
233
+ addSchemaMapEntry("", rootSchema);
234
+ rootControls.forEach(addReferences);
235
+ const fields = schema.getChildNodes();
236
+ fields.forEach(addMissing);
237
+ return rootControls.map(toDefinition);
928
238
  function toDefinition(c) {
929
- const children = c.getChildNodes().length ? c.getChildNodes().map(toDefinition) : null;
930
- return _extends({}, c.definition, {
239
+ const children = c.children.length ? c.children.map(toDefinition) : null;
240
+ return _extends({}, c.control, {
931
241
  children
932
242
  });
933
243
  }
934
- }
935
- /**
936
- * Adds missing controls to the provided form tree based on the schema fields.
937
- * @param schema - The root schema node to use for adding missing controls.
938
- * @param tree - The form tree to add missing controls to.
939
- * @param warning - An optional function to call with warning messages.
940
- */
941
- function addMissingControlsToForm(schema, tree, warning) {
942
- const {
943
- formToSchema,
944
- schemaToForm,
945
- register
946
- } = registerSchemaEntries(tree.rootNode, schema);
947
- schema.getChildNodes().forEach(addMissing);
948
- return;
949
244
  function addMissing(schemaNode) {
950
245
  if (fieldHasTag(schemaNode.field, SchemaTags.NoControl)) return;
951
246
  let skipChildren = false;
952
- const existingControls = schemaToForm[schemaNode.id];
247
+ const existingControls = schemaControlMap[schemaNode.id];
953
248
  if (!existingControls) {
954
249
  const eligibleParents = getEligibleParents(schemaNode);
955
250
  const desiredGroup = getTagParam(schemaNode.field, SchemaTags.ControlGroup);
956
- let parentGroup = desiredGroup ? tree.getByRefId(desiredGroup) : undefined;
251
+ let parentGroup = desiredGroup ? controlMap[desiredGroup] : undefined;
957
252
  if (!parentGroup && desiredGroup) warning == null || warning("No group '" + desiredGroup + "' for " + schemaNode.id);
958
- if (parentGroup && eligibleParents.indexOf(formToSchema[parentGroup.id].id) < 0) {
253
+ if (parentGroup && eligibleParents.indexOf(parentGroup.schema.id) < 0) {
959
254
  warning == null || warning(`Target group '${desiredGroup}' is not an eligible parent for '${schemaNode.id}'`);
960
255
  parentGroup = undefined;
961
256
  }
962
257
  if (!parentGroup && eligibleParents.length) {
963
- var _schemaToForm$eligibl;
964
- parentGroup = (_schemaToForm$eligibl = schemaToForm[eligibleParents[0]]) == null ? void 0 : _schemaToForm$eligibl[0];
258
+ var _schemaControlMap$eli;
259
+ parentGroup = (_schemaControlMap$eli = schemaControlMap[eligibleParents[0]]) == null ? void 0 : _schemaControlMap$eli[0];
965
260
  }
966
261
  if (parentGroup) {
967
262
  const newControl = defaultControlForField(schemaNode.field, true);
968
263
  skipChildren = !!newControl.childRefId;
969
- const parentSchemaNode = formToSchema[parentGroup.id];
970
- newControl.field = relativePath(parentSchemaNode, schemaNode);
971
- const newNode = tree.addChild(parentGroup, newControl);
972
- register(newNode, parentSchemaNode);
264
+ newControl.field = relativePath(parentGroup.schema, schemaNode);
265
+ parentGroup.children.push(toControlAndSchema(newControl, parentGroup.schema, parentGroup));
973
266
  } else warning == null || warning("Could not find a parent group for: " + schemaNode.id);
974
267
  } else {
975
- skipChildren = existingControls.some(x => x.definition.childRefId);
268
+ skipChildren = existingControls.some(x => x.control.childRefId);
976
269
  }
977
- if (!skipChildren) schemaNode.getChildNodes(true).forEach(addMissing);
270
+ if (!skipChildren) schemaNode.getChildNodes().forEach(addMissing);
978
271
  }
979
272
  function getEligibleParents(schemaNode) {
980
273
  const eligibleParents = [];
@@ -982,17 +275,53 @@ function addMissingControlsToForm(schema, tree, warning) {
982
275
  while (parent) {
983
276
  eligibleParents.push(parent.id);
984
277
  if (parent.field.collection) break;
985
- if (!parent.parent) parent.getChildNodes(true).forEach(addCompound);
278
+ if (!parent.parent) parent.getChildNodes().forEach(addCompound);
986
279
  parent = parent.parent;
987
280
  }
988
281
  return eligibleParents;
989
282
  function addCompound(node) {
990
283
  if (isCompoundNode(node) && !node.field.collection) {
991
284
  eligibleParents.push(node.id);
992
- node.getChildNodes(true).forEach(addCompound);
285
+ node.getChildNodes().forEach(addCompound);
286
+ }
287
+ }
288
+ }
289
+ function addReferences(c) {
290
+ c.children.forEach(addReferences);
291
+ if (c.control.childRefId) {
292
+ const ref = controlMap[c.control.childRefId];
293
+ if (ref) {
294
+ ref.children.forEach(x => toControlAndSchema(x.control, c.schema, c, true));
295
+ return;
993
296
  }
297
+ console.warn("Missing reference", c.control.childRefId);
994
298
  }
995
299
  }
300
+ function addSchemaMapEntry(schemaId, entry) {
301
+ if (!schemaControlMap[schemaId]) schemaControlMap[schemaId] = [];
302
+ schemaControlMap[schemaId].push(entry);
303
+ }
304
+ function toControlAndSchema(c, parentSchema, parentNode, dontRegister) {
305
+ var _c$children$map, _c$children;
306
+ const controlPath = fieldPathForDefinition(c);
307
+ let dataSchema = controlPath ? schemaForFieldPath(controlPath, parentSchema) : undefined;
308
+ if (isGroupControl(c) && dataSchema == null) dataSchema = parentSchema;
309
+ const entry = {
310
+ schema: dataSchema,
311
+ control: c,
312
+ children: [],
313
+ parent: parentNode
314
+ };
315
+ entry.children = (_c$children$map = (_c$children = c.children) == null ? void 0 : _c$children.map(x => {
316
+ var _dataSchema;
317
+ return toControlAndSchema(x, (_dataSchema = dataSchema) != null ? _dataSchema : parentSchema, entry, dontRegister);
318
+ })) != null ? _c$children$map : [];
319
+ if (!dontRegister && c.id) controlMap[c.id] = entry;
320
+ if (dataSchema) {
321
+ addSchemaMapEntry(dataSchema.id, entry);
322
+ }
323
+ return entry;
324
+ }
996
325
  }
997
326
  /**
998
327
  * Custom hook to use an updated reference.
@@ -1004,41 +333,19 @@ function useUpdatedRef(a) {
1004
333
  r.current = a;
1005
334
  return r;
1006
335
  }
1007
- /**
1008
- * Checks if a control definition is readonly.
1009
- * @param c - The control definition to check.
1010
- * @returns True if the control definition is readonly, false otherwise.
1011
- */
1012
- function isControlReadonly(c) {
1013
- return isDataControl(c) && !!c.readonly;
1014
- }
1015
- /**
1016
- * Checks if a control definition is disabled.
1017
- * @param c - The control definition to check.
1018
- * @returns True if the control definition is disabled, false otherwise.
1019
- */
1020
- function isControlDisabled(c) {
1021
- return isDataControl(c) && !!c.disabled;
1022
- }
1023
- /**
1024
- * Returns the display-only render options for a control definition.
1025
- * @param d - The control definition to get the display-only render options for.
1026
- * @returns The display-only render options, or undefined if not applicable.
1027
- */
1028
- function getDisplayOnlyOptions(d) {
1029
- return isDataControl(d) && d.renderOptions && isDisplayOnlyRenderer(d.renderOptions) ? d.renderOptions : undefined;
1030
- }
1031
336
  /**
1032
337
  * Cleans data for a schema based on the provided schema fields.
1033
338
  * @param v - The data to clean.
1034
- * @param fields - The schema fields to use for cleaning the data.
339
+ * @param schemaNode
1035
340
  * @param removeIfDefault - Flag indicating if default values should be removed.
1036
341
  * @returns The cleaned data.
1037
342
  */
1038
- function cleanDataForSchema(v, fields, removeIfDefault) {
343
+ function cleanDataForSchema(v, schemaNode, removeIfDefault) {
344
+ var _fields$find;
1039
345
  if (!v) return v;
1040
- const typeField = fields.find(x => x.isTypeField);
1041
- const typeValue = typeField ? v[typeField.field] : undefined;
346
+ const fields = schemaNode.getResolvedFields();
347
+ const typeField = (_fields$find = fields.find(x => x.isTypeField)) == null ? void 0 : _fields$find.field;
348
+ const typeValue = typeField ? v[typeField] : undefined;
1042
349
  const cleanableFields = !removeIfDefault ? fields.filter(x => {
1043
350
  var _x$onlyForTypes$lengt, _x$onlyForTypes;
1044
351
  return isCompoundField(x) || ((_x$onlyForTypes$lengt = (_x$onlyForTypes = x.onlyForTypes) == null ? void 0 : _x$onlyForTypes.length) != null ? _x$onlyForTypes$lengt : 0) > 0;
@@ -1053,13 +360,13 @@ function cleanDataForSchema(v, fields, removeIfDefault) {
1053
360
  return;
1054
361
  }
1055
362
  if (isCompoundField(x)) {
1056
- const childFields = x.treeChildren ? fields : x.children;
363
+ const childNode = schemaNode.createChildNode(x);
1057
364
  if (x.collection) {
1058
365
  if (Array.isArray(childValue)) {
1059
- out[x.field] = childValue.map(cv => cleanDataForSchema(cv, childFields, removeIfDefault));
366
+ out[x.field] = childValue.map(cv => cleanDataForSchema(cv, childNode, removeIfDefault));
1060
367
  }
1061
368
  } else {
1062
- out[x.field] = cleanDataForSchema(childValue, childFields, removeIfDefault);
369
+ out[x.field] = cleanDataForSchema(childValue, childNode, removeIfDefault);
1063
370
  }
1064
371
  }
1065
372
  function canBeNull() {
@@ -1077,45 +384,28 @@ function cleanDataForSchema(v, fields, removeIfDefault) {
1077
384
  * @returns An array of referenced classes.
1078
385
  */
1079
386
  function getAllReferencedClasses(c, collectExtra) {
1080
- var _c$children, _collectExtra;
1081
- const childClasses = (_c$children = c.children) == null ? void 0 : _c$children.flatMap(x => getAllReferencedClasses(x, collectExtra));
387
+ var _c$children2, _collectExtra;
388
+ const childClasses = (_c$children2 = c.children) == null ? void 0 : _c$children2.flatMap(x => getAllReferencedClasses(x, collectExtra));
1082
389
  const go = getGroupClassOverrides(c);
1083
390
  const {
1084
391
  entryWrapperClass,
1085
392
  selectedClass,
1086
393
  notSelectedClass
1087
394
  } = isDataControl(c) && isCheckEntryClasses(c.renderOptions) ? c.renderOptions : {};
395
+ const groupOptions = isGroupControl(c) ? c.groupOptions : undefined;
396
+ const gridClasses = groupOptions && isGridRenderer(groupOptions) ? [groupOptions.rowClass] : [];
1088
397
  const {
1089
398
  listContainerClass,
1090
399
  listEntryClass,
1091
400
  chipContainerClass,
1092
401
  chipCloseButtonClass
1093
402
  } = isDataControl(c) && isAutoCompleteClasses(c.renderOptions) ? c.renderOptions : {};
1094
- const tc = clsx([c.styleClass, c.layoutClass, c.labelClass, ...Object.values(go), ...((_collectExtra = collectExtra == null ? void 0 : collectExtra(c)) != null ? _collectExtra : []), entryWrapperClass, selectedClass, notSelectedClass, listContainerClass, listEntryClass, chipContainerClass, chipCloseButtonClass].map(getOverrideClass));
403
+ const tc = clsx([c.styleClass, c.layoutClass, c.labelClass, c.textClass, c.labelTextClass, ...gridClasses, ...Object.values(go), ...((_collectExtra = collectExtra == null ? void 0 : collectExtra(c)) != null ? _collectExtra : []), entryWrapperClass, selectedClass, notSelectedClass, listContainerClass, listEntryClass, chipContainerClass, chipCloseButtonClass].map(getOverrideClass));
1095
404
  if (childClasses && !tc) return childClasses;
1096
405
  if (!tc) return [];
1097
406
  if (childClasses) return [tc, ...childClasses];
1098
407
  return [tc];
1099
408
  }
1100
- /**
1101
- * Converts a JSON path array to a string.
1102
- * @param jsonPath - The JSON path array to convert.
1103
- * @param customIndex - Optional function to customize the index format.
1104
- * @returns The JSON path string.
1105
- */
1106
- function jsonPathString(jsonPath, customIndex) {
1107
- let out = "";
1108
- jsonPath.forEach((v, i) => {
1109
- if (typeof v === "number") {
1110
- var _customIndex;
1111
- out += (_customIndex = customIndex == null ? void 0 : customIndex(v)) != null ? _customIndex : "[" + v + "]";
1112
- } else {
1113
- if (i > 0) out += ".";
1114
- out += v;
1115
- }
1116
- });
1117
- return out;
1118
- }
1119
409
  /**
1120
410
  * Finds a child control definition within a parent control definition.
1121
411
  * @param parent - The parent control definition.
@@ -1232,14 +522,6 @@ function deepMerge(value, fallback) {
1232
522
  function coerceToString(v) {
1233
523
  return v == null ? "" : typeof v === "object" ? "error: " + JSON.stringify(v) : v.toString();
1234
524
  }
1235
- /**
1236
- * Returns the group renderer options for a control definition.
1237
- * @param {ControlDefinition} def - The control definition to get the group renderer options for.
1238
- * @returns {GroupRenderOptions | undefined} - The group renderer options, or undefined if not applicable.
1239
- */
1240
- function getGroupRendererOptions(def) {
1241
- return isGroupControl(def) ? def.groupOptions : isDataControl(def) && isDataGroupRenderer(def.renderOptions) ? def.renderOptions.groupOptions : undefined;
1242
- }
1243
525
  /**
1244
526
  * Returns the group class overrides for a control definition.
1245
527
  * @param {ControlDefinition} def - The control definition to get the group class overrides for.
@@ -1259,25 +541,17 @@ function getGroupClassOverrides(def) {
1259
541
  if (childLabelClass) out.labelClass = childLabelClass;
1260
542
  return out;
1261
543
  }
1262
- /**
1263
- * Checks if a control definition is display-only.
1264
- * @param {ControlDefinition} def - The control definition to check.
1265
- * @returns {boolean} - True if the control definition is display-only, false otherwise.
1266
- */
1267
- function isControlDisplayOnly(def) {
1268
- var _getGroupRendererOpti;
1269
- return Boolean((_getGroupRendererOpti = getGroupRendererOptions(def)) == null ? void 0 : _getGroupRendererOpti.displayOnly);
1270
- }
1271
544
  /**
1272
545
  * Combines multiple action handlers into a single handler.
1273
546
  * @param {...(ControlActionHandler | undefined)[]} handlers - The action handlers to combine.
1274
547
  * @returns {ControlActionHandler} - The combined action handler.
1275
548
  */
1276
549
  function actionHandlers(...handlers) {
550
+ const nonNullHandlers = handlers.filter(x => x != null);
551
+ if (nonNullHandlers.length === 0) return undefined;
1277
552
  return (actionId, actionData, ctx) => {
1278
- for (let i = 0; i < handlers.length; i++) {
1279
- var _handlers$i;
1280
- const res = (_handlers$i = handlers[i]) == null ? void 0 : _handlers$i.call(handlers, actionId, actionData, ctx);
553
+ for (let i = 0; i < nonNullHandlers.length; i++) {
554
+ const res = nonNullHandlers[i](actionId, actionData, ctx);
1281
555
  if (res) return res;
1282
556
  }
1283
557
  return undefined;
@@ -1425,28 +699,13 @@ function validationVisitor(onInvalid) {
1425
699
  return undefined;
1426
700
  };
1427
701
  }
1428
-
1429
- var ValidatorType;
1430
- (function (ValidatorType) {
1431
- ValidatorType["Jsonata"] = "Jsonata";
1432
- ValidatorType["Date"] = "Date";
1433
- ValidatorType["Length"] = "Length";
1434
- })(ValidatorType || (ValidatorType = {}));
1435
- var DateComparison;
1436
- (function (DateComparison) {
1437
- DateComparison["NotBefore"] = "NotBefore";
1438
- DateComparison["NotAfter"] = "NotAfter";
1439
- })(DateComparison || (DateComparison = {}));
1440
-
1441
- var ExpressionType;
1442
- (function (ExpressionType) {
1443
- ExpressionType["Jsonata"] = "Jsonata";
1444
- ExpressionType["Data"] = "Data";
1445
- ExpressionType["DataMatch"] = "FieldValue";
1446
- ExpressionType["UserMatch"] = "UserMatch";
1447
- ExpressionType["NotEmpty"] = "NotEmpty";
1448
- ExpressionType["UUID"] = "UUID";
1449
- })(ExpressionType || (ExpressionType = {}));
702
+ function useExpression(defaultValue, runExpression, expression, coerce, bindings) {
703
+ const value = useControl(defaultValue);
704
+ createScopedEffect(scope => {
705
+ if (expression != null && expression.type) runExpression(scope, expression, x => value.value = coerce(x), bindings);else value.value = defaultValue;
706
+ }, value);
707
+ return value;
708
+ }
1450
709
 
1451
710
  function dataControl(field, title, options) {
1452
711
  return _extends({
@@ -1609,535 +868,7 @@ function applyExtensionsToSchema(schemaMap, extensions) {
1609
868
  return resolveSchemas(extensions.reduce(applyExtensionToSchema, schemaMap));
1610
869
  }
1611
870
 
1612
- /**
1613
- * Creates a dynamic hook generator.
1614
- * @template A - The type of the hook result.
1615
- * @template P - The type of the hook context.
1616
- * @template S - The type of the hook state.
1617
- * @param runHook - The function to run the hook.
1618
- * @param state - The initial state of the hook.
1619
- * @param deps - The dependencies of the hook.
1620
- * @returns The dynamic hook generator.
1621
- */
1622
- function makeHook(runHook, state, deps) {
1623
- return {
1624
- deps,
1625
- state,
1626
- runHook
1627
- };
1628
- }
1629
- /**
1630
- * Converts an array of dependencies to a dependency string.
1631
- * @template A - The type of the dependencies.
1632
- * @param deps - The array of dependencies.
1633
- * @param asHookDep - The function to convert a dependency to a hook dependency.
1634
- * @returns The dependency string.
1635
- */
1636
- function makeHookDepString(deps, asHookDep) {
1637
- return deps.map(x => toDepString(asHookDep(x))).join(",");
1638
- }
1639
- /**
1640
- * Custom hook to use dynamic hooks.
1641
- * @template P - The type of the hook context.
1642
- * @template Hooks - The type of the hooks.
1643
- * @param hooks - The hooks to use.
1644
- * @returns A function that takes the hook context and returns the hook values.
1645
- */
1646
- function useDynamicHooks(hooks) {
1647
- const hookEntries = Object.entries(hooks);
1648
- const deps = makeHookDepString(hookEntries, x => x[1].deps);
1649
- const ref = useRef({});
1650
- const s = ref.current;
1651
- hookEntries.forEach(x => s[x[0]] = x[1].state);
1652
- return useCallback(p => {
1653
- return Object.fromEntries(hookEntries.map(([f, hg]) => [f, hg.runHook(p, ref.current[f])]));
1654
- }, [deps]);
1655
- }
1656
- /**
1657
- * Converts a value to a dependency string.
1658
- * @param x - The value to convert.
1659
- * @returns The dependency string.
1660
- */
1661
- function toDepString(x) {
1662
- if (x === undefined) return "_";
1663
- if (x === null) return "~";
1664
- return x.toString();
1665
- }
1666
-
1667
- function optionalHook(expr, useHook, coerce) {
1668
- return expr && expr.type ? useHook(expr, coerce) : undefined;
1669
- }
1670
- function useEvalVisibilityHook(useEvalExpressionHook, definition, overrideDataNode) {
1671
- const dynamicVisibility = useEvalDynamicBoolHook(definition, DynamicPropertyType.Visible, useEvalExpressionHook);
1672
- return makeDynamicPropertyHook(dynamicVisibility, (ctx, {
1673
- definition,
1674
- overrideDataNode
1675
- }) => useComputed(() => {
1676
- const dataNode = overrideDataNode != null ? overrideDataNode : ctx.dataNode;
1677
- return !dataNode || matchesType(dataNode) && !hideDisplayOnly(dataNode, ctx.schemaInterface, definition);
1678
- }), {
1679
- definition,
1680
- overrideDataNode
1681
- });
1682
- }
1683
- function useEvalReadonlyHook(useEvalExpressionHook, definition) {
1684
- const dynamicReadonly = useEvalDynamicBoolHook(definition, DynamicPropertyType.Readonly, useEvalExpressionHook);
1685
- return makeDynamicPropertyHook(dynamicReadonly, (ctx, {
1686
- definition
1687
- }) => useCalculatedControl(() => isControlReadonly(definition)), {
1688
- definition
1689
- });
1690
- }
1691
- function useEvalStyleHook(useEvalExpressionHook, property, definition) {
1692
- const dynamicStyle = useEvalDynamicHook(definition, property, useEvalExpressionHook);
1693
- return makeDynamicPropertyHook(dynamicStyle, () => useControl(undefined), undefined);
1694
- }
1695
- function useEvalAllowedOptionsHook(useEvalExpressionHook, definition) {
1696
- const dynamicAllowed = useEvalDynamicHook(definition, DynamicPropertyType.AllowedOptions, useEvalExpressionHook);
1697
- return makeDynamicPropertyHook(dynamicAllowed, () => useControl([]), undefined);
1698
- }
1699
- function useEvalDisabledHook(useEvalExpressionHook, definition) {
1700
- const dynamicDisabled = useEvalDynamicBoolHook(definition, DynamicPropertyType.Disabled, useEvalExpressionHook);
1701
- return makeDynamicPropertyHook(dynamicDisabled, ctx => useComputed(() => {
1702
- var _ctx$dataNode, _dataControl$meta$nul;
1703
- const dataControl = (_ctx$dataNode = ctx.dataNode) == null ? void 0 : _ctx$dataNode.control;
1704
- const setToNull = (dataControl == null || (_dataControl$meta$nul = dataControl.meta["nullControl"]) == null ? void 0 : _dataControl$meta$nul.value) === false;
1705
- return setToNull || isControlDisabled(definition);
1706
- }), undefined);
1707
- }
1708
- function useEvalDisplayHook(useEvalExpressionHook, definition) {
1709
- return useEvalDynamicHook(definition, DynamicPropertyType.Display, useEvalExpressionHook);
1710
- }
1711
- function useEvalDefaultValueHook(useEvalExpressionHook, definition) {
1712
- const dynamicValue = useEvalDynamicHook(definition, DynamicPropertyType.DefaultValue, useEvalExpressionHook);
1713
- return makeDynamicPropertyHook(dynamicValue, (ctx, {
1714
- definition
1715
- }) => {
1716
- return useComputed(calcDefault);
1717
- function calcDefault() {
1718
- var _ctx$dataNode2;
1719
- const [required, dcv] = isDataControl(definition) ? [definition.required, definition.defaultValue] : [false, undefined];
1720
- const field = (_ctx$dataNode2 = ctx.dataNode) == null ? void 0 : _ctx$dataNode2.schema.field;
1721
- return dcv != null ? dcv : field ? ctx.dataNode.elementIndex != null ? elementValueForField(field) : defaultValueForField(field, required) : undefined;
1722
- }
1723
- }, {
1724
- definition
1725
- });
1726
- }
1727
- function useDataExpression(fvExpr, node, coerce = x => x) {
1728
- const otherField = schemaDataForFieldRef(fvExpr.field, node);
1729
- return useCalculatedControl(() => {
1730
- var _otherField$control;
1731
- return coerce((_otherField$control = otherField.control) == null ? void 0 : _otherField$control.value);
1732
- });
1733
- }
1734
- function useDataMatchExpression(fvExpr, node, coerce = x => x) {
1735
- const otherField = schemaDataForFieldRef(fvExpr.field, node);
1736
- return useCalculatedControl(() => {
1737
- var _otherField$control2;
1738
- const fv = (_otherField$control2 = otherField.control) == null ? void 0 : _otherField$control2.value;
1739
- return coerce(Array.isArray(fv) ? fv.includes(fvExpr.value) : fv === fvExpr.value);
1740
- });
1741
- }
1742
- function useNotEmptyExpression(fvExpr, node, schemaInterface, coerce = x => x) {
1743
- const otherField = schemaDataForFieldRef(fvExpr.field, node);
1744
- return useCalculatedControl(() => {
1745
- var _otherField$control3;
1746
- const fv = (_otherField$control3 = otherField.control) == null ? void 0 : _otherField$control3.value;
1747
- const field = otherField.schema.field;
1748
- return coerce(field && !schemaInterface.isEmptyValue(field, fv));
1749
- });
1750
- }
1751
- function defaultEvalHooks(expr, context, coerce) {
1752
- switch (expr.type) {
1753
- case ExpressionType.Jsonata:
1754
- const bindings = useComputed(() => ({
1755
- formData: context.formData
1756
- }));
1757
- return useJsonataExpression(expr.expression, getRootDataNode(context.parentNode).control, getJsonPath(context.parentNode), bindings, coerce);
1758
- case ExpressionType.UUID:
1759
- return useUuidExpression(coerce);
1760
- case ExpressionType.Data:
1761
- return useDataExpression(expr, context.parentNode, coerce);
1762
- case ExpressionType.DataMatch:
1763
- return useDataMatchExpression(expr, context.parentNode, coerce);
1764
- case ExpressionType.NotEmpty:
1765
- return useNotEmptyExpression(expr, context.parentNode, context.schemaInterface, coerce);
1766
- default:
1767
- return useControl(undefined);
1768
- }
1769
- }
1770
- const defaultUseEvalExpressionHook = makeEvalExpressionHook(defaultEvalHooks);
1771
- function makeEvalExpressionHook(f) {
1772
- return (expr, coerce) => ({
1773
- deps: expr == null ? void 0 : expr.type,
1774
- state: expr && expr.type ? expr : undefined,
1775
- runHook: (ctx, state) => {
1776
- return state ? f(state, ctx, coerce) : undefined;
1777
- }
1778
- });
1779
- }
1780
- function useEvalDynamicBoolHook(definition, type, useEvalExpressionHook) {
1781
- return useEvalDynamicHook(definition, type, useEvalExpressionHook, x => Boolean(x));
1782
- }
1783
- function useEvalDynamicHook(definition, type, useEvalExpressionHook, coerce = x => x) {
1784
- var _definition$dynamic;
1785
- const expression = (_definition$dynamic = definition.dynamic) == null ? void 0 : _definition$dynamic.find(x => x.type === type);
1786
- return useEvalExpressionHook(expression == null ? void 0 : expression.expr, coerce);
1787
- }
1788
- function matchesType(context) {
1789
- const types = context.schema.field.onlyForTypes;
1790
- if (types == null || types.length === 0) return true;
1791
- const parent = context.parent;
1792
- const typeNode = parent.schema.getChildNodes().find(x => x.field.isTypeField);
1793
- if (typeNode == null) return true;
1794
- const typeField = parent.getChild(typeNode).control;
1795
- return typeField && types.includes(typeField.value);
1796
- }
1797
- function hideDisplayOnly(context, schemaInterface, definition) {
1798
- var _context$control;
1799
- const displayOptions = getDisplayOnlyOptions(definition);
1800
- return displayOptions && !displayOptions.emptyText && schemaInterface.isEmptyValue(context.schema.field, (_context$control = context.control) == null ? void 0 : _context$control.value);
1801
- }
1802
- function useUuidExpression(coerce = x => x) {
1803
- return useControl(() => coerce(v4()));
1804
- }
1805
- function useJsonataExpression(jExpr, data, path, bindings, coerce = x => x) {
1806
- const pathString = jsonPathString(path, x => `#$i[${x}]`);
1807
- const fullExpr = pathString ? pathString + ".(" + jExpr + ")" : jExpr;
1808
- const compiledExpr = useMemo(() => {
1809
- try {
1810
- return jsonata(jExpr ? fullExpr : "null");
1811
- } catch (e) {
1812
- console.error(e);
1813
- return jsonata("null");
1814
- }
1815
- }, [fullExpr]);
1816
- const control = useControl();
1817
- const listenerRef = useRef();
1818
- const updateRef = useRef(0);
1819
- const [ref] = useRefState(() => new SubscriptionTracker(() => {
1820
- const l = listenerRef.current;
1821
- if (l) {
1822
- listenerRef.current = undefined;
1823
- addAfterChangesCallback(() => {
1824
- listenerRef.current = l;
1825
- l();
1826
- });
1827
- }
1828
- }));
1829
- useEffect(() => {
1830
- listenerRef.current = apply;
1831
- apply();
1832
- async function apply() {
1833
- const tracker = ref.current;
1834
- try {
1835
- updateRef.current++;
1836
- control.value = coerce(await compiledExpr.evaluate(trackedValue(data, tracker.collectUsage), collectChanges(tracker.collectUsage, () => bindings == null ? void 0 : bindings.value)));
1837
- } finally {
1838
- if (! --updateRef.current) tracker.update();
1839
- }
1840
- }
1841
- }, [compiledExpr]);
1842
- useEffect(() => {
1843
- return () => {
1844
- listenerRef.current = undefined;
1845
- ref.current.cleanup();
1846
- };
1847
- }, []);
1848
- return control;
1849
- }
1850
- function useEvalActionHook(useExpr, definition) {
1851
- const dynamicValue = useEvalDynamicHook(definition, DynamicPropertyType.ActionData, useExpr);
1852
- return makeDynamicPropertyHook(dynamicValue, () => useControl(null), undefined);
1853
- }
1854
- function useEvalLabelText(useExpr, definition) {
1855
- const dynamicValue = useEvalDynamicHook(definition, DynamicPropertyType.Label, useExpr);
1856
- return makeDynamicPropertyHook(dynamicValue, () => useControl(null), undefined);
1857
- }
1858
- function makeDynamicPropertyHook(dynamicValue, makeDefault, state, deps) {
1859
- return {
1860
- deps: deps === undefined ? dynamicValue.deps : [deps, dynamicValue.deps].map(toDepString).join(),
1861
- runHook: (ctx, s) => {
1862
- var _dynamicValue$runHook, _dynamicValue$runHook2;
1863
- return (_dynamicValue$runHook = (_dynamicValue$runHook2 = dynamicValue.runHook(ctx, s[0])) == null ? void 0 : _dynamicValue$runHook2.as()) != null ? _dynamicValue$runHook : makeDefault(ctx, s[1]);
1864
- },
1865
- state: [dynamicValue.state, state]
1866
- };
1867
- }
1868
-
1869
- function useMakeValidationHook(definition, useValidatorFor = useDefaultValidator) {
1870
- var _dd$validators;
1871
- const dd = isDataControl(definition) ? definition : undefined;
1872
- const refData = useUpdatedRef({
1873
- dd,
1874
- useValidatorFor
1875
- });
1876
- const depString = dd ? makeHookDepString((_dd$validators = dd.validators) != null ? _dd$validators : [], x => x.type) : "~";
1877
- return useCallback(ctx => {
1878
- var _ctx$dataContext$data, _ctx$dataContext$data2, _dd$validators2;
1879
- const {
1880
- dd
1881
- } = refData.current;
1882
- if (!dd) return;
1883
- const field = (_ctx$dataContext$data = (_ctx$dataContext$data2 = ctx.dataContext.dataNode) == null ? void 0 : _ctx$dataContext$data2.schema.field) != null ? _ctx$dataContext$data : {
1884
- field: "__missing",
1885
- type: FieldType.Any
1886
- };
1887
- const {
1888
- control,
1889
- hiddenControl,
1890
- dataContext: {
1891
- schemaInterface
1892
- }
1893
- } = ctx;
1894
- useValueChangeEffect(control, () => control.setError("default", ""));
1895
- if (dd.required) useValidator(control, v => {
1896
- return !hiddenControl.value && schemaInterface.isEmptyValue(field, v) ? schemaInterface.validationMessageText(field, ValidationMessageType.NotEmpty, false, true) : null;
1897
- }, "required");
1898
- (_dd$validators2 = dd.validators) == null || _dd$validators2.forEach((v, i) => useValidatorFor(v, _extends({}, ctx, {
1899
- index: i,
1900
- field,
1901
- definition: dd
1902
- })));
1903
- }, [!!dd, dd == null ? void 0 : dd.required, depString, useValidatorFor]);
1904
- }
1905
- function useDefaultValidator(validator, ctx) {
1906
- switch (validator.type) {
1907
- case ValidatorType.Length:
1908
- useLengthValidator(validator, ctx);
1909
- break;
1910
- case ValidatorType.Jsonata:
1911
- useJsonataValidator(validator, ctx);
1912
- break;
1913
- case ValidatorType.Date:
1914
- useDateValidator(validator, ctx);
1915
- break;
1916
- }
1917
- }
1918
- function useJsonataValidator(validator, ctx) {
1919
- const sdn = ctx.dataContext.parentNode;
1920
- const errorMsg = useJsonataExpression(validator.expression, getRootDataNode(sdn).control, getJsonPath(sdn), undefined, v => v == null ? null : typeof v === "string" ? v : JSON.stringify(v));
1921
- useValidator(ctx.control, () => !ctx.hiddenControl.value ? errorMsg.value : null, "jsonata" + ctx.index);
1922
- }
1923
- function useLengthValidator(lv, ctx) {
1924
- const {
1925
- control,
1926
- dataContext: {
1927
- schemaInterface
1928
- },
1929
- hiddenControl,
1930
- field
1931
- } = ctx;
1932
- useValidator(control, v => {
1933
- const len = schemaInterface.controlLength(field, control);
1934
- const hidden = hiddenControl.value;
1935
- if (hidden) {
1936
- return undefined;
1937
- }
1938
- if (lv.min != null && len < lv.min) {
1939
- if (field != null && field.collection) {
1940
- control.setValue(v => Array.isArray(v) ? v.concat(Array.from({
1941
- length: lv.min - v.length
1942
- })) : Array.from({
1943
- length: lv.min
1944
- }));
1945
- } else {
1946
- return schemaInterface.validationMessageText(field, ValidationMessageType.MinLength, len, lv.min);
1947
- }
1948
- } else if (lv.max != null && len > lv.max) {
1949
- return schemaInterface.validationMessageText(field, ValidationMessageType.MaxLength, len, lv.max);
1950
- }
1951
- return undefined;
1952
- }, "length" + ctx.index);
1953
- }
1954
- function useDateValidator(dv, ctx) {
1955
- const {
1956
- control,
1957
- field,
1958
- index,
1959
- dataContext: {
1960
- schemaInterface
1961
- }
1962
- } = ctx;
1963
- let comparisonDate;
1964
- if (dv.fixedDate) {
1965
- comparisonDate = schemaInterface.parseToMillis(field, dv.fixedDate);
1966
- } else {
1967
- const nowDate = new Date();
1968
- comparisonDate = Date.UTC(nowDate.getFullYear(), nowDate.getMonth(), nowDate.getDate());
1969
- if (dv.daysFromCurrent) {
1970
- comparisonDate += dv.daysFromCurrent * 86400000;
1971
- }
1972
- }
1973
- useValidator(control, v => {
1974
- if (v) {
1975
- const selDate = schemaInterface.parseToMillis(field, v);
1976
- const notAfter = dv.comparison === DateComparison.NotAfter;
1977
- if (notAfter ? selDate > comparisonDate : selDate < comparisonDate) {
1978
- return schemaInterface.validationMessageText(field, notAfter ? ValidationMessageType.NotAfterDate : ValidationMessageType.NotBeforeDate, selDate, comparisonDate);
1979
- }
1980
- }
1981
- return null;
1982
- }, "date" + index);
1983
- }
1984
-
1985
- class DefaultSchemaInterface {
1986
- constructor(boolStrings = ["No", "Yes"], parseDateTime = s => Date.parse(s)) {
1987
- this.boolStrings = void 0;
1988
- this.parseDateTime = void 0;
1989
- this.boolStrings = boolStrings;
1990
- this.parseDateTime = parseDateTime;
1991
- }
1992
- parseToMillis(field, v) {
1993
- return this.parseDateTime(v);
1994
- }
1995
- validationMessageText(field, messageType, actual, expected) {
1996
- switch (messageType) {
1997
- case ValidationMessageType.NotEmpty:
1998
- return "Please enter a value";
1999
- case ValidationMessageType.MinLength:
2000
- return "Length must be at least " + expected;
2001
- case ValidationMessageType.MaxLength:
2002
- return "Length must be less than " + expected;
2003
- case ValidationMessageType.NotBeforeDate:
2004
- return `Date must not be before ${new Date(expected).toDateString()}`;
2005
- case ValidationMessageType.NotAfterDate:
2006
- return `Date must not be after ${new Date(expected).toDateString()}`;
2007
- default:
2008
- return "Unknown error";
2009
- }
2010
- }
2011
- getDataOptions(node) {
2012
- return this.getNodeOptions(node.schema);
2013
- }
2014
- getNodeOptions(node) {
2015
- return this.getOptions(node.field);
2016
- }
2017
- getOptions({
2018
- options
2019
- }) {
2020
- return options && options.length > 0 ? options : null;
2021
- }
2022
- getFilterOptions(array, field) {
2023
- return this.getNodeOptions(field);
2024
- }
2025
- isEmptyValue(f, value) {
2026
- if (f.collection) return Array.isArray(value) ? value.length === 0 : value == null;
2027
- switch (f.type) {
2028
- case FieldType.String:
2029
- case FieldType.DateTime:
2030
- case FieldType.Date:
2031
- case FieldType.Time:
2032
- return !value;
2033
- default:
2034
- return value == null;
2035
- }
2036
- }
2037
- searchText(field, value) {
2038
- var _this$textValue$toLow, _this$textValue;
2039
- return (_this$textValue$toLow = (_this$textValue = this.textValue(field, value)) == null ? void 0 : _this$textValue.toLowerCase()) != null ? _this$textValue$toLow : "";
2040
- }
2041
- textValue(field, value, element) {
2042
- const options = this.getOptions(field);
2043
- const option = options == null ? void 0 : options.find(x => x.value === value);
2044
- if (option) return option.name;
2045
- switch (field.type) {
2046
- case FieldType.Date:
2047
- return value ? new Date(value).toLocaleDateString() : undefined;
2048
- case FieldType.DateTime:
2049
- return value ? new Date(this.parseToMillis(field, value)).toLocaleString() : undefined;
2050
- case FieldType.Time:
2051
- return value ? new Date("1970-01-01T" + value).toLocaleTimeString() : undefined;
2052
- case FieldType.Bool:
2053
- return this.boolStrings[value ? 1 : 0];
2054
- default:
2055
- return value != null ? value.toString() : undefined;
2056
- }
2057
- }
2058
- controlLength(f, control) {
2059
- var _control$elements$len, _control$elements;
2060
- return f.collection ? (_control$elements$len = (_control$elements = control.elements) == null ? void 0 : _control$elements.length) != null ? _control$elements$len : 0 : this.valueLength(f, control.value);
2061
- }
2062
- valueLength(field, value) {
2063
- var _ref;
2064
- return (_ref = value && (value == null ? void 0 : value.length)) != null ? _ref : 0;
2065
- }
2066
- compareValue(field, v1, v2) {
2067
- if (v1 == null) return v2 == null ? 0 : 1;
2068
- if (v2 == null) return -1;
2069
- switch (field.type) {
2070
- case FieldType.Date:
2071
- case FieldType.DateTime:
2072
- case FieldType.Time:
2073
- case FieldType.String:
2074
- return v1.localeCompare(v2);
2075
- case FieldType.Bool:
2076
- return v1 ? v2 ? 0 : 1 : -1;
2077
- case FieldType.Int:
2078
- case FieldType.Double:
2079
- return v1 - v2;
2080
- default:
2081
- return 0;
2082
- }
2083
- }
2084
- compoundFieldSetup(f) {
2085
- return f.getChildNodes().map(x => {
2086
- const {
2087
- field
2088
- } = x.field;
2089
- return [field, this.makeControlSetup(x)];
2090
- });
2091
- }
2092
- compoundFieldEquality(f) {
2093
- return f.getChildNodes().map(x => {
2094
- const {
2095
- field
2096
- } = x.field;
2097
- return [field, (a, b) => this.makeEqualityFunc(x)(a[field], b[field])];
2098
- });
2099
- }
2100
- makeEqualityFunc(field, element) {
2101
- if (field.field.collection && !element) {
2102
- const elemEqual = this.makeEqualityFunc(field, true);
2103
- return (a, b) => {
2104
- if (a === b) return true;
2105
- if (a == null || b == null) return false;
2106
- if (a.length !== b.length) return false;
2107
- for (let i = 0; i < a.length; i++) {
2108
- if (!elemEqual(a[i], b[i])) return false;
2109
- }
2110
- return true;
2111
- };
2112
- }
2113
- switch (field.field.type) {
2114
- case FieldType.Compound:
2115
- const allChecks = this.compoundFieldEquality(field);
2116
- return (a, b) => a === b || a != null && b != null && allChecks.every(x => x[1](a, b));
2117
- default:
2118
- return (a, b) => a === b;
2119
- }
2120
- }
2121
- makeControlSetup(field, element) {
2122
- let setup = {
2123
- equals: this.makeEqualityFunc(field, element)
2124
- };
2125
- if (field.field.collection && !element) {
2126
- setup.elems = this.makeControlSetup(field, true);
2127
- return setup;
2128
- }
2129
- switch (field.field.type) {
2130
- case FieldType.Compound:
2131
- setup.fields = Object.fromEntries(this.compoundFieldSetup(field));
2132
- }
2133
- return setup;
2134
- }
2135
- }
2136
- const defaultSchemaInterface = new DefaultSchemaInterface();
2137
-
2138
- const _excluded = ["styleClass", "labelClass", "layoutClass"],
2139
- _excluded2 = ["parentDataNode"],
2140
- _excluded3 = ["definition", "control", "formOptions", "style", "allowedOptions", "schemaInterface", "styleClass"];
871
+ const _excluded$1 = ["formOptions", "style", "allowedOptions", "schemaInterface", "styleClass", "textClass", "displayOnly", "inline"];
2141
872
  const AppendAdornmentPriority = 0;
2142
873
  const WrapAdornmentPriority = 1000;
2143
874
  /**
@@ -2158,258 +889,26 @@ var LabelType;
2158
889
  */
2159
890
  LabelType[LabelType["Text"] = 2] = "Text";
2160
891
  })(LabelType || (LabelType = {}));
2161
- function useControlRenderer(definition, fields, renderer, options = {}) {
2162
- const r = useUpdatedRef({
2163
- definition,
2164
- fields,
2165
- renderer,
2166
- options
2167
- });
2168
- return useCallback(({
2169
- control,
2170
- parentPath
2171
- }) => {
2172
- return /*#__PURE__*/jsx(ControlRenderer, _extends({}, r.current, {
2173
- control: control,
2174
- parentPath: parentPath
2175
- }));
2176
- }, [r]);
2177
- }
2178
- function useControlRendererComponent(controlOrFormNode, renderer, options = {}, parentDataNode) {
2179
- var _options$useDataHook, _options$schemaInterf, _options$useEvalExpre;
2180
- const [definition, formNode] = "definition" in controlOrFormNode ? [controlOrFormNode.definition, controlOrFormNode] : [controlOrFormNode, legacyFormNode(controlOrFormNode)];
2181
- const dataProps = (_options$useDataHook = options.useDataHook == null ? void 0 : options.useDataHook(definition)) != null ? _options$useDataHook : defaultDataProps;
2182
- const elementIndex = options.elementIndex;
2183
- const schemaInterface = (_options$schemaInterf = options.schemaInterface) != null ? _options$schemaInterf : defaultSchemaInterface;
2184
- const useExpr = (_options$useEvalExpre = options.useEvalExpressionHook) != null ? _options$useEvalExpre : defaultUseEvalExpressionHook;
2185
- let dataNode;
2186
- if (elementIndex != null) {
2187
- dataNode = parentDataNode.getChildElement(elementIndex);
2188
- } else {
2189
- dataNode = lookupDataNode(definition, parentDataNode);
2190
- }
2191
- const useValidation = useMakeValidationHook(definition, options.useValidationHook);
2192
- const dynamicHooks = useDynamicHooks({
2193
- defaultValueControl: useEvalDefaultValueHook(useExpr, definition),
2194
- visibleControl: useEvalVisibilityHook(useExpr, definition),
2195
- readonlyControl: useEvalReadonlyHook(useExpr, definition),
2196
- disabledControl: useEvalDisabledHook(useExpr, definition),
2197
- allowedOptions: useEvalAllowedOptionsHook(useExpr, definition),
2198
- labelText: useEvalLabelText(useExpr, definition),
2199
- actionData: useEvalActionHook(useExpr, definition),
2200
- customStyle: useEvalStyleHook(useExpr, DynamicPropertyType.Style, definition),
2201
- layoutStyle: useEvalStyleHook(useExpr, DynamicPropertyType.LayoutStyle, definition),
2202
- displayControl: useEvalDisplayHook(useExpr, definition)
2203
- });
2204
- const r = useUpdatedRef({
2205
- options,
2206
- definition,
2207
- elementIndex,
2208
- parentDataNode,
2209
- dataNode,
2210
- formNode
2211
- });
2212
- if (formNode == null) debugger;
2213
- const Component = useCallback(() => {
2214
- const stopTracking = useComponentTracking();
2215
- try {
2216
- var _options$formData, _dataNode, _definition$adornment2, _definition$adornment3, _formNode$tree$getByR, _options$adjustLayout;
2217
- const {
2218
- definition: c,
2219
- options,
2220
- elementIndex,
2221
- parentDataNode: pdn,
2222
- dataNode: dn,
2223
- formNode
2224
- } = r.current;
2225
- const formData = (_options$formData = options.formData) != null ? _options$formData : {};
2226
- const dataContext = {
2227
- schemaInterface,
2228
- dataNode: dn,
2229
- parentNode: pdn,
2230
- formData
2231
- };
2232
- const {
2233
- readonlyControl,
2234
- disabledControl,
2235
- visibleControl,
2236
- displayControl,
2237
- layoutStyle,
2238
- labelText,
2239
- customStyle,
2240
- allowedOptions,
2241
- defaultValueControl,
2242
- actionData
2243
- } = dynamicHooks(dataContext);
2244
- const visible = visibleControl.current.value;
2245
- const visibility = useControl(() => visible != null ? {
2246
- visible,
2247
- showing: visible
2248
- } : undefined);
2249
- useControlEffect(() => visibleControl.value, visible => {
2250
- if (visible != null) visibility.setValue(ex => ({
2251
- visible,
2252
- showing: ex ? ex.showing : visible
2253
- }));
2254
- });
2255
- const parentControl = parentDataNode.control;
2256
- const control = (_dataNode = dataNode) == null ? void 0 : _dataNode.control;
2257
- useControlEffect(() => {
2258
- var _definition$adornment, _definition$renderOpt;
2259
- return [visibility.value, defaultValueControl.value, control == null ? void 0 : control.isNull, isDataControl(definition) && definition.dontClearHidden, ((_definition$adornment = definition.adornments) == null ? void 0 : _definition$adornment.some(x => x.type === ControlAdornmentType.Optional)) || isDataControl(definition) && ((_definition$renderOpt = definition.renderOptions) == null ? void 0 : _definition$renderOpt.type) == DataRenderType.NullToggle, parentControl.isNull, options.hidden, readonlyControl.value];
2260
- }, ([vc, dv, _, dontClear, dontDefault, parentNull, hidden, ro]) => {
2261
- if (!ro) {
2262
- if (control) {
2263
- if (vc && vc.visible === vc.showing) {
2264
- if (hidden || !vc.visible) {
2265
- control.setValue(x => options.clearHidden && !dontClear ? undefined : x == null && dontClear && !dontDefault ? dv : x);
2266
- } else if (!dontDefault) control.setValue(x => x != null ? x : dv);
2267
- }
2268
- } else if (parentNull) {
2269
- parentControl.setValue(x => x != null ? x : {});
2270
- }
2271
- }
2272
- }, true);
2273
- const myOptionsControl = useComputed(() => {
2274
- var _visibility$fields;
2275
- return {
2276
- hidden: options.hidden || !((_visibility$fields = visibility.fields) != null && _visibility$fields.showing.value),
2277
- readonly: options.readonly || readonlyControl.value,
2278
- disabled: options.disabled || disabledControl.value,
2279
- displayOnly: options.displayOnly || isControlDisplayOnly(c)
2280
- };
2281
- });
2282
- const myOptions = trackedValue(myOptionsControl);
2283
- useValidation({
2284
- control: control != null ? control : newControl(null),
2285
- hiddenControl: myOptionsControl.fields.hidden,
2286
- dataContext
2287
- });
2288
- const inheritableOptions = _objectWithoutPropertiesLoose(options, _excluded);
2289
- const childOptions = _extends({}, inheritableOptions, myOptions, {
2290
- elementIndex: undefined
2291
- });
2292
- useEffect(() => {
2293
- if (control && typeof myOptions.disabled === "boolean" && control.disabled != myOptions.disabled) control.disabled = myOptions.disabled;
2294
- }, [control, myOptions.disabled]);
2295
- if (parentControl.isNull) return /*#__PURE__*/jsx(Fragment, {});
2296
- const adornments = (_definition$adornment2 = (_definition$adornment3 = definition.adornments) == null ? void 0 : _definition$adornment3.map(x => renderer.renderAdornment({
2297
- adornment: x,
2298
- dataContext,
2299
- useExpr,
2300
- formOptions: myOptions
2301
- }))) != null ? _definition$adornment2 : [];
2302
- const otherChildNodes = definition.childRefId && ((_formNode$tree$getByR = formNode.tree.getByRefId(definition.childRefId)) == null ? void 0 : _formNode$tree$getByR.getChildNodes());
2303
- const labelAndChildren = renderControlLayout({
2304
- formNode: otherChildNodes ? formNode.tree.createTempNode(formNode.id, definition, otherChildNodes) : formNode,
2305
- definition: c,
2306
- renderer,
2307
- renderChild: (k, child, options) => {
2308
- var _ref2;
2309
- const overrideClasses = getGroupClassOverrides(c);
2310
- const _ref = options != null ? options : {},
2311
- {
2312
- parentDataNode
2313
- } = _ref,
2314
- renderOptions = _objectWithoutPropertiesLoose(_ref, _excluded2);
2315
- const dContext = (_ref2 = parentDataNode != null ? parentDataNode : dataContext.dataNode) != null ? _ref2 : dataContext.parentNode;
2316
- const allChildOptions = _extends({}, childOptions, overrideClasses, renderOptions);
2317
- return /*#__PURE__*/jsx(NewControlRenderer, {
2318
- definition: child,
2319
- renderer: renderer,
2320
- parentDataNode: dContext,
2321
- options: allChildOptions
2322
- }, k);
2323
- },
2324
- createDataProps: dataProps,
2325
- formOptions: myOptions,
2326
- dataContext,
2327
- control: displayControl != null ? displayControl : control,
2328
- elementIndex,
2329
- schemaInterface,
2330
- labelText,
2331
- displayControl,
2332
- style: customStyle.value,
2333
- allowedOptions,
2334
- customDisplay: options.customDisplay,
2335
- actionDataControl: actionData,
2336
- actionOnClick: options.actionOnClick,
2337
- styleClass: options.styleClass,
2338
- labelClass: options.labelClass,
2339
- useEvalExpression: useExpr,
2340
- useChildVisibility: (childDef, parentNode, dontOverride) => {
2341
- var _ref3;
2342
- return useEvalVisibilityHook(useExpr, childDef, !dontOverride ? lookupDataNode(childDef, (_ref3 = parentNode != null ? parentNode : dataNode) != null ? _ref3 : parentDataNode) : undefined);
2343
- }
2344
- });
2345
- const layoutProps = _extends({}, labelAndChildren, {
2346
- adornments,
2347
- className: rendererClass(options.layoutClass, c.layoutClass),
2348
- style: layoutStyle.value
2349
- });
2350
- const renderedControl = renderer.renderLayout((_options$adjustLayout = options.adjustLayout == null ? void 0 : options.adjustLayout(dataContext, layoutProps)) != null ? _options$adjustLayout : layoutProps);
2351
- return renderer.renderVisibility(_extends({
2352
- visibility
2353
- }, renderedControl));
2354
- } finally {
2355
- stopTracking();
2356
- }
2357
- }, [r, dataProps, useValidation, renderer, schemaInterface, dynamicHooks]);
2358
- Component.displayName = "RenderControl";
2359
- return Component;
2360
- }
2361
- function ControlRenderer({
2362
- definition,
2363
- fields,
2364
- renderer,
2365
- options,
2366
- control,
2367
- parentPath
2368
- }) {
2369
- var _effect = useComponentTracking();
2370
- try {
2371
- const schemaDataNode = makeSchemaDataNode(createSchemaLookup({
2372
- "": fields
2373
- }).getSchema(""), control);
2374
- const Render = useControlRendererComponent(definition, renderer, options, schemaDataNode);
2375
- return /*#__PURE__*/jsx(Render, {});
2376
- } finally {
2377
- _effect();
2378
- }
2379
- }
2380
- function NewControlRenderer({
2381
- definition,
2382
- renderer,
2383
- options,
2384
- parentDataNode
2385
- }) {
2386
- var _effect2 = useComponentTracking();
2387
- try {
2388
- const Render = useControlRendererComponent(definition, renderer, options, parentDataNode);
2389
- return /*#__PURE__*/jsx(Render, {});
2390
- } finally {
2391
- _effect2();
2392
- }
2393
- }
2394
- function defaultDataProps(_ref4) {
2395
- var _allowedOptions$value, _definition$renderOpt2;
892
+ function defaultDataProps(_ref, definition, control) {
893
+ var _definition$renderOpt;
2396
894
  let {
2397
- definition,
2398
- control,
2399
895
  formOptions,
2400
896
  style,
2401
897
  allowedOptions,
2402
898
  schemaInterface = defaultSchemaInterface,
2403
- styleClass
2404
- } = _ref4,
2405
- props = _objectWithoutPropertiesLoose(_ref4, _excluded3);
899
+ styleClass,
900
+ textClass: tc,
901
+ displayOnly,
902
+ inline
903
+ } = _ref,
904
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
2406
905
  const dataNode = props.dataContext.dataNode;
2407
906
  const field = dataNode.schema.field;
2408
907
  const className = rendererClass(styleClass, definition.styleClass);
2409
- const displayOnly = !!formOptions.displayOnly;
908
+ const textClass = rendererClass(tc, definition.textClass);
2410
909
  const required = !!definition.required && !displayOnly;
2411
910
  const fieldOptions = schemaInterface.getDataOptions(dataNode);
2412
- const _allowed = (_allowedOptions$value = allowedOptions == null ? void 0 : allowedOptions.value) != null ? _allowedOptions$value : [];
911
+ const _allowed = allowedOptions != null ? allowedOptions : [];
2413
912
  const allowed = Array.isArray(_allowed) ? _allowed : [_allowed];
2414
913
  return _extends({
2415
914
  dataNode,
@@ -2417,6 +916,7 @@ function defaultDataProps(_ref4) {
2417
916
  control,
2418
917
  field,
2419
918
  id: "c" + control.uniqueId,
919
+ inline: !!inline,
2420
920
  options: allowed.length > 0 ? allowed.map(x => {
2421
921
  var _fieldOptions$find;
2422
922
  return typeof x === "object" ? x : (_fieldOptions$find = fieldOptions == null ? void 0 : fieldOptions.find(y => y.value == x)) != null ? _fieldOptions$find : {
@@ -2425,40 +925,46 @@ function defaultDataProps(_ref4) {
2425
925
  };
2426
926
  }).filter(x => x != null) : fieldOptions,
2427
927
  readonly: !!formOptions.readonly,
2428
- displayOnly,
2429
- renderOptions: (_definition$renderOpt2 = definition.renderOptions) != null ? _definition$renderOpt2 : {
928
+ displayOnly: !!displayOnly,
929
+ renderOptions: (_definition$renderOpt = definition.renderOptions) != null ? _definition$renderOpt : {
2430
930
  type: "Standard"
2431
931
  },
2432
932
  required,
2433
933
  hidden: !!formOptions.hidden,
2434
934
  className,
935
+ textClass,
2435
936
  style
2436
937
  }, props);
2437
938
  }
2438
939
  function renderControlLayout(props) {
2439
940
  const {
2440
- definition: c,
2441
941
  renderer,
2442
942
  renderChild,
2443
943
  control,
2444
944
  dataContext,
2445
945
  createDataProps: dataProps,
2446
- displayControl,
2447
946
  style,
2448
- labelText,
2449
- useChildVisibility,
2450
947
  designMode,
2451
948
  customDisplay,
2452
- useEvalExpression,
949
+ runExpression,
2453
950
  labelClass,
951
+ labelTextClass,
2454
952
  styleClass,
2455
- formNode
953
+ textClass,
954
+ formNode,
955
+ formOptions,
956
+ actionOnClick,
957
+ state,
958
+ getChildState,
959
+ inline,
960
+ displayOnly
2456
961
  } = props;
962
+ const c = state.definition;
2457
963
  if (isDataControl(c)) {
2458
964
  return renderData(c);
2459
965
  }
2460
966
  if (isGroupControl(c)) {
2461
- var _c$groupOptions2, _labelText$value, _c$groupOptions3;
967
+ var _c$groupOptions2, _c$groupOptions3;
2462
968
  if (c.compoundField) {
2463
969
  var _c$groupOptions;
2464
970
  return renderData(dataControl(c.compoundField, c.title, {
@@ -2467,41 +973,68 @@ function renderControlLayout(props) {
2467
973
  }));
2468
974
  }
2469
975
  return {
976
+ inline,
2470
977
  processLayout: renderer.renderGroup({
2471
978
  formNode,
979
+ state,
2472
980
  definition: c,
2473
981
  renderChild,
2474
- useEvalExpression,
982
+ runExpression,
2475
983
  dataContext,
2476
984
  renderOptions: (_c$groupOptions2 = c.groupOptions) != null ? _c$groupOptions2 : {
2477
985
  type: "Standard"
2478
986
  },
2479
987
  className: rendererClass(styleClass, c.styleClass),
2480
- useChildVisibility,
988
+ textClass: rendererClass(textClass, c.textClass),
2481
989
  style,
2482
- designMode
990
+ designMode,
991
+ actionOnClick,
992
+ getChildState
2483
993
  }),
2484
994
  label: {
2485
- label: (_labelText$value = labelText == null ? void 0 : labelText.value) != null ? _labelText$value : c.title,
995
+ label: c.title,
2486
996
  className: rendererClass(labelClass, c.labelClass),
997
+ textClass: rendererClass(labelTextClass, c.labelTextClass),
2487
998
  type: LabelType.Group,
2488
999
  hide: (_c$groupOptions3 = c.groupOptions) == null ? void 0 : _c$groupOptions3.hideTitle
2489
1000
  }
2490
1001
  };
2491
1002
  }
2492
1003
  if (isActionControl(c)) {
2493
- var _props$actionDataCont, _props$actionDataCont2, _ref5, _labelText$value2, _props$actionOnClick;
2494
- const actionData = (_props$actionDataCont = (_props$actionDataCont2 = props.actionDataControl) == null ? void 0 : _props$actionDataCont2.value) != null ? _props$actionDataCont : c.actionData;
1004
+ var _c$actionStyle, _c$title, _props$actionOnClick;
1005
+ const actionData = c.actionData;
1006
+ const actionStyle = (_c$actionStyle = c.actionStyle) != null ? _c$actionStyle : ActionStyle.Button;
1007
+ const actionContent = actionStyle == ActionStyle.Group ? renderActionGroup() : undefined;
2495
1008
  return {
1009
+ inline,
2496
1010
  children: renderer.renderAction({
2497
- actionText: (_ref5 = (_labelText$value2 = labelText == null ? void 0 : labelText.value) != null ? _labelText$value2 : c.title) != null ? _ref5 : c.actionId,
1011
+ actionText: (_c$title = c.title) != null ? _c$title : c.actionId,
2498
1012
  actionId: c.actionId,
2499
1013
  actionData,
1014
+ actionContent,
1015
+ actionStyle,
1016
+ textClass: rendererClass(textClass, c.textClass),
1017
+ iconPlacement: c.iconPlacement,
1018
+ icon: c.icon,
1019
+ inline,
2500
1020
  onClick: (_props$actionOnClick = props.actionOnClick == null ? void 0 : props.actionOnClick(c.actionId, actionData, dataContext)) != null ? _props$actionOnClick : () => {},
2501
1021
  className: rendererClass(styleClass, c.styleClass),
2502
1022
  style
2503
1023
  })
2504
1024
  };
1025
+ function renderActionGroup() {
1026
+ const childDefs = formNode.getResolvedChildren();
1027
+ const childDef = {
1028
+ type: ControlDefinitionType.Group,
1029
+ groupOptions: {
1030
+ type: GroupRenderType.Contents,
1031
+ hideTitle: true
1032
+ },
1033
+ children: childDefs
1034
+ };
1035
+ const childNode = formNode.createChildNode("child", childDef);
1036
+ return renderChild("child", childNode, {});
1037
+ }
2505
1038
  }
2506
1039
  if (isDisplayControl(c)) {
2507
1040
  var _c$displayData;
@@ -2509,36 +1042,41 @@ function renderControlLayout(props) {
2509
1042
  const displayProps = {
2510
1043
  data,
2511
1044
  className: rendererClass(styleClass, c.styleClass),
1045
+ textClass: rendererClass(textClass, c.textClass),
2512
1046
  style,
2513
- display: displayControl,
2514
- dataContext
1047
+ dataContext,
1048
+ inline
2515
1049
  };
2516
1050
  if (data.type === DisplayDataType.Custom && customDisplay) {
2517
1051
  return {
1052
+ inline,
2518
1053
  children: customDisplay(data.customId, displayProps)
2519
1054
  };
2520
1055
  }
2521
1056
  return {
1057
+ inline,
2522
1058
  children: renderer.renderDisplay(displayProps)
2523
1059
  };
2524
1060
  }
2525
1061
  return {};
2526
1062
  function renderData(c) {
2527
- var _labelText$value3, _c$children$length, _c$children;
1063
+ var _c$children$length, _c$children;
2528
1064
  if (!control) return {
2529
1065
  children: "No control for: " + c.field
2530
1066
  };
2531
- const rendererProps = dataProps(props);
2532
- const label = !c.hideTitle ? controlTitle((_labelText$value3 = labelText == null ? void 0 : labelText.value) != null ? _labelText$value3 : c.title, props.dataContext.dataNode.schema.field) : undefined;
1067
+ const rendererProps = dataProps(props, c, control);
1068
+ const label = !c.hideTitle ? controlTitle(c.title, props.dataContext.dataNode.schema.field) : undefined;
2533
1069
  return {
1070
+ inline,
2534
1071
  processLayout: renderer.renderData(rendererProps),
2535
1072
  label: {
2536
1073
  type: ((_c$children$length = (_c$children = c.children) == null ? void 0 : _c$children.length) != null ? _c$children$length : 0) > 0 ? LabelType.Group : LabelType.Control,
2537
1074
  label,
2538
1075
  forId: rendererProps.id,
2539
- required: c.required && !props.formOptions.displayOnly,
1076
+ required: c.required && !displayOnly,
2540
1077
  hide: c.hideTitle,
2541
- className: rendererClass(labelClass, c.labelClass)
1078
+ className: rendererClass(labelClass, c.labelClass),
1079
+ textClass: rendererClass(labelTextClass, c.labelTextClass)
2542
1080
  },
2543
1081
  errorControl: control
2544
1082
  };
@@ -2584,13 +1122,15 @@ function renderLayoutParts(props, renderer) {
2584
1122
  style,
2585
1123
  errorControl,
2586
1124
  label,
2587
- adornments
1125
+ adornments,
1126
+ inline
2588
1127
  } = (_props$processLayout = props.processLayout == null ? void 0 : props.processLayout(props)) != null ? _props$processLayout : props;
2589
1128
  const layout = {
2590
1129
  children,
2591
1130
  errorControl,
2592
1131
  style,
2593
1132
  className: className,
1133
+ inline,
2594
1134
  wrapLayout: x => x
2595
1135
  };
2596
1136
  (adornments != null ? adornments : []).sort((a, b) => a.priority - b.priority).forEach(x => x.apply(layout));
@@ -2716,17 +1256,29 @@ function applyArrayLengthRestrictions({
2716
1256
  };
2717
1257
  }
2718
1258
  function fieldOptionAdornment(p) {
2719
- return (o, i, selected) => /*#__PURE__*/jsx(RenderArrayElements, {
1259
+ return (o, fieldIndex, selected) => /*#__PURE__*/jsx(RenderArrayElements, {
2720
1260
  array: p.formNode.getChildNodes(),
2721
1261
  children: (cd, i) => p.renderChild(i, cd, {
2722
1262
  parentDataNode: p.dataContext.parentNode,
2723
- formData: {
2724
- option: o,
2725
- optionSelected: selected
1263
+ stateKey: fieldIndex.toString(),
1264
+ variables: {
1265
+ formData: {
1266
+ option: o,
1267
+ optionSelected: selected
1268
+ }
2726
1269
  }
2727
1270
  })
2728
1271
  });
2729
1272
  }
1273
+ function lookupChildDataContext(dataContext, c) {
1274
+ var _dataContext$dataNode;
1275
+ const parentNode = (_dataContext$dataNode = dataContext.dataNode) != null ? _dataContext$dataNode : dataContext.parentNode;
1276
+ const dataNode = lookupDataNode(c, parentNode);
1277
+ return _extends({}, dataContext, {
1278
+ parentNode,
1279
+ dataNode
1280
+ });
1281
+ }
2730
1282
 
2731
1283
  function isIconAdornment(a) {
2732
1284
  return a.type === ControlAdornmentType.Icon;
@@ -2820,7 +1372,6 @@ function createFormRenderer(customRenderers = [], defaultRenderers) {
2820
1372
  renderLayout,
2821
1373
  renderVisibility,
2822
1374
  renderLabelText,
2823
- renderText: defaultRenderers.renderText,
2824
1375
  html: defaultRenderers.html
2825
1376
  };
2826
1377
  function renderVisibility(props) {
@@ -2868,7 +1419,7 @@ function createFormRenderer(customRenderers = [], defaultRenderers) {
2868
1419
  var _x$collection, _field$collection, _x$options;
2869
1420
  const noMatch = x.match ? !x.match(props, renderOptions) : undefined;
2870
1421
  if (noMatch === true) return false;
2871
- const matchCollection = ((_x$collection = x.collection) != null ? _x$collection : false) === (props.elementIndex == null && ((_field$collection = field.collection) != null ? _field$collection : false));
1422
+ const matchCollection = ((_x$collection = x.collection) != null ? _x$collection : false) === (props.dataNode.elementIndex == null && ((_field$collection = field.collection) != null ? _field$collection : false));
2872
1423
  const isSchemaAllowed = !!x.schemaType && renderType == DataRenderType.Standard ? isOneOf(x.schemaType, field.type) : undefined;
2873
1424
  const isRendererAllowed = !!x.renderType && isOneOf(x.renderType, renderType);
2874
1425
  return matchCollection && ((_x$options = x.options) != null ? _x$options : false) === options && (isSchemaAllowed || isRendererAllowed || !x.renderType && !x.schemaType && noMatch === false);
@@ -2928,5 +1479,217 @@ function isArrayRegistration(x) {
2928
1479
  return x.type === "array";
2929
1480
  }
2930
1481
 
2931
- export { AdornmentPlacement, AppendAdornmentPriority, ControlAdornmentType, ControlDefinitionType, ControlRenderer, DataRenderType, DateComparison, DefaultSchemaInterface, DisplayDataType, DynamicPropertyType, ExpressionType, FieldType, FormTree, GroupRenderType, LabelType, NewControlRenderer, SchemaTags, SyncTextType, ValidationMessageType, ValidatorType, WrapAdornmentPriority, accordionOptions, actionControl, actionHandlers, addFieldOption, addMissingControls, addMissingControlsForSchema, addMissingControlsToForm, adornmentOptions, appendMarkup, appendMarkupAt, applyArrayLengthRestrictions, applyDefaultForField, applyDefaultValues, applyExtensionToSchema, applyExtensionsToSchema, applyLengthRestrictions, applyValues, autocompleteOptions, boolField, buildSchema, checkListOptions, cleanDataForSchema, coerceToString, collectDifferences, compoundControl, compoundField, controlTitle, createAction, createActionRenderer, createAdornmentRenderer, createArrayActions, createArrayRenderer, createDataRenderer, createDisplayRenderer, createFormLookup, createFormRenderer, createFormTree, createGroupRenderer, createLabelRenderer, createLayoutRenderer, createSchemaLookup, createVisibilityRenderer, dataControl, dateField, dateTimeField, dateValidatorOptions, deepMerge, defaultCompoundField, defaultControlForField, defaultDataProps, defaultEvalHooks, defaultScalarField, defaultSchemaInterface, defaultUseEvalExpressionHook, defaultValueForField, defaultValueForFields, displayOnlyOptions, doubleField, dynamicDefaultValue, dynamicDisabled, dynamicReadonly, dynamicVisibility, elementValueForField, emptyGroupDefinition, fieldDisplayName, fieldEqExpr, fieldExpr, fieldHasTag, fieldOptionAdornment, fieldPathForDefinition, findChildDefinition, findCompoundField, findControlsForCompound, findField, findFieldPath, findNonDataGroups, findScalarField, getAllReferencedClasses, getAllValues, getDiffObject, getDisplayOnlyOptions, getExternalEditData, getGroupClassOverrides, getGroupRendererOptions, getIsEditing, getJsonPath, getLastDefinedValue, getLengthRestrictions, getNullToggler, getOverrideClass, getRootDataNode, getSchemaFieldList, getSchemaNodePath, getSchemaPath, getTagParam, groupedControl, hasOptions, hideDisplayOnly, htmlDisplayControl, intField, isAccordionAdornment, isActionControl, isArrayRenderer, isAutoCompleteClasses, isAutocompleteRenderer, isCheckEntryClasses, isCompoundField, isCompoundNode, isControlDisabled, isControlDisplayOnly, isControlReadonly, isDataControl, isDataGroupRenderer, isDateTimeRenderer, isDisplayControl, isDisplayOnlyRenderer, isFlexRenderer, isGridRenderer, isGroupControl, isIconAdornment, isOptionalAdornment, isScalarField, isSelectChildRenderer, isSetFieldAdornment, isTabsRenderer, isTextfieldRenderer, jsonPathString, jsonataExpr, jsonataOptions, jsonataValidatorOptions, layoutKeyForPlacement, legacyFormNode, lengthValidatorOptions, lookupDataNode, makeCompoundField, makeEvalExpressionHook, makeHook, makeHookDepString, makeParamTag, makeScalarField, makeSchemaDataNode, matchesType, mergeField, mergeFields, mergeObjects, optionalHook, radioButtonOptions, relativePath, renderControlLayout, renderLayoutParts, renderOptionsFor, rendererClass, resolveSchemas, rootSchemaNode, schemaDataForFieldPath, schemaDataForFieldRef, schemaForFieldPath, schemaForFieldRef, stringField, stringOptionsField, textDisplayControl, textfieldOptions, timeField, toDepString, traverseData, traverseParents, traverseSchemaPath, useControlDefinitionForSchema, useControlRenderer, useControlRendererComponent, useDateValidator, useDynamicHooks, useEvalActionHook, useEvalAllowedOptionsHook, useEvalDefaultValueHook, useEvalDisabledHook, useEvalDisplayHook, useEvalDynamicBoolHook, useEvalDynamicHook, useEvalLabelText, useEvalReadonlyHook, useEvalStyleHook, useEvalVisibilityHook, useJsonataExpression, useJsonataValidator, useLengthValidator, useMakeValidationHook, useUpdatedRef, useUuidExpression, validationVisitor, validatorOptions, visitControlData, visitControlDataArray, visitControlDefinition, visitFormData, visitFormDataInContext, withScalarOptions, wrapLayout, wrapMarkup, wrapMarkupAt };
1482
+ const _excluded = ["styleClass", "labelClass", "layoutClass", "labelTextClass", "textClass"],
1483
+ _excluded2 = ["parentDataNode", "actionOnClick", "variables"];
1484
+ function RenderForm({
1485
+ data,
1486
+ form,
1487
+ renderer,
1488
+ options = {}
1489
+ }) {
1490
+ var _effect = useComponentTracking();
1491
+ try {
1492
+ var _options$schemaInterf, _definition$adornment, _definition$adornment2, _dataContext$dataNode, _options$adjustLayout;
1493
+ const schemaInterface = (_options$schemaInterf = options.schemaInterface) != null ? _options$schemaInterf : defaultSchemaInterface;
1494
+ const [formState, setFormState] = useState(() => {
1495
+ var _options$formState;
1496
+ return (_options$formState = options == null ? void 0 : options.formState) != null ? _options$formState : createFormState(schemaInterface);
1497
+ });
1498
+ const state = formState.getControlState(data, form, options);
1499
+ useEffect(() => {
1500
+ if (!(options != null && options.formState)) {
1501
+ return () => formState.cleanup();
1502
+ }
1503
+ }, [formState, options == null ? void 0 : options.formState]);
1504
+ const definition = state.definition;
1505
+ const visible = !state.hidden;
1506
+ const visibility = useControl(() => visible != null ? {
1507
+ visible,
1508
+ showing: visible
1509
+ } : undefined);
1510
+ visibility.fields.visible.value = visible;
1511
+ const dataContext = {
1512
+ schemaInterface: state.schemaInterface,
1513
+ dataNode: state.dataNode,
1514
+ parentNode: data,
1515
+ variables: state.variables
1516
+ };
1517
+ const adornments = (_definition$adornment = (_definition$adornment2 = definition.adornments) == null ? void 0 : _definition$adornment2.map(x => renderer.renderAdornment({
1518
+ adornment: x,
1519
+ dataContext,
1520
+ formOptions: state
1521
+ }))) != null ? _definition$adornment : [];
1522
+ const {
1523
+ styleClass,
1524
+ labelClass,
1525
+ labelTextClass,
1526
+ textClass
1527
+ } = options,
1528
+ inheritableOptions = _objectWithoutPropertiesLoose(options, _excluded);
1529
+ const {
1530
+ readonly,
1531
+ hidden,
1532
+ disabled,
1533
+ variables
1534
+ } = state;
1535
+ const childOptions = _extends({}, inheritableOptions, {
1536
+ readonly,
1537
+ disabled,
1538
+ variables,
1539
+ formState
1540
+ });
1541
+ const labelAndChildren = renderControlLayout({
1542
+ formNode: form,
1543
+ renderer,
1544
+ state,
1545
+ renderChild: (k, child, options) => {
1546
+ var _ref2;
1547
+ const overrideClasses = getGroupClassOverrides(definition);
1548
+ const _ref = options != null ? options : {},
1549
+ {
1550
+ parentDataNode,
1551
+ actionOnClick,
1552
+ variables
1553
+ } = _ref,
1554
+ renderOptions = _objectWithoutPropertiesLoose(_ref, _excluded2);
1555
+ const dContext = (_ref2 = parentDataNode != null ? parentDataNode : dataContext.dataNode) != null ? _ref2 : data;
1556
+ const allChildOptions = _extends({}, childOptions, overrideClasses, renderOptions, {
1557
+ variables: _extends({}, childOptions.variables, variables),
1558
+ actionOnClick: actionHandlers(actionOnClick, childOptions.actionOnClick)
1559
+ });
1560
+ return /*#__PURE__*/jsx(RenderForm, {
1561
+ form: child,
1562
+ renderer: renderer,
1563
+ data: dContext,
1564
+ options: allChildOptions
1565
+ }, k);
1566
+ },
1567
+ inline: options == null ? void 0 : options.inline,
1568
+ displayOnly: options == null ? void 0 : options.displayOnly,
1569
+ createDataProps: defaultDataProps,
1570
+ formOptions: state,
1571
+ dataContext,
1572
+ control: (_dataContext$dataNode = dataContext.dataNode) == null ? void 0 : _dataContext$dataNode.control,
1573
+ schemaInterface,
1574
+ style: state.style,
1575
+ allowedOptions: state.allowedOptions,
1576
+ customDisplay: options.customDisplay,
1577
+ actionOnClick: options.actionOnClick,
1578
+ styleClass: styleClass,
1579
+ labelClass: labelClass,
1580
+ labelTextClass: labelTextClass,
1581
+ textClass: textClass,
1582
+ getChildState(child, parent) {
1583
+ var _ref3;
1584
+ return formState.getControlState((_ref3 = parent != null ? parent : state.dataNode) != null ? _ref3 : data, child, childOptions);
1585
+ },
1586
+ runExpression: (scope, expr, returnResult) => {
1587
+ if (expr != null && expr.type) {
1588
+ formState.evalExpression(expr, {
1589
+ scope,
1590
+ dataNode: data,
1591
+ schemaInterface,
1592
+ returnResult
1593
+ });
1594
+ }
1595
+ }
1596
+ });
1597
+ const layoutProps = _extends({}, labelAndChildren, {
1598
+ adornments,
1599
+ className: rendererClass(options.layoutClass, definition.layoutClass),
1600
+ style: state.layoutStyle
1601
+ });
1602
+ const renderedControl = renderer.renderLayout((_options$adjustLayout = options.adjustLayout == null ? void 0 : options.adjustLayout(dataContext, layoutProps)) != null ? _options$adjustLayout : layoutProps);
1603
+ return renderer.renderVisibility(_extends({
1604
+ visibility
1605
+ }, renderedControl));
1606
+ } finally {
1607
+ _effect();
1608
+ }
1609
+ }
1610
+ /**
1611
+ * @deprecated Use RenderForm instead.
1612
+ */
1613
+ function useControlRendererComponent(controlOrFormNode, renderer, options = {}, parentDataNode) {
1614
+ const [definition, formNode] = "definition" in controlOrFormNode ? [controlOrFormNode.definition, controlOrFormNode] : [controlOrFormNode, legacyFormNode(controlOrFormNode)];
1615
+ const r = useUpdatedRef({
1616
+ options,
1617
+ renderer,
1618
+ parentDataNode,
1619
+ formNode
1620
+ });
1621
+ return useMemo(() => () => {
1622
+ const {
1623
+ options,
1624
+ parentDataNode,
1625
+ formNode,
1626
+ renderer
1627
+ } = r.current;
1628
+ return /*#__PURE__*/jsx(RenderForm, {
1629
+ data: parentDataNode,
1630
+ form: formNode,
1631
+ renderer: renderer,
1632
+ options: options
1633
+ });
1634
+ }, [r]);
1635
+ }
1636
+ /**
1637
+ * @deprecated Use RenderForm instead.
1638
+ */
1639
+ function ControlRenderer({
1640
+ definition,
1641
+ fields,
1642
+ renderer,
1643
+ options,
1644
+ control,
1645
+ parentPath
1646
+ }) {
1647
+ var _effect2 = useComponentTracking();
1648
+ try {
1649
+ const schemaDataNode = createSchemaDataNode(createSchemaTree(fields).rootNode, control);
1650
+ const Render = useControlRendererComponent(definition, renderer, options, schemaDataNode);
1651
+ return /*#__PURE__*/jsx(Render, {});
1652
+ } finally {
1653
+ _effect2();
1654
+ }
1655
+ }
1656
+ /**
1657
+ * @deprecated Use RenderForm instead.
1658
+ */
1659
+ function NewControlRenderer({
1660
+ definition,
1661
+ renderer,
1662
+ options,
1663
+ parentDataNode
1664
+ }) {
1665
+ var _effect3 = useComponentTracking();
1666
+ try {
1667
+ const Render = useControlRendererComponent(definition, renderer, options, parentDataNode);
1668
+ return /*#__PURE__*/jsx(Render, {});
1669
+ } finally {
1670
+ _effect3();
1671
+ }
1672
+ }
1673
+ /**
1674
+ * @deprecated Use RenderForm instead.
1675
+ */
1676
+ function useControlRenderer(definition, fields, renderer, options = {}) {
1677
+ const r = useUpdatedRef({
1678
+ definition,
1679
+ fields,
1680
+ renderer,
1681
+ options
1682
+ });
1683
+ return useCallback(({
1684
+ control,
1685
+ parentPath
1686
+ }) => {
1687
+ return /*#__PURE__*/jsx(ControlRenderer, _extends({}, r.current, {
1688
+ control: control,
1689
+ parentPath: parentPath
1690
+ }));
1691
+ }, [r]);
1692
+ }
1693
+
1694
+ export { AppendAdornmentPriority, ControlRenderer, LabelType, NewControlRenderer, RenderForm, WrapAdornmentPriority, accordionOptions, actionControl, actionHandlers, addMissingControls, addMissingControlsForSchema, adornmentOptions, appendMarkup, appendMarkupAt, applyArrayLengthRestrictions, applyDefaultForField, applyDefaultValues, applyExtensionToSchema, applyExtensionsToSchema, applyLengthRestrictions, applyValues, autocompleteOptions, checkListOptions, cleanDataForSchema, coerceToString, collectDifferences, compoundControl, controlTitle, createAction, createActionRenderer, createAdornmentRenderer, createArrayActions, createArrayRenderer, createDataRenderer, createDisplayRenderer, createFormRenderer, createGroupRenderer, createLabelRenderer, createLayoutRenderer, createVisibilityRenderer, dataControl, dateValidatorOptions, deepMerge, defaultControlForField, defaultDataProps, defaultValueForField, defaultValueForFields, displayOnlyOptions, dynamicDefaultValue, dynamicDisabled, dynamicReadonly, dynamicVisibility, elementValueForField, emptyGroupDefinition, fieldDisplayName, fieldEqExpr, fieldExpr, fieldHasTag, fieldOptionAdornment, findChildDefinition, findCompoundField, findControlsForCompound, findFieldPath, findNonDataGroups, findScalarField, getAllReferencedClasses, getAllValues, getDiffObject, getExternalEditData, getGroupClassOverrides, getIsEditing, getLastDefinedValue, getLengthRestrictions, getNullToggler, getOverrideClass, groupedControl, hasOptions, htmlDisplayControl, isAccordionAdornment, isIconAdornment, isOptionalAdornment, isSetFieldAdornment, jsonataExpr, jsonataOptions, jsonataValidatorOptions, layoutKeyForPlacement, lengthValidatorOptions, lookupChildDataContext, mergeObjects, radioButtonOptions, renderControlLayout, renderLayoutParts, renderOptionsFor, rendererClass, textDisplayControl, textfieldOptions, useControlDefinitionForSchema, useControlRenderer, useControlRendererComponent, useExpression, useUpdatedRef, validationVisitor, validatorOptions, wrapLayout, wrapMarkup, wrapMarkupAt };
2932
1695
  //# sourceMappingURL=index.js.map