@maas/vue-equipment 0.1.2 → 0.2.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.
- package/dist/composables/index.d.mts +87 -0
- package/dist/composables/index.d.ts +87 -0
- package/dist/composables/index.js +284 -0
- package/dist/composables/index.js.map +1 -0
- package/dist/composables/index.mjs +254 -0
- package/dist/composables/index.mjs.map +1 -0
- package/dist/nuxt/module.cjs +5 -0
- package/dist/nuxt/module.d.ts +9 -0
- package/dist/nuxt/module.json +5 -0
- package/dist/nuxt/module.mjs +121 -0
- package/dist/nuxt/types.d.ts +15 -0
- package/dist/plugins/MagicModal/index.d.ts +4 -0
- package/dist/plugins/MagicModal/index.mjs +8 -0
- package/dist/plugins/MagicModal/nuxt.d.ts +2 -0
- package/dist/plugins/MagicModal/nuxt.mjs +5 -0
- package/dist/plugins/MagicModal/src/components/MagicModal.vue +254 -0
- package/dist/plugins/MagicModal/src/components/MagicModal.vue.d.ts +43 -0
- package/dist/plugins/MagicModal/src/composables/useModalApi.d.ts +18 -0
- package/dist/plugins/MagicModal/src/composables/useModalApi.mjs +74 -0
- package/dist/plugins/MagicModal/src/composables/useModalStore.d.ts +5 -0
- package/dist/plugins/MagicModal/src/composables/useModalStore.mjs +15 -0
- package/dist/plugins/MagicModal/src/store/modals.d.ts +4 -0
- package/dist/plugins/MagicModal/src/store/modals.mjs +9 -0
- package/dist/plugins/MagicModal/src/types/index.d.ts +15 -0
- package/dist/plugins/MagicModal/src/types/index.mjs +0 -0
- package/dist/plugins/MagicModal/src/utils/defaultOptions.d.ts +3 -0
- package/dist/plugins/MagicModal/src/utils/defaultOptions.mjs +15 -0
- package/dist/plugins/MagicPlayer/index.d.ts +7 -0
- package/dist/plugins/MagicPlayer/index.mjs +15 -0
- package/dist/plugins/MagicPlayer/nuxt.d.ts +2 -0
- package/dist/plugins/MagicPlayer/nuxt.mjs +5 -0
- package/dist/plugins/MagicPlayer/src/components/MagicPlayer.vue +103 -0
- package/dist/plugins/MagicPlayer/src/components/MagicPlayer.vue.d.ts +86 -0
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerControls.vue +262 -0
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerControls.vue.d.ts +25 -0
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerMuxPopover.vue +132 -0
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerMuxPopover.vue.d.ts +12 -0
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerTimeline.vue +155 -0
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerTimeline.vue.d.ts +2 -0
- package/dist/plugins/MagicPlayer/src/components/icons/FullscreenEnter.vue +13 -0
- package/dist/plugins/MagicPlayer/src/components/icons/FullscreenEnter.vue.d.ts +2 -0
- package/dist/plugins/MagicPlayer/src/components/icons/FullscreenExit.vue +14 -0
- package/dist/plugins/MagicPlayer/src/components/icons/FullscreenExit.vue.d.ts +2 -0
- package/dist/plugins/MagicPlayer/src/components/icons/Pause.vue +14 -0
- package/dist/plugins/MagicPlayer/src/components/icons/Pause.vue.d.ts +2 -0
- package/dist/plugins/MagicPlayer/src/components/icons/Play.vue +11 -0
- package/dist/plugins/MagicPlayer/src/components/icons/Play.vue.d.ts +2 -0
- package/dist/plugins/MagicPlayer/src/components/icons/VolumeOff.vue +14 -0
- package/dist/plugins/MagicPlayer/src/components/icons/VolumeOff.vue.d.ts +2 -0
- package/dist/plugins/MagicPlayer/src/components/icons/VolumeOn.vue +11 -0
- package/dist/plugins/MagicPlayer/src/components/icons/VolumeOn.vue.d.ts +2 -0
- package/dist/plugins/MagicPlayer/src/components/icons/Waiting.vue +38 -0
- package/dist/plugins/MagicPlayer/src/components/icons/Waiting.vue.d.ts +2 -0
- package/dist/plugins/MagicPlayer/src/composables/useControls.d.ts +8 -0
- package/dist/plugins/MagicPlayer/src/composables/useControls.mjs +15 -0
- package/dist/plugins/MagicPlayer/src/composables/useControlsApi.d.ts +17 -0
- package/dist/plugins/MagicPlayer/src/composables/useControlsApi.mjs +129 -0
- package/dist/plugins/MagicPlayer/src/composables/useMediaApi.d.ts +15 -0
- package/dist/plugins/MagicPlayer/src/composables/useMediaApi.mjs +122 -0
- package/dist/plugins/MagicPlayer/src/composables/usePlayer.d.ts +12 -0
- package/dist/plugins/MagicPlayer/src/composables/usePlayer.mjs +33 -0
- package/dist/plugins/MagicPlayer/src/composables/usePlayerApi.d.ts +20 -0
- package/dist/plugins/MagicPlayer/src/composables/usePlayerApi.mjs +50 -0
- package/dist/plugins/MagicPlayer/src/composables/useRuntimeSourceProvider.d.ts +8 -0
- package/dist/plugins/MagicPlayer/src/composables/useRuntimeSourceProvider.mjs +49 -0
- package/dist/plugins/MagicPlayer/src/types/index.d.ts +15 -0
- package/dist/plugins/MagicPlayer/src/types/index.mjs +1 -0
- package/dist/plugins/MagicPlayer/src/types/injectionKeys.d.ts +45 -0
- package/dist/plugins/MagicPlayer/src/types/injectionKeys.mjs +10 -0
- package/dist/plugins/MagicPlayer/src/utils/index.d.ts +4 -0
- package/dist/plugins/MagicPlayer/src/utils/index.mjs +19 -0
- package/dist/plugins/MagicScroll/index.d.ts +7 -0
- package/dist/plugins/MagicScroll/index.mjs +19 -0
- package/dist/plugins/MagicScroll/nuxt.d.ts +2 -0
- package/dist/plugins/MagicScroll/nuxt.mjs +5 -0
- package/dist/plugins/MagicScroll/src/components/MagicScrollCollision.vue +35 -0
- package/dist/plugins/MagicScroll/src/components/MagicScrollCollision.vue.d.ts +20 -0
- package/dist/plugins/MagicScroll/src/components/MagicScrollProvider.vue +34 -0
- package/dist/plugins/MagicScroll/src/components/MagicScrollProvider.vue.d.ts +21 -0
- package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue +80 -0
- package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue.d.ts +41 -0
- package/dist/plugins/MagicScroll/src/components/MagicScrollTransform.vue +42 -0
- package/dist/plugins/MagicScroll/src/components/MagicScrollTransform.vue.d.ts +84 -0
- package/dist/plugins/MagicScroll/src/composables/useCollisionDetect.d.ts +6 -0
- package/dist/plugins/MagicScroll/src/composables/useCollisionDetect.mjs +116 -0
- package/dist/plugins/MagicScroll/src/composables/useEmitter.d.ts +15 -0
- package/dist/plugins/MagicScroll/src/composables/useEmitter.mjs +9 -0
- package/dist/plugins/MagicScroll/src/composables/useProgress.d.ts +7 -0
- package/dist/plugins/MagicScroll/src/composables/useProgress.mjs +59 -0
- package/dist/plugins/MagicScroll/src/store/index.d.ts +4 -0
- package/dist/plugins/MagicScroll/src/store/index.mjs +5 -0
- package/dist/plugins/MagicScroll/src/types/index.d.ts +34 -0
- package/dist/plugins/MagicScroll/src/types/index.mjs +1 -0
- package/dist/plugins/MagicScroll/src/types/injectionKeys.d.ts +12 -0
- package/dist/plugins/MagicScroll/src/types/injectionKeys.mjs +5 -0
- package/dist/plugins/MagicScroll/src/utils/index.d.ts +2 -0
- package/dist/plugins/MagicScroll/src/utils/index.mjs +6 -0
- package/dist/plugins/index.d.ts +3 -0
- package/dist/plugins/index.mjs +3 -0
- package/package.json +13 -16
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<transition :duration="5000">
|
|
3
|
+
<teleport
|
|
4
|
+
v-if="wrapperActive"
|
|
5
|
+
:to="mappedOptions.teleport?.target"
|
|
6
|
+
:disabled="mappedOptions.teleport?.disabled"
|
|
7
|
+
>
|
|
8
|
+
<dialog
|
|
9
|
+
ref="modal"
|
|
10
|
+
class="magic-modal"
|
|
11
|
+
@click.self="close"
|
|
12
|
+
aria-modal="true"
|
|
13
|
+
>
|
|
14
|
+
<transition
|
|
15
|
+
v-if="mappedOptions.backdrop"
|
|
16
|
+
:name="mappedOptions.transitions?.backdrop"
|
|
17
|
+
>
|
|
18
|
+
<div
|
|
19
|
+
v-show="innerActive"
|
|
20
|
+
class="magic-modal__backdrop"
|
|
21
|
+
@click.self="close"
|
|
22
|
+
/>
|
|
23
|
+
</transition>
|
|
24
|
+
<transition
|
|
25
|
+
:name="mappedOptions.transitions?.content"
|
|
26
|
+
@after-leave="onAfterLeave"
|
|
27
|
+
@after-enter="onAfterEnter"
|
|
28
|
+
>
|
|
29
|
+
<div
|
|
30
|
+
v-show="innerActive"
|
|
31
|
+
class="magic-modal__content"
|
|
32
|
+
@click.self="close"
|
|
33
|
+
>
|
|
34
|
+
<component
|
|
35
|
+
v-if="component"
|
|
36
|
+
v-bind="componentProps"
|
|
37
|
+
:is="component"
|
|
38
|
+
@close="close"
|
|
39
|
+
/>
|
|
40
|
+
<slot v-else />
|
|
41
|
+
</div>
|
|
42
|
+
</transition>
|
|
43
|
+
</dialog>
|
|
44
|
+
</teleport>
|
|
45
|
+
</transition>
|
|
46
|
+
</template>
|
|
47
|
+
|
|
48
|
+
<script setup lang="ts">
|
|
49
|
+
import { ref, watch, nextTick } from 'vue'
|
|
50
|
+
import { useModalApi } from './../composables/useModalApi'
|
|
51
|
+
import { onKeyStroke } from '@vueuse/core'
|
|
52
|
+
import { defaultOptions } from './../utils/defaultOptions'
|
|
53
|
+
|
|
54
|
+
import type { MaybeRef } from '@vueuse/core'
|
|
55
|
+
import type { DefaultOptions } from './../types/index'
|
|
56
|
+
|
|
57
|
+
interface MagicModalProps {
|
|
58
|
+
id: MaybeRef<string>
|
|
59
|
+
component?: any
|
|
60
|
+
componentProps?: Record<string, unknown>
|
|
61
|
+
options?: DefaultOptions
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const props = withDefaults(defineProps<MagicModalProps>(), {
|
|
65
|
+
options: () => defaultOptions,
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
const modal = ref<HTMLElement | undefined>(undefined)
|
|
69
|
+
const modalApi = useModalApi(props.id, { focusTarget: modal })
|
|
70
|
+
|
|
71
|
+
const mappedOptions = {
|
|
72
|
+
...defaultOptions,
|
|
73
|
+
...props.options,
|
|
74
|
+
teleport: { ...defaultOptions.teleport, ...props.options.teleport },
|
|
75
|
+
transitions: { ...defaultOptions.transitions, ...props.options.transitions },
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const {
|
|
79
|
+
isActive,
|
|
80
|
+
close,
|
|
81
|
+
trapFocus,
|
|
82
|
+
releaseFocus,
|
|
83
|
+
lockScroll,
|
|
84
|
+
unlockScroll,
|
|
85
|
+
addScrollLockPadding,
|
|
86
|
+
removeScrollLockPadding,
|
|
87
|
+
} = modalApi
|
|
88
|
+
|
|
89
|
+
// Split isActive into two values to animate modal smoothly
|
|
90
|
+
const innerActive = ref(false)
|
|
91
|
+
const wrapperActive = ref(false)
|
|
92
|
+
|
|
93
|
+
// Handle state
|
|
94
|
+
async function onOpen() {
|
|
95
|
+
wrapperActive.value = true
|
|
96
|
+
await nextTick()
|
|
97
|
+
innerActive.value = true
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function onClose() {
|
|
101
|
+
innerActive.value = false
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Transition Callbacks
|
|
105
|
+
async function onAfterEnter() {
|
|
106
|
+
if (mappedOptions.scrollLock) {
|
|
107
|
+
if (mappedOptions.scrollLockPadding) {
|
|
108
|
+
addScrollLockPadding()
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
lockScroll()
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (mappedOptions.focusTrap) {
|
|
115
|
+
await nextTick()
|
|
116
|
+
trapFocus()
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function onAfterLeave() {
|
|
121
|
+
if (mappedOptions.scrollLock) {
|
|
122
|
+
unlockScroll()
|
|
123
|
+
if (mappedOptions.scrollLockPadding) {
|
|
124
|
+
removeScrollLockPadding()
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (mappedOptions.focusTrap) {
|
|
129
|
+
releaseFocus()
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
wrapperActive.value = false
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
onKeyStroke('Escape', (e) => {
|
|
136
|
+
e.preventDefault()
|
|
137
|
+
close()
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
watch(isActive, async (value) => {
|
|
141
|
+
if (value) {
|
|
142
|
+
await onOpen()
|
|
143
|
+
} else {
|
|
144
|
+
onClose()
|
|
145
|
+
}
|
|
146
|
+
})
|
|
147
|
+
</script>
|
|
148
|
+
|
|
149
|
+
<style lang="postcss">
|
|
150
|
+
* {
|
|
151
|
+
transition-duration: 0s;
|
|
152
|
+
animation-duration: 0s;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.magic-modal {
|
|
156
|
+
position: fixed;
|
|
157
|
+
inset: 0;
|
|
158
|
+
width: 100%;
|
|
159
|
+
height: 100%;
|
|
160
|
+
display: flex;
|
|
161
|
+
justify-content: center;
|
|
162
|
+
align-items: center;
|
|
163
|
+
z-index: 999;
|
|
164
|
+
background: transparent;
|
|
165
|
+
color: inherit;
|
|
166
|
+
padding: 0;
|
|
167
|
+
border: none;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.magic-modal__content {
|
|
171
|
+
-webkit-overflow-scrolling: touch;
|
|
172
|
+
scroll-behavior: smooth;
|
|
173
|
+
max-height: 100%;
|
|
174
|
+
width: 100%;
|
|
175
|
+
display: flex;
|
|
176
|
+
align-items: center;
|
|
177
|
+
justify-content: center;
|
|
178
|
+
overflow-y: auto;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.magic-modal__backdrop {
|
|
182
|
+
position: fixed;
|
|
183
|
+
top: 0;
|
|
184
|
+
left: 0;
|
|
185
|
+
right: 0;
|
|
186
|
+
bottom: 0;
|
|
187
|
+
width: 100%;
|
|
188
|
+
height: 100%;
|
|
189
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
190
|
+
z-index: -1;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/* Content */
|
|
194
|
+
.magic-modal--content-enter-active,
|
|
195
|
+
.magic-modal--content-leave-active {
|
|
196
|
+
transition: all 300ms ease-out;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.magic-modal--content-enter-from {
|
|
200
|
+
opacity: 0;
|
|
201
|
+
transform: translateY(2rem);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.magic-modal--content-enter-to {
|
|
205
|
+
opacity: 1;
|
|
206
|
+
transform: translateY(0);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.magic-modal--content-leave-from {
|
|
210
|
+
opacity: 1;
|
|
211
|
+
transform: scale(1);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.magic-modal--content-leave-to {
|
|
215
|
+
opacity: 0;
|
|
216
|
+
transform: scale(1.02);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
@media (prefers-reduced-motion) {
|
|
220
|
+
.magic-modal--content-enter-active,
|
|
221
|
+
.magic-modal--content-leave-active {
|
|
222
|
+
transition: opacity 300ms ease-out;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.magic-modal--content-enter-from,
|
|
226
|
+
.magic-modal--content-enter-to,
|
|
227
|
+
.magic-modal--content-leave-from,
|
|
228
|
+
.magic-modal--content-leave-to {
|
|
229
|
+
transform: none;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/* Backdrop */
|
|
234
|
+
.magic-modal--backdrop-enter-active,
|
|
235
|
+
.magic-modal--backdrop-leave-active {
|
|
236
|
+
transition: opacity 300ms ease-out;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.magic-modal--backdrop-enter-from {
|
|
240
|
+
opacity: 0;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.magic-modal--backdrop-enter-to {
|
|
244
|
+
opacity: 1;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.magic-modal--backdrop-leave-from {
|
|
248
|
+
opacity: 1;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.magic-modal--backdrop-leave-to {
|
|
252
|
+
opacity: 0;
|
|
253
|
+
}
|
|
254
|
+
</style>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { MaybeRef } from '@vueuse/core';
|
|
2
|
+
import type { DefaultOptions } from './../types/index';
|
|
3
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
4
|
+
id: {
|
|
5
|
+
type: import("vue").PropType<MaybeRef<string>>;
|
|
6
|
+
required: true;
|
|
7
|
+
};
|
|
8
|
+
component: {
|
|
9
|
+
type: import("vue").PropType<any>;
|
|
10
|
+
};
|
|
11
|
+
componentProps: {
|
|
12
|
+
type: import("vue").PropType<Record<string, unknown>>;
|
|
13
|
+
};
|
|
14
|
+
options: {
|
|
15
|
+
type: import("vue").PropType<DefaultOptions>;
|
|
16
|
+
default: () => DefaultOptions;
|
|
17
|
+
};
|
|
18
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
19
|
+
id: {
|
|
20
|
+
type: import("vue").PropType<MaybeRef<string>>;
|
|
21
|
+
required: true;
|
|
22
|
+
};
|
|
23
|
+
component: {
|
|
24
|
+
type: import("vue").PropType<any>;
|
|
25
|
+
};
|
|
26
|
+
componentProps: {
|
|
27
|
+
type: import("vue").PropType<Record<string, unknown>>;
|
|
28
|
+
};
|
|
29
|
+
options: {
|
|
30
|
+
type: import("vue").PropType<DefaultOptions>;
|
|
31
|
+
default: () => DefaultOptions;
|
|
32
|
+
};
|
|
33
|
+
}>>, {
|
|
34
|
+
options: DefaultOptions;
|
|
35
|
+
}, {}>, {
|
|
36
|
+
default?(_: {}): any;
|
|
37
|
+
}>;
|
|
38
|
+
export default _default;
|
|
39
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
40
|
+
new (): {
|
|
41
|
+
$slots: S;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { DefaultOptions } from '../types/index.js';
|
|
2
|
+
import type { MaybeElementRef, MaybeRef } from '@vueuse/core';
|
|
3
|
+
export type useModalApiOptions = Pick<DefaultOptions, 'scrollLock'> & {
|
|
4
|
+
focusTarget: MaybeElementRef;
|
|
5
|
+
};
|
|
6
|
+
export declare function useModalApi(id?: MaybeRef<string>, options?: useModalApiOptions): {
|
|
7
|
+
id: import("vue").ComputedRef<string>;
|
|
8
|
+
isActive: import("vue").ComputedRef<boolean>;
|
|
9
|
+
open: () => void;
|
|
10
|
+
close: () => void;
|
|
11
|
+
trapFocus: () => void;
|
|
12
|
+
releaseFocus: () => void;
|
|
13
|
+
lockScroll: () => void;
|
|
14
|
+
unlockScroll: () => void;
|
|
15
|
+
addScrollLockPadding: () => void;
|
|
16
|
+
removeScrollLockPadding: () => void;
|
|
17
|
+
};
|
|
18
|
+
export type UseModalApiReturn = ReturnType<typeof useModalApi>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ref, computed } from "vue";
|
|
2
|
+
import { v4 as uuidv4 } from "uuid";
|
|
3
|
+
import { toValue, useScrollLock } from "@vueuse/core";
|
|
4
|
+
import { useFocusTrap } from "@vueuse/integrations/useFocusTrap";
|
|
5
|
+
import { useModalStore } from "./useModalStore.mjs";
|
|
6
|
+
const defaultOptions = {
|
|
7
|
+
focusTarget: void 0,
|
|
8
|
+
scrollLock: true
|
|
9
|
+
};
|
|
10
|
+
export function useModalApi(id, options) {
|
|
11
|
+
const positionFixedElements = ref([]);
|
|
12
|
+
const mappedId = computed(() => toValue(id) || uuidv4());
|
|
13
|
+
const mappedOptions = { ...defaultOptions, ...options };
|
|
14
|
+
const focusTrap = mappedOptions.focusTarget ? useFocusTrap(mappedOptions.focusTarget) : void 0;
|
|
15
|
+
const scrollLock = mappedOptions.scrollLock && typeof window !== "undefined" ? useScrollLock(document.body) : ref(false);
|
|
16
|
+
const { modalStore, addIdToStore, removeIdFromStore } = useModalStore();
|
|
17
|
+
const isActive = computed(() => modalStore.value.includes(mappedId.value));
|
|
18
|
+
function open() {
|
|
19
|
+
addIdToStore(mappedId.value);
|
|
20
|
+
}
|
|
21
|
+
function close() {
|
|
22
|
+
removeIdFromStore(mappedId.value);
|
|
23
|
+
}
|
|
24
|
+
function trapFocus() {
|
|
25
|
+
if (focusTrap) {
|
|
26
|
+
focusTrap.activate();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function releaseFocus() {
|
|
30
|
+
if (focusTrap) {
|
|
31
|
+
focusTrap.deactivate();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function lockScroll() {
|
|
35
|
+
scrollLock.value = true;
|
|
36
|
+
}
|
|
37
|
+
function unlockScroll() {
|
|
38
|
+
scrollLock.value = false;
|
|
39
|
+
}
|
|
40
|
+
function addScrollLockPadding() {
|
|
41
|
+
if (typeof window === "undefined")
|
|
42
|
+
return;
|
|
43
|
+
const scrollbarWidth = window.innerWidth - document.body.offsetWidth;
|
|
44
|
+
document.body.style.setProperty("--scrollbar-width", `${scrollbarWidth}px`);
|
|
45
|
+
document.body.style.paddingRight = "var(--scrollbar-width)";
|
|
46
|
+
positionFixedElements.value = [
|
|
47
|
+
...document.body.getElementsByTagName("*")
|
|
48
|
+
].filter(
|
|
49
|
+
(x) => getComputedStyle(x, null).getPropertyValue("position") === "fixed"
|
|
50
|
+
);
|
|
51
|
+
positionFixedElements.value.forEach(
|
|
52
|
+
(elem) => elem.style.paddingRight = "var(--scrollbar-width)"
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
function removeScrollLockPadding() {
|
|
56
|
+
document.body.style.paddingRight = "";
|
|
57
|
+
document.body.style.removeProperty("--scrollbar-width");
|
|
58
|
+
positionFixedElements.value.forEach(
|
|
59
|
+
(elem) => elem.style.paddingRight = ""
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
id: mappedId,
|
|
64
|
+
isActive,
|
|
65
|
+
open,
|
|
66
|
+
close,
|
|
67
|
+
trapFocus,
|
|
68
|
+
releaseFocus,
|
|
69
|
+
lockScroll,
|
|
70
|
+
unlockScroll,
|
|
71
|
+
addScrollLockPadding,
|
|
72
|
+
removeScrollLockPadding
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ref } from "vue";
|
|
2
|
+
let modalStore = ref([]);
|
|
3
|
+
export function useModalStore() {
|
|
4
|
+
function addIdToStore(id) {
|
|
5
|
+
modalStore.value.push(id);
|
|
6
|
+
}
|
|
7
|
+
function removeIdFromStore(id) {
|
|
8
|
+
modalStore.value = modalStore.value.filter((x) => x !== id);
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
modalStore,
|
|
12
|
+
addIdToStore,
|
|
13
|
+
removeIdFromStore
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { shallowReactive } from "vue";
|
|
2
|
+
let modalsStore = shallowReactive([]);
|
|
3
|
+
function addIdToStore(id) {
|
|
4
|
+
modalsStore.push(id);
|
|
5
|
+
}
|
|
6
|
+
function removeIdFromStore(id) {
|
|
7
|
+
modalsStore = modalsStore.filter((x) => x !== id);
|
|
8
|
+
}
|
|
9
|
+
export { modalsStore, addIdToStore, removeIdFromStore };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type DefaultOptions = {
|
|
2
|
+
backdrop?: boolean;
|
|
3
|
+
focusTrap?: boolean;
|
|
4
|
+
scrollLock?: boolean;
|
|
5
|
+
scrollLockPadding?: boolean;
|
|
6
|
+
teleport?: {
|
|
7
|
+
target: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
};
|
|
10
|
+
transitions?: {
|
|
11
|
+
content?: string;
|
|
12
|
+
backdrop?: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export type { DefaultOptions };
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const defaultOptions = {
|
|
2
|
+
backdrop: true,
|
|
3
|
+
focusTrap: true,
|
|
4
|
+
scrollLock: true,
|
|
5
|
+
scrollLockPadding: true,
|
|
6
|
+
teleport: {
|
|
7
|
+
target: "body",
|
|
8
|
+
disabled: false
|
|
9
|
+
},
|
|
10
|
+
transitions: {
|
|
11
|
+
content: "magic-modal--content",
|
|
12
|
+
backdrop: "magic-modal--backdrop"
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
export { defaultOptions };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Plugin } from 'vue';
|
|
2
|
+
import { useMediaApi } from './src/composables/useMediaApi.js';
|
|
3
|
+
import { usePlayerApi } from './src/composables/usePlayerApi.js';
|
|
4
|
+
import { useRuntimeSourceProvider } from './src/composables/useRuntimeSourceProvider.js';
|
|
5
|
+
export type * from './src/types';
|
|
6
|
+
declare const MagicPlayer: Plugin;
|
|
7
|
+
export { MagicPlayer, useMediaApi, usePlayerApi, useRuntimeSourceProvider };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import MagicPlayerComponent from "./src/components/MagicPlayer.vue";
|
|
2
|
+
import MagicPlayerControlsComponent from "./src/components/MagicPlayerControls.vue";
|
|
3
|
+
import MagicPlayerTimelineComponent from "./src/components/MagicPlayerTimeline.vue";
|
|
4
|
+
import MagicPlayerMuxPopoverComponent from "./src/components/MagicPlayerMuxPopover.vue";
|
|
5
|
+
import { useMediaApi } from "./src/composables/useMediaApi.mjs";
|
|
6
|
+
import { usePlayerApi } from "./src/composables/usePlayerApi.mjs";
|
|
7
|
+
import { useRuntimeSourceProvider } from "./src/composables/useRuntimeSourceProvider.mjs";
|
|
8
|
+
const MagicPlayer = {
|
|
9
|
+
install: (app) => {
|
|
10
|
+
app.component("MagicPlayer", MagicPlayerComponent);
|
|
11
|
+
app.component("MagicPlayerControls", MagicPlayerControlsComponent);
|
|
12
|
+
app.component("MagicPlayerTimeline", MagicPlayerTimelineComponent), app.component("MagicPlayerMuxPopover", MagicPlayerMuxPopoverComponent);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
export { MagicPlayer, useMediaApi, usePlayerApi, useRuntimeSourceProvider };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div ref="playerRef" class="magic-player" :style="computedStyle">
|
|
3
|
+
<video
|
|
4
|
+
ref="videoRef"
|
|
5
|
+
class="magic-player-video"
|
|
6
|
+
preload="auto"
|
|
7
|
+
playsinline
|
|
8
|
+
/>
|
|
9
|
+
<div v-show="!loaded || !touched" class="magic-player-poster">
|
|
10
|
+
<slot name="poster" />
|
|
11
|
+
</div>
|
|
12
|
+
<slot />
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script setup lang="ts">
|
|
17
|
+
import { ref, computed } from 'vue'
|
|
18
|
+
import { useIntersectionObserver } from '@vueuse/core'
|
|
19
|
+
|
|
20
|
+
import type { SourceType } from './../types'
|
|
21
|
+
import { useProvidePlayer } from '../composables/usePlayer'
|
|
22
|
+
|
|
23
|
+
export type MagicPlayerProps = {
|
|
24
|
+
srcType?: SourceType
|
|
25
|
+
src: string
|
|
26
|
+
ratio?: string
|
|
27
|
+
fill?: boolean
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const props = withDefaults(defineProps<MagicPlayerProps>(), {
|
|
31
|
+
srcType: 'native',
|
|
32
|
+
src: '',
|
|
33
|
+
ratio: '16:9',
|
|
34
|
+
fill: false,
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
const playerRef = ref<HTMLDivElement | undefined>(undefined)
|
|
38
|
+
const videoRef = ref<HTMLVideoElement | undefined>(undefined)
|
|
39
|
+
|
|
40
|
+
const { mediaApi, playerApi, runtimeProvider } = useProvidePlayer({
|
|
41
|
+
playerRef: playerRef,
|
|
42
|
+
videoRef: videoRef,
|
|
43
|
+
src: props.src,
|
|
44
|
+
srcType: props.srcType,
|
|
45
|
+
})
|
|
46
|
+
const { playing } = mediaApi
|
|
47
|
+
const { touched, pause } = playerApi
|
|
48
|
+
const { loaded } = runtimeProvider
|
|
49
|
+
|
|
50
|
+
useIntersectionObserver(playerRef, ([{ isIntersecting }]) => {
|
|
51
|
+
if (!isIntersecting && playing.value) {
|
|
52
|
+
pause()
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
const computedRatio = computed(() => {
|
|
57
|
+
if (props.ratio) {
|
|
58
|
+
return props.ratio.split(':')
|
|
59
|
+
} else {
|
|
60
|
+
return undefined
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
const computedStyle = computed(() => {
|
|
65
|
+
return {
|
|
66
|
+
height: props.fill ? '100%' : undefined,
|
|
67
|
+
'aspect-ratio':
|
|
68
|
+
computedRatio.value && !props.fill
|
|
69
|
+
? `${computedRatio.value[0]}/${computedRatio.value[1]}`
|
|
70
|
+
: undefined,
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
defineExpose({
|
|
75
|
+
playerApi,
|
|
76
|
+
mediaApi,
|
|
77
|
+
runtimeProvider,
|
|
78
|
+
})
|
|
79
|
+
</script>
|
|
80
|
+
|
|
81
|
+
<style lang="postcss">
|
|
82
|
+
.magic-player {
|
|
83
|
+
--aspect-ratio: 16 / 9;
|
|
84
|
+
position: relative;
|
|
85
|
+
width: 100%;
|
|
86
|
+
overflow: hidden;
|
|
87
|
+
aspect-ratio: var(--aspect-ratio);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.magic-player-video {
|
|
91
|
+
position: absolute;
|
|
92
|
+
width: 100%;
|
|
93
|
+
height: 100%;
|
|
94
|
+
top: 0;
|
|
95
|
+
left: 0;
|
|
96
|
+
object-fit: cover;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.magic-player-poster {
|
|
100
|
+
position: absolute;
|
|
101
|
+
inset: 0;
|
|
102
|
+
}
|
|
103
|
+
</style>
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { SourceType } from './../types';
|
|
2
|
+
export type MagicPlayerProps = {
|
|
3
|
+
srcType?: SourceType;
|
|
4
|
+
src: string;
|
|
5
|
+
ratio?: string;
|
|
6
|
+
fill?: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
9
|
+
fill: {
|
|
10
|
+
type: import("vue").PropType<boolean>;
|
|
11
|
+
default: boolean;
|
|
12
|
+
};
|
|
13
|
+
srcType: {
|
|
14
|
+
type: import("vue").PropType<SourceType>;
|
|
15
|
+
default: string;
|
|
16
|
+
};
|
|
17
|
+
src: {
|
|
18
|
+
type: import("vue").PropType<string>;
|
|
19
|
+
required: true;
|
|
20
|
+
default: string;
|
|
21
|
+
};
|
|
22
|
+
ratio: {
|
|
23
|
+
type: import("vue").PropType<string>;
|
|
24
|
+
default: string;
|
|
25
|
+
};
|
|
26
|
+
}, {
|
|
27
|
+
playerApi: {
|
|
28
|
+
isFullscreen: import("vue").Ref<boolean>;
|
|
29
|
+
touched: import("vue").Ref<boolean>;
|
|
30
|
+
play: () => void;
|
|
31
|
+
pause: () => void;
|
|
32
|
+
togglePlay: () => void;
|
|
33
|
+
seek: (time: number) => void;
|
|
34
|
+
mute: () => void;
|
|
35
|
+
unmute: () => void;
|
|
36
|
+
enterFullscreen: () => Promise<void>;
|
|
37
|
+
exitFullscreen: () => Promise<void>;
|
|
38
|
+
toggleFullscreen: () => Promise<void>;
|
|
39
|
+
};
|
|
40
|
+
mediaApi: {
|
|
41
|
+
currentTime: import("vue").Ref<number>;
|
|
42
|
+
duration: import("vue").Ref<number>;
|
|
43
|
+
waiting: import("vue").Ref<boolean>;
|
|
44
|
+
seeking: import("vue").Ref<boolean>;
|
|
45
|
+
ended: import("vue").Ref<boolean>;
|
|
46
|
+
stalled: import("vue").Ref<boolean>;
|
|
47
|
+
buffered: import("vue").Ref<[number, number][]>;
|
|
48
|
+
playing: import("vue").Ref<boolean>;
|
|
49
|
+
rate: import("vue").Ref<number>;
|
|
50
|
+
volume: import("vue").Ref<number>;
|
|
51
|
+
muted: import("vue").Ref<boolean>;
|
|
52
|
+
};
|
|
53
|
+
runtimeProvider: import("../composables/useRuntimeSourceProvider").UseRuntimeSourceProviderReturn;
|
|
54
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
55
|
+
fill: {
|
|
56
|
+
type: import("vue").PropType<boolean>;
|
|
57
|
+
default: boolean;
|
|
58
|
+
};
|
|
59
|
+
srcType: {
|
|
60
|
+
type: import("vue").PropType<SourceType>;
|
|
61
|
+
default: string;
|
|
62
|
+
};
|
|
63
|
+
src: {
|
|
64
|
+
type: import("vue").PropType<string>;
|
|
65
|
+
required: true;
|
|
66
|
+
default: string;
|
|
67
|
+
};
|
|
68
|
+
ratio: {
|
|
69
|
+
type: import("vue").PropType<string>;
|
|
70
|
+
default: string;
|
|
71
|
+
};
|
|
72
|
+
}>>, {
|
|
73
|
+
fill: boolean;
|
|
74
|
+
srcType: SourceType;
|
|
75
|
+
src: string;
|
|
76
|
+
ratio: string;
|
|
77
|
+
}, {}>, {
|
|
78
|
+
poster?(_: {}): any;
|
|
79
|
+
default?(_: {}): any;
|
|
80
|
+
}>;
|
|
81
|
+
export default _default;
|
|
82
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
83
|
+
new (): {
|
|
84
|
+
$slots: S;
|
|
85
|
+
};
|
|
86
|
+
};
|