@nmorph/nmorph-ui-kit 2.2.48 → 2.2.50

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.
Files changed (22) hide show
  1. package/dist/components/data/nmorph-audio-preview/NmorphAudioPreview.css +1 -1
  2. package/dist/components/data/nmorph-audio-preview/NmorphAudioPreview.vue.js +156 -121
  3. package/dist/components/data/nmorph-file-card/NmorphFileCard.css +1 -1
  4. package/dist/components/data/nmorph-file-card/NmorphFileCard.vue.js +112 -55
  5. package/dist/components/data/nmorph-video-preview/NmorphVideoPreview.css +1 -1
  6. package/dist/components/data/nmorph-video-preview/NmorphVideoPreview.vue.js +115 -63
  7. package/dist/components/form/nmorph-text-input/NmorphTextInput.vue.js +7 -7
  8. package/dist/components/providers/nmorph-notification-provider/NmorphNotificationProvider.vue.js +92 -67
  9. package/dist/index.umd.js +19 -19
  10. package/dist/package.json.js +1 -1
  11. package/dist/src/components/data/nmorph-audio-preview/NmorphAudioPreview.vue.d.ts +5 -0
  12. package/dist/src/components/data/nmorph-audio-preview/types.d.ts +5 -0
  13. package/dist/src/components/data/nmorph-file-card/NmorphFileCard.vue.d.ts +3 -2
  14. package/dist/src/components/data/nmorph-file-card/types.d.ts +2 -0
  15. package/dist/src/components/data/nmorph-media-tile/NmorphMediaTile.vue.d.ts +2 -2
  16. package/dist/src/components/data/nmorph-video-preview/NmorphVideoPreview.vue.d.ts +13 -6
  17. package/dist/src/components/data/nmorph-video-preview/types.d.ts +4 -0
  18. package/dist/src/components/feedback/nmorph-alert/NmorphAlert.vue.d.ts +1 -1
  19. package/dist/src/components/providers/nmorph-notification-provider/types.d.ts +1 -0
  20. package/dist/src/outside-hooks/use-nmorph-notification.d.ts +2 -0
  21. package/dist/style.css +1 -1
  22. package/package.json +1 -1
@@ -1,31 +1,36 @@
1
1
  import './NmorphFileCard.css';
2
- import { defineComponent as M, useSlots as $, computed as t, openBlock as r, createElementBlock as a, normalizeClass as E, createElementVNode as _, createBlock as v, unref as n, withCtx as c, createVNode as l, resolveDynamicComponent as F, toDisplayString as d, createCommentVNode as s, renderSlot as R } from "vue";
3
- import { useModifiers as V } from "../../../utils/create-modifiers.js";
4
- import { getFileExtension as z, getPlainFileType as W, getTypeCandidates as K, isKnownFileType as m } from "../../../utils/file-types.js";
5
- import { NmorphImageResolution as O, NmorphAudioResolution as j, NmorphVideoResolution as G, NmorphArchiveResolution as P, NmorphDocResolution as q } from "../../form/nmorph-file-upload/types.js";
6
- import J from "../../../assets/icons/image.svg.js";
7
- import Q from "../../../assets/icons/video.svg.js";
8
- import U from "../../../assets/icons/archive.svg.js";
9
- import g from "../../../assets/icons/doc.svg.js";
2
+ import { defineComponent as O, useSlots as W, computed as r, openBlock as a, createElementBlock as t, normalizeClass as K, createElementVNode as v, createBlock as c, unref as n, withCtx as m, createVNode as l, resolveDynamicComponent as j, createCommentVNode as i, toDisplayString as h, renderSlot as G } from "vue";
3
+ import { useModifiers as q } from "../../../utils/create-modifiers.js";
4
+ import { getFileExtension as J, getPlainFileType as Q, getTypeCandidates as U, isKnownFileType as d } from "../../../utils/file-types.js";
5
+ import { NmorphImageResolution as X, NmorphAudioResolution as Y, NmorphVideoResolution as Z, NmorphArchiveResolution as ee, NmorphDocResolution as oe } from "../../form/nmorph-file-upload/types.js";
6
+ import re from "../nmorph-audio-preview/NmorphAudioPreview.vue.js";
7
+ /* empty css */
8
+ import ae from "../nmorph-video-preview/NmorphVideoPreview.vue.js";
9
+ /* empty css */
10
+ import ne from "../../../assets/icons/image.svg.js";
11
+ import te from "../../../assets/icons/archive.svg.js";
12
+ import A from "../../../assets/icons/doc.svg.js";
10
13
  import p from "../../basic/nmorph-icon/NmorphIcon.vue.js";
11
14
  /* empty css */
