@maas/vue-equipment 0.5.0 → 0.6.1

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 (62) hide show
  1. package/dist/composables/index.d.mts +23 -1
  2. package/dist/composables/index.d.ts +23 -1
  3. package/dist/composables/index.js +118 -8
  4. package/dist/composables/index.js.map +1 -1
  5. package/dist/composables/index.mjs +111 -2
  6. package/dist/composables/index.mjs.map +1 -1
  7. package/dist/nuxt/module.json +1 -1
  8. package/dist/nuxt/module.mjs +16 -2
  9. package/dist/plugins/MagicMarquee/src/components/MagicMarquee.vue +3 -3
  10. package/dist/plugins/MagicMarquee/src/composables/{useMarquee.d.ts → useMarqueeApi.d.ts} +2 -2
  11. package/dist/plugins/MagicMarquee/src/composables/{useMarquee.mjs → useMarqueeApi.mjs} +1 -1
  12. package/dist/plugins/MagicModal/src/components/MagicModal.vue +39 -59
  13. package/dist/plugins/MagicModal/src/components/MagicModal.vue.d.ts +15 -15
  14. package/dist/plugins/MagicModal/src/composables/private/useModalCallback.d.ts +22 -0
  15. package/dist/plugins/MagicModal/src/composables/private/useModalCallback.mjs +60 -0
  16. package/dist/plugins/MagicModal/src/composables/useModalApi.d.ts +4 -3
  17. package/dist/plugins/MagicModal/src/composables/useModalApi.mjs +5 -4
  18. package/dist/plugins/MagicModal/src/types/index.d.ts +7 -5
  19. package/dist/plugins/MagicModal/src/utils/defaultOptions.d.ts +2 -2
  20. package/dist/plugins/MagicPlayer/src/composables/useControlsApi.mjs +1 -2
  21. package/dist/plugins/MagicPlayer/src/composables/useMediaApi.d.ts +1 -1
  22. package/dist/plugins/MagicPlayer/src/composables/useMediaApi.mjs +2 -2
  23. package/dist/plugins/MagicPlayer/src/composables/useRuntimeSourceProvider.mjs +1 -2
  24. package/dist/plugins/MagicPlayer/src/types/index.d.ts +1 -1
  25. package/dist/plugins/MagicScroll/index.d.ts +2 -2
  26. package/dist/plugins/MagicScroll/index.mjs +4 -2
  27. package/dist/plugins/MagicScroll/src/components/MagicScrollMotion.vue +58 -0
  28. package/dist/plugins/MagicScroll/src/components/MagicScrollMotion.vue.d.ts +42 -0
  29. package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue +2 -2
  30. package/dist/plugins/MagicScroll/src/components/MagicScrollTransform.vue.d.ts +9 -9
  31. package/dist/plugins/MagicScroll/src/composables/{useProgress.d.ts → useScrollApi.d.ts} +4 -4
  32. package/dist/plugins/MagicScroll/src/composables/{useProgress.mjs → useScrollApi.mjs} +2 -3
  33. package/dist/plugins/MagicScroll/src/types/injectionKeys.d.ts +1 -2
  34. package/dist/plugins/MagicToast/demo/DemoToast.vue +22 -0
  35. package/dist/plugins/MagicToast/demo/DemoToast.vue.d.ts +14 -0
  36. package/dist/plugins/MagicToast/index.d.ts +5 -0
  37. package/dist/plugins/MagicToast/index.mjs +9 -0
  38. package/dist/plugins/MagicToast/nuxt.d.ts +2 -0
  39. package/dist/plugins/MagicToast/nuxt.mjs +5 -0
  40. package/dist/plugins/MagicToast/src/components/MagicToast.vue +230 -0
  41. package/dist/plugins/MagicToast/src/components/MagicToast.vue.d.ts +28 -0
  42. package/dist/plugins/MagicToast/src/components/MagicToastComponent.vue +101 -0
  43. package/dist/plugins/MagicToast/src/components/MagicToastComponent.vue.d.ts +48 -0
  44. package/dist/plugins/MagicToast/src/composables/private/useToastCallback.d.ts +21 -0
  45. package/dist/plugins/MagicToast/src/composables/private/useToastCallback.mjs +43 -0
  46. package/dist/plugins/MagicToast/src/composables/private/useToastInternalApi.d.ts +4 -0
  47. package/dist/plugins/MagicToast/src/composables/private/useToastInternalApi.mjs +26 -0
  48. package/dist/plugins/MagicToast/src/composables/private/useToastStore.d.ts +17 -0
  49. package/dist/plugins/MagicToast/src/composables/private/useToastStore.mjs +41 -0
  50. package/dist/plugins/MagicToast/src/composables/useToastApi.d.ts +11 -0
  51. package/dist/plugins/MagicToast/src/composables/useToastApi.mjs +60 -0
  52. package/dist/plugins/MagicToast/src/composables/useToastEmitter.d.ts +15 -0
  53. package/dist/plugins/MagicToast/src/composables/useToastEmitter.mjs +9 -0
  54. package/dist/plugins/MagicToast/src/types/index.d.ts +42 -0
  55. package/dist/plugins/MagicToast/src/types/index.mjs +0 -0
  56. package/dist/plugins/MagicToast/src/utils/defaultOptions.d.ts +3 -0
  57. package/dist/plugins/MagicToast/src/utils/defaultOptions.mjs +14 -0
  58. package/dist/plugins/index.d.ts +2 -1
  59. package/dist/plugins/index.mjs +2 -1
  60. package/package.json +13 -1
  61. /package/dist/plugins/MagicModal/src/composables/{useModalStore.d.ts → private/useModalStore.d.ts} +0 -0
  62. /package/dist/plugins/MagicModal/src/composables/{useModalStore.mjs → private/useModalStore.mjs} +0 -0
