@maas/vue-equipment 1.0.0-beta.7 → 1.0.0-beta.9
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 +7 -0
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionTrigger.vue +11 -8
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionTrigger.vue.d.ts +3 -0
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionView.vue +2 -1
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionView.vue.d.ts +2 -0
- package/dist/plugins/MagicCommand/src/components/MagicCommandProvider.vue +2 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandTrigger.vue +3 -1
- package/dist/plugins/MagicDraggable/src/components/MagicDraggable.vue.d.ts +1 -1
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableDrag.mjs +1 -1
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableScrollLock.mjs +32 -12
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableSnap.d.ts +3 -3
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableState.mjs +4 -4
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue.d.ts +12 -12
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDOM.mjs +32 -12
- package/dist/plugins/MagicEmitter/src/composables/useMagicEmitter.d.ts +36 -36
- package/dist/plugins/MagicMenu/src/components/MagicMenuRemote.vue +1 -1
- package/dist/plugins/MagicMenu/src/composables/private/useMenuCallback.mjs +1 -1
- package/dist/plugins/MagicMenu/src/composables/private/useMenuDOM.mjs +33 -13
- package/dist/plugins/MagicModal/src/components/MagicModal.vue.d.ts +6 -6
- package/dist/plugins/MagicModal/src/composables/private/useModalDOM.mjs +32 -12
- package/dist/plugins/MagicPie/index.d.ts +7 -0
- package/dist/plugins/MagicPie/index.mjs +8 -0
- package/dist/plugins/MagicPie/nuxt.d.ts +2 -0
- package/dist/plugins/MagicPie/nuxt.mjs +23 -0
- package/dist/plugins/MagicPie/src/components/MagicPie.vue +202 -0
- package/dist/plugins/MagicPie/src/components/MagicPie.vue.d.ts +7 -0
- package/dist/plugins/MagicPie/src/composables/private/usePieState.d.ts +6 -0
- package/dist/plugins/MagicPie/src/composables/private/usePieState.mjs +33 -0
- package/dist/plugins/MagicPie/src/composables/useMagicPie.d.ts +13 -0
- package/dist/plugins/MagicPie/src/composables/useMagicPie.mjs +43 -0
- package/dist/plugins/MagicPie/src/types/index.d.ts +9 -0
- package/dist/plugins/MagicPie/src/types/index.mjs +0 -0
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudioControls.vue +9 -9
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudioControls.vue.d.ts +1 -1
- package/dist/plugins/MagicToast/src/composables/private/useToastDrag.mjs +1 -1
- package/dist/plugins/MagicToast/src/composables/private/useToastScrollLock.mjs +31 -13
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.mjs +1 -0
- package/dist/utils/index.d.ts +7 -2
- package/dist/utils/index.js +39 -3
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { ref, shallowRef } from "vue";
|
|
2
2
|
import { useScrollLock } from "@vueuse/core";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
matchClass,
|
|
5
|
+
scrollbarGutterSupport,
|
|
6
|
+
scrollbarWidth
|
|
7
|
+
} from "@maas/vue-equipment/utils";
|
|
4
8
|
const scrollLock = typeof window !== "undefined" ? useScrollLock(document?.documentElement) : shallowRef(false);
|
|
5
9
|
export function useMenuDOM() {
|
|
6
10
|
const positionFixedElements = ref([]);
|
|
@@ -12,25 +16,41 @@ export function useMenuDOM() {
|
|
|
12
16
|
}
|
|
13
17
|
function addScrollLockPadding() {
|
|
14
18
|
if (typeof window === "undefined") return;
|
|
15
|
-
const exclude = new RegExp(/magic-menu
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
const exclude = new RegExp(/magic-menu/);
|
|
20
|
+
document.body.style.setProperty(
|
|
21
|
+
"--scrollbar-width",
|
|
22
|
+
`${scrollbarWidth()}px`
|
|
23
|
+
);
|
|
19
24
|
positionFixedElements.value = [
|
|
20
25
|
...document.body.getElementsByTagName("*")
|
|
21
26
|
].filter(
|
|
22
|
-
(x) => getComputedStyle(x, null).getPropertyValue("position") === "fixed" && !matchClass(x, exclude)
|
|
23
|
-
);
|
|
24
|
-
positionFixedElements.value.forEach(
|
|
25
|
-
(elem) => elem.style.paddingRight = "var(--scrollbar-width)"
|
|
27
|
+
(x) => getComputedStyle(x, null).getPropertyValue("position") === "fixed" && getComputedStyle(x, null).getPropertyValue("right") === "0px" && !matchClass(x, exclude)
|
|
26
28
|
);
|
|
29
|
+
switch (scrollbarGutterSupport()) {
|
|
30
|
+
case true:
|
|
31
|
+
document.documentElement.style.scrollbarGutter = "stable";
|
|
32
|
+
positionFixedElements.value.forEach((elem) => {
|
|
33
|
+
elem.style.scrollbarGutter = "stable";
|
|
34
|
+
elem.style.overflow = "auto";
|
|
35
|
+
});
|
|
36
|
+
break;
|
|
37
|
+
case false:
|
|
38
|
+
document.body.style.paddingRight = "var(--scrollbar-width)";
|
|
39
|
+
positionFixedElements.value.forEach(
|
|
40
|
+
(elem) => elem.style.paddingRight = "var(--scrollbar-width)"
|
|
41
|
+
);
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
27
44
|
}
|
|
28
45
|
function removeScrollLockPadding() {
|
|
29
|
-
document.
|
|
46
|
+
document.documentElement.style.scrollbarGutter = "";
|
|
30
47
|
document.body.style.removeProperty("--scrollbar-width");
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
48
|
+
document.body.style.paddingRight = "";
|
|
49
|
+
positionFixedElements.value.forEach((elem) => {
|
|
50
|
+
elem.style.paddingRight = "";
|
|
51
|
+
elem.style.scrollbarGutter = "";
|
|
52
|
+
elem.style.overflow = "";
|
|
53
|
+
});
|
|
34
54
|
}
|
|
35
55
|
return {
|
|
36
56
|
lockScroll,
|
|
@@ -12,19 +12,19 @@ declare const mappedOptions: Omit<MagicModalOptions, keyof MagicModalOptions> &
|
|
|
12
12
|
content?: string;
|
|
13
13
|
backdrop?: string;
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
tag: "dialog" | "div";
|
|
17
|
-
focusTrap: boolean | import("focus-trap").Options;
|
|
15
|
+
tag: "div" | "dialog";
|
|
18
16
|
scrollLock: boolean | {
|
|
19
17
|
padding: boolean;
|
|
20
18
|
};
|
|
19
|
+
keyListener: {
|
|
20
|
+
close?: string[] | false;
|
|
21
|
+
};
|
|
22
|
+
backdrop: boolean;
|
|
23
|
+
focusTrap: boolean | import("focus-trap").Options;
|
|
21
24
|
teleport: {
|
|
22
25
|
target?: string;
|
|
23
26
|
disabled?: boolean;
|
|
24
27
|
};
|
|
25
|
-
keyListener: {
|
|
26
|
-
close?: string[] | false;
|
|
27
|
-
};
|
|
28
28
|
};
|
|
29
29
|
declare const close: () => void;
|
|
30
30
|
declare const innerActive: import("vue").ShallowRef<boolean, boolean>;
|
|
@@ -2,7 +2,11 @@ import { ref, shallowRef } from "vue";
|
|
|
2
2
|
import { defu } from "defu";
|
|
3
3
|
import { useScrollLock } from "@vueuse/core";
|
|
4
4
|
import { useFocusTrap } from "@vueuse/integrations/useFocusTrap";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
matchClass,
|
|
7
|
+
scrollbarGutterSupport,
|
|
8
|
+
scrollbarWidth
|
|
9
|
+
} from "@maas/vue-equipment/utils";
|
|
6
10
|
const defaultOptions = {
|
|
7
11
|
focusTrap: false,
|
|
8
12
|
focusTarget: void 0,
|
|
@@ -36,24 +40,40 @@ export function useModalDOM(args) {
|
|
|
36
40
|
function addScrollLockPadding() {
|
|
37
41
|
if (typeof window === "undefined") return;
|
|
38
42
|
const exclude = new RegExp(/magic-modal(__backdrop)?/);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
document.body.style.setProperty(
|
|
44
|
+
"--scrollbar-width",
|
|
45
|
+
`${scrollbarWidth()}px`
|
|
46
|
+
);
|
|
42
47
|
positionFixedElements.value = [
|
|
43
48
|
...document.body.getElementsByTagName("*")
|
|
44
49
|
].filter(
|
|
45
|
-
(x) => getComputedStyle(x, null).getPropertyValue("position") === "fixed" && !matchClass(x, exclude)
|
|
46
|
-
);
|
|
47
|
-
positionFixedElements.value.forEach(
|
|
48
|
-
(elem) => elem.style.paddingRight = "var(--scrollbar-width)"
|
|
50
|
+
(x) => getComputedStyle(x, null).getPropertyValue("position") === "fixed" && getComputedStyle(x, null).getPropertyValue("right") === "0px" && !matchClass(x, exclude)
|
|
49
51
|
);
|
|
52
|
+
switch (scrollbarGutterSupport()) {
|
|
53
|
+
case true:
|
|
54
|
+
document.documentElement.style.scrollbarGutter = "stable";
|
|
55
|
+
positionFixedElements.value.forEach((elem) => {
|
|
56
|
+
elem.style.scrollbarGutter = "stable";
|
|
57
|
+
elem.style.overflow = "auto";
|
|
58
|
+
});
|
|
59
|
+
break;
|
|
60
|
+
case false:
|
|
61
|
+
document.body.style.paddingRight = "var(--scrollbar-width)";
|
|
62
|
+
positionFixedElements.value.forEach(
|
|
63
|
+
(elem) => elem.style.paddingRight = "var(--scrollbar-width)"
|
|
64
|
+
);
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
50
67
|
}
|
|
51
68
|
function removeScrollLockPadding() {
|
|
52
|
-
document.
|
|
69
|
+
document.documentElement.style.scrollbarGutter = "";
|
|
53
70
|
document.body.style.removeProperty("--scrollbar-width");
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
71
|
+
document.body.style.paddingRight = "";
|
|
72
|
+
positionFixedElements.value.forEach((elem) => {
|
|
73
|
+
elem.style.paddingRight = "";
|
|
74
|
+
elem.style.scrollbarGutter = "";
|
|
75
|
+
elem.style.overflow = "";
|
|
76
|
+
});
|
|
57
77
|
}
|
|
58
78
|
return {
|
|
59
79
|
trapFocus,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import MagicPie from './src/components/MagicPie.vue.js';
|
|
2
|
+
import { useMagicPie } from './src/composables/useMagicPie.js';
|
|
3
|
+
import type { Plugin } from 'vue';
|
|
4
|
+
import type { MagicPieOptions } from './src/types/index.js';
|
|
5
|
+
declare const MagicPiePlugin: Plugin;
|
|
6
|
+
export { MagicPiePlugin, MagicPie, useMagicPie };
|
|
7
|
+
export type { MagicPieOptions };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import MagicPie from "./src/components/MagicPie.vue";
|
|
2
|
+
import { useMagicPie } from "./src/composables/useMagicPie.mjs";
|
|
3
|
+
const MagicPiePlugin = {
|
|
4
|
+
install: (app) => {
|
|
5
|
+
app.component("MagicPie", MagicPie);
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
export { MagicPiePlugin, MagicPie, useMagicPie };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineNuxtModule,
|
|
3
|
+
createResolver,
|
|
4
|
+
addComponent,
|
|
5
|
+
addImports
|
|
6
|
+
} from "@nuxt/kit";
|
|
7
|
+
export default defineNuxtModule({
|
|
8
|
+
meta: {
|
|
9
|
+
name: "@maas/vue-equipment/nuxt/MagicPie"
|
|
10
|
+
},
|
|
11
|
+
setup() {
|
|
12
|
+
const resolver = createResolver(import.meta.url);
|
|
13
|
+
addComponent({
|
|
14
|
+
filePath: resolver.resolve("src/components/MagicPie.vue"),
|
|
15
|
+
name: "MagicPie",
|
|
16
|
+
global: true
|
|
17
|
+
});
|
|
18
|
+
addImports({
|
|
19
|
+
from: "@maas/vue-equipment/plugins/MagicPie",
|
|
20
|
+
name: "useMagicPie"
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
});
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { defineComponent as _defineComponent } from "vue";
|
|
3
|
+
import { createElementVNode as _createElementVNode, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue";
|
|
4
|
+
const _hoisted_1 = ["data-flip", "data-id"];
|
|
5
|
+
const _hoisted_2 = {
|
|
6
|
+
id: "magic-pie__svg",
|
|
7
|
+
viewBox: "0 0 100 100",
|
|
8
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
9
|
+
};
|
|
10
|
+
const _hoisted_3 = { mask: "url(#magic-pie__mask)" };
|
|
11
|
+
const _hoisted_4 = ["d"];
|
|
12
|
+
import { computed, toRefs, onBeforeUnmount } from "vue";
|
|
13
|
+
import { usePieState } from "../composables/private/usePieState";
|
|
14
|
+
export default /* @__PURE__ */ _defineComponent({
|
|
15
|
+
__name: "MagicPie",
|
|
16
|
+
props: {
|
|
17
|
+
id: { type: String, required: true },
|
|
18
|
+
options: { type: Object, required: false }
|
|
19
|
+
},
|
|
20
|
+
setup(__props) {
|
|
21
|
+
const { initializeState, deleteState } = usePieState(__props.id);
|
|
22
|
+
const state = initializeState();
|
|
23
|
+
const { percentage } = toRefs(state);
|
|
24
|
+
function generatePath(points) {
|
|
25
|
+
if (points.length < 2) {
|
|
26
|
+
throw new Error("At least two points are required to generate a path.");
|
|
27
|
+
}
|
|
28
|
+
let path2 = `M ${points[0][0]} ${points[0][1]}`;
|
|
29
|
+
for (let i = 1; i < points.length; i++) {
|
|
30
|
+
path2 += ` L ${points[i][0]} ${points[i][1]}`;
|
|
31
|
+
}
|
|
32
|
+
return path2;
|
|
33
|
+
}
|
|
34
|
+
function generatePie(percentage2, flip) {
|
|
35
|
+
if (percentage2 < 0 || percentage2 > 100) {
|
|
36
|
+
throw new Error("percentage needs to be between 0 and 100");
|
|
37
|
+
}
|
|
38
|
+
const size = 100;
|
|
39
|
+
const points = [
|
|
40
|
+
[size / 2, size / 2],
|
|
41
|
+
[size / 2, 0]
|
|
42
|
+
];
|
|
43
|
+
function getEndpoint(percentage3, size2) {
|
|
44
|
+
const circumference = size2 * 4;
|
|
45
|
+
const distance = percentage3 / 100 * circumference;
|
|
46
|
+
if (distance === 0) {
|
|
47
|
+
return [size2 / 2, 0];
|
|
48
|
+
}
|
|
49
|
+
const position = Math.floor(distance / (size2 / 2)) % 8;
|
|
50
|
+
const remainingDistance = distance % (size2 / 2);
|
|
51
|
+
let x = 0;
|
|
52
|
+
let y = 0;
|
|
53
|
+
switch (position) {
|
|
54
|
+
case 0:
|
|
55
|
+
x = size2 / 2 + remainingDistance;
|
|
56
|
+
y = 0;
|
|
57
|
+
break;
|
|
58
|
+
case 1:
|
|
59
|
+
x = size2;
|
|
60
|
+
y = remainingDistance;
|
|
61
|
+
break;
|
|
62
|
+
case 2:
|
|
63
|
+
x = size2;
|
|
64
|
+
y = size2 / 2 + remainingDistance;
|
|
65
|
+
break;
|
|
66
|
+
case 3:
|
|
67
|
+
x = size2 - remainingDistance;
|
|
68
|
+
y = size2;
|
|
69
|
+
break;
|
|
70
|
+
case 4:
|
|
71
|
+
x = size2 / 2 - remainingDistance;
|
|
72
|
+
y = size2;
|
|
73
|
+
break;
|
|
74
|
+
case 5:
|
|
75
|
+
x = 0;
|
|
76
|
+
y = size2 - remainingDistance;
|
|
77
|
+
break;
|
|
78
|
+
case 6:
|
|
79
|
+
x = 0;
|
|
80
|
+
y = size2 / 2 - remainingDistance;
|
|
81
|
+
break;
|
|
82
|
+
case 7:
|
|
83
|
+
x = remainingDistance;
|
|
84
|
+
y = 0;
|
|
85
|
+
}
|
|
86
|
+
return [x, y];
|
|
87
|
+
}
|
|
88
|
+
if (flip) {
|
|
89
|
+
if (100 - percentage2 >= 12.5) {
|
|
90
|
+
points.push([0, 0]);
|
|
91
|
+
}
|
|
92
|
+
if (100 - percentage2 >= 25) {
|
|
93
|
+
points.push([0, size / 2]);
|
|
94
|
+
}
|
|
95
|
+
if (100 - percentage2 >= 37.5) {
|
|
96
|
+
points.push([0, size]);
|
|
97
|
+
}
|
|
98
|
+
if (100 - percentage2 >= 50) {
|
|
99
|
+
points.push([size / 2, size]);
|
|
100
|
+
}
|
|
101
|
+
if (100 - percentage2 >= 62.5) {
|
|
102
|
+
points.push([size, size]);
|
|
103
|
+
}
|
|
104
|
+
if (100 - percentage2 >= 75) {
|
|
105
|
+
points.push([size, size / 2]);
|
|
106
|
+
}
|
|
107
|
+
if (100 - percentage2 >= 87.5) {
|
|
108
|
+
points.push([size, 0]);
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
if (percentage2 >= 12.5) {
|
|
112
|
+
points.push([size, 0]);
|
|
113
|
+
}
|
|
114
|
+
if (percentage2 >= 25) {
|
|
115
|
+
points.push([size, size / 2]);
|
|
116
|
+
}
|
|
117
|
+
if (percentage2 >= 37.5) {
|
|
118
|
+
points.push([size, size]);
|
|
119
|
+
}
|
|
120
|
+
if (percentage2 >= 50) {
|
|
121
|
+
points.push([size / 2, size]);
|
|
122
|
+
}
|
|
123
|
+
if (percentage2 >= 62.5) {
|
|
124
|
+
points.push([0, size]);
|
|
125
|
+
}
|
|
126
|
+
if (percentage2 >= 75) {
|
|
127
|
+
points.push([0, size / 2]);
|
|
128
|
+
}
|
|
129
|
+
if (percentage2 >= 87.5) {
|
|
130
|
+
points.push([0, 0]);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
points.push(getEndpoint(percentage2, size));
|
|
134
|
+
return generatePath(points);
|
|
135
|
+
}
|
|
136
|
+
const path = computed(() => {
|
|
137
|
+
return generatePie(percentage.value, __props.options?.flip);
|
|
138
|
+
});
|
|
139
|
+
onBeforeUnmount(() => {
|
|
140
|
+
deleteState();
|
|
141
|
+
});
|
|
142
|
+
return (_ctx, _cache) => {
|
|
143
|
+
return _openBlock(), _createElementBlock("div", {
|
|
144
|
+
class: "magic-pie",
|
|
145
|
+
"data-flip": _ctx.options?.flip,
|
|
146
|
+
"data-id": _ctx.id
|
|
147
|
+
}, [
|
|
148
|
+
(_openBlock(), _createElementBlock("svg", _hoisted_2, [
|
|
149
|
+
_cache[1] || (_cache[1] = _createElementVNode(
|
|
150
|
+
"mask",
|
|
151
|
+
{ id: "magic-pie__mask" },
|
|
152
|
+
[
|
|
153
|
+
_createElementVNode("circle", {
|
|
154
|
+
cx: "50",
|
|
155
|
+
cy: "50",
|
|
156
|
+
r: "50",
|
|
157
|
+
fill: "white"
|
|
158
|
+
})
|
|
159
|
+
],
|
|
160
|
+
-1
|
|
161
|
+
/* HOISTED */
|
|
162
|
+
)),
|
|
163
|
+
_createElementVNode("g", _hoisted_3, [
|
|
164
|
+
_cache[0] || (_cache[0] = _createElementVNode(
|
|
165
|
+
"rect",
|
|
166
|
+
{
|
|
167
|
+
width: "100",
|
|
168
|
+
height: "100"
|
|
169
|
+
},
|
|
170
|
+
null,
|
|
171
|
+
-1
|
|
172
|
+
/* HOISTED */
|
|
173
|
+
)),
|
|
174
|
+
_createElementVNode("path", { d: path.value }, null, 8, _hoisted_4)
|
|
175
|
+
])
|
|
176
|
+
]))
|
|
177
|
+
], 8, _hoisted_1);
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
</script>
|
|
182
|
+
|
|
183
|
+
<style>
|
|
184
|
+
.magic-pie {
|
|
185
|
+
position: relative;
|
|
186
|
+
|
|
187
|
+
& path {
|
|
188
|
+
fill: var(--magic-pie-foreground, currentColor);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
& rect {
|
|
192
|
+
fill: var(--magic-pie-background, transparent);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
#magic-pie__svg {
|
|
197
|
+
width: 100%;
|
|
198
|
+
height: 100%;
|
|
199
|
+
margin-left: auto;
|
|
200
|
+
margin-right: auto;
|
|
201
|
+
}
|
|
202
|
+
</style>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { MagicPieOptions } from '../types/index.js';
|
|
2
|
+
interface MagicPieProps {
|
|
3
|
+
id: string;
|
|
4
|
+
options?: MagicPieOptions;
|
|
5
|
+
}
|
|
6
|
+
declare const _default: import("vue").DefineComponent<MagicPieProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<MagicPieProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ref, reactive, toValue } from "vue";
|
|
2
|
+
const pieStateStore = ref([]);
|
|
3
|
+
export function usePieState(id) {
|
|
4
|
+
function createState(id2) {
|
|
5
|
+
const state = {
|
|
6
|
+
id: id2,
|
|
7
|
+
percentage: 0,
|
|
8
|
+
animation: void 0
|
|
9
|
+
};
|
|
10
|
+
return reactive(state);
|
|
11
|
+
}
|
|
12
|
+
function addState(id2) {
|
|
13
|
+
const state = createState(id2);
|
|
14
|
+
pieStateStore.value = [...pieStateStore.value, state];
|
|
15
|
+
return state;
|
|
16
|
+
}
|
|
17
|
+
function initializeState() {
|
|
18
|
+
let state = pieStateStore.value.find((entry) => {
|
|
19
|
+
return entry.id === id;
|
|
20
|
+
});
|
|
21
|
+
if (!state) state = addState(toValue(id));
|
|
22
|
+
return state;
|
|
23
|
+
}
|
|
24
|
+
function deleteState() {
|
|
25
|
+
pieStateStore.value = pieStateStore.value.filter(
|
|
26
|
+
(x) => x.id !== id
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
initializeState,
|
|
31
|
+
deleteState
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type MaybeRef } from 'vue';
|
|
2
|
+
interface InterpolatePercentageArgs {
|
|
3
|
+
value: number;
|
|
4
|
+
duration: number;
|
|
5
|
+
easing?: (t: number) => number;
|
|
6
|
+
}
|
|
7
|
+
export declare function useMagicPie(id: MaybeRef<string>): {
|
|
8
|
+
percentage: import("vue").Ref<number, number>;
|
|
9
|
+
setPercentage: (value: number) => void;
|
|
10
|
+
interpolatePercentage: (args: InterpolatePercentageArgs) => void;
|
|
11
|
+
cancelInterpolatePercentage: () => void;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { toValue, toRefs } from "vue";
|
|
2
|
+
import { interpolate, linear } from "@maas/vue-equipment/utils";
|
|
3
|
+
import { usePieState } from "./private/usePieState.mjs";
|
|
4
|
+
export function useMagicPie(id) {
|
|
5
|
+
const { initializeState } = usePieState(toValue(id));
|
|
6
|
+
const state = initializeState();
|
|
7
|
+
const { percentage, animation } = toRefs(state);
|
|
8
|
+
function setPercentage(value) {
|
|
9
|
+
percentage.value = Math.min(Math.max(0, value), 100);
|
|
10
|
+
}
|
|
11
|
+
function interpolatePercentage(args) {
|
|
12
|
+
const { value, duration = 1e3, easing = linear } = args;
|
|
13
|
+
const mappedValue = Math.min(Math.max(0, value), 100);
|
|
14
|
+
if (animation.value) {
|
|
15
|
+
cancelAnimationFrame(animation.value);
|
|
16
|
+
}
|
|
17
|
+
const mappedDuration = duration - duration * percentage.value / 100;
|
|
18
|
+
animation.value = interpolate({
|
|
19
|
+
from: percentage.value,
|
|
20
|
+
to: mappedValue,
|
|
21
|
+
duration: mappedDuration,
|
|
22
|
+
easing,
|
|
23
|
+
callback: (value2) => {
|
|
24
|
+
percentage.value = value2;
|
|
25
|
+
},
|
|
26
|
+
animationIdCallback: (id2) => {
|
|
27
|
+
animation.value = id2;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function cancelInterpolatePercentage() {
|
|
32
|
+
if (animation.value) {
|
|
33
|
+
cancelAnimationFrame(animation.value);
|
|
34
|
+
animation.value = void 0;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
percentage,
|
|
39
|
+
setPercentage,
|
|
40
|
+
interpolatePercentage,
|
|
41
|
+
cancelInterpolatePercentage
|
|
42
|
+
};
|
|
43
|
+
}
|
|
File without changes
|
|
@@ -38,31 +38,31 @@ import { MagicPlayerInstanceId } from "../symbols";
|
|
|
38
38
|
export default /* @__PURE__ */ _defineComponent({
|
|
39
39
|
__name: "MagicPlayerAudioControls",
|
|
40
40
|
props: {
|
|
41
|
-
|
|
41
|
+
instanceId: { type: String, required: false }
|
|
42
42
|
},
|
|
43
43
|
setup(__props) {
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
if (!
|
|
44
|
+
const injectedInstanceId = inject(MagicPlayerInstanceId, void 0);
|
|
45
|
+
const mappedInstanceId = computed(() => __props.instanceId ?? injectedInstanceId);
|
|
46
|
+
if (!mappedInstanceId.value) {
|
|
47
47
|
throw new Error(
|
|
48
|
-
"MagicAudioPlayerControls must be nested inside MagicAudioPlayer or
|
|
48
|
+
"MagicAudioPlayerControls must be nested inside MagicAudioPlayer or an instanceId must be provided."
|
|
49
49
|
);
|
|
50
50
|
}
|
|
51
51
|
const barRef = useTemplateRef("bar");
|
|
52
52
|
const trackRef = useTemplateRef("track");
|
|
53
53
|
const { playing, waiting } = usePlayerMediaApi({
|
|
54
|
-
id:
|
|
54
|
+
id: mappedInstanceId.value
|
|
55
55
|
});
|
|
56
56
|
const { play, pause, touched, mouseEntered } = usePlayerAudioApi({
|
|
57
|
-
id:
|
|
57
|
+
id: mappedInstanceId.value
|
|
58
58
|
});
|
|
59
59
|
usePlayerControlsApi({
|
|
60
|
-
id:
|
|
60
|
+
id: mappedInstanceId.value,
|
|
61
61
|
barRef,
|
|
62
62
|
trackRef
|
|
63
63
|
});
|
|
64
64
|
const { idle } = useIdle(3e3);
|
|
65
|
-
provide(MagicPlayerInstanceId,
|
|
65
|
+
provide(MagicPlayerInstanceId, mappedInstanceId.value);
|
|
66
66
|
return (_ctx, _cache) => {
|
|
67
67
|
const _component_magic_player_display_time = _resolveComponent("magic-player-display-time");
|
|
68
68
|
const _component_magic_player_timeline = _resolveComponent("magic-player-timeline");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import IconPlay from './icons/Play.vue.js';
|
|
2
2
|
import IconPause from './icons/Pause.vue.js';
|
|
3
3
|
interface MagicAudioPlayerControlsProps {
|
|
4
|
-
|
|
4
|
+
instanceId?: string;
|
|
5
5
|
}
|
|
6
6
|
declare const playing: import("vue").ShallowRef<boolean, boolean>, waiting: import("vue").ShallowRef<boolean, boolean>;
|
|
7
7
|
declare const play: () => void, pause: () => void, touched: import("vue").ShallowRef<boolean, boolean>, mouseEntered: import("vue").ShallowRef<boolean, boolean>;
|
|
@@ -257,10 +257,10 @@ export function useToastDrag(args) {
|
|
|
257
257
|
function onPointerdown(e) {
|
|
258
258
|
const scrollLockValue = toValue(scrollLock);
|
|
259
259
|
if (scrollLockValue) {
|
|
260
|
-
lockScroll();
|
|
261
260
|
if (typeof scrollLockValue === "object" && scrollLockValue.padding) {
|
|
262
261
|
addScrollLockPadding();
|
|
263
262
|
}
|
|
263
|
+
lockScroll();
|
|
264
264
|
}
|
|
265
265
|
if (dragging.value) {
|
|
266
266
|
return;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { ref, shallowRef } from "vue";
|
|
2
2
|
import { useScrollLock } from "@vueuse/core";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
scrollbarGutterSupport,
|
|
5
|
+
scrollbarWidth
|
|
6
|
+
} from "@maas/vue-equipment/utils";
|
|
4
7
|
const scrollLock = typeof window !== "undefined" ? useScrollLock(document?.documentElement) : shallowRef(false);
|
|
5
8
|
export function useToastScrollLock() {
|
|
6
9
|
const positionFixedElements = ref([]);
|
|
@@ -12,25 +15,40 @@ export function useToastScrollLock() {
|
|
|
12
15
|
}
|
|
13
16
|
function addScrollLockPadding() {
|
|
14
17
|
if (typeof window === "undefined") return;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
document.body.style.setProperty(
|
|
19
|
+
"--scrollbar-width",
|
|
20
|
+
`${scrollbarWidth()}px`
|
|
21
|
+
);
|
|
19
22
|
positionFixedElements.value = [
|
|
20
23
|
...document.body.getElementsByTagName("*")
|
|
21
24
|
].filter(
|
|
22
|
-
(x) => getComputedStyle(x, null).getPropertyValue("position") === "fixed" &&
|
|
23
|
-
);
|
|
24
|
-
positionFixedElements.value.forEach(
|
|
25
|
-
(elem) => elem.style.paddingRight = "var(--scrollbar-width)"
|
|
25
|
+
(x) => getComputedStyle(x, null).getPropertyValue("position") === "fixed" && getComputedStyle(x, null).getPropertyValue("right") === "0px"
|
|
26
26
|
);
|
|
27
|
+
switch (scrollbarGutterSupport()) {
|
|
28
|
+
case true:
|
|
29
|
+
document.documentElement.style.scrollbarGutter = "stable";
|
|
30
|
+
positionFixedElements.value.forEach((elem) => {
|
|
31
|
+
elem.style.scrollbarGutter = "stable";
|
|
32
|
+
elem.style.overflow = "auto";
|
|
33
|
+
});
|
|
34
|
+
break;
|
|
35
|
+
case false:
|
|
36
|
+
document.body.style.paddingRight = "var(--scrollbar-width)";
|
|
37
|
+
positionFixedElements.value.forEach(
|
|
38
|
+
(elem) => elem.style.paddingRight = "var(--scrollbar-width)"
|
|
39
|
+
);
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
27
42
|
}
|
|
28
43
|
function removeScrollLockPadding() {
|
|
29
|
-
document.
|
|
44
|
+
document.documentElement.style.scrollbarGutter = "";
|
|
30
45
|
document.body.style.removeProperty("--scrollbar-width");
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
46
|
+
document.body.style.paddingRight = "";
|
|
47
|
+
positionFixedElements.value.forEach((elem) => {
|
|
48
|
+
elem.style.paddingRight = "";
|
|
49
|
+
elem.style.scrollbarGutter = "";
|
|
50
|
+
elem.style.overflow = "";
|
|
51
|
+
});
|
|
34
52
|
}
|
|
35
53
|
return {
|
|
36
54
|
lockScroll,
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export * from './MagicMarquee/index.js';
|
|
|
8
8
|
export * from './MagicMenu/index.js';
|
|
9
9
|
export * from './MagicModal/index.js';
|
|
10
10
|
export * from './MagicNoise/index.js';
|
|
11
|
+
export * from './MagicPie/index.js';
|
|
11
12
|
export * from './MagicPlayer/index.js';
|
|
12
13
|
export * from './MagicScroll/index.js';
|
|
13
14
|
export * from './MagicToast/index.js';
|