@maas/vue-equipment 0.25.4 → 0.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@maas/vue-equipment/nuxt",
3
3
  "configKey": "vueEquipment",
4
- "version": "0.25.3"
4
+ "version": "0.26.0"
5
5
  }
@@ -75,12 +75,15 @@ import {
75
75
  nextTick,
76
76
  toValue,
77
77
  onBeforeMount,
78
+ onMounted,
78
79
  onBeforeUnmount,
80
+ onUnmounted,
79
81
  type Component,
80
82
  type MaybeRef,
81
83
  } from 'vue'
82
84
  import { createDefu } from 'defu'
83
85
  import { onKeyStroke, unrefElement } from '@vueuse/core'
86
+ import { useMetaViewport } from '@maas/vue-equipment/composables'
84
87
  import { defaultOptions } from './../utils/defaultOptions'
85
88
  import { useDrawerApi } from './../composables/useDrawerApi'
86
89
  import { useDrawerCallback } from '../composables/private/useDrawerCallback'
@@ -149,6 +152,8 @@ const {
149
152
  unlockScroll,
150
153
  addScrollLockPadding,
151
154
  removeScrollLockPadding,
155
+ initialize,
156
+ destroy,
152
157
  } = drawerApi
153
158
 
154
159
  // Make sure this is reactive
