@maas/vue-equipment 1.2.0 → 1.4.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 (74) hide show
  1. package/dist/nuxt/module.json +1 -1
  2. package/dist/nuxt/module.mjs +3 -2
  3. package/dist/plugins/MagicDotMatrix/index.d.ts +14 -0
  4. package/dist/plugins/MagicDotMatrix/index.mjs +20 -0
  5. package/dist/plugins/MagicDotMatrix/nuxt.d.ts +0 -0
  6. package/dist/plugins/MagicDotMatrix/nuxt.mjs +29 -0
  7. package/dist/plugins/MagicDotMatrix/src/components/MagicDotMatrix.d.vue.ts +10 -0
  8. package/dist/plugins/MagicDotMatrix/src/components/MagicDotMatrix.vue +103 -0
  9. package/dist/plugins/MagicDotMatrix/src/components/MagicDotMatrix.vue.d.ts +10 -0
  10. package/dist/plugins/MagicDotMatrix/src/composables/private/useDotMatrixApi.d.ts +10 -0
  11. package/dist/plugins/MagicDotMatrix/src/composables/private/useDotMatrixApi.mjs +82 -0
  12. package/dist/plugins/MagicDotMatrix/src/composables/private/useDotMatrixState.d.ts +6 -0
  13. package/dist/plugins/MagicDotMatrix/src/composables/private/useDotMatrixState.mjs +71 -0
  14. package/dist/plugins/MagicDotMatrix/src/composables/useMagicDotMatrix.d.ts +10 -0
  15. package/dist/plugins/MagicDotMatrix/src/composables/useMagicDotMatrix.mjs +27 -0
  16. package/dist/plugins/MagicDotMatrix/src/composables/useMagicDotMatrixEmoji.d.ts +19 -0
  17. package/dist/plugins/MagicDotMatrix/src/composables/useMagicDotMatrixEmoji.mjs +50 -0
  18. package/dist/plugins/MagicDotMatrix/src/types/index.d.ts +40 -0
  19. package/dist/plugins/MagicDotMatrix/src/types/index.mjs +0 -0
  20. package/dist/plugins/MagicDotMatrix/src/utils/defaultOptions.d.ts +4 -0
  21. package/dist/plugins/MagicDotMatrix/src/utils/defaultOptions.mjs +14 -0
  22. package/dist/plugins/MagicDotMatrix/src/utils/emoji/animateEmoji.d.ts +5 -0
  23. package/dist/plugins/MagicDotMatrix/src/utils/emoji/animateEmoji.mjs +296 -0
  24. package/dist/plugins/MagicDotMatrix/src/utils/emoji/motions.d.ts +382 -0
  25. package/dist/plugins/MagicDotMatrix/src/utils/emoji/motions.mjs +420 -0
  26. package/dist/plugins/MagicDotMatrix/src/utils/emoji/pickMotion.d.ts +7 -0
  27. package/dist/plugins/MagicDotMatrix/src/utils/emoji/pickMotion.mjs +153 -0
  28. package/dist/plugins/MagicDotMatrix/src/utils/presets/bounce.d.ts +2 -0
  29. package/dist/plugins/MagicDotMatrix/src/utils/presets/bounce.mjs +8 -0
  30. package/dist/plugins/MagicDotMatrix/src/utils/presets/checkerboard.d.ts +2 -0
  31. package/dist/plugins/MagicDotMatrix/src/utils/presets/checkerboard.mjs +18 -0
  32. package/dist/plugins/MagicDotMatrix/src/utils/presets/comet.d.ts +2 -0
  33. package/dist/plugins/MagicDotMatrix/src/utils/presets/comet.mjs +5 -0
  34. package/dist/plugins/MagicDotMatrix/src/utils/presets/drift.d.ts +2 -0
  35. package/dist/plugins/MagicDotMatrix/src/utils/presets/drift.mjs +38 -0
  36. package/dist/plugins/MagicDotMatrix/src/utils/presets/equalizer.d.ts +2 -0
  37. package/dist/plugins/MagicDotMatrix/src/utils/presets/equalizer.mjs +14 -0
  38. package/dist/plugins/MagicDotMatrix/src/utils/presets/fill.d.ts +2 -0
  39. package/dist/plugins/MagicDotMatrix/src/utils/presets/fill.mjs +10 -0
  40. package/dist/plugins/MagicDotMatrix/src/utils/presets/focus.d.ts +2 -0
  41. package/dist/plugins/MagicDotMatrix/src/utils/presets/focus.mjs +5 -0
  42. package/dist/plugins/MagicDotMatrix/src/utils/presets/index.d.ts +12 -0
  43. package/dist/plugins/MagicDotMatrix/src/utils/presets/index.mjs +12 -0
  44. package/dist/plugins/MagicDotMatrix/src/utils/presets/orbit.d.ts +2 -0
  45. package/dist/plugins/MagicDotMatrix/src/utils/presets/orbit.mjs +8 -0
  46. package/dist/plugins/MagicDotMatrix/src/utils/presets/pulse.d.ts +2 -0
  47. package/dist/plugins/MagicDotMatrix/src/utils/presets/pulse.mjs +7 -0
  48. package/dist/plugins/MagicDotMatrix/src/utils/presets/ripple.d.ts +2 -0
  49. package/dist/plugins/MagicDotMatrix/src/utils/presets/ripple.mjs +5 -0
  50. package/dist/plugins/MagicDotMatrix/src/utils/presets/scan.d.ts +2 -0
  51. package/dist/plugins/MagicDotMatrix/src/utils/presets/scan.mjs +6 -0
  52. package/dist/plugins/MagicDotMatrix/src/utils/presets/spiral.d.ts +2 -0
  53. package/dist/plugins/MagicDotMatrix/src/utils/presets/spiral.mjs +34 -0
  54. package/dist/plugins/MagicDotMatrix/src/utils/sequence/equalizerFrame.d.ts +7 -0
  55. package/dist/plugins/MagicDotMatrix/src/utils/sequence/equalizerFrame.mjs +12 -0
  56. package/dist/plugins/MagicDotMatrix/src/utils/sequence/getRings.d.ts +2 -0
  57. package/dist/plugins/MagicDotMatrix/src/utils/sequence/getRings.mjs +24 -0
  58. package/dist/plugins/MagicDotMatrix/src/utils/sequence/ringPath.d.ts +7 -0
  59. package/dist/plugins/MagicDotMatrix/src/utils/sequence/ringPath.mjs +35 -0
  60. package/dist/plugins/MagicDotMatrix/src/utils/sequence/toIndex.d.ts +6 -0
  61. package/dist/plugins/MagicDotMatrix/src/utils/sequence/toIndex.mjs +3 -0
  62. package/dist/plugins/MagicDotMatrix/src/utils/sequence/withTrail.d.ts +6 -0
  63. package/dist/plugins/MagicDotMatrix/src/utils/sequence/withTrail.mjs +17 -0
  64. package/dist/plugins/MagicDrawer/src/components/MagicDrawerTrigger.d.vue.ts +1 -1
  65. package/dist/plugins/MagicDrawer/src/components/MagicDrawerTrigger.vue +5 -1
  66. package/dist/plugins/MagicDrawer/src/components/MagicDrawerTrigger.vue.d.ts +1 -1
  67. package/dist/plugins/MagicEmitter/src/types/index.d.ts +2 -0
  68. package/dist/plugins/MagicMenu/src/components/MagicMenuTrigger.vue +13 -3
  69. package/dist/plugins/MagicTray/src/components/MagicTrayTrigger.d.vue.ts +1 -1
  70. package/dist/plugins/MagicTray/src/components/MagicTrayTrigger.vue +27 -7
  71. package/dist/plugins/MagicTray/src/components/MagicTrayTrigger.vue.d.ts +1 -1
  72. package/dist/plugins/MagicTray/src/composables/private/useTrayGesture.d.ts +2 -2
  73. package/dist/plugins/MagicTray/src/composables/private/useTrayGesture.mjs +93 -20
  74. package/package.json +2 -3
