@valbuild/core 0.106.0 → 0.109.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/declarations/src/index.d.ts +3 -3
  2. package/dist/declarations/src/initSchema.d.ts +20 -20
  3. package/dist/declarations/src/preview.d.ts +40 -2
  4. package/dist/declarations/src/render.d.ts +38 -9
  5. package/dist/declarations/src/schema/array.d.ts +24 -12
  6. package/dist/declarations/src/schema/boolean.d.ts +25 -2
  7. package/dist/declarations/src/schema/color.d.ts +25 -2
  8. package/dist/declarations/src/schema/date.d.ts +25 -2
  9. package/dist/declarations/src/schema/datetime.d.ts +25 -2
  10. package/dist/declarations/src/schema/file.d.ts +25 -2
  11. package/dist/declarations/src/schema/image.d.ts +25 -2
  12. package/dist/declarations/src/schema/index.d.ts +19 -1
  13. package/dist/declarations/src/schema/keyOf.d.ts +25 -2
  14. package/dist/declarations/src/schema/literal.d.ts +25 -2
  15. package/dist/declarations/src/schema/number.d.ts +25 -2
  16. package/dist/declarations/src/schema/object.d.ts +25 -2
  17. package/dist/declarations/src/schema/record.d.ts +25 -13
  18. package/dist/declarations/src/schema/richtext.d.ts +25 -2
  19. package/dist/declarations/src/schema/route.d.ts +25 -2
  20. package/dist/declarations/src/schema/string.d.ts +13 -2
  21. package/dist/declarations/src/schema/union.d.ts +32 -2
  22. package/dist/{index-eaee0a0b.cjs.prod.js → index-77914667.cjs.prod.js} +993 -188
  23. package/dist/{index-2cef45cc.cjs.dev.js → index-bce560db.cjs.dev.js} +993 -188
  24. package/dist/{index-193f19b4.esm.js → index-db33b67c.esm.js} +993 -188
  25. package/dist/valbuild-core.cjs.dev.js +1 -1
  26. package/dist/valbuild-core.cjs.prod.js +1 -1
  27. package/dist/valbuild-core.esm.js +1 -1
  28. package/package.json +2 -2
  29. package/patch/dist/valbuild-core-patch.cjs.dev.js +1 -1
  30. package/patch/dist/valbuild-core-patch.cjs.prod.js +1 -1
  31. package/patch/dist/valbuild-core-patch.esm.js +2 -2
@@ -19,7 +19,7 @@ import { SerializedRouteSchema } from "./route.js";
19
19
  import { ValidationError, ValidationErrors } from "./validation/ValidationError.js";
20
20
  import { FileSource } from "../source/media.js";
21
21
  import { GenericRichTextSourceNode, RichTextSource } from "../source/richtext.js";
22
- import { ReifiedPreview, PreviewScope } from "../preview.js";
22
+ import { ReifiedPreview, PreviewScope, PreviewItem } from "../preview.js";
23
23
  export type SerializedSchema = SerializedStringSchema | SerializedLiteralSchema | SerializedBooleanSchema | SerializedNumberSchema | SerializedObjectSchema | SerializedArraySchema | SerializedUnionSchema | SerializedRichTextSchema | SerializedRecordSchema | SerializedKeyOfSchema | SerializedFileSchema | SerializedDateSchema | SerializedDateTimeSchema | SerializedColorSchema | SerializedRouteSchema | SerializedImageSchema;
24
24
  type Primitives = number | string | boolean | null | FileSource;
