@maas/vue-equipment 0.2.0 → 0.3.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.
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@maas/vue-equipment",
3
3
  "configKey": "vueEquipment",
4
- "version": "0.1.3"
4
+ "version": "0.2.0"
5
5
  }
@@ -18,7 +18,7 @@ const functions = [
18
18
  {
19
19
  name: "MagicModal",
20
20
  "package": "plugins",
21
- lastUpdated: 1689600576000,
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: 1689669455000,
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 };
@@ -23,7 +23,9 @@
23
23
  </transition>
24
24
  <transition
25
25
  :name="mappedOptions.transitions?.content"
26
+ @before-leave="onBeforeLeave"
26
27
  @after-leave="onAfterLeave"
28
+ @before-enter="onBeforeEnter"
27
29
  @after-enter="onAfterEnter"
28
30
  >
29
31
  <div
@@ -49,7 +51,9 @@
49
51
  import { ref, watch, nextTick } from 'vue'
50
52
  import { useModalApi } from './../composables/useModalApi'
51
53
  import { onKeyStroke } from '@vueuse/core'
54
+ import { toValue } from '@vueuse/shared'
52
55
  import { defaultOptions } from './../utils/defaultOptions'
56
+ import { useModalEmitter } from './../composables/useModalEmitter'
53
57
 
54
58
  import type { MaybeRef } from '@vueuse/core'
55
59
  import type { DefaultOptions } from './../types/index'
@@ -102,6 +106,10 @@ function onClose() {
102
106
  }
103
107
 
104
108
  // Transition Callbacks
109
+ function onBeforeEnter() {
110
+ useModalEmitter().emit('beforeEnter', toValue(props.id))
111
+ }
112
+
105
113
  async function onAfterEnter() {
106
114
  if (mappedOptions.scrollLock) {
107
115
  if (mappedOptions.scrollLockPadding) {
@@ -115,6 +123,12 @@ async function onAfterEnter() {
115
123
  await nextTick()
116
124
  trapFocus()
117
125
  }
126
+
127
+ useModalEmitter().emit('afterEnter', toValue(props.id))
128
+ }
129
+
130
+ function onBeforeLeave() {
131
+ useModalEmitter().emit('beforeLeave', toValue(props.id))
118
132
  }
119
133
 
120
134
  function onAfterLeave() {
@@ -130,6 +144,7 @@ function onAfterLeave() {
130
144
  }
131
145
 
132
146
  wrapperActive.value = false
147
+ useModalEmitter().emit('afterLeave', toValue(props.id))
133
148
  }
134
149
 
135
150
  onKeyStroke('Escape', (e) => {
@@ -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
+ };
@@ -1,6 +1,6 @@
1
1
  import mitt from "mitt";
2
2
  const emitter = mitt();
3
- export function useEmitter() {
3
+ export function useModalEmitter() {
4
4
  return {
5
5
  on: emitter.on,
6
6
  off: emitter.off,
@@ -12,4 +12,10 @@ type DefaultOptions = {
12
12
  backdrop?: string;
13
13
  };
14
14
  };
15
- export type { DefaultOptions };
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 { useEmitter } from './src/composables/useEmitter.js';
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, useEmitter, useProgress, useCollisionDetect };
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 { useEmitter } from "./src/composables/useEmitter.mjs";
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, useEmitter, useProgress, useCollisionDetect };
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 { useEmitter } from "./useEmitter.mjs";
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
- useEmitter().emit("magic-scroll:collision", {
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
+ };
@@ -0,0 +1,9 @@
1
+ import mitt from "mitt";
2
+ const emitter = mitt();
3
+ export function useCollisionEmitter() {
4
+ return {
5
+ on: emitter.on,
6
+ off: emitter.off,
7
+ emit: emitter.emit
8
+ };
9
+ }
@@ -3,7 +3,7 @@ type AlertPositions = {
3
3
  bottom: boolean;
4
4
  };
5
5
  type CollisionEvents = {
6
- 'magic-scroll:collision': {
6
+ collision: {
7
7
  dir: 'up' | 'down';
8
8
  pos: 'top' | 'bottom';
9
9
  el: HTMLElement;
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.2.0",
4
+ "version": "0.3.0",
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
- "dev": "turbo run docs:dev && nr docs:dev",
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-it && release-it"
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
- };