@nubisco/ui 5.25.2 → 5.26.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.
@@ -1,162 +0,0 @@
1
- import { t as e } from "./_plugin-vue_export-helper-O4QQSku4.js";
2
- import { t } from "./Icon-rREAqsu0.js";
3
- import { useSurfaceLayer as n } from "./composables/useSurfaceLayer.composable.mjs";
4
- import { t as r } from "./Button-IcCXOoCT.js";
5
- import { Fragment as i, createBlock as a, createCommentVNode as o, createElementBlock as s, createElementVNode as c, createTextVNode as l, createVNode as u, defineComponent as d, mergeProps as f, normalizeClass as p, openBlock as m, ref as h, renderList as g, toDisplayString as _, unref as v, withCtx as y, withModifiers as b } from "vue";
6
- import { regular as x } from "@nubisco/ui/icons/x";
7
- import { regular as S } from "@nubisco/ui/icons/circle-notch";
8
- //#region src/types/Variants.d.ts
9
- var C = /* @__PURE__ */ function(e) {
10
- return e.Primary = "primary", e.Secondary = "secondary", e.Ghost = "ghost", e.Danger = "danger", e.Success = "success", e.Warning = "warning", e;
11
- }(C || {}), w = /* @__PURE__ */ function(e) {
12
- return e.Idle = "idle", e.Loading = "loading", e.Success = "success", e;
13
- }(w || {}), T = {
14
- key: 0,
15
- class: "nb-file-uploader__heading"
16
- }, E = {
17
- key: 1,
18
- class: "nb-file-uploader__description"
19
- }, D = ["accept", "multiple"], O = {
20
- key: 4,
21
- class: "nb-file-uploader__list"
22
- }, k = { class: "nb-file-uploader__name" }, A = { class: "nb-file-uploader__status" }, j = ["aria-label", "onClick"], M = {
23
- key: 0,
24
- class: "nb-file-uploader__error"
25
- }, N = /* @__PURE__ */ e(/* @__PURE__ */ d({
26
- __name: "FileUploader",
27
- props: {
28
- heading: {},
29
- description: {},
30
- buttonLabel: { default: "Add file" },
31
- variant: { default: C.Primary },
32
- accept: {},
33
- multiple: {
34
- type: Boolean,
35
- default: !1
36
- },
37
- maxSize: {},
38
- disabled: { type: Boolean },
39
- id: {}
40
- },
41
- emits: ["change", "remove"],
42
- setup(e, { expose: d, emit: C }) {
43
- let N = e, { layerProps: P } = n(), F = C, I = h(null), L = h([]), R = h(!1), z = 0;
44
- function B() {
45
- I.value?.click();
46
- }
47
- function V(e) {
48
- if (N.maxSize && e.size > N.maxSize) return "File exceeds size limit.";
49
- if (N.accept) {
50
- let t = N.accept.split(",").map((e) => e.trim().toLowerCase()), n = e.name.toLowerCase();
51
- if (!t.some((t) => t.startsWith(".") ? n.endsWith(t) : t.includes("/") ? e.type === t || e.type.startsWith(t.replaceAll("*", "")) : !1)) return "File type not accepted.";
52
- }
53
- }
54
- function H(e) {
55
- let t = Array.from(e);
56
- N.multiple || (L.value = []);
57
- for (let e of t) {
58
- let t = V(e);
59
- L.value.push({
60
- file: e,
61
- status: w.Idle,
62
- error: t
63
- });
64
- }
65
- F("change", L.value.filter((e) => !e.error).map((e) => e.file));
66
- }
67
- function U(e) {
68
- let t = e.target;
69
- t.files?.length && (H(t.files), t.value = "");
70
- }
71
- function W() {
72
- z++, R.value = !0;
73
- }
74
- function G() {
75
- z--, z <= 0 && (z = 0, R.value = !1);
76
- }
77
- function K(e) {
78
- z = 0, R.value = !1;
79
- let t = e.dataTransfer?.files;
80
- t?.length && H(t);
81
- }
82
- function q(e) {
83
- let t = L.value[e];
84
- L.value.splice(e, 1), F("remove", t.file), F("change", L.value.filter((e) => !e.error).map((e) => e.file));
85
- }
86
- function J(e, t, n) {
87
- L.value[e] && (L.value[e].status = t, L.value[e].error = n);
88
- }
89
- return d({
90
- files: L,
91
- setFileStatus: J
92
- }), (n, d) => (m(), s("div", f({ class: "nb-file-uploader" }, v(P), {
93
- onDragenter: b(W, ["prevent"]),
94
- onDragover: d[0] ||= b(() => {}, ["prevent"]),
95
- onDragleave: b(G, ["prevent"]),
96
- onDrop: b(K, ["prevent"])
97
- }), [
98
- e.heading ? (m(), s("p", T, _(e.heading), 1)) : o("", !0),
99
- e.description ? (m(), s("p", E, _(e.description), 1)) : o("", !0),
100
- R.value ? (m(), s("div", {
101
- key: 2,
102
- class: p(["nb-file-uploader__dropzone", `nb-file-uploader__dropzone--${e.variant}`])
103
- }, [...d[1] ||= [c("span", { class: "nb-file-uploader__drop-label" }, [
104
- l(" Drag and drop files here"),
105
- c("br"),
106
- l("or click to upload ")
107
- ], -1)]], 2)) : (m(), a(r, {
108
- key: 3,
109
- class: "nb-file-uploader__btn",
110
- variant: e.variant,
111
- onClick: b(B, ["stop"])
112
- }, {
113
- default: y(() => [l(_(e.buttonLabel), 1)]),
114
- _: 1
115
- }, 8, ["variant"])),
116
- c("input", {
117
- ref_key: "inputRef",
118
- ref: I,
119
- type: "file",
120
- class: "nb-file-uploader__input",
121
- accept: e.accept,
122
- multiple: e.multiple,
123
- onChange: U
124
- }, null, 40, D),
125
- L.value.length ? (m(), s("ul", O, [(m(!0), s(i, null, g(L.value, (e, n) => (m(), s("li", {
126
- key: n,
127
- class: p(["nb-file-uploader__item", {
128
- "nb-file-uploader__item--error": e.error,
129
- "nb-file-uploader__item--success": e.status === "success"
130
- }])
131
- }, [
132
- c("span", k, _(e.file.name), 1),
133
- c("span", A, [
134
- e.status === "loading" ? (m(), a(t, {
135
- key: 0,
136
- name: v(S),
137
- class: "nb-file-uploader__spinner"
138
- }, null, 8, ["name"])) : e.status === "success" ? (m(), a(t, {
139
- key: 1,
140
- name: "check-circle-fill",
141
- class: "nb-file-uploader__check"
142
- })) : o("", !0),
143
- e.error ? (m(), a(t, {
144
- key: 2,
145
- name: "warning-circle-fill",
146
- class: "nb-file-uploader__warn"
147
- })) : o("", !0),
148
- e.status === "loading" ? o("", !0) : (m(), s("button", {
149
- key: 3,
150
- class: "nb-file-uploader__remove",
151
- type: "button",
152
- "aria-label": `Remove ${e.file.name}`,
153
- onClick: (e) => q(n)
154
- }, [u(t, { name: v(x) }, null, 8, ["name"])], 8, j))
155
- ]),
156
- e.error ? (m(), s("div", M, _(e.error), 1)) : o("", !0)
157
- ], 2))), 128))])) : o("", !0)
158
- ], 16));
159
- }
160
- }), [["__scopeId", "data-v-7f391a7f"]]);
161
- //#endregion
162
- export { N as t };