@maas/vue-equipment 0.13.0 → 0.14.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.
Files changed (59) hide show
  1. package/dist/nuxt/module.json +1 -1
  2. package/dist/nuxt/module.mjs +22 -28
  3. package/dist/plugins/MagicConsent/src/composables/private/defineConsentApi.mjs +1 -1
  4. package/dist/plugins/MagicDrawer/index.d.ts +6 -0
  5. package/dist/plugins/MagicDrawer/index.mjs +9 -0
  6. package/dist/plugins/MagicDrawer/nuxt.d.ts +0 -0
  7. package/dist/plugins/MagicDrawer/nuxt.mjs +27 -0
  8. package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue +237 -0
  9. package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue.d.ts +52 -0
  10. package/dist/plugins/MagicDrawer/src/composables/private/useDrawerCallback.d.ts +22 -0
  11. package/dist/plugins/MagicDrawer/src/composables/private/useDrawerCallback.mjs +61 -0
  12. package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDrag.d.ts +15 -0
  13. package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDrag.mjs +201 -0
  14. package/dist/plugins/MagicDrawer/src/composables/private/useDrawerStore.d.ts +5 -0
  15. package/dist/plugins/MagicDrawer/src/composables/private/useDrawerStore.mjs +15 -0
  16. package/dist/plugins/MagicDrawer/src/composables/useDrawerApi.d.ts +19 -0
  17. package/dist/plugins/MagicDrawer/src/composables/useDrawerApi.mjs +75 -0
  18. package/dist/plugins/MagicDrawer/src/composables/useDrawerEmitter.d.ts +15 -0
  19. package/dist/plugins/MagicDrawer/src/composables/useDrawerEmitter.mjs +9 -0
  20. package/dist/plugins/MagicDrawer/src/index.d.ts +0 -0
  21. package/dist/plugins/MagicDrawer/src/index.mjs +0 -0
  22. package/dist/plugins/MagicDrawer/src/types/index.d.ts +29 -0
  23. package/dist/plugins/MagicDrawer/src/types/index.mjs +0 -0
  24. package/dist/plugins/MagicDrawer/src/utils/defaultOptions.d.ts +4 -0
  25. package/dist/plugins/MagicDrawer/src/utils/defaultOptions.mjs +22 -0
  26. package/dist/plugins/MagicModal/src/components/MagicModal.vue +2 -2
  27. package/dist/plugins/MagicModal/src/components/MagicModal.vue.d.ts +4 -4
  28. package/dist/plugins/MagicModal/src/composables/private/useModalCallback.d.ts +4 -4
  29. package/dist/plugins/MagicModal/src/composables/private/useModalCallback.mjs +14 -13
  30. package/dist/plugins/MagicModal/src/composables/useModalApi.mjs +1 -1
  31. package/dist/plugins/MagicModal/src/utils/defaultOptions.d.ts +2 -2
  32. package/dist/plugins/MagicNoise/src/utils/defaultOptions.d.ts +1 -1
  33. package/dist/plugins/MagicPlayer/src/composables/private/useControlsApi.mjs +1 -1
  34. package/dist/plugins/MagicPlayer/src/composables/private/usePlayerInternalApi.mjs +1 -1
  35. package/dist/plugins/MagicPlayer/src/composables/usePlayerApi.mjs +1 -1
  36. package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue +1 -1
  37. package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue.d.ts +1 -1
  38. package/dist/plugins/MagicScroll/src/composables/useScrollApi.mjs +1 -1
  39. package/dist/plugins/MagicToast/src/components/MagicToast.vue +6 -6
  40. package/dist/plugins/MagicToast/src/components/MagicToast.vue.d.ts +5 -5
  41. package/dist/plugins/MagicToast/src/composables/private/useToastInternalApi.mjs +1 -1
  42. package/dist/plugins/MagicToast/src/composables/private/useToastStore.d.ts +2 -2
  43. package/dist/plugins/MagicToast/src/composables/useToastApi.mjs +1 -1
  44. package/dist/plugins/MagicToast/src/types/index.d.ts +1 -1
  45. package/dist/plugins/MagicToast/src/utils/defaultOptions.d.ts +1 -1
  46. package/dist/plugins/index.d.ts +1 -0
  47. package/dist/plugins/index.mjs +1 -0
  48. package/dist/utils/css/animations/slide-btt-out.css +0 -3
  49. package/dist/utils/css/animations/slide-ltr-out.css +0 -3
  50. package/dist/utils/css/animations/slide-rtl-out.css +0 -3
  51. package/dist/utils/css/animations/slide-ttb-out.css +0 -3
  52. package/dist/utils/{index.d.cts → index.d.mts} +9 -1
  53. package/dist/utils/index.d.ts +9 -1
  54. package/dist/utils/index.js +60 -2
  55. package/dist/utils/index.js.map +1 -1
  56. package/dist/utils/{index.cjs → index.mjs} +28 -35
  57. package/dist/utils/index.mjs.map +1 -0
  58. package/package.json +2 -4
  59. package/dist/utils/index.cjs.map +0 -1
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@maas/vue-equipment/nuxt",
3
3
  "configKey": "vueEquipment",
