@treeui/vue 0.12.0 → 0.14.0

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 (94) hide show
  1. package/README.md +5 -1
  2. package/dist/components/TButton.cjs.map +1 -1
  3. package/dist/components/TButton.js.map +1 -1
  4. package/dist/components/TButton.vue.d.ts +2 -2
  5. package/dist/components/TButton.vue.d.ts.map +1 -1
  6. package/dist/components/TButton.vue_vue_type_script_setup_true_lang.cjs +1 -1
  7. package/dist/components/TButton.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  8. package/dist/components/TButton.vue_vue_type_script_setup_true_lang.js +2 -1
  9. package/dist/components/TButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
  10. package/dist/components/TChart.cjs +2 -0
  11. package/dist/components/TChart.cjs.map +1 -0
  12. package/dist/components/TChart.js +7 -0
  13. package/dist/components/TChart.js.map +1 -0
  14. package/dist/components/TChart.vue.d.ts +123 -0
  15. package/dist/components/TChart.vue.d.ts.map +1 -0
  16. package/dist/components/TChart.vue_vue_type_script_setup_true_lang.cjs +2 -0
  17. package/dist/components/TChart.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
  18. package/dist/components/TChart.vue_vue_type_script_setup_true_lang.js +370 -0
  19. package/dist/components/TChart.vue_vue_type_script_setup_true_lang.js.map +1 -0
  20. package/dist/components/TDonutChart.cjs +2 -0
  21. package/dist/components/TDonutChart.cjs.map +1 -0
  22. package/dist/components/TDonutChart.js +7 -0
  23. package/dist/components/TDonutChart.js.map +1 -0
  24. package/dist/components/TDonutChart.vue.d.ts +75 -0
  25. package/dist/components/TDonutChart.vue.d.ts.map +1 -0
  26. package/dist/components/TDonutChart.vue_vue_type_script_setup_true_lang.cjs +2 -0
  27. package/dist/components/TDonutChart.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
  28. package/dist/components/TDonutChart.vue_vue_type_script_setup_true_lang.js +168 -0
  29. package/dist/components/TDonutChart.vue_vue_type_script_setup_true_lang.js.map +1 -0
  30. package/dist/components/TFileUpload.cjs.map +1 -1
  31. package/dist/components/TFileUpload.js.map +1 -1
  32. package/dist/components/TFileUpload.vue.d.ts +77 -10
  33. package/dist/components/TFileUpload.vue.d.ts.map +1 -1
  34. package/dist/components/TFileUpload.vue_vue_type_script_setup_true_lang.cjs +1 -1
  35. package/dist/components/TFileUpload.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  36. package/dist/components/TFileUpload.vue_vue_type_script_setup_true_lang.js +393 -144
  37. package/dist/components/TFileUpload.vue_vue_type_script_setup_true_lang.js.map +1 -1
  38. package/dist/components/TGrid.vue.d.ts +1 -1
  39. package/dist/components/TGrid.vue.d.ts.map +1 -1
  40. package/dist/components/TNavMenu.cjs.map +1 -1
  41. package/dist/components/TNavMenu.js.map +1 -1
  42. package/dist/components/TNavMenu.vue.d.ts +9 -0
  43. package/dist/components/TNavMenu.vue.d.ts.map +1 -1
  44. package/dist/components/TNavMenu.vue_vue_type_script_setup_true_lang.cjs +1 -1
  45. package/dist/components/TNavMenu.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  46. package/dist/components/TNavMenu.vue_vue_type_script_setup_true_lang.js +67 -55
  47. package/dist/components/TNavMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
  48. package/dist/components/TPage.cjs +2 -0
  49. package/dist/components/TPage.cjs.map +1 -0
  50. package/dist/components/TPage.js +7 -0
  51. package/dist/components/TPage.js.map +1 -0
  52. package/dist/components/TPage.vue.d.ts +35 -0
  53. package/dist/components/TPage.vue.d.ts.map +1 -0
  54. package/dist/components/TPage.vue_vue_type_script_setup_true_lang.cjs +2 -0
  55. package/dist/components/TPage.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
  56. package/dist/components/TPage.vue_vue_type_script_setup_true_lang.js +49 -0
  57. package/dist/components/TPage.vue_vue_type_script_setup_true_lang.js.map +1 -0
  58. package/dist/components/TPageHeader.cjs +2 -0
  59. package/dist/components/TPageHeader.cjs.map +1 -0
  60. package/dist/components/TPageHeader.js +7 -0
  61. package/dist/components/TPageHeader.js.map +1 -0
  62. package/dist/components/TPageHeader.vue.d.ts +40 -0
  63. package/dist/components/TPageHeader.vue.d.ts.map +1 -0
  64. package/dist/components/TPageHeader.vue_vue_type_script_setup_true_lang.cjs +2 -0
  65. package/dist/components/TPageHeader.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
  66. package/dist/components/TPageHeader.vue_vue_type_script_setup_true_lang.js +54 -0
  67. package/dist/components/TPageHeader.vue_vue_type_script_setup_true_lang.js.map +1 -0
  68. package/dist/components/TSidebar.vue_vue_type_script_setup_true_lang.cjs +1 -1
  69. package/dist/components/TSidebar.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  70. package/dist/components/TSidebar.vue_vue_type_script_setup_true_lang.js +1 -4
  71. package/dist/components/TSidebar.vue_vue_type_script_setup_true_lang.js.map +1 -1
  72. package/dist/components/TSparkline.cjs +2 -0
  73. package/dist/components/TSparkline.cjs.map +1 -0
  74. package/dist/components/TSparkline.js +7 -0
  75. package/dist/components/TSparkline.js.map +1 -0
  76. package/dist/components/TSparkline.vue.d.ts +40 -0
  77. package/dist/components/TSparkline.vue.d.ts.map +1 -0
  78. package/dist/components/TSparkline.vue_vue_type_script_setup_true_lang.cjs +2 -0
  79. package/dist/components/TSparkline.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
  80. package/dist/components/TSparkline.vue_vue_type_script_setup_true_lang.js +107 -0
  81. package/dist/components/TSparkline.vue_vue_type_script_setup_true_lang.js.map +1 -0
  82. package/dist/components/TStack.vue.d.ts +1 -1
  83. package/dist/components/TStack.vue.d.ts.map +1 -1
  84. package/dist/components/index.d.ts +9 -1
  85. package/dist/components/index.d.ts.map +1 -1
  86. package/dist/index.cjs +1 -1
  87. package/dist/index.js +51 -46
  88. package/dist/plugin.cjs +1 -1
  89. package/dist/plugin.cjs.map +1 -1
  90. package/dist/plugin.d.ts.map +1 -1
  91. package/dist/plugin.js +100 -90
  92. package/dist/plugin.js.map +1 -1
  93. package/dist/style.css +1 -1
  94. package/package.json +3 -3
