@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.
Files changed (32) hide show
  1. package/dist/declarations/src/index.d.ts +4 -4
  2. package/dist/declarations/src/initSchema.d.ts +20 -20
  3. package/dist/declarations/src/preview.d.ts +40 -2
  4. package/dist/declarations/src/render.d.ts +64 -9
  5. package/dist/declarations/src/schema/array.d.ts +24 -12
  6. package/dist/declarations/src/schema/boolean.d.ts +25 -2
  7. package/dist/declarations/src/schema/color.d.ts +25 -2
  8. package/dist/declarations/src/schema/date.d.ts +25 -2
  9. package/dist/declarations/src/schema/datetime.d.ts +25 -2
  10. package/dist/declarations/src/schema/file.d.ts +25 -2
  11. package/dist/declarations/src/schema/image.d.ts +61 -5
  12. package/dist/declarations/src/schema/images.d.ts +8 -0
  13. package/dist/declarations/src/schema/index.d.ts +19 -1
  14. package/dist/declarations/src/schema/keyOf.d.ts +25 -2
  15. package/dist/declarations/src/schema/literal.d.ts +25 -2
  16. package/dist/declarations/src/schema/number.d.ts +25 -2
  17. package/dist/declarations/src/schema/object.d.ts +25 -2
  18. package/dist/declarations/src/schema/record.d.ts +29 -13
  19. package/dist/declarations/src/schema/richtext.d.ts +25 -2
  20. package/dist/declarations/src/schema/route.d.ts +25 -2
  21. package/dist/declarations/src/schema/string.d.ts +13 -2
  22. package/dist/declarations/src/schema/union.d.ts +32 -2
  23. package/dist/{index-2cef45cc.cjs.dev.js → index-409a38c3.cjs.dev.js} +1072 -192
  24. package/dist/{index-eaee0a0b.cjs.prod.js → index-62ef4533.cjs.prod.js} +1072 -192
  25. package/dist/{index-193f19b4.esm.js → index-6652ab3c.esm.js} +1072 -193
  26. package/dist/valbuild-core.cjs.dev.js +2 -1
  27. package/dist/valbuild-core.cjs.prod.js +2 -1
  28. package/dist/valbuild-core.esm.js +1 -1
  29. package/package.json +2 -2
  30. package/patch/dist/valbuild-core-patch.cjs.dev.js +1 -1
  31. package/patch/dist/valbuild-core-patch.cjs.prod.js +1 -1
  32. package/patch/dist/valbuild-core-patch.esm.js +2 -2
