@maas/vue-equipment 0.14.2 → 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.
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@maas/vue-equipment/nuxt",
3
3
  "configKey": "vueEquipment",
4
- "version": "0.14.1"
4
+ "version": "0.14.3"
5
5
  }
@@ -4,14 +4,14 @@ const functions$1 = [
4
4
  {
5
5
  name: "MagicConsent",
6
6
  "package": "plugins",
7
- lastUpdated: 1696320008000,
7
+ lastUpdated: 1705422905000,
8
8
  docs: "https://maas.egineering/vue-equipment/plugins/MagicConsent/",
9
9
  description: "consent"
10
10
  },
11
11
  {
12
12
  name: "MagicDrawer",
13
13
  "package": "plugins",
14
- lastUpdated: 1704735337000,
14
+ lastUpdated: 1705422905000,
15
15
  docs: "https://maas.egineering/vue-equipment/plugins/MagicDrawer/",
16
16
  description: "drawer"
17
17
  },
@@ -25,7 +25,7 @@ const functions$1 = [
25
25
  {
26
26
  name: "MagicModal",
27
27
  "package": "plugins",
28
- lastUpdated: 1695042962000,
28
+ lastUpdated: 1705422905000,
29
29
  docs: "https://maas.egineering/vue-equipment/plugins/MagicModal/",
30
30
  description: "modal"
31
31
  },
@@ -53,7 +53,7 @@ const functions$1 = [
53
53
  {
54
54
  name: "MagicToast",
55
55
  "package": "plugins",
56
- lastUpdated: 1695042962000,
56
+ lastUpdated: 1705422905000,
57
57
  docs: "https://maas.egineering/vue-equipment/plugins/MagicToast/",
58
58
  description: "toast"
59
59
  },
@@ -2,5 +2,7 @@ import type { Plugin } from 'vue';
2
2
  import MagicConsent from './src/components/MagicConsent.vue.js';
3
3
  import { useConsentApi } from './src/composables/useConsentApi.js';
4
4
  import { useConsentEmitter } from './src/composables/useConsentEmitter.js';
5
+ import type { ConsentEvents } from './src/types.js';
5
6
  declare const MagicConsentPlugin: Plugin;
6
7
  export { MagicConsentPlugin, MagicConsent, useConsentApi, useConsentEmitter };
8
+ export type { ConsentEvents };
@@ -2,5 +2,7 @@ import MagicDrawer from './src/components/MagicDrawer.vue.js';
2
2
  import { useDrawerApi } from './src/composables/useDrawerApi.js';
3
3
  import { useDrawerEmitter } from './src/composables/useDrawerEmitter.js';
4
4
  import type { Plugin } from 'vue';
5
+ import type { DrawerEvents } from './src/types.js';
5
6
  declare const MagicDrawerPlugin: Plugin;
6
7
  export { MagicDrawerPlugin, MagicDrawer, useDrawerApi, useDrawerEmitter };
8
+ export type { DrawerEvents };
@@ -7,7 +7,7 @@
7
7
  >
8
8
  <component
9
9
  :is="mappedOptions.tag"
10
- ref="drawer"
10
+ ref="drawerRef"
11
11
  class="magic-drawer"
12
12
  :id="toValue(id)"
13
13
  :class="[
@@ -19,7 +19,7 @@
19
19
  >
20
20
  <transition
21
21
  v-if="mappedOptions.backdrop || !!$slots.backdrop"
22
- :name="mappedOptions.transitions?.backdrop"
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="mappedOptions.transitions?.content"
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'
@@ -77,7 +81,6 @@ import { useDrawerApi } from './../composables/useDrawerApi'
77
81
  import { useDrawerCallback } from '../composables/private/useDrawerCallback'
78
82
  import { useDrawerDrag } from '../composables/private/useDrawerDrag'
79
83
 
80
- import type { RequireAll } from '@maas/vue-equipment/utils'
81
84
  import type { DrawerOptions } from './../types/index'
82
85
 
83
86
  import '@maas/vue-equipment/utils/css/animations/fade-in.css'
@@ -112,8 +115,9 @@ const props = withDefaults(defineProps<MagicDrawerProps>(), {
112
115
  })
113
116
 
114
117
  const elRef = ref<HTMLDivElement | undefined>(undefined)
115
- const drawer = ref<HTMLElement | undefined>(undefined)
116
- const drawerApi = useDrawerApi(props.id, { focusTarget: drawer })
118
+ const drawerRef = ref<HTMLElement | undefined>(undefined)
119
+ const drawerApi = useDrawerApi(props.id, { focusTarget: drawerRef })
120
+
117
121
  const mappedOptions: typeof defaultOptions = customDefu(
118
122
  props.options,
119
123
  defaultOptions
@@ -124,6 +128,7 @@ const { position, threshold } = mappedOptions
124
128
 
125
129
  const {
126
130
  isActive,
131
+ open,
127
132
  close,
128
133
  trapFocus,
129
134
  releaseFocus,
@@ -144,6 +149,7 @@ const { onPointerdown, dragging, style } = useDrawerDrag({
144
149
  // Split isActive into two values to animate drawer smoothly
145
150
  const innerActive = ref(false)
146
151
  const wrapperActive = ref(false)
152
+ const wasActive = ref(false)
147
153
 
148
154
  const {
149
155
  onBeforeEnter,
@@ -162,6 +168,29 @@ const {
162
168
  trapFocus,
163
169
  releaseFocus,
164
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
165
194
  })
166
195
 
167
196
  // Handle state
@@ -201,7 +230,7 @@ function convertToPixels(value: string) {
201
230
  }
202
231
 
203
232
  function saveOvershoot() {
204
- const element = unrefElement(drawer)
233
+ const element = unrefElement(drawerRef)
205
234
  const overshootVar = getComputedStyle(element!).getPropertyValue(
206
235
  '--magic-drawer-drag-overshoot'
207
236
  )
@@ -230,6 +259,17 @@ watch(isActive, async (value) => {
230
259
  watch(innerActive, () => {
231
260
  saveOvershoot()
232
261
  })
262
+
263
+ onBeforeMount(() => {
264
+ if (mappedOptions.beforeMount.open) {
265
+ open()
266
+ }
267
+ })
268
+
269
+ // Reset state on unmount
270
+ onBeforeUnmount(() => {
271
+ close()
272
+ })
233
273
  </script>
234
274
 
235
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));
@@ -18,6 +18,10 @@ export type DrawerOptions = {
18
18
  };
19
19
  tag?: 'dialog' | 'div';
20
20
  keys?: string[] | false;
21
+ beforeMount?: {
22
+ open: boolean;
23
+ animate: boolean;
24
+ };
21
25
  };
22
26
  export type DrawerEvents = {
23
27
  beforeEnter: string;
@@ -17,6 +17,10 @@ const defaultOptions = {
17
17
  momentum: 1
18
18
  },
19
19
  tag: "dialog",
20
- keys: ["Escape"]
20
+ keys: ["Escape"],
21
+ beforeMount: {
22
+ open: false,
23
+ animate: false
24
+ }
21
25
  };
22
26
  export { defaultOptions };
@@ -2,5 +2,7 @@ import MagicModal from './src/components/MagicModal.vue.js';
2
2
  import { useModalApi } from './src/composables/useModalApi.js';
3
3
  import { useModalEmitter } from './src/composables/useModalEmitter.js';
4
4
  import type { Plugin } from 'vue';
5
+ import type { ModalEvents } from './src/types.js';
5
6
  declare const MagicModalPlugin: Plugin;
6
7
  export { MagicModalPlugin, MagicModal, useModalEmitter, useModalApi };
8
+ export type { ModalEvents };
@@ -7,7 +7,7 @@
7
7
  >
8
8
  <component
9
9
  :is="mappedOptions.tag"
10
- ref="modal"
10
+ ref="modalRef"
11
11
  class="magic-modal"
12
12
  :id="toValue(id)"
13
13
  :class="toValue(props.class)"
@@ -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'
@@ -94,8 +95,8 @@ const props = withDefaults(defineProps<MagicModalProps>(), {
94
95
  options: () => defaultOptions,
95
96
  })
96
97
 
97
- const modal = ref<HTMLElement | undefined>(undefined)
98
- const modalApi = useModalApi(props.id, { focusTarget: modal })
98
+ const modalRef = ref<HTMLElement | undefined>(undefined)
99
+ const modalApi = useModalApi(props.id, { focusTarget: modalRef })
99
100
  const mappedOptions = customDefu(props.options, defaultOptions)
100
101
 
101
102
  const {
@@ -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>
@@ -7,7 +7,7 @@
7
7
  class="magic-player-mux-popover"
8
8
  >
9
9
  <canvas
10
- ref="canvas"
10
+ ref="canvasRef"
11
11
  :width="storyboard?.tile_width"
12
12
  :height="storyboard?.tile_height"
13
13
  />
@@ -42,7 +42,7 @@ const { instance } = usePlayerApi(props.id)
42
42
  const { seekedTime } = instance.value.controlsApi
43
43
  const { pixelRatio } = useDevicePixelRatio()
44
44
 
45
- const canvas = shallowRef() as Ref<HTMLCanvasElement>
45
+ const canvasRef = shallowRef() as Ref<HTMLCanvasElement>
46
46
  const storyboard = shallowRef<MuxStoryboard | undefined>()
47
47
  let context: CanvasRenderingContext2D | undefined = undefined
48
48
  let image: HTMLImageElement | undefined = undefined
@@ -62,7 +62,7 @@ async function init() {
62
62
 
63
63
  try {
64
64
  storyboard.value = await fetch(
65
- `https://image.mux.com/${props.playbackId}/storyboard.json`,
65
+ `https://image.mux.com/${props.playbackId}/storyboard.json`
66
66
  ).then((res) => res.json())
67
67
 
68
68
  if (!storyboard.value) throw new Error()
@@ -71,7 +71,7 @@ async function init() {
71
71
  image.src = storyboard.value.url
72
72
  await image.decode()
73
73
 
74
- context = canvas.value.getContext('2d')!
74
+ context = canvasRef.value.getContext('2d')!
75
75
  context.drawImage(image, 0, 0)
76
76
  } catch (e: any) {
77
77
  console.error('Can not initialize timeine preview.', e)
@@ -107,7 +107,7 @@ function drawFrame(time: number) {
107
107
  0,
108
108
  0,
109
109
  tile_width,
110
- tile_height,
110
+ tile_height
111
111
  )
112
112
  }
113
113
 
@@ -1,11 +1,12 @@
1
1
  <template>
2
- <div ref="el" class="m-scroll-motion">
2
+ <div ref="elRef" class="magic-scroll-motion">
3
3
  <slot />
4
4
  </div>
5
5
  </template>
6
6
 
7
7
  <script setup lang="ts">
8
8
  import { ref, inject, computed, onMounted, toRaw, watch } from 'vue'
9
+ import { unrefElement } from '@vueuse/core'
9
10
  import { animate, type Easing } from 'motion'
10
11
  import { ScrollProgressKey } from '../symbols'
11
12
 
@@ -22,16 +23,16 @@ const props = withDefaults(defineProps<Props>(), {
22
23
  })
23
24
 
24
25
  const animation = ref()
25
- const el = ref()
26
+ const elRef = ref()
26
27
 
27
28
  const progress = inject(
28
29
  ScrollProgressKey,
29
- computed(() => 0),
30
+ computed(() => 0)
30
31
  )
31
32
 
32
33
  function createAnimation(currentTime: number = 0) {
33
34
  if (!props.keyframes) return
34
- animation.value = animate(toRaw(el.value), props.keyframes, {
35
+ animation.value = animate(unrefElement(elRef), props.keyframes, {
35
36
  duration: 1,
36
37
  easing: props.easing || 'linear',
37
38
  offset: props.offset,
@@ -53,6 +54,6 @@ watch(
53
54
  () => props.keyframes,
54
55
  () => {
55
56
  createAnimation(progress.value)
56
- },
57
+ }
57
58
  )
58
59
  </script>
@@ -1,21 +1,12 @@
1
1
  <template>
2
- <div ref="sceneRef" class="magic-scroll-scene">
2
+ <div ref="elRef" class="magic-scroll-scene">
3
3
  <slot :map-value="mapValue" :progress="progress" />
4
4
  </div>
5
5
  </template>
6
6
 
7
7
  <script setup lang="ts">
8
- import {
9
- ref,
10
- provide,
11
- inject,
12
- onMounted,
13
- watch,
14
- nextTick,
15
- toRaw,
16
- readonly,
17
- } from 'vue'
18
- import { useIntersectionObserver } from '@vueuse/core'
8
+ import { ref, provide, inject, onMounted, watch, nextTick, readonly } from 'vue'
9
+ import { unrefElement, useIntersectionObserver } from '@vueuse/core'
19
10
  import { mapValue } from '@maas/vue-equipment/utils'
20
11
  import { useScrollApi } from '../composables/useScrollApi'
21
12
  import {
@@ -39,12 +30,12 @@ const props = withDefaults(defineProps<Props>(), {
39
30
  const scrollPosition = inject(ScrollPositionKey, undefined)
40
31
  const scrollParent = inject(ScrollParentKey)
41
32
 
42
- const intersecting = ref()
43
- const sceneRef = ref<HTMLElement | undefined>(undefined)
33
+ const elRef = ref<HTMLElement | undefined>(undefined)
44
34
  const progress = ref(0)
35
+ const intersecting = ref()
45
36
 
46
37
  const { getCalculations, getProgress } = useScrollApi({
47
- child: sceneRef,
38
+ child: elRef,
48
39
  parent: scrollParent,
49
40
  from: props.from,
50
41
  to: props.to,
@@ -70,7 +61,7 @@ watch(
70
61
  )
71
62
 
72
63
  useIntersectionObserver(
73
- toRaw(sceneRef),
64
+ elRef,
74
65
  ([{ isIntersecting }]) => {
75
66
  intersecting.value = isIntersecting
76
67
  if (isIntersecting) {
@@ -2,5 +2,7 @@ import MagicToast from './src/components/MagicToast.vue.js';
2
2
  import { useToastApi } from './src/composables/useToastApi.js';
3
3
  import { useToastEmitter } from './src/composables/useToastEmitter.js';
4
4
  import type { Plugin } from 'vue';
5
+ import type { ToastEvents } from './src/types.js';
5
6
  declare const MagicToastPlugin: Plugin;
6
7
  export { MagicToastPlugin, MagicToast, useToastApi, useToastEmitter };
8
+ export type { ToastEvents };
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.2",
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",