rimecms 0.26.9 → 0.27.1
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/README.md +26 -24
- package/dist/core/collections/auth/fields.d.ts +40 -40
- package/dist/core/fields/builders/select.js +1 -0
- package/dist/core/i18n/en/fields.d.ts +1 -0
- package/dist/core/i18n/en/fields.js +2 -1
- package/dist/core/i18n/fr/fields.d.ts +1 -0
- package/dist/core/i18n/fr/fields.js +2 -1
- package/dist/core/operations/hooks/before-read/set-document-thumbnail.server.js +2 -2
- package/dist/core/operations/hooks/before-read/sort-document-props.server.js +3 -1
- package/dist/fields/group/component/Group.svelte +1 -0
- package/dist/fields/group/index.d.ts +12 -8
- package/dist/fields/group/index.js +4 -0
- package/dist/fields/link/component/RessourceInput.svelte +2 -2
- package/dist/fields/relation/component/Cell.svelte +2 -2
- package/dist/fields/relation/component/Relation.svelte +18 -11
- package/dist/fields/relation/component/Relation.svelte.d.ts +2 -1
- package/dist/fields/relation/component/upload/Browse.svelte +2 -2
- package/dist/fields/relation/index.d.ts +1 -1
- package/dist/fields/rich-text/client.d.ts +9 -9
- package/dist/fields/rich-text/client.js +1 -1
- package/dist/fields/rich-text/component/RichText.svelte +1 -1
- package/dist/fields/rich-text/core/{config-builders.js → build-editor-config.js} +9 -2
- package/dist/fields/rich-text/core/features/fields/extension.d.ts +10 -3
- package/dist/fields/rich-text/core/features/fields/extension.js +3 -8
- package/dist/fields/rich-text/core/features/fields/fields.css +4 -0
- package/dist/fields/rich-text/core/features/fields/fields.svelte +13 -6
- package/dist/fields/rich-text/core/features/fields/fields.svelte.d.ts +4 -1
- package/dist/fields/rich-text/core/features/fields/index.d.ts +7 -5
- package/dist/fields/rich-text/core/features/fields/index.js +4 -3
- package/dist/fields/rich-text/core/features/link/component/link-selector.svelte +9 -13
- package/dist/fields/rich-text/core/features/link/index.d.ts +1 -4
- package/dist/fields/rich-text/core/features/resource/index.d.ts +2 -5
- package/dist/fields/rich-text/core/features/resource/index.js +17 -12
- package/dist/fields/rich-text/core/features/resource/resource-extension.d.ts +7 -2
- package/dist/fields/rich-text/core/features/resource/resource-extension.js +6 -10
- package/dist/fields/rich-text/core/features/resource/resource.svelte +19 -21
- package/dist/fields/rich-text/core/features/upload/index.d.ts +2 -5
- package/dist/fields/rich-text/core/features/upload/index.js +15 -12
- package/dist/fields/rich-text/core/features/upload/upload-extension.d.ts +13 -1
- package/dist/fields/rich-text/core/features/upload/upload-extension.js +6 -11
- package/dist/fields/rich-text/core/features/upload/upload.svelte +15 -10
- package/dist/fields/rich-text/core/svelte/node-view-renderer.svelte.js +10 -5
- package/dist/fields/rich-text/core/svelte/node-view-wrapper.svelte +1 -0
- package/dist/fields/rich-text/core/svelte/renderer.d.ts +1 -1
- package/dist/fields/types.d.ts +13 -0
- package/dist/panel/components/Root.svelte +4 -4
- package/dist/panel/components/fields/FieldsPreview.svelte +34 -27
- package/dist/panel/components/fields/FieldsPreview.svelte.d.ts +5 -6
- package/dist/panel/components/fields/FieldsPreviewTrigger.svelte +1 -1
- package/dist/panel/components/fields/index.d.ts +2 -2
- package/dist/panel/components/sections/collection/folder/FolderEdit.svelte +0 -2
- package/dist/panel/components/sections/collection/folder/FolderWithActions.svelte +2 -2
- package/dist/panel/components/sections/collection/grid/create-directory-dialog/CreateDirectoryDialog.svelte +0 -2
- package/dist/panel/components/sections/collection/upload-thumb-cell/UploadThumbCell.svelte +3 -2
- package/dist/panel/components/sections/document/Header.svelte +1 -0
- package/dist/panel/components/sections/document/Settings.svelte +3 -2
- package/dist/panel/components/sections/document/Settings.svelte.d.ts +2 -1
- package/dist/panel/components/sections/document/upload-header/UploadHeader.svelte +2 -7
- package/dist/panel/components/sections/live/SidePanel.svelte +7 -9
- package/dist/panel/components/ui/breadcrumb/BreadCrumb.svelte +12 -6
- package/dist/panel/components/ui/card-document/card-document.svelte +2 -2
- package/dist/panel/components/ui/command/command-dialog.svelte +3 -1
- package/dist/panel/components/ui/command/command-dialog.svelte.d.ts +1 -0
- package/dist/panel/context/api-proxy.svelte.d.ts +2 -1
- package/dist/panel/context/api-proxy.svelte.js +9 -3
- package/dist/panel/context/documentForm.svelte.d.ts +2 -2
- package/dist/panel/context/documentForm.svelte.js +7 -6
- package/dist/panel/context/form.svelte.js +0 -1
- package/dist/panel/context/locale.svelte.d.ts +1 -0
- package/dist/panel/context/locale.svelte.js +3 -3
- package/dist/panel/context/title.d.ts +7 -0
- package/dist/panel/context/title.js +9 -0
- package/dist/panel/pages/area/Area.svelte +1 -4
- package/dist/panel/pages/area/AreaVersionsDoc.svelte +0 -3
- package/dist/panel/pages/collection/Collection.svelte +2 -2
- package/dist/panel/pages/collection-document/CollectionDocVersions.svelte +0 -5
- package/dist/panel/pages/collection-document/CollectionDocument.svelte +0 -3
- package/dist/panel/pages/live/Live.svelte +3 -8
- package/dist/types.d.ts +1 -1
- package/package.json +4 -4
- /package/dist/fields/rich-text/core/{config-builders.d.ts → build-editor-config.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
|
|
4
4
|
Headless CMS powered by SvelteKit.
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
[](https://github.com/bienbiendev/rime/blob/main/LICENSE)
|
|
8
9
|
|
|
9
10
|

|
|
10
11
|
|
|
11
|
-
[Documentation
|
|
12
|
+
[Documentation](https://github.com/bienbiendev/rime-doc/tree/master/docs)
|
|
12
13
|
|
|
13
14
|
## Features
|
|
14
15
|
|
|
@@ -85,7 +86,7 @@ import { sveltekit } from '@sveltejs/kit/vite';
|
|
|
85
86
|
import { rime } from 'rimecms/vite';
|
|
86
87
|
|
|
87
88
|
export default defineConfig({
|
|
88
|
-
|
|
89
|
+
plugins: [rime(), sveltekit()]
|
|
89
90
|
});
|
|
90
91
|
```
|
|
91
92
|
|
|
@@ -200,21 +201,21 @@ export default rime({
|
|
|
200
201
|
|
|
201
202
|
```ts
|
|
202
203
|
export const load = async (event: LayoutServerLoadEvent) => {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
204
|
+
const { rime } = event.locals;
|
|
205
|
+
// Get an Area document
|
|
206
|
+
const menu = await rime.area('menu').find();
|
|
207
|
+
// Get all pages documents
|
|
208
|
+
const pages = await rime.collection('pages').findAll({ locale: 'en' });
|
|
209
|
+
// Get a page byId
|
|
210
|
+
const home = await rime.collection('pages').findById({ locale: 'en', id: 'some-id' });
|
|
211
|
+
// Get a user with a query
|
|
212
|
+
const [user] = await rime.collection('users').find({
|
|
213
|
+
query: `where[email][equals]=some@email.com` // qs query or ParsedQsQuery
|
|
214
|
+
});
|
|
215
|
+
// Get some config values
|
|
216
|
+
const languages = rime.config.getLocalesCodes();
|
|
217
|
+
const collections = rime.config.collections;
|
|
218
|
+
//...
|
|
218
219
|
};
|
|
219
220
|
```
|
|
220
221
|
|
|
@@ -223,13 +224,13 @@ export const load = async (event: LayoutServerLoadEvent) => {
|
|
|
223
224
|
```ts
|
|
224
225
|
const { docs } = await fetch('http://localhost:5173/api/pages').then((r) => r.json());
|
|
225
226
|
const { docs } = await fetch('http://localhost:5173/api/pages?sort=title&limit=1').then((r) =>
|
|
226
|
-
|
|
227
|
+
r.json()
|
|
227
228
|
);
|
|
228
229
|
const { docs } = await fetch(
|
|
229
|
-
|
|
230
|
+
'http://localhost:5173/api/pages?where[author][equals]=some-id&locale=en`;'
|
|
230
231
|
).then((r) => r.json());
|
|
231
232
|
const { docs } = await fetch(
|
|
232
|
-
|
|
233
|
+
'http://localhost:5173/api/pages?where[author.email][equals]=some@email.com&locale=en`;'
|
|
233
234
|
).then((r) => r.json());
|
|
234
235
|
```
|
|
235
236
|
|
|
@@ -260,10 +261,11 @@ It's doing bascically `vite build` under the hood and create the polka server fi
|
|
|
260
261
|
- [x] more better-auth integration
|
|
261
262
|
- [x] Handle relation poperties in queries
|
|
262
263
|
- [~] Documentation
|
|
263
|
-
- [ ]
|
|
264
|
+
- [ ] configurable files storage adapter (local, s3, etc)
|
|
265
|
+
- [ ] other storage adapter (postgress, turso, etc)
|
|
264
266
|
- [ ] auto-saved draft
|
|
267
|
+
- [ ] Live Edit system in practice
|
|
265
268
|
- [ ] Put bin commands in a separate package ex: @rime/kit
|
|
266
|
-
- [ ] configurable medias/config path
|
|
267
269
|
|
|
268
270
|
## Acknowledgments
|
|
269
271
|
|
|
@@ -3,7 +3,7 @@ declare const emailField: {
|
|
|
3
3
|
layout(layout: "compact" | "default"): /*elided*/ any;
|
|
4
4
|
readonly component: import("svelte").Component<import("../../../fields/email/component/props").EmailFieldProps, {}, "">;
|
|
5
5
|
unique(bool?: boolean): /*elided*/ any;
|
|
6
|
-
defaultValue(value: string | import("../../../
|
|
6
|
+
defaultValue(value: string | import("../../../types").DefaultValueFn<string>): /*elided*/ any;
|
|
7
7
|
isTitle(): /*elided*/ any;
|
|
8
8
|
_generateSchema: null | ((args: {
|
|
9
9
|
camel: string;
|
|
@@ -14,17 +14,17 @@ declare const emailField: {
|
|
|
14
14
|
label(label: string): /*elided*/ any;
|
|
15
15
|
hidden(): /*elided*/ any;
|
|
16
16
|
localized(): /*elided*/ any;
|
|
17
|
-
validate(validateFunction: import("../../../
|
|
17
|
+
validate(validateFunction: import("../../../types").FieldValidationFunc<import("../../../fields/email/index.js").EmailField>): /*elided*/ any;
|
|
18
18
|
condition(conditionFunction: (doc: import("../../../util/types").Dic, siblings: import("../../../util/types").Dic) => boolean): /*elided*/ any;
|
|
19
19
|
table(params?: import("../../../types").FieldPanelTableConfig | number): /*elided*/ any;
|
|
20
|
-
width(value: import("../../../
|
|
20
|
+
width(value: import("../../../types").FieldWidth): /*elided*/ any;
|
|
21
21
|
required(bool?: boolean): /*elided*/ any;
|
|
22
22
|
access(access: {
|
|
23
|
-
create?: import("../../../
|
|
24
|
-
read?: import("../../../
|
|
25
|
-
update?: import("../../../
|
|
23
|
+
create?: import("../../../types").FieldAccess;
|
|
24
|
+
read?: import("../../../types").FieldAccess;
|
|
25
|
+
update?: import("../../../types").FieldAccess;
|
|
26
26
|
}): /*elided*/ any;
|
|
27
|
-
onChange(hook: import("../../../
|
|
27
|
+
onChange(hook: import("../../../types").FieldHookClient): /*elided*/ any;
|
|
28
28
|
hint(hint: string): /*elided*/ any;
|
|
29
29
|
clone(): /*elided*/ any;
|
|
30
30
|
$generateSchema(fn: (args: {
|
|
@@ -32,27 +32,27 @@ declare const emailField: {
|
|
|
32
32
|
snake: string;
|
|
33
33
|
suffix: string;
|
|
34
34
|
}) => string): /*elided*/ any;
|
|
35
|
-
$beforeRead(hook: import("../../../
|
|
36
|
-
$beforeSave(hook: import("../../../
|
|
37
|
-
beforeValidate(hook: import("../../../
|
|
35
|
+
$beforeRead(hook: import("../../../types").FieldHook<import("../../../fields/email/index.js").EmailField>): /*elided*/ any;
|
|
36
|
+
$beforeSave(hook: import("../../../types").FieldHook<import("../../../fields/email/index.js").EmailField>): /*elided*/ any;
|
|
37
|
+
beforeValidate(hook: import("../../../types").FieldHookShared): /*elided*/ any;
|
|
38
38
|
field: import("../../../fields/email/index.js").EmailField;
|
|
39
39
|
className(str: string): /*elided*/ any;
|
|
40
40
|
compile(): {
|
|
41
41
|
type: "email";
|
|
42
42
|
live?: boolean | undefined;
|
|
43
43
|
condition?: ((doc: any, siblings: any) => boolean) | undefined;
|
|
44
|
-
width?: import("../../../
|
|
44
|
+
width?: import("../../../types").FieldWidth | undefined;
|
|
45
45
|
className?: string | undefined;
|
|
46
46
|
component: import("svelte").Component<any>;
|
|
47
47
|
cell: import("svelte").Component<any> | undefined;
|
|
48
48
|
access: {
|
|
49
|
-
create: import("../../../
|
|
50
|
-
read: import("../../../
|
|
51
|
-
update: import("../../../
|
|
49
|
+
create: import("../../../types").FieldAccess;
|
|
50
|
+
read: import("../../../types").FieldAccess;
|
|
51
|
+
update: import("../../../types").FieldAccess;
|
|
52
52
|
};
|
|
53
53
|
name: string;
|
|
54
54
|
hidden?: boolean | undefined;
|
|
55
|
-
validate?: import("../../../
|
|
55
|
+
validate?: import("../../../types").FieldValidationFunc<any> | undefined;
|
|
56
56
|
required?: boolean | undefined;
|
|
57
57
|
localized?: boolean | undefined;
|
|
58
58
|
label?: string | undefined;
|
|
@@ -65,12 +65,12 @@ declare const emailField: {
|
|
|
65
65
|
position: number;
|
|
66
66
|
} | undefined;
|
|
67
67
|
hooks?: {
|
|
68
|
-
beforeRead?: import("../../../
|
|
69
|
-
beforeSave?: import("../../../
|
|
70
|
-
beforeValidate?: import("../../../
|
|
71
|
-
onChange?: import("../../../
|
|
68
|
+
beforeRead?: import("../../../types").FieldHook<any>[] | undefined;
|
|
69
|
+
beforeSave?: import("../../../types").FieldHook<any>[] | undefined;
|
|
70
|
+
beforeValidate?: import("../../../types").FieldHookShared<any>[] | undefined;
|
|
71
|
+
onChange?: import("../../../types").FieldHookClient[] | undefined;
|
|
72
72
|
} | undefined;
|
|
73
|
-
defaultValue?: string | import("../../../
|
|
73
|
+
defaultValue?: string | import("../../../types").DefaultValueFn<string> | undefined;
|
|
74
74
|
isEmpty: (value: unknown) => boolean;
|
|
75
75
|
placeholder?: string | undefined;
|
|
76
76
|
layout?: "compact" | "default" | undefined;
|
|
@@ -99,7 +99,7 @@ export declare const usersFields: {
|
|
|
99
99
|
layout(layout: "compact" | "default"): /*elided*/ any;
|
|
100
100
|
readonly component: import("svelte").Component<import("../../../fields/email/component/props").EmailFieldProps, {}, "">;
|
|
101
101
|
unique(bool?: boolean): /*elided*/ any;
|
|
102
|
-
defaultValue(value: string | import("../../../
|
|
102
|
+
defaultValue(value: string | import("../../../types").DefaultValueFn<string>): /*elided*/ any;
|
|
103
103
|
isTitle(): /*elided*/ any;
|
|
104
104
|
_generateSchema: null | ((args: {
|
|
105
105
|
camel: string;
|
|
@@ -110,17 +110,17 @@ export declare const usersFields: {
|
|
|
110
110
|
label(label: string): /*elided*/ any;
|
|
111
111
|
hidden(): /*elided*/ any;
|
|
112
112
|
localized(): /*elided*/ any;
|
|
113
|
-
validate(validateFunction: import("../../../
|
|
113
|
+
validate(validateFunction: import("../../../types").FieldValidationFunc<import("../../../fields/email/index.js").EmailField>): /*elided*/ any;
|
|
114
114
|
condition(conditionFunction: (doc: import("../../../util/types").Dic, siblings: import("../../../util/types").Dic) => boolean): /*elided*/ any;
|
|
115
115
|
table(params?: import("../../../types").FieldPanelTableConfig | number): /*elided*/ any;
|
|
116
|
-
width(value: import("../../../
|
|
116
|
+
width(value: import("../../../types").FieldWidth): /*elided*/ any;
|
|
117
117
|
required(bool?: boolean): /*elided*/ any;
|
|
118
118
|
access(access: {
|
|
119
|
-
create?: import("../../../
|
|
120
|
-
read?: import("../../../
|
|
121
|
-
update?: import("../../../
|
|
119
|
+
create?: import("../../../types").FieldAccess;
|
|
120
|
+
read?: import("../../../types").FieldAccess;
|
|
121
|
+
update?: import("../../../types").FieldAccess;
|
|
122
122
|
}): /*elided*/ any;
|
|
123
|
-
onChange(hook: import("../../../
|
|
123
|
+
onChange(hook: import("../../../types").FieldHookClient): /*elided*/ any;
|
|
124
124
|
hint(hint: string): /*elided*/ any;
|
|
125
125
|
clone(): /*elided*/ any;
|
|
126
126
|
$generateSchema(fn: (args: {
|
|
@@ -128,27 +128,27 @@ export declare const usersFields: {
|
|
|
128
128
|
snake: string;
|
|
129
129
|
suffix: string;
|
|
130
130
|
}) => string): /*elided*/ any;
|
|
131
|
-
$beforeRead(hook: import("../../../
|
|
132
|
-
$beforeSave(hook: import("../../../
|
|
133
|
-
beforeValidate(hook: import("../../../
|
|
131
|
+
$beforeRead(hook: import("../../../types").FieldHook<import("../../../fields/email/index.js").EmailField>): /*elided*/ any;
|
|
132
|
+
$beforeSave(hook: import("../../../types").FieldHook<import("../../../fields/email/index.js").EmailField>): /*elided*/ any;
|
|
133
|
+
beforeValidate(hook: import("../../../types").FieldHookShared): /*elided*/ any;
|
|
134
134
|
field: import("../../../fields/email/index.js").EmailField;
|
|
135
135
|
className(str: string): /*elided*/ any;
|
|
136
136
|
compile(): {
|
|
137
137
|
type: "email";
|
|
138
138
|
live?: boolean | undefined;
|
|
139
139
|
condition?: ((doc: any, siblings: any) => boolean) | undefined;
|
|
140
|
-
width?: import("../../../
|
|
140
|
+
width?: import("../../../types").FieldWidth | undefined;
|
|
141
141
|
className?: string | undefined;
|
|
142
142
|
component: import("svelte").Component<any>;
|
|
143
143
|
cell: import("svelte").Component<any> | undefined;
|
|
144
144
|
access: {
|
|
145
|
-
create: import("../../../
|
|
146
|
-
read: import("../../../
|
|
147
|
-
update: import("../../../
|
|
145
|
+
create: import("../../../types").FieldAccess;
|
|
146
|
+
read: import("../../../types").FieldAccess;
|
|
147
|
+
update: import("../../../types").FieldAccess;
|
|
148
148
|
};
|
|
149
149
|
name: string;
|
|
150
150
|
hidden?: boolean | undefined;
|
|
151
|
-
validate?: import("../../../
|
|
151
|
+
validate?: import("../../../types").FieldValidationFunc<any> | undefined;
|
|
152
152
|
required?: boolean | undefined;
|
|
153
153
|
localized?: boolean | undefined;
|
|
154
154
|
label?: string | undefined;
|
|
@@ -161,12 +161,12 @@ export declare const usersFields: {
|
|
|
161
161
|
position: number;
|
|
162
162
|
} | undefined;
|
|
163
163
|
hooks?: {
|
|
164
|
-
beforeRead?: import("../../../
|
|
165
|
-
beforeSave?: import("../../../
|
|
166
|
-
beforeValidate?: import("../../../
|
|
167
|
-
onChange?: import("../../../
|
|
164
|
+
beforeRead?: import("../../../types").FieldHook<any>[] | undefined;
|
|
165
|
+
beforeSave?: import("../../../types").FieldHook<any>[] | undefined;
|
|
166
|
+
beforeValidate?: import("../../../types").FieldHookShared<any>[] | undefined;
|
|
167
|
+
onChange?: import("../../../types").FieldHookClient[] | undefined;
|
|
168
168
|
} | undefined;
|
|
169
|
-
defaultValue?: string | import("../../../
|
|
169
|
+
defaultValue?: string | import("../../../types").DefaultValueFn<string> | undefined;
|
|
170
170
|
isEmpty: (value: unknown) => boolean;
|
|
171
171
|
placeholder?: string | undefined;
|
|
172
172
|
layout?: "compact" | "default" | undefined;
|
|
@@ -6,7 +6,7 @@ export const setDocumentThumbnail = Hooks.beforeRead(async (args) => {
|
|
|
6
6
|
const config = args.config;
|
|
7
7
|
let doc = args.doc;
|
|
8
8
|
const hasThumbnail = (c) => {
|
|
9
|
-
return
|
|
9
|
+
return c.type === 'collection' && !!c.asThumbnail;
|
|
10
10
|
};
|
|
11
11
|
const paramSelect = args.context.params.select;
|
|
12
12
|
const hasSelect = Array.isArray(paramSelect) && paramSelect.length;
|
|
@@ -15,7 +15,7 @@ export const setDocumentThumbnail = Hooks.beforeRead(async (args) => {
|
|
|
15
15
|
(!hasSelect || (hasSelect && paramSelect.includes('_thumbnail')));
|
|
16
16
|
if (shouldSetThumbnail) {
|
|
17
17
|
const relationValue = getValueAtPath(config.asThumbnail, doc);
|
|
18
|
-
if (!relationValue)
|
|
18
|
+
if (!relationValue || (Array.isArray(relationValue) && relationValue.length === 0))
|
|
19
19
|
return args;
|
|
20
20
|
const unwraped = Array.isArray(relationValue) ? relationValue[0] : relationValue;
|
|
21
21
|
if (typeof unwraped === 'string')
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { FieldBuilder } from '../../core/fields/builders/field-builder.js';
|
|
2
2
|
import { FormFieldBuilder } from '../../core/fields/builders/form-field-builder.js';
|
|
3
|
-
import type { Field, FormField } from '../types.js';
|
|
3
|
+
import type { Field, FieldsPreviewProps, FormField } from '../types.js';
|
|
4
|
+
import type { Component } from 'svelte';
|
|
4
5
|
export declare class GroupFieldBuilder extends FormFieldBuilder<GroupField> {
|
|
5
6
|
_metaUrl: string;
|
|
6
7
|
constructor(name: string);
|
|
7
|
-
get component():
|
|
8
|
+
get component(): Component<{
|
|
8
9
|
path: string;
|
|
9
10
|
config: GroupField;
|
|
10
11
|
form: import("../../panel").DocumentFormContext<import("../../types").GenericDoc>;
|
|
@@ -12,6 +13,7 @@ export declare class GroupFieldBuilder extends FormFieldBuilder<GroupField> {
|
|
|
12
13
|
label(label: string): this;
|
|
13
14
|
fields(...fields: FieldBuilder<Field>[]): this;
|
|
14
15
|
localized(): this;
|
|
16
|
+
preview(component: Component<FieldsPreviewProps>): this;
|
|
15
17
|
compile(): {
|
|
16
18
|
fields: ({
|
|
17
19
|
type: string;
|
|
@@ -19,16 +21,16 @@ export declare class GroupFieldBuilder extends FormFieldBuilder<GroupField> {
|
|
|
19
21
|
condition?: ((doc: any, siblings: any) => boolean) | undefined;
|
|
20
22
|
width?: import("../types.js").FieldWidth | undefined;
|
|
21
23
|
className?: string | undefined;
|
|
22
|
-
component:
|
|
23
|
-
cell:
|
|
24
|
+
component: Component<any>;
|
|
25
|
+
cell: Component<any> | undefined;
|
|
24
26
|
access: {
|
|
25
27
|
create: import("../types.js").FieldAccess;
|
|
26
28
|
read: import("../types.js").FieldAccess;
|
|
27
29
|
update: import("../types.js").FieldAccess;
|
|
28
30
|
};
|
|
29
31
|
} & {
|
|
30
|
-
component:
|
|
31
|
-
cell?:
|
|
32
|
+
component: Component<any>;
|
|
33
|
+
cell?: Component<{
|
|
32
34
|
value: any;
|
|
33
35
|
}> | null;
|
|
34
36
|
})[];
|
|
@@ -37,8 +39,8 @@ export declare class GroupFieldBuilder extends FormFieldBuilder<GroupField> {
|
|
|
37
39
|
condition?: (doc: any, siblings: any) => boolean;
|
|
38
40
|
width?: import("../types.js").FieldWidth;
|
|
39
41
|
className?: string;
|
|
40
|
-
component:
|
|
41
|
-
cell:
|
|
42
|
+
component: Component<any>;
|
|
43
|
+
cell: Component<any> | undefined;
|
|
42
44
|
access: {
|
|
43
45
|
create: import("../types.js").FieldAccess;
|
|
44
46
|
read: import("../types.js").FieldAccess;
|
|
@@ -60,6 +62,7 @@ export declare class GroupFieldBuilder extends FormFieldBuilder<GroupField> {
|
|
|
60
62
|
};
|
|
61
63
|
defaultValue?: import("../types.js").DefaultValueFn<any> | unknown;
|
|
62
64
|
isEmpty: (value: unknown) => boolean;
|
|
65
|
+
preview?: Component<FieldsPreviewProps>;
|
|
63
66
|
};
|
|
64
67
|
}
|
|
65
68
|
export declare const group: (name: string) => GroupFieldBuilder;
|
|
@@ -77,6 +80,7 @@ export type GroupField = FormField & {
|
|
|
77
80
|
name: string;
|
|
78
81
|
label?: string;
|
|
79
82
|
fields: FieldBuilder<Field>[];
|
|
83
|
+
preview?: Component<FieldsPreviewProps>;
|
|
80
84
|
};
|
|
81
85
|
export type GroupFieldRaw = FormField & {
|
|
82
86
|
type: 'group';
|
|
@@ -34,6 +34,10 @@ export class GroupFieldBuilder extends FormFieldBuilder {
|
|
|
34
34
|
});
|
|
35
35
|
return this;
|
|
36
36
|
}
|
|
37
|
+
preview(component) {
|
|
38
|
+
this.field.preview = component;
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
37
41
|
compile() {
|
|
38
42
|
return { ...this.field, fields: this.field.fields.map((f) => f.compile()) };
|
|
39
43
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import type { GenericDoc } from '../../../core/types/doc.js';
|
|
5
5
|
import * as Command from '../../../panel/components/ui/command/index.js';
|
|
6
6
|
import Tag from '../../../panel/components/ui/tag/tag.svelte';
|
|
7
|
-
import {
|
|
7
|
+
import { getAPIProxyContext } from '../../../panel/context/api-proxy.svelte.js';
|
|
8
8
|
import type { PrototypeSlug } from '../../../types';
|
|
9
9
|
import { toKebabCase } from '../../../util/string';
|
|
10
10
|
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
let resources = $state<Ressource[]>([]);
|
|
29
29
|
let selected = $state<Ressource | null>();
|
|
30
30
|
|
|
31
|
-
const APIProxy = getAPIProxyContext(
|
|
31
|
+
const APIProxy = getAPIProxyContext();
|
|
32
32
|
let resource = $state<any>(null);
|
|
33
33
|
|
|
34
34
|
function convertDocToResource(doc: GenericDoc) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { apiUrl } from '../../../core/api/index.js';
|
|
4
4
|
import type { GenericDoc } from '../../../core/types/doc.js';
|
|
5
5
|
import UploadThumbCell from '../../../panel/components/sections/collection/upload-thumb-cell/UploadThumbCell.svelte';
|
|
6
|
-
import {
|
|
6
|
+
import { getAPIProxyContext } from '../../../panel/context/api-proxy.svelte.js';
|
|
7
7
|
import { toKebabCase } from '../../../util/string';
|
|
8
8
|
|
|
9
9
|
type Props = {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
let { value }: Props = $props();
|
|
18
18
|
let displayCount = $derived(value && value.length > 1);
|
|
19
19
|
|
|
20
|
-
const APIProxy = getAPIProxyContext(
|
|
20
|
+
const APIProxy = getAPIProxyContext();
|
|
21
21
|
|
|
22
22
|
let APIUrl = $derived.by(() => {
|
|
23
23
|
if (value && value.length && value[0].documentId) {
|
|
@@ -7,24 +7,25 @@
|
|
|
7
7
|
import { getCollectionContext } from '../../../panel/context/collection.svelte.js';
|
|
8
8
|
import { getConfigContext } from '../../../panel/context/config.svelte.js';
|
|
9
9
|
import { type DocumentFormContext } from '../../../panel/context/documentForm.svelte.js';
|
|
10
|
+
import type { FormContext } from '../../../panel/context/form.svelte.js';
|
|
10
11
|
import { getLocaleContext } from '../../../panel/context/locale.svelte';
|
|
11
12
|
import { panelUrl } from '../../../panel/util/url.js';
|
|
12
13
|
import { moveItem } from '../../../util/array.js';
|
|
13
14
|
import { snapshot } from '../../../util/state.js';
|
|
14
|
-
import {
|
|
15
|
+
import { getAPIProxyContext } from '../../../panel/context/api-proxy.svelte.js';
|
|
15
16
|
import type { Relation, RelationField } from '../index.js';
|
|
16
17
|
import Default from './default/Default.svelte';
|
|
17
18
|
import type { RelationFieldItem } from './types.js';
|
|
18
19
|
import Upload from './upload/Upload.svelte';
|
|
19
20
|
|
|
20
21
|
// Props
|
|
21
|
-
type Props = { path: string; config: RelationField; form: DocumentFormContext };
|
|
22
|
+
type Props = { path: string; config: RelationField; form: DocumentFormContext | FormContext };
|
|
22
23
|
const { path, config, form }: Props = $props();
|
|
23
24
|
|
|
24
25
|
// Context
|
|
25
26
|
const { getCollection } = getConfigContext();
|
|
26
27
|
const locale = getLocaleContext();
|
|
27
|
-
const APIProxy = getAPIProxyContext(
|
|
28
|
+
const APIProxy = getAPIProxyContext();
|
|
28
29
|
const field = $derived(form.useField(path, config));
|
|
29
30
|
// svelte-ignore state_referenced_locally
|
|
30
31
|
const relationConfig = getCollection(config.relationTo);
|
|
@@ -77,7 +78,7 @@
|
|
|
77
78
|
item.url = doc._thumbnail;
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
|
-
if (form.isLive) {
|
|
81
|
+
if ('isLive' in form && form.isLive) {
|
|
81
82
|
item.livePreview = doc;
|
|
82
83
|
}
|
|
83
84
|
return item;
|
|
@@ -88,7 +89,7 @@
|
|
|
88
89
|
const url = new URL(apiUrl(relationConfig.kebab));
|
|
89
90
|
|
|
90
91
|
// Add depth parameter if in live context
|
|
91
|
-
if (form.isLive) {
|
|
92
|
+
if ('isLive' in form && form.isLive) {
|
|
92
93
|
url.searchParams.append('depth', '1');
|
|
93
94
|
}
|
|
94
95
|
|
|
@@ -109,7 +110,7 @@
|
|
|
109
110
|
});
|
|
110
111
|
}
|
|
111
112
|
}
|
|
112
|
-
return url.href
|
|
113
|
+
return url.href;
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
const ressourceURL = makeRessourceURL();
|
|
@@ -166,7 +167,7 @@
|
|
|
166
167
|
if (config.localized) {
|
|
167
168
|
relation.locale = locale.code;
|
|
168
169
|
}
|
|
169
|
-
if (form.isLive) {
|
|
170
|
+
if ('isLive' in form && form.isLive) {
|
|
170
171
|
if (item && item.livePreview) {
|
|
171
172
|
relation.livePreview = snapshot(item.livePreview);
|
|
172
173
|
}
|
|
@@ -181,17 +182,23 @@
|
|
|
181
182
|
// So when user save the nested doc
|
|
182
183
|
// it doesn't save this one
|
|
183
184
|
const onRelationCreation = () => {
|
|
184
|
-
|
|
185
|
+
if ('isDisabled' in form) {
|
|
186
|
+
form.isDisabled = true;
|
|
187
|
+
}
|
|
185
188
|
};
|
|
186
189
|
|
|
187
190
|
// Enable the form on cancel
|
|
188
191
|
const onRelationCreationCanceled = () => {
|
|
189
|
-
|
|
192
|
+
if ('isDisabled' in form) {
|
|
193
|
+
form.isDisabled = false;
|
|
194
|
+
}
|
|
190
195
|
};
|
|
191
196
|
|
|
192
197
|
const onRelationCreated = async (doc: GenericDoc) => {
|
|
193
198
|
// Enabled the form
|
|
194
|
-
|
|
199
|
+
if ('isDisabled' in form) {
|
|
200
|
+
form.isDisabled = false;
|
|
201
|
+
}
|
|
195
202
|
// update resssource
|
|
196
203
|
ressource.data?.docs.push(doc);
|
|
197
204
|
// update collection if present
|
|
@@ -237,7 +244,7 @@
|
|
|
237
244
|
{path}
|
|
238
245
|
many={!!config.many}
|
|
239
246
|
hasError={!!field.error}
|
|
240
|
-
formNestedLevel={form.nestedLevel}
|
|
247
|
+
formNestedLevel={'nestedLevel' in form ? form.nestedLevel : 0}
|
|
241
248
|
readOnly={form.readOnly}
|
|
242
249
|
{nothingToSelect}
|
|
243
250
|
{onRelationCreated}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { type DocumentFormContext } from '../../../panel/context/documentForm.svelte.js';
|
|
2
|
+
import type { FormContext } from '../../../panel/context/form.svelte.js';
|
|
2
3
|
import type { Relation, RelationField } from '../index.js';
|
|
3
4
|
type Props = {
|
|
4
5
|
path: string;
|
|
5
6
|
config: RelationField;
|
|
6
|
-
form: DocumentFormContext;
|
|
7
|
+
form: DocumentFormContext | FormContext;
|
|
7
8
|
};
|
|
8
9
|
declare const Relation: import("svelte").Component<Props, {}, "">;
|
|
9
10
|
type Relation = ReturnType<typeof Relation>;
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import * as Dialog from '../../../../panel/components/ui/dialog/index.js';
|
|
11
11
|
import * as DropdownMenu from '../../../../panel/components/ui/dropdown-menu/index.js';
|
|
12
12
|
import Input from '../../../../panel/components/ui/input/input.svelte';
|
|
13
|
-
import {
|
|
13
|
+
import { getAPIProxyContext } from '../../../../panel/context/api-proxy.svelte.js';
|
|
14
14
|
import type { BuiltCollection, UploadDoc } from '../../../../types';
|
|
15
15
|
import { ListFilter, Search } from '@lucide/svelte';
|
|
16
16
|
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
return `${apiUrl(withDirectoriesSuffix(config.kebab))}?where[parent][equals]=${path}`;
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
const APIProxy = getAPIProxyContext(
|
|
65
|
+
const APIProxy = getAPIProxyContext();
|
|
66
66
|
let files = $derived(APIProxy.getRessource<{ docs: UploadDoc[] }>(filesURL));
|
|
67
67
|
let folders = $derived(APIProxy.getRessource<{ docs: Directory[] }>(foldersURL));
|
|
68
68
|
|
|
@@ -10,7 +10,7 @@ export declare class RelationFieldBuilder<Doc extends GenericDoc> extends FormFi
|
|
|
10
10
|
get component(): import("svelte").Component<{
|
|
11
11
|
path: string;
|
|
12
12
|
config: RelationField;
|
|
13
|
-
form: import("../../panel").DocumentFormContext;
|
|
13
|
+
form: import("../../panel").DocumentFormContext | import("../../panel/context/form.svelte").FormContext;
|
|
14
14
|
}, {}, "">;
|
|
15
15
|
get cell(): import("svelte").Component<{
|
|
16
16
|
value: {
|