@@ -0,0 +1,10 @@
1
+ export function createFill({ cols, rows }) {
2
+ const total = cols * rows;
3
+ return [
4
+ ...Array.from(
5
+ { length: total },
6
+ (_, index) => Array.from({ length: index + 1 }, (__, dot) => dot)
7
+ ),
8
+ []
9
+ ];
10
+ }
@@ -0,0 +1,2 @@
1
+ import type { DotMatrixGrid, DotMatrixSequence } from '../../types/index.js';
2
+ export declare function createFocus(grid: DotMatrixGrid): DotMatrixSequence;
@@ -0,0 +1,5 @@
1
+ import { getRings } from "../sequence/getRings.mjs";
2
+ export function createFocus(grid) {
3
+ const rings = [...getRings(grid)].reverse();
4
+ return [...rings, ...rings.slice(0, -1).reverse(), []];
5
+ }
@@ -0,0 +1,12 @@
1
+ export { createBounce } from './bounce.js';
2
+ export { createCheckerboard } from './checkerboard.js';
3
+ export { createComet } from './comet.js';
4
+ export { createDrift } from './drift.js';
5
+ export { createEqualizer } from './equalizer.js';
6
+ export { createFill } from './fill.js';
7
+ export { createFocus } from './focus.js';
8
+ export { createOrbit } from './orbit.js';
9
+ export { createPulse } from './pulse.js';
10
+ export { createRipple } from './ripple.js';
11
+ export { createScan } from './scan.js';
12
+ export { createSpiral } from './spiral.js';
@@ -0,0 +1,12 @@
1
+ export { createBounce } from "./bounce.mjs";
2
+ export { createCheckerboard } from "./checkerboard.mjs";
3
+ export { createComet } from "./comet.mjs";
4
+ export { createDrift } from "./drift.mjs";
5
+ export { createEqualizer } from "./equalizer.mjs";
6
+ export { createFill } from "./fill.mjs";
7
+ export { createFocus } from "./focus.mjs";
8
+ export { createOrbit } from "./orbit.mjs";
9
+ export { createPulse } from "./pulse.mjs";
10
+ export { createRipple } from "./ripple.mjs";
11
+ export { createScan } from "./scan.mjs";
12
+ export { createSpiral } from "./spiral.mjs";
@@ -0,0 +1,2 @@
1
+ import type { DotMatrixGrid, DotMatrixSequence } from '../../types/index.js';
2
+ export declare function createOrbit({ cols, rows }: DotMatrixGrid): DotMatrixSequence;
@@ -0,0 +1,8 @@
1
+ import { ringPath } from "../sequence/ringPath.mjs";
2
+ export function createOrbit({ cols, rows }) {
3
+ const path = ringPath({ cols, rows });
4
+ if (path.length === 0) {
5
+ return [[]];
6
+ }
7
+ return path.map((_, index) => [path[index]]);
8
+ }
@@ -0,0 +1,2 @@
1
+ import type { DotMatrixGrid, DotMatrixSequence } from '../../types/index.js';
2
+ export declare function createPulse(grid: DotMatrixGrid): DotMatrixSequence;
@@ -0,0 +1,7 @@
1
+ import { getRings } from "../sequence/getRings.mjs";
2
+ export function createPulse(grid) {
3
+ const rings = getRings(grid);
4
+ const expand = rings.map((_, index) => rings.slice(0, index + 1).flat());
5
+ const contract = rings.map((_, index) => rings.slice(0, rings.length - index - 1).flat()).slice(1);
6
+ return [...expand, ...contract, []];
7
+ }
@@ -0,0 +1,2 @@
1
+ import type { DotMatrixGrid, DotMatrixSequence } from '../../types/index.js';
2
+ export declare function createRipple(grid: DotMatrixGrid): DotMatrixSequence;
@@ -0,0 +1,5 @@
1
+ import { getRings } from "../sequence/getRings.mjs";
2
+ export function createRipple(grid) {
3
+ const rings = getRings(grid);
4
+ return [...rings, ...rings.slice(0, -1).reverse(), []];
5
+ }
@@ -0,0 +1,2 @@
1
+ import type { DotMatrixGrid, DotMatrixSequence } from '../../types/index.js';
2
+ export declare function createScan({ cols, rows }: DotMatrixGrid): DotMatrixSequence;
@@ -0,0 +1,6 @@
1
+ export function createScan({ cols, rows }) {
2
+ return Array.from(
3
+ { length: rows },
4
+ (_, row) => Array.from({ length: cols }, (__, col) => row * cols + col)
5
+ );
6
+ }
@@ -0,0 +1,2 @@
1
+ import type { DotMatrixGrid, DotMatrixSequence } from '../../types/index.js';
2
+ export declare function createSpiral(grid: DotMatrixGrid): DotMatrixSequence;
@@ -0,0 +1,34 @@
1
+ function spiralOrder({ cols, rows }) {
2
+ const result = [];
3
+ let top = 0;
4
+ let bottom = rows - 1;
5
+ let left = 0;
6
+ let right = cols - 1;
7
+ while (top <= bottom && left <= right) {
8
+ for (let col = left; col <= right; col++) {
9
+ result.push(top * cols + col);
10
+ }
11
+ top++;
12
+ for (let row = top; row <= bottom; row++) {
13
+ result.push(row * cols + right);
14
+ }
15
+ right--;
16
+ if (top <= bottom) {
17
+ for (let col = right; col >= left; col--) {
18
+ result.push(bottom * cols + col);
19
+ }
20
+ bottom--;
21
+ }
22
+ if (left <= right) {
23
+ for (let row = bottom; row >= top; row--) {
24
+ result.push(row * cols + left);
25
+ }
26
+ left++;
27
+ }
28
+ }
29
+ return result;
30
+ }
31
+ export function createSpiral(grid) {
32
+ const order = spiralOrder(grid);
33
+ return [...order.map((_, index) => order.slice(0, index + 1)), []];
34
+ }
@@ -0,0 +1,7 @@
1
+ import type { DotMatrixFrame } from '../../types/index.js';
2
+ export type EqualizerFrameArgs = {
3
+ heights: Array<number>;
4
+ cols: number;
5
+ rows: number;
6
+ };
7
+ export declare function equalizerFrame({ heights, cols, rows, }: EqualizerFrameArgs): DotMatrixFrame;
@@ -0,0 +1,12 @@
1
+ export function equalizerFrame({
2
+ heights,
3
+ cols,
4
+ rows
5
+ }) {
6
+ return heights.flatMap(
7
+ (height, col) => Array.from(
8
+ { length: Math.max(0, Math.min(height, rows)) },
9
+ (_, index) => (rows - 1 - index) * cols + col
10
+ )
11
+ );
12
+ }
@@ -0,0 +1,2 @@
1
+ import type { DotMatrixFrame, DotMatrixGrid } from '../../types/index.js';
2
+ export declare function getRings({ cols, rows }: DotMatrixGrid): Array<DotMatrixFrame>;
@@ -0,0 +1,24 @@
1
+ import { toIndex } from "./toIndex.mjs";
2
+ export function getRings({ cols, rows }) {
3
+ const centerCol = (cols - 1) / 2;
4
+ const centerRow = (rows - 1) / 2;
5
+ const maxRing = Math.max(
6
+ Math.ceil(Math.max(centerCol, cols - 1 - centerCol)),
7
+ Math.ceil(Math.max(centerRow, rows - 1 - centerRow))
8
+ );
9
+ return Array.from({ length: maxRing + 1 }, (_, ring) => {
10
+ const indices = [];
11
+ for (let row = 0; row < rows; row++) {
12
+ for (let col = 0; col < cols; col++) {
13
+ const distance = Math.max(
14
+ Math.abs(col - centerCol),
15
+ Math.abs(row - centerRow)
16
+ );
17
+ if (Math.floor(distance + 0.5) === ring) {
18
+ indices.push(toIndex({ col, row, cols }));
19
+ }
20
+ }
21
+ }
22
+ return indices;
23
+ }).filter((frame) => frame.length > 0);
24
+ }
@@ -0,0 +1,7 @@
1
+ import type { DotMatrixFrame } from '../../types/index.js';
2
+ export type RingPathArgs = {
3
+ cols: number;
4
+ rows: number;
5
+ inset?: number;
6
+ };
7
+ export declare function ringPath({ cols, rows, inset, }: RingPathArgs): DotMatrixFrame;
@@ -0,0 +1,35 @@
1
+ import { toIndex } from "./toIndex.mjs";
2
+ export function ringPath({
3
+ cols,
4
+ rows,
5
+ inset = 0
6
+ }) {
7
+ const left = inset;
8
+ const top = inset;
9
+ const right = cols - 1 - inset;
10
+ const bottom = rows - 1 - inset;
11
+ if (left > right || top > bottom) {
12
+ return [];
13
+ }
14
+ if (left === right && top === bottom) {
15
+ return [toIndex({ col: left, row: top, cols })];
16
+ }
17
+ const path = [];
18
+ for (let col = left; col <= right; col++) {
19
+ path.push(toIndex({ col, row: top, cols }));
20
+ }
21
+ for (let row = top + 1; row <= bottom; row++) {
22
+ path.push(toIndex({ col: right, row, cols }));
23
+ }
24
+ if (bottom > top) {
25
+ for (let col = right - 1; col >= left; col--) {
26
+ path.push(toIndex({ col, row: bottom, cols }));
27
+ }
28
+ }
29
+ if (right > left) {
30
+ for (let row = bottom - 1; row > top; row--) {
31
+ path.push(toIndex({ col: left, row, cols }));
32
+ }
33
+ }
34
+ return path;
35
+ }
@@ -0,0 +1,6 @@
1
+ export type ToIndexArgs = {
2
+ col: number;
3
+ row: number;
4
+ cols: number;
5
+ };
6
+ export declare function toIndex({ col, row, cols }: ToIndexArgs): number;
@@ -0,0 +1,3 @@
1
+ export function toIndex({ col, row, cols }) {
2
+ return row * cols + col;
3
+ }
@@ -0,0 +1,6 @@
1
+ import type { DotMatrixFrame, DotMatrixSequence } from '../../types/index.js';
2
+ export type WithTrailArgs = {
3
+ path: DotMatrixFrame;
4
+ length?: number;
5
+ };
6
+ export declare function withTrail({ path, length, }: WithTrailArgs): DotMatrixSequence;
@@ -0,0 +1,17 @@
1
+ export function withTrail({
2
+ path,
3
+ length = 3
4
+ }) {
5
+ if (path.length === 0) {
6
+ return [[]];
7
+ }
8
+ const trail = Math.max(1, Math.min(length, path.length));
9
+ return path.map((_, index) => [
10
+ ...new Set(
11
+ Array.from(
12
+ { length: trail },
13
+ (__, offset) => path[(index + offset) % path.length]
14
+ )
15
+ )
16
+ ]);
17
+ }
@@ -6,7 +6,7 @@ interface MagicDrawerTriggerProps {
6
6
  }
