@maas/vue-equipment 0.28.3 → 0.29.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 (25) hide show
  1. package/dist/nuxt/module.json +1 -1
  2. package/dist/nuxt/module.mjs +1 -1
  3. package/dist/plugins/MagicDraggable/index.d.ts +2 -2
  4. package/dist/plugins/MagicDraggable/src/components/MagicDraggable.vue +2 -2
  5. package/dist/plugins/MagicDraggable/src/composables/private/useDraggableDrag.mjs +28 -2
  6. package/dist/plugins/MagicDraggable/src/composables/private/useDraggableSnap.d.ts +5 -4
  7. package/dist/plugins/MagicDraggable/src/composables/private/useDraggableSnap.mjs +11 -1
  8. package/dist/plugins/MagicDraggable/src/composables/private/useDraggableState.d.ts +1 -103
  9. package/dist/plugins/MagicDraggable/src/composables/private/useDraggableState.mjs +2 -3
  10. package/dist/plugins/MagicDraggable/src/types/index.d.ts +38 -3
  11. package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue +2 -2
  12. package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDrag.mjs +2 -2
  13. package/dist/plugins/MagicDrawer/src/composables/private/useDrawerGuards.d.ts +2 -2
  14. package/dist/plugins/MagicDrawer/src/composables/private/useDrawerProgress.mjs +2 -2
  15. package/dist/plugins/MagicDrawer/src/composables/private/useDrawerSnap.d.ts +4 -4
  16. package/dist/plugins/MagicDrawer/src/composables/private/useDrawerState.d.ts +1 -1
  17. package/dist/plugins/MagicDrawer/src/composables/private/useDrawerState.mjs +2 -2
  18. package/dist/plugins/MagicDrawer/src/composables/private/useDrawerWheel.mjs +2 -2
  19. package/dist/plugins/MagicDrawer/src/composables/useMagicDrawer.d.ts +2 -2
  20. package/dist/plugins/MagicDrawer/src/composables/useMagicDrawer.mjs +2 -2
  21. package/dist/plugins/MagicDrawer/src/types/index.d.ts +6 -6
  22. package/dist/plugins/MagicEmitter/src/composables/useMagicEmitter.d.ts +188 -164
  23. package/dist/plugins/MagicEmitter/src/types/index.d.ts +5 -3
  24. package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue +8 -4
  25. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@maas/vue-equipment/nuxt",
3
3
  "configKey": "vueEquipment",
4
- "version": "0.28.2"
4
+ "version": "0.28.4"
5
5
  }
