@maas/vue-equipment 0.2.0 → 0.3.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.
- package/dist/nuxt/module.json +1 -1
- package/dist/nuxt/module.mjs +2 -2
- package/dist/plugins/MagicModal/index.d.ts +2 -1
- package/dist/plugins/MagicModal/index.mjs +2 -1
- package/dist/plugins/MagicModal/src/components/MagicModal.vue +28 -5
- package/dist/plugins/MagicModal/src/composables/useModalEmitter.d.ts +15 -0
- package/dist/plugins/{MagicScroll/src/composables/useEmitter.mjs → MagicModal/src/composables/useModalEmitter.mjs} +1 -1
- package/dist/plugins/MagicModal/src/types/index.d.ts +7 -1
- package/dist/plugins/MagicScroll/index.d.ts +2 -2
- package/dist/plugins/MagicScroll/index.mjs +2 -2
- package/dist/plugins/MagicScroll/src/composables/useCollisionDetect.mjs +2 -2
- package/dist/plugins/MagicScroll/src/composables/useCollisionEmitter.d.ts +15 -0
- package/dist/plugins/MagicScroll/src/composables/useCollisionEmitter.mjs +9 -0
- package/dist/plugins/MagicScroll/src/types/index.d.ts +1 -1
- package/package.json +6 -7
- package/dist/plugins/MagicScroll/src/composables/useEmitter.d.ts +0 -15
- /package/dist/plugins/MagicModal/src/{store → composables/store}/modals.d.ts +0 -0
- /package/dist/plugins/MagicModal/src/{store → composables/store}/modals.mjs +0 -0
package/dist/nuxt/module.json
CHANGED
package/dist/nuxt/module.mjs
CHANGED
|
@@ -18,7 +18,7 @@ const functions = [
|
|
|
18
18
|
{
|
|
19
19
|
name: "MagicModal",
|
|
20
20
|
"package": "plugins",
|
|
21
|
-
lastUpdated:
|
|
21
|
+
lastUpdated: 1691152994000,
|
|
22
22
|
docs: "https://maas.egineering/vue-equipment/plugins/MagicModal/",
|
|
23
23
|
description: "modal"
|
|
24
24
|
},
|
|
@@ -32,7 +32,7 @@ const functions = [
|
|
|
32
32
|
{
|
|
33
33
|
name: "MagicScroll",
|
|
34
34
|
"package": "plugins",
|
|
35
|
-
lastUpdated:
|
|
35
|
+
lastUpdated: 1691152994000,
|
|
36
36
|
docs: "https://maas.egineering/vue-equipment/plugins/MagicScroll/",
|
|
37
37
|
description: "scroll"
|
|
38
38
|
},
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useModalApi } from './src/composables/useModalApi.js';
|
|
2
|
+
import { useModalEmitter } from './src/composables/useModalEmitter.js';
|
|
2
3
|
import type { Plugin } from 'vue';
|
|
3
4
|
declare const MagicModal: Plugin;
|
|
4
|
-
export { MagicModal, useModalApi };
|
|
5
|
+
export { MagicModal, useModalEmitter, useModalApi };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import MagicModalComponent from "./src/components/MagicModal.vue";
|
|
2
2
|
import { useModalApi } from "./src/composables/useModalApi.mjs";
|
|
3
|
+
import { useModalEmitter } from "./src/composables/useModalEmitter.mjs";
|
|
3
4
|
const MagicModal = {
|
|
4
5
|
install: (app) => {
|
|
5
6
|
app.component("MagicModal", MagicModalComponent);
|
|
6
7
|
}
|
|
7
8
|
};
|
|
8
|
-
export { MagicModal, useModalApi };
|
|
9
|
+
export { MagicModal, useModalEmitter, useModalApi };
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
<dialog
|
|
9
9
|
ref="modal"
|
|
10
10
|
class="magic-modal"
|
|
11
|
+
:id="toValue(id)"
|
|
11
12
|
@click.self="close"
|
|
12
13
|
aria-modal="true"
|
|
13
14
|
>
|
|
@@ -23,7 +24,9 @@
|
|
|
23
24
|
</transition>
|
|
24
25
|
<transition
|
|
25
26
|
:name="mappedOptions.transitions?.content"
|
|
27
|
+
@before-leave="onBeforeLeave"
|
|
26
28
|
@after-leave="onAfterLeave"
|
|
29
|
+
@before-enter="onBeforeEnter"
|
|
27
30
|
@after-enter="onAfterEnter"
|
|
28
31
|
>
|
|
29
32
|
<div
|
|
@@ -49,7 +52,9 @@
|
|
|
49
52
|
import { ref, watch, nextTick } from 'vue'
|
|
50
53
|
import { useModalApi } from './../composables/useModalApi'
|
|
51
54
|
import { onKeyStroke } from '@vueuse/core'
|
|
55
|
+
import { toValue } from '@vueuse/shared'
|
|
52
56
|
import { defaultOptions } from './../utils/defaultOptions'
|
|
57
|
+
import { useModalEmitter } from './../composables/useModalEmitter'
|
|
53
58
|
|
|
54
59
|
import type { MaybeRef } from '@vueuse/core'
|
|
55
60
|
import type { DefaultOptions } from './../types/index'
|
|
@@ -102,6 +107,10 @@ function onClose() {
|
|
|
102
107
|
}
|
|
103
108
|
|
|
104
109
|
// Transition Callbacks
|
|
110
|
+
function onBeforeEnter() {
|
|
111
|
+
useModalEmitter().emit('beforeEnter', toValue(props.id))
|
|
112
|
+
}
|
|
113
|
+
|
|
105
114
|
async function onAfterEnter() {
|
|
106
115
|
if (mappedOptions.scrollLock) {
|
|
107
116
|
if (mappedOptions.scrollLockPadding) {
|
|
@@ -115,6 +124,12 @@ async function onAfterEnter() {
|
|
|
115
124
|
await nextTick()
|
|
116
125
|
trapFocus()
|
|
117
126
|
}
|
|
127
|
+
|
|
128
|
+
useModalEmitter().emit('afterEnter', toValue(props.id))
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function onBeforeLeave() {
|
|
132
|
+
useModalEmitter().emit('beforeLeave', toValue(props.id))
|
|
118
133
|
}
|
|
119
134
|
|
|
120
135
|
function onAfterLeave() {
|
|
@@ -130,6 +145,7 @@ function onAfterLeave() {
|
|
|
130
145
|
}
|
|
131
146
|
|
|
132
147
|
wrapperActive.value = false
|
|
148
|
+
useModalEmitter().emit('afterLeave', toValue(props.id))
|
|
133
149
|
}
|
|
134
150
|
|
|
135
151
|
onKeyStroke('Escape', (e) => {
|
|
@@ -147,9 +163,10 @@ watch(isActive, async (value) => {
|
|
|
147
163
|
</script>
|
|
148
164
|
|
|
149
165
|
<style lang="postcss">
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
166
|
+
:root {
|
|
167
|
+
--magic-modal-z-index: 999;
|
|
168
|
+
--magic-modal-backdrop-color: rgba(0, 0, 0, 0.5);
|
|
169
|
+
--magic-modal-backdrop-filter: unset;
|
|
153
170
|
}
|
|
154
171
|
|
|
155
172
|
.magic-modal {
|
|
@@ -160,13 +177,18 @@ watch(isActive, async (value) => {
|
|
|
160
177
|
display: flex;
|
|
161
178
|
justify-content: center;
|
|
162
179
|
align-items: center;
|
|
163
|
-
z-index:
|
|
180
|
+
z-index: var(--magic-modal-z-index);
|
|
164
181
|
background: transparent;
|
|
165
182
|
color: inherit;
|
|
166
183
|
padding: 0;
|
|
167
184
|
border: none;
|
|
168
185
|
}
|
|
169
186
|
|
|
187
|
+
.magic-modal * {
|
|
188
|
+
transition-duration: 0s;
|
|
189
|
+
animation-duration: 0s;
|
|
190
|
+
}
|
|
191
|
+
|
|
170
192
|
.magic-modal__content {
|
|
171
193
|
-webkit-overflow-scrolling: touch;
|
|
172
194
|
scroll-behavior: smooth;
|
|
@@ -186,7 +208,8 @@ watch(isActive, async (value) => {
|
|
|
186
208
|
bottom: 0;
|
|
187
209
|
width: 100%;
|
|
188
210
|
height: 100%;
|
|
189
|
-
background-color:
|
|
211
|
+
background-color: var(--magic-modal-backdrop-color);
|
|
212
|
+
backdrop-filter: var(--magic-modal-backdrop-filter);
|
|
190
213
|
z-index: -1;
|
|
191
214
|
}
|
|
192
215
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ModalEvents } from '../types.js';
|
|
2
|
+
export declare function useModalEmitter(): {
|
|
3
|
+
on: {
|
|
4
|
+
<Key extends keyof ModalEvents>(type: Key, handler: import("mitt").Handler<ModalEvents[Key]>): void;
|
|
5
|
+
(type: "*", handler: import("mitt").WildcardHandler<ModalEvents>): void;
|
|
6
|
+
};
|
|
7
|
+
off: {
|
|
8
|
+
<Key_1 extends keyof ModalEvents>(type: Key_1, handler?: import("mitt").Handler<ModalEvents[Key_1]> | undefined): void;
|
|
9
|
+
(type: "*", handler: import("mitt").WildcardHandler<ModalEvents>): void;
|
|
10
|
+
};
|
|
11
|
+
emit: {
|
|
12
|
+
<Key_2 extends keyof ModalEvents>(type: Key_2, event: ModalEvents[Key_2]): void;
|
|
13
|
+
<Key_3 extends keyof ModalEvents>(type: undefined extends ModalEvents[Key_3] ? Key_3 : never): void;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -12,4 +12,10 @@ type DefaultOptions = {
|
|
|
12
12
|
backdrop?: string;
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
|
-
|
|
15
|
+
type ModalEvents = {
|
|
16
|
+
afterEnter: string;
|
|
17
|
+
afterLeave: string;
|
|
18
|
+
beforeEnter: string;
|
|
19
|
+
beforeLeave: string;
|
|
20
|
+
};
|
|
21
|
+
export type { DefaultOptions, ModalEvents };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useCollisionEmitter } from './src/composables/useCollisionEmitter.js';
|
|
2
2
|
import { useProgress } from './src/composables/useProgress.js';
|
|
3
3
|
import { useCollisionDetect } from './src/composables/useCollisionDetect.js';
|
|
4
4
|
import type { Plugin } from 'vue';
|
|
5
5
|
export type * from './src/types';
|
|
6
6
|
declare const MagicScroll: Plugin;
|
|
7
|
-
export { MagicScroll,
|
|
7
|
+
export { MagicScroll, useCollisionEmitter, useProgress, useCollisionDetect };
|
|
@@ -3,7 +3,7 @@ import MagicScrollScene from "./src/components/MagicScrollScene.vue";
|
|
|
3
3
|
import MagicScrollTransform from "./src/components/MagicScrollTransform.vue";
|
|
4
4
|
import MagicScrollCollision from "./src/components/MagicScrollCollision.vue";
|
|
5
5
|
import { magicScrollStore } from "./src/store/index.mjs";
|
|
6
|
-
import {
|
|
6
|
+
import { useCollisionEmitter } from "./src/composables/useCollisionEmitter.mjs";
|
|
7
7
|
import { useProgress } from "./src/composables/useProgress.mjs";
|
|
8
8
|
import { useCollisionDetect } from "./src/composables/useCollisionDetect.mjs";
|
|
9
9
|
import { StoreKey } from "./src/types/index.mjs";
|
|
@@ -16,4 +16,4 @@ const MagicScroll = {
|
|
|
16
16
|
app.provide(StoreKey, magicScrollStore);
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
|
-
export { MagicScroll,
|
|
19
|
+
export { MagicScroll, useCollisionEmitter, useProgress, useCollisionDetect };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ref, watch, unref, computed } from "vue";
|
|
2
2
|
import { useIntersectionObserver } from "@vueuse/core";
|
|
3
|
-
import {
|
|
3
|
+
import { useCollisionEmitter } from "./useCollisionEmitter.mjs";
|
|
4
4
|
export function useCollisionDetect(pageYOffset, windowDimensions, collisionEntries, parent) {
|
|
5
5
|
const scrolled = ref(0);
|
|
6
6
|
const intersecting = ref();
|
|
@@ -85,7 +85,7 @@ export function useCollisionDetect(pageYOffset, windowDimensions, collisionEntri
|
|
|
85
85
|
return;
|
|
86
86
|
if (dir === "down" && boundingRect[pos] <= offset || dir === "up" && boundingRect[pos] >= offset) {
|
|
87
87
|
entry.alerted[dir][pos] = true;
|
|
88
|
-
|
|
88
|
+
useCollisionEmitter().emit("collision", {
|
|
89
89
|
dir,
|
|
90
90
|
pos,
|
|
91
91
|
el: entry.element,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CollisionEvents } from '../types.js';
|
|
2
|
+
export declare function useCollisionEmitter(): {
|
|
3
|
+
on: {
|
|
4
|
+
<Key extends "collision">(type: Key, handler: import("mitt").Handler<CollisionEvents[Key]>): void;
|
|
5
|
+
(type: "*", handler: import("mitt").WildcardHandler<CollisionEvents>): void;
|
|
6
|
+
};
|
|
7
|
+
off: {
|
|
8
|
+
<Key_1 extends "collision">(type: Key_1, handler?: import("mitt").Handler<CollisionEvents[Key_1]> | undefined): void;
|
|
9
|
+
(type: "*", handler: import("mitt").WildcardHandler<CollisionEvents>): void;
|
|
10
|
+
};
|
|
11
|
+
emit: {
|
|
12
|
+
<Key_2 extends "collision">(type: Key_2, event: CollisionEvents[Key_2]): void;
|
|
13
|
+
<Key_3 extends "collision">(type: undefined extends CollisionEvents[Key_3] ? Key_3 : never): void;
|
|
14
|
+
};
|
|
15
|
+
};
|
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.
|
|
4
|
+
"version": "0.3.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",
|
|
@@ -87,18 +87,17 @@
|
|
|
87
87
|
}
|
|
88
88
|
},
|
|
89
89
|
"scripts": {
|
|
90
|
+
"dev": "nr dev:docs",
|
|
91
|
+
"dev:docs": "turbo run t:docs:dev && vitepress dev packages",
|
|
92
|
+
"dev:nuxt": "turbo run dev --filter=nuxt",
|
|
90
93
|
"build": "turbo run build",
|
|
91
94
|
"build:types": "turbo run build:types",
|
|
92
|
-
"
|
|
93
|
-
"dev:nuxt": "turbo run dev --filter=nuxt",
|
|
94
|
-
"docs:build": "turbo run docs:build && vitepress build packages",
|
|
95
|
-
"docs:dev": "vitepress dev packages",
|
|
95
|
+
"docs:build": "turbo run t:docs:build && vitepress build packages",
|
|
96
96
|
"docs:preview": "vitepress preview packages",
|
|
97
97
|
"metadata:update": "nr -C packages/metadata update",
|
|
98
|
-
"module:dev": "cd packages/nuxt && nr dev",
|
|
99
98
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
100
99
|
"uninstall": "nlx rimraf --glob ./**/node_modules --glob ./**/pnpm-lock.yaml",
|
|
101
|
-
"release": "turbo run release
|
|
100
|
+
"release": "turbo run t:release && release-it"
|
|
102
101
|
},
|
|
103
102
|
"types": "./dist/nuxt/types.d.ts",
|
|
104
103
|
"volta": {
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { CollisionEvents } from '../types.js';
|
|
2
|
-
export declare function useEmitter(): {
|
|
3
|
-
on: {
|
|
4
|
-
<Key extends "magic-scroll:collision">(type: Key, handler: import("mitt").Handler<CollisionEvents[Key]>): void;
|
|
5
|
-
(type: "*", handler: import("mitt").WildcardHandler<CollisionEvents>): void;
|
|
6
|
-
};
|
|
7
|
-
off: {
|
|
8
|
-
<Key_1 extends "magic-scroll:collision">(type: Key_1, handler?: import("mitt").Handler<CollisionEvents[Key_1]> | undefined): void;
|
|
9
|
-
(type: "*", handler: import("mitt").WildcardHandler<CollisionEvents>): void;
|
|
10
|
-
};
|
|
11
|
-
emit: {
|
|
12
|
-
<Key_2 extends "magic-scroll:collision">(type: Key_2, event: CollisionEvents[Key_2]): void;
|
|
13
|
-
<Key_3 extends "magic-scroll:collision">(type: undefined extends CollisionEvents[Key_3] ? Key_3 : never): void;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
File without changes
|
|
File without changes
|