7
7
  declare var __VLS_10: {
8
8
  active: any;
9
- disabled: boolean;
9
+ disabled: any;
10
10
  };
11
11
  type __VLS_Slots = {} & {
12
12
  default?: (props: typeof __VLS_10) => any;
@@ -18,7 +18,11 @@ import { useMagicError } from "@maas/vue-equipment/plugins/MagicError";
18
18
  import { useMagicDrawer } from "../composables/useMagicDrawer";
19
19
  import { useDrawerState } from "../composables/private/useDrawerState";
20
20
  import { MagicDrawerInstanceId } from "../symbols";
21
- const { id, disabled, asChild } = defineProps({
21
+ const {
22
+ id,
23
+ disabled = void 0,
24
+ asChild
25
+ } = defineProps({
22
26
  id: { type: null, required: false },
23
27
  disabled: { type: Boolean, required: false },
24
28
  asChild: { type: Boolean, required: false }
@@ -6,7 +6,7 @@ interface MagicDrawerTriggerProps {
6
6
  }
7
7
  declare var __VLS_10: {
8
8
  active: any;
9
- disabled: boolean;
9
+ disabled: any;
10
10
  };
11
11
  type __VLS_Slots = {} & {
12
12
  default?: (props: typeof __VLS_10) => any;
@@ -1,6 +1,7 @@
1
1
  import type { AccordionEvents } from '../../../MagicAccordion/src/types/index.js';
2
2
  import type { CarouselEvents } from '../../../MagicCarousel/src/types/index.js';
3
3
  import type { CookieEvents } from '../../../MagicCookie/src/types/index.js';
4
+ import type { DotMatrixEvents } from '../../../MagicDotMatrix/src/types/index.js';
4
5
  import type { DraggableEvents } from '../../../MagicDraggable/src/types/index.js';
5
6
  import type { DrawerEvents } from '../../../MagicDrawer/src/types/index.js';
6
7
  import type { ModalEvents } from '../../../MagicModal/src/types/index.js';
@@ -17,6 +18,7 @@ export type MagicEmitterEvents = Merge<[
17
18
  AccordionEvents,
18
19
  CarouselEvents,
19
20
  CookieEvents,
21
+ DotMatrixEvents,
20
22
  DraggableEvents,
21
23
  DrawerEvents,
22
24
  ModalEvents,
@@ -29,7 +29,12 @@ import {
29
29
  MagicMenuItemId,
30
30
  MagicMenuViewId
31
31
  } from "../symbols";
32
- const { instanceId, viewId, disabled, trigger } = defineProps({
32
+ const {
33
+ instanceId,
34
+ viewId,
35
+ disabled = void 0,
36
+ trigger
37
+ } = defineProps({
33
38
  instanceId: { type: String, required: false },
34
39
  viewId: { type: String, required: false },
35
40
  disabled: { type: Boolean, required: false },
@@ -54,13 +59,18 @@ magicError.assert(mappedViewId.value, {
54
59
  message: "MagicMenuTrigger must be nested inside MagicMenuView or a viewId must be provided",
55
60
  errorCode: "missing_view_id"
56
61
  });
57
- const { getView, getRelativeViewIndex } = useMenuView(mappedInstanceId.value);
62
+ const { getView, getRelativeViewIndex, getParentView } = useMenuView(
63
+ mappedInstanceId.value
64
+ );
58
65
  const view = getView(mappedViewId.value);
59
66
  const viewIndex = getRelativeViewIndex(mappedViewId.value);
60
67
  const { initializeState } = useMenuState(mappedInstanceId.value);
61
68
  const state = initializeState();
62
69
  const { getItem } = useMenuItem(mappedInstanceId.value);
63
- const item = getItem({ viewId: mappedViewId.value, id: itemId ?? "" });
70
+ const item = getItem({
71
+ viewId: getParentView(mappedViewId.value)?.id ?? "",
72
+ id: itemId ?? ""
73
+ });
64
74
  const mappedDisabled = computed(() => disabled ?? item?.disabled ?? false);
65
75
  const mappedTrigger = computed(() => {
66
76
  if (trigger?.length) {
@@ -2,7 +2,7 @@ import type { MaybeRef } from 'vue';
2
2
  import type { MagicTraySide } from '../types/index.js';
3
3
  interface MagicTrayTriggerProps {
4
4
  id?: MaybeRef<string>;
5
- side: MagicTraySide;
5
+ side: MagicTraySide | Array<MagicTraySide>;
6
6
  disabled?: boolean;
7
7
  preventEdgeNavigation?: boolean;
8
8
  asChild?: boolean;
@@ -3,7 +3,8 @@
3
3
  class="magic-tray-trigger"
4
4
  :as-child="asChild"
5
5
  :data-id="`${mappedId}-trigger`"
6
- :data-side="side"
6
+ :data-side="mappedSide"
7
+ :data-axis="axis"
7
8
  :data-dragging="active"
8
9
  :data-dragged="hasDragged"
9
10
  :data-disabled="mappedDisabled"
@@ -21,9 +22,15 @@ import { useMagicError } from "@maas/vue-equipment/plugins/MagicError";
21
22
  import { useTrayState } from "../composables/private/useTrayState";
22
23
  import { useTrayGesture } from "../composables/private/useTrayGesture";
23
24
  import { MagicTrayInstanceId } from "../symbols";
24
- const { id, side, disabled, preventEdgeNavigation, asChild } = defineProps({
25
+ const {
26
+ id,
27
+ side,
28
+ disabled,
29
+ preventEdgeNavigation = void 0,
30
+ asChild
31
+ } = defineProps({
25
32
  id: { type: null, required: false },
26
- side: { type: String, required: true },
33
+ side: { type: [String, Array], required: true },
27
34
  disabled: { type: Boolean, required: false },
28
35
  preventEdgeNavigation: { type: Boolean, required: false },
29
36
  asChild: { type: Boolean, required: false }
@@ -48,6 +55,17 @@ const { active, hasDragged, onPointerdown, onTouchstart } = useTrayGesture({
48
55
  preventEdgeNavigation: () => preventEdgeNavigation ?? state.options.preventEdgeNavigation
49
56
  });
50
57
  const mappedDisabled = computed(() => disabled || state.options.disabled);
58
+ const sides = computed(() => Array.isArray(side) ? side : [side]);
59
+ const mappedSide = computed(() => sides.value.join(" "));
60
+ const axis = computed(() => {
61
+ const horizontal = sides.value.some(
62
+ (side2) => side2 === "left" || side2 === "right"
63
+ );
64
+ const vertical = sides.value.some(
65
+ (side2) => side2 === "top" || side2 === "bottom"
66
+ );
67
+ return horizontal && vertical ? "both" : vertical ? "y" : "x";
68
+ });
51
69
  function isEditable(target) {
52
70
  if (!(target instanceof Element)) {
53
71
  return false;
@@ -70,16 +88,18 @@ function guardedTouchstart(event) {
70
88
  </script>
71
89
 
72
90
  <style>
73
- .magic-tray-trigger[data-disabled='false'][data-side='left'],
74
- .magic-tray-trigger[data-disabled='false'][data-side='right'] {
91
+ .magic-tray-trigger[data-disabled='false'][data-axis='x'] {
75
92
  touch-action: var(--magic-tray-trigger-touch-action, pan-y);
76
93
  }
77
94
 
78
- .magic-tray-trigger[data-disabled='false'][data-side='top'],
79
- .magic-tray-trigger[data-disabled='false'][data-side='bottom'] {
95
+ .magic-tray-trigger[data-disabled='false'][data-axis='y'] {
80
96
  touch-action: var(--magic-tray-trigger-touch-action, pan-x);
81
97
  }
82
98
 
99
+ .magic-tray-trigger[data-disabled='false'][data-axis='both'] {
100
+ touch-action: var(--magic-tray-trigger-touch-action, none);
101
+ }
102
+
83
103
  .magic-tray-trigger[data-dragging='true'] * {
84
104
  -webkit-user-drag: none;
85
105
  }
@@ -2,7 +2,7 @@ import type { MaybeRef } from 'vue';
2
2
  import type { MagicTraySide } from '../types/index.js';
3
3
  interface MagicTrayTriggerProps {
4
4
  id?: MaybeRef<string>;
5
- side: MagicTraySide;
5
+ side: MagicTraySide | Array<MagicTraySide>;
6
6
  disabled?: boolean;
7
7
  preventEdgeNavigation?: boolean;
8
8
  asChild?: boolean;
@@ -9,8 +9,8 @@ type UseTrayGestureArgs = {
9
9
  export declare function useTrayGesture(args: UseTrayGestureArgs): {
10
10
  active: Readonly<import("vue").Ref<boolean, boolean>>;
11
11
  hasDragged: import("vue").ComputedRef<boolean>;
12
- onPointerdown: (side: MagicTraySide, e: PointerEvent) => void;
13
- onTouchstart: (side: MagicTraySide, e: TouchEvent) => void;
12
+ onPointerdown: (side: MagicTraySide | Array<MagicTraySide>, e: PointerEvent) => void;
13
+ onTouchstart: (side: MagicTraySide | Array<MagicTraySide>, e: TouchEvent) => void;
14
14
  };
15
15
  export type UseTrayGestureReturn = ReturnType<typeof useTrayGesture>;
16
16
  export {};
@@ -39,6 +39,7 @@ export function useTrayGesture(args) {
39
39
  let cancelTouchcancel = void 0;
40
40
  let pointerdownTarget = null;
41
41
  let releaseSelection = void 0;
42
+ let pending = void 0;
42
43
  const threshold = computed(() => state.options.threshold);
43
44
  const disabled = computed(() => state.options.disabled);
44
45
  const snapMode = computed(() => state.options.snap.mode);
@@ -57,8 +58,45 @@ export function useTrayGesture(args) {
57
58
  function lockSelectionOnce() {
58
59
  releaseSelection ??= lockSelection();
59
60
  }
60
- function canBegin(side) {
61
- return !state.dragging && !toValue(disabled) && state.elRect !== void 0 && isDraggableSide({ snapPoints: state.options.snapPoints, side });
61
+ function canStart() {
62
+ return !state.dragging && !toValue(disabled) && state.elRect !== void 0;
63
+ }
64
+ function draggableSides(side) {
65
+ const sides = Array.isArray(side) ? side : [side];
66
+ return sides.filter(
67
+ (side2) => isDraggableSide({ snapPoints: state.options.snapPoints, side: side2 })
68
+ );
69
+ }
70
+ function resolveSide(sides, dx, dy) {
71
+ const horizontal = sides.filter((side) => !isVertical(side));
72
+ const vertical = sides.filter(isVertical);
73
+ const alongX = horizontal.length > 0 && (!vertical.length || Math.abs(dx) >= Math.abs(dy));
74
+ const delta = alongX ? dx : dy;
75
+ if (Math.abs(delta) <= toValue(threshold).lock) {
76
+ return void 0;
77
+ }
78
+ const candidates = alongX ? horizontal : vertical;
79
+ const preferred = alongX ? delta > 0 ? "left" : "right" : delta > 0 ? "top" : "bottom";
80
+ return candidates.includes(preferred) ? preferred : candidates[0];
81
+ }
82
+ function resolvePending(x, y) {
83
+ if (!pending) {
84
+ return void 0;
85
+ }
86
+ if (!canStart()) {
87
+ pending = void 0;
88
+ resetListeners();
89
+ return void 0;
90
+ }
91
+ const side = resolveSide(pending.sides, x - pending.x, y - pending.y);
92
+ if (!side) {
93
+ return void 0;
94
+ }
95
+ const { x: pressX, y: pressY, target, pressedAt } = pending;
96
+ pending = void 0;
97
+ beginDrag(side, isVertical(side) ? pressY : pressX, target);
98
+ state.dragStart = pressedAt;
99
+ return side;
62
100
  }
63
101
  function dragBounds(side) {
64
102
  const points = mappedSnapPoints(side);
@@ -173,11 +211,11 @@ export function useTrayGesture(args) {
173
211
  function emitWillSnapTo(side) {
174
212
  const target = settleTarget(side);
175
213
  const isPoint = mappedSnapPoints(side).includes(target);
176
- const pending = !isPoint && rangeAt(side, target)?.range || target;
177
- if (pending === lastPendingTarget) {
214
+ const pending2 = !isPoint && rangeAt(side, target)?.range || target;
215
+ if (pending2 === lastPendingTarget) {
178
216
  return;
179
217
  }
180
- lastPendingTarget = pending;
218
+ lastPendingTarget = pending2;
181
219
  const snapPoint = snapPointAt(side, target);
182
220
  if (snapPoint === void 0) {
183
221
  return;
@@ -204,6 +242,7 @@ export function useTrayGesture(args) {
204
242
  }
205
243
  function resetDragState() {
206
244
  const side = state.draggingSide;
245
+ pending = void 0;
207
246
  if (side) {
208
247
  state.lastDragged[side] = state.snapped[side];
209
248
  }
@@ -226,7 +265,7 @@ export function useTrayGesture(args) {
226
265
  if (e.isTrusted && !e.isPrimary) {
227
266
  return;
228
267
  }
229
- const side = state.draggingSide;
268
+ const side = state.draggingSide ?? resolvePending(e.clientX, e.clientY);
230
269
  if (!side) {
231
270
  return;
232
271
  }
@@ -269,14 +308,14 @@ export function useTrayGesture(args) {
269
308
  guardedReleasePointerCapture({ event: e, element: pointerdownTarget });
270
309
  }
271
310
  function onTouchmove(e) {
272
- const side = state.draggingSide;
273
- if (!side) {
274
- return;
275
- }
276
311
  const firstTouch = e.touches[0];
277
312
  if (!firstTouch) {
278
313
  return;
279
314
  }
315
+ const side = state.draggingSide ?? resolvePending(firstTouch.clientX, firstTouch.clientY);
316
+ if (!side) {
317
+ return;
318
+ }
280
319
  e.stopImmediatePropagation();
281
320
  e.stopPropagation();
282
321
  if (hasDragged.value) {
@@ -355,15 +394,28 @@ export function useTrayGesture(args) {
355
394
  interpolateDragged({ side, to: state.snapped[side] });
356
395
  resetDragState();
357
396
  }
397
+ pending = void 0;
358
398
  resetListeners();
359
399
  }
360
400
  function onPointerdown(side, e) {
361
- if (!canBegin(side)) {
401
+ const sides = draggableSides(side);
402
+ if (!canStart() || !sides.length) {
362
403
  return;
363
404
  }
364
- const coord = isVertical(side) ? e.clientY : e.clientX;
365
405
  const target = e.target instanceof Element ? e.target : null;
366
- beginDrag(side, coord, target);
406
+ const only = sides.length === 1 ? sides[0] : void 0;
407
+ if (only) {
408
+ beginDrag(only, isVertical(only) ? e.clientY : e.clientX, target);
409
+ } else {
410
+ pending = {
411
+ sides,
412
+ x: e.clientX,
413
+ y: e.clientY,
414
+ target,
415
+ pressedAt: /* @__PURE__ */ new Date()
416
+ };
417
+ pointerdownTarget = target;
418
+ }
367
419
  guardedSetPointerCapture({ event: e, element: target });
368
420
  resetListeners();
369
421
  cancelPointerup = useEventListener(document, "pointerup", onPointerup);
@@ -382,23 +434,42 @@ export function useTrayGesture(args) {
382
434
  );
383
435
  cancelTouchend = isIOS() || isAndroid() ? useEventListener(document, "touchend", onTouchend) : void 0;
384
436
  cancelTouchcancel = isIOS() || isAndroid() ? useEventListener(document, "touchcancel", onTouchend) : void 0;
385
- onPointermove(e);
437
+ if (!pending) {
438
+ onPointermove(e);
439
+ }
386
440
  }
387
441
  function onTouchstart(side, e) {
388
442
  if (toValue(preventEdgeNavigation)) {
389
443
  cancelEdgeNavigation({ event: e });
390
444
  }
391
- if (!isAndroid() || !canBegin(side)) {
445
+ const sides = draggableSides(side);
446
+ if (!isAndroid() || !canStart() || !sides.length) {
392
447
  return;
393
448
  }
394
449
  const firstTouch = e.touches[0];
395
450
  if (!firstTouch) {
396
451
  return;
397
452
  }
398
- e.stopImmediatePropagation();
399
- e.stopPropagation();
400
- const coord = isVertical(side) ? firstTouch.clientY : firstTouch.clientX;
401
- beginDrag(side, coord, e.target instanceof Element ? e.target : null);
453
+ const target = e.target instanceof Element ? e.target : null;
454
+ const only = sides.length === 1 ? sides[0] : void 0;
455
+ if (only) {
456
+ e.stopImmediatePropagation();
457
+ e.stopPropagation();
458
+ beginDrag(
459
+ only,
460
+ isVertical(only) ? firstTouch.clientY : firstTouch.clientX,
461
+ target
462
+ );
463
+ } else {
464
+ pending = {
465
+ sides,
466
+ x: firstTouch.clientX,
467
+ y: firstTouch.clientY,
468
+ target,
469
+ pressedAt: /* @__PURE__ */ new Date()
470
+ };
471
+ pointerdownTarget = target;
472
+ }
402
473
  cancelTouchmove?.();
403
474
  cancelTouchmove = useEventListener(document, "touchmove", onTouchmove, {
404
475
  passive: false
@@ -409,7 +480,9 @@ export function useTrayGesture(args) {
409
480
  });
410
481
  cancelTouchcancel?.();
411
482
  cancelTouchcancel = useEventListener(document, "touchcancel", onTouchend);
412
- onTouchmove(e);
483
+ if (!pending) {
484
+ onTouchmove(e);
485
+ }
413
486
  }
414
487
  watch(disabled, (value) => {
415
488
  if (value) {