@maas/vue-equipment 1.0.0-beta.43 → 1.0.0-beta.45

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 (90) hide show
  1. package/dist/composables/useScrollLockPadding/index.js +1 -0
  2. package/dist/composables/useScrollLockPadding/index.js.map +1 -1
  3. package/dist/nuxt/module.json +1 -1
  4. package/dist/nuxt/module.mjs +1 -1
  5. package/dist/plugins/MagicAccordion/src/components/MagicAccordionProvider.vue +2 -5
  6. package/dist/plugins/MagicAccordion/src/composables/private/useAccordionState.d.ts +2 -3
  7. package/dist/plugins/MagicAccordion/src/composables/private/useAccordionState.mjs +38 -11
  8. package/dist/plugins/MagicAccordion/src/types/index.d.ts +1 -0
  9. package/dist/plugins/MagicCommand/src/components/MagicCommandItem.d.vue.ts +2 -2
  10. package/dist/plugins/MagicCommand/src/components/MagicCommandItem.vue.d.ts +2 -2
  11. package/dist/plugins/MagicCommand/src/components/MagicCommandProvider.vue +2 -5
  12. package/dist/plugins/MagicCommand/src/components/MagicCommandRenderer.vue +1 -0
  13. package/dist/plugins/MagicCommand/src/composables/private/useCommandState.d.ts +2 -3
  14. package/dist/plugins/MagicCommand/src/composables/private/useCommandState.mjs +36 -11
  15. package/dist/plugins/MagicCommand/src/types/index.d.ts +1 -0
  16. package/dist/plugins/MagicCookie/src/composables/private/useCookieState.d.ts +2 -3
  17. package/dist/plugins/MagicCookie/src/composables/private/useCookieState.mjs +35 -12
  18. package/dist/plugins/MagicCookie/src/composables/useMagicCookie.mjs +6 -1
  19. package/dist/plugins/MagicCookie/src/types/index.d.ts +1 -0
  20. package/dist/plugins/MagicDraggable/src/composables/private/useDraggableDrag.mjs +28 -11
  21. package/dist/plugins/MagicDraggable/src/composables/private/useDraggableSnap.mjs +11 -1
  22. package/dist/plugins/MagicDraggable/src/composables/private/useDraggableState.d.ts +1 -1
  23. package/dist/plugins/MagicDraggable/src/composables/private/useDraggableState.mjs +41 -11
  24. package/dist/plugins/MagicDraggable/src/composables/useMagicDraggable.mjs +2 -1
  25. package/dist/plugins/MagicDraggable/src/types/index.d.ts +1 -0
  26. package/dist/plugins/MagicDrawer/src/components/MagicDrawer.d.vue.ts +2 -2
  27. package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue +11 -3
  28. package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue.d.ts +2 -2
  29. package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDrag.d.ts +2 -0
  30. package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDrag.mjs +184 -29
  31. package/dist/plugins/MagicDrawer/src/composables/private/useDrawerState.d.ts +2 -3
  32. package/dist/plugins/MagicDrawer/src/composables/private/useDrawerState.mjs +35 -10
  33. package/dist/plugins/MagicDrawer/src/composables/useMagicDrawer.mjs +2 -1
  34. package/dist/plugins/MagicDrawer/src/types/index.d.ts +1 -0
  35. package/dist/plugins/MagicEmitter/src/composables/useMagicEmitter.mjs +10 -5
  36. package/dist/plugins/MagicMarquee/src/components/MagicMarquee.vue +2 -5
  37. package/dist/plugins/MagicMarquee/src/composables/private/useMarqueeState.d.ts +2 -3
  38. package/dist/plugins/MagicMarquee/src/composables/private/useMarqueeState.mjs +36 -11
  39. package/dist/plugins/MagicMarquee/src/types/index.d.ts +1 -0
  40. package/dist/plugins/MagicMenu/src/components/MagicMenuItem.d.vue.ts +2 -2
  41. package/dist/plugins/MagicMenu/src/components/MagicMenuItem.vue.d.ts +2 -2
  42. package/dist/plugins/MagicMenu/src/components/MagicMenuProvider.vue +2 -6
  43. package/dist/plugins/MagicMenu/src/composables/private/useMenuCursor.mjs +13 -1
  44. package/dist/plugins/MagicMenu/src/composables/private/useMenuState.d.ts +2 -3
  45. package/dist/plugins/MagicMenu/src/composables/private/useMenuState.mjs +32 -12
  46. package/dist/plugins/MagicMenu/src/composables/private/useMenuTrigger.mjs +1 -1
  47. package/dist/plugins/MagicMenu/src/types/index.d.ts +1 -0
  48. package/dist/plugins/MagicModal/src/composables/private/useModalState.d.ts +6 -0
  49. package/dist/plugins/MagicModal/src/composables/private/useModalState.mjs +58 -0
  50. package/dist/plugins/MagicModal/src/composables/private/useModalStore.d.ts +1 -5
  51. package/dist/plugins/MagicModal/src/composables/private/useModalStore.mjs +1 -15
  52. package/dist/plugins/MagicModal/src/composables/useMagicModal.mjs +7 -6
  53. package/dist/plugins/MagicModal/src/types/index.d.ts +5 -0
  54. package/dist/plugins/MagicNoise/src/components/MagicNoise.vue +14 -2
  55. package/dist/plugins/MagicPie/src/components/MagicPie.vue +12 -6
  56. package/dist/plugins/MagicPie/src/composables/private/usePieState.d.ts +1 -1
  57. package/dist/plugins/MagicPie/src/composables/private/usePieState.mjs +33 -12
  58. package/dist/plugins/MagicPie/src/types/index.d.ts +1 -0
  59. package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudio.vue +9 -6
  60. package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudioControls.vue +4 -8
  61. package/dist/plugins/MagicPlayer/src/components/MagicPlayerMuxPopover.vue +8 -1
  62. package/dist/plugins/MagicPlayer/src/components/MagicPlayerProvider.vue +2 -11
  63. package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideo.vue +10 -6
  64. package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideoControls.vue +4 -8
  65. package/dist/plugins/MagicPlayer/src/composables/private/usePlayerControlsApi.d.ts +0 -1
  66. package/dist/plugins/MagicPlayer/src/composables/private/usePlayerControlsApi.mjs +20 -9
  67. package/dist/plugins/MagicPlayer/src/composables/private/usePlayerEmitter.mjs +124 -75
  68. package/dist/plugins/MagicPlayer/src/composables/private/usePlayerMediaApi.mjs +100 -32
  69. package/dist/plugins/MagicPlayer/src/composables/private/usePlayerRuntime.d.ts +0 -1
  70. package/dist/plugins/MagicPlayer/src/composables/private/usePlayerRuntime.mjs +33 -13
  71. package/dist/plugins/MagicPlayer/src/composables/private/usePlayerState.d.ts +2 -3
  72. package/dist/plugins/MagicPlayer/src/composables/private/usePlayerState.mjs +35 -10
  73. package/dist/plugins/MagicPlayer/src/composables/useMagicPlayer.d.ts +0 -2
  74. package/dist/plugins/MagicPlayer/src/types/index.d.ts +1 -0
  75. package/dist/plugins/MagicScroll/src/components/MagicScrollCollision.vue +2 -2
  76. package/dist/plugins/MagicScroll/src/components/MagicScrollMotion.vue +13 -1
  77. package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue +9 -5
  78. package/dist/plugins/MagicScroll/src/composables/private/useCollisionDetection.mjs +2 -1
  79. package/dist/plugins/MagicToast/src/components/MagicToastProvider.vue +2 -11
  80. package/dist/plugins/MagicToast/src/components/MagicToastView.vue +1 -0
  81. package/dist/plugins/MagicToast/src/composables/private/useToastDrag.mjs +13 -1
  82. package/dist/plugins/MagicToast/src/composables/private/useToastState.d.ts +2 -3
  83. package/dist/plugins/MagicToast/src/composables/private/useToastState.mjs +35 -12
  84. package/dist/plugins/MagicToast/src/types/index.d.ts +1 -0
  85. package/dist/utils/index.d.ts +8 -1
  86. package/dist/utils/index.js +31 -0
  87. package/dist/utils/index.js.map +1 -1
  88. package/package.json +1 -1
  89. package/dist/plugins/MagicError/src/MagicError.d.ts +0 -0
  90. package/dist/plugins/MagicError/src/MagicError.mjs +0 -0
