@nmorph/nmorph-ui-kit 2.2.54 → 2.2.55
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/components/data/nmorph-file-card/NmorphFileCard.css +1 -1
- package/dist/components/data/nmorph-file-card/NmorphFileCard.vue.js +26 -25
- package/dist/components/data/nmorph-media-gallery/NmorphMediaGallery.vue.js +291 -275
- package/dist/components/data/nmorph-video-preview/NmorphVideoPreview.vue.js +141 -125
- package/dist/index.umd.js +20 -20
- package/dist/package.json.js +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
import './NmorphVideoPreview.css';
|
|
2
|
-
import { defineComponent as
|
|
3
|
-
import { useModifiers as
|
|
4
|
-
import { createCssSizeVariables as
|
|
5
|
-
import
|
|
2
|
+
import { defineComponent as te, useAttrs as ae, useSlots as re, ref as k, computed as r, watch as le, openBlock as t, createElementBlock as l, Fragment as ne, createElementVNode as g, mergeProps as se, createCommentVNode as s, createVNode as n, unref as a, withCtx as u, createBlock as _, toDisplayString as N, renderSlot as ie, Teleport as de } from "vue";
|
|
3
|
+
import { useModifiers as ce } from "../../../utils/create-modifiers.js";
|
|
4
|
+
import { createCssSizeVariables as ue } from "../../../utils/common.js";
|
|
5
|
+
import v from "../../basic/nmorph-icon/NmorphIcon.vue.js";
|
|
6
6
|
/* empty css */
|
|
7
|
-
import
|
|
8
|
-
import
|
|
7
|
+
import pe from "../../../assets/icons/video.svg.js";
|
|
8
|
+
import ve from "../../others/nmorph-overlay/NmorphOverlay.vue.js";
|
|
9
9
|
/* empty css */
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
const
|
|
10
|
+
import me from "../../../assets/icons/pause.svg.js";
|
|
11
|
+
import fe from "../../../assets/icons/play.svg.js";
|
|
12
|
+
import he from "../../../assets/icons/loading.svg.js";
|
|
13
|
+
import _e from "../../../assets/icons/eye.svg.js";
|
|
14
|
+
import we from "../../../assets/icons/full-screen.svg.js";
|
|
15
|
+
import ye from "../../../assets/icons/open.svg.js";
|
|
16
|
+
import be from "../../../assets/icons/download.svg.js";
|
|
17
|
+
const ke = ["src", "poster", "controls", "muted", "playsinline", "preload"], ge = ["aria-label"], Be = {
|
|
18
18
|
key: 2,
|
|
19
19
|
class: "nmorph-video-preview__state"
|
|
20
|
-
},
|
|
20
|
+
}, Pe = {
|
|
21
21
|
key: 2,
|
|
22
22
|
class: "nmorph-video-preview__error"
|
|
23
|
-
},
|
|
23
|
+
}, Ce = {
|
|
24
24
|
key: 3,
|
|
25
25
|
class: "nmorph-video-preview__meta"
|
|
26
|
-
},
|
|
26
|
+
}, Ne = {
|
|
27
27
|
key: 0,
|
|
28
28
|
class: "nmorph-video-preview__name"
|
|
29
|
-
},
|
|
29
|
+
}, Ae = {
|
|
30
30
|
key: 1,
|
|
31
31
|
class: "nmorph-video-preview__duration"
|
|
32
|
-
},
|
|
32
|
+
}, Oe = {
|
|
33
33
|
key: 4,
|
|
34
34
|
class: "nmorph-video-preview__actions"
|
|
35
|
-
},
|
|
35
|
+
}, Ee = ["aria-label"], Se = ["aria-label"], Fe = ["href", "aria-label"], He = ["href", "download", "aria-label"], De = { class: "nmorph-video-preview__portal" }, Ie = { class: "nmorph-video-preview__portal-content" }, $e = ["src", "poster", "muted", "playsinline", "preload"], A = "var(--nmorph-contrast-text-color)", F = 0.25, Xe = /* @__PURE__ */ te({
|
|
36
36
|
inheritAttrs: !1,
|
|
37
37
|
__name: "NmorphVideoPreview",
|
|
38
38
|
props: {
|
|
@@ -62,13 +62,15 @@ const _e = ["src", "poster", "controls", "muted", "playsinline", "preload"], we
|
|
|
62
62
|
previewMode: { default: "internal" }
|
|
63
63
|
},
|
|
64
64
|
emits: ["play", "pause", "open", "preview", "fullscreen", "download", "error"],
|
|
65
|
-
setup(
|
|
66
|
-
const e =
|
|
65
|
+
setup(H, { expose: D, emit: I }) {
|
|
66
|
+
const e = H, p = I, B = ae(), $ = re(), c = k(null), w = k(!1), i = k(!1), m = k(!1), x = (o) => {
|
|
67
67
|
if (!o || o < 0) return "";
|
|
68
|
-
const
|
|
69
|
-
return `${
|
|
70
|
-
},
|
|
71
|
-
() =>
|
|
68
|
+
const d = Math.round(o / 1e3), h = Math.floor(d / 60), C = d % 60;
|
|
69
|
+
return `${h}:${C.toString().padStart(2, "0")}`;
|
|
70
|
+
}, P = r(() => x(e.durationMs)), y = r(() => !!e.src && !e.loading && !e.error), M = r(() => e.showPlaybackButton && y.value && m.value), V = r(
|
|
71
|
+
() => e.showPlaybackButton && e.preload === "metadata" ? "auto" : e.preload
|
|
72
|
+
), O = r(() => e.showFullscreenAction && y.value && !e.controls), z = r(() => y.value && (e.showPreviewAction || O.value)), R = r(() => e.showDefaultActions && (e.src || e.downloadHref)), E = r(() => !!$.actions || z.value || R.value), L = r(
|
|
73
|
+
() => ce({
|
|
72
74
|
"nmorph-video-preview": [
|
|
73
75
|
e.surface,
|
|
74
76
|
e.embedded && "embedded",
|
|
@@ -78,209 +80,223 @@ const _e = ["src", "poster", "controls", "muted", "playsinline", "preload"], we
|
|
|
78
80
|
e.loading && "loading",
|
|
79
81
|
e.error && "error",
|
|
80
82
|
i.value && "playing",
|
|
81
|
-
!
|
|
83
|
+
!E.value && "no-actions"
|
|
82
84
|
]
|
|
83
85
|
})
|
|
84
|
-
),
|
|
85
|
-
() =>
|
|
86
|
+
), T = r(
|
|
87
|
+
() => ue({
|
|
86
88
|
"--nmorph-video-preview-width": e.width,
|
|
87
89
|
"--nmorph-video-preview-height": e.height
|
|
88
90
|
})
|
|
89
|
-
),
|
|
90
|
-
|
|
91
|
+
), q = r(() => Object.fromEntries(Object.entries(B).filter(([o]) => o !== "class" && o !== "style"))), j = r(() => [L.value, B.class]), K = r(() => [T.value, B.style]);
|
|
92
|
+
le(
|
|
91
93
|
() => [e.src, e.loading, e.error],
|
|
92
94
|
() => {
|
|
93
|
-
i.value = !1,
|
|
95
|
+
i.value = !1, m.value = !1;
|
|
94
96
|
}
|
|
95
97
|
);
|
|
96
|
-
const
|
|
97
|
-
e.previewMode === "internal" && (
|
|
98
|
-
},
|
|
99
|
-
|
|
100
|
-
},
|
|
101
|
-
const o =
|
|
98
|
+
const U = () => p("open"), G = () => p("download"), J = () => {
|
|
99
|
+
e.previewMode === "internal" && (w.value = !0), p("preview");
|
|
100
|
+
}, S = () => {
|
|
101
|
+
w.value = !1;
|
|
102
|
+
}, Q = async () => {
|
|
103
|
+
const o = c.value;
|
|
102
104
|
if (o) {
|
|
103
|
-
|
|
105
|
+
p("fullscreen");
|
|
104
106
|
try {
|
|
105
|
-
const
|
|
106
|
-
if (
|
|
107
|
-
await
|
|
107
|
+
const d = o.requestFullscreen?.() || o.webkitRequestFullscreen?.();
|
|
108
|
+
if (d) {
|
|
109
|
+
await d;
|
|
108
110
|
return;
|
|
109
111
|
}
|
|
110
112
|
o.webkitEnterFullscreen?.();
|
|
111
113
|
} catch {
|
|
112
114
|
}
|
|
113
115
|
}
|
|
114
|
-
},
|
|
115
|
-
if (!(!
|
|
116
|
+
}, W = async () => {
|
|
117
|
+
if (!(!c.value || e.loading || e.error || !m.value)) {
|
|
116
118
|
if (i.value) {
|
|
117
|
-
|
|
119
|
+
c.value.pause();
|
|
118
120
|
return;
|
|
119
121
|
}
|
|
120
122
|
try {
|
|
121
|
-
await
|
|
123
|
+
await c.value.play();
|
|
122
124
|
} catch {
|
|
123
125
|
i.value = !1;
|
|
124
126
|
}
|
|
125
127
|
}
|
|
126
|
-
},
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
128
|
+
}, X = (o) => {
|
|
129
|
+
const d = o.duration;
|
|
130
|
+
if (!Number.isFinite(d) || d <= 0) return !1;
|
|
131
|
+
const h = o.buffered, C = Math.max(0, d - F);
|
|
132
|
+
for (let b = 0; b < h.length; b += 1)
|
|
133
|
+
try {
|
|
134
|
+
if (h.start(b) <= F && h.end(b) >= C) return !0;
|
|
135
|
+
} catch {
|
|
136
|
+
return !1;
|
|
137
|
+
}
|
|
138
|
+
return !1;
|
|
139
|
+
}, f = () => {
|
|
140
|
+
m.value = c.value ? X(c.value) : !1;
|
|
141
|
+
}, Y = (o) => {
|
|
142
|
+
i.value = !0, p("play", o);
|
|
143
|
+
}, Z = (o) => {
|
|
144
|
+
i.value = !1, p("pause", o);
|
|
145
|
+
}, ee = () => {
|
|
133
146
|
i.value = !1;
|
|
134
|
-
},
|
|
135
|
-
i.value = !1,
|
|
147
|
+
}, oe = (o) => {
|
|
148
|
+
i.value = !1, m.value = !1, p("error", o);
|
|
136
149
|
};
|
|
137
|
-
return
|
|
138
|
-
|
|
139
|
-
class:
|
|
140
|
-
style:
|
|
150
|
+
return D({ videoRef: c }), (o, d) => (t(), l(ne, null, [
|
|
151
|
+
g("div", se(q.value, {
|
|
152
|
+
class: j.value,
|
|
153
|
+
style: K.value
|
|
141
154
|
}), [
|
|
142
|
-
!e.loading && !e.error ? (t(),
|
|
155
|
+
!e.loading && !e.error ? (t(), l("video", {
|
|
143
156
|
key: 0,
|
|
144
157
|
ref_key: "videoRef",
|
|
145
|
-
ref:
|
|
158
|
+
ref: c,
|
|
146
159
|
class: "nmorph-video-preview__media",
|
|
147
160
|
src: e.src,
|
|
148
161
|
poster: e.poster || void 0,
|
|
149
162
|
controls: e.controls,
|
|
150
163
|
muted: e.muted,
|
|
151
164
|
playsinline: e.playsinline,
|
|
152
|
-
preload:
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
165
|
+
preload: V.value,
|
|
166
|
+
onLoadedmetadata: f,
|
|
167
|
+
onDurationchange: f,
|
|
168
|
+
onProgress: f,
|
|
169
|
+
onCanplaythrough: f,
|
|
170
|
+
onSuspend: f,
|
|
171
|
+
onPlay: Y,
|
|
172
|
+
onPause: Z,
|
|
173
|
+
onEnded: ee,
|
|
174
|
+
onError: oe
|
|
175
|
+
}, null, 40, ke)) : s("", !0),
|
|
176
|
+
M.value ? (t(), l("button", {
|
|
161
177
|
key: 1,
|
|
162
178
|
class: "nmorph-video-preview__play",
|
|
163
179
|
type: "button",
|
|
164
180
|
"aria-label": i.value ? `Pause ${e.name || "video"}` : `Play ${e.name || "video"}`,
|
|
165
|
-
onClick:
|
|
181
|
+
onClick: W
|
|
166
182
|
}, [
|
|
167
|
-
n(a(
|
|
183
|
+
n(a(v), {
|
|
168
184
|
size: "medium",
|
|
169
|
-
color:
|
|
185
|
+
color: A
|
|
170
186
|
}, {
|
|
171
|
-
default:
|
|
172
|
-
i.value ? (t(),
|
|
187
|
+
default: u(() => [
|
|
188
|
+
i.value ? (t(), _(a(me), { key: 0 })) : (t(), _(a(fe), { key: 1 }))
|
|
173
189
|
]),
|
|
174
190
|
_: 1
|
|
175
191
|
})
|
|
176
|
-
], 8,
|
|
177
|
-
e.loading ? (t(),
|
|
192
|
+
], 8, ge)) : (t(), l("div", Be, [
|
|
193
|
+
e.loading ? (t(), _(a(v), {
|
|
178
194
|
key: 0,
|
|
179
195
|
size: "large"
|
|
180
196
|
}, {
|
|
181
|
-
default:
|
|
182
|
-
n(a(
|
|
197
|
+
default: u(() => [
|
|
198
|
+
n(a(he))
|
|
183
199
|
]),
|
|
184
200
|
_: 1
|
|
185
|
-
})) : (t(),
|
|
201
|
+
})) : (t(), _(a(v), {
|
|
186
202
|
key: 1,
|
|
187
203
|
size: "large"
|
|
188
204
|
}, {
|
|
189
|
-
default:
|
|
190
|
-
n(a(
|
|
205
|
+
default: u(() => [
|
|
206
|
+
n(a(pe))
|
|
191
207
|
]),
|
|
192
208
|
_: 1
|
|
193
209
|
})),
|
|
194
|
-
e.error && e.errorText ? (t(),
|
|
210
|
+
e.error && e.errorText ? (t(), l("span", Pe, N(e.errorText), 1)) : s("", !0)
|
|
195
211
|
])),
|
|
196
|
-
e.showMeta && (e.name ||
|
|
197
|
-
e.name ? (t(),
|
|
198
|
-
|
|
212
|
+
e.showMeta && (e.name || P.value) ? (t(), l("div", Ce, [
|
|
213
|
+
e.name ? (t(), l("span", Ne, N(e.name), 1)) : s("", !0),
|
|
214
|
+
P.value ? (t(), l("span", Ae, N(P.value), 1)) : s("", !0)
|
|
199
215
|
])) : s("", !0),
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
e.showPreviewAction &&
|
|
216
|
+
E.value ? (t(), l("div", Oe, [
|
|
217
|
+
ie(o.$slots, "actions", {}, () => [
|
|
218
|
+
e.showPreviewAction && y.value ? (t(), l("button", {
|
|
203
219
|
key: 0,
|
|
204
220
|
type: "button",
|
|
205
221
|
class: "nmorph-video-preview__action-button nmorph-video-preview__action-button--preview",
|
|
206
222
|
"aria-label": `Preview ${e.name || "video"}`,
|
|
207
|
-
onClick:
|
|
223
|
+
onClick: J
|
|
208
224
|
}, [
|
|
209
|
-
n(a(
|
|
225
|
+
n(a(v), {
|
|
210
226
|
size: "small",
|
|
211
|
-
color:
|
|
227
|
+
color: A
|
|
212
228
|
}, {
|
|
213
|
-
default:
|
|
214
|
-
n(a(
|
|
229
|
+
default: u(() => [
|
|
230
|
+
n(a(_e))
|
|
215
231
|
]),
|
|
216
232
|
_: 1
|
|
217
233
|
})
|
|
218
|
-
], 8,
|
|
219
|
-
|
|
234
|
+
], 8, Ee)) : s("", !0),
|
|
235
|
+
O.value ? (t(), l("button", {
|
|
220
236
|
key: 1,
|
|
221
237
|
type: "button",
|
|
222
238
|
class: "nmorph-video-preview__action-button nmorph-video-preview__action-button--fullscreen",
|
|
223
239
|
"aria-label": `Fullscreen ${e.name || "video"}`,
|
|
224
|
-
onClick:
|
|
240
|
+
onClick: Q
|
|
225
241
|
}, [
|
|
226
|
-
n(a(
|
|
242
|
+
n(a(v), {
|
|
227
243
|
size: "small",
|
|
228
|
-
color:
|
|
244
|
+
color: A
|
|
229
245
|
}, {
|
|
230
|
-
default:
|
|
231
|
-
n(a(
|
|
246
|
+
default: u(() => [
|
|
247
|
+
n(a(we))
|
|
232
248
|
]),
|
|
233
249
|
_: 1
|
|
234
250
|
})
|
|
235
|
-
], 8,
|
|
236
|
-
e.showDefaultActions && e.src ? (t(),
|
|
251
|
+
], 8, Se)) : s("", !0),
|
|
252
|
+
e.showDefaultActions && e.src ? (t(), l("a", {
|
|
237
253
|
key: 2,
|
|
238
254
|
href: e.src,
|
|
239
255
|
target: "_blank",
|
|
240
256
|
rel: "noopener noreferrer",
|
|
241
257
|
class: "nmorph-video-preview__action-link",
|
|
242
258
|
"aria-label": `Open ${e.name || "video"}`,
|
|
243
|
-
onClick:
|
|
259
|
+
onClick: U
|
|
244
260
|
}, [
|
|
245
|
-
n(a(
|
|
246
|
-
default:
|
|
247
|
-
n(a(
|
|
261
|
+
n(a(v), { size: "small" }, {
|
|
262
|
+
default: u(() => [
|
|
263
|
+
n(a(ye))
|
|
248
264
|
]),
|
|
249
265
|
_: 1
|
|
250
266
|
})
|
|
251
|
-
], 8,
|
|
252
|
-
e.downloadHref ? (t(),
|
|
267
|
+
], 8, Fe)) : s("", !0),
|
|
268
|
+
e.downloadHref ? (t(), l("a", {
|
|
253
269
|
key: 3,
|
|
254
270
|
href: e.downloadHref,
|
|
255
271
|
download: e.name,
|
|
256
272
|
class: "nmorph-video-preview__action-link",
|
|
257
273
|
"aria-label": `Download ${e.name || "video"}`,
|
|
258
|
-
onClick:
|
|
274
|
+
onClick: G
|
|
259
275
|
}, [
|
|
260
|
-
n(a(
|
|
261
|
-
default:
|
|
262
|
-
n(a(
|
|
276
|
+
n(a(v), { size: "small" }, {
|
|
277
|
+
default: u(() => [
|
|
278
|
+
n(a(be))
|
|
263
279
|
]),
|
|
264
280
|
_: 1
|
|
265
281
|
})
|
|
266
|
-
], 8,
|
|
282
|
+
], 8, He)) : s("", !0)
|
|
267
283
|
])
|
|
268
284
|
])) : s("", !0)
|
|
269
285
|
], 16),
|
|
270
|
-
|
|
286
|
+
w.value ? (t(), _(de, {
|
|
271
287
|
key: 0,
|
|
272
288
|
to: "body"
|
|
273
289
|
}, [
|
|
274
|
-
|
|
275
|
-
n(a(
|
|
276
|
-
show:
|
|
290
|
+
g("div", De, [
|
|
291
|
+
n(a(ve), {
|
|
292
|
+
show: w.value,
|
|
277
293
|
"disabled-teleport": "",
|
|
278
|
-
onOnOutsideClick:
|
|
279
|
-
onOnEscapeKeydown:
|
|
294
|
+
onOnOutsideClick: S,
|
|
295
|
+
onOnEscapeKeydown: S
|
|
280
296
|
}, {
|
|
281
|
-
default:
|
|
282
|
-
|
|
283
|
-
|
|
297
|
+
default: u(() => [
|
|
298
|
+
g("div", Ie, [
|
|
299
|
+
g("video", {
|
|
284
300
|
class: "nmorph-video-preview__portal-media",
|
|
285
301
|
src: e.src,
|
|
286
302
|
poster: e.poster || void 0,
|
|
@@ -289,7 +305,7 @@ const _e = ["src", "poster", "controls", "muted", "playsinline", "preload"], we
|
|
|
289
305
|
muted: e.muted,
|
|
290
306
|
playsinline: e.playsinline,
|
|
291
307
|
preload: e.preload
|
|
292
|
-
}, null, 8,
|
|
308
|
+
}, null, 8, $e)
|
|
293
309
|
])
|
|
294
310
|
]),
|
|
295
311
|
_: 1
|
|
@@ -300,5 +316,5 @@ const _e = ["src", "poster", "controls", "muted", "playsinline", "preload"], we
|
|
|
300
316
|
}
|
|
301
317
|
});
|
|
302
318
|
export {
|
|
303
|
-
|
|
319
|
+
Xe as default
|
|
304
320
|
};
|