@valbuild/core 0.144.0 → 0.145.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/CHANGELOG.md +26 -0
- package/dist/declarations/src/index.d.ts +8 -1
- package/dist/declarations/src/initSchema.d.ts +23 -1
- package/dist/declarations/src/render.d.ts +38 -5
- package/dist/declarations/src/schema/number.d.ts +45 -5
- package/dist/declarations/src/schema/numberRules.d.ts +27 -0
- package/dist/{index-aa16dd90.esm.js → index-307b907e.esm.js} +266 -32
- package/dist/{index-2d194c90.cjs.prod.js → index-93763025.cjs.prod.js} +266 -32
- package/dist/{index-8b22b2c1.cjs.dev.js → index-ee601322.cjs.dev.js} +266 -32
- package/dist/valbuild-core.cjs.dev.js +1 -1
- package/dist/valbuild-core.cjs.prod.js +1 -1
- package/dist/valbuild-core.esm.js +1 -1
- package/package.json +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
|
@@ -10187,6 +10187,87 @@ function patchPathToModulePath(patchPath) {
|
|
|
10187
10187
|
}).join(".");
|
|
10188
10188
|
}
|
|
10189
10189
|
|
|
10190
|
+
/**
|
|
10191
|
+
* What a number schema accepts, in one place, so the validator and the
|
|
10192
|
+
* Studio's "Round to …" / "Set to …" buttons cannot disagree about it.
|
|
10193
|
+
*
|
|
10194
|
+
* A button that offers a value the validator then rejects is worse than no
|
|
10195
|
+
* button, which is exactly what two copies of this arithmetic would drift into.
|
|
10196
|
+
*/
|
|
10197
|
+
|
|
10198
|
+
/**
|
|
10199
|
+
* Division of decimals is not exact (`0.3 / 0.1` is `2.9999999999999996`), so a
|
|
10200
|
+
* value counts as on the grid when it is within this many steps of it.
|
|
10201
|
+
*/
|
|
10202
|
+
var GRID_EPSILON = 1e-9;
|
|
10203
|
+
|
|
10204
|
+
/** Where the step grid starts: the schema's `min`, or 0 when it has none. */
|
|
10205
|
+
function stepOrigin(rules) {
|
|
10206
|
+
var _rules$min;
|
|
10207
|
+
return (_rules$min = rules.min) !== null && _rules$min !== void 0 ? _rules$min : 0;
|
|
10208
|
+
}
|
|
10209
|
+
|
|
10210
|
+
/** Is `value` one of `origin + n * step`? */
|
|
10211
|
+
function isOnStep(value, origin, step) {
|
|
10212
|
+
var steps = (value - origin) / step;
|
|
10213
|
+
return Math.abs(steps - Math.round(steps)) < GRID_EPSILON;
|
|
10214
|
+
}
|
|
10215
|
+
|
|
10216
|
+
/**
|
|
10217
|
+
* The allowed value closest to `value`: inside `min`/`max`, on the step grid,
|
|
10218
|
+
* and whole when the schema is an int.
|
|
10219
|
+
*
|
|
10220
|
+
* Returns `null` when the rules leave nothing to snap to — a `min` above
|
|
10221
|
+
* `max`, or a range too narrow to hold a single step or a single whole number.
|
|
10222
|
+
*/
|
|
10223
|
+
function nearestAllowedNumber(value, rules) {
|
|
10224
|
+
var _rules$step;
|
|
10225
|
+
var step = (_rules$step = rules.step) !== null && _rules$step !== void 0 ? _rules$step : rules.integer ? 1 : undefined;
|
|
10226
|
+
var lo = rules.min;
|
|
10227
|
+
var hi = rules.max;
|
|
10228
|
+
if (lo !== undefined && hi !== undefined && lo > hi) {
|
|
10229
|
+
return null;
|
|
10230
|
+
}
|
|
10231
|
+
var clamp = function clamp(n) {
|
|
10232
|
+
return Math.min(hi !== null && hi !== void 0 ? hi : Infinity, Math.max(lo !== null && lo !== void 0 ? lo : -Infinity, n));
|
|
10233
|
+
};
|
|
10234
|
+
if (step === undefined) {
|
|
10235
|
+
return clamp(value);
|
|
10236
|
+
}
|
|
10237
|
+
var origin = rules.integer && rules.step === undefined ? 0 : stepOrigin(rules);
|
|
10238
|
+
var toGrid = function toGrid(n) {
|
|
10239
|
+
return roundToDecimals(origin + n * step);
|
|
10240
|
+
};
|
|
10241
|
+
var n = Math.round((clamp(value) - origin) / step);
|
|
10242
|
+
// Rounding can step outside the range by one; walk back in.
|
|
10243
|
+
if (lo !== undefined && toGrid(n) < lo) n += 1;
|
|
10244
|
+
if (hi !== undefined && toGrid(n) > hi) n -= 1;
|
|
10245
|
+
var snapped = toGrid(n);
|
|
10246
|
+
if (lo !== undefined && snapped < lo || hi !== undefined && snapped > hi) {
|
|
10247
|
+
return null;
|
|
10248
|
+
}
|
|
10249
|
+
if (rules.integer && !Number.isInteger(snapped)) {
|
|
10250
|
+
return null;
|
|
10251
|
+
}
|
|
10252
|
+
return snapped;
|
|
10253
|
+
}
|
|
10254
|
+
|
|
10255
|
+
/**
|
|
10256
|
+
* `0.1 + 0.2` is `0.30000000000000004`. A value offered to an editor should
|
|
10257
|
+
* read `0.3`, so grid values are rounded to 12 significant decimals — far below
|
|
10258
|
+
* any step anyone writes, far above floating point noise.
|
|
10259
|
+
*/
|
|
10260
|
+
function roundToDecimals(n) {
|
|
10261
|
+
return Number.parseFloat(n.toFixed(12));
|
|
10262
|
+
}
|
|
10263
|
+
|
|
10264
|
+
/**
|
|
10265
|
+
* What the value has to be. `integer` is what makes a number schema an
|
|
10266
|
+
* `s.int()`: the source is a number either way, so an int is a number schema
|
|
10267
|
+
* with one more rule rather than a schema type of its own (which every walk
|
|
10268
|
+
* over a schema would have had to learn).
|
|
10269
|
+
*/
|
|
10270
|
+
|
|
10190
10271
|
var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
10191
10272
|
function NumberSchema(options) {
|
|
10192
10273
|
var _this;
|
|
@@ -10196,6 +10277,7 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10196
10277
|
var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
10197
10278
|
var description = arguments.length > 5 ? arguments[5] : undefined;
|
|
10198
10279
|
var previewInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
|
|
10280
|
+
var renderInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
|
|
10199
10281
|
_classCallCheck(this, NumberSchema);
|
|
10200
10282
|
_this = _callSuper(this, NumberSchema);
|
|
10201
10283
|
_this.options = options;
|
|
@@ -10205,6 +10287,8 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10205
10287
|
_this.isHidden = isHidden;
|
|
10206
10288
|
_this.description = description;
|
|
10207
10289
|
_this.previewInput = previewInput;
|
|
10290
|
+
_this.renderInput = renderInput;
|
|
10291
|
+
assertNumberSchemaIsConsistent(_this.options, _this.renderInput);
|
|
10208
10292
|
return _this;
|
|
10209
10293
|
}
|
|
10210
10294
|
|
|
@@ -10229,7 +10313,7 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10229
10313
|
return _createClass(NumberSchema, [{
|
|
10230
10314
|
key: "describe",
|
|
10231
10315
|
value: function describe(description) {
|
|
10232
|
-
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.previewInput);
|
|
10316
|
+
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.previewInput, this.renderInput);
|
|
10233
10317
|
}
|
|
10234
10318
|
|
|
10235
10319
|
/**
|
|
@@ -10255,12 +10339,12 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10255
10339
|
}, {
|
|
10256
10340
|
key: "validate",
|
|
10257
10341
|
value: function validate(validationFunction) {
|
|
10258
|
-
return new NumberSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.previewInput);
|
|
10342
|
+
return new NumberSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.previewInput, this.renderInput);
|
|
10259
10343
|
}
|
|
10260
10344
|
}, {
|
|
10261
10345
|
key: "executeValidate",
|
|
10262
10346
|
value: function executeValidate(path, src) {
|
|
10263
|
-
var _this$options
|
|
10347
|
+
var _this$options;
|
|
10264
10348
|
var customValidationErrors = this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
10265
10349
|
path: path
|
|
10266
10350
|
});
|
|
@@ -10273,20 +10357,35 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10273
10357
|
value: src
|
|
10274
10358
|
}]));
|
|
10275
10359
|
}
|
|
10276
|
-
|
|
10277
|
-
|
|
10278
|
-
|
|
10360
|
+
var errors = _toConsumableArray(customValidationErrors);
|
|
10361
|
+
var options = (_this$options = this.options) !== null && _this$options !== void 0 ? _this$options : {};
|
|
10362
|
+
// `!== undefined`, not truthiness: a bound of 0 is a bound. `.max(0)` and
|
|
10363
|
+
// `.min(0)` used to be ignored, which a slider from 0 makes common.
|
|
10364
|
+
if (options.max !== undefined && src > options.max) {
|
|
10365
|
+
errors.push({
|
|
10366
|
+
message: "Must be at most ".concat(options.max),
|
|
10279
10367
|
value: src
|
|
10280
|
-
}
|
|
10368
|
+
});
|
|
10281
10369
|
}
|
|
10282
|
-
if (
|
|
10283
|
-
|
|
10284
|
-
message: "
|
|
10370
|
+
if (options.min !== undefined && src < options.min) {
|
|
10371
|
+
errors.push({
|
|
10372
|
+
message: "Must be at least ".concat(options.min),
|
|
10285
10373
|
value: src
|
|
10286
|
-
}
|
|
10374
|
+
});
|
|
10287
10375
|
}
|
|
10288
|
-
if (
|
|
10289
|
-
|
|
10376
|
+
if (options.integer && !Number.isInteger(src)) {
|
|
10377
|
+
errors.push({
|
|
10378
|
+
message: "Must be a whole number",
|
|
10379
|
+
value: src
|
|
10380
|
+
});
|
|
10381
|
+
} else if (options.step !== undefined && !isOnStep(src, stepOrigin(options), options.step)) {
|
|
10382
|
+
errors.push({
|
|
10383
|
+
message: "Must be a multiple of ".concat(options.step, ", counted from ").concat(stepOrigin(options)),
|
|
10384
|
+
value: src
|
|
10385
|
+
});
|
|
10386
|
+
}
|
|
10387
|
+
if (errors.length > 0) {
|
|
10388
|
+
return _defineProperty({}, path, errors);
|
|
10290
10389
|
}
|
|
10291
10390
|
return false;
|
|
10292
10391
|
}
|
|
@@ -10325,19 +10424,19 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10325
10424
|
}, {
|
|
10326
10425
|
key: "nullable",
|
|
10327
10426
|
value: function nullable() {
|
|
10328
|
-
return new NumberSchema(this.options, true, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.previewInput);
|
|
10427
|
+
return new NumberSchema(this.options, true, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.previewInput, this.renderInput);
|
|
10329
10428
|
}
|
|
10330
10429
|
}, {
|
|
10331
10430
|
key: "readonly",
|
|
10332
10431
|
value: function readonly() {
|
|
10333
10432
|
var isReadonly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
10334
|
-
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, isReadonly, this.isHidden, this.description, this.previewInput);
|
|
10433
|
+
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, isReadonly, this.isHidden, this.description, this.previewInput, this.renderInput);
|
|
10335
10434
|
}
|
|
10336
10435
|
}, {
|
|
10337
10436
|
key: "hidden",
|
|
10338
10437
|
value: function hidden() {
|
|
10339
10438
|
var isHidden = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
10340
|
-
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, isHidden, this.description, this.previewInput);
|
|
10439
|
+
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, isHidden, this.description, this.previewInput, this.renderInput);
|
|
10341
10440
|
}
|
|
10342
10441
|
|
|
10343
10442
|
/**
|
|
@@ -10352,7 +10451,7 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10352
10451
|
value: function max(_max) {
|
|
10353
10452
|
return new NumberSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
10354
10453
|
max: _max
|
|
10355
|
-
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.previewInput);
|
|
10454
|
+
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.previewInput, this.renderInput);
|
|
10356
10455
|
}
|
|
10357
10456
|
|
|
10358
10457
|
/**
|
|
@@ -10367,7 +10466,50 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10367
10466
|
value: function min(_min) {
|
|
10368
10467
|
return new NumberSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
10369
10468
|
min: _min
|
|
10370
|
-
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.previewInput);
|
|
10469
|
+
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.previewInput, this.renderInput);
|
|
10470
|
+
}
|
|
10471
|
+
|
|
10472
|
+
/**
|
|
10473
|
+
* Validate that the number is on a grid of `step`: one of `min`, `min + step`,
|
|
10474
|
+
* `min + 2 * step` and so on, counted from 0 when there is no `.min()`.
|
|
10475
|
+
*
|
|
10476
|
+
* A slider rendered on this field moves in the same steps unless its render
|
|
10477
|
+
* says otherwise (and then its step has to be a multiple of this one).
|
|
10478
|
+
*
|
|
10479
|
+
* @example
|
|
10480
|
+
* const schema = s.int().min(0).max(100).step(5);
|
|
10481
|
+
* export default c.define("/example.val.ts", schema, 40);
|
|
10482
|
+
*/
|
|
10483
|
+
}, {
|
|
10484
|
+
key: "step",
|
|
10485
|
+
value: function step(_step) {
|
|
10486
|
+
return new NumberSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
10487
|
+
step: _step
|
|
10488
|
+
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.previewInput, this.renderInput);
|
|
10489
|
+
}
|
|
10490
|
+
|
|
10491
|
+
/**
|
|
10492
|
+
* Choose how this field is edited. `{ as: "slider", min, max }` edits it with
|
|
10493
|
+
* a slider from `min` to `max`, next to a box for typing an exact value.
|
|
10494
|
+
*
|
|
10495
|
+
* `min` and `max` are required — a slider without ends is not a slider — and
|
|
10496
|
+
* they are the slider's, not validation: use `.min()` / `.max()` for what the
|
|
10497
|
+
* value may be. The slider can only produce values this schema accepts, so
|
|
10498
|
+
* its range must lie inside `.min()`/`.max()`, its `step` (which defaults to
|
|
10499
|
+
* `.step()`, then 1) must be a multiple of `.step()`, and on `s.int()` all of
|
|
10500
|
+
* them must be whole numbers. A schema that breaks this throws here.
|
|
10501
|
+
*
|
|
10502
|
+
* Static configuration, not a callback — see `render.ts`. A second
|
|
10503
|
+
* `.render(...)` replaces the first.
|
|
10504
|
+
*
|
|
10505
|
+
* @example
|
|
10506
|
+
* const schema = s.int().render({ as: "slider", min: 0, max: 100, step: 5 });
|
|
10507
|
+
* export default c.define("/example.val.ts", schema, 40);
|
|
10508
|
+
*/
|
|
10509
|
+
}, {
|
|
10510
|
+
key: "render",
|
|
10511
|
+
value: function render(input) {
|
|
10512
|
+
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.previewInput, input);
|
|
10371
10513
|
}
|
|
10372
10514
|
}, {
|
|
10373
10515
|
key: "executeCustomValidateAt",
|
|
@@ -10391,7 +10533,7 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10391
10533
|
}, {
|
|
10392
10534
|
key: "preview",
|
|
10393
10535
|
value: function preview(select) {
|
|
10394
|
-
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, select);
|
|
10536
|
+
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, select, this.renderInput);
|
|
10395
10537
|
}
|
|
10396
10538
|
}, {
|
|
10397
10539
|
key: "executePreviewItem",
|
|
@@ -10411,11 +10553,12 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10411
10553
|
}, {
|
|
10412
10554
|
key: "executeSerialize",
|
|
10413
10555
|
value: function executeSerialize() {
|
|
10414
|
-
var _this$customValidateF;
|
|
10556
|
+
var _this$renderInput, _this$customValidateF;
|
|
10415
10557
|
return {
|
|
10416
10558
|
type: "number",
|
|
10417
10559
|
preview: this.previewInput ? true : undefined,
|
|
10418
10560
|
options: this.options,
|
|
10561
|
+
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
10419
10562
|
opt: this.opt,
|
|
10420
10563
|
customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
|
|
10421
10564
|
readonly: this.isReadonly,
|
|
@@ -10428,6 +10571,63 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10428
10571
|
var number = function number(options) {
|
|
10429
10572
|
return new NumberSchema(options);
|
|
10430
10573
|
};
|
|
10574
|
+
var _int = function _int() {
|
|
10575
|
+
return new NumberSchema({
|
|
10576
|
+
integer: true
|
|
10577
|
+
});
|
|
10578
|
+
};
|
|
10579
|
+
function assertNumberSchemaIsConsistent(options, render) {
|
|
10580
|
+
var opts = options !== null && options !== void 0 ? options : {};
|
|
10581
|
+
var kind = opts.integer ? "s.int()" : "s.number()";
|
|
10582
|
+
if (opts.step !== undefined) {
|
|
10583
|
+
if (!(opts.step > 0) || !Number.isFinite(opts.step)) {
|
|
10584
|
+
throw new Error("".concat(kind, ".step(").concat(opts.step, "): the step must be above 0"));
|
|
10585
|
+
}
|
|
10586
|
+
if (opts.integer && !Number.isInteger(opts.step)) {
|
|
10587
|
+
throw new Error("".concat(kind, ".step(").concat(opts.step, "): the step of an int must be a whole number"));
|
|
10588
|
+
}
|
|
10589
|
+
}
|
|
10590
|
+
if (render === null) {
|
|
10591
|
+
return;
|
|
10592
|
+
}
|
|
10593
|
+
var where = "".concat(kind, ".render({ as: \"slider\", min: ").concat(render.min, ", max: ").concat(render.max, " })");
|
|
10594
|
+
if (!Number.isFinite(render.min) || !Number.isFinite(render.max)) {
|
|
10595
|
+
throw new Error("".concat(where, ": the slider needs a min and a max"));
|
|
10596
|
+
}
|
|
10597
|
+
if (!(render.min < render.max)) {
|
|
10598
|
+
throw new Error("".concat(where, ": the slider's min must be below its max"));
|
|
10599
|
+
}
|
|
10600
|
+
if (opts.min !== undefined && render.min < opts.min) {
|
|
10601
|
+
throw new Error("".concat(where, ": the slider's min ").concat(render.min, " is below the schema's min ").concat(opts.min));
|
|
10602
|
+
}
|
|
10603
|
+
if (opts.max !== undefined && render.max > opts.max) {
|
|
10604
|
+
throw new Error("".concat(where, ": the slider's max ").concat(render.max, " is above the schema's max ").concat(opts.max));
|
|
10605
|
+
}
|
|
10606
|
+
if (render.step !== undefined && !(render.step > 0)) {
|
|
10607
|
+
throw new Error("".concat(where, ": the slider's step must be above 0"));
|
|
10608
|
+
}
|
|
10609
|
+
if (opts.integer) {
|
|
10610
|
+
var sliderNumbers = [["min", render.min], ["max", render.max], ["step", render.step]];
|
|
10611
|
+
for (var _i = 0, _sliderNumbers = sliderNumbers; _i < _sliderNumbers.length; _i++) {
|
|
10612
|
+
var _sliderNumbers$_i = _slicedToArray(_sliderNumbers[_i], 2),
|
|
10613
|
+
name = _sliderNumbers$_i[0],
|
|
10614
|
+
value = _sliderNumbers$_i[1];
|
|
10615
|
+
if (value !== undefined && !Number.isInteger(value)) {
|
|
10616
|
+
throw new Error("".concat(where, ": the slider's ").concat(name, " ").concat(value, " must be a whole number on an int"));
|
|
10617
|
+
}
|
|
10618
|
+
}
|
|
10619
|
+
}
|
|
10620
|
+
if (opts.step !== undefined) {
|
|
10621
|
+
var _render$step;
|
|
10622
|
+
var sliderStep = (_render$step = render.step) !== null && _render$step !== void 0 ? _render$step : opts.step;
|
|
10623
|
+
if (!isOnStep(sliderStep, 0, opts.step)) {
|
|
10624
|
+
throw new Error("".concat(where, ": the slider's step ").concat(sliderStep, " must be a multiple of the schema's step ").concat(opts.step));
|
|
10625
|
+
}
|
|
10626
|
+
if (!isOnStep(render.min, stepOrigin(opts), opts.step)) {
|
|
10627
|
+
throw new Error("".concat(where, ": the slider's min ").concat(render.min, " is not one of the schema's steps (").concat(opts.step, ", counted from ").concat(stepOrigin(opts), ")"));
|
|
10628
|
+
}
|
|
10629
|
+
}
|
|
10630
|
+
}
|
|
10431
10631
|
|
|
10432
10632
|
/**
|
|
10433
10633
|
* @deprecated Use {@link SerializedDiscriminatedUnionSchema} or
|
|
@@ -13206,6 +13406,7 @@ function initSchema(options) {
|
|
|
13206
13406
|
array: array,
|
|
13207
13407
|
object: object,
|
|
13208
13408
|
number: number,
|
|
13409
|
+
"int": _int,
|
|
13209
13410
|
discriminatedUnion: discriminatedUnion,
|
|
13210
13411
|
"enum": enumSchema,
|
|
13211
13412
|
union: union,
|
|
@@ -15116,7 +15317,7 @@ function deserializeSchema(serialized) {
|
|
|
15116
15317
|
return schema;
|
|
15117
15318
|
}
|
|
15118
15319
|
function deserializeSchemaImpl(serialized) {
|
|
15119
|
-
var _serialized$options, _serialized$options2, _serialized$multiline, _serialized$render, _serialized$accept, _serialized$dir, _serialized$remote, _serialized$jsonValue, _serialized$
|
|
15320
|
+
var _serialized$options, _serialized$options2, _serialized$multiline, _serialized$render, _serialized$render2, _serialized$accept, _serialized$dir, _serialized$remote, _serialized$jsonValue, _serialized$render3, _serialized$external, _serialized$render4, _serialized$render5, _serialized$remote2, _serialized$readonly, _serialized$hidden;
|
|
15120
15321
|
switch (serialized.type) {
|
|
15121
15322
|
case "string":
|
|
15122
15323
|
return new StringSchema(_objectSpread2(_objectSpread2({}, serialized.options), {}, {
|
|
@@ -15128,7 +15329,7 @@ function deserializeSchemaImpl(serialized) {
|
|
|
15128
15329
|
case "boolean":
|
|
15129
15330
|
return new BooleanSchema(serialized.opt, [], false, false, serialized.description);
|
|
15130
15331
|
case "number":
|
|
15131
|
-
return new NumberSchema(serialized.options, serialized.opt, [], false, false, serialized.description);
|
|
15332
|
+
return new NumberSchema(serialized.options, serialized.opt, [], false, false, serialized.description, null, (_serialized$render = serialized.render) !== null && _serialized$render !== void 0 ? _serialized$render : null);
|
|
15132
15333
|
case "object":
|
|
15133
15334
|
return new ObjectSchema(Object.fromEntries(Object.entries(serialized.items).map(function (_ref) {
|
|
15134
15335
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
@@ -15151,7 +15352,7 @@ function deserializeSchemaImpl(serialized) {
|
|
|
15151
15352
|
case "array":
|
|
15152
15353
|
return new ArraySchema(deserializeSchema(serialized.item), serialized.opt, [], false, false, serialized.description,
|
|
15153
15354
|
// The preview closure cannot survive serialization; the render can.
|
|
15154
|
-
null, (_serialized$
|
|
15355
|
+
null, (_serialized$render2 = serialized.render) !== null && _serialized$render2 !== void 0 ? _serialized$render2 : null);
|
|
15155
15356
|
case "discriminated-union":
|
|
15156
15357
|
return new DiscriminatedUnionSchema(serialized.key,
|
|
15157
15358
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -15180,12 +15381,12 @@ function deserializeSchemaImpl(serialized) {
|
|
|
15180
15381
|
altSchema: serialized.alt ? deserializeSchema(serialized.alt) : undefined
|
|
15181
15382
|
} : undefined, false, false, serialized.description, (_serialized$jsonValue = serialized.jsonValues) !== null && _serialized$jsonValue !== void 0 ? _serialized$jsonValue : false,
|
|
15182
15383
|
// The preview closure cannot survive serialization; the render can.
|
|
15183
|
-
null, (_serialized$
|
|
15384
|
+
null, (_serialized$render3 = serialized.render) !== null && _serialized$render3 !== void 0 ? _serialized$render3 : null, // The external label is static data, so it survives serialization and
|
|
15184
15385
|
// must be carried back: a deserialized schema that forgot it would walk
|
|
15185
15386
|
// an external record as if its entries were local.
|
|
15186
15387
|
(_serialized$external = serialized.external) !== null && _serialized$external !== void 0 ? _serialized$external : null);
|
|
15187
15388
|
case "keyOf":
|
|
15188
|
-
return new KeyOfSchema(serialized.schema, serialized.path, serialized.opt, [], false, false, serialized.description, (_serialized$
|
|
15389
|
+
return new KeyOfSchema(serialized.schema, serialized.path, serialized.opt, [], false, false, serialized.description, (_serialized$render4 = serialized.render) !== null && _serialized$render4 !== void 0 ? _serialized$render4 : null);
|
|
15189
15390
|
case "locale":
|
|
15190
15391
|
{
|
|
15191
15392
|
return new LocaleSchema(serialized.opt, [], false, false, serialized.description);
|
|
@@ -15203,7 +15404,7 @@ function deserializeSchemaImpl(serialized) {
|
|
|
15203
15404
|
case "image":
|
|
15204
15405
|
return new ImageSchema(serialized.options, serialized.opt, serialized.remote, [], {}, false, false, serialized.description);
|
|
15205
15406
|
case "video":
|
|
15206
|
-
return new VideoSchema(serialized.options, serialized.opt, serialized.remote, [], false, false, serialized.description, (_serialized$
|
|
15407
|
+
return new VideoSchema(serialized.options, serialized.opt, serialized.remote, [], false, false, serialized.description, (_serialized$render5 = serialized.render) !== null && _serialized$render5 !== void 0 ? _serialized$render5 : null, null, serialized.referencedModule ? {
|
|
15207
15408
|
modulePath: serialized.referencedModule,
|
|
15208
15409
|
entries: null,
|
|
15209
15410
|
remote: (_serialized$remote2 = serialized.remote) !== null && _serialized$remote2 !== void 0 ? _serialized$remote2 : false
|
|
@@ -15262,11 +15463,12 @@ function deserializeSchemaImpl(serialized) {
|
|
|
15262
15463
|
*/
|
|
15263
15464
|
/**
|
|
15264
15465
|
* A RENDER is how a field is laid out in the editor, and it applies only when
|
|
15265
|
-
* you are looking at the field.
|
|
15266
|
-
* children, never by a child about itself: `s.array(item).render({ as: "inline" })`
|
|
15267
|
-
* and `s.record(item).render({ as: "inline" })`.
|
|
15268
|
-
*
|
|
15269
|
-
* `KeyOfSchema.render`).
|
|
15466
|
+
* you are looking at the field. On a list it is declared by the CONTAINER about
|
|
15467
|
+
* its children, never by a child about itself: `s.array(item).render({ as: "inline" })`
|
|
15468
|
+
* and `s.record(item).render({ as: "inline" })`. Two other schemas take a
|
|
15469
|
+
* render, each meaning something of its own: `s.keyOf(...)` (see
|
|
15470
|
+
* `KeyOfSchema.render`) and `s.number()` / `s.int()`, whose `{ as: "slider" }`
|
|
15471
|
+
* is a different input for the same value (see {@link SliderRender}).
|
|
15270
15472
|
*
|
|
15271
15473
|
* Why the container: inline is a property of the LIST — "my items are edited in
|
|
15272
15474
|
* their rows" — and the item schema is the wrong place to say it. An item can be
|
|
@@ -15322,6 +15524,33 @@ function deserializeSchemaImpl(serialized) {
|
|
|
15322
15524
|
* What `.render(...)` takes, and what the serialized schema carries verbatim.
|
|
15323
15525
|
*/
|
|
15324
15526
|
|
|
15527
|
+
/**
|
|
15528
|
+
* `{ as: "slider", min, max }` on `s.int()` or `s.number()`: the value is
|
|
15529
|
+
* edited with a slider from `min` to `max`, next to a box that takes a typed
|
|
15530
|
+
* value.
|
|
15531
|
+
*
|
|
15532
|
+
* `min` and `max` are REQUIRED, because a slider without ends is not a slider.
|
|
15533
|
+
* They are the slider's own and are not validation: a value outside them is
|
|
15534
|
+
* still valid content (if the schema allows it), and the field says it is out
|
|
15535
|
+
* of the slider's reach and offers to bring it back. What the schema accepts is
|
|
15536
|
+
* `.min()`, `.max()` and `.step()` on the schema itself.
|
|
15537
|
+
*
|
|
15538
|
+
* The one rule tying the two together: **the slider may only produce values
|
|
15539
|
+
* the schema accepts.** So its range has to lie inside the schema's, its step
|
|
15540
|
+
* has to be a multiple of the schema's step and its `min` on the schema's grid,
|
|
15541
|
+
* and on `s.int()` all of them have to be whole numbers. A schema that breaks
|
|
15542
|
+
* that throws where it is defined — see `NumberSchema`.
|
|
15543
|
+
*
|
|
15544
|
+
* `step` defaults to the schema's `.step()`, and to 1 when there is none.
|
|
15545
|
+
*
|
|
15546
|
+
* Unlike `inline` this is about the field itself — no list reads it, and
|
|
15547
|
+
* {@link isInlineRender} answers `false` for it.
|
|
15548
|
+
*/
|
|
15549
|
+
|
|
15550
|
+
/**
|
|
15551
|
+
* What `s.number().render(...)` and `s.int().render(...)` take.
|
|
15552
|
+
*/
|
|
15553
|
+
|
|
15325
15554
|
/**
|
|
15326
15555
|
* Does this CONTAINER edit its items inside their list rows, rather than behind
|
|
15327
15556
|
* clickable preview rows that navigate to them?
|
|
@@ -15903,7 +16132,7 @@ function isPageRouter(routerId) {
|
|
|
15903
16132
|
|
|
15904
16133
|
var corePackageJson = {
|
|
15905
16134
|
name: "@valbuild/core",
|
|
15906
|
-
version: "0.
|
|
16135
|
+
version: "0.145.0",
|
|
15907
16136
|
"private": false,
|
|
15908
16137
|
description: "Val - supercharged hard-coded content",
|
|
15909
16138
|
repository: {
|
|
@@ -16030,6 +16259,11 @@ var Internal = {
|
|
|
16030
16259
|
rejectScheme: rejectScheme,
|
|
16031
16260
|
schemeOf: schemeOf,
|
|
16032
16261
|
UNSAFE_URL_SCHEMES: UNSAFE_URL_SCHEMES,
|
|
16262
|
+
number: {
|
|
16263
|
+
nearestAllowedNumber: nearestAllowedNumber,
|
|
16264
|
+
isOnStep: isOnStep,
|
|
16265
|
+
stepOrigin: stepOrigin
|
|
16266
|
+
},
|
|
16033
16267
|
color: {
|
|
16034
16268
|
parseColor: parseColor,
|
|
16035
16269
|
formatColor: formatColor,
|