@react-typed-forms/schemas 15.2.0 → 16.0.1
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/RenderForm.d.ts +39 -0
- package/lib/controlBuilder.d.ts +3 -6
- package/lib/controlRender.d.ts +107 -87
- package/lib/index.cjs +556 -2117
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +3 -9
- package/lib/index.js +421 -1642
- package/lib/index.js.map +1 -1
- package/lib/renderers.d.ts +3 -3
- package/lib/types.d.ts +31 -0
- package/lib/util.d.ts +9 -54
- package/package.json +5 -4
- package/src/RenderForm.tsx +301 -0
- package/src/controlBuilder.ts +22 -19
- package/src/controlRender.tsx +228 -507
- package/src/createFormRenderer.tsx +4 -5
- package/src/index.ts +3 -9
- package/src/renderers.tsx +2 -3
- package/src/types.ts +52 -0
- package/src/util.ts +170 -184
- package/lib/controlDefinition.d.ts +0 -398
- package/lib/defaultSchemaInterface.d.ts +0 -24
- package/lib/dynamicHooks.d.ts +0 -54
- package/lib/entityExpression.d.ts +0 -32
- package/lib/hooks.d.ts +0 -28
- package/lib/schemaBuilder.d.ts +0 -67
- package/lib/schemaField.d.ts +0 -252
- package/lib/schemaValidator.d.ts +0 -27
- package/lib/validators.d.ts +0 -19
- package/src/controlDefinition.ts +0 -821
- package/src/defaultSchemaInterface.ts +0 -191
- package/src/dynamicHooks.ts +0 -98
- package/src/entityExpression.ts +0 -38
- package/src/hooks.tsx +0 -469
- package/src/schemaBuilder.ts +0 -318
- package/src/schemaField.ts +0 -552
- package/src/schemaValidator.ts +0 -32
- package/src/validators.ts +0 -217
package/lib/index.cjs
CHANGED
|
@@ -1,37 +1,13 @@
|
|
|
1
|
-
var
|
|
1
|
+
var formsCore = require('@astroapps/forms-core');
|
|
2
2
|
var react = require('react');
|
|
3
3
|
var clsx = require('clsx');
|
|
4
|
-
var
|
|
5
|
-
var uuid = require('uuid');
|
|
4
|
+
var core = require('@react-typed-forms/core');
|
|
6
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
6
|
|
|
8
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
8
|
|
|
10
9
|
var clsx__default = /*#__PURE__*/_interopDefaultLegacy(clsx);
|
|
11
|
-
var jsonata__default = /*#__PURE__*/_interopDefaultLegacy(jsonata);
|
|
12
10
|
|
|
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
11
|
function _extends() {
|
|
36
12
|
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
37
13
|
for (var e = 1; e < arguments.length; e++) {
|
|
@@ -41,9 +17,6 @@ function _extends() {
|
|
|
41
17
|
return n;
|
|
42
18
|
}, _extends.apply(null, arguments);
|
|
43
19
|
}
|
|
44
|
-
function _inheritsLoose(t, o) {
|
|
45
|
-
t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
|
|
46
|
-
}
|
|
47
20
|
function _objectWithoutPropertiesLoose(r, e) {
|
|
48
21
|
if (null == r) return {};
|
|
49
22
|
var t = {};
|
|
@@ -53,776 +26,6 @@ function _objectWithoutPropertiesLoose(r, e) {
|
|
|
53
26
|
}
|
|
54
27
|
return t;
|
|
55
28
|
}
|
|
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
|
-
|
|
309
|
-
exports.ControlDefinitionType = void 0;
|
|
310
|
-
(function (ControlDefinitionType) {
|
|
311
|
-
ControlDefinitionType["Data"] = "Data";
|
|
312
|
-
ControlDefinitionType["Group"] = "Group";
|
|
313
|
-
ControlDefinitionType["Display"] = "Display";
|
|
314
|
-
ControlDefinitionType["Action"] = "Action";
|
|
315
|
-
})(exports.ControlDefinitionType || (exports.ControlDefinitionType = {}));
|
|
316
|
-
exports.DynamicPropertyType = void 0;
|
|
317
|
-
(function (DynamicPropertyType) {
|
|
318
|
-
DynamicPropertyType["Visible"] = "Visible";
|
|
319
|
-
DynamicPropertyType["DefaultValue"] = "DefaultValue";
|
|
320
|
-
DynamicPropertyType["Readonly"] = "Readonly";
|
|
321
|
-
DynamicPropertyType["Disabled"] = "Disabled";
|
|
322
|
-
DynamicPropertyType["Display"] = "Display";
|
|
323
|
-
DynamicPropertyType["Style"] = "Style";
|
|
324
|
-
DynamicPropertyType["LayoutStyle"] = "LayoutStyle";
|
|
325
|
-
DynamicPropertyType["AllowedOptions"] = "AllowedOptions";
|
|
326
|
-
DynamicPropertyType["Label"] = "Label";
|
|
327
|
-
DynamicPropertyType["ActionData"] = "ActionData";
|
|
328
|
-
})(exports.DynamicPropertyType || (exports.DynamicPropertyType = {}));
|
|
329
|
-
exports.AdornmentPlacement = void 0;
|
|
330
|
-
(function (AdornmentPlacement) {
|
|
331
|
-
AdornmentPlacement["ControlStart"] = "ControlStart";
|
|
332
|
-
AdornmentPlacement["ControlEnd"] = "ControlEnd";
|
|
333
|
-
AdornmentPlacement["LabelStart"] = "LabelStart";
|
|
334
|
-
AdornmentPlacement["LabelEnd"] = "LabelEnd";
|
|
335
|
-
})(exports.AdornmentPlacement || (exports.AdornmentPlacement = {}));
|
|
336
|
-
exports.ControlAdornmentType = void 0;
|
|
337
|
-
(function (ControlAdornmentType) {
|
|
338
|
-
ControlAdornmentType["Tooltip"] = "Tooltip";
|
|
339
|
-
ControlAdornmentType["Accordion"] = "Accordion";
|
|
340
|
-
ControlAdornmentType["HelpText"] = "HelpText";
|
|
341
|
-
ControlAdornmentType["Icon"] = "Icon";
|
|
342
|
-
ControlAdornmentType["SetField"] = "SetField";
|
|
343
|
-
ControlAdornmentType["Optional"] = "Optional";
|
|
344
|
-
})(exports.ControlAdornmentType || (exports.ControlAdornmentType = {}));
|
|
345
|
-
exports.DataRenderType = void 0;
|
|
346
|
-
(function (DataRenderType) {
|
|
347
|
-
DataRenderType["Standard"] = "Standard";
|
|
348
|
-
DataRenderType["Textfield"] = "Textfield";
|
|
349
|
-
DataRenderType["Radio"] = "Radio";
|
|
350
|
-
DataRenderType["HtmlEditor"] = "HtmlEditor";
|
|
351
|
-
DataRenderType["IconList"] = "IconList";
|
|
352
|
-
DataRenderType["CheckList"] = "CheckList";
|
|
353
|
-
DataRenderType["UserSelection"] = "UserSelection";
|
|
354
|
-
DataRenderType["Synchronised"] = "Synchronised";
|
|
355
|
-
DataRenderType["IconSelector"] = "IconSelector";
|
|
356
|
-
DataRenderType["DateTime"] = "DateTime";
|
|
357
|
-
DataRenderType["Checkbox"] = "Checkbox";
|
|
358
|
-
DataRenderType["Dropdown"] = "Dropdown";
|
|
359
|
-
DataRenderType["DisplayOnly"] = "DisplayOnly";
|
|
360
|
-
DataRenderType["Group"] = "Group";
|
|
361
|
-
DataRenderType["NullToggle"] = "NullToggle";
|
|
362
|
-
DataRenderType["Autocomplete"] = "Autocomplete";
|
|
363
|
-
DataRenderType["Jsonata"] = "Jsonata";
|
|
364
|
-
DataRenderType["Array"] = "Array";
|
|
365
|
-
DataRenderType["ArrayElement"] = "ArrayElement";
|
|
366
|
-
})(exports.DataRenderType || (exports.DataRenderType = {}));
|
|
367
|
-
exports.SyncTextType = void 0;
|
|
368
|
-
(function (SyncTextType) {
|
|
369
|
-
SyncTextType["Camel"] = "Camel";
|
|
370
|
-
SyncTextType["Snake"] = "Snake";
|
|
371
|
-
SyncTextType["Pascal"] = "Pascal";
|
|
372
|
-
})(exports.SyncTextType || (exports.SyncTextType = {}));
|
|
373
|
-
exports.GroupRenderType = void 0;
|
|
374
|
-
(function (GroupRenderType) {
|
|
375
|
-
GroupRenderType["Standard"] = "Standard";
|
|
376
|
-
GroupRenderType["Grid"] = "Grid";
|
|
377
|
-
GroupRenderType["Flex"] = "Flex";
|
|
378
|
-
GroupRenderType["Tabs"] = "Tabs";
|
|
379
|
-
GroupRenderType["GroupElement"] = "GroupElement";
|
|
380
|
-
GroupRenderType["SelectChild"] = "SelectChild";
|
|
381
|
-
})(exports.GroupRenderType || (exports.GroupRenderType = {}));
|
|
382
|
-
exports.DisplayDataType = void 0;
|
|
383
|
-
(function (DisplayDataType) {
|
|
384
|
-
DisplayDataType["Text"] = "Text";
|
|
385
|
-
DisplayDataType["Html"] = "Html";
|
|
386
|
-
DisplayDataType["Icon"] = "Icon";
|
|
387
|
-
DisplayDataType["Custom"] = "Custom";
|
|
388
|
-
})(exports.DisplayDataType || (exports.DisplayDataType = {}));
|
|
389
|
-
function visitControlDefinition(x, visitor, defaultValue) {
|
|
390
|
-
switch (x.type) {
|
|
391
|
-
case exports.ControlDefinitionType.Action:
|
|
392
|
-
return visitor.action(x);
|
|
393
|
-
case exports.ControlDefinitionType.Data:
|
|
394
|
-
return visitor.data(x);
|
|
395
|
-
case exports.ControlDefinitionType.Display:
|
|
396
|
-
return visitor.display(x);
|
|
397
|
-
case exports.ControlDefinitionType.Group:
|
|
398
|
-
return visitor.group(x);
|
|
399
|
-
default:
|
|
400
|
-
return defaultValue(x);
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
function isGridRenderer(options) {
|
|
404
|
-
return options.type === exports.GroupRenderType.Grid;
|
|
405
|
-
}
|
|
406
|
-
function isSelectChildRenderer(options) {
|
|
407
|
-
return options.type === exports.GroupRenderType.SelectChild;
|
|
408
|
-
}
|
|
409
|
-
function isTabsRenderer(options) {
|
|
410
|
-
return options.type === exports.GroupRenderType.Tabs;
|
|
411
|
-
}
|
|
412
|
-
function isFlexRenderer(options) {
|
|
413
|
-
return options.type === exports.GroupRenderType.Flex;
|
|
414
|
-
}
|
|
415
|
-
function isDisplayOnlyRenderer(options) {
|
|
416
|
-
return options.type === exports.DataRenderType.DisplayOnly;
|
|
417
|
-
}
|
|
418
|
-
function isTextfieldRenderer(options) {
|
|
419
|
-
return options.type === exports.DataRenderType.Textfield;
|
|
420
|
-
}
|
|
421
|
-
function isDateTimeRenderer(options) {
|
|
422
|
-
return options.type === exports.DataRenderType.DateTime;
|
|
423
|
-
}
|
|
424
|
-
function isAutocompleteRenderer(options) {
|
|
425
|
-
return options.type === exports.DataRenderType.Autocomplete;
|
|
426
|
-
}
|
|
427
|
-
function isAutoCompleteClasses(options) {
|
|
428
|
-
switch (options == null ? void 0 : options.type) {
|
|
429
|
-
case exports.DataRenderType.Autocomplete:
|
|
430
|
-
return true;
|
|
431
|
-
default:
|
|
432
|
-
return false;
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
function isDataGroupRenderer(options) {
|
|
436
|
-
return (options == null ? void 0 : options.type) === exports.DataRenderType.Group;
|
|
437
|
-
}
|
|
438
|
-
function isArrayRenderer(options) {
|
|
439
|
-
return options.type === exports.DataRenderType.Array;
|
|
440
|
-
}
|
|
441
|
-
function isDataControl(c) {
|
|
442
|
-
return c.type === exports.ControlDefinitionType.Data;
|
|
443
|
-
}
|
|
444
|
-
function isGroupControl(c) {
|
|
445
|
-
return c.type === exports.ControlDefinitionType.Group;
|
|
446
|
-
}
|
|
447
|
-
function isActionControl(c) {
|
|
448
|
-
return c.type === exports.ControlDefinitionType.Action;
|
|
449
|
-
}
|
|
450
|
-
function isDisplayControl(c) {
|
|
451
|
-
return c.type === exports.ControlDefinitionType.Display;
|
|
452
|
-
}
|
|
453
|
-
function isCheckEntryClasses(options) {
|
|
454
|
-
switch (options == null ? void 0 : options.type) {
|
|
455
|
-
case exports.DataRenderType.Radio:
|
|
456
|
-
case exports.DataRenderType.CheckList:
|
|
457
|
-
return true;
|
|
458
|
-
default:
|
|
459
|
-
return false;
|
|
460
|
-
}
|
|
461
|
-
}
|
|
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);
|
|
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 : [];
|
|
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);
|
|
547
|
-
function legacyFormNode(definition) {
|
|
548
|
-
return createFormTree([definition]).rootNode.getChildNodes()[0];
|
|
549
|
-
}
|
|
550
|
-
function createFormTree(controls, getForm) {
|
|
551
|
-
if (getForm === void 0) {
|
|
552
|
-
getForm = {
|
|
553
|
-
getForm: function getForm() {
|
|
554
|
-
return undefined;
|
|
555
|
-
}
|
|
556
|
-
};
|
|
557
|
-
}
|
|
558
|
-
var tree = new FormTreeImpl(getForm);
|
|
559
|
-
controls.forEach(function (x) {
|
|
560
|
-
return tree.addChild(tree.rootNode, x);
|
|
561
|
-
});
|
|
562
|
-
return tree;
|
|
563
|
-
}
|
|
564
|
-
function createFormLookup(formMap) {
|
|
565
|
-
var lookup = {
|
|
566
|
-
getForm: getForm
|
|
567
|
-
};
|
|
568
|
-
var forms = Object.fromEntries(Object.entries(formMap).map(function (_ref) {
|
|
569
|
-
var k = _ref[0],
|
|
570
|
-
v = _ref[1];
|
|
571
|
-
return [k, createFormTree(v, lookup)];
|
|
572
|
-
}));
|
|
573
|
-
return lookup;
|
|
574
|
-
function getForm(formId) {
|
|
575
|
-
return forms[formId];
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
function fieldPathForDefinition(c) {
|
|
579
|
-
var fieldName = isGroupControl(c) ? c.compoundField : isDataControl(c) ? c.field : undefined;
|
|
580
|
-
return fieldName == null ? void 0 : fieldName.split("/");
|
|
581
|
-
}
|
|
582
|
-
function lookupDataNode(c, parentNode) {
|
|
583
|
-
var fieldNamePath = fieldPathForDefinition(c);
|
|
584
|
-
return fieldNamePath ? schemaDataForFieldPath(fieldNamePath, parentNode) : undefined;
|
|
585
|
-
}
|
|
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;
|
|
617
|
-
});
|
|
618
|
-
}
|
|
619
|
-
/**
|
|
620
|
-
* @deprecated use visitFormNodeData instead
|
|
621
|
-
*/
|
|
622
|
-
function visitControlDataArray(controls, context, cb) {
|
|
623
|
-
if (!controls) return undefined;
|
|
624
|
-
for (var _iterator = _createForOfIteratorHelperLoose(controls), _step; !(_step = _iterator()).done;) {
|
|
625
|
-
var c = _step.value;
|
|
626
|
-
var r = visitControlData(c, context, cb);
|
|
627
|
-
if (r !== undefined) return r;
|
|
628
|
-
}
|
|
629
|
-
return undefined;
|
|
630
|
-
}
|
|
631
|
-
/**
|
|
632
|
-
* @deprecated use visitFormDataInContext instead
|
|
633
|
-
*/
|
|
634
|
-
function visitControlData(definition, ctx, cb) {
|
|
635
|
-
return visitFormDataInContext(ctx, legacyFormNode(definition), function (n, d) {
|
|
636
|
-
return cb(d, n);
|
|
637
|
-
});
|
|
638
|
-
}
|
|
639
|
-
function visitFormData(node, dataNode, cb, notSelf) {
|
|
640
|
-
var def = node.definition;
|
|
641
|
-
var result = !notSelf && isDataControl(def) ? cb(dataNode, def) : undefined;
|
|
642
|
-
if (result !== undefined) return result;
|
|
643
|
-
if (dataNode.elementIndex == null && dataNode.schema.field.collection) {
|
|
644
|
-
var _l = dataNode.control.elements.length;
|
|
645
|
-
for (var i = 0; i < _l; i++) {
|
|
646
|
-
var elemChild = dataNode.getChildElement(i);
|
|
647
|
-
var elemResult = visitFormData(node, elemChild, cb);
|
|
648
|
-
if (elemResult !== undefined) return elemResult;
|
|
649
|
-
}
|
|
650
|
-
return undefined;
|
|
651
|
-
}
|
|
652
|
-
if (dataNode.control.isNull) return undefined;
|
|
653
|
-
var children = node.getChildNodes();
|
|
654
|
-
var l = children.length;
|
|
655
|
-
for (var _i = 0; _i < l; _i++) {
|
|
656
|
-
var _elemResult = visitFormDataInContext(dataNode, children[_i], cb);
|
|
657
|
-
if (_elemResult !== undefined) return _elemResult;
|
|
658
|
-
}
|
|
659
|
-
return undefined;
|
|
660
|
-
}
|
|
661
|
-
function visitFormDataInContext(parentContext, node, cb) {
|
|
662
|
-
var dataNode = lookupDataNode(node.definition, parentContext);
|
|
663
|
-
return visitFormData(node, dataNode != null ? dataNode : parentContext, cb, !dataNode);
|
|
664
|
-
}
|
|
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
29
|
|
|
827
30
|
/**
|
|
828
31
|
* Applies default values to the given record based on the provided schema fields.
|
|
@@ -832,13 +35,12 @@ function resolveSchemas(schemaMap) {
|
|
|
832
35
|
* @returns The record with default values applied.
|
|
833
36
|
*/
|
|
834
37
|
function applyDefaultValues(v, fields, doneSet) {
|
|
835
|
-
var _doneSet;
|
|
836
38
|
if (!v) return defaultValueForFields(fields);
|
|
837
39
|
if (doneSet && doneSet.has(v)) return v;
|
|
838
|
-
|
|
40
|
+
doneSet != null ? doneSet : doneSet = new Set();
|
|
839
41
|
doneSet.add(v);
|
|
840
42
|
var applyValue = fields.filter(function (x) {
|
|
841
|
-
return isCompoundField(x) || !(x.field in v);
|
|
43
|
+
return formsCore.isCompoundField(x) || !(x.field in v);
|
|
842
44
|
});
|
|
843
45
|
if (!applyValue.length) return v;
|
|
844
46
|
var out = _extends({}, v);
|
|
@@ -862,7 +64,7 @@ function applyDefaultForField(v, field, parent, notElement, doneSet) {
|
|
|
862
64
|
return applyDefaultForField(x, field, parent, true, doneSet);
|
|
863
65
|
});
|
|
864
66
|
}
|
|
865
|
-
if (isCompoundField(field)) {
|
|
67
|
+
if (formsCore.isCompoundField(field)) {
|
|
866
68
|
if (!v && !field.required) return v;
|
|
867
69
|
return applyDefaultValues(v, field.treeChildren ? parent : field.children, doneSet);
|
|
868
70
|
}
|
|
@@ -887,9 +89,10 @@ function defaultValueForFields(fields) {
|
|
|
887
89
|
function defaultValueForField(sf, required) {
|
|
888
90
|
if (sf.defaultValue !== undefined) return sf.defaultValue;
|
|
889
91
|
var isRequired = !!(required || sf.required);
|
|
890
|
-
if (isCompoundField(sf)) {
|
|
92
|
+
if (formsCore.isCompoundField(sf)) {
|
|
891
93
|
if (isRequired) {
|
|
892
|
-
var
|
|
94
|
+
var _sf$children;
|
|
95
|
+
var childValue = defaultValueForFields((_sf$children = sf.children) != null ? _sf$children : []);
|
|
893
96
|
return sf.collection ? [childValue] : childValue;
|
|
894
97
|
}
|
|
895
98
|
return sf.notNullable ? sf.collection ? [] : {} : undefined;
|
|
@@ -905,8 +108,9 @@ function defaultValueForField(sf, required) {
|
|
|
905
108
|
* @returns The element value for the schema field.
|
|
906
109
|
*/
|
|
907
110
|
function elementValueForField(sf) {
|
|
908
|
-
if (isCompoundField(sf)) {
|
|
909
|
-
|
|
111
|
+
if (formsCore.isCompoundField(sf)) {
|
|
112
|
+
var _sf$children2;
|
|
113
|
+
return defaultValueForFields((_sf$children2 = sf.children) != null ? _sf$children2 : []);
|
|
910
114
|
}
|
|
911
115
|
return sf.defaultValue;
|
|
912
116
|
}
|
|
@@ -917,7 +121,7 @@ function elementValueForField(sf) {
|
|
|
917
121
|
* @returns The found scalar field, or undefined if not found.
|
|
918
122
|
*/
|
|
919
123
|
function findScalarField(fields, field) {
|
|
920
|
-
return findField(fields, field);
|
|
124
|
+
return formsCore.findField(fields, field);
|
|
921
125
|
}
|
|
922
126
|
/**
|
|
923
127
|
* Finds a compound field in the provided schema fields.
|
|
@@ -926,7 +130,7 @@ function findScalarField(fields, field) {
|
|
|
926
130
|
* @returns The found compound field, or undefined if not found.
|
|
927
131
|
*/
|
|
928
132
|
function findCompoundField(fields, field) {
|
|
929
|
-
return findField(fields, field);
|
|
133
|
+
return formsCore.findField(fields, field);
|
|
930
134
|
}
|
|
931
135
|
/**
|
|
932
136
|
* Checks if a field has a specific tag.
|
|
@@ -963,39 +167,39 @@ function hasOptions(o) {
|
|
|
963
167
|
* @returns The default control definition for the schema field.
|
|
964
168
|
*/
|
|
965
169
|
function defaultControlForField(sf, noChildren) {
|
|
966
|
-
if (isCompoundField(sf)) {
|
|
967
|
-
var ref = getTagParam(sf,
|
|
170
|
+
if (formsCore.isCompoundField(sf)) {
|
|
171
|
+
var ref = formsCore.getTagParam(sf, formsCore.SchemaTags.ControlRef);
|
|
968
172
|
return {
|
|
969
|
-
type:
|
|
173
|
+
type: formsCore.ControlDefinitionType.Data,
|
|
970
174
|
title: sf.displayName,
|
|
971
175
|
field: sf.field,
|
|
972
176
|
required: sf.required,
|
|
973
177
|
childRefId: ref,
|
|
974
178
|
children: !noChildren && !ref ? sf.children.filter(function (x) {
|
|
975
|
-
return !fieldHasTag(x,
|
|
179
|
+
return !fieldHasTag(x, formsCore.SchemaTags.NoControl);
|
|
976
180
|
}).map(function (x) {
|
|
977
181
|
return defaultControlForField(x);
|
|
978
182
|
}) : undefined
|
|
979
183
|
};
|
|
980
|
-
} else if (isScalarField(sf)) {
|
|
981
|
-
var htmlEditor = fieldHasTag(sf,
|
|
184
|
+
} else if (formsCore.isScalarField(sf)) {
|
|
185
|
+
var htmlEditor = fieldHasTag(sf, formsCore.SchemaTags.HtmlEditor);
|
|
982
186
|
return {
|
|
983
|
-
type:
|
|
187
|
+
type: formsCore.ControlDefinitionType.Data,
|
|
984
188
|
title: sf.displayName,
|
|
985
189
|
field: sf.field,
|
|
986
190
|
required: sf.required,
|
|
987
191
|
renderOptions: {
|
|
988
|
-
type: htmlEditor ?
|
|
192
|
+
type: htmlEditor ? formsCore.DataRenderType.HtmlEditor : formsCore.DataRenderType.Standard
|
|
989
193
|
}
|
|
990
194
|
};
|
|
991
195
|
}
|
|
992
196
|
throw "Unknown schema field";
|
|
993
197
|
}
|
|
994
198
|
function findControlsForCompound(compound, definition) {
|
|
995
|
-
if (isDataControl(definition) && compound.field.field === definition.field) {
|
|
199
|
+
if (formsCore.isDataControl(definition) && compound.field.field === definition.field) {
|
|
996
200
|
return [definition];
|
|
997
201
|
}
|
|
998
|
-
if (isGroupControl(definition)) {
|
|
202
|
+
if (formsCore.isGroupControl(definition)) {
|
|
999
203
|
var _definition$children$, _definition$children;
|
|
1000
204
|
if (definition.compoundField === compound.field.field) return [definition];
|
|
1001
205
|
return (_definition$children$ = (_definition$children = definition.children) == null ? void 0 : _definition$children.flatMap(function (d) {
|
|
@@ -1012,7 +216,7 @@ function findControlsForCompound(compound, definition) {
|
|
|
1012
216
|
function findNonDataGroups(controls) {
|
|
1013
217
|
return controls.flatMap(function (control) {
|
|
1014
218
|
var _control$children2;
|
|
1015
|
-
return isGroupControl(control) && !control.compoundField ? [control].concat(findNonDataGroups((_control$children2 = control.children) != null ? _control$children2 : [])) : [];
|
|
219
|
+
return formsCore.isGroupControl(control) && !control.compoundField ? [control].concat(findNonDataGroups((_control$children2 = control.children) != null ? _control$children2 : [])) : [];
|
|
1016
220
|
});
|
|
1017
221
|
}
|
|
1018
222
|
/**
|
|
@@ -1023,34 +227,7 @@ function findNonDataGroups(controls) {
|
|
|
1023
227
|
* @returns The control definitions with missing controls added.
|
|
1024
228
|
*/
|
|
1025
229
|
function addMissingControls(fields, controls, warning) {
|
|
1026
|
-
return addMissingControlsForSchema(
|
|
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
|
-
};
|
|
230
|
+
return addMissingControlsForSchema(formsCore.createSchemaTree(fields).rootNode, controls, warning);
|
|
1054
231
|
}
|
|
1055
232
|
/**
|
|
1056
233
|
* Adds missing controls to the provided control definitions based on the schema fields.
|
|
@@ -1060,61 +237,55 @@ function registerSchemaEntries(formNode, parentSchema) {
|
|
|
1060
237
|
* @returns The control definitions with missing controls added.
|
|
1061
238
|
*/
|
|
1062
239
|
function addMissingControlsForSchema(schema, controls, warning) {
|
|
1063
|
-
var
|
|
1064
|
-
var
|
|
1065
|
-
|
|
1066
|
-
|
|
240
|
+
var controlMap = {};
|
|
241
|
+
var schemaControlMap = {};
|
|
242
|
+
var rootControls = controls.map(function (c) {
|
|
243
|
+
return toControlAndSchema(c, schema);
|
|
244
|
+
});
|
|
245
|
+
var rootSchema = {
|
|
246
|
+
schema: schema,
|
|
247
|
+
children: rootControls
|
|
248
|
+
};
|
|
249
|
+
addSchemaMapEntry("", rootSchema);
|
|
250
|
+
rootControls.forEach(addReferences);
|
|
251
|
+
var fields = schema.getChildNodes();
|
|
252
|
+
fields.forEach(addMissing);
|
|
253
|
+
return rootControls.map(toDefinition);
|
|
1067
254
|
function toDefinition(c) {
|
|
1068
|
-
var children = c.
|
|
1069
|
-
return _extends({}, c.
|
|
255
|
+
var children = c.children.length ? c.children.map(toDefinition) : null;
|
|
256
|
+
return _extends({}, c.control, {
|
|
1070
257
|
children: children
|
|
1071
258
|
});
|
|
1072
259
|
}
|
|
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;
|
|
1087
260
|
function addMissing(schemaNode) {
|
|
1088
|
-
if (fieldHasTag(schemaNode.field,
|
|
261
|
+
if (fieldHasTag(schemaNode.field, formsCore.SchemaTags.NoControl)) return;
|
|
1089
262
|
var skipChildren = false;
|
|
1090
|
-
var existingControls =
|
|
263
|
+
var existingControls = schemaControlMap[schemaNode.id];
|
|
1091
264
|
if (!existingControls) {
|
|
1092
265
|
var eligibleParents = getEligibleParents(schemaNode);
|
|
1093
|
-
var desiredGroup = getTagParam(schemaNode.field,
|
|
1094
|
-
var parentGroup = desiredGroup ?
|
|
266
|
+
var desiredGroup = formsCore.getTagParam(schemaNode.field, formsCore.SchemaTags.ControlGroup);
|
|
267
|
+
var parentGroup = desiredGroup ? controlMap[desiredGroup] : undefined;
|
|
1095
268
|
if (!parentGroup && desiredGroup) warning == null || warning("No group '" + desiredGroup + "' for " + schemaNode.id);
|
|
1096
|
-
if (parentGroup && eligibleParents.indexOf(
|
|
269
|
+
if (parentGroup && eligibleParents.indexOf(parentGroup.schema.id) < 0) {
|
|
1097
270
|
warning == null || warning("Target group '" + desiredGroup + "' is not an eligible parent for '" + schemaNode.id + "'");
|
|
1098
271
|
parentGroup = undefined;
|
|
1099
272
|
}
|
|
1100
273
|
if (!parentGroup && eligibleParents.length) {
|
|
1101
|
-
var
|
|
1102
|
-
parentGroup = (
|
|
274
|
+
var _schemaControlMap$eli;
|
|
275
|
+
parentGroup = (_schemaControlMap$eli = schemaControlMap[eligibleParents[0]]) == null ? void 0 : _schemaControlMap$eli[0];
|
|
1103
276
|
}
|
|
1104
277
|
if (parentGroup) {
|
|
1105
278
|
var _newControl = defaultControlForField(schemaNode.field, true);
|
|
1106
279
|
skipChildren = !!_newControl.childRefId;
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
var newNode = tree.addChild(parentGroup, _newControl);
|
|
1110
|
-
register(newNode, parentSchemaNode);
|
|
280
|
+
_newControl.field = formsCore.relativePath(parentGroup.schema, schemaNode);
|
|
281
|
+
parentGroup.children.push(toControlAndSchema(_newControl, parentGroup.schema, parentGroup));
|
|
1111
282
|
} else warning == null || warning("Could not find a parent group for: " + schemaNode.id);
|
|
1112
283
|
} else {
|
|
1113
284
|
skipChildren = existingControls.some(function (x) {
|
|
1114
|
-
return x.
|
|
285
|
+
return x.control.childRefId;
|
|
1115
286
|
});
|
|
1116
287
|
}
|
|
1117
|
-
if (!skipChildren) schemaNode.getChildNodes(
|
|
288
|
+
if (!skipChildren) schemaNode.getChildNodes().forEach(addMissing);
|
|
1118
289
|
}
|
|
1119
290
|
function getEligibleParents(schemaNode) {
|
|
1120
291
|
var eligibleParents = [];
|
|
@@ -1122,17 +293,54 @@ function addMissingControlsToForm(schema, tree, warning) {
|
|
|
1122
293
|
while (parent) {
|
|
1123
294
|
eligibleParents.push(parent.id);
|
|
1124
295
|
if (parent.field.collection) break;
|
|
1125
|
-
if (!parent.parent) parent.getChildNodes(
|
|
296
|
+
if (!parent.parent) parent.getChildNodes().forEach(addCompound);
|
|
1126
297
|
parent = parent.parent;
|
|
1127
298
|
}
|
|
1128
299
|
return eligibleParents;
|
|
1129
300
|
function addCompound(node) {
|
|
1130
|
-
if (isCompoundNode(node) && !node.field.collection) {
|
|
301
|
+
if (formsCore.isCompoundNode(node) && !node.field.collection) {
|
|
1131
302
|
eligibleParents.push(node.id);
|
|
1132
|
-
node.getChildNodes(
|
|
303
|
+
node.getChildNodes().forEach(addCompound);
|
|
1133
304
|
}
|
|
1134
305
|
}
|
|
1135
306
|
}
|
|
307
|
+
function addReferences(c) {
|
|
308
|
+
c.children.forEach(addReferences);
|
|
309
|
+
if (c.control.childRefId) {
|
|
310
|
+
var ref = controlMap[c.control.childRefId];
|
|
311
|
+
if (ref) {
|
|
312
|
+
ref.children.forEach(function (x) {
|
|
313
|
+
return toControlAndSchema(x.control, c.schema, c, true);
|
|
314
|
+
});
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
console.warn("Missing reference", c.control.childRefId);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
function addSchemaMapEntry(schemaId, entry) {
|
|
321
|
+
if (!schemaControlMap[schemaId]) schemaControlMap[schemaId] = [];
|
|
322
|
+
schemaControlMap[schemaId].push(entry);
|
|
323
|
+
}
|
|
324
|
+
function toControlAndSchema(c, parentSchema, parentNode, dontRegister) {
|
|
325
|
+
var _c$children$map, _c$children;
|
|
326
|
+
var controlPath = formsCore.fieldPathForDefinition(c);
|
|
327
|
+
var dataSchema = controlPath ? formsCore.schemaForFieldPath(controlPath, parentSchema) : undefined;
|
|
328
|
+
if (formsCore.isGroupControl(c) && dataSchema == null) dataSchema = parentSchema;
|
|
329
|
+
var entry = {
|
|
330
|
+
schema: dataSchema,
|
|
331
|
+
control: c,
|
|
332
|
+
children: [],
|
|
333
|
+
parent: parentNode
|
|
334
|
+
};
|
|
335
|
+
entry.children = (_c$children$map = (_c$children = c.children) == null ? void 0 : _c$children.map(function (x) {
|
|
336
|
+
return toControlAndSchema(x, dataSchema != null ? dataSchema : parentSchema, entry, dontRegister);
|
|
337
|
+
})) != null ? _c$children$map : [];
|
|
338
|
+
if (!dontRegister && c.id) controlMap[c.id] = entry;
|
|
339
|
+
if (dataSchema) {
|
|
340
|
+
addSchemaMapEntry(dataSchema.id, entry);
|
|
341
|
+
}
|
|
342
|
+
return entry;
|
|
343
|
+
}
|
|
1136
344
|
}
|
|
1137
345
|
/**
|
|
1138
346
|
* Custom hook to use an updated reference.
|
|
@@ -1144,46 +352,24 @@ function useUpdatedRef(a) {
|
|
|
1144
352
|
r.current = a;
|
|
1145
353
|
return r;
|
|
1146
354
|
}
|
|
1147
|
-
/**
|
|
1148
|
-
* Checks if a control definition is readonly.
|
|
1149
|
-
* @param c - The control definition to check.
|
|
1150
|
-
* @returns True if the control definition is readonly, false otherwise.
|
|
1151
|
-
*/
|
|
1152
|
-
function isControlReadonly(c) {
|
|
1153
|
-
return isDataControl(c) && !!c.readonly;
|
|
1154
|
-
}
|
|
1155
|
-
/**
|
|
1156
|
-
* Checks if a control definition is disabled.
|
|
1157
|
-
* @param c - The control definition to check.
|
|
1158
|
-
* @returns True if the control definition is disabled, false otherwise.
|
|
1159
|
-
*/
|
|
1160
|
-
function isControlDisabled(c) {
|
|
1161
|
-
return isDataControl(c) && !!c.disabled;
|
|
1162
|
-
}
|
|
1163
|
-
/**
|
|
1164
|
-
* Returns the display-only render options for a control definition.
|
|
1165
|
-
* @param d - The control definition to get the display-only render options for.
|
|
1166
|
-
* @returns The display-only render options, or undefined if not applicable.
|
|
1167
|
-
*/
|
|
1168
|
-
function getDisplayOnlyOptions(d) {
|
|
1169
|
-
return isDataControl(d) && d.renderOptions && isDisplayOnlyRenderer(d.renderOptions) ? d.renderOptions : undefined;
|
|
1170
|
-
}
|
|
1171
355
|
/**
|
|
1172
356
|
* Cleans data for a schema based on the provided schema fields.
|
|
1173
357
|
* @param v - The data to clean.
|
|
1174
|
-
* @param
|
|
358
|
+
* @param schemaNode
|
|
1175
359
|
* @param removeIfDefault - Flag indicating if default values should be removed.
|
|
1176
360
|
* @returns The cleaned data.
|
|
1177
361
|
*/
|
|
1178
|
-
function cleanDataForSchema(v,
|
|
362
|
+
function cleanDataForSchema(v, schemaNode, removeIfDefault) {
|
|
363
|
+
var _fields$find;
|
|
1179
364
|
if (!v) return v;
|
|
1180
|
-
var
|
|
365
|
+
var fields = schemaNode.getResolvedFields();
|
|
366
|
+
var typeField = (_fields$find = fields.find(function (x) {
|
|
1181
367
|
return x.isTypeField;
|
|
1182
|
-
});
|
|
1183
|
-
var typeValue = typeField ? v[typeField
|
|
368
|
+
})) == null ? void 0 : _fields$find.field;
|
|
369
|
+
var typeValue = typeField ? v[typeField] : undefined;
|
|
1184
370
|
var cleanableFields = !removeIfDefault ? fields.filter(function (x) {
|
|
1185
371
|
var _x$onlyForTypes$lengt, _x$onlyForTypes;
|
|
1186
|
-
return isCompoundField(x) || ((_x$onlyForTypes$lengt = (_x$onlyForTypes = x.onlyForTypes) == null ? void 0 : _x$onlyForTypes.length) != null ? _x$onlyForTypes$lengt : 0) > 0;
|
|
372
|
+
return formsCore.isCompoundField(x) || ((_x$onlyForTypes$lengt = (_x$onlyForTypes = x.onlyForTypes) == null ? void 0 : _x$onlyForTypes.length) != null ? _x$onlyForTypes$lengt : 0) > 0;
|
|
1187
373
|
}) : fields;
|
|
1188
374
|
if (!cleanableFields.length) return v;
|
|
1189
375
|
var out = _extends({}, v);
|
|
@@ -1194,16 +380,16 @@ function cleanDataForSchema(v, fields, removeIfDefault) {
|
|
|
1194
380
|
delete out[x.field];
|
|
1195
381
|
return;
|
|
1196
382
|
}
|
|
1197
|
-
if (isCompoundField(x)) {
|
|
1198
|
-
var
|
|
383
|
+
if (formsCore.isCompoundField(x)) {
|
|
384
|
+
var childNode = schemaNode.createChildNode(x);
|
|
1199
385
|
if (x.collection) {
|
|
1200
386
|
if (Array.isArray(childValue)) {
|
|
1201
387
|
out[x.field] = childValue.map(function (cv) {
|
|
1202
|
-
return cleanDataForSchema(cv,
|
|
388
|
+
return cleanDataForSchema(cv, childNode, removeIfDefault);
|
|
1203
389
|
});
|
|
1204
390
|
}
|
|
1205
391
|
} else {
|
|
1206
|
-
out[x.field] = cleanDataForSchema(childValue,
|
|
392
|
+
out[x.field] = cleanDataForSchema(childValue, childNode, removeIfDefault);
|
|
1207
393
|
}
|
|
1208
394
|
}
|
|
1209
395
|
function canBeNull() {
|
|
@@ -1221,45 +407,28 @@ function cleanDataForSchema(v, fields, removeIfDefault) {
|
|
|
1221
407
|
* @returns An array of referenced classes.
|
|
1222
408
|
*/
|
|
1223
409
|
function getAllReferencedClasses(c, collectExtra) {
|
|
1224
|
-
var _c$
|
|
1225
|
-
var childClasses = (_c$
|
|
410
|
+
var _c$children2, _collectExtra;
|
|
411
|
+
var childClasses = (_c$children2 = c.children) == null ? void 0 : _c$children2.flatMap(function (x) {
|
|
1226
412
|
return getAllReferencedClasses(x, collectExtra);
|
|
1227
413
|
});
|
|
1228
414
|
var go = getGroupClassOverrides(c);
|
|
1229
|
-
var _ref = isDataControl(c) && isCheckEntryClasses(c.renderOptions) ? c.renderOptions : {},
|
|
415
|
+
var _ref = formsCore.isDataControl(c) && formsCore.isCheckEntryClasses(c.renderOptions) ? c.renderOptions : {},
|
|
1230
416
|
entryWrapperClass = _ref.entryWrapperClass,
|
|
1231
417
|
selectedClass = _ref.selectedClass,
|
|
1232
418
|
notSelectedClass = _ref.notSelectedClass;
|
|
1233
|
-
var
|
|
419
|
+
var groupOptions = formsCore.isGroupControl(c) ? c.groupOptions : undefined;
|
|
420
|
+
var gridClasses = groupOptions && formsCore.isGridRenderer(groupOptions) ? [groupOptions.rowClass] : [];
|
|
421
|
+
var _ref2 = formsCore.isDataControl(c) && formsCore.isAutoCompleteClasses(c.renderOptions) ? c.renderOptions : {},
|
|
1234
422
|
listContainerClass = _ref2.listContainerClass,
|
|
1235
423
|
listEntryClass = _ref2.listEntryClass,
|
|
1236
424
|
chipContainerClass = _ref2.chipContainerClass,
|
|
1237
425
|
chipCloseButtonClass = _ref2.chipCloseButtonClass;
|
|
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));
|
|
426
|
+
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));
|
|
1239
427
|
if (childClasses && !tc) return childClasses;
|
|
1240
428
|
if (!tc) return [];
|
|
1241
429
|
if (childClasses) return [tc].concat(childClasses);
|
|
1242
430
|
return [tc];
|
|
1243
431
|
}
|
|
1244
|
-
/**
|
|
1245
|
-
* Converts a JSON path array to a string.
|
|
1246
|
-
* @param jsonPath - The JSON path array to convert.
|
|
1247
|
-
* @param customIndex - Optional function to customize the index format.
|
|
1248
|
-
* @returns The JSON path string.
|
|
1249
|
-
*/
|
|
1250
|
-
function jsonPathString(jsonPath, customIndex) {
|
|
1251
|
-
var out = "";
|
|
1252
|
-
jsonPath.forEach(function (v, i) {
|
|
1253
|
-
if (typeof v === "number") {
|
|
1254
|
-
var _customIndex;
|
|
1255
|
-
out += (_customIndex = customIndex == null ? void 0 : customIndex(v)) != null ? _customIndex : "[" + v + "]";
|
|
1256
|
-
} else {
|
|
1257
|
-
if (i > 0) out += ".";
|
|
1258
|
-
out += v;
|
|
1259
|
-
}
|
|
1260
|
-
});
|
|
1261
|
-
return out;
|
|
1262
|
-
}
|
|
1263
432
|
/**
|
|
1264
433
|
* Finds a child control definition within a parent control definition.
|
|
1265
434
|
* @param parent - The parent control definition.
|
|
@@ -1332,10 +501,10 @@ function findFieldPath(fields, fieldPath) {
|
|
|
1332
501
|
var currentFields = fields;
|
|
1333
502
|
while (i < fieldNames.length && currentFields) {
|
|
1334
503
|
var cf = fieldNames[i];
|
|
1335
|
-
var nextField = findField(currentFields, cf);
|
|
504
|
+
var nextField = formsCore.findField(currentFields, cf);
|
|
1336
505
|
if (!nextField) return undefined;
|
|
1337
506
|
foundFields.push(nextField);
|
|
1338
|
-
currentFields = isCompoundField(nextField) && !nextField.collection ? nextField.children : undefined;
|
|
507
|
+
currentFields = formsCore.isCompoundField(nextField) && !nextField.collection ? nextField.children : undefined;
|
|
1339
508
|
i++;
|
|
1340
509
|
}
|
|
1341
510
|
return foundFields.length === fieldNames.length ? foundFields : undefined;
|
|
@@ -1385,21 +554,13 @@ function deepMerge(value, fallback) {
|
|
|
1385
554
|
function coerceToString(v) {
|
|
1386
555
|
return v == null ? "" : typeof v === "object" ? "error: " + JSON.stringify(v) : v.toString();
|
|
1387
556
|
}
|
|
1388
|
-
/**
|
|
1389
|
-
* Returns the group renderer options for a control definition.
|
|
1390
|
-
* @param {ControlDefinition} def - The control definition to get the group renderer options for.
|
|
1391
|
-
* @returns {GroupRenderOptions | undefined} - The group renderer options, or undefined if not applicable.
|
|
1392
|
-
*/
|
|
1393
|
-
function getGroupRendererOptions(def) {
|
|
1394
|
-
return isGroupControl(def) ? def.groupOptions : isDataControl(def) && isDataGroupRenderer(def.renderOptions) ? def.renderOptions.groupOptions : undefined;
|
|
1395
|
-
}
|
|
1396
557
|
/**
|
|
1397
558
|
* Returns the group class overrides for a control definition.
|
|
1398
559
|
* @param {ControlDefinition} def - The control definition to get the group class overrides for.
|
|
1399
560
|
* @returns {ControlClasses} - The group class overrides.
|
|
1400
561
|
*/
|
|
1401
562
|
function getGroupClassOverrides(def) {
|
|
1402
|
-
var go = getGroupRendererOptions(def);
|
|
563
|
+
var go = formsCore.getGroupRendererOptions(def);
|
|
1403
564
|
if (!go) return {};
|
|
1404
565
|
var childLayoutClass = go.childLayoutClass,
|
|
1405
566
|
childStyleClass = go.childStyleClass,
|
|
@@ -1410,26 +571,19 @@ function getGroupClassOverrides(def) {
|
|
|
1410
571
|
if (childLabelClass) out.labelClass = childLabelClass;
|
|
1411
572
|
return out;
|
|
1412
573
|
}
|
|
1413
|
-
/**
|
|
1414
|
-
* Checks if a control definition is display-only.
|
|
1415
|
-
* @param {ControlDefinition} def - The control definition to check.
|
|
1416
|
-
* @returns {boolean} - True if the control definition is display-only, false otherwise.
|
|
1417
|
-
*/
|
|
1418
|
-
function isControlDisplayOnly(def) {
|
|
1419
|
-
var _getGroupRendererOpti;
|
|
1420
|
-
return Boolean((_getGroupRendererOpti = getGroupRendererOptions(def)) == null ? void 0 : _getGroupRendererOpti.displayOnly);
|
|
1421
|
-
}
|
|
1422
574
|
/**
|
|
1423
575
|
* Combines multiple action handlers into a single handler.
|
|
1424
576
|
* @param {...(ControlActionHandler | undefined)[]} handlers - The action handlers to combine.
|
|
1425
577
|
* @returns {ControlActionHandler} - The combined action handler.
|
|
1426
578
|
*/
|
|
1427
579
|
function actionHandlers() {
|
|
1428
|
-
var
|
|
580
|
+
var nonNullHandlers = [].slice.call(arguments).filter(function (x) {
|
|
581
|
+
return x != null;
|
|
582
|
+
});
|
|
583
|
+
if (nonNullHandlers.length === 0) return undefined;
|
|
1429
584
|
return function (actionId, actionData, ctx) {
|
|
1430
|
-
for (var i = 0; i <
|
|
1431
|
-
var
|
|
1432
|
-
var res = (_handlers$i = (_handlers = handlers)[i]) == null ? void 0 : _handlers$i.call(_handlers, actionId, actionData, ctx);
|
|
585
|
+
for (var i = 0; i < nonNullHandlers.length; i++) {
|
|
586
|
+
var res = nonNullHandlers[i](actionId, actionData, ctx);
|
|
1433
587
|
if (res) return res;
|
|
1434
588
|
}
|
|
1435
589
|
return undefined;
|
|
@@ -1441,7 +595,7 @@ function getDiffObject(dataNode, force) {
|
|
|
1441
595
|
if (!c.dirty && !force) return undefined;
|
|
1442
596
|
if (c.isNull) return null;
|
|
1443
597
|
if (sf.collection && dataNode.elementIndex == null) {
|
|
1444
|
-
var idField = getTagParam(sf,
|
|
598
|
+
var idField = formsCore.getTagParam(sf, formsCore.SchemaTags.IdField);
|
|
1445
599
|
return c.as().elements.map(function (x, i) {
|
|
1446
600
|
var _getElementIndex;
|
|
1447
601
|
var change = getDiffObject(dataNode.getChildElement(i), idField !== undefined);
|
|
@@ -1450,9 +604,9 @@ function getDiffObject(dataNode, force) {
|
|
|
1450
604
|
edit: change
|
|
1451
605
|
};
|
|
1452
606
|
});
|
|
1453
|
-
} else if (isCompoundField(sf)) {
|
|
607
|
+
} else if (formsCore.isCompoundField(sf)) {
|
|
1454
608
|
var children = dataNode.schema.getChildNodes();
|
|
1455
|
-
var _idField = getTagParam(sf,
|
|
609
|
+
var _idField = formsCore.getTagParam(sf, formsCore.SchemaTags.IdField);
|
|
1456
610
|
return Object.fromEntries(children.flatMap(function (c) {
|
|
1457
611
|
var diff = getDiffObject(dataNode.getChild(c), _idField === c.field.field);
|
|
1458
612
|
return diff !== undefined ? [[c.field.field, diff]] : [];
|
|
@@ -1475,6 +629,9 @@ function getNullToggler(c) {
|
|
|
1475
629
|
c.value = currentNotNull ? lastDefined.current.value : null;
|
|
1476
630
|
c.disabled = !currentNotNull;
|
|
1477
631
|
}, core.ControlChange.Value);
|
|
632
|
+
c.subscribe(function () {
|
|
633
|
+
notNull.value = c.current.value != null;
|
|
634
|
+
}, core.ControlChange.Value);
|
|
1478
635
|
return notNull;
|
|
1479
636
|
function disableIfNotEditing() {
|
|
1480
637
|
notNull.disabled = isEditing.current.value === false;
|
|
@@ -1514,13 +671,29 @@ function getAllValues(control) {
|
|
|
1514
671
|
return core.newControl([control.value]);
|
|
1515
672
|
});
|
|
1516
673
|
}
|
|
674
|
+
function clearMultiValues(dataNode) {
|
|
675
|
+
var c = dataNode.control;
|
|
676
|
+
var sf = dataNode.schema.field;
|
|
677
|
+
if (sf.collection) {
|
|
678
|
+
return;
|
|
679
|
+
} else if (formsCore.isCompoundField(sf)) {
|
|
680
|
+
dataNode.schema.getChildNodes().forEach(function (c) {
|
|
681
|
+
clearMultiValues(dataNode.getChild(c));
|
|
682
|
+
});
|
|
683
|
+
} else {
|
|
684
|
+
var allValues = getAllValues(c);
|
|
685
|
+
allValues.setValue(function (x) {
|
|
686
|
+
return [c.current.value];
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
}
|
|
1517
690
|
function applyValues(dataNode, value) {
|
|
1518
691
|
var c = dataNode.control;
|
|
1519
692
|
var sf = dataNode.schema.field;
|
|
1520
693
|
if (c.isEqual(c.initialValue, value)) return;
|
|
1521
694
|
if (sf.collection) {
|
|
1522
695
|
return;
|
|
1523
|
-
} else if (isCompoundField(sf)) {
|
|
696
|
+
} else if (formsCore.isCompoundField(sf)) {
|
|
1524
697
|
if (value == null) return;
|
|
1525
698
|
dataNode.schema.getChildNodes().forEach(function (c) {
|
|
1526
699
|
applyValues(dataNode.getChild(c), value[c.field.field]);
|
|
@@ -1536,7 +709,10 @@ function applyValues(dataNode, value) {
|
|
|
1536
709
|
}
|
|
1537
710
|
function collectDifferences(dataNode, values) {
|
|
1538
711
|
values.forEach(function (v, i) {
|
|
1539
|
-
if (i == 0)
|
|
712
|
+
if (i == 0) {
|
|
713
|
+
dataNode.control.setInitialValue(v);
|
|
714
|
+
clearMultiValues(dataNode);
|
|
715
|
+
} else applyValues(dataNode, v);
|
|
1540
716
|
});
|
|
1541
717
|
var allEdits = [];
|
|
1542
718
|
resetMultiValues(dataNode);
|
|
@@ -1559,7 +735,7 @@ function collectDifferences(dataNode, values) {
|
|
|
1559
735
|
var sf = dataNode.schema.field;
|
|
1560
736
|
if (sf.collection) {
|
|
1561
737
|
return;
|
|
1562
|
-
} else if (isCompoundField(sf)) {
|
|
738
|
+
} else if (formsCore.isCompoundField(sf)) {
|
|
1563
739
|
if (c.value == null) return;
|
|
1564
740
|
dataNode.schema.getChildNodes().forEach(function (c) {
|
|
1565
741
|
resetMultiValues(dataNode.getChild(c));
|
|
@@ -1576,7 +752,7 @@ function collectDifferences(dataNode, values) {
|
|
|
1576
752
|
}
|
|
1577
753
|
function validationVisitor(onInvalid) {
|
|
1578
754
|
return function (s) {
|
|
1579
|
-
if (isCompoundNode(s.schema)) return undefined;
|
|
755
|
+
if (formsCore.isCompoundNode(s.schema)) return undefined;
|
|
1580
756
|
var v = s.control;
|
|
1581
757
|
v.touched = true;
|
|
1582
758
|
if (!v.validate()) {
|
|
@@ -1585,32 +761,19 @@ function validationVisitor(onInvalid) {
|
|
|
1585
761
|
return undefined;
|
|
1586
762
|
};
|
|
1587
763
|
}
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
(function (
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
}
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
DateComparison["NotBefore"] = "NotBefore";
|
|
1598
|
-
DateComparison["NotAfter"] = "NotAfter";
|
|
1599
|
-
})(exports.DateComparison || (exports.DateComparison = {}));
|
|
1600
|
-
|
|
1601
|
-
exports.ExpressionType = void 0;
|
|
1602
|
-
(function (ExpressionType) {
|
|
1603
|
-
ExpressionType["Jsonata"] = "Jsonata";
|
|
1604
|
-
ExpressionType["Data"] = "Data";
|
|
1605
|
-
ExpressionType["DataMatch"] = "FieldValue";
|
|
1606
|
-
ExpressionType["UserMatch"] = "UserMatch";
|
|
1607
|
-
ExpressionType["NotEmpty"] = "NotEmpty";
|
|
1608
|
-
ExpressionType["UUID"] = "UUID";
|
|
1609
|
-
})(exports.ExpressionType || (exports.ExpressionType = {}));
|
|
764
|
+
function useExpression(defaultValue, runExpression, expression, coerce, bindings) {
|
|
765
|
+
var value = core.useControl(defaultValue);
|
|
766
|
+
core.createScopedEffect(function (scope) {
|
|
767
|
+
if (expression != null && expression.type) runExpression(scope, expression, function (x) {
|
|
768
|
+
return value.value = coerce(x);
|
|
769
|
+
}, bindings);else value.value = defaultValue;
|
|
770
|
+
}, value);
|
|
771
|
+
return value;
|
|
772
|
+
}
|
|
1610
773
|
|
|
1611
774
|
function dataControl(field, title, options) {
|
|
1612
775
|
return _extends({
|
|
1613
|
-
type:
|
|
776
|
+
type: formsCore.ControlDefinitionType.Data,
|
|
1614
777
|
field: field,
|
|
1615
778
|
title: title
|
|
1616
779
|
}, options);
|
|
@@ -1638,80 +801,80 @@ function renderOptionsFor(type) {
|
|
|
1638
801
|
};
|
|
1639
802
|
};
|
|
1640
803
|
}
|
|
1641
|
-
var autocompleteOptions = renderOptionsFor(
|
|
1642
|
-
var checkListOptions = renderOptionsFor(
|
|
1643
|
-
var radioButtonOptions = renderOptionsFor(
|
|
1644
|
-
var lengthValidatorOptions = validatorOptions(
|
|
1645
|
-
var jsonataValidatorOptions = validatorOptions(
|
|
1646
|
-
var dateValidatorOptions = validatorOptions(
|
|
1647
|
-
var accordionOptions = adornmentOptions(
|
|
1648
|
-
var textfieldOptions = renderOptionsFor(
|
|
1649
|
-
var displayOnlyOptions = renderOptionsFor(
|
|
1650
|
-
var jsonataOptions = renderOptionsFor(
|
|
804
|
+
var autocompleteOptions = renderOptionsFor(formsCore.DataRenderType.Autocomplete);
|
|
805
|
+
var checkListOptions = renderOptionsFor(formsCore.DataRenderType.CheckList);
|
|
806
|
+
var radioButtonOptions = renderOptionsFor(formsCore.DataRenderType.Radio);
|
|
807
|
+
var lengthValidatorOptions = validatorOptions(formsCore.ValidatorType.Length);
|
|
808
|
+
var jsonataValidatorOptions = validatorOptions(formsCore.ValidatorType.Jsonata);
|
|
809
|
+
var dateValidatorOptions = validatorOptions(formsCore.ValidatorType.Date);
|
|
810
|
+
var accordionOptions = adornmentOptions(formsCore.ControlAdornmentType.Accordion);
|
|
811
|
+
var textfieldOptions = renderOptionsFor(formsCore.DataRenderType.Textfield);
|
|
812
|
+
var displayOnlyOptions = renderOptionsFor(formsCore.DataRenderType.DisplayOnly);
|
|
813
|
+
var jsonataOptions = renderOptionsFor(formsCore.DataRenderType.Jsonata);
|
|
1651
814
|
function textDisplayControl(text, options) {
|
|
1652
815
|
return _extends({
|
|
1653
|
-
type:
|
|
816
|
+
type: formsCore.ControlDefinitionType.Display,
|
|
1654
817
|
displayData: {
|
|
1655
|
-
type:
|
|
818
|
+
type: formsCore.DisplayDataType.Text,
|
|
1656
819
|
text: text
|
|
1657
820
|
}
|
|
1658
821
|
}, options);
|
|
1659
822
|
}
|
|
1660
823
|
function htmlDisplayControl(html, options) {
|
|
1661
824
|
return _extends({
|
|
1662
|
-
type:
|
|
825
|
+
type: formsCore.ControlDefinitionType.Display,
|
|
1663
826
|
displayData: {
|
|
1664
|
-
type:
|
|
827
|
+
type: formsCore.DisplayDataType.Html,
|
|
1665
828
|
html: html
|
|
1666
829
|
}
|
|
1667
830
|
}, options);
|
|
1668
831
|
}
|
|
1669
832
|
function dynamicDefaultValue(expr) {
|
|
1670
833
|
return {
|
|
1671
|
-
type:
|
|
834
|
+
type: formsCore.DynamicPropertyType.DefaultValue,
|
|
1672
835
|
expr: expr
|
|
1673
836
|
};
|
|
1674
837
|
}
|
|
1675
838
|
function dynamicReadonly(expr) {
|
|
1676
839
|
return {
|
|
1677
|
-
type:
|
|
840
|
+
type: formsCore.DynamicPropertyType.Readonly,
|
|
1678
841
|
expr: expr
|
|
1679
842
|
};
|
|
1680
843
|
}
|
|
1681
844
|
function dynamicVisibility(expr) {
|
|
1682
845
|
return {
|
|
1683
|
-
type:
|
|
846
|
+
type: formsCore.DynamicPropertyType.Visible,
|
|
1684
847
|
expr: expr
|
|
1685
848
|
};
|
|
1686
849
|
}
|
|
1687
850
|
function dynamicDisabled(expr) {
|
|
1688
851
|
return {
|
|
1689
|
-
type:
|
|
852
|
+
type: formsCore.DynamicPropertyType.Disabled,
|
|
1690
853
|
expr: expr
|
|
1691
854
|
};
|
|
1692
855
|
}
|
|
1693
856
|
function fieldExpr(field) {
|
|
1694
857
|
return {
|
|
1695
|
-
type:
|
|
858
|
+
type: formsCore.ExpressionType.Data,
|
|
1696
859
|
field: field
|
|
1697
860
|
};
|
|
1698
861
|
}
|
|
1699
862
|
function fieldEqExpr(field, value) {
|
|
1700
863
|
return {
|
|
1701
|
-
type:
|
|
864
|
+
type: formsCore.ExpressionType.DataMatch,
|
|
1702
865
|
field: field,
|
|
1703
866
|
value: value
|
|
1704
867
|
};
|
|
1705
868
|
}
|
|
1706
869
|
function jsonataExpr(expression) {
|
|
1707
870
|
return {
|
|
1708
|
-
type:
|
|
871
|
+
type: formsCore.ExpressionType.Jsonata,
|
|
1709
872
|
expression: expression
|
|
1710
873
|
};
|
|
1711
874
|
}
|
|
1712
875
|
function groupedControl(children, title, options) {
|
|
1713
876
|
return _extends({
|
|
1714
|
-
type:
|
|
877
|
+
type: formsCore.ControlDefinitionType.Group,
|
|
1715
878
|
children: children,
|
|
1716
879
|
title: title,
|
|
1717
880
|
groupOptions: {
|
|
@@ -1722,7 +885,7 @@ function groupedControl(children, title, options) {
|
|
|
1722
885
|
}
|
|
1723
886
|
function compoundControl(field, title, children, options) {
|
|
1724
887
|
return _extends({
|
|
1725
|
-
type:
|
|
888
|
+
type: formsCore.ControlDefinitionType.Data,
|
|
1726
889
|
field: field,
|
|
1727
890
|
children: children,
|
|
1728
891
|
title: title,
|
|
@@ -1733,7 +896,7 @@ function compoundControl(field, title, children, options) {
|
|
|
1733
896
|
}
|
|
1734
897
|
function actionControl(actionText, actionId, options) {
|
|
1735
898
|
return _extends({
|
|
1736
|
-
type:
|
|
899
|
+
type: formsCore.ControlDefinitionType.Action,
|
|
1737
900
|
title: actionText,
|
|
1738
901
|
actionId: actionId
|
|
1739
902
|
}, options);
|
|
@@ -1746,10 +909,10 @@ function createAction(actionId, onClick, actionText, options) {
|
|
|
1746
909
|
}, options);
|
|
1747
910
|
}
|
|
1748
911
|
var emptyGroupDefinition = {
|
|
1749
|
-
type:
|
|
912
|
+
type: formsCore.ControlDefinitionType.Group,
|
|
1750
913
|
children: [],
|
|
1751
914
|
groupOptions: {
|
|
1752
|
-
type:
|
|
915
|
+
type: formsCore.GroupRenderType.Standard,
|
|
1753
916
|
hideTitle: true
|
|
1754
917
|
}
|
|
1755
918
|
};
|
|
@@ -1771,657 +934,16 @@ function applyExtensionToSchema(schemaMap, extension) {
|
|
|
1771
934
|
cro = _ref[1];
|
|
1772
935
|
outMap[field] = (Array.isArray(cro) ? cro : [cro]).reduce(function (a, cr) {
|
|
1773
936
|
var _cr$fields;
|
|
1774
|
-
return mergeFields(a, cr.name, cr.value, (_cr$fields = cr.fields) != null ? _cr$fields : []);
|
|
937
|
+
return formsCore.mergeFields(a, cr.name, cr.value, (_cr$fields = cr.fields) != null ? _cr$fields : []);
|
|
1775
938
|
}, outMap[field]);
|
|
1776
939
|
});
|
|
1777
940
|
return outMap;
|
|
1778
941
|
}
|
|
1779
942
|
function applyExtensionsToSchema(schemaMap, extensions) {
|
|
1780
|
-
return resolveSchemas(extensions.reduce(applyExtensionToSchema, schemaMap));
|
|
943
|
+
return formsCore.resolveSchemas(extensions.reduce(applyExtensionToSchema, schemaMap));
|
|
1781
944
|
}
|
|
1782
945
|
|
|
1783
|
-
|
|
1784
|
-
* Creates a dynamic hook generator.
|
|
1785
|
-
* @template A - The type of the hook result.
|
|
1786
|
-
* @template P - The type of the hook context.
|
|
1787
|
-
* @template S - The type of the hook state.
|
|
1788
|
-
* @param runHook - The function to run the hook.
|
|
1789
|
-
* @param state - The initial state of the hook.
|
|
1790
|
-
* @param deps - The dependencies of the hook.
|
|
1791
|
-
* @returns The dynamic hook generator.
|
|
1792
|
-
*/
|
|
1793
|
-
function makeHook(runHook, state, deps) {
|
|
1794
|
-
return {
|
|
1795
|
-
deps: deps,
|
|
1796
|
-
state: state,
|
|
1797
|
-
runHook: runHook
|
|
1798
|
-
};
|
|
1799
|
-
}
|
|
1800
|
-
/**
|
|
1801
|
-
* Converts an array of dependencies to a dependency string.
|
|
1802
|
-
* @template A - The type of the dependencies.
|
|
1803
|
-
* @param deps - The array of dependencies.
|
|
1804
|
-
* @param asHookDep - The function to convert a dependency to a hook dependency.
|
|
1805
|
-
* @returns The dependency string.
|
|
1806
|
-
*/
|
|
1807
|
-
function makeHookDepString(deps, asHookDep) {
|
|
1808
|
-
return deps.map(function (x) {
|
|
1809
|
-
return toDepString(asHookDep(x));
|
|
1810
|
-
}).join(",");
|
|
1811
|
-
}
|
|
1812
|
-
/**
|
|
1813
|
-
* Custom hook to use dynamic hooks.
|
|
1814
|
-
* @template P - The type of the hook context.
|
|
1815
|
-
* @template Hooks - The type of the hooks.
|
|
1816
|
-
* @param hooks - The hooks to use.
|
|
1817
|
-
* @returns A function that takes the hook context and returns the hook values.
|
|
1818
|
-
*/
|
|
1819
|
-
function useDynamicHooks(hooks) {
|
|
1820
|
-
var hookEntries = Object.entries(hooks);
|
|
1821
|
-
var deps = makeHookDepString(hookEntries, function (x) {
|
|
1822
|
-
return x[1].deps;
|
|
1823
|
-
});
|
|
1824
|
-
var ref = react.useRef({});
|
|
1825
|
-
var s = ref.current;
|
|
1826
|
-
hookEntries.forEach(function (x) {
|
|
1827
|
-
return s[x[0]] = x[1].state;
|
|
1828
|
-
});
|
|
1829
|
-
return react.useCallback(function (p) {
|
|
1830
|
-
return Object.fromEntries(hookEntries.map(function (_ref) {
|
|
1831
|
-
var f = _ref[0],
|
|
1832
|
-
hg = _ref[1];
|
|
1833
|
-
return [f, hg.runHook(p, ref.current[f])];
|
|
1834
|
-
}));
|
|
1835
|
-
}, [deps]);
|
|
1836
|
-
}
|
|
1837
|
-
/**
|
|
1838
|
-
* Converts a value to a dependency string.
|
|
1839
|
-
* @param x - The value to convert.
|
|
1840
|
-
* @returns The dependency string.
|
|
1841
|
-
*/
|
|
1842
|
-
function toDepString(x) {
|
|
1843
|
-
if (x === undefined) return "_";
|
|
1844
|
-
if (x === null) return "~";
|
|
1845
|
-
return x.toString();
|
|
1846
|
-
}
|
|
1847
|
-
|
|
1848
|
-
function _finallyRethrows(body, finalizer) {
|
|
1849
|
-
try {
|
|
1850
|
-
var result = body();
|
|
1851
|
-
} catch (e) {
|
|
1852
|
-
return finalizer(true, e);
|
|
1853
|
-
}
|
|
1854
|
-
if (result && result.then) {
|
|
1855
|
-
return result.then(finalizer.bind(null, false), finalizer.bind(null, true));
|
|
1856
|
-
}
|
|
1857
|
-
return finalizer(false, result);
|
|
1858
|
-
}
|
|
1859
|
-
function optionalHook(expr, useHook, coerce) {
|
|
1860
|
-
return expr && expr.type ? useHook(expr, coerce) : undefined;
|
|
1861
|
-
}
|
|
1862
|
-
function useEvalVisibilityHook(useEvalExpressionHook, definition, overrideDataNode) {
|
|
1863
|
-
var dynamicVisibility = useEvalDynamicBoolHook(definition, exports.DynamicPropertyType.Visible, useEvalExpressionHook);
|
|
1864
|
-
return makeDynamicPropertyHook(dynamicVisibility, function (ctx, _ref) {
|
|
1865
|
-
var definition = _ref.definition,
|
|
1866
|
-
overrideDataNode = _ref.overrideDataNode;
|
|
1867
|
-
return core.useComputed(function () {
|
|
1868
|
-
var dataNode = overrideDataNode != null ? overrideDataNode : ctx.dataNode;
|
|
1869
|
-
return !dataNode || matchesType(dataNode) && !hideDisplayOnly(dataNode, ctx.schemaInterface, definition);
|
|
1870
|
-
});
|
|
1871
|
-
}, {
|
|
1872
|
-
definition: definition,
|
|
1873
|
-
overrideDataNode: overrideDataNode
|
|
1874
|
-
});
|
|
1875
|
-
}
|
|
1876
|
-
function useEvalReadonlyHook(useEvalExpressionHook, definition) {
|
|
1877
|
-
var dynamicReadonly = useEvalDynamicBoolHook(definition, exports.DynamicPropertyType.Readonly, useEvalExpressionHook);
|
|
1878
|
-
return makeDynamicPropertyHook(dynamicReadonly, function (ctx, _ref2) {
|
|
1879
|
-
var definition = _ref2.definition;
|
|
1880
|
-
return core.useCalculatedControl(function () {
|
|
1881
|
-
return isControlReadonly(definition);
|
|
1882
|
-
});
|
|
1883
|
-
}, {
|
|
1884
|
-
definition: definition
|
|
1885
|
-
});
|
|
1886
|
-
}
|
|
1887
|
-
function useEvalStyleHook(useEvalExpressionHook, property, definition) {
|
|
1888
|
-
var dynamicStyle = useEvalDynamicHook(definition, property, useEvalExpressionHook);
|
|
1889
|
-
return makeDynamicPropertyHook(dynamicStyle, function () {
|
|
1890
|
-
return core.useControl(undefined);
|
|
1891
|
-
}, undefined);
|
|
1892
|
-
}
|
|
1893
|
-
function useEvalAllowedOptionsHook(useEvalExpressionHook, definition) {
|
|
1894
|
-
var dynamicAllowed = useEvalDynamicHook(definition, exports.DynamicPropertyType.AllowedOptions, useEvalExpressionHook);
|
|
1895
|
-
return makeDynamicPropertyHook(dynamicAllowed, function () {
|
|
1896
|
-
return core.useControl([]);
|
|
1897
|
-
}, undefined);
|
|
1898
|
-
}
|
|
1899
|
-
function useEvalDisabledHook(useEvalExpressionHook, definition) {
|
|
1900
|
-
var dynamicDisabled = useEvalDynamicBoolHook(definition, exports.DynamicPropertyType.Disabled, useEvalExpressionHook);
|
|
1901
|
-
return makeDynamicPropertyHook(dynamicDisabled, function (ctx) {
|
|
1902
|
-
return core.useComputed(function () {
|
|
1903
|
-
var _ctx$dataNode, _dataControl$meta$nul;
|
|
1904
|
-
var dataControl = (_ctx$dataNode = ctx.dataNode) == null ? void 0 : _ctx$dataNode.control;
|
|
1905
|
-
var setToNull = (dataControl == null || (_dataControl$meta$nul = dataControl.meta["nullControl"]) == null ? void 0 : _dataControl$meta$nul.value) === false;
|
|
1906
|
-
return setToNull || isControlDisabled(definition);
|
|
1907
|
-
});
|
|
1908
|
-
}, undefined);
|
|
1909
|
-
}
|
|
1910
|
-
function useEvalDisplayHook(useEvalExpressionHook, definition) {
|
|
1911
|
-
return useEvalDynamicHook(definition, exports.DynamicPropertyType.Display, useEvalExpressionHook);
|
|
1912
|
-
}
|
|
1913
|
-
function useEvalDefaultValueHook(useEvalExpressionHook, definition) {
|
|
1914
|
-
var dynamicValue = useEvalDynamicHook(definition, exports.DynamicPropertyType.DefaultValue, useEvalExpressionHook);
|
|
1915
|
-
return makeDynamicPropertyHook(dynamicValue, function (ctx, _ref3) {
|
|
1916
|
-
var definition = _ref3.definition;
|
|
1917
|
-
return core.useComputed(calcDefault);
|
|
1918
|
-
function calcDefault() {
|
|
1919
|
-
var _ctx$dataNode2;
|
|
1920
|
-
var _ref4 = isDataControl(definition) ? [definition.required, definition.defaultValue] : [false, undefined],
|
|
1921
|
-
required = _ref4[0],
|
|
1922
|
-
dcv = _ref4[1];
|
|
1923
|
-
var field = (_ctx$dataNode2 = ctx.dataNode) == null ? void 0 : _ctx$dataNode2.schema.field;
|
|
1924
|
-
return dcv != null ? dcv : field ? ctx.dataNode.elementIndex != null ? elementValueForField(field) : defaultValueForField(field, required) : undefined;
|
|
1925
|
-
}
|
|
1926
|
-
}, {
|
|
1927
|
-
definition: definition
|
|
1928
|
-
});
|
|
1929
|
-
}
|
|
1930
|
-
function useDataExpression(fvExpr, node, coerce) {
|
|
1931
|
-
if (coerce === void 0) {
|
|
1932
|
-
coerce = function coerce(x) {
|
|
1933
|
-
return x;
|
|
1934
|
-
};
|
|
1935
|
-
}
|
|
1936
|
-
var otherField = schemaDataForFieldRef(fvExpr.field, node);
|
|
1937
|
-
return core.useCalculatedControl(function () {
|
|
1938
|
-
var _otherField$control;
|
|
1939
|
-
return coerce((_otherField$control = otherField.control) == null ? void 0 : _otherField$control.value);
|
|
1940
|
-
});
|
|
1941
|
-
}
|
|
1942
|
-
function useDataMatchExpression(fvExpr, node, coerce) {
|
|
1943
|
-
if (coerce === void 0) {
|
|
1944
|
-
coerce = function coerce(x) {
|
|
1945
|
-
return x;
|
|
1946
|
-
};
|
|
1947
|
-
}
|
|
1948
|
-
var otherField = schemaDataForFieldRef(fvExpr.field, node);
|
|
1949
|
-
return core.useCalculatedControl(function () {
|
|
1950
|
-
var _otherField$control2;
|
|
1951
|
-
var fv = (_otherField$control2 = otherField.control) == null ? void 0 : _otherField$control2.value;
|
|
1952
|
-
return coerce(Array.isArray(fv) ? fv.includes(fvExpr.value) : fv === fvExpr.value);
|
|
1953
|
-
});
|
|
1954
|
-
}
|
|
1955
|
-
function useNotEmptyExpression(fvExpr, node, schemaInterface, coerce) {
|
|
1956
|
-
if (coerce === void 0) {
|
|
1957
|
-
coerce = function coerce(x) {
|
|
1958
|
-
return x;
|
|
1959
|
-
};
|
|
1960
|
-
}
|
|
1961
|
-
var otherField = schemaDataForFieldRef(fvExpr.field, node);
|
|
1962
|
-
return core.useCalculatedControl(function () {
|
|
1963
|
-
var _otherField$control3;
|
|
1964
|
-
var fv = (_otherField$control3 = otherField.control) == null ? void 0 : _otherField$control3.value;
|
|
1965
|
-
var field = otherField.schema.field;
|
|
1966
|
-
return coerce(field && !schemaInterface.isEmptyValue(field, fv));
|
|
1967
|
-
});
|
|
1968
|
-
}
|
|
1969
|
-
function defaultEvalHooks(expr, context, coerce) {
|
|
1970
|
-
switch (expr.type) {
|
|
1971
|
-
case exports.ExpressionType.Jsonata:
|
|
1972
|
-
var bindings = core.useComputed(function () {
|
|
1973
|
-
return {
|
|
1974
|
-
formData: context.formData
|
|
1975
|
-
};
|
|
1976
|
-
});
|
|
1977
|
-
return useJsonataExpression(expr.expression, getRootDataNode(context.parentNode).control, getJsonPath(context.parentNode), bindings, coerce);
|
|
1978
|
-
case exports.ExpressionType.UUID:
|
|
1979
|
-
return useUuidExpression(coerce);
|
|
1980
|
-
case exports.ExpressionType.Data:
|
|
1981
|
-
return useDataExpression(expr, context.parentNode, coerce);
|
|
1982
|
-
case exports.ExpressionType.DataMatch:
|
|
1983
|
-
return useDataMatchExpression(expr, context.parentNode, coerce);
|
|
1984
|
-
case exports.ExpressionType.NotEmpty:
|
|
1985
|
-
return useNotEmptyExpression(expr, context.parentNode, context.schemaInterface, coerce);
|
|
1986
|
-
default:
|
|
1987
|
-
return core.useControl(undefined);
|
|
1988
|
-
}
|
|
1989
|
-
}
|
|
1990
|
-
var defaultUseEvalExpressionHook = makeEvalExpressionHook(defaultEvalHooks);
|
|
1991
|
-
function makeEvalExpressionHook(f) {
|
|
1992
|
-
return function (expr, coerce) {
|
|
1993
|
-
return {
|
|
1994
|
-
deps: expr == null ? void 0 : expr.type,
|
|
1995
|
-
state: expr && expr.type ? expr : undefined,
|
|
1996
|
-
runHook: function runHook(ctx, state) {
|
|
1997
|
-
return state ? f(state, ctx, coerce) : undefined;
|
|
1998
|
-
}
|
|
1999
|
-
};
|
|
2000
|
-
};
|
|
2001
|
-
}
|
|
2002
|
-
function useEvalDynamicBoolHook(definition, type, useEvalExpressionHook) {
|
|
2003
|
-
return useEvalDynamicHook(definition, type, useEvalExpressionHook, function (x) {
|
|
2004
|
-
return Boolean(x);
|
|
2005
|
-
});
|
|
2006
|
-
}
|
|
2007
|
-
function useEvalDynamicHook(definition, type, useEvalExpressionHook, coerce) {
|
|
2008
|
-
var _definition$dynamic;
|
|
2009
|
-
if (coerce === void 0) {
|
|
2010
|
-
coerce = function coerce(x) {
|
|
2011
|
-
return x;
|
|
2012
|
-
};
|
|
2013
|
-
}
|
|
2014
|
-
var expression = (_definition$dynamic = definition.dynamic) == null ? void 0 : _definition$dynamic.find(function (x) {
|
|
2015
|
-
return x.type === type;
|
|
2016
|
-
});
|
|
2017
|
-
return useEvalExpressionHook(expression == null ? void 0 : expression.expr, coerce);
|
|
2018
|
-
}
|
|
2019
|
-
function matchesType(context) {
|
|
2020
|
-
var types = context.schema.field.onlyForTypes;
|
|
2021
|
-
if (types == null || types.length === 0) return true;
|
|
2022
|
-
var parent = context.parent;
|
|
2023
|
-
var typeNode = parent.schema.getChildNodes().find(function (x) {
|
|
2024
|
-
return x.field.isTypeField;
|
|
2025
|
-
});
|
|
2026
|
-
if (typeNode == null) return true;
|
|
2027
|
-
var typeField = parent.getChild(typeNode).control;
|
|
2028
|
-
return typeField && types.includes(typeField.value);
|
|
2029
|
-
}
|
|
2030
|
-
function hideDisplayOnly(context, schemaInterface, definition) {
|
|
2031
|
-
var _context$control;
|
|
2032
|
-
var displayOptions = getDisplayOnlyOptions(definition);
|
|
2033
|
-
return displayOptions && !displayOptions.emptyText && schemaInterface.isEmptyValue(context.schema.field, (_context$control = context.control) == null ? void 0 : _context$control.value);
|
|
2034
|
-
}
|
|
2035
|
-
function useUuidExpression(coerce) {
|
|
2036
|
-
if (coerce === void 0) {
|
|
2037
|
-
coerce = function coerce(x) {
|
|
2038
|
-
return x;
|
|
2039
|
-
};
|
|
2040
|
-
}
|
|
2041
|
-
return core.useControl(function () {
|
|
2042
|
-
return coerce(uuid.v4());
|
|
2043
|
-
});
|
|
2044
|
-
}
|
|
2045
|
-
function useJsonataExpression(jExpr, data, path, bindings, coerce) {
|
|
2046
|
-
if (coerce === void 0) {
|
|
2047
|
-
coerce = function coerce(x) {
|
|
2048
|
-
return x;
|
|
2049
|
-
};
|
|
2050
|
-
}
|
|
2051
|
-
var pathString = jsonPathString(path, function (x) {
|
|
2052
|
-
return "#$i[" + x + "]";
|
|
2053
|
-
});
|
|
2054
|
-
var fullExpr = pathString ? pathString + ".(" + jExpr + ")" : jExpr;
|
|
2055
|
-
var compiledExpr = react.useMemo(function () {
|
|
2056
|
-
try {
|
|
2057
|
-
return jsonata__default["default"](jExpr ? fullExpr : "null");
|
|
2058
|
-
} catch (e) {
|
|
2059
|
-
console.error(e);
|
|
2060
|
-
return jsonata__default["default"]("null");
|
|
2061
|
-
}
|
|
2062
|
-
}, [fullExpr]);
|
|
2063
|
-
var control = core.useControl();
|
|
2064
|
-
var listenerRef = react.useRef();
|
|
2065
|
-
var updateRef = react.useRef(0);
|
|
2066
|
-
var _useRefState = core.useRefState(function () {
|
|
2067
|
-
return new core.SubscriptionTracker(function () {
|
|
2068
|
-
var l = listenerRef.current;
|
|
2069
|
-
if (l) {
|
|
2070
|
-
listenerRef.current = undefined;
|
|
2071
|
-
core.addAfterChangesCallback(function () {
|
|
2072
|
-
listenerRef.current = l;
|
|
2073
|
-
l();
|
|
2074
|
-
});
|
|
2075
|
-
}
|
|
2076
|
-
});
|
|
2077
|
-
}),
|
|
2078
|
-
ref = _useRefState[0];
|
|
2079
|
-
react.useEffect(function () {
|
|
2080
|
-
var apply = function apply() {
|
|
2081
|
-
try {
|
|
2082
|
-
var tracker = ref.current;
|
|
2083
|
-
var _temp = _finallyRethrows(function () {
|
|
2084
|
-
updateRef.current++;
|
|
2085
|
-
var _coerce = coerce;
|
|
2086
|
-
return Promise.resolve(compiledExpr.evaluate(core.trackedValue(data, tracker.collectUsage), core.collectChanges(tracker.collectUsage, function () {
|
|
2087
|
-
return bindings == null ? void 0 : bindings.value;
|
|
2088
|
-
}))).then(function (_compiledExpr$evaluat) {
|
|
2089
|
-
control.value = _coerce(_compiledExpr$evaluat);
|
|
2090
|
-
});
|
|
2091
|
-
}, function (_wasThrown, _result) {
|
|
2092
|
-
if (! --updateRef.current) tracker.update();
|
|
2093
|
-
if (_wasThrown) throw _result;
|
|
2094
|
-
return _result;
|
|
2095
|
-
});
|
|
2096
|
-
return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
|
|
2097
|
-
} catch (e) {
|
|
2098
|
-
return Promise.reject(e);
|
|
2099
|
-
}
|
|
2100
|
-
};
|
|
2101
|
-
listenerRef.current = apply;
|
|
2102
|
-
apply();
|
|
2103
|
-
}, [compiledExpr]);
|
|
2104
|
-
react.useEffect(function () {
|
|
2105
|
-
return function () {
|
|
2106
|
-
listenerRef.current = undefined;
|
|
2107
|
-
ref.current.cleanup();
|
|
2108
|
-
};
|
|
2109
|
-
}, []);
|
|
2110
|
-
return control;
|
|
2111
|
-
}
|
|
2112
|
-
function useEvalActionHook(useExpr, definition) {
|
|
2113
|
-
var dynamicValue = useEvalDynamicHook(definition, exports.DynamicPropertyType.ActionData, useExpr);
|
|
2114
|
-
return makeDynamicPropertyHook(dynamicValue, function () {
|
|
2115
|
-
return core.useControl(null);
|
|
2116
|
-
}, undefined);
|
|
2117
|
-
}
|
|
2118
|
-
function useEvalLabelText(useExpr, definition) {
|
|
2119
|
-
var dynamicValue = useEvalDynamicHook(definition, exports.DynamicPropertyType.Label, useExpr);
|
|
2120
|
-
return makeDynamicPropertyHook(dynamicValue, function () {
|
|
2121
|
-
return core.useControl(null);
|
|
2122
|
-
}, undefined);
|
|
2123
|
-
}
|
|
2124
|
-
function makeDynamicPropertyHook(dynamicValue, makeDefault, state, deps) {
|
|
2125
|
-
return {
|
|
2126
|
-
deps: deps === undefined ? dynamicValue.deps : [deps, dynamicValue.deps].map(toDepString).join(),
|
|
2127
|
-
runHook: function runHook(ctx, s) {
|
|
2128
|
-
var _dynamicValue$runHook, _dynamicValue$runHook2;
|
|
2129
|
-
return (_dynamicValue$runHook = (_dynamicValue$runHook2 = dynamicValue.runHook(ctx, s[0])) == null ? void 0 : _dynamicValue$runHook2.as()) != null ? _dynamicValue$runHook : makeDefault(ctx, s[1]);
|
|
2130
|
-
},
|
|
2131
|
-
state: [dynamicValue.state, state]
|
|
2132
|
-
};
|
|
2133
|
-
}
|
|
2134
|
-
|
|
2135
|
-
function useMakeValidationHook(definition, useValidatorFor) {
|
|
2136
|
-
var _dd$validators;
|
|
2137
|
-
if (useValidatorFor === void 0) {
|
|
2138
|
-
useValidatorFor = useDefaultValidator;
|
|
2139
|
-
}
|
|
2140
|
-
var dd = isDataControl(definition) ? definition : undefined;
|
|
2141
|
-
var refData = useUpdatedRef({
|
|
2142
|
-
dd: dd,
|
|
2143
|
-
useValidatorFor: useValidatorFor
|
|
2144
|
-
});
|
|
2145
|
-
var depString = dd ? makeHookDepString((_dd$validators = dd.validators) != null ? _dd$validators : [], function (x) {
|
|
2146
|
-
return x.type;
|
|
2147
|
-
}) : "~";
|
|
2148
|
-
return react.useCallback(function (ctx) {
|
|
2149
|
-
var _ctx$dataContext$data, _ctx$dataContext$data2, _dd$validators2;
|
|
2150
|
-
var dd = refData.current.dd;
|
|
2151
|
-
if (!dd) return;
|
|
2152
|
-
var field = (_ctx$dataContext$data = (_ctx$dataContext$data2 = ctx.dataContext.dataNode) == null ? void 0 : _ctx$dataContext$data2.schema.field) != null ? _ctx$dataContext$data : {
|
|
2153
|
-
field: "__missing",
|
|
2154
|
-
type: exports.FieldType.Any
|
|
2155
|
-
};
|
|
2156
|
-
var control = ctx.control,
|
|
2157
|
-
hiddenControl = ctx.hiddenControl,
|
|
2158
|
-
schemaInterface = ctx.dataContext.schemaInterface;
|
|
2159
|
-
core.useValueChangeEffect(control, function () {
|
|
2160
|
-
return control.setError("default", "");
|
|
2161
|
-
});
|
|
2162
|
-
if (dd.required) core.useValidator(control, function (v) {
|
|
2163
|
-
return !hiddenControl.value && schemaInterface.isEmptyValue(field, v) ? schemaInterface.validationMessageText(field, exports.ValidationMessageType.NotEmpty, false, true) : null;
|
|
2164
|
-
}, "required");
|
|
2165
|
-
(_dd$validators2 = dd.validators) == null || _dd$validators2.forEach(function (v, i) {
|
|
2166
|
-
return useValidatorFor(v, _extends({}, ctx, {
|
|
2167
|
-
index: i,
|
|
2168
|
-
field: field,
|
|
2169
|
-
definition: dd
|
|
2170
|
-
}));
|
|
2171
|
-
});
|
|
2172
|
-
}, [!!dd, dd == null ? void 0 : dd.required, depString, useValidatorFor]);
|
|
2173
|
-
}
|
|
2174
|
-
function useDefaultValidator(validator, ctx) {
|
|
2175
|
-
switch (validator.type) {
|
|
2176
|
-
case exports.ValidatorType.Length:
|
|
2177
|
-
useLengthValidator(validator, ctx);
|
|
2178
|
-
break;
|
|
2179
|
-
case exports.ValidatorType.Jsonata:
|
|
2180
|
-
useJsonataValidator(validator, ctx);
|
|
2181
|
-
break;
|
|
2182
|
-
case exports.ValidatorType.Date:
|
|
2183
|
-
useDateValidator(validator, ctx);
|
|
2184
|
-
break;
|
|
2185
|
-
}
|
|
2186
|
-
}
|
|
2187
|
-
function useJsonataValidator(validator, ctx) {
|
|
2188
|
-
var sdn = ctx.dataContext.parentNode;
|
|
2189
|
-
var errorMsg = useJsonataExpression(validator.expression, getRootDataNode(sdn).control, getJsonPath(sdn), undefined, function (v) {
|
|
2190
|
-
return v == null ? null : typeof v === "string" ? v : JSON.stringify(v);
|
|
2191
|
-
});
|
|
2192
|
-
core.useValidator(ctx.control, function () {
|
|
2193
|
-
return !ctx.hiddenControl.value ? errorMsg.value : null;
|
|
2194
|
-
}, "jsonata" + ctx.index);
|
|
2195
|
-
}
|
|
2196
|
-
function useLengthValidator(lv, ctx) {
|
|
2197
|
-
var control = ctx.control,
|
|
2198
|
-
schemaInterface = ctx.dataContext.schemaInterface,
|
|
2199
|
-
hiddenControl = ctx.hiddenControl,
|
|
2200
|
-
field = ctx.field;
|
|
2201
|
-
core.useValidator(control, function (v) {
|
|
2202
|
-
var len = schemaInterface.controlLength(field, control);
|
|
2203
|
-
var hidden = hiddenControl.value;
|
|
2204
|
-
if (hidden) {
|
|
2205
|
-
return undefined;
|
|
2206
|
-
}
|
|
2207
|
-
if (lv.min != null && len < lv.min) {
|
|
2208
|
-
if (field != null && field.collection) {
|
|
2209
|
-
control.setValue(function (v) {
|
|
2210
|
-
return Array.isArray(v) ? v.concat(Array.from({
|
|
2211
|
-
length: lv.min - v.length
|
|
2212
|
-
})) : Array.from({
|
|
2213
|
-
length: lv.min
|
|
2214
|
-
});
|
|
2215
|
-
});
|
|
2216
|
-
} else {
|
|
2217
|
-
return schemaInterface.validationMessageText(field, exports.ValidationMessageType.MinLength, len, lv.min);
|
|
2218
|
-
}
|
|
2219
|
-
} else if (lv.max != null && len > lv.max) {
|
|
2220
|
-
return schemaInterface.validationMessageText(field, exports.ValidationMessageType.MaxLength, len, lv.max);
|
|
2221
|
-
}
|
|
2222
|
-
return undefined;
|
|
2223
|
-
}, "length" + ctx.index);
|
|
2224
|
-
}
|
|
2225
|
-
function useDateValidator(dv, ctx) {
|
|
2226
|
-
var control = ctx.control,
|
|
2227
|
-
field = ctx.field,
|
|
2228
|
-
index = ctx.index,
|
|
2229
|
-
schemaInterface = ctx.dataContext.schemaInterface;
|
|
2230
|
-
var comparisonDate;
|
|
2231
|
-
if (dv.fixedDate) {
|
|
2232
|
-
comparisonDate = schemaInterface.parseToMillis(field, dv.fixedDate);
|
|
2233
|
-
} else {
|
|
2234
|
-
var nowDate = new Date();
|
|
2235
|
-
comparisonDate = Date.UTC(nowDate.getFullYear(), nowDate.getMonth(), nowDate.getDate());
|
|
2236
|
-
if (dv.daysFromCurrent) {
|
|
2237
|
-
comparisonDate += dv.daysFromCurrent * 86400000;
|
|
2238
|
-
}
|
|
2239
|
-
}
|
|
2240
|
-
core.useValidator(control, function (v) {
|
|
2241
|
-
if (v) {
|
|
2242
|
-
var selDate = schemaInterface.parseToMillis(field, v);
|
|
2243
|
-
var notAfter = dv.comparison === exports.DateComparison.NotAfter;
|
|
2244
|
-
if (notAfter ? selDate > comparisonDate : selDate < comparisonDate) {
|
|
2245
|
-
return schemaInterface.validationMessageText(field, notAfter ? exports.ValidationMessageType.NotAfterDate : exports.ValidationMessageType.NotBeforeDate, selDate, comparisonDate);
|
|
2246
|
-
}
|
|
2247
|
-
}
|
|
2248
|
-
return null;
|
|
2249
|
-
}, "date" + index);
|
|
2250
|
-
}
|
|
2251
|
-
|
|
2252
|
-
var DefaultSchemaInterface = /*#__PURE__*/function () {
|
|
2253
|
-
function DefaultSchemaInterface(boolStrings, parseDateTime) {
|
|
2254
|
-
if (boolStrings === void 0) {
|
|
2255
|
-
boolStrings = ["No", "Yes"];
|
|
2256
|
-
}
|
|
2257
|
-
if (parseDateTime === void 0) {
|
|
2258
|
-
parseDateTime = function parseDateTime(s) {
|
|
2259
|
-
return Date.parse(s);
|
|
2260
|
-
};
|
|
2261
|
-
}
|
|
2262
|
-
this.boolStrings = void 0;
|
|
2263
|
-
this.parseDateTime = void 0;
|
|
2264
|
-
this.boolStrings = boolStrings;
|
|
2265
|
-
this.parseDateTime = parseDateTime;
|
|
2266
|
-
}
|
|
2267
|
-
var _proto = DefaultSchemaInterface.prototype;
|
|
2268
|
-
_proto.parseToMillis = function parseToMillis(field, v) {
|
|
2269
|
-
return this.parseDateTime(v);
|
|
2270
|
-
};
|
|
2271
|
-
_proto.validationMessageText = function validationMessageText(field, messageType, actual, expected) {
|
|
2272
|
-
switch (messageType) {
|
|
2273
|
-
case exports.ValidationMessageType.NotEmpty:
|
|
2274
|
-
return "Please enter a value";
|
|
2275
|
-
case exports.ValidationMessageType.MinLength:
|
|
2276
|
-
return "Length must be at least " + expected;
|
|
2277
|
-
case exports.ValidationMessageType.MaxLength:
|
|
2278
|
-
return "Length must be less than " + expected;
|
|
2279
|
-
case exports.ValidationMessageType.NotBeforeDate:
|
|
2280
|
-
return "Date must not be before " + new Date(expected).toDateString();
|
|
2281
|
-
case exports.ValidationMessageType.NotAfterDate:
|
|
2282
|
-
return "Date must not be after " + new Date(expected).toDateString();
|
|
2283
|
-
default:
|
|
2284
|
-
return "Unknown error";
|
|
2285
|
-
}
|
|
2286
|
-
};
|
|
2287
|
-
_proto.getDataOptions = function getDataOptions(node) {
|
|
2288
|
-
return this.getNodeOptions(node.schema);
|
|
2289
|
-
};
|
|
2290
|
-
_proto.getNodeOptions = function getNodeOptions(node) {
|
|
2291
|
-
return this.getOptions(node.field);
|
|
2292
|
-
};
|
|
2293
|
-
_proto.getOptions = function getOptions(_ref) {
|
|
2294
|
-
var options = _ref.options;
|
|
2295
|
-
return options && options.length > 0 ? options : null;
|
|
2296
|
-
};
|
|
2297
|
-
_proto.getFilterOptions = function getFilterOptions(array, field) {
|
|
2298
|
-
return this.getNodeOptions(field);
|
|
2299
|
-
};
|
|
2300
|
-
_proto.isEmptyValue = function isEmptyValue(f, value) {
|
|
2301
|
-
if (f.collection) return Array.isArray(value) ? value.length === 0 : value == null;
|
|
2302
|
-
switch (f.type) {
|
|
2303
|
-
case exports.FieldType.String:
|
|
2304
|
-
case exports.FieldType.DateTime:
|
|
2305
|
-
case exports.FieldType.Date:
|
|
2306
|
-
case exports.FieldType.Time:
|
|
2307
|
-
return !value;
|
|
2308
|
-
default:
|
|
2309
|
-
return value == null;
|
|
2310
|
-
}
|
|
2311
|
-
};
|
|
2312
|
-
_proto.searchText = function searchText(field, value) {
|
|
2313
|
-
var _this$textValue$toLow, _this$textValue;
|
|
2314
|
-
return (_this$textValue$toLow = (_this$textValue = this.textValue(field, value)) == null ? void 0 : _this$textValue.toLowerCase()) != null ? _this$textValue$toLow : "";
|
|
2315
|
-
};
|
|
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) {
|
|
2319
|
-
return x.value === value;
|
|
2320
|
-
});
|
|
2321
|
-
if (option) return option.name;
|
|
2322
|
-
switch (field.type) {
|
|
2323
|
-
case exports.FieldType.Date:
|
|
2324
|
-
return value ? new Date(value).toLocaleDateString() : undefined;
|
|
2325
|
-
case exports.FieldType.DateTime:
|
|
2326
|
-
return value ? new Date(this.parseToMillis(field, value)).toLocaleString() : undefined;
|
|
2327
|
-
case exports.FieldType.Time:
|
|
2328
|
-
return value ? new Date("1970-01-01T" + value).toLocaleTimeString() : undefined;
|
|
2329
|
-
case exports.FieldType.Bool:
|
|
2330
|
-
return this.boolStrings[value ? 1 : 0];
|
|
2331
|
-
default:
|
|
2332
|
-
return value != null ? value.toString() : undefined;
|
|
2333
|
-
}
|
|
2334
|
-
};
|
|
2335
|
-
_proto.controlLength = function controlLength(f, control) {
|
|
2336
|
-
var _control$elements$len, _control$elements;
|
|
2337
|
-
return f.collection ? (_control$elements$len = (_control$elements = control.elements) == null ? void 0 : _control$elements.length) != null ? _control$elements$len : 0 : this.valueLength(f, control.value);
|
|
2338
|
-
};
|
|
2339
|
-
_proto.valueLength = function valueLength(field, value) {
|
|
2340
|
-
var _ref2;
|
|
2341
|
-
return (_ref2 = value && (value == null ? void 0 : value.length)) != null ? _ref2 : 0;
|
|
2342
|
-
};
|
|
2343
|
-
_proto.compareValue = function compareValue(field, v1, v2) {
|
|
2344
|
-
if (v1 == null) return v2 == null ? 0 : 1;
|
|
2345
|
-
if (v2 == null) return -1;
|
|
2346
|
-
switch (field.type) {
|
|
2347
|
-
case exports.FieldType.Date:
|
|
2348
|
-
case exports.FieldType.DateTime:
|
|
2349
|
-
case exports.FieldType.Time:
|
|
2350
|
-
case exports.FieldType.String:
|
|
2351
|
-
return v1.localeCompare(v2);
|
|
2352
|
-
case exports.FieldType.Bool:
|
|
2353
|
-
return v1 ? v2 ? 0 : 1 : -1;
|
|
2354
|
-
case exports.FieldType.Int:
|
|
2355
|
-
case exports.FieldType.Double:
|
|
2356
|
-
return v1 - v2;
|
|
2357
|
-
default:
|
|
2358
|
-
return 0;
|
|
2359
|
-
}
|
|
2360
|
-
};
|
|
2361
|
-
_proto.compoundFieldSetup = function compoundFieldSetup(f) {
|
|
2362
|
-
var _this = this;
|
|
2363
|
-
return f.getChildNodes().map(function (x) {
|
|
2364
|
-
var field = x.field.field;
|
|
2365
|
-
return [field, _this.makeControlSetup(x)];
|
|
2366
|
-
});
|
|
2367
|
-
};
|
|
2368
|
-
_proto.compoundFieldEquality = function compoundFieldEquality(f) {
|
|
2369
|
-
var _this2 = this;
|
|
2370
|
-
return f.getChildNodes().map(function (x) {
|
|
2371
|
-
var field = x.field.field;
|
|
2372
|
-
return [field, function (a, b) {
|
|
2373
|
-
return _this2.makeEqualityFunc(x)(a[field], b[field]);
|
|
2374
|
-
}];
|
|
2375
|
-
});
|
|
2376
|
-
};
|
|
2377
|
-
_proto.makeEqualityFunc = function makeEqualityFunc(field, element) {
|
|
2378
|
-
if (field.field.collection && !element) {
|
|
2379
|
-
var elemEqual = this.makeEqualityFunc(field, true);
|
|
2380
|
-
return function (a, b) {
|
|
2381
|
-
if (a === b) return true;
|
|
2382
|
-
if (a == null || b == null) return false;
|
|
2383
|
-
if (a.length !== b.length) return false;
|
|
2384
|
-
for (var i = 0; i < a.length; i++) {
|
|
2385
|
-
if (!elemEqual(a[i], b[i])) return false;
|
|
2386
|
-
}
|
|
2387
|
-
return true;
|
|
2388
|
-
};
|
|
2389
|
-
}
|
|
2390
|
-
switch (field.field.type) {
|
|
2391
|
-
case exports.FieldType.Compound:
|
|
2392
|
-
var allChecks = this.compoundFieldEquality(field);
|
|
2393
|
-
return function (a, b) {
|
|
2394
|
-
return a === b || a != null && b != null && allChecks.every(function (x) {
|
|
2395
|
-
return x[1](a, b);
|
|
2396
|
-
});
|
|
2397
|
-
};
|
|
2398
|
-
default:
|
|
2399
|
-
return function (a, b) {
|
|
2400
|
-
return a === b;
|
|
2401
|
-
};
|
|
2402
|
-
}
|
|
2403
|
-
};
|
|
2404
|
-
_proto.makeControlSetup = function makeControlSetup(field, element) {
|
|
2405
|
-
var setup = {
|
|
2406
|
-
equals: this.makeEqualityFunc(field, element)
|
|
2407
|
-
};
|
|
2408
|
-
if (field.field.collection && !element) {
|
|
2409
|
-
setup.elems = this.makeControlSetup(field, true);
|
|
2410
|
-
return setup;
|
|
2411
|
-
}
|
|
2412
|
-
switch (field.field.type) {
|
|
2413
|
-
case exports.FieldType.Compound:
|
|
2414
|
-
setup.fields = Object.fromEntries(this.compoundFieldSetup(field));
|
|
2415
|
-
}
|
|
2416
|
-
return setup;
|
|
2417
|
-
};
|
|
2418
|
-
return DefaultSchemaInterface;
|
|
2419
|
-
}();
|
|
2420
|
-
var defaultSchemaInterface = new DefaultSchemaInterface();
|
|
2421
|
-
|
|
2422
|
-
var _excluded = ["styleClass", "labelClass", "layoutClass"],
|
|
2423
|
-
_excluded2 = ["parentDataNode"],
|
|
2424
|
-
_excluded3 = ["definition", "control", "formOptions", "style", "allowedOptions", "schemaInterface", "styleClass"];
|
|
946
|
+
var _excluded$1 = ["formOptions", "style", "allowedOptions", "schemaInterface", "styleClass", "textClass", "displayOnly", "inline"];
|
|
2425
947
|
var AppendAdornmentPriority = 0;
|
|
2426
948
|
var WrapAdornmentPriority = 1000;
|
|
2427
949
|
/**
|
|
@@ -2442,285 +964,25 @@ exports.LabelType = void 0;
|
|
|
2442
964
|
*/
|
|
2443
965
|
LabelType[LabelType["Text"] = 2] = "Text";
|
|
2444
966
|
})(exports.LabelType || (exports.LabelType = {}));
|
|
2445
|
-
function
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
parentPath = _ref.parentPath;
|
|
2458
|
-
return /*#__PURE__*/jsxRuntime.jsx(ControlRenderer, _extends({}, r.current, {
|
|
2459
|
-
control: control,
|
|
2460
|
-
parentPath: parentPath
|
|
2461
|
-
}));
|
|
2462
|
-
}, [r]);
|
|
2463
|
-
}
|
|
2464
|
-
function useControlRendererComponent(controlOrFormNode, renderer, options, parentDataNode) {
|
|
2465
|
-
var _options$useDataHook, _options$schemaInterf, _options$useEvalExpre;
|
|
2466
|
-
if (options === void 0) {
|
|
2467
|
-
options = {};
|
|
2468
|
-
}
|
|
2469
|
-
var _ref2 = "definition" in controlOrFormNode ? [controlOrFormNode.definition, controlOrFormNode] : [controlOrFormNode, legacyFormNode(controlOrFormNode)],
|
|
2470
|
-
definition = _ref2[0],
|
|
2471
|
-
formNode = _ref2[1];
|
|
2472
|
-
var dataProps = (_options$useDataHook = options.useDataHook == null ? void 0 : options.useDataHook(definition)) != null ? _options$useDataHook : defaultDataProps;
|
|
2473
|
-
var elementIndex = options.elementIndex;
|
|
2474
|
-
var schemaInterface = (_options$schemaInterf = options.schemaInterface) != null ? _options$schemaInterf : defaultSchemaInterface;
|
|
2475
|
-
var useExpr = (_options$useEvalExpre = options.useEvalExpressionHook) != null ? _options$useEvalExpre : defaultUseEvalExpressionHook;
|
|
2476
|
-
var dataNode;
|
|
2477
|
-
if (elementIndex != null) {
|
|
2478
|
-
dataNode = parentDataNode.getChildElement(elementIndex);
|
|
2479
|
-
} else {
|
|
2480
|
-
dataNode = lookupDataNode(definition, parentDataNode);
|
|
2481
|
-
}
|
|
2482
|
-
var useValidation = useMakeValidationHook(definition, options.useValidationHook);
|
|
2483
|
-
var dynamicHooks = useDynamicHooks({
|
|
2484
|
-
defaultValueControl: useEvalDefaultValueHook(useExpr, definition),
|
|
2485
|
-
visibleControl: useEvalVisibilityHook(useExpr, definition),
|
|
2486
|
-
readonlyControl: useEvalReadonlyHook(useExpr, definition),
|
|
2487
|
-
disabledControl: useEvalDisabledHook(useExpr, definition),
|
|
2488
|
-
allowedOptions: useEvalAllowedOptionsHook(useExpr, definition),
|
|
2489
|
-
labelText: useEvalLabelText(useExpr, definition),
|
|
2490
|
-
actionData: useEvalActionHook(useExpr, definition),
|
|
2491
|
-
customStyle: useEvalStyleHook(useExpr, exports.DynamicPropertyType.Style, definition),
|
|
2492
|
-
layoutStyle: useEvalStyleHook(useExpr, exports.DynamicPropertyType.LayoutStyle, definition),
|
|
2493
|
-
displayControl: useEvalDisplayHook(useExpr, definition)
|
|
2494
|
-
});
|
|
2495
|
-
var r = useUpdatedRef({
|
|
2496
|
-
options: options,
|
|
2497
|
-
definition: definition,
|
|
2498
|
-
elementIndex: elementIndex,
|
|
2499
|
-
parentDataNode: parentDataNode,
|
|
2500
|
-
dataNode: dataNode,
|
|
2501
|
-
formNode: formNode
|
|
2502
|
-
});
|
|
2503
|
-
if (formNode == null) debugger;
|
|
2504
|
-
var Component = react.useCallback(function () {
|
|
2505
|
-
var stopTracking = core.useComponentTracking();
|
|
2506
|
-
try {
|
|
2507
|
-
var _options$formData, _dataNode, _definition$adornment2, _definition$adornment3, _formNode$tree$getByR, _options$adjustLayout;
|
|
2508
|
-
var _r$current = r.current,
|
|
2509
|
-
c = _r$current.definition,
|
|
2510
|
-
_options = _r$current.options,
|
|
2511
|
-
_elementIndex = _r$current.elementIndex,
|
|
2512
|
-
pdn = _r$current.parentDataNode,
|
|
2513
|
-
dn = _r$current.dataNode,
|
|
2514
|
-
_formNode = _r$current.formNode;
|
|
2515
|
-
var formData = (_options$formData = _options.formData) != null ? _options$formData : {};
|
|
2516
|
-
var dataContext = {
|
|
2517
|
-
schemaInterface: schemaInterface,
|
|
2518
|
-
dataNode: dn,
|
|
2519
|
-
parentNode: pdn,
|
|
2520
|
-
formData: formData
|
|
2521
|
-
};
|
|
2522
|
-
var _dynamicHooks = dynamicHooks(dataContext),
|
|
2523
|
-
readonlyControl = _dynamicHooks.readonlyControl,
|
|
2524
|
-
disabledControl = _dynamicHooks.disabledControl,
|
|
2525
|
-
visibleControl = _dynamicHooks.visibleControl,
|
|
2526
|
-
displayControl = _dynamicHooks.displayControl,
|
|
2527
|
-
layoutStyle = _dynamicHooks.layoutStyle,
|
|
2528
|
-
labelText = _dynamicHooks.labelText,
|
|
2529
|
-
customStyle = _dynamicHooks.customStyle,
|
|
2530
|
-
allowedOptions = _dynamicHooks.allowedOptions,
|
|
2531
|
-
defaultValueControl = _dynamicHooks.defaultValueControl,
|
|
2532
|
-
actionData = _dynamicHooks.actionData;
|
|
2533
|
-
var visible = visibleControl.current.value;
|
|
2534
|
-
var visibility = core.useControl(function () {
|
|
2535
|
-
return visible != null ? {
|
|
2536
|
-
visible: visible,
|
|
2537
|
-
showing: visible
|
|
2538
|
-
} : undefined;
|
|
2539
|
-
});
|
|
2540
|
-
core.useControlEffect(function () {
|
|
2541
|
-
return visibleControl.value;
|
|
2542
|
-
}, function (visible) {
|
|
2543
|
-
if (visible != null) visibility.setValue(function (ex) {
|
|
2544
|
-
return {
|
|
2545
|
-
visible: visible,
|
|
2546
|
-
showing: ex ? ex.showing : visible
|
|
2547
|
-
};
|
|
2548
|
-
});
|
|
2549
|
-
});
|
|
2550
|
-
var parentControl = parentDataNode.control;
|
|
2551
|
-
var control = (_dataNode = dataNode) == null ? void 0 : _dataNode.control;
|
|
2552
|
-
core.useControlEffect(function () {
|
|
2553
|
-
var _definition$adornment, _definition$renderOpt;
|
|
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) {
|
|
2555
|
-
return x.type === exports.ControlAdornmentType.Optional;
|
|
2556
|
-
})) || isDataControl(definition) && ((_definition$renderOpt = definition.renderOptions) == null ? void 0 : _definition$renderOpt.type) == exports.DataRenderType.NullToggle, parentControl.isNull, _options.hidden, readonlyControl.value];
|
|
2557
|
-
}, function (_ref3) {
|
|
2558
|
-
var vc = _ref3[0],
|
|
2559
|
-
dv = _ref3[1],
|
|
2560
|
-
_ = _ref3[2],
|
|
2561
|
-
dontClear = _ref3[3],
|
|
2562
|
-
dontDefault = _ref3[4],
|
|
2563
|
-
parentNull = _ref3[5],
|
|
2564
|
-
hidden = _ref3[6],
|
|
2565
|
-
ro = _ref3[7];
|
|
2566
|
-
if (!ro) {
|
|
2567
|
-
if (control) {
|
|
2568
|
-
if (vc && vc.visible === vc.showing) {
|
|
2569
|
-
if (hidden || !vc.visible) {
|
|
2570
|
-
control.setValue(function (x) {
|
|
2571
|
-
return _options.clearHidden && !dontClear ? undefined : x == null && dontClear && !dontDefault ? dv : x;
|
|
2572
|
-
});
|
|
2573
|
-
} else if (!dontDefault) control.setValue(function (x) {
|
|
2574
|
-
return x != null ? x : dv;
|
|
2575
|
-
});
|
|
2576
|
-
}
|
|
2577
|
-
} else if (parentNull) {
|
|
2578
|
-
parentControl.setValue(function (x) {
|
|
2579
|
-
return x != null ? x : {};
|
|
2580
|
-
});
|
|
2581
|
-
}
|
|
2582
|
-
}
|
|
2583
|
-
}, true);
|
|
2584
|
-
var myOptionsControl = core.useComputed(function () {
|
|
2585
|
-
var _visibility$fields;
|
|
2586
|
-
return {
|
|
2587
|
-
hidden: _options.hidden || !((_visibility$fields = visibility.fields) != null && _visibility$fields.showing.value),
|
|
2588
|
-
readonly: _options.readonly || readonlyControl.value,
|
|
2589
|
-
disabled: _options.disabled || disabledControl.value,
|
|
2590
|
-
displayOnly: _options.displayOnly || isControlDisplayOnly(c)
|
|
2591
|
-
};
|
|
2592
|
-
});
|
|
2593
|
-
var myOptions = core.trackedValue(myOptionsControl);
|
|
2594
|
-
useValidation({
|
|
2595
|
-
control: control != null ? control : core.newControl(null),
|
|
2596
|
-
hiddenControl: myOptionsControl.fields.hidden,
|
|
2597
|
-
dataContext: dataContext
|
|
2598
|
-
});
|
|
2599
|
-
var styleClass = _options.styleClass,
|
|
2600
|
-
labelClass = _options.labelClass,
|
|
2601
|
-
layoutClass = _options.layoutClass,
|
|
2602
|
-
inheritableOptions = _objectWithoutPropertiesLoose(_options, _excluded);
|
|
2603
|
-
var childOptions = _extends({}, inheritableOptions, myOptions, {
|
|
2604
|
-
elementIndex: undefined
|
|
2605
|
-
});
|
|
2606
|
-
react.useEffect(function () {
|
|
2607
|
-
if (control && typeof myOptions.disabled === "boolean" && control.disabled != myOptions.disabled) control.disabled = myOptions.disabled;
|
|
2608
|
-
}, [control, myOptions.disabled]);
|
|
2609
|
-
if (parentControl.isNull) return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
2610
|
-
var adornments = (_definition$adornment2 = (_definition$adornment3 = definition.adornments) == null ? void 0 : _definition$adornment3.map(function (x) {
|
|
2611
|
-
return renderer.renderAdornment({
|
|
2612
|
-
adornment: x,
|
|
2613
|
-
dataContext: dataContext,
|
|
2614
|
-
useExpr: useExpr,
|
|
2615
|
-
formOptions: myOptions
|
|
2616
|
-
});
|
|
2617
|
-
})) != null ? _definition$adornment2 : [];
|
|
2618
|
-
var otherChildNodes = definition.childRefId && ((_formNode$tree$getByR = _formNode.tree.getByRefId(definition.childRefId)) == null ? void 0 : _formNode$tree$getByR.getChildNodes());
|
|
2619
|
-
var labelAndChildren = renderControlLayout({
|
|
2620
|
-
formNode: otherChildNodes ? _formNode.tree.createTempNode(_formNode.id, definition, otherChildNodes) : _formNode,
|
|
2621
|
-
definition: c,
|
|
2622
|
-
renderer: renderer,
|
|
2623
|
-
renderChild: function renderChild(k, child, options) {
|
|
2624
|
-
var _ref5;
|
|
2625
|
-
var overrideClasses = getGroupClassOverrides(c);
|
|
2626
|
-
var _ref4 = options != null ? options : {},
|
|
2627
|
-
parentDataNode = _ref4.parentDataNode,
|
|
2628
|
-
renderOptions = _objectWithoutPropertiesLoose(_ref4, _excluded2);
|
|
2629
|
-
var dContext = (_ref5 = parentDataNode != null ? parentDataNode : dataContext.dataNode) != null ? _ref5 : dataContext.parentNode;
|
|
2630
|
-
var allChildOptions = _extends({}, childOptions, overrideClasses, renderOptions);
|
|
2631
|
-
return /*#__PURE__*/jsxRuntime.jsx(NewControlRenderer, {
|
|
2632
|
-
definition: child,
|
|
2633
|
-
renderer: renderer,
|
|
2634
|
-
parentDataNode: dContext,
|
|
2635
|
-
options: allChildOptions
|
|
2636
|
-
}, k);
|
|
2637
|
-
},
|
|
2638
|
-
createDataProps: dataProps,
|
|
2639
|
-
formOptions: myOptions,
|
|
2640
|
-
dataContext: dataContext,
|
|
2641
|
-
control: displayControl != null ? displayControl : control,
|
|
2642
|
-
elementIndex: _elementIndex,
|
|
2643
|
-
schemaInterface: schemaInterface,
|
|
2644
|
-
labelText: labelText,
|
|
2645
|
-
displayControl: displayControl,
|
|
2646
|
-
style: customStyle.value,
|
|
2647
|
-
allowedOptions: allowedOptions,
|
|
2648
|
-
customDisplay: _options.customDisplay,
|
|
2649
|
-
actionDataControl: actionData,
|
|
2650
|
-
actionOnClick: _options.actionOnClick,
|
|
2651
|
-
styleClass: _options.styleClass,
|
|
2652
|
-
labelClass: _options.labelClass,
|
|
2653
|
-
useEvalExpression: useExpr,
|
|
2654
|
-
useChildVisibility: function useChildVisibility(childDef, parentNode, dontOverride) {
|
|
2655
|
-
var _ref6;
|
|
2656
|
-
return useEvalVisibilityHook(useExpr, childDef, !dontOverride ? lookupDataNode(childDef, (_ref6 = parentNode != null ? parentNode : dataNode) != null ? _ref6 : parentDataNode) : undefined);
|
|
2657
|
-
}
|
|
2658
|
-
});
|
|
2659
|
-
var layoutProps = _extends({}, labelAndChildren, {
|
|
2660
|
-
adornments: adornments,
|
|
2661
|
-
className: rendererClass(_options.layoutClass, c.layoutClass),
|
|
2662
|
-
style: layoutStyle.value
|
|
2663
|
-
});
|
|
2664
|
-
var renderedControl = renderer.renderLayout((_options$adjustLayout = _options.adjustLayout == null ? void 0 : _options.adjustLayout(dataContext, layoutProps)) != null ? _options$adjustLayout : layoutProps);
|
|
2665
|
-
return renderer.renderVisibility(_extends({
|
|
2666
|
-
visibility: visibility
|
|
2667
|
-
}, renderedControl));
|
|
2668
|
-
} finally {
|
|
2669
|
-
stopTracking();
|
|
2670
|
-
}
|
|
2671
|
-
}, [r, dataProps, useValidation, renderer, schemaInterface, dynamicHooks]);
|
|
2672
|
-
Component.displayName = "RenderControl";
|
|
2673
|
-
return Component;
|
|
2674
|
-
}
|
|
2675
|
-
function ControlRenderer(_ref7) {
|
|
2676
|
-
var _effect = core.useComponentTracking();
|
|
2677
|
-
try {
|
|
2678
|
-
var definition = _ref7.definition,
|
|
2679
|
-
fields = _ref7.fields,
|
|
2680
|
-
renderer = _ref7.renderer,
|
|
2681
|
-
options = _ref7.options,
|
|
2682
|
-
control = _ref7.control,
|
|
2683
|
-
parentPath = _ref7.parentPath;
|
|
2684
|
-
var schemaDataNode = makeSchemaDataNode(createSchemaLookup({
|
|
2685
|
-
"": fields
|
|
2686
|
-
}).getSchema(""), control);
|
|
2687
|
-
var Render = useControlRendererComponent(definition, renderer, options, schemaDataNode);
|
|
2688
|
-
return /*#__PURE__*/jsxRuntime.jsx(Render, {});
|
|
2689
|
-
} finally {
|
|
2690
|
-
_effect();
|
|
2691
|
-
}
|
|
2692
|
-
}
|
|
2693
|
-
function NewControlRenderer(_ref8) {
|
|
2694
|
-
var _effect2 = core.useComponentTracking();
|
|
2695
|
-
try {
|
|
2696
|
-
var definition = _ref8.definition,
|
|
2697
|
-
renderer = _ref8.renderer,
|
|
2698
|
-
options = _ref8.options,
|
|
2699
|
-
parentDataNode = _ref8.parentDataNode;
|
|
2700
|
-
var Render = useControlRendererComponent(definition, renderer, options, parentDataNode);
|
|
2701
|
-
return /*#__PURE__*/jsxRuntime.jsx(Render, {});
|
|
2702
|
-
} finally {
|
|
2703
|
-
_effect2();
|
|
2704
|
-
}
|
|
2705
|
-
}
|
|
2706
|
-
function defaultDataProps(_ref9) {
|
|
2707
|
-
var _allowedOptions$value, _definition$renderOpt2;
|
|
2708
|
-
var definition = _ref9.definition,
|
|
2709
|
-
control = _ref9.control,
|
|
2710
|
-
formOptions = _ref9.formOptions,
|
|
2711
|
-
style = _ref9.style,
|
|
2712
|
-
allowedOptions = _ref9.allowedOptions,
|
|
2713
|
-
_ref9$schemaInterface = _ref9.schemaInterface,
|
|
2714
|
-
schemaInterface = _ref9$schemaInterface === void 0 ? defaultSchemaInterface : _ref9$schemaInterface,
|
|
2715
|
-
styleClass = _ref9.styleClass,
|
|
2716
|
-
props = _objectWithoutPropertiesLoose(_ref9, _excluded3);
|
|
967
|
+
function defaultDataProps(_ref, definition, control) {
|
|
968
|
+
var _definition$renderOpt;
|
|
969
|
+
var formOptions = _ref.formOptions,
|
|
970
|
+
style = _ref.style,
|
|
971
|
+
allowedOptions = _ref.allowedOptions,
|
|
972
|
+
_ref$schemaInterface = _ref.schemaInterface,
|
|
973
|
+
schemaInterface = _ref$schemaInterface === void 0 ? formsCore.defaultSchemaInterface : _ref$schemaInterface,
|
|
974
|
+
styleClass = _ref.styleClass,
|
|
975
|
+
tc = _ref.textClass,
|
|
976
|
+
displayOnly = _ref.displayOnly,
|
|
977
|
+
inline = _ref.inline,
|
|
978
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
2717
979
|
var dataNode = props.dataContext.dataNode;
|
|
2718
980
|
var field = dataNode.schema.field;
|
|
2719
981
|
var className = rendererClass(styleClass, definition.styleClass);
|
|
2720
|
-
var
|
|
982
|
+
var textClass = rendererClass(tc, definition.textClass);
|
|
2721
983
|
var required = !!definition.required && !displayOnly;
|
|
2722
984
|
var fieldOptions = schemaInterface.getDataOptions(dataNode);
|
|
2723
|
-
var _allowed =
|
|
985
|
+
var _allowed = allowedOptions != null ? allowedOptions : [];
|
|
2724
986
|
var allowed = Array.isArray(_allowed) ? _allowed : [_allowed];
|
|
2725
987
|
return _extends({
|
|
2726
988
|
dataNode: dataNode,
|
|
@@ -2728,6 +990,7 @@ function defaultDataProps(_ref9) {
|
|
|
2728
990
|
control: control,
|
|
2729
991
|
field: field,
|
|
2730
992
|
id: "c" + control.uniqueId,
|
|
993
|
+
inline: !!inline,
|
|
2731
994
|
options: allowed.length > 0 ? allowed.map(function (x) {
|
|
2732
995
|
var _fieldOptions$find;
|
|
2733
996
|
return typeof x === "object" ? x : (_fieldOptions$find = fieldOptions == null ? void 0 : fieldOptions.find(function (y) {
|
|
@@ -2740,38 +1003,43 @@ function defaultDataProps(_ref9) {
|
|
|
2740
1003
|
return x != null;
|
|
2741
1004
|
}) : fieldOptions,
|
|
2742
1005
|
readonly: !!formOptions.readonly,
|
|
2743
|
-
displayOnly: displayOnly,
|
|
2744
|
-
renderOptions: (_definition$
|
|
1006
|
+
displayOnly: !!displayOnly,
|
|
1007
|
+
renderOptions: (_definition$renderOpt = definition.renderOptions) != null ? _definition$renderOpt : {
|
|
2745
1008
|
type: "Standard"
|
|
2746
1009
|
},
|
|
2747
1010
|
required: required,
|
|
2748
1011
|
hidden: !!formOptions.hidden,
|
|
2749
1012
|
className: className,
|
|
1013
|
+
textClass: textClass,
|
|
2750
1014
|
style: style
|
|
2751
1015
|
}, props);
|
|
2752
1016
|
}
|
|
2753
1017
|
function renderControlLayout(props) {
|
|
2754
|
-
var
|
|
2755
|
-
renderer = props.renderer,
|
|
1018
|
+
var renderer = props.renderer,
|
|
2756
1019
|
renderChild = props.renderChild,
|
|
2757
1020
|
control = props.control,
|
|
2758
1021
|
dataContext = props.dataContext,
|
|
2759
1022
|
dataProps = props.createDataProps,
|
|
2760
|
-
displayControl = props.displayControl,
|
|
2761
1023
|
style = props.style,
|
|
2762
|
-
labelText = props.labelText,
|
|
2763
|
-
useChildVisibility = props.useChildVisibility,
|
|
2764
1024
|
designMode = props.designMode,
|
|
2765
1025
|
customDisplay = props.customDisplay,
|
|
2766
|
-
|
|
1026
|
+
runExpression = props.runExpression,
|
|
2767
1027
|
labelClass = props.labelClass,
|
|
1028
|
+
labelTextClass = props.labelTextClass,
|
|
2768
1029
|
styleClass = props.styleClass,
|
|
2769
|
-
|
|
2770
|
-
|
|
1030
|
+
textClass = props.textClass,
|
|
1031
|
+
formNode = props.formNode,
|
|
1032
|
+
actionOnClick = props.actionOnClick,
|
|
1033
|
+
state = props.state,
|
|
1034
|
+
getChildState = props.getChildState,
|
|
1035
|
+
inline = props.inline,
|
|
1036
|
+
displayOnly = props.displayOnly;
|
|
1037
|
+
var c = state.definition;
|
|
1038
|
+
if (formsCore.isDataControl(c)) {
|
|
2771
1039
|
return renderData(c);
|
|
2772
1040
|
}
|
|
2773
|
-
if (isGroupControl(c)) {
|
|
2774
|
-
var _c$groupOptions2,
|
|
1041
|
+
if (formsCore.isGroupControl(c)) {
|
|
1042
|
+
var _c$groupOptions2, _c$groupOptions3;
|
|
2775
1043
|
if (c.compoundField) {
|
|
2776
1044
|
var _c$groupOptions;
|
|
2777
1045
|
return renderData(dataControl(c.compoundField, c.title, {
|
|
@@ -2780,78 +1048,110 @@ function renderControlLayout(props) {
|
|
|
2780
1048
|
}));
|
|
2781
1049
|
}
|
|
2782
1050
|
return {
|
|
1051
|
+
inline: inline,
|
|
2783
1052
|
processLayout: renderer.renderGroup({
|
|
2784
1053
|
formNode: formNode,
|
|
1054
|
+
state: state,
|
|
2785
1055
|
definition: c,
|
|
2786
1056
|
renderChild: renderChild,
|
|
2787
|
-
|
|
1057
|
+
runExpression: runExpression,
|
|
2788
1058
|
dataContext: dataContext,
|
|
2789
1059
|
renderOptions: (_c$groupOptions2 = c.groupOptions) != null ? _c$groupOptions2 : {
|
|
2790
1060
|
type: "Standard"
|
|
2791
1061
|
},
|
|
2792
1062
|
className: rendererClass(styleClass, c.styleClass),
|
|
2793
|
-
|
|
1063
|
+
textClass: rendererClass(textClass, c.textClass),
|
|
2794
1064
|
style: style,
|
|
2795
|
-
designMode: designMode
|
|
1065
|
+
designMode: designMode,
|
|
1066
|
+
actionOnClick: actionOnClick,
|
|
1067
|
+
getChildState: getChildState
|
|
2796
1068
|
}),
|
|
2797
1069
|
label: {
|
|
2798
|
-
label:
|
|
1070
|
+
label: c.title,
|
|
2799
1071
|
className: rendererClass(labelClass, c.labelClass),
|
|
1072
|
+
textClass: rendererClass(labelTextClass, c.labelTextClass),
|
|
2800
1073
|
type: exports.LabelType.Group,
|
|
2801
1074
|
hide: (_c$groupOptions3 = c.groupOptions) == null ? void 0 : _c$groupOptions3.hideTitle
|
|
2802
1075
|
}
|
|
2803
1076
|
};
|
|
2804
1077
|
}
|
|
2805
|
-
if (isActionControl(c)) {
|
|
2806
|
-
var
|
|
2807
|
-
var
|
|
1078
|
+
if (formsCore.isActionControl(c)) {
|
|
1079
|
+
var _c$actionStyle, _c$title, _props$actionOnClick;
|
|
1080
|
+
var renderActionGroup = function renderActionGroup() {
|
|
1081
|
+
var childDefs = formNode.getResolvedChildren();
|
|
1082
|
+
var childDef = {
|
|
1083
|
+
type: formsCore.ControlDefinitionType.Group,
|
|
1084
|
+
groupOptions: {
|
|
1085
|
+
type: formsCore.GroupRenderType.Contents,
|
|
1086
|
+
hideTitle: true
|
|
1087
|
+
},
|
|
1088
|
+
children: childDefs
|
|
1089
|
+
};
|
|
1090
|
+
var childNode = formNode.createChildNode("child", childDef);
|
|
1091
|
+
return renderChild("child", childNode, {});
|
|
1092
|
+
};
|
|
1093
|
+
var actionData = c.actionData;
|
|
1094
|
+
var actionStyle = (_c$actionStyle = c.actionStyle) != null ? _c$actionStyle : formsCore.ActionStyle.Button;
|
|
1095
|
+
var actionContent = actionStyle == formsCore.ActionStyle.Group ? renderActionGroup() : undefined;
|
|
2808
1096
|
return {
|
|
1097
|
+
inline: inline,
|
|
2809
1098
|
children: renderer.renderAction({
|
|
2810
|
-
actionText: (
|
|
1099
|
+
actionText: (_c$title = c.title) != null ? _c$title : c.actionId,
|
|
2811
1100
|
actionId: c.actionId,
|
|
2812
1101
|
actionData: actionData,
|
|
1102
|
+
actionContent: actionContent,
|
|
1103
|
+
actionStyle: actionStyle,
|
|
1104
|
+
textClass: rendererClass(textClass, c.textClass),
|
|
1105
|
+
iconPlacement: c.iconPlacement,
|
|
1106
|
+
icon: c.icon,
|
|
1107
|
+
inline: inline,
|
|
2813
1108
|
onClick: (_props$actionOnClick = props.actionOnClick == null ? void 0 : props.actionOnClick(c.actionId, actionData, dataContext)) != null ? _props$actionOnClick : function () {},
|
|
2814
1109
|
className: rendererClass(styleClass, c.styleClass),
|
|
2815
1110
|
style: style
|
|
2816
1111
|
})
|
|
2817
1112
|
};
|
|
2818
1113
|
}
|
|
2819
|
-
if (isDisplayControl(c)) {
|
|
1114
|
+
if (formsCore.isDisplayControl(c)) {
|
|
2820
1115
|
var _c$displayData;
|
|
2821
1116
|
var data = (_c$displayData = c.displayData) != null ? _c$displayData : {};
|
|
2822
1117
|
var displayProps = {
|
|
2823
1118
|
data: data,
|
|
2824
1119
|
className: rendererClass(styleClass, c.styleClass),
|
|
1120
|
+
textClass: rendererClass(textClass, c.textClass),
|
|
2825
1121
|
style: style,
|
|
2826
|
-
|
|
2827
|
-
|
|
1122
|
+
dataContext: dataContext,
|
|
1123
|
+
inline: inline
|
|
2828
1124
|
};
|
|
2829
|
-
if (data.type ===
|
|
1125
|
+
if (data.type === formsCore.DisplayDataType.Custom && customDisplay) {
|
|
2830
1126
|
return {
|
|
1127
|
+
inline: inline,
|
|
2831
1128
|
children: customDisplay(data.customId, displayProps)
|
|
2832
1129
|
};
|
|
2833
1130
|
}
|
|
2834
1131
|
return {
|
|
1132
|
+
inline: inline,
|
|
2835
1133
|
children: renderer.renderDisplay(displayProps)
|
|
2836
1134
|
};
|
|
2837
1135
|
}
|
|
2838
1136
|
return {};
|
|
2839
1137
|
function renderData(c) {
|
|
2840
|
-
var
|
|
1138
|
+
var _c$children$length, _c$children;
|
|
2841
1139
|
if (!control) return {
|
|
2842
1140
|
children: "No control for: " + c.field
|
|
2843
1141
|
};
|
|
2844
|
-
var rendererProps = dataProps(props);
|
|
2845
|
-
var label = !c.hideTitle ? controlTitle(
|
|
1142
|
+
var rendererProps = dataProps(props, c, control);
|
|
1143
|
+
var label = !c.hideTitle ? controlTitle(c.title, props.dataContext.dataNode.schema.field) : undefined;
|
|
2846
1144
|
return {
|
|
1145
|
+
inline: inline,
|
|
2847
1146
|
processLayout: renderer.renderData(rendererProps),
|
|
2848
1147
|
label: {
|
|
2849
1148
|
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,
|
|
2850
1149
|
label: label,
|
|
2851
1150
|
forId: rendererProps.id,
|
|
2852
|
-
required: c.required && !
|
|
1151
|
+
required: c.required && !displayOnly,
|
|
2853
1152
|
hide: c.hideTitle,
|
|
2854
|
-
className: rendererClass(labelClass, c.labelClass)
|
|
1153
|
+
className: rendererClass(labelClass, c.labelClass),
|
|
1154
|
+
textClass: rendererClass(labelTextClass, c.labelTextClass)
|
|
2855
1155
|
},
|
|
2856
1156
|
errorControl: control
|
|
2857
1157
|
};
|
|
@@ -2871,13 +1171,13 @@ function wrapMarkup(k, wrap) {
|
|
|
2871
1171
|
}
|
|
2872
1172
|
function layoutKeyForPlacement(pos) {
|
|
2873
1173
|
switch (pos) {
|
|
2874
|
-
case
|
|
1174
|
+
case formsCore.AdornmentPlacement.ControlEnd:
|
|
2875
1175
|
return "controlEnd";
|
|
2876
|
-
case
|
|
1176
|
+
case formsCore.AdornmentPlacement.ControlStart:
|
|
2877
1177
|
return "controlStart";
|
|
2878
|
-
case
|
|
1178
|
+
case formsCore.AdornmentPlacement.LabelStart:
|
|
2879
1179
|
return "labelStart";
|
|
2880
|
-
case
|
|
1180
|
+
case formsCore.AdornmentPlacement.LabelEnd:
|
|
2881
1181
|
return "labelEnd";
|
|
2882
1182
|
}
|
|
2883
1183
|
}
|
|
@@ -2897,18 +1197,20 @@ function wrapMarkupAt(pos, wrap) {
|
|
|
2897
1197
|
}
|
|
2898
1198
|
function renderLayoutParts(props, renderer) {
|
|
2899
1199
|
var _props$processLayout;
|
|
2900
|
-
var
|
|
2901
|
-
className =
|
|
2902
|
-
children =
|
|
2903
|
-
style =
|
|
2904
|
-
errorControl =
|
|
2905
|
-
label =
|
|
2906
|
-
adornments =
|
|
1200
|
+
var _ref2 = (_props$processLayout = props.processLayout == null ? void 0 : props.processLayout(props)) != null ? _props$processLayout : props,
|
|
1201
|
+
className = _ref2.className,
|
|
1202
|
+
children = _ref2.children,
|
|
1203
|
+
style = _ref2.style,
|
|
1204
|
+
errorControl = _ref2.errorControl,
|
|
1205
|
+
label = _ref2.label,
|
|
1206
|
+
adornments = _ref2.adornments,
|
|
1207
|
+
inline = _ref2.inline;
|
|
2907
1208
|
var layout = {
|
|
2908
1209
|
children: children,
|
|
2909
1210
|
errorControl: errorControl,
|
|
2910
1211
|
style: style,
|
|
2911
1212
|
className: className,
|
|
1213
|
+
inline: inline,
|
|
2912
1214
|
wrapLayout: function wrapLayout(x) {
|
|
2913
1215
|
return x;
|
|
2914
1216
|
}
|
|
@@ -2927,7 +1229,7 @@ function controlTitle(title, field) {
|
|
|
2927
1229
|
function getLengthRestrictions(definition) {
|
|
2928
1230
|
var _definition$validator;
|
|
2929
1231
|
var lengthVal = (_definition$validator = definition.validators) == null ? void 0 : _definition$validator.find(function (x) {
|
|
2930
|
-
return x.type ===
|
|
1232
|
+
return x.type === formsCore.ValidatorType.Length;
|
|
2931
1233
|
});
|
|
2932
1234
|
return {
|
|
2933
1235
|
min: lengthVal == null ? void 0 : lengthVal.min,
|
|
@@ -2937,19 +1239,19 @@ function getLengthRestrictions(definition) {
|
|
|
2937
1239
|
function createArrayActions(control, field, options) {
|
|
2938
1240
|
var _field$displayName;
|
|
2939
1241
|
var noun = (_field$displayName = field.displayName) != null ? _field$displayName : field.field;
|
|
2940
|
-
var
|
|
2941
|
-
addText =
|
|
2942
|
-
noAdd =
|
|
2943
|
-
removeText =
|
|
2944
|
-
noRemove =
|
|
2945
|
-
removeActionId =
|
|
2946
|
-
addActionId =
|
|
2947
|
-
editActionId =
|
|
2948
|
-
editText =
|
|
2949
|
-
disabled =
|
|
2950
|
-
readonly =
|
|
2951
|
-
designMode =
|
|
2952
|
-
editExternal =
|
|
1242
|
+
var _ref3 = options != null ? options : {},
|
|
1243
|
+
addText = _ref3.addText,
|
|
1244
|
+
noAdd = _ref3.noAdd,
|
|
1245
|
+
removeText = _ref3.removeText,
|
|
1246
|
+
noRemove = _ref3.noRemove,
|
|
1247
|
+
removeActionId = _ref3.removeActionId,
|
|
1248
|
+
addActionId = _ref3.addActionId,
|
|
1249
|
+
editActionId = _ref3.editActionId,
|
|
1250
|
+
editText = _ref3.editText,
|
|
1251
|
+
disabled = _ref3.disabled,
|
|
1252
|
+
readonly = _ref3.readonly,
|
|
1253
|
+
designMode = _ref3.designMode,
|
|
1254
|
+
editExternal = _ref3.editExternal;
|
|
2953
1255
|
return {
|
|
2954
1256
|
arrayControl: control,
|
|
2955
1257
|
addAction: !readonly && !noAdd ? makeAdd(function () {
|
|
@@ -3025,15 +1327,15 @@ function createArrayActions(control, field, options) {
|
|
|
3025
1327
|
};
|
|
3026
1328
|
}
|
|
3027
1329
|
}
|
|
3028
|
-
function applyArrayLengthRestrictions(
|
|
1330
|
+
function applyArrayLengthRestrictions(_ref4, disable) {
|
|
3029
1331
|
var _arrayControl$element, _arrayControl$element2;
|
|
3030
|
-
var arrayControl =
|
|
3031
|
-
min =
|
|
3032
|
-
max =
|
|
3033
|
-
editAction =
|
|
3034
|
-
aa =
|
|
3035
|
-
ra =
|
|
3036
|
-
required =
|
|
1332
|
+
var arrayControl = _ref4.arrayControl,
|
|
1333
|
+
min = _ref4.min,
|
|
1334
|
+
max = _ref4.max,
|
|
1335
|
+
editAction = _ref4.editAction,
|
|
1336
|
+
aa = _ref4.addAction,
|
|
1337
|
+
ra = _ref4.removeAction,
|
|
1338
|
+
required = _ref4.required;
|
|
3037
1339
|
var _applyLengthRestricti = applyLengthRestrictions((_arrayControl$element = (_arrayControl$element2 = arrayControl.elements) == null ? void 0 : _arrayControl$element2.length) != null ? _arrayControl$element : 0, min == null && required ? 1 : min, max, true, true),
|
|
3038
1340
|
removeAllowed = _applyLengthRestricti[0],
|
|
3039
1341
|
addAllowed = _applyLengthRestricti[1];
|
|
@@ -3046,33 +1348,45 @@ function applyArrayLengthRestrictions(_ref13, disable) {
|
|
|
3046
1348
|
};
|
|
3047
1349
|
}
|
|
3048
1350
|
function fieldOptionAdornment(p) {
|
|
3049
|
-
return function (o,
|
|
1351
|
+
return function (o, fieldIndex, selected) {
|
|
3050
1352
|
return /*#__PURE__*/jsxRuntime.jsx(core.RenderArrayElements, {
|
|
3051
1353
|
array: p.formNode.getChildNodes(),
|
|
3052
1354
|
children: function children(cd, i) {
|
|
3053
1355
|
return p.renderChild(i, cd, {
|
|
3054
1356
|
parentDataNode: p.dataContext.parentNode,
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
1357
|
+
stateKey: fieldIndex.toString(),
|
|
1358
|
+
variables: {
|
|
1359
|
+
formData: {
|
|
1360
|
+
option: o,
|
|
1361
|
+
optionSelected: selected
|
|
1362
|
+
}
|
|
3058
1363
|
}
|
|
3059
1364
|
});
|
|
3060
1365
|
}
|
|
3061
1366
|
});
|
|
3062
1367
|
};
|
|
3063
1368
|
}
|
|
1369
|
+
function lookupChildDataContext(dataContext, c) {
|
|
1370
|
+
var _dataContext$dataNode;
|
|
1371
|
+
var parentNode = (_dataContext$dataNode = dataContext.dataNode) != null ? _dataContext$dataNode : dataContext.parentNode;
|
|
1372
|
+
var dataNode = formsCore.lookupDataNode(c, parentNode);
|
|
1373
|
+
return _extends({}, dataContext, {
|
|
1374
|
+
parentNode: parentNode,
|
|
1375
|
+
dataNode: dataNode
|
|
1376
|
+
});
|
|
1377
|
+
}
|
|
3064
1378
|
|
|
3065
1379
|
function isIconAdornment(a) {
|
|
3066
|
-
return a.type ===
|
|
1380
|
+
return a.type === formsCore.ControlAdornmentType.Icon;
|
|
3067
1381
|
}
|
|
3068
1382
|
function isAccordionAdornment(a) {
|
|
3069
|
-
return a.type ===
|
|
1383
|
+
return a.type === formsCore.ControlAdornmentType.Accordion;
|
|
3070
1384
|
}
|
|
3071
1385
|
function isSetFieldAdornment(a) {
|
|
3072
|
-
return a.type ===
|
|
1386
|
+
return a.type === formsCore.ControlAdornmentType.SetField;
|
|
3073
1387
|
}
|
|
3074
1388
|
function isOptionalAdornment(a) {
|
|
3075
|
-
return a.type ===
|
|
1389
|
+
return a.type === formsCore.ControlAdornmentType.Optional;
|
|
3076
1390
|
}
|
|
3077
1391
|
function createLayoutRenderer(render, options) {
|
|
3078
1392
|
return _extends({
|
|
@@ -3157,7 +1471,6 @@ function createFormRenderer(customRenderers, defaultRenderers) {
|
|
|
3157
1471
|
renderLayout: renderLayout,
|
|
3158
1472
|
renderVisibility: renderVisibility,
|
|
3159
1473
|
renderLabelText: renderLabelText,
|
|
3160
|
-
renderText: defaultRenderers.renderText,
|
|
3161
1474
|
html: defaultRenderers.html
|
|
3162
1475
|
};
|
|
3163
1476
|
function renderVisibility(props) {
|
|
@@ -3211,8 +1524,8 @@ function createFormRenderer(customRenderers, defaultRenderers) {
|
|
|
3211
1524
|
var _x$collection, _field$collection, _x$options;
|
|
3212
1525
|
var noMatch = x.match ? !x.match(props, renderOptions) : undefined;
|
|
3213
1526
|
if (noMatch === true) return false;
|
|
3214
|
-
var matchCollection = ((_x$collection = x.collection) != null ? _x$collection : false) === (props.elementIndex == null && ((_field$collection = field.collection) != null ? _field$collection : false));
|
|
3215
|
-
var isSchemaAllowed = !!x.schemaType && renderType ==
|
|
1527
|
+
var matchCollection = ((_x$collection = x.collection) != null ? _x$collection : false) === (props.dataNode.elementIndex == null && ((_field$collection = field.collection) != null ? _field$collection : false));
|
|
1528
|
+
var isSchemaAllowed = !!x.schemaType && renderType == formsCore.DataRenderType.Standard ? isOneOf(x.schemaType, field.type) : undefined;
|
|
3216
1529
|
var isRendererAllowed = !!x.renderType && isOneOf(x.renderType, renderType);
|
|
3217
1530
|
return matchCollection && ((_x$options = x.options) != null ? _x$options : false) === options && (isSchemaAllowed || isRendererAllowed || !x.renderType && !x.schemaType && noMatch === false);
|
|
3218
1531
|
}
|
|
@@ -3279,19 +1592,236 @@ function isArrayRegistration(x) {
|
|
|
3279
1592
|
return x.type === "array";
|
|
3280
1593
|
}
|
|
3281
1594
|
|
|
1595
|
+
var _excluded = ["styleClass", "labelClass", "layoutClass", "labelTextClass", "textClass"],
|
|
1596
|
+
_excluded2 = ["parentDataNode", "actionOnClick", "variables"];
|
|
1597
|
+
function RenderForm(_ref) {
|
|
1598
|
+
var _effect = core.useComponentTracking();
|
|
1599
|
+
try {
|
|
1600
|
+
var _options$schemaInterf, _definition$adornment, _definition$adornment2, _dataContext$dataNode, _options$adjustLayout;
|
|
1601
|
+
var data = _ref.data,
|
|
1602
|
+
form = _ref.form,
|
|
1603
|
+
renderer = _ref.renderer,
|
|
1604
|
+
_ref$options = _ref.options,
|
|
1605
|
+
options = _ref$options === void 0 ? {} : _ref$options;
|
|
1606
|
+
var schemaInterface = (_options$schemaInterf = options.schemaInterface) != null ? _options$schemaInterf : formsCore.defaultSchemaInterface;
|
|
1607
|
+
var _useState = react.useState(function () {
|
|
1608
|
+
var _options$formState;
|
|
1609
|
+
return (_options$formState = options == null ? void 0 : options.formState) != null ? _options$formState : formsCore.createFormState(schemaInterface);
|
|
1610
|
+
}),
|
|
1611
|
+
formState = _useState[0],
|
|
1612
|
+
setFormState = _useState[1];
|
|
1613
|
+
var state = formState.getControlState(data, form, options);
|
|
1614
|
+
react.useEffect(function () {
|
|
1615
|
+
if (!(options != null && options.formState)) {
|
|
1616
|
+
return function () {
|
|
1617
|
+
return formState.cleanup();
|
|
1618
|
+
};
|
|
1619
|
+
}
|
|
1620
|
+
}, [formState, options == null ? void 0 : options.formState]);
|
|
1621
|
+
var definition = state.definition;
|
|
1622
|
+
var visible = !state.hidden;
|
|
1623
|
+
var visibility = core.useControl(function () {
|
|
1624
|
+
return visible != null ? {
|
|
1625
|
+
visible: visible,
|
|
1626
|
+
showing: visible
|
|
1627
|
+
} : undefined;
|
|
1628
|
+
});
|
|
1629
|
+
visibility.fields.visible.value = visible;
|
|
1630
|
+
var dataContext = {
|
|
1631
|
+
schemaInterface: state.schemaInterface,
|
|
1632
|
+
dataNode: state.dataNode,
|
|
1633
|
+
parentNode: data,
|
|
1634
|
+
variables: state.variables
|
|
1635
|
+
};
|
|
1636
|
+
var adornments = (_definition$adornment = (_definition$adornment2 = definition.adornments) == null ? void 0 : _definition$adornment2.map(function (x) {
|
|
1637
|
+
return renderer.renderAdornment({
|
|
1638
|
+
adornment: x,
|
|
1639
|
+
dataContext: dataContext,
|
|
1640
|
+
formOptions: state
|
|
1641
|
+
});
|
|
1642
|
+
})) != null ? _definition$adornment : [];
|
|
1643
|
+
var styleClass = options.styleClass,
|
|
1644
|
+
labelClass = options.labelClass,
|
|
1645
|
+
layoutClass = options.layoutClass,
|
|
1646
|
+
labelTextClass = options.labelTextClass,
|
|
1647
|
+
textClass = options.textClass,
|
|
1648
|
+
inheritableOptions = _objectWithoutPropertiesLoose(options, _excluded);
|
|
1649
|
+
var readonly = state.readonly,
|
|
1650
|
+
hidden = state.hidden,
|
|
1651
|
+
disabled = state.disabled,
|
|
1652
|
+
variables = state.variables;
|
|
1653
|
+
var childOptions = _extends({}, inheritableOptions, {
|
|
1654
|
+
readonly: readonly,
|
|
1655
|
+
disabled: disabled,
|
|
1656
|
+
variables: variables,
|
|
1657
|
+
formState: formState
|
|
1658
|
+
});
|
|
1659
|
+
var labelAndChildren = renderControlLayout({
|
|
1660
|
+
formNode: form,
|
|
1661
|
+
renderer: renderer,
|
|
1662
|
+
state: state,
|
|
1663
|
+
renderChild: function renderChild(k, child, options) {
|
|
1664
|
+
var _ref3;
|
|
1665
|
+
var overrideClasses = getGroupClassOverrides(definition);
|
|
1666
|
+
var _ref2 = options != null ? options : {},
|
|
1667
|
+
parentDataNode = _ref2.parentDataNode,
|
|
1668
|
+
actionOnClick = _ref2.actionOnClick,
|
|
1669
|
+
variables = _ref2.variables,
|
|
1670
|
+
renderOptions = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
1671
|
+
var dContext = (_ref3 = parentDataNode != null ? parentDataNode : dataContext.dataNode) != null ? _ref3 : data;
|
|
1672
|
+
var allChildOptions = _extends({}, childOptions, overrideClasses, renderOptions, {
|
|
1673
|
+
variables: _extends({}, childOptions.variables, variables),
|
|
1674
|
+
actionOnClick: actionHandlers(actionOnClick, childOptions.actionOnClick)
|
|
1675
|
+
});
|
|
1676
|
+
return /*#__PURE__*/jsxRuntime.jsx(RenderForm, {
|
|
1677
|
+
form: child,
|
|
1678
|
+
renderer: renderer,
|
|
1679
|
+
data: dContext,
|
|
1680
|
+
options: allChildOptions
|
|
1681
|
+
}, k);
|
|
1682
|
+
},
|
|
1683
|
+
inline: options == null ? void 0 : options.inline,
|
|
1684
|
+
displayOnly: options == null ? void 0 : options.displayOnly,
|
|
1685
|
+
createDataProps: defaultDataProps,
|
|
1686
|
+
formOptions: state,
|
|
1687
|
+
dataContext: dataContext,
|
|
1688
|
+
control: (_dataContext$dataNode = dataContext.dataNode) == null ? void 0 : _dataContext$dataNode.control,
|
|
1689
|
+
schemaInterface: schemaInterface,
|
|
1690
|
+
style: state.style,
|
|
1691
|
+
allowedOptions: state.allowedOptions,
|
|
1692
|
+
customDisplay: options.customDisplay,
|
|
1693
|
+
actionOnClick: options.actionOnClick,
|
|
1694
|
+
styleClass: styleClass,
|
|
1695
|
+
labelClass: labelClass,
|
|
1696
|
+
labelTextClass: labelTextClass,
|
|
1697
|
+
textClass: textClass,
|
|
1698
|
+
getChildState: function getChildState(child, parent) {
|
|
1699
|
+
var _ref4;
|
|
1700
|
+
return formState.getControlState((_ref4 = parent != null ? parent : state.dataNode) != null ? _ref4 : data, child, childOptions);
|
|
1701
|
+
},
|
|
1702
|
+
runExpression: function runExpression(scope, expr, returnResult) {
|
|
1703
|
+
if (expr != null && expr.type) {
|
|
1704
|
+
formState.evalExpression(expr, {
|
|
1705
|
+
scope: scope,
|
|
1706
|
+
dataNode: data,
|
|
1707
|
+
schemaInterface: schemaInterface,
|
|
1708
|
+
returnResult: returnResult
|
|
1709
|
+
});
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
});
|
|
1713
|
+
var layoutProps = _extends({}, labelAndChildren, {
|
|
1714
|
+
adornments: adornments,
|
|
1715
|
+
className: rendererClass(options.layoutClass, definition.layoutClass),
|
|
1716
|
+
style: state.layoutStyle
|
|
1717
|
+
});
|
|
1718
|
+
var renderedControl = renderer.renderLayout((_options$adjustLayout = options.adjustLayout == null ? void 0 : options.adjustLayout(dataContext, layoutProps)) != null ? _options$adjustLayout : layoutProps);
|
|
1719
|
+
return renderer.renderVisibility(_extends({
|
|
1720
|
+
visibility: visibility
|
|
1721
|
+
}, renderedControl));
|
|
1722
|
+
} finally {
|
|
1723
|
+
_effect();
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
/**
|
|
1727
|
+
* @deprecated Use RenderForm instead.
|
|
1728
|
+
*/
|
|
1729
|
+
function useControlRendererComponent(controlOrFormNode, renderer, options, parentDataNode) {
|
|
1730
|
+
if (options === void 0) {
|
|
1731
|
+
options = {};
|
|
1732
|
+
}
|
|
1733
|
+
var _ref5 = "definition" in controlOrFormNode ? [controlOrFormNode.definition, controlOrFormNode] : [controlOrFormNode, formsCore.legacyFormNode(controlOrFormNode)],
|
|
1734
|
+
formNode = _ref5[1];
|
|
1735
|
+
var r = useUpdatedRef({
|
|
1736
|
+
options: options,
|
|
1737
|
+
renderer: renderer,
|
|
1738
|
+
parentDataNode: parentDataNode,
|
|
1739
|
+
formNode: formNode
|
|
1740
|
+
});
|
|
1741
|
+
return react.useMemo(function () {
|
|
1742
|
+
return function () {
|
|
1743
|
+
var _r$current = r.current,
|
|
1744
|
+
options = _r$current.options,
|
|
1745
|
+
parentDataNode = _r$current.parentDataNode,
|
|
1746
|
+
formNode = _r$current.formNode,
|
|
1747
|
+
renderer = _r$current.renderer;
|
|
1748
|
+
return /*#__PURE__*/jsxRuntime.jsx(RenderForm, {
|
|
1749
|
+
data: parentDataNode,
|
|
1750
|
+
form: formNode,
|
|
1751
|
+
renderer: renderer,
|
|
1752
|
+
options: options
|
|
1753
|
+
});
|
|
1754
|
+
};
|
|
1755
|
+
}, [r]);
|
|
1756
|
+
}
|
|
1757
|
+
/**
|
|
1758
|
+
* @deprecated Use RenderForm instead.
|
|
1759
|
+
*/
|
|
1760
|
+
function ControlRenderer(_ref6) {
|
|
1761
|
+
var _effect2 = core.useComponentTracking();
|
|
1762
|
+
try {
|
|
1763
|
+
var definition = _ref6.definition,
|
|
1764
|
+
fields = _ref6.fields,
|
|
1765
|
+
renderer = _ref6.renderer,
|
|
1766
|
+
options = _ref6.options,
|
|
1767
|
+
control = _ref6.control,
|
|
1768
|
+
parentPath = _ref6.parentPath;
|
|
1769
|
+
var schemaDataNode = formsCore.createSchemaDataNode(formsCore.createSchemaTree(fields).rootNode, control);
|
|
1770
|
+
var Render = useControlRendererComponent(definition, renderer, options, schemaDataNode);
|
|
1771
|
+
return /*#__PURE__*/jsxRuntime.jsx(Render, {});
|
|
1772
|
+
} finally {
|
|
1773
|
+
_effect2();
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
/**
|
|
1777
|
+
* @deprecated Use RenderForm instead.
|
|
1778
|
+
*/
|
|
1779
|
+
function NewControlRenderer(_ref7) {
|
|
1780
|
+
var _effect3 = core.useComponentTracking();
|
|
1781
|
+
try {
|
|
1782
|
+
var definition = _ref7.definition,
|
|
1783
|
+
renderer = _ref7.renderer,
|
|
1784
|
+
options = _ref7.options,
|
|
1785
|
+
parentDataNode = _ref7.parentDataNode;
|
|
1786
|
+
var Render = useControlRendererComponent(definition, renderer, options, parentDataNode);
|
|
1787
|
+
return /*#__PURE__*/jsxRuntime.jsx(Render, {});
|
|
1788
|
+
} finally {
|
|
1789
|
+
_effect3();
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
/**
|
|
1793
|
+
* @deprecated Use RenderForm instead.
|
|
1794
|
+
*/
|
|
1795
|
+
function useControlRenderer(definition, fields, renderer, options) {
|
|
1796
|
+
if (options === void 0) {
|
|
1797
|
+
options = {};
|
|
1798
|
+
}
|
|
1799
|
+
var r = useUpdatedRef({
|
|
1800
|
+
definition: definition,
|
|
1801
|
+
fields: fields,
|
|
1802
|
+
renderer: renderer,
|
|
1803
|
+
options: options
|
|
1804
|
+
});
|
|
1805
|
+
return react.useCallback(function (_ref8) {
|
|
1806
|
+
var control = _ref8.control,
|
|
1807
|
+
parentPath = _ref8.parentPath;
|
|
1808
|
+
return /*#__PURE__*/jsxRuntime.jsx(ControlRenderer, _extends({}, r.current, {
|
|
1809
|
+
control: control,
|
|
1810
|
+
parentPath: parentPath
|
|
1811
|
+
}));
|
|
1812
|
+
}, [r]);
|
|
1813
|
+
}
|
|
1814
|
+
|
|
3282
1815
|
exports.AppendAdornmentPriority = AppendAdornmentPriority;
|
|
3283
1816
|
exports.ControlRenderer = ControlRenderer;
|
|
3284
|
-
exports.DefaultSchemaInterface = DefaultSchemaInterface;
|
|
3285
|
-
exports.FormTree = FormTree;
|
|
3286
1817
|
exports.NewControlRenderer = NewControlRenderer;
|
|
1818
|
+
exports.RenderForm = RenderForm;
|
|
3287
1819
|
exports.WrapAdornmentPriority = WrapAdornmentPriority;
|
|
3288
1820
|
exports.accordionOptions = accordionOptions;
|
|
3289
1821
|
exports.actionControl = actionControl;
|
|
3290
1822
|
exports.actionHandlers = actionHandlers;
|
|
3291
|
-
exports.addFieldOption = addFieldOption;
|
|
3292
1823
|
exports.addMissingControls = addMissingControls;
|
|
3293
1824
|
exports.addMissingControlsForSchema = addMissingControlsForSchema;
|
|
3294
|
-
exports.addMissingControlsToForm = addMissingControlsToForm;
|
|
3295
1825
|
exports.adornmentOptions = adornmentOptions;
|
|
3296
1826
|
exports.appendMarkup = appendMarkup;
|
|
3297
1827
|
exports.appendMarkupAt = appendMarkupAt;
|
|
@@ -3303,14 +1833,12 @@ exports.applyExtensionsToSchema = applyExtensionsToSchema;
|
|
|
3303
1833
|
exports.applyLengthRestrictions = applyLengthRestrictions;
|
|
3304
1834
|
exports.applyValues = applyValues;
|
|
3305
1835
|
exports.autocompleteOptions = autocompleteOptions;
|
|
3306
|
-
exports.boolField = boolField;
|
|
3307
|
-
exports.buildSchema = buildSchema;
|
|
3308
1836
|
exports.checkListOptions = checkListOptions;
|
|
3309
1837
|
exports.cleanDataForSchema = cleanDataForSchema;
|
|
1838
|
+
exports.clearMultiValues = clearMultiValues;
|
|
3310
1839
|
exports.coerceToString = coerceToString;
|
|
3311
1840
|
exports.collectDifferences = collectDifferences;
|
|
3312
1841
|
exports.compoundControl = compoundControl;
|
|
3313
|
-
exports.compoundField = compoundField;
|
|
3314
1842
|
exports.controlTitle = controlTitle;
|
|
3315
1843
|
exports.createAction = createAction;
|
|
3316
1844
|
exports.createActionRenderer = createActionRenderer;
|
|
@@ -3319,30 +1847,19 @@ exports.createArrayActions = createArrayActions;
|
|
|
3319
1847
|
exports.createArrayRenderer = createArrayRenderer;
|
|
3320
1848
|
exports.createDataRenderer = createDataRenderer;
|
|
3321
1849
|
exports.createDisplayRenderer = createDisplayRenderer;
|
|
3322
|
-
exports.createFormLookup = createFormLookup;
|
|
3323
1850
|
exports.createFormRenderer = createFormRenderer;
|
|
3324
|
-
exports.createFormTree = createFormTree;
|
|
3325
1851
|
exports.createGroupRenderer = createGroupRenderer;
|
|
3326
1852
|
exports.createLabelRenderer = createLabelRenderer;
|
|
3327
1853
|
exports.createLayoutRenderer = createLayoutRenderer;
|
|
3328
|
-
exports.createSchemaLookup = createSchemaLookup;
|
|
3329
1854
|
exports.createVisibilityRenderer = createVisibilityRenderer;
|
|
3330
1855
|
exports.dataControl = dataControl;
|
|
3331
|
-
exports.dateField = dateField;
|
|
3332
|
-
exports.dateTimeField = dateTimeField;
|
|
3333
1856
|
exports.dateValidatorOptions = dateValidatorOptions;
|
|
3334
1857
|
exports.deepMerge = deepMerge;
|
|
3335
|
-
exports.defaultCompoundField = defaultCompoundField;
|
|
3336
1858
|
exports.defaultControlForField = defaultControlForField;
|
|
3337
1859
|
exports.defaultDataProps = defaultDataProps;
|
|
3338
|
-
exports.defaultEvalHooks = defaultEvalHooks;
|
|
3339
|
-
exports.defaultScalarField = defaultScalarField;
|
|
3340
|
-
exports.defaultSchemaInterface = defaultSchemaInterface;
|
|
3341
|
-
exports.defaultUseEvalExpressionHook = defaultUseEvalExpressionHook;
|
|
3342
1860
|
exports.defaultValueForField = defaultValueForField;
|
|
3343
1861
|
exports.defaultValueForFields = defaultValueForFields;
|
|
3344
1862
|
exports.displayOnlyOptions = displayOnlyOptions;
|
|
3345
|
-
exports.doubleField = doubleField;
|
|
3346
1863
|
exports.dynamicDefaultValue = dynamicDefaultValue;
|
|
3347
1864
|
exports.dynamicDisabled = dynamicDisabled;
|
|
3348
1865
|
exports.dynamicReadonly = dynamicReadonly;
|
|
@@ -3354,135 +1871,57 @@ exports.fieldEqExpr = fieldEqExpr;
|
|
|
3354
1871
|
exports.fieldExpr = fieldExpr;
|
|
3355
1872
|
exports.fieldHasTag = fieldHasTag;
|
|
3356
1873
|
exports.fieldOptionAdornment = fieldOptionAdornment;
|
|
3357
|
-
exports.fieldPathForDefinition = fieldPathForDefinition;
|
|
3358
1874
|
exports.findChildDefinition = findChildDefinition;
|
|
3359
1875
|
exports.findCompoundField = findCompoundField;
|
|
3360
1876
|
exports.findControlsForCompound = findControlsForCompound;
|
|
3361
|
-
exports.findField = findField;
|
|
3362
1877
|
exports.findFieldPath = findFieldPath;
|
|
3363
1878
|
exports.findNonDataGroups = findNonDataGroups;
|
|
3364
1879
|
exports.findScalarField = findScalarField;
|
|
3365
1880
|
exports.getAllReferencedClasses = getAllReferencedClasses;
|
|
3366
1881
|
exports.getAllValues = getAllValues;
|
|
3367
1882
|
exports.getDiffObject = getDiffObject;
|
|
3368
|
-
exports.getDisplayOnlyOptions = getDisplayOnlyOptions;
|
|
3369
1883
|
exports.getExternalEditData = getExternalEditData;
|
|
3370
1884
|
exports.getGroupClassOverrides = getGroupClassOverrides;
|
|
3371
|
-
exports.getGroupRendererOptions = getGroupRendererOptions;
|
|
3372
1885
|
exports.getIsEditing = getIsEditing;
|
|
3373
|
-
exports.getJsonPath = getJsonPath;
|
|
3374
1886
|
exports.getLastDefinedValue = getLastDefinedValue;
|
|
3375
1887
|
exports.getLengthRestrictions = getLengthRestrictions;
|
|
3376
1888
|
exports.getNullToggler = getNullToggler;
|
|
3377
1889
|
exports.getOverrideClass = getOverrideClass;
|
|
3378
|
-
exports.getRootDataNode = getRootDataNode;
|
|
3379
|
-
exports.getSchemaFieldList = getSchemaFieldList;
|
|
3380
|
-
exports.getSchemaNodePath = getSchemaNodePath;
|
|
3381
|
-
exports.getSchemaPath = getSchemaPath;
|
|
3382
|
-
exports.getTagParam = getTagParam;
|
|
3383
1890
|
exports.groupedControl = groupedControl;
|
|
3384
1891
|
exports.hasOptions = hasOptions;
|
|
3385
|
-
exports.hideDisplayOnly = hideDisplayOnly;
|
|
3386
1892
|
exports.htmlDisplayControl = htmlDisplayControl;
|
|
3387
|
-
exports.intField = intField;
|
|
3388
1893
|
exports.isAccordionAdornment = isAccordionAdornment;
|
|
3389
|
-
exports.isActionControl = isActionControl;
|
|
3390
|
-
exports.isArrayRenderer = isArrayRenderer;
|
|
3391
|
-
exports.isAutoCompleteClasses = isAutoCompleteClasses;
|
|
3392
|
-
exports.isAutocompleteRenderer = isAutocompleteRenderer;
|
|
3393
|
-
exports.isCheckEntryClasses = isCheckEntryClasses;
|
|
3394
|
-
exports.isCompoundField = isCompoundField;
|
|
3395
|
-
exports.isCompoundNode = isCompoundNode;
|
|
3396
|
-
exports.isControlDisabled = isControlDisabled;
|
|
3397
|
-
exports.isControlDisplayOnly = isControlDisplayOnly;
|
|
3398
|
-
exports.isControlReadonly = isControlReadonly;
|
|
3399
|
-
exports.isDataControl = isDataControl;
|
|
3400
|
-
exports.isDataGroupRenderer = isDataGroupRenderer;
|
|
3401
|
-
exports.isDateTimeRenderer = isDateTimeRenderer;
|
|
3402
|
-
exports.isDisplayControl = isDisplayControl;
|
|
3403
|
-
exports.isDisplayOnlyRenderer = isDisplayOnlyRenderer;
|
|
3404
|
-
exports.isFlexRenderer = isFlexRenderer;
|
|
3405
|
-
exports.isGridRenderer = isGridRenderer;
|
|
3406
|
-
exports.isGroupControl = isGroupControl;
|
|
3407
1894
|
exports.isIconAdornment = isIconAdornment;
|
|
3408
1895
|
exports.isOptionalAdornment = isOptionalAdornment;
|
|
3409
|
-
exports.isScalarField = isScalarField;
|
|
3410
|
-
exports.isSelectChildRenderer = isSelectChildRenderer;
|
|
3411
1896
|
exports.isSetFieldAdornment = isSetFieldAdornment;
|
|
3412
|
-
exports.isTabsRenderer = isTabsRenderer;
|
|
3413
|
-
exports.isTextfieldRenderer = isTextfieldRenderer;
|
|
3414
|
-
exports.jsonPathString = jsonPathString;
|
|
3415
1897
|
exports.jsonataExpr = jsonataExpr;
|
|
3416
1898
|
exports.jsonataOptions = jsonataOptions;
|
|
3417
1899
|
exports.jsonataValidatorOptions = jsonataValidatorOptions;
|
|
3418
1900
|
exports.layoutKeyForPlacement = layoutKeyForPlacement;
|
|
3419
|
-
exports.legacyFormNode = legacyFormNode;
|
|
3420
1901
|
exports.lengthValidatorOptions = lengthValidatorOptions;
|
|
3421
|
-
exports.
|
|
3422
|
-
exports.makeCompoundField = makeCompoundField;
|
|
3423
|
-
exports.makeEvalExpressionHook = makeEvalExpressionHook;
|
|
3424
|
-
exports.makeHook = makeHook;
|
|
3425
|
-
exports.makeHookDepString = makeHookDepString;
|
|
3426
|
-
exports.makeParamTag = makeParamTag;
|
|
3427
|
-
exports.makeScalarField = makeScalarField;
|
|
3428
|
-
exports.makeSchemaDataNode = makeSchemaDataNode;
|
|
3429
|
-
exports.matchesType = matchesType;
|
|
3430
|
-
exports.mergeField = mergeField;
|
|
3431
|
-
exports.mergeFields = mergeFields;
|
|
1902
|
+
exports.lookupChildDataContext = lookupChildDataContext;
|
|
3432
1903
|
exports.mergeObjects = mergeObjects;
|
|
3433
|
-
exports.optionalHook = optionalHook;
|
|
3434
1904
|
exports.radioButtonOptions = radioButtonOptions;
|
|
3435
|
-
exports.relativePath = relativePath;
|
|
3436
1905
|
exports.renderControlLayout = renderControlLayout;
|
|
3437
1906
|
exports.renderLayoutParts = renderLayoutParts;
|
|
3438
1907
|
exports.renderOptionsFor = renderOptionsFor;
|
|
3439
1908
|
exports.rendererClass = rendererClass;
|
|
3440
|
-
exports.resolveSchemas = resolveSchemas;
|
|
3441
|
-
exports.rootSchemaNode = rootSchemaNode;
|
|
3442
|
-
exports.schemaDataForFieldPath = schemaDataForFieldPath;
|
|
3443
|
-
exports.schemaDataForFieldRef = schemaDataForFieldRef;
|
|
3444
|
-
exports.schemaForFieldPath = schemaForFieldPath;
|
|
3445
|
-
exports.schemaForFieldRef = schemaForFieldRef;
|
|
3446
|
-
exports.stringField = stringField;
|
|
3447
|
-
exports.stringOptionsField = stringOptionsField;
|
|
3448
1909
|
exports.textDisplayControl = textDisplayControl;
|
|
3449
1910
|
exports.textfieldOptions = textfieldOptions;
|
|
3450
|
-
exports.timeField = timeField;
|
|
3451
|
-
exports.toDepString = toDepString;
|
|
3452
|
-
exports.traverseData = traverseData;
|
|
3453
|
-
exports.traverseParents = traverseParents;
|
|
3454
|
-
exports.traverseSchemaPath = traverseSchemaPath;
|
|
3455
1911
|
exports.useControlDefinitionForSchema = useControlDefinitionForSchema;
|
|
3456
1912
|
exports.useControlRenderer = useControlRenderer;
|
|
3457
1913
|
exports.useControlRendererComponent = useControlRendererComponent;
|
|
3458
|
-
exports.
|
|
3459
|
-
exports.useDynamicHooks = useDynamicHooks;
|
|
3460
|
-
exports.useEvalActionHook = useEvalActionHook;
|
|
3461
|
-
exports.useEvalAllowedOptionsHook = useEvalAllowedOptionsHook;
|
|
3462
|
-
exports.useEvalDefaultValueHook = useEvalDefaultValueHook;
|
|
3463
|
-
exports.useEvalDisabledHook = useEvalDisabledHook;
|
|
3464
|
-
exports.useEvalDisplayHook = useEvalDisplayHook;
|
|
3465
|
-
exports.useEvalDynamicBoolHook = useEvalDynamicBoolHook;
|
|
3466
|
-
exports.useEvalDynamicHook = useEvalDynamicHook;
|
|
3467
|
-
exports.useEvalLabelText = useEvalLabelText;
|
|
3468
|
-
exports.useEvalReadonlyHook = useEvalReadonlyHook;
|
|
3469
|
-
exports.useEvalStyleHook = useEvalStyleHook;
|
|
3470
|
-
exports.useEvalVisibilityHook = useEvalVisibilityHook;
|
|
3471
|
-
exports.useJsonataExpression = useJsonataExpression;
|
|
3472
|
-
exports.useJsonataValidator = useJsonataValidator;
|
|
3473
|
-
exports.useLengthValidator = useLengthValidator;
|
|
3474
|
-
exports.useMakeValidationHook = useMakeValidationHook;
|
|
1914
|
+
exports.useExpression = useExpression;
|
|
3475
1915
|
exports.useUpdatedRef = useUpdatedRef;
|
|
3476
|
-
exports.useUuidExpression = useUuidExpression;
|
|
3477
1916
|
exports.validationVisitor = validationVisitor;
|
|
3478
1917
|
exports.validatorOptions = validatorOptions;
|
|
3479
|
-
exports.visitControlData = visitControlData;
|
|
3480
|
-
exports.visitControlDataArray = visitControlDataArray;
|
|
3481
|
-
exports.visitControlDefinition = visitControlDefinition;
|
|
3482
|
-
exports.visitFormData = visitFormData;
|
|
3483
|
-
exports.visitFormDataInContext = visitFormDataInContext;
|
|
3484
|
-
exports.withScalarOptions = withScalarOptions;
|
|
3485
1918
|
exports.wrapLayout = wrapLayout;
|
|
3486
1919
|
exports.wrapMarkup = wrapMarkup;
|
|
3487
1920
|
exports.wrapMarkupAt = wrapMarkupAt;
|
|
1921
|
+
Object.keys(formsCore).forEach(function (k) {
|
|
1922
|
+
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
1923
|
+
enumerable: true,
|
|
1924
|
+
get: function () { return formsCore[k]; }
|
|
1925
|
+
});
|
|
1926
|
+
});
|
|
3488
1927
|
//# sourceMappingURL=index.cjs.map
|