@@ -1,34 +1,63 @@
1
1
  import e from "./TSpinner.js";
2
- import { Fragment as t, computed as n, createBlock as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, defineComponent as s, mergeProps as c, onBeforeUnmount as l, onMounted as u, openBlock as d, ref as f, renderList as p, renderSlot as m, toDisplayString as h, unref as g, useAttrs as _, useSlots as v } from "vue";
3
- import { createId as y, isActivationKey as b } from "@treeui/utils";
2
+ import t from "./TProgress.js";
3
+ import { Fragment as n, computed as r, createBlock as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createTextVNode as c, createVNode as l, defineComponent as u, mergeProps as d, normalizeClass as f, onBeforeUnmount as p, onMounted as m, openBlock as h, ref as g, renderList as _, renderSlot as v, toDisplayString as y, unref as ee, useAttrs as te, useSlots as ne, watch as b } from "vue";
4
+ import { createId as re, isActivationKey as ie } from "@treeui/utils";
4
5
  //#region src/components/TFileUpload.vue?vue&type=script&setup=true&lang.ts
5
- var x = [
6
+ var ae = [
6
7
  "id",
7
8
  "accept",
8
9
  "multiple",
9
10
  "disabled"
10
- ], S = [
11
+ ], oe = [
11
12
  "aria-busy",
12
13
  "aria-controls",
13
14
  "aria-describedby",
14
15
  "aria-disabled",
15
16
  "aria-invalid",
16
17
  "tabindex"
17
- ], ee = {
18
+ ], se = {
18
19
  key: 0,
19
20
  class: "t-file-upload__icon",
20
21
  "aria-hidden": "true"
21
- }, te = { class: "t-file-upload__content" }, C = { class: "t-file-upload__label" }, ne = { class: "t-file-upload__browse" }, re = {
22
+ }, ce = { class: "t-file-upload__content" }, le = { class: "t-file-upload__label" }, ue = { class: "t-file-upload__browse" }, de = {
23
+ class: "t-file-upload__status-log t-visually-hidden",
24
+ role: "log",
25
+ "aria-live": "polite"
26
+ }, fe = {
22
27
  key: 1,
23
28
  class: "t-file-upload__files"
24
- }, ie = { class: "t-file-upload__files-header" }, ae = ["disabled"], oe = { class: "t-file-upload__list" }, se = { class: "t-file-upload__file-copy" }, w = { class: "t-file-upload__file-name" }, T = { class: "t-file-upload__file-meta" }, E = [
29
+ }, pe = { class: "t-file-upload__files-header" }, me = ["disabled"], he = { class: "t-file-upload__list" }, ge = ["aria-busy"], _e = {
30
+ class: "t-file-upload__thumb",
31
+ "aria-hidden": "true"
32
+ }, ve = ["src"], ye = {
33
+ key: 1,
34
+ class: "t-file-upload__thumb-fallback"
35
+ }, be = { class: "t-file-upload__file-copy" }, xe = { class: "t-file-upload__file-name" }, Se = { class: "t-file-upload__file-meta" }, Ce = {
36
+ key: 0,
37
+ class: "t-file-upload__file-progress"
38
+ }, we = {
39
+ key: 1,
40
+ class: "t-file-upload__file-status"
41
+ }, Te = {
42
+ key: 0,
43
+ class: "t-file-upload__proof",
44
+ "aria-hidden": "true"
45
+ }, Ee = ["id"], De = [
46
+ "data-t-retry",
47
+ "disabled",
48
+ "aria-describedby",
49
+ "onFocus",
50
+ "onBlur",
51
+ "onClick"
52
+ ], Oe = [
53
+ "data-t-remove",
25
54
  "disabled",
26
55
  "aria-label",
27
56
  "onClick"
28
- ], ce = {
57
+ ], ke = {
29
58
  key: 2,
30
59
  class: "t-file-upload__actions"
31
- }, D = /*@__PURE__*/ s({
60
+ }, x = /*@__PURE__*/ u({
32
61
  inheritAttrs: !1,
33
62
  __name: "TFileUpload",
34
63
  props: {
@@ -68,32 +97,71 @@ var x = [
68
97
  showFileList: {
69
98
  type: Boolean,
70
99
  default: !0
71
- }
100
+ },
101
+ uploadState: {
102
+ type: [Map, Function],
103
+ default: void 0
104
+ },
105
+ dragLabel: { default: "Release to upload" },
106
+ dragRejectLabel: { default: "This file type is not accepted" },
107
+ thumbnails: {
108
+ type: Boolean,
109
+ default: !0
110
+ },
111
+ maxThumbnailSize: { default: 10 * 1024 * 1024 },
112
+ retryLabel: { default: "Retry" },
113
+ resumeLabel: {
114
+ type: Function,
115
+ default: (e) => `Resume from ${e}%`
116
+ },
117
+ remainingTimeFormat: {
118
+ type: Function,
119
+ default: (e) => {
120
+ if (e < 5e3) return "Less than 5s left";
121
+ let t = Math.round(e / 1e3);
122
+ if (t < 60) return `About ${t}s left`;
123
+ let n = Math.round(t / 60);
124
+ return n < 60 ? `About ${n} min left` : `About ${Math.round(n / 60)}h left`;
125
+ }
126
+ },
127
+ statusLabels: { default: () => ({}) }
72
128
  },
73
129
  emits: [
74
130
  "update:modelValue",
75
131
  "files-accepted",
76
- "files-rejected"
132
+ "files-rejected",
133
+ "retry",
134
+ "cancel"
77
135
  ],
78
- setup(s, { emit: D }) {
79
- let le = v(), O = s, k = D, A = _(), j = f(null), M = f(null), N = f(!1), P = f(!1), F = f(0), I = f([]), L = y("t-file-upload"), R = `${L}-description`, z = `${L}-feedback`, B = `${L}-files`, V = n(() => O.disabled || O.loading), H = n(() => O.modelValue.length > 0), U = n(() => !!le.default), W = n(() => O.multiple ? typeof O.maxFiles == "number" ? Math.max(O.maxFiles, 0) : Infinity : 1), ue = n(() => [
136
+ setup(u, { emit: x }) {
137
+ let Ae = {
138
+ pending: "Waiting",
139
+ uploading: "Uploading",
140
+ paused: "Paused",
141
+ error: "Upload failed",
142
+ success: "Uploaded"
143
+ }, je = ne(), S = u, C = x, w = te(), T = g(null), E = g(null), D = g(!1), O = g(!1), k = g(!1), A = g(0), j = g([]), M = g([]), N = 0, P = g(null), F = g(/* @__PURE__ */ new Map()), I = re("t-file-upload"), L = `${I}-description`, R = `${I}-feedback`, z = `${I}-files`, B = r(() => S.disabled), V = r(() => S.modelValue.length > 0), Me = r(() => !!je.default), Ne = r(() => ({
144
+ ...Ae,
145
+ ...S.statusLabels
146
+ })), H = r(() => S.multiple ? typeof S.maxFiles == "number" ? Math.max(S.maxFiles, 0) : Infinity : 1), Pe = r(() => [
80
147
  "t-file-upload",
81
- `t-file-upload--${O.size}`,
148
+ `t-file-upload--${S.size}`,
82
149
  {
83
- "is-disabled": V.value,
84
- "is-invalid": O.invalid,
85
- "is-loading": O.loading,
86
- "is-drag-active": N.value,
87
- "has-files": H.value
150
+ "is-disabled": B.value,
151
+ "is-invalid": S.invalid,
152
+ "is-loading": S.loading,
153
+ "is-drag-active": D.value,
154
+ "is-drag-reject": O.value,
155
+ "has-files": V.value
88
156
  },
89
- A.class
90
- ]), de = n(() => A.style), fe = n(() => {
91
- let { class: e, style: t, ...n } = A;
157
+ w.class
158
+ ]), Fe = r(() => w.style), Ie = r(() => {
159
+ let { class: e, style: t, ...n } = w;
92
160
  return n;
93
- }), pe = n(() => {
161
+ }), Le = r(() => {
94
162
  let e = [];
95
- return O.description && !U.value && e.push(R), I.value.length > 0 && e.push(z), O.showFileList && H.value && e.push(B), e.length > 0 ? e.join(" ") : void 0;
96
- }), me = n(() => `${O.filesLabel} (${O.modelValue.length})`), G = (e) => {
163
+ return S.description && !Me.value && e.push(L), j.value.length > 0 && e.push(R), S.showFileList && V.value && e.push(z), e.length > 0 ? e.join(" ") : void 0;
164
+ }), Re = r(() => `${S.filesLabel} (${S.modelValue.length})`), ze = r(() => O.value ? S.dragRejectLabel : D.value ? S.dragLabel : S.label), U = (e) => {
97
165
  if (e < 1024) return `${e} B`;
98
166
  let t = [
99
167
  "KB",
@@ -102,183 +170,364 @@ var x = [
102
170
  ], n = e / 1024, r = 0;
103
171
  for (; n >= 1024 && r < t.length - 1;) n /= 1024, r += 1;
104
172
  return `${n >= 10 || Number.isInteger(n) ? Math.round(n) : Number(n.toFixed(1))} ${t[r]}`;
105
- }, he = (e, t) => `${e.name}-${e.size}-${e.lastModified}-${t}`, ge = (e) => {
106
- if (!O.accept.trim()) return !0;
107
- let t = O.accept.split(",").map((e) => e.trim().toLowerCase()).filter(Boolean), n = e.name.toLowerCase(), r = e.type.toLowerCase();
108
- return t.some((e) => e.startsWith(".") ? n.endsWith(e) : e.endsWith("/*") ? r.startsWith(e.slice(0, -1)) : r === e);
109
- }, K = (e, t) => {
173
+ }, Be = (e) => {
174
+ let t = e.name.lastIndexOf("."), n = t > 0 && t < e.name.length - 1 ? e.name.slice(t + 1).toUpperCase() : "";
175
+ if (n && n.length <= 5) return n;
176
+ let r = e.type.includes("/") ? e.type.split("/")[1] : "";
177
+ return r ? r.toUpperCase() : "FILE";
178
+ }, Ve = 0, He = /* @__PURE__ */ new WeakMap(), Ue = (e) => {
179
+ let t = He.get(e);
180
+ return t || (Ve += 1, t = `${I}-f${Ve}`, He.set(e, t)), t;
181
+ }, W = r(() => S.accept.split(",").map((e) => e.trim().toLowerCase()).filter(Boolean)), We = (e) => {
182
+ if (W.value.length === 0) return !0;
183
+ let t = e.name.toLowerCase(), n = e.type.toLowerCase();
184
+ return W.value.some((e) => e.startsWith(".") ? t.endsWith(e) : e.endsWith("/*") ? n.startsWith(e.slice(0, -1)) : n === e);
185
+ }, Ge = r(() => W.value.length > 0 && W.value.every((e) => e.includes("/"))), Ke = (e) => {
186
+ let t = e.toLowerCase();
187
+ return !t || W.value.some((e) => e.endsWith("/*") ? t.startsWith(e.slice(0, -1)) : t === e);
188
+ }, qe = (e) => {
189
+ if (!Ge.value || !e) return !1;
190
+ let t = e.items;
191
+ if (!t || t.length === 0) return !1;
192
+ let n = Array.from(t).filter((e) => e.kind === "file");
193
+ return n.length !== 0 && n.every((e) => !Ke(e.type));
194
+ }, Je = (e, t) => {
195
+ let n = S.uploadState;
196
+ if (n) return typeof n == "function" ? n(e, t) : n.get(e);
197
+ }, G = r(() => S.modelValue.map(Je)), Ye = () => typeof window < "u" && typeof URL < "u" && typeof URL.createObjectURL == "function" && typeof URL.revokeObjectURL == "function", Xe = (e) => e.type.startsWith("image/") && (S.maxThumbnailSize === null || e.size <= S.maxThumbnailSize), Ze = () => {
198
+ if (Ye()) for (let e of F.value.values()) URL.revokeObjectURL(e.url);
199
+ F.value.clear();
200
+ }, K = () => {
201
+ if (!S.thumbnails || !Ye()) {
202
+ Ze();
203
+ return;
204
+ }
205
+ let e = new Set(S.modelValue);
206
+ for (let [t, n] of [...F.value]) e.has(t) || (URL.revokeObjectURL(n.url), F.value.delete(t));
207
+ for (let e of S.modelValue) {
208
+ if (F.value.has(e) || !Xe(e)) continue;
209
+ let t = URL.createObjectURL(e);
210
+ F.value.set(e, {
211
+ url: t,
212
+ width: null,
213
+ height: null
214
+ });
215
+ let n = new Image();
216
+ n.onload = () => {
217
+ let r = F.value.get(e);
218
+ !r || r.url !== t || F.value.set(e, {
219
+ url: t,
220
+ width: n.naturalWidth,
221
+ height: n.naturalHeight
222
+ });
223
+ }, n.src = t;
224
+ }
225
+ }, q = (e, t) => {
110
226
  switch (t) {
111
227
  case "file-invalid-type": return `${e.name} is not an accepted file type.`;
112
- case "file-too-large": return `${e.name} exceeds the ${G(O.maxFileSize ?? 0)} limit.`;
113
- case "too-many-files": return `You can only add up to ${W.value} file${W.value === 1 ? "" : "s"}.`;
228
+ case "file-too-large": return `${e.name} exceeds the ${U(S.maxFileSize ?? 0)} limit.`;
229
+ case "too-many-files": return `You can only add up to ${H.value} file${H.value === 1 ? "" : "s"}.`;
114
230
  default: return `${e.name} could not be added.`;
115
231
  }
116
- }, _e = () => {
117
- M.value && (M.value.value = "");
118
- }, q = () => {
119
- V.value || M.value?.click();
120
- }, ve = (e, t, n) => {
121
- I.value = n.map((e) => e.message), n.length > 0 && k("files-rejected", n), t.length > 0 && (k("update:modelValue", e), k("files-accepted", t));
122
- }, J = (e) => {
123
- if (V.value || e.length === 0) return;
124
- let t = O.multiple ? [...O.modelValue] : [], n = [], r = [], i = Number.isFinite(W.value) ? Math.max(W.value - t.length, 0) : Infinity;
232
+ }, Qe = () => {
233
+ E.value && (E.value.value = "");
234
+ }, J = () => {
235
+ B.value || E.value?.click();
236
+ }, $e = (e, t, n) => {
237
+ j.value = n.map((e) => e.message), n.length > 0 && C("files-rejected", n), t.length > 0 && (C("update:modelValue", e), C("files-accepted", t));
238
+ }, Y = (e) => {
239
+ if (B.value || e.length === 0) return;
240
+ let t = S.multiple ? [...S.modelValue] : [], n = [], r = [], i = Number.isFinite(H.value) ? Math.max(H.value - t.length, 0) : Infinity;
125
241
  for (let a of e) {
126
242
  if (i <= 0) {
127
243
  r.push({
128
244
  file: a,
129
245
  reason: "too-many-files",
130
- message: K(a, "too-many-files")
246
+ message: q(a, "too-many-files")
131
247
  });
132
248
  continue;
133
249
  }
134
- if (!ge(a)) {
250
+ if (!We(a)) {
135
251
  r.push({
136
252
  file: a,
137
253
  reason: "file-invalid-type",
138
- message: K(a, "file-invalid-type")
254
+ message: q(a, "file-invalid-type")
139
255
  });
140
256
  continue;
141
257
  }
142
- if (typeof O.maxFileSize == "number" && O.maxFileSize > 0 && a.size > O.maxFileSize) {
258
+ if (typeof S.maxFileSize == "number" && S.maxFileSize > 0 && a.size > S.maxFileSize) {
143
259
  r.push({
144
260
  file: a,
145
261
  reason: "file-too-large",
146
- message: K(a, "file-too-large")
262
+ message: q(a, "file-too-large")
147
263
  });
148
264
  continue;
149
265
  }
150
266
  n.push(a), t.push(a), Number.isFinite(i) && --i;
151
267
  }
152
- ve(t, n, r);
153
- }, Y = (e) => {
154
- V.value || (I.value = [], k("update:modelValue", O.modelValue.filter((t, n) => n !== e)));
268
+ $e(t, n, r);
269
+ }, et = (e, t, n) => {
270
+ let r = G.value[t];
271
+ !r || r.status !== "uploading" && r.status !== "paused" || C("cancel", {
272
+ file: e,
273
+ index: t,
274
+ fileKey: Ue(e),
275
+ state: r,
276
+ reason: n
277
+ });
278
+ }, tt = (e) => {
279
+ if (B.value) return;
280
+ let t = S.modelValue[e];
281
+ t && et(t, e, "remove"), j.value = [], C("update:modelValue", S.modelValue.filter((t, n) => n !== e));
155
282
  }, X = () => {
156
- V.value || !H.value || (I.value = [], k("update:modelValue", []));
157
- }, Z = (e) => e ? e.files.length > 0 || Array.from(e.types).includes("Files") : !1, ye = (e) => e?.items ? Array.from(e.items).map((e) => e.getAsFile?.() ?? null).filter((e) => e instanceof File) : [], be = (e) => {
283
+ B.value || !V.value || (S.modelValue.forEach((e, t) => {
284
+ et(e, t, "clear");
285
+ }), j.value = [], C("update:modelValue", []));
286
+ }, nt = r(() => S.modelValue.map((e, t) => {
287
+ let n = G.value[t], r = n?.status, i = F.value.get(e), a = Ue(e), o = n?.progress, s = typeof o == "number" ? Math.round(o) : void 0, c = n?.resumable === !0, l = !!(n && (r === "error" || r === "paused") && n.retryable !== !1), u = c ? "resume" : "restart", d = U(e.size), f = Be(e), p = i && i.width !== null && i.height !== null ? `${i.width} × ${i.height}` : void 0, m = r === "uploading" && s !== void 0 ? `${s}%` : void 0, h;
288
+ r === "uploading" && (n?.remainingLabel ? h = n.remainingLabel : typeof n?.remainingMs == "number" && Number.isFinite(n.remainingMs) && n.remainingMs >= 0 && (h = S.remainingTimeFormat(n.remainingMs)));
289
+ let g = (r === "error" || r === "paused") && typeof n?.uploadedBytes == "number" ? `${U(n.uploadedBytes)} of ${d} uploaded` : void 0, _ = r ? Ne.value[r] : void 0, v;
290
+ l && (v = c && s !== void 0 ? S.resumeLabel(s) : S.retryLabel);
291
+ let y = r === "error" ? n?.error : void 0;
292
+ return {
293
+ slotProps: {
294
+ file: e,
295
+ index: t,
296
+ fileKey: a,
297
+ state: n,
298
+ thumbnailUrl: n?.thumbnailUrl ?? i?.url,
299
+ sizeLabel: d,
300
+ typeLabel: f,
301
+ dimensionsLabel: p,
302
+ progressLabel: m,
303
+ remainingLabel: h,
304
+ uploadedLabel: g,
305
+ statusLabel: _,
306
+ actionLabel: v,
307
+ canRetry: l,
308
+ retryMode: u,
309
+ isDragActive: D.value,
310
+ isDragReject: O.value,
311
+ removeFile: () => tt(t),
312
+ retryFile: () => {
313
+ !l || B.value || !n || C("retry", {
314
+ file: e,
315
+ index: t,
316
+ fileKey: a,
317
+ mode: u,
318
+ state: n
319
+ });
320
+ }
321
+ },
322
+ rowClass: r ? `is-${r}` : void 0,
323
+ metaText: [
324
+ f,
325
+ d,
326
+ p,
327
+ n?.meta
328
+ ].filter(Boolean).join(" · "),
329
+ statusText: [
330
+ _,
331
+ m,
332
+ h,
333
+ g
334
+ ].filter(Boolean).join(" · "),
335
+ errorText: y,
336
+ errorId: y ? `${a}-error` : void 0,
337
+ showProgress: !!(n && (r === "uploading" || r === "paused" || r === "error" || r === "success" && s !== void 0)),
338
+ progressValue: r === "uploading" ? o : o ?? 0,
339
+ progressAriaLabel: `${_ ?? ""} ${e.name}`.trim(),
340
+ isBusy: r === "uploading",
341
+ isSuccess: r === "success"
342
+ };
343
+ })), Z = (e) => e ? e.files.length > 0 || Array.from(e.types).includes("Files") : !1, rt = (e) => e?.items ? Array.from(e.items).map((e) => e.getAsFile?.() ?? null).filter((e) => e instanceof File) : [], it = (e) => {
158
344
  let t = e.target;
159
- J(Array.from(t.files ?? [])), _e();
160
- }, xe = (e) => {
161
- !b(e) || V.value || (e.preventDefault(), q());
162
- }, Se = () => {
163
- P.value = !0;
164
- }, Ce = (e) => {
345
+ Y(Array.from(t.files ?? [])), Qe();
346
+ }, at = (e) => {
347
+ !ie(e) || B.value || (e.preventDefault(), J());
348
+ }, ot = () => {
349
+ k.value = !0;
350
+ }, st = (e) => {
165
351
  let t = e.relatedTarget;
166
- t && j.value?.contains(t) || (P.value = !1);
352
+ t && T.value?.contains(t) || (k.value = !1);
353
+ }, ct = (e) => {
354
+ P.value = e;
355
+ }, lt = (e) => {
356
+ P.value === e && (P.value = null);
357
+ }, ut = (e) => {
358
+ if (!S.paste || B.value) return;
359
+ let t = rt(e.clipboardData);
360
+ t.length !== 0 && (e.preventDefault(), Y(t));
167
361
  }, Q = (e) => {
168
- if (!O.paste || V.value) return;
169
- let t = ye(e.clipboardData);
170
- t.length !== 0 && (e.preventDefault(), J(t));
171
- }, $ = (e) => {
172
- !P.value || e.defaultPrevented || Q(e);
173
- }, we = (e) => {
174
- !O.drop || V.value || !Z(e.dataTransfer) || (e.preventDefault(), F.value += 1, N.value = !0);
175
- }, Te = (e) => {
176
- !O.drop || V.value || !Z(e.dataTransfer) || (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"), N.value = !0);
177
- }, Ee = (e) => {
178
- !O.drop || V.value || !Z(e.dataTransfer) || (e.preventDefault(), F.value = Math.max(F.value - 1, 0), F.value === 0 && (N.value = !1));
179
- }, De = (e) => {
180
- !O.drop || V.value || !Z(e.dataTransfer) || (e.preventDefault(), F.value = 0, N.value = !1, J(Array.from(e.dataTransfer?.files ?? [])));
181
- };
182
- return u(() => {
183
- document.addEventListener("paste", $);
184
- }), l(() => {
185
- document.removeEventListener("paste", $);
186
- }), (n, l) => (d(), a("div", c({
362
+ !k.value || e.defaultPrevented || ut(e);
363
+ }, dt = (e) => {
364
+ !S.drop || B.value || !Z(e.dataTransfer) || (e.preventDefault(), A.value += 1, D.value = !0, O.value = qe(e.dataTransfer));
365
+ }, ft = (e) => {
366
+ !S.drop || B.value || !Z(e.dataTransfer) || (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"), D.value = !0, O.value = qe(e.dataTransfer));
367
+ }, pt = (e) => {
368
+ !S.drop || B.value || !Z(e.dataTransfer) || (e.preventDefault(), A.value = Math.max(A.value - 1, 0), A.value === 0 && (D.value = !1, O.value = !1));
369
+ }, mt = (e) => {
370
+ !S.drop || B.value || !Z(e.dataTransfer) || (e.preventDefault(), A.value = 0, D.value = !1, O.value = !1, Y(Array.from(e.dataTransfer?.files ?? [])));
371
+ }, $ = /* @__PURE__ */ new Map();
372
+ return b(G, (e) => {
373
+ let t = [], n = /* @__PURE__ */ new Set();
374
+ S.modelValue.forEach((r, i) => {
375
+ n.add(r);
376
+ let a = e[i]?.status;
377
+ if (!a) return;
378
+ let o = $.get(r);
379
+ o !== a && ($.set(r, a), o !== void 0 && (a === "success" ? t.push(`${r.name} uploaded.`) : a === "error" && t.push(`${r.name} failed. ${e[i]?.error ?? ""}`.trim())));
380
+ });
381
+ for (let e of [...$.keys()]) n.has(e) || $.delete(e);
382
+ t.length > 0 && (N += 1, M.value = [...M.value, {
383
+ id: N,
384
+ text: t.join(" ")
385
+ }].slice(-5));
386
+ }, {
387
+ flush: "post",
388
+ immediate: !0
389
+ }), b(G, () => {
390
+ let e = P.value, t = T.value;
391
+ !e || !t || document.activeElement && document.activeElement !== document.body || t.querySelector(`[data-t-retry="${e}"]`) || (P.value = null, (t.querySelector(`[data-t-remove="${e}"]`) ?? t.querySelector(".t-file-upload__dropzone"))?.focus());
392
+ }, { flush: "post" }), b(() => S.modelValue, K), b(() => S.thumbnails, K), m(() => {
393
+ document.addEventListener("paste", Q), K();
394
+ }), p(() => {
395
+ document.removeEventListener("paste", Q), Ze();
396
+ }), (r, p) => (h(), o("div", d({
187
397
  ref_key: "rootRef",
188
- ref: j
189
- }, fe.value, {
190
- class: ue.value,
191
- style: de.value,
192
- onFocusin: Se,
193
- onFocusout: Ce,
194
- onPaste: Q
398
+ ref: T
399
+ }, Ie.value, {
400
+ class: Pe.value,
401
+ style: Fe.value,
402
+ onFocusin: ot,
403
+ onFocusout: st,
404
+ onPaste: ut
195
405
  }), [
196
- o("input", {
197
- id: g(L),
406
+ s("input", {
407
+ id: ee(I),
198
408
  ref_key: "inputRef",
199
- ref: M,
409
+ ref: E,
200
410
  class: "t-visually-hidden",
201
411
  type: "file",
202
- accept: s.accept || void 0,
203
- multiple: s.multiple,
204
- disabled: V.value,
205
- onChange: be
206
- }, null, 40, x),
207
- o("div", {
412
+ accept: u.accept || void 0,
413
+ multiple: u.multiple,
414
+ disabled: B.value,
415
+ onChange: it
416
+ }, null, 40, ae),
417
+ s("div", {
208
418
  class: "t-file-upload__dropzone",
209
- "aria-busy": s.loading || void 0,
210
- "aria-controls": s.showFileList && H.value ? B : void 0,
211
- "aria-describedby": pe.value,
212
- "aria-disabled": V.value || void 0,
213
- "aria-invalid": s.invalid || void 0,
419
+ "aria-busy": u.loading || void 0,
420
+ "aria-controls": u.showFileList && V.value ? z : void 0,
421
+ "aria-describedby": Le.value,
422
+ "aria-disabled": B.value || void 0,
423
+ "aria-invalid": u.invalid || void 0,
214
424
  role: "button",
215
- tabindex: V.value ? -1 : 0,
216
- onClick: q,
217
- onKeydown: xe,
218
- onDragenter: we,
219
- onDragover: Te,
220
- onDragleave: Ee,
221
- onDrop: De
425
+ tabindex: B.value ? -1 : 0,
426
+ onClick: J,
427
+ onKeydown: at,
428
+ onDragenter: dt,
429
+ onDragover: ft,
430
+ onDragleave: pt,
431
+ onDrop: mt
222
432
  }, [
223
- n.$slots.icon || !n.$slots.default ? (d(), a("div", ee, [m(n.$slots, "icon", {}, () => [l[0] ||= o("span", { class: "t-file-upload__icon-mark" }, "+", -1)])])) : i("", !0),
224
- o("div", te, [m(n.$slots, "default", {
225
- files: s.modelValue,
226
- isDragActive: N.value,
227
- openFileDialog: q,
433
+ r.$slots.icon || !r.$slots.default ? (h(), o("div", se, [v(r.$slots, "icon", {}, () => [p[0] ||= s("span", { class: "t-file-upload__icon-mark" }, "+", -1)])])) : a("", !0),
434
+ s("div", ce, [v(r.$slots, "default", {
435
+ files: u.modelValue,
436
+ isDragActive: D.value,
437
+ isDragReject: O.value,
438
+ openFileDialog: J,
228
439
  clearFiles: X
229
440
  }, () => [
230
- o("p", C, h(s.label), 1),
231
- s.description ? (d(), a("p", {
441
+ s("p", le, y(ze.value), 1),
442
+ u.description ? (h(), o("p", {
232
443
  key: 0,
233
- id: R,
444
+ id: L,
234
445
  class: "t-file-upload__description"
235
- }, h(s.description), 1)) : i("", !0),
236
- o("span", ne, h(s.buttonLabel), 1)
446
+ }, y(u.description), 1)) : a("", !0),
447
+ s("span", ue, y(u.buttonLabel), 1)
237
448
  ])]),
238
- s.loading ? (d(), r(e, {
449
+ u.loading ? (h(), i(e, {
239
450
  key: 1,
240
451
  class: "t-file-upload__spinner",
241
452
  size: "sm",
242
453
  label: "Uploading files"
243
- })) : i("", !0)
244
- ], 40, S),
245
- I.value.length > 0 ? (d(), a("ul", {
454
+ })) : a("", !0)
455
+ ], 40, oe),
456
+ j.value.length > 0 ? (h(), o("ul", {
246
457
  key: 0,
247
- id: z,
458
+ id: R,
248
459
  class: "t-file-upload__feedback",
249
460
  "aria-live": "polite"
250
- }, [(d(!0), a(t, null, p(I.value, (e) => (d(), a("li", { key: e }, h(e), 1))), 128))])) : i("", !0),
251
- s.showFileList && H.value ? (d(), a("div", re, [o("div", ie, [o("p", {
252
- id: B,
461
+ }, [(h(!0), o(n, null, _(j.value, (e) => (h(), o("li", { key: e }, y(e), 1))), 128))])) : a("", !0),
462
+ s("div", de, [(h(!0), o(n, null, _(M.value, (e) => (h(), o("p", {
463
+ key: e.id,
464
+ class: "t-file-upload__status-log-entry"
465
+ }, y(e.text), 1))), 128))]),
466
+ u.showFileList && V.value ? (h(), o("div", fe, [s("div", pe, [s("p", {
467
+ id: z,
253
468
  class: "t-file-upload__files-label"
254
- }, h(me.value), 1), o("button", {
469
+ }, y(Re.value), 1), s("button", {
255
470
  class: "t-file-upload__clear",
256
471
  type: "button",
257
- disabled: V.value,
472
+ disabled: B.value,
258
473
  onClick: X
259
- }, " Clear all ", 8, ae)]), o("ul", oe, [(d(!0), a(t, null, p(s.modelValue, (e, t) => (d(), a("li", {
260
- key: he(e, t),
261
- class: "t-file-upload__file"
262
- }, [m(n.$slots, "file", {
263
- file: e,
264
- index: t,
265
- removeFile: () => Y(t)
266
- }, () => [o("div", se, [o("p", w, h(e.name), 1), o("p", T, h(G(e.size)), 1)]), o("button", {
267
- class: "t-file-upload__remove",
268
- type: "button",
269
- disabled: V.value,
270
- "aria-label": `Remove ${e.name}`,
271
- onClick: (e) => Y(t)
272
- }, " Remove ", 8, E)])]))), 128))])])) : i("", !0),
273
- n.$slots.actions ? (d(), a("div", ce, [m(n.$slots, "actions", {
274
- files: s.modelValue,
275
- openFileDialog: q,
474
+ }, " Clear all ", 8, me)]), s("ul", he, [(h(!0), o(n, null, _(nt.value, (e) => (h(), o("li", {
475
+ key: e.slotProps.fileKey,
476
+ class: f(["t-file-upload__file", e.rowClass]),
477
+ "aria-busy": e.isBusy || void 0
478
+ }, [v(r.$slots, "file", d({ ref_for: !0 }, e.slotProps), () => [
479
+ s("span", _e, [e.slotProps.thumbnailUrl ? (h(), o("img", {
480
+ key: 0,
481
+ class: "t-file-upload__thumb-image",
482
+ src: e.slotProps.thumbnailUrl,
483
+ alt: ""
484
+ }, null, 8, ve)) : (h(), o("span", ye, y(e.slotProps.typeLabel), 1))]),
485
+ s("div", be, [
486
+ s("p", xe, y(e.slotProps.file.name), 1),
487
+ s("p", Se, y(e.metaText), 1),
488
+ v(r.$slots, "file-status", d({ ref_for: !0 }, e.slotProps), () => [
489
+ e.showProgress ? (h(), o("div", Ce, [l(t, {
490
+ size: "sm",
491
+ value: e.progressValue,
492
+ label: e.progressAriaLabel
493
+ }, null, 8, ["value", "label"])])) : a("", !0),
494
+ e.statusText ? (h(), o("p", we, [e.isSuccess ? (h(), o("span", Te, "✓")) : a("", !0), c(y(e.statusText), 1)])) : a("", !0),
495
+ e.errorText ? (h(), o("p", {
496
+ key: 2,
497
+ id: e.errorId,
498
+ class: "t-file-upload__file-error"
499
+ }, y(e.errorText), 9, Ee)) : a("", !0)
500
+ ])
501
+ ]),
502
+ e.slotProps.canRetry ? (h(), o("button", {
503
+ key: 0,
504
+ class: "t-file-upload__retry",
505
+ type: "button",
506
+ "data-t-retry": e.slotProps.fileKey,
507
+ disabled: B.value,
508
+ "aria-describedby": e.errorId,
509
+ onFocus: (t) => ct(e.slotProps.fileKey),
510
+ onBlur: (t) => lt(e.slotProps.fileKey),
511
+ onClick: (t) => e.slotProps.retryFile()
512
+ }, y(e.slotProps.actionLabel), 41, De)) : a("", !0),
513
+ s("button", {
514
+ class: "t-file-upload__remove",
515
+ type: "button",
516
+ "data-t-remove": e.slotProps.fileKey,
517
+ disabled: B.value,
518
+ "aria-label": `Remove ${e.slotProps.file.name}`,
519
+ onClick: (t) => e.slotProps.removeFile()
520
+ }, " Remove ", 8, Oe)
521
+ ])], 10, ge))), 128))])])) : a("", !0),
522
+ r.$slots.actions ? (h(), o("div", ke, [v(r.$slots, "actions", {
523
+ files: u.modelValue,
524
+ openFileDialog: J,
276
525
  clearFiles: X
277
- })])) : i("", !0)
526
+ })])) : a("", !0)
278
527
  ], 16));
279
528
  }
280
529
  });
281
530
  //#endregion
282
- export { D as default };
531
+ export { x as default };
283
532
 
284
533
  //# sourceMappingURL=TFileUpload.vue_vue_type_script_setup_true_lang.js.map