@@ -47,6 +47,7 @@ function useScrollLockPadding(args) {
47
47
  elem.style.scrollbarGutter = "";
48
48
  elem.style.overflow = "";
49
49
  });
50
+ positionFixedElements.value = [];
50
51
  }
51
52
  return { add, remove };
52
53
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../packages/composables/useScrollLockPadding/index.ts"],"sourcesContent":["import { ref } from 'vue'\nimport {\n matchClass,\n scrollbarGutterSupport,\n scrollbarWidth,\n} from '@maas/vue-equipment/utils'\n\nexport type UseScrollLockPaddingArgs = {\n exclude: RegExp\n}\n\nexport function useScrollLockPadding(args?: UseScrollLockPaddingArgs) {\n const exclude = args?.exclude || ''\n const positionFixedElements = ref<HTMLElement[]>([])\n\n function add() {\n if (typeof window === 'undefined') {\n return\n }\n\n const excludeRegEx = new RegExp(exclude)\n\n document.body.style.setProperty(\n '--scrollbar-width',\n `${scrollbarWidth()}px`\n )\n\n positionFixedElements.value = [\n ...document.body.getElementsByTagName('*'),\n ].filter(\n (x) =>\n getComputedStyle(x, null).getPropertyValue('position') === 'fixed' &&\n getComputedStyle(x, null).getPropertyValue('right') === '0px' &&\n !matchClass(x, excludeRegEx)\n ) as HTMLElement[]\n\n switch (scrollbarGutterSupport()) {\n case true:\n document.documentElement.style.scrollbarGutter = 'stable'\n positionFixedElements.value.forEach((elem) => {\n elem.style.scrollbarGutter = 'stable'\n elem.style.overflow = 'auto'\n })\n break\n case false:\n document.body.style.paddingRight = 'var(--scrollbar-width)'\n positionFixedElements.value.forEach(\n (elem) => (elem.style.paddingRight = 'var(--scrollbar-width)')\n )\n break\n }\n }\n\n function remove() {\n document.documentElement.style.scrollbarGutter = ''\n document.body.style.removeProperty('--scrollbar-width')\n document.body.style.paddingRight = ''\n positionFixedElements.value.forEach((elem) => {\n elem.style.paddingRight = ''\n elem.style.scrollbarGutter = ''\n elem.style.overflow = ''\n })\n }\n\n return { add, remove }\n}\n"],"mappings":";AAAA,SAAS,WAAW;AACpB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMA,SAAS,qBAAqB,MAAiC;AACpE,QAAM,UAAU,MAAM,WAAW;AACjC,QAAM,wBAAwB,IAAmB,CAAC,CAAC;AAEnD,WAAS,MAAM;AACb,QAAI,OAAO,WAAW,aAAa;AACjC;AAAA,IACF;AAEA,UAAM,eAAe,IAAI,OAAO,OAAO;AAEvC,aAAS,KAAK,MAAM;AAAA,MAClB;AAAA,MACA,GAAG,eAAe,CAAC;AAAA,IACrB;AAEA,0BAAsB,QAAQ;AAAA,MAC5B,GAAG,SAAS,KAAK,qBAAqB,GAAG;AAAA,IAC3C,EAAE;AAAA,MACA,CAAC,MACC,iBAAiB,GAAG,IAAI,EAAE,iBAAiB,UAAU,MAAM,WAC3D,iBAAiB,GAAG,IAAI,EAAE,iBAAiB,OAAO,MAAM,SACxD,CAAC,WAAW,GAAG,YAAY;AAAA,IAC/B;AAEA,YAAQ,uBAAuB,GAAG;AAAA,MAChC,KAAK;AACH,iBAAS,gBAAgB,MAAM,kBAAkB;AACjD,8BAAsB,MAAM,QAAQ,CAAC,SAAS;AAC5C,eAAK,MAAM,kBAAkB;AAC7B,eAAK,MAAM,WAAW;AAAA,QACxB,CAAC;AACD;AAAA,MACF,KAAK;AACH,iBAAS,KAAK,MAAM,eAAe;AACnC,8BAAsB,MAAM;AAAA,UAC1B,CAAC,SAAU,KAAK,MAAM,eAAe;AAAA,QACvC;AACA;AAAA,IACJ;AAAA,EACF;AAEA,WAAS,SAAS;AAChB,aAAS,gBAAgB,MAAM,kBAAkB;AACjD,aAAS,KAAK,MAAM,eAAe,mBAAmB;AACtD,aAAS,KAAK,MAAM,eAAe;AACnC,0BAAsB,MAAM,QAAQ,CAAC,SAAS;AAC5C,WAAK,MAAM,eAAe;AAC1B,WAAK,MAAM,kBAAkB;AAC7B,WAAK,MAAM,WAAW;AAAA,IACxB,CAAC;AAAA,EACH;AAEA,SAAO,EAAE,KAAK,OAAO;AACvB;","names":[]}
1
+ {"version":3,"sources":["../../../packages/composables/useScrollLockPadding/index.ts"],"sourcesContent":["import { ref } from 'vue'\nimport {\n matchClass,\n scrollbarGutterSupport,\n scrollbarWidth,\n} from '@maas/vue-equipment/utils'\n\nexport type UseScrollLockPaddingArgs = {\n exclude: RegExp\n}\n\nexport function useScrollLockPadding(args?: UseScrollLockPaddingArgs) {\n const exclude = args?.exclude || ''\n const positionFixedElements = ref<HTMLElement[]>([])\n\n function add() {\n if (typeof window === 'undefined') {\n return\n }\n\n const excludeRegEx = new RegExp(exclude)\n\n document.body.style.setProperty(\n '--scrollbar-width',\n `${scrollbarWidth()}px`\n )\n\n positionFixedElements.value = [\n ...document.body.getElementsByTagName('*'),\n ].filter(\n (x) =>\n getComputedStyle(x, null).getPropertyValue('position') === 'fixed' &&\n getComputedStyle(x, null).getPropertyValue('right') === '0px' &&\n !matchClass(x, excludeRegEx)\n ) as HTMLElement[]\n\n switch (scrollbarGutterSupport()) {\n case true:\n document.documentElement.style.scrollbarGutter = 'stable'\n positionFixedElements.value.forEach((elem) => {\n elem.style.scrollbarGutter = 'stable'\n elem.style.overflow = 'auto'\n })\n break\n case false:\n document.body.style.paddingRight = 'var(--scrollbar-width)'\n positionFixedElements.value.forEach(\n (elem) => (elem.style.paddingRight = 'var(--scrollbar-width)')\n )\n break\n }\n }\n\n function remove() {\n document.documentElement.style.scrollbarGutter = ''\n document.body.style.removeProperty('--scrollbar-width')\n document.body.style.paddingRight = ''\n positionFixedElements.value.forEach((elem) => {\n elem.style.paddingRight = ''\n elem.style.scrollbarGutter = ''\n elem.style.overflow = ''\n })\n\n // Drop nodes for garbage collection\n positionFixedElements.value = []\n }\n\n return { add, remove }\n}\n"],"mappings":";AAAA,SAAS,WAAW;AACpB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMA,SAAS,qBAAqB,MAAiC;AACpE,QAAM,UAAU,MAAM,WAAW;AACjC,QAAM,wBAAwB,IAAmB,CAAC,CAAC;AAEnD,WAAS,MAAM;AACb,QAAI,OAAO,WAAW,aAAa;AACjC;AAAA,IACF;AAEA,UAAM,eAAe,IAAI,OAAO,OAAO;AAEvC,aAAS,KAAK,MAAM;AAAA,MAClB;AAAA,MACA,GAAG,eAAe,CAAC;AAAA,IACrB;AAEA,0BAAsB,QAAQ;AAAA,MAC5B,GAAG,SAAS,KAAK,qBAAqB,GAAG;AAAA,IAC3C,EAAE;AAAA,MACA,CAAC,MACC,iBAAiB,GAAG,IAAI,EAAE,iBAAiB,UAAU,MAAM,WAC3D,iBAAiB,GAAG,IAAI,EAAE,iBAAiB,OAAO,MAAM,SACxD,CAAC,WAAW,GAAG,YAAY;AAAA,IAC/B;AAEA,YAAQ,uBAAuB,GAAG;AAAA,MAChC,KAAK;AACH,iBAAS,gBAAgB,MAAM,kBAAkB;AACjD,8BAAsB,MAAM,QAAQ,CAAC,SAAS;AAC5C,eAAK,MAAM,kBAAkB;AAC7B,eAAK,MAAM,WAAW;AAAA,QACxB,CAAC;AACD;AAAA,MACF,KAAK;AACH,iBAAS,KAAK,MAAM,eAAe;AACnC,8BAAsB,MAAM;AAAA,UAC1B,CAAC,SAAU,KAAK,MAAM,eAAe;AAAA,QACvC;AACA;AAAA,IACJ;AAAA,EACF;AAEA,WAAS,SAAS;AAChB,aAAS,gBAAgB,MAAM,kBAAkB;AACjD,aAAS,KAAK,MAAM,eAAe,mBAAmB;AACtD,aAAS,KAAK,MAAM,eAAe;AACnC,0BAAsB,MAAM,QAAQ,CAAC,SAAS;AAC5C,WAAK,MAAM,eAAe;AAC1B,WAAK,MAAM,kBAAkB;AAC7B,WAAK,MAAM,WAAW;AAAA,IACxB,CAAC;AAGD,0BAAsB,QAAQ,CAAC;AAAA,EACjC;AAEA,SAAO,EAAE,KAAK,OAAO;AACvB;","names":[]}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maas/vue-equipment/nuxt",
3
3
  "configKey": "vueEquipment",
