@maas/vue-equipment 0.40.0 → 1.0.0-beta.2
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 +6 -16
- package/dist/composables/index.d.ts +2 -13
- package/dist/composables/index.js +65 -128
- package/dist/composables/index.js.map +1 -1
- package/dist/nuxt/module.json +1 -1
- package/dist/nuxt/module.mjs +26 -40
- package/dist/plugins/.turbo/turbo-build.log +0 -0
- package/dist/plugins/.turbo/turbo-lint.log +13 -0
- package/dist/plugins/.turbo/turbo-release.log +7 -0
- package/dist/plugins/MagicAccordion/demo/data/footer.json +117 -0
- package/dist/plugins/MagicAccordion/index.d.ts +2 -0
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionContent.vue +103 -70
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionContent.vue.d.ts +17 -2
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionProvider.vue +36 -30
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionProvider.vue.d.ts +11 -2
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionTrigger.vue +71 -71
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionTrigger.vue.d.ts +12 -7
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionView.vue +51 -50
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionView.vue.d.ts +13 -4
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionCallback.d.ts +6 -6
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionCallback.mjs +6 -6
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionState.mjs +10 -10
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionView.mjs +11 -10
- package/dist/plugins/MagicAccordion/src/symbols/index.d.ts +1 -1
- package/dist/plugins/MagicAccordion/src/types/index.d.ts +4 -0
- package/dist/plugins/MagicAccordion/src/utils/defaultOptions.d.ts +2 -2
- package/dist/plugins/MagicAccordion/src/utils/defaultOptions.mjs +7 -2
- package/dist/plugins/MagicCommand/demo/data/about.json +3 -0
- package/dist/plugins/MagicCommand/demo/data/search.json +594 -0
- package/dist/plugins/MagicCommand/index.d.ts +2 -0
- package/dist/plugins/MagicCommand/index.mjs +9 -11
- package/dist/plugins/MagicCommand/src/components/MagicCommandContent.vue +192 -0
- package/dist/plugins/MagicCommand/src/components/{MagicCommandBody.vue.d.ts → MagicCommandContent.vue.d.ts} +4 -2
- package/dist/plugins/MagicCommand/src/components/MagicCommandDrawer.vue +60 -53
- package/dist/plugins/MagicCommand/src/components/MagicCommandDrawer.vue.d.ts +12 -3
- package/dist/plugins/MagicCommand/src/components/MagicCommandItem.vue +108 -79
- package/dist/plugins/MagicCommand/src/components/MagicCommandItem.vue.d.ts +18 -9
- package/dist/plugins/MagicCommand/src/components/MagicCommandModal.vue +55 -53
- package/dist/plugins/MagicCommand/src/components/MagicCommandModal.vue.d.ts +11 -2
- package/dist/plugins/MagicCommand/src/components/MagicCommandProvider.vue +94 -62
- package/dist/plugins/MagicCommand/src/components/MagicCommandProvider.vue.d.ts +52 -7
- package/dist/plugins/MagicCommand/src/components/MagicCommandRenderer.vue +63 -0
- package/dist/plugins/MagicCommand/src/components/MagicCommandRenderer.vue.d.ts +2 -0
- package/dist/plugins/MagicCommand/src/components/MagicCommandTrigger.vue +110 -0
- package/dist/plugins/MagicCommand/src/components/MagicCommandTrigger.vue.d.ts +75 -0
- package/dist/plugins/MagicCommand/src/components/MagicCommandView.vue +56 -73
- package/dist/plugins/MagicCommand/src/components/MagicCommandView.vue.d.ts +16 -9
- package/dist/plugins/MagicCommand/src/composables/private/useCommandCallback.d.ts +14 -0
- package/dist/plugins/MagicCommand/src/composables/private/useCommandCallback.mjs +32 -0
- package/dist/plugins/MagicCommand/src/composables/private/useCommandItem.d.ts +15 -6
- package/dist/plugins/MagicCommand/src/composables/private/useCommandItem.mjs +77 -44
- package/dist/plugins/MagicCommand/src/composables/private/useCommandScroll.d.ts +22 -4
- package/dist/plugins/MagicCommand/src/composables/private/useCommandScroll.mjs +45 -28
- package/dist/plugins/MagicCommand/src/composables/private/useCommandState.d.ts +7 -0
- package/dist/plugins/MagicCommand/src/composables/private/useCommandState.mjs +49 -0
- package/dist/plugins/MagicCommand/src/composables/private/useCommandTrigger.d.ts +18 -0
- package/dist/plugins/MagicCommand/src/composables/private/useCommandTrigger.mjs +76 -0
- package/dist/plugins/MagicCommand/src/composables/private/useCommandView.d.ts +21 -5
- package/dist/plugins/MagicCommand/src/composables/private/useCommandView.mjs +193 -18
- package/dist/plugins/MagicCommand/src/composables/useMagicCommand.d.ts +14 -5
- package/dist/plugins/MagicCommand/src/composables/useMagicCommand.mjs +43 -13
- package/dist/plugins/MagicCommand/src/symbols/index.d.ts +8 -1
- package/dist/plugins/MagicCommand/src/symbols/index.mjs +18 -1
- package/dist/plugins/MagicCommand/src/types/index.d.ts +73 -13
- package/dist/plugins/MagicCommand/src/utils/defaultOptions.d.ts +3 -5
- package/dist/plugins/MagicCommand/src/utils/defaultOptions.mjs +8 -3
- package/dist/plugins/MagicCookie/index.d.ts +5 -3
- package/dist/plugins/MagicCookie/index.mjs +7 -3
- package/dist/plugins/MagicCookie/nuxt.mjs +5 -9
- package/dist/plugins/MagicCookie/src/components/MagicCookieItem.vue +56 -0
- package/dist/plugins/MagicCookie/src/components/MagicCookieItem.vue.d.ts +33 -0
- package/dist/plugins/MagicCookie/src/components/MagicCookieProvider.vue +43 -0
- package/dist/plugins/MagicCookie/src/components/MagicCookieProvider.vue.d.ts +32 -0
- package/dist/plugins/MagicCookie/src/components/MagicCookieView.vue +96 -0
- package/dist/plugins/{MagicCommand/src/components/MagicCommandHead.vue.d.ts → MagicCookie/src/components/MagicCookieView.vue.d.ts} +6 -2
- package/dist/plugins/MagicCookie/src/composables/private/useCookieCallback.d.ts +9 -0
- package/dist/plugins/MagicCookie/src/composables/private/useCookieCallback.mjs +31 -0
- package/dist/plugins/MagicCookie/src/composables/private/useCookieItem.d.ts +16 -0
- package/dist/plugins/MagicCookie/src/composables/private/useCookieItem.mjs +87 -0
- package/dist/plugins/MagicCookie/src/composables/private/useCookieState.d.ts +7 -0
- package/dist/plugins/MagicCookie/src/composables/private/useCookieState.mjs +43 -0
- package/dist/plugins/MagicCookie/src/composables/useMagicCookie.d.ts +15 -15
- package/dist/plugins/MagicCookie/src/composables/useMagicCookie.mjs +59 -60
- package/dist/plugins/MagicCookie/src/symbols/index.d.ts +5 -0
- package/dist/plugins/MagicCookie/src/symbols/index.mjs +4 -0
- package/dist/plugins/MagicCookie/src/types/index.d.ts +31 -13
- package/dist/plugins/MagicCookie/src/utils/defaultOptions.d.ts +4 -0
- package/dist/plugins/MagicCookie/src/utils/defaultOptions.mjs +10 -0
- package/dist/plugins/MagicDraggable/src/components/MagicDraggable.vue +142 -97
- package/dist/plugins/MagicDraggable/src/components/MagicDraggable.vue.d.ts +12 -6
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableDrag.d.ts +6 -6
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableDrag.mjs +3 -1
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableSnap.d.ts +3 -4
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableSnap.mjs +11 -8
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableState.d.ts +2 -1
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableState.mjs +8 -8
- package/dist/plugins/MagicDraggable/src/types/index.d.ts +10 -5
- package/dist/plugins/MagicDraggable/src/utils/defaultOptions.d.ts +3 -8
- package/dist/plugins/MagicDraggable/src/utils/defaultOptions.mjs +5 -5
- package/dist/plugins/MagicDrawer/nuxt.mjs +1 -1
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue +491 -336
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue.d.ts +12 -6
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerCallback.d.ts +6 -6
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerCallback.mjs +6 -6
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDrag.d.ts +7 -9
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDrag.mjs +26 -16
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerGuards.d.ts +2 -3
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerProgress.d.ts +2 -2
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerProgress.mjs +4 -2
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerSnap.d.ts +5 -6
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerSnap.mjs +46 -29
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerState.d.ts +1 -1
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerState.mjs +8 -8
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerWheel.d.ts +2 -2
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerWheel.mjs +23 -19
- package/dist/plugins/MagicDrawer/src/composables/useMagicDrawer.mjs +4 -3
- package/dist/plugins/MagicDrawer/src/types/index.d.ts +10 -3
- package/dist/plugins/MagicDrawer/src/utils/defaultOptions.d.ts +3 -11
- package/dist/plugins/MagicDrawer/src/utils/defaultOptions.mjs +1 -3
- package/dist/plugins/MagicEmitter/src/composables/useMagicEmitter.d.ts +190 -46
- package/dist/plugins/MagicEmitter/src/types/index.d.ts +1 -1
- package/dist/plugins/MagicMarquee/index.d.ts +4 -2
- package/dist/plugins/MagicMarquee/index.mjs +2 -1
- package/dist/plugins/MagicMarquee/src/components/MagicMarquee.vue +121 -50
- package/dist/plugins/MagicMarquee/src/components/MagicMarquee.vue.d.ts +14 -10
- package/dist/plugins/MagicMarquee/src/composables/private/useMarqueeApi.d.ts +3 -7
- package/dist/plugins/MagicMarquee/src/composables/private/useMarqueeApi.mjs +52 -44
- package/dist/plugins/MagicMarquee/src/composables/private/useMarqueeState.d.ts +7 -0
- package/dist/plugins/MagicMarquee/src/composables/private/useMarqueeState.mjs +42 -0
- package/dist/plugins/MagicMarquee/src/composables/useMagicMarquee.d.ts +11 -0
- package/dist/plugins/MagicMarquee/src/composables/useMagicMarquee.mjs +45 -0
- package/dist/plugins/MagicMarquee/src/types/index.d.ts +9 -0
- package/dist/plugins/MagicMarquee/src/types/index.mjs +0 -0
- package/dist/plugins/MagicMarquee/src/utils/defaultOptions.d.ts +4 -0
- package/dist/plugins/MagicMarquee/src/utils/defaultOptions.mjs +5 -0
- package/dist/plugins/MagicMenu/index.d.ts +2 -0
- package/dist/plugins/MagicMenu/nuxt.mjs +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuChannel.vue +79 -69
- package/dist/plugins/MagicMenu/src/components/MagicMenuChannel.vue.d.ts +10 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuContent.vue +247 -215
- package/dist/plugins/MagicMenu/src/components/MagicMenuContent.vue.d.ts +12 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuFloat.vue +235 -211
- package/dist/plugins/MagicMenu/src/components/MagicMenuFloat.vue.d.ts +12 -2
- package/dist/plugins/MagicMenu/src/components/MagicMenuItem.vue +126 -124
- package/dist/plugins/MagicMenu/src/components/MagicMenuItem.vue.d.ts +15 -6
- package/dist/plugins/MagicMenu/src/components/MagicMenuProvider.vue +94 -96
- package/dist/plugins/MagicMenu/src/components/MagicMenuProvider.vue.d.ts +49 -4
- package/dist/plugins/MagicMenu/src/components/MagicMenuRemote.vue +98 -87
- package/dist/plugins/MagicMenu/src/components/MagicMenuRemote.vue.d.ts +11 -2
- package/dist/plugins/MagicMenu/src/components/MagicMenuTrigger.vue +111 -112
- package/dist/plugins/MagicMenu/src/components/MagicMenuTrigger.vue.d.ts +11 -2
- package/dist/plugins/MagicMenu/src/components/MagicMenuView.vue +67 -70
- package/dist/plugins/MagicMenu/src/components/MagicMenuView.vue.d.ts +13 -2
- package/dist/plugins/MagicMenu/src/composables/private/useMenuCallback.d.ts +6 -6
- package/dist/plugins/MagicMenu/src/composables/private/useMenuCallback.mjs +8 -8
- package/dist/plugins/MagicMenu/src/composables/private/useMenuChannel.mjs +35 -26
- package/dist/plugins/MagicMenu/src/composables/private/useMenuCursor.mjs +12 -6
- package/dist/plugins/MagicMenu/src/composables/private/useMenuItem.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/composables/private/useMenuItem.mjs +20 -14
- package/dist/plugins/MagicMenu/src/composables/private/useMenuKeyListener.mjs +20 -13
- package/dist/plugins/MagicMenu/src/composables/private/useMenuState.mjs +10 -10
- package/dist/plugins/MagicMenu/src/composables/private/useMenuTrigger.mjs +6 -3
- package/dist/plugins/MagicMenu/src/composables/private/useMenuView.d.ts +3 -3
- package/dist/plugins/MagicMenu/src/composables/private/useMenuView.mjs +99 -75
- package/dist/plugins/MagicMenu/src/symbols/index.d.ts +3 -3
- package/dist/plugins/MagicMenu/src/types/index.d.ts +1 -2
- package/dist/plugins/MagicModal/src/components/MagicModal.vue +265 -165
- package/dist/plugins/MagicModal/src/components/MagicModal.vue.d.ts +12 -6
- package/dist/plugins/MagicModal/src/composables/private/useModalCallback.d.ts +6 -6
- package/dist/plugins/MagicModal/src/composables/private/useModalCallback.mjs +6 -6
- package/dist/plugins/MagicModal/src/composables/private/useModalStore.mjs +1 -1
- package/dist/plugins/MagicModal/src/types/index.d.ts +2 -2
- package/dist/plugins/MagicModal/src/utils/defaultOptions.mjs +2 -2
- package/dist/plugins/MagicNoise/index.d.ts +3 -1
- package/dist/plugins/MagicNoise/src/components/MagicNoise.vue +120 -63
- package/dist/plugins/MagicNoise/src/components/MagicNoise.vue.d.ts +11 -4
- package/dist/plugins/MagicNoise/src/composables/private/useNoiseApi.mjs +2 -2
- package/dist/plugins/MagicPlayer/index.d.ts +4 -9
- package/dist/plugins/MagicPlayer/index.mjs +11 -17
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudio.vue +78 -0
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudio.vue.d.ts +2 -0
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudioControls.vue +134 -0
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudioControls.vue.d.ts +33 -0
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerDisplayTime.vue +45 -41
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerDisplayTime.vue.d.ts +11 -5
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerMuxPopover.vue +116 -114
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerMuxPopover.vue.d.ts +13 -5
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerOverlay.vue +111 -58
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerOverlay.vue.d.ts +1 -4
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerPoster.vue +42 -23
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerPoster.vue.d.ts +1 -4
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerProvider.vue +83 -0
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerProvider.vue.d.ts +34 -0
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerTimeline.vue +111 -65
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerTimeline.vue.d.ts +1 -4
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideo.vue +94 -0
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideo.vue.d.ts +2 -0
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideoControls.vue +222 -0
- package/dist/plugins/MagicPlayer/src/components/{MagicPlayerControls.vue.d.ts → MagicPlayerVideoControls.vue.d.ts} +12 -5
- package/dist/plugins/MagicPlayer/src/components/icons/FullscreenEnter.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/icons/FullscreenExit.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/icons/Pause.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/icons/Play.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/icons/VolumeOff.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/icons/VolumeOn.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/icons/Waiting.vue +23 -1
- package/dist/plugins/MagicPlayer/src/components/icons/Waiting.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerAudioApi.mjs +5 -6
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerControlsApi.mjs +18 -22
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerMediaApi.mjs +13 -13
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerRuntime.d.ts +2 -2
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerRuntime.mjs +4 -4
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerVideoApi.mjs +6 -8
- package/dist/plugins/MagicPlayer/src/composables/useMagicPlayer.d.ts +2 -6
- package/dist/plugins/MagicPlayer/src/composables/useMagicPlayer.mjs +5 -5
- package/dist/plugins/MagicPlayer/src/css/magic-player-audio-controls.css +95 -0
- package/dist/plugins/MagicPlayer/src/css/magic-player-display-time.css +10 -0
- package/dist/plugins/MagicPlayer/src/css/magic-player-timeline.css +89 -0
- package/dist/plugins/MagicPlayer/src/css/magic-player-video-controls.css +115 -0
- package/dist/plugins/MagicPlayer/src/symbols/index.d.ts +5 -0
- package/dist/plugins/MagicPlayer/src/symbols/index.mjs +3 -0
- package/dist/plugins/MagicPlayer/src/types/index.d.ts +11 -1
- package/dist/plugins/MagicPlayer/src/utils/defaultOptions.d.ts +3 -0
- package/dist/plugins/MagicPlayer/src/utils/defaultOptions.mjs +12 -0
- package/dist/plugins/MagicScroll/index.d.ts +4 -10
- package/dist/plugins/MagicScroll/index.mjs +2 -11
- package/dist/plugins/MagicScroll/src/components/MagicScrollCollision.vue +67 -31
- package/dist/plugins/MagicScroll/src/components/MagicScrollCollision.vue.d.ts +14 -4
- package/dist/plugins/MagicScroll/src/components/MagicScrollMotion.vue +78 -64
- package/dist/plugins/MagicScroll/src/components/MagicScrollMotion.vue.d.ts +14 -7
- package/dist/plugins/MagicScroll/src/components/MagicScrollProvider.vue +39 -39
- package/dist/plugins/MagicScroll/src/components/MagicScrollProvider.vue.d.ts +15 -9
- package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue +76 -73
- package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue.d.ts +13 -7
- package/dist/plugins/MagicScroll/src/composables/private/useCollisionDetection.d.ts +13 -0
- package/dist/plugins/MagicScroll/src/composables/private/useCollisionDetection.mjs +130 -0
- package/dist/plugins/MagicScroll/src/composables/private/useScrollApi.d.ts +3 -3
- package/dist/plugins/MagicScroll/src/composables/private/useScrollApi.mjs +5 -3
- package/dist/plugins/MagicScroll/src/symbols/index.d.ts +2 -2
- package/dist/plugins/MagicScroll/src/symbols/index.mjs +2 -2
- package/dist/plugins/MagicScroll/src/types/index.d.ts +12 -22
- package/dist/plugins/MagicToast/index.d.ts +3 -2
- package/dist/plugins/MagicToast/index.mjs +3 -3
- package/dist/plugins/MagicToast/nuxt.mjs +2 -2
- package/dist/plugins/MagicToast/src/components/MagicToastProvider.vue +296 -0
- package/dist/plugins/MagicToast/src/components/MagicToastProvider.vue.d.ts +23 -0
- package/dist/plugins/MagicToast/src/components/MagicToastView.vue +155 -0
- package/dist/plugins/MagicToast/src/components/MagicToastView.vue.d.ts +33 -0
- package/dist/plugins/MagicToast/src/composables/private/useToastCallback.d.ts +7 -30
- package/dist/plugins/MagicToast/src/composables/private/useToastCallback.mjs +34 -29
- package/dist/plugins/MagicToast/src/composables/private/useToastDrag.d.ts +12 -0
- package/dist/plugins/MagicToast/src/composables/private/useToastDrag.mjs +312 -0
- package/dist/plugins/MagicToast/src/composables/private/useToastListener.d.ts +6 -0
- package/dist/plugins/MagicToast/src/composables/private/useToastListener.mjs +25 -0
- package/dist/plugins/MagicToast/src/composables/private/useToastScrollLock.d.ts +6 -0
- package/dist/plugins/MagicToast/src/composables/private/useToastScrollLock.mjs +41 -0
- package/dist/plugins/MagicToast/src/composables/private/useToastState.d.ts +7 -0
- package/dist/plugins/MagicToast/src/composables/private/useToastState.mjs +45 -0
- package/dist/plugins/MagicToast/src/composables/private/useToastView.d.ts +12 -0
- package/dist/plugins/MagicToast/src/composables/private/useToastView.mjs +51 -0
- package/dist/plugins/MagicToast/src/composables/useMagicToast.d.ts +13 -8
- package/dist/plugins/MagicToast/src/composables/useMagicToast.mjs +26 -23
- package/dist/plugins/MagicToast/src/types/index.d.ts +58 -17
- package/dist/plugins/MagicToast/src/utils/defaultOptions.d.ts +2 -3
- package/dist/plugins/MagicToast/src/utils/defaultOptions.mjs +21 -4
- package/dist/plugins/MagicToast/symbols/index.d.ts +3 -0
- package/dist/plugins/MagicToast/symbols/index.mjs +2 -0
- package/dist/plugins/index.d.ts +0 -1
- package/dist/plugins/index.mjs +0 -1
- package/dist/utils/css/animations/auto-size-out.css +12 -0
- package/dist/utils/css/animations/squash-y.css +5 -0
- package/dist/utils/css/animations.css +2 -1
- package/dist/utils/index.d.ts +1 -2
- package/dist/utils/index.js +2 -53
- package/dist/utils/index.js.map +1 -1
- package/package.json +52 -57
- package/dist/composables/index.d.mts +0 -108
- package/dist/composables/index.mjs +0 -383
- package/dist/composables/index.mjs.map +0 -1
- package/dist/plugins/MagicAutoSize/index.d.ts +0 -4
- package/dist/plugins/MagicAutoSize/index.mjs +0 -7
- package/dist/plugins/MagicAutoSize/nuxt.d.ts +0 -2
- package/dist/plugins/MagicAutoSize/nuxt.mjs +0 -14
- package/dist/plugins/MagicAutoSize/src/components/MagicAutoSize.vue +0 -152
- package/dist/plugins/MagicAutoSize/src/components/MagicAutoSize.vue.d.ts +0 -29
- package/dist/plugins/MagicCommand/src/components/MagicCommandBody.vue +0 -91
- package/dist/plugins/MagicCommand/src/components/MagicCommandFooter.vue +0 -5
- package/dist/plugins/MagicCommand/src/components/MagicCommandFooter.vue.d.ts +0 -17
- package/dist/plugins/MagicCommand/src/components/MagicCommandGroup.vue +0 -5
- package/dist/plugins/MagicCommand/src/components/MagicCommandGroup.vue.d.ts +0 -17
- package/dist/plugins/MagicCommand/src/components/MagicCommandHead.vue +0 -5
- package/dist/plugins/MagicCommand/src/composables/private/useCommandStore.d.ts +0 -35
- package/dist/plugins/MagicCommand/src/composables/private/useCommandStore.mjs +0 -67
- package/dist/plugins/MagicCookie/src/components/MagicCookie.vue +0 -117
- package/dist/plugins/MagicCookie/src/components/MagicCookie.vue.d.ts +0 -27
- package/dist/plugins/MagicCookie/src/composables/private/useCookieApi.d.ts +0 -29
- package/dist/plugins/MagicCookie/src/composables/private/useCookieApi.mjs +0 -22
- package/dist/plugins/MagicPlayer/src/components/MagicAudioPlayer.vue +0 -89
- package/dist/plugins/MagicPlayer/src/components/MagicAudioPlayer.vue.d.ts +0 -28
- package/dist/plugins/MagicPlayer/src/components/MagicAudioPlayerControls.vue +0 -95
- package/dist/plugins/MagicPlayer/src/components/MagicAudioPlayerControls.vue.d.ts +0 -24
- package/dist/plugins/MagicPlayer/src/components/MagicPlayer.vue +0 -125
- package/dist/plugins/MagicPlayer/src/components/MagicPlayer.vue.d.ts +0 -35
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerControls.vue +0 -152
- package/dist/plugins/MagicScroll/src/components/MagicScrollTransform.vue +0 -42
- package/dist/plugins/MagicScroll/src/components/MagicScrollTransform.vue.d.ts +0 -36
- package/dist/plugins/MagicScroll/src/composables/private/useCollisionDetect.d.ts +0 -56
- package/dist/plugins/MagicScroll/src/composables/private/useCollisionDetect.mjs +0 -140
- package/dist/plugins/MagicToast/src/components/MagicToast.vue +0 -141
- package/dist/plugins/MagicToast/src/components/MagicToast.vue.d.ts +0 -14
- package/dist/plugins/MagicToast/src/components/MagicToastComponent.vue +0 -64
- package/dist/plugins/MagicToast/src/components/MagicToastComponent.vue.d.ts +0 -30
- package/dist/plugins/MagicToast/src/composables/private/useToastApi.d.ts +0 -5
- package/dist/plugins/MagicToast/src/composables/private/useToastApi.mjs +0 -22
- package/dist/plugins/MagicToast/src/composables/private/useToastInternalApi.d.ts +0 -4
- package/dist/plugins/MagicToast/src/composables/private/useToastInternalApi.mjs +0 -28
- package/dist/plugins/MagicToast/src/composables/private/useToastStore.d.ts +0 -27
- package/dist/plugins/MagicToast/src/composables/private/useToastStore.mjs +0 -41
- package/dist/utils/index.d.mts +0 -80
- package/dist/utils/index.mjs +0 -200
- package/dist/utils/index.mjs.map +0 -1
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { computed, toRefs, toValue } from "vue";
|
|
2
|
+
import { useEventListener } from "@vueuse/core";
|
|
3
|
+
import {
|
|
4
|
+
guardedReleasePointerCapture,
|
|
5
|
+
guardedSetPointerCapture,
|
|
6
|
+
isIOS,
|
|
7
|
+
interpolate,
|
|
8
|
+
isWithinRange
|
|
9
|
+
} from "@maas/vue-equipment/utils";
|
|
10
|
+
import { useToastState } from "./useToastState.mjs";
|
|
11
|
+
import { useMagicEmitter } from "../../../../MagicEmitter/index.mjs";
|
|
12
|
+
import { useToastView } from "./useToastView.mjs";
|
|
13
|
+
import { useToastScrollLock } from "./useToastScrollLock.mjs";
|
|
14
|
+
export function useToastDrag(args) {
|
|
15
|
+
const { instanceId, view } = args;
|
|
16
|
+
const { initializeState } = useToastState(instanceId);
|
|
17
|
+
const state = initializeState();
|
|
18
|
+
const { options } = toRefs(state);
|
|
19
|
+
const { threshold, animation, position, scrollLock } = options.value;
|
|
20
|
+
const { deleteView } = useToastView(instanceId);
|
|
21
|
+
const {
|
|
22
|
+
dragStart,
|
|
23
|
+
dragging,
|
|
24
|
+
shouldClose,
|
|
25
|
+
interpolateTo,
|
|
26
|
+
originX,
|
|
27
|
+
originY,
|
|
28
|
+
lastDraggedX,
|
|
29
|
+
lastDraggedY,
|
|
30
|
+
draggedX,
|
|
31
|
+
draggedY
|
|
32
|
+
} = toRefs(view);
|
|
33
|
+
let pointerdownTarget = void 0;
|
|
34
|
+
let cancelPointerup = void 0;
|
|
35
|
+
let cancelPointermove = void 0;
|
|
36
|
+
let cancelTouchend = void 0;
|
|
37
|
+
const hasDragged = computed(() => {
|
|
38
|
+
const hasDraggedX = !isWithinRange({
|
|
39
|
+
input: draggedX.value,
|
|
40
|
+
base: lastDraggedX.value,
|
|
41
|
+
threshold: toValue(threshold).lock
|
|
42
|
+
});
|
|
43
|
+
const hasDraggedY = !isWithinRange({
|
|
44
|
+
input: draggedY.value,
|
|
45
|
+
base: lastDraggedY.value,
|
|
46
|
+
threshold: toValue(threshold).lock
|
|
47
|
+
});
|
|
48
|
+
return hasDraggedX || hasDraggedY;
|
|
49
|
+
});
|
|
50
|
+
const style = computed(
|
|
51
|
+
() => `transform: translate(${draggedX.value}px, ${draggedY.value}px)`
|
|
52
|
+
);
|
|
53
|
+
const emitter = useMagicEmitter();
|
|
54
|
+
const {
|
|
55
|
+
lockScroll,
|
|
56
|
+
unlockScroll,
|
|
57
|
+
addScrollLockPadding,
|
|
58
|
+
removeScrollLockPadding
|
|
59
|
+
} = useToastScrollLock();
|
|
60
|
+
function interpolateDragged(args2) {
|
|
61
|
+
const {
|
|
62
|
+
to,
|
|
63
|
+
duration = toValue(animation)?.snap?.duration || 300,
|
|
64
|
+
easing
|
|
65
|
+
} = args2;
|
|
66
|
+
switch (position) {
|
|
67
|
+
case "top-center":
|
|
68
|
+
case "top-left":
|
|
69
|
+
case "top-right":
|
|
70
|
+
case "bottom-center":
|
|
71
|
+
case "bottom-left":
|
|
72
|
+
case "bottom-right":
|
|
73
|
+
interpolate({
|
|
74
|
+
from: draggedY.value,
|
|
75
|
+
to,
|
|
76
|
+
duration,
|
|
77
|
+
easing,
|
|
78
|
+
callback: (value) => {
|
|
79
|
+
draggedY.value = value;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
break;
|
|
83
|
+
case "center-left":
|
|
84
|
+
case "center-right":
|
|
85
|
+
interpolate({
|
|
86
|
+
from: draggedX.value,
|
|
87
|
+
to,
|
|
88
|
+
duration,
|
|
89
|
+
easing,
|
|
90
|
+
callback: (value) => {
|
|
91
|
+
draggedX.value = value;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function checkPosition() {
|
|
98
|
+
const distanceX = Math.abs(draggedX.value - lastDraggedX.value);
|
|
99
|
+
const distanceY = Math.abs(draggedY.value - lastDraggedY.value);
|
|
100
|
+
switch (position) {
|
|
101
|
+
case "top-center":
|
|
102
|
+
case "top-left":
|
|
103
|
+
case "top-right":
|
|
104
|
+
case "bottom-center":
|
|
105
|
+
case "bottom-left":
|
|
106
|
+
case "bottom-right":
|
|
107
|
+
if (distanceY > toValue(threshold).distance) {
|
|
108
|
+
shouldClose.value = true;
|
|
109
|
+
} else {
|
|
110
|
+
interpolateTo.value = 0;
|
|
111
|
+
}
|
|
112
|
+
break;
|
|
113
|
+
case "center-left":
|
|
114
|
+
case "center-right":
|
|
115
|
+
if (distanceX > toValue(threshold).distance) {
|
|
116
|
+
shouldClose.value = true;
|
|
117
|
+
} else {
|
|
118
|
+
interpolateTo.value = 0;
|
|
119
|
+
}
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function checkMomentum() {
|
|
124
|
+
const elapsed = Date.now() - dragStart.value.getTime();
|
|
125
|
+
const distanceX = Math.abs(draggedX.value - lastDraggedX.value);
|
|
126
|
+
const distanceY = Math.abs(draggedY.value - lastDraggedY.value);
|
|
127
|
+
const velocityX = elapsed && distanceX ? distanceX / elapsed : 0;
|
|
128
|
+
const velocityY = elapsed && distanceY ? distanceY / elapsed : 0;
|
|
129
|
+
switch (position) {
|
|
130
|
+
case "top-center":
|
|
131
|
+
case "top-left":
|
|
132
|
+
case "top-right":
|
|
133
|
+
case "bottom-center":
|
|
134
|
+
case "bottom-left":
|
|
135
|
+
case "bottom-right":
|
|
136
|
+
if (velocityY > 0.5) {
|
|
137
|
+
shouldClose.value = true;
|
|
138
|
+
} else {
|
|
139
|
+
interpolateTo.value = 0;
|
|
140
|
+
}
|
|
141
|
+
break;
|
|
142
|
+
case "center-left":
|
|
143
|
+
case "center-right":
|
|
144
|
+
if (velocityX > 0.5) {
|
|
145
|
+
shouldClose.value = true;
|
|
146
|
+
} else {
|
|
147
|
+
interpolateTo.value = 0;
|
|
148
|
+
}
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
function setDragged({ x, y }) {
|
|
153
|
+
switch (position) {
|
|
154
|
+
case "top-center":
|
|
155
|
+
const newDraggedTC = Math.min(y - originY.value, 0);
|
|
156
|
+
draggedY.value = newDraggedTC;
|
|
157
|
+
break;
|
|
158
|
+
case "top-left":
|
|
159
|
+
const newDraggedTL = Math.min(y - originY.value, 0);
|
|
160
|
+
draggedY.value = newDraggedTL;
|
|
161
|
+
break;
|
|
162
|
+
case "top-right":
|
|
163
|
+
const newDraggedTR = Math.min(y - originY.value, 0);
|
|
164
|
+
draggedY.value = newDraggedTR;
|
|
165
|
+
break;
|
|
166
|
+
case "bottom-center":
|
|
167
|
+
const newDraggedBC = Math.max(y - originY.value, 0);
|
|
168
|
+
draggedY.value = newDraggedBC;
|
|
169
|
+
break;
|
|
170
|
+
case "bottom-left":
|
|
171
|
+
const newDraggedBL = Math.max(y - originY.value, 0);
|
|
172
|
+
draggedY.value = newDraggedBL;
|
|
173
|
+
break;
|
|
174
|
+
case "bottom-right":
|
|
175
|
+
const newDraggedBR = Math.max(y - originY.value, 0);
|
|
176
|
+
draggedY.value = newDraggedBR;
|
|
177
|
+
break;
|
|
178
|
+
case "center-left":
|
|
179
|
+
const newDraggedCL = Math.min(x - originX.value, 0);
|
|
180
|
+
draggedX.value = newDraggedCL;
|
|
181
|
+
break;
|
|
182
|
+
case "center-right":
|
|
183
|
+
const newDraggedCR = Math.max(x - originX.value, 0);
|
|
184
|
+
draggedX.value = newDraggedCR;
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
function resetStateAndListeners() {
|
|
189
|
+
dragging.value = false;
|
|
190
|
+
shouldClose.value = false;
|
|
191
|
+
interpolateTo.value = void 0;
|
|
192
|
+
cancelTouchend?.();
|
|
193
|
+
cancelPointerup?.();
|
|
194
|
+
cancelPointermove?.();
|
|
195
|
+
}
|
|
196
|
+
function onPointerup(e) {
|
|
197
|
+
if (shouldClose.value) {
|
|
198
|
+
deleteView(view.id);
|
|
199
|
+
} else if (interpolateTo.value || interpolateTo.value === 0) {
|
|
200
|
+
interpolateDragged({
|
|
201
|
+
to: interpolateTo.value
|
|
202
|
+
});
|
|
203
|
+
} else {
|
|
204
|
+
switch (position) {
|
|
205
|
+
case "top-center":
|
|
206
|
+
case "top-left":
|
|
207
|
+
case "top-right":
|
|
208
|
+
case "bottom-center":
|
|
209
|
+
case "bottom-left":
|
|
210
|
+
case "bottom-right":
|
|
211
|
+
interpolateDragged({
|
|
212
|
+
to: lastDraggedY.value
|
|
213
|
+
});
|
|
214
|
+
break;
|
|
215
|
+
case "center-left":
|
|
216
|
+
case "center-right":
|
|
217
|
+
interpolateDragged({
|
|
218
|
+
to: lastDraggedX.value
|
|
219
|
+
});
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
emitter.emit("afterDrag", {
|
|
224
|
+
id: toValue(instanceId),
|
|
225
|
+
x: draggedX.value,
|
|
226
|
+
y: draggedY.value
|
|
227
|
+
});
|
|
228
|
+
resetStateAndListeners();
|
|
229
|
+
const scrollLockValue = toValue(scrollLock);
|
|
230
|
+
if (scrollLockValue) {
|
|
231
|
+
unlockScroll();
|
|
232
|
+
if (typeof scrollLockValue === "object" && scrollLockValue.padding) {
|
|
233
|
+
removeScrollLockPadding();
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (hasDragged.value) {
|
|
237
|
+
e.preventDefault();
|
|
238
|
+
}
|
|
239
|
+
guardedReleasePointerCapture({ event: e, element: pointerdownTarget });
|
|
240
|
+
}
|
|
241
|
+
function onPointermove(e) {
|
|
242
|
+
if (e.isTrusted && !e.isPrimary) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
e.stopImmediatePropagation();
|
|
246
|
+
e.stopPropagation();
|
|
247
|
+
shouldClose.value = false;
|
|
248
|
+
setDragged({ x: e.screenX, y: e.screenY });
|
|
249
|
+
checkMomentum();
|
|
250
|
+
checkPosition();
|
|
251
|
+
emitter.emit("drag", {
|
|
252
|
+
id: toValue(instanceId),
|
|
253
|
+
x: draggedX.value,
|
|
254
|
+
y: draggedY.value
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
function onPointerdown(e) {
|
|
258
|
+
const scrollLockValue = toValue(scrollLock);
|
|
259
|
+
if (scrollLockValue) {
|
|
260
|
+
lockScroll();
|
|
261
|
+
if (typeof scrollLockValue === "object" && scrollLockValue.padding) {
|
|
262
|
+
addScrollLockPadding();
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
if (dragging.value) {
|
|
266
|
+
return;
|
|
267
|
+
} else {
|
|
268
|
+
dragging.value = true;
|
|
269
|
+
pointerdownTarget = e.target;
|
|
270
|
+
guardedSetPointerCapture({
|
|
271
|
+
event: e,
|
|
272
|
+
element: e.target
|
|
273
|
+
});
|
|
274
|
+
emitter.emit("beforeDrag", {
|
|
275
|
+
id: toValue(instanceId),
|
|
276
|
+
x: draggedX.value,
|
|
277
|
+
y: draggedY.value
|
|
278
|
+
});
|
|
279
|
+
lastDraggedX.value = draggedX.value;
|
|
280
|
+
lastDraggedY.value = draggedY.value;
|
|
281
|
+
cancelPointerup = useEventListener(document, "pointerup", onPointerup);
|
|
282
|
+
cancelPointermove = useEventListener(
|
|
283
|
+
document,
|
|
284
|
+
"pointermove",
|
|
285
|
+
onPointermove,
|
|
286
|
+
{ passive: false }
|
|
287
|
+
);
|
|
288
|
+
cancelTouchend = isIOS() ? useEventListener(document, "touchend", onPointerup) : void 0;
|
|
289
|
+
originX.value = e.screenX - draggedX.value;
|
|
290
|
+
originY.value = e.screenY - draggedY.value;
|
|
291
|
+
dragStart.value = /* @__PURE__ */ new Date();
|
|
292
|
+
onPointermove(e);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
async function onClick(e) {
|
|
296
|
+
if (hasDragged.value) {
|
|
297
|
+
e.preventDefault();
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
if (position === "center-left" || position === "center-right") {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
if (state.options.layout?.expand === "click") {
|
|
304
|
+
state.expanded = true;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return {
|
|
308
|
+
onPointerdown,
|
|
309
|
+
onClick,
|
|
310
|
+
style
|
|
311
|
+
};
|
|
312
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useToastState } from "./useToastState.mjs";
|
|
2
|
+
export function useToastListener(instanceId) {
|
|
3
|
+
const { initializeState } = useToastState(instanceId);
|
|
4
|
+
const state = initializeState();
|
|
5
|
+
function onMouseenter() {
|
|
6
|
+
if (state.options.layout?.expand === "hover") {
|
|
7
|
+
state.expanded = true;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function onMouseleave() {
|
|
11
|
+
if (state.options.layout?.expand === "hover") {
|
|
12
|
+
state.expanded = false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function outsideClickCallback() {
|
|
16
|
+
if (state.options.layout?.expand === "click") {
|
|
17
|
+
state.expanded = false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
onMouseenter,
|
|
22
|
+
onMouseleave,
|
|
23
|
+
outsideClickCallback
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ref } from "vue";
|
|
2
|
+
import { useScrollLock } from "@vueuse/core";
|
|
3
|
+
import { matchClass } from "@maas/vue-equipment/utils";
|
|
4
|
+
const scrollLock = typeof window !== "undefined" ? useScrollLock(document?.documentElement) : ref(false);
|
|
5
|
+
export function useToastScrollLock() {
|
|
6
|
+
const positionFixedElements = ref([]);
|
|
7
|
+
function lockScroll() {
|
|
8
|
+
scrollLock.value = true;
|
|
9
|
+
}
|
|
10
|
+
function unlockScroll() {
|
|
11
|
+
scrollLock.value = false;
|
|
12
|
+
}
|
|
13
|
+
function addScrollLockPadding() {
|
|
14
|
+
if (typeof window === "undefined") return;
|
|
15
|
+
const exclude = new RegExp(/magic-toast/);
|
|
16
|
+
const scrollbarWidth = window.innerWidth - document.body.offsetWidth;
|
|
17
|
+
document.body.style.setProperty("--scrollbar-width", `${scrollbarWidth}px`);
|
|
18
|
+
document.body.style.paddingRight = "var(--scrollbar-width)";
|
|
19
|
+
positionFixedElements.value = [
|
|
20
|
+
...document.body.getElementsByTagName("*")
|
|
21
|
+
].filter(
|
|
22
|
+
(x) => getComputedStyle(x, null).getPropertyValue("position") === "fixed" && !matchClass(x, exclude)
|
|
23
|
+
);
|
|
24
|
+
positionFixedElements.value.forEach(
|
|
25
|
+
(elem) => elem.style.paddingRight = "var(--scrollbar-width)"
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
function removeScrollLockPadding() {
|
|
29
|
+
document.body.style.paddingRight = "";
|
|
30
|
+
document.body.style.removeProperty("--scrollbar-width");
|
|
31
|
+
positionFixedElements.value.forEach(
|
|
32
|
+
(elem) => elem.style.paddingRight = ""
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
lockScroll,
|
|
37
|
+
unlockScroll,
|
|
38
|
+
addScrollLockPadding,
|
|
39
|
+
removeScrollLockPadding
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type Ref, type MaybeRef } from 'vue';
|
|
2
|
+
import type { ToastState, MagicToastOptions } from '../../types/index.js';
|
|
3
|
+
export declare function useToastState(instanceId: MaybeRef<string>): {
|
|
4
|
+
initializeState: (options?: MagicToastOptions) => ToastState;
|
|
5
|
+
deleteState: () => void;
|
|
6
|
+
toastStateStore: Ref<ToastState[], ToastState[]>;
|
|
7
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ref, reactive, toValue } from "vue";
|
|
2
|
+
import { defu } from "defu";
|
|
3
|
+
import { defaultOptions } from "../../utils/defaultOptions.mjs";
|
|
4
|
+
const toastStateStore = ref([]);
|
|
5
|
+
export function useToastState(instanceId) {
|
|
6
|
+
function createState(id) {
|
|
7
|
+
const state = {
|
|
8
|
+
id,
|
|
9
|
+
options: { ...defaultOptions },
|
|
10
|
+
views: [],
|
|
11
|
+
expanded: false,
|
|
12
|
+
animating: false
|
|
13
|
+
};
|
|
14
|
+
return reactive(state);
|
|
15
|
+
}
|
|
16
|
+
function addState(id) {
|
|
17
|
+
const state = createState(id);
|
|
18
|
+
toastStateStore.value = [...toastStateStore.value, state];
|
|
19
|
+
return state;
|
|
20
|
+
}
|
|
21
|
+
function initializeState(options) {
|
|
22
|
+
let state = toastStateStore.value.find((entry) => {
|
|
23
|
+
return entry.id === toValue(instanceId);
|
|
24
|
+
});
|
|
25
|
+
if (!state) {
|
|
26
|
+
state = addState(toValue(instanceId));
|
|
27
|
+
}
|
|
28
|
+
if (options) {
|
|
29
|
+
const mappedOptions = defu(options, defaultOptions);
|
|
30
|
+
state.options = mappedOptions;
|
|
31
|
+
state.expanded = mappedOptions.initial.expanded;
|
|
32
|
+
}
|
|
33
|
+
return state;
|
|
34
|
+
}
|
|
35
|
+
function deleteState() {
|
|
36
|
+
toastStateStore.value = toastStateStore.value.filter(
|
|
37
|
+
(x) => x.id !== toValue(instanceId)
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
initializeState,
|
|
42
|
+
deleteState,
|
|
43
|
+
toastStateStore
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type MaybeRef } from 'vue';
|
|
2
|
+
import { type ToastView } from '../../types/index.js';
|
|
3
|
+
export type AddViewArgs = Pick<ToastView, 'component' | 'props'> & {
|
|
4
|
+
id?: string;
|
|
5
|
+
};
|
|
6
|
+
type InitializeViewArgs = AddViewArgs;
|
|
7
|
+
export declare function useToastView(instanceId: MaybeRef<string>): {
|
|
8
|
+
initializeView: (args: InitializeViewArgs) => ToastView;
|
|
9
|
+
deleteView: (id: string) => void;
|
|
10
|
+
getView: (id: string) => ToastView | undefined;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { reactive, markRaw } from "vue";
|
|
2
|
+
import { useToastState } from "./useToastState.mjs";
|
|
3
|
+
export function useToastView(instanceId) {
|
|
4
|
+
const { initializeState } = useToastState(instanceId);
|
|
5
|
+
const state = initializeState();
|
|
6
|
+
function uuid() {
|
|
7
|
+
return Math.random().toString(36).slice(2, 11);
|
|
8
|
+
}
|
|
9
|
+
function createView(args) {
|
|
10
|
+
const { id = uuid(), props, component } = args;
|
|
11
|
+
const view = {
|
|
12
|
+
component: markRaw(component),
|
|
13
|
+
props,
|
|
14
|
+
id,
|
|
15
|
+
dragStart: void 0,
|
|
16
|
+
dragging: false,
|
|
17
|
+
shouldClose: false,
|
|
18
|
+
interpolateTo: void 0,
|
|
19
|
+
snappedX: 0,
|
|
20
|
+
snappedY: 0,
|
|
21
|
+
originX: 0,
|
|
22
|
+
originY: 0,
|
|
23
|
+
lastDraggedX: 0,
|
|
24
|
+
lastDraggedY: 0,
|
|
25
|
+
draggedX: 0,
|
|
26
|
+
draggedY: 0
|
|
27
|
+
};
|
|
28
|
+
return reactive(view);
|
|
29
|
+
}
|
|
30
|
+
function addView(args) {
|
|
31
|
+
const view = createView(args);
|
|
32
|
+
state.views = [...state.views, view];
|
|
33
|
+
return view;
|
|
34
|
+
}
|
|
35
|
+
function initializeView(args) {
|
|
36
|
+
const { id } = args;
|
|
37
|
+
const view = getView(id ?? "") ?? addView(args);
|
|
38
|
+
return view;
|
|
39
|
+
}
|
|
40
|
+
function deleteView(id) {
|
|
41
|
+
state.views = state.views?.filter((view) => view.id !== id);
|
|
42
|
+
}
|
|
43
|
+
function getView(id) {
|
|
44
|
+
return state.views?.find((view) => view.id === id);
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
initializeView,
|
|
48
|
+
deleteView,
|
|
49
|
+
getView
|
|
50
|
+
};
|
|
51
|
+
}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { type MaybeRef } from 'vue';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ToastView } from '../types/index.js';
|
|
3
|
+
export interface AddArgs {
|
|
4
|
+
component: ToastView['component'];
|
|
5
|
+
props: ToastView['props'];
|
|
6
|
+
duration?: number;
|
|
7
|
+
id?: string;
|
|
8
|
+
}
|
|
3
9
|
export declare function useMagicToast(id: MaybeRef<string>): {
|
|
4
|
-
toasts: import("vue").ComputedRef<
|
|
5
|
-
count: import("vue").ComputedRef<number
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
clear: () => void;
|
|
10
|
+
toasts: import("vue").ComputedRef<ToastView[]>;
|
|
11
|
+
count: import("vue").ComputedRef<number>;
|
|
12
|
+
add: (args: AddArgs) => string;
|
|
13
|
+
remove: (id: string) => void;
|
|
14
|
+
expand: () => void;
|
|
15
|
+
collapse: () => void;
|
|
11
16
|
};
|
|
12
17
|
export type UseMagicToastReturn = ReturnType<typeof useMagicToast>;
|
|
@@ -1,35 +1,38 @@
|
|
|
1
|
-
import { computed, toValue
|
|
2
|
-
import {
|
|
1
|
+
import { computed, toValue } from "vue";
|
|
2
|
+
import { useToastState } from "./private/useToastState.mjs";
|
|
3
|
+
import { useToastView } from "./private/useToastView.mjs";
|
|
3
4
|
export function useMagicToast(id) {
|
|
4
|
-
const {
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const { initializeState } = useToastState(toValue(id));
|
|
6
|
+
const state = initializeState();
|
|
7
|
+
const { initializeView, deleteView } = useToastView(id);
|
|
8
|
+
const toasts = computed(() => state?.views);
|
|
7
9
|
const count = computed(() => toasts.value?.length);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
return
|
|
10
|
+
function add(args) {
|
|
11
|
+
const { id: id2, component, props, duration } = args;
|
|
12
|
+
const view = initializeView({ id: id2, component, props });
|
|
13
|
+
const mappedDuration = duration ?? state.options.duration;
|
|
14
|
+
if (mappedDuration > 0) {
|
|
15
|
+
setTimeout(() => {
|
|
16
|
+
deleteView(view.id);
|
|
17
|
+
}, mappedDuration);
|
|
18
|
+
}
|
|
19
|
+
return view.id;
|
|
18
20
|
}
|
|
19
|
-
function remove(
|
|
20
|
-
|
|
21
|
+
function remove(id2) {
|
|
22
|
+
deleteView(id2);
|
|
21
23
|
}
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
function expand() {
|
|
25
|
+
state.expanded = true;
|
|
26
|
+
}
|
|
27
|
+
function collapse() {
|
|
28
|
+
state.expanded = false;
|
|
25
29
|
}
|
|
26
30
|
return {
|
|
27
31
|
toasts,
|
|
28
32
|
count,
|
|
29
|
-
firstToast,
|
|
30
|
-
lastToast,
|
|
31
33
|
add,
|
|
32
34
|
remove,
|
|
33
|
-
|
|
35
|
+
expand,
|
|
36
|
+
collapse
|
|
34
37
|
};
|
|
35
38
|
}
|