@react-typed-forms/schemas 14.4.1 → 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/hooks.d.ts +1 -0
- package/lib/index.cjs +179 -136
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +163 -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/hooks.tsx +10 -0
- 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/hooks.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { SchemaDataNode, SchemaInterface } from "./schemaField";
|
|
|
7
7
|
import { EntityExpression } from "./entityExpression";
|
|
8
8
|
export type EvalExpressionHook<A = any> = DynamicHookGenerator<Control<A | undefined>, ControlDataContext>;
|
|
9
9
|
export type UseEvalExpressionHook = (expr: EntityExpression | undefined | null, coerce: (v: any) => any) => DynamicHookGenerator<Control<any> | undefined, ControlDataContext>;
|
|
10
|
+
export declare function optionalHook(expr: EntityExpression | undefined | null, useHook: UseEvalExpressionHook, coerce: (v: any) => any): DynamicHookGenerator<Control<any> | undefined, ControlDataContext> | undefined;
|
|
10
11
|
export declare function useEvalVisibilityHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition, overrideDataNode?: SchemaDataNode): EvalExpressionHook<boolean>;
|
|
11
12
|
export declare function useEvalReadonlyHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition): EvalExpressionHook<boolean>;
|
|
12
13
|
export declare function useEvalStyleHook(useEvalExpressionHook: UseEvalExpressionHook, property: DynamicPropertyType, definition: ControlDefinition): EvalExpressionHook<React.CSSProperties>;
|
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];
|
|
486
|
-
}
|
|
487
|
-
function getControlIds(definition) {
|
|
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);
|
|
548
|
+
return createFormTree([definition]).rootNode.getChildNodes()[0];
|
|
491
549
|
}
|
|
492
|
-
function
|
|
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);
|
|
@@ -1806,6 +1845,9 @@ function _finallyRethrows(body, finalizer) {
|
|
|
1806
1845
|
}
|
|
1807
1846
|
return finalizer(false, result);
|
|
1808
1847
|
}
|
|
1848
|
+
function optionalHook(expr, useHook, coerce) {
|
|
1849
|
+
return expr && expr.type ? useHook(expr, coerce) : undefined;
|
|
1850
|
+
}
|
|
1809
1851
|
function useEvalVisibilityHook(useEvalExpressionHook, definition, overrideDataNode) {
|
|
1810
1852
|
var dynamicVisibility = useEvalDynamicBoolHook(definition, exports.DynamicPropertyType.Visible, useEvalExpressionHook);
|
|
1811
1853
|
return makeDynamicPropertyHook(dynamicVisibility, function (ctx, _ref) {
|
|
@@ -2446,10 +2488,11 @@ function useControlRendererComponent(controlOrFormNode, renderer, options, paren
|
|
|
2446
2488
|
dataNode: dataNode,
|
|
2447
2489
|
formNode: formNode
|
|
2448
2490
|
});
|
|
2491
|
+
if (formNode == null) debugger;
|
|
2449
2492
|
var Component = React.useCallback(function () {
|
|
2450
2493
|
var stopTracking = core.useComponentTracking();
|
|
2451
2494
|
try {
|
|
2452
|
-
var _options$formData, _dataNode, _definition$adornment2, _definition$adornment3, _options$adjustLayout;
|
|
2495
|
+
var _options$formData, _dataNode, _definition$adornment2, _definition$adornment3, _formNode$tree$getByR, _options$adjustLayout;
|
|
2453
2496
|
var _r$current = r.current,
|
|
2454
2497
|
c = _r$current.definition,
|
|
2455
2498
|
_options = _r$current.options,
|
|
@@ -2557,8 +2600,9 @@ function useControlRendererComponent(controlOrFormNode, renderer, options, paren
|
|
|
2557
2600
|
formOptions: myOptions
|
|
2558
2601
|
});
|
|
2559
2602
|
})) != null ? _definition$adornment2 : [];
|
|
2603
|
+
var otherChildNodes = definition.childRefId && ((_formNode$tree$getByR = _formNode.tree.getByRefId(definition.childRefId)) == null ? void 0 : _formNode$tree$getByR.getChildNodes());
|
|
2560
2604
|
var labelAndChildren = renderControlLayout({
|
|
2561
|
-
formNode: _formNode,
|
|
2605
|
+
formNode: otherChildNodes ? _formNode.tree.createTempNode(_formNode.id, definition, otherChildNodes) : _formNode,
|
|
2562
2606
|
definition: c,
|
|
2563
2607
|
renderer: renderer,
|
|
2564
2608
|
renderChild: function renderChild(k, child, options) {
|
|
@@ -3219,6 +3263,7 @@ function isArrayRegistration(x) {
|
|
|
3219
3263
|
exports.AppendAdornmentPriority = AppendAdornmentPriority;
|
|
3220
3264
|
exports.ControlRenderer = ControlRenderer;
|
|
3221
3265
|
exports.DefaultSchemaInterface = DefaultSchemaInterface;
|
|
3266
|
+
exports.FormTree = FormTree;
|
|
3222
3267
|
exports.NewControlRenderer = NewControlRenderer;
|
|
3223
3268
|
exports.WrapAdornmentPriority = WrapAdornmentPriority;
|
|
3224
3269
|
exports.accordionOptions = accordionOptions;
|
|
@@ -3227,6 +3272,7 @@ exports.actionHandlers = actionHandlers;
|
|
|
3227
3272
|
exports.addFieldOption = addFieldOption;
|
|
3228
3273
|
exports.addMissingControls = addMissingControls;
|
|
3229
3274
|
exports.addMissingControlsForSchema = addMissingControlsForSchema;
|
|
3275
|
+
exports.addMissingControlsToForm = addMissingControlsToForm;
|
|
3230
3276
|
exports.adornmentOptions = adornmentOptions;
|
|
3231
3277
|
exports.appendMarkup = appendMarkup;
|
|
3232
3278
|
exports.appendMarkupAt = appendMarkupAt;
|
|
@@ -3257,7 +3303,6 @@ exports.createDisplayRenderer = createDisplayRenderer;
|
|
|
3257
3303
|
exports.createFormLookup = createFormLookup;
|
|
3258
3304
|
exports.createFormRenderer = createFormRenderer;
|
|
3259
3305
|
exports.createFormTree = createFormTree;
|
|
3260
|
-
exports.createFormTreeWithRoot = createFormTreeWithRoot;
|
|
3261
3306
|
exports.createGroupRenderer = createGroupRenderer;
|
|
3262
3307
|
exports.createLabelRenderer = createLabelRenderer;
|
|
3263
3308
|
exports.createLayoutRenderer = createLayoutRenderer;
|
|
@@ -3271,7 +3316,6 @@ exports.defaultCompoundField = defaultCompoundField;
|
|
|
3271
3316
|
exports.defaultControlForField = defaultControlForField;
|
|
3272
3317
|
exports.defaultDataProps = defaultDataProps;
|
|
3273
3318
|
exports.defaultEvalHooks = defaultEvalHooks;
|
|
3274
|
-
exports.defaultGetChildNodes = defaultGetChildNodes;
|
|
3275
3319
|
exports.defaultScalarField = defaultScalarField;
|
|
3276
3320
|
exports.defaultSchemaInterface = defaultSchemaInterface;
|
|
3277
3321
|
exports.defaultUseEvalExpressionHook = defaultUseEvalExpressionHook;
|
|
@@ -3366,7 +3410,7 @@ exports.matchesType = matchesType;
|
|
|
3366
3410
|
exports.mergeField = mergeField;
|
|
3367
3411
|
exports.mergeFields = mergeFields;
|
|
3368
3412
|
exports.mergeObjects = mergeObjects;
|
|
3369
|
-
exports.
|
|
3413
|
+
exports.optionalHook = optionalHook;
|
|
3370
3414
|
exports.radioButtonOptions = radioButtonOptions;
|
|
3371
3415
|
exports.relativePath = relativePath;
|
|
3372
3416
|
exports.renderControlLayout = renderControlLayout;
|
|
@@ -3418,7 +3462,6 @@ exports.visitControlDefinition = visitControlDefinition;
|
|
|
3418
3462
|
exports.visitFormData = visitFormData;
|
|
3419
3463
|
exports.visitFormDataInContext = visitFormDataInContext;
|
|
3420
3464
|
exports.withScalarOptions = withScalarOptions;
|
|
3421
|
-
exports.wrapFormNode = wrapFormNode;
|
|
3422
3465
|
exports.wrapLayout = wrapLayout;
|
|
3423
3466
|
exports.wrapMarkup = wrapMarkup;
|
|
3424
3467
|
exports.wrapMarkupAt = wrapMarkupAt;
|