@valbuild/core 0.138.0 → 0.139.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 +44 -0
- package/dist/declarations/src/index.d.ts +2 -0
- package/dist/declarations/src/render.d.ts +36 -33
- package/dist/declarations/src/schema/array.d.ts +13 -8
- package/dist/declarations/src/schema/boolean.d.ts +1 -17
- package/dist/declarations/src/schema/code.d.ts +1 -21
- package/dist/declarations/src/schema/color.d.ts +1 -19
- package/dist/declarations/src/schema/date.d.ts +1 -17
- package/dist/declarations/src/schema/datetime.d.ts +1 -19
- package/dist/declarations/src/schema/discriminatedUnion.d.ts +1 -23
- package/dist/declarations/src/schema/enum.d.ts +1 -19
- package/dist/declarations/src/schema/file.d.ts +1 -19
- package/dist/declarations/src/schema/image.d.ts +1 -24
- package/dist/declarations/src/schema/keyOf.d.ts +14 -6
- package/dist/declarations/src/schema/literal.d.ts +1 -17
- package/dist/declarations/src/schema/locale.d.ts +1 -14
- package/dist/declarations/src/schema/number.d.ts +1 -17
- package/dist/declarations/src/schema/object.d.ts +1 -23
- package/dist/declarations/src/schema/record.d.ts +12 -6
- package/dist/declarations/src/schema/richtext.d.ts +1 -19
- package/dist/declarations/src/schema/route.d.ts +1 -17
- package/dist/declarations/src/schema/settings.d.ts +8 -12
- package/dist/declarations/src/schema/string.d.ts +1 -26
- package/dist/declarations/src/schema/view.d.ts +1 -20
- package/dist/declarations/src/source/filename.d.ts +37 -0
- package/dist/{index-3296fc4f.cjs.prod.js → index-8920ba3f.cjs.prod.js} +324 -625
- package/dist/{index-a25822a3.esm.js → index-d949d13b.esm.js} +324 -625
- package/dist/{index-d3c51a0d.cjs.dev.js → index-e13b725c.cjs.dev.js} +324 -625
- 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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
# @valbuild/core
|
|
2
2
|
|
|
3
|
+
## 0.139.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#776](https://github.com/valbuild/val/pull/776) [`3eb5031`](https://github.com/valbuild/val/commit/3eb503167ae466ee586303c95efcc14665129481) Thanks [@freekh](https://github.com/freekh)! - **Breaking:** `.render({ as: "inline" })` now goes on the list, not on its items.
|
|
8
|
+
|
|
9
|
+
You now write `s.array(item).render({ as: "inline" })` and `s.record(item).render({ as: "inline" })`. Each item is then edited in its own row instead of in a preview row you click into. The list decides. The item schema stays reusable, and a page builder made of tagged blocks needs nothing on each block:
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
// before
|
|
13
|
+
s.array(
|
|
14
|
+
s.discriminatedUnion(
|
|
15
|
+
"type",
|
|
16
|
+
hero.render({ as: "inline" }),
|
|
17
|
+
text.render({ as: "inline" }),
|
|
18
|
+
),
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
// after
|
|
22
|
+
s.array(s.discriminatedUnion("type", hero, text)).render({ as: "inline" });
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
What changed:
|
|
26
|
+
|
|
27
|
+
- Only `s.array()`, `s.record()` and `s.keyOf()` have `.render(...)` now. On every other schema the method is gone, so the old placement shows up as a type error. Move the render out one level.
|
|
28
|
+
- The render only affects the list's own items. A list nested inside one of those items keeps its default unless it has its own `.render`.
|
|
29
|
+
- `s.router()`, `s.imageset()` and `s.fileset()` throw if you give them a render, because pages and media have their own editors.
|
|
30
|
+
- `s.keyOf(...).render({ as: "inline" })` means the same as before: the selected entry's content is shown below the dropdown.
|
|
31
|
+
|
|
32
|
+
**Watch for one case that still compiles:** an array or record that is itself the item of another list. `s.record(s.array(s.string()).render({ as: "inline" }))` used to show the record's arrays inline. Now it shows each array's strings inline. To keep the old layout, write `s.record(s.array(s.string())).render({ as: "inline" })`.
|
|
33
|
+
|
|
34
|
+
## 0.138.2
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- [#760](https://github.com/valbuild/val/pull/760) [`cf3bbc8`](https://github.com/valbuild/val/commit/cf3bbc8fc89ff349aac5ab101d0b4f28164583e6) Thanks [@freekh](https://github.com/freekh)! - Files and images can now be renamed in the Studio, for local files and remote ones.
|
|
39
|
+
|
|
40
|
+
- **Rename a file in a gallery** from its properties: click the pencil next to the file name. Every field that uses the file is updated to the new name in the same step, including images inside rich text, and the dialog says how many places will change before you save.
|
|
41
|
+
- **Rename the file of an image or file field** with the new **Rename** button. A field that picks its file from a gallery sends you to the gallery instead, because other fields may use the same file.
|
|
42
|
+
- **You choose the name, Val keeps the rest.** The short hash at the end of the name (`_a1b2c`) and the file extension stay as they are, so two different files can never end up with the same name. The name is cleaned up the same way an upload's is: lower case, and characters that do not belong in a URL are dropped.
|
|
43
|
+
- **Renaming a local file moves it.** The file is saved under the new name and the old file is deleted when you publish, so nothing is left behind to clean up. If another field uses the same file without going through a gallery, pick the file again in that field.
|
|
44
|
+
- **Renaming a remote file is instant.** Remote files are stored by their content, so a published remote file only gets a new address and nothing is uploaded again.
|
|
45
|
+
- **Gallery images used in rich text now count as references.** A gallery file used only inside rich text could be deleted, which left the text pointing at nothing. It is now listed under the file's references and blocks the delete like any other use.
|
|
46
|
+
|
|
3
47
|
## 0.138.0
|
|
4
48
|
|
|
5
49
|
### Minor Changes
|
|
@@ -39,6 +39,7 @@ import { isJson, getJsonImport, resolveJsonValues } from "./source/json.js";
|
|
|
39
39
|
import { isExternal, hasInlineExternalEntries } from "./source/external.js";
|
|
40
40
|
import { createExternalFileRef, splitExternalFileRef, isExternalFileRef } from "./source/externalRef.js";
|
|
41
41
|
import { createRemoteRef } from "./source/remote.js";
|
|
42
|
+
import { createRenamedFilename } from "./source/filename.js";
|
|
42
43
|
import { getValidationBasis, getValidationHash } from "./remote/validationBasis.js";
|
|
43
44
|
import { getFileHash, hashToRemoteFileHash } from "./remote/fileHash.js";
|
|
44
45
|
import { splitRemoteRef } from "./remote/splitRemoteRef.js";
|
|
@@ -233,5 +234,6 @@ declare const Internal: {
|
|
|
233
234
|
VAL_STATE_COOKIE: "val_state";
|
|
234
235
|
VAL_SESSION_COOKIE: "val_session";
|
|
235
236
|
createFilename: (data: string | null, filename: string | null, metadata: FileMetadata | ImageMetadata | undefined, sha256: string) => string | null;
|
|
237
|
+
createRenamedFilename: typeof createRenamedFilename;
|
|
236
238
|
};
|
|
237
239
|
export { Internal };
|
|
@@ -26,9 +26,19 @@ import type { SerializedSchema } from "./schema/index.js";
|
|
|
26
26
|
* description still previews as `#3` until someone writes the preview.
|
|
27
27
|
*/
|
|
28
28
|
/**
|
|
29
|
-
* A RENDER is how
|
|
30
|
-
*
|
|
31
|
-
* array
|
|
29
|
+
* A RENDER is how a field is laid out in the editor, and it applies only when
|
|
30
|
+
* you are looking at the field. It is declared by a CONTAINER about its
|
|
31
|
+
* children, never by a child about itself: `s.array(item).render({ as: "inline" })`
|
|
32
|
+
* and `s.record(item).render({ as: "inline" })`. The one other schema that takes
|
|
33
|
+
* a render is `s.keyOf(...)`, where it means something of its own (see
|
|
34
|
+
* `KeyOfSchema.render`).
|
|
35
|
+
*
|
|
36
|
+
* Why the container: inline is a property of the LIST — "my items are edited in
|
|
37
|
+
* their rows" — and the item schema is the wrong place to say it. An item can be
|
|
38
|
+
* reused in a list that wants preview rows and one that wants forms; a tagged
|
|
39
|
+
* union had to be declared inline on every variant (or on any one of them,
|
|
40
|
+
* which was worse); and a schema that was not an item carried a setting that
|
|
41
|
+
* did nothing. Putting it on the container makes all three go away.
|
|
32
42
|
*
|
|
33
43
|
* It is deliberately the ONE thing a render can say. What a string looks like
|
|
34
44
|
* when it holds more than a line is the schema's own business — `.multiline()`
|
|
@@ -45,7 +55,7 @@ import type { SerializedSchema } from "./schema/index.js";
|
|
|
45
55
|
*
|
|
46
56
|
* A render is static configuration - plain data, with no closure behind it and
|
|
47
57
|
* no dependency on source - which is why it lives in the SERIALIZED schema
|
|
48
|
-
* (`
|
|
58
|
+
* (`SerializedArraySchema.render`) and is read straight off it where the field
|
|
49
59
|
* is drawn. There is no render pipeline, no store and no host round-trip.
|
|
50
60
|
*
|
|
51
61
|
* That "static" is an ASSUMPTION we are taking deliberately, for simplicity,
|
|
@@ -56,49 +66,42 @@ import type { SerializedSchema } from "./schema/index.js";
|
|
|
56
66
|
* conflating them is what this file was split up to undo.
|
|
57
67
|
*/
|
|
58
68
|
/**
|
|
59
|
-
* `{ as: "inline" }` on
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
69
|
+
* `{ as: "inline" }` on an array or record: the container renders each of its
|
|
70
|
+
* DIRECT items' own editor inside its (sortable) row, instead of a clickable
|
|
71
|
+
* preview row that navigates to it. This is what a page-builder list is made
|
|
72
|
+
* of: `s.array(s.discriminatedUnion("type", hero, text)).render({ as: "inline" })`.
|
|
73
|
+
*
|
|
74
|
+
* It reaches one level down and no further: in
|
|
75
|
+
* `s.array(s.object({ tags: s.array(s.string()) })).render({ as: "inline" })`
|
|
76
|
+
* the objects are inline and `tags` keeps its own default.
|
|
63
77
|
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
78
|
+
* Not available on `s.router(...)`, `s.imageset(...)` or `s.fileset(...)`:
|
|
79
|
+
* pages and media have UIs of their own, and `RecordSchema.render` throws there.
|
|
66
80
|
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
81
|
+
* On `s.keyOf(...)` the same value means something else: the selected entry's
|
|
82
|
+
* content is shown below the selector. That is the keyOf field's own layout,
|
|
83
|
+
* and is not read by any list.
|
|
70
84
|
*/
|
|
71
85
|
export type InlineRender = {
|
|
72
86
|
as: "inline";
|
|
73
87
|
};
|
|
74
88
|
/**
|
|
75
|
-
* What `.render(...)` takes
|
|
76
|
-
* carries verbatim.
|
|
89
|
+
* What `.render(...)` takes, and what the serialized schema carries verbatim.
|
|
77
90
|
*/
|
|
78
91
|
export type FieldRender = InlineRender;
|
|
79
92
|
/**
|
|
80
|
-
*
|
|
81
|
-
* clickable preview
|
|
93
|
+
* Does this CONTAINER edit its items inside their list rows, rather than behind
|
|
94
|
+
* clickable preview rows that navigate to them?
|
|
95
|
+
*
|
|
96
|
+
* Pass the array or record — never the item. Anything else answers `false`,
|
|
97
|
+
* `s.keyOf` included: its render is about the keyOf field, not about a list.
|
|
82
98
|
*
|
|
83
99
|
* The one answer, so that the list rows, the nav-stop rule (`getNavPath`) and
|
|
84
100
|
* the add buttons cannot drift apart — they are three readings of the same
|
|
85
101
|
* question, and a disagreement between them is a row you can edit in place but
|
|
86
102
|
* that "add" navigates away from.
|
|
87
103
|
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* `s.array(s.discriminatedUnion("type", block, block, ...))` and the natural
|
|
91
|
-
* place to write the render is on the blocks, one per block type — the union
|
|
92
|
-
* is a dispatch, not something the
|
|
93
|
-
* author thinks of as the field. `some` rather than `every` because the row
|
|
94
|
-
* draws the union's own editor (the tag selector plus the matched variant's
|
|
95
|
-
* fields), which handles every variant either way: with `every`, adding one
|
|
96
|
-
* variant and forgetting its `.render` would silently turn the whole list back
|
|
97
|
-
* into preview rows.
|
|
98
|
-
*
|
|
99
|
-
* This is the ONLY place a render is allowed to be read from anywhere but the
|
|
100
|
-
* schema it was declared on. It stays static (see the top of this file): the
|
|
101
|
-
* answer is a function of the serialized schema alone, never of the value the
|
|
102
|
-
* row happens to hold.
|
|
104
|
+
* It stays static (see the top of this file): the answer is a function of the
|
|
105
|
+
* serialized schema alone, never of the value the row happens to hold.
|
|
103
106
|
*/
|
|
104
|
-
export declare function isInlineRender(
|
|
107
|
+
export declare function isInlineRender(container: SerializedSchema): boolean;
|
|
@@ -6,7 +6,10 @@ import { ModuleFilePath, SourcePath } from "../val/index.js";
|
|
|
6
6
|
import { ValidationError, ValidationErrors } from "./validation/ValidationError.js";
|
|
7
7
|
export type SerializedArraySchema = {
|
|
8
8
|
type: "array";
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* How this array lays out its ITEMS: `{ as: "inline" }` edits each one in
|
|
11
|
+
* its row. Static config, carried whole — see `render.ts`.
|
|
12
|
+
*/
|
|
10
13
|
render?: FieldRender;
|
|
11
14
|
item: SerializedSchema;
|
|
12
15
|
opt: boolean;
|
|
@@ -124,17 +127,19 @@ export declare class ArraySchema<T extends Schema<SelectorSource>, Src extends S
|
|
|
124
127
|
*/
|
|
125
128
|
preview(select: ItemPreviewInput<Src>): ArraySchema<T, Src>;
|
|
126
129
|
/**
|
|
127
|
-
* How this
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
+
* How this array lays out its ITEMS in the editor: `{ as: "inline" }` draws
|
|
131
|
+
* each item's own editor inside its (sortable) row, instead of a preview row
|
|
132
|
+
* that navigates to it. It reaches the direct items only.
|
|
130
133
|
*
|
|
131
134
|
* Static configuration, not a callback — see `render.ts`.
|
|
132
135
|
*
|
|
133
136
|
* @example
|
|
134
|
-
* const schema = s
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
137
|
+
* const schema = s
|
|
138
|
+
* .array(s.object({ title: s.string(), body: s.string() }))
|
|
139
|
+
* .render({ as: "inline" });
|
|
140
|
+
* export default c.define("/example.val.ts", schema, [
|
|
141
|
+
* { title: "Hello", body: "World" },
|
|
142
|
+
* ]);
|
|
138
143
|
*/
|
|
139
144
|
render(input: FieldRender): ArraySchema<T, Src>;
|
|
140
145
|
}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { CustomValidateFunction, Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
|
|
2
2
|
import { ItemPreviewInput, PreviewItem } from "../preview.js";
|
|
3
|
-
import { FieldRender } from "../render.js";
|
|
4
3
|
import { SourcePath } from "../val/index.js";
|
|
5
4
|
import { ValidationError, ValidationErrors } from "./validation/ValidationError.js";
|
|
6
5
|
export type SerializedBooleanSchema = {
|
|
7
6
|
type: "boolean";
|
|
8
|
-
/** Static layout config, carried whole in the serialized schema — see `render.ts`. */
|
|
9
|
-
render?: FieldRender;
|
|
10
7
|
/** Set when this schema declares a `preview`. The closure itself cannot serialize. */
|
|
11
8
|
preview?: true;
|
|
12
9
|
opt: boolean;
|
|
@@ -21,9 +18,8 @@ export declare class BooleanSchema<Src extends boolean | null> extends Schema<Sr
|
|
|
21
18
|
private readonly isReadonly;
|
|
22
19
|
private readonly isHidden;
|
|
23
20
|
private readonly description?;
|
|
24
|
-
private readonly renderInput;
|
|
25
21
|
private readonly previewInput;
|
|
26
|
-
constructor(opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined,
|
|
22
|
+
constructor(opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined, previewInput?: ItemPreviewInput<Src> | null);
|
|
27
23
|
/**
|
|
28
24
|
* Describe this field.
|
|
29
25
|
*
|
|
@@ -69,18 +65,6 @@ export declare class BooleanSchema<Src extends boolean | null> extends Schema<Sr
|
|
|
69
65
|
readonly(isReadonly?: boolean): BooleanSchema<Src>;
|
|
70
66
|
hidden(isHidden?: boolean): BooleanSchema<Src>;
|
|
71
67
|
protected executeCustomValidateAt(path: SourcePath, src: Src): ValidationError[];
|
|
72
|
-
/**
|
|
73
|
-
* How this field is laid out in the editor when it is the item of an array
|
|
74
|
-
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
75
|
-
* instead of a preview row that navigates to it.
|
|
76
|
-
*
|
|
77
|
-
* Static configuration, not a callback — see `render.ts`.
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* const schema = s.array(s.boolean().render({ as: "inline" }));
|
|
81
|
-
* export default c.define("/example.val.ts", schema, [true, false]);
|
|
82
|
-
*/
|
|
83
|
-
render(input: FieldRender): BooleanSchema<Src>;
|
|
84
68
|
/**
|
|
85
69
|
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
86
70
|
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CustomValidateFunction, Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
|
|
2
2
|
import { ItemPreviewInput, PreviewItem } from "../preview.js";
|
|
3
|
-
import { FieldRender } from "../render.js";
|
|
4
3
|
import { SourcePath } from "../val/index.js";
|
|
5
4
|
import { RawString } from "./string.js";
|
|
6
5
|
import { ValidationError, ValidationErrors } from "./validation/ValidationError.js";
|
|
@@ -26,8 +25,6 @@ export type CodeOptions = {
|
|
|
26
25
|
};
|
|
27
26
|
export type SerializedCodeSchema = {
|
|
28
27
|
type: "code";
|
|
29
|
-
/** Static layout config, carried whole in the serialized schema — see `render.ts`. */
|
|
30
|
-
render?: FieldRender;
|
|
31
28
|
/** Set when this schema declares a `preview`. The closure itself cannot serialize. */
|
|
32
29
|
preview?: true;
|
|
33
30
|
options?: CodeOptions;
|
|
@@ -52,9 +49,8 @@ export declare class CodeSchema<Src extends string | null> extends Schema<Src> {
|
|
|
52
49
|
private readonly isReadonly;
|
|
53
50
|
private readonly isHidden;
|
|
54
51
|
private readonly description?;
|
|
55
|
-
private readonly renderInput;
|
|
56
52
|
private readonly previewInput;
|
|
57
|
-
constructor(options?: CodeOptions | undefined, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined,
|
|
53
|
+
constructor(options?: CodeOptions | undefined, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined, previewInput?: ItemPreviewInput<Src> | null);
|
|
58
54
|
/**
|
|
59
55
|
* Describe this field.
|
|
60
56
|
*
|
|
@@ -111,22 +107,6 @@ export declare class CodeSchema<Src extends string | null> extends Schema<Src> {
|
|
|
111
107
|
nullable(): CodeSchema<Src | null>;
|
|
112
108
|
readonly(isReadonly?: boolean): CodeSchema<Src>;
|
|
113
109
|
hidden(isHidden?: boolean): CodeSchema<Src>;
|
|
114
|
-
/**
|
|
115
|
-
* How this field is laid out in the editor when it is the item of an array
|
|
116
|
-
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
117
|
-
* instead of a preview row that navigates to it.
|
|
118
|
-
*
|
|
119
|
-
* Static configuration, not a callback — see `render.ts`.
|
|
120
|
-
*
|
|
121
|
-
* @example
|
|
122
|
-
* const schema = s.array(
|
|
123
|
-
* s.code({ language: "css" }).render({ as: "inline" }),
|
|
124
|
-
* );
|
|
125
|
-
* export default c.define("/example.val.ts", schema, [
|
|
126
|
-
* ".hero { color: red; }",
|
|
127
|
-
* ]);
|
|
128
|
-
*/
|
|
129
|
-
render(input: FieldRender): CodeSchema<Src>;
|
|
130
110
|
/**
|
|
131
111
|
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
132
112
|
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CustomValidateFunction, Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
|
|
2
2
|
import { ItemPreviewInput, PreviewItem } from "../preview.js";
|
|
3
|
-
import { FieldRender } from "../render.js";
|
|
4
3
|
import { SourcePath } from "../val/index.js";
|
|
5
4
|
import { ColorFormat } from "./colorFormat.js";
|
|
6
5
|
import { RawString } from "./string.js";
|
|
@@ -29,8 +28,6 @@ export type ColorOptions = {
|
|
|
29
28
|
};
|
|
30
29
|
export type SerializedColorSchema = {
|
|
31
30
|
type: "color";
|
|
32
|
-
/** Static layout config, carried whole in the serialized schema — see `render.ts`. */
|
|
33
|
-
render?: FieldRender;
|
|
34
31
|
/** Set when this schema declares a `preview`. The closure itself cannot serialize. */
|
|
35
32
|
preview?: true;
|
|
36
33
|
options?: ColorOptions;
|
|
@@ -47,9 +44,8 @@ export declare class ColorSchema<Src extends string | null> extends Schema<Src>
|
|
|
47
44
|
private readonly isReadonly;
|
|
48
45
|
private readonly isHidden;
|
|
49
46
|
private readonly description?;
|
|
50
|
-
private readonly renderInput;
|
|
51
47
|
private readonly previewInput;
|
|
52
|
-
constructor(options?: ColorOptions | undefined, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined,
|
|
48
|
+
constructor(options?: ColorOptions | undefined, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined, previewInput?: ItemPreviewInput<Src> | null);
|
|
53
49
|
/**
|
|
54
50
|
* Describe this field.
|
|
55
51
|
*
|
|
@@ -101,20 +97,6 @@ export declare class ColorSchema<Src extends string | null> extends Schema<Src>
|
|
|
101
97
|
nullable(): ColorSchema<Src | null>;
|
|
102
98
|
readonly(isReadonly?: boolean): ColorSchema<Src>;
|
|
103
99
|
hidden(isHidden?: boolean): ColorSchema<Src>;
|
|
104
|
-
/**
|
|
105
|
-
* How this field is laid out in the editor when it is the item of an array
|
|
106
|
-
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
107
|
-
* instead of a preview row that navigates to it.
|
|
108
|
-
*
|
|
109
|
-
* Static configuration, not a callback — see `render.ts`.
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* const schema = s.array(s.color().render({ as: "inline" }));
|
|
113
|
-
* export default c.define("/example.val.ts", schema, [
|
|
114
|
-
* "hsl(217.22 91.22% 59.8%)",
|
|
115
|
-
* ]);
|
|
116
|
-
*/
|
|
117
|
-
render(input: FieldRender): ColorSchema<Src>;
|
|
118
100
|
/**
|
|
119
101
|
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
120
102
|
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CustomValidateFunction, Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
|
|
2
2
|
import { ItemPreviewInput, PreviewItem } from "../preview.js";
|
|
3
|
-
import { FieldRender } from "../render.js";
|
|
4
3
|
import { SourcePath } from "../val/index.js";
|
|
5
4
|
import { RawString } from "./string.js";
|
|
6
5
|
import { ValidationError, ValidationErrors } from "./validation/ValidationError.js";
|
|
@@ -22,8 +21,6 @@ type DateOptions = {
|
|
|
22
21
|
};
|
|
23
22
|
export type SerializedDateSchema = {
|
|
24
23
|
type: "date";
|
|
25
|
-
/** Static layout config, carried whole in the serialized schema — see `render.ts`. */
|
|
26
|
-
render?: FieldRender;
|
|
27
24
|
/** Set when this schema declares a `preview`. The closure itself cannot serialize. */
|
|
28
25
|
preview?: true;
|
|
29
26
|
options?: DateOptions;
|
|
@@ -40,9 +37,8 @@ export declare class DateSchema<Src extends string | null> extends Schema<Src> {
|
|
|
40
37
|
private readonly isReadonly;
|
|
41
38
|
private readonly isHidden;
|
|
42
39
|
private readonly description?;
|
|
43
|
-
private readonly renderInput;
|
|
44
40
|
private readonly previewInput;
|
|
45
|
-
constructor(options?: DateOptions | undefined, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined,
|
|
41
|
+
constructor(options?: DateOptions | undefined, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined, previewInput?: ItemPreviewInput<Src> | null);
|
|
46
42
|
/**
|
|
47
43
|
* Describe this field.
|
|
48
44
|
*
|
|
@@ -108,18 +104,6 @@ export declare class DateSchema<Src extends string | null> extends Schema<Src> {
|
|
|
108
104
|
readonly(isReadonly?: boolean): DateSchema<Src>;
|
|
109
105
|
hidden(isHidden?: boolean): DateSchema<Src>;
|
|
110
106
|
protected executeCustomValidateAt(path: SourcePath, src: Src): ValidationError[];
|
|
111
|
-
/**
|
|
112
|
-
* How this field is laid out in the editor when it is the item of an array
|
|
113
|
-
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
114
|
-
* instead of a preview row that navigates to it.
|
|
115
|
-
*
|
|
116
|
-
* Static configuration, not a callback — see `render.ts`.
|
|
117
|
-
*
|
|
118
|
-
* @example
|
|
119
|
-
* const schema = s.array(s.date().render({ as: "inline" }));
|
|
120
|
-
* export default c.define("/example.val.ts", schema, ["2025-06-01"]);
|
|
121
|
-
*/
|
|
122
|
-
render(input: FieldRender): DateSchema<Src>;
|
|
123
107
|
/**
|
|
124
108
|
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
125
109
|
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CustomValidateFunction, Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
|
|
2
2
|
import { ItemPreviewInput, PreviewItem } from "../preview.js";
|
|
3
|
-
import { FieldRender } from "../render.js";
|
|
4
3
|
import { SourcePath } from "../val/index.js";
|
|
5
4
|
import { RawString } from "./string.js";
|
|
6
5
|
import { ValidationError, ValidationErrors } from "./validation/ValidationError.js";
|
|
@@ -26,8 +25,6 @@ type DateTimeOptions = {
|
|
|
26
25
|
};
|
|
27
26
|
export type SerializedDateTimeSchema = {
|
|
28
27
|
type: "dateTime";
|
|
29
|
-
/** Static layout config, carried whole in the serialized schema — see `render.ts`. */
|
|
30
|
-
render?: FieldRender;
|
|
31
28
|
/** Set when this schema declares a `preview`. The closure itself cannot serialize. */
|
|
32
29
|
preview?: true;
|
|
33
30
|
options?: DateTimeOptions;
|
|
@@ -44,9 +41,8 @@ export declare class DateTimeSchema<Src extends string | null> extends Schema<Sr
|
|
|
44
41
|
private readonly isReadonly;
|
|
45
42
|
private readonly isHidden;
|
|
46
43
|
private readonly description?;
|
|
47
|
-
private readonly renderInput;
|
|
48
44
|
private readonly previewInput;
|
|
49
|
-
constructor(options?: DateTimeOptions | undefined, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined,
|
|
45
|
+
constructor(options?: DateTimeOptions | undefined, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined, previewInput?: ItemPreviewInput<Src> | null);
|
|
50
46
|
/**
|
|
51
47
|
* Describe this field.
|
|
52
48
|
*
|
|
@@ -131,20 +127,6 @@ export declare class DateTimeSchema<Src extends string | null> extends Schema<Sr
|
|
|
131
127
|
readonly(isReadonly?: boolean): DateTimeSchema<Src>;
|
|
132
128
|
hidden(isHidden?: boolean): DateTimeSchema<Src>;
|
|
133
129
|
protected executeCustomValidateAt(path: SourcePath, src: Src): ValidationError[];
|
|
134
|
-
/**
|
|
135
|
-
* How this field is laid out in the editor when it is the item of an array
|
|
136
|
-
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
137
|
-
* instead of a preview row that navigates to it.
|
|
138
|
-
*
|
|
139
|
-
* Static configuration, not a callback — see `render.ts`.
|
|
140
|
-
*
|
|
141
|
-
* @example
|
|
142
|
-
* const schema = s.array(s.datetime().render({ as: "inline" }));
|
|
143
|
-
* export default c.define("/example.val.ts", schema, [
|
|
144
|
-
* "2025-06-01T09:00:00.000Z",
|
|
145
|
-
* ]);
|
|
146
|
-
*/
|
|
147
|
-
render(input: FieldRender): DateTimeSchema<Src>;
|
|
148
130
|
/**
|
|
149
131
|
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
150
132
|
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CustomValidateFunction, Schema, SchemaAssertResult } from "./index.js";
|
|
2
2
|
import { ItemPreviewInput, PreviewItem, ReifiedPreview, PreviewScope } from "../preview.js";
|
|
3
|
-
import { FieldRender } from "../render.js";
|
|
4
3
|
import { SelectorSource } from "../selector/index.js";
|
|
5
4
|
import { SourceObject } from "../source/index.js";
|
|
6
5
|
import { ModuleFilePath, SourcePath } from "../val/index.js";
|
|
@@ -8,8 +7,6 @@ import { SerializedObjectSchema } from "./object.js";
|
|
|
8
7
|
import { ValidationError, ValidationErrors } from "./validation/ValidationError.js";
|
|
9
8
|
export type SerializedDiscriminatedUnionSchema = {
|
|
10
9
|
type: "discriminated-union";
|
|
11
|
-
/** Static layout config, carried whole in the serialized schema — see `render.ts`. */
|
|
12
|
-
render?: FieldRender;
|
|
13
10
|
/** Set when this schema declares a `preview`. The closure itself cannot serialize. */
|
|
14
11
|
preview?: true;
|
|
15
12
|
/** The name of the field every variant tags itself with. */
|
|
@@ -56,9 +53,8 @@ export declare class DiscriminatedUnionSchema<Key extends string, T extends Disc
|
|
|
56
53
|
private readonly isReadonly;
|
|
57
54
|
private readonly isHidden;
|
|
58
55
|
private readonly description?;
|
|
59
|
-
private readonly renderInput;
|
|
60
56
|
private readonly previewInput;
|
|
61
|
-
constructor(key: Key, items: T, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined,
|
|
57
|
+
constructor(key: Key, items: T, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined, previewInput?: ItemPreviewInput<Src> | null);
|
|
62
58
|
/**
|
|
63
59
|
* Describe this field.
|
|
64
60
|
*
|
|
@@ -127,24 +123,6 @@ export declare class DiscriminatedUnionSchema<Key extends string, T extends Disc
|
|
|
127
123
|
* them — a structural error `executeValidate` already reports.
|
|
128
124
|
*/
|
|
129
125
|
private matchedVariant;
|
|
130
|
-
/**
|
|
131
|
-
* How this field is laid out in the editor when it is the item of an array
|
|
132
|
-
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
133
|
-
* instead of a preview row that navigates to it.
|
|
134
|
-
*
|
|
135
|
-
* Static configuration, not a callback — see `render.ts`.
|
|
136
|
-
*
|
|
137
|
-
* @example
|
|
138
|
-
* // A page builder: the row draws the tag selector and the matched
|
|
139
|
-
* // variant's fields.
|
|
140
|
-
* const hero = s.object({ type: s.literal("hero"), title: s.string() });
|
|
141
|
-
* const text = s.object({ type: s.literal("text"), body: s.string() });
|
|
142
|
-
* const block = s.discriminatedUnion("type", hero, text).render({ as: "inline" });
|
|
143
|
-
* export default c.define("/example.val.ts", s.array(block), [
|
|
144
|
-
* { type: "hero", title: "Hello" },
|
|
145
|
-
* ]);
|
|
146
|
-
*/
|
|
147
|
-
render(input: FieldRender): DiscriminatedUnionSchema<Key, T, Src>;
|
|
148
126
|
/**
|
|
149
127
|
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
150
128
|
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { CustomValidateFunction, Schema, SchemaAssertResult } from "./index.js";
|
|
2
2
|
import { ItemPreviewInput, PreviewItem } from "../preview.js";
|
|
3
|
-
import { FieldRender } from "../render.js";
|
|
4
3
|
import { SourcePath } from "../val/index.js";
|
|
5
4
|
import { ValidationError, ValidationErrors } from "./validation/ValidationError.js";
|
|
6
5
|
export type SerializedEnumSchema = {
|
|
7
6
|
type: "enum";
|
|
8
|
-
/** Static layout config, carried whole in the serialized schema — see `render.ts`. */
|
|
9
|
-
render?: FieldRender;
|
|
10
7
|
/** Set when this schema declares a `preview`. The closure itself cannot serialize. */
|
|
11
8
|
preview?: true;
|
|
12
9
|
/**
|
|
@@ -36,7 +33,6 @@ export declare class EnumSchema<Src extends string | null> extends Schema<Src> {
|
|
|
36
33
|
private readonly isReadonly;
|
|
37
34
|
private readonly isHidden;
|
|
38
35
|
private readonly description?;
|
|
39
|
-
private readonly renderInput;
|
|
40
36
|
private readonly previewInput;
|
|
41
37
|
/**
|
|
42
38
|
* Type-only marker: as a record key, this declares the key set.
|
|
@@ -47,7 +43,7 @@ export declare class EnumSchema<Src extends string | null> extends Schema<Src> {
|
|
|
47
43
|
* cannot be a record key at all. See `LocaleSchema`.
|
|
48
44
|
*/
|
|
49
45
|
readonly __declaresRecordKeys: true;
|
|
50
|
-
constructor(values: readonly string[], opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined,
|
|
46
|
+
constructor(values: readonly string[], opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined, previewInput?: ItemPreviewInput<Src> | null);
|
|
51
47
|
/**
|
|
52
48
|
* Describe this field.
|
|
53
49
|
*
|
|
@@ -94,20 +90,6 @@ export declare class EnumSchema<Src extends string | null> extends Schema<Src> {
|
|
|
94
90
|
readonly(isReadonly?: boolean): EnumSchema<Src>;
|
|
95
91
|
hidden(isHidden?: boolean): EnumSchema<Src>;
|
|
96
92
|
protected executeCustomValidateAt(path: SourcePath, src: Src): ValidationError[];
|
|
97
|
-
/**
|
|
98
|
-
* How this field is laid out in the editor when it is the item of an array
|
|
99
|
-
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
100
|
-
* instead of a preview row that navigates to it.
|
|
101
|
-
*
|
|
102
|
-
* Static configuration, not a callback — see `render.ts`.
|
|
103
|
-
*
|
|
104
|
-
* @example
|
|
105
|
-
* const schema = s.array(
|
|
106
|
-
* s.enum("draft", "published").render({ as: "inline" }),
|
|
107
|
-
* );
|
|
108
|
-
* export default c.define("/example.val.ts", schema, ["draft"]);
|
|
109
|
-
*/
|
|
110
|
-
render(input: FieldRender): EnumSchema<Src>;
|
|
111
93
|
/**
|
|
112
94
|
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
113
95
|
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
@@ -5,15 +5,12 @@ import { ModulePath, SourcePath } from "../val/index.js";
|
|
|
5
5
|
import { ValidationError, ValidationErrors } from "./validation/ValidationError.js";
|
|
6
6
|
import { ValModule } from "../index.js";
|
|
7
7
|
import { ItemPreviewInput, PreviewItem } from "../preview.js";
|
|
8
|
-
import { FieldRender } from "../render.js";
|
|
9
8
|
import { FilesetEntryMetadata } from "./fileset.js";
|
|
10
9
|
export type FileOptions = {
|
|
11
10
|
accept?: string;
|
|
12
11
|
};
|
|
13
12
|
export type SerializedFileSchema = {
|
|
14
13
|
type: "file";
|
|
15
|
-
/** Static layout config, carried whole in the serialized schema — see `render.ts`. */
|
|
16
|
-
render?: FieldRender;
|
|
17
14
|
/** Set when this schema declares a `preview`. The closure itself cannot serialize. */
|
|
18
15
|
preview?: true;
|
|
19
16
|
options?: FileOptions;
|
|
@@ -34,9 +31,8 @@ export declare class FileSchema<Src extends FileSource | null> extends Schema<Sr
|
|
|
34
31
|
private readonly isReadonly;
|
|
35
32
|
private readonly isHidden;
|
|
36
33
|
private readonly description?;
|
|
37
|
-
private readonly renderInput;
|
|
38
34
|
private readonly previewInput;
|
|
39
|
-
constructor(options?: FileOptions | undefined, opt?: boolean, isRemote?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], moduleMetadata?: Record<ModulePath, Record<string, FilesetEntryMetadata>>, isReadonly?: boolean, isHidden?: boolean, description?: string | undefined,
|
|
35
|
+
constructor(options?: FileOptions | undefined, opt?: boolean, isRemote?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], moduleMetadata?: Record<ModulePath, Record<string, FilesetEntryMetadata>>, isReadonly?: boolean, isHidden?: boolean, description?: string | undefined, previewInput?: ItemPreviewInput<Src> | null);
|
|
40
36
|
/**
|
|
41
37
|
* Describe this field.
|
|
42
38
|
*
|
|
@@ -117,20 +113,6 @@ export declare class FileSchema<Src extends FileSource | null> extends Schema<Sr
|
|
|
117
113
|
readonly(isReadonly?: boolean): FileSchema<Src>;
|
|
118
114
|
hidden(isHidden?: boolean): FileSchema<Src>;
|
|
119
115
|
protected executeCustomValidateAt(path: SourcePath, src: Src): ValidationError[];
|
|
120
|
-
/**
|
|
121
|
-
* How this field is laid out in the editor when it is the item of an array
|
|
122
|
-
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
123
|
-
* instead of a preview row that navigates to it.
|
|
124
|
-
*
|
|
125
|
-
* Static configuration, not a callback — see `render.ts`.
|
|
126
|
-
*
|
|
127
|
-
* @example
|
|
128
|
-
* const schema = s.array(s.file().render({ as: "inline" }));
|
|
129
|
-
* export default c.define("/example.val.ts", schema, [
|
|
130
|
-
* { path: "/public/val/example.pdf", mimeType: "application/pdf" },
|
|
131
|
-
* ]);
|
|
132
|
-
*/
|
|
133
|
-
render(input: FieldRender): FileSchema<Src>;
|
|
134
116
|
/**
|
|
135
117
|
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
136
118
|
* sortable list, a reference dropdown, a search hit. Never how the field
|