@react-typed-forms/schemas 15.1.3 → 15.2.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.cjs CHANGED
@@ -1,6 +1,6 @@
1
+ var core = require('@react-typed-forms/core');
1
2
  var react = require('react');
2
3
  var clsx = require('clsx');
3
- var core = require('@react-typed-forms/core');
4
4
  var jsonata = require('jsonata');
5
5
  var uuid = require('uuid');
6
6
  var jsxRuntime = require('react/jsx-runtime');
@@ -10,6 +10,302 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
10
10
  var clsx__default = /*#__PURE__*/_interopDefaultLegacy(clsx);
11
11
  var jsonata__default = /*#__PURE__*/_interopDefaultLegacy(jsonata);
12
12
 
13
+ function _arrayLikeToArray(r, a) {
14
+ (null == a || a > r.length) && (a = r.length);
15
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
16
+ return n;
17
+ }
18
+ function _createForOfIteratorHelperLoose(r, e) {
19
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
20
+ if (t) return (t = t.call(r)).next.bind(t);
21
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
22
+ t && (r = t);
23
+ var o = 0;
24
+ return function () {
25
+ return o >= r.length ? {
26
+ done: !0
27
+ } : {
28
+ done: !1,
29
+ value: r[o++]
30
+ };
31
+ };
32
+ }
33
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
34
+ }
35
+ function _extends() {
36
+ return _extends = Object.assign ? Object.assign.bind() : function (n) {
37
+ for (var e = 1; e < arguments.length; e++) {
38
+ var t = arguments[e];
39
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
40
+ }
41
+ return n;
42
+ }, _extends.apply(null, arguments);
43
+ }
44
+ function _inheritsLoose(t, o) {
45
+ t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
46
+ }
47
+ function _objectWithoutPropertiesLoose(r, e) {
48
+ if (null == r) return {};
49
+ var t = {};
50
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
51
+ if (e.includes(n)) continue;
52
+ t[n] = r[n];
53
+ }
54
+ return t;
55
+ }
56
+ function _setPrototypeOf(t, e) {
57
+ return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
58
+ return t.__proto__ = e, t;
59
+ }, _setPrototypeOf(t, e);
60
+ }
61
+ function _unsupportedIterableToArray(r, a) {
62
+ if (r) {
63
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
64
+ var t = {}.toString.call(r).slice(8, -1);
65
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
66
+ }
67
+ }
68
+
69
+ /**
70
+ * Enum representing the various field types.
71
+ */
72
+ exports.FieldType = void 0;
73
+ (function (FieldType) {
74
+ FieldType["String"] = "String";
75
+ FieldType["Bool"] = "Bool";
76
+ FieldType["Int"] = "Int";
77
+ FieldType["Date"] = "Date";
78
+ FieldType["DateTime"] = "DateTime";
79
+ FieldType["Time"] = "Time";
80
+ FieldType["Double"] = "Double";
81
+ FieldType["EntityRef"] = "EntityRef";
82
+ FieldType["Compound"] = "Compound";
83
+ FieldType["AutoId"] = "AutoId";
84
+ FieldType["Image"] = "Image";
85
+ FieldType["Any"] = "Any";
86
+ })(exports.FieldType || (exports.FieldType = {}));
87
+ /**
88
+ * Enum representing the various validation message types.
89
+ */
90
+ exports.ValidationMessageType = void 0;
91
+ (function (ValidationMessageType) {
92
+ ValidationMessageType["NotEmpty"] = "NotEmpty";
93
+ ValidationMessageType["MinLength"] = "MinLength";
94
+ ValidationMessageType["MaxLength"] = "MaxLength";
95
+ ValidationMessageType["NotAfterDate"] = "NotAfterDate";
96
+ ValidationMessageType["NotBeforeDate"] = "NotBeforeDate";
97
+ })(exports.ValidationMessageType || (exports.ValidationMessageType = {}));
98
+ function findField(fields, field) {
99
+ return fields.find(function (x) {
100
+ return x.field === field;
101
+ });
102
+ }
103
+ function isScalarField(sf) {
104
+ return !isCompoundField(sf);
105
+ }
106
+ function isCompoundField(sf) {
107
+ return sf.type === exports.FieldType.Compound;
108
+ }
109
+ function missingField(field) {
110
+ return {
111
+ field: "__missing",
112
+ type: exports.FieldType.Any,
113
+ displayName: field
114
+ };
115
+ }
116
+ function nodeForSchema(field, lookup, parent) {
117
+ var node = {
118
+ id: parent ? parent.id + "/" + field.field : field.field,
119
+ field: field,
120
+ getSchema: lookup.getSchema,
121
+ parent: parent,
122
+ getChildNode: getChildNode,
123
+ getChildNodes: getChildNodes
124
+ };
125
+ return node;
126
+ function getChildNode(fieldName) {
127
+ if (isCompoundField(field) && !field.schemaRef && !field.treeChildren) {
128
+ var childField = field.children.find(function (x) {
129
+ return x.field === fieldName;
130
+ });
131
+ return childField ? nodeForSchema(childField, lookup, node) : undefined;
132
+ }
133
+ return getChildNodes(false, node).find(function (x) {
134
+ return x.field.field === fieldName;
135
+ });
136
+ }
137
+ function getChildNodes(noRecurse, withParent) {
138
+ if (isCompoundField(field)) {
139
+ if (field.treeChildren) {
140
+ return noRecurse ? [] : parent.getChildNodes(false, withParent != null ? withParent : node);
141
+ }
142
+ var otherRef = field.schemaRef && lookup.getSchema(field.schemaRef);
143
+ if (otherRef) return otherRef.getChildNodes(false, withParent != null ? withParent : node);
144
+ return field.children.map(function (x) {
145
+ return nodeForSchema(x, lookup, withParent != null ? withParent : node);
146
+ });
147
+ }
148
+ return [];
149
+ }
150
+ }
151
+ function createSchemaLookup(schemaMap) {
152
+ var lookup = {
153
+ getSchema: getSchema
154
+ };
155
+ return lookup;
156
+ function getSchema(schemaId) {
157
+ var fields = schemaMap[schemaId];
158
+ if (fields) {
159
+ return rootSchemaNode(fields, lookup);
160
+ }
161
+ return undefined;
162
+ }
163
+ }
164
+ function makeSchemaDataNode(schema, control, parent, elementIndex) {
165
+ var indexId = typeof elementIndex === "number" ? "/" + elementIndex : "";
166
+ var dataNode = {
167
+ id: (parent ? parent.id + "/" + schema.field.field : schema.field.field) + indexId,
168
+ schema: schema,
169
+ control: control,
170
+ parent: parent,
171
+ elementIndex: elementIndex,
172
+ getChild: getChild,
173
+ getChildElement: getChildElement
174
+ };
175
+ return dataNode;
176
+ function getChild(childNode) {
177
+ var objControl = control;
178
+ if (objControl && objControl.current.isNull) {
179
+ objControl.value = {};
180
+ }
181
+ return makeSchemaDataNode(childNode, objControl == null ? void 0 : objControl.fields[childNode.field.field], dataNode);
182
+ }
183
+ function getChildElement(elementIndex) {
184
+ var _control$elements;
185
+ return makeSchemaDataNode(schema, control == null || (_control$elements = control.elements) == null ? void 0 : _control$elements[elementIndex], dataNode, elementIndex);
186
+ }
187
+ }
188
+ function schemaDataForFieldRef(fieldRef, schema) {
189
+ var _fieldRef$split;
190
+ return schemaDataForFieldPath((_fieldRef$split = fieldRef == null ? void 0 : fieldRef.split("/")) != null ? _fieldRef$split : [], schema);
191
+ }
192
+ function schemaForFieldRef(fieldRef, schema) {
193
+ var _fieldRef$split2;
194
+ return schemaForFieldPath((_fieldRef$split2 = fieldRef == null ? void 0 : fieldRef.split("/")) != null ? _fieldRef$split2 : [], schema);
195
+ }
196
+ function traverseSchemaPath(fieldPath, schema, acc, next) {
197
+ var i = 0;
198
+ while (i < fieldPath.length) {
199
+ var nextField = fieldPath[i];
200
+ var childNode = nextField === ".." ? schema.parent : schema.getChildNode(nextField);
201
+ if (!childNode) {
202
+ childNode = nodeForSchema(missingField(nextField), schema, schema);
203
+ }
204
+ acc = next(acc, childNode);
205
+ schema = childNode;
206
+ i++;
207
+ }
208
+ return acc;
209
+ }
210
+ function traverseData(fieldPath, root, data) {
211
+ return traverseSchemaPath(fieldPath, root, data, function (acc, n) {
212
+ return acc == null ? void 0 : acc[n.field.field];
213
+ });
214
+ }
215
+ function schemaDataForFieldPath(fieldPath, dataNode) {
216
+ var i = 0;
217
+ while (i < fieldPath.length) {
218
+ var _nextNode;
219
+ var nextField = fieldPath[i];
220
+ var nextNode = nextField === ".." ? dataNode.parent : lookupField(nextField);
221
+ (_nextNode = nextNode) != null ? _nextNode : nextNode = makeSchemaDataNode(nodeForSchema(missingField(nextField), dataNode.schema, dataNode.schema), core.newControl(undefined));
222
+ dataNode = nextNode;
223
+ i++;
224
+ }
225
+ return dataNode;
226
+ function lookupField(field) {
227
+ var childNode = dataNode.schema.getChildNode(field);
228
+ if (childNode) {
229
+ return dataNode.getChild(childNode);
230
+ }
231
+ return undefined;
232
+ }
233
+ }
234
+ function schemaForFieldPath(fieldPath, schema) {
235
+ var i = 0;
236
+ while (i < fieldPath.length) {
237
+ var nextField = fieldPath[i];
238
+ var childNode = nextField === ".." ? schema.parent : schema.getChildNode(nextField);
239
+ if (!childNode) {
240
+ childNode = nodeForSchema(missingField(nextField), schema, schema);
241
+ }
242
+ schema = childNode;
243
+ i++;
244
+ }
245
+ return schema;
246
+ }
247
+ function rootSchemaNode(fields, lookup) {
248
+ if (lookup === void 0) {
249
+ lookup = {
250
+ getSchema: function getSchema(schemaId) {
251
+ return undefined;
252
+ }
253
+ };
254
+ }
255
+ return nodeForSchema({
256
+ type: exports.FieldType.Compound,
257
+ field: "",
258
+ children: fields
259
+ }, lookup, undefined);
260
+ }
261
+ function getSchemaNodePath(node) {
262
+ var paths = [];
263
+ var curNode = node;
264
+ while (curNode) {
265
+ paths.push(curNode.field.field);
266
+ curNode = curNode.parent;
267
+ }
268
+ return paths.reverse();
269
+ }
270
+ function isCompoundNode(node) {
271
+ return isCompoundField(node.field);
272
+ }
273
+ /**
274
+ * Returns the relative path from a parent node to a child node.
275
+ * @param parent
276
+ * @param child
277
+ */
278
+ function relativePath(parent, child) {
279
+ // return the path from child to parent
280
+ if (parent.id === child.id) return "";
281
+ var parentPath = getSchemaNodePath(parent);
282
+ var childPath = getSchemaNodePath(child);
283
+ var i = 0;
284
+ while (i < parentPath.length && i < childPath.length && parentPath[i] === childPath[i]) {
285
+ i++;
286
+ }
287
+ var upLevels = parentPath.length - i;
288
+ var downPath = childPath.slice(i).join("/");
289
+ return "../".repeat(upLevels) + downPath;
290
+ }
291
+ exports.SchemaTags = void 0;
292
+ (function (SchemaTags) {
293
+ SchemaTags["NoControl"] = "_NoControl";
294
+ SchemaTags["HtmlEditor"] = "_HtmlEditor";
295
+ SchemaTags["ControlGroup"] = "_ControlGroup:";
296
+ SchemaTags["ControlRef"] = "_ControlRef:";
297
+ SchemaTags["IdField"] = "_IdField:";
298
+ })(exports.SchemaTags || (exports.SchemaTags = {}));
299
+ function getTagParam(field, tag) {
300
+ var _field$tags;
301
+ return (_field$tags = field.tags) == null || (_field$tags = _field$tags.find(function (x) {
302
+ return x.startsWith(tag);
303
+ })) == null ? void 0 : _field$tags.substring(tag.length);
304
+ }
305
+ function makeParamTag(tag, value) {
306
+ return "" + tag + value;
307
+ }
308
+
13
309
  exports.ControlDefinitionType = void 0;