4
- "version": "1.0.0-beta.42",
4
+ "version": "1.0.0-beta.44",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
@@ -130,7 +130,7 @@ const functions$1 = [
130
130
  {
131
131
  name: "useScrollLockPadding",
132
132
  "package": "composables",
133
- lastUpdated: 1763989817000,
133
+ lastUpdated: 1765919360000,
134
134
  docs: "https://maas.egineering/vue-equipment/composables/useScrollLockPadding/",
135
135
  description: "A small utility to prevent fixed elements from jumping when locking scroll"
136
136
  },
@@ -9,7 +9,7 @@
9
9
  </template>
10
10
 
11
11
  <script setup>
12
- import { onBeforeUnmount, provide } from "vue";
12
+ import { provide } from "vue";
13
13
  import { VuePrimitive } from "@maas/vue-primitive";
14
14
  import { useAccordionState } from "../composables/private/useAccordionState";
15
15
  import { MagicAccordionInstanceId } from "../symbols";
@@ -18,10 +18,7 @@ const { id, asChild, options } = defineProps({
18
18
  asChild: { type: Boolean, required: false },
19
19
  options: { type: Object, required: false }
20
20
  });
21
- const { deleteState, initializeState } = useAccordionState(id);
21
+ const { initializeState } = useAccordionState(id);
22
22
  initializeState(options);
23
- onBeforeUnmount(() => {
24
- deleteState();
25
- });
26
23
  provide(MagicAccordionInstanceId, id);
27
24
  </script>
@@ -1,7 +1,6 @@
1
- import { type Ref, type MaybeRef } from 'vue';
1
+ import { type MaybeRef } from 'vue';
2
2
  import type { AccordionState, MagicAccordionOptions } from '../../types/index.js';
3
3
  export declare function useAccordionState(instanceId: MaybeRef<string>): {
4
4
  initializeState: (options?: MagicAccordionOptions) => AccordionState;
5
- deleteState: () => void;
6
- accordionStateStore: Ref<AccordionState[], AccordionState[]>;
5
+ accordionStateStore: import("vue").Ref<AccordionState[], AccordionState[]>;
7
6
  };
@@ -1,11 +1,18 @@
1
- import { ref, reactive, toValue } from "vue";
1
+ import { reactive, toValue, onScopeDispose } from "vue";
2
2
  import { defu } from "defu";
3
+ import { createStateStore } from "@maas/vue-equipment/utils";
3
4
  import { defaultOptions } from "../../utils/defaultOptions.mjs";
4
- const accordionStateStore = ref([]);
5
+ const getAccordionStateStore = createStateStore(
6
+ "MagicAccordion",
7
+ () => []
8
+ );
5
9
  export function useAccordionState(instanceId) {
10
+ const accordionStateStore = getAccordionStateStore();
11
+ let scopeCounted = false;
6
12
  function createState(id) {
7
13
  const state = {
8
14
  id,
15
+ refCount: 0,
9
16
  options: { ...defaultOptions },
10
17
  views: []
11
18
  };
@@ -16,12 +23,23 @@ export function useAccordionState(instanceId) {
16
23
  accordionStateStore.value = [...accordionStateStore.value, state];
17
24
  return state;
18
25
  }
26
+ function deleteState() {
27
+ const currentId = toValue(instanceId);
28
+ accordionStateStore.value = accordionStateStore.value.filter(
29
+ (x) => x.id !== currentId
30
+ );
31
+ }
19
32
  function initializeState(options) {
20
- let state = accordionStateStore.value.find((entry) => {
21
- return entry.id === toValue(instanceId);
22
- });
33
+ const currentId = toValue(instanceId);
34
+ let state = accordionStateStore.value.find(
35
+ (entry) => entry.id === currentId
36
+ );
23
37
  if (!state) {
24
- state = addState(toValue(instanceId));
38
+ state = addState(currentId);
39
+ }
40
+ if (!scopeCounted) {
41
+ state.refCount++;
42
+ scopeCounted = true;
25
43
  }
26
44
  if (options) {
27
45
  const mappedOptions = defu(options, defaultOptions);
@@ -29,14 +47,23 @@ export function useAccordionState(instanceId) {
29
47
  }
30
48
  return state;
31
49
  }
32
- function deleteState() {
33
- accordionStateStore.value = accordionStateStore.value.filter(
34
- (x) => x.id !== toValue(instanceId)
50
+ onScopeDispose(() => {
51
+ if (!scopeCounted) {
52
+ return;
53
+ }
54
+ const currentId = toValue(instanceId);
55
+ const state = accordionStateStore.value.find(
56
+ (entry) => entry.id === currentId
35
57
  );
36
- }
58
+ if (state) {
59
+ state.refCount--;
60
+ if (state.refCount <= 0) {
61
+ deleteState();
62
+ }
63
+ }
64
+ });
37
65
  return {
38
66
  initializeState,
39
- deleteState,
40
67
  accordionStateStore
41
68
  };
42
69
  }
@@ -14,6 +14,7 @@ export interface AccordionView {
14
14
  }
15
15
  export interface AccordionState {
16
16
  id: string;
17
+ refCount: number;
17
18
  views: AccordionView[];
18
19
  options: MagicAccordionOptions;
19
20
  }
@@ -11,11 +11,11 @@ type __VLS_Slots = {} & {
11
11
  default?: (props: typeof __VLS_1) => any;
12
12
  };
13
13
  declare const __VLS_base: import("vue").DefineComponent<MagicCommandItemProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
14
- enter: () => any;
15
14
  click: (event: MouseEvent) => any;
15
+ enter: () => any;
16
16
  }, string, import("vue").PublicProps, Readonly<MagicCommandItemProps> & Readonly<{
17
- onEnter?: (() => any) | undefined;
18
17
  onClick?: ((event: MouseEvent) => any) | undefined;
18
+ onEnter?: (() => any) | undefined;
19
19
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
20
20
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
21
21
  declare const _default: typeof __VLS_export;
@@ -11,11 +11,11 @@ type __VLS_Slots = {} & {
11
11
  default?: (props: typeof __VLS_1) => any;
12
12
  };
13
13
  declare const __VLS_base: import("vue").DefineComponent<MagicCommandItemProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
14
- enter: () => any;
15
14
  click: (event: MouseEvent) => any;
15
+ enter: () => any;
16
16
  }, string, import("vue").PublicProps, Readonly<MagicCommandItemProps> & Readonly<{
17
- onEnter?: (() => any) | undefined;
18
17
  onClick?: ((event: MouseEvent) => any) | undefined;
18
+ onEnter?: (() => any) | undefined;
19
19
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
20
20
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
21
21
  declare const _default: typeof __VLS_export;
@@ -9,7 +9,7 @@
9
9
  </template>
10
10
 
11
11
  <script setup>
12
- import { shallowRef, provide, watch, onBeforeUnmount } from "vue";
12
+ import { shallowRef, provide, watch } from "vue";
13
13
  import { useMagicKeys, usePointer } from "@vueuse/core";
14
14
  import { VuePrimitive } from "@maas/vue-primitive";
15
15
  import { useMagicError } from "@maas/vue-equipment/plugins/MagicError";
@@ -30,7 +30,7 @@ const customDefu = createDefu((obj, key, value) => {
30
30
  }
31
31
  });
32
32
  const mappedOptions = customDefu(options, defaultOptions);
33
- const { initializeState, deleteState } = useCommandState(id);
33
+ const { initializeState } = useCommandState(id);
34
34
  const state = initializeState(mappedOptions);
35
35
  const lastX = shallowRef(0);
36
36
  const lastY = shallowRef(0);
@@ -86,9 +86,6 @@ if (mappedOptions.keyListener?.close) {
86
86
  });
87
87
  }
88
88
  }
