@maas/vue-equipment 1.0.0-beta.8 → 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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maas/vue-equipment/nuxt",
3
3
  "configKey": "vueEquipment",
4
- "version": "1.0.0-beta.7",
4
+ "version": "1.0.0-beta.8",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.4",
7
7
  "unbuild": "unknown"
@@ -71,6 +71,13 @@ const functions$1 = [
71
71
  docs: "https://maas.egineering/vue-equipment/plugins/MagicNoise/",
72
72
  description: "magicNoise is a rendition of pixelated static noise"
73
73
  },
74
+ {
75
+ name: "MagicPie",
76
+ "package": "plugins",
77
+ lastUpdated: 0,
78
+ docs: "https://maas.egineering/vue-equipment/plugins/MagicPie/",
79
+ description: "magicPie renders a percentage based value as `SVG`"
80
+ },
74
81
  {
75
82
  name: "MagicPlayer",
76
83
  "package": "plugins",
@@ -22,13 +22,13 @@ type SnapToArgs = {
22
22
  };
23
23
  export declare function useDraggableSnap(args: UseDraggableSnapArgs): {
24
24
  mappedSnapPoints: import("@vueuse/core").ComputedRefWithControl<Coordinates[]>;
25
- activeSnapPoint: Ref<("center" | "right" | "left" | "top" | "bottom" | "top-left" | "top-right" | "bottom-left" | "bottom-right") | ["center" | "right" | "left" | "top" | "bottom" | "top-left" | "top-right" | "bottom-left" | "bottom-right", offset?: {
25
+ activeSnapPoint: Ref<("top-left" | "top" | "top-right" | "left" | "center" | "right" | "bottom-left" | "bottom" | "bottom-right") | ["top-left" | "top" | "top-right" | "left" | "center" | "right" | "bottom-left" | "bottom" | "bottom-right", offset?: {
26
26
  x?: number | undefined;
27
27
  y?: number | undefined;
28
- } | undefined] | undefined, "center" | "right" | "left" | "top" | "bottom" | "top-left" | "top-right" | "bottom-left" | "bottom-right" | ["center" | "right" | "left" | "top" | "bottom" | "top-left" | "top-right" | "bottom-left" | "bottom-right", offset?: {
28
+ } | undefined] | undefined, "top-left" | "top" | "top-right" | "left" | "center" | "right" | "bottom-left" | "bottom" | "bottom-right" | ["top-left" | "top" | "top-right" | "left" | "center" | "right" | "bottom-left" | "bottom" | "bottom-right", offset?: {
29
29
  x?: number;
30
30
  y?: number;
31
- } | undefined] | ["center" | "right" | "left" | "top" | "bottom" | "top-left" | "top-right" | "bottom-left" | "bottom-right", offset?: {
31
+ } | undefined] | ["top-left" | "top" | "top-right" | "left" | "center" | "right" | "bottom-left" | "bottom" | "bottom-right", offset?: {
32
32
  x?: number | undefined;
33
33
  y?: number | undefined;
34
34
  } | undefined] | undefined>;
@@ -1,5 +1,5 @@
1
1
  import { ref, reactive, toValue } from "vue";
2
- const drawerStateStore = ref([]);
2
+ const draggableStateStore = ref([]);
3
3
  export function useDraggableState(id) {
4
4
  function createState(id2) {
5
5
  const state = {
@@ -22,18 +22,18 @@ export function useDraggableState(id) {
22
22
  }
23
23
  function addState(id2) {
24
24
  const state = createState(id2);
25
- drawerStateStore.value = [...drawerStateStore.value, state];
25
+ draggableStateStore.value = [...draggableStateStore.value, state];
26
26
  return state;
27
27
  }
28
28
  function initializeState() {
29
- let state = drawerStateStore.value.find((entry) => {
29
+ let state = draggableStateStore.value.find((entry) => {
30
30
  return entry.id === id;
31
31
  });
32
32
  if (!state) state = addState(toValue(id));
33
33
  return state;
34
34
  }
35
35
  function deleteState() {
36
- drawerStateStore.value = drawerStateStore.value.filter(
36
+ draggableStateStore.value = draggableStateStore.value.filter(
37
37
  (x) => x.id !== id
38
38
  );
39
39
  }
@@ -76,9 +76,7 @@ declare const mappedOptions: Omit<MagicDrawerOptions, keyof MagicDrawerOptions>
76
76
  easing?: (t: number) => number;
77
77
  };
78
78
  });
79
- backdrop: boolean;
80
79
  tag: "div" | "dialog";
81
- focusTrap: boolean | import("focus-trap").Options;
82
80
  scrollLock: {
83
81
  padding: boolean;
84
82
  } | ((boolean | {
@@ -110,10 +108,13 @@ declare const mappedOptions: Omit<MagicDrawerOptions, keyof MagicDrawerOptions>
110
108
  } & true, "padding"> & {
111
109
  padding: boolean;
112
110
  });
113
- teleport: {
114
- target?: string;
115
- disabled?: boolean;
111
+ snapPoints: import("../types/index").DrawerSnapPoint[];
112
+ initial: {
113
+ open?: boolean;
114
+ transition?: boolean;
115
+ snapPoint?: import("../types/index").DrawerSnapPoint;
116
116
  };
117
+ position: "top" | "left" | "right" | "bottom";
117
118
  keyListener: ({
118
119
  close?: string[] | false;
119
120
  } & import("../../../../utils").RequireAll<{
@@ -127,12 +128,11 @@ declare const mappedOptions: Omit<MagicDrawerOptions, keyof MagicDrawerOptions>
127
128
  }>, "close"> & {
128
129
  close: (false | string[] | undefined) & (false | string[]);
129
130
  });
130
- position: "right" | "left" | "top" | "bottom";
131
- snapPoints: import("../types/index").DrawerSnapPoint[];
132
- initial: {
133
- open?: boolean;
134
- transition?: boolean;
135
- snapPoint?: import("../types/index").DrawerSnapPoint;
131
+ backdrop: boolean;
132
+ focusTrap: boolean | import("focus-trap").Options;
133
+ teleport: {
134
+ target?: string;
135
+ disabled?: boolean;
136
136
  };
137
137
  enableMousewheel: boolean;
138
138
  preventZoom: boolean;
@@ -74,26 +74,26 @@ export declare function useMagicEmitter(): {
74
74
  } & Omit<{
75
75
  beforeSnap: {
76
76
  id: string;
77
- snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
77
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
78
78
  } | {
79
79
  id: string;
80
- snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
80
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
81
81
  };
82
82
  snapTo: {
83
83
  id: string;
84
- snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
84
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
85
85
  duration?: number;
86
86
  } | {
87
87
  id: string;
88
- snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
88
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
89
89
  duration?: number;
90
90
  };
91
91
  afterSnap: {
92
92
  id: string;
93
- snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
93
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
94
94
  } | {
95
95
  id: string;
96
- snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
96
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
97
97
  };
98
98
  beforeDrag: {
99
99
  id: string;
@@ -324,26 +324,26 @@ export declare function useMagicEmitter(): {
324
324
  } & Omit<{
325
325
  beforeSnap: {
326
326
  id: string;
327
- snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
327
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
328
328
  } | {
329
329
  id: string;
330
- snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
330
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
331
331
  };
332
332
  snapTo: {
333
333
  id: string;
334
- snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
334
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
335
335
  duration?: number;
336
336
  } | {
337
337
  id: string;
338
- snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
338
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
339
339
  duration?: number;
340
340
  };
341
341
  afterSnap: {
342
342
  id: string;
343
- snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
343
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
344
344
  } | {
345
345
  id: string;
346
- snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
346
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
347
347
  };
348
348
  beforeDrag: {
349
349
  id: string;
@@ -576,26 +576,26 @@ export declare function useMagicEmitter(): {
576
576
  } & Omit<{
577
577
  beforeSnap: {
578
578
  id: string;
579
- snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
579
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
580
580
  } | {
581
581
  id: string;
582
- snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
582
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
583
583
  };
584
584
  snapTo: {
585
585
  id: string;
586
- snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
586
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
587
587
  duration?: number;
588
588
  } | {
589
589
  id: string;
590
- snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
590
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
591
591
  duration?: number;
592
592
  };
593
593
  afterSnap: {
594
594
  id: string;
595
- snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
595
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
596
596
  } | {
597
597
  id: string;
598
- snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
598
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
599
599
  };
600
600
  beforeDrag: {
601
601
  id: string;
@@ -826,26 +826,26 @@ export declare function useMagicEmitter(): {
826
826
  } & Omit<{
827
827
  beforeSnap: {
828
828
  id: string;
829
- snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
829
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
830
830
  } | {
831
831
  id: string;
832
- snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
832
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
833
833
  };
834
834
  snapTo: {
835
835
  id: string;
836
- snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
836
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
837
837
  duration?: number;
838
838
  } | {
839
839
  id: string;
840
- snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
840
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
841
841
  duration?: number;
842
842
  };
843
843
  afterSnap: {
844
844
  id: string;
845
- snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
845
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
846
846
  } | {
847
847
  id: string;
848
- snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
848
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
849
849
  };
850
850
  beforeDrag: {
851
851
  id: string;
@@ -1078,26 +1078,26 @@ export declare function useMagicEmitter(): {
1078
1078
  } & Omit<{
1079
1079
  beforeSnap: {
1080
1080
  id: string;
1081
- snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
1081
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
1082
1082
  } | {
1083
1083
  id: string;
1084
- snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
1084
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
1085
1085
  };
1086
1086
  snapTo: {
1087
1087
  id: string;
1088
- snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
1088
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
1089
1089
  duration?: number;
1090
1090
  } | {
1091
1091
  id: string;
1092
- snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
1092
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
1093
1093
  duration?: number;
1094
1094
  };
1095
1095
  afterSnap: {
1096
1096
  id: string;
1097
- snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
1097
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
1098
1098
  } | {
1099
1099
  id: string;
1100
- snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
1100
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
1101
1101
  };
1102
1102
  beforeDrag: {
1103
1103
  id: string;
@@ -1328,26 +1328,26 @@ export declare function useMagicEmitter(): {
1328
1328
  } & Omit<{
1329
1329
  beforeSnap: {
1330
1330
  id: string;
1331
- snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
1331
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
1332
1332
  } | {
1333
1333
  id: string;
1334
- snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
1334
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
1335
1335
  };
1336
1336
  snapTo: {
1337
1337
  id: string;
1338
- snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
1338
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
1339
1339
  duration?: number;
1340
1340
  } | {
1341
1341
  id: string;
1342
- snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
1342
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
1343
1343
  duration?: number;
1344
1344
  };
1345
1345
  afterSnap: {
1346
1346
  id: string;
1347
- snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
1347
+ snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
1348
1348
  } | {
1349
1349
  id: string;
1350
- snapPoint: import("../../../MagicDraggable/src/types").DraggableSnapPoint;
1350
+ snapPoint: import("../../../MagicDrawer/src/types").DrawerSnapPoint;
1351
1351
  };
1352
1352
  beforeDrag: {
1353
1353
  id: string;
@@ -12,19 +12,19 @@ declare const mappedOptions: Omit<MagicModalOptions, keyof MagicModalOptions> &
12
12
  content?: string;
13
13
  backdrop?: string;
14
14
  };
15
- backdrop: boolean;
16
15
  tag: "div" | "dialog";
17
- focusTrap: boolean | import("focus-trap").Options;
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>;
@@ -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,2 @@
1
+ declare const _default: import("@nuxt/schema").NuxtModule<import("@nuxt/schema").ModuleOptions, import("@nuxt/schema").ModuleOptions, false>;
2
+ export default _default;
@@ -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,6 @@
1
+ import { type MaybeRef } from 'vue';
2
+ import type { PieState } from '../../types/index.js';
3
+ export declare function usePieState(id: MaybeRef<string>): {
4
+ initializeState: () => PieState;
5
+ deleteState: () => void;
6
+ };
@@ -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
+ }
@@ -0,0 +1,9 @@
1
+ export interface MagicPieOptions {
2
+ flip?: boolean;
3
+ }
4
+ export interface PieState {
5
+ id: string;
6
+ percentage: number;
7
+ animation: number | undefined;
8
+ }
9
+ export type PiePoint = [number, number];
File without changes
@@ -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';
@@ -8,6 +8,7 @@ export * from "./MagicMarquee/index.mjs";
8
8
  export * from "./MagicMenu/index.mjs";
9
9
  export * from "./MagicModal/index.mjs";
10
10
  export * from "./MagicNoise/index.mjs";
11
+ export * from "./MagicPie/index.mjs";
11
12
  export * from "./MagicPlayer/index.mjs";
12
13
  export * from "./MagicScroll/index.mjs";
13
14
  export * from "./MagicToast/index.mjs";
@@ -23,8 +23,9 @@ type InterpolateArgs = {
23
23
  duration: number;
24
24
  easing?: (t: number) => number;
25
25
  callback: (result: number) => void;
26
+ animationIdCallback?: (id: number) => void;
26
27
  };
27
- declare function interpolate(args: InterpolateArgs): void;
28
+ declare function interpolate(args: InterpolateArgs): number;
28
29
 
29
30
  declare function isIOS(): boolean;
30
31
 
@@ -71,8 +71,17 @@ function formatTime(seconds, guide) {
71
71
 
72
72
  // src/functions/interpolate.ts
73
73
  function interpolate(args) {
74
- const { from, to, duration, callback, easing = (t) => t * (2 - t) } = args;
74
+ const {
75
+ from,
76
+ to,
77
+ duration,
78
+ callback,
79
+ animationIdCallback = () => {
80
+ },
81
+ easing = (t) => t * (2 - t)
82
+ } = args;
75
83
  let startTime;
84
+ let animationId;
76
85
  function animate(timestamp) {
77
86
  if (!startTime) startTime = timestamp;
78
87
  const progress = Math.min(1, (timestamp - startTime) / duration);
@@ -80,10 +89,12 @@ function interpolate(args) {
80
89
  const value = from + (to - from) * easedProgress;
81
90
  callback(value);
82
91
  if (progress < 1) {
83
- requestAnimationFrame(animate);
92
+ animationId = requestAnimationFrame(animate);
93
+ animationIdCallback(animationId);
84
94
  }
85
95
  }
86
- requestAnimationFrame(animate);
96
+ animationId = requestAnimationFrame(animate);
97
+ return animationId;
87
98
  }
88
99
 
89
100
  // src/functions/isIOS.ts
@@ -1 +1 @@
1
- {"version":3,"sources":["../../packages/utils/src/functions/clampValue.ts","../../packages/utils/src/functions/easings.ts","../../packages/utils/src/functions/toNumber.ts","../../packages/utils/src/functions/formatTime.ts","../../packages/utils/src/functions/interpolate.ts","../../packages/utils/src/functions/isIOS.ts","../../packages/utils/src/functions/isWithinRange.ts","../../packages/utils/src/functions/mapValue.ts","../../packages/utils/src/functions/matchClass.ts","../../packages/utils/src/functions/pointerCapture.ts","../../packages/utils/src/functions/scrollbarGutterSupport.ts","../../packages/utils/src/functions/scrollbarWidth.ts","../../packages/utils/src/functions/slugify.ts","../../packages/utils/src/functions/uniq.ts"],"sourcesContent":["export function clampValue(value: number, min: number, max: number) {\n return value <= min ? min : value >= max ? max : value\n}\n","export function linear(t: number) {\n return t\n}\nexport function easeInQuad(t: number) {\n return t * t\n}\nexport function easeOutQuad(t: number) {\n return t * (2 - t)\n}\nexport function easeInOutQuad(t: number) {\n return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t\n}\nexport function easeOutBack(t: number, o: number = 1.25) {\n return 1 + (t - 1) * (t - 1) * ((o + 1) * (t - 1) + o)\n}\nexport function easeInCubic(t: number) {\n return t * t * t\n}\nexport function easeOutCubic(t: number) {\n return --t * t * t + 1\n}\nexport function easeInOutCubic(t: number) {\n return t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1\n}\nexport function easeInQuart(t: number) {\n return t * t * t * t\n}\nexport function easeOutQuart(t: number) {\n return 1 - --t * t * t * t\n}\nexport function easeInOutQuart(t: number) {\n return t < 0.5 ? 8 * t * t * t * t : 1 - 8 * --t * t * t * t\n}\nexport function easeInQuint(t: number) {\n return t * t * t * t * t\n}\nexport function easeOutQuint(t: number) {\n return 1 + --t * t * t * t * t\n}\nexport function easeInOutQuint(t: number) {\n return t < 0.5 ? 16 * t * t * t * t * t : 1 + 16 * --t * t * t * t * t\n}\n","export function toNumber(value: string | number): number {\n return typeof value === 'string' ? parseFloat(value) : Number(value)\n}\n","import { toNumber } from './toNumber'\n\nexport function formatTime(seconds: number, guide: number) {\n seconds = seconds < 0 ? 0 : seconds\n let s: string | number = Math.floor(seconds % 60)\n let m: string | number = Math.floor((seconds / 60) % 60)\n let h: string | number = Math.floor(seconds / 3600)\n const gm = Math.floor((guide / 60) % 60)\n const gh = Math.floor(guide / 3600)\n\n // handle invalid times\n if (isNaN(seconds) || seconds === Infinity) {\n // '-' is false for all relational operators (e.g. <, >=) so this setting\n // will add the minimum number of fields specified by the guide\n h = m = s = '-'\n }\n\n // Check if we need to show hours\n h = toNumber(h) > 0 || gh > 0 ? h + ':' : ''\n\n // If hours are showing, we may need to add a leading zero.\n // Always show at least one digit of minutes.\n m = ((h || gm >= 10) && toNumber(m) < 10 ? '0' + m : m) + ':'\n\n // Check if leading zero is need for seconds\n s = toNumber(s) < 10 ? '0' + s : s\n\n return h + m + s\n}\n","export type InterpolateArgs = {\n from: number\n to: number\n duration: number\n easing?: (t: number) => number\n callback: (result: number) => void\n}\n\nexport function interpolate(args: InterpolateArgs) {\n const { from, to, duration, callback, easing = (t) => t * (2 - t) } = args\n\n let startTime: number\n\n function animate(timestamp: number) {\n if (!startTime) startTime = timestamp\n\n const progress = Math.min(1, (timestamp - startTime) / duration)\n const easedProgress = easing(progress)\n const value = from + (to - from) * easedProgress\n\n callback(value)\n\n if (progress < 1) {\n requestAnimationFrame(animate)\n }\n }\n\n requestAnimationFrame(animate)\n}\n","export function isIOS() {\n if (typeof window === 'undefined') return false\n return /iPad|iPhone|iPod/.test(navigator?.userAgent)\n}\n","interface isWithinRangeArgs {\n input: number\n base: number\n threshold: number\n}\n\nexport function isWithinRange(args: isWithinRangeArgs): boolean {\n const { input, base, threshold } = args\n return input >= base - threshold && input <= base + threshold\n}\n","export function mapValue(\n value: number,\n inMin: number,\n inMax: number,\n outMin: number,\n outMax: number\n) {\n return ((value - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin\n}\n","export function matchClass(el: Element, regex: RegExp) {\n return Array.from(el.classList).some((className) => regex.test(className))\n}\n","interface GuardedSetPointerCaptureArgs {\n event: PointerEvent\n element?: Element | null\n debug?: boolean\n}\n\ninterface GuardedReleasePointerCaptureArgs {\n event: PointerEvent\n element?: Element | null\n}\n\nexport function guardedSetPointerCapture(\n args: GuardedSetPointerCaptureArgs\n): void {\n const { event, element, debug } = args\n if (element && event.isPrimary && event.pointerType !== 'mouse') {\n try {\n const coalescedEvents: PointerEvent[] =\n 'getCoalescedEvents' in event ? event.getCoalescedEvents() : [event]\n\n if (coalescedEvents.length > 0) {\n element?.setPointerCapture(event.pointerId)\n }\n } catch (error) {\n if (debug) {\n console.warn('Failed to set pointer capture:', error)\n }\n }\n }\n}\n\nexport function guardedReleasePointerCapture(\n args: GuardedReleasePointerCaptureArgs\n): void {\n const { event, element } = args\n if (element?.hasPointerCapture(event.pointerId)) {\n element.releasePointerCapture(event.pointerId)\n }\n}\n","export function scrollbarGutterSupport() {\n return CSS.supports('scrollbar-gutter', 'stable')\n}\n","export function scrollbarWidth() {\n const wrapper = document.createElement('div')\n wrapper.style.position = 'absolute'\n wrapper.style.visibility = 'hidden'\n wrapper.style.overflow = 'hidden'\n wrapper.style.width = '100px'\n wrapper.style.height = '100px'\n wrapper.style.top = '-9999px'\n\n wrapper.innerHTML = '<div style=\"width: 200px; height: 200px;\"></div>'\n document.body.appendChild(wrapper)\n\n // Get the scrollbar width\n const withoutScrollbar = wrapper.clientWidth\n wrapper.style.overflow = 'scroll'\n const withScrollbar = wrapper.clientWidth\n\n // Clean up\n document.body.removeChild(wrapper)\n\n return Math.round(withoutScrollbar - withScrollbar)\n}\n","export interface SlugifyOptions {\n separator?: string\n trim?: boolean\n remove?: RegExp\n strict?: boolean\n lowercase?: boolean\n}\n\nconst defaultOptions: SlugifyOptions = {\n separator: '-',\n trim: true,\n remove: undefined,\n strict: true,\n lowercase: true,\n}\n\nexport function slugify(string: string, options?: SlugifyOptions): string {\n if (typeof string !== 'string') {\n throw new Error('slugify: string argument expected')\n }\n\n // Merge provided options with default options\n const _options = { ...defaultOptions, ...options }\n\n const charMap: { [key: string]: string } = {}\n\n let slug = string\n .normalize()\n .split('')\n .reduce(function (result, ch) {\n let appendChar = charMap[ch]\n if (appendChar === undefined) appendChar = ch\n if (appendChar === _options?.separator) appendChar = ' '\n return (\n result +\n appendChar.replace(_options?.remove || /[^\\w\\s$*_+~.()'\"!\\-:@]+/g, '')\n )\n }, '')\n\n if (_options.strict) {\n slug = slug.replace(/[^A-Za-z0-9\\s]/g, '')\n }\n\n if (_options.trim) {\n slug = slug.trim()\n }\n\n if (_options.separator) {\n slug = slug.replace(/ +/g, _options.separator)\n }\n\n if (_options.lowercase) {\n slug = slug.toLocaleLowerCase()\n }\n\n return slug\n}\n","export function uniq<T extends unknown[]>(a: T) {\n return Array.from(new Set(a))\n}\n"],"mappings":";AAAO,SAAS,WAAW,OAAe,KAAa,KAAa;AAClE,SAAO,SAAS,MAAM,MAAM,SAAS,MAAM,MAAM;AACnD;;;ACFO,SAAS,OAAO,GA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AAiC;AAAA,EACrC,WAAW;AAAA,EACX,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,WAAW;AACb;AAEO,SAAS,QAAQ,QAAgB,SAAkC;AACxE,MAAI,OAAO,WAAW,UAAU;AAC9B,UAAM,IAAI,MAAM,mCAAmC;AAAA,EACrD;AAGA,QAAM,WAAW,EAAE,GAAG,gBAAgB,GAAG,QAAQ;AAEjD,QAAM,UAAqC,CAAC;AAE5C,MAAI,OAAO,OACR,UAAU,EACV,MAAM,EAAE,EACR,OAAO,SAAU,QAAQ,IAAI;AAC5B,QAAI,aAAa,QAAQ,EAAE;AAC3B,QAAI,eAAe,OAAW,cAAa;AAC3C,QAAI,gBAAe,qCAAU,WAAW,cAAa;AACrD,WACE,SACA,WAAW,SAAQ,qCAAU,WAAU,4BAA4B,EAAE;AAAA,EAEzE,GAAG,EAAE;AAEP,MAAI,SAAS,QAAQ;AACnB,WAAO,KAAK,QAAQ,mBAAmB,EAAE;AAAA,EAC3C;AAEA,MAAI,SAAS,MAAM;AACjB,WAAO,KAAK,KAAK;AAAA,EACnB;AAEA,MAAI,SAAS,WAAW;AACtB,WAAO,KAAK,QAAQ,OAAO,SAAS,SAAS;AAAA,EAC/C;AAEA,MAAI,SAAS,WAAW;AACtB,WAAO,KAAK,kBAAkB;AAAA,EAChC;AAEA,SAAO;AACT;;;ACxDO,SAAS,KAA0B,GAAM;AAC9C,SAAO,MAAM,KAAK,IAAI,IAAI,CAAC,CAAC;AAC9B;","names":[]}
1
+ {"version":3,"sources":["../../packages/utils/src/functions/clampValue.ts","../../packages/utils/src/functions/easings.ts","../../packages/utils/src/functions/toNumber.ts","../../packages/utils/src/functions/formatTime.ts","../../packages/utils/src/functions/interpolate.ts","../../packages/utils/src/functions/isIOS.ts","../../packages/utils/src/functions/isWithinRange.ts","../../packages/utils/src/functions/mapValue.ts","../../packages/utils/src/functions/matchClass.ts","../../packages/utils/src/functions/pointerCapture.ts","../../packages/utils/src/functions/scrollbarGutterSupport.ts","../../packages/utils/src/functions/scrollbarWidth.ts","../../packages/utils/src/functions/slugify.ts","../../packages/utils/src/functions/uniq.ts"],"sourcesContent":["export function clampValue(value: number, min: number, max: number) {\n return value <= min ? min : value >= max ? max : value\n}\n","export function linear(t: number) {\n return t\n}\nexport function easeInQuad(t: number) {\n return t * t\n}\nexport function easeOutQuad(t: number) {\n return t * (2 - t)\n}\nexport function easeInOutQuad(t: number) {\n return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t\n}\nexport function easeOutBack(t: number, o: number = 1.25) {\n return 1 + (t - 1) * (t - 1) * ((o + 1) * (t - 1) + o)\n}\nexport function easeInCubic(t: number) {\n return t * t * t\n}\nexport function easeOutCubic(t: number) {\n return --t * t * t + 1\n}\nexport function easeInOutCubic(t: number) {\n return t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1\n}\nexport function easeInQuart(t: number) {\n return t * t * t * t\n}\nexport function easeOutQuart(t: number) {\n return 1 - --t * t * t * t\n}\nexport function easeInOutQuart(t: number) {\n return t < 0.5 ? 8 * t * t * t * t : 1 - 8 * --t * t * t * t\n}\nexport function easeInQuint(t: number) {\n return t * t * t * t * t\n}\nexport function easeOutQuint(t: number) {\n return 1 + --t * t * t * t * t\n}\nexport function easeInOutQuint(t: number) {\n return t < 0.5 ? 16 * t * t * t * t * t : 1 + 16 * --t * t * t * t * t\n}\n","export function toNumber(value: string | number): number {\n return typeof value === 'string' ? parseFloat(value) : Number(value)\n}\n","import { toNumber } from './toNumber'\n\nexport function formatTime(seconds: number, guide: number) {\n seconds = seconds < 0 ? 0 : seconds\n let s: string | number = Math.floor(seconds % 60)\n let m: string | number = Math.floor((seconds / 60) % 60)\n let h: string | number = Math.floor(seconds / 3600)\n const gm = Math.floor((guide / 60) % 60)\n const gh = Math.floor(guide / 3600)\n\n // handle invalid times\n if (isNaN(seconds) || seconds === Infinity) {\n // '-' is false for all relational operators (e.g. <, >=) so this setting\n // will add the minimum number of fields specified by the guide\n h = m = s = '-'\n }\n\n // Check if we need to show hours\n h = toNumber(h) > 0 || gh > 0 ? h + ':' : ''\n\n // If hours are showing, we may need to add a leading zero.\n // Always show at least one digit of minutes.\n m = ((h || gm >= 10) && toNumber(m) < 10 ? '0' + m : m) + ':'\n\n // Check if leading zero is need for seconds\n s = toNumber(s) < 10 ? '0' + s : s\n\n return h + m + s\n}\n","export type InterpolateArgs = {\n from: number\n to: number\n duration: number\n easing?: (t: number) => number\n callback: (result: number) => void\n animationIdCallback?: (id: number) => void\n}\n\nexport function interpolate(args: InterpolateArgs) {\n const {\n from,\n to,\n duration,\n callback,\n animationIdCallback = () => {},\n easing = (t) => t * (2 - t),\n } = args\n\n let startTime: number\n let animationId: number\n\n function animate(timestamp: number) {\n if (!startTime) startTime = timestamp\n\n const progress = Math.min(1, (timestamp - startTime) / duration)\n const easedProgress = easing(progress)\n const value = from + (to - from) * easedProgress\n\n callback(value)\n\n if (progress < 1) {\n animationId = requestAnimationFrame(animate)\n animationIdCallback(animationId)\n }\n }\n\n animationId = requestAnimationFrame(animate)\n\n return animationId\n}\n","export function isIOS() {\n if (typeof window === 'undefined') return false\n return /iPad|iPhone|iPod/.test(navigator?.userAgent)\n}\n","interface isWithinRangeArgs {\n input: number\n base: number\n threshold: number\n}\n\nexport function isWithinRange(args: isWithinRangeArgs): boolean {\n const { input, base, threshold } = args\n return input >= base - threshold && input <= base + threshold\n}\n","export function mapValue(\n value: number,\n inMin: number,\n inMax: number,\n outMin: number,\n outMax: number\n) {\n return ((value - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin\n}\n","export function matchClass(el: Element, regex: RegExp) {\n return Array.from(el.classList).some((className) => regex.test(className))\n}\n","interface GuardedSetPointerCaptureArgs {\n event: PointerEvent\n element?: Element | null\n debug?: boolean\n}\n\ninterface GuardedReleasePointerCaptureArgs {\n event: PointerEvent\n element?: Element | null\n}\n\nexport function guardedSetPointerCapture(\n args: GuardedSetPointerCaptureArgs\n): void {\n const { event, element, debug } = args\n if (element && event.isPrimary && event.pointerType !== 'mouse') {\n try {\n const coalescedEvents: PointerEvent[] =\n 'getCoalescedEvents' in event ? event.getCoalescedEvents() : [event]\n\n if (coalescedEvents.length > 0) {\n element?.setPointerCapture(event.pointerId)\n }\n } catch (error) {\n if (debug) {\n console.warn('Failed to set pointer capture:', error)\n }\n }\n }\n}\n\nexport function guardedReleasePointerCapture(\n args: GuardedReleasePointerCaptureArgs\n): void {\n const { event, element } = args\n if (element?.hasPointerCapture(event.pointerId)) {\n element.releasePointerCapture(event.pointerId)\n }\n}\n","export function scrollbarGutterSupport() {\n return CSS.supports('scrollbar-gutter', 'stable')\n}\n","export function scrollbarWidth() {\n const wrapper = document.createElement('div')\n wrapper.style.position = 'absolute'\n wrapper.style.visibility = 'hidden'\n wrapper.style.overflow = 'hidden'\n wrapper.style.width = '100px'\n wrapper.style.height = '100px'\n wrapper.style.top = '-9999px'\n\n wrapper.innerHTML = '<div style=\"width: 200px; height: 200px;\"></div>'\n document.body.appendChild(wrapper)\n\n // Get the scrollbar width\n const withoutScrollbar = wrapper.clientWidth\n wrapper.style.overflow = 'scroll'\n const withScrollbar = wrapper.clientWidth\n\n // Clean up\n document.body.removeChild(wrapper)\n\n return Math.round(withoutScrollbar - withScrollbar)\n}\n","export interface SlugifyOptions {\n separator?: string\n trim?: boolean\n remove?: RegExp\n strict?: boolean\n lowercase?: boolean\n}\n\nconst defaultOptions: SlugifyOptions = {\n separator: '-',\n trim: true,\n remove: undefined,\n strict: true,\n lowercase: true,\n}\n\nexport function slugify(string: string, options?: SlugifyOptions): string {\n if (typeof string !== 'string') {\n throw new Error('slugify: string argument expected')\n }\n\n // Merge provided options with default options\n const _options = { ...defaultOptions, ...options }\n\n const charMap: { [key: string]: string } = {}\n\n let slug = string\n .normalize()\n .split('')\n .reduce(function (result, ch) {\n let appendChar = charMap[ch]\n if (appendChar === undefined) appendChar = ch\n if (appendChar === _options?.separator) appendChar = ' '\n return (\n result +\n appendChar.replace(_options?.remove || /[^\\w\\s$*_+~.()'\"!\\-:@]+/g, '')\n )\n }, '')\n\n if (_options.strict) {\n slug = slug.replace(/[^A-Za-z0-9\\s]/g, '')\n }\n\n if (_options.trim) {\n slug = slug.trim()\n }\n\n if (_options.separator) {\n slug = slug.replace(/ +/g, _options.separator)\n }\n\n if (_options.lowercase) {\n slug = slug.toLocaleLowerCase()\n }\n\n return slug\n}\n","export function uniq<T extends unknown[]>(a: T) {\n return Array.from(new Set(a))\n}\n"],"mappings":";AAAO,SAAS,WAAW,OAAe,KAAa,KAAa;AAClE,SAAO,SAAS,MAAM,MAAM,SAAS,MAAM,MAAM;AACnD;;;ACFO,SAAS,OAAO,GAAW;AAChC,SAAO;AACT;AACO,SAAS,WAAW,GAAW;AACpC,SAAO,IAAI;AACb;AACO,SAAS,YAAY,GAAW;AACrC,SAAO,KAAK,IAAI;AAClB;AACO,SAAS,cAAc,GAAW;AACvC,SAAO,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,KAAK;AAClD;AACO,SAAS,YAAY,GAAW,IAAY,MAAM;AACvD,SAAO,KAAK,IAAI,MAAM,IAAI,OAAO,IAAI,MAAM,IAAI,KAAK;AACtD;AACO,SAAS,YAAY,GAAW;AACrC,SAAO,IAAI,IAAI;AACjB;AACO,SAAS,aAAa,GAAW;AACtC,SAAO,EAAE,IAAI,IAAI,IAAI;AACvB;AACO,SAAS,eAAe,GAAW;AACxC,SAAO,IAAI,MAAM,IAAI,IAAI,IAAI,KAAK,IAAI,MAAM,IAAI,IAAI,MAAM,IAAI,IAAI,KAAK;AACzE;AACO,SAAS,YAAY,GAAW;AACrC,SAAO,IAAI,IAAI,IAAI;AACrB;AACO,SAAS,aAAa,GAAW;AACtC,SAAO,IAAI,EAAE,IAAI,IAAI,IAAI;AAC3B;AACO,SAAS,eAAe,GAAW;AACxC,SAAO,IAAI,MAAM,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE,IAAI,IAA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AAK;AAAA,EACnB;AAEA,MAAI,SAAS,WAAW;AACtB,WAAO,KAAK,QAAQ,OAAO,SAAS,SAAS;AAAA,EAC/C;AAEA,MAAI,SAAS,WAAW;AACtB,WAAO,KAAK,kBAAkB;AAAA,EAChC;AAEA,SAAO;AACT;;;ACxDO,SAAS,KAA0B,GAAM;AAC9C,SAAO,MAAM,KAAK,IAAI,IAAI,CAAC,CAAC;AAC9B;","names":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maas/vue-equipment",
3
3
  "description": "Our Frontend Toolkit, Free and Open Source",
4
- "version": "1.0.0-beta.8",
4
+ "version": "1.0.0-beta.9",
5
5
  "contributors": [
6
6
  {
7
7
  "name": "Robin Scholz",