rimecms 0.28.10 → 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/README.md +3 -3
- 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/generate-schema/{util.d.ts → util.server.d.ts} +2 -2
- package/dist/adapter-sqlite/generate-schema/{util.js → util.server.js} +2 -2
- package/dist/adapter-sqlite/generate-schema/write.server.js +1 -1
- package/dist/adapter-sqlite/relations.server.js +6 -1
- package/dist/adapter-sqlite/transform.server.js +1 -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 +10 -10
- package/dist/core/areas/{api → rest}/get.server.d.ts +4 -2
- package/dist/core/areas/rest/get.server.js +45 -0
- package/dist/core/areas/rest/index.server.d.ts +6 -0
- package/dist/core/areas/rest/index.server.js +3 -0
- package/dist/core/areas/{api → rest}/update.server.d.ts +4 -2
- package/dist/core/areas/rest/update.server.js +43 -0
- package/dist/core/collections/auth/fields.d.ts +2 -182
- package/dist/core/collections/auth/hooks/before-upsert/augment-fields-password.server.d.ts +1 -1
- 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-panel.d.ts +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 +31 -12
- package/dist/core/collections/operations/updateById.js +6 -5
- package/dist/core/collections/{api → rest}/create.server.d.ts +4 -2
- package/dist/core/collections/rest/create.server.js +37 -0
- package/dist/core/collections/{api → rest}/delete.server.d.ts +4 -2
- package/dist/core/collections/rest/delete.server.js +37 -0
- package/dist/core/collections/{api → rest}/deleteById.server.d.ts +4 -2
- package/dist/core/collections/rest/deleteById.server.js +21 -0
- package/dist/core/collections/{api → rest}/duplicate.server.d.ts +1 -1
- package/dist/core/collections/rest/duplicate.server.js +20 -0
- package/dist/core/collections/{api → rest}/get.server.d.ts +4 -2
- package/dist/core/collections/rest/get.server.js +50 -0
- package/dist/core/collections/{api → rest}/getById.server.d.ts +4 -2
- package/dist/core/collections/rest/getById.server.js +35 -0
- package/dist/core/collections/rest/index.server.d.ts +16 -0
- package/dist/core/collections/rest/index.server.js +16 -0
- package/dist/core/collections/{api → rest}/updateById.server.d.ts +4 -2
- package/dist/core/collections/rest/updateById.server.js +44 -0
- 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/convert-base64.server.d.ts +1 -1
- package/dist/core/collections/upload/hooks/extract-path.server.d.ts +2 -2
- package/dist/core/collections/upload/hooks/extract-path.server.js +1 -1
- package/dist/core/collections/upload/hooks/handle-path-creation.server.d.ts +1 -1
- package/dist/core/collections/upload/hooks/process-file-upload.server.d.ts +1 -1
- package/dist/core/collections/upload/hooks/process-file-upload.server.js +3 -3
- package/dist/core/config/auth/better-auth.server.d.ts +2 -2
- package/dist/core/config/client/augment-directories.js +1 -1
- package/dist/core/config/config-context.server.d.ts +3 -3
- package/dist/core/config/server/augment-directories.server.js +1 -1
- package/dist/core/config/server/augment-panel-access.server.d.ts +1 -1
- package/dist/core/config/server/build-config.server.d.ts +11 -11
- package/dist/core/config/server/validate.server.js +51 -31
- package/dist/core/config/shared/find-thumbnail.js +13 -13
- package/dist/core/config/shared/find-title.js +13 -13
- package/dist/core/config/shared/upload-directories.js +1 -1
- package/dist/core/constant.d.ts +1 -1
- package/dist/core/constant.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.d.ts +1 -0
- package/dist/core/dev/cli/build/index.js +37 -8
- package/dist/core/dev/cli/build/templates.d.ts +1 -0
- package/dist/core/dev/cli/build/templates.js +24 -0
- package/dist/core/dev/cli/clear/index.server.js +3 -2
- package/dist/core/dev/cli/generate/index.server.js +3 -2
- package/dist/core/dev/cli/index.js +20 -0
- package/dist/core/dev/cli/init/index.server.js +4 -4
- package/dist/core/dev/cli/init/templates.d.ts +1 -1
- package/dist/core/dev/cli/init/templates.js +2 -2
- package/dist/core/dev/cli/util/log.server.d.ts +1 -0
- package/dist/core/dev/cli/util/log.server.js +4 -0
- package/dist/core/dev/cli/util/package-manager.server.d.ts +9 -0
- package/dist/core/dev/cli/{init/package-manager-util.server.js → util/package-manager.server.js} +15 -0
- package/dist/core/dev/cli/util/package.server.d.ts +9 -0
- package/dist/core/dev/cli/{init/get-package-info.server.js → util/package.server.js} +10 -0
- package/dist/core/dev/generate/routes/common.server.d.ts +10 -1
- package/dist/core/dev/generate/routes/common.server.js +248 -29
- package/dist/core/dev/generate/routes/index.server.d.ts +7 -1
- package/dist/core/dev/generate/routes/index.server.js +16 -55
- package/dist/core/dev/generate/routes/util.server.d.ts +6 -16
- package/dist/core/dev/generate/routes/util.server.js +8 -21
- package/dist/core/dev/generate/types/index.server.js +22 -20
- package/dist/core/dev/vite/index.server.js +22 -6
- package/dist/core/errors/handler.server.d.ts +22 -1
- package/dist/core/errors/handler.server.js +25 -2
- package/dist/core/errors/index.d.ts +0 -1
- package/dist/core/errors/index.js +0 -1
- 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 +9 -17
- package/dist/core/fields/util.js +49 -83
- package/dist/core/handlers/routes.server.d.ts +70 -1
- package/dist/core/handlers/routes.server.js +71 -4
- 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.d.ts +1 -1
- package/dist/core/operations/hooks/before-upsert/data-config-map.server.js +1 -1
- package/dist/core/operations/hooks/before-upsert/handle-new-version.server.d.ts +1 -1
- package/dist/core/operations/hooks/before-upsert/original-config-map.server.d.ts +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 +3 -5
- package/dist/core/operations/hooks/before-upsert/set-default-values.server.js +10 -15
- package/dist/core/operations/hooks/before-upsert/validate-fields.server.d.ts +1 -1
- 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/api-init/index.server.js +10 -5
- package/dist/core/plugins/cache/cache.server.js +4 -4
- package/dist/core/rime.server.d.ts +10 -10
- package/dist/core/rime.server.js +5 -1
- 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 +5 -2
- 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/RessourceInput.svelte +1 -1
- package/dist/fields/link/component/props.d.ts +2 -2
- package/dist/fields/link/index.d.ts +5 -2
- package/dist/fields/link/index.js +10 -11
- 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/client.d.ts +1 -1
- package/dist/fields/relation/client.js +1 -1
- package/dist/fields/relation/component/Cell.svelte +1 -1
- package/dist/fields/relation/component/Relation.svelte +19 -15
- package/dist/fields/relation/component/Relation.svelte.d.ts +2 -2
- package/dist/fields/relation/component/upload/Browse.svelte +1 -1
- package/dist/fields/relation/index.d.ts +8 -5
- 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/extension.d.ts +2 -2
- package/dist/fields/rich-text/core/features/fields/fields.svelte +2 -2
- package/dist/fields/rich-text/core/features/link/component/link-selector.svelte +1 -1
- package/dist/fields/rich-text/core/features/resource/resource-extension.d.ts +1 -1
- package/dist/fields/rich-text/core/features/resource/resource.svelte +1 -1
- package/dist/fields/rich-text/core/features/upload/upload-extension.d.ts +1 -1
- package/dist/fields/rich-text/core/features/upload/upload.svelte +1 -1
- package/dist/fields/rich-text/index.d.ts +2 -0
- package/dist/fields/rich-text/index.js +7 -2
- 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/index.d.ts +8 -3
- package/dist/index.js +7 -3
- 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/collection/folder/FolderWithActions.svelte +1 -1
- package/dist/panel/components/sections/document/AuthFooter.svelte +2 -7
- package/dist/panel/components/sections/document/ButtonStatus.svelte +1 -1
- package/dist/panel/components/sections/document/CurrentlyEdited.svelte +1 -1
- package/dist/panel/components/sections/document/Settings.svelte +1 -1
- package/dist/panel/components/sections/live/LiveEditPanel.svelte +2 -2
- package/dist/panel/context/collection.svelte.js +10 -10
- package/dist/panel/context/documentForm.svelte.d.ts +8 -21
- package/dist/panel/context/documentForm.svelte.js +46 -54
- package/dist/panel/context/form.svelte.d.ts +6 -3
- package/dist/panel/context/form.svelte.js +22 -18
- package/dist/panel/context/live.svelte.js +1 -1
- package/dist/panel/index.d.ts +9 -1
- package/dist/panel/index.js +7 -1
- package/dist/panel/pages/area/actions.server.d.ts +2 -21
- package/dist/panel/pages/area/actions.server.js +28 -27
- package/dist/panel/pages/area/load.server.d.ts +2 -17
- package/dist/panel/pages/area/load.server.js +37 -46
- 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/panel/pages/auth/sign-in/SignIn.svelte +7 -1
- package/dist/panel/pages/collection/load.server.d.ts +6 -6
- package/dist/panel/pages/collection/load.server.js +70 -72
- package/dist/panel/pages/collection-document/actions.server.d.ts +1 -1
- package/dist/panel/pages/collection-document/actions.server.js +78 -70
- package/dist/panel/pages/collection-document/load.server.d.ts +5 -20
- package/dist/panel/pages/collection-document/load.server.js +80 -82
- package/dist/server.d.ts +7 -0
- package/dist/server.js +7 -0
- package/dist/types.d.ts +1 -0
- package/dist/util/doc.js +15 -17
- package/dist/util/index.d.ts +9 -1
- package/dist/util/index.js +12 -1
- package/package.json +8 -50
- package/dist/core/api/index.d.ts +0 -7
- package/dist/core/api/index.js +0 -10
- package/dist/core/api/index.server.d.ts +0 -3
- package/dist/core/api/index.server.js +0 -3
- package/dist/core/areas/api/get.server.js +0 -36
- package/dist/core/areas/api/index.server.d.ts +0 -7
- package/dist/core/areas/api/index.server.js +0 -4
- package/dist/core/areas/api/update.server.js +0 -33
- package/dist/core/collections/api/create.server.js +0 -29
- package/dist/core/collections/api/delete.server.js +0 -32
- package/dist/core/collections/api/deleteById.server.js +0 -16
- package/dist/core/collections/api/duplicate.server.js +0 -18
- package/dist/core/collections/api/get.server.js +0 -45
- package/dist/core/collections/api/getById.server.js +0 -30
- package/dist/core/collections/api/index.server.d.ts +0 -17
- package/dist/core/collections/api/index.server.js +0 -9
- package/dist/core/collections/api/updateById.server.js +0 -38
- package/dist/core/dev/cli/init/get-package-info.server.d.ts +0 -1
- package/dist/core/dev/cli/init/package-manager-util.server.d.ts +0 -3
- package/dist/core/dev/generate/routes/area.server.d.ts +0 -7
- package/dist/core/dev/generate/routes/area.server.js +0 -69
- package/dist/core/dev/generate/routes/collection.server.d.ts +0 -14
- package/dist/core/dev/generate/routes/collection.server.js +0 -129
- package/dist/fields/relation/index.server.d.ts +0 -4
- package/dist/fields/relation/index.server.js +0 -13
- package/dist/live.d.ts +0 -4
- package/dist/live.js +0 -4
- package/dist/panel/index.server.d.ts +0 -4
- package/dist/panel/index.server.js +0 -4
- package/dist/panel/pages/auth/index.d.ts +0 -4
- package/dist/panel/pages/auth/index.js +0 -4
- package/dist/panel/pages/auth/index.server.d.ts +0 -18
- package/dist/panel/pages/auth/index.server.js +0 -12
- package/dist/panel/pages/index.actions.server.d.ts +0 -13
- package/dist/panel/pages/index.actions.server.js +0 -10
- package/dist/panel/pages/index.load.server.d.ts +0 -23
- package/dist/panel/pages/index.load.server.js +0 -16
- package/dist/panel/ui.d.ts +0 -4
- package/dist/panel/ui.js +0 -5
- /package/dist/core/dev/cli/{util.server.d.ts → util/prompt.server.d.ts} +0 -0
- /package/dist/core/dev/cli/{util.server.js → util/prompt.server.js} +0 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { goto } from '$app/navigation';
|
|
3
3
|
import { page } from '$app/state';
|
|
4
|
-
import { apiUrl } from '../../../../core/api/index.js';
|
|
5
4
|
import { PARAMS, VERSIONS_STATUS } from '../../../../core/constant.js';
|
|
6
5
|
import * as Dialog from '../../ui/dialog/index.js';
|
|
7
6
|
import * as DropdownMenu from '../../ui/dropdown-menu/index.js';
|
|
@@ -10,6 +9,7 @@
|
|
|
10
9
|
import { panelUrl } from '../../../util/url.js';
|
|
11
10
|
import type { GenericDoc } from '../../../../types.js';
|
|
12
11
|
import { trycatchFetch } from '../../../../util/function.js';
|
|
12
|
+
import { apiUrl } from '../../../../util/index.js';
|
|
13
13
|
import { Copy, History, Import, Pickaxe, Settings, Trash2 } from '@lucide/svelte';
|
|
14
14
|
import { toast } from 'svelte-sonner';
|
|
15
15
|
import { t__ } from '../../../../core/i18n/index.js';
|
|
@@ -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">
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { invalidateAll } from '$app/navigation';
|
|
2
|
-
import { apiUrl } from '../../core/api/index.js';
|
|
3
2
|
import { isUploadConfig } from '../../core/collections/upload/util/config.js';
|
|
4
3
|
import { PARAMS } from '../../core/constant.js';
|
|
5
4
|
import { isFormField } from '../../core/fields/util.js';
|
|
@@ -9,6 +8,7 @@ import { TabsBuilder } from '../../fields/tabs/index.js';
|
|
|
9
8
|
import { panelUrl } from '../util/url.js';
|
|
10
9
|
import { toNestedStructure } from '../../util/doc.js';
|
|
11
10
|
import { trycatch, trycatchFetch } from '../../util/function.js';
|
|
11
|
+
import { apiUrl } from '../../util/index.js';
|
|
12
12
|
import { getValueAtPath, hasProp } from '../../util/object.js';
|
|
13
13
|
import { getContext, onMount, setContext } from 'svelte';
|
|
14
14
|
import { toast } from 'svelte-sonner';
|
|
@@ -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;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { applyAction, deserialize } from '$app/forms';
|
|
2
2
|
import { page } from '$app/state';
|
|
3
|
-
import { apiUrl } from '../../core/api/index.js';
|
|
4
|
-
import { compileDocumentConfig } from '../../core/config/shared/compile.js';
|
|
5
3
|
import { PARAMS, VERSIONS_STATUS } from '../../core/constant.js';
|
|
6
|
-
import {
|
|
4
|
+
import { getFieldAtPath } from '../../core/fields/util.js';
|
|
7
5
|
import { buildConfigMap } from '../../core/operations/configMap/index.js';
|
|
8
6
|
import { isJSONContent, richTextJSONToText } from '../../fields/rich-text/index.js';
|
|
9
7
|
import { normalizeFieldPath } from '../../util/doc.js';
|
|
10
|
-
import { random } from '../../util/index.js';
|
|
8
|
+
import { apiUrl, random } from '../../util/index.js';
|
|
11
9
|
import { isObjectLiteral, omit } from '../../util/object.js';
|
|
12
10
|
import cloneDeep from 'clone-deep';
|
|
13
11
|
import { diff } from 'deep-object-diff';
|
|
@@ -29,7 +27,7 @@ function createDocumentFormState({ initial, config, readOnly, key, onNestedDocum
|
|
|
29
27
|
let initialDoc = $state(initial);
|
|
30
28
|
let doc = $state(initial);
|
|
31
29
|
let formElement = $state();
|
|
32
|
-
const documentConfig =
|
|
30
|
+
const documentConfig = config;
|
|
33
31
|
const changes = $derived(diff(initialDoc, doc));
|
|
34
32
|
let isDisabled = $state(readOnly);
|
|
35
33
|
let processing = $state(false);
|
|
@@ -336,32 +334,43 @@ function createDocumentFormState({ initial, config, readOnly, key, onNestedDocum
|
|
|
336
334
|
// Return primitive values as is
|
|
337
335
|
return data;
|
|
338
336
|
};
|
|
337
|
+
/**
|
|
338
|
+
* `config` is the raw compiled field data, same as every field component
|
|
339
|
+
* (Text.svelte, Group.svelte, ...) already works with — this mirrors
|
|
340
|
+
* `form.svelte.ts`'s `useField` on purpose, since both read plain field
|
|
341
|
+
* data (`.required`, `.isEmpty(value)`, `.validate(...)`, `.access.read`,
|
|
342
|
+
* `.condition(...)`), never builder methods. `config` is only omitted by
|
|
343
|
+
* callers with just a path in hand (e.g. `Group.svelte`'s `getField`), in
|
|
344
|
+
* which case it's resolved from `documentConfig.fields` and unwrapped via
|
|
345
|
+
* `.get` — the field must exist in the document's own field tree for that
|
|
346
|
+
* to work, which doesn't hold for standalone fields like the panel's
|
|
347
|
+
* password inputs (see AuthFooter.svelte), so those always pass `config`.
|
|
348
|
+
*/
|
|
339
349
|
function useField(path, config) {
|
|
340
350
|
if (!config) {
|
|
341
|
-
|
|
342
|
-
if (!
|
|
351
|
+
const resolved = getFieldAtPath(path, documentConfig.fields);
|
|
352
|
+
if (!resolved)
|
|
343
353
|
throw new Error(`can't find config for field : ${path}`);
|
|
354
|
+
config = resolved;
|
|
344
355
|
}
|
|
345
356
|
path = path ? normalizeFieldPath(path) : config.name;
|
|
346
357
|
const parts = $derived(path.split('.'));
|
|
347
358
|
const validate = (value) => {
|
|
348
|
-
if (config.required && config.isEmpty(value)) {
|
|
359
|
+
if (config.get.required && config.run.isEmpty(value)) {
|
|
349
360
|
errors.set(path, 'required::required_field');
|
|
350
361
|
return 'required';
|
|
351
362
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
return false;
|
|
364
|
-
}
|
|
363
|
+
const validated = config.run.validate(value, {
|
|
364
|
+
data: doc,
|
|
365
|
+
locale: locale.code,
|
|
366
|
+
id: doc.id ?? undefined,
|
|
367
|
+
operation: doc.id ? 'update' : 'create',
|
|
368
|
+
user: user.attributes,
|
|
369
|
+
config: config.get
|
|
370
|
+
});
|
|
371
|
+
if (validated !== true) {
|
|
372
|
+
errors.set(path, validated);
|
|
373
|
+
return false;
|
|
365
374
|
}
|
|
366
375
|
if (errors.has(path)) {
|
|
367
376
|
errors.delete(path);
|
|
@@ -399,25 +408,20 @@ function createDocumentFormState({ initial, config, readOnly, key, onNestedDocum
|
|
|
399
408
|
setFieldValue(removeIds(defaultLocaleValue));
|
|
400
409
|
}
|
|
401
410
|
};
|
|
402
|
-
const setFieldValue = (value) => {
|
|
411
|
+
const setFieldValue = async (value) => {
|
|
412
|
+
value = await config.run.beforeValidate(value, { config, data: doc });
|
|
403
413
|
const valid = validate(value);
|
|
404
|
-
if (!config.
|
|
405
|
-
return;
|
|
406
|
-
if (operation === 'update' && !config.access.update(user.attributes)) {
|
|
414
|
+
if (operation === 'update' && !config.run.canUpdate(user.attributes)) {
|
|
407
415
|
return;
|
|
408
416
|
}
|
|
409
417
|
if (valid) {
|
|
410
418
|
setValue(path, value);
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
useTree
|
|
418
|
-
});
|
|
419
|
-
}
|
|
420
|
-
}
|
|
419
|
+
config.run.onChange?.(value, {
|
|
420
|
+
siblings: getSiblings(),
|
|
421
|
+
useField,
|
|
422
|
+
useBlocks,
|
|
423
|
+
useTree
|
|
424
|
+
});
|
|
421
425
|
}
|
|
422
426
|
};
|
|
423
427
|
return {
|
|
@@ -432,35 +436,24 @@ function createDocumentFormState({ initial, config, readOnly, key, onNestedDocum
|
|
|
432
436
|
get editable() {
|
|
433
437
|
if (readOnly)
|
|
434
438
|
return false;
|
|
435
|
-
if (!config.access)
|
|
436
|
-
return false;
|
|
437
439
|
if (operation === 'create') {
|
|
438
|
-
return config.
|
|
440
|
+
return !!config.run.canCreate?.(user.attributes);
|
|
439
441
|
}
|
|
440
442
|
else {
|
|
441
|
-
return config.
|
|
443
|
+
return !!config.run.canUpdate?.(user.attributes);
|
|
442
444
|
}
|
|
443
445
|
},
|
|
444
446
|
get visible() {
|
|
445
|
-
if (
|
|
447
|
+
if (!config.run.canRead(user.attributes)) {
|
|
446
448
|
return false;
|
|
447
449
|
}
|
|
448
|
-
|
|
449
|
-
if (config.condition) {
|
|
450
|
-
try {
|
|
451
|
-
visible = config.condition(doc, getSiblings());
|
|
452
|
-
}
|
|
453
|
-
catch (err) {
|
|
454
|
-
console.error(err.message);
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
return visible;
|
|
450
|
+
return config.run.condition(doc, getSiblings());
|
|
458
451
|
},
|
|
459
452
|
get error() {
|
|
460
453
|
return errors.value[path] || false;
|
|
461
454
|
},
|
|
462
455
|
get isEmpty() {
|
|
463
|
-
return
|
|
456
|
+
return config.run.isEmpty(getValueAtPath(path, doc));
|
|
464
457
|
}
|
|
465
458
|
};
|
|
466
459
|
}
|
|
@@ -619,7 +612,7 @@ function createDocumentFormState({ initial, config, readOnly, key, onNestedDocum
|
|
|
619
612
|
let data = { ...defaultLocaleDoc, locale: locale.code };
|
|
620
613
|
const configMap = buildConfigMap(defaultLocaleDoc, documentConfig.fields);
|
|
621
614
|
for (const [key, field] of Object.entries(configMap)) {
|
|
622
|
-
if (field.localized) {
|
|
615
|
+
if (field.get.localized) {
|
|
623
616
|
let value = getValueAtPath(key, data);
|
|
624
617
|
value = removeIds(value);
|
|
625
618
|
data = setValueAtPath(key, data, value);
|
|
@@ -694,8 +687,7 @@ export function setDocumentFormContext(args) {
|
|
|
694
687
|
const initial = {
|
|
695
688
|
...args.initial,
|
|
696
689
|
_type: args.initial._type || args.config.type,
|
|
697
|
-
_prototype: args.initial._prototype || args.config.slug
|
|
698
|
-
title: args.initial.title || '[untitled]'
|
|
690
|
+
_prototype: args.initial._prototype || args.config.slug
|
|
699
691
|
};
|
|
700
692
|
const store = createDocumentFormState({ ...args, initial });
|
|
701
693
|
return setContext(`${FORM_KEY}.${args.key}`, store);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FormFieldBuilder } from '../../core/fields/builders/form-field-builder';
|
|
2
|
+
import type { FormField } from '../../fields/types.js';
|
|
2
3
|
import type { Dic } from '../../util/types.js';
|
|
3
4
|
import type { SubmitFunction } from '@sveltejs/kit';
|
|
4
5
|
export declare function setFormContext(initial: Dic, key: string): {
|
|
5
6
|
setValue: (path: string, value: any) => void;
|
|
6
|
-
useField: (path: string | undefined, config:
|
|
7
|
+
useField: (path: string | undefined, config: FormFieldBuilder<FormField>) => {
|
|
7
8
|
path: string;
|
|
8
9
|
value: any;
|
|
9
10
|
readonly editable: boolean;
|
|
@@ -13,6 +14,7 @@ export declare function setFormContext(initial: Dic, key: string): {
|
|
|
13
14
|
readOnly: boolean;
|
|
14
15
|
enhance: SubmitFunction;
|
|
15
16
|
getRawValue: <T>(path: string) => NonNullable<T> | null;
|
|
17
|
+
readonly pending: boolean;
|
|
16
18
|
readonly canSubmit: boolean;
|
|
17
19
|
readonly errors: {
|
|
18
20
|
readonly length: number;
|
|
@@ -42,7 +44,7 @@ export declare function setFormContext(initial: Dic, key: string): {
|
|
|
42
44
|
};
|
|
43
45
|
export declare function getFormContext(key: string): {
|
|
44
46
|
setValue: (path: string, value: any) => void;
|
|
45
|
-
useField: (path: string | undefined, config:
|
|
47
|
+
useField: (path: string | undefined, config: FormFieldBuilder<FormField>) => {
|
|
46
48
|
path: string;
|
|
47
49
|
value: any;
|
|
48
50
|
readonly editable: boolean;
|
|
@@ -52,6 +54,7 @@ export declare function getFormContext(key: string): {
|
|
|
52
54
|
readOnly: boolean;
|
|
53
55
|
enhance: SubmitFunction;
|
|
54
56
|
getRawValue: <T>(path: string) => NonNullable<T> | null;
|
|
57
|
+
readonly pending: boolean;
|
|
55
58
|
readonly canSubmit: boolean;
|
|
56
59
|
readonly errors: {
|
|
57
60
|
readonly length: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { applyAction } from '$app/forms';
|
|
2
|
-
import { getValueAtPath } from '../../util/object';
|
|
3
|
-
import { snapshot } from '../../util/state';
|
|
2
|
+
import { getValueAtPath } from '../../util/object.js';
|
|
3
|
+
import { snapshot } from '../../util/state.js';
|
|
4
4
|
import { diff } from 'deep-object-diff';
|
|
5
5
|
import { getContext, setContext } from 'svelte';
|
|
6
6
|
import { setErrorsContext } from './errors.svelte';
|
|
@@ -12,6 +12,7 @@ function createFormStore(initial, key) {
|
|
|
12
12
|
const hasError = $derived(errors.length);
|
|
13
13
|
const canSubmit = $derived(Object.keys(changes).length > 0 && !hasError);
|
|
14
14
|
let status = $state();
|
|
15
|
+
let pending = $state(false);
|
|
15
16
|
$effect(() => {
|
|
16
17
|
if (Object.keys(changes).length) {
|
|
17
18
|
errors.value = {};
|
|
@@ -42,29 +43,27 @@ function createFormStore(initial, key) {
|
|
|
42
43
|
const validate = (value) => {
|
|
43
44
|
let isEmpty;
|
|
44
45
|
try {
|
|
45
|
-
isEmpty = config.isEmpty(value);
|
|
46
|
+
isEmpty = config.run.isEmpty(value);
|
|
46
47
|
}
|
|
47
48
|
catch (err) {
|
|
48
49
|
console.error(err.message);
|
|
49
50
|
throw new Error(config.type + ' ' + err.message);
|
|
50
51
|
}
|
|
51
|
-
if (config.required && isEmpty) {
|
|
52
|
+
if (config.get.required && isEmpty) {
|
|
52
53
|
errors.value[path] = 'required::required_field';
|
|
53
54
|
return false;
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
56
|
+
const validated = config.run.validate(value, {
|
|
57
|
+
data: form,
|
|
58
|
+
id: undefined,
|
|
59
|
+
operation: undefined,
|
|
60
|
+
user: undefined,
|
|
61
|
+
locale: undefined,
|
|
62
|
+
config: config.get
|
|
63
|
+
});
|
|
64
|
+
if (validated !== true) {
|
|
65
|
+
errors.value[path] = validated;
|
|
66
|
+
return false;
|
|
68
67
|
}
|
|
69
68
|
if (errors.has(path)) {
|
|
70
69
|
errors.delete(path);
|
|
@@ -86,7 +85,7 @@ function createFormStore(initial, key) {
|
|
|
86
85
|
}
|
|
87
86
|
},
|
|
88
87
|
get visible() {
|
|
89
|
-
return config.
|
|
88
|
+
return config.run.condition(form, {});
|
|
90
89
|
},
|
|
91
90
|
get error() {
|
|
92
91
|
return errors.value[path] || false;
|
|
@@ -94,11 +93,13 @@ function createFormStore(initial, key) {
|
|
|
94
93
|
};
|
|
95
94
|
}
|
|
96
95
|
const enhance = async ({ formData }) => {
|
|
96
|
+
pending = true;
|
|
97
97
|
for (const key of Object.keys(form)) {
|
|
98
98
|
formData.set(key, form[key]);
|
|
99
99
|
}
|
|
100
100
|
return async ({ result }) => {
|
|
101
101
|
status = result.status;
|
|
102
|
+
pending = false;
|
|
102
103
|
switch (result.type) {
|
|
103
104
|
case 'failure':
|
|
104
105
|
if (result.data?.errors) {
|
|
@@ -122,6 +123,9 @@ function createFormStore(initial, key) {
|
|
|
122
123
|
readOnly: false,
|
|
123
124
|
enhance,
|
|
124
125
|
getRawValue,
|
|
126
|
+
get pending() {
|
|
127
|
+
return pending;
|
|
128
|
+
},
|
|
125
129
|
get canSubmit() {
|
|
126
130
|
return canSubmit;
|
|
127
131
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { page } from '$app/state';
|
|
2
2
|
import { env } from '$env/dynamic/public';
|
|
3
|
-
import { apiUrl } from '../../core/api/index.js';
|
|
4
3
|
import { PARAMS } from '../../core/constant.js';
|
|
4
|
+
import { apiUrl } from '../../util/index.js';
|
|
5
5
|
import { toKebabCase } from '../../util/string.js';
|
|
6
6
|
import { getContext, setContext } from 'svelte';
|
|
7
7
|
import { getValueAtPath, isObjectLiteral, setValueAtPath } from '../../util/object.js';
|
package/dist/panel/index.d.ts
CHANGED
|
@@ -4,15 +4,21 @@ import type { Snippet } from 'svelte';
|
|
|
4
4
|
import { Field } from './components/fields/index.js';
|
|
5
5
|
import Panel from './components/Root.svelte';
|
|
6
6
|
import Doc from './components/sections/document/Document.svelte';
|
|
7
|
+
import Button from './components/ui/button/button.svelte';
|
|
8
|
+
import Input from './components/ui/input/input.svelte';
|
|
9
|
+
import SpinLoader from './components/ui/spin-loader/SpinLoader.svelte';
|
|
7
10
|
import Area from './pages/area/Area.svelte';
|
|
8
11
|
import AreaVersionsDoc from './pages/area/AreaVersionsDoc.svelte';
|
|
12
|
+
import ForgotPassword from './pages/auth/forgot-password/ForgotPassword.svelte';
|
|
13
|
+
import ResetPassword from './pages/auth/reset-password/ResetPassword.svelte';
|
|
14
|
+
import SignIn from './pages/auth/sign-in/SignIn.svelte';
|
|
9
15
|
import CollectionDoc from './pages/collection-document/CollectionDocument.svelte';
|
|
10
16
|
import CollectionDocVersions from './pages/collection-document/CollectionDocVersions.svelte';
|
|
11
17
|
import Collection from './pages/collection/Collection.svelte';
|
|
12
18
|
import Dashboard from './pages/dashboard/Dashboard.svelte';
|
|
13
19
|
import Live from './pages/live/Live.svelte';
|
|
14
20
|
import type { Route } from './types.js';
|
|
15
|
-
export { Area, AreaVersionsDoc, Collection, CollectionDoc, CollectionDocVersions, Dashboard, Doc, Field, Live, Panel };
|
|
21
|
+
export { Area, AreaVersionsDoc, Button, Collection, CollectionDoc, CollectionDocVersions, Dashboard, Doc, Field, ForgotPassword, Input, Live, Panel, ResetPassword, SignIn, SpinLoader };
|
|
16
22
|
export type { DocumentFormContext } from './context/documentForm.svelte.js';
|
|
17
23
|
export type CollectionProps = {
|
|
18
24
|
data: {
|
|
@@ -48,3 +54,5 @@ export type CollectionDocData<V extends boolean = boolean> = DocVersions<V> & Ba
|
|
|
48
54
|
export type AreaDocData<V extends boolean = boolean> = DocVersions<V> & BaseDocData & {
|
|
49
55
|
operation: 'update';
|
|
50
56
|
};
|
|
57
|
+
export type CollectionDocumentDataWithVersions = CollectionDocData<true>;
|
|
58
|
+
export type AreaDataWithVersions = AreaDocData<true>;
|
package/dist/panel/index.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { Field } from './components/fields/index.js';
|
|
2
2
|
import Panel from './components/Root.svelte';
|
|
3
3
|
import Doc from './components/sections/document/Document.svelte';
|
|
4
|
+
import Button from './components/ui/button/button.svelte';
|
|
5
|
+
import Input from './components/ui/input/input.svelte';
|
|
6
|
+
import SpinLoader from './components/ui/spin-loader/SpinLoader.svelte';
|
|
4
7
|
import Area from './pages/area/Area.svelte';
|
|
5
8
|
import AreaVersionsDoc from './pages/area/AreaVersionsDoc.svelte';
|
|
9
|
+
import ForgotPassword from './pages/auth/forgot-password/ForgotPassword.svelte';
|
|
10
|
+
import ResetPassword from './pages/auth/reset-password/ResetPassword.svelte';
|
|
11
|
+
import SignIn from './pages/auth/sign-in/SignIn.svelte';
|
|
6
12
|
import CollectionDoc from './pages/collection-document/CollectionDocument.svelte';
|
|
7
13
|
import CollectionDocVersions from './pages/collection-document/CollectionDocVersions.svelte';
|
|
8
14
|
import Collection from './pages/collection/Collection.svelte';
|
|
@@ -10,4 +16,4 @@ import Dashboard from './pages/dashboard/Dashboard.svelte';
|
|
|
10
16
|
import Live from './pages/live/Live.svelte';
|
|
11
17
|
export {
|
|
12
18
|
// Components
|
|
13
|
-
Area, AreaVersionsDoc, Collection, CollectionDoc, CollectionDocVersions, Dashboard, Doc, Field, Live, Panel };
|
|
19
|
+
Area, AreaVersionsDoc, Button, Collection, CollectionDoc, CollectionDocVersions, Dashboard, Doc, Field, ForgotPassword, Input, Live, Panel, ResetPassword, SignIn, SpinLoader };
|
|
@@ -1,21 +1,2 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
export default function (slug: AreaSlug): {
|
|
4
|
-
update: (event: RequestEvent) => Promise<import("@sveltejs/kit").ActionFailure<{
|
|
5
|
-
form: Record<string, any>;
|
|
6
|
-
errors: import("../../types.js").FormErrors;
|
|
7
|
-
}> | import("@sveltejs/kit").ActionFailure<{
|
|
8
|
-
form: Record<string, any>;
|
|
9
|
-
errors: {
|
|
10
|
-
email: string;
|
|
11
|
-
};
|
|
12
|
-
}> | import("@sveltejs/kit").ActionFailure<{
|
|
13
|
-
form: {};
|
|
14
|
-
errors: {
|
|
15
|
-
_form: string;
|
|
16
|
-
};
|
|
17
|
-
}> | {
|
|
18
|
-
document: unknown;
|
|
19
|
-
message: string;
|
|
20
|
-
}>;
|
|
21
|
-
};
|
|
1
|
+
import { type Actions } from '@sveltejs/kit';
|
|
2
|
+
export declare const areaFormActions: Actions;
|
|
@@ -6,33 +6,34 @@ import { trycatch } from '../../../util/function.js';
|
|
|
6
6
|
import { toKebabCase } from '../../../util/string.js';
|
|
7
7
|
import { redirect } from '@sveltejs/kit';
|
|
8
8
|
import { t__ } from '../../../core/i18n/index.js';
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
9
|
+
export const areaFormActions = {
|
|
10
|
+
update: async (event) => {
|
|
11
|
+
const { rime, locale } = event.locals;
|
|
12
|
+
const slug = (event.params.slug || '');
|
|
13
|
+
const versionId = event.url.searchParams.get(PARAMS.VERSION_ID) || undefined;
|
|
14
|
+
const draft = event.url.searchParams.get(PARAMS.DRAFT) === 'true';
|
|
15
|
+
const [extractError, data] = await trycatch(() => extractData(event.request));
|
|
16
|
+
if (extractError) {
|
|
17
|
+
return handleError(extractError, { context: ERROR_CONTEXT.ACTION });
|
|
18
|
+
}
|
|
19
|
+
const [error, document] = await trycatch(() => rime.area(slug).update({
|
|
20
|
+
data,
|
|
21
|
+
versionId,
|
|
22
|
+
draft,
|
|
23
|
+
locale
|
|
24
|
+
}));
|
|
25
|
+
if (error) {
|
|
26
|
+
return handleError(error, { context: ERROR_CONTEXT.ACTION });
|
|
27
|
+
}
|
|
28
|
+
if (draft && 'versionId' in document) {
|
|
29
|
+
const referer = event.request.headers.get('referer');
|
|
30
|
+
if (referer && referer.includes('/versions')) {
|
|
31
|
+
return redirect(303, `${panelUrl(toKebabCase(slug))}/versions?versionId=${document.versionId}`);
|
|
24
32
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (referer && referer.includes('/versions')) {
|
|
28
|
-
return redirect(303, `${panelUrl(toKebabCase(slug))}/versions?versionId=${document.versionId}`);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
return redirect(303, `${panelUrl(toKebabCase(slug))}?versionId=${document.versionId}`);
|
|
32
|
-
}
|
|
33
|
+
else {
|
|
34
|
+
return redirect(303, `${panelUrl(toKebabCase(slug))}?versionId=${document.versionId}`);
|
|
33
35
|
}
|
|
34
|
-
return { document, message: t__('common.doc_updated') };
|
|
35
36
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
37
|
+
return { document, message: t__('common.doc_updated') };
|
|
38
|
+
}
|
|
39
|
+
};
|
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Route } from '../../types.js';
|
|
1
|
+
import type { AreaDocData } from '../../index.js';
|
|
3
2
|
import type { ServerLoadEvent } from '@sveltejs/kit';
|
|
4
|
-
export
|
|
5
|
-
aria: Partial<Route>[];
|
|
6
|
-
doc: import("../../../core/types/doc.js").GenericDoc;
|
|
7
|
-
status: 200;
|
|
8
|
-
readOnly: boolean;
|
|
9
|
-
} & {
|
|
10
|
-
operation: "update";
|
|
11
|
-
}) | ({
|
|
12
|
-
aria: Partial<Route>[];
|
|
13
|
-
doc: {};
|
|
14
|
-
status: 401;
|
|
15
|
-
readOnly: true;
|
|
16
|
-
} & {
|
|
17
|
-
operation: "update";
|
|
18
|
-
})>;
|
|
3
|
+
export declare function areaLoad<V extends boolean = boolean>(event: ServerLoadEvent, withVersions?: V): Promise<AreaDocData<V>>;
|