4
- "version": "0.12.1"
4
+ "version": "0.13.1"
5
5
  }
@@ -1,20 +1,6 @@
1
1
  import { defineNuxtModule, createResolver, extendViteConfig, installModule, addImportsSources } from '@nuxt/kit';
2
2
 
3
- const packages = {
4
- composables: {
5
- name: "composables",
6
- display: "Vue Equipment Composables",
7
- description: "A magic collection of Vue composables",
8
- dir: "packages/composables"
9
- },
10
- plugins: {
11
- name: "plugins",
12
- display: "Vue Equipment Plugins",
13
- description: "A magic collection of Vue plugins",
14
- dir: "packages/plugins"
15
- }
16
- };
17
- const functions = [
3
+ const functions$1 = [
18
4
  {
19
5
  name: "MagicConsent",
20
6
  "package": "plugins",
@@ -22,6 +8,13 @@ const functions = [
22
8
  docs: "https://maas.egineering/vue-equipment/plugins/MagicConsent/",
23
9
  description: "consent"
24
10
  },
11
+ {
12
+ name: "MagicDrawer",
13
+ "package": "plugins",
14
+ lastUpdated: 1704735337000,
15
+ docs: "https://maas.egineering/vue-equipment/plugins/MagicDrawer/",
16
+ description: "drawer"
17
+ },
25
18
  {
26
19
  name: "MagicMarquee",
27
20
  "package": "plugins",
@@ -100,10 +93,11 @@ const functions = [
100
93
  description: "attach viewport dimensions as css variables to the document"
101
94
  }
102
95
  ];
103
- const metadata = {
104
- packages: packages,
105
- functions: functions
106
- };
96
+
97
+ const functions = functions$1;
98
+ functions.map((f) => f.name);
99
+ const plugins = functions.filter((p) => p.package === "plugins");
100
+ const composables = functions.filter((p) => p.package === "composables");
107
101
 
108
102
  const module = defineNuxtModule({
109
103
  meta: {
@@ -115,8 +109,8 @@ const module = defineNuxtModule({
115
109
  composables: true
116
110
  },
117
111
  async setup(options, nuxt) {
118
- let plugins;
119
- let composables;
112
+ let mappedPlugins;
113
+ let mappedComposables;
120
114
  const resolver = createResolver(import.meta.url);
121
115
  nuxt.options.build.transpile.push("@maas/vue-equipment");
122
116
  extendViteConfig((config) => {
@@ -130,24 +124,24 @@ const module = defineNuxtModule({
130
124
  nuxt.options.alias[`@maas/vue-equipment/${pkg}`] = nuxt.options.alias[`@maas/vue-equipment/${pkg}`] || resolver.resolve(`../${pkg}`);
131
125
  });
132
126
  if (options.plugins === true) {
133
- plugins = metadata.functions.filter((fn) => fn.package === "plugins").map((fn) => fn.name);
127
+ mappedPlugins = plugins.map((fn) => fn.name);
134
128
  } else {
135
- plugins = options.plugins || [];
129
+ mappedPlugins = options.plugins || [];
136
130
  }
137
- for (const plugin of plugins) {
131
+ for (const plugin of mappedPlugins) {
138
132
  const nuxtPlugin = await resolver.resolvePath(
139
133
  `@maas/vue-equipment/plugins/${plugin}/nuxt`
140
134
  );
141
135
  await installModule(nuxtPlugin);
142
136
  }
143
137
  if (options.composables === true) {
144
- composables = metadata.functions.filter((fn) => fn.package === "composables").map((fn) => fn.name);
138
+ mappedComposables = composables.map((fn) => fn.name);
145
139
  } else {
146
- composables = options.composables || [];
140
+ mappedComposables = options.composables || [];
147
141
  }
148
142
  addImportsSources({
149
- from: "composables",
150
- imports: composables
143
+ from: "@maas/vue-equipment/composables",
144
+ imports: mappedComposables
151
145
  });
152
146
  }
153
147
  });
@@ -1,5 +1,5 @@
1
1
  import { ref } from "vue";
2
- import { slugify } from "utils";
2
+ import { slugify } from "@maas/vue-equipment/utils";
3
3
  export const globalApiState = ref({
4
4
  cookies: {},
5
5
  maxAge: void 0
@@ -0,0 +1,6 @@
1
+ import MagicDrawer from './src/components/MagicDrawer.vue.js';
2
+ import { useDrawerApi } from './src/composables/useDrawerApi.js';
3
+ import { useDrawerEmitter } from './src/composables/useDrawerEmitter.js';
4
+ import type { Plugin } from 'vue';
5
+ declare const MagicDrawerPlugin: Plugin;
6
+ export { MagicDrawerPlugin, MagicDrawer, useDrawerApi, useDrawerEmitter };
@@ -0,0 +1,9 @@
1
+ import MagicDrawer from "./src/components/MagicDrawer.vue";
2
+ import { useDrawerApi } from "./src/composables/useDrawerApi.mjs";
3
+ import { useDrawerEmitter } from "./src/composables/useDrawerEmitter.mjs";
4
+ const MagicDrawerPlugin = {
5
+ install: (app) => {
6
+ app.component("MagicDrawer", MagicDrawer);
7
+ }
8
+ };
9
+ export { MagicDrawerPlugin, MagicDrawer, useDrawerApi, useDrawerEmitter };
File without changes
@@ -0,0 +1,27 @@
1
+ import {
2
+ defineNuxtModule,
3
+ createResolver,
4
+ addComponentsDir,
5
+ addImports
6
+ } from "@nuxt/kit";
7
+ export default defineNuxtModule({
8
+ meta: {
9
+ name: "@maas/vue-equipment/nuxt/MagicDrawer"
10
+ },
11
+ setup() {
12
+ const resolver = createResolver(import.meta.url);
13
+ addComponentsDir({
14
+ path: resolver.resolve("src/components"),
15
+ global: true,
16
+ pathPrefix: false
17
+ });
18
+ addImports({
19
+ from: "@maas/vue-equipment/plugins/MagicDrawer",
20
+ name: "useDrawerApi"
21
+ });
22
+ addImports({
23
+ from: "@maas/vue-equipment/plugins/MagicDrawer",
24
+ name: "useDrawerEmitter"
25
+ });
26
+ }
27
+ });
@@ -0,0 +1,237 @@
1
+ <template>
2
+ <transition :duration="5000">
3
+ <teleport
4
+ v-if="wrapperActive"
5
+ :to="mappedOptions.teleport?.target"
6
+ :disabled="mappedOptions.teleport?.disabled"
7
+ >
8
+ <component
9
+ :is="mappedOptions.tag"
10
+ ref="drawer"
11
+ class="magic-drawer"
12
+ :id="toValue(id)"
13
+ :class="[
14
+ toValue(props.class),
15
+ `-${mappedOptions.position}`,
16
+ { '-dragging': dragging },
17
+ ]"
18
+ aria-modal="true"
19
+ >
20
+ <transition
21
+ v-if="mappedOptions.backdrop || !!$slots.backdrop"
22
+ :name="mappedOptions.transitions?.backdrop"
23
+ >
24
+ <div
25
+ v-show="innerActive"
26
+ class="magic-drawer__backdrop"
27
+ @click.self="close"
28
+ >
29
+ <slot name="backdrop" />
30
+ </div>
31
+ </transition>
32
+ <div class="magic-drawer__wrapper">
33
+ <transition
34
+ :name="mappedOptions.transitions?.content"
35
+ @before-leave="onBeforeLeave"
36
+ @leave="onLeave"
37
+ @after-leave="onAfterLeave"
38
+ @before-enter="onBeforeEnter"
39
+ @enter="onEnter"
40
+ @after-enter="onAfterEnter"
41
+ >
42
+ <div
43
+ ref="elRef"
44
+ v-show="innerActive"
45
+ class="magic-drawer__content"
46
+ @pointerdown="onPointerdown"
47
+ :style="style"
48
+ >
49
+ <component
50
+ v-if="component"
51
+ v-bind="props"
52
+ :is="component"
53
+ @close="close"
54
+ />
55
+ <slot v-else />
56
+ </div>
57
+ </transition>
58
+ </div>
59
+ </component>
60
+ </teleport>
61
+ </transition>
62
+ </template>
63
+
64
+ <script setup lang="ts">
65
+ import {
66
+ ref,
67
+ watch,
68
+ nextTick,
69
+ toValue,
70
+ type Component,
71
+ type MaybeRef,
72
+ } from 'vue'
73
+ import { createDefu } from 'defu'
74
+ import { onKeyStroke, unrefElement } from '@vueuse/core'
75
+ import { defaultOptions } from './../utils/defaultOptions'
76
+ import { useDrawerApi } from './../composables/useDrawerApi'
77
+ import { useDrawerCallback } from '../composables/private/useDrawerCallback'
78
+ import { useDrawerDrag } from '../composables/private/useDrawerDrag'
79
+
80
+ import type { RequireAll } from '@maas/vue-equipment/utils'
81
+ import type { DrawerOptions } from './../types/index'
82
+
83
+ import '@maas/vue-equipment/utils/css/animations/fade-in.css'
84
+ import '@maas/vue-equipment/utils/css/animations/fade-out.css'
85
+ import '@maas/vue-equipment/utils/css/animations/slide-ltr-in.css'
86
+ import '@maas/vue-equipment/utils/css/animations/slide-rtl-in.css'
87
+ import '@maas/vue-equipment/utils/css/animations/slide-ttb-in.css'
88
+ import '@maas/vue-equipment/utils/css/animations/slide-btt-in.css'
89
+ import '@maas/vue-equipment/utils/css/animations/slide-ltr-out.css'
90
+ import '@maas/vue-equipment/utils/css/animations/slide-rtl-out.css'
91
+ import '@maas/vue-equipment/utils/css/animations/slide-ttb-out.css'
92
+ import '@maas/vue-equipment/utils/css/animations/slide-btt-out.css'
93
+
94
+ // Prevent keys array from being merged with default
95
+ const customDefu = createDefu((obj, key, value) => {
96
+ if (key === 'keys') {
97
+ obj[key] = value
98
+ return true
99
+ }
100
+ })
101
+
102
+ interface MagicDrawerProps {
103
+ id: MaybeRef<string>
104
+ class?: MaybeRef<string>
105
+ component?: Component
106
+ props?: Record<string, unknown>
107
+ options?: DrawerOptions
108
+ }
109
+
110
+ const props = withDefaults(defineProps<MagicDrawerProps>(), {
111
+ options: () => defaultOptions,
112
+ })
113
+
114
+ const elRef = ref<HTMLDivElement | undefined>(undefined)
115
+ const drawer = ref<HTMLElement | undefined>(undefined)
116
+ const drawerApi = useDrawerApi(props.id, { focusTarget: drawer })
117
+ const mappedOptions: typeof defaultOptions = customDefu(
118
+ props.options,
119
+ defaultOptions
120
+ )
121
+
122
+ const overshoot = ref(0)
123
+ const { position, threshold } = mappedOptions
124
+
125
+ const {
126
+ isActive,
127
+ close,
128
+ trapFocus,
129
+ releaseFocus,
130
+ lockScroll,
131
+ unlockScroll,
132
+ addScrollLockPadding,
133
+ removeScrollLockPadding,
134
+ } = drawerApi
135
+
136
+ const { onPointerdown, dragging, style } = useDrawerDrag({
137
+ position,
138
+ threshold,
139
+ overshoot,
140
+ elRef,
141
+ close,
142
+ })
143
+
144
+ // Split isActive into two values to animate drawer smoothly
145
+ const innerActive = ref(false)
146
+ const wrapperActive = ref(false)
147
+
148
+ const {
149
+ onBeforeEnter,
150
+ onEnter,
151
+ onAfterEnter,
152
+ onBeforeLeave,
153
+ onLeave,
154
+ onAfterLeave,
155
+ } = useDrawerCallback({
156
+ id: props.id,
157
+ mappedOptions,
158
+ addScrollLockPadding,
159
+ removeScrollLockPadding,
160
+ lockScroll,
161
+ unlockScroll,
162
+ trapFocus,
163
+ releaseFocus,
164
+ wrapperActive,
165
+ })
166
+
167
+ // Handle state
168
+ async function onOpen() {
169
+ wrapperActive.value = true
170
+ await nextTick()
171
+ innerActive.value = true
172
+ }
173
+
174
+ function onClose() {
175
+ innerActive.value = false
176
+ }
177
+
178
+ function convertToPixels(value: string) {
179
+ const regex = /^(\d*\.?\d+)\s*(rem|px)$/
180
+
181
+ const match = value.match(regex)
182
+
183
+ if (!match) {
184
+ console.error(
185
+ `--magic-drawer-drag-overshoot (${value}) needs to be specified in px or rem`
186
+ )
187
+ return 0
188
+ }
189
+
190
+ const numericValue = parseFloat(match[1])
191
+ const unit = match[2]
192
+ const bodyFontSize = window.getComputedStyle(document.body).fontSize
193
+ const rootFontSize = parseFloat(bodyFontSize) || 16
194
+
195
+ switch (unit) {
196
+ case 'rem':
197
+ return numericValue * rootFontSize
198
+ case 'px':
199
+ return numericValue
200
+ }
201
+ }
202
+
203
+ function saveOvershoot() {
204
+ const element = unrefElement(drawer)
205
+ const overshootVar = getComputedStyle(element!).getPropertyValue(
206
+ '--magic-drawer-drag-overshoot'
207
+ )
208
+
209
+ overshoot.value = convertToPixels(overshootVar) || 0
210
+ }
211
+
212
+ if (mappedOptions.keys) {
213
+ for (const key of mappedOptions.keys) {
214
+ onKeyStroke(key, (e) => {
215
+ e.preventDefault()
216
+ close()
217
+ })
218
+ }
219
+ }
220
+
221
+ watch(isActive, async (value) => {
222
+ if (value) {
223
+ await onOpen()
224
+ } else {
225
+ onClose()
226
+ }
227
+ })
228
+
229
+ // Save overshoot, as soon as drawer apepars in in DOM
230
+ watch(innerActive, () => {
231
+ saveOvershoot()
232
+ })
233
+ </script>
234
+
235
+ <style>
236
+ :root{--magic-drawer-z-index:999;--magic-drawer-justify-content:center;--magic-drawer-align-items:flex-end;--magic-drawer-backdrop-color:rgba(0,0,0,.5);--magic-drawer-backdrop-filter:unset;--magic-drawer-content-overflow-y:auto;--magic-drawer-handle-wrapper-height:2rem;--magic-drawer-handle-width:3rem;--magic-drawer-handle-height:0.375rem;--magic-drawer-handle-color:#d4d4d8;--magic-drawer-handle-border-radius:0.25rem;--magic-drawer-enter-animation:slide-btt-in 300ms ease;--magic-drawer-leave-animation:slide-btt-out 300ms ease;--magic-drawer-drag-overshoot:4rem;--magic-drawer-drag-overshoot-x:0;--magic-drawer-drag-overshoot-y:0}.magic-drawer{align-items:var(--magic-drawer-align-items);background:transparent;border:none;color:inherit;display:flex;height:100%;inset:0;justify-content:var(--magic-drawer-justify-content);padding:0;position:fixed;width:100%;z-index:var(--magic-drawer-z-index)}.magic-drawer.-bottom{--magic-drawer-drag-overshoot-y:var(--magic-drawer-drag-overshoot)}.magic-drawer.-top{--magic-drawer-enter-animation:slide-ttb-in 300ms ease;--magic-drawer-leave-animation:slide-ttb-out 300ms ease;--magic-drawer-align-items:flex-start;--magic-drawer-drag-overshoot-y:calc(var(--magic-drawer-drag-overshoot)*-1)}.magic-drawer.-right{--magic-drawer-enter-animation:slide-rtl-in 300ms ease;--magic-drawer-leave-animation:slide-rtl-out 300ms ease;--magic-drawer-align-items:center;--magic-drawer-justify-content:flex-end;--magic-drawer-drag-overshoot-x:var(--magic-drawer-drag-overshoot)}.magic-drawer.-left{--magic-drawer-enter-animation:slide-ltr-in 300ms ease;--magic-drawer-leave-animation:slide-ltr-out 300ms ease;--magic-drawer-align-items:center;--magic-drawer-justify-content:flex-start;--magic-drawer-drag-overshoot-x:calc(var(--magic-drawer-drag-overshoot)*-1)}.magic-drawer__wrapper{transform:translate(var(--magic-drawer-drag-overshoot-x),var(--magic-drawer-drag-overshoot-y));width:100%}.magic-drawer__content{-webkit-overflow-scrolling:touch;align-items:var(--magic-drawer-align-items);cursor:grab;display:flex;justify-content:var(--magic-drawer-justify-content);max-height:100%;overflow-y:var(--magic-drawer-content-overflow-y);position:relative;scroll-behavior:smooth;width:100%}.magic-drawer.-dragging .magic-drawer__content{cursor:grabbing}.magic-drawer__backdrop{-webkit-backdrop-filter:var(--magic-drawer-backdrop-filter);backdrop-filter:var(--magic-drawer-backdrop-filter);background-color:var(--magic-drawer-backdrop-color);bottom:0;height:100%;left:0;position:fixed;right:0;top:0;width:100%;z-index:-1}.magic-drawer--content-enter-active{animation:var(--magic-drawer-enter-animation)}.magic-drawer--content-leave-active{animation:var(--magic-drawer-leave-animation)}.magic-drawer--backdrop-enter-active{animation:fade-in .3s ease}.magic-drawer--backdrop-leave-active{animation:fade-out .3s ease}
237
+ </style>
@@ -0,0 +1,52 @@
1
+ import { type Component, type MaybeRef } from 'vue';
2
+ import type { DrawerOptions } from './../types/index';
3
+ import '@maas/vue-equipment/utils/css/animations/fade-in.css';
4
+ import '@maas/vue-equipment/utils/css/animations/fade-out.css';
5
+ import '@maas/vue-equipment/utils/css/animations/slide-ltr-in.css';
6
+ import '@maas/vue-equipment/utils/css/animations/slide-rtl-in.css';
7
+ import '@maas/vue-equipment/utils/css/animations/slide-ttb-in.css';
8
+ import '@maas/vue-equipment/utils/css/animations/slide-btt-in.css';
9
+ import '@maas/vue-equipment/utils/css/animations/slide-ltr-out.css';
10
+ import '@maas/vue-equipment/utils/css/animations/slide-rtl-out.css';
11
+ import '@maas/vue-equipment/utils/css/animations/slide-ttb-out.css';
12
+ import '@maas/vue-equipment/utils/css/animations/slide-btt-out.css';
13
+ interface MagicDrawerProps {
14
+ id: MaybeRef<string>;
15
+ class?: MaybeRef<string>;
16
+ component?: Component;
17
+ props?: Record<string, unknown>;
18
+ options?: DrawerOptions;
19
+ }
20
+ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<MagicDrawerProps>, {
21
+ options: () => DrawerOptions;
22
+ }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<MagicDrawerProps>, {
23
+ options: () => DrawerOptions;
24
+ }>>>, {
25
+ options: DrawerOptions;
26
+ }, {}>, {
27
+ backdrop?(_: {}): any;
28
+ default?(_: {}): any;
29
+ }>;
30
+ export default _default;
31
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
32
+ type __VLS_TypePropsToRuntimeProps<T> = {
33
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
34
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
35
+ } : {
36
+ type: import('vue').PropType<T[K]>;
37
+ required: true;
38
+ };
39
+ };
40
+ type __VLS_WithDefaults<P, D> = {
41
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
42
+ default: D[K];
43
+ }> : P[K];
44
+ };
45
+ type __VLS_Prettify<T> = {
46
+ [K in keyof T]: T[K];
47
+ } & {};
48
+ type __VLS_WithTemplateSlots<T, S> = T & {
49
+ new (): {
50
+ $slots: S;
51
+ };
52
+ };
@@ -0,0 +1,22 @@
1
+ import { type Ref, type MaybeRef } from 'vue';
2
+ import type { DrawerOptions } from '../../types.js';
3
+ type UseDrawerCallbackArgs = {
4
+ id: MaybeRef<string>;
5
+ mappedOptions: DrawerOptions;
6
+ addScrollLockPadding: () => void;
7
+ removeScrollLockPadding: () => void;
8
+ lockScroll: () => void;
9
+ unlockScroll: () => void;
10
+ trapFocus: () => void;
11
+ releaseFocus: () => void;
12
+ wrapperActive: Ref<boolean>;
13
+ };
14
+ export declare function useDrawerCallback(args: UseDrawerCallbackArgs): {
15
+ onBeforeEnter: (_el: Element) => void;
16
+ onEnter: (_el: Element) => void;
17
+ onAfterEnter: (_el: Element) => Promise<void>;
18
+ onBeforeLeave: (_el: Element) => void;
19
+ onLeave: (_el: Element) => void;
20
+ onAfterLeave: (_el: Element) => void;
21
+ };
22
+ export {};
@@ -0,0 +1,61 @@
1
+ import { toValue, nextTick } from "vue";
2
+ import { useDrawerEmitter } from "./../useDrawerEmitter.mjs";
3
+ export function useDrawerCallback(args) {
4
+ const {
5
+ id,
6
+ mappedOptions,
7
+ addScrollLockPadding,
8
+ removeScrollLockPadding,
9
+ lockScroll,
10
+ unlockScroll,
11
+ trapFocus,
12
+ releaseFocus,
13
+ wrapperActive
14
+ } = args;
15
+ function onBeforeEnter(_el) {
16
+ useDrawerEmitter().emit("beforeEnter", toValue(id));
17
+ }
18
+ function onEnter(_el) {
19
+ useDrawerEmitter().emit("enter", toValue(id));
20
+ }
21
+ async function onAfterEnter(_el) {
22
+ useDrawerEmitter().emit("afterEnter", toValue(id));
23
+ if (mappedOptions.scrollLock) {
24
+ if (mappedOptions.scrollLockPadding) {
25
+ addScrollLockPadding();
26
+ }
27
+ lockScroll();
28
+ }
29
+ if (mappedOptions.focusTrap) {
30
+ await nextTick();
31
+ trapFocus();
32
+ }
33
+ }
34
+ function onBeforeLeave(_el) {
35
+ useDrawerEmitter().emit("beforeLeave", toValue(id));
36
+ }
37
+ function onLeave(_el) {
38
+ useDrawerEmitter().emit("leave", toValue(id));
39
+ }
40
+ function onAfterLeave(_el) {
41
+ useDrawerEmitter().emit("afterLeave", toValue(id));
42
+ if (mappedOptions.scrollLock) {
43
+ unlockScroll();
44
+ if (mappedOptions.scrollLockPadding) {
45
+ removeScrollLockPadding();
46
+ }
47
+ }
48
+ if (mappedOptions.focusTrap) {
49
+ releaseFocus();
50
+ }
51
+ wrapperActive.value = false;
52
+ }
53
+ return {
54
+ onBeforeEnter,
55
+ onEnter,
56
+ onAfterEnter,
57
+ onBeforeLeave,
58
+ onLeave,
59
+ onAfterLeave
60
+ };
61
+ }
@@ -0,0 +1,15 @@
1
+ import { type MaybeRef } from 'vue';
2
+ import { defaultOptions } from '../../utils/defaultOptions.js';
3
+ type UseDrawerDragArgs = {
4
+ elRef: MaybeRef<HTMLDivElement | undefined>;
5
+ position: MaybeRef<typeof defaultOptions.position>;
6
+ threshold: MaybeRef<typeof defaultOptions.threshold>;
7
+ overshoot: MaybeRef<number>;
8
+ close: () => void;
9
+ };
10
+ export declare function useDrawerDrag(args: UseDrawerDragArgs): {
11
+ style: import("vue").ComputedRef<string>;
12
+ dragging: import("vue").Ref<boolean>;
13
+ onPointerdown: (e: PointerEvent) => void;
14
+ };
15
+ export {};