@maas/vue-equipment 0.4.2 → 0.5.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.4.1"
4
+ "version": "0.4.2"
5
5
  }
@@ -15,6 +15,13 @@ const packages = {
15
15
  }
16
16
  };
17
17
  const functions = [
18
+ {
19
+ name: "MagicMarquee",
20
+ "package": "plugins",
21
+ lastUpdated: 1691658148000,
22
+ docs: "https://maas.egineering/vue-equipment/plugins/MagicMarquee/",
23
+ description: "marquee"
24
+ },
18
25
  {
19
26
  name: "MagicModal",
20
27
  "package": "plugins",
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from 'vue';
2
+ declare const MagicMarquee: Plugin;
3
+ export { MagicMarquee };
@@ -0,0 +1,7 @@
1
+ import MagicMarqueeComponent from "./src/components/MagicMarquee.vue";
2
+ const MagicMarquee = {
3
+ install: (app) => {
4
+ app.component("MagicMarquee", MagicMarqueeComponent);
5
+ }
6
+ };
7
+ export { MagicMarquee };
@@ -0,0 +1,2 @@
1
+ declare const _default: import("nuxt/app").Plugin<Record<string, unknown>>;
2
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import { defineNuxtPlugin } from "nuxt/app";
2
+ import { MagicMarquee } from "./index.mjs";
3
+ export default defineNuxtPlugin((nuxtApp) => {
4
+ nuxtApp.vueApp.use(MagicMarquee);
5
+ });
@@ -0,0 +1,105 @@
1
+ <template>
2
+ <div class="magic-marquee">
3
+ <div class="magic-marquee__track" ref="parentRef">
4
+ <div class="magic-marquee__content" ref="childRef">
5
+ <slot />
6
+ </div>
7
+ <div
8
+ v-for="_duplicate in duplicates"
9
+ class="magic-marquee__content"
10
+ :aria-hidden="true"
11
+ >
12
+ <slot />
13
+ </div>
14
+ </div>
15
+ </div>
16
+ </template>
17
+
18
+ <script setup lang="ts">
19
+ import { ref, reactive, computed, watch } from 'vue'
20
+ import { useMarquee } from '../composables/useMarquee'
21
+
22
+ interface Props {
23
+ direction?: 'reverse' | 'normal'
24
+ speed?: number
25
+ }
26
+
27
+ const props = withDefaults(defineProps<Props>(), {
28
+ direction: 'normal',
29
+ speed: 1,
30
+ })
31
+
32
+ const parentRef = ref<HTMLElement | undefined>(undefined)
33
+ const childRef = ref<HTMLElement | undefined>(undefined)
34
+
35
+ const { duplicates, playing, play, pause } = useMarquee({
36
+ child: childRef,
37
+ parent: parentRef,
38
+ options: {
39
+ speed: computed(() => props.speed),
40
+ direction: computed(() => props.direction),
41
+ },
42
+ })
43
+
44
+ defineExpose({
45
+ playing,
46
+ play,
47
+ pause,
48
+ })
49
+ </script>
50
+
51
+ <style lang="css">
52
+ :root {
53
+ --magic-marquee-gap: 1rem;
54
+ --magic-marquee-content-width: unset;
55
+ --magic-marquee-transform-target-x: -100%;
56
+ }
57
+
58
+ @keyframes magicMarqueeScrollX {
59
+ 0% {
60
+ transform: translate3d(0, 0, 0);
61
+ }
62
+ 100% {
63
+ transform: translate3d(-100%, 0, 0);
64
+ }
65
+ }
66
+
67
+ @keyframes magicMarqueeScrollY {
68
+ 0% {
69
+ transform: translate3d(0, 0, 0);
70
+ }
71
+ 100% {
72
+ transform: translate3d(0, -100%, 0);
73
+ }
74
+ }
75
+
76
+ .magic-marquee {
77
+ position: relative;
78
+ width: 100%;
79
+ overflow: hidden;
80
+ user-select: none;
81
+ }
82
+
83
+ .magic-marquee__track {
84
+ position: relative;
85
+ width: 100%;
86
+ display: flex;
87
+ justify-content: flex-start;
88
+ }
89
+
90
+ .magic-marquee__content {
91
+ white-space: nowrap;
92
+ backface-visibility: hidden;
93
+ padding-right: var(--magic-marquee-gap);
94
+ width: var(--magic-marquee-content-width);
95
+ animation-name: var(--magic-marquee-animation-name);
96
+ animation-duration: var(--magic-marquee-animation-duration);
97
+ animation-play-state: var(--magic-marquee-animation-play-state, running);
98
+ animation-direction: var(--magic-marquee-animation-direction, normal);
99
+ animation-timing-function: linear;
100
+ animation-iteration-count: infinite;
101
+ animation-delay: 0;
102
+ flex-shrink: 0;
103
+ flex-grow: 0;
104
+ }
105
+ </style>
@@ -0,0 +1,34 @@
1
+ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
2
+ direction: {
3
+ type: import("vue").PropType<"reverse" | "normal">;
4
+ default: string;
5
+ };
6
+ speed: {
7
+ type: import("vue").PropType<number>;
8
+ default: number;
9
+ };
10
+ }, {
11
+ playing: import("vue").Ref<boolean>;
12
+ play: () => void;
13
+ pause: () => void;
14
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
15
+ direction: {
16
+ type: import("vue").PropType<"reverse" | "normal">;
17
+ default: string;
18
+ };
19
+ speed: {
20
+ type: import("vue").PropType<number>;
21
+ default: number;
22
+ };
23
+ }>>, {
24
+ direction: "reverse" | "normal";
25
+ speed: number;
26
+ }, {}>, {
27
+ default?(_: {}): any;
28
+ }>;
29
+ export default _default;
30
+ type __VLS_WithTemplateSlots<T, S> = T & {
31
+ new (): {
32
+ $slots: S;
33
+ };
34
+ };
@@ -0,0 +1,15 @@
1
+ import { type MaybeRef } from '@vueuse/core';
2
+ export type UseMarqueeParams = {
3
+ child: MaybeRef<HTMLElement | null | undefined>;
4
+ parent: MaybeRef<HTMLElement | null | undefined>;
5
+ options?: {
6
+ speed?: MaybeRef<number>;
7
+ direction?: MaybeRef<'reverse' | 'normal'>;
8
+ };
9
+ };
10
+ export declare function useMarquee({ child, parent, options }: UseMarqueeParams): {
11
+ duplicates: import("vue").Ref<number>;
12
+ playing: import("vue").Ref<boolean>;
13
+ play: () => void;
14
+ pause: () => void;
15
+ };
@@ -0,0 +1,84 @@
1
+ import { ref, onMounted, computed, nextTick, watch } from "vue";
2
+ import {
3
+ useElementBounding,
4
+ useResizeObserver,
5
+ toValue
6
+ } from "@vueuse/core";
7
+ export function useMarquee({ child, parent, options }) {
8
+ const duplicates = ref(1);
9
+ const childRect = useElementBounding(child);
10
+ const parentRect = useElementBounding(parent);
11
+ const duration = computed(
12
+ () => (childRect.width.value / toValue(speed) / 50).toFixed(2)
13
+ );
14
+ const playing = ref(true);
15
+ const speed = computed(() => toValue(options?.speed) || 1);
16
+ const direction = computed(() => toValue(options?.direction) || "normal");
17
+ function calculateDuplicates() {
18
+ const childWidth = childRect?.width.value;
19
+ const parentWidth = parentRect?.width.value;
20
+ if (childWidth && parentWidth) {
21
+ duplicates.value = Math.ceil(parentWidth / childWidth * 2);
22
+ }
23
+ }
24
+ function setCssVariables() {
25
+ toValue(parent)?.style.setProperty(
26
+ "--magic-marquee-animation-duration",
27
+ `${toValue(duration)}s`
28
+ );
29
+ toValue(parent)?.style.setProperty(
30
+ "--magic-marquee-animation-name",
31
+ `magicMarqueeScrollX`
32
+ );
33
+ toValue(parent)?.style.setProperty(
34
+ "--magic-marquee-animation-direction",
35
+ `${toValue(options?.direction) || "normal"}`
36
+ );
37
+ }
38
+ function pause() {
39
+ playing.value = false;
40
+ toValue(parent)?.style.setProperty(
41
+ "--magic-marquee-animation-play-state",
42
+ "paused"
43
+ );
44
+ }
45
+ function play() {
46
+ playing.value = true;
47
+ toValue(parent)?.style.setProperty(
48
+ "--magic-marquee-animation-play-state",
49
+ "running"
50
+ );
51
+ }
52
+ onMounted(() => {
53
+ calculateDuplicates();
54
+ nextTick();
55
+ setCssVariables();
56
+ });
57
+ useResizeObserver(parent, () => {
58
+ childRect.update();
59
+ parentRect.update();
60
+ calculateDuplicates();
61
+ nextTick();
62
+ setCssVariables();
63
+ });
64
+ watch(speed, () => {
65
+ nextTick();
66
+ toValue(parent)?.style.setProperty(
67
+ "--magic-marquee-animation-duration",
68
+ `${toValue(duration)}s`
69
+ );
70
+ });
71
+ watch(direction, (dir) => {
72
+ nextTick();
73
+ toValue(parent)?.style.setProperty(
74
+ "--magic-marquee-animation-direction",
75
+ `${toValue(dir)}`
76
+ );
77
+ });
78
+ return {
79
+ duplicates,
80
+ playing,
81
+ play,
82
+ pause
83
+ };
84
+ }
@@ -51,8 +51,7 @@
51
51
  <script setup lang="ts">
52
52
  import { ref, watch, nextTick } from 'vue'
53
53
  import { useModalApi } from './../composables/useModalApi'
54
- import { onKeyStroke } from '@vueuse/core'
55
- import { toValue } from '@vueuse/shared'
54
+ import { onKeyStroke, toValue } from '@vueuse/core'
56
55
  import { defaultOptions } from './../utils/defaultOptions'
57
56
  import { useModalEmitter } from './../composables/useModalEmitter'
58
57
 
@@ -1,6 +1,6 @@
1
1
  import { ref, computed, watch } from "vue";
2
- import { toValue } from "@vueuse/shared";
3
2
  import {
3
+ toValue,
4
4
  useResizeObserver,
5
5
  useEventListener,
6
6
  defaultWindow
@@ -1,4 +1,4 @@
1
- import type { MaybeRef } from '@vueuse/shared';
1
+ import type { MaybeRef } from '@vueuse/core';
2
2
  export declare function useMediaApi(target: MaybeRef<HTMLMediaElement | null | undefined>): {
3
3
  currentTime: import("vue").Ref<number>;
4
4
  duration: import("vue").Ref<number>;
@@ -1,6 +1,5 @@
1
1
  import { ref, watch, unref } from "vue";
2
- import { toValue, watchIgnorable } from "@vueuse/shared";
3
- import { useEventListener } from "@vueuse/core";
2
+ import { useEventListener, toValue, watchIgnorable } from "@vueuse/core";
4
3
  export function useMediaApi(target) {
5
4
  const currentTime = ref(0);
6
5
  const duration = ref(0);
@@ -1,4 +1,4 @@
1
- import { toValue } from "@vueuse/shared";
1
+ import { toValue } from "@vueuse/core";
2
2
  import { ref, onMounted, onUnmounted } from "vue";
3
3
  export function useRuntimeSourceProvider(args) {
4
4
  let hls;
@@ -6,7 +6,7 @@
6
6
 
7
7
  <script setup lang="ts">
8
8
  import { ref, inject, computed, onMounted } from 'vue'
9
- import { toValue } from '@vueuse/shared'
9
+ import { toValue } from '@vueuse/core'
10
10
  import { useCollisionDetect } from '../composables/useCollisionDetect'
11
11
  import { ScrollPositionKey } from '../types'
12
12
 
@@ -1,4 +1,4 @@
1
- import type { MaybeRef, MaybeRefOrGetter } from '@vueuse/shared';
1
+ import type { MaybeRef, MaybeRefOrGetter } from '@vueuse/core';
2
2
  import type { FromTo } from '../types.js';
3
3
  type UseProgressParams = {
4
4
  child: MaybeRef<HTMLElement | null | undefined>;
@@ -1,6 +1,6 @@
1
1
  import { ref, inject } from "vue";
2
2
  import { useElementBounding, useWindowSize } from "@vueuse/core";
3
- import { toValue } from "@vueuse/shared";
3
+ import { toValue } from "@vueuse/core";
4
4
  import { ScrollPositionKey } from "../types/index.mjs";
5
5
  import { clampValue } from "../utils/index.mjs";
6
6
  export function useProgress(params) {
@@ -1,5 +1,5 @@
1
1
  import type { InjectionKey, Ref } from 'vue';
2
- import type { MaybeRefOrGetter } from '@vueuse/shared';
2
+ import type { MaybeRefOrGetter } from '@vueuse/core';
3
3
  declare const ScrollParentKey: InjectionKey<MaybeRefOrGetter<HTMLElement | undefined>>;
4
4
  declare const ScrollPositionKey: InjectionKey<{
5
5
  x: import("vue").WritableComputedRef<number>;
@@ -1,3 +1,4 @@
1
1
  export * from './MagicModal.js';
2
2
  export * from './MagicPlayer.js';
3
3
  export * from './MagicScroll.js';
4
+ export * from './MagicMarquee.js';
@@ -1,3 +1,4 @@
1
1
  export * from "./MagicModal/index.mjs";
2
2
  export * from "./MagicPlayer/index.mjs";
3
3
  export * from "./MagicScroll/index.mjs";
4
+ export * from "./MagicMarquee/index.mjs";
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.2",
4
+ "version": "0.5.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",
@@ -56,7 +56,6 @@
56
56
  "peerDependencies": {
57
57
  "@vueuse/core": "^10.3.0",
58
58
  "@vueuse/integrations": "^10.3.0",
59
- "@vueuse/shared": "^10.3.0",
60
59
  "focus-trap": "^7.5.2",
61
60
  "hls.js": "^1.4.10",
62
61
  "mitt": "^3.0.1",
@@ -65,25 +64,22 @@
65
64
  },
66
65
  "peerDependenciesMeta": {
67
66
  "@vueuse/core": {
68
- "optional": true
67
+ "optional": false
69
68
  },
70
69
  "@vueuse/integrations": {
71
- "optional": true
72
- },
73
- "@vueuse/shared": {
74
- "optional": true
70
+ "optional": false
75
71
  },
76
72
  "hls.js": {
77
- "optional": true
73
+ "optional": false
78
74
  },
79
75
  "mitt": {
80
- "optional": true
76
+ "optional": false
81
77
  },
82
78
  "nuxt": {
83
- "optional": true
79
+ "optional": false
84
80
  },
85
81
  "uuid": {
86
- "optional": true
82
+ "optional": false
87
83
  }
88
84
  },
89
85
  "scripts": {