@valbuild/core 0.110.0 → 0.111.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/declarations/src/index.d.ts +2 -1
- package/dist/declarations/src/initSchema.d.ts +19 -0
- package/dist/declarations/src/render.d.ts +8 -22
- package/dist/declarations/src/schema/code.d.ts +85 -0
- package/dist/declarations/src/schema/index.d.ts +2 -1
- package/dist/declarations/src/schema/string.d.ts +31 -6
- package/dist/{index-409a38c3.cjs.dev.js → index-9f6baa46.cjs.dev.js} +228 -33
- package/dist/{index-6652ab3c.esm.js → index-af98fc7c.esm.js} +228 -34
- package/dist/{index-62ef4533.cjs.prod.js → index-f1992b0f.cjs.prod.js} +228 -33
- package/dist/valbuild-core.cjs.dev.js +2 -1
- package/dist/valbuild-core.cjs.prod.js +2 -1
- package/dist/valbuild-core.esm.js +1 -1
- package/package.json +1 -1
- package/patch/dist/valbuild-core-patch.cjs.dev.js +1 -1
- package/patch/dist/valbuild-core-patch.cjs.prod.js +1 -1
- package/patch/dist/valbuild-core-patch.esm.js +2 -2
|
@@ -449,6 +449,7 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
|
449
449
|
var isHidden = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
450
450
|
var description = arguments.length > 7 ? arguments[7] : undefined;
|
|
451
451
|
var previewInput = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
|
|
452
|
+
var isMultiline = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : false;
|
|
452
453
|
_classCallCheck(this, StringSchema);
|
|
453
454
|
_this = _callSuper(this, StringSchema);
|
|
454
455
|
_this.options = options;
|
|
@@ -460,13 +461,14 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
|
460
461
|
_this.isHidden = isHidden;
|
|
461
462
|
_this.description = description;
|
|
462
463
|
_this.previewInput = previewInput;
|
|
464
|
+
_this.isMultiline = isMultiline;
|
|
463
465
|
return _this;
|
|
464
466
|
}
|
|
465
467
|
_inherits(StringSchema, _Schema);
|
|
466
468
|
return _createClass(StringSchema, [{
|
|
467
469
|
key: "describe",
|
|
468
470
|
value: function describe(description) {
|
|
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);
|
|
471
|
+
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, this.isMultiline);
|
|
470
472
|
}
|
|
471
473
|
|
|
472
474
|
/**
|
|
@@ -482,7 +484,7 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
|
482
484
|
value: function minLength(_minLength) {
|
|
483
485
|
return new StringSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
484
486
|
minLength: _minLength
|
|
485
|
-
}), this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description, this.previewInput);
|
|
487
|
+
}), this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description, this.previewInput, this.isMultiline);
|
|
486
488
|
}
|
|
487
489
|
|
|
488
490
|
/**
|
|
@@ -498,7 +500,7 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
|
498
500
|
value: function maxLength(_maxLength) {
|
|
499
501
|
return new StringSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
500
502
|
maxLength: _maxLength
|
|
501
|
-
}), this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description, this.previewInput);
|
|
503
|
+
}), this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description, this.previewInput, this.isMultiline);
|
|
502
504
|
}
|
|
503
505
|
}, {
|
|
504
506
|
key: "regexp",
|
|
@@ -506,12 +508,12 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
|
506
508
|
return new StringSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
507
509
|
regexp: _regexp,
|
|
508
510
|
regExpMessage: message
|
|
509
|
-
}), this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description, this.previewInput);
|
|
511
|
+
}), this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description, this.previewInput, this.isMultiline);
|
|
510
512
|
}
|
|
511
513
|
}, {
|
|
512
514
|
key: "validate",
|
|
513
515
|
value: function validate(validationFunction) {
|
|
514
|
-
return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions.concat(validationFunction), this.renderInput, this.isReadonly, this.isHidden, this.description, this.previewInput);
|
|
516
|
+
return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions.concat(validationFunction), this.renderInput, this.isReadonly, this.isHidden, this.description, this.previewInput, this.isMultiline);
|
|
515
517
|
}
|
|
516
518
|
}, {
|
|
517
519
|
key: "executeValidate",
|
|
@@ -584,22 +586,22 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
|
584
586
|
}, {
|
|
585
587
|
key: "nullable",
|
|
586
588
|
value: function nullable() {
|
|
587
|
-
return new StringSchema(this.options, true, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description, this.previewInput);
|
|
589
|
+
return new StringSchema(this.options, true, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description, this.previewInput, this.isMultiline);
|
|
588
590
|
}
|
|
589
591
|
}, {
|
|
590
592
|
key: "readonly",
|
|
591
593
|
value: function readonly() {
|
|
592
|
-
return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, true, this.isHidden, this.description, this.previewInput);
|
|
594
|
+
return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, true, this.isHidden, this.description, this.previewInput, this.isMultiline);
|
|
593
595
|
}
|
|
594
596
|
}, {
|
|
595
597
|
key: "hidden",
|
|
596
598
|
value: function hidden() {
|
|
597
|
-
return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, true, this.description, this.previewInput);
|
|
599
|
+
return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, true, this.description, this.previewInput, this.isMultiline);
|
|
598
600
|
}
|
|
599
601
|
}, {
|
|
600
602
|
key: "raw",
|
|
601
603
|
value: function raw() {
|
|
602
|
-
return new StringSchema(this.options, this.opt, true, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description, this.previewInput);
|
|
604
|
+
return new StringSchema(this.options, this.opt, true, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description, this.previewInput, this.isMultiline);
|
|
603
605
|
}
|
|
604
606
|
}, {
|
|
605
607
|
key: "executeCustomValidateAt",
|
|
@@ -615,6 +617,7 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
|
615
617
|
return {
|
|
616
618
|
type: "string",
|
|
617
619
|
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
620
|
+
multiline: this.isMultiline ? true : undefined,
|
|
618
621
|
preview: this.previewInput ? true : undefined,
|
|
619
622
|
options: {
|
|
620
623
|
maxLength: (_this$options4 = this.options) === null || _this$options4 === void 0 ? void 0 : _this$options4.maxLength,
|
|
@@ -636,8 +639,27 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
|
636
639
|
}
|
|
637
640
|
|
|
638
641
|
/**
|
|
639
|
-
*
|
|
640
|
-
*
|
|
642
|
+
* This string holds text that may run to several lines: the editor gives it a
|
|
643
|
+
* growing text box instead of a single-line input.
|
|
644
|
+
*
|
|
645
|
+
* Nothing else changes — the value is still a plain string, and no validation
|
|
646
|
+
* is added or removed. For code, use `s.code({ language })` instead, which is
|
|
647
|
+
* its own schema type.
|
|
648
|
+
*
|
|
649
|
+
* @example
|
|
650
|
+
* const schema = s.string().multiline();
|
|
651
|
+
* export default c.define("/example.val.ts", schema, "Line one\nLine two");
|
|
652
|
+
*/
|
|
653
|
+
}, {
|
|
654
|
+
key: "multiline",
|
|
655
|
+
value: function multiline() {
|
|
656
|
+
return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description, this.previewInput, true);
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* How this field is laid out in the editor when it is the item of an array or
|
|
661
|
+
* record: `{ as: "inline" }` renders the field itself inside each row,
|
|
662
|
+
* instead of a preview row that navigates to it.
|
|
641
663
|
*
|
|
642
664
|
* Static configuration, not a callback — see `render.ts`. What a CONTAINER
|
|
643
665
|
* shows for its items is a `preview`, which is a different thing entirely.
|
|
@@ -645,7 +667,7 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
|
645
667
|
}, {
|
|
646
668
|
key: "render",
|
|
647
669
|
value: function render(input) {
|
|
648
|
-
return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions, input, this.isReadonly, this.isHidden, this.description, this.previewInput);
|
|
670
|
+
return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions, input, this.isReadonly, this.isHidden, this.description, this.previewInput, this.isMultiline);
|
|
649
671
|
}
|
|
650
672
|
|
|
651
673
|
/**
|
|
@@ -656,7 +678,7 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
|
656
678
|
}, {
|
|
657
679
|
key: "preview",
|
|
658
680
|
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);
|
|
681
|
+
return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description, select, this.isMultiline);
|
|
660
682
|
}
|
|
661
683
|
}, {
|
|
662
684
|
key: "executePreviewItem",
|
|
@@ -6334,6 +6356,184 @@ var datetime = function datetime(options) {
|
|
|
6334
6356
|
return new DateTimeSchema(options);
|
|
6335
6357
|
};
|
|
6336
6358
|
|
|
6359
|
+
/**
|
|
6360
|
+
* The list is the declaration and {@link CodeLanguage} is derived from it, so
|
|
6361
|
+
* that a validator elsewhere (`shared`'s zod schema) can enumerate the same
|
|
6362
|
+
* languages without a second copy that drifts. Same shape as `COLOR_FORMATS`.
|
|
6363
|
+
*/
|
|
6364
|
+
var CODE_LANGUAGES = ["typescript", "javascript", "javascriptreact", "typescriptreact", "json", "java", "html", "css", "xml", "markdown", "sql", "python", "rust", "php", "go", "cpp", "sass", "vue", "angular"];
|
|
6365
|
+
/**
|
|
6366
|
+
* A string edited in a code editor.
|
|
6367
|
+
*
|
|
6368
|
+
* Its own schema type rather than a layout on `s.string()`: the language is
|
|
6369
|
+
* part of what the content IS, not of how one field happens to be drawn, and
|
|
6370
|
+
* being a type is what lets the value stay out of stega encoding — invisible
|
|
6371
|
+
* characters woven into source code are not something a consumer can render.
|
|
6372
|
+
*/
|
|
6373
|
+
var CodeSchema = /*#__PURE__*/function (_Schema) {
|
|
6374
|
+
function CodeSchema(options) {
|
|
6375
|
+
var _this;
|
|
6376
|
+
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
6377
|
+
var customValidateFunctions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
6378
|
+
var isReadonly = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
6379
|
+
var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
6380
|
+
var description = arguments.length > 5 ? arguments[5] : undefined;
|
|
6381
|
+
var renderInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
|
|
6382
|
+
var previewInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
|
|
6383
|
+
_classCallCheck(this, CodeSchema);
|
|
6384
|
+
_this = _callSuper(this, CodeSchema);
|
|
6385
|
+
_this.options = options;
|
|
6386
|
+
_this.opt = opt;
|
|
6387
|
+
_this.customValidateFunctions = customValidateFunctions;
|
|
6388
|
+
_this.isReadonly = isReadonly;
|
|
6389
|
+
_this.isHidden = isHidden;
|
|
6390
|
+
_this.description = description;
|
|
6391
|
+
_this.renderInput = renderInput;
|
|
6392
|
+
_this.previewInput = previewInput;
|
|
6393
|
+
return _this;
|
|
6394
|
+
}
|
|
6395
|
+
_inherits(CodeSchema, _Schema);
|
|
6396
|
+
return _createClass(CodeSchema, [{
|
|
6397
|
+
key: "describe",
|
|
6398
|
+
value: function describe(description) {
|
|
6399
|
+
return new CodeSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput, this.previewInput);
|
|
6400
|
+
}
|
|
6401
|
+
}, {
|
|
6402
|
+
key: "validate",
|
|
6403
|
+
value: function validate(validationFunction) {
|
|
6404
|
+
return new CodeSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
6405
|
+
}
|
|
6406
|
+
}, {
|
|
6407
|
+
key: "executeCustomValidateAt",
|
|
6408
|
+
value: function executeCustomValidateAt(path, src) {
|
|
6409
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
6410
|
+
path: path
|
|
6411
|
+
});
|
|
6412
|
+
}
|
|
6413
|
+
}, {
|
|
6414
|
+
key: "executeValidate",
|
|
6415
|
+
value: function executeValidate(path, src) {
|
|
6416
|
+
var errors = this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
6417
|
+
path: path
|
|
6418
|
+
});
|
|
6419
|
+
if (this.opt && (src === null || src === undefined)) {
|
|
6420
|
+
return errors.length > 0 ? _defineProperty({}, path, errors) : false;
|
|
6421
|
+
}
|
|
6422
|
+
if (typeof src !== "string") {
|
|
6423
|
+
errors.push({
|
|
6424
|
+
message: "Expected 'string', got '".concat(src === null ? "null" : _typeof(src), "'"),
|
|
6425
|
+
value: src
|
|
6426
|
+
});
|
|
6427
|
+
}
|
|
6428
|
+
if (errors.length > 0) {
|
|
6429
|
+
return _defineProperty({}, path, errors);
|
|
6430
|
+
}
|
|
6431
|
+
return false;
|
|
6432
|
+
}
|
|
6433
|
+
}, {
|
|
6434
|
+
key: "executeAssert",
|
|
6435
|
+
value: function executeAssert(path, src) {
|
|
6436
|
+
if (this.opt && src === null) {
|
|
6437
|
+
return {
|
|
6438
|
+
success: true,
|
|
6439
|
+
data: src
|
|
6440
|
+
};
|
|
6441
|
+
}
|
|
6442
|
+
if (typeof src !== "string") {
|
|
6443
|
+
return {
|
|
6444
|
+
success: false,
|
|
6445
|
+
errors: _defineProperty({}, path, [{
|
|
6446
|
+
message: "Expected 'string', got '".concat(src === null ? "null" : _typeof(src), "'"),
|
|
6447
|
+
typeError: true
|
|
6448
|
+
}])
|
|
6449
|
+
};
|
|
6450
|
+
}
|
|
6451
|
+
return {
|
|
6452
|
+
success: true,
|
|
6453
|
+
data: src
|
|
6454
|
+
};
|
|
6455
|
+
}
|
|
6456
|
+
}, {
|
|
6457
|
+
key: "nullable",
|
|
6458
|
+
value: function nullable() {
|
|
6459
|
+
return new CodeSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
6460
|
+
}
|
|
6461
|
+
}, {
|
|
6462
|
+
key: "readonly",
|
|
6463
|
+
value: function readonly() {
|
|
6464
|
+
return new CodeSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput, this.previewInput);
|
|
6465
|
+
}
|
|
6466
|
+
}, {
|
|
6467
|
+
key: "hidden",
|
|
6468
|
+
value: function hidden() {
|
|
6469
|
+
return new CodeSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput, this.previewInput);
|
|
6470
|
+
}
|
|
6471
|
+
|
|
6472
|
+
/**
|
|
6473
|
+
* How this field is laid out in the editor when it is the item of an array
|
|
6474
|
+
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
6475
|
+
* instead of a preview row that navigates to it.
|
|
6476
|
+
*
|
|
6477
|
+
* Static configuration, not a callback — see `render.ts`.
|
|
6478
|
+
*/
|
|
6479
|
+
}, {
|
|
6480
|
+
key: "render",
|
|
6481
|
+
value: function render(input) {
|
|
6482
|
+
return new CodeSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input, this.previewInput);
|
|
6483
|
+
}
|
|
6484
|
+
|
|
6485
|
+
/**
|
|
6486
|
+
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
6487
|
+
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
6488
|
+
* itself is edited (that is `render`). See `preview.ts`.
|
|
6489
|
+
*/
|
|
6490
|
+
}, {
|
|
6491
|
+
key: "preview",
|
|
6492
|
+
value: function preview(select) {
|
|
6493
|
+
return new CodeSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.renderInput, select);
|
|
6494
|
+
}
|
|
6495
|
+
}, {
|
|
6496
|
+
key: "executePreviewItem",
|
|
6497
|
+
value: function executePreviewItem(src) {
|
|
6498
|
+
if (this.previewInput === null) {
|
|
6499
|
+
return null;
|
|
6500
|
+
}
|
|
6501
|
+
return this.previewInput({
|
|
6502
|
+
val: src
|
|
6503
|
+
});
|
|
6504
|
+
}
|
|
6505
|
+
}, {
|
|
6506
|
+
key: "declaresItemPreview",
|
|
6507
|
+
value: function declaresItemPreview() {
|
|
6508
|
+
return this.previewInput !== null;
|
|
6509
|
+
}
|
|
6510
|
+
}, {
|
|
6511
|
+
key: "executeSerialize",
|
|
6512
|
+
value: function executeSerialize() {
|
|
6513
|
+
var _this$renderInput, _this$customValidateF;
|
|
6514
|
+
return {
|
|
6515
|
+
type: "code",
|
|
6516
|
+
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
6517
|
+
preview: this.previewInput ? true : undefined,
|
|
6518
|
+
options: this.options,
|
|
6519
|
+
opt: this.opt,
|
|
6520
|
+
customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
|
|
6521
|
+
readonly: this.isReadonly,
|
|
6522
|
+
hidden: this.isHidden,
|
|
6523
|
+
description: this.description
|
|
6524
|
+
};
|
|
6525
|
+
}
|
|
6526
|
+
}, {
|
|
6527
|
+
key: "executePreview",
|
|
6528
|
+
value: function executePreview() {
|
|
6529
|
+
return {};
|
|
6530
|
+
}
|
|
6531
|
+
}]);
|
|
6532
|
+
}(Schema);
|
|
6533
|
+
var code = function code(options) {
|
|
6534
|
+
return new CodeSchema(options);
|
|
6535
|
+
};
|
|
6536
|
+
|
|
6337
6537
|
/**
|
|
6338
6538
|
* Parsing / formatting of the CSS color strings stored by `s.color()`.
|
|
6339
6539
|
*
|
|
@@ -7112,6 +7312,7 @@ function initSchema() {
|
|
|
7112
7312
|
date: date,
|
|
7113
7313
|
datetime: datetime,
|
|
7114
7314
|
color: color,
|
|
7315
|
+
code: code,
|
|
7115
7316
|
route: route,
|
|
7116
7317
|
router: router,
|
|
7117
7318
|
images: images
|
|
@@ -7925,7 +8126,7 @@ function hasRemoteFileSchema(schema) {
|
|
|
7925
8126
|
}
|
|
7926
8127
|
}
|
|
7927
8128
|
return false;
|
|
7928
|
-
} else if (schema.type === "boolean" || schema.type === "number" || schema.type === "string" || schema.type === "literal" || schema.type === "date" || schema.type === "dateTime" || schema.type === "color" || schema.type === "keyOf" || schema.type === "route") {
|
|
8129
|
+
} else if (schema.type === "boolean" || schema.type === "number" || schema.type === "string" || schema.type === "literal" || schema.type === "date" || schema.type === "dateTime" || schema.type === "color" || schema.type === "code" || schema.type === "keyOf" || schema.type === "route") {
|
|
7929
8130
|
return false;
|
|
7930
8131
|
} else {
|
|
7931
8132
|
var exhaustiveCheck = schema;
|
|
@@ -8860,7 +9061,7 @@ function deserializeSchema(serialized) {
|
|
|
8860
9061
|
return schema;
|
|
8861
9062
|
}
|
|
8862
9063
|
function deserializeSchemaImpl(serialized) {
|
|
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;
|
|
9064
|
+
var _serialized$options, _serialized$options2, _serialized$render, _serialized$multiline, _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, _serialized$render15;
|
|
8864
9065
|
switch (serialized.type) {
|
|
8865
9066
|
case "string":
|
|
8866
9067
|
return new StringSchema(_objectSpread2(_objectSpread2({}, serialized.options), {}, {
|
|
@@ -8869,7 +9070,7 @@ function deserializeSchemaImpl(serialized) {
|
|
|
8869
9070
|
}), serialized.opt, serialized.raw, [], // A render is static data, so it survives serialization and must be
|
|
8870
9071
|
// carried back: it is the schema's own configuration now, not something
|
|
8871
9072
|
// recomputed from an instance.
|
|
8872
|
-
(_serialized$render = serialized.render) !== null && _serialized$render !== void 0 ? _serialized$render : null, false, false, serialized.description);
|
|
9073
|
+
(_serialized$render = serialized.render) !== null && _serialized$render !== void 0 ? _serialized$render : null, false, false, serialized.description, null, (_serialized$multiline = serialized.multiline) !== null && _serialized$multiline !== void 0 ? _serialized$multiline : false);
|
|
8873
9074
|
case "literal":
|
|
8874
9075
|
return new LiteralSchema(serialized.value, serialized.opt, [], false, false, serialized.description, (_serialized$render2 = serialized.render) !== null && _serialized$render2 !== void 0 ? _serialized$render2 : null);
|
|
8875
9076
|
case "boolean":
|
|
@@ -8938,6 +9139,8 @@ function deserializeSchemaImpl(serialized) {
|
|
|
8938
9139
|
return new DateTimeSchema(serialized.options, serialized.opt, [], false, false, serialized.description, (_serialized$render13 = serialized.render) !== null && _serialized$render13 !== void 0 ? _serialized$render13 : null);
|
|
8939
9140
|
case "color":
|
|
8940
9141
|
return new ColorSchema(serialized.options, serialized.opt, [], false, false, serialized.description, (_serialized$render14 = serialized.render) !== null && _serialized$render14 !== void 0 ? _serialized$render14 : null);
|
|
9142
|
+
case "code":
|
|
9143
|
+
return new CodeSchema(serialized.options, serialized.opt, [], false, false, serialized.description, (_serialized$render15 = serialized.render) !== null && _serialized$render15 !== void 0 ? _serialized$render15 : null);
|
|
8941
9144
|
default:
|
|
8942
9145
|
{
|
|
8943
9146
|
var exhaustiveCheck = serialized;
|
|
@@ -9090,10 +9293,14 @@ function previewScope(paths) {
|
|
|
9090
9293
|
|
|
9091
9294
|
/**
|
|
9092
9295
|
* 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:
|
|
9094
|
-
* })`, `.render({ as: "code", language })`, `.render({ as: "inline" })` on an
|
|
9296
|
+
* only when you are looking at the field: `.render({ as: "inline" })` on an
|
|
9095
9297
|
* array/record item.
|
|
9096
9298
|
*
|
|
9299
|
+
* It is deliberately the ONE thing a render can say. What a string looks like
|
|
9300
|
+
* when it holds more than a line is the schema's own business — `.multiline()`
|
|
9301
|
+
* for a text box, `s.code({ language })` for a code editor — not a layout
|
|
9302
|
+
* bolted onto `s.string()` from outside.
|
|
9303
|
+
*
|
|
9097
9304
|
* A PREVIEW (`preview.ts`) is the other thing: how the VALUE is shown wherever
|
|
9098
9305
|
* a preview of it is needed — a list row, a reference dropdown, a search hit —
|
|
9099
9306
|
* that is, wherever the value is navigable to rather than open. The two never
|
|
@@ -9114,13 +9321,6 @@ function previewScope(paths) {
|
|
|
9114
9321
|
* `render` its own execute/store pair again. It is NOT to re-merge the two:
|
|
9115
9322
|
* conflating them is what this file was split up to undo.
|
|
9116
9323
|
*/
|
|
9117
|
-
/**
|
|
9118
|
-
* The list is the declaration and {@link CodeLanguage} is derived from it, so
|
|
9119
|
-
* that a validator elsewhere (`shared`'s zod schema) can enumerate the same
|
|
9120
|
-
* languages without a second copy that drifts. Same shape as `COLOR_FORMATS`.
|
|
9121
|
-
*/
|
|
9122
|
-
var CODE_LANGUAGES = ["typescript", "javascript", "javascriptreact", "typescriptreact", "json", "java", "html", "css", "xml", "markdown", "sql", "python", "rust", "php", "go", "cpp", "sass", "vue", "angular"];
|
|
9123
|
-
|
|
9124
9324
|
/**
|
|
9125
9325
|
* `{ as: "inline" }` on a field that is the ITEM of an array or record: the
|
|
9126
9326
|
* container renders the field itself inside each (sortable) row, instead of a
|
|
@@ -9136,14 +9336,8 @@ var CODE_LANGUAGES = ["typescript", "javascript", "javascriptreact", "typescript
|
|
|
9136
9336
|
*/
|
|
9137
9337
|
|
|
9138
9338
|
/**
|
|
9139
|
-
* What `.render(...)` takes on every field
|
|
9140
|
-
*
|
|
9141
|
-
*/
|
|
9142
|
-
|
|
9143
|
-
/**
|
|
9144
|
-
* What `s.string().render(...)` takes, and what the serialized schema carries
|
|
9145
|
-
* verbatim. A string has editor layouts of its own (textarea, code) in
|
|
9146
|
-
* addition to the container-facing `inline`.
|
|
9339
|
+
* What `.render(...)` takes on every field, and what the serialized schema
|
|
9340
|
+
* carries verbatim.
|
|
9147
9341
|
*/
|
|
9148
9342
|
|
|
9149
9343
|
/**
|
|
@@ -9552,6 +9746,7 @@ exports.ArraySchema = ArraySchema;
|
|
|
9552
9746
|
exports.BooleanSchema = BooleanSchema;
|
|
9553
9747
|
exports.CODE_LANGUAGES = CODE_LANGUAGES;
|
|
9554
9748
|
exports.COLOR_FORMATS = COLOR_FORMATS;
|
|
9749
|
+
exports.CodeSchema = CodeSchema;
|
|
9555
9750
|
exports.ColorSchema = ColorSchema;
|
|
9556
9751
|
exports.DEFAULT_APP_HOST = DEFAULT_APP_HOST;
|
|
9557
9752
|
exports.DEFAULT_COLOR_FORMAT = DEFAULT_COLOR_FORMAT;
|