@nmorph/nmorph-ui-kit 2.2.47 → 2.2.49

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 +1 @@
1
- .nmorph-audio-preview{display:flex;gap:var(--indentation-02);align-items:center;box-sizing:border-box;width:var(--nmorph-audio-preview-width, 360px);min-width:0;max-width:100%;min-height:64px;padding:var(--indentation-03);color:var(--nmorph-text-color);background:var(--nmorph-main-color);border-radius:var(--default-border-radius);box-shadow:var(--nmorph-shadow-inset)}.nmorph-audio-preview audio{display:none}.nmorph-audio-preview .nmorph-audio-preview__icon{display:flex;flex:0 0 auto;justify-content:center;align-items:center;width:36px;height:36px;color:var(--nmorph-accent-color);background:color-mix(in srgb,var(--nmorph-accent-color) 12%,transparent);border-radius:var(--default-border-radius);--color: currentColor}.nmorph-audio-preview .nmorph-audio-preview__play{flex:0 0 auto}.nmorph-audio-preview .nmorph-audio-preview__body{display:flex;flex:1 1 0;flex-direction:column;gap:var(--indentation-02);min-width:0}.nmorph-audio-preview .nmorph-audio-preview__header{display:flex;gap:var(--indentation-02);justify-content:space-between;align-items:center;min-width:0}.nmorph-audio-preview .nmorph-audio-preview__name,.nmorph-audio-preview .nmorph-audio-preview__time,.nmorph-audio-preview .nmorph-audio-preview__error{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-audio-preview .nmorph-audio-preview__name{flex:1 1 auto;font-weight:600}.nmorph-audio-preview .nmorph-audio-preview__time{flex:0 0 auto;color:var(--nmorph-semi-contrast-text-color);font-variant-numeric:tabular-nums}.nmorph-audio-preview .nmorph-audio-preview__error{flex:0 1 auto;color:var(--nmorph-error-text-color)}.nmorph-audio-preview .nmorph-audio-preview__range{width:100%;min-width:0;height:6px;padding:0;background:linear-gradient(to right,var(--nmorph-accent-color) var(--nmorph-audio-preview-progress, 0%),color-mix(in srgb,var(--nmorph-text-color) 16%,transparent) 0);border-radius:var(--border-radius-100);outline:0;cursor:pointer;appearance:none}.nmorph-audio-preview .nmorph-audio-preview__range:disabled{cursor:default;opacity:.6}.nmorph-audio-preview .nmorph-audio-preview__range::-webkit-slider-thumb{width:14px;height:14px;background:var(--nmorph-accent-color);border:2px solid var(--nmorph-main-color);border-radius:var(--border-radius-circular);box-shadow:var(--nmorph-shadow-outset);appearance:none}.nmorph-audio-preview .nmorph-audio-preview__range::-moz-range-thumb{width:14px;height:14px;background:var(--nmorph-accent-color);border:2px solid var(--nmorph-main-color);border-radius:var(--border-radius-circular);box-shadow:var(--nmorph-shadow-outset)}.nmorph-audio-preview .nmorph-audio-preview__actions{display:flex;flex:0 0 auto;gap:var(--indentation-01);align-items:center}.nmorph-audio-preview .nmorph-audio-preview__action-link{display:inline-flex;justify-content:center;align-items:center;width:22px;height:22px;color:inherit;text-decoration:none;border-radius:var(--default-border-radius)}.nmorph-audio-preview .nmorph-audio-preview__action-link:hover{color:var(--nmorph-accent-color);background:color-mix(in srgb,var(--nmorph-accent-color) 10%,transparent)}.nmorph-audio-preview .nmorph-audio-preview__action-link .nmorph-icon{--color: currentColor}.nmorph-audio-preview.nmorph-audio-preview--compact{min-height:52px;padding:var(--indentation-02)}.nmorph-audio-preview.nmorph-audio-preview--compact .nmorph-audio-preview__icon{width:30px;height:30px}.nmorph-audio-preview.nmorph-audio-preview--error{outline:1px solid var(--nmorph-error-color)}
1
+ .nmorph-audio-preview{display:flex;gap:var(--indentation-02);align-items:center;box-sizing:border-box;width:var(--nmorph-audio-preview-width, 360px);min-width:0;max-width:100%;min-height:64px;padding:var(--indentation-03);color:var(--nmorph-text-color);background:var(--nmorph-main-color);border-radius:var(--default-border-radius);box-shadow:var(--nmorph-shadow-inset)}.nmorph-audio-preview audio{display:none}.nmorph-audio-preview .nmorph-audio-preview__icon{position:relative;display:flex;flex:0 0 auto;justify-content:center;align-items:center;width:36px;height:36px;padding:0;color:var(--nmorph-accent-color);background:color-mix(in srgb,var(--nmorph-accent-color) 12%,transparent);border:0;border-radius:var(--default-border-radius);cursor:pointer;--color: currentColor}.nmorph-audio-preview .nmorph-audio-preview__icon:disabled{cursor:default}.nmorph-audio-preview .nmorph-audio-preview__play-button{display:inline-flex;flex:0 0 auto;justify-content:center;align-items:center;width:20px;height:20px;padding:0;color:var(--nmorph-accent-color);background:color-mix(in srgb,var(--nmorph-accent-color) 10%,transparent);border:0;border-radius:var(--border-radius-circular);cursor:pointer}.nmorph-audio-preview .nmorph-audio-preview__play-button:hover{color:var(--nmorph-focus-text-color);background:var(--nmorph-accent-color)}.nmorph-audio-preview .nmorph-audio-preview__play-button .nmorph-icon{--color: currentColor}.nmorph-audio-preview .nmorph-audio-preview__play-indicator{position:absolute;right:-4px;bottom:-4px;display:inline-flex;justify-content:center;align-items:center;width:18px;height:18px;color:var(--nmorph-accent-color);background:var(--nmorph-main-color);border-radius:var(--border-radius-circular);box-shadow:var(--nmorph-shadow-outset)}.nmorph-audio-preview .nmorph-audio-preview__play-indicator .nmorph-icon{--color: currentColor}.nmorph-audio-preview .nmorph-audio-preview__body{display:flex;flex:1 1 0;flex-direction:column;gap:var(--indentation-02);box-sizing:border-box;min-width:0}.nmorph-audio-preview .nmorph-audio-preview__header{display:flex;gap:var(--indentation-02);justify-content:space-between;align-items:center;min-width:0}.nmorph-audio-preview .nmorph-audio-preview__control{display:flex;gap:var(--indentation-02);align-items:center;width:100%;min-width:0}.nmorph-audio-preview .nmorph-audio-preview__name,.nmorph-audio-preview .nmorph-audio-preview__time,.nmorph-audio-preview .nmorph-audio-preview__error{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-audio-preview .nmorph-audio-preview__name{flex:1 1 auto;font-weight:600}.nmorph-audio-preview .nmorph-audio-preview__time{flex:0 0 auto;color:var(--nmorph-semi-contrast-text-color);font-variant-numeric:tabular-nums}.nmorph-audio-preview .nmorph-audio-preview__error{flex:0 1 auto;color:var(--nmorph-error-text-color)}.nmorph-audio-preview .nmorph-audio-preview__range{flex:1 1 0;width:100%;min-width:0;height:6px;padding:0;background:linear-gradient(to right,var(--nmorph-accent-color) var(--nmorph-audio-preview-progress, 0%),color-mix(in srgb,var(--nmorph-text-color) 16%,transparent) 0);border-radius:var(--border-radius-100);outline:0;cursor:pointer;appearance:none}.nmorph-audio-preview .nmorph-audio-preview__range:disabled{cursor:default;opacity:.6}.nmorph-audio-preview .nmorph-audio-preview__range::-webkit-slider-thumb{width:14px;height:14px;background:var(--nmorph-accent-color);border:2px solid var(--nmorph-main-color);border-radius:var(--border-radius-circular);box-shadow:var(--nmorph-shadow-outset);appearance:none}.nmorph-audio-preview .nmorph-audio-preview__range::-moz-range-thumb{width:14px;height:14px;background:var(--nmorph-accent-color);border:2px solid var(--nmorph-main-color);border-radius:var(--border-radius-circular);box-shadow:var(--nmorph-shadow-outset)}.nmorph-audio-preview .nmorph-audio-preview__actions{display:flex;flex:0 0 auto;gap:var(--indentation-01);align-items:center}.nmorph-audio-preview .nmorph-audio-preview__action-link{display:inline-flex;justify-content:center;align-items:center;width:22px;height:22px;color:inherit;text-decoration:none;border-radius:var(--default-border-radius)}.nmorph-audio-preview .nmorph-audio-preview__action-link:hover{color:var(--nmorph-accent-color);background:color-mix(in srgb,var(--nmorph-accent-color) 10%,transparent)}.nmorph-audio-preview .nmorph-audio-preview__action-link .nmorph-icon{--color: currentColor}.nmorph-audio-preview.nmorph-audio-preview--compact{min-height:52px;padding:var(--indentation-02)}.nmorph-audio-preview.nmorph-audio-preview--compact .nmorph-audio-preview__icon{width:30px;height:30px}.nmorph-audio-preview.nmorph-audio-preview--no-actions .nmorph-audio-preview__body{padding-inline-end:var(--indentation-02)}.nmorph-audio-preview.nmorph-audio-preview--embedded{width:var(--nmorph-audio-preview-width, 100%);min-height:auto;padding:0;background:transparent;border-radius:0;box-shadow:none}.nmorph-audio-preview.nmorph-audio-preview--embedded .nmorph-audio-preview__body{gap:0;padding-inline-end:0}.nmorph-audio-preview.nmorph-audio-preview--embedded .nmorph-audio-preview__range{height:5px}.nmorph-audio-preview.nmorph-audio-preview--embedded .nmorph-audio-preview__range::-webkit-slider-thumb{width:11px;height:11px;box-shadow:none}.nmorph-audio-preview.nmorph-audio-preview--embedded .nmorph-audio-preview__range::-moz-range-thumb{width:11px;height:11px;box-shadow:none}.nmorph-audio-preview.nmorph-audio-preview--no-header .nmorph-audio-preview__time{flex:0 0 auto}.nmorph-audio-preview.nmorph-audio-preview--soft{background:color-mix(in srgb,var(--nmorph-accent-color) 6%,transparent);box-shadow:none}.nmorph-audio-preview.nmorph-audio-preview--plain{background:transparent;box-shadow:none}.nmorph-audio-preview.nmorph-audio-preview--error{outline:1px solid var(--nmorph-error-color)}
@@ -1,33 +1,44 @@
1
1
  import './NmorphAudioPreview.css';
2
- import { defineComponent as q, useSlots as G, ref as _, watch as J, computed as l, openBlock as t, createElementBlock as p, normalizeStyle as N, normalizeClass as K, createElementVNode as i, createBlock as h, unref as r, withCtx as m, createVNode as s, toDisplayString as y, withDirectives as Q, vModelText as W, renderSlot as X, createCommentVNode as H } from "vue";
3
- import { useModifiers as Y } from "../../../utils/create-modifiers.js";
4
- import { createCssSizeVariables as Z } from "../../../utils/common.js";
5
- import w from "../../basic/nmorph-icon/NmorphIcon.vue.js";
2
+ import { defineComponent as J, useSlots as K, ref as b, watch as Q, computed as s, openBlock as a, createElementBlock as n, normalizeStyle as T, normalizeClass as W, createElementVNode as u, createBlock as c, unref as r, withCtx as p, createVNode as i, createCommentVNode as m, toDisplayString as v, withDirectives as X, vModelText as Y, renderSlot as Z } from "vue";
3
+ import { useModifiers as ee } from "../../../utils/create-modifiers.js";
4
+ import { createCssSizeVariables as oe } from "../../../utils/common.js";
5
+ import f from "../../basic/nmorph-icon/NmorphIcon.vue.js";
6
6
  /* empty css */
7
- import ee from "../../../assets/icons/audio.svg.js";
8
- import oe from "../../basic/nmorph-button/NmorphButton.vue.js";
9
- /* empty css */
10
- import ae from "../../../assets/icons/pause.svg.js";
11
- import re from "../../../assets/icons/play.svg.js";
12
- import te from "../../../assets/icons/open.svg.js";
13
- import ne from "../../../assets/icons/download.svg.js";
7
+ import ae from "../../../assets/icons/audio.svg.js";
8
+ import P from "../../../assets/icons/pause.svg.js";
9
+ import z from "../../../assets/icons/play.svg.js";
10
+ import re from "../../../assets/icons/open.svg.js";
11
+ import te from "../../../assets/icons/download.svg.js";
14
12
  import le from "../../../assets/icons/loading.svg.js";
15
- const ie = ["src", "preload"], se = { class: "nmorph-audio-preview__icon" }, de = { class: "nmorph-audio-preview__body" }, ue = { class: "nmorph-audio-preview__header" }, ce = { class: "nmorph-audio-preview__name" }, pe = {
13
+ const ne = ["src", "preload"], se = ["disabled", "aria-label"], ie = {
14
+ key: 2,
15
+ class: "nmorph-audio-preview__play-indicator"
16
+ }, de = ["aria-label"], ue = { class: "nmorph-audio-preview__body" }, ce = {
17
+ key: 0,
18
+ class: "nmorph-audio-preview__header"
19
+ }, pe = { class: "nmorph-audio-preview__name" }, me = {
16
20
  key: 0,
17
21
  class: "nmorph-audio-preview__error"
18
- }, me = {
22
+ }, ve = {
19
23
  key: 1,
20
24
  class: "nmorph-audio-preview__time"
21
- }, ve = ["disabled", "aria-label"], fe = {
25
+ }, fe = { class: "nmorph-audio-preview__control" }, _e = ["disabled", "aria-label"], he = {
22
26
  key: 0,
27
+ class: "nmorph-audio-preview__time"
28
+ }, ye = {
29
+ key: 2,
23
30
  class: "nmorph-audio-preview__actions"
24
- }, _e = ["href", "aria-label"], he = ["href", "download", "aria-label"], Me = /* @__PURE__ */ q({
31
+ }, we = ["href", "aria-label"], be = ["href", "download", "aria-label"], Ie = /* @__PURE__ */ J({
25
32
  __name: "NmorphAudioPreview",
26
33
  props: {
27
34
  src: {},
28
35
  name: { default: "" },
29
36
  durationMs: { default: void 0 },
30
37
  width: { default: void 0 },
38
+ surface: { default: "card" },
39
+ embedded: { type: Boolean, default: !1 },
40
+ showIcon: { type: Boolean, default: !0 },
41
+ showHeader: { type: Boolean, default: !0 },
31
42
  compact: { type: Boolean, default: !1 },
32
43
  preload: { default: "metadata" },
33
44
  downloadHref: { default: "" },
@@ -37,171 +48,195 @@ const ie = ["src", "preload"], se = { class: "nmorph-audio-preview__icon" }, de
37
48
  showDefaultActions: { type: Boolean, default: !0 }
38
49
  },
39
50
  emits: ["play", "pause", "open", "download", "error"],
40
- setup(S, { expose: T, emit: $ }) {
41
- const e = S, u = $, x = G(), a = _(null), n = _(!1), v = _(0), f = _(e.durationMs ? e.durationMs / 1e3 : 0);
42
- J(
51
+ setup(C, { expose: I, emit: x }) {
52
+ const e = C, _ = x, M = K(), t = b(null), l = b(!1), y = b(0), w = b(e.durationMs ? e.durationMs / 1e3 : 0);
53
+ Q(
43
54
  () => e.durationMs,
44
55
  (o) => {
45
- f.value = o ? o / 1e3 : f.value;
56
+ w.value = o ? o / 1e3 : w.value;
46
57
  }
47
58
  );
48
- const d = l(() => f.value || 0), g = l({
49
- get: () => d.value > 0 ? v.value / d.value * 100 : 0,
59
+ const d = s(() => w.value || 0), k = s({
60
+ get: () => d.value > 0 ? y.value / d.value * 100 : 0,
50
61
  set: (o) => {
51
- !a.value || d.value <= 0 || (a.value.currentTime = o / 100 * d.value, v.value = a.value.currentTime);
62
+ !t.value || d.value <= 0 || (t.value.currentTime = o / 100 * d.value, y.value = t.value.currentTime);
52
63
  }
53
- }), B = l(() => ({ "--nmorph-audio-preview-progress": `${g.value}%` })), C = l(
54
- () => !!x.actions || e.showDefaultActions && (e.src || e.downloadHref)
55
- ), M = l(
56
- () => Y({
64
+ }), A = s(() => ({ "--nmorph-audio-preview-progress": `${k.value}%` })), H = s(
65
+ () => !!M.actions || e.showDefaultActions && (e.src || e.downloadHref)
66
+ ), D = s(
67
+ () => ee({
57
68
  "nmorph-audio-preview": [
69
+ e.surface,
70
+ e.embedded && "embedded",
71
+ !e.showIcon && "no-icon",
72
+ !e.showHeader && "no-header",
58
73
  e.compact && "compact",
59
74
  e.loading && "loading",
60
75
  e.error && "error",
61
- n.value && "playing"
76
+ l.value && "playing",
77
+ !H.value && "no-actions"
62
78
  ]
63
79
  })
64
- ), z = l(
65
- () => Z({
80
+ ), V = s(
81
+ () => oe({
66
82
  "--nmorph-audio-preview-width": e.width
67
83
  })
68
- ), k = (o) => {
84
+ ), N = (o) => {
69
85
  if (!Number.isFinite(o) || o < 0) return "0:00";
70
- const c = Math.floor(o), b = Math.floor(c / 60), j = c % 60;
71
- return `${b}:${j.toString().padStart(2, "0")}`;
72
- }, A = l(() => k(v.value)), D = l(() => k(d.value)), I = async () => {
73
- if (!(!a.value || e.loading || e.error)) {
74
- if (n.value) {
75
- a.value.pause();
86
+ const h = Math.floor(o), g = Math.floor(h / 60), G = h % 60;
87
+ return `${g}:${G.toString().padStart(2, "0")}`;
88
+ }, $ = s(() => N(y.value)), B = s(() => N(d.value)), S = async () => {
89
+ if (!(!t.value || e.loading || e.error)) {
90
+ if (l.value) {
91
+ t.value.pause();
76
92
  return;
77
93
  }
78
94
  try {
79
- await a.value.play();
95
+ await t.value.play();
80
96
  } catch {
81
- n.value = !1;
97
+ l.value = !1;
82
98
  }
83
99
  }
84
- }, P = () => {
85
- !a.value || Number.isNaN(a.value.duration) || (f.value = a.value.duration);
86
- }, V = () => {
87
- v.value = a.value?.currentTime || 0;
88
- }, E = (o) => {
89
- n.value = !0, u("play", o);
90
- }, L = (o) => {
91
- n.value = !1, u("pause", o);
92
- }, O = () => {
93
- n.value = !1;
100
+ }, E = () => {
101
+ !t.value || Number.isNaN(t.value.duration) || (w.value = t.value.duration);
102
+ }, L = () => {
103
+ y.value = t.value?.currentTime || 0;
104
+ }, O = (o) => {
105
+ l.value = !0, _("play", o);
94
106
  }, R = (o) => {
95
- n.value = !1, u("error", o);
96
- }, U = () => u("open"), F = () => u("download");
97
- return T({ audioRef: a }), (o, c) => (t(), p("div", {
98
- class: K(M.value),
99
- style: N(z.value)
107
+ l.value = !1, _("pause", o);
108
+ }, U = () => {
109
+ l.value = !1;
110
+ }, F = (o) => {
111
+ l.value = !1, _("error", o);
112
+ }, j = () => _("open"), q = () => _("download");
113
+ return I({ audioRef: t }), (o, h) => (a(), n("div", {
114
+ class: W(D.value),
115
+ style: T(V.value)
100
116
  }, [
101
- i("audio", {
117
+ u("audio", {
102
118
  ref_key: "audioRef",
103
- ref: a,
119
+ ref: t,
104
120
  src: e.src,
105
121
  preload: e.preload,
106
- onLoadedmetadata: P,
107
- onTimeupdate: V,
108
- onPlay: E,
109
- onPause: L,
110
- onEnded: O,
111
- onError: R
112
- }, null, 40, ie),
113
- i("div", se, [
114
- e.loading ? (t(), h(r(w), {
122
+ onLoadedmetadata: E,
123
+ onTimeupdate: L,
124
+ onPlay: O,
125
+ onPause: R,
126
+ onEnded: U,
127
+ onError: F
128
+ }, null, 40, ne),
129
+ e.showIcon ? (a(), n("button", {
130
+ key: 0,
131
+ class: "nmorph-audio-preview__icon",
132
+ type: "button",
133
+ disabled: e.loading || e.error,
134
+ "aria-label": l.value ? `Pause ${e.name || "audio"}` : `Play ${e.name || "audio"}`,
135
+ onClick: S
136
+ }, [
137
+ e.loading ? (a(), c(r(f), {
115
138
  key: 0,
116
139
  size: "medium"
117
140
  }, {
118
- default: m(() => [
119
- s(r(le))
141
+ default: p(() => [
142
+ i(r(le))
120
143
  ]),
121
144
  _: 1
122
- })) : (t(), h(r(w), {
145
+ })) : (a(), c(r(f), {
123
146
  key: 1,
124
147
  size: "medium"
125
148
  }, {
126
- default: m(() => [
127
- s(r(ee))
149
+ default: p(() => [
150
+ i(r(ae))
128
151
  ]),
129
152
  _: 1
130
- }))
131
- ]),
132
- s(r(oe), {
133
- class: "nmorph-audio-preview__play",
134
- height: "thin",
135
- "style-type": "transparent",
136
- disabled: e.loading || e.error,
137
- onClick: I
138
- }, {
139
- "icon-only": m(() => [
140
- n.value ? (t(), h(r(ae), { key: 0 })) : (t(), h(r(re), { key: 1 }))
141
- ]),
142
- _: 1
143
- }, 8, ["disabled"]),
144
- i("div", de, [
145
- i("div", ue, [
146
- i("span", ce, y(e.name || "Audio"), 1),
147
- e.error && e.errorText ? (t(), p("span", pe, y(e.errorText), 1)) : (t(), p("span", me, y(A.value) + " / " + y(D.value), 1))
148
- ]),
149
- Q(i("input", {
150
- "onUpdate:modelValue": c[0] || (c[0] = (b) => g.value = b),
151
- class: "nmorph-audio-preview__range",
152
- type: "range",
153
- min: "0",
154
- max: "100",
155
- step: "0.1",
156
- style: N(B.value),
157
- disabled: e.loading || e.error || d.value <= 0,
158
- "aria-label": `Audio progress ${e.name || ""}`
159
- }, null, 12, ve), [
160
- [
161
- W,
162
- g.value,
163
- void 0,
164
- { number: !0 }
165
- ]
153
+ })),
154
+ !e.loading && !e.error ? (a(), n("span", ie, [
155
+ i(r(f), { size: "small" }, {
156
+ default: p(() => [
157
+ l.value ? (a(), c(r(P), { key: 0 })) : (a(), c(r(z), { key: 1 }))
158
+ ]),
159
+ _: 1
160
+ })
161
+ ])) : m("", !0)
162
+ ], 8, se)) : !e.loading && !e.error ? (a(), n("button", {
163
+ key: 1,
164
+ class: "nmorph-audio-preview__play-button",
165
+ type: "button",
166
+ "aria-label": l.value ? `Pause ${e.name || "audio"}` : `Play ${e.name || "audio"}`,
167
+ onClick: S
168
+ }, [
169
+ i(r(f), { size: "small" }, {
170
+ default: p(() => [
171
+ l.value ? (a(), c(r(P), { key: 0 })) : (a(), c(r(z), { key: 1 }))
172
+ ]),
173
+ _: 1
174
+ })
175
+ ], 8, de)) : m("", !0),
176
+ u("div", ue, [
177
+ e.showHeader ? (a(), n("div", ce, [
178
+ u("span", pe, v(e.name || "Audio"), 1),
179
+ e.error && e.errorText ? (a(), n("span", me, v(e.errorText), 1)) : (a(), n("span", ve, v($.value) + " / " + v(B.value), 1))
180
+ ])) : m("", !0),
181
+ u("div", fe, [
182
+ X(u("input", {
183
+ "onUpdate:modelValue": h[0] || (h[0] = (g) => k.value = g),
184
+ class: "nmorph-audio-preview__range",
185
+ type: "range",
186
+ min: "0",
187
+ max: "100",
188
+ step: "0.1",
189
+ style: T(A.value),
190
+ disabled: e.loading || e.error || d.value <= 0,
191
+ "aria-label": `Audio progress ${e.name || ""}`
192
+ }, null, 12, _e), [
193
+ [
194
+ Y,
195
+ k.value,
196
+ void 0,
197
+ { number: !0 }
198
+ ]
199
+ ]),
200
+ e.showHeader ? m("", !0) : (a(), n("span", he, v($.value) + " / " + v(B.value), 1))
166
201
  ])
167
202
  ]),
168
- C.value ? (t(), p("div", fe, [
169
- X(o.$slots, "actions", {}, () => [
170
- i("a", {
203
+ H.value ? (a(), n("div", ye, [
204
+ Z(o.$slots, "actions", {}, () => [
205
+ u("a", {
171
206
  href: e.src,
172
207
  target: "_blank",
173
208
  rel: "noopener noreferrer",
174
209
  class: "nmorph-audio-preview__action-link",
175
210
  "aria-label": `Open ${e.name || "audio"}`,
176
- onClick: U
211
+ onClick: j
177
212
  }, [
178
- s(r(w), { size: "small" }, {
179
- default: m(() => [
180
- s(r(te))
213
+ i(r(f), { size: "small" }, {
214
+ default: p(() => [
215
+ i(r(re))
181
216
  ]),
182
217
  _: 1
183
218
  })
184
- ], 8, _e),
185
- e.downloadHref ? (t(), p("a", {
219
+ ], 8, we),
220
+ e.downloadHref ? (a(), n("a", {
186
221
  key: 0,
187
222
  href: e.downloadHref,
188
223
  download: e.name,
189
224
  class: "nmorph-audio-preview__action-link",
190
225
  "aria-label": `Download ${e.name || "audio"}`,
191
- onClick: F
226
+ onClick: q
192
227
  }, [
193
- s(r(w), { size: "small" }, {
194
- default: m(() => [
195
- s(r(ne))
228
+ i(r(f), { size: "small" }, {
229
+ default: p(() => [
230
+ i(r(te))
196
231
  ]),
197
232
  _: 1
198
233
  })
199
- ], 8, he)) : H("", !0)
234
+ ], 8, be)) : m("", !0)
200
235
  ])
201
- ])) : H("", !0)
236
+ ])) : m("", !0)
202
237
  ], 6));
203
238
  }
204
239
  });
205
240
  export {
206
- Me as default
241
+ Ie as default
207
242
  };
@@ -1 +1 @@
1
- .nmorph-file-card{display:flex;gap:var(--indentation-03);align-items:center;box-sizing:border-box;width:100%;min-width:0;max-width:100%;min-height:64px;padding:var(--indentation-03);color:var(--nmorph-text-color);background:var(--nmorph-main-color);border-radius:var(--default-border-radius);box-shadow:var(--nmorph-shadow-inset)}.nmorph-file-card .nmorph-file-card__icon{display:flex;flex:0 0 auto;justify-content:center;align-items:center;width:36px;height:36px;color:var(--nmorph-accent-color);background:color-mix(in srgb,var(--nmorph-accent-color) 12%,transparent);border-radius:var(--default-border-radius);--color: currentColor}.nmorph-file-card .nmorph-file-card__body{display:flex;flex:1 1 0;flex-direction:column;gap:2px;min-width:0}.nmorph-file-card .nmorph-file-card__name,.nmorph-file-card .nmorph-file-card__meta,.nmorph-file-card .nmorph-file-card__error{display:block;min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.nmorph-file-card .nmorph-file-card__name{font-weight:600;font-size:var(--font-size-small);line-height:var(--line-height-regular)}.nmorph-file-card .nmorph-file-card__meta,.nmorph-file-card .nmorph-file-card__error{font-size:var(--font-size-extra-small);line-height:var(--line-height-regular)}.nmorph-file-card .nmorph-file-card__meta{color:var(--nmorph-semi-contrast-text-color)}.nmorph-file-card .nmorph-file-card__error{color:var(--nmorph-error-text-color)}.nmorph-file-card .nmorph-file-card__badge{flex:0 0 auto;max-width:72px;padding:2px 6px;overflow:hidden;color:var(--nmorph-accent-color);font-weight:700;font-size:var(--font-size-extra-small);line-height:var(--line-height-regular);white-space:nowrap;text-transform:uppercase;text-overflow:ellipsis;background:color-mix(in srgb,var(--nmorph-accent-color) 10%,transparent);border-radius:var(--default-border-radius)}.nmorph-file-card .nmorph-file-card__actions{display:flex;flex:0 0 auto;gap:var(--indentation-01);align-items:center}.nmorph-file-card .nmorph-file-card__action-link{display:inline-flex;justify-content:center;align-items:center;width:22px;height:22px;color:inherit;text-decoration:none;border-radius:var(--default-border-radius)}.nmorph-file-card .nmorph-file-card__action-link:hover{color:var(--nmorph-accent-color);background:color-mix(in srgb,var(--nmorph-accent-color) 10%,transparent)}.nmorph-file-card .nmorph-file-card__action-link .nmorph-icon{--color: currentColor}.nmorph-file-card.nmorph-file-card--compact{min-height:52px;padding:var(--indentation-02)}.nmorph-file-card.nmorph-file-card--compact .nmorph-file-card__icon{width:30px;height:30px}.nmorph-file-card.nmorph-file-card--error{outline:1px solid var(--nmorph-error-color)}
1
+ .nmorph-file-card{display:flex;gap:var(--indentation-03);align-items:center;box-sizing:border-box;width:100%;min-width:0;max-width:100%;min-height:64px;padding:var(--indentation-03);color:var(--nmorph-text-color);background:var(--nmorph-main-color);border-radius:var(--default-border-radius);box-shadow:var(--nmorph-shadow-inset)}.nmorph-file-card .nmorph-file-card__icon{position:relative;display:flex;flex:0 0 auto;justify-content:center;align-items:center;width:36px;height:36px;color:var(--nmorph-accent-color);background:color-mix(in srgb,var(--nmorph-accent-color) 12%,transparent);border-radius:var(--default-border-radius);--color: currentColor}.nmorph-file-card .nmorph-file-card__icon-action{position:absolute;right:-4px;bottom:-4px;display:inline-flex;justify-content:center;align-items:center;width:18px;height:18px;color:var(--nmorph-accent-color);text-decoration:none;background:var(--nmorph-main-color);border-radius:var(--border-radius-circular);box-shadow:var(--nmorph-shadow-outset)}.nmorph-file-card .nmorph-file-card__icon-action:hover{color:var(--nmorph-focus-text-color);background:var(--nmorph-accent-color)}.nmorph-file-card .nmorph-file-card__icon-action .nmorph-icon{--color: currentColor}.nmorph-file-card .nmorph-file-card__body{display:flex;flex:1 1 0;flex-direction:column;gap:2px;min-width:0}.nmorph-file-card .nmorph-file-card__name,.nmorph-file-card .nmorph-file-card__meta,.nmorph-file-card .nmorph-file-card__error{display:block;min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.nmorph-file-card .nmorph-file-card__name{font-weight:600;font-size:var(--font-size-small);line-height:var(--line-height-regular)}.nmorph-file-card .nmorph-file-card__meta,.nmorph-file-card .nmorph-file-card__error{font-size:var(--font-size-extra-small);line-height:var(--line-height-regular)}.nmorph-file-card .nmorph-file-card__meta{color:var(--nmorph-semi-contrast-text-color)}.nmorph-file-card .nmorph-file-card__error{color:var(--nmorph-error-text-color)}.nmorph-file-card .nmorph-file-card__audio-preview{width:100%;min-width:0;margin-top:var(--indentation-01)}.nmorph-file-card .nmorph-file-card__badge{flex:0 0 auto;max-width:72px;padding:2px 6px;overflow:hidden;color:var(--nmorph-accent-color);font-weight:700;font-size:var(--font-size-extra-small);line-height:var(--line-height-regular);white-space:nowrap;text-transform:uppercase;text-overflow:ellipsis;background:color-mix(in srgb,var(--nmorph-accent-color) 10%,transparent);border-radius:var(--default-border-radius)}.nmorph-file-card .nmorph-file-card__actions{display:flex;flex:0 0 auto;gap:var(--indentation-01);align-items:center}.nmorph-file-card .nmorph-file-card__action-link{display:inline-flex;justify-content:center;align-items:center;width:22px;height:22px;color:inherit;text-decoration:none;border-radius:var(--default-border-radius)}.nmorph-file-card .nmorph-file-card__action-link:hover{color:var(--nmorph-accent-color);background:color-mix(in srgb,var(--nmorph-accent-color) 10%,transparent)}.nmorph-file-card .nmorph-file-card__action-link .nmorph-icon{--color: currentColor}.nmorph-file-card.nmorph-file-card--compact{min-height:52px;padding:var(--indentation-02)}.nmorph-file-card.nmorph-file-card--compact .nmorph-file-card__icon{width:30px;height:30px}.nmorph-file-card.nmorph-file-card--compact .nmorph-file-card__audio-preview{margin-top:2px}.nmorph-file-card.nmorph-file-card--error{outline:1px solid var(--nmorph-error-color)}.nmorph-file-card.nmorph-file-card--soft{background:color-mix(in srgb,var(--nmorph-accent-color) 6%,transparent);box-shadow:none}.nmorph-file-card.nmorph-file-card--plain{background:transparent;box-shadow:none}.nmorph-file-card.nmorph-file-card--icon-plain .nmorph-file-card__icon{background:transparent}
@@ -1,31 +1,34 @@
1
1
  import './NmorphFileCard.css';
2
- import { defineComponent as M, useSlots as $, computed as t, openBlock as r, createElementBlock as a, normalizeClass as F, createElementVNode as _, createBlock as v, unref as n, withCtx as c, createVNode as l, resolveDynamicComponent as R, toDisplayString as d, createCommentVNode as s, renderSlot as V } from "vue";
3
- import { useModifiers as z } from "../../../utils/create-modifiers.js";
4
- import { getFileExtension as E, 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 z, useSlots as F, computed as a, openBlock as r, createElementBlock as t, normalizeClass as P, createElementVNode as g, createBlock as f, unref as n, withCtx as m, createVNode as i, resolveDynamicComponent as R, createCommentVNode as l, toDisplayString as h, renderSlot as V } from "vue";
3
+ import { useModifiers as O } from "../../../utils/create-modifiers.js";
4
+ import { getFileExtension as W, getPlainFileType as K, getTypeCandidates as j, isKnownFileType as d } from "../../../utils/file-types.js";
5
+ import { NmorphImageResolution as G, NmorphAudioResolution as q, NmorphVideoResolution as J, NmorphArchiveResolution as Q, NmorphDocResolution as U } from "../../form/nmorph-file-upload/types.js";
6
+ import X from "../nmorph-audio-preview/NmorphAudioPreview.vue.js";
7
+ /* empty css */
8
+ import Y from "../../../assets/icons/image.svg.js";
9
+ import Z from "../../../assets/icons/video.svg.js";
10
+ import ee from "../../../assets/icons/archive.svg.js";
11
+ import C from "../../../assets/icons/doc.svg.js";
10
12
  import p from "../../basic/nmorph-icon/NmorphIcon.vue.js";
11
13
  /* 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 = {
14
+ import oe from "../../../assets/icons/eye.svg.js";
15
+ import re from "../../../assets/icons/audio.svg.js";
16
+ import ae from "../../../assets/icons/loading.svg.js";
17
+ import ne from "../../../assets/icons/open.svg.js";
18
+ import te from "../../../assets/icons/download.svg.js";
19
+ const ie = { class: "nmorph-file-card__icon" }, le = ["href", "aria-label"], se = { class: "nmorph-file-card__body" }, ce = { class: "nmorph-file-card__name" }, me = {
17
20
  key: 0,
18
21
  class: "nmorph-file-card__error"
19
- }, ne = {
22
+ }, de = {
20
23
  key: 1,
21
24
  class: "nmorph-file-card__meta"
22
- }, ie = {
25
+ }, pe = {
23
26
  key: 0,
24
27
  class: "nmorph-file-card__badge"
25
- }, le = {
28
+ }, ue = {
26
29
  key: 1,
27
30
  class: "nmorph-file-card__actions"
28
- }, se = ["href", "aria-label"], me = ["href", "download", "aria-label"], Te = /* @__PURE__ */ M({
31
+ }, fe = ["href", "aria-label"], he = ["href", "download", "aria-label"], Ee = /* @__PURE__ */ z({
29
32
  __name: "NmorphFileCard",
30
33
  props: {
31
34
  name: {},
@@ -34,6 +37,10 @@ const oe = { class: "nmorph-file-card__icon" }, re = { class: "nmorph-file-card_
34
37
  size: { default: void 0 },
35
38
  previewSrc: { default: "" },
36
39
  downloadHref: { default: "" },
40
+ mediaPreview: { default: "none" },
41
+ surface: { default: "card" },
42
+ showExtensionBadge: { type: Boolean, default: !0 },
43
+ iconSurface: { type: Boolean, default: !0 },
37
44
  compact: { type: Boolean, default: !1 },
38
45
  loading: { type: Boolean, default: !1 },
39
46
  error: { type: Boolean, default: !1 },
@@ -41,65 +48,101 @@ const oe = { class: "nmorph-file-card__icon" }, re = { class: "nmorph-file-card_
41
48
  showDefaultActions: { type: Boolean, default: !0 }
42
49
  },
43
50
  emits: ["open", "download", "error"],
44
- setup(k, { emit: B }) {
45
- const e = k, y = B, T = $(), f = t(() => (e.extension || E(e.name) || W(e.mimeType)).toLowerCase()), i = t(() => K(e.mimeType, e.name)), C = 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), x = (o) => {
51
+ setup(S, { emit: T }) {
52
+ const e = S, _ = T, b = F(), u = a(() => (e.extension || W(e.name) || K(e.mimeType)).toLowerCase()), s = a(() => j(e.mimeType, e.name)), x = a(() => e.mimeType.toLowerCase().startsWith("image/") || s.value.some((o) => d(o, G)) ? Y : e.mimeType.toLowerCase().startsWith("audio/") || s.value.some((o) => d(o, q)) ? re : e.mimeType.toLowerCase().startsWith("video/") || s.value.some((o) => d(o, J)) ? Z : s.value.some((o) => d(o, Q)) ? ee : s.value.some((o) => d(o, U)) ? C : C), I = (o) => {
46
53
  if (o === void 0 || Number.isNaN(o) || o < 0) return "";
47
54
  if (o === 0) return "0 B";
48
- const u = ["B", "KB", "MB", "GB", "TB"], h = Math.min(Math.floor(Math.log(o) / Math.log(1024)), u.length - 1), N = o / 1024 ** h, L = N >= 10 || h === 0 ? 0 : 1;
49
- return `${N.toFixed(L)} ${u[h]}`;
50
- }, I = t(() => x(e.size)), b = t(() => f.value || e.mimeType), w = t(() => [b.value, I.value].filter(Boolean).join(" · ")), S = t(
51
- () => !!T.actions || e.showDefaultActions && (e.previewSrc || e.downloadHref)
52
- ), D = t(
53
- () => z({
54
- "nmorph-file-card": [e.compact && "compact", e.loading && "loading", e.error && "error"]
55
+ const w = ["B", "KB", "MB", "GB", "TB"], y = Math.min(Math.floor(Math.log(o) / Math.log(1024)), w.length - 1), k = o / 1024 ** y, M = k >= 10 || y === 0 ? 0 : 1;
56
+ return `${k.toFixed(M)} ${w[y]}`;
57
+ }, A = a(() => I(e.size)), D = a(() => u.value || e.mimeType), B = a(() => [D.value, A.value].filter(Boolean).join(" · ")), c = a(() => e.mediaPreview === "audio" && !!e.previewSrc && !e.loading && !e.error), v = a(() => e.showDefaultActions && !!e.previewSrc && !c.value && (e.mimeType.toLowerCase() === "application/pdf" || u.value === "pdf")), $ = a(
58
+ () => !!b.actions || e.showDefaultActions && (e.previewSrc && !c.value && !v.value || e.downloadHref)
59
+ ), E = a(
60
+ () => O({
61
+ "nmorph-file-card": [
62
+ e.surface,
63
+ e.compact && "compact",
64
+ e.loading && "loading",
65
+ e.error && "error",
66
+ c.value && "media-audio",
67
+ !e.iconSurface && "icon-plain"
68
+ ]
55
69
  })
56
- ), A = () => y("open"), H = () => y("download");
57
- return (o, u) => (r(), a("div", {
58
- class: F(D.value)
70
+ ), N = () => _("open"), H = () => _("download"), L = () => _("error");
71
+ return (o, w) => (r(), t("div", {
72
+ class: P(E.value)
59
73
  }, [
60
- _("div", oe, [
61
- e.loading ? (r(), v(n(p), {
74
+ g("div", ie, [
75
+ e.loading ? (r(), f(n(p), {
62
76
  key: 0,
63
77
  size: "medium"
64
78
  }, {
65
- default: c(() => [
66
- l(n(Y))
79
+ default: m(() => [
80
+ i(n(ae))
67
81
  ]),
68
82
  _: 1
69
- })) : (r(), v(n(p), {
83
+ })) : (r(), f(n(p), {
70
84
  key: 1,
71
85
  size: "medium"
72
86
  }, {
73
- default: c(() => [
74
- (r(), v(R(C.value)))
87
+ default: m(() => [
88
+ (r(), f(R(x.value)))
75
89
  ]),
76
90
  _: 1
77
- }))
91
+ })),
92
+ v.value && !e.loading && !e.error ? (r(), t("a", {
93
+ key: 2,
94
+ href: e.previewSrc,
95
+ target: "_blank",
96
+ rel: "noopener noreferrer",
97
+ class: "nmorph-file-card__icon-action",
98
+ "aria-label": `Preview ${e.name}`,
99
+ onClick: N
100
+ }, [
101
+ i(n(p), { size: "small" }, {
102
+ default: m(() => [
103
+ i(n(oe))
104
+ ]),
105
+ _: 1
106
+ })
107
+ ], 8, le)) : l("", !0)
78
108
  ]),
79
- _("div", re, [
80
- _("span", te, d(e.name), 1),
81
- e.error && e.errorText ? (r(), a("span", ae, d(e.errorText), 1)) : w.value ? (r(), a("span", ne, d(w.value), 1)) : s("", !0)
109
+ g("div", se, [
110
+ g("span", ce, h(e.name), 1),
111
+ e.error && e.errorText ? (r(), t("span", me, h(e.errorText), 1)) : B.value ? (r(), t("span", de, h(B.value), 1)) : l("", !0),
112
+ c.value ? (r(), f(X, {
113
+ key: 2,
114
+ class: "nmorph-file-card__audio-preview",
115
+ src: e.previewSrc,
116
+ name: e.name,
117
+ surface: "plain",
118
+ embedded: "",
119
+ compact: "",
120
+ "show-icon": !1,
121
+ "show-header": !1,
122
+ "show-default-actions": !1,
123
+ onError: L
124
+ }, null, 8, ["src", "name"])) : l("", !0)
82
125
  ]),
83
- f.value ? (r(), a("span", ie, d(f.value), 1)) : s("", !0),
84
- S.value ? (r(), a("div", le, [
126
+ e.showExtensionBadge && u.value ? (r(), t("span", pe, h(u.value), 1)) : l("", !0),
127
+ $.value ? (r(), t("div", ue, [
85
128
  V(o.$slots, "actions", {}, () => [
86
- e.previewSrc ? (r(), a("a", {
129
+ e.previewSrc && !c.value && !v.value ? (r(), t("a", {
87
130
  key: 0,
88
131
  href: e.previewSrc,
89
132
  target: "_blank",
90
133
  rel: "noopener noreferrer",
91
134
  class: "nmorph-file-card__action-link",
92
135
  "aria-label": `Open ${e.name}`,
93
- onClick: A
136
+ onClick: N
94
137
  }, [
95
- l(n(p), { size: "small" }, {
96
- default: c(() => [
97
- l(n(Z))
138
+ i(n(p), { size: "small" }, {
139
+ default: m(() => [
140
+ i(n(ne))
98
141
  ]),
99
142
  _: 1
100
143
  })
101
- ], 8, se)) : s("", !0),
102
- e.downloadHref ? (r(), a("a", {
144
+ ], 8, fe)) : l("", !0),
145
+ e.downloadHref ? (r(), t("a", {
103
146
  key: 1,
104
147
  href: e.downloadHref,
105
148
  download: e.name,
@@ -107,18 +150,18 @@ const oe = { class: "nmorph-file-card__icon" }, re = { class: "nmorph-file-card_
107
150
  "aria-label": `Download ${e.name}`,
108
151
  onClick: H
109
152
  }, [
110
- l(n(p), { size: "small" }, {
111
- default: c(() => [
112
- l(n(ee))
153
+ i(n(p), { size: "small" }, {
154
+ default: m(() => [
155
+ i(n(te))
113
156
  ]),
114
157
  _: 1
115
158
  })
116
- ], 8, me)) : s("", !0)
159
+ ], 8, he)) : l("", !0)
117
160
  ])
118
- ])) : s("", !0)
161
+ ])) : l("", !0)
119
162
  ], 2));
120
163
  }
121
164
  });
122
165
  export {
123
- Te as default
166
+ Ee as default
124
167
  };