@studiolxd/brand 43.0.0 → 44.0.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.
- package/CHANGELOG.md +60 -0
- package/dist/_shared/imagecropdialog.js +124 -123
- package/dist/_shared/validate.js +31 -5
- package/dist/_types/atoms/FileUpload/FileUpload.d.ts +79 -11
- package/dist/_types/atoms/FileUpload/validate.d.ts +36 -3
- package/dist/_types/messages/BrandMessages.d.ts +7 -1
- package/dist/_types/messages/index.d.ts +1 -1
- package/dist/_types/molecules/AvatarUpload/AvatarUpload.d.ts +123 -25
- package/dist/_types/molecules/CalendarPlanner/CalendarPlanner.d.ts +5 -4
- package/dist/_types/molecules/CalendarRoster/CalendarRoster.d.ts +5 -4
- package/dist/_types/molecules/ImageCropDialog/ImageCropDialog.d.ts +28 -4
- package/dist/avatar-upload.js +98 -95
- package/dist/calendar-planner.js +47 -46
- package/dist/calendar-roster.js +62 -61
- package/dist/file-upload.js +120 -117
- package/package.json +1 -1
package/dist/file-upload.js
CHANGED
|
@@ -1,194 +1,197 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import './file-upload.css';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { n } from "./
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
3
|
+
import { n as e } from "./_shared/brandmessagescontext.js";
|
|
4
|
+
import { Icon as t } from "./icon.js";
|
|
5
|
+
import { VisuallyHidden as n } from "./visually-hidden.js";
|
|
6
|
+
import { n as r } from "./_shared/form-size.js";
|
|
7
|
+
import { t as i } from "./_shared/progressbar.js";
|
|
8
|
+
import { i as a, n as o, t as s } from "./_shared/validate.js";
|
|
9
|
+
import { forwardRef as c, useCallback as l, useEffect as u, useId as d, useRef as f, useState as p } from "react";
|
|
10
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
10
11
|
//#region src/stories/atoms/FileUpload/FileUpload.tsx
|
|
11
|
-
var
|
|
12
|
-
function
|
|
12
|
+
var g = /* @__PURE__ */ new WeakMap();
|
|
13
|
+
function ee(e) {
|
|
13
14
|
if (!e.type.startsWith("image/")) return;
|
|
14
|
-
let t =
|
|
15
|
-
return t || (t = URL.createObjectURL(e),
|
|
15
|
+
let t = g.get(e);
|
|
16
|
+
return t || (t = URL.createObjectURL(e), g.set(e, t)), t;
|
|
16
17
|
}
|
|
17
|
-
function
|
|
18
|
-
let t =
|
|
19
|
-
t && (URL.revokeObjectURL(t),
|
|
18
|
+
function _(e) {
|
|
19
|
+
let t = g.get(e);
|
|
20
|
+
t && (URL.revokeObjectURL(t), g.delete(e));
|
|
20
21
|
}
|
|
21
|
-
function
|
|
22
|
+
function v(e, t) {
|
|
22
23
|
typeof e == "function" ? e(t) : e && (e.current = t);
|
|
23
24
|
}
|
|
24
|
-
var
|
|
25
|
-
let
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}, [
|
|
29
|
-
let e =
|
|
25
|
+
var y = c(function({ multiple: c = !1, accept: g, maxSize: y, maxFiles: b, value: x, defaultValue: S = [], onChange: C, progress: w, disabled: T = !1, error: E = !1, id: D, name: te, describedBy: ne, ariaLabel: re, "aria-describedby": ie, "aria-label": ae, required: oe, onBlur: se, className: ce, locale: O = s, dropzoneLabel: le, dropzoneActiveLabel: ue, dropzoneHintLabel: de, maxSizeHint: fe, maxFilesHint: pe, filesLabel: me, progressLabel: he, removeFileLabel: k, tooLargeError: A, invalidTypeError: j, size: M }, N) {
|
|
26
|
+
let P = e("fileUpload"), F = r(M), I = F === "sm" ? "sm" : F === "lg" ? "lg" : "md", L = x !== void 0, [R, z] = p(S), [B, V] = p(/* @__PURE__ */ new Map()), [H, U] = p(!1), W = f(/* @__PURE__ */ new Set()), G = f(null), ge = d(), K = D ?? `file-upload-${ge}`, q = L ? x : R;
|
|
27
|
+
u(() => {
|
|
28
|
+
q.forEach((e) => W.current.add(e));
|
|
29
|
+
}, [q]), u(() => {
|
|
30
|
+
let e = W.current;
|
|
30
31
|
return () => {
|
|
31
|
-
e.forEach(
|
|
32
|
+
e.forEach(_);
|
|
32
33
|
};
|
|
33
34
|
}, []);
|
|
34
|
-
let
|
|
35
|
-
if (
|
|
36
|
-
let t = Array.from(e), n =
|
|
35
|
+
let J = l((e) => {
|
|
36
|
+
if (T) return;
|
|
37
|
+
let t = Array.from(e), n = L ? x ?? [] : R, r = new Map(B), i = [...n];
|
|
37
38
|
for (let e of t) {
|
|
38
|
-
if (
|
|
39
|
-
let t =
|
|
40
|
-
t && r.set(e, t),
|
|
39
|
+
if (b !== void 0 && i.filter((e) => !r.has(e)).length >= b) break;
|
|
40
|
+
let t = a(e, g, y, P("tooLarge", A), P("invalidType", j), O);
|
|
41
|
+
t && r.set(e, t), i.push(e);
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
+
V(r), L || z(i), C?.(i.filter((e) => !r.has(e)));
|
|
43
44
|
}, [
|
|
44
|
-
|
|
45
|
-
p,
|
|
45
|
+
T,
|
|
46
46
|
g,
|
|
47
|
-
|
|
48
|
-
z,
|
|
49
|
-
v,
|
|
50
|
-
B,
|
|
51
|
-
H,
|
|
47
|
+
y,
|
|
52
48
|
b,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
L,
|
|
50
|
+
x,
|
|
51
|
+
R,
|
|
52
|
+
B,
|
|
53
|
+
C,
|
|
54
|
+
P,
|
|
55
|
+
A,
|
|
56
|
+
j,
|
|
57
|
+
O
|
|
58
|
+
]), _e = l((e) => {
|
|
59
|
+
let t = (L ? x ?? [] : R).filter((t) => t !== e), n = new Map(B);
|
|
60
|
+
n.delete(e), _(e), V(n), L || z(t), C?.(t.filter((e) => !n.has(e))), G.current && (G.current.value = "");
|
|
58
61
|
}, [
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
L,
|
|
63
|
+
x,
|
|
64
|
+
R,
|
|
61
65
|
B,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}, ge = [
|
|
66
|
+
C
|
|
67
|
+
]), ve = (e) => {
|
|
68
|
+
e.target.files && J(e.target.files);
|
|
69
|
+
}, ye = (e) => {
|
|
70
|
+
e.preventDefault(), T || U(!0);
|
|
71
|
+
}, be = (e) => {
|
|
72
|
+
e.preventDefault(), U(!1);
|
|
73
|
+
}, Y = (e) => {
|
|
74
|
+
e.preventDefault(), U(!1), !T && e.dataTransfer.files && J(e.dataTransfer.files);
|
|
75
|
+
}, xe = () => {
|
|
76
|
+
T || G.current?.click();
|
|
77
|
+
}, Se = [
|
|
75
78
|
"file-upload",
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
].filter(Boolean).join(" "),
|
|
83
|
-
return
|
|
84
|
-
className:
|
|
79
|
+
F === "md" ? "" : `file-upload--${F}`,
|
|
80
|
+
H ? "file-upload--dragging" : "",
|
|
81
|
+
E ? "file-upload--error" : "",
|
|
82
|
+
T ? "file-upload--disabled" : "",
|
|
83
|
+
q.length > 0 ? "file-upload--has-files" : "",
|
|
84
|
+
ce ?? ""
|
|
85
|
+
].filter(Boolean).join(" "), X = `${K}-hint`, Ce = [ne ?? ie, X].filter(Boolean).join(" "), Z = P("dropzone", le), Q = P("dropzoneHint", de), $ = [];
|
|
86
|
+
return g && $.push(g), y && $.push(P("maxSize", fe)(o(y, O))), c && b && $.push(P("maxFiles", pe)(b)), /* @__PURE__ */ h("div", {
|
|
87
|
+
className: Se,
|
|
85
88
|
children: [
|
|
86
|
-
/* @__PURE__ */
|
|
89
|
+
/* @__PURE__ */ m(n, { children: /* @__PURE__ */ m("input", {
|
|
87
90
|
ref: (e) => {
|
|
88
|
-
|
|
91
|
+
G.current = e, v(N, e);
|
|
89
92
|
},
|
|
90
93
|
type: "file",
|
|
91
|
-
id:
|
|
92
|
-
name:
|
|
93
|
-
multiple:
|
|
94
|
-
accept:
|
|
95
|
-
disabled:
|
|
96
|
-
required:
|
|
97
|
-
"aria-label":
|
|
98
|
-
"aria-describedby":
|
|
99
|
-
"aria-invalid":
|
|
100
|
-
onChange:
|
|
101
|
-
onBlur:
|
|
94
|
+
id: K,
|
|
95
|
+
name: te,
|
|
96
|
+
multiple: c,
|
|
97
|
+
accept: g,
|
|
98
|
+
disabled: T,
|
|
99
|
+
required: oe,
|
|
100
|
+
"aria-label": re ?? ae,
|
|
101
|
+
"aria-describedby": Ce,
|
|
102
|
+
"aria-invalid": E || void 0,
|
|
103
|
+
onChange: ve,
|
|
104
|
+
onBlur: se
|
|
102
105
|
}) }),
|
|
103
|
-
/* @__PURE__ */
|
|
106
|
+
/* @__PURE__ */ h("div", {
|
|
104
107
|
className: "file-upload__dropzone",
|
|
105
|
-
onClick:
|
|
106
|
-
onDragOver:
|
|
107
|
-
onDragLeave:
|
|
108
|
-
onDrop:
|
|
108
|
+
onClick: xe,
|
|
109
|
+
onDragOver: ye,
|
|
110
|
+
onDragLeave: be,
|
|
111
|
+
onDrop: Y,
|
|
109
112
|
"aria-hidden": "true",
|
|
110
113
|
children: [
|
|
111
|
-
/* @__PURE__ */
|
|
114
|
+
/* @__PURE__ */ m(t, {
|
|
112
115
|
name: "upload",
|
|
113
|
-
size:
|
|
116
|
+
size: I,
|
|
114
117
|
className: "file-upload__icon"
|
|
115
118
|
}),
|
|
116
|
-
/* @__PURE__ */
|
|
119
|
+
/* @__PURE__ */ m("span", {
|
|
117
120
|
className: "file-upload__text",
|
|
118
|
-
children:
|
|
121
|
+
children: H ? P("dropzoneActive", ue) : Z
|
|
119
122
|
}),
|
|
120
|
-
/* @__PURE__ */
|
|
123
|
+
/* @__PURE__ */ m("span", {
|
|
121
124
|
className: "file-upload__text file-upload__text--secondary",
|
|
122
|
-
children:
|
|
125
|
+
children: Q
|
|
123
126
|
}),
|
|
124
|
-
$.length > 0 && /* @__PURE__ */
|
|
127
|
+
$.length > 0 && /* @__PURE__ */ m("span", {
|
|
125
128
|
className: "file-upload__subtext",
|
|
126
129
|
children: $.join(" · ")
|
|
127
130
|
})
|
|
128
131
|
]
|
|
129
132
|
}),
|
|
130
|
-
/* @__PURE__ */
|
|
131
|
-
id:
|
|
133
|
+
/* @__PURE__ */ m(n, {
|
|
134
|
+
id: X,
|
|
132
135
|
children: [
|
|
133
|
-
|
|
134
|
-
|
|
136
|
+
Z,
|
|
137
|
+
Q,
|
|
135
138
|
...$
|
|
136
139
|
].join(". ")
|
|
137
140
|
}),
|
|
138
|
-
|
|
141
|
+
q.length > 0 && /* @__PURE__ */ m("ul", {
|
|
139
142
|
className: "file-upload__list",
|
|
140
|
-
"aria-label":
|
|
141
|
-
children:
|
|
142
|
-
let r =
|
|
143
|
-
return /* @__PURE__ */
|
|
143
|
+
"aria-label": P("files", me),
|
|
144
|
+
children: q.map((e, n) => {
|
|
145
|
+
let r = B.get(e), i = ee(e);
|
|
146
|
+
return /* @__PURE__ */ h("li", {
|
|
144
147
|
className: `file-upload__item${r ? " file-upload__item--error" : ""}`,
|
|
145
148
|
children: [
|
|
146
|
-
/* @__PURE__ */
|
|
149
|
+
/* @__PURE__ */ m("div", {
|
|
147
150
|
className: "file-upload__item-thumb",
|
|
148
151
|
"aria-hidden": "true",
|
|
149
|
-
children: i ? /* @__PURE__ */
|
|
152
|
+
children: i ? /* @__PURE__ */ m("img", {
|
|
150
153
|
src: i,
|
|
151
154
|
alt: ""
|
|
152
|
-
}) : /* @__PURE__ */
|
|
155
|
+
}) : /* @__PURE__ */ m(t, {
|
|
153
156
|
name: "file-text",
|
|
154
157
|
size: "sm"
|
|
155
158
|
})
|
|
156
159
|
}),
|
|
157
|
-
/* @__PURE__ */
|
|
160
|
+
/* @__PURE__ */ h("div", {
|
|
158
161
|
className: "file-upload__item-info",
|
|
159
162
|
children: [
|
|
160
|
-
/* @__PURE__ */
|
|
163
|
+
/* @__PURE__ */ m("span", {
|
|
161
164
|
className: "file-upload__item-name",
|
|
162
|
-
children:
|
|
165
|
+
children: e.name
|
|
163
166
|
}),
|
|
164
|
-
/* @__PURE__ */
|
|
167
|
+
/* @__PURE__ */ m("span", {
|
|
165
168
|
className: "file-upload__item-size",
|
|
166
|
-
children:
|
|
169
|
+
children: o(e.size, O)
|
|
167
170
|
}),
|
|
168
|
-
r && /* @__PURE__ */
|
|
171
|
+
r && /* @__PURE__ */ m("span", {
|
|
169
172
|
className: "file-upload__item-error-msg",
|
|
170
173
|
role: "alert",
|
|
171
174
|
children: r
|
|
172
175
|
})
|
|
173
176
|
]
|
|
174
177
|
}),
|
|
175
|
-
/* @__PURE__ */
|
|
178
|
+
/* @__PURE__ */ m("button", {
|
|
176
179
|
className: "file-upload__item-remove",
|
|
177
180
|
type: "button",
|
|
178
|
-
onClick: () =>
|
|
179
|
-
"aria-label":
|
|
180
|
-
children: /* @__PURE__ */
|
|
181
|
+
onClick: () => _e(e),
|
|
182
|
+
"aria-label": P("removeFile", k)(e.name),
|
|
183
|
+
children: /* @__PURE__ */ m(t, {
|
|
181
184
|
name: "close",
|
|
182
185
|
size: "sm"
|
|
183
186
|
})
|
|
184
187
|
})
|
|
185
188
|
]
|
|
186
|
-
}, `${
|
|
189
|
+
}, `${e.name}-${e.size}-${n}`);
|
|
187
190
|
})
|
|
188
191
|
}),
|
|
189
|
-
|
|
190
|
-
value:
|
|
191
|
-
label:
|
|
192
|
+
w !== void 0 && /* @__PURE__ */ m(i, {
|
|
193
|
+
value: w,
|
|
194
|
+
label: P("progress", he),
|
|
192
195
|
size: "sm",
|
|
193
196
|
className: "file-upload__progress"
|
|
194
197
|
})
|
|
@@ -196,4 +199,4 @@ var g = o(function({ multiple: o = !1, accept: p, maxSize: g, maxFiles: _, value
|
|
|
196
199
|
});
|
|
197
200
|
});
|
|
198
201
|
//#endregion
|
|
199
|
-
export {
|
|
202
|
+
export { y as FileUpload };
|