89
- onBeforeUnmount(() => {
90
- deleteState();
91
- });
92
89
  provide(MagicCommandInstanceId, id);
93
90
  provide(MagicCommandProviderOptions, mappedOptions);
94
91
  </script>
@@ -32,6 +32,7 @@ function enterCallback(payload) {
32
32
  }
33
33
  emitter.on("enter", enterCallback);
34
34
  onBeforeUnmount(() => {
35
+ state.renderer = null;
35
36
  emitter.off("enter", enterCallback);
36
37
  });
37
38
  </script>
@@ -1,7 +1,6 @@
1
- import { type Ref, type MaybeRef } from 'vue';
1
+ import { type MaybeRef } from 'vue';
2
2
  import type { CommandState, MagicCommandOptions } from '../../types/index.js';
3
3
  export declare function useCommandState(instanceId: MaybeRef<string>): {
4
4
  initializeState: (options?: MagicCommandOptions) => CommandState;
5
- deleteState: () => void;
6
- commandStateStore: Ref<CommandState[], CommandState[]>;
5
+ commandStateStore: import("vue").Ref<CommandState[], CommandState[]>;
7
6
  };
@@ -1,12 +1,19 @@
1
- import { ref, reactive, toValue } from "vue";
1
+ import { reactive, toValue, onScopeDispose } from "vue";
2
2
  import { defu } from "defu";
