@maas/vue-equipment 0.30.7 → 0.32.0
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 -1
- package/dist/plugins/MagicAccordion/index.d.ts +5 -0
- package/dist/plugins/MagicAccordion/index.mjs +25 -0
- package/dist/plugins/MagicAccordion/nuxt.d.ts +2 -0
- package/dist/plugins/MagicAccordion/nuxt.mjs +23 -0
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionContent.vue +72 -0
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionContent.vue.d.ts +26 -0
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionProvider.vue +31 -0
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionProvider.vue.d.ts +27 -0
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionTrigger.vue +71 -0
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionTrigger.vue.d.ts +47 -0
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionView.vue +55 -0
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionView.vue.d.ts +25 -0
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionCallback.d.ts +14 -0
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionCallback.mjs +32 -0
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionState.d.ts +7 -0
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionState.mjs +42 -0
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionTrigger.d.ts +16 -0
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionTrigger.mjs +35 -0
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionView.d.ts +12 -0
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionView.mjs +60 -0
- package/dist/plugins/MagicAccordion/src/composables/useMagicAccordion.d.ts +10 -0
- package/dist/plugins/MagicAccordion/src/composables/useMagicAccordion.mjs +9 -0
- package/dist/plugins/MagicAccordion/src/symbols/index.d.ts +5 -0
- package/dist/plugins/MagicAccordion/src/symbols/index.mjs +8 -0
- package/dist/plugins/MagicAccordion/src/types/index.d.ts +43 -0
- package/dist/plugins/MagicAccordion/src/types/index.mjs +0 -0
- package/dist/plugins/MagicAccordion/src/utils/defaultOptions.d.ts +4 -0
- package/dist/plugins/MagicAccordion/src/utils/defaultOptions.mjs +6 -0
- package/dist/plugins/MagicAutoSize/src/components/MagicAutoSize.vue +43 -4
- package/dist/plugins/MagicAutoSize/src/components/MagicAutoSize.vue.d.ts +5 -1
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue +3 -1
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerState.d.ts +2 -45
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerState.mjs +3 -2
- package/dist/plugins/MagicDrawer/src/composables/useMagicDrawer.mjs +5 -8
- package/dist/plugins/MagicDrawer/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicEmitter/src/composables/useMagicEmitter.d.ts +376 -118
- package/dist/plugins/MagicEmitter/src/types/index.d.ts +2 -0
- package/dist/plugins/MagicMenu/index.d.ts +2 -2
- package/dist/plugins/MagicMenu/index.mjs +14 -2
- package/dist/plugins/MagicMenu/src/components/MagicMenuContent.vue +15 -4
- package/dist/plugins/MagicMenu/src/components/MagicMenuFloat.vue +8 -0
- package/dist/plugins/MagicMenu/src/composables/private/useMenuCallback.d.ts +3 -1
- package/dist/plugins/MagicMenu/src/composables/private/useMenuCallback.mjs +29 -29
- package/dist/plugins/MagicMenu/src/composables/private/useMenuTrigger.mjs +9 -13
- package/dist/plugins/MagicMenu/src/composables/private/useMenuView.mjs +6 -6
- package/dist/plugins/MagicMenu/src/types/index.d.ts +33 -8
- package/dist/plugins/MagicMenu/src/utils/defaultOptions.d.ts +2 -3
- package/dist/plugins/MagicMenu/src/utils/modeDelayDefaults.d.ts +15 -0
- package/dist/plugins/MagicMenu/src/utils/modeDelayDefaults.mjs +18 -0
- package/dist/plugins/MagicMenu/src/utils/modeFloatingStrategyDefaults.d.ts +6 -0
- package/dist/plugins/MagicMenu/src/utils/modeFloatingStrategyDefaults.mjs +7 -0
- package/dist/plugins/MagicMenu/src/utils/modeScrollLockDefaults.d.ts +12 -0
- package/dist/plugins/MagicMenu/src/utils/modeScrollLockDefaults.mjs +13 -0
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerOverlay.vue +1 -1
- package/dist/plugins/MagicScroll/src/symbols/index.d.ts +2 -2
- package/dist/plugins/MagicToast/src/composables/private/useToastApi.d.ts +1 -1
- package/dist/plugins/MagicToast/src/composables/private/useToastStore.d.ts +14 -4
- package/dist/plugins/MagicToast/src/composables/useMagicToast.d.ts +5 -5
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.mjs +1 -0
- package/dist/utils/css/easings.css +4 -0
- package/package.json +1 -1
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerStore.d.ts +0 -5
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerStore.mjs +0 -15
- /package/dist/plugins/MagicMenu/src/utils/{modeTransitions.d.ts → modeTransitionDefaults.d.ts} +0 -0
- /package/dist/plugins/MagicMenu/src/utils/{modeTransitions.mjs → modeTransitionDefaults.mjs} +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { reactive } from "vue";
|
|
2
|
+
import { useAccordionState } from "./useAccordionState.mjs";
|
|
3
|
+
export function useAccordionView(instanceId) {
|
|
4
|
+
const { initializeState } = useAccordionState(instanceId);
|
|
5
|
+
const state = initializeState();
|
|
6
|
+
function createView(args) {
|
|
7
|
+
const { id, active = false } = args;
|
|
8
|
+
const view = {
|
|
9
|
+
id,
|
|
10
|
+
active
|
|
11
|
+
};
|
|
12
|
+
return reactive(view);
|
|
13
|
+
}
|
|
14
|
+
function addView(args) {
|
|
15
|
+
const view = createView(args);
|
|
16
|
+
state.views = [...state.views, view];
|
|
17
|
+
return view;
|
|
18
|
+
}
|
|
19
|
+
function initializeView(args) {
|
|
20
|
+
const { id, active } = args;
|
|
21
|
+
let instance = getView(id);
|
|
22
|
+
if (!instance) instance = addView(args);
|
|
23
|
+
if (active) selectView(id);
|
|
24
|
+
return instance;
|
|
25
|
+
}
|
|
26
|
+
function deleteView(id) {
|
|
27
|
+
state.views = state.views?.filter((view) => view.id !== id);
|
|
28
|
+
}
|
|
29
|
+
function getView(id) {
|
|
30
|
+
return state.views?.find((view) => view.id === id);
|
|
31
|
+
}
|
|
32
|
+
function selectView(id) {
|
|
33
|
+
const instance = getView(id);
|
|
34
|
+
if (instance) {
|
|
35
|
+
if (state.options.mode === "single") {
|
|
36
|
+
unselectAllViews();
|
|
37
|
+
}
|
|
38
|
+
instance.active = true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function unselectView(id) {
|
|
42
|
+
const instance = getView(id);
|
|
43
|
+
if (instance) {
|
|
44
|
+
instance.active = false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function unselectAllViews() {
|
|
48
|
+
state.views?.forEach((view) => {
|
|
49
|
+
view.active = false;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
initializeView,
|
|
54
|
+
deleteView,
|
|
55
|
+
getView,
|
|
56
|
+
selectView,
|
|
57
|
+
unselectView,
|
|
58
|
+
unselectAllViews
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type MaybeRef } from 'vue';
|
|
2
|
+
interface UseMagicAccordionArgs {
|
|
3
|
+
instanceId: MaybeRef<string>;
|
|
4
|
+
}
|
|
5
|
+
export declare function useMagicAccordion(args: UseMagicAccordionArgs): {
|
|
6
|
+
selectView: (id: string) => void;
|
|
7
|
+
unselectView: (id: string) => void;
|
|
8
|
+
};
|
|
9
|
+
export type UseMagicAccordionReturn = ReturnType<typeof useMagicAccordion>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { InjectionKey, MaybeRef } from 'vue';
|
|
2
|
+
declare const MagicAccordionInstanceId: InjectionKey<MaybeRef<string>>;
|
|
3
|
+
declare const MagicAccordionViewId: InjectionKey<string>;
|
|
4
|
+
declare const MagicAccordionViewActive: InjectionKey<boolean>;
|
|
5
|
+
export { MagicAccordionInstanceId, MagicAccordionViewId, MagicAccordionViewActive, };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
type AccordionMode = 'single' | 'multiple';
|
|
2
|
+
export interface MagicAccordionOptions {
|
|
3
|
+
mode?: AccordionMode;
|
|
4
|
+
transition?: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface AccordionView {
|
|
8
|
+
id: string;
|
|
9
|
+
active: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface AccordionState {
|
|
12
|
+
id: string;
|
|
13
|
+
views: AccordionView[];
|
|
14
|
+
options: MagicAccordionOptions;
|
|
15
|
+
}
|
|
16
|
+
export type Interaction = 'click' | 'mouseenter';
|
|
17
|
+
export type AccordionEvents = {
|
|
18
|
+
beforeEnter: {
|
|
19
|
+
id: string;
|
|
20
|
+
viewId: string;
|
|
21
|
+
};
|
|
22
|
+
enter: {
|
|
23
|
+
id: string;
|
|
24
|
+
viewId: string;
|
|
25
|
+
};
|
|
26
|
+
afterEnter: {
|
|
27
|
+
id: string;
|
|
28
|
+
viewId: string;
|
|
29
|
+
};
|
|
30
|
+
beforeLeave: {
|
|
31
|
+
id: string;
|
|
32
|
+
viewId: string;
|
|
33
|
+
};
|
|
34
|
+
leave: {
|
|
35
|
+
id: string;
|
|
36
|
+
viewId: string;
|
|
37
|
+
};
|
|
38
|
+
afterLeave: {
|
|
39
|
+
id: string;
|
|
40
|
+
viewId: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export {};
|
|
File without changes
|
|
@@ -15,14 +15,18 @@
|
|
|
15
15
|
import { ref, computed, onMounted } from 'vue'
|
|
16
16
|
import { useResizeObserver, useMutationObserver } from '@vueuse/core'
|
|
17
17
|
|
|
18
|
+
import '@maas/vue-equipment/utils/css/easings.css'
|
|
19
|
+
|
|
18
20
|
interface MagicAutoSizeProps {
|
|
19
21
|
width?: boolean
|
|
20
22
|
height?: boolean
|
|
23
|
+
immediate?: boolean
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
const props = withDefaults(defineProps<MagicAutoSizeProps>(), {
|
|
24
27
|
width: true,
|
|
25
28
|
height: true,
|
|
29
|
+
immediate: false,
|
|
26
30
|
})
|
|
27
31
|
|
|
28
32
|
const elRef = ref<HTMLElement | undefined>(undefined)
|
|
@@ -65,15 +69,45 @@ const padding = computed(() => {
|
|
|
65
69
|
}
|
|
66
70
|
})
|
|
67
71
|
|
|
72
|
+
const child = computed(() => {
|
|
73
|
+
return Array.from(elRef.value?.childNodes ?? []).find(
|
|
74
|
+
(n) => n instanceof HTMLElement
|
|
75
|
+
)
|
|
76
|
+
})
|
|
77
|
+
|
|
68
78
|
useMutationObserver(
|
|
69
79
|
elRef,
|
|
70
80
|
(mutations) => {
|
|
71
|
-
|
|
81
|
+
console.log('mutations:', mutations)
|
|
82
|
+
const addedNode = mutations
|
|
72
83
|
.flatMap((m) => [...m.addedNodes])
|
|
73
84
|
.find((n) => n instanceof HTMLElement)
|
|
74
85
|
|
|
75
|
-
|
|
76
|
-
|
|
86
|
+
const addedComment = mutations
|
|
87
|
+
.flatMap((m) => [...m.addedNodes])
|
|
88
|
+
.find((n) => n instanceof Comment)
|
|
89
|
+
|
|
90
|
+
if (!!addedNode && addedNode instanceof HTMLElement) {
|
|
91
|
+
content.value = addedNode
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// If immediate is true, reset the size when a comment is added
|
|
95
|
+
// Vue sets a placeholder comment for a v-if
|
|
96
|
+
if (props.immediate && !!addedComment) {
|
|
97
|
+
content.value = undefined
|
|
98
|
+
size.value = {
|
|
99
|
+
width: 0,
|
|
100
|
+
height: 0,
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// If the node is removed, reset the size
|
|
105
|
+
if (!child.value) {
|
|
106
|
+
content.value = undefined
|
|
107
|
+
size.value = {
|
|
108
|
+
width: 0,
|
|
109
|
+
height: 0,
|
|
110
|
+
}
|
|
77
111
|
}
|
|
78
112
|
},
|
|
79
113
|
{
|
|
@@ -103,11 +137,16 @@ onMounted(() => {
|
|
|
103
137
|
width: filtered.offsetWidth + padding.value.x,
|
|
104
138
|
height: filtered.offsetHeight + padding.value.y,
|
|
105
139
|
}
|
|
140
|
+
} else {
|
|
141
|
+
size.value = {
|
|
142
|
+
width: 0,
|
|
143
|
+
height: 0,
|
|
144
|
+
}
|
|
106
145
|
}
|
|
107
146
|
}
|
|
108
147
|
})
|
|
109
148
|
</script>
|
|
110
149
|
|
|
111
150
|
<style>
|
|
112
|
-
|
|
151
|
+
:root{--magic-auto-size-transition:all 150ms var(--ease-in-out)}.magic-auto-size{height:var(--magic-auto-size-height);transition:var(--magic-auto-size-transition);width:var(--magic-auto-size-width)}
|
|
113
152
|
</style>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import '@maas/vue-equipment/utils/css/easings.css';
|
|
1
2
|
interface MagicAutoSizeProps {
|
|
2
3
|
width?: boolean;
|
|
3
4
|
height?: boolean;
|
|
5
|
+
immediate?: boolean;
|
|
4
6
|
}
|
|
5
7
|
declare function __VLS_template(): {
|
|
6
8
|
default?(_: {}): any;
|
|
@@ -8,16 +10,18 @@ declare function __VLS_template(): {
|
|
|
8
10
|
declare const __VLS_component: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<MagicAutoSizeProps>, {
|
|
9
11
|
width: boolean;
|
|
10
12
|
height: boolean;
|
|
13
|
+
immediate: boolean;
|
|
11
14
|
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<MagicAutoSizeProps>, {
|
|
12
15
|
width: boolean;
|
|
13
16
|
height: boolean;
|
|
17
|
+
immediate: boolean;
|
|
14
18
|
}>>>, {
|
|
19
|
+
immediate: boolean;
|
|
15
20
|
width: boolean;
|
|
16
21
|
height: boolean;
|
|
17
22
|
}, {}>;
|
|
18
23
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
|
19
24
|
export default _default;
|
|
20
|
-
|
|
21
25
|
type __VLS_WithDefaults<P, D> = {
|
|
22
26
|
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
23
27
|
default: D[K];
|
|
@@ -193,7 +193,7 @@ const { initializeWheelListener, destroyWheelListener } = useDrawerWheel({
|
|
|
193
193
|
disabled,
|
|
194
194
|
})
|
|
195
195
|
|
|
196
|
-
const { initializeState } = useDrawerState(props.id)
|
|
196
|
+
const { initializeState, deleteState } = useDrawerState(props.id)
|
|
197
197
|
const { dragging, wheeling } = initializeState()
|
|
198
198
|
|
|
199
199
|
// Split isActive into two values to animate drawer smoothly
|
|
@@ -368,6 +368,8 @@ onUnmounted(() => {
|
|
|
368
368
|
if (!mappedOptions.preventZoom) {
|
|
369
369
|
resetMetaViewport()
|
|
370
370
|
}
|
|
371
|
+
|
|
372
|
+
deleteState()
|
|
371
373
|
})
|
|
372
374
|
</script>
|
|
373
375
|
|
|
@@ -1,50 +1,7 @@
|
|
|
1
|
-
import { type MaybeRef } from 'vue';
|
|
1
|
+
import { type Ref, type MaybeRef } from 'vue';
|
|
2
2
|
import type { DrawerState } from '../../types/index.js';
|
|
3
3
|
export declare function useDrawerState(id: MaybeRef<string>): {
|
|
4
|
-
addState: (id: string) => {
|
|
5
|
-
id: string;
|
|
6
|
-
dragStart: Date | undefined;
|
|
7
|
-
dragging: boolean;
|
|
8
|
-
wheeling: boolean;
|
|
9
|
-
progress: {
|
|
10
|
-
x: number;
|
|
11
|
-
y: number;
|
|
12
|
-
};
|
|
13
|
-
shouldClose: boolean;
|
|
14
|
-
interpolateTo: number | undefined;
|
|
15
|
-
originX: number;
|
|
16
|
-
originY: number;
|
|
17
|
-
lastDraggedX: number;
|
|
18
|
-
lastDraggedY: number;
|
|
19
|
-
draggedX: number;
|
|
20
|
-
draggedY: number;
|
|
21
|
-
relDirectionY: "below" | "above" | "absolute";
|
|
22
|
-
relDirectionX: "below" | "above" | "absolute";
|
|
23
|
-
absDirectionY: "with" | "against" | undefined;
|
|
24
|
-
absDirectionX: "with" | "against" | undefined;
|
|
25
|
-
elRect: {
|
|
26
|
-
height: number;
|
|
27
|
-
width: number;
|
|
28
|
-
x: number;
|
|
29
|
-
y: number;
|
|
30
|
-
readonly bottom: number;
|
|
31
|
-
readonly left: number;
|
|
32
|
-
readonly right: number;
|
|
33
|
-
readonly top: number;
|
|
34
|
-
toJSON: () => any;
|
|
35
|
-
} | undefined;
|
|
36
|
-
wrapperRect: {
|
|
37
|
-
height: number;
|
|
38
|
-
width: number;
|
|
39
|
-
x: number;
|
|
40
|
-
y: number;
|
|
41
|
-
readonly bottom: number;
|
|
42
|
-
readonly left: number;
|
|
43
|
-
readonly right: number;
|
|
44
|
-
readonly top: number;
|
|
45
|
-
toJSON: () => any;
|
|
46
|
-
} | undefined;
|
|
47
|
-
};
|
|
48
4
|
initializeState: () => import("vue").ToRefs<DrawerState>;
|
|
49
5
|
deleteState: () => void;
|
|
6
|
+
drawerStateStore: Ref<DrawerState[]>;
|
|
50
7
|
};
|
|
@@ -4,6 +4,7 @@ export function useDrawerState(id) {
|
|
|
4
4
|
function createState(id2) {
|
|
5
5
|
const state = {
|
|
6
6
|
id: id2,
|
|
7
|
+
active: false,
|
|
7
8
|
dragStart: void 0,
|
|
8
9
|
dragging: false,
|
|
9
10
|
wheeling: false,
|
|
@@ -44,8 +45,8 @@ export function useDrawerState(id) {
|
|
|
44
45
|
drawerStateStore.value = drawerStateStore.value.filter((x) => x.id !== id);
|
|
45
46
|
}
|
|
46
47
|
return {
|
|
47
|
-
addState,
|
|
48
48
|
initializeState,
|
|
49
|
-
deleteState
|
|
49
|
+
deleteState,
|
|
50
|
+
drawerStateStore
|
|
50
51
|
};
|
|
51
52
|
}
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import { computed, toValue } from "vue";
|
|
2
2
|
import { useMagicEmitter } from "@maas/vue-equipment/plugins";
|
|
3
|
-
import { useDrawerStore } from "./private/useDrawerStore.mjs";
|
|
4
3
|
import { useDrawerState } from "./private/useDrawerState.mjs";
|
|
5
4
|
export function useMagicDrawer(id) {
|
|
6
|
-
const {
|
|
7
|
-
const {
|
|
8
|
-
const
|
|
9
|
-
const isActive = computed(() => drawerStore.value.includes(toValue(id)));
|
|
5
|
+
const { initializeState } = useDrawerState(toValue(id));
|
|
6
|
+
const { progress, active } = initializeState();
|
|
7
|
+
const isActive = computed(() => active.value);
|
|
10
8
|
function open() {
|
|
11
|
-
|
|
9
|
+
active.value = true;
|
|
12
10
|
}
|
|
13
11
|
function close() {
|
|
14
|
-
|
|
15
|
-
deleteState();
|
|
12
|
+
active.value = false;
|
|
16
13
|
}
|
|
17
14
|
function snapTo(snapPoint, duration) {
|
|
18
15
|
useMagicEmitter().emit("snapTo", {
|