rimecms 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter-sqlite/read.server.js +4 -4
- package/dist/adapter-sqlite/table.server.d.ts +3 -6
- package/dist/adapter-sqlite/table.server.js +3 -6
- package/dist/adapter-sqlite/transform.server.d.ts +1 -1
- package/dist/adapter-sqlite/transform.server.js +3 -2
- package/dist/adapter-sqlite/write.server.d.ts +13 -15
- package/dist/adapter-sqlite/write.server.js +15 -17
- package/dist/core/adapter.d.ts +19 -33
- package/dist/core/adapter.js +0 -12
- package/dist/core/auth/augment.js +2 -1
- package/dist/core/auth/hooks/augment-fields-password.server.d.ts +2 -2
- package/dist/core/auth/hooks/augment-fields-password.server.js +2 -2
- package/dist/core/auth/tables.d.ts +2 -5
- package/dist/core/auth/tables.js +3 -7
- package/dist/core/auth/validate-config.d.ts +3 -8
- package/dist/core/auth/validate-config.js +4 -10
- package/dist/core/config/types.d.ts +6 -6
- package/dist/core/config/validate.server.js +11 -0
- package/dist/core/fields/builders/boolean-builder.d.ts +2 -2
- package/dist/core/fields/builders/boolean-builder.js +4 -1
- package/dist/core/fields/builders/select-builder.d.ts +3 -3
- package/dist/core/fields/builders/select-builder.js +4 -2
- package/dist/core/fields/complete.d.ts +18 -0
- package/dist/core/fields/complete.js +32 -0
- package/dist/core/fields/empty.d.ts +14 -0
- package/dist/core/fields/empty.js +13 -0
- package/dist/core/fields/initial.d.ts +32 -0
- package/dist/core/fields/initial.js +47 -0
- package/dist/core/fields/util.d.ts +0 -16
- package/dist/core/fields/util.js +0 -29
- package/dist/core/pipeline/build-document.server.d.ts +4 -10
- package/dist/core/pipeline/build-document.server.js +8 -17
- package/dist/core/pipeline/hooks/data-config-map.server.d.ts +1 -1
- package/dist/core/pipeline/hooks/data-config-map.server.js +1 -1
- package/dist/core/pipeline/hooks/process-document-fields.server.d.ts +3 -2
- package/dist/core/pipeline/hooks/process-document-fields.server.js +3 -16
- package/dist/core/pipeline/hooks/set-default-values.server.d.ts +15 -4
- package/dist/core/pipeline/hooks/set-default-values.server.js +50 -25
- package/dist/core/pipeline/hooks/validate-fields.server.js +1 -1
- package/dist/core/pipeline/run.server.js +1 -2
- package/dist/core/prototype/area/api.server.d.ts +4 -6
- package/dist/core/prototype/area/api.server.js +4 -6
- package/dist/core/prototype/area/definition.server.js +23 -9
- package/dist/core/prototype/area/hooks.server.js +1 -1
- package/dist/core/prototype/collection/api.server.d.ts +5 -6
- package/dist/core/prototype/collection/api.server.js +5 -6
- package/dist/core/prototype/collection/definition.js +3 -8
- package/dist/core/prototype/collection/hooks/merge-with-initial.server.d.ts +15 -0
- package/dist/core/prototype/collection/hooks/merge-with-initial.server.js +20 -0
- package/dist/core/prototype/collection/hooks.server.js +5 -5
- package/dist/core/prototype/collection/nested/module.js +1 -1
- package/dist/core/prototype/collection/nested/module.server.js +1 -1
- package/dist/core/prototype/collection/operations/duplicate.js +4 -8
- package/dist/core/prototype/collection/upload/directories/derive.js +2 -2
- package/dist/core/prototype/collection/upload/hooks/handle-path-creation.server.js +2 -2
- package/dist/core/prototype/define.d.ts +2 -2
- package/dist/core/prototype/define.js +4 -4
- package/dist/core/prototype/initial.d.ts +23 -0
- package/dist/core/prototype/initial.js +19 -0
- package/dist/core/prototype/shared/versions/augment.d.ts +2 -4
- package/dist/core/prototype/shared/versions/augment.js +4 -6
- package/dist/core/prototype/shared/versions/configure.server.js +3 -3
- package/dist/core/prototype/shared/versions/hooks/fallback-data-from-original.d.ts +14 -2
- package/dist/core/prototype/shared/versions/hooks/fallback-data-from-original.js +28 -22
- package/dist/core/prototype/shared/versions/hooks/handle-new-version.server.js +3 -4
- package/dist/core/prototype/shared/versions/{blank.d.ts → initial.d.ts} +2 -4
- package/dist/core/prototype/shared/versions/{blank.js → initial.js} +2 -4
- package/dist/core/prototype/when.d.ts +2 -6
- package/dist/core/prototype/when.js +2 -6
- package/dist/fields/blocks/component/AddBlockButton.svelte +2 -2
- package/dist/fields/blocks/component/focus/BlocksFocus.svelte +2 -13
- package/dist/fields/blocks/component/focus/Inspector.svelte +43 -3
- package/dist/fields/blocks/component/focus/Renders.svelte +29 -1
- package/dist/fields/blocks/component/focus/StagePlaceholder.svelte +24 -4
- package/dist/fields/blocks/component/focus/StagePlaceholder.svelte.d.ts +6 -1
- package/dist/fields/blocks/component/focus/focus.svelte.d.ts +11 -3
- package/dist/fields/blocks/component/focus/focus.svelte.js +31 -10
- package/dist/fields/blocks/defaults.d.ts +22 -0
- package/dist/fields/blocks/defaults.js +23 -0
- package/dist/fields/blocks/index.d.ts +18 -2
- package/dist/fields/blocks/index.js +33 -1
- package/dist/fields/combobox/index.d.ts +2 -2
- package/dist/fields/combobox/index.js +2 -1
- package/dist/fields/date/index.d.ts +2 -2
- package/dist/fields/date/index.js +2 -1
- package/dist/fields/email/index.d.ts +2 -2
- package/dist/fields/email/index.js +2 -1
- package/dist/fields/group/index.d.ts +1 -0
- package/dist/fields/link/index.d.ts +3 -2
- package/dist/fields/link/index.js +2 -1
- package/dist/fields/number/index.d.ts +3 -2
- package/dist/fields/number/index.js +2 -1
- package/dist/fields/relation/component/default/Default.svelte +1 -1
- package/dist/fields/relation/component/upload/Create.svelte +1 -1
- package/dist/fields/relation/index.d.ts +2 -2
- package/dist/fields/relation/index.js +2 -1
- package/dist/fields/relation/util.d.ts +9 -21
- package/dist/fields/relation/util.js +11 -28
- package/dist/fields/rich-text/index.d.ts +2 -2
- package/dist/fields/rich-text/index.js +2 -1
- package/dist/fields/slug/index.d.ts +3 -2
- package/dist/fields/slug/index.js +2 -1
- package/dist/fields/text/index.d.ts +3 -2
- package/dist/fields/text/index.js +2 -1
- package/dist/fields/textarea/index.d.ts +3 -2
- package/dist/fields/textarea/index.js +2 -1
- package/dist/fields/time/index.d.ts +2 -2
- package/dist/fields/time/index.js +2 -1
- package/dist/fields/toggle/index.d.ts +3 -2
- package/dist/fields/toggle/index.js +2 -2
- package/dist/fields/tree/component/AddItemButton.svelte +3 -4
- package/dist/fields/tree/component/AddItemButton.svelte.d.ts +1 -1
- package/dist/fields/tree/defaults.d.ts +21 -0
- package/dist/fields/tree/defaults.js +18 -0
- package/dist/fields/tree/index.d.ts +17 -3
- package/dist/fields/tree/index.js +27 -0
- package/dist/fields/types.d.ts +14 -0
- package/dist/live/context.svelte.js +7 -3
- package/dist/panel/components/ui/command/command-dialog.svelte +2 -8
- package/dist/panel/components/ui/command/command-dialog.svelte.d.ts +1 -1
- package/dist/panel/context/blocks-ops.d.ts +0 -1
- package/dist/panel/context/blocks-ops.js +1 -2
- package/dist/panel/pages/collection-document/load.server.js +1 -1
- package/dist/util/object.d.ts +2 -2
- package/dist/util/object.js +3 -3
- package/dist/util/random.d.ts +2 -0
- package/dist/util/random.js +2 -0
- package/package.json +2 -2
- package/dist/core/fields/blank.d.ts +0 -21
- package/dist/core/fields/blank.js +0 -37
- package/dist/core/prototype/blank.d.ts +0 -26
- package/dist/core/prototype/blank.js +0 -22
- package/dist/core/prototype/collection/hooks/merge-with-blank.server.d.ts +0 -9
- package/dist/core/prototype/collection/hooks/merge-with-blank.server.js +0 -14
- package/dist/panel/components/ui/tooltip/index.d.ts +0 -7
|
@@ -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
|
|
@@ -3,30 +3,18 @@ import type { Relation } from './index.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Checks if a relation field's value is populated with full documents.
|
|
5
5
|
*
|
|
6
|
-
* A relation is
|
|
7
|
-
*
|
|
8
|
-
* If the value is a string or an array of relation identifier objects,
|
|
9
|
-
* it is considered not populated.
|
|
6
|
+
* A relation is populated when it is a non-empty array of documents: objects that are not
|
|
7
|
+
* relation references (`id`, `relationTo`, `documentId`). Anything else is not populated.
|
|
10
8
|
*
|
|
11
9
|
* @example
|
|
12
|
-
*
|
|
13
|
-
* isRelationPopulated('7674e91b-598a-4a72-a5cd-9594736a34dd');
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* //
|
|
17
|
-
* isRelationPopulated(
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* // Returns: false
|
|
21
|
-
* isRelationPopulated([
|
|
22
|
-
* {
|
|
23
|
-
* id: '7674e91b-598a-4a72-a5cd-9594736a34dd',
|
|
24
|
-
* relationTo: 'articles',
|
|
25
|
-
* documentId: 'b674e91b-598a-4a72-a5cd-9594736a34dd'
|
|
26
|
-
* }
|
|
27
|
-
* ]);
|
|
10
|
+
* isRelationPopulated([{ id: '7674…', title: 'Home' }]); // true
|
|
11
|
+
* isRelationPopulated('7674e91b-598a-4a72-a5cd-9594736a34dd'); // false
|
|
12
|
+
* isRelationPopulated([{ id: '7674…', relationTo: 'articles', documentId: 'b674…' }]); // false
|
|
13
|
+
* isRelationPopulated([]); // false
|
|
14
|
+
* isRelationPopulated(undefined); // false
|
|
15
|
+
* isRelationPopulated(null); // false
|
|
28
16
|
*/
|
|
29
|
-
export declare const isRelationPopulated: <T>(value: RelationValue<T>) => value is T[];
|
|
17
|
+
export declare const isRelationPopulated: <T>(value: RelationValue<T> | null | undefined) => value is T[];
|
|
30
18
|
/**
|
|
31
19
|
* Checks if a relation value is resolved (contains the actual referenced document).
|
|
32
20
|
*
|
|
@@ -2,38 +2,21 @@ import { hasProps, isObjectLiteral } from '../../util/object.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Checks if a relation field's value is populated with full documents.
|
|
4
4
|
*
|
|
5
|
-
* A relation is
|
|
6
|
-
*
|
|
7
|
-
* If the value is a string or an array of relation identifier objects,
|
|
8
|
-
* it is considered not populated.
|
|
5
|
+
* A relation is populated when it is a non-empty array of documents: objects that are not
|
|
6
|
+
* relation references (`id`, `relationTo`, `documentId`). Anything else is not populated.
|
|
9
7
|
*
|
|
10
8
|
* @example
|
|
11
|
-
*
|
|
12
|
-
* isRelationPopulated('7674e91b-598a-4a72-a5cd-9594736a34dd');
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* //
|
|
16
|
-
* isRelationPopulated(
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* // Returns: false
|
|
20
|
-
* isRelationPopulated([
|
|
21
|
-
* {
|
|
22
|
-
* id: '7674e91b-598a-4a72-a5cd-9594736a34dd',
|
|
23
|
-
* relationTo: 'articles',
|
|
24
|
-
* documentId: 'b674e91b-598a-4a72-a5cd-9594736a34dd'
|
|
25
|
-
* }
|
|
26
|
-
* ]);
|
|
9
|
+
* isRelationPopulated([{ id: '7674…', title: 'Home' }]); // true
|
|
10
|
+
* isRelationPopulated('7674e91b-598a-4a72-a5cd-9594736a34dd'); // false
|
|
11
|
+
* isRelationPopulated([{ id: '7674…', relationTo: 'articles', documentId: 'b674…' }]); // false
|
|
12
|
+
* isRelationPopulated([]); // false
|
|
13
|
+
* isRelationPopulated(undefined); // false
|
|
14
|
+
* isRelationPopulated(null); // false
|
|
27
15
|
*/
|
|
28
16
|
export const isRelationPopulated = (value) => {
|
|
29
|
-
if (Array.isArray(value))
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return value.every((v) => {
|
|
33
|
-
return isObjectLiteral(v) && !hasProps(['id', 'relationTo', 'documentId'], v);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
return typeof value !== 'string';
|
|
17
|
+
if (!Array.isArray(value) || value.length === 0)
|
|
18
|
+
return false;
|
|
19
|
+
return value.every((v) => isObjectLiteral(v) && !hasProps(['id', 'relationTo', 'documentId'], v));
|
|
37
20
|
};
|
|
38
21
|
/**
|
|
39
22
|
* Checks if a relation value is resolved (contains the actual referenced document).
|
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 {
|
|
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 = (
|
|
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
|
-
|
|
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 = (
|
|
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 {
|
|
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?:
|
|
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');
|
package/dist/fields/types.d.ts
CHANGED
|
@@ -64,6 +64,8 @@ export type FormField = Field & {
|
|
|
64
64
|
table?: FieldPanelTableConfig;
|
|
65
65
|
hooks?: FieldHooks;
|
|
66
66
|
defaultValue?: DefaultValueFn<any> | unknown;
|
|
67
|
+
/** When the default fills the field. Set by `defaultValue(value, { fill })`. */
|
|
68
|
+
defaultFill?: DefaultFill;
|
|
67
69
|
isEmpty: (value: unknown) => boolean;
|
|
68
70
|
/** Kept on the base row of a versioned config, shared by every version. Set by `$root()`. */
|
|
69
71
|
root?: boolean;
|
|
@@ -73,6 +75,18 @@ export type FormField = Field & {
|
|
|
73
75
|
export type DefaultValueFn<T> = ({ event }: {
|
|
74
76
|
event?: RequestEvent;
|
|
75
77
|
}) => T;
|
|
78
|
+
/**
|
|
79
|
+
* When a default fills its field.
|
|
80
|
+
*
|
|
81
|
+
* ```ts
|
|
82
|
+
* text('title').defaultValue('Untitled') // 'create': a new document starts with it
|
|
83
|
+
* text('title').defaultValue('Untitled', { fill: 'save' }) // 'save': and a save never leaves it empty
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export type DefaultFill = 'create' | 'save';
|
|
87
|
+
export type DefaultOptions = {
|
|
88
|
+
fill?: DefaultFill;
|
|
89
|
+
};
|
|
76
90
|
export type FieldHookContext<T extends FormField = FormField> = {
|
|
77
91
|
event: RequestEvent;
|
|
78
92
|
/** The document Id being processed */
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import { page } from '$app/state';
|
|
2
|
-
import { env } from '$env/dynamic/public';
|
|
3
2
|
import { PARAMS } from '../core/constants.js';
|
|
4
3
|
import { getContext, setContext } from 'svelte';
|
|
5
4
|
import { getValueAtPath, setValueAtPath } from '../util/object.js';
|
|
6
5
|
import { populate } from '../fields/relation/populate.js';
|
|
7
6
|
export const LIVE_KEY = Symbol('rime.live');
|
|
7
|
+
/**
|
|
8
|
+
* The panel's origin, the only one whose messages are read. `$env/dynamic/public` loads with the
|
|
9
|
+
* first message, so `rimecms/public` imports outside a SvelteKit page, in a component spec.
|
|
10
|
+
*/
|
|
11
|
+
let panelOrigin;
|
|
12
|
+
const getPanelOrigin = () => (panelOrigin ??= import('$env/dynamic/public').then(({ env }) => new URL(env.PUBLIC_RIME_URL).origin));
|
|
8
13
|
function createStore(href) {
|
|
9
14
|
let enabled = $state(false);
|
|
10
15
|
let doc = $state();
|
|
11
16
|
const liveStore = $state({});
|
|
12
17
|
let activePanelKey = $state(null);
|
|
13
|
-
const origin = new URL(env.PUBLIC_RIME_URL).origin;
|
|
14
18
|
/**
|
|
15
19
|
* Handles navigation within iframe to maintain live editing mode
|
|
16
20
|
*/
|
|
@@ -28,7 +32,7 @@ function createStore(href) {
|
|
|
28
32
|
*/
|
|
29
33
|
const onMessage = async (e) => {
|
|
30
34
|
// Only accept messages from the trusted panel origin
|
|
31
|
-
if (e.origin !==
|
|
35
|
+
if (e.origin !== (await getPanelOrigin()))
|
|
32
36
|
return;
|
|
33
37
|
// Handle handshake request
|
|
34
38
|
if (e.data.handshake) {
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
let {
|
|
13
13
|
open = $bindable(false),
|
|
14
14
|
ref = $bindable(null),
|
|
15
|
-
value = $bindable(''),
|
|
16
15
|
preventScroll = true,
|
|
17
16
|
onCloseAutoFocus,
|
|
18
17
|
children,
|
|
@@ -26,14 +25,9 @@
|
|
|
26
25
|
} = $props();
|
|
27
26
|
</script>
|
|
28
27
|
|
|
28
|
+
<!-- The command mounts with each opening, so its selection starts on the first line. -->
|
|
29
29
|
<Dialog.Root bind:open {...restProps}>
|
|
30
30
|
<Dialog.Content class="rz-command-dialog-content" {preventScroll} {onCloseAutoFocus}>
|
|
31
|
-
<Command
|
|
32
|
-
class="rz-command-dialog-content__command"
|
|
33
|
-
{...restProps}
|
|
34
|
-
bind:value
|
|
35
|
-
bind:ref
|
|
36
|
-
{children}
|
|
37
|
-
/>
|
|
31
|
+
<Command class="rz-command-dialog-content__command" {...restProps} bind:ref {children} />
|
|
38
32
|
</Dialog.Content>
|
|
39
33
|
</Dialog.Root>
|
|
@@ -7,6 +7,6 @@ type $$ComponentProps = WithoutChildrenOrChild<DialogPrimitive.RootProps> & With
|
|
|
7
7
|
/** The dialog is giving the focus back to where it was. */
|
|
8
8
|
onCloseAutoFocus?: (event: Event) => void;
|
|
9
9
|
};
|
|
10
|
-
declare const CommandDialog: import("svelte").Component<$$ComponentProps, {}, "
|
|
10
|
+
declare const CommandDialog: import("svelte").Component<$$ComponentProps, {}, "ref" | "open">;
|
|
11
11
|
type CommandDialog = ReturnType<typeof CommandDialog>;
|
|
12
12
|
export default CommandDialog;
|
|
@@ -24,7 +24,6 @@ export type BlockClipboardData = {
|
|
|
24
24
|
block: GenericBlock;
|
|
25
25
|
};
|
|
26
26
|
export declare const CLIPBOARD_KIND = "block";
|
|
27
|
-
export declare const tempId: () => string;
|
|
28
27
|
/** `sections.0.items.2` -> `{ list: 'sections.0.items', index: 2 }` */
|
|
29
28
|
export declare const parseBlockPath: (path: string) => BlockAt;
|
|
30
29
|
export declare const blockPath: (at: BlockAt) => string;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { getValueAtPath, isObjectLiteral, setValueAtPath } from '../../util/object.js';
|
|
2
2
|
import { normalizeFieldPath } from '../../util/string.js';
|
|
3
|
-
import {
|
|
3
|
+
import { tempId } from '../../util/random.js';
|
|
4
4
|
import cloneDeep from 'clone-deep';
|
|
5
5
|
export const CLIPBOARD_KIND = 'block';
|
|
6
|
-
export const tempId = () => `temp-${randomId(8)}`;
|
|
7
6
|
/** `sections.0.items.2` -> `{ list: 'sections.0.items', index: 2 }` */
|
|
8
7
|
export const parseBlockPath = (path) => {
|
|
9
8
|
const normalized = normalizeFieldPath(path);
|
|
@@ -30,7 +30,7 @@ export async function documentLoad(event) {
|
|
|
30
30
|
if (!authorized) {
|
|
31
31
|
throw handleError(new RimeError(RimeError.UNAUTHORIZED), { context: ERROR_CONTEXT.LOAD });
|
|
32
32
|
}
|
|
33
|
-
doc = collection.
|
|
33
|
+
doc = collection.initial();
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
36
|
/** Check for authorizations */
|
package/dist/util/object.d.ts
CHANGED
|
@@ -40,11 +40,11 @@ export declare const omitId: <T extends {
|
|
|
40
40
|
* Anything the object holds is the object's — `null` included, an array as it is.
|
|
41
41
|
*
|
|
42
42
|
* ```
|
|
43
|
-
*
|
|
43
|
+
* withDefaultValues({ title: 'T', seo: { og: null } }, { title: null, body: null, seo: { og: null, meta: null } })
|
|
44
44
|
* // { title: 'T', seo: { og: null, meta: null }, body: null }
|
|
45
45
|
* ```
|
|
46
46
|
*/
|
|
47
|
-
export declare const
|
|
47
|
+
export declare const withDefaultValues: <T extends Dic>(obj: T, defaults: Dic) => T;
|
|
48
48
|
/**
|
|
49
49
|
* Type guard to check if an object has all the specified properties.
|
|
50
50
|
*
|
package/dist/util/object.js
CHANGED
|
@@ -59,18 +59,18 @@ export const omitId = (obj) => omit(['id'], obj);
|
|
|
59
59
|
* Anything the object holds is the object's — `null` included, an array as it is.
|
|
60
60
|
*
|
|
61
61
|
* ```
|
|
62
|
-
*
|
|
62
|
+
* withDefaultValues({ title: 'T', seo: { og: null } }, { title: null, body: null, seo: { og: null, meta: null } })
|
|
63
63
|
* // { title: 'T', seo: { og: null, meta: null }, body: null }
|
|
64
64
|
* ```
|
|
65
65
|
*/
|
|
66
|
-
export const
|
|
66
|
+
export const withDefaultValues = (obj, defaults) => {
|
|
67
67
|
const out = { ...obj };
|
|
68
68
|
for (const key of Object.keys(defaults)) {
|
|
69
69
|
const value = obj[key];
|
|
70
70
|
if (value === undefined)
|
|
71
71
|
out[key] = defaults[key];
|
|
72
72
|
else if (isObjectLiteral(value) && isObjectLiteral(defaults[key])) {
|
|
73
|
-
out[key] =
|
|
73
|
+
out[key] = withDefaultValues(value, defaults[key]);
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
return out;
|