@@ -0,0 +1,60 @@
1
+ import {
2
+ computed,
3
+ onUnmounted,
4
+ onBeforeMount,
5
+ toValue,
6
+ markRaw
7
+ } from "vue";
8
+ import { v4 as uuidv4 } from "uuid";
9
+ import { useToastStore } from "./private/useToastStore.mjs";
10
+ export function useToastApi(id) {
11
+ const { findInstance, addInstance, removeInstance } = useToastStore();
12
+ const mappedId = computed(() => toValue(id) || uuidv4());
13
+ const instance = computed(() => findInstance(toValue(mappedId)));
14
+ function initialize() {
15
+ const id2 = toValue(mappedId);
16
+ if (!findInstance(id2)) {
17
+ return addInstance(id2);
18
+ }
19
+ }
20
+ function destroy(id2) {
21
+ if (!id2)
22
+ return;
23
+ clear();
24
+ removeInstance(toValue(id2));
25
+ }
26
+ const toasts = computed(() => instance.value?.toasts);
27
+ const count = computed(() => toasts.value?.length);
28
+ const oldest = computed(() => toasts.value?.[0]);
29
+ async function add(options) {
30
+ const { component, props, duration } = options;
31
+ const id2 = instance.value?.add({
32
+ props,
33
+ duration,
34
+ component: markRaw(component)
35
+ });
36
+ return id2;
37
+ }
38
+ function remove(id2) {
39
+ instance.value?.remove(id2);
40
+ }
41
+ function clear() {
42
+ if (!instance.value)
43
+ return;
44
+ instance.value.toasts = [];
45
+ }
46
+ onBeforeMount(() => {
47
+ initialize();
48
+ });
49
+ onUnmounted(() => {
50
+ destroy(toValue(mappedId));
51
+ });
52
+ return {
53
+ toasts,
54
+ count,
55
+ oldest,
56
+ add,
57
+ remove,
58
+ clear
59
+ };
60
+ }
@@ -0,0 +1,15 @@
1
+ import type { ToastEvents } from '../types.js';
2
+ export declare function useToastEmitter(): {
3
+ on: {
4
+ <Key extends keyof ToastEvents>(type: Key, handler: import("mitt").Handler<ToastEvents[Key]>): void;
5
+ (type: "*", handler: import("mitt").WildcardHandler<ToastEvents>): void;
6
+ };
7
+ off: {
8
+ <Key_1 extends keyof ToastEvents>(type: Key_1, handler?: import("mitt").Handler<ToastEvents[Key_1]> | undefined): void;
9
+ (type: "*", handler: import("mitt").WildcardHandler<ToastEvents>): void;
10
+ };
11
+ emit: {
12
+ <Key_2 extends keyof ToastEvents>(type: Key_2, event: ToastEvents[Key_2]): void;
13
+ <Key_3 extends keyof ToastEvents>(type: undefined extends ToastEvents[Key_3] ? Key_3 : never): void;
14
+ };
15
+ };
@@ -0,0 +1,9 @@
1
+ import mitt from "mitt";
2
+ const emitter = mitt();
3
+ export function useToastEmitter() {
4
+ return {
5
+ on: emitter.on,
6
+ off: emitter.off,
7
+ emit: emitter.emit
8
+ };
9
+ }
@@ -0,0 +1,42 @@
1
+ import type { MaybeRef } from 'vue';
2
+ type Toast = {
3
+ id: string;
4
+ component: Object;
5
+ props?: MaybeRef<Record<string, any>>;
6
+ remove: Function;
7
+ };
8
+ type ToastInstance = {
9
+ id: string;
10
+ toasts: Toast[];
11
+ add: (args: AddArgs) => string;
12
+ remove: (id: string) => void;
13
+ };
14
+ type Options = {
15
+ teleport?: {
16
+ target?: string;
17
+ disabled?: boolean;
18
+ };
19
+ transitions?: {
20
+ list: string;
21
+ };
22
+ layout?: {
23
+ expand?: boolean | 'hover' | 'click';
24
+ max?: false | number;
25
+ };
26
+ };
27
+ type ActiveElement = {
28
+ id: string;
29
+ height: number;
30
+ };
31
+ type ToastEvents = {
32
+ beforeEnter: string;
33
+ enter: string;
34
+ afterEnter: string;
35
+ beforeLeave: string;
36
+ leave: string;
37
+ afterLeave: string;
38
+ };
39
+ type AddArgs = Pick<Toast, 'component' | 'props'> & {
40
+ duration?: number;
41
+ };
42
+ export type { Toast, ToastInstance, Options, ActiveElement, ToastEvents, AddArgs, };
File without changes
@@ -0,0 +1,3 @@
1
+ import type { Options } from '../types/index.js';
2
+ declare const defaultOptions: Options;
3
+ export { defaultOptions };
@@ -0,0 +1,14 @@
1
+ const defaultOptions = {
2
+ teleport: {
3
+ target: "body",
4
+ disabled: false
5
+ },
6
+ transitions: {
7
+ list: "magic-toast--list"
8
+ },
9
+ layout: {
10
+ expand: "click",
11
+ max: 4
12
+ }
13
+ };
14
+ export { defaultOptions };
@@ -1,4 +1,5 @@
1
+ export * from './MagicMarquee.js';
1
2
  export * from './MagicModal.js';
