rimecms 0.29.0 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter-sqlite/area.server.js +8 -8
- package/dist/adapter-sqlite/generate-schema/column.server.d.ts +13 -0
- package/dist/adapter-sqlite/generate-schema/column.server.js +77 -0
- package/dist/adapter-sqlite/generate-schema/index.server.js +7 -12
- package/dist/adapter-sqlite/generate-schema/root.server.js +35 -39
- package/dist/adapter-sqlite/generate-schema/templates.server.d.ts +12 -0
- package/dist/adapter-sqlite/generate-schema/templates.server.js +19 -0
- package/dist/adapter-sqlite/index.server.d.ts +1 -2
- package/dist/adapter-sqlite/index.server.js +0 -2
- package/dist/adapter-sqlite/relations.server.js +6 -1
- package/dist/adapter-sqlite/util.server.d.ts +1 -6
- package/dist/adapter-sqlite/util.server.js +6 -0
- package/dist/adapter-sqlite/where.server.js +17 -16
- package/dist/adapter-sqlite/with.server.js +9 -9
- package/dist/core/collections/auth/fields.d.ts +2 -182
- package/dist/core/collections/config/augment-auth.server.js +1 -1
- package/dist/core/collections/config/augment-nested.server.js +1 -1
- package/dist/core/collections/config/augment-upload.js +2 -2
- package/dist/core/collections/config/augment-upload.server.js +4 -1
- package/dist/core/collections/operations/duplicate.js +30 -11
- package/dist/core/collections/operations/updateById.js +6 -5
- package/dist/core/collections/rest/duplicate.server.js +7 -3
- package/dist/core/collections/upload/disk/delete.server.d.ts +1 -1
- package/dist/core/collections/upload/disk/delete.server.js +48 -1
- package/dist/core/collections/upload/hooks/clean-up-files.server.js +2 -2
- package/dist/core/collections/upload/hooks/extract-path.server.d.ts +1 -1
- package/dist/core/collections/upload/hooks/extract-path.server.js +1 -1
- package/dist/core/collections/upload/hooks/process-file-upload.server.js +3 -3
- package/dist/core/config/server/validate.server.js +50 -30
- package/dist/core/config/shared/find-thumbnail.js +12 -12
- package/dist/core/config/shared/find-title.js +13 -13
- package/dist/core/config/shared/upload-directories.js +1 -1
- package/dist/core/constant.server.d.ts +1 -0
- package/dist/core/constant.server.js +2 -0
- package/dist/core/dev/cache/index.server.js +9 -9
- package/dist/core/dev/cli/build/index.js +2 -2
- package/dist/core/dev/cli/clear/index.server.js +2 -1
- package/dist/core/dev/cli/generate/index.server.js +3 -2
- package/dist/core/dev/cli/init/index.server.js +1 -1
- package/dist/core/dev/generate/routes/index.server.js +2 -2
- package/dist/core/dev/generate/types/index.server.js +17 -17
- package/dist/core/dev/vite/index.server.js +21 -5
- package/dist/core/fields/builders/boolean-builder.d.ts +3 -1
- package/dist/core/fields/builders/boolean-builder.js +3 -0
- package/dist/core/fields/builders/field-builder.d.ts +35 -2
- package/dist/core/fields/builders/field-builder.js +33 -2
- package/dist/core/fields/builders/form-field-builder.d.ts +71 -12
- package/dist/core/fields/builders/form-field-builder.js +96 -6
- package/dist/core/fields/builders/select-builder.d.ts +4 -1
- package/dist/core/fields/builders/select-builder.js +3 -0
- package/dist/core/fields/util.d.ts +8 -16
- package/dist/core/fields/util.js +49 -83
- package/dist/core/handlers/routes.server.js +16 -3
- package/dist/core/naming.d.ts +34 -0
- package/dist/core/naming.js +39 -0
- package/dist/core/operations/blocks/diff.server.js +1 -1
- package/dist/core/operations/blocks/extract.server.js +1 -1
- package/dist/core/operations/configMap/buildTreeMap.d.ts +3 -2
- package/dist/core/operations/configMap/buildTreeMap.js +1 -1
- package/dist/core/operations/configMap/index.d.ts +2 -1
- package/dist/core/operations/configMap/index.js +13 -13
- package/dist/core/operations/configMap/types.d.ts +2 -2
- package/dist/core/operations/hooks/before-read/process-document-fields.server.js +14 -17
- package/dist/core/operations/hooks/before-upsert/data-config-map.server.js +1 -1
- package/dist/core/operations/hooks/before-upsert/original-config-map.server.js +1 -1
- package/dist/core/operations/hooks/before-upsert/set-default-values.server.d.ts +2 -4
- package/dist/core/operations/hooks/before-upsert/set-default-values.server.js +10 -15
- package/dist/core/operations/hooks/before-upsert/validate-fields.server.js +49 -31
- package/dist/core/operations/relations/extract.server.js +5 -5
- package/dist/core/operations/shared/fallback-data-from-original.js +2 -2
- package/dist/core/operations/tree/diff.server.js +1 -1
- package/dist/core/operations/tree/extract.server.js +1 -1
- package/dist/core/plugins/cache/cache.server.js +3 -3
- package/dist/fields/blocks/component/AddBlockButton.svelte +7 -7
- package/dist/fields/blocks/component/AddBlockButton.svelte.d.ts +2 -2
- package/dist/fields/blocks/component/Blocks.svelte +6 -7
- package/dist/fields/blocks/component/props.d.ts +2 -2
- package/dist/fields/blocks/index.d.ts +1 -1
- package/dist/fields/blocks/index.js +3 -3
- package/dist/fields/blocks/index.server.js +1 -1
- package/dist/fields/checkbox/component/Checkbox.svelte +2 -2
- package/dist/fields/checkbox/component/props.d.ts +2 -2
- package/dist/fields/checkbox/index.server.d.ts +1 -2
- package/dist/fields/checkbox/index.server.js +1 -10
- package/dist/fields/combobox/component/ComboBox.svelte +3 -3
- package/dist/fields/combobox/component/props.d.ts +2 -2
- package/dist/fields/combobox/index.server.d.ts +1 -2
- package/dist/fields/combobox/index.server.js +2 -11
- package/dist/fields/component/index.d.ts +1 -1
- package/dist/fields/date/component/Date.svelte +4 -4
- package/dist/fields/date/component/Date.svelte.d.ts +2 -2
- package/dist/fields/date/index.d.ts +3 -1
- package/dist/fields/date/index.js +3 -0
- package/dist/fields/date/index.server.d.ts +1 -2
- package/dist/fields/date/index.server.js +1 -10
- package/dist/fields/email/component/Email.svelte +5 -6
- package/dist/fields/email/component/props.d.ts +2 -3
- package/dist/fields/email/index.d.ts +3 -2
- package/dist/fields/email/index.js +4 -1
- package/dist/fields/email/index.server.d.ts +0 -3
- package/dist/fields/email/index.server.js +0 -9
- package/dist/fields/group/component/Group.svelte +9 -15
- package/dist/fields/group/component/Group.svelte.d.ts +2 -2
- package/dist/fields/group/index.d.ts +4 -2
- package/dist/fields/group/index.server.js +2 -2
- package/dist/fields/index.server.d.ts +1 -4
- package/dist/fields/index.server.js +17 -13
- package/dist/fields/link/component/Link.svelte +5 -5
- package/dist/fields/link/component/props.d.ts +2 -2
- package/dist/fields/link/index.d.ts +4 -1
- package/dist/fields/link/index.js +9 -10
- package/dist/fields/link/runtime.d.ts +2 -0
- package/dist/fields/link/runtime.js +1 -0
- package/dist/fields/link/{index.server.d.ts → runtime.server.d.ts} +1 -2
- package/dist/fields/link/{index.server.js → runtime.server.js} +2 -11
- package/dist/fields/number/component/Number.svelte +6 -6
- package/dist/fields/number/component/props.d.ts +2 -2
- package/dist/fields/number/index.d.ts +4 -10
- package/dist/fields/number/index.js +3 -4
- package/dist/fields/number/index.server.d.ts +1 -2
- package/dist/fields/number/index.server.js +1 -10
- package/dist/fields/radio/component/Radio.svelte +6 -7
- package/dist/fields/radio/component/props.d.ts +2 -2
- package/dist/fields/radio/index.server.d.ts +1 -2
- package/dist/fields/radio/index.server.js +2 -11
- package/dist/fields/relation/component/Relation.svelte +18 -14
- package/dist/fields/relation/component/Relation.svelte.d.ts +2 -2
- package/dist/fields/relation/index.d.ts +7 -4
- package/dist/fields/relation/index.js +8 -47
- package/dist/fields/relation/runtime.d.ts +5 -0
- package/dist/fields/relation/runtime.js +4 -0
- package/dist/fields/relation/runtime.server.d.ts +8 -0
- package/dist/fields/relation/runtime.server.js +49 -0
- package/dist/fields/rich-text/component/RichText.svelte +5 -5
- package/dist/fields/rich-text/component/props.d.ts +2 -2
- package/dist/fields/rich-text/core/features/fields/fields.svelte +2 -2
- package/dist/fields/rich-text/index.d.ts +2 -0
- package/dist/fields/rich-text/index.js +3 -0
- package/dist/fields/rich-text/index.server.d.ts +1 -2
- package/dist/fields/rich-text/index.server.js +1 -10
- package/dist/fields/select/component/Select.svelte +16 -16
- package/dist/fields/select/component/props.d.ts +2 -2
- package/dist/fields/select/index.d.ts +2 -0
- package/dist/fields/select/index.js +3 -0
- package/dist/fields/select/index.server.d.ts +1 -2
- package/dist/fields/select/index.server.js +2 -17
- package/dist/fields/slug/component/Slug.svelte +14 -10
- package/dist/fields/slug/component/Slug.svelte.d.ts +2 -2
- package/dist/fields/slug/index.d.ts +5 -2
- package/dist/fields/slug/index.js +3 -0
- package/dist/fields/slug/index.server.d.ts +1 -2
- package/dist/fields/slug/index.server.js +1 -10
- package/dist/fields/tabs/component/Tabs.svelte +15 -15
- package/dist/fields/tabs/component/Tabs.svelte.d.ts +2 -2
- package/dist/fields/tabs/index.d.ts +4 -16
- package/dist/fields/tabs/index.js +1 -8
- package/dist/fields/tabs/index.server.js +3 -3
- package/dist/fields/text/component/Text.svelte +5 -5
- package/dist/fields/text/component/props.d.ts +2 -3
- package/dist/fields/text/index.d.ts +4 -10
- package/dist/fields/text/index.js +3 -4
- package/dist/fields/text/index.server.d.ts +1 -2
- package/dist/fields/text/index.server.js +1 -10
- package/dist/fields/textarea/component/TextArea.svelte +3 -3
- package/dist/fields/textarea/component/props.d.ts +2 -2
- package/dist/fields/textarea/index.d.ts +4 -1
- package/dist/fields/textarea/index.js +3 -0
- package/dist/fields/textarea/index.server.d.ts +1 -2
- package/dist/fields/textarea/index.server.js +1 -10
- package/dist/fields/time/component/Time.svelte +5 -5
- package/dist/fields/time/component/Time.svelte.d.ts +1 -1
- package/dist/fields/time/component/props.d.ts +2 -2
- package/dist/fields/time/index.d.ts +2 -0
- package/dist/fields/time/index.js +3 -0
- package/dist/fields/time/index.server.d.ts +1 -2
- package/dist/fields/time/index.server.js +1 -10
- package/dist/fields/toggle/component/Toggle.svelte +3 -3
- package/dist/fields/toggle/component/Toggle.svelte.d.ts +1 -1
- package/dist/fields/toggle/component/props.d.ts +2 -2
- package/dist/fields/toggle/index.d.ts +2 -1
- package/dist/fields/toggle/index.server.d.ts +1 -2
- package/dist/fields/toggle/index.server.js +1 -10
- package/dist/fields/tree/component/AddItemButton.svelte +1 -2
- package/dist/fields/tree/component/Tree.svelte +6 -6
- package/dist/fields/tree/component/TreeBlock.svelte +5 -12
- package/dist/fields/tree/component/props.d.ts +3 -3
- package/dist/fields/tree/index.d.ts +3 -1
- package/dist/fields/tree/index.js +2 -2
- package/dist/fields/types.d.ts +11 -5
- package/dist/panel/components/fields/FieldsPreview.svelte +4 -5
- package/dist/panel/components/fields/Hint.svelte +5 -4
- package/dist/panel/components/fields/Hint.svelte.d.ts +3 -2
- package/dist/panel/components/fields/Label.svelte +6 -11
- package/dist/panel/components/fields/Label.svelte.d.ts +3 -2
- package/dist/panel/components/fields/LabelFor.svelte +4 -4
- package/dist/panel/components/fields/LabelFor.svelte.d.ts +2 -1
- package/dist/panel/components/fields/RenderFields.svelte +11 -16
- package/dist/panel/components/fields/{root.svelte.d.ts → fieldset.svelte.d.ts} +1 -1
- package/dist/panel/components/fields/{root.svelte.js → fieldset.svelte.js} +1 -1
- package/dist/panel/components/fields/index.d.ts +5 -5
- package/dist/panel/components/fields/index.js +2 -2
- package/dist/panel/components/sections/document/AuthFooter.svelte +2 -7
- package/dist/panel/components/sections/live/LiveEditPanel.svelte +2 -2
- package/dist/panel/context/collection.svelte.js +9 -9
- package/dist/panel/context/documentForm.svelte.d.ts +8 -21
- package/dist/panel/context/documentForm.svelte.js +45 -52
- package/dist/panel/context/form.svelte.d.ts +4 -3
- package/dist/panel/context/form.svelte.js +14 -16
- package/dist/panel/pages/auth/fields.d.ts +4 -4
- package/dist/panel/pages/auth/fields.js +6 -22
- package/dist/panel/pages/auth/reset-password/ResetPassword.svelte +3 -10
- package/dist/util/doc.js +15 -17
- package/package.json +3 -2
- package/dist/fields/relation/index.server.d.ts +0 -4
- package/dist/fields/relation/index.server.js +0 -13
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { t__ } from '../../../core/i18n/index.js';
|
|
3
|
+
import { fieldset } from '../../../panel/components/fields/fieldset.svelte.js';
|
|
3
4
|
import { Field } from '../../../panel/components/fields/index.js';
|
|
4
|
-
import { root } from '../../../panel/components/fields/root.svelte.js';
|
|
5
5
|
import Button from '../../../panel/components/ui/button/button.svelte';
|
|
6
6
|
import { getLocaleContext } from '../../../panel/context/locale.svelte';
|
|
7
7
|
import type { Dic } from '../../../util/types.js';
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
if (!el.classList.contains('rz-tree-item')) return false;
|
|
38
38
|
const targetDepth = parseInt(to.el.dataset.treeDepth || '0');
|
|
39
39
|
const childrenCount = parseInt(el.dataset.treeChildren || '0');
|
|
40
|
-
return targetDepth + childrenCount <= config.maxDepth;
|
|
40
|
+
return targetDepth + childrenCount <= config.get.maxDepth;
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
onStart: () => (sorting = true),
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
});
|
|
94
94
|
</script>
|
|
95
95
|
|
|
96
|
-
<fieldset class="rz-field-tree {config.className}" use:
|
|
96
|
+
<fieldset class="rz-field-tree {config.get.className}" use:fieldset={field}>
|
|
97
97
|
<Field.Error error={field.error} />
|
|
98
98
|
|
|
99
99
|
<Field.Label {config} />
|
|
@@ -119,12 +119,12 @@
|
|
|
119
119
|
addItem={add}
|
|
120
120
|
class="rz-tree__add-button"
|
|
121
121
|
size={nested ? 'sm' : 'default'}
|
|
122
|
-
fields={config.fields}
|
|
122
|
+
fields={config.get.fields}
|
|
123
123
|
>
|
|
124
|
-
{config.addItemLabel}
|
|
124
|
+
{config.get.addItemLabel}
|
|
125
125
|
</AddItemButton>
|
|
126
126
|
|
|
127
|
-
{#if locale && locale.code !== locale.defaultCode && config.localized}
|
|
127
|
+
{#if locale && locale.code !== locale.defaultCode && config.get.localized}
|
|
128
128
|
<Button size="sm" onclick={field.setValueFromDefaultLocale} variant="secondary">
|
|
129
129
|
{t__('fields.get_data_from')}
|
|
130
130
|
{locale.defaultCode}
|
|
@@ -53,23 +53,16 @@
|
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
const renderBlockTitle = (position: string) => {
|
|
56
|
-
if (config.renderTitle) {
|
|
56
|
+
if (config.get.renderTitle) {
|
|
57
57
|
try {
|
|
58
|
-
const title = config.renderTitle({ position, values: itemValue || {} });
|
|
58
|
+
const title = config.get.renderTitle({ position, values: itemValue || {} });
|
|
59
59
|
if (title) return title;
|
|
60
60
|
} catch (err) {
|
|
61
61
|
console.error(`Can't render title in treeBlock`, err);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
return `${position} - ${config.label
|
|
64
|
+
return `${position} - ${config.get.label}`;
|
|
65
65
|
};
|
|
66
|
-
|
|
67
|
-
// $effect(() => {
|
|
68
|
-
// if (initialPath !== path) {
|
|
69
|
-
// form.setValue(path, itemValue);
|
|
70
|
-
// initialPath = path;
|
|
71
|
-
// }
|
|
72
|
-
// });
|
|
73
66
|
</script>
|
|
74
67
|
|
|
75
68
|
<div
|
|
@@ -94,11 +87,11 @@
|
|
|
94
87
|
</header>
|
|
95
88
|
|
|
96
89
|
<div class="rz-tree-item__fields" class:rz-tree-item__fields--hidden={!isOpen}>
|
|
97
|
-
<RenderFields fields={config.fields} {path} {form} />
|
|
90
|
+
<RenderFields fields={config.get.fields} {path} {form} />
|
|
98
91
|
</div>
|
|
99
92
|
</div>
|
|
100
93
|
|
|
101
|
-
{#if depth <= config.maxDepth}
|
|
94
|
+
{#if depth <= config.get.maxDepth}
|
|
102
95
|
<div data-path={path} data-tree-depth={depth} data-tree-key={treeKey} class="rz-tree__list">
|
|
103
96
|
{#if itemValue && itemValue._children && itemValue._children.length}
|
|
104
97
|
{#each itemValue._children as child, index (child.id)}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { TreeBlock } from '../../../core/types/doc.js';
|
|
2
2
|
import type { DocumentFormContext } from '../../../panel/context/documentForm.svelte.js';
|
|
3
3
|
import type { Dic } from '../../../util/types.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { TreeBuilder } from '../index.js';
|
|
5
5
|
export type TreeProps = {
|
|
6
6
|
path: string;
|
|
7
|
-
config:
|
|
7
|
+
config: TreeBuilder;
|
|
8
8
|
form: DocumentFormContext;
|
|
9
9
|
};
|
|
10
10
|
export type TreeBlockProps = {
|
|
@@ -19,6 +19,6 @@ export type TreeBlockProps = {
|
|
|
19
19
|
readonly items: TreeBlock[];
|
|
20
20
|
};
|
|
21
21
|
form: DocumentFormContext;
|
|
22
|
-
config:
|
|
22
|
+
config: TreeBuilder;
|
|
23
23
|
treeKey: string;
|
|
24
24
|
};
|
|
@@ -19,6 +19,7 @@ export declare class TreeBuilder extends FormFieldBuilder<TreeField> {
|
|
|
19
19
|
localized(): this;
|
|
20
20
|
compile(): {
|
|
21
21
|
fields: ({
|
|
22
|
+
name: string;
|
|
22
23
|
type: string;
|
|
23
24
|
live?: boolean | undefined;
|
|
24
25
|
condition?: ((doc: any, siblings: any) => boolean) | undefined;
|
|
@@ -37,6 +38,7 @@ export declare class TreeBuilder extends FormFieldBuilder<TreeField> {
|
|
|
37
38
|
value: any;
|
|
38
39
|
}> | null;
|
|
39
40
|
})[];
|
|
41
|
+
name: string;
|
|
40
42
|
type: "tree";
|
|
41
43
|
live?: boolean;
|
|
42
44
|
condition?: (doc: any, siblings: any) => boolean;
|
|
@@ -49,7 +51,6 @@ export declare class TreeBuilder extends FormFieldBuilder<TreeField> {
|
|
|
49
51
|
read: import("../types.js").FieldAccess;
|
|
50
52
|
update: import("../types.js").FieldAccess;
|
|
51
53
|
};
|
|
52
|
-
name: string;
|
|
53
54
|
hidden?: boolean;
|
|
54
55
|
validate?: import("../types.js").FieldValidationFunc<any>;
|
|
55
56
|
required?: boolean;
|
|
@@ -65,6 +66,7 @@ export declare class TreeBuilder extends FormFieldBuilder<TreeField> {
|
|
|
65
66
|
};
|
|
66
67
|
defaultValue?: import("../types.js").DefaultValueFn<any> | unknown;
|
|
67
68
|
isEmpty: (value: unknown) => boolean;
|
|
69
|
+
_root?: boolean;
|
|
68
70
|
maxDepth: number;
|
|
69
71
|
renderTitle?: TreeFieldBlockRenderTitle;
|
|
70
72
|
addItemLabel: string;
|
|
@@ -46,7 +46,7 @@ export class TreeBuilder extends FormFieldBuilder {
|
|
|
46
46
|
// Add a locale prop in its fields
|
|
47
47
|
const hasAlreadyLocale = !!this.field.fields
|
|
48
48
|
.filter((field) => field instanceof FormFieldBuilder)
|
|
49
|
-
.find((field) => field.
|
|
49
|
+
.find((field) => field.name === 'locale');
|
|
50
50
|
if (!hasAlreadyLocale) {
|
|
51
51
|
this.field.fields.push(text('locale').hidden());
|
|
52
52
|
}
|
|
@@ -55,7 +55,7 @@ export class TreeBuilder extends FormFieldBuilder {
|
|
|
55
55
|
// If it's a "position" or "path" field do not set as localized
|
|
56
56
|
// as it's a treeBlock property
|
|
57
57
|
if (field instanceof FormFieldBuilder &&
|
|
58
|
-
['position', 'path', 'locale'].includes(field.
|
|
58
|
+
['position', 'path', 'locale'].includes(field.name)) {
|
|
59
59
|
return field;
|
|
60
60
|
}
|
|
61
61
|
// For all others fields set as localized
|
package/dist/fields/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { OperationContext } from '../core/operations/hooks/index.server.js';
|
|
2
2
|
import type { DocumentFormContext } from '../panel/index.js';
|
|
3
|
-
import type { Dic
|
|
3
|
+
import type { Dic } from '../util/types.js';
|
|
4
4
|
import type { IconProps } from '@lucide/svelte';
|
|
5
5
|
import type { RequestEvent } from '@sveltejs/kit';
|
|
6
6
|
import type { Component } from 'svelte';
|
|
@@ -26,13 +26,13 @@ export type { TextField } from './text/index.js';
|
|
|
26
26
|
export type { TextAreaField } from './textarea/index.js';
|
|
27
27
|
export type { TimeField } from './time/index.js';
|
|
28
28
|
export type { ToggleField } from './toggle/index.js';
|
|
29
|
-
export type FieldValidationFunc<TConfig extends FormField, TData extends Dic = Dic> = (value: unknown, metas: {
|
|
29
|
+
export type FieldValidationFunc<TConfig extends FormField = FormField, TData extends Dic = Dic> = (value: unknown, metas: {
|
|
30
30
|
data: Partial<TData>;
|
|
31
31
|
operation: 'create' | 'update' | undefined;
|
|
32
32
|
id: string | undefined;
|
|
33
33
|
user: User | undefined;
|
|
34
34
|
locale: string | undefined;
|
|
35
|
-
config: TConfig
|
|
35
|
+
config: TConfig;
|
|
36
36
|
}) => true | string;
|
|
37
37
|
type FieldAccessParams = {
|
|
38
38
|
id?: string;
|
|
@@ -40,6 +40,7 @@ type FieldAccessParams = {
|
|
|
40
40
|
export type FieldAccess = (user: User | undefined, params?: FieldAccessParams) => boolean;
|
|
41
41
|
export type FieldWidth = '1/3' | '1/2' | '2/3';
|
|
42
42
|
export type Field = {
|
|
43
|
+
name: string;
|
|
43
44
|
type: string;
|
|
44
45
|
live?: boolean;
|
|
45
46
|
condition?: (doc: any, siblings: any) => boolean;
|
|
@@ -54,7 +55,6 @@ export type Field = {
|
|
|
54
55
|
};
|
|
55
56
|
};
|
|
56
57
|
export type FormField = Field & {
|
|
57
|
-
name: string;
|
|
58
58
|
hidden?: boolean;
|
|
59
59
|
validate?: FieldValidationFunc<any>;
|
|
60
60
|
required?: boolean;
|
|
@@ -65,6 +65,13 @@ export type FormField = Field & {
|
|
|
65
65
|
hooks?: FieldHooks;
|
|
66
66
|
defaultValue?: DefaultValueFn<any> | unknown;
|
|
67
67
|
isEmpty: (value: unknown) => boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Force the field to be on the root table
|
|
70
|
+
* usefull for fields that should not be versioned
|
|
71
|
+
* ex: _parent for nested structures should always be on the root table to prevent
|
|
72
|
+
* different versions to have different parents
|
|
73
|
+
*/
|
|
74
|
+
_root?: boolean;
|
|
68
75
|
};
|
|
69
76
|
export type DefaultValueFn<T> = ({ event }: {
|
|
70
77
|
event?: RequestEvent;
|
|
@@ -113,7 +120,6 @@ export type RelationRef = {
|
|
|
113
120
|
documentId: string;
|
|
114
121
|
};
|
|
115
122
|
export type RelationValue<T> = T[] | RelationRef[] | string[] | string;
|
|
116
|
-
export type SimplerField<T extends FormField> = WithRequired<Partial<T>, 'name' | 'isEmpty' | 'type'>;
|
|
117
123
|
export type BaseUseFieldReturn = {
|
|
118
124
|
path: string;
|
|
119
125
|
value: any;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { FormFieldBuilder } from '../../../core/fields/builders';
|
|
3
3
|
import type { BaseUseFieldReturn, FieldsPreviewProps, FormField } from '../../../fields/types.js';
|
|
4
|
-
import { capitalize } from '../../../util/string.js';
|
|
5
4
|
import type { Component } from 'svelte';
|
|
6
5
|
|
|
7
6
|
type Props = {
|
|
@@ -22,16 +21,16 @@
|
|
|
22
21
|
{:else}
|
|
23
22
|
{#each fields as builder, index (index)}
|
|
24
23
|
{@const field = getField(builder)}
|
|
25
|
-
{#if !builder.
|
|
24
|
+
{#if !builder.get.hidden && field.visible}
|
|
26
25
|
<div class="rz-render-fields-preview__row" data-visible={field.visible || null}>
|
|
27
26
|
<div class="rz-render-fields-preview__name">
|
|
28
27
|
<p>
|
|
29
|
-
{builder.
|
|
28
|
+
{builder.get.label}
|
|
30
29
|
</p>
|
|
31
30
|
</div>
|
|
32
31
|
<div class="rz-render-fields-preview__value">
|
|
33
|
-
{#if builder.
|
|
34
|
-
{@const ColumnTableCell = builder.
|
|
32
|
+
{#if builder.get.table?.cell}
|
|
33
|
+
{@const ColumnTableCell = builder.get.table.cell}
|
|
35
34
|
<span><ColumnTableCell value={field.value} /></span>
|
|
36
35
|
{:else if builder.cell}
|
|
37
36
|
{@const Cell = builder.cell}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { FormFieldBuilder } from '../../../fields';
|
|
3
|
+
import type { FormField } from '../../../fields/types.js';
|
|
3
4
|
|
|
4
|
-
type Props = { config:
|
|
5
|
+
type Props = { config: FormFieldBuilder<FormField> };
|
|
5
6
|
const { config }: Props = $props();
|
|
6
7
|
</script>
|
|
7
8
|
|
|
8
|
-
{#if config.hint}
|
|
9
|
+
{#if config.get.hint}
|
|
9
10
|
<p class="rz-field-hint">
|
|
10
|
-
{config.hint}
|
|
11
|
+
{config.get.hint}
|
|
11
12
|
</p>
|
|
12
13
|
{/if}
|
|
13
14
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FormFieldBuilder } from '../../../fields';
|
|
2
|
+
import type { FormField } from '../../../fields/types.js';
|
|
2
3
|
type Props = {
|
|
3
|
-
config:
|
|
4
|
+
config: FormFieldBuilder<FormField>;
|
|
4
5
|
};
|
|
5
6
|
declare const Hint: import("svelte").Component<Props, {}, "">;
|
|
6
7
|
type Hint = ReturnType<typeof Hint>;
|
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { FormFieldBuilder } from '../../../fields/index.js';
|
|
3
|
+
import type { FormField } from '../../../fields/types.js';
|
|
3
4
|
import { getLocaleContext } from '../../context/locale.svelte';
|
|
4
|
-
import { capitalize } from '../../../util/string.js';
|
|
5
5
|
import type { Snippet } from 'svelte';
|
|
6
6
|
import { Label } from '../ui/label/index.js';
|
|
7
7
|
|
|
8
|
-
type Props = { config
|
|
8
|
+
type Props = { config: FormFieldBuilder<FormField>; children?: Snippet; for?: string };
|
|
9
9
|
const { config, children, for: forAttribute, ...rest }: Props = $props();
|
|
10
10
|
|
|
11
11
|
const locale = getLocaleContext();
|
|
12
12
|
</script>
|
|
13
13
|
|
|
14
|
-
<Label
|
|
15
|
-
class="rz-field-label"
|
|
16
|
-
title={config?.label ? config.name : null}
|
|
17
|
-
for={forAttribute || null}
|
|
18
|
-
{...rest}
|
|
19
|
-
>
|
|
14
|
+
<Label class="rz-field-label" title={config.get.label} for={forAttribute || null} {...rest}>
|
|
20
15
|
{#if config}
|
|
21
|
-
{config.label
|
|
22
|
-
{#if config.localized}
|
|
16
|
+
{config.get.label}
|
|
17
|
+
{#if config.get.localized}
|
|
23
18
|
<sup>{locale.code}</sup>
|
|
24
19
|
{/if}
|
|
25
20
|
{/if}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FormFieldBuilder } from '../../../fields/index.js';
|
|
2
|
+
import type { FormField } from '../../../fields/types.js';
|
|
2
3
|
import type { Snippet } from 'svelte';
|
|
3
4
|
import { Label } from '../ui/label/index.js';
|
|
4
5
|
type Props = {
|
|
5
|
-
config
|
|
6
|
+
config: FormFieldBuilder<FormField>;
|
|
6
7
|
children?: Snippet;
|
|
7
8
|
for?: string;
|
|
8
9
|
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import type { FormFieldBuilder } from '../../../fields/index.js';
|
|
2
3
|
import type { FormField } from '../../../fields/types.js';
|
|
3
4
|
import { getLocaleContext } from '../../context/locale.svelte.js';
|
|
4
|
-
import { capitalize } from '../../../util/string.js';
|
|
5
5
|
import { Label } from '../ui/label/index.js';
|
|
6
6
|
|
|
7
|
-
type Props = { config: FormField
|
|
7
|
+
type Props = { config: FormFieldBuilder<FormField>; for: string };
|
|
8
8
|
const { config, for: labelFor }: Props = $props();
|
|
9
9
|
|
|
10
10
|
const locale = getLocaleContext();
|
|
11
11
|
</script>
|
|
12
12
|
|
|
13
13
|
<Label class="rz-field-label-for" for={labelFor}>
|
|
14
|
-
{config.label
|
|
15
|
-
{#if config.localized}
|
|
14
|
+
{config.get.label}
|
|
15
|
+
{#if config.get.localized}
|
|
16
16
|
<sup>{locale.code}</sup>
|
|
17
17
|
{/if}
|
|
18
18
|
</Label>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { FormFieldBuilder } from '../../../fields/index.js';
|
|
1
2
|
import type { FormField } from '../../../fields/types.js';
|
|
2
3
|
type Props = {
|
|
3
|
-
config: FormField
|
|
4
|
+
config: FormFieldBuilder<FormField>;
|
|
4
5
|
for: string;
|
|
5
6
|
};
|
|
6
7
|
declare const LabelFor: import("svelte").Component<Props, {}, "">;
|
|
@@ -20,12 +20,7 @@
|
|
|
20
20
|
const user = getUserContext();
|
|
21
21
|
|
|
22
22
|
const authorizedFields = $derived(
|
|
23
|
-
fields.filter((field) => {
|
|
24
|
-
if (field.raw.access && field.raw.access.read) {
|
|
25
|
-
return field.raw.access.read(user.attributes, { id: form.values.id });
|
|
26
|
-
}
|
|
27
|
-
return true;
|
|
28
|
-
})
|
|
23
|
+
fields.filter((field) => field.run.canRead(user.attributes, { id: form.values.id }))
|
|
29
24
|
);
|
|
30
25
|
|
|
31
26
|
const path = $derived(initialPath === '' ? '' : `${initialPath}.`);
|
|
@@ -38,31 +33,31 @@
|
|
|
38
33
|
|
|
39
34
|
<div class="rz-render-fields">
|
|
40
35
|
{#each authorizedFields as field, index (index)}
|
|
41
|
-
{#if !form.isLive || (form.isLive && isLiveField(field.
|
|
36
|
+
{#if !form.isLive || (form.isLive && isLiveField(field.get))}
|
|
42
37
|
{#if field instanceof ComponentFieldBuilder}
|
|
43
|
-
{@const FieldComponent = field.
|
|
38
|
+
{@const FieldComponent = field.get.component}
|
|
44
39
|
<div data-type={field.type} class="rz-render-fields__field rz-render-fields__field--full">
|
|
45
|
-
<FieldComponent {path} config={field
|
|
40
|
+
<FieldComponent {path} config={field} {form} />
|
|
46
41
|
</div>
|
|
47
|
-
{:else if isPresentative(field.
|
|
42
|
+
{:else if isPresentative(field.get)}
|
|
48
43
|
{@const Separator = field.component}
|
|
49
44
|
<div data-type={field.type} class="rz-render-fields__field rz-render-fields__field--full">
|
|
50
45
|
<Separator />
|
|
51
46
|
</div>
|
|
52
|
-
{:else if isTabsField(field.
|
|
47
|
+
{:else if isTabsField(field.get)}
|
|
53
48
|
{@const Tabs = field.component}
|
|
54
49
|
<div data-type="tabs" class="rz-render-fields__field rz-render-fields__field--full">
|
|
55
|
-
<Tabs config={field
|
|
50
|
+
<Tabs config={field} {path} {form} />
|
|
56
51
|
</div>
|
|
57
|
-
{:else if isFormField(field
|
|
58
|
-
{@const isCompact = 'layout' in field && field.layout === 'compact'}
|
|
52
|
+
{:else if isFormField(field) && isNotHidden(field)}
|
|
53
|
+
{@const isCompact = 'layout' in field.get && field.get.layout === 'compact'}
|
|
59
54
|
{@const FieldComponent = field.component}
|
|
60
55
|
<div
|
|
61
|
-
class="rz-render-fields__field {widthClassModifier(field.
|
|
56
|
+
class="rz-render-fields__field {widthClassModifier(field.get)}"
|
|
62
57
|
data-type={field.type}
|
|
63
58
|
data-compact={isCompact ? '' : null}
|
|
64
59
|
>
|
|
65
|
-
<FieldComponent path={path + field.
|
|
60
|
+
<FieldComponent path={path + field.name} config={field} {form} />
|
|
66
61
|
</div>
|
|
67
62
|
{/if}
|
|
68
63
|
{/if}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { fieldset } from './fieldset.svelte.js';
|
|
2
2
|
export declare const Field: {
|
|
3
3
|
Label: import("svelte").Component<{
|
|
4
|
-
config
|
|
4
|
+
config: import("../../../fields").FormFieldBuilder<import("../../../types").FormField>;
|
|
5
5
|
children?: import("svelte").Snippet;
|
|
6
6
|
for?: string;
|
|
7
7
|
}, {}, "">;
|
|
8
8
|
Hint: import("svelte").Component<{
|
|
9
|
-
config: import("../../../
|
|
9
|
+
config: import("../../../fields").FormFieldBuilder<import("../../../types").FormField>;
|
|
10
10
|
}, {}, "">;
|
|
11
11
|
LabelFor: import("svelte").Component<{
|
|
12
|
-
config: import("../../../types").FormField
|
|
12
|
+
config: import("../../../fields").FormFieldBuilder<import("../../../types").FormField>;
|
|
13
13
|
for: string;
|
|
14
14
|
}, {}, "">;
|
|
15
15
|
Error: import("svelte").Component<{
|
|
16
16
|
error: string | false;
|
|
17
17
|
}, {}, "">;
|
|
18
|
-
fieldset: typeof
|
|
18
|
+
fieldset: typeof fieldset;
|
|
19
19
|
};
|
|
@@ -2,11 +2,11 @@ import Error from './Error.svelte';
|
|
|
2
2
|
import Hint from './Hint.svelte';
|
|
3
3
|
import Label from './Label.svelte';
|
|
4
4
|
import LabelFor from './LabelFor.svelte';
|
|
5
|
-
import {
|
|
5
|
+
import { fieldset } from './fieldset.svelte.js';
|
|
6
6
|
export const Field = {
|
|
7
7
|
Label,
|
|
8
8
|
Hint,
|
|
9
9
|
LabelFor,
|
|
10
10
|
Error,
|
|
11
|
-
fieldset
|
|
11
|
+
fieldset
|
|
12
12
|
};
|
|
@@ -61,13 +61,8 @@
|
|
|
61
61
|
<div class="rz-document-auth">
|
|
62
62
|
{#if operation === 'create'}
|
|
63
63
|
{#if isAuthConfig(collection) && collection.auth.type === 'password'}
|
|
64
|
-
<Text {form} type="password" config={passwordConfig
|
|
65
|
-
<Text
|
|
66
|
-
{form}
|
|
67
|
-
type="password"
|
|
68
|
-
config={confirmPasswordConfig.compile()}
|
|
69
|
-
path="confirmPassword"
|
|
70
|
-
/>
|
|
64
|
+
<Text {form} type="password" config={passwordConfig} path="password" />
|
|
65
|
+
<Text {form} type="password" config={confirmPasswordConfig} path="confirmPassword" />
|
|
71
66
|
{/if}
|
|
72
67
|
{:else if user.attributes.isStaff && page.data?.hasMailer}
|
|
73
68
|
{#if isAuthConfig(collection) && collection.auth.type === 'password'}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { getFieldListAtPath } from '../../../../core/fields/util.js';
|
|
3
3
|
import RenderFields from '../../fields/RenderFields.svelte';
|
|
4
4
|
import { getConfigContext } from '../../../context/config.svelte.js';
|
|
5
5
|
import { setDocumentFormContext } from '../../../context/documentForm.svelte.js';
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
onMount(() => onFormReady(form));
|
|
42
42
|
|
|
43
43
|
// Reactive: re-derives when fieldPath changes (no remount needed)
|
|
44
|
-
const { fields, path } = $derived(
|
|
44
|
+
const { fields, path } = $derived(getFieldListAtPath(fieldPath, docConfig.fields));
|
|
45
45
|
</script>
|
|
46
46
|
|
|
47
47
|
<form class="rz-live-edit-panel" use:form.enhance enctype="multipart/form-data" method="post">
|
|
@@ -61,26 +61,26 @@ function createCollectionStore(args) {
|
|
|
61
61
|
for (const field of fields) {
|
|
62
62
|
if (field instanceof GroupFieldBuilder) {
|
|
63
63
|
// For group fields, pass the current group name as parent path for nested fields
|
|
64
|
-
const groupPath = parentPath ? `${parentPath}.${field.
|
|
65
|
-
columns = [...columns, ...buildFieldColumns(field.
|
|
64
|
+
const groupPath = parentPath ? `${parentPath}.${field.name}` : field.name;
|
|
65
|
+
columns = [...columns, ...buildFieldColumns(field.get.fields, groupPath)];
|
|
66
66
|
}
|
|
67
|
-
if (isFormField(field
|
|
67
|
+
if (isFormField(field) && hasProp('table', field.get)) {
|
|
68
68
|
// Create current field path
|
|
69
|
-
const path = parentPath ? `${parentPath}.${field.
|
|
69
|
+
const path = parentPath ? `${parentPath}.${field.name}` : field.name;
|
|
70
70
|
// Create column
|
|
71
71
|
const column = {
|
|
72
72
|
type: field.type,
|
|
73
73
|
path,
|
|
74
|
-
cell: field.
|
|
75
|
-
table: field.
|
|
74
|
+
cell: field.get.table.cell || field.cell,
|
|
75
|
+
table: field.get.table
|
|
76
76
|
};
|
|
77
77
|
columns.push(column);
|
|
78
78
|
}
|
|
79
79
|
else if (field instanceof TabsBuilder) {
|
|
80
|
-
for (const tab of field.
|
|
80
|
+
for (const tab of field.get.tabs) {
|
|
81
81
|
// For tab fields, create a path with the tab name
|
|
82
|
-
const path = parentPath ? `${parentPath}.${tab.
|
|
83
|
-
columns = [...columns, ...buildFieldColumns(tab.
|
|
82
|
+
const path = parentPath ? `${parentPath}.${tab.name}` : tab.name;
|
|
83
|
+
columns = [...columns, ...buildFieldColumns(tab.get.fields, path)];
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { BuiltAreaClient, BuiltCollectionClient } from '../../core/config/types.js';
|
|
2
|
+
import type { FormFieldBuilder } from '../../core/fields/builders/index.js';
|
|
2
3
|
import type { AreaSlug, GenericBlock, GenericDoc, TreeBlock } from '../../core/types/doc.js';
|
|
3
|
-
import type { FormField
|
|
4
|
+
import type { FormField } from '../../types.js';
|
|
4
5
|
import type { Dic, WithOptional } from '../../util/types.js';
|
|
5
6
|
export declare function setDocumentFormContext<T extends WithOptional<GenericDoc, 'id'>>(args: Args<T>): {
|
|
6
7
|
key: string;
|
|
@@ -9,7 +10,7 @@ export declare function setDocumentFormContext<T extends WithOptional<GenericDoc
|
|
|
9
10
|
enhance: (node: HTMLFormElement) => {
|
|
10
11
|
destroy(): void;
|
|
11
12
|
};
|
|
12
|
-
useField: <TValue>(path: string, config?:
|
|
13
|
+
useField: <TValue>(path: string, config?: FormFieldBuilder<FormField>) => {
|
|
13
14
|
path: string;
|
|
14
15
|
setValueFromDefaultLocale: () => Promise<void>;
|
|
15
16
|
get value(): TValue | undefined;
|
|
@@ -46,12 +47,11 @@ export declare function setDocumentFormContext<T extends WithOptional<GenericDoc
|
|
|
46
47
|
values: T & {
|
|
47
48
|
_type: any;
|
|
48
49
|
_prototype: any;
|
|
49
|
-
title: any;
|
|
50
50
|
};
|
|
51
51
|
readonly changes: Partial<GenericDoc>;
|
|
52
52
|
readonly errors: {
|
|
53
53
|
readonly length: number;
|
|
54
|
-
value: import("
|
|
54
|
+
value: import("../../types.js").FormErrors;
|
|
55
55
|
readonly first: string;
|
|
56
56
|
has(key: string): boolean;
|
|
57
57
|
hasRequired(key: string): boolean;
|
|
@@ -61,13 +61,7 @@ export declare function setDocumentFormContext<T extends WithOptional<GenericDoc
|
|
|
61
61
|
deleteAllThatStartWith(path: string): void;
|
|
62
62
|
};
|
|
63
63
|
readonly config: BuiltCollectionClient;
|
|
64
|
-
readonly title: string |
|
|
65
|
-
singular: string;
|
|
66
|
-
plural: string;
|
|
67
|
-
search?: string | undefined;
|
|
68
|
-
create?: string | undefined;
|
|
69
|
-
none?: string | undefined;
|
|
70
|
-
};
|
|
64
|
+
readonly title: string | import("../../core/config/types.js").CollectionLabel;
|
|
71
65
|
readonly isLive: boolean;
|
|
72
66
|
reset(): void;
|
|
73
67
|
setFocusedField(path: string): void;
|
|
@@ -79,7 +73,7 @@ export declare function getDocumentFormContext<T extends WithOptional<GenericDoc
|
|
|
79
73
|
enhance: (node: HTMLFormElement) => {
|
|
80
74
|
destroy(): void;
|
|
81
75
|
};
|
|
82
|
-
useField: <TValue>(path: string, config?:
|
|
76
|
+
useField: <TValue>(path: string, config?: FormFieldBuilder<FormField>) => {
|
|
83
77
|
path: string;
|
|
84
78
|
setValueFromDefaultLocale: () => Promise<void>;
|
|
85
79
|
get value(): TValue | undefined;
|
|
@@ -116,12 +110,11 @@ export declare function getDocumentFormContext<T extends WithOptional<GenericDoc
|
|
|
116
110
|
values: T & {
|
|
117
111
|
_type: any;
|
|
118
112
|
_prototype: any;
|
|
119
|
-
title: any;
|
|
120
113
|
};
|
|
121
114
|
readonly changes: Partial<GenericDoc>;
|
|
122
115
|
readonly errors: {
|
|
123
116
|
readonly length: number;
|
|
124
|
-
value: import("
|
|
117
|
+
value: import("../../types.js").FormErrors;
|
|
125
118
|
readonly first: string;
|
|
126
119
|
has(key: string): boolean;
|
|
127
120
|
hasRequired(key: string): boolean;
|
|
@@ -131,13 +124,7 @@ export declare function getDocumentFormContext<T extends WithOptional<GenericDoc
|
|
|
131
124
|
deleteAllThatStartWith(path: string): void;
|
|
132
125
|
};
|
|
133
126
|
readonly config: BuiltCollectionClient;
|
|
134
|
-
readonly title: string |
|
|
135
|
-
singular: string;
|
|
136
|
-
plural: string;
|
|
137
|
-
search?: string | undefined;
|
|
138
|
-
create?: string | undefined;
|
|
139
|
-
none?: string | undefined;
|
|
140
|
-
};
|
|
127
|
+
readonly title: string | import("../../core/config/types.js").CollectionLabel;
|
|
141
128
|
readonly isLive: boolean;
|
|
142
129
|
reset(): void;
|
|
143
130
|
setFocusedField(path: string): void;
|