rimecms 1.1.1 → 1.1.3

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 (142) hide show
  1. package/dist/adapter-sqlite/read.server.js +4 -4
  2. package/dist/adapter-sqlite/table.server.d.ts +3 -6
  3. package/dist/adapter-sqlite/table.server.js +3 -6
  4. package/dist/adapter-sqlite/transform.server.d.ts +1 -1
  5. package/dist/adapter-sqlite/transform.server.js +3 -2
  6. package/dist/adapter-sqlite/write.server.d.ts +13 -15
  7. package/dist/adapter-sqlite/write.server.js +15 -17
  8. package/dist/core/adapter.d.ts +19 -33
  9. package/dist/core/adapter.js +0 -12
  10. package/dist/core/auth/augment.js +2 -1
  11. package/dist/core/auth/hooks/augment-fields-password.server.d.ts +2 -2
  12. package/dist/core/auth/hooks/augment-fields-password.server.js +2 -2
  13. package/dist/core/auth/tables.d.ts +2 -5
  14. package/dist/core/auth/tables.js +3 -7
  15. package/dist/core/auth/validate-config.d.ts +3 -8
  16. package/dist/core/auth/validate-config.js +4 -10
  17. package/dist/core/config/types.d.ts +6 -6
  18. package/dist/core/config/validate.server.js +11 -0
  19. package/dist/core/fields/builders/boolean-builder.d.ts +2 -2
  20. package/dist/core/fields/builders/boolean-builder.js +4 -1
  21. package/dist/core/fields/builders/select-builder.d.ts +3 -3
  22. package/dist/core/fields/builders/select-builder.js +4 -2
  23. package/dist/core/fields/complete.d.ts +18 -0
  24. package/dist/core/fields/complete.js +32 -0
  25. package/dist/core/fields/empty.d.ts +14 -0
  26. package/dist/core/fields/empty.js +13 -0
  27. package/dist/core/fields/initial.d.ts +32 -0
  28. package/dist/core/fields/initial.js +47 -0
  29. package/dist/core/fields/util.d.ts +0 -16
  30. package/dist/core/fields/util.js +0 -29
  31. package/dist/core/i18n/en/fields.d.ts +1 -1
  32. package/dist/core/i18n/en/fields.js +1 -1
  33. package/dist/core/i18n/fr/fields.d.ts +1 -1
  34. package/dist/core/i18n/fr/fields.js +1 -1
  35. package/dist/core/pipeline/build-document.server.d.ts +4 -10
  36. package/dist/core/pipeline/build-document.server.js +8 -17
  37. package/dist/core/pipeline/hooks/data-config-map.server.d.ts +1 -1
  38. package/dist/core/pipeline/hooks/data-config-map.server.js +1 -1
  39. package/dist/core/pipeline/hooks/process-document-fields.server.d.ts +3 -2
  40. package/dist/core/pipeline/hooks/process-document-fields.server.js +3 -16
  41. package/dist/core/pipeline/hooks/set-default-values.server.d.ts +15 -4
  42. package/dist/core/pipeline/hooks/set-default-values.server.js +50 -25
  43. package/dist/core/pipeline/hooks/validate-fields.server.js +1 -1
  44. package/dist/core/pipeline/run.server.js +1 -2
  45. package/dist/core/prototype/area/api.server.d.ts +4 -6
  46. package/dist/core/prototype/area/api.server.js +4 -6
  47. package/dist/core/prototype/area/definition.server.js +23 -9
  48. package/dist/core/prototype/area/hooks.server.js +1 -1
  49. package/dist/core/prototype/collection/api.server.d.ts +5 -6
  50. package/dist/core/prototype/collection/api.server.js +5 -6
  51. package/dist/core/prototype/collection/definition.js +3 -8
  52. package/dist/core/prototype/collection/hooks/merge-with-initial.server.d.ts +15 -0
  53. package/dist/core/prototype/collection/hooks/merge-with-initial.server.js +20 -0
  54. package/dist/core/prototype/collection/hooks.server.js +5 -5
  55. package/dist/core/prototype/collection/nested/module.js +1 -1
  56. package/dist/core/prototype/collection/nested/module.server.js +1 -1
  57. package/dist/core/prototype/collection/operations/duplicate.js +4 -8
  58. package/dist/core/prototype/collection/upload/directories/derive.js +2 -2
  59. package/dist/core/prototype/collection/upload/hooks/handle-path-creation.server.js +2 -2
  60. package/dist/core/prototype/define.d.ts +2 -2
  61. package/dist/core/prototype/define.js +4 -4
  62. package/dist/core/prototype/initial.d.ts +23 -0
  63. package/dist/core/prototype/initial.js +19 -0
  64. package/dist/core/prototype/shared/versions/augment.d.ts +2 -4
  65. package/dist/core/prototype/shared/versions/augment.js +4 -6
  66. package/dist/core/prototype/shared/versions/configure.server.js +3 -3
  67. package/dist/core/prototype/shared/versions/hooks/fallback-data-from-original.d.ts +14 -2
  68. package/dist/core/prototype/shared/versions/hooks/fallback-data-from-original.js +28 -22
  69. package/dist/core/prototype/shared/versions/hooks/handle-new-version.server.js +3 -4
  70. package/dist/core/prototype/shared/versions/{blank.d.ts → initial.d.ts} +2 -4
  71. package/dist/core/prototype/shared/versions/{blank.js → initial.js} +2 -4
  72. package/dist/core/prototype/when.d.ts +2 -6
  73. package/dist/core/prototype/when.js +2 -6
  74. package/dist/fields/blocks/component/AddBlockButton.svelte +2 -2
  75. package/dist/fields/blocks/component/focus/BlocksFocus.svelte +16 -10
  76. package/dist/fields/blocks/component/focus/Inspector.svelte +27 -3
  77. package/dist/fields/blocks/component/focus/LayersList.svelte +4 -1
  78. package/dist/fields/blocks/component/focus/Renders.svelte +55 -11
  79. package/dist/fields/blocks/component/focus/Renders.svelte.d.ts +3 -0
  80. package/dist/fields/blocks/component/focus/StageAdd.svelte +42 -0
  81. package/dist/fields/blocks/component/focus/StageAdd.svelte.d.ts +6 -0
  82. package/dist/fields/blocks/component/focus/focus.svelte.d.ts +6 -4
  83. package/dist/fields/blocks/component/focus/focus.svelte.js +34 -8
  84. package/dist/fields/blocks/defaults.d.ts +22 -0
  85. package/dist/fields/blocks/defaults.js +23 -0
  86. package/dist/fields/blocks/index.d.ts +42 -5
  87. package/dist/fields/blocks/index.js +37 -1
  88. package/dist/fields/combobox/index.d.ts +2 -2
  89. package/dist/fields/combobox/index.js +2 -1
  90. package/dist/fields/date/index.d.ts +2 -2
  91. package/dist/fields/date/index.js +2 -1
  92. package/dist/fields/email/index.d.ts +2 -2
  93. package/dist/fields/email/index.js +2 -1
  94. package/dist/fields/group/index.d.ts +1 -0
  95. package/dist/fields/link/index.d.ts +3 -2
  96. package/dist/fields/link/index.js +2 -1
  97. package/dist/fields/number/index.d.ts +3 -2
  98. package/dist/fields/number/index.js +2 -1
  99. package/dist/fields/relation/component/RelationInline.svelte +1 -2
  100. package/dist/fields/relation/component/default/Default.svelte +1 -1
  101. package/dist/fields/relation/component/upload/Create.svelte +1 -1
  102. package/dist/fields/relation/index.d.ts +2 -2
  103. package/dist/fields/relation/index.js +2 -1
  104. package/dist/fields/rich-text/index.d.ts +2 -2
  105. package/dist/fields/rich-text/index.js +2 -1
  106. package/dist/fields/slug/index.d.ts +3 -2
  107. package/dist/fields/slug/index.js +2 -1
  108. package/dist/fields/text/index.d.ts +3 -2
  109. package/dist/fields/text/index.js +2 -1
  110. package/dist/fields/textarea/index.d.ts +3 -2
  111. package/dist/fields/textarea/index.js +2 -1
  112. package/dist/fields/time/index.d.ts +2 -2
  113. package/dist/fields/time/index.js +2 -1
  114. package/dist/fields/toggle/index.d.ts +3 -2
  115. package/dist/fields/toggle/index.js +2 -2
  116. package/dist/fields/tree/component/AddItemButton.svelte +3 -4
  117. package/dist/fields/tree/component/AddItemButton.svelte.d.ts +1 -1
  118. package/dist/fields/tree/defaults.d.ts +21 -0
  119. package/dist/fields/tree/defaults.js +18 -0
  120. package/dist/fields/tree/index.d.ts +17 -3
  121. package/dist/fields/tree/index.js +27 -0
  122. package/dist/fields/types.d.ts +14 -0
  123. package/dist/panel/components/ui/button/button.svelte +2 -3
  124. package/dist/panel/context/blocks-ops.d.ts +0 -1
  125. package/dist/panel/context/blocks-ops.js +1 -2
  126. package/dist/panel/pages/collection-document/load.server.js +1 -1
  127. package/dist/panel/style/index.css +4 -3
  128. package/dist/panel/style/palette.css +3 -3
  129. package/dist/panel/style/scheme.css +1 -0
  130. package/dist/util/object.d.ts +2 -2
  131. package/dist/util/object.js +3 -3
  132. package/dist/util/random.d.ts +2 -0
  133. package/dist/util/random.js +2 -0
  134. package/package.json +1 -1
  135. package/dist/core/fields/blank.d.ts +0 -21
  136. package/dist/core/fields/blank.js +0 -37
  137. package/dist/core/prototype/blank.d.ts +0 -26
  138. package/dist/core/prototype/blank.js +0 -22
  139. package/dist/core/prototype/collection/hooks/merge-with-blank.server.d.ts +0 -9
  140. package/dist/core/prototype/collection/hooks/merge-with-blank.server.js +0 -14
  141. package/dist/fields/blocks/component/focus/StagePlaceholder.svelte +0 -66
  142. package/dist/fields/blocks/component/focus/StagePlaceholder.svelte.d.ts +0 -3