@@ -215,8 +215,32 @@ var Schema = /*#__PURE__*/function () {
215
215
  * For example, if you have an object schema, you must assert each key / value pair manually.
216
216
  */
217
217
  }, {
218
- key: "appendValidationError",
218
+ key: "executePreviewItem",
219
219
  value:
220
+ /**
221
+ * This value AS A PREVIEW — what a container's row, a reference dropdown or
222
+ * a search hit shows for it. Runs the schema's own `preview` closure;
223
+ * `null` when none is declared (the consumer falls back to a generic
224
+ * preview). A union dispatches to the matching member's closure.
225
+ *
226
+ * Containers call this on their ITEM schema per item — that is how
227
+ * `executePreview` reifies an {@link ArrayPreview} / {@link RecordPreview}
228
+ * from item-level declarations.
229
+ */
230
+ function executePreviewItem(src) {
231
+ return null;
232
+ }
233
+ /**
234
+ * Could {@link executePreviewItem} ever answer? A container reifies a rows
235
+ * preview only when its item schema says yes — asked here rather than by
236
+ * running the closure, so an EMPTY list still previews as an empty list
237
+ * instead of not at all.
238
+ */
239
+ }, {
240
+ key: "declaresItemPreview",
241
+ value: function declaresItemPreview() {
242
+ return false;
243
+ }
220
244
  // remote(): Src extends RemoteCompatibleSource
221
245
  // ? Schema<RemoteSource<Src>>
222
246
  // : never {
@@ -225,7 +249,9 @@ var Schema = /*#__PURE__*/function () {
225
249
  // }
226
250
 
227
251
  /** MUTATES! since internal and perf sensitive */
228
- function appendValidationError(current, path, message, value, schemaError) {
252
+ }, {
253
+ key: "appendValidationError",
254
+ value: function appendValidationError(current, path, message, value, schemaError) {
229
255
  if (current) {
230
256
  if (current[path]) {
231
257
  current[path].push({
@@ -422,6 +448,7 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
422
448
  var isReadonly = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
423
449
  var isHidden = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
424
450
  var description = arguments.length > 7 ? arguments[7] : undefined;
451
+ var previewInput = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
425
452
  _classCallCheck(this, StringSchema);
426
453
  _this = _callSuper(this, StringSchema);
427
454
  _this.options = options;
@@ -432,13 +459,14 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
432
459
  _this.isReadonly = isReadonly;
433
460
  _this.isHidden = isHidden;
434
461
  _this.description = description;
462
+ _this.previewInput = previewInput;
435
463
  return _this;
436
464
  }
437
465
  _inherits(StringSchema, _Schema);
438
466
  return _createClass(StringSchema, [{
439
467
  key: "describe",
440
468
  value: function describe(description) {
441
- return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
469
+ return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.previewInput);
442
470
  }
443
471
 
444
472
  /**
@@ -454,7 +482,7 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
454
482
  value: function minLength(_minLength) {
455
483
  return new StringSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
456
484
  minLength: _minLength
457
- }), this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description);
485
+ }), this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description, this.previewInput);
458
486
  }
459
487
 
460
488
  /**
@@ -470,7 +498,7 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
470
498
  value: function maxLength(_maxLength) {
471
499
  return new StringSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
472
500
  maxLength: _maxLength
473
- }), this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description);
501
+ }), this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description, this.previewInput);
474
502
  }
475
503
  }, {
476
504
  key: "regexp",
@@ -478,12 +506,12 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
478
506
  return new StringSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
479
507
  regexp: _regexp,
480
508
  regExpMessage: message
481
- }), this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description);
509
+ }), this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description, this.previewInput);
482
510
  }
483
511
  }, {
484
512
  key: "validate",
485
513
  value: function validate(validationFunction) {
486
- return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions.concat(validationFunction), this.renderInput, this.isReadonly, this.isHidden, this.description);
514
+ return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions.concat(validationFunction), this.renderInput, this.isReadonly, this.isHidden, this.description, this.previewInput);
487
515
  }
488
516
  }, {
489
517
  key: "executeValidate",
@@ -556,22 +584,22 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
556
584
  }, {
557
585
  key: "nullable",
558
586
  value: function nullable() {
559
- return new StringSchema(this.options, true, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description);
587
+ return new StringSchema(this.options, true, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description, this.previewInput);
560
588
  }
561
589
  }, {
562
590
  key: "readonly",
563
591
  value: function readonly() {
564
- return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, true, this.isHidden, this.description);
592
+ return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, true, this.isHidden, this.description, this.previewInput);
565
593
  }
566
594
  }, {
567
595
  key: "hidden",
568
596
  value: function hidden() {
569
- return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, true, this.description);
597
+ return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, true, this.description, this.previewInput);
570
598
  }
571
599
  }, {
572
600
  key: "raw",
573
601
  value: function raw() {
574
- return new StringSchema(this.options, this.opt, true, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description);
602
+ return new StringSchema(this.options, this.opt, true, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description, this.previewInput);
575
603
  }
576
604
  }, {
577
605
  key: "executeCustomValidateAt",
@@ -587,6 +615,7 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
587
615
  return {
588
616
  type: "string",
589
617
  render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
618
+ preview: this.previewInput ? true : undefined,
590
619
  options: {
591
620
  maxLength: (_this$options4 = this.options) === null || _this$options4 === void 0 ? void 0 : _this$options4.maxLength,
592
621
  minLength: (_this$options5 = this.options) === null || _this$options5 === void 0 ? void 0 : _this$options5.minLength,
@@ -616,7 +645,33 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
616
645
  }, {
617
646
  key: "render",
618
647
  value: function render(input) {
619
- return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions, input, this.isReadonly, this.isHidden, this.description);
648
+ return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions, input, this.isReadonly, this.isHidden, this.description, this.previewInput);
649
+ }
650
+
651
+ /**
652
+ * How this VALUE is shown where a preview of it is needed — a row in a
653
+ * sortable list, a reference dropdown, a search hit. Never how the field
654
+ * itself is edited (that is `render`). See `preview.ts`.
655
+ */
656
+ }, {
657
+ key: "preview",
658
+ value: function preview(select) {
659
+ return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description, select);
660
+ }
661
+ }, {
662
+ key: "executePreviewItem",
663
+ value: function executePreviewItem(src) {
664
+ if (this.previewInput === null) {
665
+ return null;
666
+ }
667
+ return this.previewInput({
668
+ val: src
669
+ });
670
+ }
671
+ }, {
672
+ key: "declaresItemPreview",
673
+ value: function declaresItemPreview() {
674
+ return this.previewInput !== null;
620
675
  }
621
676
 
622
677
  /**
@@ -643,6 +698,8 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
643
698
  var isReadonly = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
644
699
  var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
645
700
  var description = arguments.length > 5 ? arguments[5] : undefined;
701
+ var renderInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
702
+ var previewInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
646
703
  _classCallCheck(this, ObjectSchema);
647
704
  _this = _callSuper(this, ObjectSchema);
648
705
  _this.items = items;
@@ -651,18 +708,20 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
651
708
  _this.isReadonly = isReadonly;
652
709
  _this.isHidden = isHidden;
653
710
  _this.description = description;
711
+ _this.renderInput = renderInput;
712
+ _this.previewInput = previewInput;
654
713
  return _this;
655
714
  }
656
715
  _inherits(ObjectSchema, _Schema);
657
716
  return _createClass(ObjectSchema, [{
658
717
  key: "describe",
659
718
  value: function describe(description) {
660
- return new ObjectSchema(this.items, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
719
+ return new ObjectSchema(this.items, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput, this.previewInput);
661
720
  }
662
721
  }, {
663
722
  key: "validate",
664
723
  value: function validate(validationFunction) {
665
- return new ObjectSchema(this.items, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description);
724
+ return new ObjectSchema(this.items, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
666
725
  }
667
726
  }, {
668
727
  key: "executeValidate",
@@ -782,17 +841,18 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
782
841
  }, {
783
842
  key: "nullable",
784
843
  value: function nullable() {
785
- return new ObjectSchema(this.items, true, [], this.isReadonly, this.isHidden, this.description);
844
+ // Explicit type args: `previewInput` would otherwise pin inference to `Src`.
845
+ return new ObjectSchema(this.items, true, [], this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
786
846
  }
787
847
  }, {
788
848
  key: "readonly",
789
849
  value: function readonly() {
790
- return new ObjectSchema(this.items, this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
850
+ return new ObjectSchema(this.items, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
791
851
  }
792
852
  }, {
793
853
  key: "hidden",
794
854
  value: function hidden() {
795
- return new ObjectSchema(this.items, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
855
+ return new ObjectSchema(this.items, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
796
856
  }
797
857
  }, {
798
858
  key: "executeCustomValidateAt",
@@ -801,12 +861,53 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
801
861
  path: path
802
862
  });
803
863
  }
864
+
865
+ /**
866
+ * How this field is laid out in the editor when it is the item of an array
867
+ * or record: `{ as: "inline" }` renders the field itself inside each row,
868
+ * instead of a preview row that navigates to it.
869
+ *
870
+ * Static configuration, not a callback — see `render.ts`.
871
+ */
872
+ }, {
873
+ key: "render",
874
+ value: function render(input) {
875
+ return new ObjectSchema(this.items, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
876
+ }
877
+
878
+ /**
879
+ * How this VALUE is shown where a preview of it is needed — a row in a
880
+ * sortable list, a reference dropdown, a search hit. Never how the field
881
+ * itself is edited (that is `render`). See `preview.ts`.
882
+ */
883
+ }, {
884
+ key: "preview",
885
+ value: function preview(select) {
886
+ return new ObjectSchema(this.items, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
887
+ }
888
+ }, {
889
+ key: "executePreviewItem",
890
+ value: function executePreviewItem(src) {
891
+ if (this.previewInput === null) {
892
+ return null;
893
+ }
894
+ return this.previewInput({
895
+ val: src
896
+ });
897
+ }
898
+ }, {
899
+ key: "declaresItemPreview",
900
+ value: function declaresItemPreview() {
901
+ return this.previewInput !== null;
902
+ }
804
903
  }, {
805
904
  key: "executeSerialize",
806
905
  value: function executeSerialize() {
807
- var _this$customValidateF;
906
+ var _this$renderInput, _this$customValidateF;
808
907
  return {
809
908
  type: "object",
909
+ render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
910
+ preview: this.previewInput ? true : undefined,
810
911
  items: Object.fromEntries(Object.entries(this.items).map(function (_ref5) {
811
912
  var _ref6 = _slicedToArray(_ref5, 2),
812
913
  key = _ref6[0],
@@ -867,6 +968,7 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
867
968
  var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
868
969
  var description = arguments.length > 5 ? arguments[5] : undefined;
869
970
  var previewInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
971
+ var renderInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
870
972
  _classCallCheck(this, ArraySchema);
871
973
  _this = _callSuper(this, ArraySchema);
872
974
  _this.item = item;
@@ -876,18 +978,19 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
876
978
  _this.isHidden = isHidden;
877
979
  _this.description = description;
878
980
  _this.previewInput = previewInput;
981
+ _this.renderInput = renderInput;
879
982
  return _this;
880
983
  }
881
984
  _inherits(ArraySchema, _Schema);
882
985
  return _createClass(ArraySchema, [{
883
986
  key: "describe",
884
987
  value: function describe(description) {
885
- return new ArraySchema(this.item, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.previewInput);
988
+ return new ArraySchema(this.item, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.previewInput, this.renderInput);
886
989
  }
887
990
  }, {
888
991
  key: "validate",
889
992
  value: function validate(validationFunction) {
890
- return new ArraySchema(this.item, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.previewInput);
993
+ return new ArraySchema(this.item, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.previewInput, this.renderInput);
891
994
  }
892
995
  }, {
893
996
  key: "executeValidate",
@@ -954,17 +1057,18 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
954
1057
  }, {
955
1058
  key: "nullable",
956
1059
  value: function nullable() {
957
- return new ArraySchema(this.item, true, [], this.isReadonly, this.isHidden, this.description, this.previewInput);
1060
+ // Explicit type args: `previewInput` would otherwise pin inference to `Src`.
1061
+ return new ArraySchema(this.item, true, [], this.isReadonly, this.isHidden, this.description, this.previewInput, this.renderInput);
958
1062
  }
959
1063
  }, {
960
1064
  key: "readonly",
961
1065
  value: function readonly() {
962
- return new ArraySchema(this.item, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.previewInput);
1066
+ return new ArraySchema(this.item, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.previewInput, this.renderInput);
963
1067
  }
964
1068
  }, {
965
1069
  key: "hidden",
966
1070
  value: function hidden() {
967
- return new ArraySchema(this.item, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.previewInput);
1071
+ return new ArraySchema(this.item, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.previewInput, this.renderInput);
968
1072
  }
969
1073
  }, {
970
1074
  key: "executeCustomValidateAt",
@@ -976,9 +1080,10 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
976
1080
  }, {
977
1081
  key: "executeSerialize",
978
1082
  value: function executeSerialize() {
979
- var _this$customValidateF;
1083
+ var _this$renderInput, _this$customValidateF;
980
1084
  return {
981
1085
  type: "array",
1086
+ render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
982
1087
  item: this.item["executeSerialize"](),
983
1088
  opt: this.opt,
984
1089
  preview: this.previewInput ? true : undefined,
@@ -1011,8 +1116,10 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
1011
1116
  res[_key] = itemResult[_key];
1012
1117
  }
1013
1118
  }
1014
- if (this.previewInput) {
1015
- var select = this.previewInput;
1119
+ // The rows preview comes from the ITEM schema's own `preview` — the
1120
+ // container just runs it per row. Asked as a fact rather than by running
1121
+ // the closure, so an empty list still previews as an empty list.
1122
+ if (this.item["declaresItemPreview"]()) {
1016
1123
  // The whole list when the LIST is what is being shown; only the wanted
1017
1124
  // rows when it is not. The user's closure is the real expense — a list
1018
1125
  // view asks for the container and gets every row, a single field asks for
@@ -1023,26 +1130,30 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
1023
1130
  var window = scope !== undefined && !scope.wants(sourcePath) ? scope : null;
1024
1131
  var items = [];
1025
1132
  for (var index = 0; index < src.length; index++) {
1133
+ var _itemSrc = src[index];
1134
+ if (_itemSrc === null || _itemSrc === undefined) {
1135
+ continue;
1136
+ }
1026
1137
  if (window !== null && !window.wantsUnder(unsafeCreateSourcePath(sourcePath, index))) {
1027
1138
  continue;
1028
1139
  }
1029
- // Per ITEM, not per list, matching what `record` already does: the
1030
- // closure is user code, and one row whose data trips it up must not take
1031
- // out the whole list. Before scoping, one throwing row produced an error
1032
- // at the container and no items at all.
1140
+ // Per ITEM, not per list: the closure is user code, and one row whose
1141
+ // data trips it up must not take out the whole list. Before scoping,
1142
+ // one throwing row produced an error at the container and no items at
1143
+ // all.
1033
1144
  try {
1034
1145
  // NB NB: display is actually defined by the user
1035
- var _select = select({
1036
- val: src[index]
1037
- }),
1038
- title = _select.title,
1039
- subtitle = _select.subtitle,
1040
- image = _select.image;
1041
- items.push([index, {
1042
- title: title,
1043
- subtitle: subtitle,
1044
- image: image
1045
- }]);
1146
+ var _item = this.item["executePreviewItem"](_itemSrc);
1147
+ if (_item !== null) {
1148
+ var title = _item.title,
1149
+ subtitle = _item.subtitle,
1150
+ image = _item.image;
1151
+ items.push([index, {
1152
+ title: title,
1153
+ subtitle: subtitle,
1154
+ image: image
1155
+ }]);
1156
+ }
1046
1157
  } catch (e) {
1047
1158
  res[unsafeCreateSourcePath(sourcePath, index)] = {
1048
1159
  status: "error",
@@ -1060,18 +1171,45 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
1060
1171
  }
1061
1172
  return res;
1062
1173
  }
1174
+ }, {
1175
+ key: "executePreviewItem",
1176
+ value: function executePreviewItem(src) {
1177
+ if (this.previewInput === null) {
1178
+ return null;
1179
+ }
1180
+ return this.previewInput({
1181
+ val: src
1182
+ });
1183
+ }
1184
+ }, {
1185
+ key: "declaresItemPreview",
1186
+ value: function declaresItemPreview() {
1187
+ return this.previewInput !== null;
1188
+ }
1063
1189
 
1064
1190
  /**
1065
- * What the editor shows for each ITEM of this array: a title, and optionally a
1066
- * subtitle and an image.
1067
- *
1068
- * `select` is your own code over the item's source, so it is run on demand for
1069
- * the rows that are actually being looked at — see `PreviewScope`.
1191
+ * How this ARRAY ITSELF is shown where a preview of it is needed — when it
1192
+ * is the item of another container, in search, in references. What its rows
1193
+ * show is the ITEM schema's `preview`, not this. Never how the field is
1194
+ * edited (that is `render`). See `preview.ts`.
1070
1195
  */
1071
1196
  }, {
1072
1197
  key: "preview",
1073
1198
  value: function preview(select) {
1074
- return new ArraySchema(this.item, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, select);
1199
+ return new ArraySchema(this.item, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, select, this.renderInput);
1200
+ }
1201
+
1202
+ /**
1203
+ * How this field is laid out in the editor when it is the item of an array
1204
+ * or record: `{ as: "inline" }` renders the field itself inside each row,
1205
+ * instead of a preview row that navigates to it.
1206
+ *
1207
+ * Static configuration, not a callback — see `render.ts`.
1208
+ */
1209
+ }, {
1210
+ key: "render",
1211
+ value: function render(input) {
1212
+ return new ArraySchema(this.item, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.previewInput, input);
1075
1213
  }
1076
1214
  }]);
1077
1215
  }(Schema);
@@ -1087,6 +1225,8 @@ var LiteralSchema = /*#__PURE__*/function (_Schema) {
1087
1225
  var isReadonly = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
1088
1226
  var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
1089
1227
  var description = arguments.length > 5 ? arguments[5] : undefined;
1228
+ var renderInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
1229
+ var previewInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
1090
1230
  _classCallCheck(this, LiteralSchema);
1091
1231
  _this = _callSuper(this, LiteralSchema);
1092
1232
  _this.value = value;
@@ -1095,18 +1235,20 @@ var LiteralSchema = /*#__PURE__*/function (_Schema) {
1095
1235
  _this.isReadonly = isReadonly;
1096
1236
  _this.isHidden = isHidden;
1097
1237
  _this.description = description;
1238
+ _this.renderInput = renderInput;
1239
+ _this.previewInput = previewInput;
1098
1240
  return _this;
1099
1241
  }
1100
1242
  _inherits(LiteralSchema, _Schema);
1101
1243
  return _createClass(LiteralSchema, [{
1102
1244
  key: "describe",
1103
1245
  value: function describe(description) {
1104
- return new LiteralSchema(this.value, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
1246
+ return new LiteralSchema(this.value, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput, this.previewInput);
1105
1247
  }
1106
1248
  }, {
1107
1249
  key: "validate",
1108
1250
  value: function validate(validationFunction) {
1109
- return new LiteralSchema(this.value, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description);
1251
+ return new LiteralSchema(this.value, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
1110
1252
  }
1111
1253
  }, {
1112
1254
  key: "executeValidate",
@@ -1169,17 +1311,17 @@ var LiteralSchema = /*#__PURE__*/function (_Schema) {
1169
1311
  }, {
1170
1312
  key: "nullable",
1171
1313
  value: function nullable() {
1172
- return new LiteralSchema(this.value, true, [], this.isReadonly, this.isHidden, this.description);
1314
+ return new LiteralSchema(this.value, true, [], this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
1173
1315
  }
1174
1316
  }, {
1175
1317
  key: "readonly",
1176
1318
  value: function readonly() {
1177
- return new LiteralSchema(this.value, this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
1319
+ return new LiteralSchema(this.value, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
1178
1320
  }
1179
1321
  }, {
1180
1322
  key: "hidden",
1181
1323
  value: function hidden() {
1182
- return new LiteralSchema(this.value, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
1324
+ return new LiteralSchema(this.value, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
1183
1325
  }
1184
1326
  }, {
1185
1327
  key: "executeCustomValidateAt",
@@ -1188,12 +1330,53 @@ var LiteralSchema = /*#__PURE__*/function (_Schema) {
1188
1330
  path: path
1189
1331
  });
1190
1332
  }
1333
+
1334
+ /**
1335
+ * How this field is laid out in the editor when it is the item of an array
1336
+ * or record: `{ as: "inline" }` renders the field itself inside each row,
1337
+ * instead of a preview row that navigates to it.
1338
+ *
1339
+ * Static configuration, not a callback — see `render.ts`.
1340
+ */
1341
+ }, {
1342
+ key: "render",
1343
+ value: function render(input) {
1344
+ return new LiteralSchema(this.value, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
1345
+ }
1346
+
1347
+ /**
1348
+ * How this VALUE is shown where a preview of it is needed — a row in a
1349
+ * sortable list, a reference dropdown, a search hit. Never how the field
1350
+ * itself is edited (that is `render`). See `preview.ts`.
1351
+ */
1352
+ }, {
1353
+ key: "preview",
1354
+ value: function preview(select) {
1355
+ return new LiteralSchema(this.value, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
1356
+ }
1357
+ }, {
1358
+ key: "executePreviewItem",
1359
+ value: function executePreviewItem(src) {
1360
+ if (this.previewInput === null) {
1361
+ return null;
1362
+ }
1363
+ return this.previewInput({
1364
+ val: src
1365
+ });
1366
+ }
1367
+ }, {
1368
+ key: "declaresItemPreview",
1369
+ value: function declaresItemPreview() {
1370
+ return this.previewInput !== null;
1371
+ }
1191
1372
  }, {
1192
1373
  key: "executeSerialize",
1193
1374
  value: function executeSerialize() {
1194
- var _this$customValidateF;
1375
+ var _this$renderInput, _this$customValidateF;
1195
1376
  return {
1196
1377
  type: "literal",
1378
+ render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
1379
+ preview: this.previewInput ? true : undefined,
1197
1380
  value: this.value,
1198
1381
  opt: this.opt,
1199
1382
  customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
@@ -1221,6 +1404,8 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
1221
1404
  var isReadonly = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
1222
1405
  var isHidden = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
1223
1406
  var description = arguments.length > 6 ? arguments[6] : undefined;
1407
+ var renderInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
1408
+ var previewInput = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
1224
1409
  _classCallCheck(this, UnionSchema);
1225
1410
  _this = _callSuper(this, UnionSchema);
1226
1411
  _this.key = key;
@@ -1230,18 +1415,20 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
1230
1415
  _this.isReadonly = isReadonly;
1231
1416
  _this.isHidden = isHidden;
1232
1417
  _this.description = description;
1418
+ _this.renderInput = renderInput;
1419
+ _this.previewInput = previewInput;
1233
1420
  return _this;
1234
1421
  }
1235
1422
  _inherits(UnionSchema, _Schema);
1236
1423
  return _createClass(UnionSchema, [{
1237
1424
  key: "describe",
1238
1425
  value: function describe(description) {
1239
- return new UnionSchema(this.key, this.items, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
1426
+ return new UnionSchema(this.key, this.items, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput, this.previewInput);
1240
1427
  }
1241
1428
  }, {
1242
1429
  key: "validate",
1243
1430
  value: function validate(validationFunction) {
1244
- return new UnionSchema(this.key, this.items, this.opt, this.customValidateFunctions.concat(validationFunction), this.isReadonly, this.isHidden, this.description);
1431
+ return new UnionSchema(this.key, this.items, this.opt, this.customValidateFunctions.concat(validationFunction), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
1245
1432
  }
1246
1433
  }, {
1247
1434
  key: "executeValidate",
@@ -1534,17 +1721,18 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
1534
1721
  }, {
1535
1722
  key: "nullable",
1536
1723
  value: function nullable() {
1537
- return new UnionSchema(this.key, this.items, true, [], this.isReadonly, this.isHidden, this.description);
1724
+ // Explicit type args: `previewInput` would otherwise pin inference to `Src`.
1725
+ return new UnionSchema(this.key, this.items, true, [], this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
1538
1726
  }
1539
1727
  }, {
1540
1728
  key: "readonly",
1541
1729
  value: function readonly() {
1542
- return new UnionSchema(this.key, this.items, this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
1730
+ return new UnionSchema(this.key, this.items, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
1543
1731
  }
1544
1732
  }, {
1545
1733
  key: "hidden",
1546
1734
  value: function hidden() {
1547
- return new UnionSchema(this.key, this.items, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
1735
+ return new UnionSchema(this.key, this.items, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
1548
1736
  }
1549
1737
  }, {
1550
1738
  key: "executeCustomValidateAt",
@@ -1604,14 +1792,69 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
1604
1792
  }
1605
1793
  return null;
1606
1794
  }
1795
+
1796
+ /**
1797
+ * How this field is laid out in the editor when it is the item of an array
1798
+ * or record: `{ as: "inline" }` renders the field itself inside each row,
1799
+ * instead of a preview row that navigates to it.
1800
+ *
1801
+ * Static configuration, not a callback — see `render.ts`.
1802
+ */
1803
+ }, {
1804
+ key: "render",
1805
+ value: function render(input) {
1806
+ return new UnionSchema(this.key, this.items, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
1807
+ }
1808
+
1809
+ /**
1810
+ * How this VALUE is shown where a preview of it is needed — a row in a
1811
+ * sortable list, a reference dropdown, a search hit. Never how the field
1812
+ * itself is edited (that is `render`). See `preview.ts`.
1813
+ *
1814
+ * Without one of its own, a tagged union previews as the VARIANT the value
1815
+ * takes — declare `preview` on the member objects and the union dispatches.
1816
+ */
1817
+ }, {
1818
+ key: "preview",
1819
+ value: function preview(select) {
1820
+ return new UnionSchema(this.key, this.items, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
1821
+ }
1822
+ }, {
1823
+ key: "executePreviewItem",
1824
+ value: function executePreviewItem(src) {
1825
+ if (this.previewInput !== null) {
1826
+ return this.previewInput({
1827
+ val: src
1828
+ });
1829
+ }
1830
+ // Only the union knows which variant the value takes; the variant's own
1831
+ // `preview` is what it previews as.
1832
+ var matched = this.matchedVariant(src);
1833
+ if (matched) {
1834
+ return matched["executePreviewItem"](src);
1835
+ }
1836
+ return null;
1837
+ }
1838
+ }, {
1839
+ key: "declaresItemPreview",
1840
+ value: function declaresItemPreview() {
1841
+ if (this.previewInput !== null) {
1842
+ return true;
1843
+ }
1844
+ return Array.isArray(this.items) && this.items.some(function (item) {
1845
+ return item["declaresItemPreview"]();
1846
+ });
1847
+ }
1607
1848
  }, {
1608
1849
  key: "executeSerialize",
1609
1850
  value: function executeSerialize() {
1610
- var _this$customValidateF2;
1851
+ var _this$renderInput2, _this$customValidateF2;
1611
1852
  if (typeof this.key === "string") {
1612
- var _this$customValidateF;
1853
+ var _this$renderInput, _this$customValidateF;
1613
1854
  return {
1614
1855
  type: "union",
1856
+ render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
1857
+ preview: this.previewInput ? true : undefined,
1615
1858
  key: this.key,
1616
1859
  items: this.items.map(function (o) {
1617
1860
  return o["executeSerialize"]();
@@ -1625,6 +1868,8 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
1625
1868
  }
1626
1869
  return {
1627
1870
  type: "union",
1871
+ render: (_this$renderInput2 = this.renderInput) !== null && _this$renderInput2 !== void 0 ? _this$renderInput2 : undefined,
1872
+ preview: this.previewInput ? true : undefined,
1628
1873
  key: this.key["executeSerialize"](),
1629
1874
  items: this.items.map(function (o) {
1630
1875
  return o["executeSerialize"]();
@@ -1851,6 +2096,30 @@ function fillFromGallery(src, schema, getModuleSource) {
1851
2096
  } : {});
1852
2097
  }
1853
2098
 
2099
+ /**
2100
+ * How an uploaded image is re-encoded in the browser, before it is uploaded.
2101
+ *
2102
+ * Off unless a schema asks for it. When it is on, the image is converted to
2103
+ * `type` and scaled down to fit `maxWidth` x `maxHeight` - unless the result
2104
+ * would be BIGGER than the original and no downscale was needed, in which case
2105
+ * the original bytes are kept. See `architecture/media.md`.
2106
+ *
2107
+ * `type` is required so that adding a format later is additive: a schema
2108
+ * written today keeps saying exactly which format it asked for.
2109
+ */
2110
+
2111
+ /** `false` (or absent) uploads the bytes exactly as the editor picked them. */
2112
+
2113
+ /**
2114
+ * What a GALLERY-BACKED field may say for itself.
2115
+ *
2116
+ * Not `ImageOptions`: `directory` and `accept` belong to the gallery, and a
2117
+ * field repeating them is how two copies of one fact get to disagree. `encode`
2118
+ * is different — it describes what happens to the bytes on their way IN, so a
2119
+ * field that wants the original where its gallery re-encodes has to be able to
2120
+ * say `encode: false`, and there is nowhere else to say it.
2121
+ */
2122
+
1854
2123
  var ImageSchema = /*#__PURE__*/function (_Schema) {
1855
2124
  function ImageSchema(options) {
1856
2125
  var _this;
@@ -1861,6 +2130,8 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
1861
2130
  var isReadonly = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
1862
2131
  var isHidden = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
1863
2132
  var description = arguments.length > 7 ? arguments[7] : undefined;
2133
+ var renderInput = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
2134
+ var previewInput = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : null;
1864
2135
  _classCallCheck(this, ImageSchema);
1865
2136
  _this = _callSuper(this, ImageSchema);
1866
2137
  _this.options = options;
@@ -1871,23 +2142,25 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
1871
2142
  _this.isReadonly = isReadonly;
1872
2143
  _this.isHidden = isHidden;
1873
2144
  _this.description = description;
2145
+ _this.renderInput = renderInput;
2146
+ _this.previewInput = previewInput;
1874
2147
  return _this;
1875
2148
  }
1876
2149
  _inherits(ImageSchema, _Schema);
1877
2150
  return _createClass(ImageSchema, [{
1878
2151
  key: "describe",
1879
2152
  value: function describe(description) {
1880
- return new ImageSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
2153
+ return new ImageSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput, this.previewInput);
1881
2154
  }
1882
2155
  }, {
1883
2156
  key: "remote",
1884
2157
  value: function remote() {
1885
- return new ImageSchema(this.options, this.opt, true, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description);
2158
+ return new ImageSchema(this.options, this.opt, true, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
1886
2159
  }
1887
2160
  }, {
1888
2161
  key: "validate",
1889
2162
  value: function validate(validationFunction) {
1890
- return new ImageSchema(this.options, this.opt, this.isRemote, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.moduleMetadata, this.isReadonly, this.isHidden, this.description);
2163
+ return new ImageSchema(this.options, this.opt, this.isRemote, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.moduleMetadata, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
1891
2164
  }
1892
2165
  }, {
1893
2166
  key: "executeValidate",
@@ -2086,17 +2359,17 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
2086
2359
  }, {
2087
2360
  key: "nullable",
2088
2361
  value: function nullable() {
2089
- return new ImageSchema(this.options, true, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description);
2362
+ return new ImageSchema(this.options, true, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
2090
2363
  }
2091
2364
  }, {
2092
2365
  key: "readonly",
2093
2366
  value: function readonly() {
2094
- return new ImageSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, true, this.isHidden, this.description);
2367
+ return new ImageSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, true, this.isHidden, this.description, this.renderInput, this.previewInput);
2095
2368
  }
2096
2369
  }, {
2097
2370
  key: "hidden",
2098
2371
  value: function hidden() {
2099
- return new ImageSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, true, this.description);
2372
+ return new ImageSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
2100
2373
  }
2101
2374
  }, {
2102
2375
  key: "executeCustomValidateAt",
@@ -2105,13 +2378,54 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
2105
2378
  path: path
2106
2379
  });
2107
2380
  }
2381
+
2382
+ /**
2383
+ * How this field is laid out in the editor when it is the item of an array
2384
+ * or record: `{ as: "inline" }` renders the field itself inside each row,
2385
+ * instead of a preview row that navigates to it.
2386
+ *
2387
+ * Static configuration, not a callback — see `render.ts`.
2388
+ */
2389
+ }, {
2390
+ key: "render",
2391
+ value: function render(input) {
2392
+ return new ImageSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
2393
+ }
2394
+
2395
+ /**
2396
+ * How this VALUE is shown where a preview of it is needed — a row in a
2397
+ * sortable list, a reference dropdown, a search hit. Never how the field
2398
+ * itself is edited (that is `render`). See `preview.ts`.
2399
+ */
2400
+ }, {
2401
+ key: "preview",
2402
+ value: function preview(select) {
2403
+ return new ImageSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
2404
+ }
2405
+ }, {
2406
+ key: "executePreviewItem",
2407
+ value: function executePreviewItem(src) {
2408
+ if (this.previewInput === null) {
2409
+ return null;
2410
+ }
2411
+ return this.previewInput({
2412
+ val: src
2413
+ });
2414
+ }
2415
+ }, {
2416
+ key: "declaresItemPreview",
2417
+ value: function declaresItemPreview() {
2418
+ return this.previewInput !== null;
2419
+ }
2108
2420
  }, {
2109
2421
  key: "executeSerialize",
2110
2422
  value: function executeSerialize() {
2111
- var _this$customValidateF;
2423
+ var _this$renderInput, _this$customValidateF;
2112
2424
  var modulePaths = this.moduleMetadata ? Object.keys(this.moduleMetadata) : [];
2113
2425
  return {
2114
2426
  type: "image",
2427
+ render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
2428
+ preview: this.previewInput ? true : undefined,
2115
2429
  options: this.options,
2116
2430
  opt: this.opt,
2117
2431
  remote: this.isRemote,
@@ -2137,7 +2451,7 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
2137
2451
 
2138
2452
  /** An image of its own, carrying its own dimensions and mime type. */
2139
2453
 
2140
- function image(options) {
2454
+ function image(options, galleryOptions) {
2141
2455
  var isModule = !!options && !!Internal.getValPath(options);
2142
2456
  if (isModule) {
2143
2457
  var allModules = {};
@@ -2149,7 +2463,9 @@ function image(options) {
2149
2463
  }
2150
2464
  allModules[modulePath] = getSource(valModule);
2151
2465
  }
2152
- return new ImageSchema({}, false, false, [], allModules);
2466
+ return new ImageSchema((galleryOptions === null || galleryOptions === void 0 ? void 0 : galleryOptions.encode) !== undefined ? {
2467
+ encode: galleryOptions.encode
2468
+ } : {}, false, false, [], allModules);
2153
2469
  }
2154
2470
  return new ImageSchema(options);
2155
2471
  }
@@ -2162,6 +2478,8 @@ var RouteSchema = /*#__PURE__*/function (_Schema) {
2162
2478
  var isReadonly = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
2163
2479
  var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
2164
2480
  var description = arguments.length > 5 ? arguments[5] : undefined;
2481
+ var renderInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
2482
+ var previewInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
2165
2483
  _classCallCheck(this, RouteSchema);
2166
2484
  _this = _callSuper(this, RouteSchema);
2167
2485
  _this.options = options;
@@ -2170,13 +2488,15 @@ var RouteSchema = /*#__PURE__*/function (_Schema) {
2170
2488
  _this.isReadonly = isReadonly;
2171
2489
  _this.isHidden = isHidden;
2172
2490
  _this.description = description;
2491
+ _this.renderInput = renderInput;
2492
+ _this.previewInput = previewInput;
2173
2493
  return _this;
2174
2494
  }
2175
2495
  _inherits(RouteSchema, _Schema);
2176
2496
  return _createClass(RouteSchema, [{
2177
2497
  key: "describe",
2178
2498
  value: function describe(description) {
2179
- return new RouteSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
2499
+ return new RouteSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput, this.previewInput);
2180
2500
  }
2181
2501
 
2182
2502
  /**
@@ -2196,7 +2516,7 @@ var RouteSchema = /*#__PURE__*/function (_Schema) {
2196
2516
  value: function include(pattern) {
2197
2517
  return new RouteSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
2198
2518
  include: pattern
2199
- }), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
2519
+ }), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
2200
2520
  }
2201
2521
 
2202
2522
  /**
@@ -2216,12 +2536,12 @@ var RouteSchema = /*#__PURE__*/function (_Schema) {
2216
2536
  value: function exclude(pattern) {
2217
2537
  return new RouteSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
2218
2538
  exclude: pattern
2219
- }), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
2539
+ }), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
2220
2540
  }
2221
2541
  }, {
2222
2542
  key: "validate",
2223
2543
  value: function validate(validationFunction) {
2224
- return new RouteSchema(this.options, this.opt, this.customValidateFunctions.concat(validationFunction), this.isReadonly, this.isHidden, this.description);
2544
+ return new RouteSchema(this.options, this.opt, this.customValidateFunctions.concat(validationFunction), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
2225
2545
  }
2226
2546
  }, {
2227
2547
  key: "executeValidate",
@@ -2276,17 +2596,17 @@ var RouteSchema = /*#__PURE__*/function (_Schema) {
2276
2596
  }, {
2277
2597
  key: "nullable",
2278
2598
  value: function nullable() {
2279
- return new RouteSchema(this.options, true, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
2599
+ return new RouteSchema(this.options, true, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
2280
2600
  }
2281
2601
  }, {
2282
2602
  key: "readonly",
2283
2603
  value: function readonly() {
2284
- return new RouteSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
2604
+ return new RouteSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
2285
2605
  }
2286
2606
  }, {
2287
2607
  key: "hidden",
2288
2608
  value: function hidden() {
2289
- return new RouteSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
2609
+ return new RouteSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
2290
2610
  }
2291
2611
  }, {
2292
2612
  key: "executeCustomValidateAt",
@@ -2295,12 +2615,53 @@ var RouteSchema = /*#__PURE__*/function (_Schema) {
2295
2615
  path: path
2296
2616
  });
2297
2617
  }
2618
+
2619
+ /**
2620
+ * How this field is laid out in the editor when it is the item of an array
2621
+ * or record: `{ as: "inline" }` renders the field itself inside each row,
2622
+ * instead of a preview row that navigates to it.
2623
+ *
2624
+ * Static configuration, not a callback — see `render.ts`.
2625
+ */
2626
+ }, {
2627
+ key: "render",
2628
+ value: function render(input) {
2629
+ return new RouteSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
2630
+ }
2631
+
2632
+ /**
2633
+ * How this VALUE is shown where a preview of it is needed — a row in a
2634
+ * sortable list, a reference dropdown, a search hit. Never how the field
2635
+ * itself is edited (that is `render`). See `preview.ts`.
2636
+ */
2637
+ }, {
2638
+ key: "preview",
2639
+ value: function preview(select) {
2640
+ return new RouteSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
2641
+ }
2642
+ }, {
2643
+ key: "executePreviewItem",
2644
+ value: function executePreviewItem(src) {
2645
+ if (this.previewInput === null) {
2646
+ return null;
2647
+ }
2648
+ return this.previewInput({
2649
+ val: src
2650
+ });
2651
+ }
2652
+ }, {
2653
+ key: "declaresItemPreview",
2654
+ value: function declaresItemPreview() {
2655
+ return this.previewInput !== null;
2656
+ }
2298
2657
  }, {
2299
2658
  key: "executeSerialize",
2300
2659
  value: function executeSerialize() {
2301
- var _this$options3, _this$options4, _this$customValidateF, _this$customValidateF2;
2660
+ var _this$renderInput, _this$options3, _this$options4, _this$customValidateF, _this$customValidateF2;
2302
2661
  return {
2303
2662
  type: "route",
2663
+ render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
2664
+ preview: this.previewInput ? true : undefined,
2304
2665
  options: {
2305
2666
  include: ((_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : _this$options3.include) && {
2306
2667
  source: this.options.include.source,
@@ -2338,6 +2699,8 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
2338
2699
  var isReadonly = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
2339
2700
  var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
2340
2701
  var description = arguments.length > 5 ? arguments[5] : undefined;
2702
+ var renderInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
2703
+ var previewInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
2341
2704
  _classCallCheck(this, RichTextSchema);
2342
2705
  _this = _callSuper(this, RichTextSchema);
2343
2706
  _this.options = options;
@@ -2346,32 +2709,34 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
2346
2709
  _this.isReadonly = isReadonly;
2347
2710
  _this.isHidden = isHidden;
2348
2711
  _this.description = description;
2712
+ _this.renderInput = renderInput;
2713
+ _this.previewInput = previewInput;
2349
2714
  return _this;
2350
2715
  }
2351
2716
  _inherits(RichTextSchema, _Schema);
2352
2717
  return _createClass(RichTextSchema, [{
2353
2718
  key: "describe",
2354
2719
  value: function describe(description) {
2355
- return new RichTextSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
2720
+ return new RichTextSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput, this.previewInput);
2356
2721
  }
2357
2722
  }, {
2358
2723
  key: "maxLength",
2359
2724
  value: function maxLength(max) {
2360
2725
  return new RichTextSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
2361
2726
  maxLength: max
2362
- }), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
2727
+ }), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
2363
2728
  }
2364
2729
  }, {
2365
2730
  key: "minLength",
2366
2731
  value: function minLength(min) {
2367
2732
  return new RichTextSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
2368
2733
  minLength: min
2369
- }), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
2734
+ }), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
2370
2735
  }
2371
2736
  }, {
2372
2737
  key: "validate",
2373
2738
  value: function validate(validationFunction) {
2374
- return new RichTextSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description);
2739
+ return new RichTextSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
2375
2740
  }
2376
2741
  }, {
2377
2742
  key: "executeValidate",
@@ -2821,17 +3186,17 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
2821
3186
  }, {
2822
3187
  key: "nullable",
2823
3188
  value: function nullable() {
2824
- return new RichTextSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description);
3189
+ return new RichTextSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
2825
3190
  }
2826
3191
  }, {
2827
3192
  key: "readonly",
2828
3193
  value: function readonly() {
2829
- return new RichTextSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
3194
+ return new RichTextSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
2830
3195
  }
2831
3196
  }, {
2832
3197
  key: "hidden",
2833
3198
  value: function hidden() {
2834
- return new RichTextSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
3199
+ return new RichTextSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
2835
3200
  }
2836
3201
  }, {
2837
3202
  key: "executeCustomValidateAt",
@@ -2840,10 +3205,50 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
2840
3205
  path: path
2841
3206
  });
2842
3207
  }
3208
+
3209
+ /**
3210
+ * How this field is laid out in the editor when it is the item of an array
3211
+ * or record: `{ as: "inline" }` renders the field itself inside each row,
3212
+ * instead of a preview row that navigates to it.
3213
+ *
3214
+ * Static configuration, not a callback — see `render.ts`.
3215
+ */
3216
+ }, {
3217
+ key: "render",
3218
+ value: function render(input) {
3219
+ return new RichTextSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
3220
+ }
3221
+
3222
+ /**
3223
+ * How this VALUE is shown where a preview of it is needed — a row in a
3224
+ * sortable list, a reference dropdown, a search hit. Never how the field
3225
+ * itself is edited (that is `render`). See `preview.ts`.
3226
+ */
3227
+ }, {
3228
+ key: "preview",
3229
+ value: function preview(select) {
3230
+ return new RichTextSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
3231
+ }
3232
+ }, {
3233
+ key: "executePreviewItem",
3234
+ value: function executePreviewItem(src) {
3235
+ if (this.previewInput === null) {
3236
+ return null;
3237
+ }
3238
+ return this.previewInput({
3239
+ val: src
3240
+ });
3241
+ }
3242
+ }, {
3243
+ key: "declaresItemPreview",
3244
+ value: function declaresItemPreview() {
3245
+ return this.previewInput !== null;
3246
+ }
2843
3247
  }, {
2844
3248
  key: "executeSerialize",
2845
3249
  value: function executeSerialize() {
2846
3250
  var _this3 = this,
3251
+ _this$renderInput,
2847
3252
  _this$customValidateF;
2848
3253
  var serializeAnchorSchema = function serializeAnchorSchema() {
2849
3254
  var _this3$options$inline, _this3$options$inline3;
@@ -2870,6 +3275,8 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
2870
3275
  };
2871
3276
  return {
2872
3277
  type: "richtext",
3278
+ render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
3279
+ preview: this.previewInput ? true : undefined,
2873
3280
  opt: this.opt,
2874
3281
  options: serializedOptions,
2875
3282
  customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
@@ -3214,6 +3621,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
3214
3621
  var description = arguments.length > 8 ? arguments[8] : undefined;
3215
3622
  var isJsonValues = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : false;
3216
3623
  var previewInput = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : null;
3624
+ var renderInput = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : null;
3217
3625
  _classCallCheck(this, RecordSchema);
3218
3626
  _this = _callSuper(this, RecordSchema);
3219
3627
  _this.item = item;
@@ -3227,18 +3635,19 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
3227
3635
  _this.description = description;
3228
3636
  _this.isJsonValues = isJsonValues;
3229
3637
  _this.previewInput = previewInput;
3638
+ _this.renderInput = renderInput;
3230
3639
  return _this;
3231
3640
  }
3232
3641
  _inherits(RecordSchema, _Schema);
3233
3642
  return _createClass(RecordSchema, [{
3234
3643
  key: "describe",
3235
3644
  value: function describe(description) {
3236
- return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.isJsonValues, this.previewInput);
3645
+ return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.isJsonValues, this.previewInput, this.renderInput);
3237
3646
  }
3238
3647
  }, {
3239
3648
  key: "validate",
3240
3649
  value: function validate(validationFunction) {
3241
- return new RecordSchema(this.item, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.previewInput);
3650
+ return new RecordSchema(this.item, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.previewInput, this.renderInput);
3242
3651
  }
3243
3652
  }, {
3244
3653
  key: "executeValidate",
@@ -3597,29 +4006,29 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
3597
4006
  }, {
3598
4007
  key: "nullable",
3599
4008
  value: function nullable() {
3600
- return new RecordSchema(this.item, true, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.previewInput);
4009
+ return new RecordSchema(this.item, true, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.previewInput, this.renderInput);
3601
4010
  }
3602
4011
  }, {
3603
4012
  key: "readonly",
3604
4013
  value: function readonly() {
3605
- return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, true, this.isHidden, this.description, this.isJsonValues, this.previewInput);
4014
+ return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, true, this.isHidden, this.description, this.isJsonValues, this.previewInput, this.renderInput);
3606
4015
  }
3607
4016
  }, {
3608
4017
  key: "hidden",
3609
4018
  value: function hidden() {
3610
- return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, true, this.description, this.isJsonValues, this.previewInput);
4019
+ return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, true, this.description, this.isJsonValues, this.previewInput, this.renderInput);
3611
4020
  }
3612
4021
  }, {
3613
4022
  key: "router",
3614
4023
  value: function router(_router) {
3615
- return new RecordSchema(this.item, this.opt, this.customValidateFunctions, _router, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.previewInput);
4024
+ return new RecordSchema(this.item, this.opt, this.customValidateFunctions, _router, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.previewInput, this.renderInput);
3616
4025
  }
3617
4026
  }, {
3618
4027
  key: "remote",
3619
4028
  value: function remote() {
3620
4029
  return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions ? _objectSpread2(_objectSpread2({}, this.mediaOptions), {}, {
3621
4030
  remote: true
3622
- }) : undefined, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.previewInput);
4031
+ }) : undefined, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.previewInput, this.renderInput);
3623
4032
  }
3624
4033
 
3625
4034
  /**
@@ -3649,9 +4058,19 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
3649
4058
  // `.validate(...)` in their source file that never ran anywhere.
3650
4059
  throw new Error(".jsonValues() must come BEFORE .validate(): a validator added first is typed against the un-lazy source shape and cannot be carried over. Write s.record(...).jsonValues().validate(...) instead.");
3651
4060
  }
4061
+ if (this.previewInput !== null) {
4062
+ // Same reasoning as the validator guard above: the record's own preview
4063
+ // closure is typed against the un-lazy source shape.
4064
+ 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.");
4065
+ }
4066
+ // Explicit type args instead of a cast on the result: `previewInput` would
4067
+ // otherwise pin inference to `Src`, and the two record source shapes no
4068
+ // longer overlap enough for the old assertion.
3652
4069
  return new RecordSchema(this.item, this.opt,
3653
4070
  // Empty by construction: the guard above rejects any that were registered.
3654
- [], this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, true, this.previewInput);
4071
+ [], this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, true,
4072
+ // Null by construction: the guard above rejects any that was declared.
4073
+ null, this.renderInput);
3655
4074
  }
3656
4075
  }, {
3657
4076
  key: "getRouterValidations",
@@ -3705,9 +4124,10 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
3705
4124
  }, {
3706
4125
  key: "executeSerialize",
3707
4126
  value: function executeSerialize() {
3708
- var _this$keySchema, _this$currentRouter, _this$customValidateF;
4127
+ var _this$renderInput, _this$keySchema, _this$currentRouter, _this$customValidateF;
3709
4128
  var result = {
3710
4129
  type: "record",
4130
+ render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
3711
4131
  item: this.item["executeSerialize"](),
3712
4132
  key: (_this$keySchema = this.keySchema) === null || _this$keySchema === void 0 ? void 0 : _this$keySchema["executeSerialize"](),
3713
4133
  opt: this.opt,
@@ -3724,6 +4144,9 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
3724
4144
  result.accept = this.mediaOptions.accept;
3725
4145
  result.directory = this.mediaOptions.directory;
3726
4146
  result.remote = this.mediaOptions.remote;
4147
+ if (this.mediaOptions.encode !== undefined) {
4148
+ result.encode = this.mediaOptions.encode;
4149
+ }
3727
4150
  if (this.mediaOptions.altSchema) {
3728
4151
  result.alt = this.mediaOptions.altSchema["executeSerialize"]();
3729
4152
  }
@@ -3771,8 +4194,10 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
3771
4194
  res[_key2] = itemResult[_key2];
3772
4195
  }
3773
4196
  }
3774
- if (this.previewInput) {
3775
- var prepare = this.previewInput;
4197
+ // The entries preview comes from the ITEM schema's own `preview` — the
4198
+ // container just runs it per entry. Asked as a fact rather than by running
4199
+ // the closure, so an empty record still previews as an empty record.
4200
+ if (this.item["declaresItemPreview"]()) {
3776
4201
  // See the same block in `array`: the whole record when the record is what
3777
4202
  // is being shown, only the wanted entries when it is not.
3778
4203
  var window = scope !== undefined && !scope.wants(sourcePath) ? scope : null;
@@ -3784,6 +4209,9 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
3784
4209
  if (isJson(val)) {
3785
4210
  continue; // as above: nothing to select from an un-loaded entry
3786
4211
  }
4212
+ if (val === null || val === undefined) {
4213
+ continue;
4214
+ }
3787
4215
  if (window !== null && !window.wantsUnder(unsafeCreateSourcePath(sourcePath, _key3))) {
3788
4216
  continue;
3789
4217
  }
@@ -3791,18 +4219,17 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
3791
4219
  // data trips it up must not take out the whole list.
3792
4220
  try {
3793
4221
  // NB NB: display is actually defined by the user
3794
- var _prepare = prepare({
3795
- key: _key3,
3796
- val: val
3797
- }),
3798
- title = _prepare.title,
3799
- subtitle = _prepare.subtitle,
3800
- image = _prepare.image;
3801
- items.push([_key3, {
3802
- title: title,
3803
- subtitle: subtitle,
3804
- image: image
3805
- }]);
4222
+ var _item = this.item["executePreviewItem"](val);
4223
+ if (_item !== null) {
4224
+ var title = _item.title,
4225
+ subtitle = _item.subtitle,
4226
+ image = _item.image;
4227
+ items.push([_key3, {
4228
+ title: title,
4229
+ subtitle: subtitle,
4230
+ image: image
4231
+ }]);
4232
+ }
3806
4233
  } catch (e) {
3807
4234
  res[unsafeCreateSourcePath(sourcePath, _key3)] = {
3808
4235
  status: "error",
@@ -3820,19 +4247,45 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
3820
4247
  }
3821
4248
  return res;
3822
4249
  }
4250
+ }, {
4251
+ key: "executePreviewItem",
4252
+ value: function executePreviewItem(src) {
4253
+ if (this.previewInput === null) {
4254
+ return null;
4255
+ }
4256
+ return this.previewInput({
4257
+ val: src
4258
+ });
4259
+ }
4260
+ }, {
4261
+ key: "declaresItemPreview",
4262
+ value: function declaresItemPreview() {
4263
+ return this.previewInput !== null;
4264
+ }
3823
4265
 
3824
4266
  /**
3825
- * What the editor shows for each ENTRY of this record: a title, and optionally
3826
- * a subtitle and an image.
3827
- *
3828
- * `select` is your own code over the entry's key and source, so it is run on
3829
- * demand for the entries that are actually being looked at — see
3830
- * `PreviewScope`.
4267
+ * How this RECORD ITSELF is shown where a preview of it is needed — when it
4268
+ * is the item of another container, in search, in references. What its
4269
+ * entries show is the ITEM schema's `preview`, not this. Never how the field
4270
+ * is edited (that is `render`). See `preview.ts`.
3831
4271
  */
3832
4272
  }, {
3833
4273
  key: "preview",
3834
4274
  value: function preview(select) {
3835
- return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, select);
4275
+ 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);
4276
+ }
4277
+
4278
+ /**
4279
+ * How this field is laid out in the editor when it is the item of an array
4280
+ * or record: `{ as: "inline" }` renders the field itself inside each row,
4281
+ * instead of a preview row that navigates to it.
4282
+ *
4283
+ * Static configuration, not a callback — see `render.ts`.
4284
+ */
4285
+ }, {
4286
+ key: "render",
4287
+ value: function render(input) {
4288
+ return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.previewInput, input);
3836
4289
  }
3837
4290
  }]);
3838
4291
  }(Schema);
@@ -4401,6 +4854,8 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
4401
4854
  var isReadonly = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
4402
4855
  var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
4403
4856
  var description = arguments.length > 5 ? arguments[5] : undefined;
4857
+ var renderInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
4858
+ var previewInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
4404
4859
  _classCallCheck(this, NumberSchema);
4405
4860
  _this = _callSuper(this, NumberSchema);
4406
4861
  _this.options = options;
@@ -4409,18 +4864,20 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
4409
4864
  _this.isReadonly = isReadonly;
4410
4865
  _this.isHidden = isHidden;
4411
4866
  _this.description = description;
4867
+ _this.renderInput = renderInput;
4868
+ _this.previewInput = previewInput;
4412
4869
  return _this;
4413
4870
  }
4414
4871
  _inherits(NumberSchema, _Schema);
4415
4872
  return _createClass(NumberSchema, [{
4416
4873
  key: "describe",
4417
4874
  value: function describe(description) {
4418
- return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
4875
+ return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput, this.previewInput);
4419
4876
  }
4420
4877
  }, {
4421
4878
  key: "validate",
4422
4879
  value: function validate(validationFunction) {
4423
- return new NumberSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description);
4880
+ return new NumberSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
4424
4881
  }
4425
4882
  }, {
4426
4883
  key: "executeValidate",
@@ -4490,31 +4947,31 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
4490
4947
  }, {
4491
4948
  key: "nullable",
4492
4949
  value: function nullable() {
4493
- return new NumberSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description);
4950
+ return new NumberSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
4494
4951
  }
4495
4952
  }, {
4496
4953
  key: "readonly",
4497
4954
  value: function readonly() {
4498
- return new NumberSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
4955
+ return new NumberSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
4499
4956
  }
4500
4957
  }, {
4501
4958
  key: "hidden",
4502
4959
  value: function hidden() {
4503
- return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
4960
+ return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
4504
4961
  }
4505
4962
  }, {
4506
4963
  key: "max",
4507
4964
  value: function max(_max) {
4508
4965
  return new NumberSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
4509
4966
  max: _max
4510
- }), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
4967
+ }), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
4511
4968
  }
4512
4969
  }, {
4513
4970
  key: "min",
4514
4971
  value: function min(_min) {
4515
4972
  return new NumberSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
4516
4973
  min: _min
4517
- }), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
4974
+ }), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
4518
4975
  }
4519
4976
  }, {
4520
4977
  key: "executeCustomValidateAt",
@@ -4523,12 +4980,53 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
4523
4980
  path: path
4524
4981
  });
4525
4982
  }
4983
+
4984
+ /**
4985
+ * How this field is laid out in the editor when it is the item of an array
4986
+ * or record: `{ as: "inline" }` renders the field itself inside each row,
4987
+ * instead of a preview row that navigates to it.
4988
+ *
4989
+ * Static configuration, not a callback — see `render.ts`.
4990
+ */
4991
+ }, {
4992
+ key: "render",
4993
+ value: function render(input) {
4994
+ return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
4995
+ }
4996
+
4997
+ /**
4998
+ * How this VALUE is shown where a preview of it is needed — a row in a
4999
+ * sortable list, a reference dropdown, a search hit. Never how the field
5000
+ * itself is edited (that is `render`). See `preview.ts`.
5001
+ */
5002
+ }, {
5003
+ key: "preview",
5004
+ value: function preview(select) {
5005
+ return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
5006
+ }
5007
+ }, {
5008
+ key: "executePreviewItem",
5009
+ value: function executePreviewItem(src) {
5010
+ if (this.previewInput === null) {
5011
+ return null;
5012
+ }
5013
+ return this.previewInput({
5014
+ val: src
5015
+ });
5016
+ }
5017
+ }, {
5018
+ key: "declaresItemPreview",
5019
+ value: function declaresItemPreview() {
5020
+ return this.previewInput !== null;
5021
+ }
4526
5022
  }, {
4527
5023
  key: "executeSerialize",
4528
5024
  value: function executeSerialize() {
4529
- var _this$customValidateF;
5025
+ var _this$renderInput, _this$customValidateF;
4530
5026
  return {
4531
5027
  type: "number",
5028
+ render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
5029
+ preview: this.previewInput ? true : undefined,
4532
5030
  options: this.options,
4533
5031
  opt: this.opt,
4534
5032
  customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
@@ -4556,6 +5054,8 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
4556
5054
  var isReadonly = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
4557
5055
  var isHidden = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
4558
5056
  var description = arguments.length > 4 ? arguments[4] : undefined;
5057
+ var renderInput = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
5058
+ var previewInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
4559
5059
  _classCallCheck(this, BooleanSchema);
4560
5060
  _this = _callSuper(this, BooleanSchema);
4561
5061
  _this.opt = opt;
@@ -4563,18 +5063,20 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
4563
5063
  _this.isReadonly = isReadonly;
4564
5064
  _this.isHidden = isHidden;
4565
5065
  _this.description = description;
5066
+ _this.renderInput = renderInput;
5067
+ _this.previewInput = previewInput;
4566
5068
  return _this;
4567
5069
  }
4568
5070
  _inherits(BooleanSchema, _Schema);
4569
5071
  return _createClass(BooleanSchema, [{
4570
5072
  key: "describe",
4571
5073
  value: function describe(description) {
4572
- return new BooleanSchema(this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
5074
+ return new BooleanSchema(this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput, this.previewInput);
4573
5075
  }
4574
5076
  }, {
4575
5077
  key: "validate",
4576
5078
  value: function validate(validationFunction) {
4577
- return new BooleanSchema(this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description);
5079
+ return new BooleanSchema(this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
4578
5080
  }
4579
5081
  }, {
4580
5082
  key: "executeValidate",
@@ -4625,17 +5127,17 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
4625
5127
  }, {
4626
5128
  key: "nullable",
4627
5129
  value: function nullable() {
4628
- return new BooleanSchema(true, [], this.isReadonly, this.isHidden, this.description);
5130
+ return new BooleanSchema(true, [], this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
4629
5131
  }
4630
5132
  }, {
4631
5133
  key: "readonly",
4632
5134
  value: function readonly() {
4633
- return new BooleanSchema(this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
5135
+ return new BooleanSchema(this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
4634
5136
  }
4635
5137
  }, {
4636
5138
  key: "hidden",
4637
5139
  value: function hidden() {
4638
- return new BooleanSchema(this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
5140
+ return new BooleanSchema(this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
4639
5141
  }
4640
5142
  }, {
4641
5143
  key: "executeCustomValidateAt",
@@ -4644,12 +5146,53 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
4644
5146
  path: path
4645
5147
  });
4646
5148
  }
5149
+
5150
+ /**
5151
+ * How this field is laid out in the editor when it is the item of an array
5152
+ * or record: `{ as: "inline" }` renders the field itself inside each row,
5153
+ * instead of a preview row that navigates to it.
5154
+ *
5155
+ * Static configuration, not a callback — see `render.ts`.
5156
+ */
5157
+ }, {
5158
+ key: "render",
5159
+ value: function render(input) {
5160
+ return new BooleanSchema(this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
5161
+ }
5162
+
5163
+ /**
5164
+ * How this VALUE is shown where a preview of it is needed — a row in a
5165
+ * sortable list, a reference dropdown, a search hit. Never how the field
5166
+ * itself is edited (that is `render`). See `preview.ts`.
5167
+ */
5168
+ }, {
5169
+ key: "preview",
5170
+ value: function preview(select) {
5171
+ return new BooleanSchema(this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
5172
+ }
5173
+ }, {
5174
+ key: "executePreviewItem",
5175
+ value: function executePreviewItem(src) {
5176
+ if (this.previewInput === null) {
5177
+ return null;
5178
+ }
5179
+ return this.previewInput({
5180
+ val: src
5181
+ });
5182
+ }
5183
+ }, {
5184
+ key: "declaresItemPreview",
5185
+ value: function declaresItemPreview() {
5186
+ return this.previewInput !== null;
5187
+ }
4647
5188
  }, {
4648
5189
  key: "executeSerialize",
4649
5190
  value: function executeSerialize() {
4650
- var _this$customValidateF;
5191
+ var _this$renderInput, _this$customValidateF;
4651
5192
  return {
4652
5193
  type: "boolean",
5194
+ render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
5195
+ preview: this.previewInput ? true : undefined,
4653
5196
  opt: this.opt,
4654
5197
  customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
4655
5198
  readonly: this.isReadonly,
@@ -4676,6 +5219,8 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
4676
5219
  var isReadonly = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
4677
5220
  var isHidden = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
4678
5221
  var description = arguments.length > 6 ? arguments[6] : undefined;
5222
+ var renderInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
5223
+ var previewInput = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
4679
5224
  _classCallCheck(this, KeyOfSchema);
4680
5225
  _this = _callSuper(this, KeyOfSchema);
4681
5226
  _this.schema = schema;
@@ -4685,18 +5230,20 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
4685
5230
  _this.isReadonly = isReadonly;
4686
5231
  _this.isHidden = isHidden;
4687
5232
  _this.description = description;
5233
+ _this.renderInput = renderInput;
5234
+ _this.previewInput = previewInput;
4688
5235
  return _this;
4689
5236
  }
4690
5237
  _inherits(KeyOfSchema, _Schema);
4691
5238
  return _createClass(KeyOfSchema, [{
4692
5239
  key: "describe",
4693
5240
  value: function describe(description) {
4694
- return new KeyOfSchema(this.schema, this.sourcePath, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
5241
+ return new KeyOfSchema(this.schema, this.sourcePath, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput, this.previewInput);
4695
5242
  }
4696
5243
  }, {
4697
5244
  key: "validate",
4698
5245
  value: function validate(validationFunction) {
4699
- return new KeyOfSchema(this.schema, this.sourcePath, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description);
5246
+ return new KeyOfSchema(this.schema, this.sourcePath, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
4700
5247
  }
4701
5248
  }, {
4702
5249
  key: "executeValidate",
@@ -4826,17 +5373,17 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
4826
5373
  }, {
4827
5374
  key: "nullable",
4828
5375
  value: function nullable() {
4829
- return new KeyOfSchema(this.schema, this.sourcePath, true, [], this.isReadonly, this.isHidden, this.description);
5376
+ return new KeyOfSchema(this.schema, this.sourcePath, true, [], this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
4830
5377
  }
4831
5378
  }, {
4832
5379
  key: "readonly",
4833
5380
  value: function readonly() {
4834
- return new KeyOfSchema(this.schema, this.sourcePath, this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
5381
+ return new KeyOfSchema(this.schema, this.sourcePath, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
4835
5382
  }
4836
5383
  }, {
4837
5384
  key: "hidden",
4838
5385
  value: function hidden() {
4839
- return new KeyOfSchema(this.schema, this.sourcePath, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
5386
+ return new KeyOfSchema(this.schema, this.sourcePath, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
4840
5387
  }
4841
5388
  }, {
4842
5389
  key: "executeCustomValidateAt",
@@ -4845,10 +5392,49 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
4845
5392
  path: path
4846
5393
  });
4847
5394
  }
5395
+
5396
+ /**
5397
+ * How this field is laid out in the editor when it is the item of an array
5398
+ * or record: `{ as: "inline" }` renders the field itself inside each row,
5399
+ * instead of a preview row that navigates to it.
5400
+ *
5401
+ * Static configuration, not a callback — see `render.ts`.
5402
+ */
5403
+ }, {
5404
+ key: "render",
5405
+ value: function render(input) {
5406
+ return new KeyOfSchema(this.schema, this.sourcePath, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
5407
+ }
5408
+
5409
+ /**
5410
+ * How this VALUE is shown where a preview of it is needed — a row in a
5411
+ * sortable list, a reference dropdown, a search hit. Never how the field
5412
+ * itself is edited (that is `render`). See `preview.ts`.
5413
+ */
5414
+ }, {
5415
+ key: "preview",
5416
+ value: function preview(select) {
5417
+ return new KeyOfSchema(this.schema, this.sourcePath, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
5418
+ }
5419
+ }, {
5420
+ key: "executePreviewItem",
5421
+ value: function executePreviewItem(src) {
5422
+ if (this.previewInput === null) {
5423
+ return null;
5424
+ }
5425
+ return this.previewInput({
5426
+ val: src
5427
+ });
5428
+ }
5429
+ }, {
5430
+ key: "declaresItemPreview",
5431
+ value: function declaresItemPreview() {
5432
+ return this.previewInput !== null;
5433
+ }
4848
5434
  }, {
4849
5435
  key: "executeSerialize",
4850
5436
  value: function executeSerialize() {
4851
- var _this$customValidateF;
5437
+ var _this$renderInput, _this$customValidateF;
4852
5438
  var path = this.sourcePath;
4853
5439
  if (!path) {
4854
5440
  throw new Error("Cannot serialize keyOf schema with empty selector. TIP: keyOf must be used with a Val Module of record schema.");
@@ -4871,6 +5457,8 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
4871
5457
  }
4872
5458
  return {
4873
5459
  type: "keyOf",
5460
+ render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
5461
+ preview: this.previewInput ? true : undefined,
4874
5462
  path: path,
4875
5463
  schema: serializedSchema,
4876
5464
  opt: this.opt,
@@ -4922,6 +5510,8 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
4922
5510
  var isReadonly = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
4923
5511
  var isHidden = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
4924
5512
  var description = arguments.length > 7 ? arguments[7] : undefined;
5513
+ var renderInput = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
5514
+ var previewInput = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : null;
4925
5515
  _classCallCheck(this, FileSchema);
4926
5516
  _this = _callSuper(this, FileSchema);
4927
5517
  _this.options = options;
@@ -4932,23 +5522,25 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
4932
5522
  _this.isReadonly = isReadonly;
4933
5523
  _this.isHidden = isHidden;
4934
5524
  _this.description = description;
5525
+ _this.renderInput = renderInput;
5526
+ _this.previewInput = previewInput;
4935
5527
  return _this;
4936
5528
  }
4937
5529
  _inherits(FileSchema, _Schema);
4938
5530
  return _createClass(FileSchema, [{
4939
5531
  key: "describe",
4940
5532
  value: function describe(description) {
4941
- return new FileSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
5533
+ return new FileSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput, this.previewInput);
4942
5534
  }
4943
5535
  }, {
4944
5536
  key: "remote",
4945
5537
  value: function remote() {
4946
- return new FileSchema(this.options, this.opt, true, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description);
5538
+ return new FileSchema(this.options, this.opt, true, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
4947
5539
  }
4948
5540
  }, {
4949
5541
  key: "validate",
4950
5542
  value: function validate(validationFunction) {
4951
- return new FileSchema(this.options, this.opt, this.isRemote, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.moduleMetadata, this.isReadonly, this.isHidden, this.description);
5543
+ return new FileSchema(this.options, this.opt, this.isRemote, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.moduleMetadata, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
4952
5544
  }
4953
5545
  }, {
4954
5546
  key: "executeValidate",
@@ -5129,17 +5721,17 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
5129
5721
  }, {
5130
5722
  key: "nullable",
5131
5723
  value: function nullable() {
5132
- return new FileSchema(this.options, true, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description);
5724
+ return new FileSchema(this.options, true, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
5133
5725
  }
5134
5726
  }, {
5135
5727
  key: "readonly",
5136
5728
  value: function readonly() {
5137
- return new FileSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, true, this.isHidden, this.description);
5729
+ return new FileSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, true, this.isHidden, this.description, this.renderInput, this.previewInput);
5138
5730
  }
5139
5731
  }, {
5140
5732
  key: "hidden",
5141
5733
  value: function hidden() {
5142
- return new FileSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, true, this.description);
5734
+ return new FileSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
5143
5735
  }
5144
5736
  }, {
5145
5737
  key: "executeCustomValidateAt",
@@ -5148,13 +5740,54 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
5148
5740
  path: path
5149
5741
  });
5150
5742
  }
5743
+
5744
+ /**
5745
+ * How this field is laid out in the editor when it is the item of an array
5746
+ * or record: `{ as: "inline" }` renders the field itself inside each row,
5747
+ * instead of a preview row that navigates to it.
5748
+ *
5749
+ * Static configuration, not a callback — see `render.ts`.
5750
+ */
5751
+ }, {
5752
+ key: "render",
5753
+ value: function render(input) {
5754
+ return new FileSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
5755
+ }
5756
+
5757
+ /**
5758
+ * How this VALUE is shown where a preview of it is needed — a row in a
5759
+ * sortable list, a reference dropdown, a search hit. Never how the field
5760
+ * itself is edited (that is `render`). See `preview.ts`.
5761
+ */
5762
+ }, {
5763
+ key: "preview",
5764
+ value: function preview(select) {
5765
+ return new FileSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
5766
+ }
5767
+ }, {
5768
+ key: "executePreviewItem",
5769
+ value: function executePreviewItem(src) {
5770
+ if (this.previewInput === null) {
5771
+ return null;
5772
+ }
5773
+ return this.previewInput({
5774
+ val: src
5775
+ });
5776
+ }
5777
+ }, {
5778
+ key: "declaresItemPreview",
5779
+ value: function declaresItemPreview() {
5780
+ return this.previewInput !== null;
5781
+ }
5151
5782
  }, {
5152
5783
  key: "executeSerialize",
5153
5784
  value: function executeSerialize() {
5154
- var _this$customValidateF;
5785
+ var _this$renderInput, _this$customValidateF;
5155
5786
  var modulePaths = this.moduleMetadata ? Object.keys(this.moduleMetadata) : [];
5156
5787
  return {
5157
5788
  type: "file",
5789
+ render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
5790
+ preview: this.previewInput ? true : undefined,
5158
5791
  options: this.options,
5159
5792
  opt: this.opt,
5160
5793
  remote: this.isRemote,
@@ -5243,6 +5876,8 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
5243
5876
  var isReadonly = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
5244
5877
  var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
5245
5878
  var description = arguments.length > 5 ? arguments[5] : undefined;
5879
+ var renderInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
5880
+ var previewInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
5246
5881
  _classCallCheck(this, DateSchema);
5247
5882
  _this = _callSuper(this, DateSchema);
5248
5883
  _this.options = options;
@@ -5251,18 +5886,20 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
5251
5886
  _this.isReadonly = isReadonly;
5252
5887
  _this.isHidden = isHidden;
5253
5888
  _this.description = description;
5889
+ _this.renderInput = renderInput;
5890
+ _this.previewInput = previewInput;
5254
5891
  return _this;
5255
5892
  }
5256
5893
  _inherits(DateSchema, _Schema);
5257
5894
  return _createClass(DateSchema, [{
5258
5895
  key: "describe",
5259
5896
  value: function describe(description) {
5260
- return new DateSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
5897
+ return new DateSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput, this.previewInput);
5261
5898
  }
5262
5899
  }, {
5263
5900
  key: "validate",
5264
5901
  value: function validate(validationFunction) {
5265
- return new DateSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description);
5902
+ return new DateSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
5266
5903
  }
5267
5904
  }, {
5268
5905
  key: "executeValidate",
@@ -5351,29 +5988,29 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
5351
5988
  value: function from(_from) {
5352
5989
  return new DateSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
5353
5990
  from: _from
5354
- }), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
5991
+ }), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
5355
5992
  }
5356
5993
  }, {
5357
5994
  key: "to",
5358
5995
  value: function to(_to) {
5359
5996
  return new DateSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
5360
5997
  to: _to
5361
- }), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
5998
+ }), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
5362
5999
  }
5363
6000
  }, {
5364
6001
  key: "nullable",
5365
6002
  value: function nullable() {
5366
- return new DateSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description);
6003
+ return new DateSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
5367
6004
  }
5368
6005
  }, {
5369
6006
  key: "readonly",
5370
6007
  value: function readonly() {
5371
- return new DateSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
6008
+ return new DateSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
5372
6009
  }
5373
6010
  }, {
5374
6011
  key: "hidden",
5375
6012
  value: function hidden() {
5376
- return new DateSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
6013
+ return new DateSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
5377
6014
  }
5378
6015
  }, {
5379
6016
  key: "executeCustomValidateAt",
@@ -5382,12 +6019,53 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
5382
6019
  path: path
5383
6020
  });
5384
6021
  }
6022
+
6023
+ /**
6024
+ * How this field is laid out in the editor when it is the item of an array
6025
+ * or record: `{ as: "inline" }` renders the field itself inside each row,
6026
+ * instead of a preview row that navigates to it.
6027
+ *
6028
+ * Static configuration, not a callback — see `render.ts`.
6029
+ */
6030
+ }, {
6031
+ key: "render",
6032
+ value: function render(input) {
6033
+ return new DateSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
6034
+ }
6035
+
6036
+ /**
6037
+ * How this VALUE is shown where a preview of it is needed — a row in a
6038
+ * sortable list, a reference dropdown, a search hit. Never how the field
6039
+ * itself is edited (that is `render`). See `preview.ts`.
6040
+ */
6041
+ }, {
6042
+ key: "preview",
6043
+ value: function preview(select) {
6044
+ return new DateSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
6045
+ }
6046
+ }, {
6047
+ key: "executePreviewItem",
6048
+ value: function executePreviewItem(src) {
6049
+ if (this.previewInput === null) {
6050
+ return null;
6051
+ }
6052
+ return this.previewInput({
6053
+ val: src
6054
+ });
6055
+ }
6056
+ }, {
6057
+ key: "declaresItemPreview",
6058
+ value: function declaresItemPreview() {
6059
+ return this.previewInput !== null;
6060
+ }
5385
6061
  }, {
5386
6062
  key: "executeSerialize",
5387
6063
  value: function executeSerialize() {
5388
- var _this$customValidateF;
6064
+ var _this$renderInput, _this$customValidateF;
5389
6065
  return {
5390
6066
  type: "date",
6067
+ render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
6068
+ preview: this.previewInput ? true : undefined,
5391
6069
  opt: this.opt,
5392
6070
  options: this.options,
5393
6071
  customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
@@ -5415,6 +6093,8 @@ var DateTimeSchema = /*#__PURE__*/function (_Schema) {
5415
6093
  var isReadonly = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
5416
6094
  var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
5417
6095
  var description = arguments.length > 5 ? arguments[5] : undefined;
6096
+ var renderInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
6097
+ var previewInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
5418
6098
  _classCallCheck(this, DateTimeSchema);
5419
6099
  _this = _callSuper(this, DateTimeSchema);
5420
6100
  _this.options = options;
@@ -5423,18 +6103,20 @@ var DateTimeSchema = /*#__PURE__*/function (_Schema) {
5423
6103
  _this.isReadonly = isReadonly;
5424
6104
  _this.isHidden = isHidden;
5425
6105
  _this.description = description;
6106
+ _this.renderInput = renderInput;
6107
+ _this.previewInput = previewInput;
5426
6108
  return _this;
5427
6109
  }
5428
6110
  _inherits(DateTimeSchema, _Schema);
5429
6111
  return _createClass(DateTimeSchema, [{
5430
6112
  key: "describe",
5431
6113
  value: function describe(description) {
5432
- return new DateTimeSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
6114
+ return new DateTimeSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput, this.previewInput);
5433
6115
  }
5434
6116
  }, {
5435
6117
  key: "validate",
5436
6118
  value: function validate(validationFunction) {
5437
- return new DateTimeSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description);
6119
+ return new DateTimeSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
5438
6120
  }
5439
6121
  }, {
5440
6122
  key: "executeValidate",
@@ -5555,29 +6237,29 @@ var DateTimeSchema = /*#__PURE__*/function (_Schema) {
5555
6237
  value: function from(_from) {
5556
6238
  return new DateTimeSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
5557
6239
  from: _from
5558
- }), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
6240
+ }), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
5559
6241
  }
5560
6242
  }, {
5561
6243
  key: "to",
5562
6244
  value: function to(_to) {
5563
6245
  return new DateTimeSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
5564
6246
  to: _to
5565
- }), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
6247
+ }), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
5566
6248
  }
5567
6249
  }, {
5568
6250
  key: "nullable",
5569
6251
  value: function nullable() {
5570
- return new DateTimeSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description);
6252
+ return new DateTimeSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
5571
6253
  }
5572
6254
  }, {
5573
6255
  key: "readonly",
5574
6256
  value: function readonly() {
5575
- return new DateTimeSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
6257
+ return new DateTimeSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
5576
6258
  }
5577
6259
  }, {
5578
6260
  key: "hidden",
5579
6261
  value: function hidden() {
5580
- return new DateTimeSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
6262
+ return new DateTimeSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
5581
6263
  }
5582
6264
  }, {
5583
6265
  key: "executeCustomValidateAt",
@@ -5586,12 +6268,53 @@ var DateTimeSchema = /*#__PURE__*/function (_Schema) {
5586
6268
  path: path
5587
6269
  });
5588
6270
  }
6271
+
6272
+ /**
6273
+ * How this field is laid out in the editor when it is the item of an array
6274
+ * or record: `{ as: "inline" }` renders the field itself inside each row,
6275
+ * instead of a preview row that navigates to it.
6276
+ *
6277
+ * Static configuration, not a callback — see `render.ts`.
6278
+ */
6279
+ }, {
6280
+ key: "render",
6281
+ value: function render(input) {
6282
+ return new DateTimeSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
6283
+ }
6284
+
6285
+ /**
6286
+ * How this VALUE is shown where a preview of it is needed — a row in a
6287
+ * sortable list, a reference dropdown, a search hit. Never how the field
6288
+ * itself is edited (that is `render`). See `preview.ts`.
6289
+ */
6290
+ }, {
6291
+ key: "preview",
6292
+ value: function preview(select) {
6293
+ return new DateTimeSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
6294
+ }
6295
+ }, {
6296
+ key: "executePreviewItem",
6297
+ value: function executePreviewItem(src) {
6298
+ if (this.previewInput === null) {
6299
+ return null;
6300
+ }
6301
+ return this.previewInput({
6302
+ val: src
6303
+ });
6304
+ }
6305
+ }, {
6306
+ key: "declaresItemPreview",
6307
+ value: function declaresItemPreview() {
6308
+ return this.previewInput !== null;
6309
+ }
5589
6310
  }, {
5590
6311
  key: "executeSerialize",
5591
6312
  value: function executeSerialize() {
5592
- var _this$customValidateF;
6313
+ var _this$renderInput, _this$customValidateF;
5593
6314
  return {
5594
6315
  type: "dateTime",
6316
+ render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
6317
+ preview: this.previewInput ? true : undefined,
5595
6318
  opt: this.opt,
5596
6319
  options: this.options,
5597
6320
  customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
@@ -6099,6 +6822,8 @@ var ColorSchema = /*#__PURE__*/function (_Schema) {
6099
6822
  var isReadonly = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
6100
6823
  var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
6101
6824
  var description = arguments.length > 5 ? arguments[5] : undefined;
6825
+ var renderInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
6826
+ var previewInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
6102
6827
  _classCallCheck(this, ColorSchema);
6103
6828
  _this = _callSuper(this, ColorSchema);
6104
6829
  _this.options = options;
@@ -6107,18 +6832,20 @@ var ColorSchema = /*#__PURE__*/function (_Schema) {
6107
6832
  _this.isReadonly = isReadonly;
6108
6833
  _this.isHidden = isHidden;
6109
6834
  _this.description = description;
6835
+ _this.renderInput = renderInput;
6836
+ _this.previewInput = previewInput;
6110
6837
  return _this;
6111
6838
  }
6112
6839
  _inherits(ColorSchema, _Schema);
6113
6840
  return _createClass(ColorSchema, [{
6114
6841
  key: "describe",
6115
6842
  value: function describe(description) {
6116
- return new ColorSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
6843
+ return new ColorSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput, this.previewInput);
6117
6844
  }
6118
6845
  }, {
6119
6846
  key: "validate",
6120
6847
  value: function validate(validationFunction) {
6121
- return new ColorSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description);
6848
+ return new ColorSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
6122
6849
  }
6123
6850
  }, {
6124
6851
  key: "executeCustomValidateAt",
@@ -6215,24 +6942,65 @@ var ColorSchema = /*#__PURE__*/function (_Schema) {
6215
6942
  }, {
6216
6943
  key: "nullable",
6217
6944
  value: function nullable() {
6218
- return new ColorSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description);
6945
+ return new ColorSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
6219
6946
  }
6220
6947
  }, {
6221
6948
  key: "readonly",
6222
6949
  value: function readonly() {
6223
- return new ColorSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
6950
+ return new ColorSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
6224
6951
  }
6225
6952
  }, {
6226
6953
  key: "hidden",
6227
6954
  value: function hidden() {
6228
- return new ColorSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
6955
+ return new ColorSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
6956
+ }
6957
+
6958
+ /**
6959
+ * How this field is laid out in the editor when it is the item of an array
6960
+ * or record: `{ as: "inline" }` renders the field itself inside each row,
6961
+ * instead of a preview row that navigates to it.
6962
+ *
6963
+ * Static configuration, not a callback — see `render.ts`.
6964
+ */
6965
+ }, {
6966
+ key: "render",
6967
+ value: function render(input) {
6968
+ return new ColorSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
6969
+ }
6970
+
6971
+ /**
6972
+ * How this VALUE is shown where a preview of it is needed — a row in a
6973
+ * sortable list, a reference dropdown, a search hit. Never how the field
6974
+ * itself is edited (that is `render`). See `preview.ts`.
6975
+ */
6976
+ }, {
6977
+ key: "preview",
6978
+ value: function preview(select) {
6979
+ return new ColorSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
6980
+ }
6981
+ }, {
6982
+ key: "executePreviewItem",
6983
+ value: function executePreviewItem(src) {
6984
+ if (this.previewInput === null) {
6985
+ return null;
6986
+ }
6987
+ return this.previewInput({
6988
+ val: src
6989
+ });
6990
+ }
6991
+ }, {
6992
+ key: "declaresItemPreview",
6993
+ value: function declaresItemPreview() {
6994
+ return this.previewInput !== null;
6229
6995
  }
6230
6996
  }, {
6231
6997
  key: "executeSerialize",
6232
6998
  value: function executeSerialize() {
6233
- var _this$customValidateF;
6999
+ var _this$renderInput, _this$customValidateF;
6234
7000
  return {
6235
7001
  type: "color",
7002
+ render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
7003
+ preview: this.previewInput ? true : undefined,
6236
7004
  opt: this.opt,
6237
7005
  options: this.options,
6238
7006
  customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
@@ -6312,7 +7080,8 @@ var images = function images(options) {
6312
7080
  accept: (_options$accept = options.accept) !== null && _options$accept !== void 0 ? _options$accept : "image/*",
6313
7081
  directory: directory,
6314
7082
  remote: (_options$remote = options.remote) !== null && _options$remote !== void 0 ? _options$remote : false,
6315
- altSchema: altSchema
7083
+ altSchema: altSchema,
7084
+ encode: options.encode
6316
7085
  });
6317
7086
  };
6318
7087
 
@@ -8055,10 +8824,16 @@ function createRemoteRef(remoteHost, _ref) {
8055
8824
  */
8056
8825
  function getValidationBasis(coreVersion, schema, fileExt, metadata, fileHash) {
8057
8826
  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);
8827
+ var options = _objectSpread2({}, schema.options);
8828
+ // Ignore options that do not affect the validation basis below:
8829
+ // `encode` says how the bytes were PRODUCED in the browser, not whether the
8830
+ // bytes that arrived are valid. Leaving it in would mean that changing a
8831
+ // quality setting re-validates every remote file in the project.
8832
+ delete options.encode;
8058
8833
  var schemaValidationBasis = {
8059
8834
  type: schema.type,
8060
8835
  opt: schema.opt,
8061
- options: _objectSpread2({}, schema.options)
8836
+ options: options
8062
8837
  };
8063
8838
  return coreVersion + JSON.stringify(schemaValidationBasis) + fileExt + metadataValidationBasis + fileHash;
8064
8839
  }
@@ -8085,7 +8860,7 @@ function deserializeSchema(serialized) {
8085
8860
  return schema;
8086
8861
  }
8087
8862
  function deserializeSchemaImpl(serialized) {
8088
- var _serialized$options, _serialized$options2, _serialized$render, _serialized$accept, _serialized$directory, _serialized$remote, _serialized$jsonValue;
8863
+ var _serialized$options, _serialized$options2, _serialized$render, _serialized$render2, _serialized$render3, _serialized$render4, _serialized$render5, _serialized$render6, _serialized$render7, _serialized$accept, _serialized$directory, _serialized$remote, _serialized$jsonValue, _serialized$render9, _serialized$render0, _serialized$render10, _serialized$render11, _serialized$render12, _serialized$render13, _serialized$render14;
8089
8864
  switch (serialized.type) {
8090
8865
  case "string":
8091
8866
  return new StringSchema(_objectSpread2(_objectSpread2({}, serialized.options), {}, {
@@ -8096,20 +8871,22 @@ function deserializeSchemaImpl(serialized) {
8096
8871
  // recomputed from an instance.
8097
8872
  (_serialized$render = serialized.render) !== null && _serialized$render !== void 0 ? _serialized$render : null, false, false, serialized.description);
8098
8873
  case "literal":
8099
- return new LiteralSchema(serialized.value, serialized.opt, [], false, false, serialized.description);
8874
+ return new LiteralSchema(serialized.value, serialized.opt, [], false, false, serialized.description, (_serialized$render2 = serialized.render) !== null && _serialized$render2 !== void 0 ? _serialized$render2 : null);
8100
8875
  case "boolean":
8101
- return new BooleanSchema(serialized.opt, [], false, false, serialized.description);
8876
+ return new BooleanSchema(serialized.opt, [], false, false, serialized.description, (_serialized$render3 = serialized.render) !== null && _serialized$render3 !== void 0 ? _serialized$render3 : null);
8102
8877
  case "number":
8103
- return new NumberSchema(serialized.options, serialized.opt, [], false, false, serialized.description);
8878
+ return new NumberSchema(serialized.options, serialized.opt, [], false, false, serialized.description, (_serialized$render4 = serialized.render) !== null && _serialized$render4 !== void 0 ? _serialized$render4 : null);
8104
8879
  case "object":
8105
8880
  return new ObjectSchema(Object.fromEntries(Object.entries(serialized.items).map(function (_ref) {
8106
8881
  var _ref2 = _slicedToArray(_ref, 2),
8107
8882
  key = _ref2[0],
8108
8883
  item = _ref2[1];
8109
8884
  return [key, deserializeSchema(item)];
8110
- })), serialized.opt, [], false, false, serialized.description);
8885
+ })), serialized.opt, [], false, false, serialized.description, (_serialized$render5 = serialized.render) !== null && _serialized$render5 !== void 0 ? _serialized$render5 : null);
8111
8886
  case "array":
8112
- return new ArraySchema(deserializeSchema(serialized.item), serialized.opt, [], false, false, serialized.description);
8887
+ return new ArraySchema(deserializeSchema(serialized.item), serialized.opt, [], false, false, serialized.description,
8888
+ // The preview closure cannot survive serialization; the render can.
8889
+ null, (_serialized$render6 = serialized.render) !== null && _serialized$render6 !== void 0 ? _serialized$render6 : null);
8113
8890
  case "union":
8114
8891
  return new UnionSchema(typeof serialized.key === "string" ? serialized.key :
8115
8892
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -8118,17 +8895,17 @@ function deserializeSchemaImpl(serialized) {
8118
8895
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
8119
8896
  serialized.items.map(deserializeSchema),
8120
8897
  // TODO: we do not really need any here - right?
8121
- serialized.opt, [], false, false, serialized.description);
8898
+ serialized.opt, [], false, false, serialized.description, (_serialized$render7 = serialized.render) !== null && _serialized$render7 !== void 0 ? _serialized$render7 : null);
8122
8899
  case "richtext":
8123
8900
  {
8124
- var _serialized$options3, _serialized$options4, _serialized$options5, _serialized$options6, _serialized$options7, _serialized$options8, _serialized$options9;
8901
+ var _serialized$options3, _serialized$options4, _serialized$options5, _serialized$options6, _serialized$options7, _serialized$options8, _serialized$options9, _serialized$render8;
8125
8902
  var deserializedOptions = _objectSpread2(_objectSpread2({}, serialized.options || {}), {}, {
8126
8903
  inline: _typeof((_serialized$options3 = serialized.options) === null || _serialized$options3 === void 0 || (_serialized$options3 = _serialized$options3.inline) === null || _serialized$options3 === void 0 ? void 0 : _serialized$options3.img) === "object" || _typeof((_serialized$options4 = serialized.options) === null || _serialized$options4 === void 0 || (_serialized$options4 = _serialized$options4.inline) === null || _serialized$options4 === void 0 ? void 0 : _serialized$options4.a) === "object" ? {
8127
8904
  a: _typeof((_serialized$options5 = serialized.options) === null || _serialized$options5 === void 0 || (_serialized$options5 = _serialized$options5.inline) === null || _serialized$options5 === void 0 ? void 0 : _serialized$options5.a) === "object" ? deserializeSchema(serialized.options.inline.a) : (_serialized$options6 = serialized.options) === null || _serialized$options6 === void 0 || (_serialized$options6 = _serialized$options6.inline) === null || _serialized$options6 === void 0 ? void 0 : _serialized$options6.a,
8128
8905
  img: _typeof((_serialized$options7 = serialized.options) === null || _serialized$options7 === void 0 || (_serialized$options7 = _serialized$options7.inline) === null || _serialized$options7 === void 0 ? void 0 : _serialized$options7.img) === "object" ? deserializeSchema(serialized.options.inline.img) : (_serialized$options8 = serialized.options) === null || _serialized$options8 === void 0 || (_serialized$options8 = _serialized$options8.inline) === null || _serialized$options8 === void 0 ? void 0 : _serialized$options8.img
8129
8906
  } : (_serialized$options9 = serialized.options) === null || _serialized$options9 === void 0 ? void 0 : _serialized$options9.inline
8130
8907
  });
8131
- return new RichTextSchema(deserializedOptions, serialized.opt, [], false, false, serialized.description);
8908
+ return new RichTextSchema(deserializedOptions, serialized.opt, [], false, false, serialized.description, (_serialized$render8 = serialized.render) !== null && _serialized$render8 !== void 0 ? _serialized$render8 : null);
8132
8909
  }
8133
8910
  case "record":
8134
8911
  return new RecordSchema(deserializeSchema(serialized.item), serialized.opt, [], null, serialized.key ? deserializeSchema(serialized.key) : null, serialized.mediaType ? {
@@ -8137,27 +8914,30 @@ function deserializeSchemaImpl(serialized) {
8137
8914
  directory: (_serialized$directory = serialized.directory) !== null && _serialized$directory !== void 0 ? _serialized$directory : "/public/val",
8138
8915
  remote: (_serialized$remote = serialized.remote) !== null && _serialized$remote !== void 0 ? _serialized$remote : false,
8139
8916
  altSchema: serialized.alt ? deserializeSchema(serialized.alt) : undefined
8140
- } : undefined, false, false, serialized.description, (_serialized$jsonValue = serialized.jsonValues) !== null && _serialized$jsonValue !== void 0 ? _serialized$jsonValue : false);
8917
+ } : undefined, false, false, serialized.description, (_serialized$jsonValue = serialized.jsonValues) !== null && _serialized$jsonValue !== void 0 ? _serialized$jsonValue : false,
8918
+ // The preview closure cannot survive serialization; the render can.
8919
+ null, (_serialized$render9 = serialized.render) !== null && _serialized$render9 !== void 0 ? _serialized$render9 : null);
8141
8920
  case "keyOf":
8142
- return new KeyOfSchema(serialized.schema, serialized.path, serialized.opt, [], false, false, serialized.description);
8921
+ return new KeyOfSchema(serialized.schema, serialized.path, serialized.opt, [], false, false, serialized.description, (_serialized$render0 = serialized.render) !== null && _serialized$render0 !== void 0 ? _serialized$render0 : null);
8143
8922
  case "route":
8144
8923
  {
8924
+ var _serialized$render1;
8145
8925
  var routeOptions = serialized.options ? {
8146
8926
  include: serialized.options.include ? new RegExp(serialized.options.include.source, serialized.options.include.flags) : undefined,
8147
8927
  exclude: serialized.options.exclude ? new RegExp(serialized.options.exclude.source, serialized.options.exclude.flags) : undefined
8148
8928
  } : undefined;
8149
- return new RouteSchema(routeOptions, serialized.opt, [], false, false, serialized.description);
8929
+ return new RouteSchema(routeOptions, serialized.opt, [], false, false, serialized.description, (_serialized$render1 = serialized.render) !== null && _serialized$render1 !== void 0 ? _serialized$render1 : null);
8150
8930
  }
8151
8931
  case "file":
8152
- return new FileSchema(serialized.options, serialized.opt, serialized.remote, [], {}, false, false, serialized.description);
8932
+ return new FileSchema(serialized.options, serialized.opt, serialized.remote, [], {}, false, false, serialized.description, (_serialized$render10 = serialized.render) !== null && _serialized$render10 !== void 0 ? _serialized$render10 : null);
8153
8933
  case "image":
8154
- return new ImageSchema(serialized.options, serialized.opt, serialized.remote, [], {}, false, false, serialized.description);
8934
+ return new ImageSchema(serialized.options, serialized.opt, serialized.remote, [], {}, false, false, serialized.description, (_serialized$render11 = serialized.render) !== null && _serialized$render11 !== void 0 ? _serialized$render11 : null);
8155
8935
  case "date":
8156
- return new DateSchema(serialized.options, serialized.opt, [], false, false, serialized.description);
8936
+ return new DateSchema(serialized.options, serialized.opt, [], false, false, serialized.description, (_serialized$render12 = serialized.render) !== null && _serialized$render12 !== void 0 ? _serialized$render12 : null);
8157
8937
  case "dateTime":
8158
- return new DateTimeSchema(serialized.options, serialized.opt, [], false, false, serialized.description);
8938
+ return new DateTimeSchema(serialized.options, serialized.opt, [], false, false, serialized.description, (_serialized$render13 = serialized.render) !== null && _serialized$render13 !== void 0 ? _serialized$render13 : null);
8159
8939
  case "color":
8160
- return new ColorSchema(serialized.options, serialized.opt, [], false, false, serialized.description);
8940
+ return new ColorSchema(serialized.options, serialized.opt, [], false, false, serialized.description, (_serialized$render14 = serialized.render) !== null && _serialized$render14 !== void 0 ? _serialized$render14 : null);
8161
8941
  default:
8162
8942
  {
8163
8943
  var exhaustiveCheck = serialized;
@@ -8172,8 +8952,29 @@ function deserializeSchemaImpl(serialized) {
8172
8952
  }
8173
8953
 
8174
8954
  /**
8175
- * What a container shows for ONE of its items: the user's `preview` callback
8176
- * returns this, and the Studio draws a row from it.
8955
+ * A PREVIEW is how a VALUE is shown wherever a preview of it is needed — a row
8956
+ * in a sortable list, a key in a reference dropdown, a search hit, a
8957
+ * reference — which is everywhere the value is NAVIGABLE to rather than open.
8958
+ * It is never how the field itself is edited: that is a RENDER (`render.ts`),
8959
+ * which applies only when you are looking at the field. The two do not
8960
+ * intersect — a schema can carry both, and each is read in its own places.
8961
+ *
8962
+ * A preview is declared on the schema of the VALUE being previewed:
8963
+ *
8964
+ * ```ts
8965
+ * const author = s.object({ name: s.string() })
8966
+ * .preview(({ val }) => ({ title: val.name }));
8967
+ * const authors = s.array(author);
8968
+ * ```
8969
+ *
8970
+ * The container reifies its rows by running each ITEM's preview closure — see
8971
+ * {@link ArrayPreview} / {@link RecordPreview}. (Previews used to be declared
8972
+ * on the container instead; a `.preview` on an array/record now previews the
8973
+ * array/record itself as a value, for when IT is the item of something.)
8974
+ */
8975
+ /**
8976
+ * What a preview shows for one value: the user's `preview` callback returns
8977
+ * this, and the Studio draws a row from it.
8177
8978
  *
8178
8979
  * NB: {@link ArrayPreview} / {@link RecordPreview} name the DATA a container
8179
8980
  * previews with. The Studio also has React components called `ArrayPreview` /
@@ -8183,6 +8984,19 @@ function deserializeSchemaImpl(serialized) {
8183
8984
  * at the import rather than renaming that convention.
8184
8985
  */
8185
8986
 
8987
+ /**
8988
+ * What `.preview(...)` takes, on every schema: the value's own source in, a
8989
+ * {@link PreviewItem} out. `NonNullable` because a container skips null items
8990
+ * rather than previewing them.
8991
+ *
8992
+ * Declared through method syntax deliberately (the same bivariance shape
8993
+ * React's event handler types use): `nullable()` copies a schema's closure
8994
+ * into the `Src | null` variant of the same class, and with a plain function
8995
+ * type the checker cannot see that `NonNullable<Src | null>` IS
8996
+ * `NonNullable<Src>` while `Src` is still a type parameter — every schema's
8997
+ * `nullable()` would need a cast instead.
8998
+ */
8999
+
8186
9000
  /**
8187
9001
  * Main preview type.
8188
9002
  *
@@ -8275,11 +9089,21 @@ function previewScope(paths) {
8275
9089
  // TODO: improve this so that we do not get RawString and string, only string. Are there other things?
8276
9090
 
8277
9091
  /**
8278
- * A RENDER is how one field is laid out in the editor: `s.string().render({ as:
8279
- * "textarea" })`, `.render({ as: "code", language })`.
9092
+ * A RENDER is how the FIELD ITSELF is laid out in the editor, and it applies
9093
+ * only when you are looking at the field: `s.string().render({ as: "textarea"
9094
+ * })`, `.render({ as: "code", language })`, `.render({ as: "inline" })` on an
9095
+ * array/record item.
8280
9096
  *
8281
- * It is static configuration - plain data, with no closure behind it and no
8282
- * dependency on source - which is why it lives in the SERIALIZED schema
9097
+ * A PREVIEW (`preview.ts`) is the other thing: how the VALUE is shown wherever
9098
+ * a preview of it is needed — a list row, a reference dropdown, a search hit —
9099
+ * that is, wherever the value is navigable to rather than open. The two never
9100
+ * intersect: a schema can carry both, a `render` is read where the field is
9101
+ * edited and a `preview` where the value is previewed. A second `.render(...)`
9102
+ * on the same schema REPLACES the first (last one wins), exactly like a second
9103
+ * `.preview(...)` replaces the first — they do not merge.
9104
+ *
9105
+ * A render is static configuration - plain data, with no closure behind it and
9106
+ * no dependency on source - which is why it lives in the SERIALIZED schema
8283
9107
  * (`SerializedStringSchema.render`) and is read straight off it where the field
8284
9108
  * is drawn. There is no render pipeline, no store and no host round-trip.
8285
9109
  *
@@ -8289,9 +9113,6 @@ function previewScope(paths) {
8289
9113
  * the shape it needs back is `executePreview`'s, and the honest move is to give
8290
9114
  * `render` its own execute/store pair again. It is NOT to re-merge the two:
8291
9115
  * conflating them is what this file was split up to undo.
8292
- *
8293
- * The dynamic, source-dependent, demand-scoped thing - what a container shows
8294
- * for its items - is a PREVIEW. See `preview.ts`.
8295
9116
  */
8296
9117
  /**
8297
9118
  * The list is the declaration and {@link CodeLanguage} is derived from it, so
@@ -8300,10 +9121,68 @@ function previewScope(paths) {
8300
9121
  */
8301
9122
  var CODE_LANGUAGES = ["typescript", "javascript", "javascriptreact", "typescriptreact", "json", "java", "html", "css", "xml", "markdown", "sql", "python", "rust", "php", "go", "cpp", "sass", "vue", "angular"];
8302
9123
 
9124
+ /**
9125
+ * `{ as: "inline" }` on a field that is the ITEM of an array or record: the
9126
+ * container renders the field itself inside each (sortable) row, instead of a
9127
+ * clickable preview row that navigates to it. This is what a page-builder list
9128
+ * is made of: `s.array(s.object({...}).render({ as: "inline" }))`.
9129
+ *
9130
+ * On a field that is not directly under an array or record it is inert — an
9131
+ * object's fields are already laid out in place.
9132
+ *
9133
+ * Like every render it is static configuration (see the top of this file): it
9134
+ * travels whole in the serialized schema and the editor reads it straight off
9135
+ * the item schema it already has.
9136
+ */
9137
+
9138
+ /**
9139
+ * What `.render(...)` takes on every field except `s.string()`, and what the
9140
+ * serialized schema carries verbatim.
9141
+ */
9142
+
8303
9143
  /**
8304
9144
  * What `s.string().render(...)` takes, and what the serialized schema carries
8305
- * verbatim.
9145
+ * verbatim. A string has editor layouts of its own (textarea, code) in
9146
+ * addition to the container-facing `inline`.
9147
+ */
9148
+
9149
+ /**
9150
+ * Is this item schema edited INSIDE its list row, rather than behind a
9151
+ * clickable preview row that navigates to it?
9152
+ *
9153
+ * The one answer, so that the list rows, the nav-stop rule (`getNavPath`) and
9154
+ * the add buttons cannot drift apart — they are three readings of the same
9155
+ * question, and a disagreement between them is a row you can edit in place but
9156
+ * that "add" navigates away from.
9157
+ *
9158
+ * A tagged union counts as inline when the union itself declares it OR when
9159
+ * ANY of its variants does. A page-builder list is `s.array(s.union("type",
9160
+ * block, block, ...))` and the natural place to write the render is on the
9161
+ * blocks, one per block type — the union is a dispatch, not something the
9162
+ * author thinks of as the field. `some` rather than `every` because the row
9163
+ * draws the union's own editor (the tag selector plus the matched variant's
9164
+ * fields), which handles every variant either way: with `every`, adding one
9165
+ * variant and forgetting its `.render` would silently turn the whole list back
9166
+ * into preview rows.
9167
+ *
9168
+ * This is the ONLY place a render is allowed to be read from anywhere but the
9169
+ * schema it was declared on. It stays static (see the top of this file): the
9170
+ * answer is a function of the serialized schema alone, never of the value the
9171
+ * row happens to hold.
8306
9172
  */
9173
+ function isInlineRender(schema) {
9174
+ var _schema$render;
9175
+ if (((_schema$render = schema.render) === null || _schema$render === void 0 ? void 0 : _schema$render.as) === "inline") {
9176
+ return true;
9177
+ }
9178
+ if (schema.type === "union") {
9179
+ return schema.items.some(function (item) {
9180
+ var _item$render;
9181
+ return ((_item$render = item.render) === null || _item$render === void 0 ? void 0 : _item$render.as) === "inline";
9182
+ });
9183
+ }
9184
+ return false;
9185
+ }
8307
9186
 
8308
9187
  var externalPageRouter = {
8309
9188
  getRouterId: function getRouterId() {
@@ -8710,6 +9589,7 @@ exports.extractValModules = extractValModules;
8710
9589
  exports.getSourcePathFromRoute = getSourcePathFromRoute;
8711
9590
  exports.hasRemoteFileSchema = hasRemoteFileSchema;
8712
9591
  exports.initVal = initVal;
9592
+ exports.isInlineRender = isInlineRender;
8713
9593
  exports.modules = modules;
8714
9594
  exports.previewScope = previewScope;
8715
9595
  exports.splitModuleFilePathAndModulePath = splitModuleFilePathAndModulePath;