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,730 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
|
3
|
+
import type { Field, MediaItem } from '@katecms/core'
|
|
4
|
+
import { isMediaItem } from '@katecms/core'
|
|
5
|
+
import { useMediaLibrary } from '../../composables/useMediaLibrary'
|
|
6
|
+
import type { MediaLibraryFilterState } from '../../utils/media-library-query'
|
|
7
|
+
|
|
8
|
+
type ImageFieldConfig = Extract<Field, { type: 'image' }>
|
|
9
|
+
type CropSource = { kind: 'library', item: MediaItem } | { kind: 'file', file: File }
|
|
10
|
+
|
|
11
|
+
const props = withDefaults(defineProps<{
|
|
12
|
+
fieldKey: string
|
|
13
|
+
field?: ImageFieldConfig
|
|
14
|
+
}>(), {
|
|
15
|
+
field: () => ({ type: 'image', label: '' }),
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
const model = defineModel<unknown>()
|
|
19
|
+
|
|
20
|
+
const rootClass = 'katecms-image-field'
|
|
21
|
+
const returnFormat = computed(() => props.field?.returnFormat || 'array')
|
|
22
|
+
const libraryEnabled = computed(() => props.field?.library !== 'uploadedTo')
|
|
23
|
+
const iconMode = computed(() => !!props.field?.iconMode)
|
|
24
|
+
|
|
25
|
+
const cropEnabled = computed(() => {
|
|
26
|
+
const crop = props.field?.cropType
|
|
27
|
+
return crop === true || (Array.isArray(crop) && !!crop[0] && !!crop[1])
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
const cropAspect = computed<number | undefined>(() => {
|
|
31
|
+
const crop = props.field?.cropType
|
|
32
|
+
return Array.isArray(crop) && crop[0] && crop[1] ? crop[0] / crop[1] : undefined
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
const mimeTokens = computed(() =>
|
|
36
|
+
(props.field?.mimeTypes || '')
|
|
37
|
+
.split(/[\s,]+/)
|
|
38
|
+
.map(t => t.trim().toLowerCase())
|
|
39
|
+
.filter(Boolean),
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
const acceptAttr = computed(() => {
|
|
43
|
+
if (!mimeTokens.value.length) {
|
|
44
|
+
return 'image/*'
|
|
45
|
+
}
|
|
46
|
+
return mimeTokens.value.map(t => (t.includes('/') ? t : `.${t.replace(/^\./, '')}`)).join(',')
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
const selected = ref<MediaItem | null>(null)
|
|
50
|
+
const previewUrl = computed(() => (selected.value ? selected.value.url : ''))
|
|
51
|
+
const hasValue = computed(() => selected.value !== null)
|
|
52
|
+
|
|
53
|
+
function applySelection(item: MediaItem | null) {
|
|
54
|
+
selected.value = item
|
|
55
|
+
if (!item) {
|
|
56
|
+
model.value = returnFormat.value === 'array' ? undefined : ''
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
if (returnFormat.value === 'url') {
|
|
60
|
+
model.value = item.url
|
|
61
|
+
}
|
|
62
|
+
else if (returnFormat.value === 'id') {
|
|
63
|
+
model.value = item.id
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
model.value = item
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function readImageSize(blob: Blob): Promise<{ width: number, height: number }> {
|
|
71
|
+
return new Promise((resolve, reject) => {
|
|
72
|
+
const url = URL.createObjectURL(blob)
|
|
73
|
+
const img = new Image()
|
|
74
|
+
img.onload = () => {
|
|
75
|
+
URL.revokeObjectURL(url)
|
|
76
|
+
resolve({ width: img.naturalWidth, height: img.naturalHeight })
|
|
77
|
+
}
|
|
78
|
+
img.onerror = () => {
|
|
79
|
+
URL.revokeObjectURL(url)
|
|
80
|
+
reject(new Error('image load error'))
|
|
81
|
+
}
|
|
82
|
+
img.src = url
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function matchesMime(mime: string, filename: string): boolean {
|
|
87
|
+
if (!mime.startsWith('image/')) {
|
|
88
|
+
return false
|
|
89
|
+
}
|
|
90
|
+
if (!mimeTokens.value.length) {
|
|
91
|
+
return true
|
|
92
|
+
}
|
|
93
|
+
const subtype = mime.split('/')[1] || ''
|
|
94
|
+
const name = filename.toLowerCase()
|
|
95
|
+
return mimeTokens.value.some((token) => {
|
|
96
|
+
if (token.includes('/')) {
|
|
97
|
+
return token.endsWith('/*') ? mime.startsWith(token.slice(0, -1)) : mime === token
|
|
98
|
+
}
|
|
99
|
+
return subtype === token || name.endsWith(`.${token}`)
|
|
100
|
+
})
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function validateBasic(mime: string, filename: string, sizeBytes: number): string | null {
|
|
104
|
+
const field = props.field
|
|
105
|
+
if (!matchesMime(mime, filename)) {
|
|
106
|
+
return field?.mimeTypes
|
|
107
|
+
? `Invalid file type. Allowed: ${field.mimeTypes}.`
|
|
108
|
+
: 'Only image files are allowed.'
|
|
109
|
+
}
|
|
110
|
+
const mb = sizeBytes / (1024 * 1024)
|
|
111
|
+
if (field?.maxSize && mb > field.maxSize) {
|
|
112
|
+
return `File is larger than ${field.maxSize} MB.`
|
|
113
|
+
}
|
|
114
|
+
if (field?.minSize && mb < field.minSize) {
|
|
115
|
+
return `File is smaller than ${field.minSize} MB.`
|
|
116
|
+
}
|
|
117
|
+
return null
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function validateDimensions(width: number, height: number): string | null {
|
|
121
|
+
const field = props.field
|
|
122
|
+
if (field?.minWidth && width < field.minWidth) {
|
|
123
|
+
return `Width is less than ${field.minWidth}px.`
|
|
124
|
+
}
|
|
125
|
+
if (field?.minHeight && height < field.minHeight) {
|
|
126
|
+
return `Height is less than ${field.minHeight}px.`
|
|
127
|
+
}
|
|
128
|
+
if (field?.maxWidth && width > field.maxWidth) {
|
|
129
|
+
return `Width is greater than ${field.maxWidth}px.`
|
|
130
|
+
}
|
|
131
|
+
if (field?.maxHeight && height > field.maxHeight) {
|
|
132
|
+
return `Height is greater than ${field.maxHeight}px.`
|
|
133
|
+
}
|
|
134
|
+
return null
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const open = ref(false)
|
|
138
|
+
const {
|
|
139
|
+
items: library,
|
|
140
|
+
loading,
|
|
141
|
+
loadingMore,
|
|
142
|
+
hasMore,
|
|
143
|
+
filters,
|
|
144
|
+
months,
|
|
145
|
+
load: loadLibrary,
|
|
146
|
+
loadMore,
|
|
147
|
+
applyFilters,
|
|
148
|
+
prepend: prependLibrary,
|
|
149
|
+
replace: replaceLibrary,
|
|
150
|
+
} = useMediaLibrary(() => item => matchesMime(item.mime_type, item.filename), { baseType: 'image' })
|
|
151
|
+
const error = ref<string | null>(null)
|
|
152
|
+
const uploading = ref(false)
|
|
153
|
+
const processing = ref(false)
|
|
154
|
+
|
|
155
|
+
async function fetchLibrary() {
|
|
156
|
+
error.value = null
|
|
157
|
+
try {
|
|
158
|
+
await loadLibrary({ resetFilters: true })
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
error.value = 'Could not load the media library.'
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
async function onLibraryFilters(next: MediaLibraryFilterState) {
|
|
166
|
+
error.value = null
|
|
167
|
+
try {
|
|
168
|
+
await applyFilters(next)
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
error.value = 'Could not load the media library.'
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
async function onLoadMore() {
|
|
176
|
+
try {
|
|
177
|
+
await loadMore()
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
error.value = 'Could not load more files.'
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function openModal() {
|
|
185
|
+
open.value = true
|
|
186
|
+
error.value = null
|
|
187
|
+
if (libraryEnabled.value) {
|
|
188
|
+
fetchLibrary()
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function closeModal() {
|
|
193
|
+
if (processing.value) {
|
|
194
|
+
return
|
|
195
|
+
}
|
|
196
|
+
if (cropping.value) {
|
|
197
|
+
cancelCrop()
|
|
198
|
+
}
|
|
199
|
+
open.value = false
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
async function uploadFile(file: File | Blob, filename: string): Promise<MediaItem> {
|
|
203
|
+
const form = new FormData()
|
|
204
|
+
form.append('file', file, filename)
|
|
205
|
+
const data = await $fetch<{ media: MediaItem }>('/api/_katecms/media', {
|
|
206
|
+
method: 'POST',
|
|
207
|
+
body: form,
|
|
208
|
+
})
|
|
209
|
+
return data.media
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
async function waitUntilReady(item: MediaItem): Promise<MediaItem> {
|
|
213
|
+
if (item.variants_status !== 'pending') {
|
|
214
|
+
return item
|
|
215
|
+
}
|
|
216
|
+
const maxAttempts = 60
|
|
217
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
218
|
+
await new Promise(resolve => setTimeout(resolve, 1000))
|
|
219
|
+
try {
|
|
220
|
+
const data = await $fetch<{ media: MediaItem }>(`/api/_katecms/media/${item.id}`)
|
|
221
|
+
if (data.media.variants_status !== 'pending') {
|
|
222
|
+
return data.media
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
catch {
|
|
226
|
+
// Keep polling on a temporary error.
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return item
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
async function finalize(item: MediaItem) {
|
|
233
|
+
prependLibrary(item)
|
|
234
|
+
if (returnFormat.value === 'array' && item.variants_status === 'pending') {
|
|
235
|
+
processing.value = true
|
|
236
|
+
try {
|
|
237
|
+
const ready = await waitUntilReady(item)
|
|
238
|
+
replaceLibrary(ready)
|
|
239
|
+
applySelection(ready)
|
|
240
|
+
}
|
|
241
|
+
finally {
|
|
242
|
+
processing.value = false
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
applySelection(item)
|
|
247
|
+
}
|
|
248
|
+
open.value = false
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const cropping = ref(false)
|
|
252
|
+
const cropSrc = ref('')
|
|
253
|
+
let cropObjectUrl: string | null = null
|
|
254
|
+
let cropOutName = 'image.png'
|
|
255
|
+
let cropOutMime = 'image/png'
|
|
256
|
+
let cropSource: CropSource | null = null
|
|
257
|
+
|
|
258
|
+
function beginCrop(src: string, filename: string, mime: string) {
|
|
259
|
+
cropSrc.value = src
|
|
260
|
+
cropOutName = filename
|
|
261
|
+
cropOutMime = mime
|
|
262
|
+
cropping.value = true
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function revokeCropUrl() {
|
|
266
|
+
if (cropObjectUrl) {
|
|
267
|
+
URL.revokeObjectURL(cropObjectUrl)
|
|
268
|
+
cropObjectUrl = null
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function cancelCrop() {
|
|
273
|
+
cropping.value = false
|
|
274
|
+
cropSrc.value = ''
|
|
275
|
+
revokeCropUrl()
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
async function onCropConfirm(blob: Blob | null) {
|
|
279
|
+
cropping.value = false
|
|
280
|
+
revokeCropUrl()
|
|
281
|
+
const source = cropSource
|
|
282
|
+
cropSource = null
|
|
283
|
+
error.value = null
|
|
284
|
+
|
|
285
|
+
if (blob === null) {
|
|
286
|
+
if (!source) {
|
|
287
|
+
cropSrc.value = ''
|
|
288
|
+
return
|
|
289
|
+
}
|
|
290
|
+
if (source.kind === 'library') {
|
|
291
|
+
const dimError = validateDimensions(source.item.width ?? 0, source.item.height ?? 0)
|
|
292
|
+
if (dimError) {
|
|
293
|
+
error.value = dimError
|
|
294
|
+
cropSrc.value = ''
|
|
295
|
+
return
|
|
296
|
+
}
|
|
297
|
+
applySelection(source.item)
|
|
298
|
+
closeModal()
|
|
299
|
+
cropSrc.value = ''
|
|
300
|
+
return
|
|
301
|
+
}
|
|
302
|
+
uploading.value = true
|
|
303
|
+
try {
|
|
304
|
+
const size = await readImageSize(source.file)
|
|
305
|
+
const dimError = validateDimensions(size.width, size.height)
|
|
306
|
+
if (dimError) {
|
|
307
|
+
error.value = dimError
|
|
308
|
+
return
|
|
309
|
+
}
|
|
310
|
+
const item = await uploadFile(source.file, source.file.name)
|
|
311
|
+
await finalize(item)
|
|
312
|
+
}
|
|
313
|
+
catch {
|
|
314
|
+
error.value = 'Could not upload the file.'
|
|
315
|
+
}
|
|
316
|
+
finally {
|
|
317
|
+
uploading.value = false
|
|
318
|
+
cropSrc.value = ''
|
|
319
|
+
}
|
|
320
|
+
return
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
uploading.value = true
|
|
324
|
+
try {
|
|
325
|
+
const size = await readImageSize(blob)
|
|
326
|
+
const dimError = validateDimensions(size.width, size.height)
|
|
327
|
+
if (dimError) {
|
|
328
|
+
error.value = dimError
|
|
329
|
+
return
|
|
330
|
+
}
|
|
331
|
+
const item = await uploadFile(blob, cropOutName)
|
|
332
|
+
await finalize(item)
|
|
333
|
+
}
|
|
334
|
+
catch {
|
|
335
|
+
error.value = 'Could not save the cropped image.'
|
|
336
|
+
}
|
|
337
|
+
finally {
|
|
338
|
+
uploading.value = false
|
|
339
|
+
cropSrc.value = ''
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
async function choose(item: MediaItem) {
|
|
344
|
+
error.value = null
|
|
345
|
+
if (cropEnabled.value) {
|
|
346
|
+
cropSource = { kind: 'library', item }
|
|
347
|
+
beginCrop(item.url, item.filename, item.mime_type)
|
|
348
|
+
return
|
|
349
|
+
}
|
|
350
|
+
const dimError = validateDimensions(item.width ?? 0, item.height ?? 0)
|
|
351
|
+
if (dimError) {
|
|
352
|
+
error.value = dimError
|
|
353
|
+
return
|
|
354
|
+
}
|
|
355
|
+
applySelection(item)
|
|
356
|
+
closeModal()
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
const fileInput = ref<HTMLInputElement>()
|
|
360
|
+
|
|
361
|
+
function triggerUpload() {
|
|
362
|
+
fileInput.value?.click()
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
async function onFileChange(event: Event) {
|
|
366
|
+
const input = event.target as HTMLInputElement
|
|
367
|
+
const file = input.files?.[0]
|
|
368
|
+
input.value = ''
|
|
369
|
+
if (!file) {
|
|
370
|
+
return
|
|
371
|
+
}
|
|
372
|
+
error.value = null
|
|
373
|
+
|
|
374
|
+
const basicError = validateBasic(file.type, file.name, file.size)
|
|
375
|
+
if (basicError) {
|
|
376
|
+
error.value = basicError
|
|
377
|
+
return
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
if (cropEnabled.value) {
|
|
381
|
+
revokeCropUrl()
|
|
382
|
+
cropObjectUrl = URL.createObjectURL(file)
|
|
383
|
+
cropSource = { kind: 'file', file }
|
|
384
|
+
beginCrop(cropObjectUrl, file.name, file.type)
|
|
385
|
+
return
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
try {
|
|
389
|
+
const size = await readImageSize(file)
|
|
390
|
+
const dimError = validateDimensions(size.width, size.height)
|
|
391
|
+
if (dimError) {
|
|
392
|
+
error.value = dimError
|
|
393
|
+
return
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
catch {
|
|
397
|
+
error.value = 'Could not read the image.'
|
|
398
|
+
return
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
uploading.value = true
|
|
402
|
+
try {
|
|
403
|
+
const item = await uploadFile(file, file.name)
|
|
404
|
+
await finalize(item)
|
|
405
|
+
}
|
|
406
|
+
catch {
|
|
407
|
+
error.value = 'Could not upload the file.'
|
|
408
|
+
}
|
|
409
|
+
finally {
|
|
410
|
+
uploading.value = false
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
function remove() {
|
|
415
|
+
applySelection(null)
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
async function restoreFromModel() {
|
|
419
|
+
const value = model.value
|
|
420
|
+
if (value === undefined || value === null || value === '') {
|
|
421
|
+
return
|
|
422
|
+
}
|
|
423
|
+
if (isMediaItem(value)) {
|
|
424
|
+
selected.value = value
|
|
425
|
+
return
|
|
426
|
+
}
|
|
427
|
+
if (typeof value === 'string') {
|
|
428
|
+
selected.value = { url: value } as MediaItem
|
|
429
|
+
return
|
|
430
|
+
}
|
|
431
|
+
if (typeof value === 'number') {
|
|
432
|
+
try {
|
|
433
|
+
const data = await $fetch<{ media: MediaItem }>(`/api/_katecms/media/${value}`)
|
|
434
|
+
selected.value = data.media
|
|
435
|
+
}
|
|
436
|
+
catch {
|
|
437
|
+
// Keep the model value without a preview.
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
onMounted(restoreFromModel)
|
|
443
|
+
onBeforeUnmount(revokeCropUrl)
|
|
444
|
+
</script>
|
|
445
|
+
|
|
446
|
+
<template>
|
|
447
|
+
<KateCmsFieldWrapper
|
|
448
|
+
:field-key="fieldKey"
|
|
449
|
+
:field="field"
|
|
450
|
+
label-tag="div"
|
|
451
|
+
>
|
|
452
|
+
<div :class="rootClass">
|
|
453
|
+
<div :class="`${rootClass}__control`">
|
|
454
|
+
<div
|
|
455
|
+
v-if="hasValue"
|
|
456
|
+
:class="[
|
|
457
|
+
`${rootClass}__preview`,
|
|
458
|
+
{ [`${rootClass}__preview--icon`]: iconMode },
|
|
459
|
+
]"
|
|
460
|
+
>
|
|
461
|
+
<div
|
|
462
|
+
:class="[
|
|
463
|
+
`${rootClass}__image`,
|
|
464
|
+
{ [`${rootClass}__image--icon`]: iconMode },
|
|
465
|
+
]"
|
|
466
|
+
>
|
|
467
|
+
<img
|
|
468
|
+
:src="previewUrl"
|
|
469
|
+
:alt="selected?.alt || ''"
|
|
470
|
+
>
|
|
471
|
+
</div>
|
|
472
|
+
<div
|
|
473
|
+
:class="[
|
|
474
|
+
`${rootClass}__actions`,
|
|
475
|
+
{ [`${rootClass}__actions--icon`]: iconMode },
|
|
476
|
+
]"
|
|
477
|
+
>
|
|
478
|
+
<KateCmsUiButton
|
|
479
|
+
tag="button"
|
|
480
|
+
:variant="['secondary', 'small', 'icon']"
|
|
481
|
+
aria-label="Change"
|
|
482
|
+
title="Change"
|
|
483
|
+
@click="openModal"
|
|
484
|
+
>
|
|
485
|
+
<svg
|
|
486
|
+
width="16"
|
|
487
|
+
height="16"
|
|
488
|
+
viewBox="0 0 16 16"
|
|
489
|
+
fill="none"
|
|
490
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
491
|
+
>
|
|
492
|
+
<path
|
|
493
|
+
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"
|
|
494
|
+
stroke="currentColor"
|
|
495
|
+
stroke-width="1.2"
|
|
496
|
+
stroke-linecap="round"
|
|
497
|
+
stroke-linejoin="round"
|
|
498
|
+
/>
|
|
499
|
+
<path
|
|
500
|
+
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"
|
|
501
|
+
stroke="currentColor"
|
|
502
|
+
stroke-width="1.2"
|
|
503
|
+
stroke-linecap="round"
|
|
504
|
+
stroke-linejoin="round"
|
|
505
|
+
/>
|
|
506
|
+
<path
|
|
507
|
+
d="M10.667 3.33203L12.667 5.33203"
|
|
508
|
+
stroke="currentColor"
|
|
509
|
+
stroke-width="1.2"
|
|
510
|
+
stroke-linecap="round"
|
|
511
|
+
stroke-linejoin="round"
|
|
512
|
+
/>
|
|
513
|
+
</svg>
|
|
514
|
+
</KateCmsUiButton>
|
|
515
|
+
<KateCmsUiButton
|
|
516
|
+
tag="button"
|
|
517
|
+
:variant="['red', 'small', 'icon']"
|
|
518
|
+
aria-label="Remove"
|
|
519
|
+
title="Remove"
|
|
520
|
+
@click="remove"
|
|
521
|
+
>
|
|
522
|
+
<svg
|
|
523
|
+
data-v-e86d7870=""
|
|
524
|
+
data-v-dc89e617=""
|
|
525
|
+
width="18"
|
|
526
|
+
height="18"
|
|
527
|
+
viewBox="0 0 18 18"
|
|
528
|
+
fill="none"
|
|
529
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
530
|
+
><path
|
|
531
|
+
data-v-e86d7870=""
|
|
532
|
+
data-v-dc89e617=""
|
|
533
|
+
d="M3 5.25H15"
|
|
534
|
+
stroke-width="1.5"
|
|
535
|
+
stroke-linecap="round"
|
|
536
|
+
stroke-linejoin="round"
|
|
537
|
+
stroke="currentColor"
|
|
538
|
+
/><path
|
|
539
|
+
data-v-e86d7870=""
|
|
540
|
+
data-v-dc89e617=""
|
|
541
|
+
d="M7.5 8.25V12.75"
|
|
542
|
+
stroke-width="1.5"
|
|
543
|
+
stroke-linecap="round"
|
|
544
|
+
stroke-linejoin="round"
|
|
545
|
+
stroke="currentColor"
|
|
546
|
+
/><path
|
|
547
|
+
data-v-e86d7870=""
|
|
548
|
+
data-v-dc89e617=""
|
|
549
|
+
d="M10.5 8.25V12.75"
|
|
550
|
+
stroke-width="1.5"
|
|
551
|
+
stroke-linecap="round"
|
|
552
|
+
stroke-linejoin="round"
|
|
553
|
+
stroke="currentColor"
|
|
554
|
+
/><path
|
|
555
|
+
data-v-e86d7870=""
|
|
556
|
+
data-v-dc89e617=""
|
|
557
|
+
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"
|
|
558
|
+
stroke-width="1.5"
|
|
559
|
+
stroke-linecap="round"
|
|
560
|
+
stroke-linejoin="round"
|
|
561
|
+
stroke="currentColor"
|
|
562
|
+
/><path
|
|
563
|
+
data-v-e86d7870=""
|
|
564
|
+
data-v-dc89e617=""
|
|
565
|
+
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"
|
|
566
|
+
stroke-width="1.5"
|
|
567
|
+
stroke-linecap="round"
|
|
568
|
+
stroke-linejoin="round"
|
|
569
|
+
stroke="currentColor"
|
|
570
|
+
/></svg>
|
|
571
|
+
</KateCmsUiButton>
|
|
572
|
+
</div>
|
|
573
|
+
</div>
|
|
574
|
+
|
|
575
|
+
<KateCmsUiButton
|
|
576
|
+
v-else
|
|
577
|
+
tag="button"
|
|
578
|
+
:variant="iconMode ? ['icon', 'secondary'] : undefined"
|
|
579
|
+
:aria-label="iconMode ? 'Add Image' : undefined"
|
|
580
|
+
:title="iconMode ? 'Add Image' : undefined"
|
|
581
|
+
@click="openModal"
|
|
582
|
+
>
|
|
583
|
+
<svg
|
|
584
|
+
v-if="iconMode"
|
|
585
|
+
width="16"
|
|
586
|
+
height="16"
|
|
587
|
+
viewBox="0 0 16 16"
|
|
588
|
+
fill="none"
|
|
589
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
590
|
+
>
|
|
591
|
+
<path
|
|
592
|
+
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"
|
|
593
|
+
stroke="currentColor"
|
|
594
|
+
stroke-width="1.2"
|
|
595
|
+
stroke-linecap="round"
|
|
596
|
+
stroke-linejoin="round"
|
|
597
|
+
/>
|
|
598
|
+
<path
|
|
599
|
+
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"
|
|
600
|
+
stroke="currentColor"
|
|
601
|
+
stroke-width="1.2"
|
|
602
|
+
stroke-linecap="round"
|
|
603
|
+
stroke-linejoin="round"
|
|
604
|
+
/>
|
|
605
|
+
<path
|
|
606
|
+
d="M10.667 3.33203L12.667 5.33203"
|
|
607
|
+
stroke="currentColor"
|
|
608
|
+
stroke-width="1.2"
|
|
609
|
+
stroke-linecap="round"
|
|
610
|
+
stroke-linejoin="round"
|
|
611
|
+
/>
|
|
612
|
+
</svg>
|
|
613
|
+
<template v-else>
|
|
614
|
+
Add Image
|
|
615
|
+
</template>
|
|
616
|
+
</KateCmsUiButton>
|
|
617
|
+
</div>
|
|
618
|
+
|
|
619
|
+
<input
|
|
620
|
+
:id="fieldKey"
|
|
621
|
+
ref="fileInput"
|
|
622
|
+
type="file"
|
|
623
|
+
:accept="acceptAttr"
|
|
624
|
+
hidden
|
|
625
|
+
@change="onFileChange"
|
|
626
|
+
>
|
|
627
|
+
|
|
628
|
+
<KateCmsMediaLibraryModal
|
|
629
|
+
:open="open"
|
|
630
|
+
media-kind="image"
|
|
631
|
+
:library-enabled="libraryEnabled"
|
|
632
|
+
:library="library"
|
|
633
|
+
:selected-id="selected?.id"
|
|
634
|
+
:loading="loading"
|
|
635
|
+
:loading-more="loadingMore"
|
|
636
|
+
:has-more="hasMore"
|
|
637
|
+
:filters="filters"
|
|
638
|
+
:months="months"
|
|
639
|
+
:error="error"
|
|
640
|
+
:uploading="uploading"
|
|
641
|
+
:processing="processing"
|
|
642
|
+
:cropping="cropping"
|
|
643
|
+
@close="closeModal"
|
|
644
|
+
@choose="choose"
|
|
645
|
+
@upload="triggerUpload"
|
|
646
|
+
@load-more="onLoadMore"
|
|
647
|
+
@update:filters="onLibraryFilters"
|
|
648
|
+
>
|
|
649
|
+
<KateCmsImageCropper
|
|
650
|
+
:src="cropSrc"
|
|
651
|
+
:aspect="cropAspect"
|
|
652
|
+
:mime="cropOutMime"
|
|
653
|
+
@confirm="onCropConfirm"
|
|
654
|
+
@cancel="cancelCrop"
|
|
655
|
+
/>
|
|
656
|
+
</KateCmsMediaLibraryModal>
|
|
657
|
+
</div>
|
|
658
|
+
</KateCmsFieldWrapper>
|
|
659
|
+
</template>
|
|
660
|
+
|
|
661
|
+
<style scoped lang="scss">
|
|
662
|
+
@use "../../assets/styles" as *;
|
|
663
|
+
|
|
664
|
+
$root: '.katecms-image-field';
|
|
665
|
+
|
|
666
|
+
#{$root} {
|
|
667
|
+
&__control {
|
|
668
|
+
max-width: 100%;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
&__preview {
|
|
672
|
+
|
|
673
|
+
&:hover {
|
|
674
|
+
#{$root} {
|
|
675
|
+
&__actions:not(#{$root}__actions--icon) {
|
|
676
|
+
opacity: 1;
|
|
677
|
+
visibility: visible;
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
&:not(#{$root}__preview--icon) {
|
|
683
|
+
position: relative;
|
|
684
|
+
width: 400px;
|
|
685
|
+
height: auto;
|
|
686
|
+
max-height: 400px;
|
|
687
|
+
max-width: 100%;
|
|
688
|
+
border: 1px solid $color-border;
|
|
689
|
+
border-radius: $border-radius;
|
|
690
|
+
overflow: hidden;
|
|
691
|
+
background-color: $color-bg;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
&--icon {
|
|
695
|
+
display: flex;
|
|
696
|
+
align-items: center;
|
|
697
|
+
column-gap: math-rem(8);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
&__image {
|
|
702
|
+
&--icon {
|
|
703
|
+
width: math-rem(38);
|
|
704
|
+
height: math-rem(38);
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
img {
|
|
708
|
+
display: block;
|
|
709
|
+
width: 100%;
|
|
710
|
+
height: 100% !important;
|
|
711
|
+
max-height: 400px;
|
|
712
|
+
object-fit: contain;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
&__actions {
|
|
717
|
+
display: flex;
|
|
718
|
+
gap: math-rem(6);
|
|
719
|
+
|
|
720
|
+
&:not(#{$root}__actions--icon) {
|
|
721
|
+
position: absolute;
|
|
722
|
+
right: math-rem(8);
|
|
723
|
+
top: math-rem(8);
|
|
724
|
+
opacity: 0;
|
|
725
|
+
visibility: hidden;
|
|
726
|
+
transition: opacity .2s, visibility .2s;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
</style>
|