@@ -1,9 +1,9 @@
1
- import type { DefaultValueFn, FormField, OptionWithIcon } from '../types.js';
1
+ import type { DefaultOptions, DefaultValueFn, FormField, OptionWithIcon } from '../types.js';
2
2
  import { PickOneFieldBuilder } from '../../core/fields/builders/select-builder.js';
3
3
  export declare class ComboBoxFieldBuilder extends PickOneFieldBuilder<ComboBoxField> {
4
4
  get component(): import("svelte").Component<import("./component/props.js").ComboBoxProps, {}, "">;
5
5
  options(...options: OptionWithIcon[] | string[]): this;
6
- defaultValue(value: string | DefaultValueFn<string>): this;
6
+ defaultValue(value: string | DefaultValueFn<string>, options?: DefaultOptions): this;
7
7
  protected generateType(): string;
8
8
  }
9
9
  export declare const combobox: (name: string) => ComboBoxFieldBuilder;
@@ -7,8 +7,9 @@ export class ComboBoxFieldBuilder extends PickOneFieldBuilder {
7
7
  options(...options) {
8
8
  return super.options(...options);
9
9
  }
10
- defaultValue(value) {
10
+ defaultValue(value, options) {
11
11
  this.field.defaultValue = value;
12
+ this.field.defaultFill = options?.fill;
12
13
  return this;
13
14
  }
14
15
  generateType() {
@@ -1,6 +1,6 @@
1
1
  import type { DataType } from '../../core/fields/builders/form-field-builder.js';
2
2
  import { FormFieldBuilder } from '../../core/fields/builders/form-field-builder.js';
3
- import type { DefaultValueFn, FormField } from '../types.js';
3
+ import type { DefaultOptions, DefaultValueFn, FormField } from '../types.js';
4
4
  export declare const date: (name: string) => DateFieldBuilder;
5
5
  export declare class DateFieldBuilder extends FormFieldBuilder<DateField> {
6
6
  constructor(name: string);
@@ -13,7 +13,7 @@ export declare class DateFieldBuilder extends FormFieldBuilder<DateField> {
13
13
  get cell(): import("svelte").Component<{
14
14
  value: Date | undefined;
15
15
  }, {}, "">;
16
- defaultValue(value: Date | DefaultValueFn<Date>): this;
16
+ defaultValue(value: Date | DefaultValueFn<Date>, options?: DefaultOptions): this;
17
17
  isTitle(): this;
18
18
  protected generateType(): string;
19
19
  }
@@ -22,8 +22,9 @@ export class DateFieldBuilder extends FormFieldBuilder {
22
22
  get cell() {
23
23
  return Cell;
24
24
  }
25
- defaultValue(value) {
25
+ defaultValue(value, options) {
26
26
  this.field.defaultValue = value;
27
+ this.field.defaultFill = options?.fill;
27
28
  return this;
28
29
  }
29
30
  isTitle() {
@@ -1,13 +1,13 @@
1
1
  import type { DataType } from '../../core/fields/builders/form-field-builder.js';
2
2
  import { FormFieldBuilder } from '../../core/fields/builders/form-field-builder.js';
3
- import type { DefaultValueFn, FormField } from '../types.js';
3
+ import type { DefaultOptions, DefaultValueFn, FormField } from '../types.js';
4
4
  export declare class EmailFieldBuilder extends FormFieldBuilder<EmailField> {
5
5
  constructor(name: string);
6
6
  get dataType(): DataType;
7
7
  get component(): import("svelte").Component<import("./component/props").EmailFieldProps, {}, "">;
8
8
  layout(layout: 'compact' | 'default'): this;
9
9
  unique(bool?: boolean): this;
10
- defaultValue(value: string | DefaultValueFn<string>): this;
10
+ defaultValue(value: string | DefaultValueFn<string>, options?: DefaultOptions): this;
11
11
  isTitle(): this;
12
12
  protected generateType(): string;
13
13
  }
@@ -24,8 +24,9 @@ export class EmailFieldBuilder extends FormFieldBuilder {
24
24
  this.field.unique = typeof bool === 'boolean' ? bool : true;
25
25
  return this;
26
26
  }
27
- defaultValue(value) {
27
+ defaultValue(value, options) {
28
28
  this.field.defaultValue = value;
29
+ this.field.defaultFill = options?.fill;
29
30
  return this;
30
31
  }
31
32
  isTitle() {
@@ -61,6 +61,7 @@ export declare class GroupFieldBuilder extends FormFieldBuilder<GroupField> {
61
61
  onChange?: import("../types.js").FieldHookClient[];
62
62
  };
63
63
  defaultValue?: import("../types.js").DefaultValueFn<any> | unknown;
64
+ defaultFill?: import("../types.js").DefaultFill;
64
65
  isEmpty: (value: unknown) => boolean;
65
66
  root?: boolean;
66
67
  index?: boolean;
@@ -1,6 +1,6 @@
1
1
  import type { DataType } from '../../core/fields/builders/form-field-builder.js';
2
2
  import { FormFieldBuilder } from '../../core/fields/builders/form-field-builder.js';
3
- import type { DefaultValueFn, FormField } from '../types.js';
3
+ import type { DefaultOptions, DefaultValueFn, FormField } from '../types.js';
4
4
  import type { Link, LinkType } from './types.js';
5
5
  export declare class LinkFieldBuilder extends FormFieldBuilder<LinkField> {
6
6
  constructor(name: string);
@@ -9,7 +9,7 @@ export declare class LinkFieldBuilder extends FormFieldBuilder<LinkField> {
9
9
  value: Link | null;
10
10
  }, {}, "">;
11
11
  layout(str: 'compact' | 'default'): this;
12
- defaultValue(value: Link | DefaultValueFn<Link>): this;
12
+ defaultValue(value: Link | DefaultValueFn<Link>, options?: DefaultOptions): this;
13
13
  get dataType(): DataType;
14
14
  types(...values: LinkType[]): this;
15
15
  static readonly sanitize: (link: unknown) => Link | undefined;
@@ -52,6 +52,7 @@ export declare class LinkFieldBuilder extends FormFieldBuilder<LinkField> {
52
52
  target: "_self" | "_blank";
53
53
  url?: string | undefined;
54
54
  } | undefined;
55
+ defaultFill?: import("../types.js").DefaultFill | undefined;
55
56
  isEmpty: (value: unknown) => boolean;
56
57
  root?: boolean | undefined;
57
58
  index?: boolean | undefined;
@@ -26,8 +26,9 @@ export class LinkFieldBuilder extends FormFieldBuilder {
26
26
  this.field.layout = str;
27
27
  return this;
28
28
  }
29
- defaultValue(value) {
29
+ defaultValue(value, options) {
30
30
  this.field.defaultValue = value;
31
+ this.field.defaultFill = options?.fill;
31
32
  return this;
32
33
  }
33
34
  get dataType() {
@@ -1,11 +1,11 @@
1
1
  import type { DataType } from '../../core/fields/builders/form-field-builder.js';
2
2
  import { FormFieldBuilder } from '../../core/fields/builders/form-field-builder.js';
3
- import type { DefaultValueFn, FieldValidationFunc, FormField } from '../types.js';
3
+ import type { DefaultOptions, DefaultValueFn, FieldValidationFunc, FormField } from '../types.js';
4
4
  export declare const number: (name: string) => NumberFieldBuilder;
5
5
  export declare class NumberFieldBuilder extends FormFieldBuilder<NumberField> {
6
6
  constructor(name: string);
7
7
  get component(): import("svelte").Component<import("./component/props").NumberFieldProps, {}, "">;
8
- defaultValue(value: number | DefaultValueFn<number>): this;
8
+ defaultValue(value: number | DefaultValueFn<number>, options?: DefaultOptions): this;
9
9
  min(value: number): this;
10
10
  max(value: number): this;
11
11
  get dataType(): DataType;
@@ -43,6 +43,7 @@ export declare class NumberFieldBuilder extends FormFieldBuilder<NumberField> {
43
43
  onChange?: import("../types.js").FieldHookClient[] | undefined;
44
44
  } | undefined;
45
45
  defaultValue?: number | DefaultValueFn<number> | undefined;
46
+ defaultFill?: import("../types.js").DefaultFill | undefined;
46
47
  isEmpty: (value: unknown) => boolean;
47
48
  root?: boolean | undefined;
48
49
  index?: boolean | undefined;
@@ -22,8 +22,9 @@ export class NumberFieldBuilder extends FormFieldBuilder {
22
22
  get component() {
23
23
  return Number;
24
24
  }
25
- defaultValue(value) {
25
+ defaultValue(value, options) {
26
26
  this.field.defaultValue = value;
27
+ this.field.defaultFill = options?.fill;
27
28
  return this;
28
29
  }
29
30
  min(value) {
@@ -3,13 +3,13 @@
3
3
  import type { UploadDoc } from '../../../core/prototype/collection/upload/types.js';
4
4
  import { isUploadConfig } from '../../../core/prototype/collection/upload/util/config.js';
5
5
  import { apiUrl } from '../../../core/routes/util.js';
6
+ import { populate } from '../populate.js';
6
7
  import FileDrop from '../../../panel/components/sections/collection/bulk-upload/FileDrop.svelte';
7
8
  import SpinLoader from '../../../panel/components/ui/spin-loader/SpinLoader.svelte';
8
9
  import { getAPIProxyContext } from '../../../panel/context/api-proxy.svelte.js';
9
10
  import { getConfigContext } from '../../../panel/context/config.svelte.js';
10
11
  import type { DocumentFormContext } from '../../../panel/context/documentForm.svelte.js';
11
12
  import { getLocaleContext } from '../../../panel/context/locale.svelte.js';
12
- import { populate } from '../populate.js';
13
13
  import { uploadFiles, type UploadProgress } from '../../../panel/util/upload-file.js';
14
14
  import { Image as ImageIcon, Trash2 } from '@lucide/svelte';
15
15
  import type { Snippet } from 'svelte';
@@ -276,7 +276,6 @@
276
276
  .rz-relation-inline :global(.rz-relation-inline__empty) {
277
277
  width: 100%;
278
278
  padding: var(--rz-size-11) var(--rz-size-4);
279
- background-color: var(--rz-bg-raised);
280
279
  }
281
280
 
282
281
  .rz-relation-inline__loading {
@@ -156,7 +156,7 @@
156
156
  >
157
157
  <Sheet.Content style="--rz-page-gutter:var(--rz-size-6)" side="right" showCloseButton={false}>
158
158
  <Document
159
- doc={relationConfig.blank()}
159
+ doc={relationConfig.initial()}
160
160
  readOnly={false}
161
161
  onClose={() => {
162
162
  creating = false;
@@ -24,7 +24,7 @@
24
24
  >
25
25
  <Sheet.Content style="--rz-page-gutter:var(--rz-size-6)" showCloseButton={false} side="right">
26
26
  <Doc
27
- doc={config.blank()}
27
+ doc={config.initial()}
28
28
  readOnly={false}
29
29
  onClose={() => {
30
30
  open = false;
@@ -1,7 +1,7 @@
1
1
  import type { DataType } from '../../core/fields/builders/form-field-builder.js';
2
2
  import { FormFieldBuilder } from '../../core/fields/builders/form-field-builder.js';
3
3
  import type { CollectionSlug, GenericDoc } from '../../core/prototype/types.js';
4
- import type { DefaultValueFn, FormField } from '../types.js';
4
+ import type { DefaultOptions, DefaultValueFn, FormField } from '../types.js';
5
5
  import type { RegisterCollection } from '../../index.js';
6
6
  import type { WithOptional } from '../../util/types.js';
7
7
  export declare class RelationFieldBuilder<Doc extends GenericDoc = GenericDoc> extends FormFieldBuilder<RelationField<Doc>> {
@@ -22,7 +22,7 @@ export declare class RelationFieldBuilder<Doc extends GenericDoc = GenericDoc> e
22
22
  query(query: string | QueryResolver<Doc>): this;
23
23
  to<Slug extends CollectionSlug>(slug: Slug): RelationFieldBuilder<RegisterCollection[Slug]>;
24
24
  many(): this;
25
- defaultValue(value: string | string[] | DefaultValueFn<string | string[]>): this;
25
+ defaultValue(value: string | string[] | DefaultValueFn<string | string[]>, options?: DefaultOptions): this;
26
26
  /** Documentation only — relation fields are diverted into relationFieldsMap/junction
27
27
  * tables before reaching the adapter's generic column renderer (see root.server.ts). */
28
28
  get dataType(): DataType;
@@ -35,8 +35,9 @@ export class RelationFieldBuilder extends FormFieldBuilder {
35
35
  this.field.many = true;
36
36
  return this;
37
37
  }
38
- defaultValue(value) {
38
+ defaultValue(value, options) {
39
39
  this.field.defaultValue = value;
40
+ this.field.defaultFill = options?.fill;
40
41
  return this;
41
42
  }
42
43
  /** Documentation only — relation fields are diverted into relationFieldsMap/junction
@@ -1,6 +1,6 @@
1
1
  import type { DataType } from '../../core/fields/builders/form-field-builder.js';
2
2
  import { FormFieldBuilder } from '../../core/fields/builders/form-field-builder.js';
3
- import type { DefaultValueFn, FormField } from '../types.js';
3
+ import type { DefaultOptions, DefaultValueFn, FormField } from '../types.js';
4
4
  import type { JSONContent } from '@tiptap/core';
5
5
  import type { RichTextFeature } from './core/types.js';
6
6
  export declare class RichTextFieldBuilder extends FormFieldBuilder<RichTextField> {
@@ -27,7 +27,7 @@ export declare class RichTextFieldBuilder extends FormFieldBuilder<RichTextField
27
27
  static readonly jsonParse: (value: string) => string;
28
28
  static readonly sanitize: (value: unknown) => any;
29
29
  static readonly stringify: (value: string) => string;
30
- defaultValue(value: RichTextContent | DefaultValueFn<RichTextContent>): this;
30
+ defaultValue(value: RichTextContent | DefaultValueFn<RichTextContent>, options?: DefaultOptions): this;
31
31
  get dataType(): DataType;
32
32
  protected generateType(): string;
33
33
  }
@@ -95,8 +95,9 @@ export class RichTextFieldBuilder extends FormFieldBuilder {
95
95
  }
96
96
  return value;
97
97
  };
98
- defaultValue(value) {
98
+ defaultValue(value, options) {
99
99
  this.field.defaultValue = value;
100
+ this.field.defaultFill = options?.fill;
100
101
  return this;
101
102
  }
102
103
  get dataType() {
@@ -1,6 +1,6 @@
1
1
  import type { DataType } from '../../core/fields/builders/form-field-builder.js';
2
2
  import { FormFieldBuilder } from '../../core/fields/builders/form-field-builder.js';
3
- import type { DefaultValueFn, FormField } from '../types.js';
3
+ import type { DefaultOptions, DefaultValueFn, FormField } from '../types.js';
4
4
  export declare const slug: (name: string) => SlugFieldBuilder;
5
5
  export declare class SlugFieldBuilder extends FormFieldBuilder<SlugField> {
6
6
  constructor(name: string);
@@ -15,7 +15,7 @@ export declare class SlugFieldBuilder extends FormFieldBuilder<SlugField> {
15
15
  placeholder(placeholder: string): this;
16
16
  slugify(fieldName: string): this;
17
17
  layout(layout: 'compact' | 'default'): this;
18
- defaultValue(value: string | DefaultValueFn<string>): this;
18
+ defaultValue(value: string | DefaultValueFn<string>, options?: DefaultOptions): this;
19
19
  unique(bool?: boolean): this;
20
20
  get dataType(): DataType;
21
21
  isTitle(): this;
@@ -53,6 +53,7 @@ export declare class SlugFieldBuilder extends FormFieldBuilder<SlugField> {
53
53
  onChange?: import("../types.js").FieldHookClient[] | undefined;
54
54
  } | undefined;
55
55
  defaultValue?: string | DefaultValueFn<string> | undefined;
56
+ defaultFill?: import("../types.js").DefaultFill | undefined;
56
57
  isEmpty: (value: unknown) => boolean;
57
58
  root?: boolean | undefined;
58
59
  index?: boolean | undefined;
@@ -31,8 +31,9 @@ export class SlugFieldBuilder extends FormFieldBuilder {
31
31
  this.field.layout = layout;
32
32
  return this;
33
33
  }
34
- defaultValue(value) {
34
+ defaultValue(value, options) {
35
35
  this.field.defaultValue = value;
36
+ this.field.defaultFill = options?.fill;
36
37
  return this;
37
38
  }
38
39
  unique(bool) {
@@ -1,13 +1,13 @@
1
1
  import type { DataType } from '../../core/fields/builders/form-field-builder.js';
2
2
  import { FormFieldBuilder } from '../../core/fields/builders/form-field-builder.js';
3
- import type { DefaultValueFn, FormField } from '../types.js';
3
+ import type { DefaultOptions, DefaultValueFn, FormField } from '../types.js';
4
4
  /****************************************************/
5
5
  export declare class TextFieldBuilder extends FormFieldBuilder<TextField> {
6
6
  constructor(name: string);
7
7
  unique(bool?: boolean): this;
8
8
  get component(): import("svelte").Component<import("./component/props").TextFieldProps, {}, "">;
9
9
  get cell(): null;
10
- defaultValue(value: string | DefaultValueFn<string>): this;
10
+ defaultValue(value: string | DefaultValueFn<string>, options?: DefaultOptions): this;
11
11
  get dataType(): DataType;
12
12
  isTitle(): this;
13
13
  placeholder(str: string): this;
@@ -50,6 +50,7 @@ export declare class TextFieldBuilder extends FormFieldBuilder<TextField> {
50
50
  beforeValidate?: import("../types.js").FieldHookShared<any>[] | undefined;
51
51
  onChange?: import("../types.js").FieldHookClient[] | undefined;
52
52
  } | undefined;
53
+ defaultFill?: import("../types.js").DefaultFill | undefined;
53
54
  isEmpty: (value: unknown) => boolean;
54
55
  root?: boolean | undefined;
55
56
  index?: boolean | undefined;
@@ -19,8 +19,9 @@ export class TextFieldBuilder extends FormFieldBuilder {
19
19
  get cell() {
20
20
  return null;
21
21
  }
22
- defaultValue(value) {
22
+ defaultValue(value, options) {
23
23
  this.field.defaultValue = value;
24
+ this.field.defaultFill = options?.fill;
24
25
  return this;
25
26
  }
26
27
  get dataType() {
@@ -1,12 +1,12 @@
1
1
  import type { DataType } from '../../core/fields/builders/form-field-builder.js';
2
2
  import { FormFieldBuilder } from '../../core/fields/builders/form-field-builder.js';
3
- import type { DefaultValueFn, FormField } from '../types.js';
3
+ import type { DefaultOptions, DefaultValueFn, FormField } from '../types.js';
4
4
  export declare const textarea: (name: string) => TextAreaFieldBuilder;
5
5
  export declare class TextAreaFieldBuilder extends FormFieldBuilder<TextAreaField> {
6
6
  constructor(name: string);
7
7
  get component(): import("svelte").Component<import("./component/props").TextAreaFieldProps, {}, "">;
8
8
  get cell(): null;
9
- defaultValue(value: string | DefaultValueFn<string>): this;
9
+ defaultValue(value: string | DefaultValueFn<string>, options?: DefaultOptions): this;
10
10
  get dataType(): DataType;
11
11
  isTitle(): this;
12
12
  placeholder(str: string): this;
@@ -44,6 +44,7 @@ export declare class TextAreaFieldBuilder extends FormFieldBuilder<TextAreaField
44
44
  onChange?: import("../types.js").FieldHookClient[] | undefined;
45
45
  } | undefined;
46
46
  defaultValue?: string | DefaultValueFn<string> | undefined;
47
+ defaultFill?: import("../types.js").DefaultFill | undefined;
47
48
  isEmpty: (value: unknown) => boolean;
48
49
  root?: boolean | undefined;
49
50
  index?: boolean | undefined;
@@ -15,8 +15,9 @@ export class TextAreaFieldBuilder extends FormFieldBuilder {
15
15
  get cell() {
16
16
  return null;
17
17
  }
18
- defaultValue(value) {
18
+ defaultValue(value, options) {
19
19
  this.field.defaultValue = value;
20
+ this.field.defaultFill = options?.fill;
20
21
  return this;
21
22
  }
22
23
  get dataType() {
@@ -1,11 +1,11 @@
1
1
  import type { DataType } from '../../core/fields/builders/form-field-builder.js';
2
2
  import { FormFieldBuilder } from '../../core/fields/builders/form-field-builder.js';
3
- import type { DefaultValueFn, FormField } from '../types.js';
3
+ import type { DefaultOptions, DefaultValueFn, FormField } from '../types.js';
4
4
  export declare const time: (name: string) => TimeFieldBuilder;
5
5
  export declare class TimeFieldBuilder extends FormFieldBuilder<TimeField> {
6
6
  constructor(name: string);
7
7
  get component(): import("svelte").Component<import("./component/props").TimeFieldProps, {}, "">;
8
- defaultValue(value: string | DefaultValueFn<string>): this;
8
+ defaultValue(value: string | DefaultValueFn<string>, options?: DefaultOptions): this;
9
9
  get dataType(): DataType;
10
10
  protected generateType(): string;
11
11
  }
@@ -15,8 +15,9 @@ export class TimeFieldBuilder extends FormFieldBuilder {
15
15
  get component() {
16
16
  return TimeComponent;
17
17
  }
18
- defaultValue(value) {
18
+ defaultValue(value, options) {
19
19
  this.field.defaultValue = value;
20
+ this.field.defaultFill = options?.fill;
20
21
  return this;
21
22
  }
22
23
  get dataType() {
@@ -1,12 +1,12 @@
1
1
  import { BooleanFieldBuilder } from '../../core/fields/builders/boolean-builder.js';
2
- import type { DefaultValueFn, FormField } from '../types.js';
2
+ import type { DefaultOptions, DefaultValueFn, FormField } from '../types.js';
3
3
  export declare class ToggleFieldBuilder extends BooleanFieldBuilder<ToggleField> {
4
4
  constructor(name: string);
5
5
  get component(): import("svelte").Component<import("./component/props").ToggleProps, {}, "">;
6
6
  get cell(): import("svelte").Component<{
7
7
  value: boolean | null;
8
8
  }, {}, "">;
9
- defaultValue(value: boolean | DefaultValueFn<boolean>): this;
9
+ defaultValue(value: boolean | DefaultValueFn<boolean>, options?: DefaultOptions): this;
10
10
  compile(): {
11
11
  type: "toggle";
12
12
  defaultValue?: (boolean | DefaultValueFn<boolean>) | undefined;
@@ -41,6 +41,7 @@ export declare class ToggleFieldBuilder extends BooleanFieldBuilder<ToggleField>
41
41
  beforeValidate?: import("../types.js").FieldHookShared<any>[] | undefined;
42
42
  onChange?: import("../types.js").FieldHookClient[] | undefined;
43
43
  } | undefined;
44
+ defaultFill?: import("../types.js").DefaultFill | undefined;
44
45
  isEmpty: (value: unknown) => boolean;
45
46
  root?: boolean | undefined;
46
47
  index?: boolean | undefined;
@@ -4,7 +4,6 @@ import Toggle from './component/Toggle.svelte';
4
4
  export class ToggleFieldBuilder extends BooleanFieldBuilder {
5
5
  constructor(name) {
6
6
  super(name, 'toggle');
7
- this.field.isEmpty = (value) => typeof value !== 'boolean';
8
7
  }
9
8
  get component() {
10
9
  return Toggle;
@@ -12,8 +11,9 @@ export class ToggleFieldBuilder extends BooleanFieldBuilder {
12
11
  get cell() {
13
12
  return Cell;
14
13
  }
15
- defaultValue(value) {
14
+ defaultValue(value, options) {
16
15
  this.field.defaultValue = value;
16
+ this.field.defaultFill = options?.fill;
17
17
  return this;
18
18
  }
19
19
  compile() {
@@ -1,13 +1,13 @@
1
1
  <script lang="ts">
2
2
  import type { FieldBuilder } from '../../../core/fields/builders';
3
- import { emptyValuesFromFieldConfig } from '../../../core/fields/util';
3
+ import { initialValues } from '../../../core/fields/initial.js';
4
4
  import type { Field } from '../../types.js';
5
5
  import Button from '../../../panel/components/ui/button/button.svelte';
6
6
  import type { Dic } from '../../../util/types';
7
7
  import { Plus } from '@lucide/svelte';
8
8
  import type { Snippet } from 'svelte';
9
9
 
10
- type AddItem = (emptyValues: Dic) => void;
10
+ type AddItem = (values: Dic) => void;
11
11
  type Props = {
12
12
  size: 'default' | 'sm';
13
13
  class: string;
@@ -18,8 +18,7 @@
18
18
  const { class: className, fields, addItem, size, children }: Props = $props();
19
19
 
20
20
  const add = () => {
21
- const empty = emptyValuesFromFieldConfig(fields);
22
- addItem(empty);
21
+ addItem(initialValues(fields));
23
22
  };
24
23
  </script>
25
24
 
@@ -2,7 +2,7 @@ import type { FieldBuilder } from '../../../core/fields/builders';
2
2
  import type { Field } from '../../types.js';
3
3
  import type { Dic } from '../../../util/types';
4
4
  import type { Snippet } from 'svelte';
5
- type AddItem = (emptyValues: Dic) => void;
5
+ type AddItem = (values: Dic) => void;
6
6
  type Props = {
7
7
  size: 'default' | 'sm';
8
8
  class: string;
@@ -0,0 +1,21 @@
1
+ import type { FieldBuilder } from '../../core/fields/builders/field-builder.js';
2
+ import type { Field } from '../types.js';
3
+ import type { Dic } from '../../util/types.js';
4
+ /** A tree item in a default: the values it starts with, and its own items. */
5
+ export type TreeItemDefault = Dic & {
6
+ _children?: TreeItemDefault[];
7
+ };
8
+ /**
9
+ * A default tree as a document holds it: each item with a fresh temporary id and the initial
10
+ * values of the tree's fields, the values it names winning, its `_children` completed the same
11
+ * way. A new copy on each call.
12
+ *
13
+ * ```ts
14
+ * completeTree([text('label')], [{ label: 'Home', _children: [{ label: 'About' }] }]);
15
+ * // [{
16
+ * // id: 'temp-…', path: null, position: null, label: 'Home',
17
+ * // _children: [{ id: 'temp-…', path: null, position: null, label: 'About', _children: [] }]
18
+ * // }]
19
+ * ```
20
+ */
21
+ export declare const completeTree: (fields: FieldBuilder<Field>[], value: TreeItemDefault[]) => Dic[];
@@ -0,0 +1,18 @@
1
+ import { completeItem } from '../../core/fields/complete.js';
2
+ /**
3
+ * A default tree as a document holds it: each item with a fresh temporary id and the initial
4
+ * values of the tree's fields, the values it names winning, its `_children` completed the same
5
+ * way. A new copy on each call.
6
+ *
7
+ * ```ts
8
+ * completeTree([text('label')], [{ label: 'Home', _children: [{ label: 'About' }] }]);
9
+ * // [{
10
+ * // id: 'temp-…', path: null, position: null, label: 'Home',
11
+ * // _children: [{ id: 'temp-…', path: null, position: null, label: 'About', _children: [] }]
12
+ * // }]
13
+ * ```
14
+ */
15
+ export const completeTree = (fields, value) => value.map((given) => ({
16
+ ...completeItem(fields, given),
17
+ _children: completeTree(fields, given._children ?? [])
18
+ }));
@@ -1,7 +1,9 @@
1
1
  import { FieldBuilder, type FieldNode, type ValueNode } from '../../core/fields/builders/field-builder.js';
2
- import { FormFieldBuilder } from '../../core/fields/builders/form-field-builder.js';
3
- import type { Field, FormField } from '../types.js';
2
+ import { FormFieldBuilder, type FormFieldUse } from '../../core/fields/builders/form-field-builder.js';
3
+ import type { CompletesDefault } from '../../core/fields/complete.js';
4
+ import type { DefaultOptions, DefaultValueFn, Field, FormField } from '../types.js';
4
5
  import type { Dic } from '../../util/types.js';
6
+ import { type TreeItemDefault } from './defaults.js';
5
7
  export declare const tree: (name: string) => TreeBuilder;
6
8
  export declare class TreeBuilder extends FormFieldBuilder<TreeField> {
7
9
  constructor(name: string);
@@ -15,6 +17,17 @@ export declare class TreeBuilder extends FormFieldBuilder<TreeField> {
15
17
  addItemLabel(label: string): this;
16
18
  renderTitle(render: TreeFieldBlockRenderTitle): this;
17
19
  maxDepth(n: number): this;
20
+ /**
21
+ * The items a new document starts with. Each names the values it starts with and its own
22
+ * `_children`; the rest comes from the tree's fields.
23
+ *
24
+ * ```ts
25
+ * tree('nav').fields(text('label')).defaultValue([{ label: 'Home', _children: [{ label: 'About' }] }]);
26
+ * ```
27
+ */
28
+ defaultValue(value: TreeItemDefault[] | DefaultValueFn<TreeItemDefault[]>, options?: DefaultOptions): this;
29
+ /** The default completed as a document holds it — see `completeTree`. */
30
+ get use(): FormFieldUse<TreeField> & CompletesDefault<TreeItemDefault>;
18
31
  localized(): this;
19
32
  compile(): {
20
33
  fields: ({
@@ -63,7 +76,8 @@ export declare class TreeBuilder extends FormFieldBuilder<TreeField> {
63
76
  beforeValidate?: import("../types.js").FieldHookShared[];
64
77
  onChange?: import("../types.js").FieldHookClient[];
65
78
  };
66
- defaultValue?: import("../types.js").DefaultValueFn<any> | unknown;
79
+ defaultValue?: DefaultValueFn<any> | unknown;
80
+ defaultFill?: import("../types.js").DefaultFill;
67
81
  isEmpty: (value: unknown) => boolean;
68
82
  root?: boolean;
69
83
  index?: boolean;
@@ -6,6 +6,7 @@ import { number } from '../number/index.js';
6
6
  import { text } from '../text/index.js';
7
7
  import Cell from './component/Cell.svelte';
8
8
  import Tree from './component/Tree.svelte';
9
+ import { completeTree } from './defaults.js';
9
10
  export const tree = (name) => new TreeBuilder(name);
10
11
  export class TreeBuilder extends FormFieldBuilder {
11
12
  constructor(name) {
@@ -38,6 +39,32 @@ export class TreeBuilder extends FormFieldBuilder {
38
39
  this.field.maxDepth = n;
39
40
  return this;
40
41
  }
42
+ /**
43
+ * The items a new document starts with. Each names the values it starts with and its own
44
+ * `_children`; the rest comes from the tree's fields.
45
+ *
46
+ * ```ts
47
+ * tree('nav').fields(text('label')).defaultValue([{ label: 'Home', _children: [{ label: 'About' }] }]);
48
+ * ```
49
+ */
50
+ defaultValue(value, options) {
51
+ this.field.defaultValue = value;
52
+ this.field.defaultFill = options?.fill;
53
+ return this;
54
+ }
55
+ /** The default completed as a document holds it — see `completeTree`. */
56
+ get use() {
57
+ const use = super.use;
58
+ const completeDefault = (value) => completeTree(this.field.fields, value);
59
+ return {
60
+ ...use,
61
+ completeDefault,
62
+ defaultValue: (context = {}) => {
63
+ const value = use.defaultValue(context);
64
+ return Array.isArray(value) ? completeDefault(value) : [];
65
+ }
66
+ };
67
+ }
41
68
  localized() {
42
69
  if (this.field.fields.length === 0) {
43
70
  throw new Error('localized() must be called after fields assignment');