2
3
  export * from './MagicPlayer.js';
3
4
  export * from './MagicScroll.js';
4
- export * from './MagicMarquee.js';
5
+ export * from './MagicToast.js';
@@ -1,4 +1,5 @@
1
+ export * from "./MagicMarquee/index.mjs";
1
2
  export * from "./MagicModal/index.mjs";
2
3
  export * from "./MagicPlayer/index.mjs";
3
4
  export * from "./MagicScroll/index.mjs";
4
- export * from "./MagicMarquee/index.mjs";
5
+ export * from "./MagicToast/index.mjs";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maas/vue-equipment",
3
3
  "description": "A magic collection of Vue composables, plugins, components and directives",
4
- "version": "0.5.0",
4
+ "version": "0.6.1",
5
5
  "author": "Robin Scholz <https://github.com/robinscholz>, Christoph Jeworutzki <https://github.com/ChristophJeworutzki>",
6
6
  "devDependencies": {
7
7
  "@antfu/ni": "^0.21.5",
@@ -54,15 +54,21 @@
54
54
  "license": "MIT",
55
55
  "main": "./dist/nuxt/module.cjs",
56
56
  "peerDependencies": {
57
+ "@maas/magic-timer": "^0.1.3",
57
58
  "@vueuse/core": "^10.3.0",
58
59
  "@vueuse/integrations": "^10.3.0",
59
60
  "focus-trap": "^7.5.2",
60
61
  "hls.js": "^1.4.10",
62
+ "luxon": "^3.4.2",
61
63
  "mitt": "^3.0.1",
64
+ "motion": "^10.16.2",
62
65
  "nuxt": "^3.5.1",
63
66
  "uuid": "^9.0.0"
64
67
  },
65
68
  "peerDependenciesMeta": {
69
+ "@maas/magic-timer": {
70
+ "optional": false
71
+ },
66
72
  "@vueuse/core": {
67
73
  "optional": false
68
74
  },
@@ -72,9 +78,15 @@
72
78
  "hls.js": {
73
79
  "optional": false
74
80
  },
81
+ "luxon": {
82
+ "optional": false
83
+ },
75
84
  "mitt": {
76
85
  "optional": false
77
86
  },
87
+ "motion": {
88
+ "optional": false
89
+ },
78
90
  "nuxt": {
79
91
  "optional": false
80
92
  },