@react-typed-forms/schemas 14.5.0 → 15.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/CHANGELOG.json +17 -0
- package/CHANGELOG.md +11 -0
- package/jest.config.js +1 -1
- package/lib/controlBuilder.d.ts +1 -1
- package/lib/controlDefinition.d.ts +8 -8
- package/lib/index.cjs +175 -136
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +160 -135
- package/lib/index.js.map +1 -1
- package/lib/util.d.ts +12 -3
- package/package.json +1 -1
- package/src/controlBuilder.ts +1 -1
- package/src/controlDefinition.ts +84 -72
- package/src/controlRender.tsx +12 -1
- package/src/util.ts +80 -77
- package/tsconfig.test.json +21 -0
package/CHANGELOG.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-typed-forms/schemas",
|
|
3
|
+
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "15.0.0",
|
|
6
|
+
"tag": "@react-typed-forms/schemas_v15.0.0",
|
|
7
|
+
"date": "Tue, 25 Feb 2025 09:07:22 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"major": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "Form Tree API refactor"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
package/CHANGELOG.md
ADDED
package/jest.config.js
CHANGED
package/lib/controlBuilder.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ export declare const emptyGroupDefinition: GroupedControlsDefinition;
|
|
|
52
52
|
export declare function useControlDefinitionForSchema(sf: SchemaField[], definition?: GroupedControlsDefinition): GroupedControlsDefinition;
|
|
53
53
|
export interface EditorGroup {
|
|
54
54
|
parent: string;
|
|
55
|
-
group:
|
|
55
|
+
group: ControlDefinition;
|
|
56
56
|
}
|
|
57
57
|
export interface CustomRenderOptions {
|
|
58
58
|
value: string;
|
|
@@ -358,20 +358,20 @@ export interface FormNode {
|
|
|
358
358
|
definition: ControlDefinition;
|
|
359
359
|
tree: FormTree;
|
|
360
360
|
parent?: FormNode;
|
|
361
|
-
getChildNodes(
|
|
361
|
+
getChildNodes(): FormNode[];
|
|
362
362
|
}
|
|
363
|
-
export declare function defaultGetChildNodes(parent: FormNode, children?: ControlDefinition[] | null): FormNode[];
|
|
364
363
|
export interface FormTreeLookup {
|
|
365
364
|
getForm(formId: string): FormTree | undefined;
|
|
366
365
|
}
|
|
367
|
-
export
|
|
368
|
-
rootNode: FormNode;
|
|
369
|
-
|
|
366
|
+
export declare abstract class FormTree implements FormTreeLookup {
|
|
367
|
+
abstract rootNode: FormNode;
|
|
368
|
+
abstract getByRefId(id: string): FormNode | undefined;
|
|
369
|
+
abstract addChild(parent: FormNode, control: ControlDefinition): FormNode;
|
|
370
|
+
abstract getForm(formId: string): FormTree | undefined;
|
|
371
|
+
createTempNode(id: string, definition: ControlDefinition, children?: FormNode[], parent?: FormNode): FormNode;
|
|
372
|
+
createChildNodes(parent: FormNode, definitions: ControlDefinition[] | undefined | null): FormNode[];
|
|
370
373
|
}
|
|
371
|
-
export declare function wrapFormNode(node: FormNode, getChildren?: (dontFollowRef?: boolean) => FormNode[]): FormNode;
|
|
372
|
-
export declare function nodeForControl(definition: ControlDefinition, tree: FormTree, indexOrId?: number | string, parent?: FormNode): FormNode;
|
|
373
374
|
export declare function legacyFormNode(definition: ControlDefinition): FormNode;
|
|
374
|
-
export declare function createFormTreeWithRoot(createRootNode: (tree: FormTree) => FormNode, getChildrenForId: (id: string, parent: FormNode) => FormNode[], getForm?: FormTreeLookup): FormTree;
|
|
375
375
|
export declare function createFormTree(controls: ControlDefinition[], getForm?: FormTreeLookup): FormTree;
|
|
376
376
|
export declare function createFormLookup<A extends Record<string, ControlDefinition[]>>(formMap: A): {
|
|
377
377
|
getForm(formId: keyof A): FormTree;
|
package/lib/index.cjs
CHANGED
|
@@ -41,6 +41,9 @@ function _extends() {
|
|
|
41
41
|
return n;
|
|
42
42
|
}, _extends.apply(null, arguments);
|
|
43
43
|
}
|
|
44
|
+
function _inheritsLoose(t, o) {
|
|
45
|
+
t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
|
|
46
|
+
}
|
|
44
47
|
function _objectWithoutPropertiesLoose(r, e) {
|
|
45
48
|
if (null == r) return {};
|
|
46
49
|
var t = {};
|
|
@@ -50,6 +53,11 @@ function _objectWithoutPropertiesLoose(r, e) {
|
|
|
50
53
|
}
|
|
51
54
|
return t;
|
|
52
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
|
+
}
|
|
53
61
|
function _unsupportedIterableToArray(r, a) {
|
|
54
62
|
if (r) {
|
|
55
63
|
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
@@ -451,45 +459,95 @@ function isCheckEntryClasses(options) {
|
|
|
451
459
|
return false;
|
|
452
460
|
}
|
|
453
461
|
}
|
|
454
|
-
function
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
function
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
462
|
+
var FormNodeImpl = /*#__PURE__*/function () {
|
|
463
|
+
function FormNodeImpl(id, definition, tree, parent) {
|
|
464
|
+
this.id = void 0;
|
|
465
|
+
this.definition = void 0;
|
|
466
|
+
this.tree = void 0;
|
|
467
|
+
this.parent = void 0;
|
|
468
|
+
this.children = [];
|
|
469
|
+
this.id = id;
|
|
470
|
+
this.definition = definition;
|
|
471
|
+
this.tree = tree;
|
|
472
|
+
this.parent = parent;
|
|
473
|
+
}
|
|
474
|
+
var _proto = FormNodeImpl.prototype;
|
|
475
|
+
_proto.getChildNodes = function getChildNodes() {
|
|
476
|
+
return this.children;
|
|
477
|
+
};
|
|
478
|
+
return FormNodeImpl;
|
|
479
|
+
}();
|
|
480
|
+
var FormTree = /*#__PURE__*/function () {
|
|
481
|
+
function FormTree() {}
|
|
482
|
+
var _proto2 = FormTree.prototype;
|
|
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);
|
|
477
492
|
}
|
|
478
|
-
|
|
479
|
-
|
|
493
|
+
};
|
|
494
|
+
return tempNode;
|
|
480
495
|
};
|
|
481
|
-
|
|
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 : [];
|
|
502
|
+
};
|
|
503
|
+
return FormTree;
|
|
504
|
+
}();
|
|
505
|
+
var FormTreeImpl = /*#__PURE__*/function (_FormTree) {
|
|
506
|
+
function FormTreeImpl(forms) {
|
|
507
|
+
var _this3;
|
|
508
|
+
_this3 = _FormTree.call(this) || this;
|
|
509
|
+
_this3.forms = void 0;
|
|
510
|
+
_this3.controlMap = {};
|
|
511
|
+
_this3.rootNode = void 0;
|
|
512
|
+
_this3.idCount = 1;
|
|
513
|
+
_this3.forms = forms;
|
|
514
|
+
_this3.rootNode = new FormNodeImpl("", {
|
|
515
|
+
type: "Group"
|
|
516
|
+
}, _this3);
|
|
517
|
+
return _this3;
|
|
518
|
+
}
|
|
519
|
+
_inheritsLoose(FormTreeImpl, _FormTree);
|
|
520
|
+
var _proto3 = FormTreeImpl.prototype;
|
|
521
|
+
_proto3.getByRefId = function getByRefId(id) {
|
|
522
|
+
return this.controlMap[id];
|
|
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
|
+
};
|
|
542
|
+
_proto3.getForm = function getForm(formId) {
|
|
543
|
+
return this.forms.getForm(formId);
|
|
544
|
+
};
|
|
545
|
+
return FormTreeImpl;
|
|
546
|
+
}(FormTree);
|
|
482
547
|
function legacyFormNode(definition) {
|
|
483
|
-
return
|
|
484
|
-
$legacy: [definition]
|
|
485
|
-
}).getForm("$legacy").rootNode.getChildNodes()[0];
|
|
548
|
+
return createFormTree([definition]).rootNode.getChildNodes()[0];
|
|
486
549
|
}
|
|
487
|
-
function
|
|
488
|
-
var _definition$children$, _definition$children;
|
|
489
|
-
var childEntries = (_definition$children$ = (_definition$children = definition.children) == null ? void 0 : _definition$children.flatMap(getControlIds)) != null ? _definition$children$ : [];
|
|
490
|
-
return !definition.id ? childEntries : [[definition.id, definition]].concat(childEntries);
|
|
491
|
-
}
|
|
492
|
-
function createFormTreeWithRoot(createRootNode, getChildrenForId, getForm) {
|
|
550
|
+
function createFormTree(controls, getForm) {
|
|
493
551
|
if (getForm === void 0) {
|
|
494
552
|
getForm = {
|
|
495
553
|
getForm: function getForm() {
|
|
@@ -497,34 +555,12 @@ function createFormTreeWithRoot(createRootNode, getChildrenForId, getForm) {
|
|
|
497
555
|
}
|
|
498
556
|
};
|
|
499
557
|
}
|
|
500
|
-
var tree =
|
|
501
|
-
|
|
502
|
-
rootNode
|
|
558
|
+
var tree = new FormTreeImpl(getForm);
|
|
559
|
+
controls.forEach(function (x) {
|
|
560
|
+
return tree.addChild(tree.rootNode, x);
|
|
503
561
|
});
|
|
504
|
-
tree.rootNode = createRootNode(tree);
|
|
505
562
|
return tree;
|
|
506
563
|
}
|
|
507
|
-
function createFormTree(controls, getForm) {
|
|
508
|
-
if (getForm === void 0) {
|
|
509
|
-
getForm = {
|
|
510
|
-
getForm: function getForm() {
|
|
511
|
-
return undefined;
|
|
512
|
-
}
|
|
513
|
-
};
|
|
514
|
-
}
|
|
515
|
-
var controlMap = Object.fromEntries(controls.flatMap(getControlIds));
|
|
516
|
-
return createFormTreeWithRoot(function (tree) {
|
|
517
|
-
return nodeForControl({
|
|
518
|
-
children: controls,
|
|
519
|
-
type: exports.ControlDefinitionType.Group
|
|
520
|
-
}, tree);
|
|
521
|
-
}, function (id, parent) {
|
|
522
|
-
var _controlMap$id$childr, _controlMap$id;
|
|
523
|
-
return (_controlMap$id$childr = (_controlMap$id = controlMap[id]) == null || (_controlMap$id = _controlMap$id.children) == null ? void 0 : _controlMap$id.map(function (x, i) {
|
|
524
|
-
return nodeForControl(x, parent.tree, i, parent);
|
|
525
|
-
})) != null ? _controlMap$id$childr : [];
|
|
526
|
-
}, getForm);
|
|
527
|
-
}
|
|
528
564
|
function createFormLookup(formMap) {
|
|
529
565
|
var lookup = {
|
|
530
566
|
getForm: getForm
|
|
@@ -983,61 +1019,102 @@ function findNonDataGroups(controls) {
|
|
|
983
1019
|
* Adds missing controls to the provided control definitions based on the schema fields.
|
|
984
1020
|
* @param fields - The schema fields to use for adding missing controls.
|
|
985
1021
|
* @param controls - The control definitions to add missing controls to.
|
|
1022
|
+
* @param warning - An optional function to call with warning messages.
|
|
986
1023
|
* @returns The control definitions with missing controls added.
|
|
987
1024
|
*/
|
|
988
|
-
function addMissingControls(fields, controls) {
|
|
989
|
-
return addMissingControlsForSchema(rootSchemaNode(fields), controls);
|
|
1025
|
+
function addMissingControls(fields, 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
|
+
};
|
|
990
1054
|
}
|
|
991
1055
|
/**
|
|
992
1056
|
* Adds missing controls to the provided control definitions based on the schema fields.
|
|
993
1057
|
* @param schema - The root schema node to use for adding missing controls.
|
|
994
1058
|
* @param controls - The control definitions to add missing controls to.
|
|
1059
|
+
* @param warning - An optional function to call with warning messages.
|
|
995
1060
|
* @returns The control definitions with missing controls added.
|
|
996
1061
|
*/
|
|
997
|
-
function addMissingControlsForSchema(schema, controls) {
|
|
998
|
-
var
|
|
999
|
-
var
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
});
|
|
1003
|
-
var rootSchema = {
|
|
1004
|
-
schema: schema,
|
|
1005
|
-
children: rootControls
|
|
1006
|
-
};
|
|
1007
|
-
addSchemaMapEntry("", rootSchema);
|
|
1008
|
-
rootControls.forEach(addReferences);
|
|
1009
|
-
var fields = schema.getChildNodes();
|
|
1010
|
-
fields.forEach(addMissing);
|
|
1011
|
-
return rootControls.map(toDefinition);
|
|
1062
|
+
function addMissingControlsForSchema(schema, controls, warning) {
|
|
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 : [];
|
|
1012
1067
|
function toDefinition(c) {
|
|
1013
|
-
var children = c.
|
|
1014
|
-
return _extends({}, c.
|
|
1068
|
+
var children = c.getChildNodes().length ? c.getChildNodes().map(toDefinition) : null;
|
|
1069
|
+
return _extends({}, c.definition, {
|
|
1015
1070
|
children: children
|
|
1016
1071
|
});
|
|
1017
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;
|
|
1018
1087
|
function addMissing(schemaNode) {
|
|
1019
1088
|
if (fieldHasTag(schemaNode.field, exports.SchemaTags.NoControl)) return;
|
|
1020
|
-
var
|
|
1089
|
+
var skipChildren = false;
|
|
1090
|
+
var existingControls = schemaToForm[schemaNode.id];
|
|
1021
1091
|
if (!existingControls) {
|
|
1022
1092
|
var eligibleParents = getEligibleParents(schemaNode);
|
|
1023
1093
|
var desiredGroup = getTagParam(schemaNode.field, exports.SchemaTags.ControlGroup);
|
|
1024
|
-
var parentGroup = desiredGroup ?
|
|
1025
|
-
if (!parentGroup && desiredGroup)
|
|
1026
|
-
if (parentGroup && eligibleParents.indexOf(parentGroup.
|
|
1027
|
-
|
|
1094
|
+
var parentGroup = desiredGroup ? tree.getByRefId(desiredGroup) : undefined;
|
|
1095
|
+
if (!parentGroup && desiredGroup) warning == null || warning("No group '" + desiredGroup + "' for " + schemaNode.id);
|
|
1096
|
+
if (parentGroup && eligibleParents.indexOf(formToSchema[parentGroup.id].id) < 0) {
|
|
1097
|
+
warning == null || warning("Target group '" + desiredGroup + "' is not an eligible parent for '" + schemaNode.id + "'");
|
|
1028
1098
|
parentGroup = undefined;
|
|
1029
1099
|
}
|
|
1030
1100
|
if (!parentGroup && eligibleParents.length) {
|
|
1031
|
-
var
|
|
1032
|
-
parentGroup = (
|
|
1101
|
+
var _schemaToForm$eligibl;
|
|
1102
|
+
parentGroup = (_schemaToForm$eligibl = schemaToForm[eligibleParents[0]]) == null ? void 0 : _schemaToForm$eligibl[0];
|
|
1033
1103
|
}
|
|
1034
1104
|
if (parentGroup) {
|
|
1035
1105
|
var _newControl = defaultControlForField(schemaNode.field, true);
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1106
|
+
skipChildren = !!_newControl.childRefId;
|
|
1107
|
+
var parentSchemaNode = formToSchema[parentGroup.id];
|
|
1108
|
+
_newControl.field = relativePath(parentSchemaNode, schemaNode);
|
|
1109
|
+
var newNode = tree.addChild(parentGroup, _newControl);
|
|
1110
|
+
register(newNode, parentSchemaNode);
|
|
1111
|
+
} else warning == null || warning("Could not find a parent group for: " + schemaNode.id);
|
|
1112
|
+
} else {
|
|
1113
|
+
skipChildren = existingControls.some(function (x) {
|
|
1114
|
+
return x.definition.childRefId;
|
|
1115
|
+
});
|
|
1039
1116
|
}
|
|
1040
|
-
schemaNode.getChildNodes(true).forEach(addMissing);
|
|
1117
|
+
if (!skipChildren) schemaNode.getChildNodes(true).forEach(addMissing);
|
|
1041
1118
|
}
|
|
1042
1119
|
function getEligibleParents(schemaNode) {
|
|
1043
1120
|
var eligibleParents = [];
|
|
@@ -1056,44 +1133,6 @@ function addMissingControlsForSchema(schema, controls) {
|
|
|
1056
1133
|
}
|
|
1057
1134
|
}
|
|
1058
1135
|
}
|
|
1059
|
-
function addReferences(c) {
|
|
1060
|
-
c.children.forEach(addReferences);
|
|
1061
|
-
if (c.control.childRefId) {
|
|
1062
|
-
var ref = controlMap[c.control.childRefId];
|
|
1063
|
-
if (ref) {
|
|
1064
|
-
ref.children.forEach(function (x) {
|
|
1065
|
-
return toControlAndSchema(x.control, c.schema, c, true);
|
|
1066
|
-
});
|
|
1067
|
-
return;
|
|
1068
|
-
}
|
|
1069
|
-
console.warn("Missing reference", c.control.childRefId);
|
|
1070
|
-
}
|
|
1071
|
-
}
|
|
1072
|
-
function addSchemaMapEntry(schemaId, entry) {
|
|
1073
|
-
if (!schemaControlMap[schemaId]) schemaControlMap[schemaId] = [];
|
|
1074
|
-
schemaControlMap[schemaId].push(entry);
|
|
1075
|
-
}
|
|
1076
|
-
function toControlAndSchema(c, parentSchema, parentNode, dontRegister) {
|
|
1077
|
-
var _c$children$map, _c$children;
|
|
1078
|
-
var controlPath = fieldPathForDefinition(c);
|
|
1079
|
-
var dataSchema = controlPath ? schemaForFieldPath(controlPath, parentSchema) : undefined;
|
|
1080
|
-
if (isGroupControl(c) && dataSchema == null) dataSchema = parentSchema;
|
|
1081
|
-
var entry = {
|
|
1082
|
-
schema: dataSchema,
|
|
1083
|
-
control: c,
|
|
1084
|
-
children: [],
|
|
1085
|
-
parent: parentNode
|
|
1086
|
-
};
|
|
1087
|
-
entry.children = (_c$children$map = (_c$children = c.children) == null ? void 0 : _c$children.map(function (x) {
|
|
1088
|
-
var _dataSchema;
|
|
1089
|
-
return toControlAndSchema(x, (_dataSchema = dataSchema) != null ? _dataSchema : parentSchema, entry, dontRegister);
|
|
1090
|
-
})) != null ? _c$children$map : [];
|
|
1091
|
-
if (!dontRegister && c.id) controlMap[c.id] = entry;
|
|
1092
|
-
if (dataSchema) {
|
|
1093
|
-
addSchemaMapEntry(dataSchema.id, entry);
|
|
1094
|
-
}
|
|
1095
|
-
return entry;
|
|
1096
|
-
}
|
|
1097
1136
|
}
|
|
1098
1137
|
/**
|
|
1099
1138
|
* Custom hook to use an updated reference.
|
|
@@ -1182,8 +1221,8 @@ function cleanDataForSchema(v, fields, removeIfDefault) {
|
|
|
1182
1221
|
* @returns An array of referenced classes.
|
|
1183
1222
|
*/
|
|
1184
1223
|
function getAllReferencedClasses(c, collectExtra) {
|
|
1185
|
-
var _c$
|
|
1186
|
-
var childClasses = (_c$
|
|
1224
|
+
var _c$children, _collectExtra;
|
|
1225
|
+
var childClasses = (_c$children = c.children) == null ? void 0 : _c$children.flatMap(function (x) {
|
|
1187
1226
|
return getAllReferencedClasses(x, collectExtra);
|
|
1188
1227
|
});
|
|
1189
1228
|
var go = getGroupClassOverrides(c);
|
|
@@ -2449,10 +2488,11 @@ function useControlRendererComponent(controlOrFormNode, renderer, options, paren
|
|
|
2449
2488
|
dataNode: dataNode,
|
|
2450
2489
|
formNode: formNode
|
|
2451
2490
|
});
|
|
2491
|
+
if (formNode == null) debugger;
|
|
2452
2492
|
var Component = React.useCallback(function () {
|
|
2453
2493
|
var stopTracking = core.useComponentTracking();
|
|
2454
2494
|
try {
|
|
2455
|
-
var _options$formData, _dataNode, _definition$adornment2, _definition$adornment3, _options$adjustLayout;
|
|
2495
|
+
var _options$formData, _dataNode, _definition$adornment2, _definition$adornment3, _formNode$tree$getByR, _options$adjustLayout;
|
|
2456
2496
|
var _r$current = r.current,
|
|
2457
2497
|
c = _r$current.definition,
|
|
2458
2498
|
_options = _r$current.options,
|
|
@@ -2560,8 +2600,9 @@ function useControlRendererComponent(controlOrFormNode, renderer, options, paren
|
|
|
2560
2600
|
formOptions: myOptions
|
|
2561
2601
|
});
|
|
2562
2602
|
})) != null ? _definition$adornment2 : [];
|
|
2603
|
+
var otherChildNodes = definition.childRefId && ((_formNode$tree$getByR = _formNode.tree.getByRefId(definition.childRefId)) == null ? void 0 : _formNode$tree$getByR.getChildNodes());
|
|
2563
2604
|
var labelAndChildren = renderControlLayout({
|
|
2564
|
-
formNode: _formNode,
|
|
2605
|
+
formNode: otherChildNodes ? _formNode.tree.createTempNode(_formNode.id, definition, otherChildNodes) : _formNode,
|
|
2565
2606
|
definition: c,
|
|
2566
2607
|
renderer: renderer,
|
|
2567
2608
|
renderChild: function renderChild(k, child, options) {
|
|
@@ -3222,6 +3263,7 @@ function isArrayRegistration(x) {
|
|
|
3222
3263
|
exports.AppendAdornmentPriority = AppendAdornmentPriority;
|
|
3223
3264
|
exports.ControlRenderer = ControlRenderer;
|
|
3224
3265
|
exports.DefaultSchemaInterface = DefaultSchemaInterface;
|
|
3266
|
+
exports.FormTree = FormTree;
|
|
3225
3267
|
exports.NewControlRenderer = NewControlRenderer;
|
|
3226
3268
|
exports.WrapAdornmentPriority = WrapAdornmentPriority;
|
|
3227
3269
|
exports.accordionOptions = accordionOptions;
|
|
@@ -3230,6 +3272,7 @@ exports.actionHandlers = actionHandlers;
|
|
|
3230
3272
|
exports.addFieldOption = addFieldOption;
|
|
3231
3273
|
exports.addMissingControls = addMissingControls;
|
|
3232
3274
|
exports.addMissingControlsForSchema = addMissingControlsForSchema;
|
|
3275
|
+
exports.addMissingControlsToForm = addMissingControlsToForm;
|
|
3233
3276
|
exports.adornmentOptions = adornmentOptions;
|
|
3234
3277
|
exports.appendMarkup = appendMarkup;
|
|
3235
3278
|
exports.appendMarkupAt = appendMarkupAt;
|
|
@@ -3260,7 +3303,6 @@ exports.createDisplayRenderer = createDisplayRenderer;
|
|
|
3260
3303
|
exports.createFormLookup = createFormLookup;
|
|
3261
3304
|
exports.createFormRenderer = createFormRenderer;
|
|
3262
3305
|
exports.createFormTree = createFormTree;
|
|
3263
|
-
exports.createFormTreeWithRoot = createFormTreeWithRoot;
|
|
3264
3306
|
exports.createGroupRenderer = createGroupRenderer;
|
|
3265
3307
|
exports.createLabelRenderer = createLabelRenderer;
|
|
3266
3308
|
exports.createLayoutRenderer = createLayoutRenderer;
|
|
@@ -3274,7 +3316,6 @@ exports.defaultCompoundField = defaultCompoundField;
|
|
|
3274
3316
|
exports.defaultControlForField = defaultControlForField;
|
|
3275
3317
|
exports.defaultDataProps = defaultDataProps;
|
|
3276
3318
|
exports.defaultEvalHooks = defaultEvalHooks;
|
|
3277
|
-
exports.defaultGetChildNodes = defaultGetChildNodes;
|
|
3278
3319
|
exports.defaultScalarField = defaultScalarField;
|
|
3279
3320
|
exports.defaultSchemaInterface = defaultSchemaInterface;
|
|
3280
3321
|
exports.defaultUseEvalExpressionHook = defaultUseEvalExpressionHook;
|
|
@@ -3369,7 +3410,6 @@ exports.matchesType = matchesType;
|
|
|
3369
3410
|
exports.mergeField = mergeField;
|
|
3370
3411
|
exports.mergeFields = mergeFields;
|
|
3371
3412
|
exports.mergeObjects = mergeObjects;
|
|
3372
|
-
exports.nodeForControl = nodeForControl;
|
|
3373
3413
|
exports.optionalHook = optionalHook;
|
|
3374
3414
|
exports.radioButtonOptions = radioButtonOptions;
|
|
3375
3415
|
exports.relativePath = relativePath;
|
|
@@ -3422,7 +3462,6 @@ exports.visitControlDefinition = visitControlDefinition;
|
|
|
3422
3462
|
exports.visitFormData = visitFormData;
|
|
3423
3463
|
exports.visitFormDataInContext = visitFormDataInContext;
|
|
3424
3464
|
exports.withScalarOptions = withScalarOptions;
|
|
3425
|
-
exports.wrapFormNode = wrapFormNode;
|
|
3426
3465
|
exports.wrapLayout = wrapLayout;
|
|
3427
3466
|
exports.wrapMarkup = wrapMarkup;
|
|
3428
3467
|
exports.wrapMarkupAt = wrapMarkupAt;
|