@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.
@@ -1,38 +1,38 @@
1
1
  import './NmorphVideoPreview.css';
2
- import { defineComponent as Y, useAttrs as Z, useSlots as ee, ref as w, computed as l, watch as oe, openBlock as t, createElementBlock as r, Fragment as te, createElementVNode as y, mergeProps as ae, createCommentVNode as s, createVNode as n, unref as a, withCtx as d, createBlock as m, toDisplayString as g, renderSlot as re, Teleport as le } from "vue";
3
- import { useModifiers as ne } from "../../../utils/create-modifiers.js";
4
- import { createCssSizeVariables as se } from "../../../utils/common.js";
5
- import u from "../../basic/nmorph-icon/NmorphIcon.vue.js";
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 ie from "../../../assets/icons/video.svg.js";
8
- import de from "../../others/nmorph-overlay/NmorphOverlay.vue.js";
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 ce from "../../../assets/icons/pause.svg.js";
11
- import ue from "../../../assets/icons/play.svg.js";
12
- import pe from "../../../assets/icons/loading.svg.js";
13
- import ve from "../../../assets/icons/eye.svg.js";
14
- import me from "../../../assets/icons/full-screen.svg.js";
15
- import fe from "../../../assets/icons/open.svg.js";
16
- import he from "../../../assets/icons/download.svg.js";
17
- const _e = ["src", "poster", "controls", "muted", "playsinline", "preload"], we = ["aria-label"], ye = {
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
- }, be = {
20
+ }, Pe = {
21
21
  key: 2,
22
22
  class: "nmorph-video-preview__error"
23
- }, ke = {
23
+ }, Ce = {
24
24
  key: 3,
25
25
  class: "nmorph-video-preview__meta"
26
- }, ge = {
26
+ }, Ne = {
27
27
  key: 0,
28
28
  class: "nmorph-video-preview__name"
29
- }, Be = {
29
+ }, Ae = {
30
30
  key: 1,
31
31
  class: "nmorph-video-preview__duration"
32
- }, Pe = {
32
+ }, Oe = {
33
33
  key: 4,
34
34
  class: "nmorph-video-preview__actions"
35
- }, Ae = ["aria-label"], Ce = ["aria-label"], He = ["href", "aria-label"], Ne = ["href", "download", "aria-label"], Oe = { class: "nmorph-video-preview__portal" }, $e = { class: "nmorph-video-preview__portal-content" }, Se = ["src", "poster", "muted", "playsinline", "preload"], B = "var(--nmorph-contrast-text-color)", Je = /* @__PURE__ */ Y({
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(N, { expose: O, emit: $ }) {
66
- const e = N, c = $, b = Z(), S = ee(), p = w(null), f = w(!1), i = w(!1), h = w(!1), E = (o) => {
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 v = Math.round(o / 1e3), W = Math.floor(v / 60), X = v % 60;
69
- return `${W}:${X.toString().padStart(2, "0")}`;
70
- }, k = l(() => E(e.durationMs)), _ = l(() => !!e.src && !e.loading && !e.error), F = l(() => e.showPlaybackButton && _.value && h.value), P = l(() => e.showFullscreenAction && _.value && !e.controls), I = l(() => _.value && (e.showPreviewAction || P.value)), z = l(() => e.showDefaultActions && (e.src || e.downloadHref)), A = l(() => !!S.actions || I.value || z.value), D = l(
71
- () => ne({
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
- !A.value && "no-actions"
83
+ !E.value && "no-actions"
82
84
  ]
83
85
  })
84
- ), M = l(
85
- () => se({
86
+ ), T = r(
87
+ () => ue({
86
88
  "--nmorph-video-preview-width": e.width,
87
89
  "--nmorph-video-preview-height": e.height
88
90
  })
89
- ), x = l(() => Object.fromEntries(Object.entries(b).filter(([o]) => o !== "class" && o !== "style"))), R = l(() => [D.value, b.class]), T = l(() => [M.value, b.style]);
90
- oe(
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, h.value = !1;
95
+ i.value = !1, m.value = !1;
94
96
  }
95
97
  );
96
- const V = () => c("open"), L = () => c("download"), q = () => {
97
- e.previewMode === "internal" && (f.value = !0), c("preview");
98
- }, C = () => {
99
- f.value = !1;
100
- }, j = async () => {
101
- const o = p.value;
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
- c("fullscreen");
105
+ p("fullscreen");
104
106
  try {
105
- const v = o.requestFullscreen?.() || o.webkitRequestFullscreen?.();
106
- if (v) {
107
- await v;
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
- }, K = async () => {
115
- if (!(!p.value || e.loading || e.error)) {
116
+ }, W = async () => {
117
+ if (!(!c.value || e.loading || e.error || !m.value)) {
116
118
  if (i.value) {
117
- p.value.pause();
119
+ c.value.pause();
118
120
  return;
119
121
  }
120
122
  try {
121
- await p.value.play();
123
+ await c.value.play();
122
124
  } catch {
123
125
  i.value = !1;
124
126
  }
125
127
  }
126
- }, H = () => {
127
- h.value = !0;
128
- }, G = (o) => {
129
- i.value = !0, c("play", o);
130
- }, J = (o) => {
131
- i.value = !1, c("pause", o);
132
- }, Q = () => {
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
- }, U = (o) => {
135
- i.value = !1, h.value = !1, c("error", o);
147
+ }, oe = (o) => {
148
+ i.value = !1, m.value = !1, p("error", o);
136
149
  };
137
- return O({ videoRef: p }), (o, v) => (t(), r(te, null, [
138
- y("div", ae(x.value, {
139
- class: R.value,
140
- style: T.value
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(), r("video", {
155
+ !e.loading && !e.error ? (t(), l("video", {
143
156
  key: 0,
144
157
  ref_key: "videoRef",
145
- ref: p,
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: e.preload,
153
- onLoadeddata: H,
154
- onCanplay: H,
155
- onPlay: G,
156
- onPause: J,
157
- onEnded: Q,
158
- onError: U
159
- }, null, 40, _e)) : s("", !0),
160
- F.value ? (t(), r("button", {
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: K
181
+ onClick: W
166
182
  }, [
167
- n(a(u), {
183
+ n(a(v), {
168
184
  size: "medium",
169
- color: B
185
+ color: A
170
186
  }, {
171
- default: d(() => [
172
- i.value ? (t(), m(a(ce), { key: 0 })) : (t(), m(a(ue), { key: 1 }))
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, we)) : (t(), r("div", ye, [
177
- e.loading ? (t(), m(a(u), {
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: d(() => [
182
- n(a(pe))
197
+ default: u(() => [
198
+ n(a(he))
183
199
  ]),
184
200
  _: 1
185
- })) : (t(), m(a(u), {
201
+ })) : (t(), _(a(v), {
186
202
  key: 1,
187
203
  size: "large"
188
204
  }, {
189
- default: d(() => [
190
- n(a(ie))
205
+ default: u(() => [
206
+ n(a(pe))
191
207
  ]),
192
208
  _: 1
193
209
  })),
194
- e.error && e.errorText ? (t(), r("span", be, g(e.errorText), 1)) : s("", !0)
210
+ e.error && e.errorText ? (t(), l("span", Pe, N(e.errorText), 1)) : s("", !0)
195
211
  ])),
196
- e.showMeta && (e.name || k.value) ? (t(), r("div", ke, [
197
- e.name ? (t(), r("span", ge, g(e.name), 1)) : s("", !0),
198
- k.value ? (t(), r("span", Be, g(k.value), 1)) : s("", !0)
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
- A.value ? (t(), r("div", Pe, [
201
- re(o.$slots, "actions", {}, () => [
202
- e.showPreviewAction && _.value ? (t(), r("button", {
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: q
223
+ onClick: J
208
224
  }, [
209
- n(a(u), {
225
+ n(a(v), {
210
226
  size: "small",
211
- color: B
227
+ color: A
212
228
  }, {
213
- default: d(() => [
214
- n(a(ve))
229
+ default: u(() => [
230
+ n(a(_e))
215
231
  ]),
216
232
  _: 1
217
233
  })
218
- ], 8, Ae)) : s("", !0),
219
- P.value ? (t(), r("button", {
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: j
240
+ onClick: Q
225
241
  }, [
226
- n(a(u), {
242
+ n(a(v), {
227
243
  size: "small",
228
- color: B
244
+ color: A
229
245
  }, {
230
- default: d(() => [
231
- n(a(me))
246
+ default: u(() => [
247
+ n(a(we))
232
248
  ]),
233
249
  _: 1
234
250
  })
235
- ], 8, Ce)) : s("", !0),
236
- e.showDefaultActions && e.src ? (t(), r("a", {
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: V
259
+ onClick: U
244
260
  }, [
245
- n(a(u), { size: "small" }, {
246
- default: d(() => [
247
- n(a(fe))
261
+ n(a(v), { size: "small" }, {
262
+ default: u(() => [
263
+ n(a(ye))
248
264
  ]),
249
265
  _: 1
250
266
  })
251
- ], 8, He)) : s("", !0),
252
- e.downloadHref ? (t(), r("a", {
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: L
274
+ onClick: G
259
275
  }, [
260
- n(a(u), { size: "small" }, {
261
- default: d(() => [
262
- n(a(he))
276
+ n(a(v), { size: "small" }, {
277
+ default: u(() => [
278
+ n(a(be))
263
279
  ]),
264
280
  _: 1
265
281
  })
266
- ], 8, Ne)) : s("", !0)
282
+ ], 8, He)) : s("", !0)
267
283
  ])
268
284
  ])) : s("", !0)
269
285
  ], 16),
270
- f.value ? (t(), m(le, {
286
+ w.value ? (t(), _(de, {
271
287
  key: 0,
272
288
  to: "body"
273
289
  }, [
274
- y("div", Oe, [
275
- n(a(de), {
276
- show: f.value,
290
+ g("div", De, [
291
+ n(a(ve), {
292
+ show: w.value,
277
293
  "disabled-teleport": "",
278
- onOnOutsideClick: C,
279
- onOnEscapeKeydown: C
294
+ onOnOutsideClick: S,
295
+ onOnEscapeKeydown: S
280
296
  }, {
281
- default: d(() => [
282
- y("div", $e, [
283
- y("video", {
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, Se)
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
- Je as default
319
+ Xe as default
304
320
  };