@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.
- package/dist/nuxt/module.json +1 -1
- package/dist/nuxt/module.mjs +8 -0
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableSnap.mjs +2 -2
- package/dist/plugins/MagicDraggable/src/types/index.d.ts +2 -1
- package/dist/plugins/MagicDrawer/src/components/MagicDrawerContent.vue +8 -21
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerCallback.d.ts +1 -1
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerCallback.mjs +1 -8
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerSnap.mjs +2 -2
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerState.mjs +1 -1
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerUtils.mjs +7 -26
- package/dist/plugins/MagicDrawer/src/symbols/index.d.ts +2 -4
- package/dist/plugins/MagicDrawer/src/types/index.d.ts +6 -1
- package/dist/plugins/MagicDrawer/src/utils/defaultOptions.mjs +3 -1
- package/dist/plugins/MagicEmitter/src/composables/useMagicEmitter.d.ts +552 -6
- package/dist/plugins/MagicEmitter/src/types/index.d.ts +3 -1
- package/dist/plugins/MagicToast/src/composables/private/useToastDrag.mjs +2 -2
- package/dist/plugins/MagicToast/src/types/index.d.ts +2 -5
- package/dist/plugins/MagicToast/src/utils/defaultOptions.mjs +3 -1
- package/dist/plugins/MagicTray/index.d.ts +11 -0
- package/dist/plugins/MagicTray/index.mjs +24 -0
- package/dist/plugins/MagicTray/nuxt.d.ts +2 -0
- package/dist/plugins/MagicTray/nuxt.mjs +23 -0
- package/dist/plugins/MagicTray/src/components/MagicTray.d.vue.ts +25 -0
- package/dist/plugins/MagicTray/src/components/MagicTray.vue +26 -0
- package/dist/plugins/MagicTray/src/components/MagicTray.vue.d.ts +25 -0
- package/dist/plugins/MagicTray/src/components/MagicTrayContent.d.vue.ts +20 -0
- package/dist/plugins/MagicTray/src/components/MagicTrayContent.vue +191 -0
- package/dist/plugins/MagicTray/src/components/MagicTrayContent.vue.d.ts +20 -0
- package/dist/plugins/MagicTray/src/components/MagicTrayHandle.d.vue.ts +19 -0
- package/dist/plugins/MagicTray/src/components/MagicTrayHandle.vue +56 -0
- package/dist/plugins/MagicTray/src/components/MagicTrayHandle.vue.d.ts +19 -0
- package/dist/plugins/MagicTray/src/components/MagicTrayProvider.d.vue.ts +19 -0
- package/dist/plugins/MagicTray/src/components/MagicTrayProvider.vue +23 -0
- package/dist/plugins/MagicTray/src/components/MagicTrayProvider.vue.d.ts +19 -0
- package/dist/plugins/MagicTray/src/components/MagicTrayTransform.d.vue.ts +19 -0
- package/dist/plugins/MagicTray/src/components/MagicTrayTransform.vue +52 -0
- package/dist/plugins/MagicTray/src/components/MagicTrayTransform.vue.d.ts +19 -0
- package/dist/plugins/MagicTray/src/composables/private/useTrayDrag.d.ts +36 -0
- package/dist/plugins/MagicTray/src/composables/private/useTrayDrag.mjs +456 -0
- package/dist/plugins/MagicTray/src/composables/private/useTrayProgress.d.ts +8 -0
- package/dist/plugins/MagicTray/src/composables/private/useTrayProgress.mjs +25 -0
- package/dist/plugins/MagicTray/src/composables/private/useTraySnap.d.ts +36 -0
- package/dist/plugins/MagicTray/src/composables/private/useTraySnap.mjs +156 -0
- package/dist/plugins/MagicTray/src/composables/private/useTrayState.d.ts +6 -0
- package/dist/plugins/MagicTray/src/composables/private/useTrayState.mjs +94 -0
- package/dist/plugins/MagicTray/src/composables/private/useTrayUtils.d.ts +6 -0
- package/dist/plugins/MagicTray/src/composables/private/useTrayUtils.mjs +32 -0
- package/dist/plugins/MagicTray/src/composables/useMagicTray.d.ts +9 -0
- package/dist/plugins/MagicTray/src/composables/useMagicTray.mjs +23 -0
- package/dist/plugins/MagicTray/src/symbols/index.d.ts +3 -0
- package/dist/plugins/MagicTray/src/symbols/index.mjs +2 -0
- package/dist/plugins/MagicTray/src/types/index.d.ts +91 -0
- package/dist/plugins/MagicTray/src/types/index.mjs +0 -0
- package/dist/plugins/MagicTray/src/utils/defaultOptions.d.ts +3 -0
- package/dist/plugins/MagicTray/src/utils/defaultOptions.mjs +23 -0
- package/dist/utils/index.d.ts +6 -2
- package/dist/utils/index.js +24 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/types/RequireAllNested.ts +5 -1
- package/package.json +7 -11
package/dist/nuxt/module.json
CHANGED
package/dist/nuxt/module.mjs
CHANGED
|
@@ -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)
|
|
145
|
-
easing = toValue(animation).snap
|
|
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:
|
|
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
|
-
|
|
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 '../../
|
|
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)
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
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:
|
|
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: {
|