@nmorph/nmorph-ui-kit 2.2.52 → 2.2.54

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