@react-typed-forms/schemas 8.2.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 +323 -215
- 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 +12 -0
- 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 -453
- 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;
|
|
@@ -603,6 +517,189 @@ function rendererClass(controlClass, globalClass) {
|
|
|
603
517
|
if (oc === controlClass) return clsx__default["default"](controlClass, globalClass);
|
|
604
518
|
return oc ? oc : undefined;
|
|
605
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
|
+
}
|
|
606
703
|
|
|
607
704
|
function dataControl(field, title, options) {
|
|
608
705
|
return _extends({
|
|
@@ -714,41 +811,19 @@ function useControlDefinitionForSchema(sf, definition) {
|
|
|
714
811
|
});
|
|
715
812
|
}, [sf, definition]);
|
|
716
813
|
}
|
|
717
|
-
function
|
|
718
|
-
|
|
719
|
-
|
|
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]);
|
|
720
822
|
});
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
});
|
|
726
|
-
return _extends({}, roField, {
|
|
727
|
-
children: customRenderOptions.reduce(function (renderOptionFields, ro) {
|
|
728
|
-
return ro.fields.map(function (x) {
|
|
729
|
-
return _extends({}, x, {
|
|
730
|
-
onlyForTypes: [ro.value]
|
|
731
|
-
});
|
|
732
|
-
}).reduce(function (af, x) {
|
|
733
|
-
return mergeField(x, af);
|
|
734
|
-
}, renderOptionFields);
|
|
735
|
-
}, withTypes)
|
|
736
|
-
});
|
|
737
|
-
}
|
|
738
|
-
function addRenderOptionType(typeField) {
|
|
739
|
-
var _typeField$options;
|
|
740
|
-
var options = (_typeField$options = typeField.options) != null ? _typeField$options : [];
|
|
741
|
-
return _extends({}, typeField, {
|
|
742
|
-
options: [].concat(options, customRenderOptions.map(function (_ref) {
|
|
743
|
-
var name = _ref.name,
|
|
744
|
-
value = _ref.value;
|
|
745
|
-
return {
|
|
746
|
-
name: name,
|
|
747
|
-
value: value
|
|
748
|
-
};
|
|
749
|
-
}))
|
|
750
|
-
});
|
|
751
|
-
}
|
|
823
|
+
return outMap;
|
|
824
|
+
}
|
|
825
|
+
function applyExtensionsToSchema(schemaMap, extensions) {
|
|
826
|
+
return resolveSchemas(extensions.reduce(applyExtensionToSchema, schemaMap));
|
|
752
827
|
}
|
|
753
828
|
|
|
754
829
|
function useCalculatedControl(calculate) {
|
|
@@ -801,76 +876,65 @@ function _finallyRethrows(body, finalizer) {
|
|
|
801
876
|
}
|
|
802
877
|
function useEvalVisibilityHook(useEvalExpressionHook, definition, schemaField) {
|
|
803
878
|
var dynamicVisibility = useEvalDynamicHook(definition, exports.DynamicPropertyType.Visible, useEvalExpressionHook);
|
|
804
|
-
|
|
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
|
+
}, {
|
|
805
886
|
schemaField: schemaField,
|
|
806
887
|
definition: definition
|
|
807
888
|
});
|
|
808
|
-
return React.useCallback(function (ctx) {
|
|
809
|
-
var _dynamicVisibility;
|
|
810
|
-
var _r$current = r.current,
|
|
811
|
-
schemaField = _r$current.schemaField,
|
|
812
|
-
definition = _r$current.definition;
|
|
813
|
-
return (_dynamicVisibility = dynamicVisibility == null ? void 0 : dynamicVisibility(ctx)) != null ? _dynamicVisibility : core.useComputed(function () {
|
|
814
|
-
return matchesType(ctx, schemaField == null ? void 0 : schemaField.onlyForTypes) && (!schemaField || !hideDisplayOnly(ctx, schemaField, definition, ctx.schemaInterface));
|
|
815
|
-
});
|
|
816
|
-
}, [dynamicVisibility, r]);
|
|
817
889
|
}
|
|
818
890
|
function useEvalReadonlyHook(useEvalExpressionHook, definition) {
|
|
819
891
|
var dynamicReadonly = useEvalDynamicHook(definition, exports.DynamicPropertyType.Readonly, useEvalExpressionHook);
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
if (dynamicReadonly) return dynamicReadonly(ctx);
|
|
892
|
+
return makeDynamicPropertyHook(dynamicReadonly, function (ctx, _ref2) {
|
|
893
|
+
var definition = _ref2.definition;
|
|
823
894
|
return useCalculatedControl(function () {
|
|
824
|
-
return isControlReadonly(
|
|
895
|
+
return isControlReadonly(definition);
|
|
825
896
|
});
|
|
826
|
-
},
|
|
897
|
+
}, {
|
|
898
|
+
definition: definition
|
|
899
|
+
});
|
|
827
900
|
}
|
|
828
901
|
function useEvalStyleHook(useEvalExpressionHook, property, definition) {
|
|
829
902
|
var dynamicStyle = useEvalDynamicHook(definition, property, useEvalExpressionHook);
|
|
830
|
-
return
|
|
831
|
-
if (dynamicStyle) return dynamicStyle(ctx);
|
|
903
|
+
return makeDynamicPropertyHook(dynamicStyle, function () {
|
|
832
904
|
return core.useControl(undefined);
|
|
833
|
-
},
|
|
905
|
+
}, undefined);
|
|
834
906
|
}
|
|
835
907
|
function useEvalAllowedOptionsHook(useEvalExpressionHook, definition) {
|
|
836
908
|
var dynamicAllowed = useEvalDynamicHook(definition, exports.DynamicPropertyType.AllowedOptions, useEvalExpressionHook);
|
|
837
|
-
return
|
|
838
|
-
if (dynamicAllowed) return dynamicAllowed(ctx);
|
|
909
|
+
return makeDynamicPropertyHook(dynamicAllowed, function () {
|
|
839
910
|
return core.useControl([]);
|
|
840
|
-
},
|
|
911
|
+
}, undefined);
|
|
841
912
|
}
|
|
842
913
|
function useEvalDisabledHook(useEvalExpressionHook, definition) {
|
|
843
914
|
var dynamicDisabled = useEvalDynamicHook(definition, exports.DynamicPropertyType.Disabled, useEvalExpressionHook);
|
|
844
|
-
return
|
|
845
|
-
if (dynamicDisabled) return dynamicDisabled(ctx);
|
|
915
|
+
return makeDynamicPropertyHook(dynamicDisabled, function () {
|
|
846
916
|
return core.useControl(false);
|
|
847
|
-
},
|
|
917
|
+
}, undefined);
|
|
848
918
|
}
|
|
849
919
|
function useEvalDisplayHook(useEvalExpressionHook, definition) {
|
|
850
|
-
|
|
851
|
-
return React.useCallback(function (ctx) {
|
|
852
|
-
return dynamicDisplay == null ? void 0 : dynamicDisplay(ctx);
|
|
853
|
-
}, [dynamicDisplay]);
|
|
920
|
+
return useEvalDynamicHook(definition, exports.DynamicPropertyType.Display, useEvalExpressionHook);
|
|
854
921
|
}
|
|
855
922
|
function useEvalDefaultValueHook(useEvalExpressionHook, definition, schemaField) {
|
|
856
923
|
var dynamicValue = useEvalDynamicHook(definition, exports.DynamicPropertyType.DefaultValue, useEvalExpressionHook);
|
|
857
|
-
|
|
858
|
-
definition
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
return React.useCallback(function (ctx) {
|
|
862
|
-
var _dynamicValue;
|
|
863
|
-
var _r$current2 = r.current,
|
|
864
|
-
definition = _r$current2.definition,
|
|
865
|
-
schemaField = _r$current2.schemaField;
|
|
866
|
-
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);
|
|
867
928
|
function calcDefault() {
|
|
868
|
-
var
|
|
869
|
-
required =
|
|
870
|
-
dcv =
|
|
929
|
+
var _ref4 = isDataControlDefinition(definition) ? [definition.required, definition.defaultValue] : [false, undefined],
|
|
930
|
+
required = _ref4[0],
|
|
931
|
+
dcv = _ref4[1];
|
|
871
932
|
return dcv != null ? dcv : schemaField ? defaultValueForField(schemaField, required) : undefined;
|
|
872
933
|
}
|
|
873
|
-
},
|
|
934
|
+
}, {
|
|
935
|
+
definition: definition,
|
|
936
|
+
schemaField: schemaField
|
|
937
|
+
});
|
|
874
938
|
}
|
|
875
939
|
function useDataExpression(fvExpr, fields, data) {
|
|
876
940
|
var refField = findField(fields, fvExpr.field);
|
|
@@ -902,12 +966,13 @@ function defaultEvalHooks(expr, context) {
|
|
|
902
966
|
var defaultUseEvalExpressionHook = makeEvalExpressionHook(defaultEvalHooks);
|
|
903
967
|
function makeEvalExpressionHook(f) {
|
|
904
968
|
return function (expr) {
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
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
|
+
};
|
|
911
976
|
};
|
|
912
977
|
}
|
|
913
978
|
function useEvalDynamicHook(definition, type, useEvalExpressionHook) {
|
|
@@ -986,12 +1051,19 @@ function useJsonataExpression(jExpr, dataContext, bindings) {
|
|
|
986
1051
|
}
|
|
987
1052
|
function useEvalLabelText(useExpr, definition) {
|
|
988
1053
|
var dynamicValue = useEvalDynamicHook(definition, exports.DynamicPropertyType.Label, useExpr);
|
|
989
|
-
return
|
|
990
|
-
if (dynamicValue) {
|
|
991
|
-
return dynamicValue(ctx);
|
|
992
|
-
}
|
|
1054
|
+
return makeDynamicPropertyHook(dynamicValue, function () {
|
|
993
1055
|
return core.useControl(null);
|
|
994
|
-
},
|
|
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
|
+
};
|
|
995
1067
|
}
|
|
996
1068
|
|
|
997
1069
|
function useValidationHook(definition) {
|
|
@@ -1094,15 +1166,17 @@ function useControlRenderer(definition, fields, renderer, options) {
|
|
|
1094
1166
|
var schemaInterface = (_options$schemaInterf = options.schemaInterface) != null ? _options$schemaInterf : defaultSchemaInterface;
|
|
1095
1167
|
var useExpr = (_options$useEvalExpre = options.useEvalExpressionHook) != null ? _options$useEvalExpre : defaultUseEvalExpressionHook;
|
|
1096
1168
|
var schemaField = lookupSchemaField(definition, fields);
|
|
1097
|
-
var
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
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
|
+
});
|
|
1106
1180
|
var useValidation = useValidationHook(definition);
|
|
1107
1181
|
var r = useUpdatedRef({
|
|
1108
1182
|
options: options,
|
|
@@ -1128,13 +1202,16 @@ function useControlRenderer(definition, fields, renderer, options) {
|
|
|
1128
1202
|
data: rootControl,
|
|
1129
1203
|
path: parentPath
|
|
1130
1204
|
};
|
|
1131
|
-
var
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
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;
|
|
1138
1215
|
var visible = visibleControl.current.value;
|
|
1139
1216
|
var visibility = core.useControl(function () {
|
|
1140
1217
|
return visible != null ? {
|
|
@@ -1152,8 +1229,6 @@ function useControlRenderer(definition, fields, renderer, options) {
|
|
|
1152
1229
|
};
|
|
1153
1230
|
});
|
|
1154
1231
|
});
|
|
1155
|
-
var allowedOptions = useAllowedOptions(parentDataContext);
|
|
1156
|
-
var defaultValueControl = useDefaultValue(parentDataContext);
|
|
1157
1232
|
var _getControlData = getControlData(_schemaField, parentDataContext),
|
|
1158
1233
|
parentControl = _getControlData[0],
|
|
1159
1234
|
control = _getControlData[1],
|
|
@@ -1219,13 +1294,18 @@ function useControlRenderer(definition, fields, renderer, options) {
|
|
|
1219
1294
|
labelText: labelText,
|
|
1220
1295
|
schemaField: _schemaField,
|
|
1221
1296
|
displayControl: displayControl,
|
|
1222
|
-
style: customStyle,
|
|
1223
|
-
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
|
+
}
|
|
1224
1304
|
});
|
|
1225
1305
|
var renderedControl = renderer.renderLayout(_extends({}, labelAndChildren, {
|
|
1226
1306
|
adornments: adornments,
|
|
1227
1307
|
className: c.layoutClass,
|
|
1228
|
-
style: layoutStyle
|
|
1308
|
+
style: layoutStyle.value
|
|
1229
1309
|
}));
|
|
1230
1310
|
return renderer.renderVisibility(_extends({
|
|
1231
1311
|
visibility: visibility
|
|
@@ -1233,7 +1313,7 @@ function useControlRenderer(definition, fields, renderer, options) {
|
|
|
1233
1313
|
} finally {
|
|
1234
1314
|
stopTracking();
|
|
1235
1315
|
}
|
|
1236
|
-
}, [r, dataProps,
|
|
1316
|
+
}, [r, dataProps, useValidation, renderer, schemaInterface, dynamicHooks]);
|
|
1237
1317
|
Component.displayName = "RenderControl";
|
|
1238
1318
|
return Component;
|
|
1239
1319
|
}
|
|
@@ -1271,15 +1351,17 @@ function ControlRenderer(_ref3) {
|
|
|
1271
1351
|
_effect();
|
|
1272
1352
|
}
|
|
1273
1353
|
}
|
|
1274
|
-
function groupProps(definition, renderChild,
|
|
1354
|
+
function groupProps(definition, renderChild, dataContext, className, style, useChildVisibility) {
|
|
1275
1355
|
var _definition$children, _definition$groupOpti;
|
|
1276
1356
|
return {
|
|
1277
|
-
|
|
1357
|
+
childDefinitions: (_definition$children = definition.children) != null ? _definition$children : [],
|
|
1278
1358
|
renderChild: renderChild,
|
|
1359
|
+
dataContext: dataContext,
|
|
1279
1360
|
renderOptions: (_definition$groupOpti = definition.groupOptions) != null ? _definition$groupOpti : {
|
|
1280
1361
|
type: "Standard"
|
|
1281
1362
|
},
|
|
1282
1363
|
className: cc(className),
|
|
1364
|
+
useChildVisibility: useChildVisibility,
|
|
1283
1365
|
style: style
|
|
1284
1366
|
};
|
|
1285
1367
|
}
|
|
@@ -1298,7 +1380,7 @@ function defaultDataProps(_ref4) {
|
|
|
1298
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;
|
|
1299
1381
|
var allowed = (_allowedOptions$value = allowedOptions == null ? void 0 : allowedOptions.value) != null ? _allowedOptions$value : [];
|
|
1300
1382
|
return _extends({
|
|
1301
|
-
|
|
1383
|
+
childDefinitions: (_definition$children2 = definition.children) != null ? _definition$children2 : [],
|
|
1302
1384
|
control: control,
|
|
1303
1385
|
field: field,
|
|
1304
1386
|
id: "c" + control.uniqueId,
|
|
@@ -1365,7 +1447,8 @@ function renderControlLayout(_ref5) {
|
|
|
1365
1447
|
displayControl = _ref5.displayControl,
|
|
1366
1448
|
style = _ref5.style,
|
|
1367
1449
|
labelText = _ref5.labelText,
|
|
1368
|
-
allowedOptions = _ref5.allowedOptions
|
|
1450
|
+
allowedOptions = _ref5.allowedOptions,
|
|
1451
|
+
useChildVisibility = _ref5.useChildVisibility;
|
|
1369
1452
|
if (isDataControlDefinition(c)) {
|
|
1370
1453
|
return renderData(c);
|
|
1371
1454
|
}
|
|
@@ -1379,7 +1462,7 @@ function renderControlLayout(_ref5) {
|
|
|
1379
1462
|
}));
|
|
1380
1463
|
}
|
|
1381
1464
|
return {
|
|
1382
|
-
processLayout: renderer.renderGroup(groupProps(c, childRenderer, dataContext, c.styleClass, style)),
|
|
1465
|
+
processLayout: renderer.renderGroup(groupProps(c, childRenderer, dataContext, c.styleClass, style, useChildVisibility)),
|
|
1383
1466
|
label: {
|
|
1384
1467
|
label: (_labelText$value = labelText == null ? void 0 : labelText.value) != null ? _labelText$value : c.title,
|
|
1385
1468
|
className: cc(c.labelClass),
|
|
@@ -1433,6 +1516,7 @@ function renderControlLayout(_ref5) {
|
|
|
1433
1516
|
renderChild: elemIndex != null ? function (k, d, p) {
|
|
1434
1517
|
return childRenderer(k, d, p ? [elemIndex].concat(p) : [elemIndex]);
|
|
1435
1518
|
} : childRenderer,
|
|
1519
|
+
useChildVisibility: useChildVisibility,
|
|
1436
1520
|
elementRenderer: elemIndex == null && schemaField.collection ? function (ei) {
|
|
1437
1521
|
return renderLayoutParts(renderData(c, ei), renderer).children;
|
|
1438
1522
|
} : undefined
|
|
@@ -1726,7 +1810,7 @@ function createDefaultGroupRenderer(options) {
|
|
|
1726
1810
|
function render(props) {
|
|
1727
1811
|
var renderChild = props.renderChild,
|
|
1728
1812
|
renderOptions = props.renderOptions,
|
|
1729
|
-
|
|
1813
|
+
childDefinitions = props.childDefinitions;
|
|
1730
1814
|
var _ref7 = isGridRenderer(renderOptions) ? gridStyles(renderOptions) : isFlexRenderer(renderOptions) ? flexStyles(renderOptions) : {
|
|
1731
1815
|
className: standardClassName
|
|
1732
1816
|
},
|
|
@@ -1737,7 +1821,7 @@ function createDefaultGroupRenderer(options) {
|
|
|
1737
1821
|
children: /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1738
1822
|
className: rendererClass(props.className, clsx__default["default"](className, gcn)),
|
|
1739
1823
|
style: style
|
|
1740
|
-
},
|
|
1824
|
+
}, childDefinitions == null ? void 0 : childDefinitions.map(function (c, i) {
|
|
1741
1825
|
return renderChild(i, i);
|
|
1742
1826
|
}))
|
|
1743
1827
|
});
|
|
@@ -1824,19 +1908,28 @@ function createDefaultDataRenderer(options) {
|
|
|
1824
1908
|
});
|
|
1825
1909
|
};
|
|
1826
1910
|
}
|
|
1911
|
+
var renderOptions = props.renderOptions;
|
|
1827
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;
|
|
1828
1920
|
return renderers.renderGroup({
|
|
1829
|
-
style:
|
|
1830
|
-
className:
|
|
1831
|
-
|
|
1832
|
-
renderOptions: {
|
|
1921
|
+
style: style,
|
|
1922
|
+
className: className,
|
|
1923
|
+
childDefinitions: childDefinitions,
|
|
1924
|
+
renderOptions: groupOptions != null ? groupOptions : {
|
|
1833
1925
|
type: "Standard",
|
|
1834
1926
|
hideTitle: true
|
|
1835
1927
|
},
|
|
1836
|
-
renderChild:
|
|
1928
|
+
renderChild: renderChild,
|
|
1929
|
+
dataContext: dataContext,
|
|
1930
|
+
useChildVisibility: useChildVisibility
|
|
1837
1931
|
});
|
|
1838
1932
|
}
|
|
1839
|
-
var renderOptions = props.renderOptions;
|
|
1840
1933
|
var renderType = renderOptions.type;
|
|
1841
1934
|
if (fieldType == exports.FieldType.Any) return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, "No control for Any");
|
|
1842
1935
|
if (isDisplayOnlyRenderer(renderOptions)) return function (p) {
|
|
@@ -2051,6 +2144,12 @@ function createDataRenderer(render, options) {
|
|
|
2051
2144
|
render: render
|
|
2052
2145
|
}, options);
|
|
2053
2146
|
}
|
|
2147
|
+
function createGroupRenderer(render, options) {
|
|
2148
|
+
return _extends({
|
|
2149
|
+
type: "group",
|
|
2150
|
+
render: render
|
|
2151
|
+
}, options);
|
|
2152
|
+
}
|
|
2054
2153
|
function createLabelRenderer(render, options) {
|
|
2055
2154
|
return _extends({
|
|
2056
2155
|
type: "label",
|
|
@@ -2279,12 +2378,14 @@ exports.DefaultLayout = DefaultLayout;
|
|
|
2279
2378
|
exports.DefaultVisibility = DefaultVisibility;
|
|
2280
2379
|
exports.SelectDataRenderer = SelectDataRenderer;
|
|
2281
2380
|
exports.WrapAdornmentPriority = WrapAdornmentPriority;
|
|
2282
|
-
exports.
|
|
2381
|
+
exports.addFieldOption = addFieldOption;
|
|
2283
2382
|
exports.addMissingControls = addMissingControls;
|
|
2284
2383
|
exports.appendMarkup = appendMarkup;
|
|
2285
2384
|
exports.appendMarkupAt = appendMarkupAt;
|
|
2286
2385
|
exports.applyDefaultForField = applyDefaultForField;
|
|
2287
2386
|
exports.applyDefaultValues = applyDefaultValues;
|
|
2387
|
+
exports.applyExtensionToSchema = applyExtensionToSchema;
|
|
2388
|
+
exports.applyExtensionsToSchema = applyExtensionsToSchema;
|
|
2288
2389
|
exports.boolField = boolField;
|
|
2289
2390
|
exports.buildSchema = buildSchema;
|
|
2290
2391
|
exports.cleanDataForSchema = cleanDataForSchema;
|
|
@@ -2305,6 +2406,7 @@ exports.createDefaultLabelRenderer = createDefaultLabelRenderer;
|
|
|
2305
2406
|
exports.createDefaultRenderers = createDefaultRenderers;
|
|
2306
2407
|
exports.createDefaultVisibilityRenderer = createDefaultVisibilityRenderer;
|
|
2307
2408
|
exports.createFormRenderer = createFormRenderer;
|
|
2409
|
+
exports.createGroupRenderer = createGroupRenderer;
|
|
2308
2410
|
exports.createInputConversion = createInputConversion;
|
|
2309
2411
|
exports.createLabelRenderer = createLabelRenderer;
|
|
2310
2412
|
exports.createLayoutRenderer = createLayoutRenderer;
|
|
@@ -2353,6 +2455,7 @@ exports.isCompoundField = isCompoundField;
|
|
|
2353
2455
|
exports.isControlReadonly = isControlReadonly;
|
|
2354
2456
|
exports.isDataControl = isDataControl;
|
|
2355
2457
|
exports.isDataControlDefinition = isDataControlDefinition;
|
|
2458
|
+
exports.isDataGroupRenderer = isDataGroupRenderer;
|
|
2356
2459
|
exports.isDisplayControlsDefinition = isDisplayControlsDefinition;
|
|
2357
2460
|
exports.isDisplayOnlyRenderer = isDisplayOnlyRenderer;
|
|
2358
2461
|
exports.isFlexRenderer = isFlexRenderer;
|
|
@@ -2368,17 +2471,22 @@ exports.lookupChildControl = lookupChildControl;
|
|
|
2368
2471
|
exports.lookupSchemaField = lookupSchemaField;
|
|
2369
2472
|
exports.makeCompoundField = makeCompoundField;
|
|
2370
2473
|
exports.makeEvalExpressionHook = makeEvalExpressionHook;
|
|
2474
|
+
exports.makeHook = makeHook;
|
|
2371
2475
|
exports.makeScalarField = makeScalarField;
|
|
2372
2476
|
exports.matchesType = matchesType;
|
|
2373
2477
|
exports.mergeField = mergeField;
|
|
2478
|
+
exports.mergeFields = mergeFields;
|
|
2374
2479
|
exports.renderControlLayout = renderControlLayout;
|
|
2375
2480
|
exports.renderLayoutParts = renderLayoutParts;
|
|
2376
2481
|
exports.rendererClass = rendererClass;
|
|
2482
|
+
exports.resolveSchemas = resolveSchemas;
|
|
2377
2483
|
exports.stringField = stringField;
|
|
2378
2484
|
exports.stringOptionsField = stringOptionsField;
|
|
2379
2485
|
exports.textDisplayControl = textDisplayControl;
|
|
2486
|
+
exports.toDepString = toDepString;
|
|
2380
2487
|
exports.useControlDefinitionForSchema = useControlDefinitionForSchema;
|
|
2381
2488
|
exports.useControlRenderer = useControlRenderer;
|
|
2489
|
+
exports.useDynamicHooks = useDynamicHooks;
|
|
2382
2490
|
exports.useEvalAllowedOptionsHook = useEvalAllowedOptionsHook;
|
|
2383
2491
|
exports.useEvalDefaultValueHook = useEvalDefaultValueHook;
|
|
2384
2492
|
exports.useEvalDisabledHook = useEvalDisabledHook;
|