@react-typed-forms/schemas 8.1.0 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/controlBuilder.d.ts +9 -2
- package/lib/controlRender.d.ts +12 -11
- package/lib/hooks.d.ts +8 -8
- package/lib/index.js +329 -219
- package/lib/index.js.map +1 -1
- package/lib/renderers.d.ts +1 -0
- package/lib/schemaBuilder.d.ts +5 -2
- package/lib/types.d.ts +9 -1
- package/lib/util.d.ts +13 -1
- package/package.json +2 -2
- package/.babelrc +0 -4
- package/.rush/temp/operation/build/state.json +0 -3
- package/.rush/temp/operation/update-readme/state.json +0 -3
- package/.rush/temp/package-deps_build.json +0 -13
- package/.rush/temp/shrinkwrap-deps.json +0 -612
- package/src/controlBuilder.ts +0 -175
- package/src/controlRender.tsx +0 -790
- package/src/hooks.tsx +0 -373
- package/src/index.ts +0 -10
- package/src/internal.ts +0 -48
- package/src/renderers.tsx +0 -996
- package/src/schemaBuilder.ts +0 -171
- package/src/schemaInterface.ts +0 -31
- package/src/tailwind.tsx +0 -29
- package/src/types.ts +0 -423
- package/src/util.ts +0 -445
- package/src/validators.ts +0 -116
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var React = require('react');
|
|
2
|
-
var clsx = require('clsx');
|
|
3
2
|
var core = require('@react-typed-forms/core');
|
|
3
|
+
var clsx = require('clsx');
|
|
4
4
|
var jsonata = require('jsonata');
|
|
5
5
|
|
|
6
6
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -77,6 +77,7 @@ exports.DataRenderType = void 0;
|
|
|
77
77
|
DataRenderType["Checkbox"] = "Checkbox";
|
|
78
78
|
DataRenderType["Dropdown"] = "Dropdown";
|
|
79
79
|
DataRenderType["DisplayOnly"] = "DisplayOnly";
|
|
80
|
+
DataRenderType["Group"] = "Group";
|
|
80
81
|
})(exports.DataRenderType || (exports.DataRenderType = {}));
|
|
81
82
|
exports.SyncTextType = void 0;
|
|
82
83
|
(function (SyncTextType) {
|
|
@@ -142,6 +143,9 @@ function isFlexRenderer(options) {
|
|
|
142
143
|
function isDisplayOnlyRenderer(options) {
|
|
143
144
|
return options.type === exports.DataRenderType.DisplayOnly;
|
|
144
145
|
}
|
|
146
|
+
function isDataGroupRenderer(options) {
|
|
147
|
+
return options.type === exports.DataRenderType.Group;
|
|
148
|
+
}
|
|
145
149
|
|
|
146
150
|
function _extends() {
|
|
147
151
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
@@ -201,96 +205,6 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
|
201
205
|
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
202
206
|
}
|
|
203
207
|
|
|
204
|
-
function buildSchema(def) {
|
|
205
|
-
return Object.entries(def).map(function (x) {
|
|
206
|
-
return x[1](x[0]);
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
function stringField(displayName, options) {
|
|
210
|
-
return makeScalarField(_extends({
|
|
211
|
-
type: exports.FieldType.String,
|
|
212
|
-
displayName: displayName
|
|
213
|
-
}, options));
|
|
214
|
-
}
|
|
215
|
-
function stringOptionsField(displayName) {
|
|
216
|
-
return makeScalarField({
|
|
217
|
-
type: exports.FieldType.String,
|
|
218
|
-
displayName: displayName,
|
|
219
|
-
options: [].slice.call(arguments, 1)
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
function withScalarOptions(options, v) {
|
|
223
|
-
return function (n) {
|
|
224
|
-
return _extends({}, v(n), options);
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
function makeScalarField(options) {
|
|
228
|
-
return function (n) {
|
|
229
|
-
return _extends({}, defaultScalarField(n, n), options);
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
function makeCompoundField(options) {
|
|
233
|
-
return function (n) {
|
|
234
|
-
return _extends({}, defaultCompoundField(n, n, false), options);
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
function intField(displayName, options) {
|
|
238
|
-
return makeScalarField(_extends({
|
|
239
|
-
type: exports.FieldType.Int,
|
|
240
|
-
displayName: displayName
|
|
241
|
-
}, options));
|
|
242
|
-
}
|
|
243
|
-
function boolField(displayName, options) {
|
|
244
|
-
return makeScalarField(_extends({
|
|
245
|
-
type: exports.FieldType.Bool,
|
|
246
|
-
displayName: displayName
|
|
247
|
-
}, options));
|
|
248
|
-
}
|
|
249
|
-
function compoundField(displayName, fields, other) {
|
|
250
|
-
return function (field) {
|
|
251
|
-
return _extends({}, defaultCompoundField(field, displayName, false), other, {
|
|
252
|
-
children: fields
|
|
253
|
-
});
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
function defaultScalarField(field, displayName) {
|
|
257
|
-
return {
|
|
258
|
-
field: field,
|
|
259
|
-
displayName: displayName,
|
|
260
|
-
type: exports.FieldType.String
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
function defaultCompoundField(field, displayName, collection) {
|
|
264
|
-
return {
|
|
265
|
-
field: field,
|
|
266
|
-
displayName: displayName,
|
|
267
|
-
type: exports.FieldType.Compound,
|
|
268
|
-
collection: collection,
|
|
269
|
-
children: []
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
function mergeField(field, mergeInto) {
|
|
273
|
-
var existing = mergeInto.find(function (x) {
|
|
274
|
-
return x.field === field.field;
|
|
275
|
-
});
|
|
276
|
-
if (existing) {
|
|
277
|
-
return mergeInto.map(function (x) {
|
|
278
|
-
return x !== existing ? x : _extends({}, x, {
|
|
279
|
-
onlyForTypes: mergeTypes(x.onlyForTypes, field.onlyForTypes)
|
|
280
|
-
});
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
return [].concat(mergeInto, [field]);
|
|
284
|
-
function mergeTypes(f, s) {
|
|
285
|
-
if (!f) return s;
|
|
286
|
-
if (!s) return f;
|
|
287
|
-
var extras = s.filter(function (x) {
|
|
288
|
-
return !f.includes(x);
|
|
289
|
-
});
|
|
290
|
-
return extras.length ? [].concat(f, extras) : f;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
|
|
294
208
|
function applyDefaultValues(v, fields) {
|
|
295
209
|
if (!v) return defaultValueForFields(fields);
|
|
296
210
|
var applyValue = fields.filter(function (x) {
|
|
@@ -516,7 +430,7 @@ function visitControlData(definition, ctx, cb) {
|
|
|
516
430
|
}
|
|
517
431
|
function lookupChildControl(data, child) {
|
|
518
432
|
var childPath = [].concat(data.path, [child]);
|
|
519
|
-
return data.data
|
|
433
|
+
return watchControlLookup(data.data, childPath);
|
|
520
434
|
}
|
|
521
435
|
function cleanDataForSchema(v, fields) {
|
|
522
436
|
if (!v) return v;
|
|
@@ -558,10 +472,12 @@ function cleanDataForSchema(v, fields) {
|
|
|
558
472
|
});
|
|
559
473
|
return out;
|
|
560
474
|
}
|
|
561
|
-
function getAllReferencedClasses(c) {
|
|
562
|
-
var _c$children;
|
|
563
|
-
var childClasses = (_c$children = c.children) == null ? void 0 : _c$children.flatMap(
|
|
564
|
-
|
|
475
|
+
function getAllReferencedClasses(c, collectExtra) {
|
|
476
|
+
var _c$children, _collectExtra;
|
|
477
|
+
var childClasses = (_c$children = c.children) == null ? void 0 : _c$children.flatMap(function (x) {
|
|
478
|
+
return getAllReferencedClasses(x, collectExtra);
|
|
479
|
+
});
|
|
480
|
+
var tc = clsx__default["default"]([c.styleClass, c.layoutClass, c.labelClass].concat((_collectExtra = collectExtra == null ? void 0 : collectExtra(c)) != null ? _collectExtra : []).map(getOverrideClass));
|
|
565
481
|
if (childClasses && !tc) return childClasses;
|
|
566
482
|
if (!tc) return [];
|
|
567
483
|
if (childClasses) return [tc].concat(childClasses);
|
|
@@ -601,6 +517,189 @@ function rendererClass(controlClass, globalClass) {
|
|
|
601
517
|
if (oc === controlClass) return clsx__default["default"](controlClass, globalClass);
|
|
602
518
|
return oc ? oc : undefined;
|
|
603
519
|
}
|
|
520
|
+
function watchControlLookup(base, path) {
|
|
521
|
+
var index = 0;
|
|
522
|
+
while (index < path.length && base) {
|
|
523
|
+
var childId = path[index];
|
|
524
|
+
var c = base.current;
|
|
525
|
+
if (typeof childId === "string") {
|
|
526
|
+
var _c$fields;
|
|
527
|
+
var next = (_c$fields = c.fields) == null ? void 0 : _c$fields[childId];
|
|
528
|
+
if (!next) core.trackControlChange(base, core.ControlChange.Structure);
|
|
529
|
+
base = next;
|
|
530
|
+
} else {
|
|
531
|
+
var _c$elements;
|
|
532
|
+
base = (_c$elements = c.elements) == null ? void 0 : _c$elements[childId];
|
|
533
|
+
}
|
|
534
|
+
index++;
|
|
535
|
+
}
|
|
536
|
+
return base;
|
|
537
|
+
}
|
|
538
|
+
function makeHook(runHook, state, deps) {
|
|
539
|
+
return {
|
|
540
|
+
deps: deps,
|
|
541
|
+
state: state,
|
|
542
|
+
runHook: runHook
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
function useDynamicHooks(hooks) {
|
|
546
|
+
var hookEntries = Object.entries(hooks);
|
|
547
|
+
var deps = hookEntries.map(function (_ref) {
|
|
548
|
+
var x = _ref[1];
|
|
549
|
+
return toDepString(x.deps);
|
|
550
|
+
}).join(",");
|
|
551
|
+
var ref = React.useRef({});
|
|
552
|
+
var s = ref.current;
|
|
553
|
+
hookEntries.forEach(function (x) {
|
|
554
|
+
return s[x[0]] = x[1].state;
|
|
555
|
+
});
|
|
556
|
+
return React.useCallback(function (p) {
|
|
557
|
+
return Object.fromEntries(hookEntries.map(function (_ref2) {
|
|
558
|
+
var f = _ref2[0],
|
|
559
|
+
hg = _ref2[1];
|
|
560
|
+
return [f, hg.runHook(p, ref.current[f])];
|
|
561
|
+
}));
|
|
562
|
+
}, [deps]);
|
|
563
|
+
}
|
|
564
|
+
function toDepString(x) {
|
|
565
|
+
if (x === undefined) return "_";
|
|
566
|
+
if (x === null) return "~";
|
|
567
|
+
return x.toString();
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
function buildSchema(def) {
|
|
571
|
+
return Object.entries(def).map(function (x) {
|
|
572
|
+
return x[1](x[0]);
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
function stringField(displayName, options) {
|
|
576
|
+
return makeScalarField(_extends({
|
|
577
|
+
type: exports.FieldType.String,
|
|
578
|
+
displayName: displayName
|
|
579
|
+
}, options));
|
|
580
|
+
}
|
|
581
|
+
function stringOptionsField(displayName) {
|
|
582
|
+
return makeScalarField({
|
|
583
|
+
type: exports.FieldType.String,
|
|
584
|
+
displayName: displayName,
|
|
585
|
+
options: [].slice.call(arguments, 1)
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
function withScalarOptions(options, v) {
|
|
589
|
+
return function (n) {
|
|
590
|
+
return _extends({}, v(n), options);
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
function makeScalarField(options) {
|
|
594
|
+
return function (n) {
|
|
595
|
+
return _extends({}, defaultScalarField(n, n), options);
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
function makeCompoundField(options) {
|
|
599
|
+
return function (n) {
|
|
600
|
+
return _extends({}, defaultCompoundField(n, n, false), options);
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
function intField(displayName, options) {
|
|
604
|
+
return makeScalarField(_extends({
|
|
605
|
+
type: exports.FieldType.Int,
|
|
606
|
+
displayName: displayName
|
|
607
|
+
}, options));
|
|
608
|
+
}
|
|
609
|
+
function boolField(displayName, options) {
|
|
610
|
+
return makeScalarField(_extends({
|
|
611
|
+
type: exports.FieldType.Bool,
|
|
612
|
+
displayName: displayName
|
|
613
|
+
}, options));
|
|
614
|
+
}
|
|
615
|
+
function compoundField(displayName, fields, other) {
|
|
616
|
+
return function (field) {
|
|
617
|
+
return _extends({}, defaultCompoundField(field, displayName, false), other, {
|
|
618
|
+
children: fields
|
|
619
|
+
});
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
function defaultScalarField(field, displayName) {
|
|
623
|
+
return {
|
|
624
|
+
field: field,
|
|
625
|
+
displayName: displayName,
|
|
626
|
+
type: exports.FieldType.String
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
function defaultCompoundField(field, displayName, collection) {
|
|
630
|
+
return {
|
|
631
|
+
field: field,
|
|
632
|
+
displayName: displayName,
|
|
633
|
+
type: exports.FieldType.Compound,
|
|
634
|
+
collection: collection,
|
|
635
|
+
children: []
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
function mergeField(field, mergeInto) {
|
|
639
|
+
var existing = mergeInto.find(function (x) {
|
|
640
|
+
return x.field === field.field;
|
|
641
|
+
});
|
|
642
|
+
if (existing) {
|
|
643
|
+
return mergeInto.map(function (x) {
|
|
644
|
+
return x !== existing ? x : _extends({}, x, {
|
|
645
|
+
onlyForTypes: mergeTypes(x.onlyForTypes, field.onlyForTypes)
|
|
646
|
+
});
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
return [].concat(mergeInto, [field]);
|
|
650
|
+
function mergeTypes(f, s) {
|
|
651
|
+
if (!f) return s;
|
|
652
|
+
if (!s) return f;
|
|
653
|
+
var extras = s.filter(function (x) {
|
|
654
|
+
return !f.includes(x);
|
|
655
|
+
});
|
|
656
|
+
return extras.length ? [].concat(f, extras) : f;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
function mergeFields(fields, name, value, newFields) {
|
|
660
|
+
var withType = fields.map(function (x) {
|
|
661
|
+
return x.isTypeField ? addFieldOption(x, name, value) : x;
|
|
662
|
+
});
|
|
663
|
+
return newFields.map(function (x) {
|
|
664
|
+
return _extends({}, x, {
|
|
665
|
+
onlyForTypes: [value]
|
|
666
|
+
});
|
|
667
|
+
}).reduce(function (af, x) {
|
|
668
|
+
return mergeField(x, af);
|
|
669
|
+
}, withType);
|
|
670
|
+
}
|
|
671
|
+
function addFieldOption(typeField, name, value) {
|
|
672
|
+
var _typeField$options;
|
|
673
|
+
var options = (_typeField$options = typeField.options) != null ? _typeField$options : [];
|
|
674
|
+
return _extends({}, typeField, {
|
|
675
|
+
options: [].concat(options, [{
|
|
676
|
+
name: name,
|
|
677
|
+
value: value
|
|
678
|
+
}])
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
function resolveSchemas(schemaMap) {
|
|
682
|
+
var out = {};
|
|
683
|
+
function resolveSchemaType(type) {
|
|
684
|
+
if (type in out) {
|
|
685
|
+
return out[type];
|
|
686
|
+
}
|
|
687
|
+
var resolvedFields = [];
|
|
688
|
+
out[type] = resolvedFields;
|
|
689
|
+
schemaMap[type].forEach(function (x) {
|
|
690
|
+
if (isCompoundField(x) && x.schemaRef) {
|
|
691
|
+
resolvedFields.push(_extends({}, x, {
|
|
692
|
+
children: resolveSchemaType(x.schemaRef)
|
|
693
|
+
}));
|
|
694
|
+
} else {
|
|
695
|
+
resolvedFields.push(x);
|
|
696
|
+
}
|
|
697
|
+
});
|
|
698
|
+
return resolvedFields;
|
|
699
|
+
}
|
|
700
|
+
Object.keys(schemaMap).forEach(resolveSchemaType);
|
|
701
|
+
return out;
|
|
702
|
+
}
|
|
604
703
|
|
|
605
704
|
function dataControl(field, title, options) {
|
|
606
705
|
return _extends({
|
|
@@ -712,41 +811,19 @@ function useControlDefinitionForSchema(sf, definition) {
|
|
|
712
811
|
});
|
|
713
812
|
}, [sf, definition]);
|
|
714
813
|
}
|
|
715
|
-
function
|
|
716
|
-
|
|
717
|
-
|
|
814
|
+
function applyExtensionToSchema(schemaMap, extension) {
|
|
815
|
+
var outMap = _extends({}, schemaMap);
|
|
816
|
+
Object.entries(extension).forEach(function (_ref) {
|
|
817
|
+
var field = _ref[0],
|
|
818
|
+
cro = _ref[1];
|
|
819
|
+
outMap[field] = (Array.isArray(cro) ? cro : [cro]).reduce(function (a, cr) {
|
|
820
|
+
return mergeFields(a, cr.name, cr.value, cr.fields);
|
|
821
|
+
}, outMap[field]);
|
|
718
822
|
});
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
});
|
|
724
|
-
return _extends({}, roField, {
|
|
725
|
-
children: customRenderOptions.reduce(function (renderOptionFields, ro) {
|
|
726
|
-
return ro.fields.map(function (x) {
|
|
727
|
-
return _extends({}, x, {
|
|
728
|
-
onlyForTypes: [ro.value]
|
|
729
|
-
});
|
|
730
|
-
}).reduce(function (af, x) {
|
|
731
|
-
return mergeField(x, af);
|
|
732
|
-
}, renderOptionFields);
|
|
733
|
-
}, withTypes)
|
|
734
|
-
});
|
|
735
|
-
}
|
|
736
|
-
function addRenderOptionType(typeField) {
|
|
737
|
-
var _typeField$options;
|
|
738
|
-
var options = (_typeField$options = typeField.options) != null ? _typeField$options : [];
|
|
739
|
-
return _extends({}, typeField, {
|
|
740
|
-
options: [].concat(options, customRenderOptions.map(function (_ref) {
|
|
741
|
-
var name = _ref.name,
|
|
742
|
-
value = _ref.value;
|
|
743
|
-
return {
|
|
744
|
-
name: name,
|
|
745
|
-
value: value
|
|
746
|
-
};
|
|
747
|
-
}))
|
|
748
|
-
});
|
|
749
|
-
}
|
|
823
|
+
return outMap;
|
|
824
|
+
}
|
|
825
|
+
function applyExtensionsToSchema(schemaMap, extensions) {
|
|
826
|
+
return resolveSchemas(extensions.reduce(applyExtensionToSchema, schemaMap));
|
|
750
827
|
}
|
|
751
828
|
|
|
752
829
|
function useCalculatedControl(calculate) {
|
|
@@ -799,76 +876,65 @@ function _finallyRethrows(body, finalizer) {
|
|
|
799
876
|
}
|
|
800
877
|
function useEvalVisibilityHook(useEvalExpressionHook, definition, schemaField) {
|
|
801
878
|
var dynamicVisibility = useEvalDynamicHook(definition, exports.DynamicPropertyType.Visible, useEvalExpressionHook);
|
|
802
|
-
|
|
879
|
+
return makeDynamicPropertyHook(dynamicVisibility, function (ctx, _ref) {
|
|
880
|
+
var schemaField = _ref.schemaField,
|
|
881
|
+
definition = _ref.definition;
|
|
882
|
+
return core.useComputed(function () {
|
|
883
|
+
return matchesType(ctx, schemaField == null ? void 0 : schemaField.onlyForTypes) && (!schemaField || !hideDisplayOnly(ctx, schemaField, definition, ctx.schemaInterface));
|
|
884
|
+
});
|
|
885
|
+
}, {
|
|
803
886
|
schemaField: schemaField,
|
|
804
887
|
definition: definition
|
|
805
888
|
});
|
|
806
|
-
return React.useCallback(function (ctx) {
|
|
807
|
-
var _dynamicVisibility;
|
|
808
|
-
var _r$current = r.current,
|
|
809
|
-
schemaField = _r$current.schemaField,
|
|
810
|
-
definition = _r$current.definition;
|
|
811
|
-
return (_dynamicVisibility = dynamicVisibility == null ? void 0 : dynamicVisibility(ctx)) != null ? _dynamicVisibility : core.useComputed(function () {
|
|
812
|
-
return matchesType(ctx, schemaField == null ? void 0 : schemaField.onlyForTypes) && (!schemaField || !hideDisplayOnly(ctx, schemaField, definition, ctx.schemaInterface));
|
|
813
|
-
});
|
|
814
|
-
}, [dynamicVisibility, r]);
|
|
815
889
|
}
|
|
816
890
|
function useEvalReadonlyHook(useEvalExpressionHook, definition) {
|
|
817
891
|
var dynamicReadonly = useEvalDynamicHook(definition, exports.DynamicPropertyType.Readonly, useEvalExpressionHook);
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
if (dynamicReadonly) return dynamicReadonly(ctx);
|
|
892
|
+
return makeDynamicPropertyHook(dynamicReadonly, function (ctx, _ref2) {
|
|
893
|
+
var definition = _ref2.definition;
|
|
821
894
|
return useCalculatedControl(function () {
|
|
822
|
-
return isControlReadonly(
|
|
895
|
+
return isControlReadonly(definition);
|
|
823
896
|
});
|
|
824
|
-
},
|
|
897
|
+
}, {
|
|
898
|
+
definition: definition
|
|
899
|
+
});
|
|
825
900
|
}
|
|
826
901
|
function useEvalStyleHook(useEvalExpressionHook, property, definition) {
|
|
827
902
|
var dynamicStyle = useEvalDynamicHook(definition, property, useEvalExpressionHook);
|
|
828
|
-
return
|
|
829
|
-
if (dynamicStyle) return dynamicStyle(ctx);
|
|
903
|
+
return makeDynamicPropertyHook(dynamicStyle, function () {
|
|
830
904
|
return core.useControl(undefined);
|
|
831
|
-
},
|
|
905
|
+
}, undefined);
|
|
832
906
|
}
|
|
833
907
|
function useEvalAllowedOptionsHook(useEvalExpressionHook, definition) {
|
|
834
908
|
var dynamicAllowed = useEvalDynamicHook(definition, exports.DynamicPropertyType.AllowedOptions, useEvalExpressionHook);
|
|
835
|
-
return
|
|
836
|
-
if (dynamicAllowed) return dynamicAllowed(ctx);
|
|
909
|
+
return makeDynamicPropertyHook(dynamicAllowed, function () {
|
|
837
910
|
return core.useControl([]);
|
|
838
|
-
},
|
|
911
|
+
}, undefined);
|
|
839
912
|
}
|
|
840
913
|
function useEvalDisabledHook(useEvalExpressionHook, definition) {
|
|
841
914
|
var dynamicDisabled = useEvalDynamicHook(definition, exports.DynamicPropertyType.Disabled, useEvalExpressionHook);
|
|
842
|
-
return
|
|
843
|
-
if (dynamicDisabled) return dynamicDisabled(ctx);
|
|
915
|
+
return makeDynamicPropertyHook(dynamicDisabled, function () {
|
|
844
916
|
return core.useControl(false);
|
|
845
|
-
},
|
|
917
|
+
}, undefined);
|
|
846
918
|
}
|
|
847
919
|
function useEvalDisplayHook(useEvalExpressionHook, definition) {
|
|
848
|
-
|
|
849
|
-
return React.useCallback(function (ctx) {
|
|
850
|
-
return dynamicDisplay == null ? void 0 : dynamicDisplay(ctx);
|
|
851
|
-
}, [dynamicDisplay]);
|
|
920
|
+
return useEvalDynamicHook(definition, exports.DynamicPropertyType.Display, useEvalExpressionHook);
|
|
852
921
|
}
|
|
853
922
|
function useEvalDefaultValueHook(useEvalExpressionHook, definition, schemaField) {
|
|
854
923
|
var dynamicValue = useEvalDynamicHook(definition, exports.DynamicPropertyType.DefaultValue, useEvalExpressionHook);
|
|
855
|
-
|
|
856
|
-
definition
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
return React.useCallback(function (ctx) {
|
|
860
|
-
var _dynamicValue;
|
|
861
|
-
var _r$current2 = r.current,
|
|
862
|
-
definition = _r$current2.definition,
|
|
863
|
-
schemaField = _r$current2.schemaField;
|
|
864
|
-
return (_dynamicValue = dynamicValue == null ? void 0 : dynamicValue(ctx)) != null ? _dynamicValue : core.useComputed(calcDefault);
|
|
924
|
+
return makeDynamicPropertyHook(dynamicValue, function (ctx, _ref3) {
|
|
925
|
+
var definition = _ref3.definition,
|
|
926
|
+
schemaField = _ref3.schemaField;
|
|
927
|
+
return core.useComputed(calcDefault);
|
|
865
928
|
function calcDefault() {
|
|
866
|
-
var
|
|
867
|
-
required =
|
|
868
|
-
dcv =
|
|
929
|
+
var _ref4 = isDataControlDefinition(definition) ? [definition.required, definition.defaultValue] : [false, undefined],
|
|
930
|
+
required = _ref4[0],
|
|
931
|
+
dcv = _ref4[1];
|
|
869
932
|
return dcv != null ? dcv : schemaField ? defaultValueForField(schemaField, required) : undefined;
|
|
870
933
|
}
|
|
871
|
-
},
|
|
934
|
+
}, {
|
|
935
|
+
definition: definition,
|
|
936
|
+
schemaField: schemaField
|
|
937
|
+
});
|
|
872
938
|
}
|
|
873
939
|
function useDataExpression(fvExpr, fields, data) {
|
|
874
940
|
var refField = findField(fields, fvExpr.field);
|
|
@@ -900,12 +966,13 @@ function defaultEvalHooks(expr, context) {
|
|
|
900
966
|
var defaultUseEvalExpressionHook = makeEvalExpressionHook(defaultEvalHooks);
|
|
901
967
|
function makeEvalExpressionHook(f) {
|
|
902
968
|
return function (expr) {
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
969
|
+
return {
|
|
970
|
+
deps: expr == null ? void 0 : expr.type,
|
|
971
|
+
state: expr,
|
|
972
|
+
runHook: function runHook(ctx, state) {
|
|
973
|
+
return state ? f(state, ctx) : undefined;
|
|
974
|
+
}
|
|
975
|
+
};
|
|
909
976
|
};
|
|
910
977
|
}
|
|
911
978
|
function useEvalDynamicHook(definition, type, useEvalExpressionHook) {
|
|
@@ -984,12 +1051,19 @@ function useJsonataExpression(jExpr, dataContext, bindings) {
|
|
|
984
1051
|
}
|
|
985
1052
|
function useEvalLabelText(useExpr, definition) {
|
|
986
1053
|
var dynamicValue = useEvalDynamicHook(definition, exports.DynamicPropertyType.Label, useExpr);
|
|
987
|
-
return
|
|
988
|
-
if (dynamicValue) {
|
|
989
|
-
return dynamicValue(ctx);
|
|
990
|
-
}
|
|
1054
|
+
return makeDynamicPropertyHook(dynamicValue, function () {
|
|
991
1055
|
return core.useControl(null);
|
|
992
|
-
},
|
|
1056
|
+
}, undefined);
|
|
1057
|
+
}
|
|
1058
|
+
function makeDynamicPropertyHook(dynamicValue, makeDefault, state, deps) {
|
|
1059
|
+
return {
|
|
1060
|
+
deps: deps !== undefined ? dynamicValue.deps : [deps, dynamicValue.deps].map(toDepString).join(),
|
|
1061
|
+
runHook: function runHook(ctx, s) {
|
|
1062
|
+
var _dynamicValue$runHook;
|
|
1063
|
+
return (_dynamicValue$runHook = dynamicValue.runHook(ctx, s[0])) != null ? _dynamicValue$runHook : makeDefault(ctx, s[1]);
|
|
1064
|
+
},
|
|
1065
|
+
state: [dynamicValue.state, state]
|
|
1066
|
+
};
|
|
993
1067
|
}
|
|
994
1068
|
|
|
995
1069
|
function useValidationHook(definition) {
|
|
@@ -1092,15 +1166,17 @@ function useControlRenderer(definition, fields, renderer, options) {
|
|
|
1092
1166
|
var schemaInterface = (_options$schemaInterf = options.schemaInterface) != null ? _options$schemaInterf : defaultSchemaInterface;
|
|
1093
1167
|
var useExpr = (_options$useEvalExpre = options.useEvalExpressionHook) != null ? _options$useEvalExpre : defaultUseEvalExpressionHook;
|
|
1094
1168
|
var schemaField = lookupSchemaField(definition, fields);
|
|
1095
|
-
var
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1169
|
+
var dynamicHooks = useDynamicHooks({
|
|
1170
|
+
defaultValueControl: useEvalDefaultValueHook(useExpr, definition, schemaField),
|
|
1171
|
+
visibleControl: useEvalVisibilityHook(useExpr, definition, schemaField),
|
|
1172
|
+
readonlyControl: useEvalReadonlyHook(useExpr, definition),
|
|
1173
|
+
disabledControl: useEvalDisabledHook(useExpr, definition),
|
|
1174
|
+
allowedOptions: useEvalAllowedOptionsHook(useExpr, definition),
|
|
1175
|
+
labelText: useEvalLabelText(useExpr, definition),
|
|
1176
|
+
customStyle: useEvalStyleHook(useExpr, exports.DynamicPropertyType.Style, definition),
|
|
1177
|
+
layoutStyle: useEvalStyleHook(useExpr, exports.DynamicPropertyType.LayoutStyle, definition),
|
|
1178
|
+
displayControl: useEvalDisplayHook(useExpr, definition)
|
|
1179
|
+
});
|
|
1104
1180
|
var useValidation = useValidationHook(definition);
|
|
1105
1181
|
var r = useUpdatedRef({
|
|
1106
1182
|
options: options,
|
|
@@ -1126,13 +1202,16 @@ function useControlRenderer(definition, fields, renderer, options) {
|
|
|
1126
1202
|
data: rootControl,
|
|
1127
1203
|
path: parentPath
|
|
1128
1204
|
};
|
|
1129
|
-
var
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1205
|
+
var _dynamicHooks = dynamicHooks(parentDataContext),
|
|
1206
|
+
readonlyControl = _dynamicHooks.readonlyControl,
|
|
1207
|
+
disabledControl = _dynamicHooks.disabledControl,
|
|
1208
|
+
visibleControl = _dynamicHooks.visibleControl,
|
|
1209
|
+
displayControl = _dynamicHooks.displayControl,
|
|
1210
|
+
layoutStyle = _dynamicHooks.layoutStyle,
|
|
1211
|
+
labelText = _dynamicHooks.labelText,
|
|
1212
|
+
customStyle = _dynamicHooks.customStyle,
|
|
1213
|
+
allowedOptions = _dynamicHooks.allowedOptions,
|
|
1214
|
+
defaultValueControl = _dynamicHooks.defaultValueControl;
|
|
1136
1215
|
var visible = visibleControl.current.value;
|
|
1137
1216
|
var visibility = core.useControl(function () {
|
|
1138
1217
|
return visible != null ? {
|
|
@@ -1150,8 +1229,6 @@ function useControlRenderer(definition, fields, renderer, options) {
|
|
|
1150
1229
|
};
|
|
1151
1230
|
});
|
|
1152
1231
|
});
|
|
1153
|
-
var allowedOptions = useAllowedOptions(parentDataContext);
|
|
1154
|
-
var defaultValueControl = useDefaultValue(parentDataContext);
|
|
1155
1232
|
var _getControlData = getControlData(_schemaField, parentDataContext),
|
|
1156
1233
|
parentControl = _getControlData[0],
|
|
1157
1234
|
control = _getControlData[1],
|
|
@@ -1217,13 +1294,18 @@ function useControlRenderer(definition, fields, renderer, options) {
|
|
|
1217
1294
|
labelText: labelText,
|
|
1218
1295
|
schemaField: _schemaField,
|
|
1219
1296
|
displayControl: displayControl,
|
|
1220
|
-
style: customStyle,
|
|
1221
|
-
allowedOptions: allowedOptions
|
|
1297
|
+
style: customStyle.value,
|
|
1298
|
+
allowedOptions: allowedOptions,
|
|
1299
|
+
useChildVisibility: function useChildVisibility(child) {
|
|
1300
|
+
var childDef = findChildDefinition(c, child);
|
|
1301
|
+
var schemaField = lookupSchemaField(childDef, controlDataContext.fields);
|
|
1302
|
+
return useEvalVisibilityHook(useExpr, childDef, schemaField);
|
|
1303
|
+
}
|
|
1222
1304
|
});
|
|
1223
1305
|
var renderedControl = renderer.renderLayout(_extends({}, labelAndChildren, {
|
|
1224
1306
|
adornments: adornments,
|
|
1225
1307
|
className: c.layoutClass,
|
|
1226
|
-
style: layoutStyle
|
|
1308
|
+
style: layoutStyle.value
|
|
1227
1309
|
}));
|
|
1228
1310
|
return renderer.renderVisibility(_extends({
|
|
1229
1311
|
visibility: visibility
|
|
@@ -1231,7 +1313,7 @@ function useControlRenderer(definition, fields, renderer, options) {
|
|
|
1231
1313
|
} finally {
|
|
1232
1314
|
stopTracking();
|
|
1233
1315
|
}
|
|
1234
|
-
}, [r, dataProps,
|
|
1316
|
+
}, [r, dataProps, useValidation, renderer, schemaInterface, dynamicHooks]);
|
|
1235
1317
|
Component.displayName = "RenderControl";
|
|
1236
1318
|
return Component;
|
|
1237
1319
|
}
|
|
@@ -1269,15 +1351,17 @@ function ControlRenderer(_ref3) {
|
|
|
1269
1351
|
_effect();
|
|
1270
1352
|
}
|
|
1271
1353
|
}
|
|
1272
|
-
function groupProps(definition, renderChild,
|
|
1354
|
+
function groupProps(definition, renderChild, dataContext, className, style, useChildVisibility) {
|
|
1273
1355
|
var _definition$children, _definition$groupOpti;
|
|
1274
1356
|
return {
|
|
1275
|
-
|
|
1357
|
+
childDefinitions: (_definition$children = definition.children) != null ? _definition$children : [],
|
|
1276
1358
|
renderChild: renderChild,
|
|
1359
|
+
dataContext: dataContext,
|
|
1277
1360
|
renderOptions: (_definition$groupOpti = definition.groupOptions) != null ? _definition$groupOpti : {
|
|
1278
1361
|
type: "Standard"
|
|
1279
1362
|
},
|
|
1280
1363
|
className: cc(className),
|
|
1364
|
+
useChildVisibility: useChildVisibility,
|
|
1281
1365
|
style: style
|
|
1282
1366
|
};
|
|
1283
1367
|
}
|
|
@@ -1296,7 +1380,7 @@ function defaultDataProps(_ref4) {
|
|
|
1296
1380
|
var fieldOptions = ((_field$options$length = (_field$options = field.options) == null ? void 0 : _field$options.length) != null ? _field$options$length : 0) === 0 ? null : field.options;
|
|
1297
1381
|
var allowed = (_allowedOptions$value = allowedOptions == null ? void 0 : allowedOptions.value) != null ? _allowedOptions$value : [];
|
|
1298
1382
|
return _extends({
|
|
1299
|
-
|
|
1383
|
+
childDefinitions: (_definition$children2 = definition.children) != null ? _definition$children2 : [],
|
|
1300
1384
|
control: control,
|
|
1301
1385
|
field: field,
|
|
1302
1386
|
id: "c" + control.uniqueId,
|
|
@@ -1363,7 +1447,8 @@ function renderControlLayout(_ref5) {
|
|
|
1363
1447
|
displayControl = _ref5.displayControl,
|
|
1364
1448
|
style = _ref5.style,
|
|
1365
1449
|
labelText = _ref5.labelText,
|
|
1366
|
-
allowedOptions = _ref5.allowedOptions
|
|
1450
|
+
allowedOptions = _ref5.allowedOptions,
|
|
1451
|
+
useChildVisibility = _ref5.useChildVisibility;
|
|
1367
1452
|
if (isDataControlDefinition(c)) {
|
|
1368
1453
|
return renderData(c);
|
|
1369
1454
|
}
|
|
@@ -1377,7 +1462,7 @@ function renderControlLayout(_ref5) {
|
|
|
1377
1462
|
}));
|
|
1378
1463
|
}
|
|
1379
1464
|
return {
|
|
1380
|
-
processLayout: renderer.renderGroup(groupProps(c, childRenderer, dataContext, c.styleClass, style)),
|
|
1465
|
+
processLayout: renderer.renderGroup(groupProps(c, childRenderer, dataContext, c.styleClass, style, useChildVisibility)),
|
|
1381
1466
|
label: {
|
|
1382
1467
|
label: (_labelText$value = labelText == null ? void 0 : labelText.value) != null ? _labelText$value : c.title,
|
|
1383
1468
|
className: cc(c.labelClass),
|
|
@@ -1431,6 +1516,7 @@ function renderControlLayout(_ref5) {
|
|
|
1431
1516
|
renderChild: elemIndex != null ? function (k, d, p) {
|
|
1432
1517
|
return childRenderer(k, d, p ? [elemIndex].concat(p) : [elemIndex]);
|
|
1433
1518
|
} : childRenderer,
|
|
1519
|
+
useChildVisibility: useChildVisibility,
|
|
1434
1520
|
elementRenderer: elemIndex == null && schemaField.collection ? function (ei) {
|
|
1435
1521
|
return renderLayoutParts(renderData(c, ei), renderer).children;
|
|
1436
1522
|
} : undefined
|
|
@@ -1724,7 +1810,7 @@ function createDefaultGroupRenderer(options) {
|
|
|
1724
1810
|
function render(props) {
|
|
1725
1811
|
var renderChild = props.renderChild,
|
|
1726
1812
|
renderOptions = props.renderOptions,
|
|
1727
|
-
|
|
1813
|
+
childDefinitions = props.childDefinitions;
|
|
1728
1814
|
var _ref7 = isGridRenderer(renderOptions) ? gridStyles(renderOptions) : isFlexRenderer(renderOptions) ? flexStyles(renderOptions) : {
|
|
1729
1815
|
className: standardClassName
|
|
1730
1816
|
},
|
|
@@ -1735,7 +1821,7 @@ function createDefaultGroupRenderer(options) {
|
|
|
1735
1821
|
children: /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1736
1822
|
className: rendererClass(props.className, clsx__default["default"](className, gcn)),
|
|
1737
1823
|
style: style
|
|
1738
|
-
},
|
|
1824
|
+
}, childDefinitions == null ? void 0 : childDefinitions.map(function (c, i) {
|
|
1739
1825
|
return renderChild(i, i);
|
|
1740
1826
|
}))
|
|
1741
1827
|
});
|
|
@@ -1822,19 +1908,28 @@ function createDefaultDataRenderer(options) {
|
|
|
1822
1908
|
});
|
|
1823
1909
|
};
|
|
1824
1910
|
}
|
|
1911
|
+
var renderOptions = props.renderOptions;
|
|
1825
1912
|
if (fieldType === exports.FieldType.Compound) {
|
|
1913
|
+
var groupOptions = isDataGroupRenderer(renderOptions) ? renderOptions.groupOptions : undefined;
|
|
1914
|
+
var style = props.style,
|
|
1915
|
+
className = props.className,
|
|
1916
|
+
childDefinitions = props.childDefinitions,
|
|
1917
|
+
renderChild = props.renderChild,
|
|
1918
|
+
dataContext = props.dataContext,
|
|
1919
|
+
useChildVisibility = props.useChildVisibility;
|
|
1826
1920
|
return renderers.renderGroup({
|
|
1827
|
-
style:
|
|
1828
|
-
className:
|
|
1829
|
-
|
|
1830
|
-
renderOptions: {
|
|
1921
|
+
style: style,
|
|
1922
|
+
className: className,
|
|
1923
|
+
childDefinitions: childDefinitions,
|
|
1924
|
+
renderOptions: groupOptions != null ? groupOptions : {
|
|
1831
1925
|
type: "Standard",
|
|
1832
1926
|
hideTitle: true
|
|
1833
1927
|
},
|
|
1834
|
-
renderChild:
|
|
1928
|
+
renderChild: renderChild,
|
|
1929
|
+
dataContext: dataContext,
|
|
1930
|
+
useChildVisibility: useChildVisibility
|
|
1835
1931
|
});
|
|
1836
1932
|
}
|
|
1837
|
-
var renderOptions = props.renderOptions;
|
|
1838
1933
|
var renderType = renderOptions.type;
|
|
1839
1934
|
if (fieldType == exports.FieldType.Any) return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, "No control for Any");
|
|
1840
1935
|
if (isDisplayOnlyRenderer(renderOptions)) return function (p) {
|
|
@@ -2049,6 +2144,12 @@ function createDataRenderer(render, options) {
|
|
|
2049
2144
|
render: render
|
|
2050
2145
|
}, options);
|
|
2051
2146
|
}
|
|
2147
|
+
function createGroupRenderer(render, options) {
|
|
2148
|
+
return _extends({
|
|
2149
|
+
type: "group",
|
|
2150
|
+
render: render
|
|
2151
|
+
}, options);
|
|
2152
|
+
}
|
|
2052
2153
|
function createLabelRenderer(render, options) {
|
|
2053
2154
|
return _extends({
|
|
2054
2155
|
type: "label",
|
|
@@ -2277,12 +2378,14 @@ exports.DefaultLayout = DefaultLayout;
|
|
|
2277
2378
|
exports.DefaultVisibility = DefaultVisibility;
|
|
2278
2379
|
exports.SelectDataRenderer = SelectDataRenderer;
|
|
2279
2380
|
exports.WrapAdornmentPriority = WrapAdornmentPriority;
|
|
2280
|
-
exports.
|
|
2381
|
+
exports.addFieldOption = addFieldOption;
|
|
2281
2382
|
exports.addMissingControls = addMissingControls;
|
|
2282
2383
|
exports.appendMarkup = appendMarkup;
|
|
2283
2384
|
exports.appendMarkupAt = appendMarkupAt;
|
|
2284
2385
|
exports.applyDefaultForField = applyDefaultForField;
|
|
2285
2386
|
exports.applyDefaultValues = applyDefaultValues;
|
|
2387
|
+
exports.applyExtensionToSchema = applyExtensionToSchema;
|
|
2388
|
+
exports.applyExtensionsToSchema = applyExtensionsToSchema;
|
|
2286
2389
|
exports.boolField = boolField;
|
|
2287
2390
|
exports.buildSchema = buildSchema;
|
|
2288
2391
|
exports.cleanDataForSchema = cleanDataForSchema;
|
|
@@ -2303,6 +2406,7 @@ exports.createDefaultLabelRenderer = createDefaultLabelRenderer;
|
|
|
2303
2406
|
exports.createDefaultRenderers = createDefaultRenderers;
|
|
2304
2407
|
exports.createDefaultVisibilityRenderer = createDefaultVisibilityRenderer;
|
|
2305
2408
|
exports.createFormRenderer = createFormRenderer;
|
|
2409
|
+
exports.createGroupRenderer = createGroupRenderer;
|
|
2306
2410
|
exports.createInputConversion = createInputConversion;
|
|
2307
2411
|
exports.createLabelRenderer = createLabelRenderer;
|
|
2308
2412
|
exports.createLayoutRenderer = createLayoutRenderer;
|
|
@@ -2351,6 +2455,7 @@ exports.isCompoundField = isCompoundField;
|
|
|
2351
2455
|
exports.isControlReadonly = isControlReadonly;
|
|
2352
2456
|
exports.isDataControl = isDataControl;
|
|
2353
2457
|
exports.isDataControlDefinition = isDataControlDefinition;
|
|
2458
|
+
exports.isDataGroupRenderer = isDataGroupRenderer;
|
|
2354
2459
|
exports.isDisplayControlsDefinition = isDisplayControlsDefinition;
|
|
2355
2460
|
exports.isDisplayOnlyRenderer = isDisplayOnlyRenderer;
|
|
2356
2461
|
exports.isFlexRenderer = isFlexRenderer;
|
|
@@ -2366,17 +2471,22 @@ exports.lookupChildControl = lookupChildControl;
|
|
|
2366
2471
|
exports.lookupSchemaField = lookupSchemaField;
|
|
2367
2472
|
exports.makeCompoundField = makeCompoundField;
|
|
2368
2473
|
exports.makeEvalExpressionHook = makeEvalExpressionHook;
|
|
2474
|
+
exports.makeHook = makeHook;
|
|
2369
2475
|
exports.makeScalarField = makeScalarField;
|
|
2370
2476
|
exports.matchesType = matchesType;
|
|
2371
2477
|
exports.mergeField = mergeField;
|
|
2478
|
+
exports.mergeFields = mergeFields;
|
|
2372
2479
|
exports.renderControlLayout = renderControlLayout;
|
|
2373
2480
|
exports.renderLayoutParts = renderLayoutParts;
|
|
2374
2481
|
exports.rendererClass = rendererClass;
|
|
2482
|
+
exports.resolveSchemas = resolveSchemas;
|
|
2375
2483
|
exports.stringField = stringField;
|
|
2376
2484
|
exports.stringOptionsField = stringOptionsField;
|
|
2377
2485
|
exports.textDisplayControl = textDisplayControl;
|
|
2486
|
+
exports.toDepString = toDepString;
|
|
2378
2487
|
exports.useControlDefinitionForSchema = useControlDefinitionForSchema;
|
|
2379
2488
|
exports.useControlRenderer = useControlRenderer;
|
|
2489
|
+
exports.useDynamicHooks = useDynamicHooks;
|
|
2380
2490
|
exports.useEvalAllowedOptionsHook = useEvalAllowedOptionsHook;
|
|
2381
2491
|
exports.useEvalDefaultValueHook = useEvalDefaultValueHook;
|
|
2382
2492
|
exports.useEvalDisabledHook = useEvalDisabledHook;
|