@maas/vue-equipment 0.14.3 → 0.14.4
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/plugins/MagicDrawer/src/components/MagicDrawer.vue +43 -2
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerCallback.d.ts +1 -0
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerCallback.mjs +3 -1
- package/dist/plugins/MagicDrawer/src/types/index.d.ts +4 -0
- package/dist/plugins/MagicDrawer/src/utils/defaultOptions.mjs +5 -1
- package/dist/plugins/MagicModal/src/components/MagicModal.vue +6 -0
- package/package.json +1 -1
package/dist/nuxt/module.json
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
>
|
|
20
20
|
<transition
|
|
21
21
|
v-if="mappedOptions.backdrop || !!$slots.backdrop"
|
|
22
|
-
:name="
|
|
22
|
+
:name="backdropTransition"
|
|
23
23
|
>
|
|
24
24
|
<div
|
|
25
25
|
v-show="innerActive"
|
|
@@ -29,9 +29,10 @@
|
|
|
29
29
|
<slot name="backdrop" />
|
|
30
30
|
</div>
|
|
31
31
|
</transition>
|
|
32
|
+
|
|
32
33
|
<div class="magic-drawer__wrapper">
|
|
33
34
|
<transition
|
|
34
|
-
:name="
|
|
35
|
+
:name="contentTransition"
|
|
35
36
|
@before-leave="onBeforeLeave"
|
|
36
37
|
@leave="onLeave"
|
|
37
38
|
@after-leave="onAfterLeave"
|
|
@@ -65,8 +66,11 @@
|
|
|
65
66
|
import {
|
|
66
67
|
ref,
|
|
67
68
|
watch,
|
|
69
|
+
computed,
|
|
68
70
|
nextTick,
|
|
69
71
|
toValue,
|
|
72
|
+
onBeforeMount,
|
|
73
|
+
onBeforeUnmount,
|
|
70
74
|
type Component,
|
|
71
75
|
type MaybeRef,
|
|
72
76
|
} from 'vue'
|
|
@@ -113,6 +117,7 @@ const props = withDefaults(defineProps<MagicDrawerProps>(), {
|
|
|
113
117
|
const elRef = ref<HTMLDivElement | undefined>(undefined)
|
|
114
118
|
const drawerRef = ref<HTMLElement | undefined>(undefined)
|
|
115
119
|
const drawerApi = useDrawerApi(props.id, { focusTarget: drawerRef })
|
|
120
|
+
|
|
116
121
|
const mappedOptions: typeof defaultOptions = customDefu(
|
|
117
122
|
props.options,
|
|
118
123
|
defaultOptions
|
|
@@ -123,6 +128,7 @@ const { position, threshold } = mappedOptions
|
|
|
123
128
|
|
|
124
129
|
const {
|
|
125
130
|
isActive,
|
|
131
|
+
open,
|
|
126
132
|
close,
|
|
127
133
|
trapFocus,
|
|
128
134
|
releaseFocus,
|
|
@@ -143,6 +149,7 @@ const { onPointerdown, dragging, style } = useDrawerDrag({
|
|
|
143
149
|
// Split isActive into two values to animate drawer smoothly
|
|
144
150
|
const innerActive = ref(false)
|
|
145
151
|
const wrapperActive = ref(false)
|
|
152
|
+
const wasActive = ref(false)
|
|
146
153
|
|
|
147
154
|
const {
|
|
148
155
|
onBeforeEnter,
|
|
@@ -161,6 +168,29 @@ const {
|
|
|
161
168
|
trapFocus,
|
|
162
169
|
releaseFocus,
|
|
163
170
|
wrapperActive,
|
|
171
|
+
wasActive,
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
// Surpress animation on initial mount if the options call for it
|
|
175
|
+
// To achive this, the transition names are set to undefined
|
|
176
|
+
const surpressTransition = computed(() => {
|
|
177
|
+
return (
|
|
178
|
+
mappedOptions.beforeMount.open &&
|
|
179
|
+
!mappedOptions.beforeMount.animate &&
|
|
180
|
+
!wasActive.value
|
|
181
|
+
)
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
const backdropTransition = computed(() => {
|
|
185
|
+
return surpressTransition.value
|
|
186
|
+
? undefined
|
|
187
|
+
: mappedOptions.transitions?.backdrop
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
const contentTransition = computed(() => {
|
|
191
|
+
return surpressTransition.value
|
|
192
|
+
? undefined
|
|
193
|
+
: mappedOptions.transitions?.content
|
|
164
194
|
})
|
|
165
195
|
|
|
166
196
|
// Handle state
|
|
@@ -229,6 +259,17 @@ watch(isActive, async (value) => {
|
|
|
229
259
|
watch(innerActive, () => {
|
|
230
260
|
saveOvershoot()
|
|
231
261
|
})
|
|
262
|
+
|
|
263
|
+
onBeforeMount(() => {
|
|
264
|
+
if (mappedOptions.beforeMount.open) {
|
|
265
|
+
open()
|
|
266
|
+
}
|
|
267
|
+
})
|
|
268
|
+
|
|
269
|
+
// Reset state on unmount
|
|
270
|
+
onBeforeUnmount(() => {
|
|
271
|
+
close()
|
|
272
|
+
})
|
|
232
273
|
</script>
|
|
233
274
|
|
|
234
275
|
<style>
|
|
@@ -10,6 +10,7 @@ type UseDrawerCallbackArgs = {
|
|
|
10
10
|
trapFocus: () => void;
|
|
11
11
|
releaseFocus: () => void;
|
|
12
12
|
wrapperActive: Ref<boolean>;
|
|
13
|
+
wasActive: Ref<boolean>;
|
|
13
14
|
};
|
|
14
15
|
export declare function useDrawerCallback(args: UseDrawerCallbackArgs): {
|
|
15
16
|
onBeforeEnter: (_el: Element) => void;
|
|
@@ -10,7 +10,8 @@ export function useDrawerCallback(args) {
|
|
|
10
10
|
unlockScroll,
|
|
11
11
|
trapFocus,
|
|
12
12
|
releaseFocus,
|
|
13
|
-
wrapperActive
|
|
13
|
+
wrapperActive,
|
|
14
|
+
wasActive
|
|
14
15
|
} = args;
|
|
15
16
|
function onBeforeEnter(_el) {
|
|
16
17
|
useDrawerEmitter().emit("beforeEnter", toValue(id));
|
|
@@ -30,6 +31,7 @@ export function useDrawerCallback(args) {
|
|
|
30
31
|
await nextTick();
|
|
31
32
|
trapFocus();
|
|
32
33
|
}
|
|
34
|
+
wasActive.value = true;
|
|
33
35
|
}
|
|
34
36
|
function onBeforeLeave(_el) {
|
|
35
37
|
useDrawerEmitter().emit("beforeLeave", toValue(id));
|
|
@@ -60,6 +60,7 @@ import {
|
|
|
60
60
|
watch,
|
|
61
61
|
nextTick,
|
|
62
62
|
toValue,
|
|
63
|
+
onBeforeUnmount,
|
|
63
64
|
type Component,
|
|
64
65
|
type MaybeRef,
|
|
65
66
|
} from 'vue'
|
|
@@ -159,6 +160,11 @@ watch(isActive, async (value) => {
|
|
|
159
160
|
onClose()
|
|
160
161
|
}
|
|
161
162
|
})
|
|
163
|
+
|
|
164
|
+
// Reset state on unmount
|
|
165
|
+
onBeforeUnmount(() => {
|
|
166
|
+
close()
|
|
167
|
+
})
|
|
162
168
|
</script>
|
|
163
169
|
|
|
164
170
|
<style>
|
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.14.
|
|
4
|
+
"version": "0.14.4",
|
|
5
5
|
"author": "Robin Scholz <https://github.com/robinscholz>, Christoph Jeworutzki <https://github.com/ChristophJeworutzki>",
|
|
6
6
|
"devDependencies": {
|
|
7
7
|
"@antfu/ni": "^0.21.12",
|