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,999 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { CSSProperties } from 'vue'
|
|
3
|
+
import { computed, onBeforeUnmount, onMounted, ref, toRaw, watch } from 'vue'
|
|
4
|
+
import {
|
|
5
|
+
createFieldDefault,
|
|
6
|
+
isLayoutOnlyFieldType,
|
|
7
|
+
isVisible,
|
|
8
|
+
ROW_COLLAPSED_KEY,
|
|
9
|
+
} from '@katecms/core'
|
|
10
|
+
import type { Field } from '@katecms/core'
|
|
11
|
+
import { resolveField } from '../../utils/helpers'
|
|
12
|
+
|
|
13
|
+
type RepeaterFieldConfig = Extract<Field, { type: 'repeater' }>
|
|
14
|
+
|
|
15
|
+
const props = withDefaults(defineProps<{
|
|
16
|
+
fieldKey: string
|
|
17
|
+
field?: RepeaterFieldConfig
|
|
18
|
+
}>(), {
|
|
19
|
+
field: () => ({ type: 'repeater', label: '', subFields: {} }),
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
const model = defineModel<Record<string, unknown>[]>({ default: () => [] })
|
|
23
|
+
|
|
24
|
+
const rootClass = 'katecms-repeater-field'
|
|
25
|
+
|
|
26
|
+
const subFields = computed<Record<string, Field>>(() => {
|
|
27
|
+
const fields = props.field?.subFields ?? {}
|
|
28
|
+
if (!(ROW_COLLAPSED_KEY in fields)) {
|
|
29
|
+
return fields
|
|
30
|
+
}
|
|
31
|
+
const { [ROW_COLLAPSED_KEY]: _conflict, ...rest } = fields
|
|
32
|
+
return rest
|
|
33
|
+
})
|
|
34
|
+
const minRows = computed(() => props.field?.min ?? 0)
|
|
35
|
+
const maxRows = computed(() => props.field?.max)
|
|
36
|
+
const buttonLabel = computed(() => props.field?.buttonLabel || 'Add Row')
|
|
37
|
+
const collapsedKey = computed(() => resolveCollapsedKey(props.field))
|
|
38
|
+
const collapsible = computed(() => !!collapsedKey.value)
|
|
39
|
+
|
|
40
|
+
const rows = ref<Record<string, unknown>[]>([])
|
|
41
|
+
const canAdd = computed(() => maxRows.value == null || rows.value.length < maxRows.value)
|
|
42
|
+
const canRemove = computed(() => rows.value.length > minRows.value)
|
|
43
|
+
const allExpanded = computed(() =>
|
|
44
|
+
rows.value.length > 0 && rows.value.every(row => !isRowCollapsed(row)),
|
|
45
|
+
)
|
|
46
|
+
const allCollapsed = computed(() =>
|
|
47
|
+
rows.value.length > 0 && rows.value.every(row => isRowCollapsed(row)),
|
|
48
|
+
)
|
|
49
|
+
const showCollapseAll = computed(() => collapsible.value && rows.value.length > 0 && !allCollapsed.value)
|
|
50
|
+
const showExpandAll = computed(() => collapsible.value && rows.value.length > 0 && !allExpanded.value)
|
|
51
|
+
|
|
52
|
+
const draggingIndex = ref<number | null>(null)
|
|
53
|
+
const isDragging = ref(false)
|
|
54
|
+
const dropTargetIndex = ref(0)
|
|
55
|
+
const dragOffset = ref({ x: 0, y: 0 })
|
|
56
|
+
const dragSize = ref({ width: 0, height: 0 })
|
|
57
|
+
const dragPosition = ref({ left: 0, top: 0 })
|
|
58
|
+
|
|
59
|
+
const rowsContainerRef = ref<HTMLElement | null>(null)
|
|
60
|
+
const rowRefs = ref<(HTMLElement | null)[]>([])
|
|
61
|
+
|
|
62
|
+
watch(
|
|
63
|
+
() => props.field,
|
|
64
|
+
(field) => {
|
|
65
|
+
if (!field) {
|
|
66
|
+
return
|
|
67
|
+
}
|
|
68
|
+
if (field.collapsed && !resolveCollapsedKey(field)) {
|
|
69
|
+
console.warn(
|
|
70
|
+
`[katecms] Repeater "${props.fieldKey}": option "collapsed" refers to unknown sub-field "${field.collapsed}". Collapsible mode is disabled.`,
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
if (field.subFields && ROW_COLLAPSED_KEY in field.subFields) {
|
|
74
|
+
console.warn(
|
|
75
|
+
`[katecms] Repeater "${props.fieldKey}": sub-field name "${ROW_COLLAPSED_KEY}" is reserved and will be ignored.`,
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{ immediate: true },
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
function resolveCollapsedKey(field: RepeaterFieldConfig): string | undefined {
|
|
83
|
+
const key = field?.collapsed
|
|
84
|
+
if (!key || key === ROW_COLLAPSED_KEY) {
|
|
85
|
+
return undefined
|
|
86
|
+
}
|
|
87
|
+
return key in (field.subFields ?? {}) ? key : undefined
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function isRowCollapsed(row: Record<string, unknown>, field: RepeaterFieldConfig = props.field): boolean {
|
|
91
|
+
if (!resolveCollapsedKey(field)) {
|
|
92
|
+
return false
|
|
93
|
+
}
|
|
94
|
+
return row[ROW_COLLAPSED_KEY] === true
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const rowKeyMap = new WeakMap<object, number>()
|
|
98
|
+
let rowKeySeq = 0
|
|
99
|
+
|
|
100
|
+
function keyForRow(row: Record<string, unknown>): number {
|
|
101
|
+
const raw = toRaw(row)
|
|
102
|
+
let key = rowKeyMap.get(raw)
|
|
103
|
+
if (key === undefined) {
|
|
104
|
+
rowKeySeq += 1
|
|
105
|
+
key = rowKeySeq
|
|
106
|
+
rowKeyMap.set(raw, key)
|
|
107
|
+
}
|
|
108
|
+
return key
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function transferRowKey(from: Record<string, unknown>, to: Record<string, unknown>) {
|
|
112
|
+
const key = rowKeyMap.get(toRaw(from))
|
|
113
|
+
if (key !== undefined) {
|
|
114
|
+
rowKeyMap.set(toRaw(to), key)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function deepClone<T>(value: T): T {
|
|
119
|
+
const raw = toRaw(value) as T
|
|
120
|
+
if (raw === null || typeof raw !== 'object') {
|
|
121
|
+
return raw
|
|
122
|
+
}
|
|
123
|
+
if (Array.isArray(raw)) {
|
|
124
|
+
return raw.map(item => deepClone(item)) as unknown as T
|
|
125
|
+
}
|
|
126
|
+
if (raw instanceof Date) {
|
|
127
|
+
return new Date(raw.getTime()) as unknown as T
|
|
128
|
+
}
|
|
129
|
+
const proto = Object.getPrototypeOf(raw)
|
|
130
|
+
if (proto === Object.prototype || proto === null) {
|
|
131
|
+
const result: Record<string, unknown> = {}
|
|
132
|
+
for (const [key, item] of Object.entries(raw as Record<string, unknown>)) {
|
|
133
|
+
result[key] = deepClone(item)
|
|
134
|
+
}
|
|
135
|
+
return result as T
|
|
136
|
+
}
|
|
137
|
+
if (typeof structuredClone === 'function') {
|
|
138
|
+
try {
|
|
139
|
+
return structuredClone(raw)
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
// Non-cloneable value — keep as-is.
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return raw
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function createSubFieldDefault(subField: Field): unknown {
|
|
149
|
+
if (subField.type === 'repeater') {
|
|
150
|
+
return createRepeaterRows(subField)
|
|
151
|
+
}
|
|
152
|
+
return deepClone(createFieldDefault(subField))
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function createRowForRepeater(
|
|
156
|
+
field: RepeaterFieldConfig,
|
|
157
|
+
collapsed?: boolean,
|
|
158
|
+
): Record<string, unknown> {
|
|
159
|
+
const row: Record<string, unknown> = {}
|
|
160
|
+
for (const [key, subField] of Object.entries(field.subFields ?? {})) {
|
|
161
|
+
if (key === ROW_COLLAPSED_KEY || isLayoutOnlyFieldType(subField.type)) {
|
|
162
|
+
continue
|
|
163
|
+
}
|
|
164
|
+
row[key] = createSubFieldDefault(subField)
|
|
165
|
+
}
|
|
166
|
+
row[ROW_COLLAPSED_KEY] = collapsed ?? false
|
|
167
|
+
return row
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function createRepeaterRows(field: RepeaterFieldConfig): Record<string, unknown>[] {
|
|
171
|
+
const count = field.min ?? 0
|
|
172
|
+
const result: Record<string, unknown>[] = []
|
|
173
|
+
while (result.length < count) {
|
|
174
|
+
result.push(createRowForRepeater(field))
|
|
175
|
+
}
|
|
176
|
+
return result
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function createRow(): Record<string, unknown> {
|
|
180
|
+
return createRowForRepeater(props.field, false)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function normalizeRow(row: unknown, field: RepeaterFieldConfig): Record<string, unknown> {
|
|
184
|
+
if (!row || typeof row !== 'object' || Array.isArray(row)) {
|
|
185
|
+
return createRowForRepeater(field)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const source = row as Record<string, unknown>
|
|
189
|
+
let next = source
|
|
190
|
+
const assign = (key: string, value: unknown) => {
|
|
191
|
+
if (next === source) {
|
|
192
|
+
next = { ...source }
|
|
193
|
+
transferRowKey(source, next)
|
|
194
|
+
}
|
|
195
|
+
next[key] = value
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
for (const [key, subField] of Object.entries(field.subFields ?? {})) {
|
|
199
|
+
if (key === ROW_COLLAPSED_KEY || subField.type !== 'repeater') {
|
|
200
|
+
continue
|
|
201
|
+
}
|
|
202
|
+
const { rows: nestedRows, changed } = normalizeRepeaterValue(source[key], subField)
|
|
203
|
+
if (changed) {
|
|
204
|
+
assign(key, nestedRows)
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const collapsedValue = source[ROW_COLLAPSED_KEY]
|
|
209
|
+
if (resolveCollapsedKey(field)) {
|
|
210
|
+
if (typeof collapsedValue !== 'boolean') {
|
|
211
|
+
assign(ROW_COLLAPSED_KEY, false)
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
else if (ROW_COLLAPSED_KEY in source && typeof collapsedValue !== 'boolean') {
|
|
215
|
+
assign(ROW_COLLAPSED_KEY, collapsedValue === true)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return next
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function normalizeRepeaterValue(
|
|
222
|
+
value: unknown,
|
|
223
|
+
field: RepeaterFieldConfig,
|
|
224
|
+
): { rows: Record<string, unknown>[], changed: boolean } {
|
|
225
|
+
const source = Array.isArray(value) ? value : []
|
|
226
|
+
let changed = !Array.isArray(value)
|
|
227
|
+
|
|
228
|
+
const normalized = source.map((row) => {
|
|
229
|
+
const next = normalizeRow(row, field)
|
|
230
|
+
if (next !== row) {
|
|
231
|
+
changed = true
|
|
232
|
+
}
|
|
233
|
+
return next
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
const min = field.min ?? 0
|
|
237
|
+
while (normalized.length < min) {
|
|
238
|
+
normalized.push(createRowForRepeater(field))
|
|
239
|
+
changed = true
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return { rows: normalized, changed }
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function commit(next: Record<string, unknown>[]) {
|
|
246
|
+
rows.value = next
|
|
247
|
+
model.value = next
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function syncRowsFromModel() {
|
|
251
|
+
rows.value = normalizeRepeaterValue(model.value, props.field).rows
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function ensureModel() {
|
|
255
|
+
const { rows: normalized, changed } = normalizeRepeaterValue(model.value, props.field)
|
|
256
|
+
rows.value = normalized
|
|
257
|
+
if (changed) {
|
|
258
|
+
model.value = normalized
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
syncRowsFromModel()
|
|
263
|
+
|
|
264
|
+
onMounted(() => {
|
|
265
|
+
ensureModel()
|
|
266
|
+
watch(
|
|
267
|
+
[model, () => props.field],
|
|
268
|
+
() => {
|
|
269
|
+
ensureModel()
|
|
270
|
+
},
|
|
271
|
+
)
|
|
272
|
+
})
|
|
273
|
+
|
|
274
|
+
interface RowView {
|
|
275
|
+
row: Record<string, unknown>
|
|
276
|
+
key: number
|
|
277
|
+
expanded: boolean
|
|
278
|
+
visibleSubFields: Array<[string, Field]>
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
const rowViews = computed<RowView[]>(() =>
|
|
282
|
+
rows.value.map((row) => {
|
|
283
|
+
const expanded = !collapsible.value || !isRowCollapsed(row)
|
|
284
|
+
return {
|
|
285
|
+
row,
|
|
286
|
+
key: keyForRow(row),
|
|
287
|
+
expanded,
|
|
288
|
+
visibleSubFields: visibleSubFields(row, expanded),
|
|
289
|
+
}
|
|
290
|
+
}),
|
|
291
|
+
)
|
|
292
|
+
|
|
293
|
+
function visibleSubFields(row: Record<string, unknown>, expanded: boolean): Array<[string, Field]> {
|
|
294
|
+
return Object.entries(subFields.value).filter(([key, subField]) => {
|
|
295
|
+
if (!isVisible(subField.conditionalLogic, row)) {
|
|
296
|
+
return false
|
|
297
|
+
}
|
|
298
|
+
if (collapsible.value && !expanded) {
|
|
299
|
+
return key === collapsedKey.value
|
|
300
|
+
}
|
|
301
|
+
return true
|
|
302
|
+
})
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function subFieldKey(index: number, key: string): string {
|
|
306
|
+
return `${props.fieldKey}_${index}_${key}`
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function subFieldStyle(subField: Field, expanded: boolean, subKey: string) {
|
|
310
|
+
if (collapsible.value && !expanded && subKey === collapsedKey.value) {
|
|
311
|
+
return { width: '100%' }
|
|
312
|
+
}
|
|
313
|
+
return subField.columnWidth ? { width: `${subField.columnWidth}%` } : undefined
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function patchRow(index: number, patch: Record<string, unknown>) {
|
|
317
|
+
commit(rows.value.map((row, rowIndex) => {
|
|
318
|
+
if (rowIndex !== index) {
|
|
319
|
+
return row
|
|
320
|
+
}
|
|
321
|
+
const next = { ...row, ...patch }
|
|
322
|
+
transferRowKey(row, next)
|
|
323
|
+
return next
|
|
324
|
+
}))
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function updateRowValue(index: number, key: string, value: unknown) {
|
|
328
|
+
if (isLayoutOnlyFieldType(subFields.value[key]?.type ?? '')) {
|
|
329
|
+
return
|
|
330
|
+
}
|
|
331
|
+
patchRow(index, { [key]: value })
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function toggleRow(index: number) {
|
|
335
|
+
if (!collapsible.value) {
|
|
336
|
+
return
|
|
337
|
+
}
|
|
338
|
+
const row = rows.value[index]
|
|
339
|
+
if (!row) {
|
|
340
|
+
return
|
|
341
|
+
}
|
|
342
|
+
patchRow(index, { [ROW_COLLAPSED_KEY]: !isRowCollapsed(row) })
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function collapseAllRows() {
|
|
346
|
+
commit(rows.value.map((row) => {
|
|
347
|
+
if (row[ROW_COLLAPSED_KEY] === true) {
|
|
348
|
+
return row
|
|
349
|
+
}
|
|
350
|
+
const next = { ...row, [ROW_COLLAPSED_KEY]: true }
|
|
351
|
+
transferRowKey(row, next)
|
|
352
|
+
return next
|
|
353
|
+
}))
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function expandAllRows() {
|
|
357
|
+
commit(rows.value.map((row) => {
|
|
358
|
+
if (row[ROW_COLLAPSED_KEY] === false) {
|
|
359
|
+
return row
|
|
360
|
+
}
|
|
361
|
+
const next = { ...row, [ROW_COLLAPSED_KEY]: false }
|
|
362
|
+
transferRowKey(row, next)
|
|
363
|
+
return next
|
|
364
|
+
}))
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function insertRowAt(index: number, row: Record<string, unknown>) {
|
|
368
|
+
if (!canAdd.value) {
|
|
369
|
+
return
|
|
370
|
+
}
|
|
371
|
+
const rowToInsert = collapsible.value
|
|
372
|
+
? { ...row, [ROW_COLLAPSED_KEY]: false }
|
|
373
|
+
: row
|
|
374
|
+
const next = [...rows.value]
|
|
375
|
+
next.splice(index, 0, rowToInsert)
|
|
376
|
+
commit(next)
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
function addRowBefore(index: number) {
|
|
380
|
+
insertRowAt(index, createRow())
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function addRow() {
|
|
384
|
+
insertRowAt(rows.value.length, createRow())
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
function duplicateRow(index: number) {
|
|
388
|
+
const source = rows.value[index]
|
|
389
|
+
if (!source) {
|
|
390
|
+
return
|
|
391
|
+
}
|
|
392
|
+
const copy = deepClone(source)
|
|
393
|
+
insertRowAt(index + 1, copy)
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
function removeRow(index: number) {
|
|
397
|
+
if (!canRemove.value) {
|
|
398
|
+
return
|
|
399
|
+
}
|
|
400
|
+
commit(rows.value.filter((_, rowIndex) => rowIndex !== index))
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
function reorderRows(fromIndex: number, toIndex: number) {
|
|
404
|
+
const length = rows.value.length
|
|
405
|
+
if (
|
|
406
|
+
fromIndex === toIndex
|
|
407
|
+
|| fromIndex < 0 || fromIndex >= length
|
|
408
|
+
|| toIndex < 0 || toIndex >= length
|
|
409
|
+
) {
|
|
410
|
+
return
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
const next = [...rows.value]
|
|
414
|
+
const [movedRow] = next.splice(fromIndex, 1)
|
|
415
|
+
if (movedRow === undefined) {
|
|
416
|
+
return
|
|
417
|
+
}
|
|
418
|
+
next.splice(toIndex, 0, movedRow)
|
|
419
|
+
commit(next)
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
function reorderToInsert(from: number, insertAt: number) {
|
|
423
|
+
const length = rows.value.length
|
|
424
|
+
if (
|
|
425
|
+
from < 0 || from >= length
|
|
426
|
+
|| insertAt < 0 || insertAt > length
|
|
427
|
+
|| insertAt === from || insertAt === from + 1
|
|
428
|
+
) {
|
|
429
|
+
return
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
const next = [...rows.value]
|
|
433
|
+
const [movedRow] = next.splice(from, 1)
|
|
434
|
+
if (movedRow === undefined) {
|
|
435
|
+
return
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
let target = insertAt
|
|
439
|
+
if (from < insertAt) {
|
|
440
|
+
target -= 1
|
|
441
|
+
}
|
|
442
|
+
next.splice(target, 0, movedRow)
|
|
443
|
+
commit(next)
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
function moveRow(index: number, direction: -1 | 1) {
|
|
447
|
+
reorderRows(index, index + direction)
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
const dragPlaceholderStyle = computed(() => ({
|
|
451
|
+
width: `${dragSize.value.width}px`,
|
|
452
|
+
height: `${dragSize.value.height}px`,
|
|
453
|
+
}))
|
|
454
|
+
|
|
455
|
+
function setRowRef(el: Element | null, index: number) {
|
|
456
|
+
rowRefs.value[index] = el instanceof HTMLElement ? el : null
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
function rowDragStyle(index: number): CSSProperties | undefined {
|
|
460
|
+
if (!isDragging.value || draggingIndex.value !== index) {
|
|
461
|
+
return undefined
|
|
462
|
+
}
|
|
463
|
+
return {
|
|
464
|
+
position: 'fixed',
|
|
465
|
+
left: `${dragPosition.value.left}px`,
|
|
466
|
+
top: `${dragPosition.value.top}px`,
|
|
467
|
+
width: `${dragSize.value.width}px`,
|
|
468
|
+
height: `${dragSize.value.height}px`,
|
|
469
|
+
zIndex: 1000,
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
function updateDropTargetFromPoint(clientY: number) {
|
|
474
|
+
const from = draggingIndex.value
|
|
475
|
+
if (from === null) {
|
|
476
|
+
return
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
let insertAt = rows.value.length
|
|
480
|
+
|
|
481
|
+
for (let i = 0; i < rows.value.length; i++) {
|
|
482
|
+
if (i === from) {
|
|
483
|
+
continue
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
const el = rowRefs.value[i]
|
|
487
|
+
if (!el) {
|
|
488
|
+
continue
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
const rect = el.getBoundingClientRect()
|
|
492
|
+
if (clientY < rect.top + rect.height / 2) {
|
|
493
|
+
insertAt = i
|
|
494
|
+
break
|
|
495
|
+
}
|
|
496
|
+
insertAt = i + 1
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
dropTargetIndex.value = Math.max(0, Math.min(insertAt, rows.value.length))
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
function onDocumentMouseMove(event: MouseEvent) {
|
|
503
|
+
if (!isDragging.value) {
|
|
504
|
+
return
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
dragPosition.value = {
|
|
508
|
+
left: event.clientX - dragOffset.value.x,
|
|
509
|
+
top: event.clientY - dragOffset.value.y,
|
|
510
|
+
}
|
|
511
|
+
updateDropTargetFromPoint(event.clientY)
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
function onDocumentMouseUp() {
|
|
515
|
+
if (!isDragging.value || draggingIndex.value === null) {
|
|
516
|
+
return
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
reorderToInsert(draggingIndex.value, dropTargetIndex.value)
|
|
520
|
+
resetDrag()
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
function onHandleMouseDown(index: number, event: MouseEvent) {
|
|
524
|
+
if (event.button !== 0) {
|
|
525
|
+
return
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
event.preventDefault()
|
|
529
|
+
event.stopPropagation()
|
|
530
|
+
|
|
531
|
+
const handle = event.currentTarget
|
|
532
|
+
if (!(handle instanceof HTMLElement)) {
|
|
533
|
+
return
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
const rowEl = handle.closest<HTMLElement>(`.${rootClass}__row`)
|
|
537
|
+
if (!rowEl) {
|
|
538
|
+
return
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
const rect = rowEl.getBoundingClientRect()
|
|
542
|
+
draggingIndex.value = index
|
|
543
|
+
dropTargetIndex.value = index
|
|
544
|
+
dragOffset.value = {
|
|
545
|
+
x: event.clientX - rect.left,
|
|
546
|
+
y: event.clientY - rect.top,
|
|
547
|
+
}
|
|
548
|
+
dragSize.value = {
|
|
549
|
+
width: rect.width,
|
|
550
|
+
height: rect.height,
|
|
551
|
+
}
|
|
552
|
+
dragPosition.value = {
|
|
553
|
+
left: rect.left,
|
|
554
|
+
top: rect.top,
|
|
555
|
+
}
|
|
556
|
+
isDragging.value = true
|
|
557
|
+
|
|
558
|
+
document.body.style.userSelect = 'none'
|
|
559
|
+
document.addEventListener('mousemove', onDocumentMouseMove)
|
|
560
|
+
document.addEventListener('mouseup', onDocumentMouseUp)
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
function resetDrag() {
|
|
564
|
+
isDragging.value = false
|
|
565
|
+
draggingIndex.value = null
|
|
566
|
+
dropTargetIndex.value = 0
|
|
567
|
+
dragSize.value = { width: 0, height: 0 }
|
|
568
|
+
document.body.style.userSelect = ''
|
|
569
|
+
document.removeEventListener('mousemove', onDocumentMouseMove)
|
|
570
|
+
document.removeEventListener('mouseup', onDocumentMouseUp)
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
onBeforeUnmount(() => {
|
|
574
|
+
resetDrag()
|
|
575
|
+
})
|
|
576
|
+
</script>
|
|
577
|
+
|
|
578
|
+
<template>
|
|
579
|
+
<KateCmsFieldWrapper
|
|
580
|
+
:field-key="fieldKey"
|
|
581
|
+
:field="field"
|
|
582
|
+
label-tag="div"
|
|
583
|
+
>
|
|
584
|
+
<div :class="rootClass">
|
|
585
|
+
<div
|
|
586
|
+
v-if="!Object.keys(subFields).length"
|
|
587
|
+
:class="`${rootClass}__hint`"
|
|
588
|
+
>
|
|
589
|
+
No subfields defined.
|
|
590
|
+
</div>
|
|
591
|
+
|
|
592
|
+
<div
|
|
593
|
+
v-else
|
|
594
|
+
ref="rowsContainerRef"
|
|
595
|
+
:class="`${rootClass}__rows`"
|
|
596
|
+
>
|
|
597
|
+
<template
|
|
598
|
+
v-for="(view, index) in rowViews"
|
|
599
|
+
:key="view.key"
|
|
600
|
+
>
|
|
601
|
+
<div
|
|
602
|
+
v-if="isDragging && dropTargetIndex === index"
|
|
603
|
+
:class="`${rootClass}__drop-placeholder`"
|
|
604
|
+
:style="dragPlaceholderStyle"
|
|
605
|
+
/>
|
|
606
|
+
|
|
607
|
+
<div
|
|
608
|
+
:ref="(el) => setRowRef(el as Element | null, index)"
|
|
609
|
+
:class="[
|
|
610
|
+
`${rootClass}__row`,
|
|
611
|
+
{ 'is-floating': isDragging && draggingIndex === index },
|
|
612
|
+
]"
|
|
613
|
+
:style="rowDragStyle(index)"
|
|
614
|
+
>
|
|
615
|
+
<button
|
|
616
|
+
v-if="collapsible"
|
|
617
|
+
type="button"
|
|
618
|
+
:class="`${rootClass}__toggle`"
|
|
619
|
+
:aria-label="view.expanded ? 'Collapse row' : 'Expand row'"
|
|
620
|
+
:title="view.expanded ? 'Collapse row' : 'Expand row'"
|
|
621
|
+
:aria-expanded="view.expanded"
|
|
622
|
+
@click="toggleRow(index)"
|
|
623
|
+
>
|
|
624
|
+
<svg
|
|
625
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
626
|
+
viewBox="0 0 640 640"
|
|
627
|
+
:class="[{ 'is-open': view.expanded }]"
|
|
628
|
+
>
|
|
629
|
+
<path
|
|
630
|
+
d="M297.4 470.6C309.9 483.1 330.2 483.1 342.7 470.6L534.7 278.6C547.2 266.1 547.2 245.8 534.7 233.3C522.2 220.8 501.9 220.8 489.4 233.3L320 402.7L150.6 233.4C138.1 220.9 117.8 220.9 105.3 233.4C92.8 245.9 92.8 266.2 105.3 278.7L297.3 470.7z"
|
|
631
|
+
/>
|
|
632
|
+
</svg>
|
|
633
|
+
</button>
|
|
634
|
+
|
|
635
|
+
<button
|
|
636
|
+
:class="`${rootClass}__handle`"
|
|
637
|
+
type="button"
|
|
638
|
+
aria-label="Drag to reorder"
|
|
639
|
+
title="Drag to reorder"
|
|
640
|
+
@mousedown="onHandleMouseDown(index, $event)"
|
|
641
|
+
v-text="index + 1"
|
|
642
|
+
/>
|
|
643
|
+
|
|
644
|
+
<div :class="`${rootClass}__row-wrap`">
|
|
645
|
+
<div
|
|
646
|
+
v-if="view.visibleSubFields.length"
|
|
647
|
+
:class="`${rootClass}__row-body`"
|
|
648
|
+
>
|
|
649
|
+
<div
|
|
650
|
+
v-for="[subKey, subField] in view.visibleSubFields"
|
|
651
|
+
:key="subKey"
|
|
652
|
+
:class="`${rootClass}__sub-field`"
|
|
653
|
+
:style="subFieldStyle(subField, view.expanded, subKey)"
|
|
654
|
+
>
|
|
655
|
+
<component
|
|
656
|
+
:is="resolveField(subField.type)"
|
|
657
|
+
:model-value="view.row[subKey]"
|
|
658
|
+
:field-key="subFieldKey(index, subKey)"
|
|
659
|
+
:field="subField"
|
|
660
|
+
@update:model-value="updateRowValue(index, subKey, $event)"
|
|
661
|
+
/>
|
|
662
|
+
</div>
|
|
663
|
+
</div>
|
|
664
|
+
</div>
|
|
665
|
+
|
|
666
|
+
<div :class="`${rootClass}__row-options`">
|
|
667
|
+
<div :class="`${rootClass}__row-options-wrap`">
|
|
668
|
+
<button
|
|
669
|
+
type="button"
|
|
670
|
+
:class="`${rootClass}__btn`"
|
|
671
|
+
:disabled="!canAdd"
|
|
672
|
+
aria-label="Add row"
|
|
673
|
+
title="Add row"
|
|
674
|
+
@click="addRowBefore(index)"
|
|
675
|
+
>
|
|
676
|
+
<svg
|
|
677
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
678
|
+
viewBox="0 0 640 640"
|
|
679
|
+
>
|
|
680
|
+
<path
|
|
681
|
+
d="M352 128C352 110.3 337.7 96 320 96C302.3 96 288 110.3 288 128L288 288L128 288C110.3 288 96 302.3 96 320C96 337.7 110.3 352 128 352L288 352L288 512C288 529.7 302.3 544 320 544C337.7 544 352 529.7 352 512L352 352L512 352C529.7 352 544 337.7 544 320C544 302.3 529.7 288 512 288L352 288L352 128z"
|
|
682
|
+
/>
|
|
683
|
+
</svg>
|
|
684
|
+
</button>
|
|
685
|
+
<button
|
|
686
|
+
type="button"
|
|
687
|
+
:class="`${rootClass}__btn`"
|
|
688
|
+
:disabled="!canAdd"
|
|
689
|
+
aria-label="Duplicate row"
|
|
690
|
+
title="Duplicate row"
|
|
691
|
+
@click="duplicateRow(index)"
|
|
692
|
+
>
|
|
693
|
+
<svg
|
|
694
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
695
|
+
viewBox="0 0 640 640"
|
|
696
|
+
>
|
|
697
|
+
<path
|
|
698
|
+
d="M352 528L128 528C119.2 528 112 520.8 112 512L112 288C112 279.2 119.2 272 128 272L176 272L176 224L128 224C92.7 224 64 252.7 64 288L64 512C64 547.3 92.7 576 128 576L352 576C387.3 576 416 547.3 416 512L416 464L368 464L368 512C368 520.8 360.8 528 352 528zM288 368C279.2 368 272 360.8 272 352L272 128C272 119.2 279.2 112 288 112L512 112C520.8 112 528 119.2 528 128L528 352C528 360.8 520.8 368 512 368L288 368zM224 352C224 387.3 252.7 416 288 416L512 416C547.3 416 576 387.3 576 352L576 128C576 92.7 547.3 64 512 64L288 64C252.7 64 224 92.7 224 128L224 352z"
|
|
699
|
+
/>
|
|
700
|
+
</svg>
|
|
701
|
+
</button>
|
|
702
|
+
<button
|
|
703
|
+
type="button"
|
|
704
|
+
:class="`${rootClass}__btn`"
|
|
705
|
+
:disabled="index === 0"
|
|
706
|
+
aria-label="Move up"
|
|
707
|
+
title="Move up"
|
|
708
|
+
@click="moveRow(index, -1)"
|
|
709
|
+
>
|
|
710
|
+
<svg
|
|
711
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
712
|
+
viewBox="0 0 640 640"
|
|
713
|
+
>
|
|
714
|
+
<path
|
|
715
|
+
d="M342.6 73.4C330.1 60.9 309.8 60.9 297.3 73.4L137.3 233.4C124.8 245.9 124.8 266.2 137.3 278.7C149.8 291.2 170.1 291.2 182.6 278.7L288 173.3L288 544C288 561.7 302.3 576 320 576C337.7 576 352 561.7 352 544L352 173.3L457.4 278.7C469.9 291.2 490.2 291.2 502.7 278.7C515.2 266.2 515.2 245.9 502.7 233.4L342.7 73.4z"
|
|
716
|
+
/>
|
|
717
|
+
</svg>
|
|
718
|
+
</button>
|
|
719
|
+
<button
|
|
720
|
+
type="button"
|
|
721
|
+
:class="`${rootClass}__btn`"
|
|
722
|
+
:disabled="!canRemove"
|
|
723
|
+
aria-label="Remove row"
|
|
724
|
+
title="Remove row"
|
|
725
|
+
@click="removeRow(index)"
|
|
726
|
+
>
|
|
727
|
+
<svg
|
|
728
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
729
|
+
viewBox="0 0 640 640"
|
|
730
|
+
>
|
|
731
|
+
<path
|
|
732
|
+
d="M183.1 137.4C170.6 124.9 150.3 124.9 137.8 137.4C125.3 149.9 125.3 170.2 137.8 182.7L275.2 320L137.9 457.4C125.4 469.9 125.4 490.2 137.9 502.7C150.4 515.2 170.7 515.2 183.2 502.7L320.5 365.3L457.9 502.6C470.4 515.1 490.7 515.1 503.2 502.6C515.7 490.1 515.7 469.8 503.2 457.3L365.8 320L503.1 182.6C515.6 170.1 515.6 149.8 503.1 137.3C490.6 124.8 470.3 124.8 457.8 137.3L320.5 274.7L183.1 137.4z"
|
|
733
|
+
/>
|
|
734
|
+
</svg>
|
|
735
|
+
</button>
|
|
736
|
+
<button
|
|
737
|
+
type="button"
|
|
738
|
+
:class="`${rootClass}__btn`"
|
|
739
|
+
:disabled="index === rows.length - 1"
|
|
740
|
+
aria-label="Move down"
|
|
741
|
+
title="Move down"
|
|
742
|
+
@click="moveRow(index, 1)"
|
|
743
|
+
>
|
|
744
|
+
<svg
|
|
745
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
746
|
+
viewBox="0 0 640 640"
|
|
747
|
+
>
|
|
748
|
+
<path
|
|
749
|
+
d="M297.4 566.6C309.9 579.1 330.2 579.1 342.7 566.6L502.7 406.6C515.2 394.1 515.2 373.8 502.7 361.3C490.2 348.8 469.9 348.8 457.4 361.3L352 466.7L352 96C352 78.3 337.7 64 320 64C302.3 64 288 78.3 288 96L288 466.7L182.6 361.3C170.1 348.8 149.8 348.8 137.3 361.3C124.8 373.8 124.8 394.1 137.3 406.6L297.3 566.6z"
|
|
750
|
+
/>
|
|
751
|
+
</svg>
|
|
752
|
+
</button>
|
|
753
|
+
</div>
|
|
754
|
+
</div>
|
|
755
|
+
</div>
|
|
756
|
+
</template>
|
|
757
|
+
|
|
758
|
+
<div
|
|
759
|
+
v-if="isDragging && dropTargetIndex === rowViews.length"
|
|
760
|
+
:class="`${rootClass}__drop-placeholder`"
|
|
761
|
+
:style="dragPlaceholderStyle"
|
|
762
|
+
/>
|
|
763
|
+
</div>
|
|
764
|
+
|
|
765
|
+
<div
|
|
766
|
+
v-if="Object.keys(subFields).length"
|
|
767
|
+
:class="`${rootClass}__toolbar`"
|
|
768
|
+
>
|
|
769
|
+
<div
|
|
770
|
+
v-if="showCollapseAll || showExpandAll"
|
|
771
|
+
:class="`${rootClass}__toggle-all-group`"
|
|
772
|
+
>
|
|
773
|
+
<KateCmsUiButton
|
|
774
|
+
v-if="showCollapseAll"
|
|
775
|
+
tag="button"
|
|
776
|
+
:variant="['secondary', 'small']"
|
|
777
|
+
@click="collapseAllRows"
|
|
778
|
+
>
|
|
779
|
+
Collapse all
|
|
780
|
+
</KateCmsUiButton>
|
|
781
|
+
<KateCmsUiButton
|
|
782
|
+
v-if="showExpandAll"
|
|
783
|
+
tag="button"
|
|
784
|
+
:variant="['secondary', 'small']"
|
|
785
|
+
@click="expandAllRows"
|
|
786
|
+
>
|
|
787
|
+
Expand all
|
|
788
|
+
</KateCmsUiButton>
|
|
789
|
+
</div>
|
|
790
|
+
<KateCmsUiButton
|
|
791
|
+
tag="button"
|
|
792
|
+
variant="small"
|
|
793
|
+
:disabled="!canAdd"
|
|
794
|
+
@click="addRow"
|
|
795
|
+
>
|
|
796
|
+
{{ buttonLabel }}
|
|
797
|
+
</KateCmsUiButton>
|
|
798
|
+
</div>
|
|
799
|
+
</div>
|
|
800
|
+
</KateCmsFieldWrapper>
|
|
801
|
+
</template>
|
|
802
|
+
|
|
803
|
+
<style scoped lang="scss">
|
|
804
|
+
@use "../../assets/styles" as *;
|
|
805
|
+
|
|
806
|
+
$root: '.katecms-repeater-field';
|
|
807
|
+
|
|
808
|
+
#{$root} {
|
|
809
|
+
display: flex;
|
|
810
|
+
flex-direction: column;
|
|
811
|
+
gap: math-rem(12);
|
|
812
|
+
|
|
813
|
+
&__hint {
|
|
814
|
+
margin: 0;
|
|
815
|
+
color: $color-muted;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
&__rows {
|
|
819
|
+
display: flex;
|
|
820
|
+
flex-direction: column;
|
|
821
|
+
gap: math-rem(10);
|
|
822
|
+
position: relative;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
&__drop {
|
|
826
|
+
&-placeholder {
|
|
827
|
+
flex-shrink: 0;
|
|
828
|
+
box-sizing: border-box;
|
|
829
|
+
border: 1px dashed $color-border;
|
|
830
|
+
border-radius: $border-radius;
|
|
831
|
+
background-color: $color-bg;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
&__row {
|
|
836
|
+
position: relative;
|
|
837
|
+
display: flex;
|
|
838
|
+
flex-wrap: wrap;
|
|
839
|
+
column-gap: math-rem(4);
|
|
840
|
+
border: 1px solid $color-border;
|
|
841
|
+
border-radius: $border-radius;
|
|
842
|
+
background-color: $color-surface;
|
|
843
|
+
|
|
844
|
+
&.is-floating {
|
|
845
|
+
box-shadow: $shadow-md;
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
&-wrap {
|
|
849
|
+
flex-basis: 0;
|
|
850
|
+
flex-grow: 1;
|
|
851
|
+
max-width: 100%;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
&-options {
|
|
855
|
+
flex: 0 0 32px;
|
|
856
|
+
background-color: $color-bg;
|
|
857
|
+
border-left: 1px solid $color-border;
|
|
858
|
+
border-radius: 0 $border-radius $border-radius 0;
|
|
859
|
+
|
|
860
|
+
&-wrap {
|
|
861
|
+
display: flex;
|
|
862
|
+
flex-direction: column;
|
|
863
|
+
height: 100%;
|
|
864
|
+
max-height: 90px;
|
|
865
|
+
position: sticky;
|
|
866
|
+
top: 0;
|
|
867
|
+
|
|
868
|
+
> #{$root} {
|
|
869
|
+
&__btn {
|
|
870
|
+
&:first-child {
|
|
871
|
+
border-radius: 0 $border-radius-inter 0 0;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
&-body {
|
|
879
|
+
display: flex;
|
|
880
|
+
flex-wrap: wrap;
|
|
881
|
+
gap: math-rem(16) 0;
|
|
882
|
+
padding: math-rem(12) math-rem(8);
|
|
883
|
+
margin-left: math-rem(-8);
|
|
884
|
+
margin-right: math-rem(-8);
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
&__handle {
|
|
889
|
+
flex: 0 0 32px;
|
|
890
|
+
cursor: move;
|
|
891
|
+
background-color: $color-bg;
|
|
892
|
+
font-size: math-rem(14);
|
|
893
|
+
color: $color-muted;
|
|
894
|
+
display: flex;
|
|
895
|
+
justify-content: center;
|
|
896
|
+
align-items: center;
|
|
897
|
+
border: 0;
|
|
898
|
+
border-right: 1px solid $color-border;
|
|
899
|
+
padding: 0;
|
|
900
|
+
margin: 0;
|
|
901
|
+
border-radius: $border-radius-inter 0 0 $border-radius-inter;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
&__btn {
|
|
905
|
+
display: flex;
|
|
906
|
+
align-items: center;
|
|
907
|
+
justify-content: center;
|
|
908
|
+
padding: 0;
|
|
909
|
+
margin: 0;
|
|
910
|
+
border-radius: 0;
|
|
911
|
+
border: none;
|
|
912
|
+
background-color: $color-bg;
|
|
913
|
+
flex-basis: 0;
|
|
914
|
+
flex-grow: 1;
|
|
915
|
+
cursor: pointer;
|
|
916
|
+
|
|
917
|
+
&:not(:last-child) {
|
|
918
|
+
border-bottom: 1px solid $color-border;
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
&[disabled] {
|
|
922
|
+
cursor: not-allowed;
|
|
923
|
+
|
|
924
|
+
svg {
|
|
925
|
+
opacity: .3;
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
&:not([disabled]):hover {
|
|
930
|
+
background-color: $color-accent-wash;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
svg {
|
|
934
|
+
width: 12px;
|
|
935
|
+
height: 12px;
|
|
936
|
+
fill: $color-ink;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
&__toggle {
|
|
941
|
+
position: absolute;
|
|
942
|
+
top: 0;
|
|
943
|
+
left: 0;
|
|
944
|
+
width: 32px;
|
|
945
|
+
height: 32px;
|
|
946
|
+
display: flex;
|
|
947
|
+
align-items: center;
|
|
948
|
+
justify-content: center;
|
|
949
|
+
padding: 0;
|
|
950
|
+
margin: 0;
|
|
951
|
+
border-radius: $border-radius-inter 0 0 0;
|
|
952
|
+
border: 0;
|
|
953
|
+
border-bottom: 1px solid $color-border;
|
|
954
|
+
border-right: 1px solid $color-border;
|
|
955
|
+
background-color: $color-bg;
|
|
956
|
+
z-index: 5;
|
|
957
|
+
cursor: pointer;
|
|
958
|
+
|
|
959
|
+
&:hover {
|
|
960
|
+
background-color: $color-accent-wash;
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
svg {
|
|
964
|
+
width: 12px;
|
|
965
|
+
height: 12px;
|
|
966
|
+
fill: $color-ink;
|
|
967
|
+
transition: transform .3s;
|
|
968
|
+
|
|
969
|
+
&.is-open {
|
|
970
|
+
transform: rotate(-180deg);
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
&-all {
|
|
975
|
+
&-group {
|
|
976
|
+
display: flex;
|
|
977
|
+
flex-wrap: wrap;
|
|
978
|
+
gap: math-rem(8);
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
&__sub {
|
|
984
|
+
&-field {
|
|
985
|
+
padding-left: math-rem(8);
|
|
986
|
+
padding-right: math-rem(8);
|
|
987
|
+
width: 100%;
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
&__toolbar {
|
|
992
|
+
display: flex;
|
|
993
|
+
flex-wrap: wrap;
|
|
994
|
+
align-items: center;
|
|
995
|
+
justify-content: space-between;
|
|
996
|
+
gap: math-rem(8);
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
</style>
|