14
310
  (function (ControlDefinitionType) {
15
311
  ControlDefinitionType["Data"] = "Data";
@@ -46,12 +342,6 @@ exports.ControlAdornmentType = void 0;
46
342
  ControlAdornmentType["SetField"] = "SetField";
47
343
  ControlAdornmentType["Optional"] = "Optional";
48
344
  })(exports.ControlAdornmentType || (exports.ControlAdornmentType = {}));
49
- exports.IconLibrary = void 0;
50
- (function (IconLibrary) {
51
- IconLibrary["FontAwesome"] = "FontAwesome";
52
- IconLibrary["Material"] = "Material";
53
- IconLibrary["CssClass"] = "CssClass";
54
- })(exports.IconLibrary || (exports.IconLibrary = {}));
55
345
  exports.DataRenderType = void 0;
56
346
  (function (DataRenderType) {
57
347
  DataRenderType["Standard"] = "Standard";
@@ -88,7 +378,6 @@ exports.GroupRenderType = void 0;
88
378
  GroupRenderType["Tabs"] = "Tabs";
89
379
  GroupRenderType["GroupElement"] = "GroupElement";
90
380
  GroupRenderType["SelectChild"] = "SelectChild";
91
- GroupRenderType["Inline"] = "Inline";
92
381
  })(exports.GroupRenderType || (exports.GroupRenderType = {}));
93
382
  exports.DisplayDataType = void 0;
94
383
  (function (DisplayDataType) {
@@ -97,16 +386,6 @@ exports.DisplayDataType = void 0;
97
386
  DisplayDataType["Icon"] = "Icon";
98
387
  DisplayDataType["Custom"] = "Custom";
99
388
  })(exports.DisplayDataType || (exports.DisplayDataType = {}));