12
- import X from "../../../assets/icons/audio.svg.js";
13
- import Y from "../../../assets/icons/loading.svg.js";
14
- import Z from "../../../assets/icons/open.svg.js";
15
- import ee from "../../../assets/icons/download.svg.js";
16
- const oe = { class: "nmorph-file-card__icon" }, re = { class: "nmorph-file-card__body" }, te = { class: "nmorph-file-card__name" }, ae = {
15
+ import ie from "../../../assets/icons/eye.svg.js";
16
+ import le from "../../../assets/icons/audio.svg.js";
17
+ import se from "../../../assets/icons/video.svg.js";
18
+ import ce from "../../../assets/icons/loading.svg.js";
19
+ import me from "../../../assets/icons/open.svg.js";
20
+ import de from "../../../assets/icons/download.svg.js";
21
+ const pe = { class: "nmorph-file-card__icon" }, ue = ["href", "aria-label"], fe = { class: "nmorph-file-card__body" }, ve = { class: "nmorph-file-card__info" }, he = { class: "nmorph-file-card__name" }, _e = {
17
22
  key: 0,
18
23
  class: "nmorph-file-card__error"
19
- }, ne = {
24
+ }, we = {
20
25
  key: 1,
21
26
  class: "nmorph-file-card__meta"
22
- }, ie = {
27
+ }, ye = {
23
28
  key: 0,
24
29
  class: "nmorph-file-card__badge"
25
- }, le = {
30
+ }, ge = {
26
31
  key: 1,
27
32
  class: "nmorph-file-card__actions"
28
- }, se = ["href", "aria-label"], me = ["href", "download", "aria-label"], Te = /* @__PURE__ */ M({
33
+ }, Be = ["href", "aria-label"], Ne = ["href", "download", "aria-label"], Oe = /* @__PURE__ */ O({
29
34
  __name: "NmorphFileCard",
30
35
  props: {
31
36
  name: {},
@@ -34,6 +39,7 @@ const oe = { class: "nmorph-file-card__icon" }, re = { class: "nmorph-file-card_
34
39
  size: { default: void 0 },
35
40
  previewSrc: { default: "" },
36
41
  downloadHref: { default: "" },
42
+ mediaPreview: { default: "none" },
37
43
  surface: { default: "card" },
38
44
  showExtensionBadge: { type: Boolean, default: !0 },
39
45
  iconSurface: { type: Boolean, default: !0 },
@@ -44,90 +50,141 @@ const oe = { class: "nmorph-file-card__icon" }, re = { class: "nmorph-file-card_
44
50
  showDefaultActions: { type: Boolean, default: !0 }
45
51
  },
46
52
  emits: ["open", "download", "error"],
47
- setup(B, { emit: k }) {
48
- const e = B, y = k, T = $(), u = t(() => (e.extension || z(e.name) || W(e.mimeType)).toLowerCase()), i = t(() => K(e.mimeType, e.name)), x = t(() => e.mimeType.toLowerCase().startsWith("image/") || i.value.some((o) => m(o, O)) ? J : e.mimeType.toLowerCase().startsWith("audio/") || i.value.some((o) => m(o, j)) ? X : e.mimeType.toLowerCase().startsWith("video/") || i.value.some((o) => m(o, G)) ? Q : i.value.some((o) => m(o, P)) ? U : i.value.some((o) => m(o, q)) ? g : g), C = (o) => {
53
+ setup(P, { emit: H }) {
54
+ const e = P, _ = H, D = W(), u = r(() => (e.extension || J(e.name) || Q(e.mimeType)).toLowerCase()), s = r(() => U(e.mimeType, e.name)), $ = r(() => e.mimeType.toLowerCase().startsWith("image/") || s.value.some((o) => d(o, X)) ? ne : e.mimeType.toLowerCase().startsWith("audio/") || s.value.some((o) => d(o, Y)) ? le : e.mimeType.toLowerCase().startsWith("video/") || s.value.some((o) => d(o, Z)) ? se : s.value.some((o) => d(o, ee)) ? te : s.value.some((o) => d(o, oe)) ? A : A), E = (o) => {
49
55
  if (o === void 0 || Number.isNaN(o) || o < 0) return "";
50
56
  if (o === 0) return "0 B";
51
- const f = ["B", "KB", "MB", "GB", "TB"], h = Math.min(Math.floor(Math.log(o) / Math.log(1024)), f.length - 1), N = o / 1024 ** h, L = N >= 10 || h === 0 ? 0 : 1;
52
- return `${N.toFixed(L)} ${f[h]}`;
53
- }, S = t(() => C(e.size)), I = t(() => u.value || e.mimeType), w = t(() => [I.value, S.value].filter(Boolean).join(" · ")), b = t(
54
- () => !!T.actions || e.showDefaultActions && (e.previewSrc || e.downloadHref)
55
- ), D = t(
56
- () => V({
57
+ const B = ["B", "KB", "MB", "GB", "TB"], N = Math.min(Math.floor(Math.log(o) / Math.log(1024)), B.length - 1), k = o / 1024 ** N, V = k >= 10 || N === 0 || Number.isInteger(k) ? 0 : 1;
58
+ return `${k.toFixed(V)} ${B[N]}`;
59
+ }, L = r(() => E(e.size)), M = r(() => u.value || e.mimeType), b = r(() => [M.value, L.value].filter(Boolean).join(" · ")), w = r(() => e.mediaPreview === "audio" && !!e.previewSrc && !e.loading && !e.error), y = r(() => e.mediaPreview === "video" && !!e.previewSrc && !e.loading && !e.error), f = r(() => w.value || y.value), z = r(() => e.compact ? "96px" : "120px"), S = r(() => e.mimeType.toLowerCase() === "application/pdf" || u.value === "pdf"), x = r(() => S.value ? e.previewSrc || e.downloadHref : ""), g = r(
60
+ () => e.showDefaultActions && !!x.value && !f.value && S.value
61
+ ), C = r(
62
+ () => !!D.actions || e.showDefaultActions && (e.previewSrc && !f.value && !g.value || e.downloadHref)
63
+ ), F = r(
64
+ () => q({
57
65
  "nmorph-file-card": [
58
66
  e.surface,
59
67
  e.compact && "compact",
60
68
  e.loading && "loading",
61
69
  e.error && "error",
62
- !e.iconSurface && "icon-plain"
70
+ f.value && "media",
71
+ w.value && "media-audio",
72
+ y.value && "media-video",
73
+ !e.iconSurface && "icon-plain",
74
+ !C.value && "no-actions"
63
75
  ]
64
76
  })
65
- ), A = () => y("open"), H = () => y("download");
66
- return (o, f) => (r(), a("div", {
67
- class: E(D.value)
77
+ ), T = () => _("open"), R = () => _("download"), I = () => _("error");
78
+ return (o, B) => (a(), t("div", {
79
+ class: K(F.value)
68
80
  }, [
69
- _("div", oe, [
70
- e.loading ? (r(), v(n(p), {
81
+ v("div", pe, [
82
+ e.loading ? (a(), c(n(p), {
71
83
  key: 0,
72
84
  size: "medium"
73
85
  }, {
74
- default: c(() => [
75
- l(n(Y))
86
+ default: m(() => [
87
+ l(n(ce))
76
88
  ]),
77
89
  _: 1
78
- })) : (r(), v(n(p), {
90
+ })) : (a(), c(n(p), {
79
91
  key: 1,
80
92
  size: "medium"
81
93
  }, {
82
- default: c(() => [
83
- (r(), v(F(x.value)))
94
+ default: m(() => [
95
+ (a(), c(j($.value)))
84
96
  ]),
85
97
  _: 1
86
- }))
98
+ })),
99
+ g.value && !e.loading && !e.error ? (a(), t("a", {
100
+ key: 2,
101
+ href: x.value,
102
+ target: "_blank",
103
+ rel: "noopener noreferrer",
104
+ class: "nmorph-file-card__icon-action",
105
+ "aria-label": `Preview ${e.name}`,
106
+ onClick: T
107
+ }, [
108
+ l(n(p), { size: "small" }, {
109
+ default: m(() => [
110
+ l(n(ie))
111
+ ]),
112
+ _: 1
113
+ })
114
+ ], 8, ue)) : i("", !0)
87
115
  ]),
88
- _("div", re, [
89
- _("span", te, d(e.name), 1),
90
- e.error && e.errorText ? (r(), a("span", ae, d(e.errorText), 1)) : w.value ? (r(), a("span", ne, d(w.value), 1)) : s("", !0)
116
+ v("div", fe, [
117
+ v("div", ve, [
118
+ v("span", he, h(e.name), 1),
119
+ e.error && e.errorText ? (a(), t("span", _e, h(e.errorText), 1)) : b.value ? (a(), t("span", we, h(b.value), 1)) : i("", !0)
120
+ ]),
121
+ w.value ? (a(), c(re, {
122
+ key: 0,
123
+ class: "nmorph-file-card__audio-preview",
124
+ src: e.previewSrc,
125
+ name: e.name,
126
+ surface: "plain",
127
+ embedded: "",
128
+ compact: "",
129
+ "show-icon": !1,
130
+ "show-header": !1,
131
+ "show-default-actions": !1,
132
+ onError: I
133
+ }, null, 8, ["src", "name"])) : i("", !0),
134
+ y.value ? (a(), c(ae, {
135
+ key: 1,
136
+ class: "nmorph-file-card__video-preview",
137
+ src: e.previewSrc,
138
+ name: e.name,
139
+ height: z.value,
140
+ surface: "plain",
141
+ embedded: "",
142
+ compact: "",
143
+ controls: !1,
144
+ "show-meta": !1,
145
+ "show-default-actions": !1,
146
+ onError: I
147
+ }, null, 8, ["src", "name", "height"])) : i("", !0)
91
148
  ]),
92
- e.showExtensionBadge && u.value ? (r(), a("span", ie, d(u.value), 1)) : s("", !0),
93
- b.value ? (r(), a("div", le, [
94
- R(o.$slots, "actions", {}, () => [
95
- e.previewSrc ? (r(), a("a", {
149
+ e.showExtensionBadge && u.value ? (a(), t("span", ye, h(u.value), 1)) : i("", !0),
150
+ C.value ? (a(), t("div", ge, [
151
+ G(o.$slots, "actions", {}, () => [
152
+ e.previewSrc && !f.value && !g.value ? (a(), t("a", {
96
153
  key: 0,
97
154
  href: e.previewSrc,
98
155
  target: "_blank",
99
156
  rel: "noopener noreferrer",
100
157
  class: "nmorph-file-card__action-link",
101
158
  "aria-label": `Open ${e.name}`,
102
- onClick: A
159
+ onClick: T
103
160
  }, [
104
161
  l(n(p), { size: "small" }, {
105
- default: c(() => [
106
- l(n(Z))
162
+ default: m(() => [
163
+ l(n(me))
107
164
  ]),
108
165
  _: 1
109
166
  })
110
- ], 8, se)) : s("", !0),
111
- e.downloadHref ? (r(), a("a", {
167
+ ], 8, Be)) : i("", !0),
168
+ e.downloadHref ? (a(), t("a", {
112
169
  key: 1,
113
170
  href: e.downloadHref,
114
171
  download: e.name,
115
172
  class: "nmorph-file-card__action-link",
116
173
  "aria-label": `Download ${e.name}`,
117
- onClick: H
174
+ onClick: R
118
175
  }, [
119
176
  l(n(p), { size: "small" }, {
120
- default: c(() => [
121
- l(n(ee))
177
+ default: m(() => [
178
+ l(n(de))
122
179
  ]),
123
180
  _: 1
124
181
  })
125
- ], 8, me)) : s("", !0)
182
+ ], 8, Ne)) : i("", !0)
126
183
  ])
127
- ])) : s("", !0)
184
+ ])) : i("", !0)
128
185
  ], 2));
129
186
  }
130
187
  });
131
188
  export {
132
- Te as default
189
+ Oe as default
133
190
  };
@@ -1 +1 @@
1
- .nmorph-video-preview{position:relative;display:flex;width:var(--nmorph-video-preview-width, 280px);min-width:0;max-width:100%;height:var(--nmorph-video-preview-height, 158px);overflow:hidden;color:var(--nmorph-white-color);background:color-mix(in srgb,var(--nmorph-black-color) 72%,var(--nmorph-main-color));border-radius:var(--default-border-radius);box-shadow:var(--nmorph-shadow-inset)}.nmorph-video-preview .nmorph-video-preview__media,.nmorph-video-preview .nmorph-video-preview__state{width:100%;height:100%}.nmorph-video-preview .nmorph-video-preview__media{display:block;object-fit:cover}.nmorph-video-preview.nmorph-video-preview--contain .nmorph-video-preview__media{object-fit:contain}.nmorph-video-preview .nmorph-video-preview__state{display:flex;flex-direction:column;gap:var(--indentation-02);justify-content:center;align-items:center;padding:var(--indentation-03);text-align:center}.nmorph-video-preview .nmorph-video-preview__error{max-width:100%;overflow:hidden;color:var(--nmorph-error-text-color);font-size:var(--font-size-extra-small);white-space:nowrap;text-overflow:ellipsis}.nmorph-video-preview .nmorph-video-preview__meta{position:absolute;right:0;bottom:0;left:0;display:flex;gap:var(--indentation-02);justify-content:space-between;align-items:center;padding:18px var(--indentation-03) var(--indentation-02);background:linear-gradient(transparent,color-mix(in srgb,var(--nmorph-black-color) 66%,transparent));pointer-events:none}.nmorph-video-preview .nmorph-video-preview__name,.nmorph-video-preview .nmorph-video-preview__duration{min-width:0;overflow:hidden;font-size:var(--font-size-extra-small);line-height:var(--line-height-regular);white-space:nowrap;text-overflow:ellipsis}.nmorph-video-preview .nmorph-video-preview__name{flex:1 1 auto}.nmorph-video-preview .nmorph-video-preview__duration{flex:0 0 auto;font-variant-numeric:tabular-nums}.nmorph-video-preview .nmorph-video-preview__actions{position:absolute;top:var(--indentation-02);right:var(--indentation-02);display:flex;gap:var(--indentation-01);padding:2px;background:color-mix(in srgb,var(--nmorph-main-color) 86%,transparent);border-radius:var(--default-border-radius)}.nmorph-video-preview .nmorph-video-preview__action-link{display:inline-flex;justify-content:center;align-items:center;width:22px;height:22px;color:var(--nmorph-text-color);text-decoration:none;border-radius:var(--default-border-radius)}.nmorph-video-preview .nmorph-video-preview__action-link:hover{color:var(--nmorph-accent-color);background:color-mix(in srgb,var(--nmorph-accent-color) 10%,transparent)}.nmorph-video-preview .nmorph-video-preview__action-link .nmorph-icon{--color: currentColor}.nmorph-video-preview.nmorph-video-preview--compact{width:var(--nmorph-video-preview-width, 180px);height:var(--nmorph-video-preview-height, 102px)}.nmorph-video-preview.nmorph-video-preview--error{outline:1px solid var(--nmorph-error-color)}
1
+ .nmorph-video-preview{position:relative;display:flex;width:var(--nmorph-video-preview-width, 280px);min-width:0;max-width:100%;height:var(--nmorph-video-preview-height, 158px);overflow:hidden;color:var(--nmorph-white-color);background:color-mix(in srgb,var(--nmorph-black-color) 72%,var(--nmorph-main-color));border-radius:var(--default-border-radius);box-shadow:var(--nmorph-shadow-inset)}.nmorph-video-preview .nmorph-video-preview__media,.nmorph-video-preview .nmorph-video-preview__state{width:100%;height:100%}.nmorph-video-preview.nmorph-video-preview--soft .nmorph-video-preview__state,.nmorph-video-preview.nmorph-video-preview--plain .nmorph-video-preview__state{color:var(--nmorph-text-color)}.nmorph-video-preview .nmorph-video-preview__media{display:block;object-fit:cover}.nmorph-video-preview.nmorph-video-preview--contain .nmorph-video-preview__media{object-fit:contain}.nmorph-video-preview .nmorph-video-preview__state{display:flex;flex-direction:column;gap:var(--indentation-02);justify-content:center;align-items:center;padding:var(--indentation-03);text-align:center}.nmorph-video-preview .nmorph-video-preview__error{max-width:100%;overflow:hidden;color:var(--nmorph-error-text-color);font-size:var(--font-size-extra-small);white-space:nowrap;text-overflow:ellipsis}.nmorph-video-preview .nmorph-video-preview__meta{position:absolute;right:0;bottom:0;left:0;display:flex;gap:var(--indentation-02);justify-content:space-between;align-items:center;padding:18px var(--indentation-03) var(--indentation-02);background:linear-gradient(transparent,color-mix(in srgb,var(--nmorph-black-color) 66%,transparent));pointer-events:none}.nmorph-video-preview .nmorph-video-preview__play{position:absolute;top:50%;left:50%;z-index:1;display:inline-flex;justify-content:center;align-items:center;width:42px;height:42px;padding:0;color:var(--nmorph-text-color);background:color-mix(in srgb,var(--nmorph-main-color) 86%,transparent);border:0;border-radius:var(--border-radius-circular);box-shadow:var(--nmorph-shadow-outset);transform:translate(-50%,-50%);cursor:pointer}.nmorph-video-preview .nmorph-video-preview__play .nmorph-icon{--color: currentColor}.nmorph-video-preview .nmorph-video-preview__play:hover{color:var(--nmorph-accent-color)}.nmorph-video-preview.nmorph-video-preview--playing .nmorph-video-preview__play{opacity:.72}.nmorph-video-preview.nmorph-video-preview--embedded{width:var(--nmorph-video-preview-width, 100%);height:var(--nmorph-video-preview-height, 120px);box-shadow:none}.nmorph-video-preview.nmorph-video-preview--embedded .nmorph-video-preview__play,.nmorph-video-preview.nmorph-video-preview--soft .nmorph-video-preview__play,.nmorph-video-preview.nmorph-video-preview--plain .nmorph-video-preview__play{box-shadow:none}.nmorph-video-preview .nmorph-video-preview__name,.nmorph-video-preview .nmorph-video-preview__duration{min-width:0;overflow:hidden;font-size:var(--font-size-extra-small);line-height:var(--line-height-regular);white-space:nowrap;text-overflow:ellipsis}.nmorph-video-preview .nmorph-video-preview__name{flex:1 1 auto}.nmorph-video-preview .nmorph-video-preview__duration{flex:0 0 auto;font-variant-numeric:tabular-nums}.nmorph-video-preview .nmorph-video-preview__actions{position:absolute;top:var(--indentation-02);right:var(--indentation-02);display:flex;gap:var(--indentation-01);padding:2px;background:color-mix(in srgb,var(--nmorph-main-color) 86%,transparent);border-radius:var(--default-border-radius)}.nmorph-video-preview .nmorph-video-preview__action-link{display:inline-flex;justify-content:center;align-items:center;width:22px;height:22px;color:var(--nmorph-text-color);text-decoration:none;border-radius:var(--default-border-radius)}.nmorph-video-preview .nmorph-video-preview__action-link:hover{color:var(--nmorph-accent-color);background:color-mix(in srgb,var(--nmorph-accent-color) 10%,transparent)}.nmorph-video-preview .nmorph-video-preview__action-link .nmorph-icon{--color: currentColor}.nmorph-video-preview.nmorph-video-preview--compact{width:var(--nmorph-video-preview-width, 180px);height:var(--nmorph-video-preview-height, 102px)}.nmorph-video-preview.nmorph-video-preview--soft{background:color-mix(in srgb,var(--nmorph-accent-color) 6%,transparent);box-shadow:none}.nmorph-video-preview.nmorph-video-preview--plain{background:transparent;box-shadow:none}.nmorph-video-preview.nmorph-video-preview--error{outline:1px solid var(--nmorph-error-color)}
@@ -1,32 +1,34 @@
1
1
  import './NmorphVideoPreview.css';
2
- import { defineComponent as C, useSlots as b, computed as p, openBlock as o, createElementBlock as t, normalizeStyle as D, normalizeClass as H, createBlock as v, unref as a, withCtx as m, createVNode as l, toDisplayString as f, createCommentVNode as s, renderSlot as V, createElementVNode as $ } from "vue";
3
- import { useModifiers as x } from "../../../utils/create-modifiers.js";
4
- import { createCssSizeVariables as I } from "../../../utils/common.js";
2
+ import { defineComponent as V, useSlots as E, ref as y, computed as u, openBlock as o, createElementBlock as t, normalizeStyle as A, normalizeClass as T, createCommentVNode as n, createVNode as s, unref as r, withCtx as p, createBlock as m, toDisplayString as h, renderSlot as O, createElementVNode as R } from "vue";
3
+ import { useModifiers as L } from "../../../utils/create-modifiers.js";
4
+ import { createCssSizeVariables as j } from "../../../utils/common.js";
5
5
  import c from "../../basic/nmorph-icon/NmorphIcon.vue.js";
6
6
  /* empty css */
7
- import A from "../../../assets/icons/loading.svg.js";
8
- import E from "../../../assets/icons/video.svg.js";
9
- import M from "../../../assets/icons/open.svg.js";
10
- import P from "../../../assets/icons/download.svg.js";
11
- const T = ["src", "poster", "controls", "muted", "playsinline", "preload"], O = {
12
- key: 1,
7
+ import q from "../../../assets/icons/video.svg.js";
8
+ import F from "../../../assets/icons/pause.svg.js";
9
+ import G from "../../../assets/icons/play.svg.js";
10
+ import J from "../../../assets/icons/loading.svg.js";
11
+ import K from "../../../assets/icons/open.svg.js";
12
+ import Q from "../../../assets/icons/download.svg.js";
13
+ const U = ["src", "poster", "controls", "muted", "playsinline", "preload"], W = ["aria-label"], X = {
14
+ key: 2,
13
15
  class: "nmorph-video-preview__state"
14
- }, L = {
16
+ }, Y = {
15
17
  key: 2,
16
18
  class: "nmorph-video-preview__error"
17
- }, j = {
18
- key: 2,
19
+ }, Z = {
20
+ key: 3,
19
21
  class: "nmorph-video-preview__meta"
20
- }, q = {
22
+ }, ee = {
21
23
  key: 0,
22
24
  class: "nmorph-video-preview__name"
23
- }, F = {
25
+ }, oe = {
24
26
  key: 1,
25
27
  class: "nmorph-video-preview__duration"
26
- }, G = {
27
- key: 3,
28
+ }, ae = {
29
+ key: 4,
28
30
  class: "nmorph-video-preview__actions"
29
- }, J = ["href", "aria-label"], K = ["href", "download", "aria-label"], re = /* @__PURE__ */ C({
31
+ }, re = ["href", "aria-label"], te = ["href", "download", "aria-label"], he = /* @__PURE__ */ V({
30
32
  __name: "NmorphVideoPreview",
31
33
  props: {
32
34
  src: {},
@@ -35,6 +37,9 @@ const T = ["src", "poster", "controls", "muted", "playsinline", "preload"], O =
35
37
  width: { default: void 0 },
36
38
  height: { default: void 0 },
37
39
  durationMs: { default: void 0 },
40
+ surface: { default: "card" },
41
+ embedded: { type: Boolean, default: !1 },
42
+ showMeta: { type: Boolean, default: !0 },
38
43
  compact: { type: Boolean, default: !1 },
39
44
  controls: { type: Boolean, default: !0 },
40
45
  muted: { type: Boolean, default: !1 },
@@ -48,29 +53,61 @@ const T = ["src", "poster", "controls", "muted", "playsinline", "preload"], O =
48
53
  showDefaultActions: { type: Boolean, default: !0 }
49
54
  },
50
55
  emits: ["play", "pause", "open", "download", "error"],
51
- setup(_, { emit: h }) {
52
- const e = _, i = h, w = b(), y = (d) => {
53
- if (!d || d < 0) return "";
54
- const r = Math.round(d / 1e3), n = Math.floor(r / 60), z = r % 60;
55
- return `${n}:${z.toString().padStart(2, "0")}`;
56
- }, u = p(() => y(e.durationMs)), k = p(
57
- () => !!w.actions || e.showDefaultActions && (e.src || e.downloadHref)
58
- ), g = p(
59
- () => x({
60
- "nmorph-video-preview": [e.compact && "compact", e.fit, e.loading && "loading", e.error && "error"]
56
+ setup(w, { expose: k, emit: g }) {
57
+ const e = w, i = g, b = E(), d = y(null), l = y(!1), B = (a) => {
58
+ if (!a || a < 0) return "";
59
+ const v = Math.round(a / 1e3), I = Math.floor(v / 60), M = v % 60;
60
+ return `${I}:${M.toString().padStart(2, "0")}`;
61
+ }, f = u(() => B(e.durationMs)), _ = u(
62
+ () => !!b.actions || e.showDefaultActions && (e.src || e.downloadHref)
63
+ ), H = u(
64
+ () => L({
65
+ "nmorph-video-preview": [
66
+ e.surface,
67
+ e.embedded && "embedded",
68
+ !e.showMeta && "no-meta",
69
+ e.compact && "compact",
70
+ e.fit,
71
+ e.loading && "loading",
72
+ e.error && "error",
73
+ l.value && "playing",
74
+ !_.value && "no-actions"
75
+ ]
61
76
  })
62
- ), B = p(
63
- () => I({
77
+ ), N = u(
78
+ () => j({
64
79
  "--nmorph-video-preview-width": e.width,
65
80
  "--nmorph-video-preview-height": e.height
66
81
  })
67
- ), N = () => i("open"), S = () => i("download");
68
- return (d, r) => (o(), t("div", {
69
- class: H(g.value),
70
- style: D(B.value)
82
+ ), z = () => i("open"), C = () => i("download"), P = async () => {
83
+ if (!(!d.value || e.loading || e.error)) {
84
+ if (l.value) {
85
+ d.value.pause();
86
+ return;
87
+ }
88
+ try {
89
+ await d.value.play();
90
+ } catch {
91
+ l.value = !1;
92
+ }
93
+ }
94
+ }, S = (a) => {
95
+ l.value = !0, i("play", a);
96
+ }, $ = (a) => {
97
+ l.value = !1, i("pause", a);
98
+ }, x = () => {
99
+ l.value = !1;
100
+ }, D = (a) => {
101
+ l.value = !1, i("error", a);
102
+ };
103
+ return k({ videoRef: d }), (a, v) => (o(), t("div", {
104
+ class: T(H.value),
105
+ style: A(N.value)
71
106
  }, [
72
107
  !e.loading && !e.error ? (o(), t("video", {
73
108
  key: 0,
109
+ ref_key: "videoRef",
110
+ ref: d,
74
111
  class: "nmorph-video-preview__media",
75
112
  src: e.src,
76
113
  poster: e.poster || void 0,
@@ -78,70 +115,85 @@ const T = ["src", "poster", "controls", "muted", "playsinline", "preload"], O =
78
115
  muted: e.muted,
79
116
  playsinline: e.playsinline,
80
117
  preload: e.preload,
81
- onPlay: r[0] || (r[0] = (n) => i("play", n)),
82
- onPause: r[1] || (r[1] = (n) => i("pause", n)),
83
- onError: r[2] || (r[2] = (n) => i("error", n))
84
- }, null, 40, T)) : (o(), t("div", O, [
85
- e.loading ? (o(), v(a(c), {
118
+ onPlay: S,
119
+ onPause: $,
120
+ onEnded: x,
121
+ onError: D
122
+ }, null, 40, U)) : n("", !0),
123
+ !e.loading && !e.error ? (o(), t("button", {
124
+ key: 1,
125
+ class: "nmorph-video-preview__play",
126
+ type: "button",
127
+ "aria-label": l.value ? `Pause ${e.name || "video"}` : `Play ${e.name || "video"}`,
128
+ onClick: P
129
+ }, [
130
+ s(r(c), { size: "medium" }, {
131
+ default: p(() => [
132
+ l.value ? (o(), m(r(F), { key: 0 })) : (o(), m(r(G), { key: 1 }))
133
+ ]),
134
+ _: 1
135
+ })
136
+ ], 8, W)) : (o(), t("div", X, [
137
+ e.loading ? (o(), m(r(c), {
86
138
  key: 0,
87
139
  size: "large"
88
140
  }, {
89
- default: m(() => [
90
- l(a(A))
141
+ default: p(() => [
142
+ s(r(J))
91
143
  ]),
92
144
  _: 1
93
- })) : (o(), v(a(c), {
145
+ })) : (o(), m(r(c), {
94
146
  key: 1,
95
147
  size: "large"
96
148
  }, {
97
- default: m(() => [
98
- l(a(E))
149
+ default: p(() => [
150
+ s(r(q))
99
151
  ]),
100
152
  _: 1
101
153
  })),
102
- e.error && e.errorText ? (o(), t("span", L, f(e.errorText), 1)) : s("", !0)
154
+ e.error && e.errorText ? (o(), t("span", Y, h(e.errorText), 1)) : n("", !0)
103
155
  ])),
104
- e.name || u.value ? (o(), t("div", j, [
105
- e.name ? (o(), t("span", q, f(e.name), 1)) : s("", !0),
106
- u.value ? (o(), t("span", F, f(u.value), 1)) : s("", !0)
107
- ])) : s("", !0),
108
- k.value ? (o(), t("div", G, [
109
- V(d.$slots, "actions", {}, () => [
110
- $("a", {
156
+ e.showMeta && (e.name || f.value) ? (o(), t("div", Z, [
157
+ e.name ? (o(), t("span", ee, h(e.name), 1)) : n("", !0),
158
+ f.value ? (o(), t("span", oe, h(f.value), 1)) : n("", !0)
159
+ ])) : n("", !0),
160
+ _.value ? (o(), t("div", ae, [
161
+ O(a.$slots, "actions", {}, () => [
162
+ R("a", {
111
163
  href: e.src,
112
164
  target: "_blank",
113
165
  rel: "noopener noreferrer",
114
166
  class: "nmorph-video-preview__action-link",
115
167
  "aria-label": `Open ${e.name || "video"}`,
116
- onClick: N
168
+ onClick: z
117
169
  }, [
118
- l(a(c), { size: "small" }, {
119
- default: m(() => [
120
- l(a(M))
170
+ s(r(c), { size: "small" }, {
171
+ default: p(() => [
172
+ s(r(K))
121
173
  ]),
122
174
  _: 1
123
175
  })
124
- ], 8, J),
176
+ ], 8, re),
125
177
  e.downloadHref ? (o(), t("a", {
126
178
  key: 0,
127
179
  href: e.downloadHref,
128
180
  download: e.name,
129
181
  class: "nmorph-video-preview__action-link",
130
182
  "aria-label": `Download ${e.name || "video"}`,
131
- onClick: S
183
+ onClick: C
132
184
  }, [
133
- l(a(c), { size: "small" }, {
134
- default: m(() => [
135
- l(a(P))
185
+ s(r(c), { size: "small" }, {
186
+ default: p(() => [
187
+ s(r(Q))
136
188
  ]),
137
189
  _: 1
138
190
  })
139
- ], 8, K)) : s("", !0)
191
+ ], 8, te)) : n("", !0)
140
192
  ])
141
- ])) : s("", !0)
193
+ ])) : n("", !0)
142
194
  ], 6));
143
195
  }
144
196
  });
145
197
  export {
146
- re as default
198
+ he as default
147
199
  };
@@ -5,12 +5,12 @@ import { useFocusableInput as W } from "../../../hooks/use-focusable-input.js";
5
5
  import { useFormItemInput as X, useFormItemModel as Y } from "../nmorph-form/use-form-item-input.js";
6
6
  import { NmorphComponentHeight as Z } from "../../../types/common.types.js";
7
7
  import ee from "../../../assets/icons/eye-blocked.svg.js";
8
- import te from "../../../assets/icons/eye.svg.js";
9
- import oe from "../../basic/nmorph-button/NmorphButton.vue.js";
8
+ import te from "../../basic/nmorph-button/NmorphButton.vue.js";
10
9
  /* empty css */
11
- import ne from "../../basic/nmorph-icon/NmorphIcon.vue.js";
10
+ import oe from "../../basic/nmorph-icon/NmorphIcon.vue.js";
12
11
  /* empty css */
13
- import le from "../../../assets/icons/error.svg.js";
12
+ import ne from "../../../assets/icons/error.svg.js";
13
+ import le from "../../../assets/icons/eye.svg.js";
14
14
  const re = { class: "nmorph-text-input__input-side" }, ae = {
15
15
  key: 0,
16
16
  class: "nmorph-text-input__prepend-icon"
@@ -59,7 +59,7 @@ const re = { class: "nmorph-text-input__input-side" }, ae = {
59
59
  onBlur: () => l("blur")
60
60
  });
61
61
  x({ inputDOMRef: u, focus: E, blur: $, select: D });
62
- const K = a(() => e.clearable ? le : s.value ? ee : te), R = a(() => e.indentation || (p["prepend-icon"] ? "28px" : "8px")), S = a(() => ({ "--nmorph-text-input-indentation": R.value }));
62
+ const K = a(() => e.clearable ? ne : s.value ? ee : le), R = a(() => e.indentation || (p["prepend-icon"] ? "28px" : "8px")), S = a(() => ({ "--nmorph-text-input-indentation": R.value }));
63
63
  return (r, t) => (i(), f("div", {
64
64
  class: T(N.value),
65
65
  style: O(S.value)
@@ -89,7 +89,7 @@ const re = { class: "nmorph-text-input__input-side" }, ae = {
89
89
  onKeydown: t[2] || (t[2] = (n) => l("keydown", n)),
90
90
  onKeyup: t[3] || (t[3] = G((n) => l("on-enter"), ["enter"]))
91
91
  }), null, 16, se),
92
- e.typePassword || e.clearable ? (i(), b(o(oe), {
92
+ e.typePassword || e.clearable ? (i(), b(o(te), {
93
93
  key: 1,
94
94
  disabled: e.disabled,
95
95
  class: "nmorph-text-input__password-btn",
@@ -101,7 +101,7 @@ const re = { class: "nmorph-text-input__input-side" }, ae = {
101
101
  onClick: P
102
102
  }, {
103
103
  default: v(() => [
104
- L(o(ne), null, {
104
+ L(o(oe), null, {
105
105
  default: v(() => [
106
106
  (i(), b(Q(K.value)))
107
107
  ]),