3
+ import { createStateStore } from "@maas/vue-equipment/utils";
3
4
  import { defaultOptions } from "../../utils/defaultOptions.mjs";
4
- const commandStateStore = ref([]);
5
+ const getCommandStateStore = createStateStore(
6
+ "MagicCommand",
7
+ () => []
8
+ );
5
9
  export function useCommandState(instanceId) {
10
+ const commandStateStore = getCommandStateStore();
11
+ let scopeCounted = false;
6
12
  function createState(id) {
7
13
  const view = commandStateStore.value.find((state2) => state2.id === id)?.views.findLast((view2) => view2.active)?.id;
8
14
  const state = {
9
15
  id,
16
+ refCount: 0,
10
17
  options: { ...defaultOptions },
11
18
  views: [],
12
19
  renderer: null,
@@ -23,12 +30,21 @@ export function useCommandState(instanceId) {
23
30
  commandStateStore.value = [...commandStateStore.value, state];
24
31
  return state;
25
32
  }
33
+ function deleteState() {
34
+ const currentId = toValue(instanceId);
35
+ commandStateStore.value = commandStateStore.value.filter(
36
+ (x) => x.id !== currentId
37
+ );
38
+ }
26
39
  function initializeState(options) {
27
- let state = commandStateStore.value.find((entry) => {
28
- return entry.id === toValue(instanceId);
29
- });
40
+ const currentId = toValue(instanceId);
41
+ let state = commandStateStore.value.find((entry) => entry.id === currentId);
30
42
  if (!state) {
31
- state = addState(toValue(instanceId));
43
+ state = addState(currentId);
44
+ }
45
+ if (!scopeCounted) {
46
+ state.refCount++;
47
+ scopeCounted = true;
32
48
  }
33
49
  if (options) {
34
50
  const mappedOptions = defu(options, defaultOptions);
@@ -36,14 +52,23 @@ export function useCommandState(instanceId) {
36
52
  }
37
53
  return state;
38
54
  }
39
- function deleteState() {
40
- commandStateStore.value = commandStateStore.value.filter(
41
- (x) => x.id !== toValue(instanceId)
55
+ onScopeDispose(() => {
56
+ if (!scopeCounted) {
57
+ return;
58
+ }
59
+ const currentId = toValue(instanceId);
60
+ const state = commandStateStore.value.find(
61
+ (entry) => entry.id === currentId
42
62
  );
43
- }
63
+ if (state) {
64
+ state.refCount--;
65
+ if (state.refCount <= 0) {
66
+ deleteState();
67
+ }
68
+ }
69
+ });
44
70
  return {
45
71
  initializeState,
46
- deleteState,
47
72
  commandStateStore
48
73
  };
49
74
  }
@@ -44,6 +44,7 @@ export interface CommandView {
44
44
  }
45
45
  export interface CommandState {
46
46
  id: string;
47
+ refCount: number;
47
48
  active: boolean;
48
49
  views: CommandView[];
49
50
  renderer: HTMLElement | null;
@@ -1,7 +1,6 @@
1
- import { type Ref, type MaybeRef } from 'vue';
1
+ import { type MaybeRef } from 'vue';
2
2
  import type { CookieState, MagicCookieOptions } from '../../types/index.js';
3
3
  export declare function useCookieState(instanceId: MaybeRef<string>): {
4
4
  initializeState: (options?: MagicCookieOptions) => CookieState;
5
- deleteState: () => void;
6
- cookieStateStore: Ref<CookieState[], CookieState[]>;
5
+ cookieStateStore: import("vue").Ref<CookieState[], CookieState[]>;
7
6
  };
@@ -1,11 +1,18 @@
1
- import { ref, reactive, toValue } from "vue";
1
+ import { reactive, toValue, onScopeDispose } from "vue";
2
2
  import { defu } from "defu";
3
+ import { createStateStore } from "@maas/vue-equipment/utils";
3
4
  import { defaultOptions } from "../../utils/defaultOptions.mjs";
4
- const cookieStateStore = ref([]);
5
+ const getCookieStateStore = createStateStore(
6
+ "MagicCookie",
7
+ () => []
8
+ );
5
9
  export function useCookieState(instanceId) {
10
+ const cookieStateStore = getCookieStateStore();
11
+ let scopeCounted = false;
6
12
  function createState(id) {
7
13
  const state = {
8
14
  id,
15
+ refCount: 0,
9
16
  items: [],
10
17
  options: { ...defaultOptions },
11
18
  viewActive: false
@@ -17,12 +24,21 @@ export function useCookieState(instanceId) {
17
24
  cookieStateStore.value = [...cookieStateStore.value, state];
18
25
  return state;
19
26
  }
27
+ function deleteState() {
28
+ const currentId = toValue(instanceId);
29
+ cookieStateStore.value = cookieStateStore.value.filter(
30
+ (x) => x.id !== currentId
31
+ );
32
+ }
20
33
  function initializeState(options) {
21
- let state = cookieStateStore.value.find((entry) => {
22
- return entry.id === toValue(instanceId);
23
- });
34
+ const currentId = toValue(instanceId);
35
+ let state = cookieStateStore.value.find((entry) => entry.id === currentId);
24
36
  if (!state) {
25
- state = addState(toValue(instanceId));
37
+ state = addState(currentId);
38
+ }
39
+ if (!scopeCounted) {
40
+ state.refCount++;
41
+ scopeCounted = true;
26
42
  }
27
43
  if (options) {
28
44
  const mappedOptions = defu(options, defaultOptions);
@@ -30,14 +46,21 @@ export function useCookieState(instanceId) {
30
46
  }
31
47
  return state;
32
48
  }
33
- function deleteState() {
34
- cookieStateStore.value = cookieStateStore.value.filter(
35
- (x) => x.id !== toValue(instanceId)
36
- );
37
- }
49
+ onScopeDispose(() => {
50
+ if (!scopeCounted) {
51
+ return;
52
+ }
53
+ const currentId = toValue(instanceId);
54
+ const state = cookieStateStore.value.find((entry) => entry.id === currentId);
55
+ if (state) {
56
+ state.refCount--;
57
+ if (state.refCount <= 0) {
58
+ deleteState();
59
+ }
60
+ }
61
+ });
38
62
  return {
39
63
  initializeState,
40
- deleteState,
41
64
  cookieStateStore
42
65
  };
43
66
  }
@@ -1,4 +1,4 @@
1
- import { computed, nextTick } from "vue";
1
+ import { computed, nextTick, onScopeDispose } from "vue";
2
2
  import { useMagicEmitter } from "@maas/vue-equipment/plugins/MagicEmitter";
3
3
  import { useCookieState } from "./private/useCookieState.mjs";
4
4
  import { useCookieItem } from "./private/useCookieItem.mjs";
@@ -65,6 +65,11 @@ export function useMagicCookie(id) {
65
65
  function onReject(callback) {
66
66
  emitter.on("rejectAll", callback);
67
67
  }
68
+ onScopeDispose(() => {
69
+ emitter.off("acceptAll");
70
+ emitter.off("acceptSelected");
71
+ emitter.off("rejectAll");
72
+ });
68
73
  return {
69
74
  cookies,
70
75
  cookiesSet,
@@ -8,6 +8,7 @@ export interface CookieItem {
8
8
  }
9
9
  export interface CookieState {
10
10
  id: string;
11
+ refCount: number;
11
12
  options: MagicCookieOptions;
12
13
  items: CookieItem[];
13
14
  viewActive: boolean;
@@ -4,9 +4,10 @@ import {
4
4
  toValue,
5
5
  nextTick,
6
6
  watch,
7
- onBeforeUnmount,
7
+ onScopeDispose,
8
+ onMounted,
8
9
  toRefs,
9
- onMounted
10
+ markRaw
10
11
  } from "vue";
11
12
  import {
12
13
  useEventListener,
@@ -61,9 +62,12 @@ export function useDraggableDrag(args) {
61
62
  wrapperRect,
62
63
  activeSnapPoint
63
64
  } = toRefs(state);
64
- let cancelPointerup = void 0;
65
- let cancelPointermove = void 0;
66
- let cancelTouchend = void 0;
65
+ let cancelPointerup = null;
66
+ let cancelPointermove = null;
67
+ let cancelPointercancel = null;
68
+ let cancelTouchend = null;
69
+ let resizeObserverEl = null;
70
+ let resizeObserverWrapper = null;
67
71
  const momentumThresholdReached = shallowRef(false);
68
72
  const distanceThresholdReached = shallowRef(false);
69
73
  const style = computed(
@@ -97,8 +101,10 @@ export function useDraggableDrag(args) {
97
101
  const emitter = useMagicEmitter();
98
102
  const { lockScroll, unlockScroll } = useDraggableScrollLock();
99
103
  function getSizes() {
100
- elRect.value = unrefElement(elRef)?.getBoundingClientRect();
101
- wrapperRect.value = unrefElement(wrapperRef)?.getBoundingClientRect();
104
+ const el = unrefElement(elRef);
105
+ const wrapper = unrefElement(wrapperRef);
106
+ elRect.value = el ? markRaw(el.getBoundingClientRect()) : void 0;
107
+ wrapperRect.value = wrapper ? markRaw(wrapper.getBoundingClientRect()) : void 0;
102
108
  }
103
109
  function setDragged({ x, y }) {
104
110
  draggedX.value = x - originX.value;
@@ -111,6 +117,7 @@ export function useDraggableDrag(args) {
111
117
  distanceThresholdReached.value = false;
112
118
  cancelTouchend?.();
113
119
  cancelPointerup?.();
120
+ cancelPointercancel?.();
114
121
  cancelPointermove?.();
115
122
  }
116
123
  function snapToCallback(payload) {
@@ -338,13 +345,18 @@ export function useDraggableDrag(args) {
338
345
  originX.value = e.screenX - draggedX.value;
339
346
  originY.value = e.screenY - draggedY.value;
340
347
  cancelPointerup = useEventListener(document, "pointerup", onPointerup);
348
+ cancelPointercancel = useEventListener(
349
+ document,
350
+ "pointercancel",
351
+ onPointerup
352
+ );
341
353
  cancelPointermove = useEventListener(
342
354
  document,
343
355
  "pointermove",
344
356
  onPointermove,
345
357
  { passive: false }
346
358
  );
347
- cancelTouchend = isIOS() ? useEventListener(document, "touchend", onPointerup) : void 0;
359
+ cancelTouchend = isIOS() ? useEventListener(document, "touchend", onPointerup) : null;
348
360
  dragStart.value = /* @__PURE__ */ new Date();
349
361
  onPointermove(e);
350
362
  }
@@ -374,11 +386,16 @@ export function useDraggableDrag(args) {
374
386
  }
375
387
  function destroy() {
376
388
  emitter.off("snapTo", snapToCallback);
389
+ cancelPointermove?.();
390
+ cancelPointerup?.();
391
+ cancelTouchend?.();
392
+ resizeObserverEl?.stop();
393
+ resizeObserverWrapper?.stop();
377
394
  }
378
395
  onMounted(() => {
379
396
  initialize();
380
397
  });
381
- useResizeObserver(wrapperRef, async () => {
398
+ resizeObserverWrapper = useResizeObserver(wrapperRef, async () => {
382
399
  useThrottleFn(async () => {
383
400
  getSizes();
384
401
  if (activeSnapPoint.value) {
@@ -388,7 +405,7 @@ export function useDraggableDrag(args) {
388
405
  }
389
406
  }, 100)();
390
407
  });
391
- useResizeObserver(elRef, async () => {
408
+ resizeObserverEl = useResizeObserver(elRef, async () => {
392
409
  useThrottleFn(async () => {
393
410
  getSizes();
394
411
  if (activeSnapPoint.value) {
@@ -404,7 +421,7 @@ export function useDraggableDrag(args) {
404
421
  onIdle();
405
422
  }
406
423
  });
407
- onBeforeUnmount(() => {
424
+ onScopeDispose(() => {
408
425
  destroy();
409
426
  });
410
427
  return {
@@ -1,4 +1,11 @@
1
- import { ref, toRefs, computed, toValue, nextTick } from "vue";
1
+ import {
2
+ ref,
3
+ toRefs,
4
+ computed,
5
+ toValue,
6
+ nextTick,
7
+ onScopeDispose
8
+ } from "vue";
2
9
  import { computedWithControl } from "@vueuse/core";
3
10
  import { interpolate } from "@maas/vue-equipment/utils";
4
11
  import { useMagicEmitter } from "@maas/vue-equipment/plugins/MagicEmitter";
@@ -203,6 +210,9 @@ export function useDraggableSnap(args) {
203
210
  }
204
211
  activeSnapPoint.value = snapPoint;
205
212
  }
213
+ onScopeDispose(() => {
214
+ cancelInterpolation();
215
+ });
206
216
  return {
207
217
  mappedActiveSnapPoint,
208
218
  mappedSnapPoints,
@@ -2,5 +2,5 @@ import { type MaybeRef } from 'vue';
2
2
  import type { DraggableState } from '../../types/index.js';
3
3
  export declare function useDraggableState(id: MaybeRef<string>): {
4
4
  initializeState: () => DraggableState;
5
- deleteState: () => void;
5
+ draggableStateStore: import("vue").Ref<DraggableState[], DraggableState[]>;
6
6
  };
@@ -1,9 +1,16 @@
1
- import { ref, reactive, toValue } from "vue";
2
- const draggableStateStore = ref([]);
1
+ import { reactive, toValue, onScopeDispose } from "vue";
2
+ import { createStateStore } from "@maas/vue-equipment/utils";
3
+ const getDraggableStateStore = createStateStore(
4
+ "MagicDraggable",
5
+ () => []
6
+ );
3
7
  export function useDraggableState(id) {
8
+ const draggableStateStore = getDraggableStateStore();
9
+ let scopeCounted = false;
4
10
  function createState(id2) {
5
11
  const state = {
6
12
  id: id2,
13
+ refCount: 0,
7
14
  dragStart: void 0,
8
15
  dragging: false,
9
16
  interpolateTo: void 0,
@@ -26,20 +33,43 @@ export function useDraggableState(id) {
26
33
  draggableStateStore.value = [...draggableStateStore.value, state];
27
34
  return state;
28
35
  }
29
- function initializeState() {
30
- let state = draggableStateStore.value.find((entry) => {
31
- return entry.id === id;
32
- });
33
- if (!state) state = addState(toValue(id));
34
- return state;
35
- }
36
36
  function deleteState() {
37
+ const currentId = toValue(id);
37
38
  draggableStateStore.value = draggableStateStore.value.filter(
38
- (x) => x.id !== id
39
+ (x) => x.id !== currentId
40
+ );
41
+ }
42
+ function initializeState() {
43
+ const currentId = toValue(id);
44
+ let state = draggableStateStore.value.find(
45
+ (entry) => entry.id === currentId
39
46
  );
47
+ if (!state) {
48
+ state = addState(currentId);
49
+ }
50
+ if (!scopeCounted) {
51
+ state.refCount++;
52
+ scopeCounted = true;
53
+ }
54
+ return state;
40
55
  }
56
+ onScopeDispose(() => {
57
+ if (!scopeCounted) {
58
+ return;
59
+ }
60
+ const currentId = toValue(id);
61
+ const state = draggableStateStore.value.find(
62
+ (entry) => entry.id === currentId
63
+ );
64
+ if (state) {
65
+ state.refCount--;
66
+ if (state.refCount <= 0) {
67
+ deleteState();
68
+ }
69
+ }
70
+ });
41
71
  return {
42
72
  initializeState,
43
- deleteState
73
+ draggableStateStore
44
74
  };
45
75
  }
@@ -1,8 +1,9 @@
1
1
  import { toValue } from "vue";
2
2
  import { useMagicEmitter } from "@maas/vue-equipment/plugins/MagicEmitter";
3
3
  export function useMagicDraggable(id) {
4
+ const emitter = useMagicEmitter();
4
5
  function snapTo(snapPoint, duration) {
5
- useMagicEmitter().emit("snapTo", {
6
+ emitter.emit("snapTo", {
6
7
  id: toValue(id),
7
8
  snapPoint,
8
9
  duration