@valbuild/core 0.106.0 → 0.110.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 +4 -4
- 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 +64 -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 +61 -5
- package/dist/declarations/src/schema/images.d.ts +8 -0
- 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 +29 -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-2cef45cc.cjs.dev.js → index-409a38c3.cjs.dev.js} +1072 -192
- package/dist/{index-eaee0a0b.cjs.prod.js → index-62ef4533.cjs.prod.js} +1072 -192
- package/dist/{index-193f19b4.esm.js → index-6652ab3c.esm.js} +1072 -193
- package/dist/valbuild-core.cjs.dev.js +2 -1
- package/dist/valbuild-core.cjs.prod.js +2 -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"]();
|
|
@@ -1849,6 +2094,30 @@ function fillFromGallery(src, schema, getModuleSource) {
|
|
|
1849
2094
|
} : {});
|
|
1850
2095
|
}
|
|
1851
2096
|
|
|
2097
|
+
/**
|
|
2098
|
+
* How an uploaded image is re-encoded in the browser, before it is uploaded.
|
|
2099
|
+
*
|
|
2100
|
+
* Off unless a schema asks for it. When it is on, the image is converted to
|
|
2101
|
+
* `type` and scaled down to fit `maxWidth` x `maxHeight` - unless the result
|
|
2102
|
+
* would be BIGGER than the original and no downscale was needed, in which case
|
|
2103
|
+
* the original bytes are kept. See `architecture/media.md`.
|
|
2104
|
+
*
|
|
2105
|
+
* `type` is required so that adding a format later is additive: a schema
|
|
2106
|
+
* written today keeps saying exactly which format it asked for.
|
|
2107
|
+
*/
|
|
2108
|
+
|
|
2109
|
+
/** `false` (or absent) uploads the bytes exactly as the editor picked them. */
|
|
2110
|
+
|
|
2111
|
+
/**
|
|
2112
|
+
* What a GALLERY-BACKED field may say for itself.
|
|
2113
|
+
*
|
|
2114
|
+
* Not `ImageOptions`: `directory` and `accept` belong to the gallery, and a
|
|
2115
|
+
* field repeating them is how two copies of one fact get to disagree. `encode`
|
|
2116
|
+
* is different — it describes what happens to the bytes on their way IN, so a
|
|
2117
|
+
* field that wants the original where its gallery re-encodes has to be able to
|
|
2118
|
+
* say `encode: false`, and there is nowhere else to say it.
|
|
2119
|
+
*/
|
|
2120
|
+
|
|
1852
2121
|
var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
1853
2122
|
function ImageSchema(options) {
|
|
1854
2123
|
var _this;
|
|
@@ -1859,6 +2128,8 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
|
1859
2128
|
var isReadonly = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
1860
2129
|
var isHidden = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
1861
2130
|
var description = arguments.length > 7 ? arguments[7] : undefined;
|
|
2131
|
+
var renderInput = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
|
|
2132
|
+
var previewInput = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : null;
|
|
1862
2133
|
_classCallCheck(this, ImageSchema);
|
|
1863
2134
|
_this = _callSuper(this, ImageSchema);
|
|
1864
2135
|
_this.options = options;
|
|
@@ -1869,23 +2140,25 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
|
1869
2140
|
_this.isReadonly = isReadonly;
|
|
1870
2141
|
_this.isHidden = isHidden;
|
|
1871
2142
|
_this.description = description;
|
|
2143
|
+
_this.renderInput = renderInput;
|
|
2144
|
+
_this.previewInput = previewInput;
|
|
1872
2145
|
return _this;
|
|
1873
2146
|
}
|
|
1874
2147
|
_inherits(ImageSchema, _Schema);
|
|
1875
2148
|
return _createClass(ImageSchema, [{
|
|
1876
2149
|
key: "describe",
|
|
1877
2150
|
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);
|
|
2151
|
+
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
2152
|
}
|
|
1880
2153
|
}, {
|
|
1881
2154
|
key: "remote",
|
|
1882
2155
|
value: function remote() {
|
|
1883
|
-
return new ImageSchema(this.options, this.opt, true, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description);
|
|
2156
|
+
return new ImageSchema(this.options, this.opt, true, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
1884
2157
|
}
|
|
1885
2158
|
}, {
|
|
1886
2159
|
key: "validate",
|
|
1887
2160
|
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);
|
|
2161
|
+
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
2162
|
}
|
|
1890
2163
|
}, {
|
|
1891
2164
|
key: "executeValidate",
|
|
@@ -2084,17 +2357,17 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2084
2357
|
}, {
|
|
2085
2358
|
key: "nullable",
|
|
2086
2359
|
value: function nullable() {
|
|
2087
|
-
return new ImageSchema(this.options, true, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description);
|
|
2360
|
+
return new ImageSchema(this.options, true, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
2088
2361
|
}
|
|
2089
2362
|
}, {
|
|
2090
2363
|
key: "readonly",
|
|
2091
2364
|
value: function readonly() {
|
|
2092
|
-
return new ImageSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, true, this.isHidden, this.description);
|
|
2365
|
+
return new ImageSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, true, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
2093
2366
|
}
|
|
2094
2367
|
}, {
|
|
2095
2368
|
key: "hidden",
|
|
2096
2369
|
value: function hidden() {
|
|
2097
|
-
return new ImageSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, true, this.description);
|
|
2370
|
+
return new ImageSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
|
|
2098
2371
|
}
|
|
2099
2372
|
}, {
|
|
2100
2373
|
key: "executeCustomValidateAt",
|
|
@@ -2103,13 +2376,54 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2103
2376
|
path: path
|
|
2104
2377
|
});
|
|
2105
2378
|
}
|
|
2379
|
+
|
|
2380
|
+
/**
|
|
2381
|
+
* How this field is laid out in the editor when it is the item of an array
|
|
2382
|
+
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
2383
|
+
* instead of a preview row that navigates to it.
|
|
2384
|
+
*
|
|
2385
|
+
* Static configuration, not a callback — see `render.ts`.
|
|
2386
|
+
*/
|
|
2387
|
+
}, {
|
|
2388
|
+
key: "render",
|
|
2389
|
+
value: function render(input) {
|
|
2390
|
+
return new ImageSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
|
|
2391
|
+
}
|
|
2392
|
+
|
|
2393
|
+
/**
|
|
2394
|
+
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
2395
|
+
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
2396
|
+
* itself is edited (that is `render`). See `preview.ts`.
|
|
2397
|
+
*/
|
|
2398
|
+
}, {
|
|
2399
|
+
key: "preview",
|
|
2400
|
+
value: function preview(select) {
|
|
2401
|
+
return new ImageSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
|
|
2402
|
+
}
|
|
2403
|
+
}, {
|
|
2404
|
+
key: "executePreviewItem",
|
|
2405
|
+
value: function executePreviewItem(src) {
|
|
2406
|
+
if (this.previewInput === null) {
|
|
2407
|
+
return null;
|
|
2408
|
+
}
|
|
2409
|
+
return this.previewInput({
|
|
2410
|
+
val: src
|
|
2411
|
+
});
|
|
2412
|
+
}
|
|
2413
|
+
}, {
|
|
2414
|
+
key: "declaresItemPreview",
|
|
2415
|
+
value: function declaresItemPreview() {
|
|
2416
|
+
return this.previewInput !== null;
|
|
2417
|
+
}
|
|
2106
2418
|
}, {
|
|
2107
2419
|
key: "executeSerialize",
|
|
2108
2420
|
value: function executeSerialize() {
|
|
2109
|
-
var _this$customValidateF;
|
|
2421
|
+
var _this$renderInput, _this$customValidateF;
|
|
2110
2422
|
var modulePaths = this.moduleMetadata ? Object.keys(this.moduleMetadata) : [];
|
|
2111
2423
|
return {
|
|
2112
2424
|
type: "image",
|
|
2425
|
+
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
2426
|
+
preview: this.previewInput ? true : undefined,
|
|
2113
2427
|
options: this.options,
|
|
2114
2428
|
opt: this.opt,
|
|
2115
2429
|
remote: this.isRemote,
|
|
@@ -2135,7 +2449,7 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2135
2449
|
|
|
2136
2450
|
/** An image of its own, carrying its own dimensions and mime type. */
|
|
2137
2451
|
|
|
2138
|
-
function image(options) {
|
|
2452
|
+
function image(options, galleryOptions) {
|
|
2139
2453
|
var isModule = !!options && !!Internal.getValPath(options);
|
|
2140
2454
|
if (isModule) {
|
|
2141
2455
|
var allModules = {};
|
|
@@ -2147,7 +2461,9 @@ function image(options) {
|
|
|
2147
2461
|
}
|
|
2148
2462
|
allModules[modulePath] = getSource(valModule);
|
|
2149
2463
|
}
|
|
2150
|
-
return new ImageSchema(
|
|
2464
|
+
return new ImageSchema((galleryOptions === null || galleryOptions === void 0 ? void 0 : galleryOptions.encode) !== undefined ? {
|
|
2465
|
+
encode: galleryOptions.encode
|
|
2466
|
+
} : {}, false, false, [], allModules);
|
|
2151
2467
|
}
|
|
2152
2468
|
return new ImageSchema(options);
|
|
2153
2469
|
}
|
|
@@ -2160,6 +2476,8 @@ var RouteSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2160
2476
|
var isReadonly = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
2161
2477
|
var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
2162
2478
|
var description = arguments.length > 5 ? arguments[5] : undefined;
|
|
2479
|
+
var renderInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
|
|
2480
|
+
var previewInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
|
|
2163
2481
|
_classCallCheck(this, RouteSchema);
|
|
2164
2482
|
_this = _callSuper(this, RouteSchema);
|
|
2165
2483
|
_this.options = options;
|
|
@@ -2168,13 +2486,15 @@ var RouteSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2168
2486
|
_this.isReadonly = isReadonly;
|
|
2169
2487
|
_this.isHidden = isHidden;
|
|
2170
2488
|
_this.description = description;
|
|
2489
|
+
_this.renderInput = renderInput;
|
|
2490
|
+
_this.previewInput = previewInput;
|
|
2171
2491
|
return _this;
|
|
2172
2492
|
}
|
|
2173
2493
|
_inherits(RouteSchema, _Schema);
|
|
2174
2494
|
return _createClass(RouteSchema, [{
|
|
2175
2495
|
key: "describe",
|
|
2176
2496
|
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);
|
|
2497
|
+
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
2498
|
}
|
|
2179
2499
|
|
|
2180
2500
|
/**
|
|
@@ -2194,7 +2514,7 @@ var RouteSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2194
2514
|
value: function include(pattern) {
|
|
2195
2515
|
return new RouteSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
2196
2516
|
include: pattern
|
|
2197
|
-
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
|
|
2517
|
+
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
2198
2518
|
}
|
|
2199
2519
|
|
|
2200
2520
|
/**
|
|
@@ -2214,12 +2534,12 @@ var RouteSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2214
2534
|
value: function exclude(pattern) {
|
|
2215
2535
|
return new RouteSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
2216
2536
|
exclude: pattern
|
|
2217
|
-
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
|
|
2537
|
+
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
2218
2538
|
}
|
|
2219
2539
|
}, {
|
|
2220
2540
|
key: "validate",
|
|
2221
2541
|
value: function validate(validationFunction) {
|
|
2222
|
-
return new RouteSchema(this.options, this.opt, this.customValidateFunctions.concat(validationFunction), this.isReadonly, this.isHidden, this.description);
|
|
2542
|
+
return new RouteSchema(this.options, this.opt, this.customValidateFunctions.concat(validationFunction), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
2223
2543
|
}
|
|
2224
2544
|
}, {
|
|
2225
2545
|
key: "executeValidate",
|
|
@@ -2274,17 +2594,17 @@ var RouteSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2274
2594
|
}, {
|
|
2275
2595
|
key: "nullable",
|
|
2276
2596
|
value: function nullable() {
|
|
2277
|
-
return new RouteSchema(this.options, true, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
|
|
2597
|
+
return new RouteSchema(this.options, true, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
2278
2598
|
}
|
|
2279
2599
|
}, {
|
|
2280
2600
|
key: "readonly",
|
|
2281
2601
|
value: function readonly() {
|
|
2282
|
-
return new RouteSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
|
|
2602
|
+
return new RouteSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
2283
2603
|
}
|
|
2284
2604
|
}, {
|
|
2285
2605
|
key: "hidden",
|
|
2286
2606
|
value: function hidden() {
|
|
2287
|
-
return new RouteSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
2607
|
+
return new RouteSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
|
|
2288
2608
|
}
|
|
2289
2609
|
}, {
|
|
2290
2610
|
key: "executeCustomValidateAt",
|
|
@@ -2293,12 +2613,53 @@ var RouteSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2293
2613
|
path: path
|
|
2294
2614
|
});
|
|
2295
2615
|
}
|
|
2616
|
+
|
|
2617
|
+
/**
|
|
2618
|
+
* How this field is laid out in the editor when it is the item of an array
|
|
2619
|
+
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
2620
|
+
* instead of a preview row that navigates to it.
|
|
2621
|
+
*
|
|
2622
|
+
* Static configuration, not a callback — see `render.ts`.
|
|
2623
|
+
*/
|
|
2624
|
+
}, {
|
|
2625
|
+
key: "render",
|
|
2626
|
+
value: function render(input) {
|
|
2627
|
+
return new RouteSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
|
|
2628
|
+
}
|
|
2629
|
+
|
|
2630
|
+
/**
|
|
2631
|
+
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
2632
|
+
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
2633
|
+
* itself is edited (that is `render`). See `preview.ts`.
|
|
2634
|
+
*/
|
|
2635
|
+
}, {
|
|
2636
|
+
key: "preview",
|
|
2637
|
+
value: function preview(select) {
|
|
2638
|
+
return new RouteSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
|
|
2639
|
+
}
|
|
2640
|
+
}, {
|
|
2641
|
+
key: "executePreviewItem",
|
|
2642
|
+
value: function executePreviewItem(src) {
|
|
2643
|
+
if (this.previewInput === null) {
|
|
2644
|
+
return null;
|
|
2645
|
+
}
|
|
2646
|
+
return this.previewInput({
|
|
2647
|
+
val: src
|
|
2648
|
+
});
|
|
2649
|
+
}
|
|
2650
|
+
}, {
|
|
2651
|
+
key: "declaresItemPreview",
|
|
2652
|
+
value: function declaresItemPreview() {
|
|
2653
|
+
return this.previewInput !== null;
|
|
2654
|
+
}
|
|
2296
2655
|
}, {
|
|
2297
2656
|
key: "executeSerialize",
|
|
2298
2657
|
value: function executeSerialize() {
|
|
2299
|
-
var _this$options3, _this$options4, _this$customValidateF, _this$customValidateF2;
|
|
2658
|
+
var _this$renderInput, _this$options3, _this$options4, _this$customValidateF, _this$customValidateF2;
|
|
2300
2659
|
return {
|
|
2301
2660
|
type: "route",
|
|
2661
|
+
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
2662
|
+
preview: this.previewInput ? true : undefined,
|
|
2302
2663
|
options: {
|
|
2303
2664
|
include: ((_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : _this$options3.include) && {
|
|
2304
2665
|
source: this.options.include.source,
|
|
@@ -2336,6 +2697,8 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2336
2697
|
var isReadonly = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
2337
2698
|
var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
2338
2699
|
var description = arguments.length > 5 ? arguments[5] : undefined;
|
|
2700
|
+
var renderInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
|
|
2701
|
+
var previewInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
|
|
2339
2702
|
_classCallCheck(this, RichTextSchema);
|
|
2340
2703
|
_this = _callSuper(this, RichTextSchema);
|
|
2341
2704
|
_this.options = options;
|
|
@@ -2344,32 +2707,34 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2344
2707
|
_this.isReadonly = isReadonly;
|
|
2345
2708
|
_this.isHidden = isHidden;
|
|
2346
2709
|
_this.description = description;
|
|
2710
|
+
_this.renderInput = renderInput;
|
|
2711
|
+
_this.previewInput = previewInput;
|
|
2347
2712
|
return _this;
|
|
2348
2713
|
}
|
|
2349
2714
|
_inherits(RichTextSchema, _Schema);
|
|
2350
2715
|
return _createClass(RichTextSchema, [{
|
|
2351
2716
|
key: "describe",
|
|
2352
2717
|
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);
|
|
2718
|
+
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
2719
|
}
|
|
2355
2720
|
}, {
|
|
2356
2721
|
key: "maxLength",
|
|
2357
2722
|
value: function maxLength(max) {
|
|
2358
2723
|
return new RichTextSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
2359
2724
|
maxLength: max
|
|
2360
|
-
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
|
|
2725
|
+
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
2361
2726
|
}
|
|
2362
2727
|
}, {
|
|
2363
2728
|
key: "minLength",
|
|
2364
2729
|
value: function minLength(min) {
|
|
2365
2730
|
return new RichTextSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
2366
2731
|
minLength: min
|
|
2367
|
-
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
|
|
2732
|
+
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
2368
2733
|
}
|
|
2369
2734
|
}, {
|
|
2370
2735
|
key: "validate",
|
|
2371
2736
|
value: function validate(validationFunction) {
|
|
2372
|
-
return new RichTextSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description);
|
|
2737
|
+
return new RichTextSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
2373
2738
|
}
|
|
2374
2739
|
}, {
|
|
2375
2740
|
key: "executeValidate",
|
|
@@ -2819,17 +3184,17 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2819
3184
|
}, {
|
|
2820
3185
|
key: "nullable",
|
|
2821
3186
|
value: function nullable() {
|
|
2822
|
-
return new RichTextSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description);
|
|
3187
|
+
return new RichTextSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
2823
3188
|
}
|
|
2824
3189
|
}, {
|
|
2825
3190
|
key: "readonly",
|
|
2826
3191
|
value: function readonly() {
|
|
2827
|
-
return new RichTextSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
|
|
3192
|
+
return new RichTextSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
2828
3193
|
}
|
|
2829
3194
|
}, {
|
|
2830
3195
|
key: "hidden",
|
|
2831
3196
|
value: function hidden() {
|
|
2832
|
-
return new RichTextSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
3197
|
+
return new RichTextSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
|
|
2833
3198
|
}
|
|
2834
3199
|
}, {
|
|
2835
3200
|
key: "executeCustomValidateAt",
|
|
@@ -2838,10 +3203,50 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2838
3203
|
path: path
|
|
2839
3204
|
});
|
|
2840
3205
|
}
|
|
3206
|
+
|
|
3207
|
+
/**
|
|
3208
|
+
* How this field is laid out in the editor when it is the item of an array
|
|
3209
|
+
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
3210
|
+
* instead of a preview row that navigates to it.
|
|
3211
|
+
*
|
|
3212
|
+
* Static configuration, not a callback — see `render.ts`.
|
|
3213
|
+
*/
|
|
3214
|
+
}, {
|
|
3215
|
+
key: "render",
|
|
3216
|
+
value: function render(input) {
|
|
3217
|
+
return new RichTextSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
|
|
3218
|
+
}
|
|
3219
|
+
|
|
3220
|
+
/**
|
|
3221
|
+
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
3222
|
+
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
3223
|
+
* itself is edited (that is `render`). See `preview.ts`.
|
|
3224
|
+
*/
|
|
3225
|
+
}, {
|
|
3226
|
+
key: "preview",
|
|
3227
|
+
value: function preview(select) {
|
|
3228
|
+
return new RichTextSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
|
|
3229
|
+
}
|
|
3230
|
+
}, {
|
|
3231
|
+
key: "executePreviewItem",
|
|
3232
|
+
value: function executePreviewItem(src) {
|
|
3233
|
+
if (this.previewInput === null) {
|
|
3234
|
+
return null;
|
|
3235
|
+
}
|
|
3236
|
+
return this.previewInput({
|
|
3237
|
+
val: src
|
|
3238
|
+
});
|
|
3239
|
+
}
|
|
3240
|
+
}, {
|
|
3241
|
+
key: "declaresItemPreview",
|
|
3242
|
+
value: function declaresItemPreview() {
|
|
3243
|
+
return this.previewInput !== null;
|
|
3244
|
+
}
|
|
2841
3245
|
}, {
|
|
2842
3246
|
key: "executeSerialize",
|
|
2843
3247
|
value: function executeSerialize() {
|
|
2844
3248
|
var _this3 = this,
|
|
3249
|
+
_this$renderInput,
|
|
2845
3250
|
_this$customValidateF;
|
|
2846
3251
|
var serializeAnchorSchema = function serializeAnchorSchema() {
|
|
2847
3252
|
var _this3$options$inline, _this3$options$inline3;
|
|
@@ -2868,6 +3273,8 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2868
3273
|
};
|
|
2869
3274
|
return {
|
|
2870
3275
|
type: "richtext",
|
|
3276
|
+
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
3277
|
+
preview: this.previewInput ? true : undefined,
|
|
2871
3278
|
opt: this.opt,
|
|
2872
3279
|
options: serializedOptions,
|
|
2873
3280
|
customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
|
|
@@ -3212,6 +3619,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3212
3619
|
var description = arguments.length > 8 ? arguments[8] : undefined;
|
|
3213
3620
|
var isJsonValues = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : false;
|
|
3214
3621
|
var previewInput = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : null;
|
|
3622
|
+
var renderInput = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : null;
|
|
3215
3623
|
_classCallCheck(this, RecordSchema);
|
|
3216
3624
|
_this = _callSuper(this, RecordSchema);
|
|
3217
3625
|
_this.item = item;
|
|
@@ -3225,18 +3633,19 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3225
3633
|
_this.description = description;
|
|
3226
3634
|
_this.isJsonValues = isJsonValues;
|
|
3227
3635
|
_this.previewInput = previewInput;
|
|
3636
|
+
_this.renderInput = renderInput;
|
|
3228
3637
|
return _this;
|
|
3229
3638
|
}
|
|
3230
3639
|
_inherits(RecordSchema, _Schema);
|
|
3231
3640
|
return _createClass(RecordSchema, [{
|
|
3232
3641
|
key: "describe",
|
|
3233
3642
|
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);
|
|
3643
|
+
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
3644
|
}
|
|
3236
3645
|
}, {
|
|
3237
3646
|
key: "validate",
|
|
3238
3647
|
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);
|
|
3648
|
+
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
3649
|
}
|
|
3241
3650
|
}, {
|
|
3242
3651
|
key: "executeValidate",
|
|
@@ -3595,29 +4004,29 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3595
4004
|
}, {
|
|
3596
4005
|
key: "nullable",
|
|
3597
4006
|
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);
|
|
4007
|
+
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
4008
|
}
|
|
3600
4009
|
}, {
|
|
3601
4010
|
key: "readonly",
|
|
3602
4011
|
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);
|
|
4012
|
+
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
4013
|
}
|
|
3605
4014
|
}, {
|
|
3606
4015
|
key: "hidden",
|
|
3607
4016
|
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);
|
|
4017
|
+
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
4018
|
}
|
|
3610
4019
|
}, {
|
|
3611
4020
|
key: "router",
|
|
3612
4021
|
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);
|
|
4022
|
+
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
4023
|
}
|
|
3615
4024
|
}, {
|
|
3616
4025
|
key: "remote",
|
|
3617
4026
|
value: function remote() {
|
|
3618
4027
|
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions ? _objectSpread2(_objectSpread2({}, this.mediaOptions), {}, {
|
|
3619
4028
|
remote: true
|
|
3620
|
-
}) : undefined, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.previewInput);
|
|
4029
|
+
}) : undefined, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.previewInput, this.renderInput);
|
|
3621
4030
|
}
|
|
3622
4031
|
|
|
3623
4032
|
/**
|
|
@@ -3647,9 +4056,19 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3647
4056
|
// `.validate(...)` in their source file that never ran anywhere.
|
|
3648
4057
|
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
4058
|
}
|
|
4059
|
+
if (this.previewInput !== null) {
|
|
4060
|
+
// Same reasoning as the validator guard above: the record's own preview
|
|
4061
|
+
// closure is typed against the un-lazy source shape.
|
|
4062
|
+
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.");
|
|
4063
|
+
}
|
|
4064
|
+
// Explicit type args instead of a cast on the result: `previewInput` would
|
|
4065
|
+
// otherwise pin inference to `Src`, and the two record source shapes no
|
|
4066
|
+
// longer overlap enough for the old assertion.
|
|
3650
4067
|
return new RecordSchema(this.item, this.opt,
|
|
3651
4068
|
// 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,
|
|
4069
|
+
[], this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, true,
|
|
4070
|
+
// Null by construction: the guard above rejects any that was declared.
|
|
4071
|
+
null, this.renderInput);
|
|
3653
4072
|
}
|
|
3654
4073
|
}, {
|
|
3655
4074
|
key: "getRouterValidations",
|
|
@@ -3703,9 +4122,10 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3703
4122
|
}, {
|
|
3704
4123
|
key: "executeSerialize",
|
|
3705
4124
|
value: function executeSerialize() {
|
|
3706
|
-
var _this$keySchema, _this$currentRouter, _this$customValidateF;
|
|
4125
|
+
var _this$renderInput, _this$keySchema, _this$currentRouter, _this$customValidateF;
|
|
3707
4126
|
var result = {
|
|
3708
4127
|
type: "record",
|
|
4128
|
+
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
3709
4129
|
item: this.item["executeSerialize"](),
|
|
3710
4130
|
key: (_this$keySchema = this.keySchema) === null || _this$keySchema === void 0 ? void 0 : _this$keySchema["executeSerialize"](),
|
|
3711
4131
|
opt: this.opt,
|
|
@@ -3722,6 +4142,9 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3722
4142
|
result.accept = this.mediaOptions.accept;
|
|
3723
4143
|
result.directory = this.mediaOptions.directory;
|
|
3724
4144
|
result.remote = this.mediaOptions.remote;
|
|
4145
|
+
if (this.mediaOptions.encode !== undefined) {
|
|
4146
|
+
result.encode = this.mediaOptions.encode;
|
|
4147
|
+
}
|
|
3725
4148
|
if (this.mediaOptions.altSchema) {
|
|
3726
4149
|
result.alt = this.mediaOptions.altSchema["executeSerialize"]();
|
|
3727
4150
|
}
|
|
@@ -3769,8 +4192,10 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3769
4192
|
res[_key2] = itemResult[_key2];
|
|
3770
4193
|
}
|
|
3771
4194
|
}
|
|
3772
|
-
|
|
3773
|
-
|
|
4195
|
+
// The entries preview comes from the ITEM schema's own `preview` — the
|
|
4196
|
+
// container just runs it per entry. Asked as a fact rather than by running
|
|
4197
|
+
// the closure, so an empty record still previews as an empty record.
|
|
4198
|
+
if (this.item["declaresItemPreview"]()) {
|
|
3774
4199
|
// See the same block in `array`: the whole record when the record is what
|
|
3775
4200
|
// is being shown, only the wanted entries when it is not.
|
|
3776
4201
|
var window = scope !== undefined && !scope.wants(sourcePath) ? scope : null;
|
|
@@ -3782,6 +4207,9 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3782
4207
|
if (isJson(val)) {
|
|
3783
4208
|
continue; // as above: nothing to select from an un-loaded entry
|
|
3784
4209
|
}
|
|
4210
|
+
if (val === null || val === undefined) {
|
|
4211
|
+
continue;
|
|
4212
|
+
}
|
|
3785
4213
|
if (window !== null && !window.wantsUnder(unsafeCreateSourcePath(sourcePath, _key3))) {
|
|
3786
4214
|
continue;
|
|
3787
4215
|
}
|
|
@@ -3789,18 +4217,17 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3789
4217
|
// data trips it up must not take out the whole list.
|
|
3790
4218
|
try {
|
|
3791
4219
|
// NB NB: display is actually defined by the user
|
|
3792
|
-
var
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
}]);
|
|
4220
|
+
var _item = this.item["executePreviewItem"](val);
|
|
4221
|
+
if (_item !== null) {
|
|
4222
|
+
var title = _item.title,
|
|
4223
|
+
subtitle = _item.subtitle,
|
|
4224
|
+
image = _item.image;
|
|
4225
|
+
items.push([_key3, {
|
|
4226
|
+
title: title,
|
|
4227
|
+
subtitle: subtitle,
|
|
4228
|
+
image: image
|
|
4229
|
+
}]);
|
|
4230
|
+
}
|
|
3804
4231
|
} catch (e) {
|
|
3805
4232
|
res[unsafeCreateSourcePath(sourcePath, _key3)] = {
|
|
3806
4233
|
status: "error",
|
|
@@ -3818,19 +4245,45 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3818
4245
|
}
|
|
3819
4246
|
return res;
|
|
3820
4247
|
}
|
|
4248
|
+
}, {
|
|
4249
|
+
key: "executePreviewItem",
|
|
4250
|
+
value: function executePreviewItem(src) {
|
|
4251
|
+
if (this.previewInput === null) {
|
|
4252
|
+
return null;
|
|
4253
|
+
}
|
|
4254
|
+
return this.previewInput({
|
|
4255
|
+
val: src
|
|
4256
|
+
});
|
|
4257
|
+
}
|
|
4258
|
+
}, {
|
|
4259
|
+
key: "declaresItemPreview",
|
|
4260
|
+
value: function declaresItemPreview() {
|
|
4261
|
+
return this.previewInput !== null;
|
|
4262
|
+
}
|
|
3821
4263
|
|
|
3822
4264
|
/**
|
|
3823
|
-
*
|
|
3824
|
-
*
|
|
3825
|
-
*
|
|
3826
|
-
*
|
|
3827
|
-
* demand for the entries that are actually being looked at — see
|
|
3828
|
-
* `PreviewScope`.
|
|
4265
|
+
* How this RECORD ITSELF is shown where a preview of it is needed — when it
|
|
4266
|
+
* is the item of another container, in search, in references. What its
|
|
4267
|
+
* entries show is the ITEM schema's `preview`, not this. Never how the field
|
|
4268
|
+
* is edited (that is `render`). See `preview.ts`.
|
|
3829
4269
|
*/
|
|
3830
4270
|
}, {
|
|
3831
4271
|
key: "preview",
|
|
3832
4272
|
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);
|
|
4273
|
+
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);
|
|
4274
|
+
}
|
|
4275
|
+
|
|
4276
|
+
/**
|
|
4277
|
+
* How this field is laid out in the editor when it is the item of an array
|
|
4278
|
+
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
4279
|
+
* instead of a preview row that navigates to it.
|
|
4280
|
+
*
|
|
4281
|
+
* Static configuration, not a callback — see `render.ts`.
|
|
4282
|
+
*/
|
|
4283
|
+
}, {
|
|
4284
|
+
key: "render",
|
|
4285
|
+
value: function render(input) {
|
|
4286
|
+
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
4287
|
}
|
|
3835
4288
|
}]);
|
|
3836
4289
|
}(Schema);
|
|
@@ -4399,6 +4852,8 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4399
4852
|
var isReadonly = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
4400
4853
|
var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
4401
4854
|
var description = arguments.length > 5 ? arguments[5] : undefined;
|
|
4855
|
+
var renderInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
|
|
4856
|
+
var previewInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
|
|
4402
4857
|
_classCallCheck(this, NumberSchema);
|
|
4403
4858
|
_this = _callSuper(this, NumberSchema);
|
|
4404
4859
|
_this.options = options;
|
|
@@ -4407,18 +4862,20 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4407
4862
|
_this.isReadonly = isReadonly;
|
|
4408
4863
|
_this.isHidden = isHidden;
|
|
4409
4864
|
_this.description = description;
|
|
4865
|
+
_this.renderInput = renderInput;
|
|
4866
|
+
_this.previewInput = previewInput;
|
|
4410
4867
|
return _this;
|
|
4411
4868
|
}
|
|
4412
4869
|
_inherits(NumberSchema, _Schema);
|
|
4413
4870
|
return _createClass(NumberSchema, [{
|
|
4414
4871
|
key: "describe",
|
|
4415
4872
|
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);
|
|
4873
|
+
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
4874
|
}
|
|
4418
4875
|
}, {
|
|
4419
4876
|
key: "validate",
|
|
4420
4877
|
value: function validate(validationFunction) {
|
|
4421
|
-
return new NumberSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description);
|
|
4878
|
+
return new NumberSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
4422
4879
|
}
|
|
4423
4880
|
}, {
|
|
4424
4881
|
key: "executeValidate",
|
|
@@ -4488,31 +4945,31 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4488
4945
|
}, {
|
|
4489
4946
|
key: "nullable",
|
|
4490
4947
|
value: function nullable() {
|
|
4491
|
-
return new NumberSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description);
|
|
4948
|
+
return new NumberSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
4492
4949
|
}
|
|
4493
4950
|
}, {
|
|
4494
4951
|
key: "readonly",
|
|
4495
4952
|
value: function readonly() {
|
|
4496
|
-
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
|
|
4953
|
+
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
4497
4954
|
}
|
|
4498
4955
|
}, {
|
|
4499
4956
|
key: "hidden",
|
|
4500
4957
|
value: function hidden() {
|
|
4501
|
-
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
4958
|
+
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
|
|
4502
4959
|
}
|
|
4503
4960
|
}, {
|
|
4504
4961
|
key: "max",
|
|
4505
4962
|
value: function max(_max) {
|
|
4506
4963
|
return new NumberSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
4507
4964
|
max: _max
|
|
4508
|
-
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
|
|
4965
|
+
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
4509
4966
|
}
|
|
4510
4967
|
}, {
|
|
4511
4968
|
key: "min",
|
|
4512
4969
|
value: function min(_min) {
|
|
4513
4970
|
return new NumberSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
4514
4971
|
min: _min
|
|
4515
|
-
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
|
|
4972
|
+
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
4516
4973
|
}
|
|
4517
4974
|
}, {
|
|
4518
4975
|
key: "executeCustomValidateAt",
|
|
@@ -4521,12 +4978,53 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4521
4978
|
path: path
|
|
4522
4979
|
});
|
|
4523
4980
|
}
|
|
4981
|
+
|
|
4982
|
+
/**
|
|
4983
|
+
* How this field is laid out in the editor when it is the item of an array
|
|
4984
|
+
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
4985
|
+
* instead of a preview row that navigates to it.
|
|
4986
|
+
*
|
|
4987
|
+
* Static configuration, not a callback — see `render.ts`.
|
|
4988
|
+
*/
|
|
4989
|
+
}, {
|
|
4990
|
+
key: "render",
|
|
4991
|
+
value: function render(input) {
|
|
4992
|
+
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
|
|
4993
|
+
}
|
|
4994
|
+
|
|
4995
|
+
/**
|
|
4996
|
+
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
4997
|
+
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
4998
|
+
* itself is edited (that is `render`). See `preview.ts`.
|
|
4999
|
+
*/
|
|
5000
|
+
}, {
|
|
5001
|
+
key: "preview",
|
|
5002
|
+
value: function preview(select) {
|
|
5003
|
+
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
|
|
5004
|
+
}
|
|
5005
|
+
}, {
|
|
5006
|
+
key: "executePreviewItem",
|
|
5007
|
+
value: function executePreviewItem(src) {
|
|
5008
|
+
if (this.previewInput === null) {
|
|
5009
|
+
return null;
|
|
5010
|
+
}
|
|
5011
|
+
return this.previewInput({
|
|
5012
|
+
val: src
|
|
5013
|
+
});
|
|
5014
|
+
}
|
|
5015
|
+
}, {
|
|
5016
|
+
key: "declaresItemPreview",
|
|
5017
|
+
value: function declaresItemPreview() {
|
|
5018
|
+
return this.previewInput !== null;
|
|
5019
|
+
}
|
|
4524
5020
|
}, {
|
|
4525
5021
|
key: "executeSerialize",
|
|
4526
5022
|
value: function executeSerialize() {
|
|
4527
|
-
var _this$customValidateF;
|
|
5023
|
+
var _this$renderInput, _this$customValidateF;
|
|
4528
5024
|
return {
|
|
4529
5025
|
type: "number",
|
|
5026
|
+
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
5027
|
+
preview: this.previewInput ? true : undefined,
|
|
4530
5028
|
options: this.options,
|
|
4531
5029
|
opt: this.opt,
|
|
4532
5030
|
customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
|
|
@@ -4554,6 +5052,8 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4554
5052
|
var isReadonly = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
4555
5053
|
var isHidden = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
4556
5054
|
var description = arguments.length > 4 ? arguments[4] : undefined;
|
|
5055
|
+
var renderInput = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
|
|
5056
|
+
var previewInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
|
|
4557
5057
|
_classCallCheck(this, BooleanSchema);
|
|
4558
5058
|
_this = _callSuper(this, BooleanSchema);
|
|
4559
5059
|
_this.opt = opt;
|
|
@@ -4561,18 +5061,20 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4561
5061
|
_this.isReadonly = isReadonly;
|
|
4562
5062
|
_this.isHidden = isHidden;
|
|
4563
5063
|
_this.description = description;
|
|
5064
|
+
_this.renderInput = renderInput;
|
|
5065
|
+
_this.previewInput = previewInput;
|
|
4564
5066
|
return _this;
|
|
4565
5067
|
}
|
|
4566
5068
|
_inherits(BooleanSchema, _Schema);
|
|
4567
5069
|
return _createClass(BooleanSchema, [{
|
|
4568
5070
|
key: "describe",
|
|
4569
5071
|
value: function describe(description) {
|
|
4570
|
-
return new BooleanSchema(this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
|
|
5072
|
+
return new BooleanSchema(this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput, this.previewInput);
|
|
4571
5073
|
}
|
|
4572
5074
|
}, {
|
|
4573
5075
|
key: "validate",
|
|
4574
5076
|
value: function validate(validationFunction) {
|
|
4575
|
-
return new BooleanSchema(this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description);
|
|
5077
|
+
return new BooleanSchema(this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
4576
5078
|
}
|
|
4577
5079
|
}, {
|
|
4578
5080
|
key: "executeValidate",
|
|
@@ -4623,17 +5125,17 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4623
5125
|
}, {
|
|
4624
5126
|
key: "nullable",
|
|
4625
5127
|
value: function nullable() {
|
|
4626
|
-
return new BooleanSchema(true, [], this.isReadonly, this.isHidden, this.description);
|
|
5128
|
+
return new BooleanSchema(true, [], this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
4627
5129
|
}
|
|
4628
5130
|
}, {
|
|
4629
5131
|
key: "readonly",
|
|
4630
5132
|
value: function readonly() {
|
|
4631
|
-
return new BooleanSchema(this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
|
|
5133
|
+
return new BooleanSchema(this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
4632
5134
|
}
|
|
4633
5135
|
}, {
|
|
4634
5136
|
key: "hidden",
|
|
4635
5137
|
value: function hidden() {
|
|
4636
|
-
return new BooleanSchema(this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
5138
|
+
return new BooleanSchema(this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
|
|
4637
5139
|
}
|
|
4638
5140
|
}, {
|
|
4639
5141
|
key: "executeCustomValidateAt",
|
|
@@ -4642,12 +5144,53 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4642
5144
|
path: path
|
|
4643
5145
|
});
|
|
4644
5146
|
}
|
|
5147
|
+
|
|
5148
|
+
/**
|
|
5149
|
+
* How this field is laid out in the editor when it is the item of an array
|
|
5150
|
+
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
5151
|
+
* instead of a preview row that navigates to it.
|
|
5152
|
+
*
|
|
5153
|
+
* Static configuration, not a callback — see `render.ts`.
|
|
5154
|
+
*/
|
|
5155
|
+
}, {
|
|
5156
|
+
key: "render",
|
|
5157
|
+
value: function render(input) {
|
|
5158
|
+
return new BooleanSchema(this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
|
|
5159
|
+
}
|
|
5160
|
+
|
|
5161
|
+
/**
|
|
5162
|
+
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
5163
|
+
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
5164
|
+
* itself is edited (that is `render`). See `preview.ts`.
|
|
5165
|
+
*/
|
|
5166
|
+
}, {
|
|
5167
|
+
key: "preview",
|
|
5168
|
+
value: function preview(select) {
|
|
5169
|
+
return new BooleanSchema(this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
|
|
5170
|
+
}
|
|
5171
|
+
}, {
|
|
5172
|
+
key: "executePreviewItem",
|
|
5173
|
+
value: function executePreviewItem(src) {
|
|
5174
|
+
if (this.previewInput === null) {
|
|
5175
|
+
return null;
|
|
5176
|
+
}
|
|
5177
|
+
return this.previewInput({
|
|
5178
|
+
val: src
|
|
5179
|
+
});
|
|
5180
|
+
}
|
|
5181
|
+
}, {
|
|
5182
|
+
key: "declaresItemPreview",
|
|
5183
|
+
value: function declaresItemPreview() {
|
|
5184
|
+
return this.previewInput !== null;
|
|
5185
|
+
}
|
|
4645
5186
|
}, {
|
|
4646
5187
|
key: "executeSerialize",
|
|
4647
5188
|
value: function executeSerialize() {
|
|
4648
|
-
var _this$customValidateF;
|
|
5189
|
+
var _this$renderInput, _this$customValidateF;
|
|
4649
5190
|
return {
|
|
4650
5191
|
type: "boolean",
|
|
5192
|
+
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
5193
|
+
preview: this.previewInput ? true : undefined,
|
|
4651
5194
|
opt: this.opt,
|
|
4652
5195
|
customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
|
|
4653
5196
|
readonly: this.isReadonly,
|
|
@@ -4674,6 +5217,8 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4674
5217
|
var isReadonly = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
4675
5218
|
var isHidden = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
4676
5219
|
var description = arguments.length > 6 ? arguments[6] : undefined;
|
|
5220
|
+
var renderInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
|
|
5221
|
+
var previewInput = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
|
|
4677
5222
|
_classCallCheck(this, KeyOfSchema);
|
|
4678
5223
|
_this = _callSuper(this, KeyOfSchema);
|
|
4679
5224
|
_this.schema = schema;
|
|
@@ -4683,18 +5228,20 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4683
5228
|
_this.isReadonly = isReadonly;
|
|
4684
5229
|
_this.isHidden = isHidden;
|
|
4685
5230
|
_this.description = description;
|
|
5231
|
+
_this.renderInput = renderInput;
|
|
5232
|
+
_this.previewInput = previewInput;
|
|
4686
5233
|
return _this;
|
|
4687
5234
|
}
|
|
4688
5235
|
_inherits(KeyOfSchema, _Schema);
|
|
4689
5236
|
return _createClass(KeyOfSchema, [{
|
|
4690
5237
|
key: "describe",
|
|
4691
5238
|
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);
|
|
5239
|
+
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
5240
|
}
|
|
4694
5241
|
}, {
|
|
4695
5242
|
key: "validate",
|
|
4696
5243
|
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);
|
|
5244
|
+
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
5245
|
}
|
|
4699
5246
|
}, {
|
|
4700
5247
|
key: "executeValidate",
|
|
@@ -4824,17 +5371,17 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4824
5371
|
}, {
|
|
4825
5372
|
key: "nullable",
|
|
4826
5373
|
value: function nullable() {
|
|
4827
|
-
return new KeyOfSchema(this.schema, this.sourcePath, true, [], this.isReadonly, this.isHidden, this.description);
|
|
5374
|
+
return new KeyOfSchema(this.schema, this.sourcePath, true, [], this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
4828
5375
|
}
|
|
4829
5376
|
}, {
|
|
4830
5377
|
key: "readonly",
|
|
4831
5378
|
value: function readonly() {
|
|
4832
|
-
return new KeyOfSchema(this.schema, this.sourcePath, this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
|
|
5379
|
+
return new KeyOfSchema(this.schema, this.sourcePath, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
4833
5380
|
}
|
|
4834
5381
|
}, {
|
|
4835
5382
|
key: "hidden",
|
|
4836
5383
|
value: function hidden() {
|
|
4837
|
-
return new KeyOfSchema(this.schema, this.sourcePath, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
5384
|
+
return new KeyOfSchema(this.schema, this.sourcePath, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
|
|
4838
5385
|
}
|
|
4839
5386
|
}, {
|
|
4840
5387
|
key: "executeCustomValidateAt",
|
|
@@ -4843,10 +5390,49 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4843
5390
|
path: path
|
|
4844
5391
|
});
|
|
4845
5392
|
}
|
|
5393
|
+
|
|
5394
|
+
/**
|
|
5395
|
+
* How this field is laid out in the editor when it is the item of an array
|
|
5396
|
+
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
5397
|
+
* instead of a preview row that navigates to it.
|
|
5398
|
+
*
|
|
5399
|
+
* Static configuration, not a callback — see `render.ts`.
|
|
5400
|
+
*/
|
|
5401
|
+
}, {
|
|
5402
|
+
key: "render",
|
|
5403
|
+
value: function render(input) {
|
|
5404
|
+
return new KeyOfSchema(this.schema, this.sourcePath, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
|
|
5405
|
+
}
|
|
5406
|
+
|
|
5407
|
+
/**
|
|
5408
|
+
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
5409
|
+
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
5410
|
+
* itself is edited (that is `render`). See `preview.ts`.
|
|
5411
|
+
*/
|
|
5412
|
+
}, {
|
|
5413
|
+
key: "preview",
|
|
5414
|
+
value: function preview(select) {
|
|
5415
|
+
return new KeyOfSchema(this.schema, this.sourcePath, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
|
|
5416
|
+
}
|
|
5417
|
+
}, {
|
|
5418
|
+
key: "executePreviewItem",
|
|
5419
|
+
value: function executePreviewItem(src) {
|
|
5420
|
+
if (this.previewInput === null) {
|
|
5421
|
+
return null;
|
|
5422
|
+
}
|
|
5423
|
+
return this.previewInput({
|
|
5424
|
+
val: src
|
|
5425
|
+
});
|
|
5426
|
+
}
|
|
5427
|
+
}, {
|
|
5428
|
+
key: "declaresItemPreview",
|
|
5429
|
+
value: function declaresItemPreview() {
|
|
5430
|
+
return this.previewInput !== null;
|
|
5431
|
+
}
|
|
4846
5432
|
}, {
|
|
4847
5433
|
key: "executeSerialize",
|
|
4848
5434
|
value: function executeSerialize() {
|
|
4849
|
-
var _this$customValidateF;
|
|
5435
|
+
var _this$renderInput, _this$customValidateF;
|
|
4850
5436
|
var path = this.sourcePath;
|
|
4851
5437
|
if (!path) {
|
|
4852
5438
|
throw new Error("Cannot serialize keyOf schema with empty selector. TIP: keyOf must be used with a Val Module of record schema.");
|
|
@@ -4869,6 +5455,8 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4869
5455
|
}
|
|
4870
5456
|
return {
|
|
4871
5457
|
type: "keyOf",
|
|
5458
|
+
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
5459
|
+
preview: this.previewInput ? true : undefined,
|
|
4872
5460
|
path: path,
|
|
4873
5461
|
schema: serializedSchema,
|
|
4874
5462
|
opt: this.opt,
|
|
@@ -4920,6 +5508,8 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4920
5508
|
var isReadonly = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
4921
5509
|
var isHidden = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
4922
5510
|
var description = arguments.length > 7 ? arguments[7] : undefined;
|
|
5511
|
+
var renderInput = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
|
|
5512
|
+
var previewInput = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : null;
|
|
4923
5513
|
_classCallCheck(this, FileSchema);
|
|
4924
5514
|
_this = _callSuper(this, FileSchema);
|
|
4925
5515
|
_this.options = options;
|
|
@@ -4930,23 +5520,25 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4930
5520
|
_this.isReadonly = isReadonly;
|
|
4931
5521
|
_this.isHidden = isHidden;
|
|
4932
5522
|
_this.description = description;
|
|
5523
|
+
_this.renderInput = renderInput;
|
|
5524
|
+
_this.previewInput = previewInput;
|
|
4933
5525
|
return _this;
|
|
4934
5526
|
}
|
|
4935
5527
|
_inherits(FileSchema, _Schema);
|
|
4936
5528
|
return _createClass(FileSchema, [{
|
|
4937
5529
|
key: "describe",
|
|
4938
5530
|
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);
|
|
5531
|
+
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
5532
|
}
|
|
4941
5533
|
}, {
|
|
4942
5534
|
key: "remote",
|
|
4943
5535
|
value: function remote() {
|
|
4944
|
-
return new FileSchema(this.options, this.opt, true, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description);
|
|
5536
|
+
return new FileSchema(this.options, this.opt, true, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
4945
5537
|
}
|
|
4946
5538
|
}, {
|
|
4947
5539
|
key: "validate",
|
|
4948
5540
|
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);
|
|
5541
|
+
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
5542
|
}
|
|
4951
5543
|
}, {
|
|
4952
5544
|
key: "executeValidate",
|
|
@@ -5127,17 +5719,17 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
|
|
|
5127
5719
|
}, {
|
|
5128
5720
|
key: "nullable",
|
|
5129
5721
|
value: function nullable() {
|
|
5130
|
-
return new FileSchema(this.options, true, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description);
|
|
5722
|
+
return new FileSchema(this.options, true, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
5131
5723
|
}
|
|
5132
5724
|
}, {
|
|
5133
5725
|
key: "readonly",
|
|
5134
5726
|
value: function readonly() {
|
|
5135
|
-
return new FileSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, true, this.isHidden, this.description);
|
|
5727
|
+
return new FileSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, true, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
5136
5728
|
}
|
|
5137
5729
|
}, {
|
|
5138
5730
|
key: "hidden",
|
|
5139
5731
|
value: function hidden() {
|
|
5140
|
-
return new FileSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, true, this.description);
|
|
5732
|
+
return new FileSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
|
|
5141
5733
|
}
|
|
5142
5734
|
}, {
|
|
5143
5735
|
key: "executeCustomValidateAt",
|
|
@@ -5146,13 +5738,54 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
|
|
|
5146
5738
|
path: path
|
|
5147
5739
|
});
|
|
5148
5740
|
}
|
|
5741
|
+
|
|
5742
|
+
/**
|
|
5743
|
+
* How this field is laid out in the editor when it is the item of an array
|
|
5744
|
+
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
5745
|
+
* instead of a preview row that navigates to it.
|
|
5746
|
+
*
|
|
5747
|
+
* Static configuration, not a callback — see `render.ts`.
|
|
5748
|
+
*/
|
|
5749
|
+
}, {
|
|
5750
|
+
key: "render",
|
|
5751
|
+
value: function render(input) {
|
|
5752
|
+
return new FileSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
|
|
5753
|
+
}
|
|
5754
|
+
|
|
5755
|
+
/**
|
|
5756
|
+
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
5757
|
+
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
5758
|
+
* itself is edited (that is `render`). See `preview.ts`.
|
|
5759
|
+
*/
|
|
5760
|
+
}, {
|
|
5761
|
+
key: "preview",
|
|
5762
|
+
value: function preview(select) {
|
|
5763
|
+
return new FileSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
|
|
5764
|
+
}
|
|
5765
|
+
}, {
|
|
5766
|
+
key: "executePreviewItem",
|
|
5767
|
+
value: function executePreviewItem(src) {
|
|
5768
|
+
if (this.previewInput === null) {
|
|
5769
|
+
return null;
|
|
5770
|
+
}
|
|
5771
|
+
return this.previewInput({
|
|
5772
|
+
val: src
|
|
5773
|
+
});
|
|
5774
|
+
}
|
|
5775
|
+
}, {
|
|
5776
|
+
key: "declaresItemPreview",
|
|
5777
|
+
value: function declaresItemPreview() {
|
|
5778
|
+
return this.previewInput !== null;
|
|
5779
|
+
}
|
|
5149
5780
|
}, {
|
|
5150
5781
|
key: "executeSerialize",
|
|
5151
5782
|
value: function executeSerialize() {
|
|
5152
|
-
var _this$customValidateF;
|
|
5783
|
+
var _this$renderInput, _this$customValidateF;
|
|
5153
5784
|
var modulePaths = this.moduleMetadata ? Object.keys(this.moduleMetadata) : [];
|
|
5154
5785
|
return {
|
|
5155
5786
|
type: "file",
|
|
5787
|
+
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
5788
|
+
preview: this.previewInput ? true : undefined,
|
|
5156
5789
|
options: this.options,
|
|
5157
5790
|
opt: this.opt,
|
|
5158
5791
|
remote: this.isRemote,
|
|
@@ -5241,6 +5874,8 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
|
|
|
5241
5874
|
var isReadonly = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
5242
5875
|
var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
5243
5876
|
var description = arguments.length > 5 ? arguments[5] : undefined;
|
|
5877
|
+
var renderInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
|
|
5878
|
+
var previewInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
|
|
5244
5879
|
_classCallCheck(this, DateSchema);
|
|
5245
5880
|
_this = _callSuper(this, DateSchema);
|
|
5246
5881
|
_this.options = options;
|
|
@@ -5249,18 +5884,20 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
|
|
|
5249
5884
|
_this.isReadonly = isReadonly;
|
|
5250
5885
|
_this.isHidden = isHidden;
|
|
5251
5886
|
_this.description = description;
|
|
5887
|
+
_this.renderInput = renderInput;
|
|
5888
|
+
_this.previewInput = previewInput;
|
|
5252
5889
|
return _this;
|
|
5253
5890
|
}
|
|
5254
5891
|
_inherits(DateSchema, _Schema);
|
|
5255
5892
|
return _createClass(DateSchema, [{
|
|
5256
5893
|
key: "describe",
|
|
5257
5894
|
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);
|
|
5895
|
+
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
5896
|
}
|
|
5260
5897
|
}, {
|
|
5261
5898
|
key: "validate",
|
|
5262
5899
|
value: function validate(validationFunction) {
|
|
5263
|
-
return new DateSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description);
|
|
5900
|
+
return new DateSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
5264
5901
|
}
|
|
5265
5902
|
}, {
|
|
5266
5903
|
key: "executeValidate",
|
|
@@ -5349,29 +5986,29 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
|
|
|
5349
5986
|
value: function from(_from) {
|
|
5350
5987
|
return new DateSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
5351
5988
|
from: _from
|
|
5352
|
-
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
|
|
5989
|
+
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
5353
5990
|
}
|
|
5354
5991
|
}, {
|
|
5355
5992
|
key: "to",
|
|
5356
5993
|
value: function to(_to) {
|
|
5357
5994
|
return new DateSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
5358
5995
|
to: _to
|
|
5359
|
-
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
|
|
5996
|
+
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
5360
5997
|
}
|
|
5361
5998
|
}, {
|
|
5362
5999
|
key: "nullable",
|
|
5363
6000
|
value: function nullable() {
|
|
5364
|
-
return new DateSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description);
|
|
6001
|
+
return new DateSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
5365
6002
|
}
|
|
5366
6003
|
}, {
|
|
5367
6004
|
key: "readonly",
|
|
5368
6005
|
value: function readonly() {
|
|
5369
|
-
return new DateSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
|
|
6006
|
+
return new DateSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
5370
6007
|
}
|
|
5371
6008
|
}, {
|
|
5372
6009
|
key: "hidden",
|
|
5373
6010
|
value: function hidden() {
|
|
5374
|
-
return new DateSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
6011
|
+
return new DateSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
|
|
5375
6012
|
}
|
|
5376
6013
|
}, {
|
|
5377
6014
|
key: "executeCustomValidateAt",
|
|
@@ -5380,12 +6017,53 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
|
|
|
5380
6017
|
path: path
|
|
5381
6018
|
});
|
|
5382
6019
|
}
|
|
6020
|
+
|
|
6021
|
+
/**
|
|
6022
|
+
* How this field is laid out in the editor when it is the item of an array
|
|
6023
|
+
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
6024
|
+
* instead of a preview row that navigates to it.
|
|
6025
|
+
*
|
|
6026
|
+
* Static configuration, not a callback — see `render.ts`.
|
|
6027
|
+
*/
|
|
6028
|
+
}, {
|
|
6029
|
+
key: "render",
|
|
6030
|
+
value: function render(input) {
|
|
6031
|
+
return new DateSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
|
|
6032
|
+
}
|
|
6033
|
+
|
|
6034
|
+
/**
|
|
6035
|
+
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
6036
|
+
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
6037
|
+
* itself is edited (that is `render`). See `preview.ts`.
|
|
6038
|
+
*/
|
|
6039
|
+
}, {
|
|
6040
|
+
key: "preview",
|
|
6041
|
+
value: function preview(select) {
|
|
6042
|
+
return new DateSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
|
|
6043
|
+
}
|
|
6044
|
+
}, {
|
|
6045
|
+
key: "executePreviewItem",
|
|
6046
|
+
value: function executePreviewItem(src) {
|
|
6047
|
+
if (this.previewInput === null) {
|
|
6048
|
+
return null;
|
|
6049
|
+
}
|
|
6050
|
+
return this.previewInput({
|
|
6051
|
+
val: src
|
|
6052
|
+
});
|
|
6053
|
+
}
|
|
6054
|
+
}, {
|
|
6055
|
+
key: "declaresItemPreview",
|
|
6056
|
+
value: function declaresItemPreview() {
|
|
6057
|
+
return this.previewInput !== null;
|
|
6058
|
+
}
|
|
5383
6059
|
}, {
|
|
5384
6060
|
key: "executeSerialize",
|
|
5385
6061
|
value: function executeSerialize() {
|
|
5386
|
-
var _this$customValidateF;
|
|
6062
|
+
var _this$renderInput, _this$customValidateF;
|
|
5387
6063
|
return {
|
|
5388
6064
|
type: "date",
|
|
6065
|
+
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
6066
|
+
preview: this.previewInput ? true : undefined,
|
|
5389
6067
|
opt: this.opt,
|
|
5390
6068
|
options: this.options,
|
|
5391
6069
|
customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
|
|
@@ -5413,6 +6091,8 @@ var DateTimeSchema = /*#__PURE__*/function (_Schema) {
|
|
|
5413
6091
|
var isReadonly = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
5414
6092
|
var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
5415
6093
|
var description = arguments.length > 5 ? arguments[5] : undefined;
|
|
6094
|
+
var renderInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
|
|
6095
|
+
var previewInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
|
|
5416
6096
|
_classCallCheck(this, DateTimeSchema);
|
|
5417
6097
|
_this = _callSuper(this, DateTimeSchema);
|
|
5418
6098
|
_this.options = options;
|
|
@@ -5421,18 +6101,20 @@ var DateTimeSchema = /*#__PURE__*/function (_Schema) {
|
|
|
5421
6101
|
_this.isReadonly = isReadonly;
|
|
5422
6102
|
_this.isHidden = isHidden;
|
|
5423
6103
|
_this.description = description;
|
|
6104
|
+
_this.renderInput = renderInput;
|
|
6105
|
+
_this.previewInput = previewInput;
|
|
5424
6106
|
return _this;
|
|
5425
6107
|
}
|
|
5426
6108
|
_inherits(DateTimeSchema, _Schema);
|
|
5427
6109
|
return _createClass(DateTimeSchema, [{
|
|
5428
6110
|
key: "describe",
|
|
5429
6111
|
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);
|
|
6112
|
+
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
6113
|
}
|
|
5432
6114
|
}, {
|
|
5433
6115
|
key: "validate",
|
|
5434
6116
|
value: function validate(validationFunction) {
|
|
5435
|
-
return new DateTimeSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description);
|
|
6117
|
+
return new DateTimeSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
5436
6118
|
}
|
|
5437
6119
|
}, {
|
|
5438
6120
|
key: "executeValidate",
|
|
@@ -5553,29 +6235,29 @@ var DateTimeSchema = /*#__PURE__*/function (_Schema) {
|
|
|
5553
6235
|
value: function from(_from) {
|
|
5554
6236
|
return new DateTimeSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
5555
6237
|
from: _from
|
|
5556
|
-
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
|
|
6238
|
+
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
5557
6239
|
}
|
|
5558
6240
|
}, {
|
|
5559
6241
|
key: "to",
|
|
5560
6242
|
value: function to(_to) {
|
|
5561
6243
|
return new DateTimeSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
5562
6244
|
to: _to
|
|
5563
|
-
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
|
|
6245
|
+
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
5564
6246
|
}
|
|
5565
6247
|
}, {
|
|
5566
6248
|
key: "nullable",
|
|
5567
6249
|
value: function nullable() {
|
|
5568
|
-
return new DateTimeSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description);
|
|
6250
|
+
return new DateTimeSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
5569
6251
|
}
|
|
5570
6252
|
}, {
|
|
5571
6253
|
key: "readonly",
|
|
5572
6254
|
value: function readonly() {
|
|
5573
|
-
return new DateTimeSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
|
|
6255
|
+
return new DateTimeSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
5574
6256
|
}
|
|
5575
6257
|
}, {
|
|
5576
6258
|
key: "hidden",
|
|
5577
6259
|
value: function hidden() {
|
|
5578
|
-
return new DateTimeSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
6260
|
+
return new DateTimeSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
|
|
5579
6261
|
}
|
|
5580
6262
|
}, {
|
|
5581
6263
|
key: "executeCustomValidateAt",
|
|
@@ -5584,12 +6266,53 @@ var DateTimeSchema = /*#__PURE__*/function (_Schema) {
|
|
|
5584
6266
|
path: path
|
|
5585
6267
|
});
|
|
5586
6268
|
}
|
|
6269
|
+
|
|
6270
|
+
/**
|
|
6271
|
+
* How this field is laid out in the editor when it is the item of an array
|
|
6272
|
+
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
6273
|
+
* instead of a preview row that navigates to it.
|
|
6274
|
+
*
|
|
6275
|
+
* Static configuration, not a callback — see `render.ts`.
|
|
6276
|
+
*/
|
|
6277
|
+
}, {
|
|
6278
|
+
key: "render",
|
|
6279
|
+
value: function render(input) {
|
|
6280
|
+
return new DateTimeSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
|
|
6281
|
+
}
|
|
6282
|
+
|
|
6283
|
+
/**
|
|
6284
|
+
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
6285
|
+
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
6286
|
+
* itself is edited (that is `render`). See `preview.ts`.
|
|
6287
|
+
*/
|
|
6288
|
+
}, {
|
|
6289
|
+
key: "preview",
|
|
6290
|
+
value: function preview(select) {
|
|
6291
|
+
return new DateTimeSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
|
|
6292
|
+
}
|
|
6293
|
+
}, {
|
|
6294
|
+
key: "executePreviewItem",
|
|
6295
|
+
value: function executePreviewItem(src) {
|
|
6296
|
+
if (this.previewInput === null) {
|
|
6297
|
+
return null;
|
|
6298
|
+
}
|
|
6299
|
+
return this.previewInput({
|
|
6300
|
+
val: src
|
|
6301
|
+
});
|
|
6302
|
+
}
|
|
6303
|
+
}, {
|
|
6304
|
+
key: "declaresItemPreview",
|
|
6305
|
+
value: function declaresItemPreview() {
|
|
6306
|
+
return this.previewInput !== null;
|
|
6307
|
+
}
|
|
5587
6308
|
}, {
|
|
5588
6309
|
key: "executeSerialize",
|
|
5589
6310
|
value: function executeSerialize() {
|
|
5590
|
-
var _this$customValidateF;
|
|
6311
|
+
var _this$renderInput, _this$customValidateF;
|
|
5591
6312
|
return {
|
|
5592
6313
|
type: "dateTime",
|
|
6314
|
+
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
6315
|
+
preview: this.previewInput ? true : undefined,
|
|
5593
6316
|
opt: this.opt,
|
|
5594
6317
|
options: this.options,
|
|
5595
6318
|
customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
|
|
@@ -6097,6 +6820,8 @@ var ColorSchema = /*#__PURE__*/function (_Schema) {
|
|
|
6097
6820
|
var isReadonly = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
6098
6821
|
var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
6099
6822
|
var description = arguments.length > 5 ? arguments[5] : undefined;
|
|
6823
|
+
var renderInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
|
|
6824
|
+
var previewInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
|
|
6100
6825
|
_classCallCheck(this, ColorSchema);
|
|
6101
6826
|
_this = _callSuper(this, ColorSchema);
|
|
6102
6827
|
_this.options = options;
|
|
@@ -6105,18 +6830,20 @@ var ColorSchema = /*#__PURE__*/function (_Schema) {
|
|
|
6105
6830
|
_this.isReadonly = isReadonly;
|
|
6106
6831
|
_this.isHidden = isHidden;
|
|
6107
6832
|
_this.description = description;
|
|
6833
|
+
_this.renderInput = renderInput;
|
|
6834
|
+
_this.previewInput = previewInput;
|
|
6108
6835
|
return _this;
|
|
6109
6836
|
}
|
|
6110
6837
|
_inherits(ColorSchema, _Schema);
|
|
6111
6838
|
return _createClass(ColorSchema, [{
|
|
6112
6839
|
key: "describe",
|
|
6113
6840
|
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);
|
|
6841
|
+
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
6842
|
}
|
|
6116
6843
|
}, {
|
|
6117
6844
|
key: "validate",
|
|
6118
6845
|
value: function validate(validationFunction) {
|
|
6119
|
-
return new ColorSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description);
|
|
6846
|
+
return new ColorSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
6120
6847
|
}
|
|
6121
6848
|
}, {
|
|
6122
6849
|
key: "executeCustomValidateAt",
|
|
@@ -6213,24 +6940,65 @@ var ColorSchema = /*#__PURE__*/function (_Schema) {
|
|
|
6213
6940
|
}, {
|
|
6214
6941
|
key: "nullable",
|
|
6215
6942
|
value: function nullable() {
|
|
6216
|
-
return new ColorSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description);
|
|
6943
|
+
return new ColorSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
6217
6944
|
}
|
|
6218
6945
|
}, {
|
|
6219
6946
|
key: "readonly",
|
|
6220
6947
|
value: function readonly() {
|
|
6221
|
-
return new ColorSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
|
|
6948
|
+
return new ColorSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
6222
6949
|
}
|
|
6223
6950
|
}, {
|
|
6224
6951
|
key: "hidden",
|
|
6225
6952
|
value: function hidden() {
|
|
6226
|
-
return new ColorSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
6953
|
+
return new ColorSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
|
|
6954
|
+
}
|
|
6955
|
+
|
|
6956
|
+
/**
|
|
6957
|
+
* How this field is laid out in the editor when it is the item of an array
|
|
6958
|
+
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
6959
|
+
* instead of a preview row that navigates to it.
|
|
6960
|
+
*
|
|
6961
|
+
* Static configuration, not a callback — see `render.ts`.
|
|
6962
|
+
*/
|
|
6963
|
+
}, {
|
|
6964
|
+
key: "render",
|
|
6965
|
+
value: function render(input) {
|
|
6966
|
+
return new ColorSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
|
|
6967
|
+
}
|
|
6968
|
+
|
|
6969
|
+
/**
|
|
6970
|
+
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
6971
|
+
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
6972
|
+
* itself is edited (that is `render`). See `preview.ts`.
|
|
6973
|
+
*/
|
|
6974
|
+
}, {
|
|
6975
|
+
key: "preview",
|
|
6976
|
+
value: function preview(select) {
|
|
6977
|
+
return new ColorSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
|
|
6978
|
+
}
|
|
6979
|
+
}, {
|
|
6980
|
+
key: "executePreviewItem",
|
|
6981
|
+
value: function executePreviewItem(src) {
|
|
6982
|
+
if (this.previewInput === null) {
|
|
6983
|
+
return null;
|
|
6984
|
+
}
|
|
6985
|
+
return this.previewInput({
|
|
6986
|
+
val: src
|
|
6987
|
+
});
|
|
6988
|
+
}
|
|
6989
|
+
}, {
|
|
6990
|
+
key: "declaresItemPreview",
|
|
6991
|
+
value: function declaresItemPreview() {
|
|
6992
|
+
return this.previewInput !== null;
|
|
6227
6993
|
}
|
|
6228
6994
|
}, {
|
|
6229
6995
|
key: "executeSerialize",
|
|
6230
6996
|
value: function executeSerialize() {
|
|
6231
|
-
var _this$customValidateF;
|
|
6997
|
+
var _this$renderInput, _this$customValidateF;
|
|
6232
6998
|
return {
|
|
6233
6999
|
type: "color",
|
|
7000
|
+
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
7001
|
+
preview: this.previewInput ? true : undefined,
|
|
6234
7002
|
opt: this.opt,
|
|
6235
7003
|
options: this.options,
|
|
6236
7004
|
customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
|
|
@@ -6310,7 +7078,8 @@ var images = function images(options) {
|
|
|
6310
7078
|
accept: (_options$accept = options.accept) !== null && _options$accept !== void 0 ? _options$accept : "image/*",
|
|
6311
7079
|
directory: directory,
|
|
6312
7080
|
remote: (_options$remote = options.remote) !== null && _options$remote !== void 0 ? _options$remote : false,
|
|
6313
|
-
altSchema: altSchema
|
|
7081
|
+
altSchema: altSchema,
|
|
7082
|
+
encode: options.encode
|
|
6314
7083
|
});
|
|
6315
7084
|
};
|
|
6316
7085
|
|
|
@@ -8053,10 +8822,16 @@ function createRemoteRef(remoteHost, _ref) {
|
|
|
8053
8822
|
*/
|
|
8054
8823
|
function getValidationBasis(coreVersion, schema, fileExt, metadata, fileHash) {
|
|
8055
8824
|
var metadataValidationBasis = "".concat((metadata === null || metadata === void 0 ? void 0 : metadata.width) || "").concat((metadata === null || metadata === void 0 ? void 0 : metadata.height) || "").concat(metadata === null || metadata === void 0 ? void 0 : metadata.mimeType);
|
|
8825
|
+
var options = _objectSpread2({}, schema.options);
|
|
8826
|
+
// Ignore options that do not affect the validation basis below:
|
|
8827
|
+
// `encode` says how the bytes were PRODUCED in the browser, not whether the
|
|
8828
|
+
// bytes that arrived are valid. Leaving it in would mean that changing a
|
|
8829
|
+
// quality setting re-validates every remote file in the project.
|
|
8830
|
+
delete options.encode;
|
|
8056
8831
|
var schemaValidationBasis = {
|
|
8057
8832
|
type: schema.type,
|
|
8058
8833
|
opt: schema.opt,
|
|
8059
|
-
options:
|
|
8834
|
+
options: options
|
|
8060
8835
|
};
|
|
8061
8836
|
return coreVersion + JSON.stringify(schemaValidationBasis) + fileExt + metadataValidationBasis + fileHash;
|
|
8062
8837
|
}
|
|
@@ -8083,7 +8858,7 @@ function deserializeSchema(serialized) {
|
|
|
8083
8858
|
return schema;
|
|
8084
8859
|
}
|
|
8085
8860
|
function deserializeSchemaImpl(serialized) {
|
|
8086
|
-
var _serialized$options, _serialized$options2, _serialized$render, _serialized$accept, _serialized$directory, _serialized$remote, _serialized$jsonValue;
|
|
8861
|
+
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
8862
|
switch (serialized.type) {
|
|
8088
8863
|
case "string":
|
|
8089
8864
|
return new StringSchema(_objectSpread2(_objectSpread2({}, serialized.options), {}, {
|
|
@@ -8094,20 +8869,22 @@ function deserializeSchemaImpl(serialized) {
|
|
|
8094
8869
|
// recomputed from an instance.
|
|
8095
8870
|
(_serialized$render = serialized.render) !== null && _serialized$render !== void 0 ? _serialized$render : null, false, false, serialized.description);
|
|
8096
8871
|
case "literal":
|
|
8097
|
-
return new LiteralSchema(serialized.value, serialized.opt, [], false, false, serialized.description);
|
|
8872
|
+
return new LiteralSchema(serialized.value, serialized.opt, [], false, false, serialized.description, (_serialized$render2 = serialized.render) !== null && _serialized$render2 !== void 0 ? _serialized$render2 : null);
|
|
8098
8873
|
case "boolean":
|
|
8099
|
-
return new BooleanSchema(serialized.opt, [], false, false, serialized.description);
|
|
8874
|
+
return new BooleanSchema(serialized.opt, [], false, false, serialized.description, (_serialized$render3 = serialized.render) !== null && _serialized$render3 !== void 0 ? _serialized$render3 : null);
|
|
8100
8875
|
case "number":
|
|
8101
|
-
return new NumberSchema(serialized.options, serialized.opt, [], false, false, serialized.description);
|
|
8876
|
+
return new NumberSchema(serialized.options, serialized.opt, [], false, false, serialized.description, (_serialized$render4 = serialized.render) !== null && _serialized$render4 !== void 0 ? _serialized$render4 : null);
|
|
8102
8877
|
case "object":
|
|
8103
8878
|
return new ObjectSchema(Object.fromEntries(Object.entries(serialized.items).map(function (_ref) {
|
|
8104
8879
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
8105
8880
|
key = _ref2[0],
|
|
8106
8881
|
item = _ref2[1];
|
|
8107
8882
|
return [key, deserializeSchema(item)];
|
|
8108
|
-
})), serialized.opt, [], false, false, serialized.description);
|
|
8883
|
+
})), serialized.opt, [], false, false, serialized.description, (_serialized$render5 = serialized.render) !== null && _serialized$render5 !== void 0 ? _serialized$render5 : null);
|
|
8109
8884
|
case "array":
|
|
8110
|
-
return new ArraySchema(deserializeSchema(serialized.item), serialized.opt, [], false, false, serialized.description
|
|
8885
|
+
return new ArraySchema(deserializeSchema(serialized.item), serialized.opt, [], false, false, serialized.description,
|
|
8886
|
+
// The preview closure cannot survive serialization; the render can.
|
|
8887
|
+
null, (_serialized$render6 = serialized.render) !== null && _serialized$render6 !== void 0 ? _serialized$render6 : null);
|
|
8111
8888
|
case "union":
|
|
8112
8889
|
return new UnionSchema(typeof serialized.key === "string" ? serialized.key :
|
|
8113
8890
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -8116,17 +8893,17 @@ function deserializeSchemaImpl(serialized) {
|
|
|
8116
8893
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8117
8894
|
serialized.items.map(deserializeSchema),
|
|
8118
8895
|
// TODO: we do not really need any here - right?
|
|
8119
|
-
serialized.opt, [], false, false, serialized.description);
|
|
8896
|
+
serialized.opt, [], false, false, serialized.description, (_serialized$render7 = serialized.render) !== null && _serialized$render7 !== void 0 ? _serialized$render7 : null);
|
|
8120
8897
|
case "richtext":
|
|
8121
8898
|
{
|
|
8122
|
-
var _serialized$options3, _serialized$options4, _serialized$options5, _serialized$options6, _serialized$options7, _serialized$options8, _serialized$options9;
|
|
8899
|
+
var _serialized$options3, _serialized$options4, _serialized$options5, _serialized$options6, _serialized$options7, _serialized$options8, _serialized$options9, _serialized$render8;
|
|
8123
8900
|
var deserializedOptions = _objectSpread2(_objectSpread2({}, serialized.options || {}), {}, {
|
|
8124
8901
|
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
8902
|
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
8903
|
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
8904
|
} : (_serialized$options9 = serialized.options) === null || _serialized$options9 === void 0 ? void 0 : _serialized$options9.inline
|
|
8128
8905
|
});
|
|
8129
|
-
return new RichTextSchema(deserializedOptions, serialized.opt, [], false, false, serialized.description);
|
|
8906
|
+
return new RichTextSchema(deserializedOptions, serialized.opt, [], false, false, serialized.description, (_serialized$render8 = serialized.render) !== null && _serialized$render8 !== void 0 ? _serialized$render8 : null);
|
|
8130
8907
|
}
|
|
8131
8908
|
case "record":
|
|
8132
8909
|
return new RecordSchema(deserializeSchema(serialized.item), serialized.opt, [], null, serialized.key ? deserializeSchema(serialized.key) : null, serialized.mediaType ? {
|
|
@@ -8135,27 +8912,30 @@ function deserializeSchemaImpl(serialized) {
|
|
|
8135
8912
|
directory: (_serialized$directory = serialized.directory) !== null && _serialized$directory !== void 0 ? _serialized$directory : "/public/val",
|
|
8136
8913
|
remote: (_serialized$remote = serialized.remote) !== null && _serialized$remote !== void 0 ? _serialized$remote : false,
|
|
8137
8914
|
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
|
|
8915
|
+
} : undefined, false, false, serialized.description, (_serialized$jsonValue = serialized.jsonValues) !== null && _serialized$jsonValue !== void 0 ? _serialized$jsonValue : false,
|
|
8916
|
+
// The preview closure cannot survive serialization; the render can.
|
|
8917
|
+
null, (_serialized$render9 = serialized.render) !== null && _serialized$render9 !== void 0 ? _serialized$render9 : null);
|
|
8139
8918
|
case "keyOf":
|
|
8140
|
-
return new KeyOfSchema(serialized.schema, serialized.path, serialized.opt, [], false, false, serialized.description);
|
|
8919
|
+
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
8920
|
case "route":
|
|
8142
8921
|
{
|
|
8922
|
+
var _serialized$render1;
|
|
8143
8923
|
var routeOptions = serialized.options ? {
|
|
8144
8924
|
include: serialized.options.include ? new RegExp(serialized.options.include.source, serialized.options.include.flags) : undefined,
|
|
8145
8925
|
exclude: serialized.options.exclude ? new RegExp(serialized.options.exclude.source, serialized.options.exclude.flags) : undefined
|
|
8146
8926
|
} : undefined;
|
|
8147
|
-
return new RouteSchema(routeOptions, serialized.opt, [], false, false, serialized.description);
|
|
8927
|
+
return new RouteSchema(routeOptions, serialized.opt, [], false, false, serialized.description, (_serialized$render1 = serialized.render) !== null && _serialized$render1 !== void 0 ? _serialized$render1 : null);
|
|
8148
8928
|
}
|
|
8149
8929
|
case "file":
|
|
8150
|
-
return new FileSchema(serialized.options, serialized.opt, serialized.remote, [], {}, false, false, serialized.description);
|
|
8930
|
+
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
8931
|
case "image":
|
|
8152
|
-
return new ImageSchema(serialized.options, serialized.opt, serialized.remote, [], {}, false, false, serialized.description);
|
|
8932
|
+
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
8933
|
case "date":
|
|
8154
|
-
return new DateSchema(serialized.options, serialized.opt, [], false, false, serialized.description);
|
|
8934
|
+
return new DateSchema(serialized.options, serialized.opt, [], false, false, serialized.description, (_serialized$render12 = serialized.render) !== null && _serialized$render12 !== void 0 ? _serialized$render12 : null);
|
|
8155
8935
|
case "dateTime":
|
|
8156
|
-
return new DateTimeSchema(serialized.options, serialized.opt, [], false, false, serialized.description);
|
|
8936
|
+
return new DateTimeSchema(serialized.options, serialized.opt, [], false, false, serialized.description, (_serialized$render13 = serialized.render) !== null && _serialized$render13 !== void 0 ? _serialized$render13 : null);
|
|
8157
8937
|
case "color":
|
|
8158
|
-
return new ColorSchema(serialized.options, serialized.opt, [], false, false, serialized.description);
|
|
8938
|
+
return new ColorSchema(serialized.options, serialized.opt, [], false, false, serialized.description, (_serialized$render14 = serialized.render) !== null && _serialized$render14 !== void 0 ? _serialized$render14 : null);
|
|
8159
8939
|
default:
|
|
8160
8940
|
{
|
|
8161
8941
|
var exhaustiveCheck = serialized;
|
|
@@ -8170,8 +8950,29 @@ function deserializeSchemaImpl(serialized) {
|
|
|
8170
8950
|
}
|
|
8171
8951
|
|
|
8172
8952
|
/**
|
|
8173
|
-
*
|
|
8174
|
-
*
|
|
8953
|
+
* A PREVIEW is how a VALUE is shown wherever a preview of it is needed — a row
|
|
8954
|
+
* in a sortable list, a key in a reference dropdown, a search hit, a
|
|
8955
|
+
* reference — which is everywhere the value is NAVIGABLE to rather than open.
|
|
8956
|
+
* It is never how the field itself is edited: that is a RENDER (`render.ts`),
|
|
8957
|
+
* which applies only when you are looking at the field. The two do not
|
|
8958
|
+
* intersect — a schema can carry both, and each is read in its own places.
|
|
8959
|
+
*
|
|
8960
|
+
* A preview is declared on the schema of the VALUE being previewed:
|
|
8961
|
+
*
|
|
8962
|
+
* ```ts
|
|
8963
|
+
* const author = s.object({ name: s.string() })
|
|
8964
|
+
* .preview(({ val }) => ({ title: val.name }));
|
|
8965
|
+
* const authors = s.array(author);
|
|
8966
|
+
* ```
|
|
8967
|
+
*
|
|
8968
|
+
* The container reifies its rows by running each ITEM's preview closure — see
|
|
8969
|
+
* {@link ArrayPreview} / {@link RecordPreview}. (Previews used to be declared
|
|
8970
|
+
* on the container instead; a `.preview` on an array/record now previews the
|
|
8971
|
+
* array/record itself as a value, for when IT is the item of something.)
|
|
8972
|
+
*/
|
|
8973
|
+
/**
|
|
8974
|
+
* What a preview shows for one value: the user's `preview` callback returns
|
|
8975
|
+
* this, and the Studio draws a row from it.
|
|
8175
8976
|
*
|
|
8176
8977
|
* NB: {@link ArrayPreview} / {@link RecordPreview} name the DATA a container
|
|
8177
8978
|
* previews with. The Studio also has React components called `ArrayPreview` /
|
|
@@ -8181,6 +8982,19 @@ function deserializeSchemaImpl(serialized) {
|
|
|
8181
8982
|
* at the import rather than renaming that convention.
|
|
8182
8983
|
*/
|
|
8183
8984
|
|
|
8985
|
+
/**
|
|
8986
|
+
* What `.preview(...)` takes, on every schema: the value's own source in, a
|
|
8987
|
+
* {@link PreviewItem} out. `NonNullable` because a container skips null items
|
|
8988
|
+
* rather than previewing them.
|
|
8989
|
+
*
|
|
8990
|
+
* Declared through method syntax deliberately (the same bivariance shape
|
|
8991
|
+
* React's event handler types use): `nullable()` copies a schema's closure
|
|
8992
|
+
* into the `Src | null` variant of the same class, and with a plain function
|
|
8993
|
+
* type the checker cannot see that `NonNullable<Src | null>` IS
|
|
8994
|
+
* `NonNullable<Src>` while `Src` is still a type parameter — every schema's
|
|
8995
|
+
* `nullable()` would need a cast instead.
|
|
8996
|
+
*/
|
|
8997
|
+
|
|
8184
8998
|
/**
|
|
8185
8999
|
* Main preview type.
|
|
8186
9000
|
*
|
|
@@ -8273,11 +9087,21 @@ function previewScope(paths) {
|
|
|
8273
9087
|
// TODO: improve this so that we do not get RawString and string, only string. Are there other things?
|
|
8274
9088
|
|
|
8275
9089
|
/**
|
|
8276
|
-
* A RENDER is how
|
|
8277
|
-
*
|
|
9090
|
+
* A RENDER is how the FIELD ITSELF is laid out in the editor, and it applies
|
|
9091
|
+
* only when you are looking at the field: `s.string().render({ as: "textarea"
|
|
9092
|
+
* })`, `.render({ as: "code", language })`, `.render({ as: "inline" })` on an
|
|
9093
|
+
* array/record item.
|
|
8278
9094
|
*
|
|
8279
|
-
*
|
|
8280
|
-
*
|
|
9095
|
+
* A PREVIEW (`preview.ts`) is the other thing: how the VALUE is shown wherever
|
|
9096
|
+
* a preview of it is needed — a list row, a reference dropdown, a search hit —
|
|
9097
|
+
* that is, wherever the value is navigable to rather than open. The two never
|
|
9098
|
+
* intersect: a schema can carry both, a `render` is read where the field is
|
|
9099
|
+
* edited and a `preview` where the value is previewed. A second `.render(...)`
|
|
9100
|
+
* on the same schema REPLACES the first (last one wins), exactly like a second
|
|
9101
|
+
* `.preview(...)` replaces the first — they do not merge.
|
|
9102
|
+
*
|
|
9103
|
+
* A render is static configuration - plain data, with no closure behind it and
|
|
9104
|
+
* no dependency on source - which is why it lives in the SERIALIZED schema
|
|
8281
9105
|
* (`SerializedStringSchema.render`) and is read straight off it where the field
|
|
8282
9106
|
* is drawn. There is no render pipeline, no store and no host round-trip.
|
|
8283
9107
|
*
|
|
@@ -8287,9 +9111,6 @@ function previewScope(paths) {
|
|
|
8287
9111
|
* the shape it needs back is `executePreview`'s, and the honest move is to give
|
|
8288
9112
|
* `render` its own execute/store pair again. It is NOT to re-merge the two:
|
|
8289
9113
|
* 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
9114
|
*/
|
|
8294
9115
|
/**
|
|
8295
9116
|
* The list is the declaration and {@link CodeLanguage} is derived from it, so
|
|
@@ -8298,10 +9119,68 @@ function previewScope(paths) {
|
|
|
8298
9119
|
*/
|
|
8299
9120
|
var CODE_LANGUAGES = ["typescript", "javascript", "javascriptreact", "typescriptreact", "json", "java", "html", "css", "xml", "markdown", "sql", "python", "rust", "php", "go", "cpp", "sass", "vue", "angular"];
|
|
8300
9121
|
|
|
9122
|
+
/**
|
|
9123
|
+
* `{ as: "inline" }` on a field that is the ITEM of an array or record: the
|
|
9124
|
+
* container renders the field itself inside each (sortable) row, instead of a
|
|
9125
|
+
* clickable preview row that navigates to it. This is what a page-builder list
|
|
9126
|
+
* is made of: `s.array(s.object({...}).render({ as: "inline" }))`.
|
|
9127
|
+
*
|
|
9128
|
+
* On a field that is not directly under an array or record it is inert — an
|
|
9129
|
+
* object's fields are already laid out in place.
|
|
9130
|
+
*
|
|
9131
|
+
* Like every render it is static configuration (see the top of this file): it
|
|
9132
|
+
* travels whole in the serialized schema and the editor reads it straight off
|
|
9133
|
+
* the item schema it already has.
|
|
9134
|
+
*/
|
|
9135
|
+
|
|
9136
|
+
/**
|
|
9137
|
+
* What `.render(...)` takes on every field except `s.string()`, and what the
|
|
9138
|
+
* serialized schema carries verbatim.
|
|
9139
|
+
*/
|
|
9140
|
+
|
|
8301
9141
|
/**
|
|
8302
9142
|
* What `s.string().render(...)` takes, and what the serialized schema carries
|
|
8303
|
-
* verbatim.
|
|
9143
|
+
* verbatim. A string has editor layouts of its own (textarea, code) in
|
|
9144
|
+
* addition to the container-facing `inline`.
|
|
9145
|
+
*/
|
|
9146
|
+
|
|
9147
|
+
/**
|
|
9148
|
+
* Is this item schema edited INSIDE its list row, rather than behind a
|
|
9149
|
+
* clickable preview row that navigates to it?
|
|
9150
|
+
*
|
|
9151
|
+
* The one answer, so that the list rows, the nav-stop rule (`getNavPath`) and
|
|
9152
|
+
* the add buttons cannot drift apart — they are three readings of the same
|
|
9153
|
+
* question, and a disagreement between them is a row you can edit in place but
|
|
9154
|
+
* that "add" navigates away from.
|
|
9155
|
+
*
|
|
9156
|
+
* A tagged union counts as inline when the union itself declares it OR when
|
|
9157
|
+
* ANY of its variants does. A page-builder list is `s.array(s.union("type",
|
|
9158
|
+
* block, block, ...))` and the natural place to write the render is on the
|
|
9159
|
+
* blocks, one per block type — the union is a dispatch, not something the
|
|
9160
|
+
* author thinks of as the field. `some` rather than `every` because the row
|
|
9161
|
+
* draws the union's own editor (the tag selector plus the matched variant's
|
|
9162
|
+
* fields), which handles every variant either way: with `every`, adding one
|
|
9163
|
+
* variant and forgetting its `.render` would silently turn the whole list back
|
|
9164
|
+
* into preview rows.
|
|
9165
|
+
*
|
|
9166
|
+
* This is the ONLY place a render is allowed to be read from anywhere but the
|
|
9167
|
+
* schema it was declared on. It stays static (see the top of this file): the
|
|
9168
|
+
* answer is a function of the serialized schema alone, never of the value the
|
|
9169
|
+
* row happens to hold.
|
|
8304
9170
|
*/
|
|
9171
|
+
function isInlineRender(schema) {
|
|
9172
|
+
var _schema$render;
|
|
9173
|
+
if (((_schema$render = schema.render) === null || _schema$render === void 0 ? void 0 : _schema$render.as) === "inline") {
|
|
9174
|
+
return true;
|
|
9175
|
+
}
|
|
9176
|
+
if (schema.type === "union") {
|
|
9177
|
+
return schema.items.some(function (item) {
|
|
9178
|
+
var _item$render;
|
|
9179
|
+
return ((_item$render = item.render) === null || _item$render === void 0 ? void 0 : _item$render.as) === "inline";
|
|
9180
|
+
});
|
|
9181
|
+
}
|
|
9182
|
+
return false;
|
|
9183
|
+
}
|
|
8305
9184
|
|
|
8306
9185
|
var externalPageRouter = {
|
|
8307
9186
|
getRouterId: function getRouterId() {
|
|
@@ -8667,4 +9546,4 @@ function tryJsonParse(str) {
|
|
|
8667
9546
|
}
|
|
8668
9547
|
}
|
|
8669
9548
|
|
|
8670
|
-
export { ArraySchema as A, BooleanSchema as B, ColorSchema as C, DEFAULT_CONTENT_HOST as D, FATAL_ERROR_TYPES as F, GenericSelector as G, Internal as I, KeyOfSchema as K, LiteralSchema as L, ModuleFilePathSep as M, NumberSchema as N, ObjectSchema as O, PatchError as P, RecordSchema as R, Schema as S, UnionSchema as U, VAL_EXTENSION as V, _typeof as _, _slicedToArray as a, _createClass as b, _classCallCheck as c, _toConsumableArray as d, DEFAULT_APP_HOST as e, extractValModules as f, computeValModuleShas as g, hasRemoteFileSchema as h, initVal as i, DEFAULT_VAL_REMOTE_HOST as j, derefPatch as k, StringSchema as l, modules as m, ImageSchema as n, FileSchema as o, DateSchema as p, COLOR_FORMATS as q, DEFAULT_COLOR_FORMAT as r, splitModuleFilePathAndModulePath as s, DateTimeSchema as t, RouteSchema as u, RichTextSchema as v, deserializeSchema as w, previewScope as x, CODE_LANGUAGES as y,
|
|
9549
|
+
export { ArraySchema as A, BooleanSchema as B, ColorSchema as C, DEFAULT_CONTENT_HOST as D, getSourcePathFromRoute as E, FATAL_ERROR_TYPES as F, GenericSelector as G, Internal as I, KeyOfSchema as K, LiteralSchema as L, ModuleFilePathSep as M, NumberSchema as N, ObjectSchema as O, PatchError as P, RecordSchema as R, Schema as S, UnionSchema as U, VAL_EXTENSION as V, _typeof as _, _slicedToArray as a, _createClass as b, _classCallCheck as c, _toConsumableArray as d, DEFAULT_APP_HOST as e, extractValModules as f, computeValModuleShas as g, hasRemoteFileSchema as h, initVal as i, DEFAULT_VAL_REMOTE_HOST as j, derefPatch as k, StringSchema as l, modules as m, ImageSchema as n, FileSchema as o, DateSchema as p, COLOR_FORMATS as q, DEFAULT_COLOR_FORMAT as r, splitModuleFilePathAndModulePath as s, DateTimeSchema as t, RouteSchema as u, RichTextSchema as v, deserializeSchema as w, previewScope as x, CODE_LANGUAGES as y, isInlineRender as z };
|