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,15 +1,15 @@
|
|
|
1
|
+
import type { DataType } from '../../core/fields/builders/form-field-builder.js';
|
|
1
2
|
import { FormFieldBuilder } from '../../core/fields/builders/form-field-builder.js';
|
|
2
3
|
import type { CollectionSlug, GenericDoc } from '../../core/types/doc.js';
|
|
3
|
-
import type { DefaultValueFn, Field,
|
|
4
|
+
import type { DefaultValueFn, Field, FormField, RelationRef, RelationValue } from '../types.js';
|
|
4
5
|
import type { RegisterCollection } from '../../index.js';
|
|
5
6
|
import type { WithOptional } from '../../util/types.js';
|
|
6
|
-
export declare
|
|
7
|
-
export declare class RelationFieldBuilder<Doc extends GenericDoc> extends FormFieldBuilder<RelationField<Doc>> {
|
|
7
|
+
export declare class RelationFieldBuilder<Doc extends GenericDoc = GenericDoc> extends FormFieldBuilder<RelationField<Doc>> {
|
|
8
8
|
_metaUrl: string;
|
|
9
9
|
constructor(name: string);
|
|
10
10
|
get component(): import("svelte").Component<{
|
|
11
11
|
path: string;
|
|
12
|
-
config:
|
|
12
|
+
config: RelationFieldBuilder;
|
|
13
13
|
form: import("../../panel").DocumentFormContext | import("../../panel/context/form.svelte").FormContext;
|
|
14
14
|
}, {}, "">;
|
|
15
15
|
get cell(): import("svelte").Component<{
|
|
@@ -24,6 +24,9 @@ export declare class RelationFieldBuilder<Doc extends GenericDoc> extends FormFi
|
|
|
24
24
|
to<Slug extends CollectionSlug>(slug: Slug): RelationFieldBuilder<RegisterCollection[Slug]>;
|
|
25
25
|
many(): this;
|
|
26
26
|
defaultValue(value: string | string[] | DefaultValueFn<string | string[]>): this;
|
|
27
|
+
/** Documentation only — relation fields are diverted into relationFieldsMap/junction
|
|
28
|
+
* tables before reaching the adapter's generic column renderer (see root.server.ts). */
|
|
29
|
+
get dataType(): DataType;
|
|
27
30
|
}
|
|
28
31
|
export declare const relation: (name: string) => RelationFieldBuilder<GenericDoc>;
|
|
29
32
|
/**
|
|
@@ -1,54 +1,10 @@
|
|
|
1
|
-
import { browser } from '$app/environment';
|
|
2
|
-
import { env } from '$env/dynamic/public';
|
|
3
|
-
import { PARAMS } from '../../core/constant.js';
|
|
4
1
|
import { FormFieldBuilder } from '../../core/fields/builders/form-field-builder.js';
|
|
5
|
-
import { trycatchFetch } from '../../util/function.js';
|
|
6
2
|
import { hasProps, isObjectLiteral } from '../../util/object.js';
|
|
7
|
-
|
|
3
|
+
// @ts-expect-error — resolved at build time by the rime Vite plugin to either
|
|
4
|
+
// relation/runtime.server.ts (real check) or relation/runtime.ts (client no-op)
|
|
5
|
+
import { ensureRelationExists } from '$rime/runtime';
|
|
8
6
|
import Cell from './component/Cell.svelte';
|
|
9
7
|
import RelationComponent from './component/Relation.svelte';
|
|
10
|
-
export const ensureRelationExists = async (value, { config }) => {
|
|
11
|
-
// Skip relation validation on panel as it will be done server-side
|
|
12
|
-
if (browser)
|
|
13
|
-
return value;
|
|
14
|
-
const getRequsetEvent = await import('$app/server').then((m) => m.getRequestEvent);
|
|
15
|
-
const output = [];
|
|
16
|
-
const retrieveRelation = async (id) => {
|
|
17
|
-
const [err, response] = await trycatchFetch(`${env.PUBLIC_RIME_URL}/api/${toKebabCase(config.relationTo)}/${id}?${PARAMS.SELECT}=id`, {
|
|
18
|
-
method: 'GET',
|
|
19
|
-
headers: getRequsetEvent().request.headers
|
|
20
|
-
});
|
|
21
|
-
if (err)
|
|
22
|
-
return null;
|
|
23
|
-
const { doc } = await response.json();
|
|
24
|
-
return doc;
|
|
25
|
-
};
|
|
26
|
-
if (value && Array.isArray(value)) {
|
|
27
|
-
for (const relation of value) {
|
|
28
|
-
let documentId;
|
|
29
|
-
if (typeof relation === 'string') {
|
|
30
|
-
documentId = relation;
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
documentId = relation.documentId;
|
|
34
|
-
}
|
|
35
|
-
if (!documentId) {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
const doc = await retrieveRelation(documentId);
|
|
39
|
-
if (doc) {
|
|
40
|
-
output.push(relation);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
else if (typeof value === 'string') {
|
|
45
|
-
const doc = await retrieveRelation(value);
|
|
46
|
-
if (doc) {
|
|
47
|
-
output.push(doc.id);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return output;
|
|
51
|
-
};
|
|
52
8
|
export class RelationFieldBuilder extends FormFieldBuilder {
|
|
53
9
|
//
|
|
54
10
|
_metaUrl = import.meta.url;
|
|
@@ -86,6 +42,11 @@ export class RelationFieldBuilder extends FormFieldBuilder {
|
|
|
86
42
|
this.field.defaultValue = value;
|
|
87
43
|
return this;
|
|
88
44
|
}
|
|
45
|
+
/** Documentation only — relation fields are diverted into relationFieldsMap/junction
|
|
46
|
+
* tables before reaching the adapter's generic column renderer (see root.server.ts). */
|
|
47
|
+
get dataType() {
|
|
48
|
+
return 'json';
|
|
49
|
+
}
|
|
89
50
|
}
|
|
90
51
|
export const relation = (name) => new RelationFieldBuilder(name);
|
|
91
52
|
/**
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FieldHookShared } from '../types.js';
|
|
2
|
+
/** Client-side no-op — resolved via `$rime/runtime` when bundling for the browser (see
|
|
3
|
+
* relation/index.ts). The panel never needs to validate a relation actually exists;
|
|
4
|
+
* the real check (relation/runtime.server.ts) runs server-side before any write lands. */
|
|
5
|
+
export declare const ensureRelationExists: FieldHookShared;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Client-side no-op — resolved via `$rime/runtime` when bundling for the browser (see
|
|
2
|
+
* relation/index.ts). The panel never needs to validate a relation actually exists;
|
|
3
|
+
* the real check (relation/runtime.server.ts) runs server-side before any write lands. */
|
|
4
|
+
export const ensureRelationExists = async (value) => value;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FieldHookShared } from '../types.js';
|
|
2
|
+
import type { ToType } from '../index.server.js';
|
|
3
|
+
import type { RelationFieldBuilder } from './index.js';
|
|
4
|
+
export declare const toType: ToType<RelationFieldBuilder<any>>;
|
|
5
|
+
/** Real implementation — resolved server-side via `$rime/runtime` (see relation/index.ts,
|
|
6
|
+
* relation/runtime.ts for the client-side no-op counterpart). Uses a plain static import of
|
|
7
|
+
* `$app/server`, which SvelteKit's build blocks from ever reaching client code. */
|
|
8
|
+
export declare const ensureRelationExists: FieldHookShared;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { getRequestEvent } from '$app/server';
|
|
2
|
+
import { env } from '$env/dynamic/public';
|
|
3
|
+
import { PARAMS } from '../../core/constant.js';
|
|
4
|
+
import { trycatchFetch } from '../../util/function.js';
|
|
5
|
+
import { capitalize, toKebabCase } from '../../util/string.js';
|
|
6
|
+
export const toType = (field) => {
|
|
7
|
+
return `${field.name}${field.get.required ? '' : '?'}: RelationValue<${capitalize(field.get.relationTo)}Doc>`;
|
|
8
|
+
};
|
|
9
|
+
/** Real implementation — resolved server-side via `$rime/runtime` (see relation/index.ts,
|
|
10
|
+
* relation/runtime.ts for the client-side no-op counterpart). Uses a plain static import of
|
|
11
|
+
* `$app/server`, which SvelteKit's build blocks from ever reaching client code. */
|
|
12
|
+
export const ensureRelationExists = async (value, { config }) => {
|
|
13
|
+
const output = [];
|
|
14
|
+
const retrieveRelation = async (id) => {
|
|
15
|
+
const [err, response] = await trycatchFetch(`${env.PUBLIC_RIME_URL}/api/${toKebabCase(config.relationTo)}/${id}?${PARAMS.SELECT}=id`, {
|
|
16
|
+
method: 'GET',
|
|
17
|
+
headers: getRequestEvent().request.headers
|
|
18
|
+
});
|
|
19
|
+
if (err)
|
|
20
|
+
return null;
|
|
21
|
+
const { doc } = await response.json();
|
|
22
|
+
return doc;
|
|
23
|
+
};
|
|
24
|
+
if (value && Array.isArray(value)) {
|
|
25
|
+
for (const relation of value) {
|
|
26
|
+
let documentId;
|
|
27
|
+
if (typeof relation === 'string') {
|
|
28
|
+
documentId = relation;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
documentId = relation.documentId;
|
|
32
|
+
}
|
|
33
|
+
if (!documentId) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const doc = await retrieveRelation(documentId);
|
|
37
|
+
if (doc) {
|
|
38
|
+
output.push(relation);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else if (typeof value === 'string') {
|
|
43
|
+
const doc = await retrieveRelation(value);
|
|
44
|
+
if (doc) {
|
|
45
|
+
output.push(doc.id);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return output;
|
|
49
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { fieldset } from '../../../panel/components/fields/fieldset.svelte.js';
|
|
2
3
|
import { Field } from '../../../panel/components/fields/index.js';
|
|
3
|
-
import { root } from '../../../panel/components/fields/root.svelte.js';
|
|
4
4
|
import { random } from '../../../util/index.js';
|
|
5
5
|
import { Editor, type JSONContent } from '@tiptap/core';
|
|
6
6
|
import { onMount } from 'svelte';
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
|
|
28
28
|
const ctx = setRichTextContext(instanceId);
|
|
29
29
|
|
|
30
|
-
const withSuggestion = $derived(hasSuggestion(config.features || defaultFeatures));
|
|
30
|
+
const withSuggestion = $derived(hasSuggestion(config.get.features || defaultFeatures));
|
|
31
31
|
|
|
32
32
|
onMount(() => {
|
|
33
33
|
// Build editor configuration
|
|
34
34
|
const richTextEditorConfig = buildEditorConfig({
|
|
35
|
-
features: config.features || defaultFeatures
|
|
35
|
+
features: config.get.features || defaultFeatures
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
features = richTextEditorConfig.features;
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
|
|
61
61
|
<fieldset
|
|
62
62
|
class:rz-field-rich-text--standalone={standAlone}
|
|
63
|
-
class="rz-field-rich-text {config.className || ''}"
|
|
64
|
-
use:
|
|
63
|
+
class="rz-field-rich-text {config.get.className || ''}"
|
|
64
|
+
use:fieldset={field}
|
|
65
65
|
>
|
|
66
66
|
<Field.Label {config} for={path || config.name} />
|
|
67
67
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { DocumentFormContext } from '../../../panel/context/documentForm.svelte.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { RichTextFieldBuilder } from '../index.js';
|
|
3
3
|
export type RichTextFieldProps = {
|
|
4
4
|
class?: string;
|
|
5
5
|
path: string;
|
|
6
6
|
standAlone?: boolean;
|
|
7
|
-
config:
|
|
7
|
+
config: RichTextFieldBuilder;
|
|
8
8
|
form: DocumentFormContext;
|
|
9
9
|
};
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
>
|
|
56
56
|
<FieldsPreview
|
|
57
57
|
fields={previewFields}
|
|
58
|
-
getField={(field) => form.useField(field.name, field
|
|
58
|
+
getField={(field) => form.useField(field.name, field)}
|
|
59
59
|
preview={extension.options.preview}
|
|
60
60
|
/>
|
|
61
61
|
</FieldsPreviewTrigger>
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
<Sheet.Content preventScroll={false} side="right" class="rz-rich-text-sheet">
|
|
66
66
|
{#each previewFields || [] as field, index (index)}
|
|
67
67
|
{@const FieldComponent = field.component}
|
|
68
|
-
<FieldComponent path={field.
|
|
68
|
+
<FieldComponent path={field.name} config={field} {form} />
|
|
69
69
|
{/each}
|
|
70
70
|
</Sheet.Content>
|
|
71
71
|
</Sheet.Root>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DataType } from '../../core/fields/builders/form-field-builder.js';
|
|
1
2
|
import { FormFieldBuilder } from '../../core/fields/builders/form-field-builder.js';
|
|
2
3
|
import type { DefaultValueFn, FormField } from '../types.js';
|
|
3
4
|
import type { JSONContent } from '@tiptap/core';
|
|
@@ -28,6 +29,7 @@ export declare class RichTextFieldBuilder extends FormFieldBuilder<RichTextField
|
|
|
28
29
|
static readonly sanitize: (value: unknown) => any;
|
|
29
30
|
static readonly stringify: (value: string) => string;
|
|
30
31
|
defaultValue(value: RichTextContent | DefaultValueFn<RichTextContent>): this;
|
|
32
|
+
get dataType(): DataType;
|
|
31
33
|
}
|
|
32
34
|
export declare const richText: (name: string) => RichTextFieldBuilder;
|
|
33
35
|
/**
|
|
@@ -101,6 +101,9 @@ export class RichTextFieldBuilder extends FormFieldBuilder {
|
|
|
101
101
|
this.field.defaultValue = value;
|
|
102
102
|
return this;
|
|
103
103
|
}
|
|
104
|
+
get dataType() {
|
|
105
|
+
return 'json';
|
|
106
|
+
}
|
|
104
107
|
}
|
|
105
108
|
export const richText = (name) => new RichTextFieldBuilder(name);
|
|
106
109
|
/**
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ToType } from '../index.server.js';
|
|
2
2
|
import type { RichTextFieldBuilder } from './index.js';
|
|
3
|
-
export declare const toSchema: ToSchema<RichTextFieldBuilder>;
|
|
4
3
|
export declare const toType: ToType<RichTextFieldBuilder>;
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
import { templateUniqueRequired } from '../../adapter-sqlite/generate-schema/templates.server.js';
|
|
2
|
-
import { getSchemaColumnNames } from '../../adapter-sqlite/generate-schema/util.server.js';
|
|
3
|
-
export const toSchema = (field, parentPath) => {
|
|
4
|
-
const { camel, snake } = getSchemaColumnNames({ name: field.name, parentPath });
|
|
5
|
-
const suffix = templateUniqueRequired(field.raw, typeof field.raw.defaultValue === 'object' ? field.raw.defaultValue : {});
|
|
6
|
-
if (field._generateSchema)
|
|
7
|
-
return field._generateSchema({ camel, snake, suffix });
|
|
8
|
-
return `${camel}: text('${snake}')${suffix}`;
|
|
9
|
-
};
|
|
10
1
|
export const toType = (field) => {
|
|
11
|
-
return `${field.name}${field.
|
|
2
|
+
return `${field.name}${field.get.required ? '' : '?'}: import('@tiptap/core').JSONContent`;
|
|
12
3
|
};
|
|
@@ -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 * as Command from '../../../panel/components/ui/command/index.js';
|
|
6
6
|
import Tag from '../../../panel/components/ui/tag/tag.svelte';
|
|
7
7
|
import { useSortable } from '../../../panel/util/Sortable.js';
|
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
|
|
13
13
|
let listHTMLElement: HTMLElement;
|
|
14
14
|
let initialized = false;
|
|
15
|
-
let options = $derived(config.options);
|
|
16
|
-
const validValues = $derived(config.options.map((o) => o.value));
|
|
15
|
+
let options = $derived(config.get.options);
|
|
16
|
+
const validValues = $derived(config.get.options.map((o) => o.value));
|
|
17
17
|
const field = $derived(form.useField<string | string[]>(path, config));
|
|
18
18
|
|
|
19
19
|
let isFull = $derived.by(() => {
|
|
20
20
|
if (!field.value) return false;
|
|
21
|
-
const notManyAndOneSelected = !config.many && typeof field.value === 'string';
|
|
22
|
-
const manyAndAllSelected = config.many && field.value.length === config.options.length;
|
|
21
|
+
const notManyAndOneSelected = !config.get.many && typeof field.value === 'string';
|
|
22
|
+
const manyAndAllSelected = config.get.many && field.value.length === config.get.options.length;
|
|
23
23
|
return notManyAndOneSelected || manyAndAllSelected;
|
|
24
24
|
});
|
|
25
25
|
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
$effect(() => {
|
|
40
|
-
if (config.many) {
|
|
40
|
+
if (config.get.many) {
|
|
41
41
|
sortable(listHTMLElement);
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
$effect(() => {
|
|
46
|
-
if (config.many) {
|
|
46
|
+
if (config.get.many) {
|
|
47
47
|
if (field.value && Array.isArray(field.value) && !initialized) {
|
|
48
48
|
field.value = field.value.filter((val: string) => validValues.includes(val));
|
|
49
49
|
}
|
|
@@ -56,12 +56,12 @@
|
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
$effect(() => {
|
|
59
|
-
if (config.many) {
|
|
59
|
+
if (config.get.many) {
|
|
60
60
|
const currentValue = $state.snapshot(field.value);
|
|
61
61
|
if (!currentValue) {
|
|
62
|
-
options = config.options;
|
|
62
|
+
options = config.get.options;
|
|
63
63
|
} else {
|
|
64
|
-
options = config.options.filter((option) => !currentValue.includes(option.value));
|
|
64
|
+
options = config.get.options.filter((option) => !currentValue.includes(option.value));
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
});
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
|
|
74
74
|
const addValue = (val: string) => {
|
|
75
75
|
if (isFull) return;
|
|
76
|
-
if (config.many) {
|
|
76
|
+
if (config.get.many) {
|
|
77
77
|
field.value = [...(field.value || []), val];
|
|
78
78
|
} else {
|
|
79
79
|
field.value = val;
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
const removeValue = (val?: string) => {
|
|
84
|
-
if (config.many) {
|
|
84
|
+
if (config.get.many) {
|
|
85
85
|
field.value = [...(field.value || [])].filter((v) => v !== val);
|
|
86
86
|
} else {
|
|
87
87
|
field.value = null;
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
};
|
|
90
90
|
</script>
|
|
91
91
|
|
|
92
|
-
<fieldset class="rz-field-select {config.className || ''}" use:
|
|
92
|
+
<fieldset class="rz-field-select {config.get.className || ''}" use:fieldset={field}>
|
|
93
93
|
<Field.Label for={path || config.name} {config} />
|
|
94
94
|
<Field.Error error={field.error} />
|
|
95
95
|
|
|
@@ -102,9 +102,9 @@
|
|
|
102
102
|
data-focused={inputFocused ? '' : null}
|
|
103
103
|
data-error={field.error ? '' : null}
|
|
104
104
|
>
|
|
105
|
-
{#if config.many}
|
|
105
|
+
{#if config.get.many}
|
|
106
106
|
{#each field.value || [] as val (val)}
|
|
107
|
-
{@const option = config.options.find((o) => o.value === val)}
|
|
107
|
+
{@const option = config.get.options.find((o) => o.value === val)}
|
|
108
108
|
{#if option}
|
|
109
109
|
<Tag onRemove={() => removeValue(option.value)} readOnly={form.readOnly}>
|
|
110
110
|
{option.label}
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
{/if}
|
|
113
113
|
{/each}
|
|
114
114
|
{:else if field.value}
|
|
115
|
-
{@const option = config.options.filter((o) => o.value === field.value)[0]}
|
|
115
|
+
{@const option = config.get.options.filter((o) => o.value === field.value)[0]}
|
|
116
116
|
{#if option}
|
|
117
117
|
<Tag onRemove={() => removeValue()} readOnly={form.readOnly}>
|
|
118
118
|
{option.label}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DocumentFormContext } from '../../../panel/context/documentForm.svelte.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { SelectFieldBuilder } from '../index.js';
|
|
3
3
|
export type SelectFieldProps = {
|
|
4
4
|
path: string;
|
|
5
|
-
config:
|
|
5
|
+
config: SelectFieldBuilder;
|
|
6
6
|
form: DocumentFormContext;
|
|
7
7
|
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { DataType } from '../../core/fields/builders/form-field-builder.js';
|
|
1
2
|
import type { DefaultValueFn, Field, FormField, Option } from '../types.js';
|
|
2
3
|
import { PickManyFieldBuilder } from '../../core/fields/builders/select-builder.js';
|
|
3
4
|
export declare class SelectFieldBuilder extends PickManyFieldBuilder<SelectField> {
|
|
4
5
|
_metaUrl: string;
|
|
5
6
|
get component(): import("svelte").Component<import("./component/props.js").SelectFieldProps, {}, "">;
|
|
7
|
+
get dataType(): DataType;
|
|
6
8
|
}
|
|
7
9
|
export declare const select: (name: string) => SelectFieldBuilder;
|
|
8
10
|
/**
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ToType } from '../index.server.js';
|
|
2
2
|
import type { SelectFieldBuilder } from './index.js';
|
|
3
|
-
export declare const toSchema: ToSchema<SelectFieldBuilder>;
|
|
4
3
|
export declare const toType: ToType<SelectFieldBuilder>;
|
|
@@ -1,19 +1,4 @@
|
|
|
1
|
-
import { templateUniqueRequired } from '../../adapter-sqlite/generate-schema/templates.server.js';
|
|
2
|
-
import { getSchemaColumnNames } from '../../adapter-sqlite/generate-schema/util.server.js';
|
|
3
|
-
export const toSchema = (field, parentPath) => {
|
|
4
|
-
const { camel, snake } = getSchemaColumnNames({ name: field.raw.name, parentPath });
|
|
5
|
-
const defaultValue = field.raw.many ? [] : '';
|
|
6
|
-
const suffix = templateUniqueRequired(field.raw, typeof field.raw.defaultValue === 'undefined' ? defaultValue : field.raw.defaultValue);
|
|
7
|
-
if (field._generateSchema)
|
|
8
|
-
return field._generateSchema({ camel, snake, suffix });
|
|
9
|
-
if (field.raw.many) {
|
|
10
|
-
return `${camel}: text('${snake}', { mode: 'json' })${suffix}`;
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
return `${camel}: text('${snake}')${suffix}`;
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
1
|
export const toType = (field) => {
|
|
17
|
-
const optionsJoinedType = field.
|
|
18
|
-
return `${field.
|
|
2
|
+
const optionsJoinedType = field.get.options.map((o) => `'${o.value}'`).join(' | ');
|
|
3
|
+
return `${field.name}${field.get.required ? '' : '?'}: (${optionsJoinedType})${field.get.many ? '[]' : ''}`;
|
|
19
4
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
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 { Input } from '../../../panel/components/ui/input/index.js';
|
|
7
7
|
import type { DocumentFormContext } from '../../../panel/context/documentForm.svelte.js';
|
|
8
8
|
import { slugify } from '../../../util/string.js';
|
|
9
9
|
import { Hash } from '@lucide/svelte';
|
|
10
|
-
import type {
|
|
10
|
+
import type { SlugFieldBuilder } from '../index.js';
|
|
11
11
|
|
|
12
|
-
type Props = { path: string; config:
|
|
12
|
+
type Props = { path: string; config: SlugFieldBuilder; form: DocumentFormContext };
|
|
13
13
|
const { path, config, form }: Props = $props();
|
|
14
14
|
|
|
15
15
|
const field = $derived(form.useField(path, config));
|
|
@@ -17,7 +17,9 @@
|
|
|
17
17
|
// svelte-ignore state_referenced_locally
|
|
18
18
|
const initialValue = form.getRawValue(path);
|
|
19
19
|
const initialEmpty = !initialValue;
|
|
20
|
-
const slugifySource = $derived(
|
|
20
|
+
const slugifySource = $derived(
|
|
21
|
+
config.get.slugify ? form.useField<string>(config.get.slugify) : null
|
|
22
|
+
);
|
|
21
23
|
|
|
22
24
|
const slugifiedValue = $derived.by(() => {
|
|
23
25
|
if (slugifySource && slugifySource.value) {
|
|
@@ -42,17 +44,19 @@
|
|
|
42
44
|
field.value = inputElement.value;
|
|
43
45
|
};
|
|
44
46
|
|
|
45
|
-
const classNameCompact = $derived(
|
|
46
|
-
|
|
47
|
+
const classNameCompact = $derived(
|
|
48
|
+
config.get.layout === 'compact' ? 'rz-slug-field--compact' : ''
|
|
49
|
+
);
|
|
50
|
+
const classNames = $derived(`rz-slug-field ${classNameCompact || ''} ${config.get.className}`);
|
|
47
51
|
</script>
|
|
48
52
|
|
|
49
|
-
<fieldset class={classNames} use:
|
|
53
|
+
<fieldset class={classNames} use:fieldset={field}>
|
|
50
54
|
<Field.Label {config} for={path || config.name} />
|
|
51
55
|
|
|
52
56
|
<div class="rz-slug">
|
|
53
57
|
<Input
|
|
54
58
|
id={path || config.name}
|
|
55
|
-
placeholder={config.placeholder}
|
|
59
|
+
placeholder={config.get.placeholder}
|
|
56
60
|
data-error={field.error ? '' : null}
|
|
57
61
|
type="text"
|
|
58
62
|
icon={Hash}
|
|
@@ -63,7 +67,7 @@
|
|
|
63
67
|
onblur={() => (isFocused = false)}
|
|
64
68
|
/>
|
|
65
69
|
|
|
66
|
-
{#if config.slugify}
|
|
70
|
+
{#if config.get.slugify}
|
|
67
71
|
<Button
|
|
68
72
|
disabled={!field.editable}
|
|
69
73
|
onclick={() => (field.value = slugifiedValue)}
|
|
@@ -71,7 +75,7 @@
|
|
|
71
75
|
size="sm"
|
|
72
76
|
variant="secondary"
|
|
73
77
|
>
|
|
74
|
-
{t__('fields.generate_from', config.slugify)}
|
|
78
|
+
{t__('fields.generate_from', config.get.slugify)}
|
|
75
79
|
</Button>
|
|
76
80
|
{/if}
|
|
77
81
|
</div>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { DocumentFormContext } from '../../../panel/context/documentForm.svelte.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { SlugFieldBuilder } from '../index.js';
|
|
3
3
|
type Props = {
|
|
4
4
|
path: string;
|
|
5
|
-
config:
|
|
5
|
+
config: SlugFieldBuilder;
|
|
6
6
|
form: DocumentFormContext;
|
|
7
7
|
};
|
|
8
8
|
declare const Slug: import("svelte").Component<Props, {}, "">;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DataType } from '../../core/fields/builders/form-field-builder.js';
|
|
1
2
|
import { FormFieldBuilder } from '../../core/fields/builders/form-field-builder.js';
|
|
2
3
|
import type { DefaultValueFn, FormField } from '../types.js';
|
|
3
4
|
export declare const slug: (name: string) => SlugFieldBuilder;
|
|
@@ -6,7 +7,7 @@ export declare class SlugFieldBuilder extends FormFieldBuilder<SlugField> {
|
|
|
6
7
|
constructor(name: string);
|
|
7
8
|
get component(): import("svelte").Component<{
|
|
8
9
|
path: string;
|
|
9
|
-
config:
|
|
10
|
+
config: SlugFieldBuilder;
|
|
10
11
|
form: import("../../panel").DocumentFormContext;
|
|
11
12
|
}, {}, "">;
|
|
12
13
|
get cell(): import("svelte").Component<{
|
|
@@ -17,8 +18,10 @@ export declare class SlugFieldBuilder extends FormFieldBuilder<SlugField> {
|
|
|
17
18
|
layout(layout: 'compact' | 'default'): this;
|
|
18
19
|
defaultValue(value: string | DefaultValueFn<string>): this;
|
|
19
20
|
unique(bool?: boolean): this;
|
|
21
|
+
get dataType(): DataType;
|
|
20
22
|
isTitle(): this;
|
|
21
23
|
compile(): {
|
|
24
|
+
name: string;
|
|
22
25
|
type: "slug";
|
|
23
26
|
live?: boolean | undefined;
|
|
24
27
|
condition?: ((doc: any, siblings: any) => boolean) | undefined;
|
|
@@ -31,7 +34,6 @@ export declare class SlugFieldBuilder extends FormFieldBuilder<SlugField> {
|
|
|
31
34
|
read: import("../types.js").FieldAccess;
|
|
32
35
|
update: import("../types.js").FieldAccess;
|
|
33
36
|
};
|
|
34
|
-
name: string;
|
|
35
37
|
hidden?: boolean | undefined;
|
|
36
38
|
validate?: import("../types.js").FieldValidationFunc<any> | undefined;
|
|
37
39
|
required?: boolean | undefined;
|
|
@@ -53,6 +55,7 @@ export declare class SlugFieldBuilder extends FormFieldBuilder<SlugField> {
|
|
|
53
55
|
} | undefined;
|
|
54
56
|
defaultValue?: string | DefaultValueFn<string> | undefined;
|
|
55
57
|
isEmpty: (value: unknown) => boolean;
|
|
58
|
+
_root?: boolean | undefined;
|
|
56
59
|
slugify?: string | undefined;
|
|
57
60
|
unique?: boolean | undefined;
|
|
58
61
|
isTitle?: true | undefined;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ToType } from '../index.server.js';
|
|
2
2
|
import type { SlugFieldBuilder } from './index.js';
|
|
3
|
-
export declare const toSchema: ToSchema<SlugFieldBuilder>;
|
|
4
3
|
export declare const toType: ToType<SlugFieldBuilder>;
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
import { templateUniqueRequired } from '../../adapter-sqlite/generate-schema/templates.server.js';
|
|
2
|
-
import { getSchemaColumnNames } from '../../adapter-sqlite/generate-schema/util.server.js';
|
|
3
|
-
export const toSchema = (field, parentPath) => {
|
|
4
|
-
const { camel, snake } = getSchemaColumnNames({ name: field.name, parentPath });
|
|
5
|
-
const suffix = templateUniqueRequired({ unique: field.raw.unique, required: field.raw.required }, typeof field.raw.defaultValue === 'string' ? field.raw.defaultValue : '');
|
|
6
|
-
if (field._generateSchema)
|
|
7
|
-
return field._generateSchema({ camel, snake, suffix });
|
|
8
|
-
return `${camel}: text('${snake}')${suffix}`;
|
|
9
|
-
};
|
|
10
1
|
export const toType = (field) => {
|
|
11
|
-
return `${field.name}${field.
|
|
2
|
+
return `${field.name}${field.get.required ? '' : '?'}: string`;
|
|
12
3
|
};
|