100
- exports.ActionStyle = void 0;
101
- (function (ActionStyle) {
102
- ActionStyle["Button"] = "Button";
103
- ActionStyle["Link"] = "Link";
104
- })(exports.ActionStyle || (exports.ActionStyle = {}));
105
- exports.IconPlacement = void 0;
106
- (function (IconPlacement) {
107
- IconPlacement["BeforeText"] = "BeforeText";
108
- IconPlacement["AfterText"] = "AfterText";
109
- })(exports.IconPlacement || (exports.IconPlacement = {}));
110
389
  function visitControlDefinition(x, visitor, defaultValue) {
111
390
  switch (x.type) {
112
391
  case exports.ControlDefinitionType.Action:
@@ -124,9 +403,6 @@ function visitControlDefinition(x, visitor, defaultValue) {
124
403
  function isGridRenderer(options) {
125
404
  return options.type === exports.GroupRenderType.Grid;
126
405
  }
127
- function isInlineRenderer(options) {
128
- return options.type === exports.GroupRenderType.Inline;
129
- }
130
406
  function isSelectChildRenderer(options) {
131
407
  return options.type === exports.GroupRenderType.SelectChild;
132
408
  }
@@ -183,669 +459,61 @@ function isCheckEntryClasses(options) {
183
459
  return false;
184
460
  }
185
461
  }
186
- function traverseParents(current, get, until) {
187
- var outArray = [];
188
- while (current && !(until != null && until(current))) {
189
- outArray.push(get(current));
190
- current = current.parent;
191
- }
192
- return outArray.reverse();
193
- }
194
- function getRootDataNode(dataNode) {
195
- while (dataNode.parent) {
196
- dataNode = dataNode.parent;
197
- }
198
- return dataNode;
199
- }
200
- function getJsonPath(dataNode) {
201
- return traverseParents(dataNode, function (d) {
202
- return d.elementIndex == null ? d.schema.field.field : d.elementIndex;
203
- }, function (x) {
204
- return !x.parent;
205
- });
206
- }
207
- function getSchemaPath(schemaNode) {
208
- return traverseParents(schemaNode, function (d) {
209
- return d.field;
210
- }, function (x) {
211
- return !x.parent;
212
- });
213
- }
214
- function getSchemaFieldList(schema) {
215
- return schema.getChildNodes().map(function (x) {
216
- return x.field;
217
- });
218
- }
219
- function fontAwesomeIcon(icon) {
220
- return {
221
- library: exports.IconLibrary.FontAwesome,
222
- name: icon
223
- };
224
- }
225
-
226
- function _arrayLikeToArray(r, a) {
227
- (null == a || a > r.length) && (a = r.length);
228
- for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
229
- return n;
230
- }
231
- function _createForOfIteratorHelperLoose(r, e) {
232
- var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
233
- if (t) return (t = t.call(r)).next.bind(t);
234
- if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
235
- t && (r = t);
236
- var o = 0;
237
- return function () {
238
- return o >= r.length ? {
239
- done: !0
240
- } : {
241
- done: !1,
242
- value: r[o++]
243
- };
244
- };
245
- }
246
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
247
- }
248
- function _extends() {
249
- return _extends = Object.assign ? Object.assign.bind() : function (n) {
250
- for (var e = 1; e < arguments.length; e++) {
251
- var t = arguments[e];
252
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
253
- }
254
- return n;
255
- }, _extends.apply(null, arguments);
256
- }
257
- function _inheritsLoose(t, o) {
258
- t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
259
- }
260
- function _objectWithoutPropertiesLoose(r, e) {
261
- if (null == r) return {};
262
- var t = {};
263
- for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
264
- if (e.includes(n)) continue;
265
- t[n] = r[n];
266
- }
267
- return t;
268
- }
269
- function _setPrototypeOf(t, e) {
270
- return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
271
- return t.__proto__ = e, t;
272
- }, _setPrototypeOf(t, e);
273
- }
274
- function _unsupportedIterableToArray(r, a) {
275
- if (r) {
276
- if ("string" == typeof r) return _arrayLikeToArray(r, a);
277
- var t = {}.toString.call(r).slice(8, -1);
278
- return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
279
- }
280
- }
281
-
282
- /**
283
- * Enum representing the various field types.
284
- */
285
- exports.FieldType = void 0;
286
- (function (FieldType) {
287
- FieldType["String"] = "String";
288
- FieldType["Bool"] = "Bool";
289
- FieldType["Int"] = "Int";
290
- FieldType["Date"] = "Date";
291
- FieldType["DateTime"] = "DateTime";
292
- FieldType["Time"] = "Time";
293
- FieldType["Double"] = "Double";
294
- FieldType["EntityRef"] = "EntityRef";
295
- FieldType["Compound"] = "Compound";
296
- FieldType["AutoId"] = "AutoId";
297
- FieldType["Image"] = "Image";
298
- FieldType["Any"] = "Any";
299
- })(exports.FieldType || (exports.FieldType = {}));
300
- /**
301
- * Enum representing the various validation message types.
302
- */
303
- exports.ValidationMessageType = void 0;
304
- (function (ValidationMessageType) {
305
- ValidationMessageType["NotEmpty"] = "NotEmpty";
306
- ValidationMessageType["MinLength"] = "MinLength";
307
- ValidationMessageType["MaxLength"] = "MaxLength";
308
- ValidationMessageType["NotAfterDate"] = "NotAfterDate";
309
- ValidationMessageType["NotBeforeDate"] = "NotBeforeDate";
310
- })(exports.ValidationMessageType || (exports.ValidationMessageType = {}));
311
- function findField(fields, field) {
312
- return fields.find(function (x) {
313
- return x.field === field;
314
- });
315
- }
316
- function isScalarField(sf) {
317
- return !isCompoundField(sf);
318
- }
319
- function isCompoundField(sf) {
320
- return sf.type === exports.FieldType.Compound;
321
- }
322
- function missingField(field) {
323
- return {
324
- field: "__missing",
325
- type: exports.FieldType.Any,
326
- displayName: field
327
- };
328
- }
329
- exports.SchemaTags = void 0;
330
- (function (SchemaTags) {
331
- SchemaTags["NoControl"] = "_NoControl";
332
- SchemaTags["HtmlEditor"] = "_HtmlEditor";
333
- SchemaTags["ControlGroup"] = "_ControlGroup:";
334
- SchemaTags["ControlRef"] = "_ControlRef:";
335
- SchemaTags["IdField"] = "_IdField:";
336
- })(exports.SchemaTags || (exports.SchemaTags = {}));
337
- function getTagParam(field, tag) {
338
- var _field$tags;
339
- return (_field$tags = field.tags) == null || (_field$tags = _field$tags.find(function (x) {
340
- return x.startsWith(tag);
341
- })) == null ? void 0 : _field$tags.substring(tag.length);
342
- }
343
- function makeParamTag(tag, value) {
344
- return "" + tag + value;
345
- }
346
-
347
- function buildSchema(def) {
348
- return Object.entries(def).map(function (x) {
349
- return x[1](x[0]);
350
- });
351
- }
352
- function stringField(displayName, options) {
353
- return makeScalarField(_extends({
354
- type: exports.FieldType.String,
355
- displayName: displayName
356
- }, options));
357
- }
358
- function stringOptionsField(displayName) {
359
- return makeScalarField({
360
- type: exports.FieldType.String,
361
- displayName: displayName,
362
- options: [].slice.call(arguments, 1)
363
- });
364
- }
365
- function withScalarOptions(options, v) {
366
- return function (n) {
367
- return _extends({}, v(n), options);
368
- };
369
- }
370
- function makeScalarField(options) {
371
- return function (n) {
372
- return _extends({}, defaultScalarField(n, n), options);
373
- };
374
- }
375
- function makeCompoundField(options) {
376
- return function (n) {
377
- return _extends({}, defaultCompoundField(n, n, false), options);
378
- };
379
- }
380
- function intField(displayName, options) {
381
- return makeScalarField(_extends({
382
- type: exports.FieldType.Int,
383
- displayName: displayName
384
- }, options));
385
- }
386
- function doubleField(displayName, options) {
387
- return makeScalarField(_extends({
388
- type: exports.FieldType.Double,
389
- displayName: displayName
390
- }, options));
391
- }
392
- function dateField(displayName, options) {
393
- return makeScalarField(_extends({
394
- type: exports.FieldType.Date,
395
- displayName: displayName
396
- }, options));
397
- }
398
- function timeField(displayName, options) {
399
- return makeScalarField(_extends({
400
- type: exports.FieldType.Time,
401
- displayName: displayName
402
- }, options));
403
- }
404
- function dateTimeField(displayName, options) {
405
- return makeScalarField(_extends({
406
- type: exports.FieldType.DateTime,
407
- displayName: displayName
408
- }, options));
409
- }
410
- function boolField(displayName, options) {
411
- return makeScalarField(_extends({
412
- type: exports.FieldType.Bool,
413
- displayName: displayName
414
- }, options));
415
- }
416
- function compoundField(displayName, fields, other) {
417
- return function (field) {
418
- return _extends({}, defaultCompoundField(field, displayName, false), other, {
419
- children: fields
420
- });
421
- };
422
- }
423
- function defaultScalarField(field, displayName) {
424
- return {
425
- field: field,
426
- displayName: displayName,
427
- type: exports.FieldType.String
428
- };
429
- }
430
- function defaultCompoundField(field, displayName, collection) {
431
- return {
432
- field: field,
433
- displayName: displayName,
434
- type: exports.FieldType.Compound,
435
- collection: collection,
436
- children: []
437
- };
438
- }
439
- function mergeField(field, mergeInto) {
440
- var existing = mergeInto.find(function (x) {
441
- return x.field === field.field;
442
- });
443
- if (existing) {
444
- return mergeInto.map(function (x) {
445
- return x !== existing ? x : _extends({}, x, {
446
- onlyForTypes: mergeTypes(x.onlyForTypes, field.onlyForTypes)
447
- });
448
- });
449
- }
450
- return [].concat(mergeInto, [field]);
451
- function mergeTypes(f, s) {
452
- if (!f) return s;
453
- if (!s) return f;
454
- var extras = s.filter(function (x) {
455
- return !f.includes(x);
456
- });
457
- return extras.length ? [].concat(f, extras) : f;
458
- }
459
- }
460
- function mergeFields(fields, name, value, newFields) {
461
- var withType = fields.map(function (x) {
462
- return x.isTypeField ? addFieldOption(x, name, value) : x;
463
- });
464
- return newFields.map(function (x) {
465
- return _extends({}, x, {
466
- onlyForTypes: [value]
467
- });
468
- }).reduce(function (af, x) {
469
- return mergeField(x, af);
470
- }, withType);
471
- }
472
- function addFieldOption(typeField, name, value) {
473
- var _typeField$options;
474
- var options = (_typeField$options = typeField.options) != null ? _typeField$options : [];
475
- if (options.some(function (x) {
476
- return x.value === value;
477
- })) return typeField;
478
- return _extends({}, typeField, {
479
- options: [].concat(options, [{
480
- name: name,
481
- value: value
482
- }])
483
- });
484
- }
485
- function resolveSchemas(schemaMap) {
486
- var out = {};
487
- function resolveSchemaType(type) {
488
- if (type in out) {
489
- return out[type];
490
- }
491
- var resolvedFields = [];
492
- out[type] = resolvedFields;
493
- schemaMap[type].forEach(function (x) {
494
- if (isCompoundField(x) && x.schemaRef) {
495
- resolvedFields.push(_extends({}, x, {
496
- children: resolveSchemaType(x.schemaRef)
497
- }));
498
- } else {
499
- resolvedFields.push(x);
500
- }
501
- });
502
- return resolvedFields;
503
- }
504
- Object.keys(schemaMap).forEach(resolveSchemaType);
505
- return out;
506
- }
507
-
508
- var SchemaTree = /*#__PURE__*/function () {
509
- function SchemaTree() {}
510
- var _proto = SchemaTree.prototype;
511
- _proto.createChildNode = function createChildNode(parent, field) {
512
- return new SchemaNode(parent.id + "/" + field.field, field, this, parent);
513
- };
514
- _proto.getSchema = function getSchema(schemaId) {
515
- var _this$getSchemaTree;
516
- return (_this$getSchemaTree = this.getSchemaTree(schemaId)) == null ? void 0 : _this$getSchemaTree.rootNode;
517
- };
518
- return SchemaTree;
519
- }();
520
- var SchemaTreeImpl = /*#__PURE__*/function (_SchemaTree) {
521
- function SchemaTreeImpl(rootFields, lookup) {
522
- var _this;
523
- _this = _SchemaTree.call(this) || this;
524
- _this.lookup = void 0;
525
- _this.rootNode = void 0;
526
- _this.lookup = lookup;
527
- _this.rootNode = new SchemaNode("", {
528
- type: exports.FieldType.Compound,
529
- field: "",
530
- children: rootFields
531
- }, _this);
532
- return _this;
533
- }
534
- _inheritsLoose(SchemaTreeImpl, _SchemaTree);
535
- var _proto2 = SchemaTreeImpl.prototype;
536
- _proto2.getSchemaTree = function getSchemaTree(schemaId) {
537
- var _this$lookup;
538
- return (_this$lookup = this.lookup) == null ? void 0 : _this$lookup.getSchemaTree(schemaId);
539
- };
540
- return SchemaTreeImpl;
541
- }(SchemaTree);
542
- function createSchemaTree(rootFields, lookup) {
543
- return new SchemaTreeImpl(rootFields, lookup);
544
- }
545
- var SchemaNode = /*#__PURE__*/function () {
546
- function SchemaNode(id, field, tree, parent) {
547
- this.id = void 0;
548
- this.field = void 0;
549
- this.tree = void 0;
550
- this.parent = void 0;
551
- this.id = id;
552
- this.field = field;
553
- this.tree = tree;
554
- this.parent = parent;
555
- }
556
- var _proto3 = SchemaNode.prototype;
557
- _proto3.getSchema = function getSchema(schemaId) {
558
- return this.tree.getSchema(schemaId);
559
- };
560
- _proto3.getUnresolvedFields = function getUnresolvedFields() {
561
- return isCompoundField(this.field) ? this.field.children : [];
562
- };
563
- _proto3.getResolvedParent = function getResolvedParent() {
564
- var _this$parent;
565
- var f = this.field;
566
- if (!isCompoundField(f)) return undefined;
567
- var parentNode = f.schemaRef ? this.tree.getSchema(f.schemaRef) : f.treeChildren ? (_this$parent = this.parent) == null ? void 0 : _this$parent.getResolvedParent() : undefined;
568
- return parentNode != null ? parentNode : this;
569
- };
570
- _proto3.getResolvedFields = function getResolvedFields() {
571
- var _resolvedParent$getUn;
572
- var resolvedParent = this.getResolvedParent();
573
- return (_resolvedParent$getUn = resolvedParent == null ? void 0 : resolvedParent.getUnresolvedFields()) != null ? _resolvedParent$getUn : [];
574
- };
575
- _proto3.getChildNodes = function getChildNodes() {
576
- var node = this;
577
- return node.getResolvedFields().map(function (x) {
578
- return node.createChildNode(x);
579
- });
580
- };
581
- _proto3.getChildField = function getChildField(field) {
582
- var _this$getResolvedFiel;
583
- return (_this$getResolvedFiel = this.getResolvedFields().find(function (x) {
584
- return x.field === field;
585
- })) != null ? _this$getResolvedFiel : missingField(field);
586
- };
587
- _proto3.createChildNode = function createChildNode(field) {
588
- return this.tree.createChildNode(this, field);
589
- };
590
- _proto3.getChildNode = function getChildNode(field) {
591
- return this.createChildNode(this.getChildField(field));
592
- };
593
- return SchemaNode;
594
- }();
595
- function resolveSchemaNode(node, fieldSegment) {
596
- if (fieldSegment == ".") return node;
597
- if (fieldSegment == "..") return node.parent;
598
- return node.getChildNode(fieldSegment);
599
- }
600
- function createSchemaNode(field, lookup, parent) {
601
- return new SchemaNode(parent ? parent.id + "/" + field.field : field.field, field, lookup, parent);
602
- }
603
- function createSchemaLookup(schemaMap) {
604
- var lookup = {
605
- getSchemaTree: getSchemaTree,
606
- getSchema: getSchema
607
- };
608
- return lookup;
609
- function getSchema(schemaId) {
610
- return getSchemaTree(schemaId).rootNode;
611
- }
612
- function getSchemaTree(schemaId) {
613
- var fields = schemaMap[schemaId];
614
- if (fields) {
615
- return new SchemaTreeImpl(fields, lookup);
616
- }
617
- return undefined;
618
- }
619
- }
620
- function schemaForFieldRef(fieldRef, schema) {
621
- var _fieldRef$split;
622
- return schemaForFieldPath((_fieldRef$split = fieldRef == null ? void 0 : fieldRef.split("/")) != null ? _fieldRef$split : [], schema);
623
- }
624
- function traverseSchemaPath(fieldPath, schema, acc, next) {
625
- var i = 0;
626
- while (i < fieldPath.length) {
627
- var nextField = fieldPath[i];
628
- var childNode = resolveSchemaNode(schema, nextField);
629
- if (!childNode) {
630
- childNode = createSchemaNode(missingField(nextField), schema.tree, schema);
631
- }
632
- acc = next(acc, childNode);
633
- schema = childNode;
634
- i++;
635
- }
636
- return acc;
637
- }
638
- function traverseData(fieldPath, root, data) {
639
- return traverseSchemaPath(fieldPath, root, data, function (acc, n) {
640
- return acc == null ? void 0 : acc[n.field.field];
641
- });
642
- }
643
- function schemaForFieldPath(fieldPath, schema) {
644
- var i = 0;
645
- while (i < fieldPath.length) {
646
- var nextField = fieldPath[i];
647
- var childNode = resolveSchemaNode(schema, nextField);
648
- if (!childNode) {
649
- childNode = createSchemaNode(missingField(nextField), schema.tree, schema);
650
- }
651
- schema = childNode;
652
- i++;
653
- }
654
- return schema;
655
- }
656
- function getSchemaNodePath(node) {
657
- var paths = [];
658
- var curNode = node;
659
- while (curNode) {
660
- paths.push(curNode.field.field);
661
- curNode = curNode.parent;
662
- }
663
- return paths.reverse();
664
- }
665
- function getSchemaNodePathString(node) {
666
- return getSchemaNodePath(node).join("/");
667
- }
668
- function isCompoundNode(node) {
669
- return isCompoundField(node.field);
670
- }
671
- /**
672
- * Returns the relative path from a parent node to a child node.
673
- * @param parent
674
- * @param child
675
- */
676
- function relativePath(parent, child) {
677
- // return the path from child to parent
678
- if (parent.id === child.id) return ".";
679
- var parentPath = getSchemaNodePath(parent);
680
- var childPath = getSchemaNodePath(child);
681
- return relativeSegmentPath(parentPath, childPath);
682
- }
683
- /**
684
- * Returns the relative path from a parent node to a child node.
685
- * @param parentPath
686
- * @param childPath
687
- */
688
- function relativeSegmentPath(parentPath, childPath) {
689
- var i = 0;
690
- while (i < parentPath.length && i < childPath.length && parentPath[i] === childPath[i]) {
691
- i++;
692
- }
693
- var upLevels = parentPath.length - i;
694
- var downPath = childPath.slice(i).join("/");
695
- return "../".repeat(upLevels) + downPath;
696
- }
697
-
698
- var SchemaDataTree = function SchemaDataTree() {};
699
- var SchemaDataNode = /*#__PURE__*/function () {
700
- function SchemaDataNode(id, schema, elementIndex, control, tree, parent) {
701
- this.id = void 0;
702
- this.schema = void 0;
703
- this.elementIndex = void 0;
704
- this.control = void 0;
705
- this.tree = void 0;
706
- this.parent = void 0;
707
- this.id = id;
708
- this.schema = schema;
709
- this.elementIndex = elementIndex;
710
- this.control = control;
711
- this.tree = tree;
712
- this.parent = parent;
713
- }
714
- var _proto = SchemaDataNode.prototype;
715
- _proto.getChild = function getChild(childNode) {
716
- return this.tree.getChild(this, childNode);
717
- };
718
- _proto.getChildElement = function getChildElement(elementIndex) {
719
- return this.tree.getChildElement(this, elementIndex);
720
- };
721
- return SchemaDataNode;
722
- }();
723
- var SchemaDataTreeImpl = /*#__PURE__*/function (_SchemaDataTree) {
724
- function SchemaDataTreeImpl(rootSchema, rootControl) {
725
- var _this;
726
- _this = _SchemaDataTree.call(this) || this;
727
- _this.rootNode = void 0;
728
- _this.rootNode = new SchemaDataNode("", rootSchema, undefined, rootControl, _this);
729
- return _this;
730
- }
731
- _inheritsLoose(SchemaDataTreeImpl, _SchemaDataTree);
732
- var _proto2 = SchemaDataTreeImpl.prototype;
733
- _proto2.getChild = function getChild(parent, childNode) {
734
- var objControl = parent.control;
735
- return new SchemaDataNode(parent.id + "/" + childNode.field.field, childNode, undefined, objControl.fields[childNode.field.field], this, parent);
736
- };
737
- _proto2.getChildElement = function getChildElement(parent, elementIndex) {
738
- var elemControl = parent.control;
739
- return new SchemaDataNode(parent.id + "/" + elementIndex, parent.schema, elementIndex, elemControl.elements[elementIndex], this, parent);
740
- };
741
- return SchemaDataTreeImpl;
742
- }(SchemaDataTree);
743
- /**
744
- * @deprecated Use createSchemaDataNode instead.
745
- */
746
- var makeSchemaDataNode = createSchemaDataNode;
747
- function createSchemaDataNode(schema, control) {
748
- return new SchemaDataTreeImpl(schema, control).rootNode;
749
- }
750
- function schemaDataForFieldRef(fieldRef, schema) {
751
- var _fieldRef$split;
752
- return schemaDataForFieldPath((_fieldRef$split = fieldRef == null ? void 0 : fieldRef.split("/")) != null ? _fieldRef$split : [], schema);
753
- }
754
- function schemaDataForFieldPath(fieldPath, dataNode) {
755
- var i = 0;
756
- while (i < fieldPath.length) {
757
- var _nextNode;
758
- var nextField = fieldPath[i];
759
- var nextNode = nextField === ".." ? dataNode.parent : nextField === "." ? dataNode : lookupField(nextField);
760
- (_nextNode = nextNode) != null ? _nextNode : nextNode = makeSchemaDataNode(createSchemaNode(missingField(nextField), dataNode.schema.tree, dataNode.schema), core.newControl(undefined));
761
- dataNode = nextNode;
762
- i++;
763
- }
764
- return dataNode;
765
- function lookupField(field) {
766
- var childNode = resolveSchemaNode(dataNode.schema, field);
767
- if (childNode) {
768
- return dataNode.getChild(childNode);
769
- }
770
- return undefined;
771
- }
772
- }
773
-
774
- var FormNode = /*#__PURE__*/function () {
775
- function FormNode(id, definition, tree, parent) {
462
+ var FormNodeImpl = /*#__PURE__*/function () {
463
+ function FormNodeImpl(id, definition, tree, parent) {
776
464
  this.id = void 0;
777
465
  this.definition = void 0;
778
466
  this.tree = void 0;
779
467
  this.parent = void 0;
468
+ this.children = [];
780
469
  this.id = id;
781
470
  this.definition = definition;
782
471
  this.tree = tree;
783
472
  this.parent = parent;
784
473
  }
785
- var _proto = FormNode.prototype;
786
- _proto.visit = function visit(visitFn) {
787
- var res = visitFn(this);
788
- if (res !== undefined) return res;
789
- var children = this.getUnresolvedChildNodes();
790
- for (var _iterator = _createForOfIteratorHelperLoose(children), _step; !(_step = _iterator()).done;) {
791
- var child = _step.value;
792
- var _res = child.visit(visitFn);
793
- if (_res !== undefined) return _res;
794
- }
795
- return undefined;
796
- };
797
- _proto.getResolvedChildren = function getResolvedChildren() {
798
- var _children, _ref;
799
- var childRefId = this.definition.childRefId;
800
- var parent = childRefId ? this.tree.getByRefId(childRefId) : undefined;
801
- return (_children = (_ref = parent != null ? parent : this.definition) == null ? void 0 : _ref.children) != null ? _children : [];
802
- };
803
- _proto.createChildNode = function createChildNode(childId, childDef) {
804
- return new FormNode(this.tree.getChildId(this.id, childId, childDef), childDef, this.tree, this);
805
- };
474
+ var _proto = FormNodeImpl.prototype;
806
475
  _proto.getChildNodes = function getChildNodes() {
807
- var _this = this;
808
- var resolved = this.getResolvedChildren();
809
- return resolved.map(function (x, i) {
810
- return _this.createChildNode(i.toString(), x);
811
- });
476
+ return this.children;
812
477
  };
813
- _proto.getUnresolvedChildNodes = function getUnresolvedChildNodes() {
814
- var _this$definition$chil,
815
- _this$definition$chil2,
816
- _this2 = this;
817
- return (_this$definition$chil = (_this$definition$chil2 = this.definition.children) == null ? void 0 : _this$definition$chil2.map(function (x, i) {
818
- return _this2.createChildNode(i.toString(), x);
819
- })) != null ? _this$definition$chil : [];
820
- };
821
- return FormNode;
478
+ return FormNodeImpl;
822
479
  }();
823
480
  var FormTree = /*#__PURE__*/function () {
824
481
  function FormTree() {}
825
482
  var _proto2 = FormTree.prototype;
826
- _proto2.getChildId = function getChildId(parentId, childId, control) {
827
- return parentId + "/" + childId;
483
+ _proto2.createTempNode = function createTempNode(id, definition, children, parent) {
484
+ var _this = this;
485
+ var tempNode = {
486
+ id: id,
487
+ definition: definition,
488
+ tree: this,
489
+ parent: parent,
490
+ getChildNodes: function getChildNodes() {
491
+ return children != null ? children : _this.createChildNodes(tempNode, definition.children);
492
+ }
493
+ };
494
+ return tempNode;
495
+ };
496
+ _proto2.createChildNodes = function createChildNodes(parent, definitions) {
497
+ var _definitions$map,
498
+ _this2 = this;
499
+ return (_definitions$map = definitions == null ? void 0 : definitions.map(function (x, i) {
500
+ return _this2.createTempNode(parent.id + "_" + i, x, undefined, parent);
501
+ })) != null ? _definitions$map : [];
828
502
  };
829
503
  return FormTree;
830
504
  }();
831
- function getControlIds(definition) {
832
- var _definition$children$, _definition$children;
833
- var childEntries = (_definition$children$ = (_definition$children = definition.children) == null ? void 0 : _definition$children.flatMap(getControlIds)) != null ? _definition$children$ : [];
834
- return !definition.id ? childEntries : [[definition.id, definition]].concat(childEntries);
835
- }
836
- function createControlMap(control) {
837
- return Object.fromEntries(getControlIds(control));
838
- }
839
505
  var FormTreeImpl = /*#__PURE__*/function (_FormTree) {
840
- function FormTreeImpl(forms, root) {
506
+ function FormTreeImpl(forms) {
841
507
  var _this3;
842
508
  _this3 = _FormTree.call(this) || this;
843
509
  _this3.forms = void 0;
844
- _this3.controlMap = void 0;
510
+ _this3.controlMap = {};
845
511
  _this3.rootNode = void 0;
512
+ _this3.idCount = 1;
846
513
  _this3.forms = forms;
847
- _this3.rootNode = new FormNode("", root, _this3);
848
- _this3.controlMap = createControlMap(root);
514
+ _this3.rootNode = new FormNodeImpl("", {
515
+ type: "Group"
516
+ }, _this3);
849
517
  return _this3;
850
518
  }
851
519
  _inheritsLoose(FormTreeImpl, _FormTree);
@@ -853,6 +521,24 @@ var FormTreeImpl = /*#__PURE__*/function (_FormTree) {
853
521
  _proto3.getByRefId = function getByRefId(id) {
854
522
  return this.controlMap[id];
855
523
  };
524
+ _proto3.register = function register(node) {
525
+ var _this4 = this;
526
+ this.controlMap[node.id] = node;
527
+ node.getChildNodes().forEach(function (x) {
528
+ return _this4.register(x);
529
+ });
530
+ };
531
+ _proto3.addChild = function addChild(parent, control) {
532
+ var _control$children,
533
+ _this5 = this;
534
+ var node = new FormNodeImpl(control.id ? control.id : "c" + this.idCount++, control, this, parent);
535
+ (_control$children = control.children) == null || _control$children.forEach(function (x) {
536
+ return _this5.addChild(node, x);
537
+ });
538
+ parent.getChildNodes().push(node);
539
+ this.register(node);
540
+ return node;
541
+ };
856
542
  _proto3.getForm = function getForm(formId) {
857
543
  return this.forms.getForm(formId);
858
544
  };
@@ -869,18 +555,19 @@ function createFormTree(controls, getForm) {
869
555
  }
870
556
  };
871
557
  }
872
- return new FormTreeImpl(getForm, {
873
- type: exports.ControlDefinitionType.Group,
874
- children: controls
558
+ var tree = new FormTreeImpl(getForm);
559
+ controls.forEach(function (x) {
560
+ return tree.addChild(tree.rootNode, x);
875
561
  });
562
+ return tree;
876
563
  }
877
564
  function createFormLookup(formMap) {
878
565
  var lookup = {
879
566
  getForm: getForm
880
567
  };
881
- var forms = Object.fromEntries(Object.entries(formMap).map(function (_ref2) {
882
- var k = _ref2[0],
883
- v = _ref2[1];
568
+ var forms = Object.fromEntries(Object.entries(formMap).map(function (_ref) {
569
+ var k = _ref[0],
570
+ v = _ref[1];
884
571
  return [k, createFormTree(v, lookup)];
885
572
  }));
886
573
  return lookup;
@@ -896,13 +583,37 @@ function lookupDataNode(c, parentNode) {
896
583
  var fieldNamePath = fieldPathForDefinition(c);
897
584
  return fieldNamePath ? schemaDataForFieldPath(fieldNamePath, parentNode) : undefined;
898
585
  }
899
- function lookupChildDataContext(dataContext, c) {
900
- var _dataContext$dataNode;
901
- var parentNode = (_dataContext$dataNode = dataContext.dataNode) != null ? _dataContext$dataNode : dataContext.parentNode;
902
- var dataNode = lookupDataNode(c, parentNode);
903
- return _extends({}, dataContext, {
904
- parentNode: parentNode,
905
- dataNode: dataNode
586
+ function traverseParents(current, get, until) {
587
+ var outArray = [];
588
+ while (current && !(until != null && until(current))) {
589
+ outArray.push(get(current));
590
+ current = current.parent;
591
+ }
592
+ return outArray.reverse();
593
+ }
594
+ function getRootDataNode(dataNode) {
595
+ while (dataNode.parent) {
596
+ dataNode = dataNode.parent;
597
+ }
598
+ return dataNode;
599
+ }
600
+ function getJsonPath(dataNode) {
601
+ return traverseParents(dataNode, function (d) {
602
+ return d.elementIndex == null ? d.schema.field.field : d.elementIndex;
603
+ }, function (x) {
604
+ return !x.parent;
605
+ });
606
+ }
607
+ function getSchemaPath(schemaNode) {
608
+ return traverseParents(schemaNode, function (d) {
609
+ return d.field;
610
+ }, function (x) {
611
+ return !x.parent;
612
+ });
613
+ }
614
+ function getSchemaFieldList(schema) {
615
+ return schema.getChildNodes().map(function (x) {
616
+ return x.field;
906
617
  });
907
618
  }
908
619
  /**
@@ -910,8 +621,8 @@ function lookupChildDataContext(dataContext, c) {
910
621
  */
911
622
  function visitControlDataArray(controls, context, cb) {
912
623
  if (!controls) return undefined;
913
- for (var _iterator2 = _createForOfIteratorHelperLoose(controls), _step2; !(_step2 = _iterator2()).done;) {
914
- var c = _step2.value;
624
+ for (var _iterator = _createForOfIteratorHelperLoose(controls), _step; !(_step = _iterator()).done;) {
625
+ var c = _step.value;
915
626
  var r = visitControlData(c, context, cb);
916
627
  if (r !== undefined) return r;
917
628
  }
@@ -952,6 +663,167 @@ function visitFormDataInContext(parentContext, node, cb) {
952
663
  return visitFormData(node, dataNode != null ? dataNode : parentContext, cb, !dataNode);
953
664
  }
954
665
 
666
+ function buildSchema(def) {
667
+ return Object.entries(def).map(function (x) {
668
+ return x[1](x[0]);
669
+ });
670
+ }
671
+ function stringField(displayName, options) {
672
+ return makeScalarField(_extends({
673
+ type: exports.FieldType.String,
674
+ displayName: displayName
675
+ }, options));
676
+ }
677
+ function stringOptionsField(displayName) {
678
+ return makeScalarField({
679
+ type: exports.FieldType.String,
680
+ displayName: displayName,
681
+ options: [].slice.call(arguments, 1)
682
+ });
683
+ }
684
+ function withScalarOptions(options, v) {
685
+ return function (n) {
686
+ return _extends({}, v(n), options);
687
+ };
688
+ }
689
+ function makeScalarField(options) {
690
+ return function (n) {
691
+ return _extends({}, defaultScalarField(n, n), options);
692
+ };
693
+ }
694
+ function makeCompoundField(options) {
695
+ return function (n) {
696
+ return _extends({}, defaultCompoundField(n, n, false), options);
697
+ };
698
+ }
699
+ function intField(displayName, options) {
700
+ return makeScalarField(_extends({
701
+ type: exports.FieldType.Int,
702
+ displayName: displayName
703
+ }, options));
704
+ }
705
+ function doubleField(displayName, options) {
706
+ return makeScalarField(_extends({
707
+ type: exports.FieldType.Double,
708
+ displayName: displayName
709
+ }, options));
710
+ }
711
+ function dateField(displayName, options) {
712
+ return makeScalarField(_extends({
713
+ type: exports.FieldType.Date,
714
+ displayName: displayName
715
+ }, options));
716
+ }
717
+ function timeField(displayName, options) {
718
+ return makeScalarField(_extends({
719
+ type: exports.FieldType.Time,
720
+ displayName: displayName
721
+ }, options));
722
+ }
723
+ function dateTimeField(displayName, options) {
724
+ return makeScalarField(_extends({
725
+ type: exports.FieldType.DateTime,
726
+ displayName: displayName
727
+ }, options));
728
+ }
729
+ function boolField(displayName, options) {
730
+ return makeScalarField(_extends({
731
+ type: exports.FieldType.Bool,
732
+ displayName: displayName
733
+ }, options));
734
+ }
735
+ function compoundField(displayName, fields, other) {
736
+ return function (field) {
737
+ return _extends({}, defaultCompoundField(field, displayName, false), other, {
738
+ children: fields
739
+ });
740
+ };
741
+ }
742
+ function defaultScalarField(field, displayName) {
743
+ return {
744
+ field: field,
745
+ displayName: displayName,
746
+ type: exports.FieldType.String
747
+ };
748
+ }
749
+ function defaultCompoundField(field, displayName, collection) {
750
+ return {
751
+ field: field,
752
+ displayName: displayName,
753
+ type: exports.FieldType.Compound,
754
+ collection: collection,
755
+ children: []
756
+ };
757
+ }
758
+ function mergeField(field, mergeInto) {
759
+ var existing = mergeInto.find(function (x) {
760
+ return x.field === field.field;
761
+ });
762
+ if (existing) {
763
+ return mergeInto.map(function (x) {
764
+ return x !== existing ? x : _extends({}, x, {
765
+ onlyForTypes: mergeTypes(x.onlyForTypes, field.onlyForTypes)
766
+ });
767
+ });
768
+ }
769
+ return [].concat(mergeInto, [field]);
770
+ function mergeTypes(f, s) {
771
+ if (!f) return s;
772
+ if (!s) return f;
773
+ var extras = s.filter(function (x) {
774
+ return !f.includes(x);
775
+ });
776
+ return extras.length ? [].concat(f, extras) : f;
777
+ }
778
+ }
779
+ function mergeFields(fields, name, value, newFields) {
780
+ var withType = fields.map(function (x) {
781
+ return x.isTypeField ? addFieldOption(x, name, value) : x;
782
+ });
783
+ return newFields.map(function (x) {
784
+ return _extends({}, x, {
785
+ onlyForTypes: [value]
786
+ });
787
+ }).reduce(function (af, x) {
788
+ return mergeField(x, af);
789
+ }, withType);
790
+ }
791
+ function addFieldOption(typeField, name, value) {
792
+ var _typeField$options;
793
+ var options = (_typeField$options = typeField.options) != null ? _typeField$options : [];
794
+ if (options.some(function (x) {
795
+ return x.value === value;
796
+ })) return typeField;
797
+ return _extends({}, typeField, {
798
+ options: [].concat(options, [{
799
+ name: name,
800
+ value: value
801
+ }])
802
+ });
803
+ }
804
+ function resolveSchemas(schemaMap) {
805
+ var out = {};
806
+ function resolveSchemaType(type) {
807
+ if (type in out) {
808
+ return out[type];
809
+ }
810
+ var resolvedFields = [];
811
+ out[type] = resolvedFields;
812
+ schemaMap[type].forEach(function (x) {
813
+ if (isCompoundField(x) && x.schemaRef) {
814
+ resolvedFields.push(_extends({}, x, {
815
+ children: resolveSchemaType(x.schemaRef)
816
+ }));
817
+ } else {
818
+ resolvedFields.push(x);
819
+ }
820
+ });
821
+ return resolvedFields;
822
+ }
823
+ Object.keys(schemaMap).forEach(resolveSchemaType);
824
+ return out;
825
+ }
826
+
955
827
  /**
956
828
  * Applies default values to the given record based on the provided schema fields.
957
829
  * @param v - The record to apply default values to.
@@ -1017,8 +889,7 @@ function defaultValueForField(sf, required) {
1017
889
  var isRequired = !!(required || sf.required);
1018
890
  if (isCompoundField(sf)) {
1019
891
  if (isRequired) {
1020
- var _sf$children;
1021
- var childValue = defaultValueForFields((_sf$children = sf.children) != null ? _sf$children : []);
892
+ var childValue = defaultValueForFields(sf.children);
1022
893
  return sf.collection ? [childValue] : childValue;
1023
894
  }
1024
895
  return sf.notNullable ? sf.collection ? [] : {} : undefined;
@@ -1035,8 +906,7 @@ function defaultValueForField(sf, required) {
1035
906
  */
1036
907
  function elementValueForField(sf) {
1037
908
  if (isCompoundField(sf)) {
1038
- var _sf$children2;
1039
- return defaultValueForFields((_sf$children2 = sf.children) != null ? _sf$children2 : []);
909
+ return defaultValueForFields(sf.children);
1040
910
  }
1041
911
  return sf.defaultValue;
1042
912
  }
@@ -1153,7 +1023,34 @@ function findNonDataGroups(controls) {
1153
1023
  * @returns The control definitions with missing controls added.
1154
1024
  */
1155
1025
  function addMissingControls(fields, controls, warning) {
1156
- return addMissingControlsForSchema(createSchemaTree(fields).rootNode, controls, warning);
1026
+ return addMissingControlsForSchema(rootSchemaNode(fields), controls, warning);
1027
+ }
1028
+ function registerSchemaEntries(formNode, parentSchema) {
1029
+ var formToSchema = {};
1030
+ var schemaToForm = {};
1031
+ function register(node, parentSchema) {
1032
+ var c = node.definition;
1033
+ var controlPath = fieldPathForDefinition(c);
1034
+ var dataSchema = controlPath ? schemaForFieldPath(controlPath, parentSchema) : undefined;
1035
+ if (isGroupControl(c) && dataSchema == null) dataSchema = parentSchema;
1036
+ if (dataSchema) {
1037
+ var _schemaToForm$dataSch;
1038
+ formToSchema[node.id] = dataSchema;
1039
+ var formNodes = (_schemaToForm$dataSch = schemaToForm[dataSchema.id]) != null ? _schemaToForm$dataSch : [];
1040
+ formNodes.push(node);
1041
+ schemaToForm[dataSchema.id] = formNodes;
1042
+ }
1043
+ node.getChildNodes().forEach(function (x) {
1044
+ var _dataSchema;
1045
+ return register(x, (_dataSchema = dataSchema) != null ? _dataSchema : parentSchema);
1046
+ });
1047
+ }
1048
+ register(formNode, parentSchema);
1049
+ return {
1050
+ formToSchema: formToSchema,
1051
+ schemaToForm: schemaToForm,
1052
+ register: register
1053
+ };
1157
1054
  }
1158
1055
  /**
1159
1056
  * Adds missing controls to the provided control definitions based on the schema fields.
@@ -1163,55 +1060,61 @@ function addMissingControls(fields, controls, warning) {
1163
1060
  * @returns The control definitions with missing controls added.
1164
1061
  */
1165
1062
  function addMissingControlsForSchema(schema, controls, warning) {
1166
- var controlMap = {};
1167
- var schemaControlMap = {};
1168
- var rootControls = controls.map(function (c) {
1169
- return toControlAndSchema(c, schema);
1170
- });
1171
- var rootSchema = {
1172
- schema: schema,
1173
- children: rootControls
1174
- };
1175
- addSchemaMapEntry("", rootSchema);
1176
- rootControls.forEach(addReferences);
1177
- var fields = schema.getChildNodes();
1178
- fields.forEach(addMissing);
1179
- return rootControls.map(toDefinition);
1063
+ var _toDefinition$childre;
1064
+ var tree = createFormTree(controls);
1065
+ addMissingControlsToForm(schema, tree, warning);
1066
+ return (_toDefinition$childre = toDefinition(tree.rootNode).children) != null ? _toDefinition$childre : [];
1180
1067
  function toDefinition(c) {
1181
- var children = c.children.length ? c.children.map(toDefinition) : null;
1182
- return _extends({}, c.control, {
1068
+ var children = c.getChildNodes().length ? c.getChildNodes().map(toDefinition) : null;
1069
+ return _extends({}, c.definition, {
1183
1070
  children: children
1184
1071
  });
1185
1072
  }
1073
+ }
1074
+ /**
1075
+ * Adds missing controls to the provided form tree based on the schema fields.
1076
+ * @param schema - The root schema node to use for adding missing controls.
1077
+ * @param tree - The form tree to add missing controls to.
1078
+ * @param warning - An optional function to call with warning messages.
1079
+ */
1080
+ function addMissingControlsToForm(schema, tree, warning) {
1081
+ var _registerSchemaEntrie = registerSchemaEntries(tree.rootNode, schema),
1082
+ formToSchema = _registerSchemaEntrie.formToSchema,
1083
+ schemaToForm = _registerSchemaEntrie.schemaToForm,
1084
+ register = _registerSchemaEntrie.register;
1085
+ schema.getChildNodes().forEach(addMissing);
1086
+ return;
1186
1087
  function addMissing(schemaNode) {
1187
1088
  if (fieldHasTag(schemaNode.field, exports.SchemaTags.NoControl)) return;
1188
1089
  var skipChildren = false;
1189
- var existingControls = schemaControlMap[schemaNode.id];
1090
+ var existingControls = schemaToForm[schemaNode.id];
1190
1091
  if (!existingControls) {
1191
1092
  var eligibleParents = getEligibleParents(schemaNode);
1192
1093
  var desiredGroup = getTagParam(schemaNode.field, exports.SchemaTags.ControlGroup);
1193
- var parentGroup = desiredGroup ? controlMap[desiredGroup] : undefined;
1094
+ var parentGroup = desiredGroup ? tree.getByRefId(desiredGroup) : undefined;
1194
1095
  if (!parentGroup && desiredGroup) warning == null || warning("No group '" + desiredGroup + "' for " + schemaNode.id);
1195
- if (parentGroup && eligibleParents.indexOf(parentGroup.schema.id) < 0) {
1096
+ if (parentGroup && eligibleParents.indexOf(formToSchema[parentGroup.id].id) < 0) {
1196
1097
  warning == null || warning("Target group '" + desiredGroup + "' is not an eligible parent for '" + schemaNode.id + "'");
1197
1098
  parentGroup = undefined;
1198
1099
  }
1199
1100
  if (!parentGroup && eligibleParents.length) {
1200
- var _schemaControlMap$eli;
1201
- parentGroup = (_schemaControlMap$eli = schemaControlMap[eligibleParents[0]]) == null ? void 0 : _schemaControlMap$eli[0];
1101
+ var _schemaToForm$eligibl;
1102
+ parentGroup = (_schemaToForm$eligibl = schemaToForm[eligibleParents[0]]) == null ? void 0 : _schemaToForm$eligibl[0];
1202
1103
  }
1203
1104
  if (parentGroup) {
1204
1105
  var _newControl = defaultControlForField(schemaNode.field, true);
1205
1106
  skipChildren = !!_newControl.childRefId;
1206
- _newControl.field = relativePath(parentGroup.schema, schemaNode);
1207
- parentGroup.children.push(toControlAndSchema(_newControl, parentGroup.schema, parentGroup));
1107
+ var parentSchemaNode = formToSchema[parentGroup.id];
1108
+ _newControl.field = relativePath(parentSchemaNode, schemaNode);
1109
+ var newNode = tree.addChild(parentGroup, _newControl);
1110
+ register(newNode, parentSchemaNode);
1208
1111
  } else warning == null || warning("Could not find a parent group for: " + schemaNode.id);
1209
1112
  } else {
1210
1113
  skipChildren = existingControls.some(function (x) {
1211
- return x.control.childRefId;
1114
+ return x.definition.childRefId;
1212
1115
  });
1213
1116
  }
1214
- if (!skipChildren) schemaNode.getChildNodes().forEach(addMissing);
1117
+ if (!skipChildren) schemaNode.getChildNodes(true).forEach(addMissing);
1215
1118
  }
1216
1119
  function getEligibleParents(schemaNode) {
1217
1120
  var eligibleParents = [];
@@ -1219,54 +1122,16 @@ function addMissingControlsForSchema(schema, controls, warning) {
1219
1122
  while (parent) {
1220
1123
  eligibleParents.push(parent.id);
1221
1124
  if (parent.field.collection) break;
1222
- if (!parent.parent) parent.getChildNodes().forEach(addCompound);
1125
+ if (!parent.parent) parent.getChildNodes(true).forEach(addCompound);
1223
1126
  parent = parent.parent;
1224
1127
  }
1225
1128
  return eligibleParents;
1226
1129
  function addCompound(node) {
1227
1130
  if (isCompoundNode(node) && !node.field.collection) {
1228
1131
  eligibleParents.push(node.id);
1229
- node.getChildNodes().forEach(addCompound);
1230
- }
1231
- }
1232
- }
1233
- function addReferences(c) {
1234
- c.children.forEach(addReferences);
1235
- if (c.control.childRefId) {
1236
- var ref = controlMap[c.control.childRefId];
1237
- if (ref) {
1238
- ref.children.forEach(function (x) {
1239
- return toControlAndSchema(x.control, c.schema, c, true);
1240
- });
1241
- return;
1132
+ node.getChildNodes(true).forEach(addCompound);
1242
1133
  }
1243
- console.warn("Missing reference", c.control.childRefId);
1244
- }
1245
- }
1246
- function addSchemaMapEntry(schemaId, entry) {
1247
- if (!schemaControlMap[schemaId]) schemaControlMap[schemaId] = [];
1248
- schemaControlMap[schemaId].push(entry);
1249
- }
1250
- function toControlAndSchema(c, parentSchema, parentNode, dontRegister) {
1251
- var _c$children$map, _c$children;
1252
- var controlPath = fieldPathForDefinition(c);
1253
- var dataSchema = controlPath ? schemaForFieldPath(controlPath, parentSchema) : undefined;
1254
- if (isGroupControl(c) && dataSchema == null) dataSchema = parentSchema;
1255
- var entry = {
1256
- schema: dataSchema,
1257
- control: c,
1258
- children: [],
1259
- parent: parentNode
1260
- };
1261
- entry.children = (_c$children$map = (_c$children = c.children) == null ? void 0 : _c$children.map(function (x) {
1262
- var _dataSchema;
1263
- return toControlAndSchema(x, (_dataSchema = dataSchema) != null ? _dataSchema : parentSchema, entry, dontRegister);
1264
- })) != null ? _c$children$map : [];
1265
- if (!dontRegister && c.id) controlMap[c.id] = entry;
1266
- if (dataSchema) {
1267
- addSchemaMapEntry(dataSchema.id, entry);
1268
1134
  }
1269
- return entry;
1270
1135
  }
1271
1136
  }
1272
1137
  /**
@@ -1306,18 +1171,16 @@ function getDisplayOnlyOptions(d) {
1306
1171
  /**
1307
1172
  * Cleans data for a schema based on the provided schema fields.
1308
1173
  * @param v - The data to clean.
1309
- * @param schemaNode
1174
+ * @param fields - The schema fields to use for cleaning the data.
1310
1175
  * @param removeIfDefault - Flag indicating if default values should be removed.
1311
1176
  * @returns The cleaned data.
1312
1177
  */
1313
- function cleanDataForSchema(v, schemaNode, removeIfDefault) {
1314
- var _fields$find;
1178
+ function cleanDataForSchema(v, fields, removeIfDefault) {
1315
1179
  if (!v) return v;
1316
- var fields = schemaNode.getResolvedFields();
1317
- var typeField = (_fields$find = fields.find(function (x) {
1180
+ var typeField = fields.find(function (x) {
1318
1181
  return x.isTypeField;
1319
- })) == null ? void 0 : _fields$find.field;
1320
- var typeValue = typeField ? v[typeField] : undefined;
1182
+ });
1183
+ var typeValue = typeField ? v[typeField.field] : undefined;
1321
1184
  var cleanableFields = !removeIfDefault ? fields.filter(function (x) {
1322
1185
  var _x$onlyForTypes$lengt, _x$onlyForTypes;
1323
1186
  return isCompoundField(x) || ((_x$onlyForTypes$lengt = (_x$onlyForTypes = x.onlyForTypes) == null ? void 0 : _x$onlyForTypes.length) != null ? _x$onlyForTypes$lengt : 0) > 0;
@@ -1332,15 +1195,15 @@ function cleanDataForSchema(v, schemaNode, removeIfDefault) {
1332
1195
  return;
1333
1196
  }
1334
1197
  if (isCompoundField(x)) {
1335
- var childNode = schemaNode.createChildNode(x);
1198
+ var childFields = x.treeChildren ? fields : x.children;
1336
1199
  if (x.collection) {
1337
1200
  if (Array.isArray(childValue)) {
1338
1201
  out[x.field] = childValue.map(function (cv) {
1339
- return cleanDataForSchema(cv, childNode, removeIfDefault);
1202
+ return cleanDataForSchema(cv, childFields, removeIfDefault);
1340
1203
  });
1341
1204
  }
1342
1205
  } else {
1343
- out[x.field] = cleanDataForSchema(childValue, childNode, removeIfDefault);
1206
+ out[x.field] = cleanDataForSchema(childValue, childFields, removeIfDefault);
1344
1207
  }
1345
1208
  }
1346
1209
  function canBeNull() {
@@ -1358,8 +1221,8 @@ function cleanDataForSchema(v, schemaNode, removeIfDefault) {
1358
1221
  * @returns An array of referenced classes.
1359
1222
  */
1360
1223
  function getAllReferencedClasses(c, collectExtra) {
1361
- var _c$children2, _collectExtra;
1362
- var childClasses = (_c$children2 = c.children) == null ? void 0 : _c$children2.flatMap(function (x) {
1224
+ var _c$children, _collectExtra;
1225
+ var childClasses = (_c$children = c.children) == null ? void 0 : _c$children.flatMap(function (x) {
1363
1226
  return getAllReferencedClasses(x, collectExtra);
1364
1227
  });
1365
1228
  var go = getGroupClassOverrides(c);
@@ -1367,14 +1230,12 @@ function getAllReferencedClasses(c, collectExtra) {
1367
1230
  entryWrapperClass = _ref.entryWrapperClass,
1368
1231
  selectedClass = _ref.selectedClass,
1369
1232
  notSelectedClass = _ref.notSelectedClass;
1370
- var groupOptions = isGroupControl(c) ? c.groupOptions : undefined;
1371
- var gridClasses = groupOptions && isGridRenderer(groupOptions) ? [groupOptions.rowClass] : [];
1372
1233
  var _ref2 = isDataControl(c) && isAutoCompleteClasses(c.renderOptions) ? c.renderOptions : {},
1373
1234
  listContainerClass = _ref2.listContainerClass,
1374
1235
  listEntryClass = _ref2.listEntryClass,
1375
1236
  chipContainerClass = _ref2.chipContainerClass,
1376
1237
  chipCloseButtonClass = _ref2.chipCloseButtonClass;
1377
- var tc = clsx__default["default"]([c.styleClass, c.layoutClass, c.labelClass, c.textClass, c.labelTextClass].concat(gridClasses, Object.values(go), (_collectExtra = collectExtra == null ? void 0 : collectExtra(c)) != null ? _collectExtra : [], [entryWrapperClass, selectedClass, notSelectedClass, listContainerClass, listEntryClass, chipContainerClass, chipCloseButtonClass]).map(getOverrideClass));
1238
+ var tc = clsx__default["default"]([c.styleClass, c.layoutClass, c.labelClass].concat(Object.values(go), (_collectExtra = collectExtra == null ? void 0 : collectExtra(c)) != null ? _collectExtra : [], [entryWrapperClass, selectedClass, notSelectedClass, listContainerClass, listEntryClass, chipContainerClass, chipCloseButtonClass]).map(getOverrideClass));
1378
1239
  if (childClasses && !tc) return childClasses;
1379
1240
  if (!tc) return [];
1380
1241
  if (childClasses) return [tc].concat(childClasses);
@@ -2162,10 +2023,7 @@ function matchesType(context) {
2162
2023
  var typeNode = parent.schema.getChildNodes().find(function (x) {
2163
2024
  return x.field.isTypeField;
2164
2025
  });
2165
- if (typeNode == null) {
2166
- console.warn("No type field found for", parent.schema);
2167
- return false;
2168
- }
2026
+ if (typeNode == null) return true;
2169
2027
  var typeField = parent.getChild(typeNode).control;
2170
2028
  return typeField && types.includes(typeField.value);
2171
2029
  }
@@ -2203,7 +2061,7 @@ function useJsonataExpression(jExpr, data, path, bindings, coerce) {
2203
2061
  }
2204
2062
  }, [fullExpr]);
2205
2063
  var control = core.useControl();
2206
- var listenerRef = react.useRef(undefined);
2064
+ var listenerRef = react.useRef();
2207
2065
  var updateRef = react.useRef(0);
2208
2066
  var _useRefState = core.useRefState(function () {
2209
2067
  return new core.SubscriptionTracker(function () {
@@ -2313,7 +2171,7 @@ function useMakeValidationHook(definition, useValidatorFor) {
2313
2171
  });
2314
2172
  }, [!!dd, dd == null ? void 0 : dd.required, depString, useValidatorFor]);
2315
2173
  }
2316
- var useDefaultValidator = function useDefaultValidator(validator, ctx) {
2174
+ function useDefaultValidator(validator, ctx) {
2317
2175
  switch (validator.type) {
2318
2176
  case exports.ValidatorType.Length:
2319
2177
  useLengthValidator(validator, ctx);
@@ -2325,7 +2183,7 @@ var useDefaultValidator = function useDefaultValidator(validator, ctx) {
2325
2183
  useDateValidator(validator, ctx);
2326
2184
  break;
2327
2185
  }
2328
- };
2186
+ }
2329
2187
  function useJsonataValidator(validator, ctx) {
2330
2188
  var sdn = ctx.dataContext.parentNode;
2331
2189
  var errorMsg = useJsonataExpression(validator.expression, getRootDataNode(sdn).control, getJsonPath(sdn), undefined, function (v) {
@@ -2455,13 +2313,9 @@ var DefaultSchemaInterface = /*#__PURE__*/function () {
2455
2313
  var _this$textValue$toLow, _this$textValue;
2456
2314
  return (_this$textValue$toLow = (_this$textValue = this.textValue(field, value)) == null ? void 0 : _this$textValue.toLowerCase()) != null ? _this$textValue$toLow : "";
2457
2315
  };
2458
- _proto.textValueForData = function textValueForData(dataNode) {
2459
- var options = this.getDataOptions(dataNode);
2460
- return this.textValue(dataNode.schema.field, dataNode.control.value, dataNode.elementIndex != null, options);
2461
- };
2462
- _proto.textValue = function textValue(field, value, element, options) {
2463
- var actualOptions = options != null ? options : this.getOptions(field);
2464
- var option = actualOptions == null ? void 0 : actualOptions.find(function (x) {
2316
+ _proto.textValue = function textValue(field, value, element) {
2317
+ var options = this.getOptions(field);
2318
+ var option = options == null ? void 0 : options.find(function (x) {
2465
2319
  return x.value === value;
2466
2320
  });
2467
2321
  if (option) return option.name;
@@ -2565,9 +2419,9 @@ var DefaultSchemaInterface = /*#__PURE__*/function () {
2565
2419
  }();
2566
2420
  var defaultSchemaInterface = new DefaultSchemaInterface();
2567
2421
 
2568
- var _excluded = ["styleClass", "labelClass", "layoutClass", "labelTextClass", "textClass"],
2422
+ var _excluded = ["styleClass", "labelClass", "layoutClass"],
2569
2423
  _excluded2 = ["parentDataNode"],
2570
- _excluded3 = ["formOptions", "style", "allowedOptions", "schemaInterface", "styleClass", "textClass"];
2424
+ _excluded3 = ["definition", "control", "formOptions", "style", "allowedOptions", "schemaInterface", "styleClass"];
2571
2425
  var AppendAdornmentPriority = 0;
2572
2426
  var WrapAdornmentPriority = 1000;
2573
2427
  /**
@@ -2616,9 +2470,15 @@ function useControlRendererComponent(controlOrFormNode, renderer, options, paren
2616
2470
  definition = _ref2[0],
2617
2471
  formNode = _ref2[1];
2618
2472
  var dataProps = (_options$useDataHook = options.useDataHook == null ? void 0 : options.useDataHook(definition)) != null ? _options$useDataHook : defaultDataProps;
2473
+ var elementIndex = options.elementIndex;
2619
2474
  var schemaInterface = (_options$schemaInterf = options.schemaInterface) != null ? _options$schemaInterf : defaultSchemaInterface;
2620
2475
  var useExpr = (_options$useEvalExpre = options.useEvalExpressionHook) != null ? _options$useEvalExpre : defaultUseEvalExpressionHook;
2621
- var dataNode = lookupDataNode(definition, parentDataNode);
2476
+ var dataNode;
2477
+ if (elementIndex != null) {
2478
+ dataNode = parentDataNode.getChildElement(elementIndex);
2479
+ } else {
2480
+ dataNode = lookupDataNode(definition, parentDataNode);
2481
+ }
2622
2482
  var useValidation = useMakeValidationHook(definition, options.useValidationHook);
2623
2483
  var dynamicHooks = useDynamicHooks({
2624
2484
  defaultValueControl: useEvalDefaultValueHook(useExpr, definition),
@@ -2635,6 +2495,7 @@ function useControlRendererComponent(controlOrFormNode, renderer, options, paren
2635
2495
  var r = useUpdatedRef({
2636
2496
  options: options,
2637
2497
  definition: definition,
2498
+ elementIndex: elementIndex,
2638
2499
  parentDataNode: parentDataNode,
2639
2500
  dataNode: dataNode,
2640
2501
  formNode: formNode
@@ -2643,10 +2504,11 @@ function useControlRendererComponent(controlOrFormNode, renderer, options, paren
2643
2504
  var Component = react.useCallback(function () {
2644
2505
  var stopTracking = core.useComponentTracking();
2645
2506
  try {
2646
- var _options$formData, _definition$adornment2, _definition$adornment3, _options$adjustLayout;
2507
+ var _options$formData, _dataNode, _definition$adornment2, _definition$adornment3, _formNode$tree$getByR, _options$adjustLayout;
2647
2508
  var _r$current = r.current,
2648
2509
  c = _r$current.definition,
2649
2510
  _options = _r$current.options,
2511
+ _elementIndex = _r$current.elementIndex,
2650
2512
  pdn = _r$current.parentDataNode,
2651
2513
  dn = _r$current.dataNode,
2652
2514
  _formNode = _r$current.formNode;
@@ -2686,7 +2548,7 @@ function useControlRendererComponent(controlOrFormNode, renderer, options, paren
2686
2548
  });
2687
2549
  });
2688
2550
  var parentControl = parentDataNode.control;
2689
- var control = dataNode == null ? void 0 : dataNode.control;
2551
+ var control = (_dataNode = dataNode) == null ? void 0 : _dataNode.control;
2690
2552
  core.useControlEffect(function () {
2691
2553
  var _definition$adornment, _definition$renderOpt;
2692
2554
  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(function (x) {
@@ -2725,8 +2587,7 @@ function useControlRendererComponent(controlOrFormNode, renderer, options, paren
2725
2587
  hidden: _options.hidden || !((_visibility$fields = visibility.fields) != null && _visibility$fields.showing.value),
2726
2588
  readonly: _options.readonly || readonlyControl.value,
2727
2589
  disabled: _options.disabled || disabledControl.value,
2728
- displayOnly: _options.displayOnly || isControlDisplayOnly(c),
2729
- inline: _options.inline
2590
+ displayOnly: _options.displayOnly || isControlDisplayOnly(c)
2730
2591
  };
2731
2592
  });
2732
2593
  var myOptions = core.trackedValue(myOptionsControl);
@@ -2738,13 +2599,14 @@ function useControlRendererComponent(controlOrFormNode, renderer, options, paren
2738
2599
  var styleClass = _options.styleClass,
2739
2600
  labelClass = _options.labelClass,
2740
2601
  layoutClass = _options.layoutClass,
2741
- labelTextClass = _options.labelTextClass,
2742
- textClass = _options.textClass,
2743
2602
  inheritableOptions = _objectWithoutPropertiesLoose(_options, _excluded);
2744
- var childOptions = _extends({}, inheritableOptions, myOptions);
2603
+ var childOptions = _extends({}, inheritableOptions, myOptions, {
2604
+ elementIndex: undefined
2605
+ });
2745
2606
  react.useEffect(function () {
2746
2607
  if (control && typeof myOptions.disabled === "boolean" && control.disabled != myOptions.disabled) control.disabled = myOptions.disabled;
2747
2608
  }, [control, myOptions.disabled]);
2609
+ if (parentControl.isNull) return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {});
2748
2610
  var adornments = (_definition$adornment2 = (_definition$adornment3 = definition.adornments) == null ? void 0 : _definition$adornment3.map(function (x) {
2749
2611
  return renderer.renderAdornment({
2750
2612
  adornment: x,
@@ -2753,8 +2615,10 @@ function useControlRendererComponent(controlOrFormNode, renderer, options, paren
2753
2615
  formOptions: myOptions
2754
2616
  });
2755
2617
  })) != null ? _definition$adornment2 : [];
2618
+ var otherChildNodes = definition.childRefId && ((_formNode$tree$getByR = _formNode.tree.getByRefId(definition.childRefId)) == null ? void 0 : _formNode$tree$getByR.getChildNodes());
2756
2619
  var labelAndChildren = renderControlLayout({
2757
- formNode: _formNode,
2620
+ formNode: otherChildNodes ? _formNode.tree.createTempNode(_formNode.id, definition, otherChildNodes) : _formNode,
2621
+ definition: c,
2758
2622
  renderer: renderer,
2759
2623
  renderChild: function renderChild(k, child, options) {
2760
2624
  var _ref5;
@@ -2775,6 +2639,7 @@ function useControlRendererComponent(controlOrFormNode, renderer, options, paren
2775
2639
  formOptions: myOptions,
2776
2640
  dataContext: dataContext,
2777
2641
  control: displayControl != null ? displayControl : control,
2642
+ elementIndex: _elementIndex,
2778
2643
  schemaInterface: schemaInterface,
2779
2644
  labelText: labelText,
2780
2645
  displayControl: displayControl,
@@ -2785,7 +2650,6 @@ function useControlRendererComponent(controlOrFormNode, renderer, options, paren
2785
2650
  actionOnClick: _options.actionOnClick,
2786
2651
  styleClass: _options.styleClass,
2787
2652
  labelClass: _options.labelClass,
2788
- textClass: _options.textClass,
2789
2653
  useEvalExpression: useExpr,
2790
2654
  useChildVisibility: function useChildVisibility(childDef, parentNode, dontOverride) {
2791
2655
  var _ref6;
@@ -2817,7 +2681,9 @@ function ControlRenderer(_ref7) {
2817
2681
  options = _ref7.options,
2818
2682
  control = _ref7.control,
2819
2683
  parentPath = _ref7.parentPath;
2820
- var schemaDataNode = makeSchemaDataNode(createSchemaTree(fields).rootNode, control);
2684
+ var schemaDataNode = makeSchemaDataNode(createSchemaLookup({
2685
+ "": fields
2686
+ }).getSchema(""), control);
2821
2687
  var Render = useControlRendererComponent(definition, renderer, options, schemaDataNode);
2822
2688
  return /*#__PURE__*/jsxRuntime.jsx(Render, {});
2823
2689
  } finally {
@@ -2837,20 +2703,20 @@ function NewControlRenderer(_ref8) {
2837
2703
  _effect2();
2838
2704
  }
2839
2705
  }
2840
- function defaultDataProps(_ref9, definition, control) {
2706
+ function defaultDataProps(_ref9) {
2841
2707
  var _allowedOptions$value, _definition$renderOpt2;
2842
- var formOptions = _ref9.formOptions,
2708
+ var definition = _ref9.definition,
2709
+ control = _ref9.control,
2710
+ formOptions = _ref9.formOptions,
2843
2711
  style = _ref9.style,
2844
2712
  allowedOptions = _ref9.allowedOptions,
2845
2713
  _ref9$schemaInterface = _ref9.schemaInterface,
2846
2714
  schemaInterface = _ref9$schemaInterface === void 0 ? defaultSchemaInterface : _ref9$schemaInterface,
2847
2715
  styleClass = _ref9.styleClass,
2848
- tc = _ref9.textClass,
2849
2716
  props = _objectWithoutPropertiesLoose(_ref9, _excluded3);
2850
2717
  var dataNode = props.dataContext.dataNode;
2851
2718
  var field = dataNode.schema.field;
2852
2719
  var className = rendererClass(styleClass, definition.styleClass);
2853
- var textClass = rendererClass(tc, definition.textClass);
2854
2720
  var displayOnly = !!formOptions.displayOnly;
2855
2721
  var required = !!definition.required && !displayOnly;
2856
2722
  var fieldOptions = schemaInterface.getDataOptions(dataNode);
@@ -2862,7 +2728,6 @@ function defaultDataProps(_ref9, definition, control) {
2862
2728
  control: control,
2863
2729
  field: field,
2864
2730
  id: "c" + control.uniqueId,
2865
- inline: !!formOptions.inline,
2866
2731
  options: allowed.length > 0 ? allowed.map(function (x) {
2867
2732
  var _fieldOptions$find;
2868
2733
  return typeof x === "object" ? x : (_fieldOptions$find = fieldOptions == null ? void 0 : fieldOptions.find(function (y) {
@@ -2882,12 +2747,12 @@ function defaultDataProps(_ref9, definition, control) {
2882
2747
  required: required,
2883
2748
  hidden: !!formOptions.hidden,
2884
2749
  className: className,
2885
- textClass: textClass,
2886
2750
  style: style
2887
2751
  }, props);
2888
2752
  }
2889
2753
  function renderControlLayout(props) {
2890
- var renderer = props.renderer,
2754
+ var c = props.definition,
2755
+ renderer = props.renderer,
2891
2756
  renderChild = props.renderChild,
2892
2757
  control = props.control,
2893
2758
  dataContext = props.dataContext,
@@ -2900,12 +2765,8 @@ function renderControlLayout(props) {
2900
2765
  customDisplay = props.customDisplay,
2901
2766
  useEvalExpression = props.useEvalExpression,
2902
2767
  labelClass = props.labelClass,
2903
- labelTextClass = props.labelTextClass,
2904
2768
  styleClass = props.styleClass,
2905
- textClass = props.textClass,
2906
- formNode = props.formNode,
2907
- formOptions = props.formOptions;
2908
- var c = formNode.definition;
2769
+ formNode = props.formNode;
2909
2770
  if (isDataControl(c)) {
2910
2771
  return renderData(c);
2911
2772
  }
@@ -2919,7 +2780,6 @@ function renderControlLayout(props) {
2919
2780
  }));
2920
2781
  }
2921
2782
  return {
2922
- inline: formOptions.inline,
2923
2783
  processLayout: renderer.renderGroup({
2924
2784
  formNode: formNode,
2925
2785
  definition: c,
@@ -2930,7 +2790,6 @@ function renderControlLayout(props) {
2930
2790
  type: "Standard"
2931
2791
  },
2932
2792
  className: rendererClass(styleClass, c.styleClass),
2933
- textClass: rendererClass(textClass, c.textClass),
2934
2793
  useChildVisibility: useChildVisibility,
2935
2794
  style: style,
2936
2795
  designMode: designMode
@@ -2938,25 +2797,19 @@ function renderControlLayout(props) {
2938
2797
  label: {
2939
2798
  label: (_labelText$value = labelText == null ? void 0 : labelText.value) != null ? _labelText$value : c.title,
2940
2799
  className: rendererClass(labelClass, c.labelClass),
2941
- textClass: rendererClass(labelTextClass, c.labelTextClass),
2942
2800
  type: exports.LabelType.Group,
2943
2801
  hide: (_c$groupOptions3 = c.groupOptions) == null ? void 0 : _c$groupOptions3.hideTitle
2944
2802
  }
2945
2803
  };
2946
2804
  }
2947
2805
  if (isActionControl(c)) {
2948
- var _props$actionDataCont, _props$actionDataCont2, _ref10, _labelText$value2, _c$actionStyle, _props$actionOnClick;
2806
+ var _props$actionDataCont, _props$actionDataCont2, _ref10, _labelText$value2, _props$actionOnClick;
2949
2807
  var actionData = (_props$actionDataCont = (_props$actionDataCont2 = props.actionDataControl) == null ? void 0 : _props$actionDataCont2.value) != null ? _props$actionDataCont : c.actionData;
2950
2808
  return {
2951
- inline: formOptions.inline,
2952
2809
  children: renderer.renderAction({
2953
2810
  actionText: (_ref10 = (_labelText$value2 = labelText == null ? void 0 : labelText.value) != null ? _labelText$value2 : c.title) != null ? _ref10 : c.actionId,
2954
2811
  actionId: c.actionId,
2955
2812
  actionData: actionData,
2956
- actionStyle: (_c$actionStyle = c.actionStyle) != null ? _c$actionStyle : exports.ActionStyle.Button,
2957
- textClass: rendererClass(textClass, c.textClass),
2958
- icon: c.icon,
2959
- inline: formOptions.inline,
2960
2813
  onClick: (_props$actionOnClick = props.actionOnClick == null ? void 0 : props.actionOnClick(c.actionId, actionData, dataContext)) != null ? _props$actionOnClick : function () {},
2961
2814
  className: rendererClass(styleClass, c.styleClass),
2962
2815
  style: style
@@ -2969,20 +2822,16 @@ function renderControlLayout(props) {
2969
2822
  var displayProps = {
2970
2823
  data: data,
2971
2824
  className: rendererClass(styleClass, c.styleClass),
2972
- textClass: rendererClass(textClass, c.textClass),
2973
2825
  style: style,
2974
2826
  display: displayControl,
2975
- dataContext: dataContext,
2976
- inline: formOptions.inline
2827
+ dataContext: dataContext
2977
2828
  };
2978
2829
  if (data.type === exports.DisplayDataType.Custom && customDisplay) {
2979
2830
  return {
2980
- inline: formOptions.inline,
2981
2831
  children: customDisplay(data.customId, displayProps)
2982
2832
  };
2983
2833
  }
2984
2834
  return {
2985
- inline: formOptions.inline,
2986
2835
  children: renderer.renderDisplay(displayProps)
2987
2836
  };
2988
2837
  }
@@ -2992,10 +2841,9 @@ function renderControlLayout(props) {
2992
2841
  if (!control) return {
2993
2842
  children: "No control for: " + c.field
2994
2843
  };
2995
- var rendererProps = dataProps(props, c, control);
2844
+ var rendererProps = dataProps(props);
2996
2845
  var label = !c.hideTitle ? controlTitle((_labelText$value3 = labelText == null ? void 0 : labelText.value) != null ? _labelText$value3 : c.title, props.dataContext.dataNode.schema.field) : undefined;
2997
2846
  return {
2998
- inline: formOptions.inline,
2999
2847
  processLayout: renderer.renderData(rendererProps),
3000
2848
  label: {
3001
2849
  type: ((_c$children$length = (_c$children = c.children) == null ? void 0 : _c$children.length) != null ? _c$children$length : 0) > 0 ? exports.LabelType.Group : exports.LabelType.Control,
@@ -3003,8 +2851,7 @@ function renderControlLayout(props) {
3003
2851
  forId: rendererProps.id,
3004
2852
  required: c.required && !props.formOptions.displayOnly,
3005
2853
  hide: c.hideTitle,
3006
- className: rendererClass(labelClass, c.labelClass),
3007
- textClass: rendererClass(labelTextClass, c.labelTextClass)
2854
+ className: rendererClass(labelClass, c.labelClass)
3008
2855
  },
3009
2856
  errorControl: control
3010
2857
  };
@@ -3056,14 +2903,12 @@ function renderLayoutParts(props, renderer) {
3056
2903
  style = _ref11.style,
3057
2904
  errorControl = _ref11.errorControl,
3058
2905
  label = _ref11.label,
3059
- adornments = _ref11.adornments,
3060
- inline = _ref11.inline;
2906
+ adornments = _ref11.adornments;
3061
2907
  var layout = {
3062
2908
  children: children,
3063
2909
  errorControl: errorControl,
3064
2910
  style: style,
3065
2911
  className: className,
3066
- inline: inline,
3067
2912
  wrapLayout: function wrapLayout(x) {
3068
2913
  return x;
3069
2914
  }
@@ -3312,6 +3157,7 @@ function createFormRenderer(customRenderers, defaultRenderers) {
3312
3157
  renderLayout: renderLayout,
3313
3158
  renderVisibility: renderVisibility,
3314
3159
  renderLabelText: renderLabelText,
3160
+ renderText: defaultRenderers.renderText,
3315
3161
  html: defaultRenderers.html
3316
3162
  };
3317
3163
  function renderVisibility(props) {
@@ -3365,7 +3211,7 @@ function createFormRenderer(customRenderers, defaultRenderers) {
3365
3211
  var _x$collection, _field$collection, _x$options;
3366
3212
  var noMatch = x.match ? !x.match(props, renderOptions) : undefined;
3367
3213
  if (noMatch === true) return false;
3368
- var matchCollection = ((_x$collection = x.collection) != null ? _x$collection : false) === (props.dataNode.elementIndex == null && ((_field$collection = field.collection) != null ? _field$collection : false));
3214
+ var matchCollection = ((_x$collection = x.collection) != null ? _x$collection : false) === (props.elementIndex == null && ((_field$collection = field.collection) != null ? _field$collection : false));
3369
3215
  var isSchemaAllowed = !!x.schemaType && renderType == exports.DataRenderType.Standard ? isOneOf(x.schemaType, field.type) : undefined;
3370
3216
  var isRendererAllowed = !!x.renderType && isOneOf(x.renderType, renderType);
3371
3217
  return matchCollection && ((_x$options = x.options) != null ? _x$options : false) === options && (isSchemaAllowed || isRendererAllowed || !x.renderType && !x.schemaType && noMatch === false);
@@ -3436,14 +3282,8 @@ function isArrayRegistration(x) {
3436
3282
  exports.AppendAdornmentPriority = AppendAdornmentPriority;
3437
3283
  exports.ControlRenderer = ControlRenderer;
3438
3284
  exports.DefaultSchemaInterface = DefaultSchemaInterface;
3439
- exports.FormNode = FormNode;
3440
3285
  exports.FormTree = FormTree;
3441
3286
  exports.NewControlRenderer = NewControlRenderer;
3442
- exports.SchemaDataNode = SchemaDataNode;
3443
- exports.SchemaDataTree = SchemaDataTree;
3444
- exports.SchemaDataTreeImpl = SchemaDataTreeImpl;
3445
- exports.SchemaNode = SchemaNode;
3446
- exports.SchemaTree = SchemaTree;
3447
3287
  exports.WrapAdornmentPriority = WrapAdornmentPriority;
3448
3288
  exports.accordionOptions = accordionOptions;
3449
3289
  exports.actionControl = actionControl;
@@ -3451,6 +3291,7 @@ exports.actionHandlers = actionHandlers;
3451
3291
  exports.addFieldOption = addFieldOption;
3452
3292
  exports.addMissingControls = addMissingControls;
3453
3293
  exports.addMissingControlsForSchema = addMissingControlsForSchema;
3294
+ exports.addMissingControlsToForm = addMissingControlsToForm;
3454
3295
  exports.adornmentOptions = adornmentOptions;
3455
3296
  exports.appendMarkup = appendMarkup;
3456
3297
  exports.appendMarkupAt = appendMarkupAt;
@@ -3476,7 +3317,6 @@ exports.createActionRenderer = createActionRenderer;
3476
3317
  exports.createAdornmentRenderer = createAdornmentRenderer;
3477
3318
  exports.createArrayActions = createArrayActions;
3478
3319
  exports.createArrayRenderer = createArrayRenderer;
3479
- exports.createControlMap = createControlMap;
3480
3320
  exports.createDataRenderer = createDataRenderer;
3481
3321
  exports.createDisplayRenderer = createDisplayRenderer;
3482
3322
  exports.createFormLookup = createFormLookup;
@@ -3485,10 +3325,7 @@ exports.createFormTree = createFormTree;
3485
3325
  exports.createGroupRenderer = createGroupRenderer;
3486
3326
  exports.createLabelRenderer = createLabelRenderer;
3487
3327
  exports.createLayoutRenderer = createLayoutRenderer;
3488
- exports.createSchemaDataNode = createSchemaDataNode;
3489
3328
  exports.createSchemaLookup = createSchemaLookup;
3490
- exports.createSchemaNode = createSchemaNode;
3491
- exports.createSchemaTree = createSchemaTree;
3492
3329
  exports.createVisibilityRenderer = createVisibilityRenderer;
3493
3330
  exports.dataControl = dataControl;
3494
3331
  exports.dateField = dateField;
@@ -3525,7 +3362,6 @@ exports.findField = findField;
3525
3362
  exports.findFieldPath = findFieldPath;
3526
3363
  exports.findNonDataGroups = findNonDataGroups;
3527
3364
  exports.findScalarField = findScalarField;
3528
- exports.fontAwesomeIcon = fontAwesomeIcon;
3529
3365
  exports.getAllReferencedClasses = getAllReferencedClasses;
3530
3366
  exports.getAllValues = getAllValues;
3531
3367
  exports.getDiffObject = getDiffObject;
@@ -3542,7 +3378,6 @@ exports.getOverrideClass = getOverrideClass;
3542
3378
  exports.getRootDataNode = getRootDataNode;
3543
3379
  exports.getSchemaFieldList = getSchemaFieldList;
3544
3380
  exports.getSchemaNodePath = getSchemaNodePath;
3545
- exports.getSchemaNodePathString = getSchemaNodePathString;
3546
3381
  exports.getSchemaPath = getSchemaPath;
3547
3382
  exports.getTagParam = getTagParam;
3548
3383
  exports.groupedControl = groupedControl;
@@ -3570,7 +3405,6 @@ exports.isFlexRenderer = isFlexRenderer;
3570
3405
  exports.isGridRenderer = isGridRenderer;
3571
3406
  exports.isGroupControl = isGroupControl;
3572
3407
  exports.isIconAdornment = isIconAdornment;
3573
- exports.isInlineRenderer = isInlineRenderer;
3574
3408
  exports.isOptionalAdornment = isOptionalAdornment;
3575
3409
  exports.isScalarField = isScalarField;
3576
3410
  exports.isSelectChildRenderer = isSelectChildRenderer;
@@ -3584,7 +3418,6 @@ exports.jsonataValidatorOptions = jsonataValidatorOptions;
3584
3418
  exports.layoutKeyForPlacement = layoutKeyForPlacement;
3585
3419
  exports.legacyFormNode = legacyFormNode;
3586
3420
  exports.lengthValidatorOptions = lengthValidatorOptions;
3587
- exports.lookupChildDataContext = lookupChildDataContext;
3588
3421
  exports.lookupDataNode = lookupDataNode;
3589
3422
  exports.makeCompoundField = makeCompoundField;
3590
3423
  exports.makeEvalExpressionHook = makeEvalExpressionHook;
@@ -3597,17 +3430,15 @@ exports.matchesType = matchesType;
3597
3430
  exports.mergeField = mergeField;
3598
3431
  exports.mergeFields = mergeFields;
3599
3432
  exports.mergeObjects = mergeObjects;
3600
- exports.missingField = missingField;
3601
3433
  exports.optionalHook = optionalHook;
3602
3434
  exports.radioButtonOptions = radioButtonOptions;
3603
3435
  exports.relativePath = relativePath;
3604
- exports.relativeSegmentPath = relativeSegmentPath;
3605
3436
  exports.renderControlLayout = renderControlLayout;
3606
3437
  exports.renderLayoutParts = renderLayoutParts;
3607
3438
  exports.renderOptionsFor = renderOptionsFor;
3608
3439
  exports.rendererClass = rendererClass;
3609
- exports.resolveSchemaNode = resolveSchemaNode;
3610
3440
  exports.resolveSchemas = resolveSchemas;
3441
+ exports.rootSchemaNode = rootSchemaNode;
3611
3442
  exports.schemaDataForFieldPath = schemaDataForFieldPath;
3612
3443
  exports.schemaDataForFieldRef = schemaDataForFieldRef;
3613
3444
  exports.schemaForFieldPath = schemaForFieldPath;