katecms 0.0.0-stage → 1.0.0-beta.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 +5 -3
- package/dist/module.d.mts +93 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +579 -0
- package/dist/runtime/assets/img/katecms-logo.svg +17 -0
- package/dist/runtime/composables/getCollection.d.ts +62 -0
- package/dist/runtime/composables/getCollection.js +167 -0
- package/dist/runtime/composables/getOptions.d.ts +22 -0
- package/dist/runtime/composables/getOptions.js +22 -0
- package/dist/runtime/composables/getQueryCollection.d.ts +95 -0
- package/dist/runtime/composables/getQueryCollection.js +199 -0
- package/dist/runtime/composables/getTerms.d.ts +79 -0
- package/dist/runtime/composables/getTerms.js +148 -0
- package/dist/runtime/composables/useAuth.d.ts +14 -0
- package/dist/runtime/composables/useAuth.js +33 -0
- package/dist/runtime/composables/useAuthCooldown.d.ts +6 -0
- package/dist/runtime/composables/useAuthCooldown.js +44 -0
- package/dist/runtime/composables/useCmsPaths.d.ts +15 -0
- package/dist/runtime/composables/useCmsPaths.js +21 -0
- package/dist/runtime/composables/useKateCmsExtensions.d.ts +49 -0
- package/dist/runtime/composables/useKateCmsExtensions.js +29 -0
- package/dist/runtime/composables/useMediaLibrary.d.ts +84 -0
- package/dist/runtime/composables/useMediaLibrary.js +140 -0
- package/dist/runtime/composables/useMenuAccess.d.ts +8 -0
- package/dist/runtime/composables/useMenuAccess.js +16 -0
- package/dist/runtime/internal/admin/AdminHeader.d.vue.ts +24 -0
- package/dist/runtime/internal/admin/AdminHeader.vue +91 -0
- package/dist/runtime/internal/admin/AdminHeader.vue.d.ts +24 -0
- package/dist/runtime/internal/admin/AppMenu.d.vue.ts +3 -0
- package/dist/runtime/internal/admin/AppMenu.vue +244 -0
- package/dist/runtime/internal/admin/AppMenu.vue.d.ts +3 -0
- package/dist/runtime/internal/admin/AppUser.d.vue.ts +3 -0
- package/dist/runtime/internal/admin/AppUser.vue +227 -0
- package/dist/runtime/internal/admin/AppUser.vue.d.ts +3 -0
- package/dist/runtime/internal/admin/CollectionEntryForm.d.vue.ts +41 -0
- package/dist/runtime/internal/admin/CollectionEntryForm.vue +916 -0
- package/dist/runtime/internal/admin/CollectionEntryForm.vue.d.ts +41 -0
- package/dist/runtime/internal/admin/ConfirmDialog.d.vue.ts +28 -0
- package/dist/runtime/internal/admin/ConfirmDialog.vue +136 -0
- package/dist/runtime/internal/admin/ConfirmDialog.vue.d.ts +28 -0
- package/dist/runtime/internal/admin/DictionaryTermForm.d.vue.ts +33 -0
- package/dist/runtime/internal/admin/DictionaryTermForm.vue +328 -0
- package/dist/runtime/internal/admin/DictionaryTermForm.vue.d.ts +33 -0
- package/dist/runtime/internal/admin/EntryRevisions.d.vue.ts +15 -0
- package/dist/runtime/internal/admin/EntryRevisions.vue +125 -0
- package/dist/runtime/internal/admin/EntryRevisions.vue.d.ts +15 -0
- package/dist/runtime/internal/admin/MediaLibraryFilters.d.vue.ts +16 -0
- package/dist/runtime/internal/admin/MediaLibraryFilters.vue +153 -0
- package/dist/runtime/internal/admin/MediaLibraryFilters.vue.d.ts +16 -0
- package/dist/runtime/internal/admin/MediaLibraryModal.d.vue.ts +65 -0
- package/dist/runtime/internal/admin/MediaLibraryModal.vue +451 -0
- package/dist/runtime/internal/admin/MediaLibraryModal.vue.d.ts +65 -0
- package/dist/runtime/internal/admin/OptionPageForm.d.vue.ts +26 -0
- package/dist/runtime/internal/admin/OptionPageForm.vue +222 -0
- package/dist/runtime/internal/admin/OptionPageForm.vue.d.ts +26 -0
- package/dist/runtime/internal/admin/UserAvatarField.d.vue.ts +12 -0
- package/dist/runtime/internal/admin/UserAvatarField.vue +305 -0
- package/dist/runtime/internal/admin/UserAvatarField.vue.d.ts +12 -0
- package/dist/runtime/internal/fields/AccordionField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/AccordionField.vue +220 -0
- package/dist/runtime/internal/fields/AccordionField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/ButtonGroupField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/ButtonGroupField.vue +109 -0
- package/dist/runtime/internal/fields/ButtonGroupField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/CheckboxField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/CheckboxField.vue +190 -0
- package/dist/runtime/internal/fields/CheckboxField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/ColorPickerField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/ColorPickerField.vue +791 -0
- package/dist/runtime/internal/fields/ColorPickerField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/DatePickerField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/DatePickerField.vue +26 -0
- package/dist/runtime/internal/fields/DatePickerField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/DateTimePickerField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/DateTimePickerField.vue +26 -0
- package/dist/runtime/internal/fields/DateTimePickerField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/DictionaryField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/DictionaryField.vue +345 -0
- package/dist/runtime/internal/fields/DictionaryField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/EmailField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/EmailField.vue +21 -0
- package/dist/runtime/internal/fields/EmailField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/FileField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/FileField.vue +408 -0
- package/dist/runtime/internal/fields/FileField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/FlexibleContentField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/FlexibleContentField.vue +1114 -0
- package/dist/runtime/internal/fields/FlexibleContentField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/GalleryField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/GalleryField.vue +584 -0
- package/dist/runtime/internal/fields/GalleryField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/GroupField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/GroupField.vue +111 -0
- package/dist/runtime/internal/fields/GroupField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/ImageField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/ImageField.vue +638 -0
- package/dist/runtime/internal/fields/ImageField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/ImageSelectField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/ImageSelectField.vue +179 -0
- package/dist/runtime/internal/fields/ImageSelectField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/LinkField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/LinkField.vue +303 -0
- package/dist/runtime/internal/fields/LinkField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/NumberField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/NumberField.vue +25 -0
- package/dist/runtime/internal/fields/NumberField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/OembedField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/OembedField.vue +161 -0
- package/dist/runtime/internal/fields/OembedField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/OpenStreetMapField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/OpenStreetMapField.vue +1502 -0
- package/dist/runtime/internal/fields/OpenStreetMapField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/PageLinkField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/PageLinkField.vue +153 -0
- package/dist/runtime/internal/fields/PageLinkField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/PasswordField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/PasswordField.vue +108 -0
- package/dist/runtime/internal/fields/PasswordField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/PostObjectField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/PostObjectField.vue +151 -0
- package/dist/runtime/internal/fields/PostObjectField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/RadioField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/RadioField.vue +163 -0
- package/dist/runtime/internal/fields/RadioField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/RangeField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/RangeField.vue +48 -0
- package/dist/runtime/internal/fields/RangeField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/RelationshipField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/RelationshipField.vue +525 -0
- package/dist/runtime/internal/fields/RelationshipField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/RepeaterField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/RepeaterField.vue +856 -0
- package/dist/runtime/internal/fields/RepeaterField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/SelectField.d.vue.ts +21 -0
- package/dist/runtime/internal/fields/SelectField.vue +101 -0
- package/dist/runtime/internal/fields/SelectField.vue.d.ts +21 -0
- package/dist/runtime/internal/fields/SeparatorField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/SeparatorField.vue +63 -0
- package/dist/runtime/internal/fields/SeparatorField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/TabField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/TabField.vue +210 -0
- package/dist/runtime/internal/fields/TabField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/TextField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/TextField.vue +22 -0
- package/dist/runtime/internal/fields/TextField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/TextareaField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/TextareaField.vue +62 -0
- package/dist/runtime/internal/fields/TextareaField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/TimePickerField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/TimePickerField.vue +24 -0
- package/dist/runtime/internal/fields/TimePickerField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/TrueFalseField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/TrueFalseField.vue +151 -0
- package/dist/runtime/internal/fields/TrueFalseField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/UrlField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/UrlField.vue +21 -0
- package/dist/runtime/internal/fields/UrlField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/UserField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/UserField.vue +164 -0
- package/dist/runtime/internal/fields/UserField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/WysiwygField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/WysiwygField.vue +971 -0
- package/dist/runtime/internal/fields/WysiwygField.vue.d.ts +0 -0
- package/dist/runtime/internal/parts/DateTimeControl.d.vue.ts +90 -0
- package/dist/runtime/internal/parts/DateTimeControl.vue +568 -0
- package/dist/runtime/internal/parts/DateTimeControl.vue.d.ts +90 -0
- package/dist/runtime/internal/parts/FieldAddon.d.vue.ts +0 -0
- package/dist/runtime/internal/parts/FieldAddon.vue +43 -0
- package/dist/runtime/internal/parts/FieldAddon.vue.d.ts +0 -0
- package/dist/runtime/internal/parts/FieldInstructions.d.vue.ts +0 -0
- package/dist/runtime/internal/parts/FieldInstructions.vue +24 -0
- package/dist/runtime/internal/parts/FieldInstructions.vue.d.ts +0 -0
- package/dist/runtime/internal/parts/FieldLabel.d.vue.ts +0 -0
- package/dist/runtime/internal/parts/FieldLabel.vue +40 -0
- package/dist/runtime/internal/parts/FieldLabel.vue.d.ts +0 -0
- package/dist/runtime/internal/parts/FieldWrapper.d.vue.ts +0 -0
- package/dist/runtime/internal/parts/FieldWrapper.vue +47 -0
- package/dist/runtime/internal/parts/FieldWrapper.vue.d.ts +0 -0
- package/dist/runtime/internal/parts/ImageCropper.d.vue.ts +17 -0
- package/dist/runtime/internal/parts/ImageCropper.vue +363 -0
- package/dist/runtime/internal/parts/ImageCropper.vue.d.ts +17 -0
- package/dist/runtime/internal/parts/InputControl.d.vue.ts +0 -0
- package/dist/runtime/internal/parts/InputControl.vue +163 -0
- package/dist/runtime/internal/parts/InputControl.vue.d.ts +0 -0
- package/dist/runtime/internal/ui/UiButton.d.vue.ts +35 -0
- package/dist/runtime/internal/ui/UiButton.vue +204 -0
- package/dist/runtime/internal/ui/UiButton.vue.d.ts +35 -0
- package/dist/runtime/internal/ui/UiNotice.d.vue.ts +40 -0
- package/dist/runtime/internal/ui/UiNotice.vue +253 -0
- package/dist/runtime/internal/ui/UiNotice.vue.d.ts +40 -0
- package/dist/runtime/internal/ui/UiSelect.d.vue.ts +61 -0
- package/dist/runtime/internal/ui/UiSelect.vue +1212 -0
- package/dist/runtime/internal/ui/UiSelect.vue.d.ts +61 -0
- package/dist/runtime/middleware/auth-guard.d.ts +9 -0
- package/dist/runtime/middleware/auth-guard.js +37 -0
- package/dist/runtime/pages/admin/collections/[id].d.vue.ts +3 -0
- package/dist/runtime/pages/admin/collections/[id].vue +423 -0
- package/dist/runtime/pages/admin/collections/[id].vue.d.ts +3 -0
- package/dist/runtime/pages/admin/collections/create.d.vue.ts +3 -0
- package/dist/runtime/pages/admin/collections/create.vue +179 -0
- package/dist/runtime/pages/admin/collections/create.vue.d.ts +3 -0
- package/dist/runtime/pages/admin/collections/index.d.vue.ts +3 -0
- package/dist/runtime/pages/admin/collections/index.vue +828 -0
- package/dist/runtime/pages/admin/collections/index.vue.d.ts +3 -0
- package/dist/runtime/pages/admin/demo-fields.d.vue.ts +3 -0
- package/dist/runtime/pages/admin/demo-fields.vue +1327 -0
- package/dist/runtime/pages/admin/demo-fields.vue.d.ts +3 -0
- package/dist/runtime/pages/admin/dictionaries/[id].d.vue.ts +3 -0
- package/dist/runtime/pages/admin/dictionaries/[id].vue +213 -0
- package/dist/runtime/pages/admin/dictionaries/[id].vue.d.ts +3 -0
- package/dist/runtime/pages/admin/dictionaries/index.d.vue.ts +3 -0
- package/dist/runtime/pages/admin/dictionaries/index.vue +387 -0
- package/dist/runtime/pages/admin/dictionaries/index.vue.d.ts +3 -0
- package/dist/runtime/pages/admin/index.d.vue.ts +3 -0
- package/dist/runtime/pages/admin/index.vue +138 -0
- package/dist/runtime/pages/admin/index.vue.d.ts +3 -0
- package/dist/runtime/pages/admin/login.d.vue.ts +3 -0
- package/dist/runtime/pages/admin/login.vue +373 -0
- package/dist/runtime/pages/admin/login.vue.d.ts +3 -0
- package/dist/runtime/pages/admin/media.d.vue.ts +3 -0
- package/dist/runtime/pages/admin/media.vue +1054 -0
- package/dist/runtime/pages/admin/media.vue.d.ts +3 -0
- package/dist/runtime/pages/admin/options/[page].d.vue.ts +3 -0
- package/dist/runtime/pages/admin/options/[page].vue +151 -0
- package/dist/runtime/pages/admin/options/[page].vue.d.ts +3 -0
- package/dist/runtime/pages/admin/register.d.vue.ts +3 -0
- package/dist/runtime/pages/admin/register.vue +391 -0
- package/dist/runtime/pages/admin/register.vue.d.ts +3 -0
- package/dist/runtime/pages/admin/users/[id].d.vue.ts +3 -0
- package/dist/runtime/pages/admin/users/[id].vue +337 -0
- package/dist/runtime/pages/admin/users/[id].vue.d.ts +3 -0
- package/dist/runtime/pages/admin/users/create.d.vue.ts +3 -0
- package/dist/runtime/pages/admin/users/create.vue +201 -0
- package/dist/runtime/pages/admin/users/create.vue.d.ts +3 -0
- package/dist/runtime/pages/admin/users/index.d.vue.ts +3 -0
- package/dist/runtime/pages/admin/users/index.vue +329 -0
- package/dist/runtime/pages/admin/users/index.vue.d.ts +3 -0
- package/dist/runtime/pages/index.d.vue.ts +3 -0
- package/dist/runtime/pages/index.vue +399 -0
- package/dist/runtime/pages/index.vue.d.ts +3 -0
- package/dist/runtime/server/api/_katecms/auth/login.post.d.ts +5 -0
- package/dist/runtime/server/api/_katecms/auth/login.post.js +44 -0
- package/dist/runtime/server/api/_katecms/auth/logout.post.d.ts +4 -0
- package/dist/runtime/server/api/_katecms/auth/logout.post.js +6 -0
- package/dist/runtime/server/api/_katecms/auth/register.post.d.ts +19 -0
- package/dist/runtime/server/api/_katecms/auth/register.post.js +83 -0
- package/dist/runtime/server/api/_katecms/auth/state.get.d.ts +9 -0
- package/dist/runtime/server/api/_katecms/auth/state.get.js +12 -0
- package/dist/runtime/server/api/_katecms/collections/[collection]/[id].delete.d.ts +15 -0
- package/dist/runtime/server/api/_katecms/collections/[collection]/[id].delete.js +59 -0
- package/dist/runtime/server/api/_katecms/collections/[collection]/[id].get.d.ts +4 -0
- package/dist/runtime/server/api/_katecms/collections/[collection]/[id].get.js +50 -0
- package/dist/runtime/server/api/_katecms/collections/[collection]/[id].patch.d.ts +4 -0
- package/dist/runtime/server/api/_katecms/collections/[collection]/[id].patch.js +130 -0
- package/dist/runtime/server/api/_katecms/collections/[collection]/revisions/[revisionId].post.d.ts +4 -0
- package/dist/runtime/server/api/_katecms/collections/[collection]/revisions/[revisionId].post.js +123 -0
- package/dist/runtime/server/api/_katecms/collections/[collection]/revisions.get.d.ts +6 -0
- package/dist/runtime/server/api/_katecms/collections/[collection]/revisions.get.js +31 -0
- package/dist/runtime/server/api/_katecms/collections/[collection].get.d.ts +8 -0
- package/dist/runtime/server/api/_katecms/collections/[collection].get.js +135 -0
- package/dist/runtime/server/api/_katecms/collections/[collection].post.d.ts +4 -0
- package/dist/runtime/server/api/_katecms/collections/[collection].post.js +91 -0
- package/dist/runtime/server/api/_katecms/dictionaries/[dictionary]/[id].delete.d.ts +7 -0
- package/dist/runtime/server/api/_katecms/dictionaries/[dictionary]/[id].delete.js +31 -0
- package/dist/runtime/server/api/_katecms/dictionaries/[dictionary]/[id].get.d.ts +4 -0
- package/dist/runtime/server/api/_katecms/dictionaries/[dictionary]/[id].get.js +45 -0
- package/dist/runtime/server/api/_katecms/dictionaries/[dictionary]/[id].patch.d.ts +4 -0
- package/dist/runtime/server/api/_katecms/dictionaries/[dictionary]/[id].patch.js +83 -0
- package/dist/runtime/server/api/_katecms/dictionaries/[dictionary].get.d.ts +4 -0
- package/dist/runtime/server/api/_katecms/dictionaries/[dictionary].get.js +38 -0
- package/dist/runtime/server/api/_katecms/dictionaries/[dictionary].post.d.ts +4 -0
- package/dist/runtime/server/api/_katecms/dictionaries/[dictionary].post.js +64 -0
- package/dist/runtime/server/api/_katecms/media/[id]/regenerate.post.d.ts +8 -0
- package/dist/runtime/server/api/_katecms/media/[id]/regenerate.post.js +30 -0
- package/dist/runtime/server/api/_katecms/media/[id].delete.d.ts +7 -0
- package/dist/runtime/server/api/_katecms/media/[id].delete.js +22 -0
- package/dist/runtime/server/api/_katecms/media/[id].get.d.ts +9 -0
- package/dist/runtime/server/api/_katecms/media/[id].get.js +17 -0
- package/dist/runtime/server/api/_katecms/media/[id].patch.d.ts +6 -0
- package/dist/runtime/server/api/_katecms/media/[id].patch.js +48 -0
- package/dist/runtime/server/api/_katecms/media/index.get.d.ts +5 -0
- package/dist/runtime/server/api/_katecms/media/index.get.js +75 -0
- package/dist/runtime/server/api/_katecms/media/index.post.d.ts +9 -0
- package/dist/runtime/server/api/_katecms/media/index.post.js +84 -0
- package/dist/runtime/server/api/_katecms/media/regenerate.post.d.ts +7 -0
- package/dist/runtime/server/api/_katecms/media/regenerate.post.js +30 -0
- package/dist/runtime/server/api/_katecms/menu.get.d.ts +8 -0
- package/dist/runtime/server/api/_katecms/menu.get.js +14 -0
- package/dist/runtime/server/api/_katecms/oembed.get.d.ts +2 -0
- package/dist/runtime/server/api/_katecms/oembed.get.js +53 -0
- package/dist/runtime/server/api/_katecms/options/[page].get.d.ts +7 -0
- package/dist/runtime/server/api/_katecms/options/[page].get.js +28 -0
- package/dist/runtime/server/api/_katecms/options/[page].patch.d.ts +4 -0
- package/dist/runtime/server/api/_katecms/options/[page].patch.js +36 -0
- package/dist/runtime/server/api/_katecms/query.get.d.ts +24 -0
- package/dist/runtime/server/api/_katecms/query.get.js +270 -0
- package/dist/runtime/server/api/_katecms/relation/entries.get.d.ts +17 -0
- package/dist/runtime/server/api/_katecms/relation/entries.get.js +74 -0
- package/dist/runtime/server/api/_katecms/relation/terms.get.d.ts +17 -0
- package/dist/runtime/server/api/_katecms/relation/terms.get.js +51 -0
- package/dist/runtime/server/api/_katecms/resolve.get.d.ts +17 -0
- package/dist/runtime/server/api/_katecms/resolve.get.js +116 -0
- package/dist/runtime/server/api/_katecms/terms.get.d.ts +20 -0
- package/dist/runtime/server/api/_katecms/terms.get.js +201 -0
- package/dist/runtime/server/api/_katecms/users/[id].delete.d.ts +11 -0
- package/dist/runtime/server/api/_katecms/users/[id].delete.js +45 -0
- package/dist/runtime/server/api/_katecms/users/[id].patch.d.ts +19 -0
- package/dist/runtime/server/api/_katecms/users/[id].patch.js +129 -0
- package/dist/runtime/server/api/_katecms/users.get.d.ts +10 -0
- package/dist/runtime/server/api/_katecms/users.get.js +34 -0
- package/dist/runtime/server/api/_katecms/users.post.d.ts +10 -0
- package/dist/runtime/server/api/_katecms/users.post.js +62 -0
- package/dist/runtime/server/api/uploads/[...key].get.d.ts +3 -0
- package/dist/runtime/server/api/uploads/[...key].get.js +28 -0
- package/dist/runtime/server/kit.d.ts +5 -0
- package/dist/runtime/server/kit.js +5 -0
- package/dist/runtime/server/middleware/admin-headers.d.ts +3 -0
- package/dist/runtime/server/middleware/admin-headers.js +12 -0
- package/dist/runtime/server/plugins/auto-migrate.d.ts +2 -0
- package/dist/runtime/server/plugins/auto-migrate.js +45 -0
- package/dist/runtime/server/tsconfig.json +3 -0
- package/dist/runtime/server/utils/auth-attempts.d.ts +22 -0
- package/dist/runtime/server/utils/auth-attempts.js +42 -0
- package/dist/runtime/server/utils/auth-rate-limit.d.ts +11 -0
- package/dist/runtime/server/utils/auth-rate-limit.js +36 -0
- package/dist/runtime/server/utils/client-address.d.ts +16 -0
- package/dist/runtime/server/utils/client-address.js +23 -0
- package/dist/runtime/server/utils/collections.d.ts +42 -0
- package/dist/runtime/server/utils/collections.js +300 -0
- package/dist/runtime/server/utils/db.d.ts +3 -0
- package/dist/runtime/server/utils/db.js +25 -0
- package/dist/runtime/server/utils/dictionaries.d.ts +53 -0
- package/dist/runtime/server/utils/dictionaries.js +301 -0
- package/dist/runtime/server/utils/media-list.d.ts +18 -0
- package/dist/runtime/server/utils/media-list.js +84 -0
- package/dist/runtime/server/utils/media.d.ts +12 -0
- package/dist/runtime/server/utils/media.js +77 -0
- package/dist/runtime/server/utils/oembed-fetch.d.ts +4 -0
- package/dist/runtime/server/utils/oembed-fetch.js +142 -0
- package/dist/runtime/server/utils/options.d.ts +17 -0
- package/dist/runtime/server/utils/options.js +66 -0
- package/dist/runtime/server/utils/permissions.d.ts +13 -0
- package/dist/runtime/server/utils/permissions.js +20 -0
- package/dist/runtime/server/utils/public-fields-query.d.ts +6 -0
- package/dist/runtime/server/utils/public-fields-query.js +8 -0
- package/dist/runtime/server/utils/public-term.d.ts +8 -0
- package/dist/runtime/server/utils/public-term.js +80 -0
- package/dist/runtime/server/utils/regenerate.d.ts +12 -0
- package/dist/runtime/server/utils/regenerate.js +40 -0
- package/dist/runtime/server/utils/relation.d.ts +18 -0
- package/dist/runtime/server/utils/relation.js +77 -0
- package/dist/runtime/server/utils/request-address.d.ts +6 -0
- package/dist/runtime/server/utils/request-address.js +10 -0
- package/dist/runtime/server/utils/revisions.d.ts +20 -0
- package/dist/runtime/server/utils/revisions.js +172 -0
- package/dist/runtime/server/utils/session.d.ts +18 -0
- package/dist/runtime/server/utils/session.js +71 -0
- package/dist/runtime/server/utils/upload-headers.d.ts +2 -0
- package/dist/runtime/server/utils/upload-headers.js +30 -0
- package/dist/runtime/server/utils/users.d.ts +13 -0
- package/dist/runtime/server/utils/users.js +47 -0
- package/dist/runtime/utils/admin-users.d.ts +20 -0
- package/dist/runtime/utils/admin-users.js +19 -0
- package/dist/runtime/utils/auth-error.d.ts +6 -0
- package/dist/runtime/utils/auth-error.js +11 -0
- package/dist/runtime/utils/cms-paths.d.ts +5 -0
- package/dist/runtime/utils/cms-paths.js +13 -0
- package/dist/runtime/utils/collections.d.ts +176 -0
- package/dist/runtime/utils/collections.js +30 -0
- package/dist/runtime/utils/dictionaries.d.ts +65 -0
- package/dist/runtime/utils/dictionaries.js +14 -0
- package/dist/runtime/utils/field-errors.d.ts +4 -0
- package/dist/runtime/utils/field-errors.js +9 -0
- package/dist/runtime/utils/field-values.d.ts +19 -0
- package/dist/runtime/utils/field-values.js +82 -0
- package/dist/runtime/utils/helpers.d.ts +4 -0
- package/dist/runtime/utils/helpers.js +20 -0
- package/dist/runtime/utils/media-library-query.d.ts +54 -0
- package/dist/runtime/utils/media-library-query.js +190 -0
- package/dist/runtime/utils/options.d.ts +19 -0
- package/dist/runtime/utils/options.js +3 -0
- package/dist/runtime/utils/preview.d.ts +22 -0
- package/dist/runtime/utils/preview.js +33 -0
- package/dist/runtime/utils/relation.d.ts +33 -0
- package/dist/runtime/utils/relation.js +23 -0
- package/dist/runtime/utils/slugify.d.ts +2 -0
- package/dist/runtime/utils/slugify.js +4 -0
- package/dist/types.d.mts +7 -0
- package/package.json +84 -3
- package/src/admin-components.ts +124 -0
- package/src/module.ts +592 -0
- package/src/runtime/assets/img/katecms-logo.svg +17 -0
- package/src/runtime/assets/styles/_functions.scss +70 -0
- package/src/runtime/assets/styles/_index.scss +3 -0
- package/src/runtime/assets/styles/_mixins.scss +256 -0
- package/src/runtime/assets/styles/_variables.scss +35 -0
- package/src/runtime/composables/getCollection.ts +253 -0
- package/src/runtime/composables/getOptions.ts +42 -0
- package/src/runtime/composables/getQueryCollection.ts +325 -0
- package/src/runtime/composables/getTerms.ts +231 -0
- package/src/runtime/composables/useAuth.ts +43 -0
- package/src/runtime/composables/useAuthCooldown.ts +52 -0
- package/src/runtime/composables/useCmsPaths.ts +24 -0
- package/src/runtime/composables/useKateCmsExtensions.ts +81 -0
- package/src/runtime/composables/useMediaLibrary.ts +168 -0
- package/src/runtime/composables/useMenuAccess.ts +25 -0
- package/src/runtime/internal/admin/AdminHeader.vue +106 -0
- package/src/runtime/internal/admin/AppMenu.vue +290 -0
- package/src/runtime/internal/admin/AppUser.vue +260 -0
- package/src/runtime/internal/admin/CollectionEntryForm.vue +1044 -0
- package/src/runtime/internal/admin/ConfirmDialog.vue +164 -0
- package/src/runtime/internal/admin/DictionaryTermForm.vue +400 -0
- package/src/runtime/internal/admin/EntryRevisions.vue +145 -0
- package/src/runtime/internal/admin/MediaLibraryFilters.vue +186 -0
- package/src/runtime/internal/admin/MediaLibraryModal.vue +526 -0
- package/src/runtime/internal/admin/OptionPageForm.vue +277 -0
- package/src/runtime/internal/admin/UserAvatarField.vue +337 -0
- package/src/runtime/internal/fields/AccordionField.vue +258 -0
- package/src/runtime/internal/fields/ButtonGroupField.vue +144 -0
- package/src/runtime/internal/fields/CheckboxField.vue +228 -0
- package/src/runtime/internal/fields/ColorPickerField.vue +926 -0
- package/src/runtime/internal/fields/DatePickerField.vue +33 -0
- package/src/runtime/internal/fields/DateTimePickerField.vue +33 -0
- package/src/runtime/internal/fields/DictionaryField.vue +403 -0
- package/src/runtime/internal/fields/EmailField.vue +28 -0
- package/src/runtime/internal/fields/FileField.vue +480 -0
- package/src/runtime/internal/fields/FlexibleContentField.vue +1296 -0
- package/src/runtime/internal/fields/GalleryField.vue +677 -0
- package/src/runtime/internal/fields/GroupField.vue +136 -0
- package/src/runtime/internal/fields/ImageField.vue +730 -0
- package/src/runtime/internal/fields/ImageSelectField.vue +213 -0
- package/src/runtime/internal/fields/LinkField.vue +338 -0
- package/src/runtime/internal/fields/NumberField.vue +32 -0
- package/src/runtime/internal/fields/OembedField.vue +187 -0
- package/src/runtime/internal/fields/OpenStreetMapField.vue +1716 -0
- package/src/runtime/internal/fields/PageLinkField.vue +186 -0
- package/src/runtime/internal/fields/PasswordField.vue +127 -0
- package/src/runtime/internal/fields/PostObjectField.vue +187 -0
- package/src/runtime/internal/fields/RadioField.vue +195 -0
- package/src/runtime/internal/fields/RangeField.vue +62 -0
- package/src/runtime/internal/fields/RelationshipField.vue +604 -0
- package/src/runtime/internal/fields/RepeaterField.vue +999 -0
- package/src/runtime/internal/fields/SelectField.vue +118 -0
- package/src/runtime/internal/fields/SeparatorField.vue +77 -0
- package/src/runtime/internal/fields/TabField.vue +249 -0
- package/src/runtime/internal/fields/TextField.vue +29 -0
- package/src/runtime/internal/fields/TextareaField.vue +61 -0
- package/src/runtime/internal/fields/TimePickerField.vue +31 -0
- package/src/runtime/internal/fields/TrueFalseField.vue +181 -0
- package/src/runtime/internal/fields/UrlField.vue +28 -0
- package/src/runtime/internal/fields/UserField.vue +203 -0
- package/src/runtime/internal/fields/WysiwygField.vue +1061 -0
- package/src/runtime/internal/parts/DateTimeControl.vue +657 -0
- package/src/runtime/internal/parts/FieldAddon.vue +60 -0
- package/src/runtime/internal/parts/FieldInstructions.vue +38 -0
- package/src/runtime/internal/parts/FieldLabel.vue +56 -0
- package/src/runtime/internal/parts/FieldWrapper.vue +63 -0
- package/src/runtime/internal/parts/ImageCropper.vue +415 -0
- package/src/runtime/internal/parts/InputControl.vue +189 -0
- package/src/runtime/internal/ui/UiButton.vue +274 -0
- package/src/runtime/internal/ui/UiNotice.vue +302 -0
- package/src/runtime/internal/ui/UiSelect.vue +1420 -0
- package/src/runtime/middleware/auth-guard.ts +52 -0
- package/src/runtime/pages/admin/collections/[id].vue +486 -0
- package/src/runtime/pages/admin/collections/create.vue +208 -0
- package/src/runtime/pages/admin/collections/index.vue +955 -0
- package/src/runtime/pages/admin/demo-fields.vue +1354 -0
- package/src/runtime/pages/admin/dictionaries/[id].vue +246 -0
- package/src/runtime/pages/admin/dictionaries/index.vue +438 -0
- package/src/runtime/pages/admin/index.vue +155 -0
- package/src/runtime/pages/admin/login.vue +159 -0
- package/src/runtime/pages/admin/media.vue +1176 -0
- package/src/runtime/pages/admin/options/[page].vue +174 -0
- package/src/runtime/pages/admin/register.vue +179 -0
- package/src/runtime/pages/admin/users/[id].vue +382 -0
- package/src/runtime/pages/admin/users/create.vue +232 -0
- package/src/runtime/pages/admin/users/index.vue +374 -0
- package/src/runtime/pages/index.vue +265 -0
- package/src/runtime/server/api/_katecms/auth/login.post.ts +62 -0
- package/src/runtime/server/api/_katecms/auth/logout.post.ts +7 -0
- package/src/runtime/server/api/_katecms/auth/register.post.ts +112 -0
- package/src/runtime/server/api/_katecms/auth/state.get.ts +19 -0
- package/src/runtime/server/api/_katecms/collections/[collection]/[id].delete.ts +77 -0
- package/src/runtime/server/api/_katecms/collections/[collection]/[id].get.ts +57 -0
- package/src/runtime/server/api/_katecms/collections/[collection]/[id].patch.ts +157 -0
- package/src/runtime/server/api/_katecms/collections/[collection]/revisions/[revisionId].post.ts +133 -0
- package/src/runtime/server/api/_katecms/collections/[collection]/revisions.get.ts +35 -0
- package/src/runtime/server/api/_katecms/collections/[collection].get.ts +177 -0
- package/src/runtime/server/api/_katecms/collections/[collection].post.ts +111 -0
- package/src/runtime/server/api/_katecms/dictionaries/[dictionary]/[id].delete.ts +37 -0
- package/src/runtime/server/api/_katecms/dictionaries/[dictionary]/[id].get.ts +51 -0
- package/src/runtime/server/api/_katecms/dictionaries/[dictionary]/[id].patch.ts +101 -0
- package/src/runtime/server/api/_katecms/dictionaries/[dictionary].get.ts +43 -0
- package/src/runtime/server/api/_katecms/dictionaries/[dictionary].post.ts +78 -0
- package/src/runtime/server/api/_katecms/media/[id]/regenerate.post.ts +39 -0
- package/src/runtime/server/api/_katecms/media/[id].delete.ts +28 -0
- package/src/runtime/server/api/_katecms/media/[id].get.ts +25 -0
- package/src/runtime/server/api/_katecms/media/[id].patch.ts +60 -0
- package/src/runtime/server/api/_katecms/media/index.get.ts +96 -0
- package/src/runtime/server/api/_katecms/media/index.post.ts +104 -0
- package/src/runtime/server/api/_katecms/media/regenerate.post.ts +38 -0
- package/src/runtime/server/api/_katecms/menu.get.ts +19 -0
- package/src/runtime/server/api/_katecms/oembed.get.ts +62 -0
- package/src/runtime/server/api/_katecms/options/[page].get.ts +35 -0
- package/src/runtime/server/api/_katecms/options/[page].patch.ts +46 -0
- package/src/runtime/server/api/_katecms/query.get.ts +332 -0
- package/src/runtime/server/api/_katecms/relation/entries.get.ts +98 -0
- package/src/runtime/server/api/_katecms/relation/terms.get.ts +61 -0
- package/src/runtime/server/api/_katecms/resolve.get.ts +148 -0
- package/src/runtime/server/api/_katecms/terms.get.ts +258 -0
- package/src/runtime/server/api/_katecms/users/[id].delete.ts +57 -0
- package/src/runtime/server/api/_katecms/users/[id].patch.ts +177 -0
- package/src/runtime/server/api/_katecms/users.get.ts +48 -0
- package/src/runtime/server/api/_katecms/users.post.ts +85 -0
- package/src/runtime/server/api/uploads/[...key].get.ts +33 -0
- package/src/runtime/server/kit.ts +5 -0
- package/src/runtime/server/middleware/admin-headers.ts +14 -0
- package/src/runtime/server/plugins/auto-migrate.ts +53 -0
- package/src/runtime/server/tsconfig.json +3 -0
- package/src/runtime/server/utils/auth-attempts.ts +71 -0
- package/src/runtime/server/utils/auth-rate-limit.ts +48 -0
- package/src/runtime/server/utils/client-address.ts +41 -0
- package/src/runtime/server/utils/collections.ts +381 -0
- package/src/runtime/server/utils/db.ts +36 -0
- package/src/runtime/server/utils/dictionaries.ts +397 -0
- package/src/runtime/server/utils/media-list.ts +131 -0
- package/src/runtime/server/utils/media.ts +94 -0
- package/src/runtime/server/utils/oembed-fetch.ts +157 -0
- package/src/runtime/server/utils/options.ts +86 -0
- package/src/runtime/server/utils/permissions.ts +44 -0
- package/src/runtime/server/utils/public-fields-query.ts +14 -0
- package/src/runtime/server/utils/public-term.ts +98 -0
- package/src/runtime/server/utils/regenerate.ts +56 -0
- package/src/runtime/server/utils/relation.ts +96 -0
- package/src/runtime/server/utils/request-address.ts +16 -0
- package/src/runtime/server/utils/revisions.ts +256 -0
- package/src/runtime/server/utils/session.ts +112 -0
- package/src/runtime/server/utils/upload-headers.ts +35 -0
- package/src/runtime/server/utils/users.ts +67 -0
- package/src/runtime/utils/admin-users.ts +43 -0
- package/src/runtime/utils/auth-error.ts +22 -0
- package/src/runtime/utils/cms-paths.ts +17 -0
- package/src/runtime/utils/collections.ts +228 -0
- package/src/runtime/utils/dictionaries.ts +89 -0
- package/src/runtime/utils/field-errors.ts +12 -0
- package/src/runtime/utils/field-values.ts +101 -0
- package/src/runtime/utils/helpers.ts +33 -0
- package/src/runtime/utils/media-library-query.ts +263 -0
- package/src/runtime/utils/options.ts +25 -0
- package/src/runtime/utils/preview.ts +56 -0
- package/src/runtime/utils/relation.ts +60 -0
- package/src/runtime/utils/slugify.ts +10 -0
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, nextTick, reactive, ref, watch } from 'vue'
|
|
3
|
+
import {
|
|
4
|
+
buildFormValues,
|
|
5
|
+
collectPanelDefaults,
|
|
6
|
+
collectVisibleValueKeys,
|
|
7
|
+
isLayoutOnlyFieldType,
|
|
8
|
+
isVisible,
|
|
9
|
+
validateRequiredFields,
|
|
10
|
+
} from '@katecms/core'
|
|
11
|
+
import type { Field, Fields } from '@katecms/core'
|
|
12
|
+
import { resolveField } from '../../utils/helpers'
|
|
13
|
+
import { provideKateCmsFieldValues } from '../../utils/field-values'
|
|
14
|
+
import { provideKateCmsFieldErrors } from '../../utils/field-errors'
|
|
15
|
+
import type { AdminOptionMeta } from '../../utils/options'
|
|
16
|
+
|
|
17
|
+
const props = withDefaults(defineProps<{
|
|
18
|
+
page: AdminOptionMeta
|
|
19
|
+
modelValue: Record<string, unknown>
|
|
20
|
+
saving?: boolean
|
|
21
|
+
error?: string | null
|
|
22
|
+
canUpdate?: boolean
|
|
23
|
+
formId?: string
|
|
24
|
+
}>(), {
|
|
25
|
+
saving: false,
|
|
26
|
+
error: null,
|
|
27
|
+
canUpdate: true,
|
|
28
|
+
formId: 'cms-options-form',
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
const emit = defineEmits<{
|
|
32
|
+
'update:modelValue': [value: Record<string, unknown>]
|
|
33
|
+
'submit': []
|
|
34
|
+
}>()
|
|
35
|
+
|
|
36
|
+
const rootClass = 'katecms-options-form'
|
|
37
|
+
|
|
38
|
+
const fieldDefs = computed(() => (props.page.fields ?? {}) as Fields)
|
|
39
|
+
const values = reactive<Record<string, unknown>>({})
|
|
40
|
+
provideKateCmsFieldValues(values)
|
|
41
|
+
|
|
42
|
+
const fieldErrors = ref<Record<string, string>>({})
|
|
43
|
+
const attemptedSubmit = ref(false)
|
|
44
|
+
provideKateCmsFieldErrors(fieldErrors)
|
|
45
|
+
|
|
46
|
+
const readOnly = computed(() => !props.canUpdate)
|
|
47
|
+
|
|
48
|
+
let syncingFromParent = false
|
|
49
|
+
|
|
50
|
+
function replaceValues(next: Record<string, unknown>) {
|
|
51
|
+
syncingFromParent = true
|
|
52
|
+
for (const key of Object.keys(values)) {
|
|
53
|
+
Reflect.deleteProperty(values, key)
|
|
54
|
+
}
|
|
55
|
+
Object.assign(values, next)
|
|
56
|
+
queueMicrotask(() => {
|
|
57
|
+
syncingFromParent = false
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
watch(
|
|
62
|
+
() => props.page.slug,
|
|
63
|
+
() => {
|
|
64
|
+
replaceValues({
|
|
65
|
+
...buildFormValues(fieldDefs.value),
|
|
66
|
+
...props.modelValue,
|
|
67
|
+
})
|
|
68
|
+
attemptedSubmit.value = false
|
|
69
|
+
fieldErrors.value = {}
|
|
70
|
+
},
|
|
71
|
+
{ immediate: true },
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
watch(
|
|
75
|
+
values,
|
|
76
|
+
() => {
|
|
77
|
+
if (syncingFromParent) {
|
|
78
|
+
return
|
|
79
|
+
}
|
|
80
|
+
emit('update:modelValue', { ...values })
|
|
81
|
+
},
|
|
82
|
+
{ deep: true },
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
const visibleFields = computed(() =>
|
|
86
|
+
Object.entries(fieldDefs.value).filter(([, field]) =>
|
|
87
|
+
isVisible(field.conditionalLogic, values),
|
|
88
|
+
),
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
const hiddenCache: Record<string, unknown> = {}
|
|
92
|
+
|
|
93
|
+
function restoreFieldValue(key: string, field: Field) {
|
|
94
|
+
if (isLayoutOnlyFieldType(field.type)) {
|
|
95
|
+
if (field.type === 'tab' || field.type === 'accordion') {
|
|
96
|
+
for (const [panelKey, panelDefault] of Object.entries(collectPanelDefaults(field))) {
|
|
97
|
+
if (!(panelKey in values)) {
|
|
98
|
+
values[panelKey] = panelKey in hiddenCache
|
|
99
|
+
? hiddenCache[panelKey]
|
|
100
|
+
: panelDefault
|
|
101
|
+
Reflect.deleteProperty(hiddenCache, panelKey)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
Reflect.deleteProperty(values, key)
|
|
106
|
+
return
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (!(key in values)) {
|
|
110
|
+
values[key] = key in hiddenCache
|
|
111
|
+
? hiddenCache[key]
|
|
112
|
+
: 'defaultValue' in field
|
|
113
|
+
? field.defaultValue
|
|
114
|
+
: field.type === 'group'
|
|
115
|
+
? undefined
|
|
116
|
+
: field.type === 'repeater' || field.type === 'flexible_content' || field.type === 'gallery'
|
|
117
|
+
? []
|
|
118
|
+
: field.type === 'open_street_map' && field.multiple
|
|
119
|
+
? []
|
|
120
|
+
: undefined
|
|
121
|
+
Reflect.deleteProperty(hiddenCache, key)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
watch(visibleFields, (visible) => {
|
|
126
|
+
const visibleKeys = collectVisibleValueKeys(visible)
|
|
127
|
+
|
|
128
|
+
for (const key of Object.keys(values)) {
|
|
129
|
+
if (!visibleKeys.has(key)) {
|
|
130
|
+
hiddenCache[key] = values[key]
|
|
131
|
+
Reflect.deleteProperty(values, key)
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
for (const [key, field] of visible) {
|
|
136
|
+
restoreFieldValue(key, field)
|
|
137
|
+
}
|
|
138
|
+
}, { immediate: true })
|
|
139
|
+
|
|
140
|
+
const canSubmit = computed(() => !readOnly.value && !props.saving)
|
|
141
|
+
|
|
142
|
+
function collectFieldErrors(): Record<string, string> {
|
|
143
|
+
const next: Record<string, string> = {}
|
|
144
|
+
for (const issue of validateRequiredFields(fieldDefs.value, values)) {
|
|
145
|
+
next[issue.key] = issue.message
|
|
146
|
+
}
|
|
147
|
+
return next
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function scrollToFirstError(errors: Record<string, string>) {
|
|
151
|
+
const key = Object.keys(errors)[0]
|
|
152
|
+
if (!key || typeof document === 'undefined') {
|
|
153
|
+
return
|
|
154
|
+
}
|
|
155
|
+
const target = document.querySelector(`[data-field-key="${CSS.escape(key)}"]`)
|
|
156
|
+
if (target instanceof HTMLElement) {
|
|
157
|
+
target.scrollIntoView({ block: 'center', behavior: 'smooth' })
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function validateForSubmit(): boolean {
|
|
162
|
+
if (!canSubmit.value) {
|
|
163
|
+
return false
|
|
164
|
+
}
|
|
165
|
+
attemptedSubmit.value = true
|
|
166
|
+
const errors = collectFieldErrors()
|
|
167
|
+
fieldErrors.value = errors
|
|
168
|
+
if (Object.keys(errors).length > 0) {
|
|
169
|
+
nextTick(() => scrollToFirstError(errors))
|
|
170
|
+
return false
|
|
171
|
+
}
|
|
172
|
+
return true
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function onSubmit() {
|
|
176
|
+
if (!validateForSubmit()) {
|
|
177
|
+
return
|
|
178
|
+
}
|
|
179
|
+
emit('submit')
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
defineExpose({ validateForSubmit })
|
|
183
|
+
|
|
184
|
+
watch(
|
|
185
|
+
values,
|
|
186
|
+
() => {
|
|
187
|
+
if (!attemptedSubmit.value) {
|
|
188
|
+
return
|
|
189
|
+
}
|
|
190
|
+
fieldErrors.value = collectFieldErrors()
|
|
191
|
+
},
|
|
192
|
+
{ deep: true },
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
const requiredNotice = computed(() => {
|
|
196
|
+
const messages = Object.values(fieldErrors.value)
|
|
197
|
+
if (messages.length === 0) {
|
|
198
|
+
return ''
|
|
199
|
+
}
|
|
200
|
+
if (messages.length === 1) {
|
|
201
|
+
return messages[0]
|
|
202
|
+
}
|
|
203
|
+
return 'Please fill in the required fields.'
|
|
204
|
+
})
|
|
205
|
+
</script>
|
|
206
|
+
|
|
207
|
+
<template>
|
|
208
|
+
<form
|
|
209
|
+
:id="formId"
|
|
210
|
+
:class="rootClass"
|
|
211
|
+
novalidate
|
|
212
|
+
@submit.prevent="onSubmit"
|
|
213
|
+
>
|
|
214
|
+
<KateCmsUiNotice
|
|
215
|
+
v-if="requiredNotice"
|
|
216
|
+
placement="static"
|
|
217
|
+
variant="danger"
|
|
218
|
+
:message="requiredNotice"
|
|
219
|
+
:closable="false"
|
|
220
|
+
/>
|
|
221
|
+
<KateCmsUiNotice
|
|
222
|
+
v-if="error"
|
|
223
|
+
placement="static"
|
|
224
|
+
variant="danger"
|
|
225
|
+
:message="error"
|
|
226
|
+
/>
|
|
227
|
+
|
|
228
|
+
<div
|
|
229
|
+
v-if="visibleFields.length"
|
|
230
|
+
:class="`${rootClass}__fields`"
|
|
231
|
+
>
|
|
232
|
+
<div
|
|
233
|
+
v-for="[key, field] in visibleFields"
|
|
234
|
+
:key="key"
|
|
235
|
+
:class="`${rootClass}__field`"
|
|
236
|
+
:style="field.columnWidth ? { width: `${field.columnWidth}%` } : undefined"
|
|
237
|
+
>
|
|
238
|
+
<component
|
|
239
|
+
:is="resolveField(field.type)"
|
|
240
|
+
v-model="values[key]"
|
|
241
|
+
:field-key="key"
|
|
242
|
+
:field="field"
|
|
243
|
+
/>
|
|
244
|
+
</div>
|
|
245
|
+
</div>
|
|
246
|
+
</form>
|
|
247
|
+
</template>
|
|
248
|
+
|
|
249
|
+
<style scoped lang="scss">
|
|
250
|
+
@use "../../assets/styles" as *;
|
|
251
|
+
|
|
252
|
+
$root: '.katecms-options-form';
|
|
253
|
+
|
|
254
|
+
@include katecms-wrapper {
|
|
255
|
+
#{$root} {
|
|
256
|
+
display: flex;
|
|
257
|
+
flex-direction: column;
|
|
258
|
+
gap: math-rem(14);
|
|
259
|
+
min-width: 0;
|
|
260
|
+
|
|
261
|
+
&__fields {
|
|
262
|
+
display: flex;
|
|
263
|
+
flex-wrap: wrap;
|
|
264
|
+
row-gap: math-rem(16);
|
|
265
|
+
margin-left: math-rem(-8);
|
|
266
|
+
margin-right: math-rem(-8);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
&__field {
|
|
270
|
+
padding-left: math-rem(8);
|
|
271
|
+
padding-right: math-rem(8);
|
|
272
|
+
width: 100%;
|
|
273
|
+
box-sizing: border-box;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
</style>
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, ref } from 'vue'
|
|
3
|
+
import { $fetch } from '#imports'
|
|
4
|
+
import { isImageMedia } from '@katecms/core'
|
|
5
|
+
import type { MediaItem } from '@katecms/core'
|
|
6
|
+
import { avatarSrc } from '../../utils/admin-users'
|
|
7
|
+
import { useMediaLibrary } from '../../composables/useMediaLibrary'
|
|
8
|
+
import type { MediaLibraryFilterState } from '../../utils/media-library-query'
|
|
9
|
+
|
|
10
|
+
/** Bound avatar media item (`null` when cleared / not set). */
|
|
11
|
+
const model = defineModel<MediaItem | null>({ default: null })
|
|
12
|
+
|
|
13
|
+
const rootClass = 'katecms-user-avatar-field'
|
|
14
|
+
|
|
15
|
+
const open = ref(false)
|
|
16
|
+
const {
|
|
17
|
+
items: library,
|
|
18
|
+
loading,
|
|
19
|
+
loadingMore,
|
|
20
|
+
hasMore,
|
|
21
|
+
filters,
|
|
22
|
+
months,
|
|
23
|
+
load: loadLibrary,
|
|
24
|
+
loadMore,
|
|
25
|
+
applyFilters,
|
|
26
|
+
prepend: prependLibrary,
|
|
27
|
+
} = useMediaLibrary(() => isImageMedia, { baseType: 'image' })
|
|
28
|
+
const uploading = ref(false)
|
|
29
|
+
const error = ref<string | null>(null)
|
|
30
|
+
const fileInput = ref<HTMLInputElement>()
|
|
31
|
+
|
|
32
|
+
const previewUrl = computed(() => avatarSrc(model.value))
|
|
33
|
+
|
|
34
|
+
async function fetchLibrary() {
|
|
35
|
+
error.value = null
|
|
36
|
+
try {
|
|
37
|
+
await loadLibrary({ resetFilters: true })
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
error.value = 'Could not load the media library.'
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async function onLibraryFilters(next: MediaLibraryFilterState) {
|
|
45
|
+
error.value = null
|
|
46
|
+
try {
|
|
47
|
+
await applyFilters(next)
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
error.value = 'Could not load the media library.'
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function onLoadMore() {
|
|
55
|
+
try {
|
|
56
|
+
await loadMore()
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
error.value = 'Could not load more files.'
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function openModal() {
|
|
64
|
+
open.value = true
|
|
65
|
+
error.value = null
|
|
66
|
+
fetchLibrary()
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function closeModal() {
|
|
70
|
+
if (uploading.value) {
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
open.value = false
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function applyAvatar(item: MediaItem | null) {
|
|
77
|
+
model.value = item
|
|
78
|
+
open.value = false
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function choose(item: MediaItem) {
|
|
82
|
+
applyAvatar(item)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function clearAvatar() {
|
|
86
|
+
model.value = null
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function triggerUpload() {
|
|
90
|
+
fileInput.value?.click()
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async function onFileChange(event: Event) {
|
|
94
|
+
const input = event.target as HTMLInputElement
|
|
95
|
+
const file = input.files?.[0]
|
|
96
|
+
input.value = ''
|
|
97
|
+
if (!file) {
|
|
98
|
+
return
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
uploading.value = true
|
|
102
|
+
error.value = null
|
|
103
|
+
try {
|
|
104
|
+
const form = new FormData()
|
|
105
|
+
form.append('file', file, file.name)
|
|
106
|
+
const data = await $fetch<{ media: MediaItem }>('/api/_katecms/media', {
|
|
107
|
+
method: 'POST',
|
|
108
|
+
body: form,
|
|
109
|
+
})
|
|
110
|
+
prependLibrary(data.media)
|
|
111
|
+
applyAvatar(data.media)
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
error.value = 'Could not upload the image.'
|
|
115
|
+
}
|
|
116
|
+
finally {
|
|
117
|
+
uploading.value = false
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
</script>
|
|
121
|
+
|
|
122
|
+
<template>
|
|
123
|
+
<div :class="rootClass">
|
|
124
|
+
<div :class="`${rootClass}__preview`">
|
|
125
|
+
<img
|
|
126
|
+
v-if="previewUrl"
|
|
127
|
+
:src="previewUrl"
|
|
128
|
+
:alt="model?.alt || ''"
|
|
129
|
+
:class="`${rootClass}__image`"
|
|
130
|
+
>
|
|
131
|
+
<div
|
|
132
|
+
v-else
|
|
133
|
+
:class="`${rootClass}__placeholder`"
|
|
134
|
+
aria-hidden="true"
|
|
135
|
+
>
|
|
136
|
+
<svg
|
|
137
|
+
viewBox="0 0 24 24"
|
|
138
|
+
fill="none"
|
|
139
|
+
stroke="currentColor"
|
|
140
|
+
stroke-width="1.5"
|
|
141
|
+
stroke-linecap="round"
|
|
142
|
+
stroke-linejoin="round"
|
|
143
|
+
>
|
|
144
|
+
<path d="M20 21a8 8 0 0 0-16 0" />
|
|
145
|
+
<circle
|
|
146
|
+
cx="12"
|
|
147
|
+
cy="8"
|
|
148
|
+
r="4"
|
|
149
|
+
/>
|
|
150
|
+
</svg>
|
|
151
|
+
</div>
|
|
152
|
+
</div>
|
|
153
|
+
|
|
154
|
+
<div :class="`${rootClass}__actions`">
|
|
155
|
+
<KateCmsUiButton
|
|
156
|
+
tag="button"
|
|
157
|
+
:variant="['secondary', 'small', 'icon']"
|
|
158
|
+
:aria-label="model ? 'Change' : 'Choose avatar'"
|
|
159
|
+
:title="model ? 'Change' : 'Choose avatar'"
|
|
160
|
+
@click="openModal"
|
|
161
|
+
>
|
|
162
|
+
<svg
|
|
163
|
+
data-v-b9a9df7f=""
|
|
164
|
+
width="16"
|
|
165
|
+
height="16"
|
|
166
|
+
viewBox="0 0 16 16"
|
|
167
|
+
fill="none"
|
|
168
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
169
|
+
><path
|
|
170
|
+
data-v-b9a9df7f=""
|
|
171
|
+
d="M6.00033 4.66406H4.00033C3.6467 4.66406 3.30756 4.80454 3.05752 5.05459C2.80747 5.30464 2.66699 5.64377 2.66699 5.9974V11.9974C2.66699 12.351 2.80747 12.6902 3.05752 12.9402C3.30756 13.1903 3.6467 13.3307 4.00033 13.3307H10.0003C10.3539 13.3307 10.6931 13.1903 10.9431 12.9402C11.1932 12.6902 11.3337 12.351 11.3337 11.9974V9.9974"
|
|
172
|
+
stroke="currentColor"
|
|
173
|
+
stroke-width="1.2"
|
|
174
|
+
stroke-linecap="round"
|
|
175
|
+
stroke-linejoin="round"
|
|
176
|
+
/><path
|
|
177
|
+
data-v-b9a9df7f=""
|
|
178
|
+
d="M6 9.99885H8L13.6667 4.33218C13.9319 4.06697 14.0809 3.70726 14.0809 3.33218C14.0809 2.95711 13.9319 2.5974 13.6667 2.33218C13.4015 2.06697 13.0417 1.91797 12.6667 1.91797C12.2916 1.91797 11.9319 2.06697 11.6667 2.33218L6 7.99885V9.99885Z"
|
|
179
|
+
stroke="currentColor"
|
|
180
|
+
stroke-width="1.2"
|
|
181
|
+
stroke-linecap="round"
|
|
182
|
+
stroke-linejoin="round"
|
|
183
|
+
/><path
|
|
184
|
+
data-v-b9a9df7f=""
|
|
185
|
+
d="M10.667 3.33203L12.667 5.33203"
|
|
186
|
+
stroke="currentColor"
|
|
187
|
+
stroke-width="1.2"
|
|
188
|
+
stroke-linecap="round"
|
|
189
|
+
stroke-linejoin="round"
|
|
190
|
+
/></svg>
|
|
191
|
+
</KateCmsUiButton>
|
|
192
|
+
<KateCmsUiButton
|
|
193
|
+
v-if="model"
|
|
194
|
+
tag="button"
|
|
195
|
+
:variant="['red', 'small', 'icon']"
|
|
196
|
+
aria-label="Remove"
|
|
197
|
+
title="Remove"
|
|
198
|
+
@click="clearAvatar"
|
|
199
|
+
>
|
|
200
|
+
<svg
|
|
201
|
+
data-v-b9a9df7f=""
|
|
202
|
+
data-v-e86d7870=""
|
|
203
|
+
data-v-dc89e617=""
|
|
204
|
+
width="18"
|
|
205
|
+
height="18"
|
|
206
|
+
viewBox="0 0 18 18"
|
|
207
|
+
fill="none"
|
|
208
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
209
|
+
><path
|
|
210
|
+
data-v-b9a9df7f=""
|
|
211
|
+
data-v-e86d7870=""
|
|
212
|
+
data-v-dc89e617=""
|
|
213
|
+
d="M3 5.25H15"
|
|
214
|
+
stroke-width="1.5"
|
|
215
|
+
stroke-linecap="round"
|
|
216
|
+
stroke-linejoin="round"
|
|
217
|
+
stroke="currentColor"
|
|
218
|
+
/><path
|
|
219
|
+
data-v-b9a9df7f=""
|
|
220
|
+
data-v-e86d7870=""
|
|
221
|
+
data-v-dc89e617=""
|
|
222
|
+
d="M7.5 8.25V12.75"
|
|
223
|
+
stroke-width="1.5"
|
|
224
|
+
stroke-linecap="round"
|
|
225
|
+
stroke-linejoin="round"
|
|
226
|
+
stroke="currentColor"
|
|
227
|
+
/><path
|
|
228
|
+
data-v-b9a9df7f=""
|
|
229
|
+
data-v-e86d7870=""
|
|
230
|
+
data-v-dc89e617=""
|
|
231
|
+
d="M10.5 8.25V12.75"
|
|
232
|
+
stroke-width="1.5"
|
|
233
|
+
stroke-linecap="round"
|
|
234
|
+
stroke-linejoin="round"
|
|
235
|
+
stroke="currentColor"
|
|
236
|
+
/><path
|
|
237
|
+
data-v-b9a9df7f=""
|
|
238
|
+
data-v-e86d7870=""
|
|
239
|
+
data-v-dc89e617=""
|
|
240
|
+
d="M3.75 5.25L4.5 14.25C4.5 14.6478 4.65804 15.0294 4.93934 15.3107C5.22064 15.592 5.60218 15.75 6 15.75H12C12.3978 15.75 12.7794 15.592 13.0607 15.3107C13.342 15.0294 13.5 14.6478 13.5 14.25L14.25 5.25"
|
|
241
|
+
stroke-width="1.5"
|
|
242
|
+
stroke-linecap="round"
|
|
243
|
+
stroke-linejoin="round"
|
|
244
|
+
stroke="currentColor"
|
|
245
|
+
/><path
|
|
246
|
+
data-v-b9a9df7f=""
|
|
247
|
+
data-v-e86d7870=""
|
|
248
|
+
data-v-dc89e617=""
|
|
249
|
+
d="M6.75 5.25V3C6.75 2.80109 6.82902 2.61032 6.96967 2.46967C7.11032 2.32902 7.30109 2.25 7.5 2.25H10.5C10.6989 2.25 10.8897 2.32902 11.0303 2.46967C11.171 2.61032 11.25 2.80109 11.25 3V5.25"
|
|
250
|
+
stroke-width="1.5"
|
|
251
|
+
stroke-linecap="round"
|
|
252
|
+
stroke-linejoin="round"
|
|
253
|
+
stroke="currentColor"
|
|
254
|
+
/></svg>
|
|
255
|
+
</KateCmsUiButton>
|
|
256
|
+
</div>
|
|
257
|
+
|
|
258
|
+
<input
|
|
259
|
+
ref="fileInput"
|
|
260
|
+
type="file"
|
|
261
|
+
accept="image/*"
|
|
262
|
+
hidden
|
|
263
|
+
@change="onFileChange"
|
|
264
|
+
>
|
|
265
|
+
|
|
266
|
+
<KateCmsMediaLibraryModal
|
|
267
|
+
:open="open"
|
|
268
|
+
media-kind="image"
|
|
269
|
+
:library-enabled="true"
|
|
270
|
+
:library="library"
|
|
271
|
+
:selected-id="model?.id"
|
|
272
|
+
:loading="loading"
|
|
273
|
+
:loading-more="loadingMore"
|
|
274
|
+
:has-more="hasMore"
|
|
275
|
+
:filters="filters"
|
|
276
|
+
:months="months"
|
|
277
|
+
:error="error"
|
|
278
|
+
:uploading="uploading"
|
|
279
|
+
@close="closeModal"
|
|
280
|
+
@choose="choose"
|
|
281
|
+
@upload="triggerUpload"
|
|
282
|
+
@load-more="onLoadMore"
|
|
283
|
+
@update:filters="onLibraryFilters"
|
|
284
|
+
/>
|
|
285
|
+
</div>
|
|
286
|
+
</template>
|
|
287
|
+
|
|
288
|
+
<style scoped lang="scss">
|
|
289
|
+
@use "../../assets/styles" as *;
|
|
290
|
+
|
|
291
|
+
$root: '.katecms-user-avatar-field';
|
|
292
|
+
|
|
293
|
+
#{$root} {
|
|
294
|
+
display: flex;
|
|
295
|
+
align-items: center;
|
|
296
|
+
gap: math-rem(14);
|
|
297
|
+
|
|
298
|
+
&__preview {
|
|
299
|
+
flex-shrink: 0;
|
|
300
|
+
width: math-rem(72);
|
|
301
|
+
height: math-rem(72);
|
|
302
|
+
border-radius: 50%;
|
|
303
|
+
overflow: hidden;
|
|
304
|
+
border: 1px solid $color-border;
|
|
305
|
+
background: $color-bg;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
&__image {
|
|
309
|
+
display: block;
|
|
310
|
+
width: 100%;
|
|
311
|
+
height: 100%;
|
|
312
|
+
max-width: none;
|
|
313
|
+
object-fit: cover;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
&__placeholder {
|
|
317
|
+
display: flex;
|
|
318
|
+
align-items: center;
|
|
319
|
+
justify-content: center;
|
|
320
|
+
width: 100%;
|
|
321
|
+
height: 100%;
|
|
322
|
+
color: $color-muted;
|
|
323
|
+
|
|
324
|
+
svg {
|
|
325
|
+
width: math-rem(32);
|
|
326
|
+
height: math-rem(32);
|
|
327
|
+
max-width: none;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
&__actions {
|
|
332
|
+
display: flex;
|
|
333
|
+
flex-wrap: wrap;
|
|
334
|
+
gap: math-rem(8);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
</style>
|