@maas/vue-equipment 1.0.0-beta.65 → 1.0.0-beta.66

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 (60) hide show
  1. package/dist/nuxt/module.json +1 -1
  2. package/dist/nuxt/module.mjs +8 -0
  3. package/dist/plugins/MagicDraggable/src/composables/private/useDraggableSnap.mjs +2 -2
  4. package/dist/plugins/MagicDraggable/src/types/index.d.ts +2 -1
  5. package/dist/plugins/MagicDrawer/src/components/MagicDrawerContent.vue +8 -21
  6. package/dist/plugins/MagicDrawer/src/composables/private/useDrawerCallback.d.ts +1 -1
  7. package/dist/plugins/MagicDrawer/src/composables/private/useDrawerCallback.mjs +1 -8
  8. package/dist/plugins/MagicDrawer/src/composables/private/useDrawerSnap.mjs +2 -2
  9. package/dist/plugins/MagicDrawer/src/composables/private/useDrawerState.mjs +1 -1
  10. package/dist/plugins/MagicDrawer/src/composables/private/useDrawerUtils.mjs +7 -26
  11. package/dist/plugins/MagicDrawer/src/symbols/index.d.ts +2 -4
  12. package/dist/plugins/MagicDrawer/src/types/index.d.ts +6 -1
  13. package/dist/plugins/MagicDrawer/src/utils/defaultOptions.mjs +3 -1
  14. package/dist/plugins/MagicEmitter/src/composables/useMagicEmitter.d.ts +552 -6
  15. package/dist/plugins/MagicEmitter/src/types/index.d.ts +3 -1
  16. package/dist/plugins/MagicToast/src/composables/private/useToastDrag.mjs +2 -2
  17. package/dist/plugins/MagicToast/src/types/index.d.ts +2 -5
  18. package/dist/plugins/MagicToast/src/utils/defaultOptions.mjs +3 -1
  19. package/dist/plugins/MagicTray/index.d.ts +11 -0
  20. package/dist/plugins/MagicTray/index.mjs +24 -0
  21. package/dist/plugins/MagicTray/nuxt.d.ts +2 -0
  22. package/dist/plugins/MagicTray/nuxt.mjs +23 -0
  23. package/dist/plugins/MagicTray/src/components/MagicTray.d.vue.ts +25 -0
  24. package/dist/plugins/MagicTray/src/components/MagicTray.vue +26 -0
  25. package/dist/plugins/MagicTray/src/components/MagicTray.vue.d.ts +25 -0
  26. package/dist/plugins/MagicTray/src/components/MagicTrayContent.d.vue.ts +20 -0
  27. package/dist/plugins/MagicTray/src/components/MagicTrayContent.vue +191 -0
  28. package/dist/plugins/MagicTray/src/components/MagicTrayContent.vue.d.ts +20 -0
  29. package/dist/plugins/MagicTray/src/components/MagicTrayHandle.d.vue.ts +19 -0
  30. package/dist/plugins/MagicTray/src/components/MagicTrayHandle.vue +56 -0
  31. package/dist/plugins/MagicTray/src/components/MagicTrayHandle.vue.d.ts +19 -0
  32. package/dist/plugins/MagicTray/src/components/MagicTrayProvider.d.vue.ts +19 -0
  33. package/dist/plugins/MagicTray/src/components/MagicTrayProvider.vue +23 -0
  34. package/dist/plugins/MagicTray/src/components/MagicTrayProvider.vue.d.ts +19 -0
  35. package/dist/plugins/MagicTray/src/components/MagicTrayTransform.d.vue.ts +19 -0
  36. package/dist/plugins/MagicTray/src/components/MagicTrayTransform.vue +52 -0
  37. package/dist/plugins/MagicTray/src/components/MagicTrayTransform.vue.d.ts +19 -0
  38. package/dist/plugins/MagicTray/src/composables/private/useTrayDrag.d.ts +36 -0
  39. package/dist/plugins/MagicTray/src/composables/private/useTrayDrag.mjs +456 -0
  40. package/dist/plugins/MagicTray/src/composables/private/useTrayProgress.d.ts +8 -0
  41. package/dist/plugins/MagicTray/src/composables/private/useTrayProgress.mjs +25 -0
  42. package/dist/plugins/MagicTray/src/composables/private/useTraySnap.d.ts +36 -0
  43. package/dist/plugins/MagicTray/src/composables/private/useTraySnap.mjs +156 -0
  44. package/dist/plugins/MagicTray/src/composables/private/useTrayState.d.ts +6 -0
  45. package/dist/plugins/MagicTray/src/composables/private/useTrayState.mjs +94 -0
  46. package/dist/plugins/MagicTray/src/composables/private/useTrayUtils.d.ts +6 -0
  47. package/dist/plugins/MagicTray/src/composables/private/useTrayUtils.mjs +32 -0
  48. package/dist/plugins/MagicTray/src/composables/useMagicTray.d.ts +9 -0
  49. package/dist/plugins/MagicTray/src/composables/useMagicTray.mjs +23 -0
  50. package/dist/plugins/MagicTray/src/symbols/index.d.ts +3 -0
  51. package/dist/plugins/MagicTray/src/symbols/index.mjs +2 -0
  52. package/dist/plugins/MagicTray/src/types/index.d.ts +91 -0
  53. package/dist/plugins/MagicTray/src/types/index.mjs +0 -0
  54. package/dist/plugins/MagicTray/src/utils/defaultOptions.d.ts +3 -0
  55. package/dist/plugins/MagicTray/src/utils/defaultOptions.mjs +23 -0
  56. package/dist/utils/index.d.ts +6 -2
  57. package/dist/utils/index.js +24 -0
  58. package/dist/utils/index.js.map +1 -1
  59. package/dist/utils/types/RequireAllNested.ts +5 -1
  60. package/package.json +7 -11
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maas/vue-equipment/nuxt",
3
3
  "configKey": "vueEquipment",