@@ -18,7 +18,7 @@ const functions$1 = [
18
18
  {
19
19
  name: "MagicDraggable",
20
20
  "package": "plugins",
21
- lastUpdated: 1715012147000,
21
+ lastUpdated: 1716453773000,
22
22
  docs: "https://maas.egineering/vue-equipment/plugins/MagicDraggable/",
23
23
  description: "draggable"
24
24
  },
@@ -1,6 +1,6 @@
1
1
  import type { Plugin } from 'vue';
2
2
  import MagicDraggable from './src/components/MagicDraggable.vue.js';
3
- import type { DraggableOptions } from './src/types.js';
3
+ import type { DraggableOptions, DraggableEvents } from './src/types.js';
4
4
  declare const MagicDraggablePlugin: Plugin;
5
5
  export { MagicDraggablePlugin, MagicDraggable };
6
- export type { DraggableOptions };
6
+ export type { DraggableOptions, DraggableEvents };
@@ -62,8 +62,8 @@ const mappedOptions = defu(props.options, defaultOptions)
62
62
  const elRef = ref<HTMLElement | undefined>(undefined)
63
63
  const wrapperRef = ref<HTMLDivElement | undefined>(undefined)
64
64
 
65
- const { findState } = useDraggableState(props.id)
66
- const { dragging } = findState()
65
+ const { initializeState } = useDraggableState(props.id)
66
+ const { dragging } = initializeState()
67
67
 
68
68
  // Make sure this is reactive
69
69
  const disabled = computed(() => {
@@ -13,12 +13,13 @@ import {
13
13
  useIdle
14
14
  } from "@vueuse/core";
15
15
  import { isIOS, isWithinRange } from "@maas/vue-equipment/utils";
16
+ import { useMagicEmitter } from "@maas/vue-equipment/plugins";
16
17
  import { useDraggableSnap } from "./useDraggableSnap.mjs";
17
18
  import { useDraggableState } from "./useDraggableState.mjs";
18
19
  import { useDraggableScrollLock } from "./useDraggableScrollLock.mjs";
19
20
  export function useDraggableDrag(args) {
20
21
  const { id, elRef, wrapperRef, threshold, snapPoints, initial, animation } = args;
21
- const { findState } = useDraggableState(toValue(id));
22
+ const { initializeState } = useDraggableState(toValue(id));
22
23
  const {
23
24
  dragStart,
24
25
  dragging,
@@ -33,7 +34,7 @@ export function useDraggableDrag(args) {
33
34
  draggedY,
34
35
  elRect,
35
36
  wrapperRect
36
- } = findState();
37
+ } = initializeState();
37
38
  let cancelPointerup = void 0;
38
39
  let cancelPointermove = void 0;
39
40
  let cancelTouchend = void 0;
@@ -63,6 +64,7 @@ export function useDraggableDrag(args) {
63
64
  snapPointsMap,
64
65
  interpolateDragged
65
66
  } = useDraggableSnap({
67
+ id,
66
68
  elRect,
67
69
  wrapperRect,
68
70
  animation,
@@ -70,6 +72,7 @@ export function useDraggableDrag(args) {
70
72
  draggedY,
71
73
  draggedX
72
74
  });
75
+ const emitter = useMagicEmitter();
73
76
  const {
74
77
  lockScroll,
75
78
  unlockScroll,
@@ -236,6 +239,19 @@ export function useDraggableDrag(args) {
236
239
  const key = `x${interpolateTo.value.x}y${interpolateTo.value.y}`;
237
240
  activeSnapPoint.value = snapPointsMap.value[key];
238
241
  }
242
+ if (intermediateDraggedX.value === draggedX.value && intermediateDraggedY.value === draggedY.value) {
243
+ emitter.emit("dragCanceled", {
244
+ id: toValue(id),
245
+ x: draggedX.value,
246
+ y: draggedY.value
247
+ });
248
+ } else {
249
+ emitter.emit("afterDrag", {
250
+ id: toValue(id),
251
+ x: draggedX.value,
252
+ y: draggedY.value
253
+ });
254
+ }
239
255
  resetStateAndListeners();
240
256
  unlockScroll();
241
257
  removeScrollLockPadding();
@@ -260,6 +276,11 @@ export function useDraggableDrag(args) {
260
276
  if (toValue(snapPoints).length) {
261
277
  findSnapPointByVector();
262
278
  }
279
+ emitter.emit("drag", {
280
+ id: toValue(id),
281
+ x: draggedX.value,
282
+ y: draggedY.value
283
+ });
263
284
  }
264
285
  function onIdle() {
265
286
  interpolateTo.value = findClosestSnapPoint();
@@ -277,6 +298,11 @@ export function useDraggableDrag(args) {
277
298
  return;
278
299
  } else {
279
300
  dragging.value = true;
301
+ emitter.emit("beforeDrag", {
302
+ id: toValue(id),
303
+ x: draggedX.value,
304
+ y: draggedY.value
305
+ });
280
306
  }
281
307
  intermediateDraggedX.value = draggedX.value;
282
308
  intermediateDraggedY.value = draggedY.value;
@@ -1,7 +1,8 @@
1
1
  import { type MaybeRef, type Ref } from 'vue';
2
2
  import { type DefaultOptions } from '../../utils/defaultOptions.js';
3
- import type { SnapPoint, Coordinates } from '../../types.js';
3
+ import type { DraggableSnapPoint, Coordinates } from '../../types.js';
4
4
  type UseDraggableSnapArgs = {
5
+ id: MaybeRef<string>;
5
6
  elRect: Ref<DOMRect | undefined>;
6
7
  wrapperRect: Ref<DOMRect | undefined>;
7
8
  draggedY: Ref<number>;
@@ -16,7 +17,7 @@ type InterpolateDraggedArgs = {
16
17
  easing?: (t: number) => number;
17
18
  };
18
19
  type SnapToArgs = {
19
- snapPoint: SnapPoint;
20
+ snapPoint: DraggableSnapPoint;
20
21
  interpolate?: boolean;
21
22
  duration?: number;
22
23
  };
@@ -26,8 +27,8 @@ export declare function useDraggableSnap(args: UseDraggableSnapArgs): {
26
27
  x?: number | undefined;
27
28
  y?: number | undefined;
28
29
  } | undefined] | undefined>;
29
- snapPointsMap: import("@vueuse/core").ComputedRefWithControl<Record<string, SnapPoint>>;
30
- mapSnapPoint: (snapPoint: SnapPoint) => Coordinates | undefined;
30
+ snapPointsMap: import("@vueuse/core").ComputedRefWithControl<Record<string, DraggableSnapPoint>>;
31
+ mapSnapPoint: (snapPoint: DraggableSnapPoint) => Coordinates | undefined;
31
32
  interpolateDragged: (args: InterpolateDraggedArgs) => void;
32
33
  snapTo: (args: SnapToArgs) => Promise<void>;
33
34
  };
@@ -1,9 +1,10 @@
1
1
  import { ref, toValue, nextTick } from "vue";
2
2
  import { computedWithControl } from "@vueuse/core";
3
3
  import { interpolate } from "@maas/vue-equipment/utils";
4
+ import { useMagicEmitter } from "@maas/vue-equipment/plugins";
4
5
  import { defu } from "defu";
5
6
  export function useDraggableSnap(args) {
6
- const { draggedY, draggedX, elRect, wrapperRect, animation, snapPoints } = args;
7
+ const { id, draggedY, draggedX, elRect, wrapperRect, animation, snapPoints } = args;
7
8
  const activeSnapPoint = ref(void 0);
8
9
  const mappedSnapPoints = computedWithControl(
9
10
  () => toValue(wrapperRect),
@@ -28,6 +29,7 @@ export function useDraggableSnap(args) {
28
29
  return mapped;
29
30
  }
30
31
  );
32
+ const emitter = useMagicEmitter();
31
33
  function mapSnapPoint(snapPoint) {
32
34
  if (!wrapperRect.value) {
33
35
  console.warn("Wrapper rect is not defined");
@@ -95,6 +97,8 @@ export function useDraggableSnap(args) {
95
97
  duration = toValue(animation).snap?.duration,
96
98
  easing = toValue(animation).snap?.easing
97
99
  } = args2;
100
+ const snapPoint = snapPointsMap.value[`x${x}y${y}`];
101
+ emitter.emit("beforeSnap", { id: toValue(id), snapPoint });
98
102
  interpolate({
99
103
  from: draggedY.value,
100
104
  to: y,
@@ -102,6 +106,9 @@ export function useDraggableSnap(args) {
102
106
  easing,
103
107
  callback: (value) => {
104
108
  draggedY.value = value;
109
+ if (y > x && draggedY.value === y) {
110
+ emitter.emit("afterSnap", { id: toValue(id), snapPoint });
111
+ }
105
112
  }
106
113
  });
107
114
  interpolate({
@@ -111,6 +118,9 @@ export function useDraggableSnap(args) {
111
118
  easing,
112
119
  callback: (value) => {
113
120
  draggedX.value = value;
121
+ if (x >= y && draggedX.value === x) {
122
+ emitter.emit("afterSnap", { id: toValue(id), snapPoint });
123
+ }
114
124
  }
115
125
  });
116
126
  }
@@ -1,108 +1,6 @@
1
1
  import { type MaybeRef } from 'vue';
2
2
  import type { DraggableState } from '../../types/index.js';
3
3
  export declare function useDraggableState(id: MaybeRef<string>): {
4
- addState: (id: string) => {
5
- id: string;
6
- dragStart: {
7
- toString: () => string;
8
- toDateString: () => string;
9
- toTimeString: () => string;
10
- toLocaleString: {
11
- (): string;
12
- (locales?: string | string[] | undefined, options?: Intl.DateTimeFormatOptions | undefined): string;
13
- (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions | undefined): string;
14
- };
15
- toLocaleDateString: {
16
- (): string;
17
- (locales?: string | string[] | undefined, options?: Intl.DateTimeFormatOptions | undefined): string;
18
- (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions | undefined): string;
19
- };
20
- toLocaleTimeString: {
21
- (): string;
22
- (locales?: string | string[] | undefined, options?: Intl.DateTimeFormatOptions | undefined): string;
23
- (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions | undefined): string;
24
- };
25
- valueOf: () => number;
26
- getTime: () => number;
27
- getFullYear: () => number;
28
- getUTCFullYear: () => number;
29
- getMonth: () => number;
30
- getUTCMonth: () => number;
31
- getDate: () => number;
32
- getUTCDate: () => number;
33
- getDay: () => number;
34
- getUTCDay: () => number;
35
- getHours: () => number;
36
- getUTCHours: () => number;
37
- getMinutes: () => number;
38
- getUTCMinutes: () => number;
39
- getSeconds: () => number;
40
- getUTCSeconds: () => number;
41
- getMilliseconds: () => number;
42
- getUTCMilliseconds: () => number;
43
- getTimezoneOffset: () => number;
44
- setTime: (time: number) => number;
45
- setMilliseconds: (ms: number) => number;
46
- setUTCMilliseconds: (ms: number) => number;
47
- setSeconds: (sec: number, ms?: number | undefined) => number;
48
- setUTCSeconds: (sec: number, ms?: number | undefined) => number;
49
- setMinutes: (min: number, sec?: number | undefined, ms?: number | undefined) => number;
50
- setUTCMinutes: (min: number, sec?: number | undefined, ms?: number | undefined) => number;
51
- setHours: (hours: number, min?: number | undefined, sec?: number | undefined, ms?: number | undefined) => number;
52
- setUTCHours: (hours: number, min?: number | undefined, sec?: number | undefined, ms?: number | undefined) => number;
53
- setDate: (date: number) => number;
54
- setUTCDate: (date: number) => number;
55
- setMonth: (month: number, date?: number | undefined) => number;
56
- setUTCMonth: (month: number, date?: number | undefined) => number;
57
- setFullYear: (year: number, month?: number | undefined, date?: number | undefined) => number;
58
- setUTCFullYear: (year: number, month?: number | undefined, date?: number | undefined) => number;
59
- toUTCString: () => string;
60
- toISOString: () => string;
61
- toJSON: (key?: any) => string;
62
- getVarDate: () => VarDate;
63
- [Symbol.toPrimitive]: {
64
- (hint: "default"): string;
65
- (hint: "string"): string;
66
- (hint: "number"): number;
67
- (hint: string): string | number;
68
- };
69
- } | undefined;
70
- dragging: boolean;
71
- interpolateTo: {
72
- x: number;
73
- y: number;
74
- } | undefined;
75
- originX: number;
76
- originY: number;
77
- lastDraggedX: number;
78
- lastDraggedY: number;
79
- intermediateDraggedX: number;
80
- intermediateDraggedY: number;
81
- draggedX: number;
82
- draggedY: number;
83
- elRect: {
84
- height: number;
85
- width: number;
86
- x: number;
87
- y: number;
88
- readonly bottom: number;
89
- readonly left: number;
90
- readonly right: number;
91
- readonly top: number;
92
- toJSON: () => any;
93
- } | undefined;
94
- wrapperRect: {
95
- height: number;
96
- width: number;
97
- x: number;
98
- y: number;
99
- readonly bottom: number;
100
- readonly left: number;
101
- readonly right: number;
102
- readonly top: number;
103
- toJSON: () => any;
104
- } | undefined;
105
- };
106
- findState: () => import("vue").ToRefs<DraggableState>;
4
+ initializeState: () => import("vue").ToRefs<DraggableState>;
107
5
  deleteState: () => void;
108
6
  };
@@ -25,7 +25,7 @@ export function useDraggableState(id) {
25
25
  drawerStateStore.value = [...drawerStateStore.value, instance];
26
26
  return instance;
27
27
  }
28
- function findState() {
28
+ function initializeState() {
29
29
  let instance = drawerStateStore.value.find((instance2) => {
30
30
  return instance2.id === id;
31
31
  });
@@ -39,8 +39,7 @@ export function useDraggableState(id) {
39
39
  );
40
40
  }
41
41
  return {
42
- addState,
43
- findState,
42
+ initializeState,
44
43
  deleteState
45
44
  };
46
45
  }
@@ -3,7 +3,7 @@ export type Coordinates = {
3
3
  x: number;
4
4
  y: number;
5
5
  };
6
- export type SnapPoint = [
6
+ export type DraggableSnapPoint = [
7
7
  Position,
8
8
  offset?: {
9
9
  x?: number;
@@ -25,9 +25,9 @@ export interface DraggableOptions {
25
25
  };
26
26
  };
27
27
  initial?: {
28
- snapPoint?: SnapPoint;
28
+ snapPoint?: DraggableSnapPoint;
29
29
  };
30
- snapPoints?: SnapPoint[];
30
+ snapPoints?: DraggableSnapPoint[];
31
31
  disabled?: boolean;
32
32
  }
33
33
  export interface DraggableState {
@@ -46,4 +46,39 @@ export interface DraggableState {
46
46
  elRect: DOMRect | undefined;
47
47
  wrapperRect: DOMRect | undefined;
48
48
  }
49
+ export type DraggableEvents = {
50
+ beforeSnap: {
51
+ id: string;
52
+ snapPoint: DraggableSnapPoint;
53
+ };
54
+ snapTo: {
55
+ id: string;
56
+ snapPoint: DraggableSnapPoint;
57
+ duration?: number;
58
+ };
59
+ afterSnap: {
60
+ id: string;
61
+ snapPoint: DraggableSnapPoint;
62
+ };
63
+ beforeDrag: {
64
+ id: string;
65
+ x: number;
66
+ y: number;
67
+ };
68
+ drag: {
69
+ id: string;
70
+ x: number;
71
+ y: number;
72
+ };
73
+ afterDrag: {
74
+ id: string;
75
+ x: number;
76
+ y: number;
77
+ };
78
+ dragCanceled: {
79
+ id: string;
80
+ x: number;
81
+ y: number;
82
+ };
83
+ };
49
84
  export {};
@@ -192,8 +192,8 @@ const { initializeWheelListener, destroyWheelListener } = useDrawerWheel({
192
192
  disabled,
193
193
  })
194
194
 
195
- const { findState } = useDrawerState(props.id)
196
- const { dragging, wheeling } = findState()
195
+ const { initializeState } = useDrawerState(props.id)
196
+ const { dragging, wheeling } = initializeState()
197
197
 
198
198
  // Split isActive into two values to animate drawer smoothly
199
199
  const innerActive = ref(false)
@@ -35,7 +35,7 @@ export function useDrawerDrag(args) {
35
35
  disabled,
36
36
  close
37
37
  } = args;
38
- const { findState } = useDrawerState(toValue(id));
38
+ const { initializeState } = useDrawerState(toValue(id));
39
39
  const {
40
40
  dragStart,
41
41
  dragging,
@@ -54,7 +54,7 @@ export function useDrawerDrag(args) {
54
54
  absDirectionY,
55
55
  elRect,
56
56
  wrapperRect
57
- } = findState();
57
+ } = initializeState();
58
58
  let cancelPointerup = void 0;
59
59
  let cancelPointermove = void 0;
60
60
  let cancelTouchend = void 0;
@@ -1,12 +1,12 @@
1
1
  import { type Ref, type MaybeRef } from 'vue';
2
2
  import { type DefaultOptions } from '../../utils/defaultOptions.js';
3
- import { type SnapPoint } from '../../types.js';
3
+ import { type DrawerSnapPoint } from '../../types.js';
4
4
  interface UseDrawerGuardsArgs {
5
5
  elRef: Ref<HTMLElement | undefined>;
6
6
  absDirectionX: MaybeRef<'with' | 'against' | undefined>;
7
7
  absDirectionY: MaybeRef<'with' | 'against' | undefined>;
8
8
  position: MaybeRef<DefaultOptions['position']>;
9
- activeSnapPoint: MaybeRef<SnapPoint | undefined>;
9
+ activeSnapPoint: MaybeRef<DrawerSnapPoint | undefined>;
10
10
  }
11
11
  export declare function useDrawerGuards(args: UseDrawerGuardsArgs): {
12
12
  canDrag: (el: EventTarget) => boolean;
@@ -12,7 +12,7 @@ import { useMagicEmitter } from "@maas/vue-equipment/plugins";
12
12
  import { useDrawerState } from "./useDrawerState.mjs";
13
13
  export function useDrawerProgress(args) {
14
14
  const { id, drawerRef, elRef, position, overshoot } = args;
15
- const { findState } = useDrawerState(id);
15
+ const { initializeState } = useDrawerState(id);
16
16
  const drawerRect = useElementBounding(drawerRef);
17
17
  const elRect = useElementBounding(elRef);
18
18
  const maxX = computed(
@@ -21,7 +21,7 @@ export function useDrawerProgress(args) {
21
21
  const maxY = computed(
22
22
  () => drawerRect.height.value - elRect.height.value + toValue(overshoot)
23
23
  );
24
- const { progress } = findState();
24
+ const { progress } = initializeState();
25
25
  function rafCallback() {
26
26
  drawerRect.update();
27
27
  elRect.update();
@@ -1,6 +1,6 @@
1
1
  import { type MaybeRef, type Ref } from 'vue';
2
2
  import { type DefaultOptions } from '../../utils/defaultOptions.js';
3
- import { type SnapPoint } from '../../types.js';
3
+ import { type DrawerSnapPoint } from '../../types.js';
4
4
  type UseDrawerSnapArgs = {
5
5
  id: MaybeRef<string>;
6
6
  wrapperRect: Ref<DOMRect | undefined>;
@@ -18,7 +18,7 @@ type FindClosestSnapPointArgs = {
18
18
  direction?: 'below' | 'above' | 'absolute';
19
19
  };
20
20
  type SnapToArgs = {
21
- snapPoint: SnapPoint;
21
+ snapPoint: DrawerSnapPoint;
22
22
  interpolate: boolean;
23
23
  duration?: number;
24
24
  };
@@ -30,11 +30,11 @@ type InterpolateDraggedArgs = {
30
30
  export declare function useDrawerSnap(args: UseDrawerSnapArgs): {
31
31
  snappedY: Ref<number>;
32
32
  snappedX: Ref<number>;
33
- activeSnapPoint: Ref<SnapPoint | undefined>;
33
+ activeSnapPoint: Ref<DrawerSnapPoint | undefined>;
34
34
  snapTo: (args: SnapToArgs) => Promise<void>;
35
35
  findClosestSnapPoint: (args: FindClosestSnapPointArgs) => number | undefined;
36
36
  interpolateDragged: (args: InterpolateDraggedArgs) => void;
37
- snapPointsMap: import("@vueuse/core").ComputedRefWithControl<Record<number, SnapPoint>>;
37
+ snapPointsMap: import("@vueuse/core").ComputedRefWithControl<Record<number, DrawerSnapPoint>>;
38
38
  drawerHeight: import("vue").ComputedRef<number>;
39
39
  drawerWidth: import("vue").ComputedRef<number>;
40
40
  };
@@ -108,6 +108,6 @@ export declare function useDrawerState(id: MaybeRef<string>): {
108
108
  toJSON: () => any;
109
109
  } | undefined;
110
110
  };
111
- findState: () => import("vue").ToRefs<DrawerState>;
111
+ initializeState: () => import("vue").ToRefs<DrawerState>;
112
112
  deleteState: () => void;
113
113
  };
@@ -33,7 +33,7 @@ export function useDrawerState(id) {
33
33
  drawerStateStore.value = [...drawerStateStore.value, instance];
34
34
  return instance;
35
35
  }
36
- function findState() {
36
+ function initializeState() {
37
37
  let instance = drawerStateStore.value.find((instance2) => {
38
38
  return instance2.id === id;
39
39
  });
@@ -48,7 +48,7 @@ export function useDrawerState(id) {
48
48
  }
49
49
  return {
50
50
  addState,
51
- findState,
51
+ initializeState,
52
52
  deleteState
53
53
  };
54
54
  }
@@ -7,8 +7,8 @@ import WheelGestures from "wheel-gestures";
7
7
  import { useDrawerState } from "./useDrawerState.mjs";
8
8
  export function useDrawerWheel(args) {
9
9
  const { id, elRef, position, disabled } = args;
10
- const { findState } = useDrawerState(toValue(id));
11
- const { dragging, wheeling } = findState();
10
+ const { initializeState } = useDrawerState(toValue(id));
11
+ const { dragging, wheeling } = initializeState();
12
12
  let startEvent;
13
13
  const axis = computed(() => {
14
14
  switch (toValue(position)) {
@@ -1,5 +1,5 @@
1
1
  import { type MaybeRef } from 'vue';
2
- import type { SnapPoint } from '../types/index.js';
2
+ import type { DrawerSnapPoint } from '../types/index.js';
3
3
  export declare function useMagicDrawer(id: MaybeRef<string>): {
4
4
  isActive: import("vue").ComputedRef<boolean>;
5
5
  progress: import("vue").Ref<{
@@ -8,6 +8,6 @@ export declare function useMagicDrawer(id: MaybeRef<string>): {
8
8
  }>;
9
9
  open: () => void;
10
10
  close: () => void;
11
- snapTo: (snapPoint: SnapPoint, duration?: number) => void;
11
+ snapTo: (snapPoint: DrawerSnapPoint, duration?: number) => void;
12
12
  };
13
13
  export type UseMagicDrawerReturn = ReturnType<typeof useMagicDrawer>;
@@ -4,8 +4,8 @@ import { useDrawerStore } from "./private/useDrawerStore.mjs";
4
4
  import { useDrawerState } from "./private/useDrawerState.mjs";
5
5
  export function useMagicDrawer(id) {
6
6
  const { drawerStore, addInstance, removeInstance } = useDrawerStore();
7
- const { deleteState, findState } = useDrawerState(toValue(id));
8
- const { progress } = findState();
7
+ const { deleteState, initializeState } = useDrawerState(toValue(id));
8
+ const { progress } = initializeState();
9
9
  const isActive = computed(() => drawerStore.value.includes(toValue(id)));
10
10
  function open() {
11
11
  addInstance(toValue(id));
@@ -1,5 +1,5 @@
1
1
  import { type Options } from 'focus-trap';
2
- export type SnapPoint = number | `${string}px`;
2
+ export type DrawerSnapPoint = number | `${string}px`;
3
3
  export interface DrawerOptions {
4
4
  position?: 'top' | 'right' | 'bottom' | 'left';
5
5
  backdrop?: boolean;
@@ -8,7 +8,7 @@ export interface DrawerOptions {
8
8
  scrollLock?: boolean | {
9
9
  padding: boolean;
10
10
  };
11
- snapPoints?: SnapPoint[];
11
+ snapPoints?: DrawerSnapPoint[];
12
12
  teleport?: {
13
13
  target?: string;
14
14
  disabled?: boolean;
@@ -31,7 +31,7 @@ export interface DrawerOptions {
31
31
  initial?: {
32
32
  open?: boolean;
33
33
  transition?: boolean;
34
- snapPoint?: SnapPoint;
34
+ snapPoint?: DrawerSnapPoint;
35
35
  };
36
36
  keyListener?: {
37
37
  close?: string[] | false;
@@ -74,16 +74,16 @@ export type DrawerEvents = {
74
74
  afterLeave: string;
75
75
  beforeSnap: {
76
76
  id: string;
77
- snapPoint: SnapPoint;
77
+ snapPoint: DrawerSnapPoint;
78
78
  };
79
79
  snapTo: {
80
80
  id: string;
81
- snapPoint: SnapPoint;
81
+ snapPoint: DrawerSnapPoint;
82
82
  duration?: number;
83
83
  };
84
84
  afterSnap: {
85
85
  id: string;
86
- snapPoint: SnapPoint;
86
+ snapPoint: DrawerSnapPoint;
87
87
  };
88
88
  beforeDrag: {
89
89
  id: string;
@@ -1,78 +1,82 @@
1
1
  export declare function useMagicEmitter(): {
2
2
  on: {
3
- <Key extends "progress" | "snapTo" | "accept" | "acceptSelected" | "reject" | "collision" | "beforeEnter" | "enter" | "afterEnter" | "beforeLeave" | "leave" | "afterLeave" | "beforeSnap" | "afterSnap" | "beforeDrag" | "drag" | "afterDrag">(type: Key, handler: import("mitt").Handler<({
3
+ <Key extends "progress" | "snapTo" | "collision" | "beforeSnap" | "afterSnap" | "beforeDrag" | "drag" | "afterDrag" | "dragCanceled" | keyof import("../../..").CookieEvents | keyof import("../../..").CommandEvents>(type: Key, handler: import("mitt").Handler<{
4
4
  collision: {
5
5
  dir: "up" | "down";
6
6
  pos: "top" | "bottom";
7
7
  el: HTMLElement;
8
8
  data?: Record<string, unknown> | undefined;
9
9
  };
10
- } & {
11
10
  beforeEnter: string;
12
11
  enter: string;
13
12
  afterEnter: string;
14
13
  beforeLeave: string;
15
14
  leave: string;
16
15
  afterLeave: string;
17
- } & {
18
16
  accept: import("../../../MagicCookie/src/types").CookieConsent;
19
17
  reject: import("../../../MagicCookie/src/types").CookieConsent;
20
18
  acceptSelected: import("../../../MagicCookie/src/types").CookieConsent;
21
- } & {
22
- beforeEnter: string;
23
- enter: string;
24
- afterEnter: string;
25
- beforeLeave: string;
26
- leave: string;
27
- afterLeave: string;
28
19
  beforeSnap: {
29
20
  id: string;
30
- snapPoint: import("../../../MagicDrawer/src/types").SnapPoint;
21
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
22
+ } | {
23
+ id: string;
24
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
31
25
  };
32
26
  snapTo: {
33
27
  id: string;
34
- snapPoint: import("../../../MagicDrawer/src/types").SnapPoint;
28
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
29
+ duration?: number | undefined;
30
+ } | {
31
+ id: string;
32
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
35
33
  duration?: number | undefined;
36
34
  };
37
35
  afterSnap: {
38
36
  id: string;
39
- snapPoint: import("../../../MagicDrawer/src/types").SnapPoint;
37
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
38
+ } | {
39
+ id: string;
40
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
40
41
  };
41
42
  beforeDrag: {
42
43
  id: string;
43
44
  x: number;
44
45
  y: number;
46
+ } | {
47
+ id: string;
48
+ x: number;
49
+ y: number;
45
50
  };
46
51
  drag: {
47
52
  id: string;
48
53
  x: number;
49
54
  y: number;
55
+ } | {
56
+ id: string;
57
+ x: number;
58
+ y: number;
50
59
  };
51
60
  afterDrag: {
52
61
  id: string;
53
62
  x: number;
54
63
  y: number;
64
+ } | {
65
+ id: string;
66
+ x: number;
67
+ y: number;
68
+ };
69
+ dragCanceled: {
70
+ id: string;
71
+ x: number;
72
+ y: number;
55
73
  };
56
74
  progress: {
57
75
  id: string;
58
76
  x: number;
59
77
  y: number;
60
78
  };
61
- } & {
62
- beforeEnter: string;
63
- enter: string;
64
- afterEnter: string;
65
- beforeLeave: string;
66
- leave: string;
67
- afterLeave: string;
68
- } & {
69
- beforeEnter: string;
70
- enter: string;
71
- afterEnter: string;
72
- beforeLeave: string;
73
- leave: string;
74
- afterLeave: string;
75
- })[Key]>): void;
79
+ }[Key]>): void;
76
80
  (type: "*", handler: import("mitt").WildcardHandler<{
77
81
  collision: {
78
82
  dir: "up" | "down";
@@ -80,147 +84,155 @@ export declare function useMagicEmitter(): {
80
84
  el: HTMLElement;
81
85
  data?: Record<string, unknown> | undefined;
82
86
  };
83
- } & {
84
87
  beforeEnter: string;
85
88
  enter: string;
86
89
  afterEnter: string;
87
90
  beforeLeave: string;
88
91
  leave: string;
89
92
  afterLeave: string;
90
- } & {
91
93
  accept: import("../../../MagicCookie/src/types").CookieConsent;
92
94
  reject: import("../../../MagicCookie/src/types").CookieConsent;
93
95
  acceptSelected: import("../../../MagicCookie/src/types").CookieConsent;
94
- } & {
95
- beforeEnter: string;
96
- enter: string;
97
- afterEnter: string;
98
- beforeLeave: string;
99
- leave: string;
100
- afterLeave: string;
101
96
  beforeSnap: {
102
97
  id: string;
103
- snapPoint: import("../../../MagicDrawer/src/types").SnapPoint;
98
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
99
+ } | {
100
+ id: string;
101
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
104
102
  };
105
103
  snapTo: {
106
104
  id: string;
107
- snapPoint: import("../../../MagicDrawer/src/types").SnapPoint;
105
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
106
+ duration?: number | undefined;
107
+ } | {
108
+ id: string;
109
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
108
110
  duration?: number | undefined;
109
111
  };
110
112
  afterSnap: {
111
113
  id: string;
112
- snapPoint: import("../../../MagicDrawer/src/types").SnapPoint;
114
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
115
+ } | {
116
+ id: string;
117
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
113
118
  };
114
119
  beforeDrag: {
115
120
  id: string;
116
121
  x: number;
117
122
  y: number;
123
+ } | {
124
+ id: string;
125
+ x: number;
126
+ y: number;
118
127
  };
119
128
  drag: {
120
129
  id: string;
121
130
  x: number;
122
131
  y: number;
132
+ } | {
133
+ id: string;
134
+ x: number;
135
+ y: number;
123
136
  };
124
137
  afterDrag: {
125
138
  id: string;
126
139
  x: number;
127
140
  y: number;
141
+ } | {
142
+ id: string;
143
+ x: number;
144
+ y: number;
145
+ };
146
+ dragCanceled: {
147
+ id: string;
148
+ x: number;
149
+ y: number;
128
150
  };
129
151
  progress: {
130
152
  id: string;
131
153
  x: number;
132
154
  y: number;
133
155
  };
134
- } & {
135
- beforeEnter: string;
136
- enter: string;
137
- afterEnter: string;
138
- beforeLeave: string;
139
- leave: string;
140
- afterLeave: string;
141
- } & {
142
- beforeEnter: string;
143
- enter: string;
144
- afterEnter: string;
145
- beforeLeave: string;
146
- leave: string;
147
- afterLeave: string;
148
156
  }>): void;
149
157
  };
150
158
  off: {
151
- <Key_1 extends "progress" | "snapTo" | "accept" | "acceptSelected" | "reject" | "collision" | "beforeEnter" | "enter" | "afterEnter" | "beforeLeave" | "leave" | "afterLeave" | "beforeSnap" | "afterSnap" | "beforeDrag" | "drag" | "afterDrag">(type: Key_1, handler?: import("mitt").Handler<({
159
+ <Key_1 extends "progress" | "snapTo" | "collision" | "beforeSnap" | "afterSnap" | "beforeDrag" | "drag" | "afterDrag" | "dragCanceled" | keyof import("../../..").CookieEvents | keyof import("../../..").CommandEvents>(type: Key_1, handler?: import("mitt").Handler<{
152
160
  collision: {
153
161
  dir: "up" | "down";
154
162
  pos: "top" | "bottom";
155
163
  el: HTMLElement;
156
164
  data?: Record<string, unknown> | undefined;
157
165
  };
158
- } & {
159
166
  beforeEnter: string;
160
167
  enter: string;
161
168
  afterEnter: string;
162
169
  beforeLeave: string;
163
170
  leave: string;
164
171
  afterLeave: string;
165
- } & {
166
172
  accept: import("../../../MagicCookie/src/types").CookieConsent;
167
173
  reject: import("../../../MagicCookie/src/types").CookieConsent;
168
174
  acceptSelected: import("../../../MagicCookie/src/types").CookieConsent;
169
- } & {
170
- beforeEnter: string;
171
- enter: string;
172
- afterEnter: string;
173
- beforeLeave: string;
174
- leave: string;
175
- afterLeave: string;
176
175
  beforeSnap: {
177
176
  id: string;
178
- snapPoint: import("../../../MagicDrawer/src/types").SnapPoint;
177
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
178
+ } | {
179
+ id: string;
180
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
179
181
  };
180
182
  snapTo: {
181
183
  id: string;
182
- snapPoint: import("../../../MagicDrawer/src/types").SnapPoint;
184
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
185
+ duration?: number | undefined;
186
+ } | {
187
+ id: string;
188
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
183
189
  duration?: number | undefined;
184
190
  };
185
191
  afterSnap: {
186
192
  id: string;
187
- snapPoint: import("../../../MagicDrawer/src/types").SnapPoint;
193
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
194
+ } | {
195
+ id: string;
196
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
188
197
  };
189
198
  beforeDrag: {
190
199
  id: string;
191
200
  x: number;
192
201
  y: number;
202
+ } | {
203
+ id: string;
204
+ x: number;
205
+ y: number;
193
206
  };
194
207
  drag: {
195
208
  id: string;
196
209
  x: number;
197
210
  y: number;
211
+ } | {
212
+ id: string;
213
+ x: number;
214
+ y: number;
198
215
  };
199
216
  afterDrag: {
200
217
  id: string;
201
218
  x: number;
202
219
  y: number;
220
+ } | {
221
+ id: string;
222
+ x: number;
223
+ y: number;
224
+ };
225
+ dragCanceled: {
226
+ id: string;
227
+ x: number;
228
+ y: number;
203
229
  };
204
230
  progress: {
205
231
  id: string;
206
232
  x: number;
207
233
  y: number;
208
234
  };
209
- } & {
210
- beforeEnter: string;
211
- enter: string;
212
- afterEnter: string;
213
- beforeLeave: string;
214
- leave: string;
215
- afterLeave: string;
216
- } & {
217
- beforeEnter: string;
218
- enter: string;
219
- afterEnter: string;
220
- beforeLeave: string;
221
- leave: string;
222
- afterLeave: string;
223
- })[Key_1]> | undefined): void;
235
+ }[Key_1]> | undefined): void;
224
236
  (type: "*", handler: import("mitt").WildcardHandler<{
225
237
  collision: {
226
238
  dir: "up" | "down";
@@ -228,219 +240,231 @@ export declare function useMagicEmitter(): {
228
240
  el: HTMLElement;
229
241
  data?: Record<string, unknown> | undefined;
230
242
  };
231
- } & {
232
243
  beforeEnter: string;
233
244
  enter: string;
234
245
  afterEnter: string;
235
246
  beforeLeave: string;
236
247
  leave: string;
237
248
  afterLeave: string;
238
- } & {
239
249
  accept: import("../../../MagicCookie/src/types").CookieConsent;
240
250
  reject: import("../../../MagicCookie/src/types").CookieConsent;
241
251
  acceptSelected: import("../../../MagicCookie/src/types").CookieConsent;
242
- } & {
243
- beforeEnter: string;
244
- enter: string;
245
- afterEnter: string;
246
- beforeLeave: string;
247
- leave: string;
248
- afterLeave: string;
249
252
  beforeSnap: {
250
253
  id: string;
251
- snapPoint: import("../../../MagicDrawer/src/types").SnapPoint;
254
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
255
+ } | {
256
+ id: string;
257
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
252
258
  };
253
259
  snapTo: {
254
260
  id: string;
255
- snapPoint: import("../../../MagicDrawer/src/types").SnapPoint;
261
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
262
+ duration?: number | undefined;
263
+ } | {
264
+ id: string;
265
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
256
266
  duration?: number | undefined;
257
267
  };
258
268
  afterSnap: {
259
269
  id: string;
260
- snapPoint: import("../../../MagicDrawer/src/types").SnapPoint;
270
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
271
+ } | {
272
+ id: string;
273
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
261
274
  };
262
275
  beforeDrag: {
263
276
  id: string;
264
277
  x: number;
265
278
  y: number;
279
+ } | {
280
+ id: string;
281
+ x: number;
282
+ y: number;
266
283
  };
267
284
  drag: {
268
285
  id: string;
269
286
  x: number;
270
287
  y: number;
288
+ } | {
289
+ id: string;
290
+ x: number;
291
+ y: number;
271
292
  };
272
293
  afterDrag: {
273
294
  id: string;
274
295
  x: number;
275
296
  y: number;
297
+ } | {
298
+ id: string;
299
+ x: number;
300
+ y: number;
301
+ };
302
+ dragCanceled: {
303
+ id: string;
304
+ x: number;
305
+ y: number;
276
306
  };
277
307
  progress: {
278
308
  id: string;
279
309
  x: number;
280
310
  y: number;
281
311
  };
282
- } & {
283
- beforeEnter: string;
284
- enter: string;
285
- afterEnter: string;
286
- beforeLeave: string;
287
- leave: string;
288
- afterLeave: string;
289
- } & {
290
- beforeEnter: string;
291
- enter: string;
292
- afterEnter: string;
293
- beforeLeave: string;
294
- leave: string;
295
- afterLeave: string;
296
312
  }>): void;
297
313
  };
298
314
  emit: {
299
- <Key_2 extends "progress" | "snapTo" | "accept" | "acceptSelected" | "reject" | "collision" | "beforeEnter" | "enter" | "afterEnter" | "beforeLeave" | "leave" | "afterLeave" | "beforeSnap" | "afterSnap" | "beforeDrag" | "drag" | "afterDrag">(type: Key_2, event: ({
315
+ <Key_2 extends "progress" | "snapTo" | "collision" | "beforeSnap" | "afterSnap" | "beforeDrag" | "drag" | "afterDrag" | "dragCanceled" | keyof import("../../..").CookieEvents | keyof import("../../..").CommandEvents>(type: Key_2, event: {
300
316
  collision: {
301
317
  dir: "up" | "down";
302
318
  pos: "top" | "bottom";
303
319
  el: HTMLElement;
304
320
  data?: Record<string, unknown> | undefined;
305
321
  };
306
- } & {
307
322
  beforeEnter: string;
308
323
  enter: string;
309
324
  afterEnter: string;
310
325
  beforeLeave: string;
311
326
  leave: string;
312
327
  afterLeave: string;
313
- } & {
314
328
  accept: import("../../../MagicCookie/src/types").CookieConsent;
315
329
  reject: import("../../../MagicCookie/src/types").CookieConsent;
316
330
  acceptSelected: import("../../../MagicCookie/src/types").CookieConsent;
317
- } & {
318
- beforeEnter: string;
319
- enter: string;
320
- afterEnter: string;
321
- beforeLeave: string;
322
- leave: string;
323
- afterLeave: string;
324
331
  beforeSnap: {
325
332
  id: string;
326
- snapPoint: import("../../../MagicDrawer/src/types").SnapPoint;
333
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
334
+ } | {
335
+ id: string;
336
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
327
337
  };
328
338
  snapTo: {
329
339
  id: string;
330
- snapPoint: import("../../../MagicDrawer/src/types").SnapPoint;
340
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
341
+ duration?: number | undefined;
342
+ } | {
343
+ id: string;
344
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
331
345
  duration?: number | undefined;
332
346
  };
333
347
  afterSnap: {
334
348
  id: string;
335
- snapPoint: import("../../../MagicDrawer/src/types").SnapPoint;
349
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
350
+ } | {
351
+ id: string;
352
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
336
353
  };
337
354
  beforeDrag: {
338
355
  id: string;
339
356
  x: number;
340
357
  y: number;
358
+ } | {
359
+ id: string;
360
+ x: number;
361
+ y: number;
341
362
  };
342
363
  drag: {
343
364
  id: string;
344
365
  x: number;
345
366
  y: number;
367
+ } | {
368
+ id: string;
369
+ x: number;
370
+ y: number;
346
371
  };
347
372
  afterDrag: {
348
373
  id: string;
349
374
  x: number;
350
375
  y: number;
376
+ } | {
377
+ id: string;
378
+ x: number;
379
+ y: number;
380
+ };
381
+ dragCanceled: {
382
+ id: string;
383
+ x: number;
384
+ y: number;
351
385
  };
352
386
  progress: {
353
387
  id: string;
354
388
  x: number;
355
389
  y: number;
356
390
  };
357
- } & {
358
- beforeEnter: string;
359
- enter: string;
360
- afterEnter: string;
361
- beforeLeave: string;
362
- leave: string;
363
- afterLeave: string;
364
- } & {
365
- beforeEnter: string;
366
- enter: string;
367
- afterEnter: string;
368
- beforeLeave: string;
369
- leave: string;
370
- afterLeave: string;
371
- })[Key_2]): void;
372
- <Key_3 extends "progress" | "snapTo" | "accept" | "acceptSelected" | "reject" | "collision" | "beforeEnter" | "enter" | "afterEnter" | "beforeLeave" | "leave" | "afterLeave" | "beforeSnap" | "afterSnap" | "beforeDrag" | "drag" | "afterDrag">(type: undefined extends ({
391
+ }[Key_2]): void;
392
+ <Key_3 extends "progress" | "snapTo" | "collision" | "beforeSnap" | "afterSnap" | "beforeDrag" | "drag" | "afterDrag" | "dragCanceled" | keyof import("../../..").CookieEvents | keyof import("../../..").CommandEvents>(type: undefined extends {
373
393
  collision: {
374
394
  dir: "up" | "down";
375
395
  pos: "top" | "bottom";
376
396
  el: HTMLElement;
377
397
  data?: Record<string, unknown> | undefined;
378
398
  };
379
- } & {
380
399
  beforeEnter: string;
381
400
  enter: string;
382
401
  afterEnter: string;
383
402
  beforeLeave: string;
384
403
  leave: string;
385
404
  afterLeave: string;
386
- } & {
387
405
  accept: import("../../../MagicCookie/src/types").CookieConsent;
388
406
  reject: import("../../../MagicCookie/src/types").CookieConsent;
389
407
  acceptSelected: import("../../../MagicCookie/src/types").CookieConsent;
390
- } & {
391
- beforeEnter: string;
392
- enter: string;
393
- afterEnter: string;
394
- beforeLeave: string;
395
- leave: string;
396
- afterLeave: string;
397
408
  beforeSnap: {
398
409
  id: string;
399
- snapPoint: import("../../../MagicDrawer/src/types").SnapPoint;
410
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
411
+ } | {
412
+ id: string;
413
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
400
414
  };
401
415
  snapTo: {
402
416
  id: string;
403
- snapPoint: import("../../../MagicDrawer/src/types").SnapPoint;
417
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
418
+ duration?: number | undefined;
419
+ } | {
420
+ id: string;
421
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
404
422
  duration?: number | undefined;
405
423
  };
406
424
  afterSnap: {
407
425
  id: string;
408
- snapPoint: import("../../../MagicDrawer/src/types").SnapPoint;
426
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
427
+ } | {
428
+ id: string;
429
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
409
430
  };
410
431
  beforeDrag: {
411
432
  id: string;
412
433
  x: number;
413
434
  y: number;
435
+ } | {
436
+ id: string;
437
+ x: number;
438
+ y: number;
414
439
  };
415
440
  drag: {
416
441
  id: string;
417
442
  x: number;
418
443
  y: number;
444
+ } | {
445
+ id: string;
446
+ x: number;
447
+ y: number;
419
448
  };
420
449
  afterDrag: {
421
450
  id: string;
422
451
  x: number;
423
452
  y: number;
453
+ } | {
454
+ id: string;
455
+ x: number;
456
+ y: number;
457
+ };
458
+ dragCanceled: {
459
+ id: string;
460
+ x: number;
461
+ y: number;
424
462
  };
425
463
  progress: {
426
464
  id: string;
427
465
  x: number;
428
466
  y: number;
429
467
  };
430
- } & {
431
- beforeEnter: string;
432
- enter: string;
433
- afterEnter: string;
434
- beforeLeave: string;
435
- leave: string;
436
- afterLeave: string;
437
- } & {
438
- beforeEnter: string;
439
- enter: string;
440
- afterEnter: string;
441
- beforeLeave: string;
442
- leave: string;
443
- afterLeave: string;
444
- })[Key_3] ? Key_3 : never): void;
468
+ }[Key_3] ? Key_3 : never): void;
445
469
  };
446
470
  };
@@ -1,17 +1,19 @@
1
1
  import type { CollisionEvents } from '../../../MagicScroll.js';
2
2
  import type { CommandEvents } from '../../../MagicCommand.js';
3
3
  import type { CookieEvents } from '../../../MagicCookie.js';
4
+ import type { DraggableEvents } from '../../../MagicDraggable.js';
4
5
  import type { DrawerEvents } from '../../../MagicDrawer.js';
5
6
  import type { ModalEvents } from '../../../MagicModal.js';
6
7
  import type { ToastEvents } from '../../../MagicToast.js';
7
- type Merge<T extends any[]> = T extends [infer First, ...infer Rest] ? MergeTypes<First, Merge<Rest>> : {};
8
8
  type MergeTypes<T, U> = {
9
- [K in keyof T]: K extends keyof U ? U[K] : T[K];
10
- } & U;
9
+ [K in keyof (T & U)]: K extends keyof T ? K extends keyof U ? T[K] | U[K] : T[K] : K extends keyof U ? U[K] : never;
10
+ };
11
+ type Merge<T extends any[]> = T extends [infer First, ...infer Rest] ? MergeTypes<First, Merge<Rest>> : {};
11
12
  export type MagicEmitterEvents = Merge<[
12
13
  CollisionEvents,
13
14
  CommandEvents,
14
15
  CookieEvents,
16
+ DraggableEvents,
15
17
  DrawerEvents,
16
18
  ModalEvents,
17
19
  ToastEvents
@@ -47,10 +47,6 @@ async function calculate() {
47
47
  progress.value = getProgress()
48
48
  }
49
49
 
50
- onMounted(() => {
51
- calculate()
52
- })
53
-
54
50
  watch(
55
51
  () => scrollReturn?.y.value,
56
52
  () => {
@@ -60,6 +56,14 @@ watch(
60
56
  }
61
57
  )
62
58
 
59
+ watch(
60
+ () => scrollReturn?.y.value,
61
+ () => {
62
+ calculate()
63
+ },
64
+ { once: true }
65
+ )
66
+
63
67
  useIntersectionObserver(
64
68
  elRef,
65
69
  ([{ isIntersecting }]) => {
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.28.3",
4
+ "version": "0.29.0",
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",