@maas/vue-equipment 0.26.0 → 0.26.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.
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@maas/vue-equipment/nuxt",
3
3
  "configKey": "vueEquipment",
4
- "version": "0.25.4"
4
+ "version": "0.26.1"
5
5
  }
@@ -4,7 +4,7 @@ const functions$1 = [
4
4
  {
5
5
  name: "MagicCommand",
6
6
  "package": "plugins",
7
- lastUpdated: 1708958249000,
7
+ lastUpdated: 1713883907000,
8
8
  docs: "https://maas.egineering/vue-equipment/plugins/MagicCommand/",
9
9
  description: "command"
10
10
  },
@@ -53,7 +53,7 @@ const functions$1 = [
53
53
  {
54
54
  name: "MagicScroll",
55
55
  "package": "plugins",
56
- lastUpdated: 1707310473000,
56
+ lastUpdated: 1713883907000,
57
57
  docs: "https://maas.egineering/vue-equipment/plugins/MagicScroll/",
58
58
  description: "scroll"
59
59
  },
@@ -4,6 +4,7 @@ interface Props {
4
4
  }
5
5
  declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<Props>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<Props>>>, {}, {}>;
6
6
  export default _default;
7
+
7
8
  type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
8
9
  type __VLS_TypePropsToOption<T> = {
9
10
  [K in keyof T]-?: {} extends Pick<T, K> ? {
@@ -1,6 +1,6 @@
1
1
  import { useCommandApi } from './src/composables/useCommandApi.js';
2
2
  import { useCommandEmitter } from './src/composables/useCommandEmitter.js';
3
- import { CommandInstanceId, CommandOptionsKey } from './src/symbols.js';
3
+ import { CommandInstanceId, CommandOptionsKey } from './src/symbols/index.js';
4
4
  import type { Plugin } from 'vue';
5
5
  import type { CommandEvents } from './src/types/index.js';
6
6
  declare const MagicCommandPlugin: Plugin;
@@ -8,8 +8,9 @@ export default defineNuxtModule({
8
8
  meta: {
9
9
  name: "@maas/vue-equipment/nuxt/MagicDrawer"
10
10
  },
11
- setup() {
11
+ setup(_options, nuxt) {
12
12
  const resolver = createResolver(import.meta.url);
13
+ nuxt.options.build.transpile.push("wheel-gestures");
13
14
  addComponentsDir({
14
15
  path: resolver.resolve("src/components"),
15
16
  global: true,
@@ -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,
@@ -17,6 +17,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
17
17
  speed: number;
18
18
  }, {}>, {
19
19
  default?(_: {}): any;
20
+ default?(_: {}): any;
20
21
  }>;
21
22
  export default _default;
22
23
  type __VLS_WithDefaults<P, D> = {
@@ -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 {};
@@ -6,9 +6,9 @@ import MagicScrollCollision from './src/components/MagicScrollCollision.vue.js';
6
6
  import { useCollisionEmitter } from './src/composables/useCollisionEmitter.js';
7
7
  import { useScrollApi } from './src/composables/useScrollApi.js';
8
8
  import { useCollisionDetect } from './src/composables/useCollisionDetect.js';
9
- import { ScrollParentKey, ScrollPositionKey, ScrollProgressKey } from './src/symbols.js';
9
+ import { ScrollParentKey, ScrollPositionKey, ScrollProgressKey } from './src/symbols/index.js';
10
10
  import type { Plugin } from 'vue';
11
11
  declare const MagicScrollPlugin: Plugin;
12
12
  export { MagicScrollPlugin, MagicScrollProvider, MagicScrollScene, MagicScrollTransform, MagicScrollMotion, MagicScrollCollision, useCollisionEmitter, useScrollApi, useCollisionDetect, ScrollParentKey, ScrollPositionKey, ScrollProgressKey, };
13
- export * from './src/symbols.js';
13
+ export * from './src/symbols/index.js';
14
14
  export type * from './src/types/index';
@@ -43,10 +43,17 @@
43
43
  </template>
44
44
 
45
45
  <script setup lang="ts">
46
- import { uuid } from '@maas/vue-equipment/utils'
46
+ import {
47
+ toValue,
48
+ ref,
49
+ watch,
50
+ onBeforeMount,
51
+ onUnmounted,
52
+ type MaybeRef,
53
+ } from 'vue'
47
54
  import { defu } from 'defu'
48
- import { toValue, ref, watch, type MaybeRef } from 'vue'
49
55
  import { onClickOutside, type MaybeElement } from '@vueuse/core'
56
+ import { uuid } from '@maas/vue-equipment/utils'
50
57
  import { defaultOptions } from './../utils/defaultOptions'
51
58
  import { useToastApi } from './../composables/useToastApi'
52
59
  import { useToastCallback } from './../composables/private/useToastCallback'
@@ -69,7 +76,7 @@ interface MagicToastProps {
69
76
 
70
77
  const props = defineProps<MagicToastProps>()
71
78
 
72
- const { toasts, count, oldest } = useToastApi(props.id)
79
+ const { toasts, count, oldest, initialize, destroy } = useToastApi(props.id)
73
80
 
74
81
  const mappedOptions = defu(props.options, defaultOptions)
75
82
  const isExpanded = ref(mappedOptions.layout?.expand === true)
@@ -111,10 +118,20 @@ function outsideClickCallback() {
111
118
  }
112
119
 
113
120
  onClickOutside(listRef, outsideClickCallback)
121
+
122
+ // Lifecycle hooks and listeners
114
123
  watch(
115
124
  () => props.id,
116
125
  () => (teleportKey.value = uuid())
117
126
  )
127
+
128
+ onBeforeMount(() => {
129
+ initialize()
130
+ })
131
+
132
+ onUnmounted(() => {
133
+ destroy(toValue(props.id))
134
+ })
118
135
  </script>
119
136
 
120
137
  <style>
@@ -7,5 +7,7 @@ export declare function useToastApi(id?: MaybeRef<string>): {
7
7
  add: (options: AddArgs) => Promise<string | undefined>;
8
8
  remove: (id: string) => void;
9
9
  clear: () => void;
10
+ initialize: () => import("./../types").ToastInstance | undefined;
11
+ destroy: (id: string) => void;
10
12
  };
11
13
  export type UseToastApiReturn = ReturnType<typeof useToastApi>;
@@ -1,11 +1,5 @@
1
1
  import { uuid } from "@maas/vue-equipment/utils";
2
- import {
3
- computed,
4
- onUnmounted,
5
- onBeforeMount,
6
- toValue,
7
- markRaw
8
- } from "vue";
2
+ import { computed, toValue, markRaw } from "vue";
9
3
  import { useToastStore } from "./private/useToastStore.mjs";
10
4
  export function useToastApi(id) {
11
5
  const { findInstance, addInstance, removeInstance } = useToastStore();
@@ -43,18 +37,14 @@ export function useToastApi(id) {
43
37
  return;
44
38
  instance.value.toasts = [];
45
39
  }
46
- onBeforeMount(() => {
47
- initialize();
48
- });
49
- onUnmounted(() => {
50
- destroy(toValue(mappedId));
51
- });
52
40
  return {
53
41
  toasts,
54
42
  count,
55
43
  oldest,
56
44
  add,
57
45
  remove,
58
- clear
46
+ clear,
47
+ initialize,
48
+ destroy
59
49
  };
60
50
  }
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.26.0",
4
+ "version": "0.26.2",
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",