4
- "version": "1.0.0-beta.64",
4
+ "version": "1.0.0-beta.65",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
@@ -106,6 +106,14 @@ const functions$1 = [
106
106
  docs: "https://maas.egineering/vue-equipment/plugins/MagicToast/",
107
107
  description: "MagicToast let’s you trigger and display toasts from anywhere"
108
108
  },
109
+ {
110
+ name: "MagicTray",
111
+ "package": "plugins",
112
+ lastUpdated: 0,
113
+ docs: "https://maas.egineering/vue-equipment/plugins/MagicTray/",
114
+ description: "MagicTray is a flexible",
115
+ soon: true
116
+ },
109
117
  {
110
118
  name: "useCountdown",
111
119
  "package": "composables",
@@ -141,8 +141,8 @@ export function useDraggableSnap(args) {
141
141
  const {
142
142
  x,
143
143
  y,
144
- duration = toValue(animation)?.snap?.duration || 300,
145
- easing = toValue(animation).snap?.easing
144
+ duration = toValue(animation).snap.duration,
145
+ easing = toValue(animation).snap.easing
146
146
  } = args2;
147
147
  const snapPoint = snapPointsMap.value[`x${x}y${y}`];
148
148
  if (!snapPoint) {
@@ -1,3 +1,4 @@
1
+ import type { RequireAllNested } from '@maas/vue-equipment/utils';
1
2
  type Position = 'top-left' | 'top' | 'top-right' | 'left' | 'center' | 'right' | 'bottom-left' | 'bottom' | 'bottom-right';
2
3
  export type Coordinates = {
3
4
  x: number;
@@ -35,7 +36,7 @@ export interface MagicDraggableOptions {
35
36
  }
36
37
  export type RequiredMagicDraggableOptions = Required<MagicDraggableOptions> & {
37
38
  threshold: Required<MagicDraggableOptions['threshold']>;
38
- animation: Required<MagicDraggableOptions['animation']>;
39
+ animation: RequireAllNested<NonNullable<MagicDraggableOptions['animation']>>;
39
40
  };
40
41
  export interface DraggableState {
41
42
  id: string;
@@ -53,6 +53,7 @@ import {
53
53
  toRefs
54
54
  } from "vue";
55
55
  import { unrefElement } from "@vueuse/core";
56
+ import { convertToPixels } from "@maas/vue-equipment/utils";
56
57
  import {
57
58
  useMagicError
58
59
  } from "@maas/vue-equipment/plugins/MagicError";
@@ -166,26 +167,6 @@ watch(
166
167
  }
167
168
  }
168
169
  );
169
- function convertToPixels(value) {
170
- const regex = /^(\d*\.?\d+)\s*(rem|px)$/;
171
- const match = value.match(regex);
172
- if (!match) {
173
- logWarning(
174
- `--magic-drawer-drag-overshoot (${value}) needs to be specified in px or rem`
175
- );
176
- return 0;
177
- }
178
- const numericValue = parseFloat(match[1] ?? "");
179
- const unit = match[2];
180
- const bodyFontSize = window.getComputedStyle(document.body).fontSize;
181
- const rootFontSize = parseFloat(bodyFontSize) || 16;
182
- switch (unit) {
183
- case "rem":
184
- return numericValue * rootFontSize;
185
- case "px":
186
- return numericValue;
187
- }
188
- }
189
170
  function saveOvershoot() {
190
171
  const element = unrefElement(drawerRef);
191
172
  if (!element) {
@@ -194,7 +175,13 @@ function saveOvershoot() {
194
175
  const overshootVar = getComputedStyle(element, null).getPropertyValue(
195
176
  "--magic-drawer-drag-overshoot"
196
177
  );
197
- overshoot.value = convertToPixels(overshootVar) || 0;
178
+ const pixels = convertToPixels(overshootVar);
179
+ if (pixels === void 0) {
180
+ logWarning(
181
+ `--magic-drawer-drag-overshoot (${overshootVar}) needs to be specified in px or rem`
182
+ );
183
+ }
184
+ overshoot.value = pixels ?? 0;
198
185
  }
199
186
  function guardedPointerdown(event) {
200
187
  if (!disabled.value) {
@@ -1,6 +1,6 @@
1
1
  import { type Ref, type MaybeRef } from 'vue';
2
2
  import type { MagicDrawerOptions } from '../../types/index.js';
3
- import type { DrawerActive } from '../../symbols/index.js';
3
+ import type { DrawerActive } from '../../types/index.js';
4
4
  type UseDrawerCallbackArgs = {
5
5
  id: MaybeRef<string>;
6
6
  options: MagicDrawerOptions;
@@ -3,14 +3,7 @@ import { useMetaViewport } from "@maas/vue-equipment/composables/useMetaViewport
3
3
  import { useMagicEmitter } from "@maas/vue-equipment/plugins/MagicEmitter";
4
4
  import { useDrawerDOM } from "./useDrawerDOM.mjs";
5
5
  export function useDrawerCallback(args) {
6
- const {
7
- id,
8
- options,
9
- trapFocus,
10
- releaseFocus,
11
- active,
12
- wasActive
13
- } = args;
6
+ const { id, options, trapFocus, releaseFocus, active, wasActive } = args;
14
7
  const { lockScroll, unlockScroll } = useDrawerDOM();
15
8
  const { setMetaViewport, resetMetaViewport } = useMetaViewport();
16
9
  const emitter = useMagicEmitter();
@@ -227,8 +227,8 @@ export function useDrawerSnap(args) {
227
227
  function interpolateDragged(args2) {
228
228
  const {
229
229
  to,
230
- duration = toValue(animation)?.snap?.duration || 300,
231
- easing
230
+ duration = toValue(animation).snap.duration,
231
+ easing = toValue(animation).snap.easing
232
232
  } = args2;
233
233
  const snapPoint = snapPointsMap.value[to];
234
234
  if (!snapPoint && snapPoint !== 0) {
@@ -1,7 +1,7 @@
1
1
  import { reactive, toValue, onScopeDispose } from "vue";
2
2
  import { createStateStore } from "@maas/vue-equipment/utils";
3
- import { defaultOptions } from "../../utils/defaultOptions.mjs";
4
3
  import { createDefu } from "defu";
4
+ import { defaultOptions } from "../../utils/defaultOptions.mjs";
5
5
  const getDrawerStateStore = createStateStore(
6
6
  "MagicDrawer",
7
7
  () => []
@@ -1,32 +1,13 @@
1
+ import { rubberband } from "@maas/vue-equipment/utils";
1
2
  export function useDrawerUtils() {
2
3
  function clamp(value, from, to, flip) {
3
- if (from > to) {
4
- if (value > from) {
5
- return value;
6
- }
7
- if (value < to) {
8
- return to;
9
- } else {
10
- return value;
11
- }
12
- } else if (from < to) {
13
- if (value < from) {
14
- return value;
15
- }
16
- if (value > to) {
17
- return to;
18
- } else {
19
- return value;
20
- }
4
+ const overshoot = Math.abs(to);
5
+ if (to < from) {
6
+ return value < from ? from - rubberband(from - value, overshoot) : value;
7
+ } else if (to > from) {
8
+ return value > from ? from + rubberband(value - from, overshoot) : value;
21
9
  } else {
22
- switch (flip) {
23
- case true:
24
- return value > to ? to : value;
25
- case false:
26
- return value < to ? to : value;
27
- default:
28
- return value < to ? to : value;
29
- }
10
+ return flip ? Math.min(value, to) : Math.max(value, to);
30
11
  }
31
12
  }
32
13
  return {
@@ -1,7 +1,5 @@
1
1
  import type { InjectionKey, MaybeRef } from 'vue';
2
+ import type { DrawerActive } from '../types/index.js';
2
3
  declare const MagicDrawerInstanceId: InjectionKey<MaybeRef<string>>;
3
- declare const MagicDrawerActiveKey: InjectionKey<{
4
- innerActive: boolean;
5
- wrapperActive: boolean;
6
- }>;
4
+ declare const MagicDrawerActiveKey: InjectionKey<DrawerActive>;
7
5
  export { MagicDrawerInstanceId, MagicDrawerActiveKey };
@@ -1,4 +1,5 @@
1
1
  import { type Options as FocusTrapOptions } from 'focus-trap';
2
+ import type { RequireAllNested } from '@maas/vue-equipment/utils';
2
3
  export type DrawerSnapPoint = number | `${number}px`;
3
4
  export interface MagicDrawerOptions {
4
5
  position?: 'top' | 'right' | 'bottom' | 'left';
@@ -43,7 +44,7 @@ export interface MagicDrawerOptions {
43
44
  export type RequiredMagicDrawerOptions = Required<MagicDrawerOptions> & {
44
45
  scrollLock: Required<MagicDrawerOptions['scrollLock']>;
45
46
  threshold: Required<MagicDrawerOptions['threshold']>;
46
- animation: Required<MagicDrawerOptions['animation']>;
47
+ animation: RequireAllNested<NonNullable<MagicDrawerOptions['animation']>>;
47
48
  keyListener: Required<MagicDrawerOptions['keyListener']>;
48
49
  };
49
50
  export interface DrawerState {
@@ -114,3 +115,7 @@ export type DrawerEvents = {
114
115
  y: number;
115
116
  };
116
117
  };
118
+ export interface DrawerActive {
119
+ innerActive: boolean;
120
+ wrapperActive: boolean;
121
+ }
@@ -1,3 +1,4 @@
1
+ import { easeOutQuad } from "@maas/vue-equipment/utils";
1
2
  const defaultOptions = {
2
3
  position: "bottom",
3
4
  tag: "dialog",
@@ -23,7 +24,8 @@ const defaultOptions = {
23
24
  },
24
25
  animation: {
25
26
  snap: {
26
- duration: 300
27
+ duration: 300,
28
+ easing: easeOutQuad
27
29
  }
28
30
  },
29
31
  initial: {