@@ -210,6 +215,8 @@ const {
210
215
 
211
216
  useDrawerProgress({ id: props.id, elRef, drawerRef, position, overshoot })
212
217
 
218
+ const { resetMetaViewport } = useMetaViewport()
219
+
213
220
  // Prevent animation on initial mount if the options call for it
214
221
  // To achieve this, the transition names are set to undefined
215
222
  const preventTransition = computed(() => {
@@ -332,10 +339,33 @@ onBeforeMount(async () => {
332
339
  }
333
340
  })
334
341
 
342
+ onMounted(() => {
343
+ initialize()
344
+ })
345
+
335
346
  // Reset state on unmount
336
347
  onBeforeUnmount(() => {
337
348
  close()
338
349
  })
350
+
351
+ onUnmounted(() => {
352
+ if (mappedOptions.scrollLock) {
353
+ unlockScroll()
354
+ if (mappedOptions.scrollLockPadding) {
355
+ removeScrollLockPadding()
356
+ }
357
+ }
358
+
359
+ if (mappedOptions.focusTrap) {
360
+ releaseFocus()
361
+ }
362
+
363
+ if (mappedOptions.preventZoom) {
364
+ resetMetaViewport()
365
+ }
366
+
367
+ destroy()
368
+ })
339
369
  </script>
340
370
 
341
371
  <style>
@@ -13,11 +13,11 @@ type UseDrawerCallbackArgs = {
13
13
  wasActive: Ref<boolean>;
14
14
  };
15
15
  export declare function useDrawerCallback(args: UseDrawerCallbackArgs): {
16
- onBeforeEnter: (_el: Element) => void;
17
- onEnter: (_el: Element) => void;
18
- onAfterEnter: (_el: Element) => Promise<void>;
19
- onBeforeLeave: (_el: Element) => void;
16
+ onBeforeEnter: (_el?: Element) => void;
17
+ onEnter: (_el?: Element) => void;
18
+ onAfterEnter: (_el?: Element) => Promise<void>;
19
+ onBeforeLeave: (_el?: Element) => void;
20
20
  onLeave: (_el: Element) => void;
21
- onAfterLeave: (_el: Element) => void;
21
+ onAfterLeave: (_el?: Element) => void;
22
22
  };
23
23
  export {};
@@ -20,5 +20,7 @@ export declare function useDrawerApi(id?: MaybeRef<string>, options?: UseDrawerA
20
20
  unlockScroll: () => void;
21
21
  addScrollLockPadding: () => void;
22
22
  removeScrollLockPadding: () => void;
23
+ initialize: () => void;
24
+ destroy: () => void;
23
25
  };
24
26
  export type UseDrawerApiReturn = ReturnType<typeof useDrawerApi>;
@@ -1,10 +1,4 @@
1
- import {
2
- ref,
3
- computed,
4
- toValue,
5
- onMounted,
6
- onBeforeUnmount
7
- } from "vue";
1
+ import { ref, computed, toValue } from "vue";
8
2
  import { defu } from "defu";
9
3
  import { useScrollLock } from "@vueuse/core";
10
4
  import { useFocusTrap } from "@vueuse/integrations/useFocusTrap";
@@ -86,12 +80,12 @@ export function useDrawerApi(id, options) {
86
80
  (elem) => elem.style.paddingRight = ""
87
81
  );
88
82
  }
89
- onMounted(() => {
83
+ function initialize() {
90
84
  useDrawerEmitter().on("progress", progressCallback);
91
- });
92
- onBeforeUnmount(() => {
85
+ }
86
+ function destroy() {
93
87
  useDrawerEmitter().off("progress", progressCallback);
94
- });
88
+ }
95
89
  return {
96
90
  id: mappedId,
97
91
  isActive,
@@ -104,6 +98,8 @@ export function useDrawerApi(id, options) {
104
98
  lockScroll,
105
99
  unlockScroll,
106
100
  addScrollLockPadding,
107
- removeScrollLockPadding
101
+ removeScrollLockPadding,
102
+ initialize,
103
+ destroy
108
104
  };
109
105
  }
@@ -16,7 +16,7 @@
16
16
  </template>
17
17
 
18
18
  <script setup lang="ts">
19
- import { ref, computed } from 'vue'
19
+ import { ref, computed, onMounted } from 'vue'
20
20
  import { useMarqueeApi } from '../composables/useMarqueeApi'
21
21
 
22
22
  interface Props {
@@ -32,7 +32,7 @@ const props = withDefaults(defineProps<Props>(), {
32
32
  const parentRef = ref<HTMLElement | undefined>(undefined)
33
33
  const childRef = ref<HTMLElement | undefined>(undefined)
34
34
 
35
- const { duplicates, playing, play, pause } = useMarqueeApi({
35
+ const { duplicates, playing, play, pause, initialize } = useMarqueeApi({
36
36
  child: childRef,
37
37
  parent: parentRef,
38
38
  options: {
@@ -41,6 +41,10 @@ const { duplicates, playing, play, pause } = useMarqueeApi({
41
41
  },
42
42
  })
43
43
 
44
+ onMounted(() => {
45
+ initialize()
46
+ })
47
+
44
48
  defineExpose({
45
49
  playing,
46
50
  play,
@@ -12,4 +12,5 @@ export declare function useMarqueeApi({ child, parent, options }: UseMarqueeApiP
12
12
  playing: import("vue").Ref<boolean>;
13
13
  play: () => void;
14
14
  pause: () => void;
15
+ initialize: () => Promise<void>;
15
16
  };
@@ -1,4 +1,4 @@
1
- import { ref, onMounted, computed, nextTick, watch } from "vue";
1
+ import { ref, computed, nextTick, watch } from "vue";
2
2
  import {
3
3
  useElementBounding,
4
4
  useElementSize,
@@ -51,11 +51,11 @@ export function useMarqueeApi({ child, parent, options }) {
51
51
  "running"
52
52
  );
53
53
  }
54
- onMounted(() => {
54
+ async function initialize() {
55
55
  calculateDuplicates();
56
- nextTick();
56
+ await nextTick();
57
57
  setCssVariables();
58
- });
58
+ }
59
59
  watch(
60
60
  width,
61
61
  useThrottleFn(() => {
@@ -84,6 +84,7 @@ export function useMarqueeApi({ child, parent, options }) {
84
84
  duplicates,
85
85
  playing,
86
86
  play,
87
- pause
87
+ pause,
88
+ initialize
88
89
  };
89
90
  }
@@ -60,6 +60,7 @@ import {
60
60
  nextTick,
61
61
  toValue,
62
62
  onBeforeUnmount,
63
+ onUnmounted,
63
64
  type Component,
64
65
  type MaybeRef,
65
66
  } from 'vue'
@@ -167,6 +168,19 @@ watch(isActive, async (value) => {
167
168
  onBeforeUnmount(() => {
168
169
  close()
169
170
  })
171
+
172
+ onUnmounted(() => {
173
+ if (mappedOptions.scrollLock) {
174
+ unlockScroll()
175
+ if (mappedOptions.scrollLockPadding) {
176
+ removeScrollLockPadding()
177
+ }
178
+ }
179
+
180
+ if (mappedOptions.focusTrap) {
181
+ releaseFocus()
182
+ }
183
+ })
170
184
  </script>
171
185
 
172
186
  <style>
@@ -12,11 +12,11 @@ type UseModalCallbackArgs = {
12
12
  wrapperActive: Ref<boolean>;
13
13
  };
14
14
  export declare function useModalCallback(args: UseModalCallbackArgs): {
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;
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
21
  };
22
22
  export {};
@@ -1,7 +1,7 @@
1
1
  .clip-enter-active {
2
- animation: clip-in 0.6s cubic-bezier(0.83, 0, 0.17, 1) forwards;
2
+ animation: clip-in var(--duration, 600ms) var(--easing, cubic-bezier(0.83, 0, 0.17, 1)) forwards;
3
3
  }
4
4
 
5
5
  .clip-leave-active {
6
- animation: clip-out 0.6s cubic-bezier(0.83, 0, 0.17, 1) forwards;
6
+ animation: clip-out var(--duration, 600ms) var(--easing, cubic-bezier(0.83, 0, 0.17, 1)) forwards;
7
7
  }
@@ -1,8 +1,7 @@
1
1
  .fade-up-enter-active {
2
- animation: fade-up-in 300ms ease;
2
+ animation: fade-up-in var(--duration, 300ms) var(--easing, cubic-bezier(0.45, 0, 0.55, 1));
3
3
  }
4
4
 
5
5
  .fade-up-leave-active {
6
- animation: fade-up-out 300ms ease;
6
+ animation: fade-up-out var(--duration, 300ms) var(--easing, cubic-bezier(0.45, 0, 0.55, 1));
7
7
  }
8
-
@@ -1,8 +1,7 @@
1
1
  .fade-enter-active {
2
- animation: fade-in 300ms ease;
2
+ animation: fade-in var(--duration, 300ms) var(--easing, cubic-bezier(0.45, 0, 0.55, 1));
3
3
  }
4
4
 
5
5
  .fade-leave-active {
6
- animation: fade-out 300ms ease;
6
+ animation: fade-out var(--duration, 300ms) var(--easing, cubic-bezier(0.45, 0, 0.55, 1));
7
7
  }
8
-
@@ -1,8 +1,8 @@
1
1
  .slide-btt-enter-active {
2
- animation: slide-btt-in 300ms ease;
2
+ animation: slide-btt-in var(--duration, 300ms) var(--easing, cubic-bezier(0.45, 0, 0.55, 1));
3
3
  }
4
4
 
5
5
  .slide-btt-leave-active {
6
- animation: slide-btt-out 300ms ease;
6
+ animation: slide-btt-out var(--duration, 300ms) var(--easing, cubic-bezier(0.45, 0, 0.55, 1));
7
7
  }
8
8
 
@@ -1,7 +1,7 @@
1
1
  .slide-ltr-enter-active {
2
- animation: slide-ltr-in 300ms ease;
2
+ animation: slide-ltr-in var(--duration, 300ms) var(--easing, cubic-bezier(0.45, 0, 0.55, 1));
3
3
  }
4
4
 
5
5
  .slide-ltr-leave-active {
6
- animation: slide-ltr-out 300ms ease;
7
- }
6
+ animation: slide-ltr-out var(--duration, 300ms) var(--easing, cubic-bezier(0.45, 0, 0.55, 1));
7
+ }
@@ -1,8 +1,7 @@
1
1
  .slide-rtl-enter-active {
2
- animation: slide-rtl-in 300ms ease;
2
+ animation: slide-rtl-in var(--duration, 300ms) var(--easing, cubic-bezier(0.45, 0, 0.55, 1));
3
3
  }
4
4
 
5
5
  .slide-rtl-leave-active {
6
- animation: slide-rtl-out 300ms ease;
6
+ animation: slide-rtl-out var(--duration, 300ms) var(--easing, cubic-bezier(0.45, 0, 0.55, 1));
7
7
  }
8
-
@@ -1,9 +1,7 @@
1
1
  .slide-ttb-enter-active {
2
- animation: slide-ttb-in 300ms ease;
2
+ animation: slide-ttb-in var(--duration, 300ms) var(--easing, cubic-bezier(0.45, 0, 0.55, 1));
3
3
  }
4
4
 
5
5
  .slide-ttb-leave-active {
6
- animation: slide-ttb-out 300ms ease;
6
+ animation: slide-ttb-out var(--duration, 300ms) var(--easing, cubic-bezier(0.45, 0, 0.55, 1));
7
7
  }
8
-
9
-
@@ -1,7 +1,7 @@
1
1
  .zoom-enter-active {
2
- animation: zoom-in 300ms ease;
2
+ animation: zoom-in var(--duration, 300ms) var(--easing, cubic-bezier(0.45, 0, 0.55, 1));
3
3
  }
4
4
 
5
5
  .zoom-leave-active {
6
- animation: zoom-out 300ms ease;
7
- }
6
+ animation: zoom-out var(--duration, 300ms) var(--easing, cubic-bezier(0.45, 0, 0.55, 1));
7
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maas/vue-equipment",
3
3
  "description": "A magic collection of Vue composables, plugins, components and directives",
4
- "version": "0.25.4",
4
+ "version": "0.26.1",
5
5
  "author": "Robin Scholz <https://github.com/robinscholz>, Christoph Jeworutzki <https://github.com/ChristophJeworutzki>",
6
6
  "devDependencies": {
7
7
  "@antfu/ni": "^0.21.12",