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