@autoafleveren/ui 1.3.2 → 1.4.0
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/dist/config/tailwind/config.cjs +1 -0
- package/dist/icons.cjs +17 -17
- package/dist/icons.js +1710 -1644
- package/dist/types/components/AppActionBar/AppActionBarItem.vue.d.ts +4 -0
- package/dist/types/composables/index.d.ts +2 -1
- package/dist/types/composables/useActionBar/index.d.ts +3 -3
- package/dist/types/composables/useFocusTrap/index.d.ts +10 -0
- package/dist/ui-storybook.css +1 -1
- package/dist/ui.cjs +47 -40
- package/dist/ui.js +12385 -11552
- package/package.json +5 -2
- package/src/App.vue +15 -0
- package/src/Playground.vue.example +9 -0
- package/src/config/eslint.cjs +199 -0
- package/src/config/tailwind/config.cjs +229 -0
- package/src/config/tailwind/screens.json +9 -0
- package/src/css/build.css +52 -0
- package/src/css/main.css +4 -0
- package/src/css/theme.css +208 -0
- package/src/css/tinymce.css +58 -0
- package/src/main.ts +34 -0
- package/src/modules/components/AppActionBar/AppActionBar.vue +96 -0
- package/src/modules/components/AppActionBar/AppActionBarItem.vue +149 -0
- package/src/modules/components/AppActionBar/AppActionBarSubMenu.vue +89 -0
- package/src/modules/components/AppActionBar/Components/Error.vue +11 -0
- package/src/modules/components/AppActionBar/Components/Loading.vue +9 -0
- package/src/modules/components/AppActionBar/Components/MultiSelect.vue +102 -0
- package/src/modules/components/AppActionBar/Components/__tests__/multi-select.spec.ts +74 -0
- package/src/modules/components/AppActionBar/__mocks__/index.ts +36 -0
- package/src/modules/components/AppActionBar/__tests__/app-action-bar-item.spec.ts +134 -0
- package/src/modules/components/AppActionBar/__tests__/app-action-bar-sub-menu.spec.ts +45 -0
- package/src/modules/components/AppActionBar/__tests__/app-action-bar.spec.ts +92 -0
- package/src/modules/components/AppActionBar/index.d.ts +29 -0
- package/src/modules/components/AppActionBar/index.ts +18 -0
- package/src/modules/components/AppAlert/AppAlert.vue +69 -0
- package/src/modules/components/AppAlert/__tests__/app-alert.spec.ts +67 -0
- package/src/modules/components/AppAlert/index.d.ts +3 -0
- package/src/modules/components/AppAlert/index.ts +18 -0
- package/src/modules/components/AppAvatar/AppAvatar.vue +30 -0
- package/src/modules/components/AppAvatar/DefaultAvatar.vue +187 -0
- package/src/modules/components/AppAvatar/__tests__/app-avatar.spec.ts +70 -0
- package/src/modules/components/AppAvatar/index.d.ts +9 -0
- package/src/modules/components/AppAvatar/index.ts +9 -0
- package/src/modules/components/AppBackButton/AppBackButton.vue +51 -0
- package/src/modules/components/AppBackButton/__tests__/app-back-button.spec.ts +70 -0
- package/src/modules/components/AppBadge/AppBadge.vue +65 -0
- package/src/modules/components/AppBadge/__tests__/app-badge.spec.ts +64 -0
- package/src/modules/components/AppBadge/index.d.ts +13 -0
- package/src/modules/components/AppBadge/index.ts +29 -0
- package/src/modules/components/AppButton/AppButton.vue +53 -0
- package/src/modules/components/AppButton/ButtonIconSlot.vue +26 -0
- package/src/modules/components/AppButton/__tests__/app-button.spec.ts +145 -0
- package/src/modules/components/AppButton/__tests__/button-icon-slot.spec.ts +30 -0
- package/src/modules/components/AppButton/index.d.ts +16 -0
- package/src/modules/components/AppButton/index.ts +57 -0
- package/src/modules/components/AppCard/AppCard.vue +88 -0
- package/src/modules/components/AppCard/CardAction.vue +101 -0
- package/src/modules/components/AppCard/CardIconSlot.vue +65 -0
- package/src/modules/components/AppCard/__tests__/app-card.spec.ts +109 -0
- package/src/modules/components/AppCard/__tests__/card-action.spec.ts +55 -0
- package/src/modules/components/AppCard/__tests__/card-icon-slot.spec.ts +27 -0
- package/src/modules/components/AppCard/index.d.ts +12 -0
- package/src/modules/components/AppCard/index.ts +5 -0
- package/src/modules/components/AppColor/AppColor.vue +74 -0
- package/src/modules/components/AppColor/__tests__/app-color.spec.ts +53 -0
- package/src/modules/components/AppColor/index.d.ts +10 -0
- package/src/modules/components/AppColorCard/AppColorCard.vue +41 -0
- package/src/modules/components/AppColorCard/__tests__/app-color-card.spec.ts +55 -0
- package/src/modules/components/AppConfirm/AppConfirm.vue +237 -0
- package/src/modules/components/AppConfirm/__tests__/app-confirm.spec.ts +366 -0
- package/src/modules/components/AppConfirm/index.d.ts +31 -0
- package/src/modules/components/AppConfirm/index.ts +1 -0
- package/src/modules/components/AppContextMenu/AppContextMenu.vue +109 -0
- package/src/modules/components/AppContextMenu/ShortcutItem.vue +38 -0
- package/src/modules/components/AppContextMenu/__mocks__/index.ts +25 -0
- package/src/modules/components/AppContextMenu/__tests__/app-context-menu.spec.ts +71 -0
- package/src/modules/components/AppContextMenu/__tests__/shortcut-item.spec.ts +29 -0
- package/src/modules/components/AppContextMenu/index.d.ts +23 -0
- package/src/modules/components/AppDataTable/AppDataTable.vue +323 -0
- package/src/modules/components/AppDataTable/AppDataTableFooter.vue +91 -0
- package/src/modules/components/AppDataTable/__mocks__/index.ts +71 -0
- package/src/modules/components/AppDataTable/__tests__/app-data-table-footer.spec.ts +107 -0
- package/src/modules/components/AppDataTable/__tests__/app-data-table.spec.ts +153 -0
- package/src/modules/components/AppDataTable/index.d.ts +29 -0
- package/src/modules/components/AppDefinitionList/AppDefinitionItem.vue +57 -0
- package/src/modules/components/AppDefinitionList/AppDefinitionList.vue +32 -0
- package/src/modules/components/AppDefinitionList/__mocks__/index.ts +31 -0
- package/src/modules/components/AppDefinitionList/__tests__/app-definition-item.spec.ts +93 -0
- package/src/modules/components/AppDefinitionList/__tests__/app-definition-list.spec.ts +35 -0
- package/src/modules/components/AppDefinitionList/index.d.ts +8 -0
- package/src/modules/components/AppDisclosure/AppDisclosure.vue +19 -0
- package/src/modules/components/AppDisclosure/AppDisclosureButton.vue +43 -0
- package/src/modules/components/AppDisclosure/AppDisclosurePanel.vue +31 -0
- package/src/modules/components/AppDisclosure/__tests__/app-disclosure-button.spec.ts +70 -0
- package/src/modules/components/AppDisclosure/__tests__/app-disclosure-panel.spec.ts +64 -0
- package/src/modules/components/AppDisclosure/__tests__/app-disclosure.spec.ts +41 -0
- package/src/modules/components/AppDrawer/AppDrawer.vue +149 -0
- package/src/modules/components/AppDrawer/__tests__/app-drawer.spec.ts +120 -0
- package/src/modules/components/AppDrawer/index.d.ts +27 -0
- package/src/modules/components/AppDropdownButton/AppDropdownButton.vue +82 -0
- package/src/modules/components/AppDropdownButton/AppDropdownItem.vue +67 -0
- package/src/modules/components/AppDropdownButton/__mocks__/index.ts +25 -0
- package/src/modules/components/AppDropdownButton/__tests__/app-dropdown-button.spec.ts +81 -0
- package/src/modules/components/AppDropdownButton/__tests__/app-dropdown-item.spec.ts +108 -0
- package/src/modules/components/AppDropdownButton/index.d.ts +26 -0
- package/src/modules/components/AppDropdownButton/index.ts +8 -0
- package/src/modules/components/AppError/AppError.vue +233 -0
- package/src/modules/components/AppError/__tests__/app-error.spec.ts +366 -0
- package/src/modules/components/AppError/index.d.ts +30 -0
- package/src/modules/components/AppError/index.ts +1 -0
- package/src/modules/components/AppImageDropzone/AppImageDropzone.vue +130 -0
- package/src/modules/components/AppImageDropzone/__tests__/app-image-dropzone.spec.ts +92 -0
- package/src/modules/components/AppImageDropzone/index.d.ts +8 -0
- package/src/modules/components/AppInput/AppInput.vue +247 -0
- package/src/modules/components/AppInput/FileInput.vue +58 -0
- package/src/modules/components/AppInput/Input.vue +141 -0
- package/src/modules/components/AppInput/InputIconSlot.vue +27 -0
- package/src/modules/components/AppInput/LocationInput.vue +150 -0
- package/src/modules/components/AppInput/__mocks__/location.ts +13 -0
- package/src/modules/components/AppInput/__tests__/app-input.spec.ts +255 -0
- package/src/modules/components/AppInput/__tests__/file-input.spec.ts +48 -0
- package/src/modules/components/AppInput/__tests__/input-icon-slot.spec.ts +27 -0
- package/src/modules/components/AppInput/__tests__/input.spec.ts +260 -0
- package/src/modules/components/AppInput/__tests__/location-input.spec.ts +159 -0
- package/src/modules/components/AppInput/choice.ts +24 -0
- package/src/modules/components/AppInput/datepicker.ts +62 -0
- package/src/modules/components/AppInput/index.d.ts +68 -0
- package/src/modules/components/AppInput/index.ts +133 -0
- package/src/modules/components/AppInput/location.ts +8 -0
- package/src/modules/components/AppInput/richText.ts +45 -0
- package/src/modules/components/AppInputLabel/AppInputLabel.vue +15 -0
- package/src/modules/components/AppInputLabel/__tests__/app-input-label.spec.ts +38 -0
- package/src/modules/components/AppInputLabel/index.d.ts +6 -0
- package/src/modules/components/AppLicensePlate/AppLicensePlate.vue +34 -0
- package/src/modules/components/AppLicensePlate/__tests__/app-license-plate.spec.ts +46 -0
- package/src/modules/components/AppLicensePlate/index.d.ts +1 -0
- package/src/modules/components/AppLoader/AppLoader.vue +37 -0
- package/src/modules/components/AppLoader/index.d.ts +1 -0
- package/src/modules/components/AppLoader/index.ts +8 -0
- package/src/modules/components/AppMaps/AppMaps.vue +105 -0
- package/src/modules/components/AppMaps/index.ts +44 -0
- package/src/modules/components/AppMenu/AppMenu.vue +79 -0
- package/src/modules/components/AppMenu/AppMenuItem.vue +40 -0
- package/src/modules/components/AppMenu/__mocks__/index.ts +23 -0
- package/src/modules/components/AppMenu/__tests__/app-menu-item.spec.ts +47 -0
- package/src/modules/components/AppMenu/__tests__/app-menu.spec.ts +53 -0
- package/src/modules/components/AppMenu/index.d.ts +15 -0
- package/src/modules/components/AppModal/AppModal.vue +261 -0
- package/src/modules/components/AppModal/__tests__/app-modal.spec.ts +282 -0
- package/src/modules/components/AppModal/index.d.ts +36 -0
- package/src/modules/components/AppNavigationMenu/AppNavigationMenu.vue +95 -0
- package/src/modules/components/AppNavigationMenu/Mobile.vue +126 -0
- package/src/modules/components/AppNavigationMenu/NavigationItem.vue +82 -0
- package/src/modules/components/AppNavigationMenu/SupportItem.vue +29 -0
- package/src/modules/components/AppNavigationMenu/__tests__/app-navigation-menu.spec.ts +104 -0
- package/src/modules/components/AppNavigationMenu/__tests__/mobile.spec.ts +155 -0
- package/src/modules/components/AppNavigationMenu/__tests__/navigation-item.spec.ts +91 -0
- package/src/modules/components/AppNavigationMenu/__tests__/support-item.spec.ts +48 -0
- package/src/modules/components/AppPagination/AppPagination.vue +133 -0
- package/src/modules/components/AppPagination/AppPaginationItem.vue +28 -0
- package/src/modules/components/AppPagination/__mocks__/index.ts +20 -0
- package/src/modules/components/AppPagination/__tests__/app-pagination.spec.ts +143 -0
- package/src/modules/components/AppPagination/index.d.ts +24 -0
- package/src/modules/components/AppProgressBar/AppProgressBar.vue +93 -0
- package/src/modules/components/AppProgressBar/AppProgressBarStep.vue +5 -0
- package/src/modules/components/AppProgressBar/__mocks__/index.ts +17 -0
- package/src/modules/components/AppProgressBar/__tests__/app-progress-bar-step.spec.ts +18 -0
- package/src/modules/components/AppProgressBar/__tests__/app-progress-bar.spec.ts +77 -0
- package/src/modules/components/AppProgressBar/index.d.ts +21 -0
- package/src/modules/components/AppRating/AppRating.vue +42 -0
- package/src/modules/components/AppRating/VueStarRating/Star.vue +215 -0
- package/src/modules/components/AppRating/VueStarRating/StarRating.vue +231 -0
- package/src/modules/components/AppRating/VueStarRating/classes/AlphaColor.ts +68 -0
- package/src/modules/components/AppRating/VueStarRating/readme.md +279 -0
- package/src/modules/components/AppRating/__tests__/app-rating.spec.ts +36 -0
- package/src/modules/components/AppSection/AppSection.vue +35 -0
- package/src/modules/components/AppSection/__tests__/app-section.spec.ts +53 -0
- package/src/modules/components/AppSelect/AppSelect.vue +176 -0
- package/src/modules/components/AppSelect/__mocks__/index.ts +24 -0
- package/src/modules/components/AppSelect/__tests__/app-select.spec.ts +73 -0
- package/src/modules/components/AppSelect/index.d.ts +43 -0
- package/src/modules/components/AppSelect/index.ts +69 -0
- package/src/modules/components/AppStepper/AppStepper.vue +79 -0
- package/src/modules/components/AppStepper/__tests__/app-stepper.spec.ts +59 -0
- package/src/modules/components/AppTable/AppTable.vue +40 -0
- package/src/modules/components/AppTimeline/AppTimeline.vue +22 -0
- package/src/modules/components/AppTimeline/AppTimelineItem.vue +97 -0
- package/src/modules/components/AppTimeline/AppTimelineItemIcon.vue +55 -0
- package/src/modules/components/AppTimeline/__mocks__/timeline.ts +29 -0
- package/src/modules/components/AppTimeline/__tests__/app-timeline-item-Icon.spec.ts +35 -0
- package/src/modules/components/AppTimeline/__tests__/app-timeline-item.spec.ts +121 -0
- package/src/modules/components/AppTimeline/__tests__/app-timeline.spec.ts +55 -0
- package/src/modules/components/AppTimeline/index.d.ts +30 -0
- package/src/modules/components/AppTimeline/index.ts +13 -0
- package/src/modules/components/AppToggle/AppToggle.vue +36 -0
- package/src/modules/components/AppToggle/__tests__/app-toggle.spec.ts +54 -0
- package/src/modules/components/AppToggle/index.d.ts +3 -0
- package/src/modules/components/AppToggleCard/AppToggleCard.vue +45 -0
- package/src/modules/components/AppToggleCard/__tests__/app-toggle-card.spec.ts +55 -0
- package/src/modules/components/index.ts +43 -0
- package/src/modules/composables/index.ts +14 -0
- package/src/modules/composables/useActionBar/__mocks__/index.ts +17 -0
- package/src/modules/composables/useActionBar/__tests__/index.spec.ts +62 -0
- package/src/modules/composables/useActionBar/index.d.ts +1 -0
- package/src/modules/composables/useActionBar/index.ts +67 -0
- package/src/modules/composables/useComputedPosition/index.d.ts +16 -0
- package/src/modules/composables/useComputedPosition/index.ts +199 -0
- package/src/modules/composables/useConfirm/__tests__/index.spec.ts +29 -0
- package/src/modules/composables/useConfirm/index.ts +63 -0
- package/src/modules/composables/useContextMenu/index.ts +127 -0
- package/src/modules/composables/useDrawer/__tests__/index.spec.ts +34 -0
- package/src/modules/composables/useDrawer/index.ts +136 -0
- package/src/modules/composables/useEcho/index.ts +167 -0
- package/src/modules/composables/useError/__tests__/index.spec.ts +29 -0
- package/src/modules/composables/useError/index.ts +61 -0
- package/src/modules/composables/useFocusTrap/index.d.ts +3 -0
- package/src/modules/composables/useFocusTrap/index.ts +98 -0
- package/src/modules/composables/useGoogleApi/__tests__/index.spec.ts +39 -0
- package/src/modules/composables/useGoogleApi/index.ts +26 -0
- package/src/modules/composables/useLayout/__tests__/index.spec.ts +34 -0
- package/src/modules/composables/useLayout/index.d.ts +1 -0
- package/src/modules/composables/useLayout/index.ts +68 -0
- package/src/modules/composables/useModal/__tests__/index.spec.ts +34 -0
- package/src/modules/composables/useModal/index.ts +97 -0
- package/src/modules/composables/useNavigation/__mocks__/navigation.ts +22 -0
- package/src/modules/composables/useNavigation/__tests__/index.spec.ts +88 -0
- package/src/modules/composables/useNavigation/index.d.ts +17 -0
- package/src/modules/composables/useNavigation/index.ts +97 -0
- package/src/modules/icons/BuildingCircleCheck.vue +32 -0
- package/src/modules/icons/BuildingCircleXmark.vue +20 -0
- package/src/modules/icons/CarsIcon.vue +29 -0
- package/src/modules/icons/ChatPersonRoundedIcon.vue +184 -0
- package/src/modules/icons/CompanyIcon.vue +18 -0
- package/src/modules/icons/HeroGirlIcon.vue +246 -0
- package/src/modules/icons/HeroPersonIcon.vue +402 -0
- package/src/modules/icons/HeroPersonRoundedIcon.vue +412 -0
- package/src/modules/icons/HeroPersonWithBgIcon.vue +4503 -0
- package/src/modules/icons/LocationMarkerIcon.vue +33 -0
- package/src/modules/icons/PartyPopperIcon.vue +146 -0
- package/src/modules/icons/index.ts +32 -0
- package/src/modules/icons/status/ErrorIcon.vue +24 -0
- package/src/modules/icons/status/SuccessIcon.vue +24 -0
- package/src/modules/icons/status/WarningIcon.vue +27 -0
- package/src/modules/icons/status/index.ts +3 -0
- package/src/modules/index.ts +8 -0
- package/src/modules/layouts/Auth/Auth.vue +36 -0
- package/src/modules/layouts/Auth/__tests__/auth.spec.ts +63 -0
- package/src/modules/layouts/Base/Base.vue +69 -0
- package/src/modules/layouts/Base/__tests__/base.spec.ts +56 -0
- package/src/modules/layouts/Platform/Platform.vue +96 -0
- package/src/modules/layouts/Platform/__tests__/platform.spec.ts +56 -0
- package/src/modules/layouts/index.ts +9 -0
- package/src/modules/plugins/Sentry/index.d.ts +16 -0
- package/src/modules/plugins/Sentry/index.ts +65 -0
- package/src/modules/plugins/Sentry/language/nl.ts +13 -0
- package/src/modules/plugins/TinyMCE/lang/nl.js +430 -0
- package/src/modules/plugins/Toast/Toast.vue +58 -0
- package/src/modules/plugins/Toast/__tests__/toast.spec.ts +90 -0
- package/src/modules/plugins/Toast/index.ts +36 -0
- package/src/modules/plugins/Toast/types.d.ts +265 -0
- package/src/modules/plugins/index.ts +63 -0
- package/src/stories/Introduction.mdx +4 -0
- package/src/stories/assets/code-brackets.svg +1 -0
- package/src/stories/assets/colors.svg +1 -0
- package/src/stories/assets/comments.svg +1 -0
- package/src/stories/assets/direction.svg +1 -0
- package/src/stories/assets/flow.svg +1 -0
- package/src/stories/assets/images/logo.png +0 -0
- package/src/stories/assets/images/road.png +0 -0
- package/src/stories/assets/plugin.svg +1 -0
- package/src/stories/assets/repo.svg +1 -0
- package/src/stories/assets/stackalt.svg +1 -0
- package/src/stories/components/ActionBar/ActionBar.stories.ts +67 -0
- package/src/stories/components/Alert/Alert.stories.ts +53 -0
- package/src/stories/components/Avatar/Avatar.stories.ts +44 -0
- package/src/stories/components/BackButton/BackButton.stories.ts +39 -0
- package/src/stories/components/Badge/Badge.stories.ts +42 -0
- package/src/stories/components/Button/Button.stories.ts +132 -0
- package/src/stories/components/Card/Card.stories.ts +70 -0
- package/src/stories/components/Color/Color.stories.ts +41 -0
- package/src/stories/components/ColorCard/ColorCard.stories.ts +43 -0
- package/src/stories/components/Confirm/Confirm.stories.ts +110 -0
- package/src/stories/components/ContextMenu/ContextMenu.stories.ts +85 -0
- package/src/stories/components/DefinitionList/DefinitionList.stories.ts +32 -0
- package/src/stories/components/Disclosure/Disclosure.stories.ts +61 -0
- package/src/stories/components/DropdownButton/DropdownButton.stories.ts +121 -0
- package/src/stories/components/Error/Error.stories.ts +106 -0
- package/src/stories/components/ImageDropzone/ImageDropzone.stories.ts +41 -0
- package/src/stories/components/Input/Input.stories.ts +180 -0
- package/src/stories/components/Input/LocationInput.stories.ts +77 -0
- package/src/stories/components/LicensePlate/LicensePlate.stories.ts +39 -0
- package/src/stories/components/Maps/Maps.stories.ts +36 -0
- package/src/stories/components/Menu/Menu.stories.ts +41 -0
- package/src/stories/components/Modal/Modal.stories.ts +68 -0
- package/src/stories/components/Navigation/Navigation.stories.ts +62 -0
- package/src/stories/components/Pagination/Pagination.stories.ts +62 -0
- package/src/stories/components/ProgressBar/ProgressBar.stories.ts +48 -0
- package/src/stories/components/Rating/Rating.stories.ts +38 -0
- package/src/stories/components/Section/Section.stories.ts +44 -0
- package/src/stories/components/Select/Select.stories.ts +90 -0
- package/src/stories/components/Stepper/Stepper.stories.ts +38 -0
- package/src/stories/components/Table/DataTable.stories.ts +96 -0
- package/src/stories/components/Table/Table.stories.ts +45 -0
- package/src/stories/components/Timeline/Timeline.stories.ts +46 -0
- package/src/stories/components/Toast/Toast.stories.ts +47 -0
- package/src/stories/components/Toggle/Toggle.stories.ts +41 -0
- package/src/stories/components/ToggleCard/ToggleCard.stories.ts +43 -0
- package/src/stories/layouts/Auth.stories.ts +43 -0
- package/src/stories/layouts/Base.stories.ts +70 -0
- package/src/tests/mocks/resize-observer.ts +13 -0
- package/src/tests/stubs/AppSelect.ts +89 -0
- package/src/tests/stubs/HeadlessUiDialogStub.ts +24 -0
- package/src/tests/stubs/HeadlessUiTransitionChildStub.ts +20 -0
- package/src/tests/stubs/HeadlessUiTransitionRootStub.ts +25 -0
- package/src/tests/stubs/IconStub.ts +9 -0
- package/src/tests/stubs/Vue3EasyDataTableStub.ts +53 -0
- package/src/typings/plugin.d.ts +5 -0
- package/src/typings/shims-vue.d.ts +13 -0
- package/src/typings/utilities.d.ts +4 -0
- package/src/typings/vite-environment.d.ts +12 -0
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed, ref } from 'vue';
|
|
3
|
+
import { Dialog, DialogOverlay, DialogTitle, TransitionChild, TransitionRoot } from '@headlessui/vue';
|
|
4
|
+
import { onKeyStroke } from '@vueuse/core';
|
|
5
|
+
import { AppButton } from '~components';
|
|
6
|
+
import { FontAwesomeIcon, byPrefixAndName } from '~icons';
|
|
7
|
+
|
|
8
|
+
import type { Component } from 'vue';
|
|
9
|
+
import type { ModalProps } from './index.d';
|
|
10
|
+
|
|
11
|
+
const props = withDefaults(defineProps<Omit<ModalProps, 'onOpen' | 'onClose' | 'plugins'>>(), {
|
|
12
|
+
submitButtonText: 'Opslaan',
|
|
13
|
+
cancelButtonText: 'Annuleren',
|
|
14
|
+
withBackdrop: true,
|
|
15
|
+
withFooter: true,
|
|
16
|
+
preventBackdropClose: false,
|
|
17
|
+
preventBackdropCloseOnLoading: true,
|
|
18
|
+
contentClasses: '',
|
|
19
|
+
modalClasses: '',
|
|
20
|
+
title: '',
|
|
21
|
+
content: '',
|
|
22
|
+
properties: undefined,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const emit = defineEmits<{
|
|
26
|
+
(event: 'open'): void;
|
|
27
|
+
(event: 'close', value: { animation: () => Promise<void> }): void;
|
|
28
|
+
(event: 'cancel'): void;
|
|
29
|
+
(event: 'submit', value: FormData): void;
|
|
30
|
+
}>();
|
|
31
|
+
|
|
32
|
+
const isOpen = ref(false);
|
|
33
|
+
const form = ref<HTMLFormElement>();
|
|
34
|
+
const modalLoading = ref(false);
|
|
35
|
+
const cancelLoading = ref(false);
|
|
36
|
+
const contentRef = ref<Component>();
|
|
37
|
+
|
|
38
|
+
const preventBackdropCloseComputed = computed(() => {
|
|
39
|
+
return props.preventBackdropClose
|
|
40
|
+
|| (props.preventBackdropCloseOnLoading && (modalLoading.value || cancelLoading.value));
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
async function open(): Promise<void> {
|
|
44
|
+
isOpen.value = true;
|
|
45
|
+
|
|
46
|
+
emit('open');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function close(): Promise<void> {
|
|
50
|
+
cancelLoading.value = true;
|
|
51
|
+
|
|
52
|
+
isOpen.value = false;
|
|
53
|
+
|
|
54
|
+
// eslint-disable-next-line no-promise-executor-return
|
|
55
|
+
emit('close', { animation: async () => new Promise(resolve => setTimeout(resolve, 350)) });
|
|
56
|
+
|
|
57
|
+
cancelLoading.value = false;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function cancel(): Promise<void> {
|
|
61
|
+
// @ts-expect-error cancel not always exists
|
|
62
|
+
const returnValue1 = await contentRef.value?.cancel?.();
|
|
63
|
+
const returnValue2 = await props.onCancel?.();
|
|
64
|
+
|
|
65
|
+
if (props.onCancel === undefined) {
|
|
66
|
+
emit('cancel');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (returnValue1 === false || returnValue2 === false) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
await close();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async function submit(): Promise<void> {
|
|
77
|
+
modalLoading.value = true;
|
|
78
|
+
|
|
79
|
+
const formData = new FormData(form.value);
|
|
80
|
+
|
|
81
|
+
// @ts-expect-error submit not always exists
|
|
82
|
+
await contentRef.value?.submit?.(formData);
|
|
83
|
+
await props.onSubmit?.(formData);
|
|
84
|
+
|
|
85
|
+
modalLoading.value = false;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
defineExpose({
|
|
89
|
+
isOpen,
|
|
90
|
+
open,
|
|
91
|
+
close,
|
|
92
|
+
submit,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
onKeyStroke('Escape', close, { dedupe: true });
|
|
96
|
+
</script>
|
|
97
|
+
|
|
98
|
+
<template>
|
|
99
|
+
<TransitionRoot
|
|
100
|
+
:show="isOpen"
|
|
101
|
+
as="template"
|
|
102
|
+
>
|
|
103
|
+
<Dialog
|
|
104
|
+
as="div"
|
|
105
|
+
class="app-modal-dialog fixed inset-0 z-250 overflow-y-auto"
|
|
106
|
+
data-test-modal-dialog
|
|
107
|
+
@close="() => !preventBackdropCloseComputed ? close() : undefined"
|
|
108
|
+
>
|
|
109
|
+
<div class="flex min-h-screen items-center justify-center text-center">
|
|
110
|
+
<TransitionChild
|
|
111
|
+
v-if="withBackdrop"
|
|
112
|
+
as="template"
|
|
113
|
+
enter="ease-out duration-300"
|
|
114
|
+
enter-from="opacity-0"
|
|
115
|
+
enter-to="opacity-100"
|
|
116
|
+
leave="ease-in duration-200"
|
|
117
|
+
leave-from="opacity-100"
|
|
118
|
+
leave-to="opacity-0"
|
|
119
|
+
>
|
|
120
|
+
<DialogOverlay class="fixed inset-0 z-40 bg-black/20 backdrop-blur-xs transition-opacity" />
|
|
121
|
+
</TransitionChild>
|
|
122
|
+
|
|
123
|
+
<span
|
|
124
|
+
class="inline-block h-screen align-middle"
|
|
125
|
+
aria-hidden="true"
|
|
126
|
+
>
|
|
127
|
+
​
|
|
128
|
+
</span>
|
|
129
|
+
|
|
130
|
+
<TransitionChild
|
|
131
|
+
as="template"
|
|
132
|
+
enter="ease-in-out duration-300"
|
|
133
|
+
enter-from="opacity-0 translate-y-4 md:translate-y-0 md:scale-95"
|
|
134
|
+
enter-to="opacity-100 translate-y-0 md:scale-100"
|
|
135
|
+
leave="ease-in duration-200"
|
|
136
|
+
leave-from="opacity-100 translate-y-0 md:scale-100"
|
|
137
|
+
leave-to="opacity-0 translate-y-4 md:translate-y-0 md:scale-95"
|
|
138
|
+
>
|
|
139
|
+
<div
|
|
140
|
+
:class="`relative z-50 mx-auto inline-block w-full max-w-2xl rounded-2xl p-4
|
|
141
|
+
text-left align-middle transition-all md:max-w-[70vw] ${modalClasses}`"
|
|
142
|
+
>
|
|
143
|
+
<div class="rounded-2xl bg-zinc-100 drop-shadow-card">
|
|
144
|
+
<div class="flex flex-col items-center space-y-5">
|
|
145
|
+
<div class="w-full text-center">
|
|
146
|
+
<DialogTitle
|
|
147
|
+
as="h3"
|
|
148
|
+
class="flex justify-between px-8 pt-8 text-2xl font-bold leading-6 text-zinc-900"
|
|
149
|
+
>
|
|
150
|
+
<slot name="title">
|
|
151
|
+
{{ title }}
|
|
152
|
+
</slot>
|
|
153
|
+
|
|
154
|
+
<FontAwesomeIcon
|
|
155
|
+
:icon="byPrefixAndName.far?.xmark"
|
|
156
|
+
class="size-5 cursor-pointer"
|
|
157
|
+
@click="close"
|
|
158
|
+
/>
|
|
159
|
+
</DialogTitle>
|
|
160
|
+
|
|
161
|
+
<div
|
|
162
|
+
:class="`my-6 px-8 w-full text-center text-sm text-zinc-600 ${contentClasses}`"
|
|
163
|
+
data-test-modal-content
|
|
164
|
+
>
|
|
165
|
+
<form ref="form">
|
|
166
|
+
<slot>
|
|
167
|
+
<template v-if="typeof content === 'string'">
|
|
168
|
+
{{ content }}
|
|
169
|
+
</template>
|
|
170
|
+
|
|
171
|
+
<Component
|
|
172
|
+
:is="content"
|
|
173
|
+
v-else
|
|
174
|
+
ref="contentRef"
|
|
175
|
+
v-bind="properties"
|
|
176
|
+
@close="close"
|
|
177
|
+
@submit="submit"
|
|
178
|
+
@cancel="cancel"
|
|
179
|
+
/>
|
|
180
|
+
</slot>
|
|
181
|
+
</form>
|
|
182
|
+
</div>
|
|
183
|
+
</div>
|
|
184
|
+
</div>
|
|
185
|
+
|
|
186
|
+
<div
|
|
187
|
+
v-if="withFooter"
|
|
188
|
+
class="w-full rounded-b-xl bg-white p-8"
|
|
189
|
+
>
|
|
190
|
+
<div class="ml-auto flex w-fit flex-row-reverse items-center">
|
|
191
|
+
<AppButton
|
|
192
|
+
v-if="submitButtonText"
|
|
193
|
+
:disabled="modalLoading || cancelLoading"
|
|
194
|
+
:loading="modalLoading"
|
|
195
|
+
type="button"
|
|
196
|
+
color-type="primary"
|
|
197
|
+
class="ml-6 justify-center"
|
|
198
|
+
@click="submit"
|
|
199
|
+
>
|
|
200
|
+
<template
|
|
201
|
+
v-if="submitButtonTrailingIcon"
|
|
202
|
+
#trailingIcon
|
|
203
|
+
>
|
|
204
|
+
<Component
|
|
205
|
+
:is="submitButtonTrailingIcon"
|
|
206
|
+
class="stroke-2"
|
|
207
|
+
/>
|
|
208
|
+
</template>
|
|
209
|
+
|
|
210
|
+
<template
|
|
211
|
+
v-if="submitButtonLeadingIcon"
|
|
212
|
+
#leadingIcon
|
|
213
|
+
>
|
|
214
|
+
<Component
|
|
215
|
+
:is="submitButtonLeadingIcon"
|
|
216
|
+
class="stroke-2"
|
|
217
|
+
/>
|
|
218
|
+
</template>
|
|
219
|
+
|
|
220
|
+
{{ submitButtonText }}
|
|
221
|
+
</AppButton>
|
|
222
|
+
|
|
223
|
+
<AppButton
|
|
224
|
+
v-if="cancelButtonText"
|
|
225
|
+
:disabled="modalLoading || cancelLoading"
|
|
226
|
+
:loading="cancelLoading"
|
|
227
|
+
color-type="plain"
|
|
228
|
+
class="justify-center text-zinc-900!"
|
|
229
|
+
@click="cancel"
|
|
230
|
+
>
|
|
231
|
+
<template
|
|
232
|
+
v-if="cancelButtonTrailingIcon"
|
|
233
|
+
#trailingIcon
|
|
234
|
+
>
|
|
235
|
+
<Component
|
|
236
|
+
:is="cancelButtonTrailingIcon"
|
|
237
|
+
class="stroke-2"
|
|
238
|
+
/>
|
|
239
|
+
</template>
|
|
240
|
+
|
|
241
|
+
<template
|
|
242
|
+
v-if="cancelButtonLeadingIcon"
|
|
243
|
+
#leadingIcon
|
|
244
|
+
>
|
|
245
|
+
<Component
|
|
246
|
+
:is="cancelButtonLeadingIcon"
|
|
247
|
+
class="stroke-2"
|
|
248
|
+
/>
|
|
249
|
+
</template>
|
|
250
|
+
|
|
251
|
+
{{ cancelButtonText }}
|
|
252
|
+
</AppButton>
|
|
253
|
+
</div>
|
|
254
|
+
</div>
|
|
255
|
+
</div>
|
|
256
|
+
</div>
|
|
257
|
+
</TransitionChild>
|
|
258
|
+
</div>
|
|
259
|
+
</Dialog>
|
|
260
|
+
</TransitionRoot>
|
|
261
|
+
</template>
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
+
import { flushPromises, shallowMount } from '@vue/test-utils';
|
|
3
|
+
import { Dialog, DialogTitle, TransitionChild, TransitionRoot } from '@headlessui/vue';
|
|
4
|
+
import { AppButton, AppModal } from '~components';
|
|
5
|
+
import HeadlessUiTransitionRootStub from '~/tests/stubs/HeadlessUiTransitionRootStub';
|
|
6
|
+
import HeadlessUiDialogStub from '~/tests/stubs/HeadlessUiDialogStub';
|
|
7
|
+
import HeadlessUiTransitionChildStub from '~/tests/stubs/HeadlessUiTransitionChildStub';
|
|
8
|
+
|
|
9
|
+
import type { ModalProps } from '../index.d';
|
|
10
|
+
|
|
11
|
+
function createWrapper(props: ModalProps) {
|
|
12
|
+
return shallowMount(AppModal, {
|
|
13
|
+
props,
|
|
14
|
+
global: {
|
|
15
|
+
stubs: {
|
|
16
|
+
Dialog: HeadlessUiDialogStub,
|
|
17
|
+
TransitionRoot: HeadlessUiTransitionRootStub,
|
|
18
|
+
TransitionChild: HeadlessUiTransitionChildStub,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
describe('generic AppModal component', () => {
|
|
25
|
+
it('should display a modal when title is set', () => {
|
|
26
|
+
const wrapper = createWrapper({ title: 'title' });
|
|
27
|
+
|
|
28
|
+
const transitionWrapper = wrapper.findComponent(TransitionRoot)
|
|
29
|
+
.findComponent(Dialog)
|
|
30
|
+
.findAllComponents(TransitionChild)[1];
|
|
31
|
+
|
|
32
|
+
expect(transitionWrapper.exists()).toBe(true);
|
|
33
|
+
expect(transitionWrapper.isVisible()).toBe(true);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should set the right title', () => {
|
|
37
|
+
const title = 'This is a test';
|
|
38
|
+
|
|
39
|
+
const wrapper = createWrapper({
|
|
40
|
+
title,
|
|
41
|
+
content: 'Bla',
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const titleWrapper = wrapper.findComponent(TransitionRoot)
|
|
45
|
+
.findComponent(Dialog)
|
|
46
|
+
.findAllComponents(TransitionChild)[1]
|
|
47
|
+
.findComponent(DialogTitle);
|
|
48
|
+
|
|
49
|
+
expect(titleWrapper.text()).toStrictEqual(title);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('should set the right content', () => {
|
|
53
|
+
const content = 'This is test content';
|
|
54
|
+
|
|
55
|
+
const wrapper = createWrapper({
|
|
56
|
+
title: 'This is a test',
|
|
57
|
+
content,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const modalContent = wrapper.findComponent(TransitionRoot)
|
|
61
|
+
.findComponent(Dialog)
|
|
62
|
+
.findAllComponents(TransitionChild)[1]
|
|
63
|
+
.find('[data-test-modal-content]');
|
|
64
|
+
|
|
65
|
+
expect(modalContent.text()).toStrictEqual(content);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('should render the content as text by default', () => {
|
|
69
|
+
const content = 'This is test content';
|
|
70
|
+
|
|
71
|
+
const wrapper = createWrapper({
|
|
72
|
+
title: 'This is a test',
|
|
73
|
+
content,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const modalContent = wrapper.findComponent(TransitionRoot)
|
|
77
|
+
.findComponent(Dialog)
|
|
78
|
+
.findAllComponents(TransitionChild)[1]
|
|
79
|
+
.find('[data-test-modal-content]');
|
|
80
|
+
|
|
81
|
+
expect(modalContent.text()).toBe(content);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('shouldn\'t render the submit button when submitButtonText is set to null', () => {
|
|
85
|
+
const content = 'This is test content';
|
|
86
|
+
|
|
87
|
+
const wrapper = createWrapper({
|
|
88
|
+
title: 'This is a test',
|
|
89
|
+
content,
|
|
90
|
+
submitButtonText: null,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const buttons = wrapper.findComponent(TransitionRoot)
|
|
94
|
+
.findComponent(Dialog)
|
|
95
|
+
.findAllComponents(TransitionChild)[1]
|
|
96
|
+
.findAllComponents(AppButton);
|
|
97
|
+
|
|
98
|
+
expect(buttons).toHaveLength(1);
|
|
99
|
+
expect(buttons[0].text()).toBe('Annuleren');
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('shouldn\'t render the cancel button when cancelButtonText is set to null', () => {
|
|
103
|
+
const content = 'This is test content';
|
|
104
|
+
|
|
105
|
+
const wrapper = createWrapper({
|
|
106
|
+
title: 'This is a test',
|
|
107
|
+
content,
|
|
108
|
+
cancelButtonText: null,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const buttons = wrapper.findComponent(TransitionRoot)
|
|
112
|
+
.findComponent(Dialog)
|
|
113
|
+
.findAllComponents(TransitionChild)[1]
|
|
114
|
+
.findAllComponents(AppButton);
|
|
115
|
+
|
|
116
|
+
expect(buttons).toHaveLength(1);
|
|
117
|
+
expect(buttons[0].text()).toBe('Opslaan');
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('should be able to set a custom text in submit button', () => {
|
|
121
|
+
const submitButtonText = 'huts';
|
|
122
|
+
|
|
123
|
+
const wrapper = createWrapper({
|
|
124
|
+
title: 'This is a test',
|
|
125
|
+
content: 'Bla',
|
|
126
|
+
submitButtonText,
|
|
127
|
+
cancelButtonText: 'cancel button',
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const button = wrapper.findComponent(TransitionRoot)
|
|
131
|
+
.findComponent(Dialog)
|
|
132
|
+
.findAllComponents(TransitionChild)[1]
|
|
133
|
+
.findAllComponents(AppButton)[0];
|
|
134
|
+
|
|
135
|
+
expect(button.exists()).toBe(true);
|
|
136
|
+
expect(button.text()).toStrictEqual(submitButtonText);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('should be able to set a custom text in cancel button', () => {
|
|
140
|
+
const cancelButtonText = 'huts';
|
|
141
|
+
|
|
142
|
+
const wrapper = createWrapper({
|
|
143
|
+
title: 'This is a test',
|
|
144
|
+
content: 'Bla',
|
|
145
|
+
submitButtonText: 'confirm button',
|
|
146
|
+
cancelButtonText,
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
const cancelButton = wrapper.findComponent(TransitionRoot)
|
|
150
|
+
.findComponent(Dialog)
|
|
151
|
+
.findAllComponents(TransitionChild)[1]
|
|
152
|
+
.findAllComponents(AppButton)[1];
|
|
153
|
+
|
|
154
|
+
expect(cancelButton.exists()).toBe(true);
|
|
155
|
+
expect(cancelButton.text()).toStrictEqual(cancelButtonText);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('should emit a submit when submit button is pressed', async () => {
|
|
159
|
+
expect.assertions(2);
|
|
160
|
+
|
|
161
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
162
|
+
const submitSpy = vi.fn().mockResolvedValue(undefined);
|
|
163
|
+
|
|
164
|
+
const wrapper = createWrapper({
|
|
165
|
+
title: 'This is a test',
|
|
166
|
+
content: 'Bla',
|
|
167
|
+
submitButtonText: 'confirm',
|
|
168
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
169
|
+
onSubmit: submitSpy,
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
const button = wrapper.findComponent(TransitionRoot)
|
|
173
|
+
.findComponent(Dialog)
|
|
174
|
+
.findAllComponents(TransitionChild)[1]
|
|
175
|
+
.findAllComponents(AppButton)[0];
|
|
176
|
+
|
|
177
|
+
expect(submitSpy).toHaveBeenCalledTimes(0);
|
|
178
|
+
|
|
179
|
+
await button.trigger('click');
|
|
180
|
+
|
|
181
|
+
expect(submitSpy).toHaveBeenCalledTimes(1);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it('should emit a cancel when cancel button is pressed', async () => {
|
|
185
|
+
expect.assertions(1);
|
|
186
|
+
|
|
187
|
+
const wrapper = createWrapper({
|
|
188
|
+
title: 'This is a test',
|
|
189
|
+
content: 'Bla',
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
const cancelButton = wrapper.findComponent(TransitionRoot)
|
|
193
|
+
.findComponent(Dialog)
|
|
194
|
+
.findAllComponents(TransitionChild)[1]
|
|
195
|
+
.findAllComponents(AppButton)[1];
|
|
196
|
+
|
|
197
|
+
await cancelButton.trigger('click');
|
|
198
|
+
|
|
199
|
+
const emitted = wrapper.emitted<Event[]>();
|
|
200
|
+
|
|
201
|
+
await flushPromises();
|
|
202
|
+
|
|
203
|
+
expect(emitted).toHaveProperty('cancel');
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it('should show spinner when confirming', async () => {
|
|
207
|
+
expect.assertions(2);
|
|
208
|
+
|
|
209
|
+
const wrapper = createWrapper({
|
|
210
|
+
title: 'This is a test',
|
|
211
|
+
content: 'Bla',
|
|
212
|
+
submitButtonText: 'confirm',
|
|
213
|
+
cancelButtonText: 'confirm',
|
|
214
|
+
onSubmit: async () => new Promise(resolve => setTimeout(resolve, 250)),
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
// @ts-expect-error setting data on wrapper works in this case but not according to Typescript
|
|
218
|
+
wrapper.vm.confirmLoading = true;
|
|
219
|
+
// @ts-expect-error setting data on wrapper works in this case but not according to Typescript
|
|
220
|
+
wrapper.vm.cancelLoading = true;
|
|
221
|
+
|
|
222
|
+
await flushPromises();
|
|
223
|
+
|
|
224
|
+
const buttons = wrapper.findComponent(TransitionRoot)
|
|
225
|
+
.findComponent(Dialog)
|
|
226
|
+
.findAllComponents(TransitionChild)[1]
|
|
227
|
+
.findAllComponents(AppButton);
|
|
228
|
+
|
|
229
|
+
const button = wrapper.findComponent(TransitionRoot)
|
|
230
|
+
.findComponent(Dialog)
|
|
231
|
+
.findAllComponents(TransitionChild)[1]
|
|
232
|
+
.findAllComponents(AppButton)[0];
|
|
233
|
+
|
|
234
|
+
await button.trigger('click');
|
|
235
|
+
|
|
236
|
+
expect(buttons[0].props('loading')).toBe(true);
|
|
237
|
+
expect(buttons[1].props('loading')).toBe(true);
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it('should close confirm when backdrop is clicked and preventBackdropClose is "false"', async () => {
|
|
241
|
+
expect.assertions(3);
|
|
242
|
+
|
|
243
|
+
const wrapper = createWrapper({
|
|
244
|
+
title: 'This is a test',
|
|
245
|
+
content: 'BlaBlaBla',
|
|
246
|
+
preventBackdropClose: false,
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
const dialog = wrapper.findComponent(Dialog);
|
|
250
|
+
expect(dialog.exists()).toBe(true);
|
|
251
|
+
|
|
252
|
+
dialog.vm.$emit('close');
|
|
253
|
+
|
|
254
|
+
await flushPromises();
|
|
255
|
+
|
|
256
|
+
const closeConfirmEmit = wrapper.emitted<Event[]>('close');
|
|
257
|
+
|
|
258
|
+
expect(closeConfirmEmit).toBeDefined();
|
|
259
|
+
expect(closeConfirmEmit).toHaveLength(1);
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it('should not close confirm when backdrop is clicked with \'preventBackdropClose = true\'', async () => {
|
|
263
|
+
expect.assertions(2);
|
|
264
|
+
|
|
265
|
+
const wrapper = createWrapper({
|
|
266
|
+
title: 'This is a test',
|
|
267
|
+
content: 'BlaBlaBla',
|
|
268
|
+
preventBackdropClose: true,
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
const dialog = wrapper.findComponent(Dialog);
|
|
272
|
+
expect(dialog.exists()).toBe(true);
|
|
273
|
+
|
|
274
|
+
dialog.vm.$emit('close');
|
|
275
|
+
|
|
276
|
+
await flushPromises();
|
|
277
|
+
|
|
278
|
+
const closeConfirmEmit = wrapper.emitted<Event[]>('close');
|
|
279
|
+
|
|
280
|
+
expect(closeConfirmEmit).toBeUndefined();
|
|
281
|
+
});
|
|
282
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Component, Plugin } from 'vue';
|
|
2
|
+
import type { AppModal } from '~components';
|
|
3
|
+
|
|
4
|
+
export type OnSubmit = (data: FormData) => unknown;
|
|
5
|
+
export type OnCancel = () => unknown;
|
|
6
|
+
export type OnClose = () => unknown;
|
|
7
|
+
export type OnOpen = () => unknown;
|
|
8
|
+
|
|
9
|
+
export interface ModalProps {
|
|
10
|
+
title: string;
|
|
11
|
+
submitButtonText?: string | null;
|
|
12
|
+
submitButtonTrailingIcon?: Component;
|
|
13
|
+
submitButtonLeadingIcon?: Component;
|
|
14
|
+
cancelButtonText?: string | null;
|
|
15
|
+
cancelButtonTrailingIcon?: Component;
|
|
16
|
+
cancelButtonLeadingIcon?: Component;
|
|
17
|
+
withBackdrop?: boolean;
|
|
18
|
+
withFooter?: boolean;
|
|
19
|
+
preventBackdropClose?: boolean;
|
|
20
|
+
preventBackdropCloseOnLoading?: boolean;
|
|
21
|
+
contentClasses?: string;
|
|
22
|
+
modalClasses?: string;
|
|
23
|
+
content?: string | Component;
|
|
24
|
+
properties?: Record<string, unknown>;
|
|
25
|
+
plugins?: Plugin[];
|
|
26
|
+
onSubmit?: OnSubmit;
|
|
27
|
+
onCancel?: OnCancel;
|
|
28
|
+
onClose?: OnClose;
|
|
29
|
+
onOpen?: OnOpen;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface ModalInstance {
|
|
33
|
+
ref: AppModal;
|
|
34
|
+
instance: App;
|
|
35
|
+
element: HTMLDivElement;
|
|
36
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { useNavigation } from '~composables';
|
|
3
|
+
import { ChevronRightIcon, ChevronLeftIcon } from '~icons';
|
|
4
|
+
import MainMenuMobile from './Mobile.vue';
|
|
5
|
+
import NavigationItem from './NavigationItem.vue';
|
|
6
|
+
import SupportItem from './SupportItem.vue';
|
|
7
|
+
|
|
8
|
+
const { navigationItems, mainMenuOpen, expanded, toggleExpand, contactIcon } = useNavigation();
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<template>
|
|
12
|
+
<div
|
|
13
|
+
class="relative before:absolute before:-right-4 before:top-0 before:z-[-1] before:size-4 before:bg-secondary
|
|
14
|
+
after:absolute after:-right-4 after:bottom-0 after:z-[-1] after:size-4 after:bg-secondary"
|
|
15
|
+
>
|
|
16
|
+
<aside
|
|
17
|
+
:class="{
|
|
18
|
+
'flex-col px-3 md:w-20!': mainMenuOpen,
|
|
19
|
+
'md:w-72!': expanded,
|
|
20
|
+
}"
|
|
21
|
+
:aria-expanded="expanded"
|
|
22
|
+
class="app-navigation-menu group sticky top-0 hidden h-screen w-0 justify-center py-5 transition-all duration-500
|
|
23
|
+
before:absolute before:-right-8 before:top-0 before:size-8 before:bg-zinc-100 after:absolute after:-right-8
|
|
24
|
+
after:bottom-0 after:size-8 after:bg-zinc-100 md:flex md:bg-secondary"
|
|
25
|
+
data-test-main-menu
|
|
26
|
+
>
|
|
27
|
+
<ul
|
|
28
|
+
:class="{ 'mx-auto': !expanded }"
|
|
29
|
+
class="mb-auto transition-all duration-500 z-10"
|
|
30
|
+
>
|
|
31
|
+
<li
|
|
32
|
+
v-for="item in navigationItems.filter(item => item.bottom !== true && item.visible !== false)"
|
|
33
|
+
:key="item.name"
|
|
34
|
+
data-test-top-navigation-item
|
|
35
|
+
>
|
|
36
|
+
<NavigationItem
|
|
37
|
+
:item="item"
|
|
38
|
+
:link-classes="item.linkClasses"
|
|
39
|
+
/>
|
|
40
|
+
</li>
|
|
41
|
+
</ul>
|
|
42
|
+
|
|
43
|
+
<ul
|
|
44
|
+
:class="{ 'mx-auto': !expanded }"
|
|
45
|
+
class="mt-auto pb-10 transition-all duration-500"
|
|
46
|
+
>
|
|
47
|
+
<li
|
|
48
|
+
v-for="item in navigationItems.filter(item => item.bottom && item.visible !== false)"
|
|
49
|
+
:key="item.name"
|
|
50
|
+
data-test-bottom-navigation-item
|
|
51
|
+
>
|
|
52
|
+
<NavigationItem
|
|
53
|
+
:item="item"
|
|
54
|
+
:link-classes="item.linkClasses"
|
|
55
|
+
/>
|
|
56
|
+
</li>
|
|
57
|
+
|
|
58
|
+
<li v-if="contactIcon">
|
|
59
|
+
<SupportItem class="static!" />
|
|
60
|
+
</li>
|
|
61
|
+
</ul>
|
|
62
|
+
|
|
63
|
+
<div
|
|
64
|
+
class="absolute bottom-2 right-5 hidden size-10 cursor-pointer items-center justify-center overflow-hidden rounded-full bg-secondary
|
|
65
|
+
transition-all duration-200 md:flex"
|
|
66
|
+
@click="toggleExpand"
|
|
67
|
+
>
|
|
68
|
+
<div
|
|
69
|
+
:class="{ '-translate-x-4!': !expanded }"
|
|
70
|
+
class="flex translate-x-4 space-x-4 transition-transform duration-700"
|
|
71
|
+
>
|
|
72
|
+
<ChevronLeftIcon class="size-5 text-zinc-400 hover:text-white" />
|
|
73
|
+
|
|
74
|
+
<ChevronRightIcon class="size-5 text-zinc-400 hover:text-white" />
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
</aside>
|
|
78
|
+
|
|
79
|
+
<MainMenuMobile />
|
|
80
|
+
</div>
|
|
81
|
+
</template>
|
|
82
|
+
|
|
83
|
+
<style scoped>
|
|
84
|
+
@reference "./../../../css/main.css";
|
|
85
|
+
|
|
86
|
+
.app-navigation-menu:before {
|
|
87
|
+
border-top-left-radius: 50%;
|
|
88
|
+
box-shadow: -1rem 0 0 0 var(--color-secondary);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.app-navigation-menu:after {
|
|
92
|
+
border-bottom-left-radius: 50%;
|
|
93
|
+
box-shadow: -1rem 0 0 0 var(--color-secondary);
|
|
94
|
+
}
|
|
95
|
+
</style>
|