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,38 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { Field } from '@katecms/core'
|
|
3
|
+
|
|
4
|
+
type FieldPresentation = Partial<Pick<
|
|
5
|
+
Extract<Field, { type: 'text' }>,
|
|
6
|
+
'instructions'
|
|
7
|
+
>>
|
|
8
|
+
|
|
9
|
+
withDefaults(defineProps<{
|
|
10
|
+
field?: FieldPresentation
|
|
11
|
+
}>(), {
|
|
12
|
+
field: () => ({}),
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
const rootClass = 'katecms-field-instructions'
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<template>
|
|
19
|
+
<div
|
|
20
|
+
v-if="field?.instructions"
|
|
21
|
+
:class="rootClass"
|
|
22
|
+
>
|
|
23
|
+
{{ field.instructions }}
|
|
24
|
+
</div>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<style scoped lang="scss">
|
|
28
|
+
@use "../../assets/styles" as *;
|
|
29
|
+
|
|
30
|
+
$root: '.katecms-field-instructions';
|
|
31
|
+
|
|
32
|
+
#{$root} {
|
|
33
|
+
margin: 0;
|
|
34
|
+
font-size: math-rem(13);
|
|
35
|
+
line-height: 1.4;
|
|
36
|
+
color: $color-muted;
|
|
37
|
+
}
|
|
38
|
+
</style>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { Field } from '@katecms/core'
|
|
3
|
+
|
|
4
|
+
type FieldPresentation = Partial<Pick<
|
|
5
|
+
Extract<Field, { type: 'text' }>,
|
|
6
|
+
'label' | 'required'
|
|
7
|
+
>>
|
|
8
|
+
|
|
9
|
+
withDefaults(defineProps<{
|
|
10
|
+
field?: FieldPresentation
|
|
11
|
+
tag?: string
|
|
12
|
+
htmlFor?: string
|
|
13
|
+
}>(), {
|
|
14
|
+
field: () => ({}),
|
|
15
|
+
tag: 'label',
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
const rootClass = 'katecms-field-label'
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<template>
|
|
22
|
+
<component
|
|
23
|
+
:is="tag"
|
|
24
|
+
v-if="field?.label"
|
|
25
|
+
:class="rootClass"
|
|
26
|
+
:for="tag === 'label' ? htmlFor : undefined"
|
|
27
|
+
>
|
|
28
|
+
{{ field.label }}
|
|
29
|
+
<span
|
|
30
|
+
v-if="field?.required"
|
|
31
|
+
:class="[`${rootClass}__required`]"
|
|
32
|
+
aria-hidden="true"
|
|
33
|
+
>*</span>
|
|
34
|
+
</component>
|
|
35
|
+
</template>
|
|
36
|
+
|
|
37
|
+
<style scoped lang="scss">
|
|
38
|
+
@use "../../assets/styles" as *;
|
|
39
|
+
|
|
40
|
+
$root: '.katecms-field-label';
|
|
41
|
+
|
|
42
|
+
#{$root} {
|
|
43
|
+
display: flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
gap: math-rem(4);
|
|
46
|
+
text-transform: uppercase;
|
|
47
|
+
letter-spacing: 0.04em;
|
|
48
|
+
font-weight: 600;
|
|
49
|
+
font-size: math-rem(12);
|
|
50
|
+
color: $color-ink;
|
|
51
|
+
|
|
52
|
+
&__required {
|
|
53
|
+
color: $color-danger;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
</style>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import type { Field } from '@katecms/core'
|
|
4
|
+
import { useKateCmsFieldError } from '../../utils/field-errors'
|
|
5
|
+
|
|
6
|
+
type FieldPresentation = Partial<Pick<
|
|
7
|
+
Extract<Field, { type: 'text' }>,
|
|
8
|
+
'label' | 'instructions' | 'required'
|
|
9
|
+
>>
|
|
10
|
+
|
|
11
|
+
const props = withDefaults(defineProps<{
|
|
12
|
+
fieldKey: string
|
|
13
|
+
field?: FieldPresentation
|
|
14
|
+
labelTag?: string
|
|
15
|
+
}>(), {
|
|
16
|
+
field: () => ({}),
|
|
17
|
+
labelTag: 'label',
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
const rootClass = 'katecms-field'
|
|
21
|
+
const errorMessage = useKateCmsFieldError(() => props.fieldKey)
|
|
22
|
+
const invalid = computed(() => !!errorMessage.value)
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<template>
|
|
26
|
+
<div
|
|
27
|
+
:class="[rootClass, { 'is-invalid': invalid }]"
|
|
28
|
+
:data-field-key="fieldKey"
|
|
29
|
+
>
|
|
30
|
+
<KateCmsFieldLabel
|
|
31
|
+
:html-for="fieldKey"
|
|
32
|
+
:field="field"
|
|
33
|
+
:tag="labelTag"
|
|
34
|
+
/>
|
|
35
|
+
<KateCmsFieldInstructions :field="field" />
|
|
36
|
+
<slot />
|
|
37
|
+
<div
|
|
38
|
+
v-if="errorMessage"
|
|
39
|
+
:class="`${rootClass}__error`"
|
|
40
|
+
>
|
|
41
|
+
{{ errorMessage }}
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
</template>
|
|
45
|
+
|
|
46
|
+
<style scoped lang="scss">
|
|
47
|
+
@use "../../assets/styles" as *;
|
|
48
|
+
|
|
49
|
+
$root: '.katecms-field';
|
|
50
|
+
|
|
51
|
+
#{$root} {
|
|
52
|
+
display: flex;
|
|
53
|
+
flex-direction: column;
|
|
54
|
+
gap: math-rem(6);
|
|
55
|
+
min-width: 0;
|
|
56
|
+
|
|
57
|
+
&__error {
|
|
58
|
+
font-size: math-rem(13);
|
|
59
|
+
line-height: 1.4;
|
|
60
|
+
color: $color-danger;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
</style>
|
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { onBeforeUnmount, onMounted, ref } from 'vue'
|
|
3
|
+
|
|
4
|
+
const props = withDefaults(defineProps<{
|
|
5
|
+
src: string
|
|
6
|
+
aspect?: number | null
|
|
7
|
+
mime?: string
|
|
8
|
+
}>(), {
|
|
9
|
+
aspect: null,
|
|
10
|
+
mime: 'image/png',
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
const emit = defineEmits<{
|
|
14
|
+
confirm: [blob: Blob | null]
|
|
15
|
+
cancel: []
|
|
16
|
+
}>()
|
|
17
|
+
|
|
18
|
+
const rootClass = 'katecms-image-cropper'
|
|
19
|
+
|
|
20
|
+
const PAD = 16
|
|
21
|
+
const MIN_SIZE = 24
|
|
22
|
+
|
|
23
|
+
const imgEl = ref<HTMLImageElement>()
|
|
24
|
+
const stage = ref<HTMLElement>()
|
|
25
|
+
const body = ref<HTMLElement>()
|
|
26
|
+
|
|
27
|
+
const naturalW = ref(0)
|
|
28
|
+
const naturalH = ref(0)
|
|
29
|
+
const displayW = ref(0)
|
|
30
|
+
const displayH = ref(0)
|
|
31
|
+
|
|
32
|
+
const rect = ref({ x: 0, y: 0, w: 0, h: 0 })
|
|
33
|
+
|
|
34
|
+
function initCrop() {
|
|
35
|
+
if (props.aspect) {
|
|
36
|
+
let w = displayW.value
|
|
37
|
+
let h = w / props.aspect
|
|
38
|
+
if (h > displayH.value) {
|
|
39
|
+
h = displayH.value
|
|
40
|
+
w = h * props.aspect
|
|
41
|
+
}
|
|
42
|
+
rect.value = { x: (displayW.value - w) / 2, y: (displayH.value - h) / 2, w, h }
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
rect.value = { x: 0, y: 0, w: displayW.value, h: displayH.value }
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function fit() {
|
|
50
|
+
const el = body.value
|
|
51
|
+
if (!el || !naturalW.value) {
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
const availW = Math.max(1, el.clientWidth - PAD * 2)
|
|
55
|
+
const availH = Math.max(1, el.clientHeight - PAD * 2)
|
|
56
|
+
const ratio = naturalW.value / naturalH.value
|
|
57
|
+
let w = availW
|
|
58
|
+
let h = w / ratio
|
|
59
|
+
if (h > availH) {
|
|
60
|
+
h = availH
|
|
61
|
+
w = h * ratio
|
|
62
|
+
}
|
|
63
|
+
const prevW = displayW.value
|
|
64
|
+
displayW.value = w
|
|
65
|
+
displayH.value = h
|
|
66
|
+
if (prevW && rect.value.w) {
|
|
67
|
+
const k = w / prevW
|
|
68
|
+
rect.value = {
|
|
69
|
+
x: rect.value.x * k,
|
|
70
|
+
y: rect.value.y * k,
|
|
71
|
+
w: rect.value.w * k,
|
|
72
|
+
h: rect.value.h * k,
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
initCrop()
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function onImgLoad() {
|
|
81
|
+
const el = imgEl.value
|
|
82
|
+
if (!el) {
|
|
83
|
+
return
|
|
84
|
+
}
|
|
85
|
+
naturalW.value = el.naturalWidth
|
|
86
|
+
naturalH.value = el.naturalHeight
|
|
87
|
+
fit()
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
let resizeObserver: ResizeObserver | null = null
|
|
91
|
+
|
|
92
|
+
onMounted(() => {
|
|
93
|
+
if (body.value && typeof ResizeObserver !== 'undefined') {
|
|
94
|
+
resizeObserver = new ResizeObserver(() => fit())
|
|
95
|
+
resizeObserver.observe(body.value)
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
type DragMode = 'move' | 'nw' | 'ne' | 'sw' | 'se'
|
|
100
|
+
|
|
101
|
+
let activeMode: DragMode | null = null
|
|
102
|
+
let startPointer = { x: 0, y: 0 }
|
|
103
|
+
let startRect = { x: 0, y: 0, w: 0, h: 0 }
|
|
104
|
+
|
|
105
|
+
function stagePoint(event: PointerEvent) {
|
|
106
|
+
const bounds = stage.value!.getBoundingClientRect()
|
|
107
|
+
return {
|
|
108
|
+
x: Math.min(displayW.value, Math.max(0, event.clientX - bounds.left)),
|
|
109
|
+
y: Math.min(displayH.value, Math.max(0, event.clientY - bounds.top)),
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function onPointerDown(event: PointerEvent, mode: DragMode) {
|
|
114
|
+
event.preventDefault()
|
|
115
|
+
event.stopPropagation()
|
|
116
|
+
activeMode = mode
|
|
117
|
+
startPointer = stagePoint(event)
|
|
118
|
+
startRect = { ...rect.value }
|
|
119
|
+
window.addEventListener('pointermove', onPointerMove)
|
|
120
|
+
window.addEventListener('pointerup', onPointerUp)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function clamp(n: number, min: number, max: number) {
|
|
124
|
+
return Math.min(max, Math.max(min, n))
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function resizeFree(px: number, py: number, mode: DragMode) {
|
|
128
|
+
let x1 = startRect.x
|
|
129
|
+
let y1 = startRect.y
|
|
130
|
+
let x2 = startRect.x + startRect.w
|
|
131
|
+
let y2 = startRect.y + startRect.h
|
|
132
|
+
if (mode.includes('e')) {
|
|
133
|
+
x2 = px
|
|
134
|
+
}
|
|
135
|
+
if (mode.includes('w')) {
|
|
136
|
+
x1 = px
|
|
137
|
+
}
|
|
138
|
+
if (mode.includes('s')) {
|
|
139
|
+
y2 = py
|
|
140
|
+
}
|
|
141
|
+
if (mode.includes('n')) {
|
|
142
|
+
y1 = py
|
|
143
|
+
}
|
|
144
|
+
const x = Math.min(x1, x2)
|
|
145
|
+
const y = Math.min(y1, y2)
|
|
146
|
+
rect.value = {
|
|
147
|
+
x,
|
|
148
|
+
y,
|
|
149
|
+
w: Math.max(MIN_SIZE, Math.abs(x2 - x1)),
|
|
150
|
+
h: Math.max(MIN_SIZE, Math.abs(y2 - y1)),
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function resizeAspect(px: number, py: number, mode: DragMode) {
|
|
155
|
+
const aspect = props.aspect
|
|
156
|
+
if (!aspect) {
|
|
157
|
+
return
|
|
158
|
+
}
|
|
159
|
+
const anchorX = mode.includes('w') ? startRect.x + startRect.w : startRect.x
|
|
160
|
+
const anchorY = mode.includes('n') ? startRect.y + startRect.h : startRect.y
|
|
161
|
+
const dirX = mode.includes('w') ? -1 : 1
|
|
162
|
+
const dirY = mode.includes('n') ? -1 : 1
|
|
163
|
+
|
|
164
|
+
let w = Math.abs(px - anchorX)
|
|
165
|
+
let h = Math.abs(py - anchorY)
|
|
166
|
+
if (w / h > aspect) {
|
|
167
|
+
h = w / aspect
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
w = h * aspect
|
|
171
|
+
}
|
|
172
|
+
const maxW = dirX === 1 ? displayW.value - anchorX : anchorX
|
|
173
|
+
const maxH = dirY === 1 ? displayH.value - anchorY : anchorY
|
|
174
|
+
if (w > maxW) {
|
|
175
|
+
w = maxW
|
|
176
|
+
h = w / aspect
|
|
177
|
+
}
|
|
178
|
+
if (h > maxH) {
|
|
179
|
+
h = maxH
|
|
180
|
+
w = h * aspect
|
|
181
|
+
}
|
|
182
|
+
if (w < MIN_SIZE) {
|
|
183
|
+
w = MIN_SIZE
|
|
184
|
+
h = w / aspect
|
|
185
|
+
}
|
|
186
|
+
rect.value = {
|
|
187
|
+
x: dirX === 1 ? anchorX : anchorX - w,
|
|
188
|
+
y: dirY === 1 ? anchorY : anchorY - h,
|
|
189
|
+
w,
|
|
190
|
+
h,
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function onPointerMove(event: PointerEvent) {
|
|
195
|
+
if (!activeMode) {
|
|
196
|
+
return
|
|
197
|
+
}
|
|
198
|
+
const { x: px, y: py } = stagePoint(event)
|
|
199
|
+
if (activeMode === 'move') {
|
|
200
|
+
const dx = px - startPointer.x
|
|
201
|
+
const dy = py - startPointer.y
|
|
202
|
+
rect.value = {
|
|
203
|
+
...rect.value,
|
|
204
|
+
x: clamp(startRect.x + dx, 0, displayW.value - startRect.w),
|
|
205
|
+
y: clamp(startRect.y + dy, 0, displayH.value - startRect.h),
|
|
206
|
+
}
|
|
207
|
+
return
|
|
208
|
+
}
|
|
209
|
+
if (props.aspect) {
|
|
210
|
+
resizeAspect(px, py, activeMode)
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
resizeFree(px, py, activeMode)
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function onPointerUp() {
|
|
218
|
+
activeMode = null
|
|
219
|
+
window.removeEventListener('pointermove', onPointerMove)
|
|
220
|
+
window.removeEventListener('pointerup', onPointerUp)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function apply() {
|
|
224
|
+
const el = imgEl.value
|
|
225
|
+
if (!el || !rect.value.w || !rect.value.h) {
|
|
226
|
+
return
|
|
227
|
+
}
|
|
228
|
+
const scale = naturalW.value / displayW.value
|
|
229
|
+
const sx = rect.value.x * scale
|
|
230
|
+
const sy = rect.value.y * scale
|
|
231
|
+
const sw = rect.value.w * scale
|
|
232
|
+
const sh = rect.value.h * scale
|
|
233
|
+
|
|
234
|
+
if (naturalW.value - sw < 1 && naturalH.value - sh < 1) {
|
|
235
|
+
emit('confirm', null)
|
|
236
|
+
return
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const canvas = document.createElement('canvas')
|
|
240
|
+
canvas.width = Math.round(sw)
|
|
241
|
+
canvas.height = Math.round(sh)
|
|
242
|
+
const ctx = canvas.getContext('2d')
|
|
243
|
+
if (!ctx) {
|
|
244
|
+
return
|
|
245
|
+
}
|
|
246
|
+
ctx.drawImage(el, sx, sy, sw, sh, 0, 0, canvas.width, canvas.height)
|
|
247
|
+
|
|
248
|
+
const type = props.mime.startsWith('image/') ? props.mime : 'image/png'
|
|
249
|
+
canvas.toBlob(
|
|
250
|
+
(blob) => {
|
|
251
|
+
if (blob) {
|
|
252
|
+
emit('confirm', blob)
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
type,
|
|
256
|
+
0.92,
|
|
257
|
+
)
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
onBeforeUnmount(() => {
|
|
261
|
+
window.removeEventListener('pointermove', onPointerMove)
|
|
262
|
+
window.removeEventListener('pointerup', onPointerUp)
|
|
263
|
+
resizeObserver?.disconnect()
|
|
264
|
+
})
|
|
265
|
+
</script>
|
|
266
|
+
|
|
267
|
+
<template>
|
|
268
|
+
<div :class="rootClass">
|
|
269
|
+
<div
|
|
270
|
+
ref="body"
|
|
271
|
+
:class="`${rootClass}__body`"
|
|
272
|
+
>
|
|
273
|
+
<div
|
|
274
|
+
ref="stage"
|
|
275
|
+
:class="`${rootClass}__stage`"
|
|
276
|
+
:style="{ width: `${displayW}px`, height: `${displayH}px` }"
|
|
277
|
+
>
|
|
278
|
+
<img
|
|
279
|
+
ref="imgEl"
|
|
280
|
+
:src="src"
|
|
281
|
+
crossorigin="anonymous"
|
|
282
|
+
:class="`${rootClass}__img`"
|
|
283
|
+
alt=""
|
|
284
|
+
@load="onImgLoad"
|
|
285
|
+
>
|
|
286
|
+
|
|
287
|
+
<div
|
|
288
|
+
:class="`${rootClass}__box`"
|
|
289
|
+
:style="{
|
|
290
|
+
left: `${rect.x}px`,
|
|
291
|
+
top: `${rect.y}px`,
|
|
292
|
+
width: `${rect.w}px`,
|
|
293
|
+
height: `${rect.h}px`,
|
|
294
|
+
}"
|
|
295
|
+
@pointerdown="onPointerDown($event, 'move')"
|
|
296
|
+
>
|
|
297
|
+
<span
|
|
298
|
+
:class="[`${rootClass}__handle`, `${rootClass}__handle--nw`]"
|
|
299
|
+
@pointerdown="onPointerDown($event, 'nw')"
|
|
300
|
+
/>
|
|
301
|
+
<span
|
|
302
|
+
:class="[`${rootClass}__handle`, `${rootClass}__handle--ne`]"
|
|
303
|
+
@pointerdown="onPointerDown($event, 'ne')"
|
|
304
|
+
/>
|
|
305
|
+
<span
|
|
306
|
+
:class="[`${rootClass}__handle`, `${rootClass}__handle--sw`]"
|
|
307
|
+
@pointerdown="onPointerDown($event, 'sw')"
|
|
308
|
+
/>
|
|
309
|
+
<span
|
|
310
|
+
:class="[`${rootClass}__handle`, `${rootClass}__handle--se`]"
|
|
311
|
+
@pointerdown="onPointerDown($event, 'se')"
|
|
312
|
+
/>
|
|
313
|
+
</div>
|
|
314
|
+
</div>
|
|
315
|
+
</div>
|
|
316
|
+
|
|
317
|
+
<div :class="`${rootClass}__footer`">
|
|
318
|
+
<KateCmsUiButton
|
|
319
|
+
tag="button"
|
|
320
|
+
variant="secondary"
|
|
321
|
+
@click="emit('cancel')"
|
|
322
|
+
>
|
|
323
|
+
Cancel
|
|
324
|
+
</KateCmsUiButton>
|
|
325
|
+
<KateCmsUiButton
|
|
326
|
+
tag="button"
|
|
327
|
+
@click="apply"
|
|
328
|
+
>
|
|
329
|
+
Crop
|
|
330
|
+
</KateCmsUiButton>
|
|
331
|
+
</div>
|
|
332
|
+
</div>
|
|
333
|
+
</template>
|
|
334
|
+
|
|
335
|
+
<style scoped lang="scss">
|
|
336
|
+
@use "../../assets/styles" as *;
|
|
337
|
+
|
|
338
|
+
$root: '.katecms-image-cropper';
|
|
339
|
+
|
|
340
|
+
#{$root} {
|
|
341
|
+
display: flex;
|
|
342
|
+
flex-direction: column;
|
|
343
|
+
height: 100%;
|
|
344
|
+
|
|
345
|
+
&__body {
|
|
346
|
+
flex: 1;
|
|
347
|
+
display: flex;
|
|
348
|
+
align-items: center;
|
|
349
|
+
justify-content: center;
|
|
350
|
+
padding: math-rem(16);
|
|
351
|
+
overflow: hidden;
|
|
352
|
+
background-color: $color-ink;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
&__stage {
|
|
356
|
+
position: relative;
|
|
357
|
+
user-select: none;
|
|
358
|
+
touch-action: none;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
&__img {
|
|
362
|
+
display: block;
|
|
363
|
+
width: 100%;
|
|
364
|
+
height: 100%;
|
|
365
|
+
pointer-events: none;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
&__box {
|
|
369
|
+
position: absolute;
|
|
370
|
+
box-shadow: 0 0 0 1px rgba(255, 255, 255, .9), 0 0 0 9999px rgba(0, 0, 0, .45);
|
|
371
|
+
cursor: move;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
&__handle {
|
|
375
|
+
position: absolute;
|
|
376
|
+
width: 12px;
|
|
377
|
+
height: 12px;
|
|
378
|
+
background-color: $color-surface;
|
|
379
|
+
border: 1px solid $color-accent;
|
|
380
|
+
border-radius: 50%;
|
|
381
|
+
|
|
382
|
+
&--nw {
|
|
383
|
+
top: -6px;
|
|
384
|
+
left: -6px;
|
|
385
|
+
cursor: nwse-resize;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
&--ne {
|
|
389
|
+
top: -6px;
|
|
390
|
+
right: -6px;
|
|
391
|
+
cursor: nesw-resize;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
&--sw {
|
|
395
|
+
bottom: -6px;
|
|
396
|
+
left: -6px;
|
|
397
|
+
cursor: nesw-resize;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
&--se {
|
|
401
|
+
bottom: -6px;
|
|
402
|
+
right: -6px;
|
|
403
|
+
cursor: nwse-resize;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
&__footer {
|
|
408
|
+
display: flex;
|
|
409
|
+
justify-content: flex-end;
|
|
410
|
+
gap: math-rem(8);
|
|
411
|
+
padding: math-rem(14) math-rem(16);
|
|
412
|
+
border-top: 1px solid $color-border;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
</style>
|