@autoafleveren/ui 1.3.2 → 1.3.3
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/composables/index.d.ts +1 -1
- package/dist/types/composables/useActionBar/index.d.ts +3 -3
- package/dist/ui.cjs +36 -36
- package/dist/ui.js +6766 -6696
- package/package.json +3 -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 +123 -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 +100 -0
- package/src/modules/components/AppContextMenu/ShortcutItem.vue +37 -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 +31 -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 +13 -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/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,167 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { ref } from 'vue';
|
|
3
|
+
import Echo from 'laravel-echo';
|
|
4
|
+
import { ConnectionManager } from 'pusher-js';
|
|
5
|
+
import mitt from 'mitt';
|
|
6
|
+
|
|
7
|
+
import type { Authorizer, Channel } from 'pusher-js';
|
|
8
|
+
|
|
9
|
+
interface Listener {
|
|
10
|
+
name: string;
|
|
11
|
+
isListening: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface Caster {
|
|
15
|
+
here: (callback: CallableFunction) => this;
|
|
16
|
+
joining: (callback: CallableFunction) => this;
|
|
17
|
+
whisper: (eventName: string, data: Record<any, any>) => this;
|
|
18
|
+
leaving: (callback: CallableFunction) => this;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const state = {
|
|
22
|
+
listeners: ref<Listener[]>([]),
|
|
23
|
+
echo: null as Echo<'pusher'> | null,
|
|
24
|
+
key: null as string | null,
|
|
25
|
+
authorizer: null as ((channel: Channel) => Authorizer) | null,
|
|
26
|
+
emitter: mitt(),
|
|
27
|
+
casters: ref<Caster[]>([]),
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export function getOrCreateListener(listerName = 'unique'): Listener {
|
|
31
|
+
if (!state.listeners.value.some(listener => listener.name === listerName)) {
|
|
32
|
+
state.listeners.value?.push({
|
|
33
|
+
name: listerName,
|
|
34
|
+
// @ts-expect-error refs unwrapped
|
|
35
|
+
isListening: ref<boolean>(false),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// @ts-expect-error find always return a listener
|
|
40
|
+
return state.listeners.value.find(listener => listener.name === listerName);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function registerEcho(key: string, authorizer: (channel: Channel) => Authorizer): void {
|
|
44
|
+
state.echo = new Echo({
|
|
45
|
+
broadcaster: 'pusher',
|
|
46
|
+
client: ConnectionManager,
|
|
47
|
+
key,
|
|
48
|
+
authorizer,
|
|
49
|
+
cluster: 'eu',
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
51
|
+
forceTLS: true,
|
|
52
|
+
encrypted: true,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function useEcho(listenerName: string | null = null) {
|
|
57
|
+
const listener: Listener = getOrCreateListener(listenerName ?? undefined);
|
|
58
|
+
|
|
59
|
+
function join(channel: string): Caster {
|
|
60
|
+
if (state.echo === null) {
|
|
61
|
+
throw new Error('Echo is not initialized');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
state.casters[channel] = state.echo.join(channel);
|
|
65
|
+
|
|
66
|
+
return state.casters[channel] as Caster;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function whisper<T = unknown>(event: string, data: T, channel?: string): void {
|
|
70
|
+
if (state.echo === null) {
|
|
71
|
+
throw new Error('Echo is not initialized');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const channelName = channel ?? Object.keys(state.casters)[0];
|
|
75
|
+
|
|
76
|
+
state.casters[channelName]?.whisper?.(event, data);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function listen<T = unknown>(event: string, callback: (data: T) => void, channel?: string): void {
|
|
80
|
+
if (state.echo === null) {
|
|
81
|
+
throw new Error('Echo is not initialized');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const channelName = channel ?? Object.keys(state.casters)[0];
|
|
85
|
+
|
|
86
|
+
if (typeof state.casters[channelName]?.listenForWhisper === 'function') {
|
|
87
|
+
state.casters[channelName]?.listenForWhisper?.(event, callback);
|
|
88
|
+
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
throw new Error(`Nothing to whisper to on this channel ${event}-${channelName}`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function leave(channel: string): void {
|
|
96
|
+
if (state.echo === null) {
|
|
97
|
+
throw new Error('Echo is not initialized');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
state.echo.leave(channel);
|
|
101
|
+
|
|
102
|
+
delete state.casters[channel];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function on(channel: string, event: string, handler: (data: any) => unknown, privateChannel = true, unique = false): void {
|
|
106
|
+
if (state.echo === null) {
|
|
107
|
+
throw new Error('Echo is not initialized');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const channelEventKey = `${channel}.${event}`;
|
|
111
|
+
const isSubscribed = state.emitter.all.has(channelEventKey);
|
|
112
|
+
|
|
113
|
+
if (listener) {
|
|
114
|
+
listener.isListening = true;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (isSubscribed && unique) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (!isSubscribed) {
|
|
122
|
+
const channelConnection = privateChannel
|
|
123
|
+
? state.echo.private(channel)
|
|
124
|
+
: state.echo.channel(channel);
|
|
125
|
+
|
|
126
|
+
channelConnection.listen(`.${event}`, (data: any) => {
|
|
127
|
+
state.emitter.emit(channelEventKey, data);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
state.emitter.on(channelEventKey, async (data: any) => {
|
|
132
|
+
const closeOnCompletion = await handler(data) ?? false;
|
|
133
|
+
|
|
134
|
+
if (listener) {
|
|
135
|
+
listener.isListening = false;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (closeOnCompletion) {
|
|
139
|
+
off(channel, event);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function off(channel: string, event: string): void {
|
|
145
|
+
if (state.echo === null) {
|
|
146
|
+
throw new Error('Echo is not initialized');
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
state.emitter.off(`${channel}.${event}`);
|
|
150
|
+
state.emitter.all.delete(`${channel}.${event}`);
|
|
151
|
+
|
|
152
|
+
state.echo.leave(channel);
|
|
153
|
+
|
|
154
|
+
listener.isListening = false;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return {
|
|
158
|
+
on,
|
|
159
|
+
off,
|
|
160
|
+
join,
|
|
161
|
+
leave,
|
|
162
|
+
whisper,
|
|
163
|
+
listen,
|
|
164
|
+
listener,
|
|
165
|
+
state,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { describe, it, expect, beforeAll, vi } from 'vitest';
|
|
2
|
+
import { flushPromises } from '@vue/test-utils';
|
|
3
|
+
import { useError } from '../index';
|
|
4
|
+
import ResizeObserverMock from '~/tests/mocks/resize-observer';
|
|
5
|
+
|
|
6
|
+
describe('the useError composables', () => {
|
|
7
|
+
const error = useError();
|
|
8
|
+
beforeAll(() => {
|
|
9
|
+
global.ResizeObserver = ResizeObserverMock;
|
|
10
|
+
|
|
11
|
+
window.scrollTo = vi.fn();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('create a div, append this to the body and destroys on unmount', async () => {
|
|
15
|
+
error.open({ title: 'title' });
|
|
16
|
+
|
|
17
|
+
await flushPromises();
|
|
18
|
+
|
|
19
|
+
let documentModalHolder = document.querySelector('[data-test-error-dialog]');
|
|
20
|
+
|
|
21
|
+
expect(documentModalHolder).not.toBeNull();
|
|
22
|
+
|
|
23
|
+
error.close();
|
|
24
|
+
|
|
25
|
+
documentModalHolder = document.querySelector('[data-test-error-dialog]');
|
|
26
|
+
|
|
27
|
+
expect(documentModalHolder).toBeNull();
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { createApp, ref } from 'vue';
|
|
2
|
+
import { AppError } from '~components';
|
|
3
|
+
|
|
4
|
+
import type { App } from 'vue';
|
|
5
|
+
import type { ErrorInstance, ErrorProps } from '~components/AppError/index.d';
|
|
6
|
+
|
|
7
|
+
const state = {
|
|
8
|
+
instances: ref<ErrorInstance[]>([]),
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
function closeError(confirmInstance: ErrorInstance): void {
|
|
12
|
+
confirmInstance?.instance?.unmount();
|
|
13
|
+
confirmInstance?.element?.remove();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function useError() {
|
|
17
|
+
async function open(options: ErrorProps): Promise<unknown> {
|
|
18
|
+
window.scrollTo(0, 0);
|
|
19
|
+
|
|
20
|
+
const errorRootElement = document.createElement('div');
|
|
21
|
+
document.body.append(errorRootElement);
|
|
22
|
+
|
|
23
|
+
let errorInstance = null as null | App;
|
|
24
|
+
|
|
25
|
+
return new Promise(resolve => {
|
|
26
|
+
errorInstance = createApp(AppError, {
|
|
27
|
+
...options,
|
|
28
|
+
|
|
29
|
+
onClose: resolve,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
errorInstance.mount(errorRootElement);
|
|
33
|
+
|
|
34
|
+
state.instances.value.push({
|
|
35
|
+
instance: errorInstance,
|
|
36
|
+
element: errorRootElement,
|
|
37
|
+
});
|
|
38
|
+
}).finally(() => {
|
|
39
|
+
if (errorInstance) {
|
|
40
|
+
setTimeout(() => {
|
|
41
|
+
closeError({
|
|
42
|
+
instance: errorInstance,
|
|
43
|
+
element: errorRootElement,
|
|
44
|
+
});
|
|
45
|
+
}, 500);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function close(): Promise<void> {
|
|
51
|
+
state.instances.value.forEach(instance => closeError(instance));
|
|
52
|
+
|
|
53
|
+
return Promise.resolve();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
...state,
|
|
58
|
+
open,
|
|
59
|
+
close,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
describe,
|
|
3
|
+
it,
|
|
4
|
+
expect,
|
|
5
|
+
vi,
|
|
6
|
+
} from 'vitest';
|
|
7
|
+
import { useGoogleApi } from '../index';
|
|
8
|
+
|
|
9
|
+
const apiLoaderMock = vi.fn();
|
|
10
|
+
|
|
11
|
+
vi.mock('@googlemaps/js-api-loader', () => ({
|
|
12
|
+
Loader: class {
|
|
13
|
+
private readonly options: unknown = null;
|
|
14
|
+
private constructor(options: unknown) {
|
|
15
|
+
this.options = options;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public async load(): Promise<unknown> {
|
|
19
|
+
apiLoaderMock(this.options);
|
|
20
|
+
|
|
21
|
+
return Promise.resolve(this.options);
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
}));
|
|
25
|
+
|
|
26
|
+
describe('the useGoogleApi composables', () => {
|
|
27
|
+
const googleApi = useGoogleApi();
|
|
28
|
+
|
|
29
|
+
it('loads google api', async () => {
|
|
30
|
+
expect(googleApi.loaded.value).toBe(false);
|
|
31
|
+
expect(apiLoaderMock).toHaveBeenCalledTimes(0);
|
|
32
|
+
|
|
33
|
+
await googleApi.load('apikey');
|
|
34
|
+
|
|
35
|
+
expect(apiLoaderMock).toHaveBeenCalledTimes(1);
|
|
36
|
+
expect(apiLoaderMock).toHaveBeenCalledWith({ apiKey: 'apikey', version: 'weekly' });
|
|
37
|
+
expect(googleApi.loaded.value).toBe(true);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
import { Loader } from '@googlemaps/js-api-loader';
|
|
3
|
+
|
|
4
|
+
const state = {
|
|
5
|
+
loaded: ref<boolean>(false),
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export function useGoogleApi() {
|
|
9
|
+
async function load(apiKey: string): Promise<void> {
|
|
10
|
+
if (!state.loaded) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
await new Loader({
|
|
15
|
+
apiKey,
|
|
16
|
+
version: 'weekly',
|
|
17
|
+
}).load();
|
|
18
|
+
|
|
19
|
+
state.loaded.value = true;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
...state,
|
|
24
|
+
load,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { useLayout } from '../index';
|
|
3
|
+
|
|
4
|
+
describe('the useLayout composables', () => {
|
|
5
|
+
const layout = useLayout();
|
|
6
|
+
|
|
7
|
+
it('can set layout image', () => {
|
|
8
|
+
expect(layout.layoutImage.value).toBeNull();
|
|
9
|
+
|
|
10
|
+
layout.setLayoutImage('/images/layout.png');
|
|
11
|
+
|
|
12
|
+
expect(layout.layoutImage.value).toBe('/images/layout.png');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('can set primary colors', () => {
|
|
16
|
+
expect(layout.colors.primaryColor.value).toBe('#47A6DC');
|
|
17
|
+
expect(layout.colors.primaryColorActive.value).toBe('#3094CD');
|
|
18
|
+
|
|
19
|
+
layout.setPrimaryColors('primary', 'primary-active');
|
|
20
|
+
|
|
21
|
+
expect(layout.colors.primaryColor.value).toBe('primary');
|
|
22
|
+
expect(layout.colors.primaryColorActive.value).toBe('primary-active');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('can set secondary colors', () => {
|
|
26
|
+
expect(layout.colors.secondaryColor.value).toBe('#27272A');
|
|
27
|
+
expect(layout.colors.secondaryColorActive.value).toBe('#202023');
|
|
28
|
+
|
|
29
|
+
layout.setSecondaryColors('secondary', 'secondary-active');
|
|
30
|
+
|
|
31
|
+
expect(layout.colors.secondaryColor.value).toBe('secondary');
|
|
32
|
+
expect(layout.colors.secondaryColorActive.value).toBe('secondary-active');
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type LayoutImage = string | null;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
|
|
3
|
+
import type { LayoutImage } from './index.d';
|
|
4
|
+
|
|
5
|
+
function componentToHex(colorPart: number): string {
|
|
6
|
+
const hex = colorPart.toString(16);
|
|
7
|
+
|
|
8
|
+
return hex.length === 1 ? `0${hex}` : hex;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function rgb2Hex(rgb: number[]): string {
|
|
12
|
+
return `#${componentToHex(rgb[0])}${componentToHex(rgb[1])}${componentToHex(rgb[2])}`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function hex2rgb(hex: string, asString: boolean): string;
|
|
16
|
+
export function hex2rgb(hex: string): number[];
|
|
17
|
+
export function hex2rgb(hex: string, asString = false): number[] | string {
|
|
18
|
+
const red = parseInt(hex.slice(1, 3), 16);
|
|
19
|
+
const green = parseInt(hex.slice(3, 5), 16);
|
|
20
|
+
const blue = parseInt(hex.slice(5, 7), 16);
|
|
21
|
+
|
|
22
|
+
if (asString) {
|
|
23
|
+
return `${red} ${green} ${blue}`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return [red, green, blue];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const state = {
|
|
30
|
+
layoutImage: ref<LayoutImage>(null),
|
|
31
|
+
colors: {
|
|
32
|
+
primaryColor: ref<string>('#47A6DC'),
|
|
33
|
+
primaryColorActive: ref<string>('#3094CD'),
|
|
34
|
+
secondaryColor: ref<string>('#27272A'),
|
|
35
|
+
secondaryColorActive: ref<string>('#202023'),
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export function useLayout() {
|
|
40
|
+
function setLayoutImage(image: LayoutImage): void {
|
|
41
|
+
state.layoutImage.value = image;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function setPrimaryColors(color: string, colorActive: string): void {
|
|
45
|
+
state.colors.primaryColor.value = color;
|
|
46
|
+
state.colors.primaryColorActive.value = colorActive;
|
|
47
|
+
|
|
48
|
+
document.documentElement.style.setProperty('--color-primary', `rgb(${hex2rgb(color, true)})`);
|
|
49
|
+
document.documentElement.style.setProperty('--color-primary-active', `rgb(${hex2rgb(colorActive, true)})`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function setSecondaryColors(color: string, colorActive: string): void {
|
|
53
|
+
state.colors.secondaryColor.value = color;
|
|
54
|
+
state.colors.secondaryColorActive.value = colorActive;
|
|
55
|
+
|
|
56
|
+
document.documentElement.style.setProperty('--color-secondary', `rgb(${hex2rgb(color, true)})`);
|
|
57
|
+
document.documentElement.style.setProperty('--color-secondary-active', `rgb(${hex2rgb(colorActive, true)})`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
...state,
|
|
62
|
+
setLayoutImage,
|
|
63
|
+
setPrimaryColors,
|
|
64
|
+
setSecondaryColors,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type { LayoutImage };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { describe, it, expect, beforeAll, vi } from 'vitest';
|
|
2
|
+
import { flushPromises } from '@vue/test-utils';
|
|
3
|
+
import { useModal } from '../index';
|
|
4
|
+
import ResizeObserverMock from '~/tests/mocks/resize-observer';
|
|
5
|
+
|
|
6
|
+
describe('the useModal composables', () => {
|
|
7
|
+
const modal = useModal('content');
|
|
8
|
+
|
|
9
|
+
beforeAll(() => {
|
|
10
|
+
global.ResizeObserver = ResizeObserverMock;
|
|
11
|
+
|
|
12
|
+
window.scrollTo = vi.fn();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('create a div, append this to the body and destroys on unmount', async () => {
|
|
16
|
+
expect.assertions(2);
|
|
17
|
+
|
|
18
|
+
modal.open({ title: 'title' });
|
|
19
|
+
|
|
20
|
+
await flushPromises();
|
|
21
|
+
|
|
22
|
+
let documentModalHolder = document.querySelector('[data-test-modal-dialog]');
|
|
23
|
+
|
|
24
|
+
expect(documentModalHolder).not.toBeNull();
|
|
25
|
+
|
|
26
|
+
modal.close();
|
|
27
|
+
|
|
28
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
29
|
+
|
|
30
|
+
documentModalHolder = document.querySelector('[data-test-modal-dialog]');
|
|
31
|
+
|
|
32
|
+
expect(documentModalHolder).toBeNull();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { createApp, inject, isRef, ref } from 'vue';
|
|
2
|
+
import { AppModal } from '~components';
|
|
3
|
+
|
|
4
|
+
import type { App, Component, MaybeRef } from 'vue';
|
|
5
|
+
import type { ModalInstance, ModalProps } from '~components/AppModal/index.d';
|
|
6
|
+
|
|
7
|
+
const state = {
|
|
8
|
+
instances: ref<ModalInstance[]>([]),
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
function closeModal(modalInstance: ModalInstance): void {
|
|
12
|
+
modalInstance?.instance?.unmount();
|
|
13
|
+
modalInstance?.element?.remove();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function useModal(component: MaybeRef<Component | string>, options?: ModalProps) {
|
|
17
|
+
const instance = ref<ModalInstance>();
|
|
18
|
+
const plugins = inject<Plugin[]>('plugins');
|
|
19
|
+
|
|
20
|
+
async function open(openOptions: ModalProps): Promise<unknown> {
|
|
21
|
+
if (options) {
|
|
22
|
+
options.content = component;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
window.scrollTo(0, 0);
|
|
26
|
+
|
|
27
|
+
const modalRootElement = document.createElement('div');
|
|
28
|
+
document.body.append(modalRootElement);
|
|
29
|
+
|
|
30
|
+
let modalInstance = null as null | App;
|
|
31
|
+
let modalRef = null as null | typeof AppModal;
|
|
32
|
+
|
|
33
|
+
return new Promise(resolve => {
|
|
34
|
+
if (isRef(component)) {
|
|
35
|
+
modalRef = component.value as typeof AppModal;
|
|
36
|
+
} else {
|
|
37
|
+
modalInstance = createApp(AppModal, {
|
|
38
|
+
...options,
|
|
39
|
+
|
|
40
|
+
...openOptions,
|
|
41
|
+
|
|
42
|
+
onClose: (data: unknown) => {
|
|
43
|
+
options?.onClose?.();
|
|
44
|
+
|
|
45
|
+
resolve(data);
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
plugins?.forEach(plugin => {
|
|
50
|
+
// @ts-expect-error plugin not typed correctly
|
|
51
|
+
modalInstance?.use(plugin);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
modalRef = modalInstance.mount(modalRootElement) as unknown as typeof AppModal;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
modalRef.open();
|
|
58
|
+
|
|
59
|
+
instance.value = {
|
|
60
|
+
ref: modalRef,
|
|
61
|
+
instance: modalInstance,
|
|
62
|
+
element: modalRootElement,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
state.instances.value.push(instance.value);
|
|
66
|
+
}).finally(() => {
|
|
67
|
+
if (modalInstance) {
|
|
68
|
+
setTimeout(() => {
|
|
69
|
+
closeModal({
|
|
70
|
+
ref: modalRef,
|
|
71
|
+
instance: modalInstance,
|
|
72
|
+
element: modalRootElement,
|
|
73
|
+
});
|
|
74
|
+
}, 500);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function close(): Promise<void> {
|
|
80
|
+
instance.value?.ref.close();
|
|
81
|
+
|
|
82
|
+
setTimeout(() => {
|
|
83
|
+
if (instance.value) {
|
|
84
|
+
closeModal(instance.value);
|
|
85
|
+
}
|
|
86
|
+
}, 300);
|
|
87
|
+
|
|
88
|
+
return Promise.resolve();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return {
|
|
92
|
+
...state,
|
|
93
|
+
instance,
|
|
94
|
+
open,
|
|
95
|
+
close,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { HomeIcon } from '@heroicons/vue/24/outline';
|
|
2
|
+
|
|
3
|
+
import type { NavigationItem } from '../index.d';
|
|
4
|
+
|
|
5
|
+
export const navigationItem: NavigationItem = {
|
|
6
|
+
name: 'Home',
|
|
7
|
+
to: {
|
|
8
|
+
name: 'index',
|
|
9
|
+
// eslint-disable-next-line unicorn/prevent-abbreviations
|
|
10
|
+
params: {},
|
|
11
|
+
matched: [],
|
|
12
|
+
query: {},
|
|
13
|
+
fullPath: '',
|
|
14
|
+
hash: '',
|
|
15
|
+
redirectedFrom: undefined,
|
|
16
|
+
meta: {},
|
|
17
|
+
path: '',
|
|
18
|
+
},
|
|
19
|
+
href: '/href',
|
|
20
|
+
icon: HomeIcon,
|
|
21
|
+
active: true,
|
|
22
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { RouterLinkStub } from '@vue/test-utils';
|
|
3
|
+
import { useNavigation } from '../index';
|
|
4
|
+
import { navigationItem as navigationItemMock } from '../__mocks__/navigation';
|
|
5
|
+
|
|
6
|
+
describe('the useNavigation composables', () => {
|
|
7
|
+
const navigation = useNavigation();
|
|
8
|
+
|
|
9
|
+
it('can set navigation items', () => {
|
|
10
|
+
expect(navigation.navigationItems.value).toHaveLength(0);
|
|
11
|
+
|
|
12
|
+
navigation.setNavigationItems([
|
|
13
|
+
navigationItemMock,
|
|
14
|
+
navigationItemMock,
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
expect(navigation.navigationItems.value).toHaveLength(2);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('can set navigation component', () => {
|
|
21
|
+
expect(navigation.navigationComponent.value).toBe('a');
|
|
22
|
+
|
|
23
|
+
navigation.setNavigationComponent(RouterLinkStub);
|
|
24
|
+
|
|
25
|
+
expect(navigation.navigationComponent.value).toBe(RouterLinkStub);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('can set logo', () => {
|
|
29
|
+
expect(navigation.logo.value).toBeNull();
|
|
30
|
+
|
|
31
|
+
navigation.setLogo('logo.png');
|
|
32
|
+
|
|
33
|
+
expect(navigation.logo.value).toBe('logo.png');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('can open, close and toggle main menu', () => {
|
|
37
|
+
expect(navigation.mainMenuOpen.value).toBe(false);
|
|
38
|
+
|
|
39
|
+
navigation.openMainMenu();
|
|
40
|
+
|
|
41
|
+
expect(navigation.mainMenuOpen.value).toBe(true);
|
|
42
|
+
|
|
43
|
+
navigation.closeMainMenu();
|
|
44
|
+
|
|
45
|
+
expect(navigation.mainMenuOpen.value).toBe(false);
|
|
46
|
+
|
|
47
|
+
navigation.toggleMainMenu();
|
|
48
|
+
|
|
49
|
+
expect(navigation.mainMenuOpen.value).toBe(true);
|
|
50
|
+
|
|
51
|
+
navigation.toggleMainMenu();
|
|
52
|
+
|
|
53
|
+
expect(navigation.mainMenuOpen.value).toBe(false);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('can open,close and toggle mobile menu', () => {
|
|
57
|
+
expect(navigation.mobileMenuOpen.value).toBe(false);
|
|
58
|
+
|
|
59
|
+
navigation.openMobileMenu();
|
|
60
|
+
|
|
61
|
+
expect(navigation.mobileMenuOpen.value).toBe(true);
|
|
62
|
+
|
|
63
|
+
navigation.closeMobileMenu();
|
|
64
|
+
|
|
65
|
+
expect(navigation.mobileMenuOpen.value).toBe(false);
|
|
66
|
+
|
|
67
|
+
navigation.toggleMobileMenu();
|
|
68
|
+
|
|
69
|
+
expect(navigation.mobileMenuOpen.value).toBe(true);
|
|
70
|
+
|
|
71
|
+
navigation.toggleMobileMenu();
|
|
72
|
+
|
|
73
|
+
expect(navigation.mobileMenuOpen.value).toBe(false);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('should export the state', () => {
|
|
77
|
+
const states = [
|
|
78
|
+
'navigationItems',
|
|
79
|
+
'mainMenuOpen',
|
|
80
|
+
'mobileMenuOpen',
|
|
81
|
+
'navigationComponent',
|
|
82
|
+
'logo',
|
|
83
|
+
'contactRoute',
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
expect(states.every(state => Object.keys(navigation).includes(state))).toBe(true);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Component } from 'vue';
|
|
2
|
+
import type { RouteLocationNormalized } from 'vue-router';
|
|
3
|
+
|
|
4
|
+
export interface NavigationItem {
|
|
5
|
+
name: string;
|
|
6
|
+
icon: string | Component;
|
|
7
|
+
to?: RouteLocationNormalized | string;
|
|
8
|
+
href?: string;
|
|
9
|
+
active?: boolean;
|
|
10
|
+
rounded?: boolean;
|
|
11
|
+
bottom?: boolean;
|
|
12
|
+
visible?: boolean;
|
|
13
|
+
onClick?: () => unknown;
|
|
14
|
+
linkClasses?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type Logo = string | Component;
|