25
25
  export type AssertError = {
@@ -114,6 +114,24 @@ export declare abstract class Schema<Src extends SelectorSource> {
114
114
  * its items are — which is the single-visible-row case.
115
115
  */
116
116
  protected abstract executePreview(sourcePath: SourcePath | ModuleFilePath, src: Src, scope?: PreviewScope): ReifiedPreview;
117
+ /**
118
+ * This value AS A PREVIEW — what a container's row, a reference dropdown or
119
+ * a search hit shows for it. Runs the schema's own `preview` closure;
120
+ * `null` when none is declared (the consumer falls back to a generic
121
+ * preview). A union dispatches to the matching member's closure.
122
+ *
123
+ * Containers call this on their ITEM schema per item — that is how
124
+ * `executePreview` reifies an {@link ArrayPreview} / {@link RecordPreview}
125
+ * from item-level declarations.
126
+ */
127
+ protected executePreviewItem(src: NonNullable<Src>): PreviewItem | null;
128
+ /**
129
+ * Could {@link executePreviewItem} ever answer? A container reifies a rows
130
+ * preview only when its item schema says yes — asked here rather than by
131
+ * running the closure, so an EMPTY list still previews as an empty list
132
+ * instead of not at all.
133
+ */
134
+ protected declaresItemPreview(): boolean;
117
135
  /** MUTATES! since internal and perf sensitive */
118
136
  protected appendValidationError(current: ValidationErrors, path: SourcePath, message: string, value: unknown, schemaError?: boolean): ValidationErrors;
119
137
  /**
@@ -5,9 +5,14 @@ import { Source, SourceObject } from "../source/index.js";
5
5
  import { SourcePath } from "../val/index.js";
6
6
  import { ValidationError, ValidationErrors } from "./validation/ValidationError.js";
7
7
  import { RawString } from "./string.js";
8
- import { ReifiedPreview } from "../preview.js";
8
+ import { ItemPreviewInput, PreviewItem, ReifiedPreview } from "../preview.js";
9
+ import { FieldRender } from "../render.js";
9
10
  export type SerializedKeyOfSchema = {
10
11
  type: "keyOf";
12
+ /** Static layout config, carried whole in the serialized schema — see `render.ts`. */
13
+ render?: FieldRender;
14
+ /** Set when this schema declares a `preview`. The closure itself cannot serialize. */
15
+ preview?: true;
11
16
  path: SourcePath;
12
17
  schema?: SerializedRefSchema | undefined;
13
18
  opt: boolean;
@@ -34,7 +39,9 @@ export declare class KeyOfSchema<Sel extends GenericSelector<SourceObject>, Src
34
39
  private readonly isReadonly;
35
40
  private readonly isHidden;
36
41
  private readonly description?;
37
- constructor(schema?: SerializedRefSchema | undefined, sourcePath?: SourcePath | undefined, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined);
42
+ private readonly renderInput;
43
+ private readonly previewInput;
44
+ constructor(schema?: SerializedRefSchema | undefined, sourcePath?: SourcePath | undefined, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined, renderInput?: FieldRender | null, previewInput?: ItemPreviewInput<Src> | null);
38
45
  describe(description: string | null): KeyOfSchema<Sel, Src>;
39
46
  validate(validationFunction: (src: Src) => false | string): KeyOfSchema<Sel, Src>;
40
47
  protected executeValidate(path: SourcePath, src: Src): ValidationErrors;
@@ -43,6 +50,22 @@ export declare class KeyOfSchema<Sel extends GenericSelector<SourceObject>, Src
43
50
  readonly(): KeyOfSchema<Sel, Src>;
44
51
  hidden(): KeyOfSchema<Sel, Src>;
45
52
  protected executeCustomValidateAt(path: SourcePath, src: Src): ValidationError[];
53
+ /**
54
+ * How this field is laid out in the editor when it is the item of an array
55
+ * or record: `{ as: "inline" }` renders the field itself inside each row,
56
+ * instead of a preview row that navigates to it.
57
+ *
58
+ * Static configuration, not a callback — see `render.ts`.
59
+ */
60
+ render(input: FieldRender): KeyOfSchema<Sel, Src>;
61
+ /**
62
+ * How this VALUE is shown where a preview of it is needed — a row in a
63
+ * sortable list, a reference dropdown, a search hit. Never how the field
64
+ * itself is edited (that is `render`). See `preview.ts`.
65
+ */
66
+ preview(select: ItemPreviewInput<Src>): KeyOfSchema<Sel, Src>;
67
+ protected executePreviewItem(src: NonNullable<Src>): PreviewItem | null;
68
+ protected declaresItemPreview(): boolean;
46
69
  protected executeSerialize(): SerializedSchema;
47
70
  protected executePreview(): ReifiedPreview;
48
71
  }
@@ -1,9 +1,14 @@
1
1
  import { CustomValidateFunction, Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
2
- import { ReifiedPreview } from "../preview.js";
2
+ import { ItemPreviewInput, PreviewItem, ReifiedPreview } from "../preview.js";
3
+ import { FieldRender } from "../render.js";
3
4
  import { SourcePath } from "../val/index.js";
4
5
  import { ValidationError, ValidationErrors } from "./validation/ValidationError.js";
5
6
  export type SerializedLiteralSchema = {
6
7
  type: "literal";
8
+ /** Static layout config, carried whole in the serialized schema — see `render.ts`. */
9
+ render?: FieldRender;
10
+ /** Set when this schema declares a `preview`. The closure itself cannot serialize. */
11
+ preview?: true;
7
12
  value: string;
8
13
  opt: boolean;
9
14
  customValidate?: boolean;
@@ -18,7 +23,9 @@ export declare class LiteralSchema<Src extends string | null> extends Schema<Src
18
23
  private readonly isReadonly;
19
24
  private readonly isHidden;
20
25
  private readonly description?;
21
- constructor(value: string, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined);
26
+ private readonly renderInput;
27
+ private readonly previewInput;
28
+ constructor(value: string, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined, renderInput?: FieldRender | null, previewInput?: ItemPreviewInput<Src> | null);
22
29
  describe(description: string | null): LiteralSchema<Src>;
23
30
  validate(validationFunction: (src: Src) => false | string): LiteralSchema<Src>;
24
31
  protected executeValidate(path: SourcePath, src: Src): ValidationErrors;
@@ -27,6 +34,22 @@ export declare class LiteralSchema<Src extends string | null> extends Schema<Src
27
34
  readonly(): LiteralSchema<Src>;
28
35
  hidden(): LiteralSchema<Src>;
29
36
  protected executeCustomValidateAt(path: SourcePath, src: Src): ValidationError[];
37
+ /**
38
+ * How this field is laid out in the editor when it is the item of an array
39
+ * or record: `{ as: "inline" }` renders the field itself inside each row,
40
+ * instead of a preview row that navigates to it.
41
+ *
42
+ * Static configuration, not a callback — see `render.ts`.
43
+ */
44
+ render(input: FieldRender): LiteralSchema<Src>;
45
+ /**
46
+ * How this VALUE is shown where a preview of it is needed — a row in a
47
+ * sortable list, a reference dropdown, a search hit. Never how the field
48
+ * itself is edited (that is `render`). See `preview.ts`.
49
+ */
50
+ preview(select: ItemPreviewInput<Src>): LiteralSchema<Src>;
51
+ protected executePreviewItem(src: NonNullable<Src>): PreviewItem | null;
52
+ protected declaresItemPreview(): boolean;
30
53
  protected executeSerialize(): SerializedSchema;
31
54
  protected executePreview(): ReifiedPreview;
32
55
  }
@@ -1,5 +1,6 @@
1
1
  import { CustomValidateFunction, Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
2
- import { ReifiedPreview } from "../preview.js";
2
+ import { ItemPreviewInput, PreviewItem, ReifiedPreview } from "../preview.js";
3
+ import { FieldRender } from "../render.js";
3
4
  import { SourcePath } from "../val/index.js";
4
5
  import { ValidationError, ValidationErrors } from "./validation/ValidationError.js";
5
6
  type NumberOptions = {
@@ -8,6 +9,10 @@ type NumberOptions = {
8
9
  };
9
10
  export type SerializedNumberSchema = {
10
11
  type: "number";
12
+ /** Static layout config, carried whole in the serialized schema — see `render.ts`. */
13
+ render?: FieldRender;
14
+ /** Set when this schema declares a `preview`. The closure itself cannot serialize. */
15
+ preview?: true;
11
16
  options?: NumberOptions;
12
17
  opt: boolean;
13
18
  customValidate?: boolean;
@@ -22,7 +27,9 @@ export declare class NumberSchema<Src extends number | null> extends Schema<Src>
22
27
  private readonly isReadonly;
23
28
  private readonly isHidden;
24
29
  private readonly description?;
25
- constructor(options?: NumberOptions | undefined, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined);
30
+ private readonly renderInput;
31
+ private readonly previewInput;
32
+ constructor(options?: NumberOptions | undefined, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined, renderInput?: FieldRender | null, previewInput?: ItemPreviewInput<Src> | null);
26
33
  describe(description: string | null): NumberSchema<Src>;
27
34
  validate(validationFunction: (src: Src) => false | string): NumberSchema<Src>;
28
35
  protected executeValidate(path: SourcePath, src: Src): ValidationErrors;
@@ -33,6 +40,22 @@ export declare class NumberSchema<Src extends number | null> extends Schema<Src>
33
40
  max(max: number): NumberSchema<Src>;
34
41
  min(min: number): NumberSchema<Src>;
35
42
  protected executeCustomValidateAt(path: SourcePath, src: Src): ValidationError[];
43
+ /**
44
+ * How this field is laid out in the editor when it is the item of an array
45
+ * or record: `{ as: "inline" }` renders the field itself inside each row,
46
+ * instead of a preview row that navigates to it.
47
+ *
48
+ * Static configuration, not a callback — see `render.ts`.
49
+ */
50
+ render(input: FieldRender): NumberSchema<Src>;
51
+ /**
52
+ * How this VALUE is shown where a preview of it is needed — a row in a
53
+ * sortable list, a reference dropdown, a search hit. Never how the field
54
+ * itself is edited (that is `render`). See `preview.ts`.
55
+ */
56
+ preview(select: ItemPreviewInput<Src>): NumberSchema<Src>;
57
+ protected executePreviewItem(src: NonNullable<Src>): PreviewItem | null;
58
+ protected declaresItemPreview(): boolean;
36
59
  protected executeSerialize(): SerializedSchema;
37
60
  protected executePreview(): ReifiedPreview;
38
61
  }
@@ -1,10 +1,15 @@
1
1
  import { CustomValidateFunction, Schema, SchemaAssertResult, SelectorOfSchema, SerializedSchema } from "./index.js";
2
- import { ReifiedPreview, PreviewScope } from "../preview.js";
2
+ import { ItemPreviewInput, PreviewItem, ReifiedPreview, PreviewScope } from "../preview.js";
3
+ import { FieldRender } from "../render.js";
3
4
  import { SelectorSource } from "../selector/index.js";
4
5
  import { ModuleFilePath, SourcePath } from "../val/index.js";
5
6
  import { ValidationError, ValidationErrors } from "./validation/ValidationError.js";
6
7
  export type SerializedObjectSchema = {
7
8
  type: "object";
9
+ /** Static layout config, carried whole in the serialized schema — see `render.ts`. */
10
+ render?: FieldRender;
11
+ /** Set when this schema declares a `preview`. The closure itself cannot serialize. */
12
+ preview?: true;
8
13
  items: Record<string, SerializedSchema>;
9
14
  opt: boolean;
10
15
  customValidate?: boolean;
@@ -42,7 +47,9 @@ export declare class ObjectSchema<Props extends ObjectSchemaProps, Src extends O
42
47
  private readonly isReadonly;
43
48
  private readonly isHidden;
44
49
  private readonly description?;
45
- constructor(items: Props, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined);
50
+ private readonly renderInput;
51
+ private readonly previewInput;
52
+ constructor(items: Props, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined, renderInput?: FieldRender | null, previewInput?: ItemPreviewInput<Src> | null);
46
53
  describe(description: string | null): ObjectSchema<Props, Src>;
47
54
  validate(validationFunction: (src: Src) => false | string): ObjectSchema<Props, Src>;
48
55
  protected executeValidate(path: SourcePath, src: Src): ValidationErrors;
@@ -51,6 +58,22 @@ export declare class ObjectSchema<Props extends ObjectSchemaProps, Src extends O
51
58
  readonly(): ObjectSchema<Props, Src>;
52
59
  hidden(): ObjectSchema<Props, Src>;
53
60
  protected executeCustomValidateAt(path: SourcePath, src: Src): ValidationError[];
61
+ /**
62
+ * How this field is laid out in the editor when it is the item of an array
63
+ * or record: `{ as: "inline" }` renders the field itself inside each row,
64
+ * instead of a preview row that navigates to it.
65
+ *
66
+ * Static configuration, not a callback — see `render.ts`.
67
+ */
68
+ render(input: FieldRender): ObjectSchema<Props, Src>;
69
+ /**
70
+ * How this VALUE is shown where a preview of it is needed — a row in a
71
+ * sortable list, a reference dropdown, a search hit. Never how the field
72
+ * itself is edited (that is `render`). See `preview.ts`.
73
+ */
74
+ preview(select: ItemPreviewInput<Src>): ObjectSchema<Props, Src>;
75
+ protected executePreviewItem(src: NonNullable<Src>): PreviewItem | null;
76
+ protected declaresItemPreview(): boolean;
54
77
  protected executeSerialize(): SerializedSchema;
55
78
  protected executePreview(sourcePath: SourcePath | ModuleFilePath, src: Src, scope?: PreviewScope): ReifiedPreview;
56
79
  }
@@ -1,5 +1,6 @@
1
1
  import { CustomValidateFunction, Schema, SchemaAssertResult, SelectorOfSchema, SerializedSchema } from "./index.js";
2
- import { PreviewItem, PreviewSelector, ReifiedPreview, PreviewScope } from "../preview.js";
2
+ import { ItemPreviewInput, PreviewItem, ReifiedPreview, PreviewScope } from "../preview.js";
3
+ import { FieldRender } from "../render.js";
3
4
  import { ValRouter } from "../router.js";
4
5
  import { SelectorSource } from "../selector/index.js";
5
6
  import { JsonOf, JsonSource } from "../source/json.js";
@@ -17,8 +18,14 @@ export type SerializedRecordSchema = {
17
18
  item: SerializedSchema;
18
19
  key?: SerializedSchema;
19
20
  opt: boolean;
20
- /** Set when this schema declares a `preview`. See `SerializedArraySchema`. */
21
+ /**
22
+ * Set when this schema declares a `preview` — of the RECORD ITSELF as a
23
+ * value. Whether its ENTRIES preview is carried by the item's serialized
24
+ * schema. See `SerializedArraySchema`.
25
+ */
21
26
  preview?: true;
27
+ /** Static layout config, carried whole in the serialized schema — see `render.ts`. */
28
+ render?: FieldRender;
22
29
  router?: string;
23
30
  customValidate?: boolean;
24
31
  mediaType?: "files" | "images";
@@ -45,10 +52,6 @@ export type SerializedRecordSchema = {
45
52
  * authoring.
46
53
  */
47
54
  export type JsonValuesRecordSrc<T extends Schema<SelectorSource>, K extends Schema<string>> = Record<SelectorOfSchema<K>, JsonSource<JsonOf<SelectorOfSchema<T>>> | SelectorOfSchema<T>>;
48
- type RecordPreviewInput<T extends Schema<SelectorSource>> = (input: {
49
- key: string;
50
- val: PreviewSelector<T>;
51
- }) => PreviewItem;
52
55
  export declare class RecordSchema<T extends Schema<SelectorSource>, K extends Schema<string>, Src extends Record<SelectorOfSchema<K>, SelectorOfSchema<T>> | JsonValuesRecordSrc<T, K> | null> extends Schema<Src> {
53
56
  private readonly item;
54
57
  private readonly opt;
@@ -62,9 +65,10 @@ export declare class RecordSchema<T extends Schema<SelectorSource>, K extends Sc
62
65
  /** When true, entry values are lazily loaded {@link JsonSource} thunks. */
63
66
  private readonly isJsonValues;
64
67
  private readonly previewInput;
68
+ private readonly renderInput;
65
69
  constructor(item: T, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], currentRouter?: ValRouter | null, keySchema?: Schema<string> | null, mediaOptions?: MediaOptions | undefined, isReadonly?: boolean, isHidden?: boolean, description?: string | undefined,
66
70
  /** When true, entry values are lazily loaded {@link JsonSource} thunks. */
67
- isJsonValues?: boolean, previewInput?: RecordPreviewInput<T> | null);
71
+ isJsonValues?: boolean, previewInput?: ItemPreviewInput<Src> | null, renderInput?: FieldRender | null);
68
72
  describe(description: string | null): RecordSchema<T, K, Src>;
69
73
  validate(validationFunction: (src: Src) => false | string): RecordSchema<T, K, Src>;
70
74
  protected executeValidate(path: SourcePath, src: Src): ValidationErrors;
@@ -106,15 +110,23 @@ export declare class RecordSchema<T extends Schema<SelectorSource>, K extends Sc
106
110
  */
107
111
  validateJsonEntryContent(path: SourcePath, content: SelectorSource): ValidationErrors;
108
112
  protected executePreview(sourcePath: SourcePath | ModuleFilePath, src: Src, scope?: PreviewScope): ReifiedPreview;
113
+ protected executePreviewItem(src: NonNullable<Src>): PreviewItem | null;
114
+ protected declaresItemPreview(): boolean;
115
+ /**
116
+ * How this RECORD ITSELF is shown where a preview of it is needed — when it
117
+ * is the item of another container, in search, in references. What its
118
+ * entries show is the ITEM schema's `preview`, not this. Never how the field
119
+ * is edited (that is `render`). See `preview.ts`.
120
+ */
121
+ preview(select: ItemPreviewInput<Src>): RecordSchema<T, K, Src>;
109
122
  /**
110
- * What the editor shows for each ENTRY of this record: a title, and optionally
111
- * a subtitle and an image.
123
+ * How this field is laid out in the editor when it is the item of an array
124
+ * or record: `{ as: "inline" }` renders the field itself inside each row,
125
+ * instead of a preview row that navigates to it.
112
126
  *
113
- * `select` is your own code over the entry's key and source, so it is run on
114
- * demand for the entries that are actually being looked at — see
115
- * `PreviewScope`.
127
+ * Static configuration, not a callback — see `render.ts`.
116
128
  */
117
- preview(select: RecordPreviewInput<T>): RecordSchema<T, K, Src>;
129
+ render(input: FieldRender): RecordSchema<T, K, Src>;
118
130
  }
119
131
  export declare function record<K extends Schema<string>, S extends Schema<SelectorSource>>(key: K, schema: S): RecordSchema<S, K, Record<SelectorOfSchema<K>, SelectorOfSchema<S>>>;
120
132
  export declare function record<S extends Schema<SelectorSource>>(schema: S): RecordSchema<S, Schema<string>, Record<string, SelectorOfSchema<S>>>;
@@ -1,5 +1,6 @@
1
1
  import { CustomValidateFunction, Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
2
- import { ReifiedPreview } from "../preview.js";
2
+ import { ItemPreviewInput, PreviewItem, ReifiedPreview } from "../preview.js";
3
+ import { FieldRender } from "../render.js";
3
4
  import { RichTextSource, RichTextOptions, SerializedRichTextOptions } from "../source/richtext.js";
4
5
  import { SourcePath } from "../val/index.js";
5
6
  import { ValidationError, ValidationErrors } from "./validation/ValidationError.js";
@@ -9,6 +10,10 @@ type ValidationOptions = {
9
10
  };
10
11
  export type SerializedRichTextSchema = {
11
12
  type: "richtext";
13
+ /** Static layout config, carried whole in the serialized schema — see `render.ts`. */
14
+ render?: FieldRender;
15
+ /** Set when this schema declares a `preview`. The closure itself cannot serialize. */
16
+ preview?: true;
12
17
  opt: boolean;
13
18
  options?: SerializedRichTextOptions & ValidationOptions;
14
19
  customValidate?: boolean;
@@ -23,7 +28,9 @@ export declare class RichTextSchema<O extends RichTextOptions, Src extends RichT
23
28
  private readonly isReadonly;
24
29
  private readonly isHidden;
25
30
  private readonly description?;
26
- constructor(options: O & ValidationOptions, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined);
31
+ private readonly renderInput;
32
+ private readonly previewInput;
33
+ constructor(options: O & ValidationOptions, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined, renderInput?: FieldRender | null, previewInput?: ItemPreviewInput<Src> | null);
27
34
  describe(description: string | null): RichTextSchema<O, Src>;
28
35
  maxLength(max: number): RichTextSchema<O, Src>;
29
36
  minLength(min: number): RichTextSchema<O, Src>;
@@ -36,6 +43,22 @@ export declare class RichTextSchema<O extends RichTextOptions, Src extends RichT
36
43
  readonly(): RichTextSchema<O, Src>;
37
44
  hidden(): RichTextSchema<O, Src>;
38
45
  protected executeCustomValidateAt(path: SourcePath, src: Src): ValidationError[];
46
+ /**
47
+ * How this field is laid out in the editor when it is the item of an array
48
+ * or record: `{ as: "inline" }` renders the field itself inside each row,
49
+ * instead of a preview row that navigates to it.
50
+ *
51
+ * Static configuration, not a callback — see `render.ts`.
52
+ */
53
+ render(input: FieldRender): RichTextSchema<O, Src>;
54
+ /**
55
+ * How this VALUE is shown where a preview of it is needed — a row in a
56
+ * sortable list, a reference dropdown, a search hit. Never how the field
57
+ * itself is edited (that is `render`). See `preview.ts`.
58
+ */
59
+ preview(select: ItemPreviewInput<Src>): RichTextSchema<O, Src>;
60
+ protected executePreviewItem(src: NonNullable<Src>): PreviewItem | null;
61
+ protected declaresItemPreview(): boolean;
39
62
  protected executeSerialize(): SerializedSchema;
40
63
  protected executePreview(): ReifiedPreview;
41
64
  }
@@ -1,6 +1,7 @@
1
1
  import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
2
2
  import { SourcePath } from "../val/index.js";
3
- import { ReifiedPreview } from "../preview.js";
3
+ import { ItemPreviewInput, PreviewItem, ReifiedPreview } from "../preview.js";
4
+ import { FieldRender } from "../render.js";
4
5
  import { ValidationError, ValidationErrors } from "./validation/ValidationError.js";
5
6
  type RouteOptions = {
6
7
  include?: RegExp;
@@ -8,6 +9,10 @@ type RouteOptions = {
8
9
  };
9
10
  export type SerializedRouteSchema = {
10
11
  type: "route";
12
+ /** Static layout config, carried whole in the serialized schema — see `render.ts`. */
13
+ render?: FieldRender;
14
+ /** Set when this schema declares a `preview`. The closure itself cannot serialize. */
15
+ preview?: true;
11
16
  options?: {
12
17
  include?: {
13
18
  source: string;
@@ -32,7 +37,9 @@ export declare class RouteSchema<Src extends string | null> extends Schema<Src>
32
37
  private readonly isReadonly;
33
38
  private readonly isHidden;
34
39
  private readonly description?;
35
- constructor(options?: RouteOptions | undefined, opt?: boolean, customValidateFunctions?: ((src: Src) => false | string)[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined);
40
+ private readonly renderInput;
41
+ private readonly previewInput;
42
+ constructor(options?: RouteOptions | undefined, opt?: boolean, customValidateFunctions?: ((src: Src) => false | string)[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined, renderInput?: FieldRender | null, previewInput?: ItemPreviewInput<Src> | null);
36
43
  describe(description: string | null): RouteSchema<Src>;
37
44
  /**
38
45
  * Specify a pattern for which routes are allowed.
@@ -67,6 +74,22 @@ export declare class RouteSchema<Src extends string | null> extends Schema<Src>
67
74
  readonly(): RouteSchema<Src>;
68
75
  hidden(): RouteSchema<Src>;
69
76
  protected executeCustomValidateAt(path: SourcePath, src: Src): ValidationError[];
77
+ /**
78
+ * How this field is laid out in the editor when it is the item of an array
79
+ * or record: `{ as: "inline" }` renders the field itself inside each row,
80
+ * instead of a preview row that navigates to it.
81
+ *
82
+ * Static configuration, not a callback — see `render.ts`.
83
+ */
84
+ render(input: FieldRender): RouteSchema<Src>;
85
+ /**
86
+ * How this VALUE is shown where a preview of it is needed — a row in a
87
+ * sortable list, a reference dropdown, a search hit. Never how the field
88
+ * itself is edited (that is `render`). See `preview.ts`.
89
+ */
90
+ preview(select: ItemPreviewInput<Src>): RouteSchema<Src>;
91
+ protected executePreviewItem(src: NonNullable<Src>): PreviewItem | null;
92
+ protected declaresItemPreview(): boolean;
70
93
  protected executeSerialize(): SerializedSchema;
71
94
  protected executePreview(): ReifiedPreview;
72
95
  }
@@ -1,5 +1,5 @@
1
1
  import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
2
- import { ReifiedPreview } from "../preview.js";
2
+ import { ItemPreviewInput, PreviewItem, ReifiedPreview } from "../preview.js";
3
3
  import { StringRender } from "../render.js";
4
4
  import { SourcePath } from "../val/index.js";
5
5
  import { ValidationError, ValidationErrors } from "./validation/ValidationError.js";
@@ -21,6 +21,8 @@ export type SerializedStringSchema = {
21
21
  * buys, and what to do if a render ever needs to stop being static.
22
22
  */
23
23
  render?: StringRender;
24
+ /** Set when this schema declares a `preview`. The closure itself cannot serialize. */
25
+ preview?: true;
24
26
  options?: {
25
27
  maxLength?: number;
26
28
  minLength?: number;
@@ -51,7 +53,8 @@ export declare class StringSchema<Src extends string | null> extends Schema<Src>
51
53
  private readonly isReadonly;
52
54
  private readonly isHidden;
53
55
  private readonly description?;
54
- constructor(options?: StringOptions | undefined, opt?: boolean, isRaw?: boolean, customValidateFunctions?: ((src: Src) => false | string)[], renderInput?: StringRender | null, isReadonly?: boolean, isHidden?: boolean, description?: string | undefined);
56
+ private readonly previewInput;
57
+ constructor(options?: StringOptions | undefined, opt?: boolean, isRaw?: boolean, customValidateFunctions?: ((src: Src) => false | string)[], renderInput?: StringRender | null, isReadonly?: boolean, isHidden?: boolean, description?: string | undefined, previewInput?: ItemPreviewInput<Src> | null);
55
58
  describe(description: string | null): StringSchema<Src>;
56
59
  /**
57
60
  * @deprecated Use `minLength` instead
@@ -81,6 +84,14 @@ export declare class StringSchema<Src extends string | null> extends Schema<Src>
81
84
  * shows for its items is a `preview`, which is a different thing entirely.
82
85
  */
83
86
  render(input: StringRender): StringSchema<Src>;
87
+ /**
88
+ * How this VALUE is shown where a preview of it is needed — a row in a
89
+ * sortable list, a reference dropdown, a search hit. Never how the field
90
+ * itself is edited (that is `render`). See `preview.ts`.
91
+ */
92
+ preview(select: ItemPreviewInput<Src>): StringSchema<Src>;
93
+ protected executePreviewItem(src: NonNullable<Src>): PreviewItem | null;
94
+ protected declaresItemPreview(): boolean;
84
95
  /**
85
96
  * Nothing: a string has no items, so there is nothing to preview. Its layout
86
97
  * is a `render`, which travels in the serialized schema instead of through
@@ -1,5 +1,6 @@
1
1
  import { CustomValidateFunction, Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
2
- import { ReifiedPreview, PreviewScope } from "../preview.js";
2
+ import { ItemPreviewInput, PreviewItem, ReifiedPreview, PreviewScope } from "../preview.js";
3
+ import { FieldRender } from "../render.js";
3
4
  import { SelectorSource } from "../selector/index.js";
4
5
  import { SourceObject } from "../source/index.js";
5
6
  import { ModuleFilePath, SourcePath } from "../val/index.js";
@@ -9,6 +10,10 @@ import { ValidationError, ValidationErrors } from "./validation/ValidationError.
9
10
  export type SerializedUnionSchema = SerializedStringUnionSchema | SerializedObjectUnionSchema;
10
11
  export type SerializedStringUnionSchema = {
11
12
  type: "union";
13
+ /** Static layout config, carried whole in the serialized schema — see `render.ts`. */
14
+ render?: FieldRender;
15
+ /** Set when this schema declares a `preview`. The closure itself cannot serialize. */
16
+ preview?: true;
12
17
  key: SerializedLiteralSchema;
13
18
  items: SerializedLiteralSchema[];
14
19
  opt: boolean;
@@ -19,6 +24,10 @@ export type SerializedStringUnionSchema = {
19
24
  };
20
25
  export type SerializedObjectUnionSchema = {
21
26
  type: "union";
27
+ /** Static layout config, carried whole in the serialized schema — see `render.ts`. */
28
+ render?: FieldRender;
29
+ /** Set when this schema declares a `preview`. The closure itself cannot serialize. */
30
+ preview?: true;
22
31
  key: string;
23
32
  items: SerializedObjectSchema[];
24
33
  opt: boolean;
@@ -40,6 +49,8 @@ export declare class UnionSchema<Key extends string | Schema<string>, T extends
40
49
  private readonly isReadonly;
41
50
  private readonly isHidden;
42
51
  private readonly description?;
52
+ private readonly renderInput;
53
+ private readonly previewInput;
43
54
  describe(description: string | null): UnionSchema<Key, T, Src>;
44
55
  validate(validationFunction: (src: Src) => false | string): UnionSchema<Key, T, Src>;
45
56
  protected executeValidate(path: SourcePath, src: Src): ValidationErrors;
@@ -55,8 +66,27 @@ export declare class UnionSchema<Key extends string | Schema<string>, T extends
55
66
  * already reports.
56
67
  */
57
68
  private matchedVariant;
69
+ /**
70
+ * How this field is laid out in the editor when it is the item of an array
71
+ * or record: `{ as: "inline" }` renders the field itself inside each row,
72
+ * instead of a preview row that navigates to it.
73
+ *
74
+ * Static configuration, not a callback — see `render.ts`.
75
+ */
76
+ render(input: FieldRender): UnionSchema<Key, T, Src>;
77
+ /**
78
+ * How this VALUE is shown where a preview of it is needed — a row in a
79
+ * sortable list, a reference dropdown, a search hit. Never how the field
80
+ * itself is edited (that is `render`). See `preview.ts`.
81
+ *
82
+ * Without one of its own, a tagged union previews as the VARIANT the value
83
+ * takes — declare `preview` on the member objects and the union dispatches.
84
+ */
85
+ preview(select: ItemPreviewInput<Src>): UnionSchema<Key, T, Src>;
86
+ protected executePreviewItem(src: NonNullable<Src>): PreviewItem | null;
87
+ protected declaresItemPreview(): boolean;
58
88
  protected executeSerialize(): SerializedSchema;
59
- constructor(key: Key, items: T, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined);
89
+ constructor(key: Key, items: T, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined, renderInput?: FieldRender | null, previewInput?: ItemPreviewInput<Src> | null);
60
90
  protected executePreview(sourcePath: SourcePath | ModuleFilePath, src: Src, scope?: PreviewScope): ReifiedPreview;
61
91
  }
62
92
  export declare const union: <Key extends string | Schema<string>, T extends Schema<Key extends string ? SourceObject & { [k in Key]: string; } : Key extends Schema<string> ? string : unknown>[]>(key: Key, ...objects: T) => UnionSchema<Key, T, SourceOf<Key, T>>;