@valbuild/core 0.106.0 → 0.109.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/dist/declarations/src/index.d.ts +3 -3
- package/dist/declarations/src/initSchema.d.ts +20 -20
- package/dist/declarations/src/preview.d.ts +40 -2
- package/dist/declarations/src/render.d.ts +38 -9
- package/dist/declarations/src/schema/array.d.ts +24 -12
- package/dist/declarations/src/schema/boolean.d.ts +25 -2
- package/dist/declarations/src/schema/color.d.ts +25 -2
- package/dist/declarations/src/schema/date.d.ts +25 -2
- package/dist/declarations/src/schema/datetime.d.ts +25 -2
- package/dist/declarations/src/schema/file.d.ts +25 -2
- package/dist/declarations/src/schema/image.d.ts +25 -2
- package/dist/declarations/src/schema/index.d.ts +19 -1
- package/dist/declarations/src/schema/keyOf.d.ts +25 -2
- package/dist/declarations/src/schema/literal.d.ts +25 -2
- package/dist/declarations/src/schema/number.d.ts +25 -2
- package/dist/declarations/src/schema/object.d.ts +25 -2
- package/dist/declarations/src/schema/record.d.ts +25 -13
- package/dist/declarations/src/schema/richtext.d.ts +25 -2
- package/dist/declarations/src/schema/route.d.ts +25 -2
- package/dist/declarations/src/schema/string.d.ts +13 -2
- package/dist/declarations/src/schema/union.d.ts +32 -2
- package/dist/{index-eaee0a0b.cjs.prod.js → index-77914667.cjs.prod.js} +993 -188
- package/dist/{index-2cef45cc.cjs.dev.js → index-bce560db.cjs.dev.js} +993 -188
- package/dist/{index-193f19b4.esm.js → index-db33b67c.esm.js} +993 -188
- package/dist/valbuild-core.cjs.dev.js +1 -1
- package/dist/valbuild-core.cjs.prod.js +1 -1
- package/dist/valbuild-core.esm.js +1 -1
- package/package.json +2 -2
- package/patch/dist/valbuild-core-patch.cjs.dev.js +1 -1
- package/patch/dist/valbuild-core-patch.cjs.prod.js +1 -1
- package/patch/dist/valbuild-core-patch.esm.js +2 -2
|
@@ -215,8 +215,32 @@ var Schema = /*#__PURE__*/function () {
|
|
|
215
215
|
* For example, if you have an object schema, you must assert each key / value pair manually.
|
|
216
216
|
*/
|
|
217
217
|
}, {
|
|
218
|
-
key: "
|
|
218
|
+
key: "executePreviewItem",
|
|
219
219
|
value:
|
|
220
|
+
/**
|
|
221
|
+
* This value AS A PREVIEW — what a container's row, a reference dropdown or
|
|
222
|
+
* a search hit shows for it. Runs the schema's own `preview` closure;
|
|
223
|
+
* `null` when none is declared (the consumer falls back to a generic
|
|
224
|
+
* preview). A union dispatches to the matching member's closure.
|
|
225
|
+
*
|
|
226
|
+
* Containers call this on their ITEM schema per item — that is how
|
|
227
|
+
* `executePreview` reifies an {@link ArrayPreview} / {@link RecordPreview}
|
|
228
|
+
* from item-level declarations.
|
|
229
|
+
*/
|
|
230
|
+
function executePreviewItem(src) {
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Could {@link executePreviewItem} ever answer? A container reifies a rows
|
|
235
|
+
* preview only when its item schema says yes — asked here rather than by
|
|
236
|
+
* running the closure, so an EMPTY list still previews as an empty list
|
|
237
|
+
* instead of not at all.
|
|
238
|
+
*/
|
|
239
|
+
}, {
|
|
240
|
+
key: "declaresItemPreview",
|
|
241
|
+
value: function declaresItemPreview() {
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
220
244
|
// remote(): Src extends RemoteCompatibleSource
|
|
221
245
|
// ? Schema<RemoteSource<Src>>
|
|
222
246
|
// : never {
|
|
@@ -225,7 +249,9 @@ var Schema = /*#__PURE__*/function () {
|
|
|
225
249
|
// }
|
|
226
250
|
|
|
227
251
|
/** MUTATES! since internal and perf sensitive */
|
|
228
|
-
|
|
252
|
+
}, {
|
|
253
|
+
key: "appendValidationError",
|
|
254
|
+
value: function appendValidationError(current, path, message, value, schemaError) {
|
|
229
255
|
if (current) {
|
|
230
256
|
if (current[path]) {
|
|
231
257
|
current[path].push({
|
|
@@ -422,6 +448,7 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
|
422
448
|
var isReadonly = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
423
449
|
var isHidden = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
424
450
|
var description = arguments.length > 7 ? arguments[7] : undefined;
|
|
451
|
+
var previewInput = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
|
|
425
452
|
_classCallCheck(this, StringSchema);
|
|
426
453
|
_this = _callSuper(this, StringSchema);
|
|
427
454
|
_this.options = options;
|
|
@@ -432,13 +459,14 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
|
432
459
|
_this.isReadonly = isReadonly;
|
|
433
460
|
_this.isHidden = isHidden;
|
|
434
461
|
_this.description = description;
|
|
462
|
+
_this.previewInput = previewInput;
|
|
435
463
|
return _this;
|
|
436
464
|
}
|
|
437
465
|
_inherits(StringSchema, _Schema);
|
|
438
466
|
return _createClass(StringSchema, [{
|
|
439
467
|
key: "describe",
|
|
440
468
|
value: function describe(description) {
|
|
441
|
-
return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
|
|
469
|
+
return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.previewInput);
|
|
442
470
|
}
|
|
443
471
|
|
|
444
472
|
/**
|
|
@@ -454,7 +482,7 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
|
454
482
|
value: function minLength(_minLength) {
|
|
455
483
|
return new StringSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
456
484
|
minLength: _minLength
|
|
457
|
-
}), this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description);
|
|
485
|
+
}), this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description, this.previewInput);
|
|
458
486
|
}
|
|
459
487
|
|
|
460
488
|
/**
|
|
@@ -470,7 +498,7 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
|
470
498
|
value: function maxLength(_maxLength) {
|
|
471
499
|
return new StringSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
472
500
|
maxLength: _maxLength
|
|
473
|
-
}), this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description);
|
|
501
|
+
}), this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description, this.previewInput);
|
|
474
502
|
}
|
|
475
503
|
}, {
|
|
476
504
|
key: "regexp",
|
|
@@ -478,12 +506,12 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
|
478
506
|
return new StringSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
479
507
|
regexp: _regexp,
|
|
480
508
|
regExpMessage: message
|
|
481
|
-
}), this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description);
|
|
509
|
+
}), this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description, this.previewInput);
|
|
482
510
|
}
|
|
483
511
|
}, {
|
|
484
512
|
key: "validate",
|
|
485
513
|
value: function validate(validationFunction) {
|
|
486
|
-
return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions.concat(validationFunction), this.renderInput, this.isReadonly, this.isHidden, this.description);
|
|
514
|
+
return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions.concat(validationFunction), this.renderInput, this.isReadonly, this.isHidden, this.description, this.previewInput);
|
|
487
515
|
}
|
|
488
516
|
}, {
|
|
489
517
|
key: "executeValidate",
|
|
@@ -556,22 +584,22 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
|
556
584
|
}, {
|
|
557
585
|
key: "nullable",
|
|
558
586
|
value: function nullable() {
|
|
559
|
-
return new StringSchema(this.options, true, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description);
|
|
587
|
+
return new StringSchema(this.options, true, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description, this.previewInput);
|
|
560
588
|
}
|
|
561
589
|
}, {
|
|
562
590
|
key: "readonly",
|
|
563
591
|
value: function readonly() {
|
|
564
|
-
return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, true, this.isHidden, this.description);
|
|
592
|
+
return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, true, this.isHidden, this.description, this.previewInput);
|
|
565
593
|
}
|
|
566
594
|
}, {
|
|
567
595
|
key: "hidden",
|
|
568
596
|
value: function hidden() {
|
|
569
|
-
return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, true, this.description);
|
|
597
|
+
return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, true, this.description, this.previewInput);
|
|
570
598
|
}
|
|
571
599
|
}, {
|
|
572
600
|
key: "raw",
|
|
573
601
|
value: function raw() {
|
|
574
|
-
return new StringSchema(this.options, this.opt, true, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description);
|
|
602
|
+
return new StringSchema(this.options, this.opt, true, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description, this.previewInput);
|
|
575
603
|
}
|
|
576
604
|
}, {
|
|
577
605
|
key: "executeCustomValidateAt",
|
|
@@ -587,6 +615,7 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
|
587
615
|
return {
|
|
588
616
|
type: "string",
|
|
589
617
|
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
618
|
+
preview: this.previewInput ? true : undefined,
|
|
590
619
|
options: {
|
|
591
620
|
maxLength: (_this$options4 = this.options) === null || _this$options4 === void 0 ? void 0 : _this$options4.maxLength,
|
|
592
621
|
minLength: (_this$options5 = this.options) === null || _this$options5 === void 0 ? void 0 : _this$options5.minLength,
|
|
@@ -616,7 +645,33 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
|
616
645
|
}, {
|
|
617
646
|
key: "render",
|
|
618
647
|
value: function render(input) {
|
|
619
|
-
return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions, input, this.isReadonly, this.isHidden, this.description);
|
|
648
|
+
return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions, input, this.isReadonly, this.isHidden, this.description, this.previewInput);
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
653
|
+
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
654
|
+
* itself is edited (that is `render`). See `preview.ts`.
|
|
655
|
+
*/
|
|
656
|
+
}, {
|
|
657
|
+
key: "preview",
|
|
658
|
+
value: function preview(select) {
|
|
659
|
+
return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description, select);
|
|
660
|
+
}
|
|
661
|
+
}, {
|
|
662
|
+
key: "executePreviewItem",
|
|
663
|
+
value: function executePreviewItem(src) {
|
|
664
|
+
if (this.previewInput === null) {
|
|
665
|
+
return null;
|
|
666
|
+
}
|
|
667
|
+
return this.previewInput({
|
|
668
|
+
val: src
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
}, {
|
|
672
|
+
key: "declaresItemPreview",
|
|
673
|
+
value: function declaresItemPreview() {
|
|
674
|
+
return this.previewInput !== null;
|
|
620
675
|
}
|
|
621
676
|
|
|
622
677
|
/**
|
|
@@ -643,6 +698,8 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
|
|
|
643
698
|
var isReadonly = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
644
699
|
var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
645
700
|
var description = arguments.length > 5 ? arguments[5] : undefined;
|
|
701
|
+
var renderInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
|
|
702
|
+
var previewInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
|
|
646
703
|
_classCallCheck(this, ObjectSchema);
|
|
647
704
|
_this = _callSuper(this, ObjectSchema);
|
|
648
705
|
_this.items = items;
|
|
@@ -651,18 +708,20 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
|
|
|
651
708
|
_this.isReadonly = isReadonly;
|
|
652
709
|
_this.isHidden = isHidden;
|
|
653
710
|
_this.description = description;
|
|
711
|
+
_this.renderInput = renderInput;
|
|
712
|
+
_this.previewInput = previewInput;
|
|
654
713
|
return _this;
|
|
655
714
|
}
|
|
656
715
|
_inherits(ObjectSchema, _Schema);
|
|
657
716
|
return _createClass(ObjectSchema, [{
|
|
658
717
|
key: "describe",
|
|
659
718
|
value: function describe(description) {
|
|
660
|
-
return new ObjectSchema(this.items, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
|
|
719
|
+
return new ObjectSchema(this.items, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput, this.previewInput);
|
|
661
720
|
}
|
|
662
721
|
}, {
|
|
663
722
|
key: "validate",
|
|
664
723
|
value: function validate(validationFunction) {
|
|
665
|
-
return new ObjectSchema(this.items, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description);
|
|
724
|
+
return new ObjectSchema(this.items, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
666
725
|
}
|
|
667
726
|
}, {
|
|
668
727
|
key: "executeValidate",
|
|
@@ -782,17 +841,18 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
|
|
|
782
841
|
}, {
|
|
783
842
|
key: "nullable",
|
|
784
843
|
value: function nullable() {
|
|
785
|
-
|
|
844
|
+
// Explicit type args: `previewInput` would otherwise pin inference to `Src`.
|
|
845
|
+
return new ObjectSchema(this.items, true, [], this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
786
846
|
}
|
|
787
847
|
}, {
|
|
788
848
|
key: "readonly",
|
|
789
849
|
value: function readonly() {
|
|
790
|
-
return new ObjectSchema(this.items, this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
|
|
850
|
+
return new ObjectSchema(this.items, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
791
851
|
}
|
|
792
852
|
}, {
|
|
793
853
|
key: "hidden",
|
|
794
854
|
value: function hidden() {
|
|
795
|
-
return new ObjectSchema(this.items, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
855
|
+
return new ObjectSchema(this.items, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
|
|
796
856
|
}
|
|
797
857
|
}, {
|
|
798
858
|
key: "executeCustomValidateAt",
|
|
@@ -801,12 +861,53 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
|
|
|
801
861
|
path: path
|
|
802
862
|
});
|
|
803
863
|
}
|
|
864
|
+
|
|
865
|
+
/**
|
|
866
|
+
* How this field is laid out in the editor when it is the item of an array
|
|
867
|
+
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
868
|
+
* instead of a preview row that navigates to it.
|
|
869
|
+
*
|
|
870
|
+
* Static configuration, not a callback — see `render.ts`.
|
|
871
|
+
*/
|
|
872
|
+
}, {
|
|
873
|
+
key: "render",
|
|
874
|
+
value: function render(input) {
|
|
875
|
+
return new ObjectSchema(this.items, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
/**
|
|
879
|
+
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
880
|
+
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
881
|
+
* itself is edited (that is `render`). See `preview.ts`.
|
|
882
|
+
*/
|
|
883
|
+
}, {
|
|
884
|
+
key: "preview",
|
|
885
|
+
value: function preview(select) {
|
|
886
|
+
return new ObjectSchema(this.items, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
|
|
887
|
+
}
|
|
888
|
+
}, {
|
|
889
|
+
key: "executePreviewItem",
|
|
890
|
+
value: function executePreviewItem(src) {
|
|
891
|
+
if (this.previewInput === null) {
|
|
892
|
+
return null;
|
|
893
|
+
}
|
|
894
|
+
return this.previewInput({
|
|
895
|
+
val: src
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
}, {
|
|
899
|
+
key: "declaresItemPreview",
|
|
900
|
+
value: function declaresItemPreview() {
|
|
901
|
+
return this.previewInput !== null;
|
|
902
|
+
}
|
|
804
903
|
}, {
|
|
805
904
|
key: "executeSerialize",
|
|
806
905
|
value: function executeSerialize() {
|
|
807
|
-
var _this$customValidateF;
|
|
906
|
+
var _this$renderInput, _this$customValidateF;
|
|
808
907
|
return {
|
|
809
908
|
type: "object",
|
|
909
|
+
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
910
|
+
preview: this.previewInput ? true : undefined,
|
|
810
911
|
items: Object.fromEntries(Object.entries(this.items).map(function (_ref5) {
|
|
811
912
|
var _ref6 = _slicedToArray(_ref5, 2),
|
|
812
913
|
key = _ref6[0],
|
|
@@ -867,6 +968,7 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
|
|
|
867
968
|
var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
868
969
|
var description = arguments.length > 5 ? arguments[5] : undefined;
|
|
869
970
|
var previewInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
|
|
971
|
+
var renderInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
|
|
870
972
|
_classCallCheck(this, ArraySchema);
|
|
871
973
|
_this = _callSuper(this, ArraySchema);
|
|
872
974
|
_this.item = item;
|
|
@@ -876,18 +978,19 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
|
|
|
876
978
|
_this.isHidden = isHidden;
|
|
877
979
|
_this.description = description;
|
|
878
980
|
_this.previewInput = previewInput;
|
|
981
|
+
_this.renderInput = renderInput;
|
|
879
982
|
return _this;
|
|
880
983
|
}
|
|
881
984
|
_inherits(ArraySchema, _Schema);
|
|
882
985
|
return _createClass(ArraySchema, [{
|
|
883
986
|
key: "describe",
|
|
884
987
|
value: function describe(description) {
|
|
885
|
-
return new ArraySchema(this.item, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.previewInput);
|
|
988
|
+
return new ArraySchema(this.item, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.previewInput, this.renderInput);
|
|
886
989
|
}
|
|
887
990
|
}, {
|
|
888
991
|
key: "validate",
|
|
889
992
|
value: function validate(validationFunction) {
|
|
890
|
-
return new ArraySchema(this.item, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.previewInput);
|
|
993
|
+
return new ArraySchema(this.item, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.previewInput, this.renderInput);
|
|
891
994
|
}
|
|
892
995
|
}, {
|
|
893
996
|
key: "executeValidate",
|
|
@@ -954,17 +1057,18 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
|
|
|
954
1057
|
}, {
|
|
955
1058
|
key: "nullable",
|
|
956
1059
|
value: function nullable() {
|
|
957
|
-
|
|
1060
|
+
// Explicit type args: `previewInput` would otherwise pin inference to `Src`.
|
|
1061
|
+
return new ArraySchema(this.item, true, [], this.isReadonly, this.isHidden, this.description, this.previewInput, this.renderInput);
|
|
958
1062
|
}
|
|
959
1063
|
}, {
|
|
960
1064
|
key: "readonly",
|
|
961
1065
|
value: function readonly() {
|
|
962
|
-
return new ArraySchema(this.item, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.previewInput);
|
|
1066
|
+
return new ArraySchema(this.item, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.previewInput, this.renderInput);
|
|
963
1067
|
}
|
|
964
1068
|
}, {
|
|
965
1069
|
key: "hidden",
|
|
966
1070
|
value: function hidden() {
|
|
967
|
-
return new ArraySchema(this.item, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.previewInput);
|
|
1071
|
+
return new ArraySchema(this.item, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.previewInput, this.renderInput);
|
|
968
1072
|
}
|
|
969
1073
|
}, {
|
|
970
1074
|
key: "executeCustomValidateAt",
|
|
@@ -976,9 +1080,10 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
|
|
|
976
1080
|
}, {
|
|
977
1081
|
key: "executeSerialize",
|
|
978
1082
|
value: function executeSerialize() {
|
|
979
|
-
var _this$customValidateF;
|
|
1083
|
+
var _this$renderInput, _this$customValidateF;
|
|
980
1084
|
return {
|
|
981
1085
|
type: "array",
|
|
1086
|
+
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
982
1087
|
item: this.item["executeSerialize"](),
|
|
983
1088
|
opt: this.opt,
|
|
984
1089
|
preview: this.previewInput ? true : undefined,
|
|
@@ -1011,8 +1116,10 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
|
|
|
1011
1116
|
res[_key] = itemResult[_key];
|
|
1012
1117
|
}
|
|
1013
1118
|
}
|
|
1014
|
-
|
|
1015
|
-
|
|
1119
|
+
// The rows preview comes from the ITEM schema's own `preview` — the
|
|
1120
|
+
// container just runs it per row. Asked as a fact rather than by running
|
|
1121
|
+
// the closure, so an empty list still previews as an empty list.
|
|
1122
|
+
if (this.item["declaresItemPreview"]()) {
|
|
1016
1123
|
// The whole list when the LIST is what is being shown; only the wanted
|
|
1017
1124
|
// rows when it is not. The user's closure is the real expense — a list
|
|
1018
1125
|
// view asks for the container and gets every row, a single field asks for
|
|
@@ -1023,26 +1130,30 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
|
|
|
1023
1130
|
var window = scope !== undefined && !scope.wants(sourcePath) ? scope : null;
|
|
1024
1131
|
var items = [];
|
|
1025
1132
|
for (var index = 0; index < src.length; index++) {
|
|
1133
|
+
var _itemSrc = src[index];
|
|
1134
|
+
if (_itemSrc === null || _itemSrc === undefined) {
|
|
1135
|
+
continue;
|
|
1136
|
+
}
|
|
1026
1137
|
if (window !== null && !window.wantsUnder(unsafeCreateSourcePath(sourcePath, index))) {
|
|
1027
1138
|
continue;
|
|
1028
1139
|
}
|
|
1029
|
-
// Per ITEM, not per list
|
|
1030
|
-
//
|
|
1031
|
-
//
|
|
1032
|
-
//
|
|
1140
|
+
// Per ITEM, not per list: the closure is user code, and one row whose
|
|
1141
|
+
// data trips it up must not take out the whole list. Before scoping,
|
|
1142
|
+
// one throwing row produced an error at the container and no items at
|
|
1143
|
+
// all.
|
|
1033
1144
|
try {
|
|
1034
1145
|
// NB NB: display is actually defined by the user
|
|
1035
|
-
var
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
}
|
|
1146
|
+
var _item = this.item["executePreviewItem"](_itemSrc);
|
|
1147
|
+
if (_item !== null) {
|
|
1148
|
+
var title = _item.title,
|
|
1149
|
+
subtitle = _item.subtitle,
|
|
1150
|
+
image = _item.image;
|
|
1151
|
+
items.push([index, {
|
|
1152
|
+
title: title,
|
|
1153
|
+
subtitle: subtitle,
|
|
1154
|
+
image: image
|
|
1155
|
+
}]);
|
|
1156
|
+
}
|
|
1046
1157
|
} catch (e) {
|
|
1047
1158
|
res[unsafeCreateSourcePath(sourcePath, index)] = {
|
|
1048
1159
|
status: "error",
|
|
@@ -1060,18 +1171,45 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
|
|
|
1060
1171
|
}
|
|
1061
1172
|
return res;
|
|
1062
1173
|
}
|
|
1174
|
+
}, {
|
|
1175
|
+
key: "executePreviewItem",
|
|
1176
|
+
value: function executePreviewItem(src) {
|
|
1177
|
+
if (this.previewInput === null) {
|
|
1178
|
+
return null;
|
|
1179
|
+
}
|
|
1180
|
+
return this.previewInput({
|
|
1181
|
+
val: src
|
|
1182
|
+
});
|
|
1183
|
+
}
|
|
1184
|
+
}, {
|
|
1185
|
+
key: "declaresItemPreview",
|
|
1186
|
+
value: function declaresItemPreview() {
|
|
1187
|
+
return this.previewInput !== null;
|
|
1188
|
+
}
|
|
1063
1189
|
|
|
1064
1190
|
/**
|
|
1065
|
-
*
|
|
1066
|
-
*
|
|
1067
|
-
*
|
|
1068
|
-
*
|
|
1069
|
-
* the rows that are actually being looked at — see `PreviewScope`.
|
|
1191
|
+
* How this ARRAY ITSELF is shown where a preview of it is needed — when it
|
|
1192
|
+
* is the item of another container, in search, in references. What its rows
|
|
1193
|
+
* show is the ITEM schema's `preview`, not this. Never how the field is
|
|
1194
|
+
* edited (that is `render`). See `preview.ts`.
|
|
1070
1195
|
*/
|
|
1071
1196
|
}, {
|
|
1072
1197
|
key: "preview",
|
|
1073
1198
|
value: function preview(select) {
|
|
1074
|
-
return new ArraySchema(this.item, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, select);
|
|
1199
|
+
return new ArraySchema(this.item, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, select, this.renderInput);
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
/**
|
|
1203
|
+
* How this field is laid out in the editor when it is the item of an array
|
|
1204
|
+
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
1205
|
+
* instead of a preview row that navigates to it.
|
|
1206
|
+
*
|
|
1207
|
+
* Static configuration, not a callback — see `render.ts`.
|
|
1208
|
+
*/
|
|
1209
|
+
}, {
|
|
1210
|
+
key: "render",
|
|
1211
|
+
value: function render(input) {
|
|
1212
|
+
return new ArraySchema(this.item, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.previewInput, input);
|
|
1075
1213
|
}
|
|
1076
1214
|
}]);
|
|
1077
1215
|
}(Schema);
|
|
@@ -1087,6 +1225,8 @@ var LiteralSchema = /*#__PURE__*/function (_Schema) {
|
|
|
1087
1225
|
var isReadonly = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
1088
1226
|
var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
1089
1227
|
var description = arguments.length > 5 ? arguments[5] : undefined;
|
|
1228
|
+
var renderInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
|
|
1229
|
+
var previewInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
|
|
1090
1230
|
_classCallCheck(this, LiteralSchema);
|
|
1091
1231
|
_this = _callSuper(this, LiteralSchema);
|
|
1092
1232
|
_this.value = value;
|
|
@@ -1095,18 +1235,20 @@ var LiteralSchema = /*#__PURE__*/function (_Schema) {
|
|
|
1095
1235
|
_this.isReadonly = isReadonly;
|
|
1096
1236
|
_this.isHidden = isHidden;
|
|
1097
1237
|
_this.description = description;
|
|
1238
|
+
_this.renderInput = renderInput;
|
|
1239
|
+
_this.previewInput = previewInput;
|
|
1098
1240
|
return _this;
|
|
1099
1241
|
}
|
|
1100
1242
|
_inherits(LiteralSchema, _Schema);
|
|
1101
1243
|
return _createClass(LiteralSchema, [{
|
|
1102
1244
|
key: "describe",
|
|
1103
1245
|
value: function describe(description) {
|
|
1104
|
-
return new LiteralSchema(this.value, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
|
|
1246
|
+
return new LiteralSchema(this.value, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput, this.previewInput);
|
|
1105
1247
|
}
|
|
1106
1248
|
}, {
|
|
1107
1249
|
key: "validate",
|
|
1108
1250
|
value: function validate(validationFunction) {
|
|
1109
|
-
return new LiteralSchema(this.value, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description);
|
|
1251
|
+
return new LiteralSchema(this.value, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
1110
1252
|
}
|
|
1111
1253
|
}, {
|
|
1112
1254
|
key: "executeValidate",
|
|
@@ -1169,17 +1311,17 @@ var LiteralSchema = /*#__PURE__*/function (_Schema) {
|
|
|
1169
1311
|
}, {
|
|
1170
1312
|
key: "nullable",
|
|
1171
1313
|
value: function nullable() {
|
|
1172
|
-
return new LiteralSchema(this.value, true, [], this.isReadonly, this.isHidden, this.description);
|
|
1314
|
+
return new LiteralSchema(this.value, true, [], this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
1173
1315
|
}
|
|
1174
1316
|
}, {
|
|
1175
1317
|
key: "readonly",
|
|
1176
1318
|
value: function readonly() {
|
|
1177
|
-
return new LiteralSchema(this.value, this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
|
|
1319
|
+
return new LiteralSchema(this.value, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
1178
1320
|
}
|
|
1179
1321
|
}, {
|
|
1180
1322
|
key: "hidden",
|
|
1181
1323
|
value: function hidden() {
|
|
1182
|
-
return new LiteralSchema(this.value, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
1324
|
+
return new LiteralSchema(this.value, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
|
|
1183
1325
|
}
|
|
1184
1326
|
}, {
|
|
1185
1327
|
key: "executeCustomValidateAt",
|
|
@@ -1188,12 +1330,53 @@ var LiteralSchema = /*#__PURE__*/function (_Schema) {
|
|
|
1188
1330
|
path: path
|
|
1189
1331
|
});
|
|
1190
1332
|
}
|
|
1333
|
+
|
|
1334
|
+
/**
|
|
1335
|
+
* How this field is laid out in the editor when it is the item of an array
|
|
1336
|
+
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
1337
|
+
* instead of a preview row that navigates to it.
|
|
1338
|
+
*
|
|
1339
|
+
* Static configuration, not a callback — see `render.ts`.
|
|
1340
|
+
*/
|
|
1341
|
+
}, {
|
|
1342
|
+
key: "render",
|
|
1343
|
+
value: function render(input) {
|
|
1344
|
+
return new LiteralSchema(this.value, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
/**
|
|
1348
|
+
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
1349
|
+
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
1350
|
+
* itself is edited (that is `render`). See `preview.ts`.
|
|
1351
|
+
*/
|
|
1352
|
+
}, {
|
|
1353
|
+
key: "preview",
|
|
1354
|
+
value: function preview(select) {
|
|
1355
|
+
return new LiteralSchema(this.value, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
|
|
1356
|
+
}
|
|
1357
|
+
}, {
|
|
1358
|
+
key: "executePreviewItem",
|
|
1359
|
+
value: function executePreviewItem(src) {
|
|
1360
|
+
if (this.previewInput === null) {
|
|
1361
|
+
return null;
|
|
1362
|
+
}
|
|
1363
|
+
return this.previewInput({
|
|
1364
|
+
val: src
|
|
1365
|
+
});
|
|
1366
|
+
}
|
|
1367
|
+
}, {
|
|
1368
|
+
key: "declaresItemPreview",
|
|
1369
|
+
value: function declaresItemPreview() {
|
|
1370
|
+
return this.previewInput !== null;
|
|
1371
|
+
}
|
|
1191
1372
|
}, {
|
|
1192
1373
|
key: "executeSerialize",
|
|
1193
1374
|
value: function executeSerialize() {
|
|
1194
|
-
var _this$customValidateF;
|
|
1375
|
+
var _this$renderInput, _this$customValidateF;
|
|
1195
1376
|
return {
|
|
1196
1377
|
type: "literal",
|
|
1378
|
+
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
1379
|
+
preview: this.previewInput ? true : undefined,
|
|
1197
1380
|
value: this.value,
|
|
1198
1381
|
opt: this.opt,
|
|
1199
1382
|
customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
|
|
@@ -1221,6 +1404,8 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
|
1221
1404
|
var isReadonly = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
1222
1405
|
var isHidden = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
1223
1406
|
var description = arguments.length > 6 ? arguments[6] : undefined;
|
|
1407
|
+
var renderInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
|
|
1408
|
+
var previewInput = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
|
|
1224
1409
|
_classCallCheck(this, UnionSchema);
|
|
1225
1410
|
_this = _callSuper(this, UnionSchema);
|
|
1226
1411
|
_this.key = key;
|
|
@@ -1230,18 +1415,20 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
|
1230
1415
|
_this.isReadonly = isReadonly;
|
|
1231
1416
|
_this.isHidden = isHidden;
|
|
1232
1417
|
_this.description = description;
|
|
1418
|
+
_this.renderInput = renderInput;
|
|
1419
|
+
_this.previewInput = previewInput;
|
|
1233
1420
|
return _this;
|
|
1234
1421
|
}
|
|
1235
1422
|
_inherits(UnionSchema, _Schema);
|
|
1236
1423
|
return _createClass(UnionSchema, [{
|
|
1237
1424
|
key: "describe",
|
|
1238
1425
|
value: function describe(description) {
|
|
1239
|
-
return new UnionSchema(this.key, this.items, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
|
|
1426
|
+
return new UnionSchema(this.key, this.items, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput, this.previewInput);
|
|
1240
1427
|
}
|
|
1241
1428
|
}, {
|
|
1242
1429
|
key: "validate",
|
|
1243
1430
|
value: function validate(validationFunction) {
|
|
1244
|
-
return new UnionSchema(this.key, this.items, this.opt, this.customValidateFunctions.concat(validationFunction), this.isReadonly, this.isHidden, this.description);
|
|
1431
|
+
return new UnionSchema(this.key, this.items, this.opt, this.customValidateFunctions.concat(validationFunction), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
1245
1432
|
}
|
|
1246
1433
|
}, {
|
|
1247
1434
|
key: "executeValidate",
|
|
@@ -1534,17 +1721,18 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
|
1534
1721
|
}, {
|
|
1535
1722
|
key: "nullable",
|
|
1536
1723
|
value: function nullable() {
|
|
1537
|
-
|
|
1724
|
+
// Explicit type args: `previewInput` would otherwise pin inference to `Src`.
|
|
1725
|
+
return new UnionSchema(this.key, this.items, true, [], this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
1538
1726
|
}
|
|
1539
1727
|
}, {
|
|
1540
1728
|
key: "readonly",
|
|
1541
1729
|
value: function readonly() {
|
|
1542
|
-
return new UnionSchema(this.key, this.items, this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
|
|
1730
|
+
return new UnionSchema(this.key, this.items, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
1543
1731
|
}
|
|
1544
1732
|
}, {
|
|
1545
1733
|
key: "hidden",
|
|
1546
1734
|
value: function hidden() {
|
|
1547
|
-
return new UnionSchema(this.key, this.items, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
1735
|
+
return new UnionSchema(this.key, this.items, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
|
|
1548
1736
|
}
|
|
1549
1737
|
}, {
|
|
1550
1738
|
key: "executeCustomValidateAt",
|
|
@@ -1604,14 +1792,69 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
|
1604
1792
|
}
|
|
1605
1793
|
return null;
|
|
1606
1794
|
}
|
|
1795
|
+
|
|
1796
|
+
/**
|
|
1797
|
+
* How this field is laid out in the editor when it is the item of an array
|
|
1798
|
+
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
1799
|
+
* instead of a preview row that navigates to it.
|
|
1800
|
+
*
|
|
1801
|
+
* Static configuration, not a callback — see `render.ts`.
|
|
1802
|
+
*/
|
|
1803
|
+
}, {
|
|
1804
|
+
key: "render",
|
|
1805
|
+
value: function render(input) {
|
|
1806
|
+
return new UnionSchema(this.key, this.items, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1809
|
+
/**
|
|
1810
|
+
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
1811
|
+
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
1812
|
+
* itself is edited (that is `render`). See `preview.ts`.
|
|
1813
|
+
*
|
|
1814
|
+
* Without one of its own, a tagged union previews as the VARIANT the value
|
|
1815
|
+
* takes — declare `preview` on the member objects and the union dispatches.
|
|
1816
|
+
*/
|
|
1817
|
+
}, {
|
|
1818
|
+
key: "preview",
|
|
1819
|
+
value: function preview(select) {
|
|
1820
|
+
return new UnionSchema(this.key, this.items, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
|
|
1821
|
+
}
|
|
1822
|
+
}, {
|
|
1823
|
+
key: "executePreviewItem",
|
|
1824
|
+
value: function executePreviewItem(src) {
|
|
1825
|
+
if (this.previewInput !== null) {
|
|
1826
|
+
return this.previewInput({
|
|
1827
|
+
val: src
|
|
1828
|
+
});
|
|
1829
|
+
}
|
|
1830
|
+
// Only the union knows which variant the value takes; the variant's own
|
|
1831
|
+
// `preview` is what it previews as.
|
|
1832
|
+
var matched = this.matchedVariant(src);
|
|
1833
|
+
if (matched) {
|
|
1834
|
+
return matched["executePreviewItem"](src);
|
|
1835
|
+
}
|
|
1836
|
+
return null;
|
|
1837
|
+
}
|
|
1838
|
+
}, {
|
|
1839
|
+
key: "declaresItemPreview",
|
|
1840
|
+
value: function declaresItemPreview() {
|
|
1841
|
+
if (this.previewInput !== null) {
|
|
1842
|
+
return true;
|
|
1843
|
+
}
|
|
1844
|
+
return Array.isArray(this.items) && this.items.some(function (item) {
|
|
1845
|
+
return item["declaresItemPreview"]();
|
|
1846
|
+
});
|
|
1847
|
+
}
|
|
1607
1848
|
}, {
|
|
1608
1849
|
key: "executeSerialize",
|
|
1609
1850
|
value: function executeSerialize() {
|
|
1610
|
-
var _this$customValidateF2;
|
|
1851
|
+
var _this$renderInput2, _this$customValidateF2;
|
|
1611
1852
|
if (typeof this.key === "string") {
|
|
1612
|
-
var _this$customValidateF;
|
|
1853
|
+
var _this$renderInput, _this$customValidateF;
|
|
1613
1854
|
return {
|
|
1614
1855
|
type: "union",
|
|
1856
|
+
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
1857
|
+
preview: this.previewInput ? true : undefined,
|
|
1615
1858
|
key: this.key,
|
|
1616
1859
|
items: this.items.map(function (o) {
|
|
1617
1860
|
return o["executeSerialize"]();
|
|
@@ -1625,6 +1868,8 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
|
1625
1868
|
}
|
|
1626
1869
|
return {
|
|
1627
1870
|
type: "union",
|
|
1871
|
+
render: (_this$renderInput2 = this.renderInput) !== null && _this$renderInput2 !== void 0 ? _this$renderInput2 : undefined,
|
|
1872
|
+
preview: this.previewInput ? true : undefined,
|
|
1628
1873
|
key: this.key["executeSerialize"](),
|
|
1629
1874
|
items: this.items.map(function (o) {
|
|
1630
1875
|
return o["executeSerialize"]();
|
|
@@ -1861,6 +2106,8 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
|
1861
2106
|
var isReadonly = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
1862
2107
|
var isHidden = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
1863
2108
|
var description = arguments.length > 7 ? arguments[7] : undefined;
|
|
2109
|
+
var renderInput = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
|
|
2110
|
+
var previewInput = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : null;
|
|
1864
2111
|
_classCallCheck(this, ImageSchema);
|
|
1865
2112
|
_this = _callSuper(this, ImageSchema);
|
|
1866
2113
|
_this.options = options;
|
|
@@ -1871,23 +2118,25 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
|
1871
2118
|
_this.isReadonly = isReadonly;
|
|
1872
2119
|
_this.isHidden = isHidden;
|
|
1873
2120
|
_this.description = description;
|
|
2121
|
+
_this.renderInput = renderInput;
|
|
2122
|
+
_this.previewInput = previewInput;
|
|
1874
2123
|
return _this;
|
|
1875
2124
|
}
|
|
1876
2125
|
_inherits(ImageSchema, _Schema);
|
|
1877
2126
|
return _createClass(ImageSchema, [{
|
|
1878
2127
|
key: "describe",
|
|
1879
2128
|
value: function describe(description) {
|
|
1880
|
-
return new ImageSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
|
|
2129
|
+
return new ImageSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput, this.previewInput);
|
|
1881
2130
|
}
|
|
1882
2131
|
}, {
|
|
1883
2132
|
key: "remote",
|
|
1884
2133
|
value: function remote() {
|
|
1885
|
-
return new ImageSchema(this.options, this.opt, true, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description);
|
|
2134
|
+
return new ImageSchema(this.options, this.opt, true, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
1886
2135
|
}
|
|
1887
2136
|
}, {
|
|
1888
2137
|
key: "validate",
|
|
1889
2138
|
value: function validate(validationFunction) {
|
|
1890
|
-
return new ImageSchema(this.options, this.opt, this.isRemote, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.moduleMetadata, this.isReadonly, this.isHidden, this.description);
|
|
2139
|
+
return new ImageSchema(this.options, this.opt, this.isRemote, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.moduleMetadata, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
1891
2140
|
}
|
|
1892
2141
|
}, {
|
|
1893
2142
|
key: "executeValidate",
|
|
@@ -2086,17 +2335,17 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2086
2335
|
}, {
|
|
2087
2336
|
key: "nullable",
|
|
2088
2337
|
value: function nullable() {
|
|
2089
|
-
return new ImageSchema(this.options, true, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description);
|
|
2338
|
+
return new ImageSchema(this.options, true, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
2090
2339
|
}
|
|
2091
2340
|
}, {
|
|
2092
2341
|
key: "readonly",
|
|
2093
2342
|
value: function readonly() {
|
|
2094
|
-
return new ImageSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, true, this.isHidden, this.description);
|
|
2343
|
+
return new ImageSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, true, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
2095
2344
|
}
|
|
2096
2345
|
}, {
|
|
2097
2346
|
key: "hidden",
|
|
2098
2347
|
value: function hidden() {
|
|
2099
|
-
return new ImageSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, true, this.description);
|
|
2348
|
+
return new ImageSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
|
|
2100
2349
|
}
|
|
2101
2350
|
}, {
|
|
2102
2351
|
key: "executeCustomValidateAt",
|
|
@@ -2105,13 +2354,54 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2105
2354
|
path: path
|
|
2106
2355
|
});
|
|
2107
2356
|
}
|
|
2357
|
+
|
|
2358
|
+
/**
|
|
2359
|
+
* How this field is laid out in the editor when it is the item of an array
|
|
2360
|
+
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
2361
|
+
* instead of a preview row that navigates to it.
|
|
2362
|
+
*
|
|
2363
|
+
* Static configuration, not a callback — see `render.ts`.
|
|
2364
|
+
*/
|
|
2365
|
+
}, {
|
|
2366
|
+
key: "render",
|
|
2367
|
+
value: function render(input) {
|
|
2368
|
+
return new ImageSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
|
|
2369
|
+
}
|
|
2370
|
+
|
|
2371
|
+
/**
|
|
2372
|
+
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
2373
|
+
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
2374
|
+
* itself is edited (that is `render`). See `preview.ts`.
|
|
2375
|
+
*/
|
|
2376
|
+
}, {
|
|
2377
|
+
key: "preview",
|
|
2378
|
+
value: function preview(select) {
|
|
2379
|
+
return new ImageSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
|
|
2380
|
+
}
|
|
2381
|
+
}, {
|
|
2382
|
+
key: "executePreviewItem",
|
|
2383
|
+
value: function executePreviewItem(src) {
|
|
2384
|
+
if (this.previewInput === null) {
|
|
2385
|
+
return null;
|
|
2386
|
+
}
|
|
2387
|
+
return this.previewInput({
|
|
2388
|
+
val: src
|
|
2389
|
+
});
|
|
2390
|
+
}
|
|
2391
|
+
}, {
|
|
2392
|
+
key: "declaresItemPreview",
|
|
2393
|
+
value: function declaresItemPreview() {
|
|
2394
|
+
return this.previewInput !== null;
|
|
2395
|
+
}
|
|
2108
2396
|
}, {
|
|
2109
2397
|
key: "executeSerialize",
|
|
2110
2398
|
value: function executeSerialize() {
|
|
2111
|
-
var _this$customValidateF;
|
|
2399
|
+
var _this$renderInput, _this$customValidateF;
|
|
2112
2400
|
var modulePaths = this.moduleMetadata ? Object.keys(this.moduleMetadata) : [];
|
|
2113
2401
|
return {
|
|
2114
2402
|
type: "image",
|
|
2403
|
+
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
2404
|
+
preview: this.previewInput ? true : undefined,
|
|
2115
2405
|
options: this.options,
|
|
2116
2406
|
opt: this.opt,
|
|
2117
2407
|
remote: this.isRemote,
|
|
@@ -2162,6 +2452,8 @@ var RouteSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2162
2452
|
var isReadonly = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
2163
2453
|
var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
2164
2454
|
var description = arguments.length > 5 ? arguments[5] : undefined;
|
|
2455
|
+
var renderInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
|
|
2456
|
+
var previewInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
|
|
2165
2457
|
_classCallCheck(this, RouteSchema);
|
|
2166
2458
|
_this = _callSuper(this, RouteSchema);
|
|
2167
2459
|
_this.options = options;
|
|
@@ -2170,13 +2462,15 @@ var RouteSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2170
2462
|
_this.isReadonly = isReadonly;
|
|
2171
2463
|
_this.isHidden = isHidden;
|
|
2172
2464
|
_this.description = description;
|
|
2465
|
+
_this.renderInput = renderInput;
|
|
2466
|
+
_this.previewInput = previewInput;
|
|
2173
2467
|
return _this;
|
|
2174
2468
|
}
|
|
2175
2469
|
_inherits(RouteSchema, _Schema);
|
|
2176
2470
|
return _createClass(RouteSchema, [{
|
|
2177
2471
|
key: "describe",
|
|
2178
2472
|
value: function describe(description) {
|
|
2179
|
-
return new RouteSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
|
|
2473
|
+
return new RouteSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput, this.previewInput);
|
|
2180
2474
|
}
|
|
2181
2475
|
|
|
2182
2476
|
/**
|
|
@@ -2196,7 +2490,7 @@ var RouteSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2196
2490
|
value: function include(pattern) {
|
|
2197
2491
|
return new RouteSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
2198
2492
|
include: pattern
|
|
2199
|
-
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
|
|
2493
|
+
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
2200
2494
|
}
|
|
2201
2495
|
|
|
2202
2496
|
/**
|
|
@@ -2216,12 +2510,12 @@ var RouteSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2216
2510
|
value: function exclude(pattern) {
|
|
2217
2511
|
return new RouteSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
2218
2512
|
exclude: pattern
|
|
2219
|
-
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
|
|
2513
|
+
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
2220
2514
|
}
|
|
2221
2515
|
}, {
|
|
2222
2516
|
key: "validate",
|
|
2223
2517
|
value: function validate(validationFunction) {
|
|
2224
|
-
return new RouteSchema(this.options, this.opt, this.customValidateFunctions.concat(validationFunction), this.isReadonly, this.isHidden, this.description);
|
|
2518
|
+
return new RouteSchema(this.options, this.opt, this.customValidateFunctions.concat(validationFunction), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
2225
2519
|
}
|
|
2226
2520
|
}, {
|
|
2227
2521
|
key: "executeValidate",
|
|
@@ -2276,17 +2570,17 @@ var RouteSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2276
2570
|
}, {
|
|
2277
2571
|
key: "nullable",
|
|
2278
2572
|
value: function nullable() {
|
|
2279
|
-
return new RouteSchema(this.options, true, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
|
|
2573
|
+
return new RouteSchema(this.options, true, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
2280
2574
|
}
|
|
2281
2575
|
}, {
|
|
2282
2576
|
key: "readonly",
|
|
2283
2577
|
value: function readonly() {
|
|
2284
|
-
return new RouteSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
|
|
2578
|
+
return new RouteSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
2285
2579
|
}
|
|
2286
2580
|
}, {
|
|
2287
2581
|
key: "hidden",
|
|
2288
2582
|
value: function hidden() {
|
|
2289
|
-
return new RouteSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
2583
|
+
return new RouteSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
|
|
2290
2584
|
}
|
|
2291
2585
|
}, {
|
|
2292
2586
|
key: "executeCustomValidateAt",
|
|
@@ -2295,12 +2589,53 @@ var RouteSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2295
2589
|
path: path
|
|
2296
2590
|
});
|
|
2297
2591
|
}
|
|
2592
|
+
|
|
2593
|
+
/**
|
|
2594
|
+
* How this field is laid out in the editor when it is the item of an array
|
|
2595
|
+
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
2596
|
+
* instead of a preview row that navigates to it.
|
|
2597
|
+
*
|
|
2598
|
+
* Static configuration, not a callback — see `render.ts`.
|
|
2599
|
+
*/
|
|
2600
|
+
}, {
|
|
2601
|
+
key: "render",
|
|
2602
|
+
value: function render(input) {
|
|
2603
|
+
return new RouteSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
|
|
2604
|
+
}
|
|
2605
|
+
|
|
2606
|
+
/**
|
|
2607
|
+
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
2608
|
+
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
2609
|
+
* itself is edited (that is `render`). See `preview.ts`.
|
|
2610
|
+
*/
|
|
2611
|
+
}, {
|
|
2612
|
+
key: "preview",
|
|
2613
|
+
value: function preview(select) {
|
|
2614
|
+
return new RouteSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
|
|
2615
|
+
}
|
|
2616
|
+
}, {
|
|
2617
|
+
key: "executePreviewItem",
|
|
2618
|
+
value: function executePreviewItem(src) {
|
|
2619
|
+
if (this.previewInput === null) {
|
|
2620
|
+
return null;
|
|
2621
|
+
}
|
|
2622
|
+
return this.previewInput({
|
|
2623
|
+
val: src
|
|
2624
|
+
});
|
|
2625
|
+
}
|
|
2626
|
+
}, {
|
|
2627
|
+
key: "declaresItemPreview",
|
|
2628
|
+
value: function declaresItemPreview() {
|
|
2629
|
+
return this.previewInput !== null;
|
|
2630
|
+
}
|
|
2298
2631
|
}, {
|
|
2299
2632
|
key: "executeSerialize",
|
|
2300
2633
|
value: function executeSerialize() {
|
|
2301
|
-
var _this$options3, _this$options4, _this$customValidateF, _this$customValidateF2;
|
|
2634
|
+
var _this$renderInput, _this$options3, _this$options4, _this$customValidateF, _this$customValidateF2;
|
|
2302
2635
|
return {
|
|
2303
2636
|
type: "route",
|
|
2637
|
+
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
2638
|
+
preview: this.previewInput ? true : undefined,
|
|
2304
2639
|
options: {
|
|
2305
2640
|
include: ((_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : _this$options3.include) && {
|
|
2306
2641
|
source: this.options.include.source,
|
|
@@ -2338,6 +2673,8 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2338
2673
|
var isReadonly = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
2339
2674
|
var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
2340
2675
|
var description = arguments.length > 5 ? arguments[5] : undefined;
|
|
2676
|
+
var renderInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
|
|
2677
|
+
var previewInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
|
|
2341
2678
|
_classCallCheck(this, RichTextSchema);
|
|
2342
2679
|
_this = _callSuper(this, RichTextSchema);
|
|
2343
2680
|
_this.options = options;
|
|
@@ -2346,32 +2683,34 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2346
2683
|
_this.isReadonly = isReadonly;
|
|
2347
2684
|
_this.isHidden = isHidden;
|
|
2348
2685
|
_this.description = description;
|
|
2686
|
+
_this.renderInput = renderInput;
|
|
2687
|
+
_this.previewInput = previewInput;
|
|
2349
2688
|
return _this;
|
|
2350
2689
|
}
|
|
2351
2690
|
_inherits(RichTextSchema, _Schema);
|
|
2352
2691
|
return _createClass(RichTextSchema, [{
|
|
2353
2692
|
key: "describe",
|
|
2354
2693
|
value: function describe(description) {
|
|
2355
|
-
return new RichTextSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
|
|
2694
|
+
return new RichTextSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput, this.previewInput);
|
|
2356
2695
|
}
|
|
2357
2696
|
}, {
|
|
2358
2697
|
key: "maxLength",
|
|
2359
2698
|
value: function maxLength(max) {
|
|
2360
2699
|
return new RichTextSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
2361
2700
|
maxLength: max
|
|
2362
|
-
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
|
|
2701
|
+
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
2363
2702
|
}
|
|
2364
2703
|
}, {
|
|
2365
2704
|
key: "minLength",
|
|
2366
2705
|
value: function minLength(min) {
|
|
2367
2706
|
return new RichTextSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
2368
2707
|
minLength: min
|
|
2369
|
-
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
|
|
2708
|
+
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
2370
2709
|
}
|
|
2371
2710
|
}, {
|
|
2372
2711
|
key: "validate",
|
|
2373
2712
|
value: function validate(validationFunction) {
|
|
2374
|
-
return new RichTextSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description);
|
|
2713
|
+
return new RichTextSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
2375
2714
|
}
|
|
2376
2715
|
}, {
|
|
2377
2716
|
key: "executeValidate",
|
|
@@ -2821,17 +3160,17 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2821
3160
|
}, {
|
|
2822
3161
|
key: "nullable",
|
|
2823
3162
|
value: function nullable() {
|
|
2824
|
-
return new RichTextSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description);
|
|
3163
|
+
return new RichTextSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
2825
3164
|
}
|
|
2826
3165
|
}, {
|
|
2827
3166
|
key: "readonly",
|
|
2828
3167
|
value: function readonly() {
|
|
2829
|
-
return new RichTextSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
|
|
3168
|
+
return new RichTextSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
2830
3169
|
}
|
|
2831
3170
|
}, {
|
|
2832
3171
|
key: "hidden",
|
|
2833
3172
|
value: function hidden() {
|
|
2834
|
-
return new RichTextSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
3173
|
+
return new RichTextSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
|
|
2835
3174
|
}
|
|
2836
3175
|
}, {
|
|
2837
3176
|
key: "executeCustomValidateAt",
|
|
@@ -2840,10 +3179,50 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2840
3179
|
path: path
|
|
2841
3180
|
});
|
|
2842
3181
|
}
|
|
3182
|
+
|
|
3183
|
+
/**
|
|
3184
|
+
* How this field is laid out in the editor when it is the item of an array
|
|
3185
|
+
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
3186
|
+
* instead of a preview row that navigates to it.
|
|
3187
|
+
*
|
|
3188
|
+
* Static configuration, not a callback — see `render.ts`.
|
|
3189
|
+
*/
|
|
3190
|
+
}, {
|
|
3191
|
+
key: "render",
|
|
3192
|
+
value: function render(input) {
|
|
3193
|
+
return new RichTextSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
|
|
3194
|
+
}
|
|
3195
|
+
|
|
3196
|
+
/**
|
|
3197
|
+
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
3198
|
+
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
3199
|
+
* itself is edited (that is `render`). See `preview.ts`.
|
|
3200
|
+
*/
|
|
3201
|
+
}, {
|
|
3202
|
+
key: "preview",
|
|
3203
|
+
value: function preview(select) {
|
|
3204
|
+
return new RichTextSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
|
|
3205
|
+
}
|
|
3206
|
+
}, {
|
|
3207
|
+
key: "executePreviewItem",
|
|
3208
|
+
value: function executePreviewItem(src) {
|
|
3209
|
+
if (this.previewInput === null) {
|
|
3210
|
+
return null;
|
|
3211
|
+
}
|
|
3212
|
+
return this.previewInput({
|
|
3213
|
+
val: src
|
|
3214
|
+
});
|
|
3215
|
+
}
|
|
3216
|
+
}, {
|
|
3217
|
+
key: "declaresItemPreview",
|
|
3218
|
+
value: function declaresItemPreview() {
|
|
3219
|
+
return this.previewInput !== null;
|
|
3220
|
+
}
|
|
2843
3221
|
}, {
|
|
2844
3222
|
key: "executeSerialize",
|
|
2845
3223
|
value: function executeSerialize() {
|
|
2846
3224
|
var _this3 = this,
|
|
3225
|
+
_this$renderInput,
|
|
2847
3226
|
_this$customValidateF;
|
|
2848
3227
|
var serializeAnchorSchema = function serializeAnchorSchema() {
|
|
2849
3228
|
var _this3$options$inline, _this3$options$inline3;
|
|
@@ -2870,6 +3249,8 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2870
3249
|
};
|
|
2871
3250
|
return {
|
|
2872
3251
|
type: "richtext",
|
|
3252
|
+
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
3253
|
+
preview: this.previewInput ? true : undefined,
|
|
2873
3254
|
opt: this.opt,
|
|
2874
3255
|
options: serializedOptions,
|
|
2875
3256
|
customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
|
|
@@ -3214,6 +3595,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3214
3595
|
var description = arguments.length > 8 ? arguments[8] : undefined;
|
|
3215
3596
|
var isJsonValues = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : false;
|
|
3216
3597
|
var previewInput = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : null;
|
|
3598
|
+
var renderInput = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : null;
|
|
3217
3599
|
_classCallCheck(this, RecordSchema);
|
|
3218
3600
|
_this = _callSuper(this, RecordSchema);
|
|
3219
3601
|
_this.item = item;
|
|
@@ -3227,18 +3609,19 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3227
3609
|
_this.description = description;
|
|
3228
3610
|
_this.isJsonValues = isJsonValues;
|
|
3229
3611
|
_this.previewInput = previewInput;
|
|
3612
|
+
_this.renderInput = renderInput;
|
|
3230
3613
|
return _this;
|
|
3231
3614
|
}
|
|
3232
3615
|
_inherits(RecordSchema, _Schema);
|
|
3233
3616
|
return _createClass(RecordSchema, [{
|
|
3234
3617
|
key: "describe",
|
|
3235
3618
|
value: function describe(description) {
|
|
3236
|
-
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.isJsonValues, this.previewInput);
|
|
3619
|
+
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.isJsonValues, this.previewInput, this.renderInput);
|
|
3237
3620
|
}
|
|
3238
3621
|
}, {
|
|
3239
3622
|
key: "validate",
|
|
3240
3623
|
value: function validate(validationFunction) {
|
|
3241
|
-
return new RecordSchema(this.item, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.previewInput);
|
|
3624
|
+
return new RecordSchema(this.item, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.previewInput, this.renderInput);
|
|
3242
3625
|
}
|
|
3243
3626
|
}, {
|
|
3244
3627
|
key: "executeValidate",
|
|
@@ -3597,29 +3980,29 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3597
3980
|
}, {
|
|
3598
3981
|
key: "nullable",
|
|
3599
3982
|
value: function nullable() {
|
|
3600
|
-
return new RecordSchema(this.item, true, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.previewInput);
|
|
3983
|
+
return new RecordSchema(this.item, true, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.previewInput, this.renderInput);
|
|
3601
3984
|
}
|
|
3602
3985
|
}, {
|
|
3603
3986
|
key: "readonly",
|
|
3604
3987
|
value: function readonly() {
|
|
3605
|
-
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, true, this.isHidden, this.description, this.isJsonValues, this.previewInput);
|
|
3988
|
+
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, true, this.isHidden, this.description, this.isJsonValues, this.previewInput, this.renderInput);
|
|
3606
3989
|
}
|
|
3607
3990
|
}, {
|
|
3608
3991
|
key: "hidden",
|
|
3609
3992
|
value: function hidden() {
|
|
3610
|
-
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, true, this.description, this.isJsonValues, this.previewInput);
|
|
3993
|
+
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, true, this.description, this.isJsonValues, this.previewInput, this.renderInput);
|
|
3611
3994
|
}
|
|
3612
3995
|
}, {
|
|
3613
3996
|
key: "router",
|
|
3614
3997
|
value: function router(_router) {
|
|
3615
|
-
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, _router, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.previewInput);
|
|
3998
|
+
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, _router, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.previewInput, this.renderInput);
|
|
3616
3999
|
}
|
|
3617
4000
|
}, {
|
|
3618
4001
|
key: "remote",
|
|
3619
4002
|
value: function remote() {
|
|
3620
4003
|
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions ? _objectSpread2(_objectSpread2({}, this.mediaOptions), {}, {
|
|
3621
4004
|
remote: true
|
|
3622
|
-
}) : undefined, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.previewInput);
|
|
4005
|
+
}) : undefined, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.previewInput, this.renderInput);
|
|
3623
4006
|
}
|
|
3624
4007
|
|
|
3625
4008
|
/**
|
|
@@ -3649,9 +4032,19 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3649
4032
|
// `.validate(...)` in their source file that never ran anywhere.
|
|
3650
4033
|
throw new Error(".jsonValues() must come BEFORE .validate(): a validator added first is typed against the un-lazy source shape and cannot be carried over. Write s.record(...).jsonValues().validate(...) instead.");
|
|
3651
4034
|
}
|
|
4035
|
+
if (this.previewInput !== null) {
|
|
4036
|
+
// Same reasoning as the validator guard above: the record's own preview
|
|
4037
|
+
// closure is typed against the un-lazy source shape.
|
|
4038
|
+
throw new Error(".jsonValues() must come BEFORE .preview(): a preview added first is typed against the un-lazy source shape and cannot be carried over. Write s.record(...).jsonValues().preview(...) instead.");
|
|
4039
|
+
}
|
|
4040
|
+
// Explicit type args instead of a cast on the result: `previewInput` would
|
|
4041
|
+
// otherwise pin inference to `Src`, and the two record source shapes no
|
|
4042
|
+
// longer overlap enough for the old assertion.
|
|
3652
4043
|
return new RecordSchema(this.item, this.opt,
|
|
3653
4044
|
// Empty by construction: the guard above rejects any that were registered.
|
|
3654
|
-
[], this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, true,
|
|
4045
|
+
[], this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, true,
|
|
4046
|
+
// Null by construction: the guard above rejects any that was declared.
|
|
4047
|
+
null, this.renderInput);
|
|
3655
4048
|
}
|
|
3656
4049
|
}, {
|
|
3657
4050
|
key: "getRouterValidations",
|
|
@@ -3705,9 +4098,10 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3705
4098
|
}, {
|
|
3706
4099
|
key: "executeSerialize",
|
|
3707
4100
|
value: function executeSerialize() {
|
|
3708
|
-
var _this$keySchema, _this$currentRouter, _this$customValidateF;
|
|
4101
|
+
var _this$renderInput, _this$keySchema, _this$currentRouter, _this$customValidateF;
|
|
3709
4102
|
var result = {
|
|
3710
4103
|
type: "record",
|
|
4104
|
+
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
3711
4105
|
item: this.item["executeSerialize"](),
|
|
3712
4106
|
key: (_this$keySchema = this.keySchema) === null || _this$keySchema === void 0 ? void 0 : _this$keySchema["executeSerialize"](),
|
|
3713
4107
|
opt: this.opt,
|
|
@@ -3771,8 +4165,10 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3771
4165
|
res[_key2] = itemResult[_key2];
|
|
3772
4166
|
}
|
|
3773
4167
|
}
|
|
3774
|
-
|
|
3775
|
-
|
|
4168
|
+
// The entries preview comes from the ITEM schema's own `preview` — the
|
|
4169
|
+
// container just runs it per entry. Asked as a fact rather than by running
|
|
4170
|
+
// the closure, so an empty record still previews as an empty record.
|
|
4171
|
+
if (this.item["declaresItemPreview"]()) {
|
|
3776
4172
|
// See the same block in `array`: the whole record when the record is what
|
|
3777
4173
|
// is being shown, only the wanted entries when it is not.
|
|
3778
4174
|
var window = scope !== undefined && !scope.wants(sourcePath) ? scope : null;
|
|
@@ -3784,6 +4180,9 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3784
4180
|
if (isJson(val)) {
|
|
3785
4181
|
continue; // as above: nothing to select from an un-loaded entry
|
|
3786
4182
|
}
|
|
4183
|
+
if (val === null || val === undefined) {
|
|
4184
|
+
continue;
|
|
4185
|
+
}
|
|
3787
4186
|
if (window !== null && !window.wantsUnder(unsafeCreateSourcePath(sourcePath, _key3))) {
|
|
3788
4187
|
continue;
|
|
3789
4188
|
}
|
|
@@ -3791,18 +4190,17 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3791
4190
|
// data trips it up must not take out the whole list.
|
|
3792
4191
|
try {
|
|
3793
4192
|
// NB NB: display is actually defined by the user
|
|
3794
|
-
var
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
}]);
|
|
4193
|
+
var _item = this.item["executePreviewItem"](val);
|
|
4194
|
+
if (_item !== null) {
|
|
4195
|
+
var title = _item.title,
|
|
4196
|
+
subtitle = _item.subtitle,
|
|
4197
|
+
image = _item.image;
|
|
4198
|
+
items.push([_key3, {
|
|
4199
|
+
title: title,
|
|
4200
|
+
subtitle: subtitle,
|
|
4201
|
+
image: image
|
|
4202
|
+
}]);
|
|
4203
|
+
}
|
|
3806
4204
|
} catch (e) {
|
|
3807
4205
|
res[unsafeCreateSourcePath(sourcePath, _key3)] = {
|
|
3808
4206
|
status: "error",
|
|
@@ -3820,19 +4218,45 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3820
4218
|
}
|
|
3821
4219
|
return res;
|
|
3822
4220
|
}
|
|
4221
|
+
}, {
|
|
4222
|
+
key: "executePreviewItem",
|
|
4223
|
+
value: function executePreviewItem(src) {
|
|
4224
|
+
if (this.previewInput === null) {
|
|
4225
|
+
return null;
|
|
4226
|
+
}
|
|
4227
|
+
return this.previewInput({
|
|
4228
|
+
val: src
|
|
4229
|
+
});
|
|
4230
|
+
}
|
|
4231
|
+
}, {
|
|
4232
|
+
key: "declaresItemPreview",
|
|
4233
|
+
value: function declaresItemPreview() {
|
|
4234
|
+
return this.previewInput !== null;
|
|
4235
|
+
}
|
|
3823
4236
|
|
|
3824
4237
|
/**
|
|
3825
|
-
*
|
|
3826
|
-
*
|
|
3827
|
-
*
|
|
3828
|
-
*
|
|
3829
|
-
* demand for the entries that are actually being looked at — see
|
|
3830
|
-
* `PreviewScope`.
|
|
4238
|
+
* How this RECORD ITSELF is shown where a preview of it is needed — when it
|
|
4239
|
+
* is the item of another container, in search, in references. What its
|
|
4240
|
+
* entries show is the ITEM schema's `preview`, not this. Never how the field
|
|
4241
|
+
* is edited (that is `render`). See `preview.ts`.
|
|
3831
4242
|
*/
|
|
3832
4243
|
}, {
|
|
3833
4244
|
key: "preview",
|
|
3834
4245
|
value: function preview(select) {
|
|
3835
|
-
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, select);
|
|
4246
|
+
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, select, this.renderInput);
|
|
4247
|
+
}
|
|
4248
|
+
|
|
4249
|
+
/**
|
|
4250
|
+
* How this field is laid out in the editor when it is the item of an array
|
|
4251
|
+
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
4252
|
+
* instead of a preview row that navigates to it.
|
|
4253
|
+
*
|
|
4254
|
+
* Static configuration, not a callback — see `render.ts`.
|
|
4255
|
+
*/
|
|
4256
|
+
}, {
|
|
4257
|
+
key: "render",
|
|
4258
|
+
value: function render(input) {
|
|
4259
|
+
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.previewInput, input);
|
|
3836
4260
|
}
|
|
3837
4261
|
}]);
|
|
3838
4262
|
}(Schema);
|
|
@@ -4401,6 +4825,8 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4401
4825
|
var isReadonly = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
4402
4826
|
var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
4403
4827
|
var description = arguments.length > 5 ? arguments[5] : undefined;
|
|
4828
|
+
var renderInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
|
|
4829
|
+
var previewInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
|
|
4404
4830
|
_classCallCheck(this, NumberSchema);
|
|
4405
4831
|
_this = _callSuper(this, NumberSchema);
|
|
4406
4832
|
_this.options = options;
|
|
@@ -4409,18 +4835,20 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4409
4835
|
_this.isReadonly = isReadonly;
|
|
4410
4836
|
_this.isHidden = isHidden;
|
|
4411
4837
|
_this.description = description;
|
|
4838
|
+
_this.renderInput = renderInput;
|
|
4839
|
+
_this.previewInput = previewInput;
|
|
4412
4840
|
return _this;
|
|
4413
4841
|
}
|
|
4414
4842
|
_inherits(NumberSchema, _Schema);
|
|
4415
4843
|
return _createClass(NumberSchema, [{
|
|
4416
4844
|
key: "describe",
|
|
4417
4845
|
value: function describe(description) {
|
|
4418
|
-
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
|
|
4846
|
+
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput, this.previewInput);
|
|
4419
4847
|
}
|
|
4420
4848
|
}, {
|
|
4421
4849
|
key: "validate",
|
|
4422
4850
|
value: function validate(validationFunction) {
|
|
4423
|
-
return new NumberSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description);
|
|
4851
|
+
return new NumberSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
4424
4852
|
}
|
|
4425
4853
|
}, {
|
|
4426
4854
|
key: "executeValidate",
|
|
@@ -4490,31 +4918,31 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4490
4918
|
}, {
|
|
4491
4919
|
key: "nullable",
|
|
4492
4920
|
value: function nullable() {
|
|
4493
|
-
return new NumberSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description);
|
|
4921
|
+
return new NumberSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
4494
4922
|
}
|
|
4495
4923
|
}, {
|
|
4496
4924
|
key: "readonly",
|
|
4497
4925
|
value: function readonly() {
|
|
4498
|
-
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
|
|
4926
|
+
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
4499
4927
|
}
|
|
4500
4928
|
}, {
|
|
4501
4929
|
key: "hidden",
|
|
4502
4930
|
value: function hidden() {
|
|
4503
|
-
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
4931
|
+
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
|
|
4504
4932
|
}
|
|
4505
4933
|
}, {
|
|
4506
4934
|
key: "max",
|
|
4507
4935
|
value: function max(_max) {
|
|
4508
4936
|
return new NumberSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
4509
4937
|
max: _max
|
|
4510
|
-
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
|
|
4938
|
+
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
4511
4939
|
}
|
|
4512
4940
|
}, {
|
|
4513
4941
|
key: "min",
|
|
4514
4942
|
value: function min(_min) {
|
|
4515
4943
|
return new NumberSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
4516
4944
|
min: _min
|
|
4517
|
-
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
|
|
4945
|
+
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
4518
4946
|
}
|
|
4519
4947
|
}, {
|
|
4520
4948
|
key: "executeCustomValidateAt",
|
|
@@ -4523,12 +4951,53 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4523
4951
|
path: path
|
|
4524
4952
|
});
|
|
4525
4953
|
}
|
|
4954
|
+
|
|
4955
|
+
/**
|
|
4956
|
+
* How this field is laid out in the editor when it is the item of an array
|
|
4957
|
+
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
4958
|
+
* instead of a preview row that navigates to it.
|
|
4959
|
+
*
|
|
4960
|
+
* Static configuration, not a callback — see `render.ts`.
|
|
4961
|
+
*/
|
|
4962
|
+
}, {
|
|
4963
|
+
key: "render",
|
|
4964
|
+
value: function render(input) {
|
|
4965
|
+
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
|
|
4966
|
+
}
|
|
4967
|
+
|
|
4968
|
+
/**
|
|
4969
|
+
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
4970
|
+
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
4971
|
+
* itself is edited (that is `render`). See `preview.ts`.
|
|
4972
|
+
*/
|
|
4973
|
+
}, {
|
|
4974
|
+
key: "preview",
|
|
4975
|
+
value: function preview(select) {
|
|
4976
|
+
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
|
|
4977
|
+
}
|
|
4978
|
+
}, {
|
|
4979
|
+
key: "executePreviewItem",
|
|
4980
|
+
value: function executePreviewItem(src) {
|
|
4981
|
+
if (this.previewInput === null) {
|
|
4982
|
+
return null;
|
|
4983
|
+
}
|
|
4984
|
+
return this.previewInput({
|
|
4985
|
+
val: src
|
|
4986
|
+
});
|
|
4987
|
+
}
|
|
4988
|
+
}, {
|
|
4989
|
+
key: "declaresItemPreview",
|
|
4990
|
+
value: function declaresItemPreview() {
|
|
4991
|
+
return this.previewInput !== null;
|
|
4992
|
+
}
|
|
4526
4993
|
}, {
|
|
4527
4994
|
key: "executeSerialize",
|
|
4528
4995
|
value: function executeSerialize() {
|
|
4529
|
-
var _this$customValidateF;
|
|
4996
|
+
var _this$renderInput, _this$customValidateF;
|
|
4530
4997
|
return {
|
|
4531
4998
|
type: "number",
|
|
4999
|
+
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
5000
|
+
preview: this.previewInput ? true : undefined,
|
|
4532
5001
|
options: this.options,
|
|
4533
5002
|
opt: this.opt,
|
|
4534
5003
|
customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
|
|
@@ -4556,6 +5025,8 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4556
5025
|
var isReadonly = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
4557
5026
|
var isHidden = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
4558
5027
|
var description = arguments.length > 4 ? arguments[4] : undefined;
|
|
5028
|
+
var renderInput = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
|
|
5029
|
+
var previewInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
|
|
4559
5030
|
_classCallCheck(this, BooleanSchema);
|
|
4560
5031
|
_this = _callSuper(this, BooleanSchema);
|
|
4561
5032
|
_this.opt = opt;
|
|
@@ -4563,18 +5034,20 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4563
5034
|
_this.isReadonly = isReadonly;
|
|
4564
5035
|
_this.isHidden = isHidden;
|
|
4565
5036
|
_this.description = description;
|
|
5037
|
+
_this.renderInput = renderInput;
|
|
5038
|
+
_this.previewInput = previewInput;
|
|
4566
5039
|
return _this;
|
|
4567
5040
|
}
|
|
4568
5041
|
_inherits(BooleanSchema, _Schema);
|
|
4569
5042
|
return _createClass(BooleanSchema, [{
|
|
4570
5043
|
key: "describe",
|
|
4571
5044
|
value: function describe(description) {
|
|
4572
|
-
return new BooleanSchema(this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
|
|
5045
|
+
return new BooleanSchema(this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput, this.previewInput);
|
|
4573
5046
|
}
|
|
4574
5047
|
}, {
|
|
4575
5048
|
key: "validate",
|
|
4576
5049
|
value: function validate(validationFunction) {
|
|
4577
|
-
return new BooleanSchema(this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description);
|
|
5050
|
+
return new BooleanSchema(this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
4578
5051
|
}
|
|
4579
5052
|
}, {
|
|
4580
5053
|
key: "executeValidate",
|
|
@@ -4625,17 +5098,17 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4625
5098
|
}, {
|
|
4626
5099
|
key: "nullable",
|
|
4627
5100
|
value: function nullable() {
|
|
4628
|
-
return new BooleanSchema(true, [], this.isReadonly, this.isHidden, this.description);
|
|
5101
|
+
return new BooleanSchema(true, [], this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
4629
5102
|
}
|
|
4630
5103
|
}, {
|
|
4631
5104
|
key: "readonly",
|
|
4632
5105
|
value: function readonly() {
|
|
4633
|
-
return new BooleanSchema(this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
|
|
5106
|
+
return new BooleanSchema(this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
4634
5107
|
}
|
|
4635
5108
|
}, {
|
|
4636
5109
|
key: "hidden",
|
|
4637
5110
|
value: function hidden() {
|
|
4638
|
-
return new BooleanSchema(this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
5111
|
+
return new BooleanSchema(this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
|
|
4639
5112
|
}
|
|
4640
5113
|
}, {
|
|
4641
5114
|
key: "executeCustomValidateAt",
|
|
@@ -4644,12 +5117,53 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4644
5117
|
path: path
|
|
4645
5118
|
});
|
|
4646
5119
|
}
|
|
5120
|
+
|
|
5121
|
+
/**
|
|
5122
|
+
* How this field is laid out in the editor when it is the item of an array
|
|
5123
|
+
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
5124
|
+
* instead of a preview row that navigates to it.
|
|
5125
|
+
*
|
|
5126
|
+
* Static configuration, not a callback — see `render.ts`.
|
|
5127
|
+
*/
|
|
5128
|
+
}, {
|
|
5129
|
+
key: "render",
|
|
5130
|
+
value: function render(input) {
|
|
5131
|
+
return new BooleanSchema(this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
|
|
5132
|
+
}
|
|
5133
|
+
|
|
5134
|
+
/**
|
|
5135
|
+
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
5136
|
+
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
5137
|
+
* itself is edited (that is `render`). See `preview.ts`.
|
|
5138
|
+
*/
|
|
5139
|
+
}, {
|
|
5140
|
+
key: "preview",
|
|
5141
|
+
value: function preview(select) {
|
|
5142
|
+
return new BooleanSchema(this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
|
|
5143
|
+
}
|
|
5144
|
+
}, {
|
|
5145
|
+
key: "executePreviewItem",
|
|
5146
|
+
value: function executePreviewItem(src) {
|
|
5147
|
+
if (this.previewInput === null) {
|
|
5148
|
+
return null;
|
|
5149
|
+
}
|
|
5150
|
+
return this.previewInput({
|
|
5151
|
+
val: src
|
|
5152
|
+
});
|
|
5153
|
+
}
|
|
5154
|
+
}, {
|
|
5155
|
+
key: "declaresItemPreview",
|
|
5156
|
+
value: function declaresItemPreview() {
|
|
5157
|
+
return this.previewInput !== null;
|
|
5158
|
+
}
|
|
4647
5159
|
}, {
|
|
4648
5160
|
key: "executeSerialize",
|
|
4649
5161
|
value: function executeSerialize() {
|
|
4650
|
-
var _this$customValidateF;
|
|
5162
|
+
var _this$renderInput, _this$customValidateF;
|
|
4651
5163
|
return {
|
|
4652
5164
|
type: "boolean",
|
|
5165
|
+
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
5166
|
+
preview: this.previewInput ? true : undefined,
|
|
4653
5167
|
opt: this.opt,
|
|
4654
5168
|
customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
|
|
4655
5169
|
readonly: this.isReadonly,
|
|
@@ -4676,6 +5190,8 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4676
5190
|
var isReadonly = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
4677
5191
|
var isHidden = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
4678
5192
|
var description = arguments.length > 6 ? arguments[6] : undefined;
|
|
5193
|
+
var renderInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
|
|
5194
|
+
var previewInput = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
|
|
4679
5195
|
_classCallCheck(this, KeyOfSchema);
|
|
4680
5196
|
_this = _callSuper(this, KeyOfSchema);
|
|
4681
5197
|
_this.schema = schema;
|
|
@@ -4685,18 +5201,20 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4685
5201
|
_this.isReadonly = isReadonly;
|
|
4686
5202
|
_this.isHidden = isHidden;
|
|
4687
5203
|
_this.description = description;
|
|
5204
|
+
_this.renderInput = renderInput;
|
|
5205
|
+
_this.previewInput = previewInput;
|
|
4688
5206
|
return _this;
|
|
4689
5207
|
}
|
|
4690
5208
|
_inherits(KeyOfSchema, _Schema);
|
|
4691
5209
|
return _createClass(KeyOfSchema, [{
|
|
4692
5210
|
key: "describe",
|
|
4693
5211
|
value: function describe(description) {
|
|
4694
|
-
return new KeyOfSchema(this.schema, this.sourcePath, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
|
|
5212
|
+
return new KeyOfSchema(this.schema, this.sourcePath, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput, this.previewInput);
|
|
4695
5213
|
}
|
|
4696
5214
|
}, {
|
|
4697
5215
|
key: "validate",
|
|
4698
5216
|
value: function validate(validationFunction) {
|
|
4699
|
-
return new KeyOfSchema(this.schema, this.sourcePath, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description);
|
|
5217
|
+
return new KeyOfSchema(this.schema, this.sourcePath, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
4700
5218
|
}
|
|
4701
5219
|
}, {
|
|
4702
5220
|
key: "executeValidate",
|
|
@@ -4826,17 +5344,17 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4826
5344
|
}, {
|
|
4827
5345
|
key: "nullable",
|
|
4828
5346
|
value: function nullable() {
|
|
4829
|
-
return new KeyOfSchema(this.schema, this.sourcePath, true, [], this.isReadonly, this.isHidden, this.description);
|
|
5347
|
+
return new KeyOfSchema(this.schema, this.sourcePath, true, [], this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
4830
5348
|
}
|
|
4831
5349
|
}, {
|
|
4832
5350
|
key: "readonly",
|
|
4833
5351
|
value: function readonly() {
|
|
4834
|
-
return new KeyOfSchema(this.schema, this.sourcePath, this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
|
|
5352
|
+
return new KeyOfSchema(this.schema, this.sourcePath, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
4835
5353
|
}
|
|
4836
5354
|
}, {
|
|
4837
5355
|
key: "hidden",
|
|
4838
5356
|
value: function hidden() {
|
|
4839
|
-
return new KeyOfSchema(this.schema, this.sourcePath, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
5357
|
+
return new KeyOfSchema(this.schema, this.sourcePath, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
|
|
4840
5358
|
}
|
|
4841
5359
|
}, {
|
|
4842
5360
|
key: "executeCustomValidateAt",
|
|
@@ -4845,10 +5363,49 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4845
5363
|
path: path
|
|
4846
5364
|
});
|
|
4847
5365
|
}
|
|
5366
|
+
|
|
5367
|
+
/**
|
|
5368
|
+
* How this field is laid out in the editor when it is the item of an array
|
|
5369
|
+
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
5370
|
+
* instead of a preview row that navigates to it.
|
|
5371
|
+
*
|
|
5372
|
+
* Static configuration, not a callback — see `render.ts`.
|
|
5373
|
+
*/
|
|
5374
|
+
}, {
|
|
5375
|
+
key: "render",
|
|
5376
|
+
value: function render(input) {
|
|
5377
|
+
return new KeyOfSchema(this.schema, this.sourcePath, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
|
|
5378
|
+
}
|
|
5379
|
+
|
|
5380
|
+
/**
|
|
5381
|
+
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
5382
|
+
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
5383
|
+
* itself is edited (that is `render`). See `preview.ts`.
|
|
5384
|
+
*/
|
|
5385
|
+
}, {
|
|
5386
|
+
key: "preview",
|
|
5387
|
+
value: function preview(select) {
|
|
5388
|
+
return new KeyOfSchema(this.schema, this.sourcePath, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
|
|
5389
|
+
}
|
|
5390
|
+
}, {
|
|
5391
|
+
key: "executePreviewItem",
|
|
5392
|
+
value: function executePreviewItem(src) {
|
|
5393
|
+
if (this.previewInput === null) {
|
|
5394
|
+
return null;
|
|
5395
|
+
}
|
|
5396
|
+
return this.previewInput({
|
|
5397
|
+
val: src
|
|
5398
|
+
});
|
|
5399
|
+
}
|
|
5400
|
+
}, {
|
|
5401
|
+
key: "declaresItemPreview",
|
|
5402
|
+
value: function declaresItemPreview() {
|
|
5403
|
+
return this.previewInput !== null;
|
|
5404
|
+
}
|
|
4848
5405
|
}, {
|
|
4849
5406
|
key: "executeSerialize",
|
|
4850
5407
|
value: function executeSerialize() {
|
|
4851
|
-
var _this$customValidateF;
|
|
5408
|
+
var _this$renderInput, _this$customValidateF;
|
|
4852
5409
|
var path = this.sourcePath;
|
|
4853
5410
|
if (!path) {
|
|
4854
5411
|
throw new Error("Cannot serialize keyOf schema with empty selector. TIP: keyOf must be used with a Val Module of record schema.");
|
|
@@ -4871,6 +5428,8 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4871
5428
|
}
|
|
4872
5429
|
return {
|
|
4873
5430
|
type: "keyOf",
|
|
5431
|
+
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
5432
|
+
preview: this.previewInput ? true : undefined,
|
|
4874
5433
|
path: path,
|
|
4875
5434
|
schema: serializedSchema,
|
|
4876
5435
|
opt: this.opt,
|
|
@@ -4922,6 +5481,8 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4922
5481
|
var isReadonly = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
4923
5482
|
var isHidden = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
4924
5483
|
var description = arguments.length > 7 ? arguments[7] : undefined;
|
|
5484
|
+
var renderInput = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
|
|
5485
|
+
var previewInput = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : null;
|
|
4925
5486
|
_classCallCheck(this, FileSchema);
|
|
4926
5487
|
_this = _callSuper(this, FileSchema);
|
|
4927
5488
|
_this.options = options;
|
|
@@ -4932,23 +5493,25 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4932
5493
|
_this.isReadonly = isReadonly;
|
|
4933
5494
|
_this.isHidden = isHidden;
|
|
4934
5495
|
_this.description = description;
|
|
5496
|
+
_this.renderInput = renderInput;
|
|
5497
|
+
_this.previewInput = previewInput;
|
|
4935
5498
|
return _this;
|
|
4936
5499
|
}
|
|
4937
5500
|
_inherits(FileSchema, _Schema);
|
|
4938
5501
|
return _createClass(FileSchema, [{
|
|
4939
5502
|
key: "describe",
|
|
4940
5503
|
value: function describe(description) {
|
|
4941
|
-
return new FileSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
|
|
5504
|
+
return new FileSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput, this.previewInput);
|
|
4942
5505
|
}
|
|
4943
5506
|
}, {
|
|
4944
5507
|
key: "remote",
|
|
4945
5508
|
value: function remote() {
|
|
4946
|
-
return new FileSchema(this.options, this.opt, true, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description);
|
|
5509
|
+
return new FileSchema(this.options, this.opt, true, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
4947
5510
|
}
|
|
4948
5511
|
}, {
|
|
4949
5512
|
key: "validate",
|
|
4950
5513
|
value: function validate(validationFunction) {
|
|
4951
|
-
return new FileSchema(this.options, this.opt, this.isRemote, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.moduleMetadata, this.isReadonly, this.isHidden, this.description);
|
|
5514
|
+
return new FileSchema(this.options, this.opt, this.isRemote, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.moduleMetadata, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
4952
5515
|
}
|
|
4953
5516
|
}, {
|
|
4954
5517
|
key: "executeValidate",
|
|
@@ -5129,17 +5692,17 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
|
|
|
5129
5692
|
}, {
|
|
5130
5693
|
key: "nullable",
|
|
5131
5694
|
value: function nullable() {
|
|
5132
|
-
return new FileSchema(this.options, true, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description);
|
|
5695
|
+
return new FileSchema(this.options, true, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
5133
5696
|
}
|
|
5134
5697
|
}, {
|
|
5135
5698
|
key: "readonly",
|
|
5136
5699
|
value: function readonly() {
|
|
5137
|
-
return new FileSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, true, this.isHidden, this.description);
|
|
5700
|
+
return new FileSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, true, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
5138
5701
|
}
|
|
5139
5702
|
}, {
|
|
5140
5703
|
key: "hidden",
|
|
5141
5704
|
value: function hidden() {
|
|
5142
|
-
return new FileSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, true, this.description);
|
|
5705
|
+
return new FileSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
|
|
5143
5706
|
}
|
|
5144
5707
|
}, {
|
|
5145
5708
|
key: "executeCustomValidateAt",
|
|
@@ -5148,13 +5711,54 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
|
|
|
5148
5711
|
path: path
|
|
5149
5712
|
});
|
|
5150
5713
|
}
|
|
5714
|
+
|
|
5715
|
+
/**
|
|
5716
|
+
* How this field is laid out in the editor when it is the item of an array
|
|
5717
|
+
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
5718
|
+
* instead of a preview row that navigates to it.
|
|
5719
|
+
*
|
|
5720
|
+
* Static configuration, not a callback — see `render.ts`.
|
|
5721
|
+
*/
|
|
5722
|
+
}, {
|
|
5723
|
+
key: "render",
|
|
5724
|
+
value: function render(input) {
|
|
5725
|
+
return new FileSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
|
|
5726
|
+
}
|
|
5727
|
+
|
|
5728
|
+
/**
|
|
5729
|
+
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
5730
|
+
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
5731
|
+
* itself is edited (that is `render`). See `preview.ts`.
|
|
5732
|
+
*/
|
|
5733
|
+
}, {
|
|
5734
|
+
key: "preview",
|
|
5735
|
+
value: function preview(select) {
|
|
5736
|
+
return new FileSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
|
|
5737
|
+
}
|
|
5738
|
+
}, {
|
|
5739
|
+
key: "executePreviewItem",
|
|
5740
|
+
value: function executePreviewItem(src) {
|
|
5741
|
+
if (this.previewInput === null) {
|
|
5742
|
+
return null;
|
|
5743
|
+
}
|
|
5744
|
+
return this.previewInput({
|
|
5745
|
+
val: src
|
|
5746
|
+
});
|
|
5747
|
+
}
|
|
5748
|
+
}, {
|
|
5749
|
+
key: "declaresItemPreview",
|
|
5750
|
+
value: function declaresItemPreview() {
|
|
5751
|
+
return this.previewInput !== null;
|
|
5752
|
+
}
|
|
5151
5753
|
}, {
|
|
5152
5754
|
key: "executeSerialize",
|
|
5153
5755
|
value: function executeSerialize() {
|
|
5154
|
-
var _this$customValidateF;
|
|
5756
|
+
var _this$renderInput, _this$customValidateF;
|
|
5155
5757
|
var modulePaths = this.moduleMetadata ? Object.keys(this.moduleMetadata) : [];
|
|
5156
5758
|
return {
|
|
5157
5759
|
type: "file",
|
|
5760
|
+
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
5761
|
+
preview: this.previewInput ? true : undefined,
|
|
5158
5762
|
options: this.options,
|
|
5159
5763
|
opt: this.opt,
|
|
5160
5764
|
remote: this.isRemote,
|
|
@@ -5243,6 +5847,8 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
|
|
|
5243
5847
|
var isReadonly = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
5244
5848
|
var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
5245
5849
|
var description = arguments.length > 5 ? arguments[5] : undefined;
|
|
5850
|
+
var renderInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
|
|
5851
|
+
var previewInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
|
|
5246
5852
|
_classCallCheck(this, DateSchema);
|
|
5247
5853
|
_this = _callSuper(this, DateSchema);
|
|
5248
5854
|
_this.options = options;
|
|
@@ -5251,18 +5857,20 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
|
|
|
5251
5857
|
_this.isReadonly = isReadonly;
|
|
5252
5858
|
_this.isHidden = isHidden;
|
|
5253
5859
|
_this.description = description;
|
|
5860
|
+
_this.renderInput = renderInput;
|
|
5861
|
+
_this.previewInput = previewInput;
|
|
5254
5862
|
return _this;
|
|
5255
5863
|
}
|
|
5256
5864
|
_inherits(DateSchema, _Schema);
|
|
5257
5865
|
return _createClass(DateSchema, [{
|
|
5258
5866
|
key: "describe",
|
|
5259
5867
|
value: function describe(description) {
|
|
5260
|
-
return new DateSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
|
|
5868
|
+
return new DateSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput, this.previewInput);
|
|
5261
5869
|
}
|
|
5262
5870
|
}, {
|
|
5263
5871
|
key: "validate",
|
|
5264
5872
|
value: function validate(validationFunction) {
|
|
5265
|
-
return new DateSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description);
|
|
5873
|
+
return new DateSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
5266
5874
|
}
|
|
5267
5875
|
}, {
|
|
5268
5876
|
key: "executeValidate",
|
|
@@ -5351,29 +5959,29 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
|
|
|
5351
5959
|
value: function from(_from) {
|
|
5352
5960
|
return new DateSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
5353
5961
|
from: _from
|
|
5354
|
-
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
|
|
5962
|
+
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
5355
5963
|
}
|
|
5356
5964
|
}, {
|
|
5357
5965
|
key: "to",
|
|
5358
5966
|
value: function to(_to) {
|
|
5359
5967
|
return new DateSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
5360
5968
|
to: _to
|
|
5361
|
-
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
|
|
5969
|
+
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
5362
5970
|
}
|
|
5363
5971
|
}, {
|
|
5364
5972
|
key: "nullable",
|
|
5365
5973
|
value: function nullable() {
|
|
5366
|
-
return new DateSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description);
|
|
5974
|
+
return new DateSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
5367
5975
|
}
|
|
5368
5976
|
}, {
|
|
5369
5977
|
key: "readonly",
|
|
5370
5978
|
value: function readonly() {
|
|
5371
|
-
return new DateSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
|
|
5979
|
+
return new DateSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
5372
5980
|
}
|
|
5373
5981
|
}, {
|
|
5374
5982
|
key: "hidden",
|
|
5375
5983
|
value: function hidden() {
|
|
5376
|
-
return new DateSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
5984
|
+
return new DateSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
|
|
5377
5985
|
}
|
|
5378
5986
|
}, {
|
|
5379
5987
|
key: "executeCustomValidateAt",
|
|
@@ -5382,12 +5990,53 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
|
|
|
5382
5990
|
path: path
|
|
5383
5991
|
});
|
|
5384
5992
|
}
|
|
5993
|
+
|
|
5994
|
+
/**
|
|
5995
|
+
* How this field is laid out in the editor when it is the item of an array
|
|
5996
|
+
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
5997
|
+
* instead of a preview row that navigates to it.
|
|
5998
|
+
*
|
|
5999
|
+
* Static configuration, not a callback — see `render.ts`.
|
|
6000
|
+
*/
|
|
6001
|
+
}, {
|
|
6002
|
+
key: "render",
|
|
6003
|
+
value: function render(input) {
|
|
6004
|
+
return new DateSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
|
|
6005
|
+
}
|
|
6006
|
+
|
|
6007
|
+
/**
|
|
6008
|
+
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
6009
|
+
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
6010
|
+
* itself is edited (that is `render`). See `preview.ts`.
|
|
6011
|
+
*/
|
|
6012
|
+
}, {
|
|
6013
|
+
key: "preview",
|
|
6014
|
+
value: function preview(select) {
|
|
6015
|
+
return new DateSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
|
|
6016
|
+
}
|
|
6017
|
+
}, {
|
|
6018
|
+
key: "executePreviewItem",
|
|
6019
|
+
value: function executePreviewItem(src) {
|
|
6020
|
+
if (this.previewInput === null) {
|
|
6021
|
+
return null;
|
|
6022
|
+
}
|
|
6023
|
+
return this.previewInput({
|
|
6024
|
+
val: src
|
|
6025
|
+
});
|
|
6026
|
+
}
|
|
6027
|
+
}, {
|
|
6028
|
+
key: "declaresItemPreview",
|
|
6029
|
+
value: function declaresItemPreview() {
|
|
6030
|
+
return this.previewInput !== null;
|
|
6031
|
+
}
|
|
5385
6032
|
}, {
|
|
5386
6033
|
key: "executeSerialize",
|
|
5387
6034
|
value: function executeSerialize() {
|
|
5388
|
-
var _this$customValidateF;
|
|
6035
|
+
var _this$renderInput, _this$customValidateF;
|
|
5389
6036
|
return {
|
|
5390
6037
|
type: "date",
|
|
6038
|
+
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
6039
|
+
preview: this.previewInput ? true : undefined,
|
|
5391
6040
|
opt: this.opt,
|
|
5392
6041
|
options: this.options,
|
|
5393
6042
|
customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
|
|
@@ -5415,6 +6064,8 @@ var DateTimeSchema = /*#__PURE__*/function (_Schema) {
|
|
|
5415
6064
|
var isReadonly = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
5416
6065
|
var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
5417
6066
|
var description = arguments.length > 5 ? arguments[5] : undefined;
|
|
6067
|
+
var renderInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
|
|
6068
|
+
var previewInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
|
|
5418
6069
|
_classCallCheck(this, DateTimeSchema);
|
|
5419
6070
|
_this = _callSuper(this, DateTimeSchema);
|
|
5420
6071
|
_this.options = options;
|
|
@@ -5423,18 +6074,20 @@ var DateTimeSchema = /*#__PURE__*/function (_Schema) {
|
|
|
5423
6074
|
_this.isReadonly = isReadonly;
|
|
5424
6075
|
_this.isHidden = isHidden;
|
|
5425
6076
|
_this.description = description;
|
|
6077
|
+
_this.renderInput = renderInput;
|
|
6078
|
+
_this.previewInput = previewInput;
|
|
5426
6079
|
return _this;
|
|
5427
6080
|
}
|
|
5428
6081
|
_inherits(DateTimeSchema, _Schema);
|
|
5429
6082
|
return _createClass(DateTimeSchema, [{
|
|
5430
6083
|
key: "describe",
|
|
5431
6084
|
value: function describe(description) {
|
|
5432
|
-
return new DateTimeSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
|
|
6085
|
+
return new DateTimeSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput, this.previewInput);
|
|
5433
6086
|
}
|
|
5434
6087
|
}, {
|
|
5435
6088
|
key: "validate",
|
|
5436
6089
|
value: function validate(validationFunction) {
|
|
5437
|
-
return new DateTimeSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description);
|
|
6090
|
+
return new DateTimeSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
5438
6091
|
}
|
|
5439
6092
|
}, {
|
|
5440
6093
|
key: "executeValidate",
|
|
@@ -5555,29 +6208,29 @@ var DateTimeSchema = /*#__PURE__*/function (_Schema) {
|
|
|
5555
6208
|
value: function from(_from) {
|
|
5556
6209
|
return new DateTimeSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
5557
6210
|
from: _from
|
|
5558
|
-
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
|
|
6211
|
+
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
5559
6212
|
}
|
|
5560
6213
|
}, {
|
|
5561
6214
|
key: "to",
|
|
5562
6215
|
value: function to(_to) {
|
|
5563
6216
|
return new DateTimeSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
5564
6217
|
to: _to
|
|
5565
|
-
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
|
|
6218
|
+
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
5566
6219
|
}
|
|
5567
6220
|
}, {
|
|
5568
6221
|
key: "nullable",
|
|
5569
6222
|
value: function nullable() {
|
|
5570
|
-
return new DateTimeSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description);
|
|
6223
|
+
return new DateTimeSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
5571
6224
|
}
|
|
5572
6225
|
}, {
|
|
5573
6226
|
key: "readonly",
|
|
5574
6227
|
value: function readonly() {
|
|
5575
|
-
return new DateTimeSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
|
|
6228
|
+
return new DateTimeSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
5576
6229
|
}
|
|
5577
6230
|
}, {
|
|
5578
6231
|
key: "hidden",
|
|
5579
6232
|
value: function hidden() {
|
|
5580
|
-
return new DateTimeSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
6233
|
+
return new DateTimeSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
|
|
5581
6234
|
}
|
|
5582
6235
|
}, {
|
|
5583
6236
|
key: "executeCustomValidateAt",
|
|
@@ -5586,12 +6239,53 @@ var DateTimeSchema = /*#__PURE__*/function (_Schema) {
|
|
|
5586
6239
|
path: path
|
|
5587
6240
|
});
|
|
5588
6241
|
}
|
|
6242
|
+
|
|
6243
|
+
/**
|
|
6244
|
+
* How this field is laid out in the editor when it is the item of an array
|
|
6245
|
+
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
6246
|
+
* instead of a preview row that navigates to it.
|
|
6247
|
+
*
|
|
6248
|
+
* Static configuration, not a callback — see `render.ts`.
|
|
6249
|
+
*/
|
|
6250
|
+
}, {
|
|
6251
|
+
key: "render",
|
|
6252
|
+
value: function render(input) {
|
|
6253
|
+
return new DateTimeSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
|
|
6254
|
+
}
|
|
6255
|
+
|
|
6256
|
+
/**
|
|
6257
|
+
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
6258
|
+
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
6259
|
+
* itself is edited (that is `render`). See `preview.ts`.
|
|
6260
|
+
*/
|
|
6261
|
+
}, {
|
|
6262
|
+
key: "preview",
|
|
6263
|
+
value: function preview(select) {
|
|
6264
|
+
return new DateTimeSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
|
|
6265
|
+
}
|
|
6266
|
+
}, {
|
|
6267
|
+
key: "executePreviewItem",
|
|
6268
|
+
value: function executePreviewItem(src) {
|
|
6269
|
+
if (this.previewInput === null) {
|
|
6270
|
+
return null;
|
|
6271
|
+
}
|
|
6272
|
+
return this.previewInput({
|
|
6273
|
+
val: src
|
|
6274
|
+
});
|
|
6275
|
+
}
|
|
6276
|
+
}, {
|
|
6277
|
+
key: "declaresItemPreview",
|
|
6278
|
+
value: function declaresItemPreview() {
|
|
6279
|
+
return this.previewInput !== null;
|
|
6280
|
+
}
|
|
5589
6281
|
}, {
|
|
5590
6282
|
key: "executeSerialize",
|
|
5591
6283
|
value: function executeSerialize() {
|
|
5592
|
-
var _this$customValidateF;
|
|
6284
|
+
var _this$renderInput, _this$customValidateF;
|
|
5593
6285
|
return {
|
|
5594
6286
|
type: "dateTime",
|
|
6287
|
+
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
6288
|
+
preview: this.previewInput ? true : undefined,
|
|
5595
6289
|
opt: this.opt,
|
|
5596
6290
|
options: this.options,
|
|
5597
6291
|
customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
|
|
@@ -6099,6 +6793,8 @@ var ColorSchema = /*#__PURE__*/function (_Schema) {
|
|
|
6099
6793
|
var isReadonly = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
6100
6794
|
var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
6101
6795
|
var description = arguments.length > 5 ? arguments[5] : undefined;
|
|
6796
|
+
var renderInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
|
|
6797
|
+
var previewInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
|
|
6102
6798
|
_classCallCheck(this, ColorSchema);
|
|
6103
6799
|
_this = _callSuper(this, ColorSchema);
|
|
6104
6800
|
_this.options = options;
|
|
@@ -6107,18 +6803,20 @@ var ColorSchema = /*#__PURE__*/function (_Schema) {
|
|
|
6107
6803
|
_this.isReadonly = isReadonly;
|
|
6108
6804
|
_this.isHidden = isHidden;
|
|
6109
6805
|
_this.description = description;
|
|
6806
|
+
_this.renderInput = renderInput;
|
|
6807
|
+
_this.previewInput = previewInput;
|
|
6110
6808
|
return _this;
|
|
6111
6809
|
}
|
|
6112
6810
|
_inherits(ColorSchema, _Schema);
|
|
6113
6811
|
return _createClass(ColorSchema, [{
|
|
6114
6812
|
key: "describe",
|
|
6115
6813
|
value: function describe(description) {
|
|
6116
|
-
return new ColorSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
|
|
6814
|
+
return new ColorSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput, this.previewInput);
|
|
6117
6815
|
}
|
|
6118
6816
|
}, {
|
|
6119
6817
|
key: "validate",
|
|
6120
6818
|
value: function validate(validationFunction) {
|
|
6121
|
-
return new ColorSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description);
|
|
6819
|
+
return new ColorSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
6122
6820
|
}
|
|
6123
6821
|
}, {
|
|
6124
6822
|
key: "executeCustomValidateAt",
|
|
@@ -6215,24 +6913,65 @@ var ColorSchema = /*#__PURE__*/function (_Schema) {
|
|
|
6215
6913
|
}, {
|
|
6216
6914
|
key: "nullable",
|
|
6217
6915
|
value: function nullable() {
|
|
6218
|
-
return new ColorSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description);
|
|
6916
|
+
return new ColorSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
6219
6917
|
}
|
|
6220
6918
|
}, {
|
|
6221
6919
|
key: "readonly",
|
|
6222
6920
|
value: function readonly() {
|
|
6223
|
-
return new ColorSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
|
|
6921
|
+
return new ColorSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
6224
6922
|
}
|
|
6225
6923
|
}, {
|
|
6226
6924
|
key: "hidden",
|
|
6227
6925
|
value: function hidden() {
|
|
6228
|
-
return new ColorSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
6926
|
+
return new ColorSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
|
|
6927
|
+
}
|
|
6928
|
+
|
|
6929
|
+
/**
|
|
6930
|
+
* How this field is laid out in the editor when it is the item of an array
|
|
6931
|
+
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
6932
|
+
* instead of a preview row that navigates to it.
|
|
6933
|
+
*
|
|
6934
|
+
* Static configuration, not a callback — see `render.ts`.
|
|
6935
|
+
*/
|
|
6936
|
+
}, {
|
|
6937
|
+
key: "render",
|
|
6938
|
+
value: function render(input) {
|
|
6939
|
+
return new ColorSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
|
|
6940
|
+
}
|
|
6941
|
+
|
|
6942
|
+
/**
|
|
6943
|
+
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
6944
|
+
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
6945
|
+
* itself is edited (that is `render`). See `preview.ts`.
|
|
6946
|
+
*/
|
|
6947
|
+
}, {
|
|
6948
|
+
key: "preview",
|
|
6949
|
+
value: function preview(select) {
|
|
6950
|
+
return new ColorSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
|
|
6951
|
+
}
|
|
6952
|
+
}, {
|
|
6953
|
+
key: "executePreviewItem",
|
|
6954
|
+
value: function executePreviewItem(src) {
|
|
6955
|
+
if (this.previewInput === null) {
|
|
6956
|
+
return null;
|
|
6957
|
+
}
|
|
6958
|
+
return this.previewInput({
|
|
6959
|
+
val: src
|
|
6960
|
+
});
|
|
6961
|
+
}
|
|
6962
|
+
}, {
|
|
6963
|
+
key: "declaresItemPreview",
|
|
6964
|
+
value: function declaresItemPreview() {
|
|
6965
|
+
return this.previewInput !== null;
|
|
6229
6966
|
}
|
|
6230
6967
|
}, {
|
|
6231
6968
|
key: "executeSerialize",
|
|
6232
6969
|
value: function executeSerialize() {
|
|
6233
|
-
var _this$customValidateF;
|
|
6970
|
+
var _this$renderInput, _this$customValidateF;
|
|
6234
6971
|
return {
|
|
6235
6972
|
type: "color",
|
|
6973
|
+
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
6974
|
+
preview: this.previewInput ? true : undefined,
|
|
6236
6975
|
opt: this.opt,
|
|
6237
6976
|
options: this.options,
|
|
6238
6977
|
customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
|
|
@@ -8085,7 +8824,7 @@ function deserializeSchema(serialized) {
|
|
|
8085
8824
|
return schema;
|
|
8086
8825
|
}
|
|
8087
8826
|
function deserializeSchemaImpl(serialized) {
|
|
8088
|
-
var _serialized$options, _serialized$options2, _serialized$render, _serialized$accept, _serialized$directory, _serialized$remote, _serialized$jsonValue;
|
|
8827
|
+
var _serialized$options, _serialized$options2, _serialized$render, _serialized$render2, _serialized$render3, _serialized$render4, _serialized$render5, _serialized$render6, _serialized$render7, _serialized$accept, _serialized$directory, _serialized$remote, _serialized$jsonValue, _serialized$render9, _serialized$render0, _serialized$render10, _serialized$render11, _serialized$render12, _serialized$render13, _serialized$render14;
|
|
8089
8828
|
switch (serialized.type) {
|
|
8090
8829
|
case "string":
|
|
8091
8830
|
return new StringSchema(_objectSpread2(_objectSpread2({}, serialized.options), {}, {
|
|
@@ -8096,20 +8835,22 @@ function deserializeSchemaImpl(serialized) {
|
|
|
8096
8835
|
// recomputed from an instance.
|
|
8097
8836
|
(_serialized$render = serialized.render) !== null && _serialized$render !== void 0 ? _serialized$render : null, false, false, serialized.description);
|
|
8098
8837
|
case "literal":
|
|
8099
|
-
return new LiteralSchema(serialized.value, serialized.opt, [], false, false, serialized.description);
|
|
8838
|
+
return new LiteralSchema(serialized.value, serialized.opt, [], false, false, serialized.description, (_serialized$render2 = serialized.render) !== null && _serialized$render2 !== void 0 ? _serialized$render2 : null);
|
|
8100
8839
|
case "boolean":
|
|
8101
|
-
return new BooleanSchema(serialized.opt, [], false, false, serialized.description);
|
|
8840
|
+
return new BooleanSchema(serialized.opt, [], false, false, serialized.description, (_serialized$render3 = serialized.render) !== null && _serialized$render3 !== void 0 ? _serialized$render3 : null);
|
|
8102
8841
|
case "number":
|
|
8103
|
-
return new NumberSchema(serialized.options, serialized.opt, [], false, false, serialized.description);
|
|
8842
|
+
return new NumberSchema(serialized.options, serialized.opt, [], false, false, serialized.description, (_serialized$render4 = serialized.render) !== null && _serialized$render4 !== void 0 ? _serialized$render4 : null);
|
|
8104
8843
|
case "object":
|
|
8105
8844
|
return new ObjectSchema(Object.fromEntries(Object.entries(serialized.items).map(function (_ref) {
|
|
8106
8845
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
8107
8846
|
key = _ref2[0],
|
|
8108
8847
|
item = _ref2[1];
|
|
8109
8848
|
return [key, deserializeSchema(item)];
|
|
8110
|
-
})), serialized.opt, [], false, false, serialized.description);
|
|
8849
|
+
})), serialized.opt, [], false, false, serialized.description, (_serialized$render5 = serialized.render) !== null && _serialized$render5 !== void 0 ? _serialized$render5 : null);
|
|
8111
8850
|
case "array":
|
|
8112
|
-
return new ArraySchema(deserializeSchema(serialized.item), serialized.opt, [], false, false, serialized.description
|
|
8851
|
+
return new ArraySchema(deserializeSchema(serialized.item), serialized.opt, [], false, false, serialized.description,
|
|
8852
|
+
// The preview closure cannot survive serialization; the render can.
|
|
8853
|
+
null, (_serialized$render6 = serialized.render) !== null && _serialized$render6 !== void 0 ? _serialized$render6 : null);
|
|
8113
8854
|
case "union":
|
|
8114
8855
|
return new UnionSchema(typeof serialized.key === "string" ? serialized.key :
|
|
8115
8856
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -8118,17 +8859,17 @@ function deserializeSchemaImpl(serialized) {
|
|
|
8118
8859
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8119
8860
|
serialized.items.map(deserializeSchema),
|
|
8120
8861
|
// TODO: we do not really need any here - right?
|
|
8121
|
-
serialized.opt, [], false, false, serialized.description);
|
|
8862
|
+
serialized.opt, [], false, false, serialized.description, (_serialized$render7 = serialized.render) !== null && _serialized$render7 !== void 0 ? _serialized$render7 : null);
|
|
8122
8863
|
case "richtext":
|
|
8123
8864
|
{
|
|
8124
|
-
var _serialized$options3, _serialized$options4, _serialized$options5, _serialized$options6, _serialized$options7, _serialized$options8, _serialized$options9;
|
|
8865
|
+
var _serialized$options3, _serialized$options4, _serialized$options5, _serialized$options6, _serialized$options7, _serialized$options8, _serialized$options9, _serialized$render8;
|
|
8125
8866
|
var deserializedOptions = _objectSpread2(_objectSpread2({}, serialized.options || {}), {}, {
|
|
8126
8867
|
inline: _typeof((_serialized$options3 = serialized.options) === null || _serialized$options3 === void 0 || (_serialized$options3 = _serialized$options3.inline) === null || _serialized$options3 === void 0 ? void 0 : _serialized$options3.img) === "object" || _typeof((_serialized$options4 = serialized.options) === null || _serialized$options4 === void 0 || (_serialized$options4 = _serialized$options4.inline) === null || _serialized$options4 === void 0 ? void 0 : _serialized$options4.a) === "object" ? {
|
|
8127
8868
|
a: _typeof((_serialized$options5 = serialized.options) === null || _serialized$options5 === void 0 || (_serialized$options5 = _serialized$options5.inline) === null || _serialized$options5 === void 0 ? void 0 : _serialized$options5.a) === "object" ? deserializeSchema(serialized.options.inline.a) : (_serialized$options6 = serialized.options) === null || _serialized$options6 === void 0 || (_serialized$options6 = _serialized$options6.inline) === null || _serialized$options6 === void 0 ? void 0 : _serialized$options6.a,
|
|
8128
8869
|
img: _typeof((_serialized$options7 = serialized.options) === null || _serialized$options7 === void 0 || (_serialized$options7 = _serialized$options7.inline) === null || _serialized$options7 === void 0 ? void 0 : _serialized$options7.img) === "object" ? deserializeSchema(serialized.options.inline.img) : (_serialized$options8 = serialized.options) === null || _serialized$options8 === void 0 || (_serialized$options8 = _serialized$options8.inline) === null || _serialized$options8 === void 0 ? void 0 : _serialized$options8.img
|
|
8129
8870
|
} : (_serialized$options9 = serialized.options) === null || _serialized$options9 === void 0 ? void 0 : _serialized$options9.inline
|
|
8130
8871
|
});
|
|
8131
|
-
return new RichTextSchema(deserializedOptions, serialized.opt, [], false, false, serialized.description);
|
|
8872
|
+
return new RichTextSchema(deserializedOptions, serialized.opt, [], false, false, serialized.description, (_serialized$render8 = serialized.render) !== null && _serialized$render8 !== void 0 ? _serialized$render8 : null);
|
|
8132
8873
|
}
|
|
8133
8874
|
case "record":
|
|
8134
8875
|
return new RecordSchema(deserializeSchema(serialized.item), serialized.opt, [], null, serialized.key ? deserializeSchema(serialized.key) : null, serialized.mediaType ? {
|
|
@@ -8137,27 +8878,30 @@ function deserializeSchemaImpl(serialized) {
|
|
|
8137
8878
|
directory: (_serialized$directory = serialized.directory) !== null && _serialized$directory !== void 0 ? _serialized$directory : "/public/val",
|
|
8138
8879
|
remote: (_serialized$remote = serialized.remote) !== null && _serialized$remote !== void 0 ? _serialized$remote : false,
|
|
8139
8880
|
altSchema: serialized.alt ? deserializeSchema(serialized.alt) : undefined
|
|
8140
|
-
} : undefined, false, false, serialized.description, (_serialized$jsonValue = serialized.jsonValues) !== null && _serialized$jsonValue !== void 0 ? _serialized$jsonValue : false
|
|
8881
|
+
} : undefined, false, false, serialized.description, (_serialized$jsonValue = serialized.jsonValues) !== null && _serialized$jsonValue !== void 0 ? _serialized$jsonValue : false,
|
|
8882
|
+
// The preview closure cannot survive serialization; the render can.
|
|
8883
|
+
null, (_serialized$render9 = serialized.render) !== null && _serialized$render9 !== void 0 ? _serialized$render9 : null);
|
|
8141
8884
|
case "keyOf":
|
|
8142
|
-
return new KeyOfSchema(serialized.schema, serialized.path, serialized.opt, [], false, false, serialized.description);
|
|
8885
|
+
return new KeyOfSchema(serialized.schema, serialized.path, serialized.opt, [], false, false, serialized.description, (_serialized$render0 = serialized.render) !== null && _serialized$render0 !== void 0 ? _serialized$render0 : null);
|
|
8143
8886
|
case "route":
|
|
8144
8887
|
{
|
|
8888
|
+
var _serialized$render1;
|
|
8145
8889
|
var routeOptions = serialized.options ? {
|
|
8146
8890
|
include: serialized.options.include ? new RegExp(serialized.options.include.source, serialized.options.include.flags) : undefined,
|
|
8147
8891
|
exclude: serialized.options.exclude ? new RegExp(serialized.options.exclude.source, serialized.options.exclude.flags) : undefined
|
|
8148
8892
|
} : undefined;
|
|
8149
|
-
return new RouteSchema(routeOptions, serialized.opt, [], false, false, serialized.description);
|
|
8893
|
+
return new RouteSchema(routeOptions, serialized.opt, [], false, false, serialized.description, (_serialized$render1 = serialized.render) !== null && _serialized$render1 !== void 0 ? _serialized$render1 : null);
|
|
8150
8894
|
}
|
|
8151
8895
|
case "file":
|
|
8152
|
-
return new FileSchema(serialized.options, serialized.opt, serialized.remote, [], {}, false, false, serialized.description);
|
|
8896
|
+
return new FileSchema(serialized.options, serialized.opt, serialized.remote, [], {}, false, false, serialized.description, (_serialized$render10 = serialized.render) !== null && _serialized$render10 !== void 0 ? _serialized$render10 : null);
|
|
8153
8897
|
case "image":
|
|
8154
|
-
return new ImageSchema(serialized.options, serialized.opt, serialized.remote, [], {}, false, false, serialized.description);
|
|
8898
|
+
return new ImageSchema(serialized.options, serialized.opt, serialized.remote, [], {}, false, false, serialized.description, (_serialized$render11 = serialized.render) !== null && _serialized$render11 !== void 0 ? _serialized$render11 : null);
|
|
8155
8899
|
case "date":
|
|
8156
|
-
return new DateSchema(serialized.options, serialized.opt, [], false, false, serialized.description);
|
|
8900
|
+
return new DateSchema(serialized.options, serialized.opt, [], false, false, serialized.description, (_serialized$render12 = serialized.render) !== null && _serialized$render12 !== void 0 ? _serialized$render12 : null);
|
|
8157
8901
|
case "dateTime":
|
|
8158
|
-
return new DateTimeSchema(serialized.options, serialized.opt, [], false, false, serialized.description);
|
|
8902
|
+
return new DateTimeSchema(serialized.options, serialized.opt, [], false, false, serialized.description, (_serialized$render13 = serialized.render) !== null && _serialized$render13 !== void 0 ? _serialized$render13 : null);
|
|
8159
8903
|
case "color":
|
|
8160
|
-
return new ColorSchema(serialized.options, serialized.opt, [], false, false, serialized.description);
|
|
8904
|
+
return new ColorSchema(serialized.options, serialized.opt, [], false, false, serialized.description, (_serialized$render14 = serialized.render) !== null && _serialized$render14 !== void 0 ? _serialized$render14 : null);
|
|
8161
8905
|
default:
|
|
8162
8906
|
{
|
|
8163
8907
|
var exhaustiveCheck = serialized;
|
|
@@ -8172,8 +8916,29 @@ function deserializeSchemaImpl(serialized) {
|
|
|
8172
8916
|
}
|
|
8173
8917
|
|
|
8174
8918
|
/**
|
|
8175
|
-
*
|
|
8176
|
-
*
|
|
8919
|
+
* A PREVIEW is how a VALUE is shown wherever a preview of it is needed — a row
|
|
8920
|
+
* in a sortable list, a key in a reference dropdown, a search hit, a
|
|
8921
|
+
* reference — which is everywhere the value is NAVIGABLE to rather than open.
|
|
8922
|
+
* It is never how the field itself is edited: that is a RENDER (`render.ts`),
|
|
8923
|
+
* which applies only when you are looking at the field. The two do not
|
|
8924
|
+
* intersect — a schema can carry both, and each is read in its own places.
|
|
8925
|
+
*
|
|
8926
|
+
* A preview is declared on the schema of the VALUE being previewed:
|
|
8927
|
+
*
|
|
8928
|
+
* ```ts
|
|
8929
|
+
* const author = s.object({ name: s.string() })
|
|
8930
|
+
* .preview(({ val }) => ({ title: val.name }));
|
|
8931
|
+
* const authors = s.array(author);
|
|
8932
|
+
* ```
|
|
8933
|
+
*
|
|
8934
|
+
* The container reifies its rows by running each ITEM's preview closure — see
|
|
8935
|
+
* {@link ArrayPreview} / {@link RecordPreview}. (Previews used to be declared
|
|
8936
|
+
* on the container instead; a `.preview` on an array/record now previews the
|
|
8937
|
+
* array/record itself as a value, for when IT is the item of something.)
|
|
8938
|
+
*/
|
|
8939
|
+
/**
|
|
8940
|
+
* What a preview shows for one value: the user's `preview` callback returns
|
|
8941
|
+
* this, and the Studio draws a row from it.
|
|
8177
8942
|
*
|
|
8178
8943
|
* NB: {@link ArrayPreview} / {@link RecordPreview} name the DATA a container
|
|
8179
8944
|
* previews with. The Studio also has React components called `ArrayPreview` /
|
|
@@ -8183,6 +8948,19 @@ function deserializeSchemaImpl(serialized) {
|
|
|
8183
8948
|
* at the import rather than renaming that convention.
|
|
8184
8949
|
*/
|
|
8185
8950
|
|
|
8951
|
+
/**
|
|
8952
|
+
* What `.preview(...)` takes, on every schema: the value's own source in, a
|
|
8953
|
+
* {@link PreviewItem} out. `NonNullable` because a container skips null items
|
|
8954
|
+
* rather than previewing them.
|
|
8955
|
+
*
|
|
8956
|
+
* Declared through method syntax deliberately (the same bivariance shape
|
|
8957
|
+
* React's event handler types use): `nullable()` copies a schema's closure
|
|
8958
|
+
* into the `Src | null` variant of the same class, and with a plain function
|
|
8959
|
+
* type the checker cannot see that `NonNullable<Src | null>` IS
|
|
8960
|
+
* `NonNullable<Src>` while `Src` is still a type parameter — every schema's
|
|
8961
|
+
* `nullable()` would need a cast instead.
|
|
8962
|
+
*/
|
|
8963
|
+
|
|
8186
8964
|
/**
|
|
8187
8965
|
* Main preview type.
|
|
8188
8966
|
*
|
|
@@ -8275,11 +9053,21 @@ function previewScope(paths) {
|
|
|
8275
9053
|
// TODO: improve this so that we do not get RawString and string, only string. Are there other things?
|
|
8276
9054
|
|
|
8277
9055
|
/**
|
|
8278
|
-
* A RENDER is how
|
|
8279
|
-
*
|
|
9056
|
+
* A RENDER is how the FIELD ITSELF is laid out in the editor, and it applies
|
|
9057
|
+
* only when you are looking at the field: `s.string().render({ as: "textarea"
|
|
9058
|
+
* })`, `.render({ as: "code", language })`, `.render({ as: "inline" })` on an
|
|
9059
|
+
* array/record item.
|
|
9060
|
+
*
|
|
9061
|
+
* A PREVIEW (`preview.ts`) is the other thing: how the VALUE is shown wherever
|
|
9062
|
+
* a preview of it is needed — a list row, a reference dropdown, a search hit —
|
|
9063
|
+
* that is, wherever the value is navigable to rather than open. The two never
|
|
9064
|
+
* intersect: a schema can carry both, a `render` is read where the field is
|
|
9065
|
+
* edited and a `preview` where the value is previewed. A second `.render(...)`
|
|
9066
|
+
* on the same schema REPLACES the first (last one wins), exactly like a second
|
|
9067
|
+
* `.preview(...)` replaces the first — they do not merge.
|
|
8280
9068
|
*
|
|
8281
|
-
*
|
|
8282
|
-
* dependency on source - which is why it lives in the SERIALIZED schema
|
|
9069
|
+
* A render is static configuration - plain data, with no closure behind it and
|
|
9070
|
+
* no dependency on source - which is why it lives in the SERIALIZED schema
|
|
8283
9071
|
* (`SerializedStringSchema.render`) and is read straight off it where the field
|
|
8284
9072
|
* is drawn. There is no render pipeline, no store and no host round-trip.
|
|
8285
9073
|
*
|
|
@@ -8289,9 +9077,6 @@ function previewScope(paths) {
|
|
|
8289
9077
|
* the shape it needs back is `executePreview`'s, and the honest move is to give
|
|
8290
9078
|
* `render` its own execute/store pair again. It is NOT to re-merge the two:
|
|
8291
9079
|
* conflating them is what this file was split up to undo.
|
|
8292
|
-
*
|
|
8293
|
-
* The dynamic, source-dependent, demand-scoped thing - what a container shows
|
|
8294
|
-
* for its items - is a PREVIEW. See `preview.ts`.
|
|
8295
9080
|
*/
|
|
8296
9081
|
/**
|
|
8297
9082
|
* The list is the declaration and {@link CodeLanguage} is derived from it, so
|
|
@@ -8300,9 +9085,29 @@ function previewScope(paths) {
|
|
|
8300
9085
|
*/
|
|
8301
9086
|
var CODE_LANGUAGES = ["typescript", "javascript", "javascriptreact", "typescriptreact", "json", "java", "html", "css", "xml", "markdown", "sql", "python", "rust", "php", "go", "cpp", "sass", "vue", "angular"];
|
|
8302
9087
|
|
|
9088
|
+
/**
|
|
9089
|
+
* `{ as: "inline" }` on a field that is the ITEM of an array or record: the
|
|
9090
|
+
* container renders the field itself inside each (sortable) row, instead of a
|
|
9091
|
+
* clickable preview row that navigates to it. This is what a page-builder list
|
|
9092
|
+
* is made of: `s.array(s.object({...}).render({ as: "inline" }))`.
|
|
9093
|
+
*
|
|
9094
|
+
* On a field that is not directly under an array or record it is inert — an
|
|
9095
|
+
* object's fields are already laid out in place.
|
|
9096
|
+
*
|
|
9097
|
+
* Like every render it is static configuration (see the top of this file): it
|
|
9098
|
+
* travels whole in the serialized schema and the editor reads it straight off
|
|
9099
|
+
* the item schema it already has.
|
|
9100
|
+
*/
|
|
9101
|
+
|
|
9102
|
+
/**
|
|
9103
|
+
* What `.render(...)` takes on every field except `s.string()`, and what the
|
|
9104
|
+
* serialized schema carries verbatim.
|
|
9105
|
+
*/
|
|
9106
|
+
|
|
8303
9107
|
/**
|
|
8304
9108
|
* What `s.string().render(...)` takes, and what the serialized schema carries
|
|
8305
|
-
* verbatim.
|
|
9109
|
+
* verbatim. A string has editor layouts of its own (textarea, code) in
|
|
9110
|
+
* addition to the container-facing `inline`.
|
|
8306
9111
|
*/
|
|
8307
9112
|
|
|
8308
9113
|
var externalPageRouter = {
|