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,926 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
3
|
+
import type { PropType } from 'vue'
|
|
4
|
+
import type { Field, ColorArrayValue } from '@katecms/core'
|
|
5
|
+
import { isColorArrayValue } from '@katecms/core'
|
|
6
|
+
|
|
7
|
+
type ColorPickerFieldConfig = Extract<Field, { type: 'color_picker' }>
|
|
8
|
+
type ColorFormat = 'hex' | 'rgba' | 'hsla'
|
|
9
|
+
|
|
10
|
+
type Hsva = { h: number, s: number, v: number, a: number }
|
|
11
|
+
|
|
12
|
+
const props = defineProps({
|
|
13
|
+
fieldKey: {
|
|
14
|
+
type: String,
|
|
15
|
+
required: true,
|
|
16
|
+
},
|
|
17
|
+
field: {
|
|
18
|
+
type: Object as PropType<ColorPickerFieldConfig>,
|
|
19
|
+
default: () => ({}),
|
|
20
|
+
},
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
// string: '#rrggbb' | '#rrggbbaa' | 'rgba(...)' | 'hsla(...)'
|
|
24
|
+
// array: { hex, rgba, r, g, b, a }
|
|
25
|
+
const model = defineModel<unknown>()
|
|
26
|
+
|
|
27
|
+
const rootClass = 'katecms-color-picker-field'
|
|
28
|
+
const rootEl = ref<HTMLElement | null>(null)
|
|
29
|
+
const open = ref(false)
|
|
30
|
+
const dropUp = ref(false)
|
|
31
|
+
const format = ref<ColorFormat>('hex')
|
|
32
|
+
const inputText = ref('')
|
|
33
|
+
const hasValue = ref(false)
|
|
34
|
+
const hsva = ref<Hsva>({ h: 210, s: 0.75, v: 0.98, a: 1 })
|
|
35
|
+
|
|
36
|
+
let syncingFromModel = false
|
|
37
|
+
let dragging: 'palette' | 'hue' | 'alpha' | null = null
|
|
38
|
+
let dragEl: HTMLElement | null = null
|
|
39
|
+
let dragRect: DOMRect | null = null
|
|
40
|
+
let dragPointerId: number | null = null
|
|
41
|
+
|
|
42
|
+
const enableOpacity = computed(() => !!props.field?.enableOpacity)
|
|
43
|
+
const returnFormat = computed(() => props.field?.returnFormat || 'string')
|
|
44
|
+
const showColorWheel = computed(() => props.field?.showColorWheel !== false)
|
|
45
|
+
const showRgba = computed(() => !!props.field?.rgba)
|
|
46
|
+
const showHsla = computed(() => !!props.field?.hsla)
|
|
47
|
+
const palette = computed(() => props.field?.paletteColors ?? [])
|
|
48
|
+
|
|
49
|
+
const formatButtons = computed(() => {
|
|
50
|
+
const buttons: { id: ColorFormat, label: string }[] = [
|
|
51
|
+
{ id: 'hex', label: enableOpacity.value ? 'HEXA' : 'HEX' },
|
|
52
|
+
]
|
|
53
|
+
if (showRgba.value) buttons.push({ id: 'rgba', label: enableOpacity.value ? 'RGBA' : 'RGB' })
|
|
54
|
+
if (showHsla.value) buttons.push({ id: 'hsla', label: enableOpacity.value ? 'HSLA' : 'HSL' })
|
|
55
|
+
return buttons
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
const rgb = computed(() => hsvaToRgb(hsva.value.h, hsva.value.s, hsva.value.v))
|
|
59
|
+
const payload = computed<ColorArrayValue>(() => {
|
|
60
|
+
const { r, g, b } = rgb.value
|
|
61
|
+
const a = enableOpacity.value ? Number(hsva.value.a.toFixed(2)) : 1
|
|
62
|
+
return {
|
|
63
|
+
hex: toHex(r, g, b, enableOpacity.value ? a : 1),
|
|
64
|
+
rgba: `rgba(${r}, ${g}, ${b}, ${a})`,
|
|
65
|
+
r,
|
|
66
|
+
g,
|
|
67
|
+
b,
|
|
68
|
+
a,
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
const previewColor = computed(() => {
|
|
73
|
+
if (!hasValue.value) return 'transparent'
|
|
74
|
+
return payload.value.rgba
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
const displayText = computed(() => {
|
|
78
|
+
if (!hasValue.value) return 'Select a color'
|
|
79
|
+
return formatColorString(format.value)
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
const hueColor = computed(() => {
|
|
83
|
+
const { r, g, b } = hsvaToRgb(hsva.value.h, 1, 1)
|
|
84
|
+
return `rgb(${r}, ${g}, ${b})`
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
const paletteHueStyle = computed(() => ({
|
|
88
|
+
backgroundColor: hueColor.value,
|
|
89
|
+
}))
|
|
90
|
+
|
|
91
|
+
const paletteLayersStyle = computed(() => ({
|
|
92
|
+
opacity: enableOpacity.value ? hsva.value.a : 1,
|
|
93
|
+
}))
|
|
94
|
+
|
|
95
|
+
const pickerStyle = computed(() => ({
|
|
96
|
+
left: `${hsva.value.s * 100}%`,
|
|
97
|
+
top: `${(1 - hsva.value.v) * 100}%`,
|
|
98
|
+
backgroundColor: payload.value.rgba,
|
|
99
|
+
}))
|
|
100
|
+
|
|
101
|
+
const hueStyle = computed(() => ({
|
|
102
|
+
left: `${(hsva.value.h / 360) * 100}%`,
|
|
103
|
+
backgroundColor: hueColor.value,
|
|
104
|
+
}))
|
|
105
|
+
|
|
106
|
+
const alphaKnobStyle = computed(() => ({
|
|
107
|
+
left: `${hsva.value.a * 100}%`,
|
|
108
|
+
backgroundColor: payload.value.rgba,
|
|
109
|
+
}))
|
|
110
|
+
|
|
111
|
+
const alphaTrackStyle = computed(() => {
|
|
112
|
+
const { r, g, b } = rgb.value
|
|
113
|
+
return {
|
|
114
|
+
backgroundImage: `linear-gradient(to right, rgba(${r}, ${g}, ${b}, 0), rgba(${r}, ${g}, ${b}, 1)), url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2 2'><path fill='white' d='M1,0H2V1H1V0ZM0,1H1V2H0V1Z'/><path fill='gray' d='M0,0H1V1H0V0ZM1,1H2V2H1V1Z'/></svg>")`,
|
|
115
|
+
backgroundSize: '100%, 8px',
|
|
116
|
+
}
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
function clamp(n: number, min: number, max: number) {
|
|
120
|
+
return Math.min(max, Math.max(min, n))
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function toHex(r: number, g: number, b: number, a = 1): string {
|
|
124
|
+
const h = (n: number) => clamp(Math.round(n), 0, 255).toString(16).padStart(2, '0')
|
|
125
|
+
const base = `#${h(r)}${h(g)}${h(b)}`
|
|
126
|
+
if (!enableOpacity.value || a >= 1) return base
|
|
127
|
+
return `${base}${h(a * 255)}`
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function hsvaToRgb(h: number, s: number, v: number) {
|
|
131
|
+
const c = v * s
|
|
132
|
+
const x = c * (1 - Math.abs(((h / 60) % 2) - 1))
|
|
133
|
+
const m = v - c
|
|
134
|
+
let r = 0
|
|
135
|
+
let g = 0
|
|
136
|
+
let b = 0
|
|
137
|
+
if (h < 60) { r = c; g = x }
|
|
138
|
+
else if (h < 120) { r = x; g = c }
|
|
139
|
+
else if (h < 180) { g = c; b = x }
|
|
140
|
+
else if (h < 240) { g = x; b = c }
|
|
141
|
+
else if (h < 300) { r = x; b = c }
|
|
142
|
+
else { r = c; b = x }
|
|
143
|
+
return {
|
|
144
|
+
r: Math.round((r + m) * 255),
|
|
145
|
+
g: Math.round((g + m) * 255),
|
|
146
|
+
b: Math.round((b + m) * 255),
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function rgbToHsva(r: number, g: number, b: number, a = 1): Hsva {
|
|
151
|
+
const rn = r / 255
|
|
152
|
+
const gn = g / 255
|
|
153
|
+
const bn = b / 255
|
|
154
|
+
const max = Math.max(rn, gn, bn)
|
|
155
|
+
const min = Math.min(rn, gn, bn)
|
|
156
|
+
const d = max - min
|
|
157
|
+
let h = 0
|
|
158
|
+
if (d !== 0) {
|
|
159
|
+
if (max === rn) h = ((gn - bn) / d) % 6
|
|
160
|
+
else if (max === gn) h = (bn - rn) / d + 2
|
|
161
|
+
else h = (rn - gn) / d + 4
|
|
162
|
+
h *= 60
|
|
163
|
+
if (h < 0) h += 360
|
|
164
|
+
}
|
|
165
|
+
const s = max === 0 ? 0 : d / max
|
|
166
|
+
return { h, s, v: max, a: clamp(a, 0, 1) }
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function rgbToHsl(r: number, g: number, b: number) {
|
|
170
|
+
const rn = r / 255
|
|
171
|
+
const gn = g / 255
|
|
172
|
+
const bn = b / 255
|
|
173
|
+
const max = Math.max(rn, gn, bn)
|
|
174
|
+
const min = Math.min(rn, gn, bn)
|
|
175
|
+
const l = (max + min) / 2
|
|
176
|
+
if (max === min) return { h: 0, s: 0, l }
|
|
177
|
+
const d = max - min
|
|
178
|
+
const s = l > 0.5 ? d / (2 - max - min) : d / (max + min)
|
|
179
|
+
let h = 0
|
|
180
|
+
if (max === rn) h = ((gn - bn) / d + (gn < bn ? 6 : 0)) / 6
|
|
181
|
+
else if (max === gn) h = ((bn - rn) / d + 2) / 6
|
|
182
|
+
else h = ((rn - gn) / d + 4) / 6
|
|
183
|
+
return { h: h * 360, s, l }
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function hslToRgb(h: number, s: number, l: number) {
|
|
187
|
+
const hh = ((h % 360) + 360) % 360 / 360
|
|
188
|
+
if (s === 0) {
|
|
189
|
+
const v = Math.round(l * 255)
|
|
190
|
+
return { r: v, g: v, b: v }
|
|
191
|
+
}
|
|
192
|
+
const hue2rgb = (p: number, q: number, t: number) => {
|
|
193
|
+
let tt = t
|
|
194
|
+
if (tt < 0) tt += 1
|
|
195
|
+
if (tt > 1) tt -= 1
|
|
196
|
+
if (tt < 1 / 6) return p + (q - p) * 6 * tt
|
|
197
|
+
if (tt < 1 / 2) return q
|
|
198
|
+
if (tt < 2 / 3) return p + (q - p) * (2 / 3 - tt) * 6
|
|
199
|
+
return p
|
|
200
|
+
}
|
|
201
|
+
const q = l < 0.5 ? l * (1 + s) : l + s - l * s
|
|
202
|
+
const p = 2 * l - q
|
|
203
|
+
return {
|
|
204
|
+
r: Math.round(hue2rgb(p, q, hh + 1 / 3) * 255),
|
|
205
|
+
g: Math.round(hue2rgb(p, q, hh) * 255),
|
|
206
|
+
b: Math.round(hue2rgb(p, q, hh - 1 / 3) * 255),
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function parseColor(value: unknown): Hsva | null {
|
|
211
|
+
if (!value) return null
|
|
212
|
+
|
|
213
|
+
if (typeof value === 'object') {
|
|
214
|
+
if (isColorArrayValue(value)) {
|
|
215
|
+
return rgbToHsva(value.r, value.g, value.b, typeof value.a === 'number' ? value.a : 1)
|
|
216
|
+
}
|
|
217
|
+
const obj = value as { hex?: string, rgba?: string }
|
|
218
|
+
if (typeof obj.hex === 'string') return parseColor(obj.hex)
|
|
219
|
+
if (typeof obj.rgba === 'string') return parseColor(obj.rgba)
|
|
220
|
+
return null
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (typeof value !== 'string') return null
|
|
224
|
+
const str = value.trim()
|
|
225
|
+
if (!str) return null
|
|
226
|
+
|
|
227
|
+
if (str.startsWith('#')) {
|
|
228
|
+
let hex = str.slice(1)
|
|
229
|
+
if (hex.length === 3 || hex.length === 4) {
|
|
230
|
+
hex = hex.split('').map(ch => ch + ch).join('')
|
|
231
|
+
}
|
|
232
|
+
if (hex.length === 6 || hex.length === 8) {
|
|
233
|
+
const r = Number.parseInt(hex.slice(0, 2), 16)
|
|
234
|
+
const g = Number.parseInt(hex.slice(2, 4), 16)
|
|
235
|
+
const b = Number.parseInt(hex.slice(4, 6), 16)
|
|
236
|
+
const a = hex.length === 8 ? Number.parseInt(hex.slice(6, 8), 16) / 255 : 1
|
|
237
|
+
if ([r, g, b].every(n => Number.isFinite(n))) {
|
|
238
|
+
return rgbToHsva(r, g, b, a)
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return null
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const rgbaMatch = str.match(/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?\s*\)$/i)
|
|
245
|
+
if (rgbaMatch) {
|
|
246
|
+
return rgbToHsva(
|
|
247
|
+
Number(rgbaMatch[1]),
|
|
248
|
+
Number(rgbaMatch[2]),
|
|
249
|
+
Number(rgbaMatch[3]),
|
|
250
|
+
rgbaMatch[4] !== undefined ? Number(rgbaMatch[4]) : 1,
|
|
251
|
+
)
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const hslaMatch = str.match(/^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)$/i)
|
|
255
|
+
if (hslaMatch) {
|
|
256
|
+
const rgbVal = hslToRgb(Number(hslaMatch[1]), Number(hslaMatch[2]) / 100, Number(hslaMatch[3]) / 100)
|
|
257
|
+
return rgbToHsva(
|
|
258
|
+
rgbVal.r,
|
|
259
|
+
rgbVal.g,
|
|
260
|
+
rgbVal.b,
|
|
261
|
+
hslaMatch[4] !== undefined ? Number(hslaMatch[4]) : 1,
|
|
262
|
+
)
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return null
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function formatColorString(fmt: ColorFormat): string {
|
|
269
|
+
const { r, g, b, a, hex, rgba } = payload.value
|
|
270
|
+
if (fmt === 'rgba') {
|
|
271
|
+
if (!enableOpacity.value) return `rgb(${r}, ${g}, ${b})`
|
|
272
|
+
return rgba
|
|
273
|
+
}
|
|
274
|
+
if (fmt === 'hsla') {
|
|
275
|
+
const hsl = rgbToHsl(r, g, b)
|
|
276
|
+
const h = Math.round(hsl.h)
|
|
277
|
+
const s = Math.round(hsl.s * 100)
|
|
278
|
+
const l = Math.round(hsl.l * 100)
|
|
279
|
+
if (!enableOpacity.value) return `hsl(${h}, ${s}%, ${l}%)`
|
|
280
|
+
return `hsla(${h}, ${s}%, ${l}%, ${a})`
|
|
281
|
+
}
|
|
282
|
+
return hex
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function isSameArrayValue(value: unknown, next: ColorArrayValue): boolean {
|
|
286
|
+
if (!value || typeof value !== 'object') return false
|
|
287
|
+
const cur = value as Partial<ColorArrayValue>
|
|
288
|
+
return cur.hex === next.hex
|
|
289
|
+
&& cur.rgba === next.rgba
|
|
290
|
+
&& cur.r === next.r
|
|
291
|
+
&& cur.g === next.g
|
|
292
|
+
&& cur.b === next.b
|
|
293
|
+
&& cur.a === next.a
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function writeModel(next: unknown) {
|
|
297
|
+
if (Object.is(model.value, next)) return
|
|
298
|
+
if (typeof next === 'string' && model.value === next) return
|
|
299
|
+
if (next && typeof next === 'object' && isSameArrayValue(model.value, next as ColorArrayValue)) return
|
|
300
|
+
|
|
301
|
+
syncingFromModel = true
|
|
302
|
+
model.value = next
|
|
303
|
+
// The parent may update the model asynchronously — keep the flag until the next tick.
|
|
304
|
+
queueMicrotask(() => {
|
|
305
|
+
syncingFromModel = false
|
|
306
|
+
})
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function commit(options: { syncInput?: boolean } = {}) {
|
|
310
|
+
const syncInput = options.syncInput !== false
|
|
311
|
+
hasValue.value = true
|
|
312
|
+
if (syncInput) {
|
|
313
|
+
inputText.value = formatColorString(format.value)
|
|
314
|
+
}
|
|
315
|
+
if (returnFormat.value === 'array') {
|
|
316
|
+
writeModel({ ...payload.value })
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
writeModel(formatColorString(format.value))
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function clearValue() {
|
|
324
|
+
hasValue.value = false
|
|
325
|
+
inputText.value = ''
|
|
326
|
+
writeModel(returnFormat.value === 'array' ? undefined : '')
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function applyParsed(next: Hsva) {
|
|
330
|
+
hsva.value = {
|
|
331
|
+
h: next.h,
|
|
332
|
+
s: next.s,
|
|
333
|
+
v: next.v,
|
|
334
|
+
a: enableOpacity.value ? next.a : 1,
|
|
335
|
+
}
|
|
336
|
+
commit()
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function colorsMatchRgb(
|
|
340
|
+
a: { r: number, g: number, b: number, a?: number },
|
|
341
|
+
b: { r: number, g: number, b: number, a?: number },
|
|
342
|
+
) {
|
|
343
|
+
return a.r === b.r
|
|
344
|
+
&& a.g === b.g
|
|
345
|
+
&& a.b === b.b
|
|
346
|
+
&& Number((a.a ?? 1).toFixed(2)) === Number((b.a ?? 1).toFixed(2))
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function syncFromModel() {
|
|
350
|
+
const parsed = parseColor(model.value)
|
|
351
|
+
if (!parsed) {
|
|
352
|
+
hasValue.value = false
|
|
353
|
+
inputText.value = ''
|
|
354
|
+
return
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
const nextA = enableOpacity.value ? parsed.a : 1
|
|
358
|
+
const nextRgb = hsvaToRgb(parsed.h, parsed.s, parsed.v)
|
|
359
|
+
const curRgb = hsvaToRgb(hsva.value.h, hsva.value.s, hsva.value.v)
|
|
360
|
+
|
|
361
|
+
// RGB→HSV loses hue on black/white — do not overwrite local HSV if the color is unchanged.
|
|
362
|
+
if (
|
|
363
|
+
hasValue.value
|
|
364
|
+
&& colorsMatchRgb(
|
|
365
|
+
{ ...curRgb, a: hsva.value.a },
|
|
366
|
+
{ ...nextRgb, a: nextA },
|
|
367
|
+
)
|
|
368
|
+
) {
|
|
369
|
+
if (typeof model.value === 'string') {
|
|
370
|
+
inputText.value = model.value
|
|
371
|
+
}
|
|
372
|
+
return
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
hsva.value = {
|
|
376
|
+
h: parsed.h,
|
|
377
|
+
s: parsed.s,
|
|
378
|
+
v: parsed.v,
|
|
379
|
+
a: nextA,
|
|
380
|
+
}
|
|
381
|
+
hasValue.value = true
|
|
382
|
+
if (typeof model.value === 'string') {
|
|
383
|
+
inputText.value = model.value
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
inputText.value = formatColorString(format.value)
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function setFormat(next: ColorFormat) {
|
|
391
|
+
format.value = next
|
|
392
|
+
if (hasValue.value) {
|
|
393
|
+
inputText.value = formatColorString(next)
|
|
394
|
+
if (returnFormat.value === 'string') {
|
|
395
|
+
writeModel(formatColorString(next))
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
function onInputApply() {
|
|
401
|
+
const parsed = parseColor(inputText.value)
|
|
402
|
+
if (!parsed) {
|
|
403
|
+
inputText.value = hasValue.value ? formatColorString(format.value) : ''
|
|
404
|
+
return
|
|
405
|
+
}
|
|
406
|
+
applyParsed(parsed)
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
function selectSwatch(color: string) {
|
|
410
|
+
const parsed = parseColor(color)
|
|
411
|
+
if (!parsed) return
|
|
412
|
+
applyParsed(parsed)
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function updateDropDirection() {
|
|
416
|
+
if (!rootEl.value || typeof window === 'undefined') return
|
|
417
|
+
const rect = rootEl.value.getBoundingClientRect()
|
|
418
|
+
const spaceBelow = window.innerHeight - rect.bottom
|
|
419
|
+
dropUp.value = spaceBelow < 320 && rect.top > spaceBelow
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
function toggle() {
|
|
423
|
+
if (open.value) {
|
|
424
|
+
open.value = false
|
|
425
|
+
return
|
|
426
|
+
}
|
|
427
|
+
syncFromModel()
|
|
428
|
+
updateDropDirection()
|
|
429
|
+
open.value = true
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
function onDocPointerDown(event: PointerEvent) {
|
|
433
|
+
if (!open.value || !rootEl.value) return
|
|
434
|
+
if (!rootEl.value.contains(event.target as Node)) {
|
|
435
|
+
open.value = false
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function onDocKeydown(event: KeyboardEvent) {
|
|
440
|
+
if (event.key === 'Escape') open.value = false
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
function pointerRatio(event: PointerEvent, rect: DOMRect, vertical = false) {
|
|
444
|
+
if (vertical) {
|
|
445
|
+
return clamp((event.clientY - rect.top) / rect.height, 0, 1)
|
|
446
|
+
}
|
|
447
|
+
return clamp((event.clientX - rect.left) / rect.width, 0, 1)
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
function onPalettePointer(event: PointerEvent, rect: DOMRect) {
|
|
451
|
+
// Local HSV only — do not write the model (RGB→HSV would shift hue).
|
|
452
|
+
hsva.value = {
|
|
453
|
+
...hsva.value,
|
|
454
|
+
s: clamp((event.clientX - rect.left) / rect.width, 0, 1),
|
|
455
|
+
v: 1 - clamp((event.clientY - rect.top) / rect.height, 0, 1),
|
|
456
|
+
}
|
|
457
|
+
hasValue.value = true
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
function onHuePointer(event: PointerEvent, rect: DOMRect) {
|
|
461
|
+
hsva.value = {
|
|
462
|
+
...hsva.value,
|
|
463
|
+
h: pointerRatio(event, rect) * 360,
|
|
464
|
+
}
|
|
465
|
+
hasValue.value = true
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
function onAlphaPointer(event: PointerEvent, rect: DOMRect) {
|
|
469
|
+
hsva.value = {
|
|
470
|
+
...hsva.value,
|
|
471
|
+
a: pointerRatio(event, rect),
|
|
472
|
+
}
|
|
473
|
+
hasValue.value = true
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
function applyDragPointer(event: PointerEvent) {
|
|
477
|
+
if (!dragging || !dragRect) return
|
|
478
|
+
if (dragging === 'palette') onPalettePointer(event, dragRect)
|
|
479
|
+
else if (dragging === 'hue') onHuePointer(event, dragRect)
|
|
480
|
+
else onAlphaPointer(event, dragRect)
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
function onWindowPointerMove(event: PointerEvent) {
|
|
484
|
+
if (!dragging || dragPointerId !== event.pointerId) return
|
|
485
|
+
event.preventDefault()
|
|
486
|
+
applyDragPointer(event)
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function onWindowPointerUp(event: PointerEvent) {
|
|
490
|
+
if (dragPointerId !== null && event.pointerId !== dragPointerId) return
|
|
491
|
+
endDrag()
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
function startDrag(kind: 'palette' | 'hue' | 'alpha', event: PointerEvent) {
|
|
495
|
+
const el = event.currentTarget as HTMLElement | null
|
|
496
|
+
if (!el) return
|
|
497
|
+
event.preventDefault()
|
|
498
|
+
event.stopPropagation()
|
|
499
|
+
|
|
500
|
+
dragging = kind
|
|
501
|
+
dragEl = el
|
|
502
|
+
dragRect = el.getBoundingClientRect()
|
|
503
|
+
dragPointerId = event.pointerId
|
|
504
|
+
el.setPointerCapture?.(event.pointerId)
|
|
505
|
+
|
|
506
|
+
window.addEventListener('pointermove', onWindowPointerMove, { passive: false })
|
|
507
|
+
window.addEventListener('pointerup', onWindowPointerUp)
|
|
508
|
+
window.addEventListener('pointercancel', onWindowPointerUp)
|
|
509
|
+
|
|
510
|
+
applyDragPointer(event)
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
function endDrag() {
|
|
514
|
+
if (!dragging) return
|
|
515
|
+
|
|
516
|
+
if (dragEl && dragPointerId !== null) {
|
|
517
|
+
try {
|
|
518
|
+
dragEl.releasePointerCapture?.(dragPointerId)
|
|
519
|
+
}
|
|
520
|
+
catch {
|
|
521
|
+
// ignore
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
window.removeEventListener('pointermove', onWindowPointerMove)
|
|
526
|
+
window.removeEventListener('pointerup', onWindowPointerUp)
|
|
527
|
+
window.removeEventListener('pointercancel', onWindowPointerUp)
|
|
528
|
+
|
|
529
|
+
dragging = null
|
|
530
|
+
dragEl = null
|
|
531
|
+
dragRect = null
|
|
532
|
+
dragPointerId = null
|
|
533
|
+
|
|
534
|
+
// One commit at the end of the drag — no intermediate RGB↔HSV cycles.
|
|
535
|
+
commit()
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
onMounted(() => {
|
|
539
|
+
if (!model.value && props.field?.defaultValue) {
|
|
540
|
+
model.value = props.field.defaultValue
|
|
541
|
+
}
|
|
542
|
+
syncFromModel()
|
|
543
|
+
document.addEventListener('pointerdown', onDocPointerDown)
|
|
544
|
+
document.addEventListener('keydown', onDocKeydown)
|
|
545
|
+
})
|
|
546
|
+
|
|
547
|
+
onBeforeUnmount(() => {
|
|
548
|
+
endDrag()
|
|
549
|
+
document.removeEventListener('pointerdown', onDocPointerDown)
|
|
550
|
+
document.removeEventListener('keydown', onDocKeydown)
|
|
551
|
+
})
|
|
552
|
+
|
|
553
|
+
watch(model, () => {
|
|
554
|
+
if (syncingFromModel || dragging) return
|
|
555
|
+
syncFromModel()
|
|
556
|
+
})
|
|
557
|
+
|
|
558
|
+
watch(formatButtons, (buttons) => {
|
|
559
|
+
if (!buttons.some(btn => btn.id === format.value)) {
|
|
560
|
+
format.value = 'hex'
|
|
561
|
+
}
|
|
562
|
+
})
|
|
563
|
+
</script>
|
|
564
|
+
|
|
565
|
+
<template>
|
|
566
|
+
<KateCmsFieldWrapper
|
|
567
|
+
:field-key="fieldKey"
|
|
568
|
+
:field="field"
|
|
569
|
+
label-tag="div"
|
|
570
|
+
>
|
|
571
|
+
<div
|
|
572
|
+
ref="rootEl"
|
|
573
|
+
:class="rootClass"
|
|
574
|
+
>
|
|
575
|
+
<button
|
|
576
|
+
:id="fieldKey"
|
|
577
|
+
type="button"
|
|
578
|
+
:class="`${rootClass}__chip`"
|
|
579
|
+
@click="toggle"
|
|
580
|
+
>
|
|
581
|
+
<span :class="[`${rootClass}__swatch`, { 'is-empty': !hasValue }]">
|
|
582
|
+
<span :style="{ backgroundColor: previewColor }" />
|
|
583
|
+
</span>
|
|
584
|
+
<span :class="`${rootClass}__value`">{{ displayText }}</span>
|
|
585
|
+
</button>
|
|
586
|
+
|
|
587
|
+
<div
|
|
588
|
+
v-if="open"
|
|
589
|
+
:class="[`${rootClass}__popup`, { 'is-drop-up': dropUp }]"
|
|
590
|
+
>
|
|
591
|
+
<div
|
|
592
|
+
v-if="showColorWheel"
|
|
593
|
+
:class="`${rootClass}__selection`"
|
|
594
|
+
>
|
|
595
|
+
<div
|
|
596
|
+
:class="`${rootClass}__palette`"
|
|
597
|
+
@pointerdown="startDrag('palette', $event)"
|
|
598
|
+
>
|
|
599
|
+
<div
|
|
600
|
+
:class="`${rootClass}__palette-layers`"
|
|
601
|
+
:style="paletteLayersStyle"
|
|
602
|
+
>
|
|
603
|
+
<div
|
|
604
|
+
:class="`${rootClass}__palette-hue`"
|
|
605
|
+
:style="paletteHueStyle"
|
|
606
|
+
/>
|
|
607
|
+
<div :class="`${rootClass}__palette-white`" />
|
|
608
|
+
<div :class="`${rootClass}__palette-black`" />
|
|
609
|
+
</div>
|
|
610
|
+
<span
|
|
611
|
+
:class="`${rootClass}__picker`"
|
|
612
|
+
:style="pickerStyle"
|
|
613
|
+
/>
|
|
614
|
+
</div>
|
|
615
|
+
|
|
616
|
+
<div
|
|
617
|
+
:class="`${rootClass}__slider ${rootClass}__slider--hue`"
|
|
618
|
+
@pointerdown="startDrag('hue', $event)"
|
|
619
|
+
>
|
|
620
|
+
<span
|
|
621
|
+
:class="`${rootClass}__picker ${rootClass}__picker--slider`"
|
|
622
|
+
:style="hueStyle"
|
|
623
|
+
/>
|
|
624
|
+
</div>
|
|
625
|
+
|
|
626
|
+
<div
|
|
627
|
+
v-if="enableOpacity"
|
|
628
|
+
:class="`${rootClass}__slider ${rootClass}__slider--alpha`"
|
|
629
|
+
:style="alphaTrackStyle"
|
|
630
|
+
@pointerdown="startDrag('alpha', $event)"
|
|
631
|
+
>
|
|
632
|
+
<span
|
|
633
|
+
:class="`${rootClass}__picker ${rootClass}__picker--slider`"
|
|
634
|
+
:style="alphaKnobStyle"
|
|
635
|
+
/>
|
|
636
|
+
</div>
|
|
637
|
+
</div>
|
|
638
|
+
|
|
639
|
+
<div
|
|
640
|
+
v-if="palette.length"
|
|
641
|
+
:class="`${rootClass}__swatches`"
|
|
642
|
+
>
|
|
643
|
+
<button
|
|
644
|
+
v-for="color in palette"
|
|
645
|
+
:key="color"
|
|
646
|
+
type="button"
|
|
647
|
+
:class="`${rootClass}__swatch-btn`"
|
|
648
|
+
:title="color"
|
|
649
|
+
@click="selectSwatch(color)"
|
|
650
|
+
>
|
|
651
|
+
<span :style="{ backgroundColor: color }" />
|
|
652
|
+
</button>
|
|
653
|
+
</div>
|
|
654
|
+
|
|
655
|
+
<div :class="`${rootClass}__interaction`">
|
|
656
|
+
<div
|
|
657
|
+
v-if="formatButtons.length > 1"
|
|
658
|
+
:class="`${rootClass}__formats`"
|
|
659
|
+
>
|
|
660
|
+
<button
|
|
661
|
+
v-for="btn in formatButtons"
|
|
662
|
+
:key="btn.id"
|
|
663
|
+
type="button"
|
|
664
|
+
:class="[`${rootClass}__format`, { 'is-active': format === btn.id }]"
|
|
665
|
+
@click="setFormat(btn.id)"
|
|
666
|
+
>
|
|
667
|
+
{{ btn.label }}
|
|
668
|
+
</button>
|
|
669
|
+
</div>
|
|
670
|
+
|
|
671
|
+
<input
|
|
672
|
+
v-model="inputText"
|
|
673
|
+
type="text"
|
|
674
|
+
:class="`${rootClass}__input`"
|
|
675
|
+
spellcheck="false"
|
|
676
|
+
placeholder="#000000"
|
|
677
|
+
@keydown.enter.prevent="onInputApply"
|
|
678
|
+
@blur="onInputApply"
|
|
679
|
+
>
|
|
680
|
+
|
|
681
|
+
<KateCmsUiButton
|
|
682
|
+
tag="button"
|
|
683
|
+
:variant="['secondary', 'small']"
|
|
684
|
+
@click="clearValue"
|
|
685
|
+
>
|
|
686
|
+
Clear
|
|
687
|
+
</KateCmsUiButton>
|
|
688
|
+
</div>
|
|
689
|
+
</div>
|
|
690
|
+
</div>
|
|
691
|
+
</KateCmsFieldWrapper>
|
|
692
|
+
</template>
|
|
693
|
+
|
|
694
|
+
<style scoped lang="scss">
|
|
695
|
+
@use "../../assets/styles" as *;
|
|
696
|
+
|
|
697
|
+
$root: '.katecms-color-picker-field';
|
|
698
|
+
$checker: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2 2'><path fill='white' d='M1,0H2V1H1V0ZM0,1H1V2H0V1Z'/><path fill='gray' d='M0,0H1V1H0V0ZM1,1H2V2H1V1Z'/></svg>");
|
|
699
|
+
|
|
700
|
+
#{$root} {
|
|
701
|
+
position: relative;
|
|
702
|
+
width: fit-content;
|
|
703
|
+
max-width: 100%;
|
|
704
|
+
|
|
705
|
+
&__chip {
|
|
706
|
+
display: flex;
|
|
707
|
+
align-items: center;
|
|
708
|
+
gap: 10px;
|
|
709
|
+
width: 240px;
|
|
710
|
+
height: 38px;
|
|
711
|
+
padding: 0 8px;
|
|
712
|
+
border: 1px solid $color-border;
|
|
713
|
+
border-radius: $border-radius;
|
|
714
|
+
background-color: $color-surface;
|
|
715
|
+
cursor: pointer;
|
|
716
|
+
text-align: left;
|
|
717
|
+
|
|
718
|
+
&:focus-visible {
|
|
719
|
+
outline: 2px solid $color-accent;
|
|
720
|
+
outline-offset: 1px;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
&__swatch {
|
|
725
|
+
position: relative;
|
|
726
|
+
flex: 0 0 auto;
|
|
727
|
+
width: 32px;
|
|
728
|
+
height: 24px;
|
|
729
|
+
border: 1px solid $color-border;
|
|
730
|
+
border-radius: $border-radius-inter;
|
|
731
|
+
background: $checker;
|
|
732
|
+
background-size: 8px;
|
|
733
|
+
overflow: hidden;
|
|
734
|
+
|
|
735
|
+
&.is-empty {
|
|
736
|
+
background-image: none;
|
|
737
|
+
background-color: transparent;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
> span {
|
|
741
|
+
position: absolute;
|
|
742
|
+
inset: 0;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
&-btn {
|
|
746
|
+
position: relative;
|
|
747
|
+
width: 25px;
|
|
748
|
+
height: 25px;
|
|
749
|
+
padding: 0;
|
|
750
|
+
border: 1px solid $color-border;
|
|
751
|
+
border-radius: 4px;
|
|
752
|
+
background: $checker;
|
|
753
|
+
background-size: 8px;
|
|
754
|
+
cursor: pointer;
|
|
755
|
+
overflow: hidden;
|
|
756
|
+
|
|
757
|
+
> span {
|
|
758
|
+
position: absolute;
|
|
759
|
+
inset: 0;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
&:focus-visible {
|
|
763
|
+
outline: 2px solid $color-accent;
|
|
764
|
+
outline-offset: 1px;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
&__value {
|
|
770
|
+
font-size: 14px;
|
|
771
|
+
color: $color-muted;
|
|
772
|
+
overflow: hidden;
|
|
773
|
+
text-overflow: ellipsis;
|
|
774
|
+
white-space: nowrap;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
&__popup {
|
|
778
|
+
position: absolute;
|
|
779
|
+
z-index: 1000;
|
|
780
|
+
top: calc(100% + 6px);
|
|
781
|
+
left: 0;
|
|
782
|
+
width: 224px;
|
|
783
|
+
padding: 8px;
|
|
784
|
+
background: $color-surface;
|
|
785
|
+
border: 1px solid $color-border;
|
|
786
|
+
border-radius: $border-radius;
|
|
787
|
+
box-shadow: $shadow-md;
|
|
788
|
+
|
|
789
|
+
&.is-drop-up {
|
|
790
|
+
top: auto;
|
|
791
|
+
bottom: calc(100% + 6px);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
&__selection {
|
|
796
|
+
display: flex;
|
|
797
|
+
flex-direction: column;
|
|
798
|
+
gap: 10px;
|
|
799
|
+
margin-bottom: 10px;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
&__palette {
|
|
803
|
+
position: relative;
|
|
804
|
+
width: 100%;
|
|
805
|
+
height: 130px;
|
|
806
|
+
border-radius: $border-radius-inter;
|
|
807
|
+
cursor: crosshair;
|
|
808
|
+
touch-action: none;
|
|
809
|
+
background: $checker;
|
|
810
|
+
background-size: 8px;
|
|
811
|
+
|
|
812
|
+
&-layers,
|
|
813
|
+
&-hue,
|
|
814
|
+
&-white,
|
|
815
|
+
&-black {
|
|
816
|
+
position: absolute;
|
|
817
|
+
inset: 0;
|
|
818
|
+
pointer-events: none;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
&-white {
|
|
822
|
+
background: linear-gradient(to right, #fff, transparent);
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
&-black {
|
|
826
|
+
background: linear-gradient(to top, #000, transparent);
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
&__picker {
|
|
831
|
+
position: absolute;
|
|
832
|
+
z-index: 2;
|
|
833
|
+
width: 16px;
|
|
834
|
+
height: 16px;
|
|
835
|
+
border: 2px solid #fff;
|
|
836
|
+
border-radius: 50%;
|
|
837
|
+
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
|
|
838
|
+
transform: translate(-50%, -50%);
|
|
839
|
+
background-color: transparent;
|
|
840
|
+
//pointer-events: none;
|
|
841
|
+
|
|
842
|
+
&--slider {
|
|
843
|
+
top: 50%;
|
|
844
|
+
width: 15px;
|
|
845
|
+
height: 15px;
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
&__slider {
|
|
850
|
+
position: relative;
|
|
851
|
+
height: 10px;
|
|
852
|
+
border-radius: 999px;
|
|
853
|
+
cursor: pointer;
|
|
854
|
+
touch-action: none;
|
|
855
|
+
|
|
856
|
+
&--hue {
|
|
857
|
+
background: linear-gradient(
|
|
858
|
+
to right,
|
|
859
|
+
#f00 0%,
|
|
860
|
+
#ff0 17%,
|
|
861
|
+
#0f0 33%,
|
|
862
|
+
#0ff 50%,
|
|
863
|
+
#00f 67%,
|
|
864
|
+
#f0f 83%,
|
|
865
|
+
#f00 100%
|
|
866
|
+
);
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
&--alpha {
|
|
870
|
+
//box-shadow: inset 0 0 0 1px $color-border;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
&__swatches {
|
|
875
|
+
display: flex;
|
|
876
|
+
flex-wrap: wrap;
|
|
877
|
+
gap: 5px;
|
|
878
|
+
margin-bottom: 10px;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
&__interaction {
|
|
882
|
+
display: flex;
|
|
883
|
+
flex-direction: column;
|
|
884
|
+
gap: 8px;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
&__formats {
|
|
888
|
+
display: flex;
|
|
889
|
+
gap: 4px;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
&__format {
|
|
893
|
+
flex: 1;
|
|
894
|
+
height: 28px;
|
|
895
|
+
border: 1px solid $color-border;
|
|
896
|
+
border-radius: $border-radius-inter;
|
|
897
|
+
background: $color-bg;
|
|
898
|
+
color: $color-muted;
|
|
899
|
+
font-size: 11px;
|
|
900
|
+
cursor: pointer;
|
|
901
|
+
|
|
902
|
+
&.is-active {
|
|
903
|
+
border-color: $color-accent;
|
|
904
|
+
color: $color-accent;
|
|
905
|
+
background: $color-accent-wash;
|
|
906
|
+
font-weight: 600;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
&__input {
|
|
911
|
+
width: 100%;
|
|
912
|
+
height: 32px;
|
|
913
|
+
padding: 0 8px;
|
|
914
|
+
border: 1px solid $color-border;
|
|
915
|
+
border-radius: $border-radius-inter;
|
|
916
|
+
background: $color-surface;
|
|
917
|
+
color: $color-ink;
|
|
918
|
+
font-size: 13px;
|
|
919
|
+
|
|
920
|
+
&:focus {
|
|
921
|
+
outline: none;
|
|
922
|
+
border-color: $color-accent;
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
</style>
|