bmi-next-brokers 2.4.1 → 2.4.2
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.
|
@@ -20,6 +20,7 @@ export interface CompactFileUploadProps extends React.InputHTMLAttributes<HTMLIn
|
|
|
20
20
|
onSuccessAction?: () => void;
|
|
21
21
|
onInvalidTypeAction?: () => void;
|
|
22
22
|
maxFileSize?: number;
|
|
23
|
+
onInvalidSizeAction?: () => void;
|
|
23
24
|
onFileSelect?: (files: FileList | null) => void | Promise<void>;
|
|
24
25
|
statusIconBorderRadius?: string;
|
|
25
26
|
customIcon?: IconName;
|
|
@@ -27,4 +28,4 @@ export interface CompactFileUploadProps extends React.InputHTMLAttributes<HTMLIn
|
|
|
27
28
|
fullWidth?: boolean;
|
|
28
29
|
clearFileText?: string;
|
|
29
30
|
}
|
|
30
|
-
export declare const CompactFileUpload: ({ variant, label, error, success, warning, loading, defaultFile, disabled, inverted, browseText, clearFileText, allowedTypes, inspectFileFunction, onInvalidTypeAction, maxFileSize, onFileSelect, onSuccessAction, statusIconBorderRadius, customIcon, customInspectIcon, fullWidth, ...props }: CompactFileUploadProps) => import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
export declare const CompactFileUpload: ({ variant, label, error, success, warning, loading, defaultFile, disabled, inverted, browseText, clearFileText, allowedTypes, inspectFileFunction, onInvalidTypeAction, maxFileSize, onInvalidSizeAction, onFileSelect, onSuccessAction, statusIconBorderRadius, customIcon, customInspectIcon, fullWidth, ...props }: CompactFileUploadProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,147 +1,148 @@
|
|
|
1
|
-
import { jsx as e, jsxs as s, Fragment as
|
|
2
|
-
import { useState as
|
|
1
|
+
import { jsx as e, jsxs as s, Fragment as T } from "react/jsx-runtime";
|
|
2
|
+
import { useState as W, useRef as Z, useEffect as L } from "react";
|
|
3
3
|
import { Icon as h } from "../../icons/Icon.js";
|
|
4
|
-
import { Spinner as
|
|
5
|
-
import { Button as
|
|
6
|
-
import '../../assets/CompactFileUpload.css';const
|
|
7
|
-
inputContainer:
|
|
8
|
-
compactFileUploadContainer:
|
|
9
|
-
fullWidth:
|
|
4
|
+
import { Spinner as z } from "../Spinner/Spinner.js";
|
|
5
|
+
import { Button as j } from "../Button/Button.js";
|
|
6
|
+
import '../../assets/CompactFileUpload.css';const tt = "_inputContainer_4x7bg_1", et = "_compactFileUploadContainer_4x7bg_9", at = "_fullWidth_4x7bg_26", nt = "_dragOver_4x7bg_35", ct = "_variant_document_4x7bg_41", ot = "_icon_4x7bg_41", it = "_variant_add_4x7bg_45", lt = "_disabled_4x7bg_50", st = "_error_4x7bg_61", rt = "_warning_4x7bg_69", mt = "_inverted_4x7bg_78", dt = "_uploadContent_4x7bg_103", pt = "_textContent_4x7bg_113", _t = "_dragText_4x7bg_123", ht = "_hiddenInput_4x7bg_153", ut = "_compactFileContent_4x7bg_166", gt = "_compactFileIcon_4x7bg_174", xt = "_compactIconBackground_4x7bg_182", ft = "_compactFileText_4x7bg_190", bt = "_compactLabel_4x7bg_202", vt = "_compactFileName_4x7bg_209", Ct = "_compactStatusText_4x7bg_210", Nt = "_success_4x7bg_221", Ft = "_loading_4x7bg_229", It = "_addIconWrapper_4x7bg_233", wt = "_browseText_4x7bg_239", Dt = "_compactVisibilityIcon_4x7bg_246", yt = "_compactActions_4x7bg_255", $t = "_deleteText_4x7bg_262", t = {
|
|
7
|
+
inputContainer: tt,
|
|
8
|
+
compactFileUploadContainer: et,
|
|
9
|
+
fullWidth: at,
|
|
10
10
|
dragOver: nt,
|
|
11
|
-
variant_document:
|
|
12
|
-
icon:
|
|
13
|
-
variant_add:
|
|
14
|
-
disabled:
|
|
15
|
-
error:
|
|
16
|
-
warning:
|
|
17
|
-
inverted:
|
|
18
|
-
uploadContent:
|
|
19
|
-
textContent:
|
|
20
|
-
dragText:
|
|
21
|
-
hiddenInput:
|
|
22
|
-
compactFileContent:
|
|
23
|
-
compactFileIcon:
|
|
24
|
-
compactIconBackground:
|
|
25
|
-
compactFileText:
|
|
26
|
-
compactLabel:
|
|
11
|
+
variant_document: ct,
|
|
12
|
+
icon: ot,
|
|
13
|
+
variant_add: it,
|
|
14
|
+
disabled: lt,
|
|
15
|
+
error: st,
|
|
16
|
+
warning: rt,
|
|
17
|
+
inverted: mt,
|
|
18
|
+
uploadContent: dt,
|
|
19
|
+
textContent: pt,
|
|
20
|
+
dragText: _t,
|
|
21
|
+
hiddenInput: ht,
|
|
22
|
+
compactFileContent: ut,
|
|
23
|
+
compactFileIcon: gt,
|
|
24
|
+
compactIconBackground: xt,
|
|
25
|
+
compactFileText: ft,
|
|
26
|
+
compactLabel: bt,
|
|
27
27
|
compactFileName: vt,
|
|
28
|
-
compactStatusText:
|
|
29
|
-
success:
|
|
30
|
-
loading:
|
|
31
|
-
addIconWrapper:
|
|
32
|
-
browseText:
|
|
33
|
-
compactVisibilityIcon:
|
|
34
|
-
compactActions:
|
|
35
|
-
deleteText:
|
|
36
|
-
},
|
|
37
|
-
variant:
|
|
28
|
+
compactStatusText: Ct,
|
|
29
|
+
success: Nt,
|
|
30
|
+
loading: Ft,
|
|
31
|
+
addIconWrapper: It,
|
|
32
|
+
browseText: wt,
|
|
33
|
+
compactVisibilityIcon: Dt,
|
|
34
|
+
compactActions: yt,
|
|
35
|
+
deleteText: $t
|
|
36
|
+
}, Et = ({
|
|
37
|
+
variant: B = "document",
|
|
38
38
|
label: u,
|
|
39
39
|
error: o,
|
|
40
|
-
success:
|
|
40
|
+
success: n,
|
|
41
41
|
warning: g,
|
|
42
42
|
loading: c,
|
|
43
|
-
defaultFile:
|
|
43
|
+
defaultFile: w = null,
|
|
44
44
|
disabled: m = !1,
|
|
45
|
-
inverted:
|
|
46
|
-
browseText:
|
|
45
|
+
inverted: E = !1,
|
|
46
|
+
browseText: O = "Seleccionar archivo",
|
|
47
47
|
clearFileText: x = "Eliminar",
|
|
48
48
|
allowedTypes: d,
|
|
49
|
-
inspectFileFunction:
|
|
49
|
+
inspectFileFunction: R = () => {
|
|
50
50
|
console.warn(
|
|
51
51
|
"No hay función asignada para ver el archivo. Hay que pasarla al componente como prop inspectFileFunction."
|
|
52
52
|
);
|
|
53
53
|
},
|
|
54
54
|
onInvalidTypeAction: f,
|
|
55
|
-
maxFileSize:
|
|
55
|
+
maxFileSize: D,
|
|
56
|
+
onInvalidSizeAction: b,
|
|
56
57
|
onFileSelect: v,
|
|
57
|
-
onSuccessAction:
|
|
58
|
-
statusIconBorderRadius:
|
|
59
|
-
customIcon:
|
|
60
|
-
customInspectIcon:
|
|
61
|
-
fullWidth:
|
|
62
|
-
...
|
|
58
|
+
onSuccessAction: C,
|
|
59
|
+
statusIconBorderRadius: y = "50%",
|
|
60
|
+
customIcon: U = "Documentos",
|
|
61
|
+
customInspectIcon: V = "Visibility",
|
|
62
|
+
fullWidth: M = !1,
|
|
63
|
+
...A
|
|
63
64
|
}) => {
|
|
64
|
-
const [
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}, [
|
|
65
|
+
const [S, N] = W(!1), [i, F] = W(null), _ = Z(null);
|
|
66
|
+
L(() => {
|
|
67
|
+
F(w ?? null);
|
|
68
|
+
}, [w]), L(() => {
|
|
68
69
|
if (!i) return;
|
|
69
|
-
const
|
|
70
|
-
o &&
|
|
71
|
-
`⚠️ CompactFileUpload: Múltiples estados detectados (${
|
|
70
|
+
const a = [];
|
|
71
|
+
o && a.push("error"), n && a.push("success"), c && a.push("loading"), a.length > 1 && console.warn(
|
|
72
|
+
`⚠️ CompactFileUpload: Múltiples estados detectados (${a.join(", ")}). Solo un estado debe estar activo a la vez.`
|
|
72
73
|
);
|
|
73
|
-
}, [o,
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
},
|
|
79
|
-
|
|
80
|
-
},
|
|
81
|
-
if (
|
|
82
|
-
const r =
|
|
83
|
-
|
|
84
|
-
},
|
|
85
|
-
const r =
|
|
86
|
-
|
|
87
|
-
},
|
|
88
|
-
if (!
|
|
74
|
+
}, [o, n, c, i]);
|
|
75
|
+
const q = (a) => {
|
|
76
|
+
a.preventDefault(), m || N(!0);
|
|
77
|
+
}, H = (a) => {
|
|
78
|
+
a.preventDefault(), N(!1);
|
|
79
|
+
}, P = (a) => {
|
|
80
|
+
a.preventDefault();
|
|
81
|
+
}, G = (a) => {
|
|
82
|
+
if (a.preventDefault(), N(!1), m) return;
|
|
83
|
+
const r = a.dataTransfer.files;
|
|
84
|
+
$(r);
|
|
85
|
+
}, J = async (a) => {
|
|
86
|
+
const r = a.target.files;
|
|
87
|
+
$(r);
|
|
88
|
+
}, $ = async (a) => {
|
|
89
|
+
if (!a) return;
|
|
89
90
|
if (d && d.length > 0)
|
|
90
|
-
for (let l = 0; l <
|
|
91
|
-
const p =
|
|
91
|
+
for (let l = 0; l < a.length; l++) {
|
|
92
|
+
const p = a[l];
|
|
92
93
|
if (!d.some(
|
|
93
|
-
(
|
|
94
|
+
(I) => I.startsWith(".") ? p.name.toLowerCase().endsWith(I.toLowerCase()) : p.type === I
|
|
94
95
|
)) {
|
|
95
96
|
f == null || f(), console.warn(`File ${p.name} is not an allowed type`);
|
|
96
97
|
return;
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
|
-
if (
|
|
100
|
-
for (let l = 0; l <
|
|
101
|
-
const p =
|
|
102
|
-
if (p.size >
|
|
103
|
-
console.warn(`File ${p.name} exceeds maximum size`);
|
|
100
|
+
if (D)
|
|
101
|
+
for (let l = 0; l < a.length; l++) {
|
|
102
|
+
const p = a[l];
|
|
103
|
+
if (p.size > D) {
|
|
104
|
+
b == null || b(), console.warn(`File ${p.name} exceeds maximum size`);
|
|
104
105
|
return;
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
|
-
const r =
|
|
108
|
-
|
|
108
|
+
const r = a ? a[0] : null;
|
|
109
|
+
F(r), await (v == null ? void 0 : v(
|
|
109
110
|
r ? (() => {
|
|
110
111
|
const l = new DataTransfer();
|
|
111
112
|
return l.items.add(r), l.files;
|
|
112
113
|
})() : null
|
|
113
114
|
));
|
|
114
|
-
}, G = () => {
|
|
115
|
-
!i && !m && _.current && _.current.click();
|
|
116
|
-
}, $ = () => {
|
|
117
|
-
N(null), _.current && (_.current.value = "");
|
|
118
|
-
}, J = () => {
|
|
119
|
-
$();
|
|
120
115
|
}, K = () => {
|
|
121
|
-
|
|
122
|
-
},
|
|
116
|
+
!i && !m && _.current && _.current.click();
|
|
117
|
+
}, k = () => {
|
|
118
|
+
F(null), _.current && (_.current.value = "");
|
|
119
|
+
}, Q = () => {
|
|
120
|
+
k();
|
|
121
|
+
}, X = () => {
|
|
122
|
+
C == null || C(), k();
|
|
123
|
+
}, Y = [
|
|
123
124
|
t.compactFileUploadContainer,
|
|
124
|
-
|
|
125
|
-
t[`variant_${
|
|
125
|
+
M && t.fullWidth,
|
|
126
|
+
t[`variant_${B}`],
|
|
126
127
|
!i && g ? t.warning : "",
|
|
127
|
-
i && !c && !
|
|
128
|
-
i && !o && !
|
|
129
|
-
i && !o && !c &&
|
|
128
|
+
i && !c && !n && o ? t.error : "",
|
|
129
|
+
i && !o && !n && c ? t.loading : "",
|
|
130
|
+
i && !o && !c && n ? t.success : "",
|
|
130
131
|
m ? t.disabled : "",
|
|
131
|
-
|
|
132
|
-
|
|
132
|
+
E ? t.inverted : "",
|
|
133
|
+
S ? t.dragOver : ""
|
|
133
134
|
].filter(Boolean).join(" ");
|
|
134
135
|
return /* @__PURE__ */ e("div", { className: t.inputContainer, children: /* @__PURE__ */ s(
|
|
135
136
|
"div",
|
|
136
137
|
{
|
|
137
|
-
className:
|
|
138
|
-
onDragEnter:
|
|
139
|
-
onDragLeave:
|
|
140
|
-
onDragOver:
|
|
141
|
-
onDrop:
|
|
142
|
-
onClick:
|
|
138
|
+
className: Y,
|
|
139
|
+
onDragEnter: q,
|
|
140
|
+
onDragLeave: H,
|
|
141
|
+
onDragOver: P,
|
|
142
|
+
onDrop: G,
|
|
143
|
+
onClick: K,
|
|
143
144
|
style: { cursor: m ? "not-allowed" : "pointer" },
|
|
144
|
-
...
|
|
145
|
+
...A,
|
|
145
146
|
children: [
|
|
146
147
|
/* @__PURE__ */ e(
|
|
147
148
|
"input",
|
|
@@ -149,7 +150,7 @@ import '../../assets/CompactFileUpload.css';const Z = "_inputContainer_4x7bg_1",
|
|
|
149
150
|
ref: _,
|
|
150
151
|
type: "file",
|
|
151
152
|
className: t.hiddenInput,
|
|
152
|
-
onChange:
|
|
153
|
+
onChange: J,
|
|
153
154
|
disabled: m,
|
|
154
155
|
accept: d == null ? void 0 : d.join(",")
|
|
155
156
|
}
|
|
@@ -162,8 +163,8 @@ import '../../assets/CompactFileUpload.css';const Z = "_inputContainer_4x7bg_1",
|
|
|
162
163
|
{
|
|
163
164
|
className: t.compactIconBackground,
|
|
164
165
|
style: {
|
|
165
|
-
background: o && !c ? "#DC2626" : c ? "#2054A5" :
|
|
166
|
-
borderRadius:
|
|
166
|
+
background: o && !c ? "#DC2626" : c ? "#2054A5" : n ? "#65A30D" : "#2054A5",
|
|
167
|
+
borderRadius: y
|
|
167
168
|
},
|
|
168
169
|
children: c ? /* @__PURE__ */ e(
|
|
169
170
|
"div",
|
|
@@ -175,7 +176,7 @@ import '../../assets/CompactFileUpload.css';const Z = "_inputContainer_4x7bg_1",
|
|
|
175
176
|
margin: "4px"
|
|
176
177
|
},
|
|
177
178
|
children: /* @__PURE__ */ e(
|
|
178
|
-
|
|
179
|
+
z,
|
|
179
180
|
{
|
|
180
181
|
size: 10,
|
|
181
182
|
color: "primary",
|
|
@@ -196,7 +197,7 @@ import '../../assets/CompactFileUpload.css';const Z = "_inputContainer_4x7bg_1",
|
|
|
196
197
|
children: /* @__PURE__ */ e(
|
|
197
198
|
h,
|
|
198
199
|
{
|
|
199
|
-
name: o ? "CancelIcon" :
|
|
200
|
+
name: o ? "CancelIcon" : n ? "CheckIcon" : U,
|
|
200
201
|
fill: "white",
|
|
201
202
|
height: 20,
|
|
202
203
|
width: 20
|
|
@@ -207,37 +208,37 @@ import '../../assets/CompactFileUpload.css';const Z = "_inputContainer_4x7bg_1",
|
|
|
207
208
|
}
|
|
208
209
|
) }),
|
|
209
210
|
/* @__PURE__ */ s("div", { className: t.compactFileText, children: [
|
|
210
|
-
!o && !c && !
|
|
211
|
+
!o && !c && !n && /* @__PURE__ */ s(T, { children: [
|
|
211
212
|
u && /* @__PURE__ */ e("span", { className: `small1Medium ${t.compactLabel}`, children: u }),
|
|
212
213
|
/* @__PURE__ */ e("span", { className: `small3Regular ${t.compactFileName}`, children: i == null ? void 0 : i.name })
|
|
213
214
|
] }),
|
|
214
|
-
(o || c ||
|
|
215
|
+
(o || c || n) && /* @__PURE__ */ e(
|
|
215
216
|
"span",
|
|
216
217
|
{
|
|
217
218
|
className: `
|
|
218
219
|
small1Medium
|
|
219
220
|
${t.compactFileName}
|
|
220
221
|
${o && t.error}
|
|
221
|
-
${
|
|
222
|
+
${n && t.success}
|
|
222
223
|
${c && t.loading}
|
|
223
224
|
`,
|
|
224
225
|
children: i == null ? void 0 : i.name
|
|
225
226
|
}
|
|
226
227
|
),
|
|
227
228
|
o && /* @__PURE__ */ e("span", { className: `small3Regular ${t.compactStatusText}`, children: o }),
|
|
228
|
-
|
|
229
|
+
n && !c && /* @__PURE__ */ e("span", { className: `small3Regular ${t.compactStatusText}`, children: n }),
|
|
229
230
|
c && /* @__PURE__ */ e("span", { className: `small3Regular ${t.compactStatusText}`, children: c })
|
|
230
231
|
] }),
|
|
231
232
|
/* @__PURE__ */ s("div", { className: t.compactActions, children: [
|
|
232
|
-
!o && !c && !
|
|
233
|
+
!o && !c && !n && /* @__PURE__ */ e(
|
|
233
234
|
"div",
|
|
234
235
|
{
|
|
235
236
|
className: t.compactVisibilityIcon,
|
|
236
|
-
onClick:
|
|
237
|
+
onClick: R,
|
|
237
238
|
children: /* @__PURE__ */ e(
|
|
238
239
|
h,
|
|
239
240
|
{
|
|
240
|
-
name:
|
|
241
|
+
name: V,
|
|
241
242
|
fill: "#2054A5",
|
|
242
243
|
height: 24,
|
|
243
244
|
width: 24
|
|
@@ -245,16 +246,16 @@ import '../../assets/CompactFileUpload.css';const Z = "_inputContainer_4x7bg_1",
|
|
|
245
246
|
)
|
|
246
247
|
}
|
|
247
248
|
),
|
|
248
|
-
(o ||
|
|
249
|
-
|
|
249
|
+
(o || n) && /* @__PURE__ */ e(
|
|
250
|
+
j,
|
|
250
251
|
{
|
|
251
252
|
variant: x ? "outline" : "ghost",
|
|
252
253
|
icon: {
|
|
253
254
|
name: "CancelIcon",
|
|
254
255
|
position: "before"
|
|
255
256
|
},
|
|
256
|
-
onClick: (
|
|
257
|
-
|
|
257
|
+
onClick: (a) => {
|
|
258
|
+
a.stopPropagation(), n ? X() : Q();
|
|
258
259
|
},
|
|
259
260
|
children: x || ""
|
|
260
261
|
}
|
|
@@ -268,7 +269,7 @@ import '../../assets/CompactFileUpload.css';const Z = "_inputContainer_4x7bg_1",
|
|
|
268
269
|
className: t.compactIconBackground,
|
|
269
270
|
style: {
|
|
270
271
|
background: "#EA580C",
|
|
271
|
-
borderRadius:
|
|
272
|
+
borderRadius: y
|
|
272
273
|
},
|
|
273
274
|
children: /* @__PURE__ */ e(
|
|
274
275
|
"div",
|
|
@@ -302,7 +303,7 @@ import '../../assets/CompactFileUpload.css';const Z = "_inputContainer_4x7bg_1",
|
|
|
302
303
|
/* @__PURE__ */ e("span", { className: `small3Regular ${t.compactStatusText}`, children: g })
|
|
303
304
|
] }),
|
|
304
305
|
/* @__PURE__ */ e("div", { className: t.compactActions, children: /* @__PURE__ */ e(
|
|
305
|
-
|
|
306
|
+
j,
|
|
306
307
|
{
|
|
307
308
|
variant: "outline",
|
|
308
309
|
icon: {
|
|
@@ -312,7 +313,7 @@ import '../../assets/CompactFileUpload.css';const Z = "_inputContainer_4x7bg_1",
|
|
|
312
313
|
children: "Subir doc"
|
|
313
314
|
}
|
|
314
315
|
) })
|
|
315
|
-
] }) : /* @__PURE__ */ e(
|
|
316
|
+
] }) : /* @__PURE__ */ e(T, { children: /* @__PURE__ */ s("div", { className: t.textContent, children: [
|
|
316
317
|
/* @__PURE__ */ e(
|
|
317
318
|
"div",
|
|
318
319
|
{
|
|
@@ -323,12 +324,12 @@ import '../../assets/CompactFileUpload.css';const Z = "_inputContainer_4x7bg_1",
|
|
|
323
324
|
children: /* @__PURE__ */ e("div", { style: { marginTop: "3px" }, children: /* @__PURE__ */ e(h, { name: "Add", fill: "white", height: 27, width: 27 }) })
|
|
324
325
|
}
|
|
325
326
|
),
|
|
326
|
-
/* @__PURE__ */ e("span", { className: `small1Medium ${t.browseText}`, children:
|
|
327
|
+
/* @__PURE__ */ e("span", { className: `small1Medium ${t.browseText}`, children: O })
|
|
327
328
|
] }) }) })
|
|
328
329
|
]
|
|
329
330
|
}
|
|
330
331
|
) });
|
|
331
332
|
};
|
|
332
333
|
export {
|
|
333
|
-
|
|
334
|
+
Et as CompactFileUpload
|
|
334
335
|
};
|
|
@@ -16,7 +16,8 @@ export interface FileUploadProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
|
16
16
|
inspectFileFunction?: () => void;
|
|
17
17
|
onInvalidTypeAction?: () => void;
|
|
18
18
|
maxFileSize?: number;
|
|
19
|
+
onInvalidSizeAction?: () => void;
|
|
19
20
|
onFileSelect?: (files: FileList | null) => void;
|
|
20
21
|
fullWidth?: boolean;
|
|
21
22
|
}
|
|
22
|
-
export declare const FileUpload: ({ variant, helperText, error, success, loading, disabled, defaultFile, inverted, dragText, browseText, allowedTypes, inspectFileFunction, onInvalidTypeAction, maxFileSize, onFileSelect, fullWidth, style, }: FileUploadProps) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare const FileUpload: ({ variant, helperText, error, success, loading, disabled, defaultFile, inverted, dragText, browseText, allowedTypes, inspectFileFunction, onInvalidTypeAction, maxFileSize, onInvalidSizeAction, onFileSelect, fullWidth, style, }: FileUploadProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,186 +1,187 @@
|
|
|
1
|
-
import { jsx as t, jsxs as v, Fragment as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { Button as
|
|
1
|
+
import { jsx as t, jsxs as v, Fragment as S } from "react/jsx-runtime";
|
|
2
|
+
import { useState as g, useRef as A, useEffect as T } from "react";
|
|
3
|
+
import { Button as W } from "../Button/Button.js";
|
|
4
4
|
import { Icon as u } from "../../icons/Icon.js";
|
|
5
|
-
import { Spinner as
|
|
6
|
-
import '../../assets/FileUpload.css';const
|
|
7
|
-
inputContainer:
|
|
8
|
-
fullWidth:
|
|
9
|
-
label:
|
|
10
|
-
label_large:
|
|
11
|
-
label_disabled:
|
|
12
|
-
label_inverted:
|
|
13
|
-
label_inverted_disabled:
|
|
14
|
-
required:
|
|
15
|
-
required_disabled:
|
|
16
|
-
required_inverted:
|
|
17
|
-
required_inverted_disabled:
|
|
18
|
-
fileUploadContainer:
|
|
5
|
+
import { Spinner as G } from "../Spinner/Spinner.js";
|
|
6
|
+
import '../../assets/FileUpload.css';const J = "_inputContainer_1vae9_1", K = "_fullWidth_1vae9_9", Q = "_label_1vae9_13", X = "_label_large_1vae9_21", Y = "_label_disabled_1vae9_26", ee = "_label_inverted_1vae9_30", ne = "_label_inverted_disabled_1vae9_34", te = "_required_1vae9_38", ie = "_required_disabled_1vae9_43", ae = "_required_inverted_1vae9_47", le = "_required_inverted_disabled_1vae9_51", se = "_fileUploadContainer_1vae9_55", oe = "_iconContainerLeft_1vae9_69", ce = "_iconContainerRight_1vae9_77", re = "_dragOver_1vae9_89", _e = "_variant_document_1vae9_105", de = "_icon_1vae9_69", ve = "_variant_add_1vae9_109", ue = "_disabled_1vae9_114", fe = "_error_1vae9_125", he = "_success_1vae9_134", pe = "_loading_1vae9_142", me = "_inverted_1vae9_151", Fe = "_uploadContent_1vae9_177", Ce = "_selectedFileContent_1vae9_189", ge = "_withoutError_1vae9_199", Ie = "_selectedFileName_1vae9_203", be = "_selectedFileSize_1vae9_211", xe = "_removeButton_1vae9_218", we = "_textContent_1vae9_278", Ne = "_dragText_1vae9_288", De = "_browseText_1vae9_292", Ee = "_hiddenInput_1vae9_329", Se = "_selectedFilesContainer_1vae9_342", Te = "_selectedFilesHeader_1vae9_350", We = "_selectedFilesText_1vae9_357", Le = "_clearButton_1vae9_363", qe = "_filesList_1vae9_384", Ue = "_fileItem_1vae9_390", Be = "_fileName_1vae9_402", $e = "_fileSize_1vae9_413", Oe = "_bigZIndex_1vae9_454", ke = "_cancelIconWrapper_1vae9_458", ze = "_fadeInSlideDown_1vae9_1", Re = "_selectedFileInfo_1vae9_474", He = "_fadeInSlideUp_1vae9_1", je = "_successIconWrapper_1vae9_488", Me = "_loadingIconWrapper_1vae9_504", Ve = "_fadeIn_1vae9_1", Ze = "_withSuccess_1vae9_528", Pe = "_withLoading_1vae9_542", ye = "_errorText_1vae9_556", Ae = "_successText_1vae9_572", Ge = "_inlineFileContainer_1vae9_634", Je = "_inlineFileIcon_1vae9_643", Ke = "_inlineFileInfo_1vae9_670", Qe = "_inlineFileName_1vae9_678", Xe = "_inlineErrorText_1vae9_687", Ye = "_inlineSuccessText_1vae9_693", en = "_inlineFileActions_1vae9_699", nn = "_inlineActionIcon_1vae9_706", tn = "_fadeInSlideUpCentered_1vae9_1", e = {
|
|
7
|
+
inputContainer: J,
|
|
8
|
+
fullWidth: K,
|
|
9
|
+
label: Q,
|
|
10
|
+
label_large: X,
|
|
11
|
+
label_disabled: Y,
|
|
12
|
+
label_inverted: ee,
|
|
13
|
+
label_inverted_disabled: ne,
|
|
14
|
+
required: te,
|
|
15
|
+
required_disabled: ie,
|
|
16
|
+
required_inverted: ae,
|
|
17
|
+
required_inverted_disabled: le,
|
|
18
|
+
fileUploadContainer: se,
|
|
19
19
|
iconContainerLeft: oe,
|
|
20
|
-
iconContainerRight:
|
|
21
|
-
dragOver:
|
|
22
|
-
variant_document:
|
|
23
|
-
icon:
|
|
24
|
-
variant_add:
|
|
25
|
-
disabled:
|
|
26
|
-
error:
|
|
27
|
-
success:
|
|
28
|
-
loading:
|
|
29
|
-
inverted:
|
|
30
|
-
uploadContent:
|
|
31
|
-
selectedFileContent:
|
|
32
|
-
withoutError:
|
|
33
|
-
selectedFileName:
|
|
34
|
-
selectedFileSize:
|
|
35
|
-
removeButton:
|
|
36
|
-
textContent:
|
|
37
|
-
dragText:
|
|
38
|
-
browseText:
|
|
39
|
-
hiddenInput:
|
|
40
|
-
selectedFilesContainer:
|
|
41
|
-
selectedFilesHeader:
|
|
42
|
-
selectedFilesText:
|
|
43
|
-
clearButton:
|
|
44
|
-
filesList:
|
|
45
|
-
fileItem:
|
|
46
|
-
fileName:
|
|
47
|
-
fileSize:
|
|
48
|
-
bigZIndex:
|
|
49
|
-
cancelIconWrapper:
|
|
50
|
-
fadeInSlideDown:
|
|
51
|
-
selectedFileInfo:
|
|
52
|
-
fadeInSlideUp:
|
|
53
|
-
successIconWrapper:
|
|
54
|
-
loadingIconWrapper:
|
|
55
|
-
fadeIn:
|
|
56
|
-
withSuccess:
|
|
57
|
-
withLoading:
|
|
58
|
-
errorText:
|
|
59
|
-
successText:
|
|
60
|
-
inlineFileContainer:
|
|
61
|
-
inlineFileIcon:
|
|
20
|
+
iconContainerRight: ce,
|
|
21
|
+
dragOver: re,
|
|
22
|
+
variant_document: _e,
|
|
23
|
+
icon: de,
|
|
24
|
+
variant_add: ve,
|
|
25
|
+
disabled: ue,
|
|
26
|
+
error: fe,
|
|
27
|
+
success: he,
|
|
28
|
+
loading: pe,
|
|
29
|
+
inverted: me,
|
|
30
|
+
uploadContent: Fe,
|
|
31
|
+
selectedFileContent: Ce,
|
|
32
|
+
withoutError: ge,
|
|
33
|
+
selectedFileName: Ie,
|
|
34
|
+
selectedFileSize: be,
|
|
35
|
+
removeButton: xe,
|
|
36
|
+
textContent: we,
|
|
37
|
+
dragText: Ne,
|
|
38
|
+
browseText: De,
|
|
39
|
+
hiddenInput: Ee,
|
|
40
|
+
selectedFilesContainer: Se,
|
|
41
|
+
selectedFilesHeader: Te,
|
|
42
|
+
selectedFilesText: We,
|
|
43
|
+
clearButton: Le,
|
|
44
|
+
filesList: qe,
|
|
45
|
+
fileItem: Ue,
|
|
46
|
+
fileName: Be,
|
|
47
|
+
fileSize: $e,
|
|
48
|
+
bigZIndex: Oe,
|
|
49
|
+
cancelIconWrapper: ke,
|
|
50
|
+
fadeInSlideDown: ze,
|
|
51
|
+
selectedFileInfo: Re,
|
|
52
|
+
fadeInSlideUp: He,
|
|
53
|
+
successIconWrapper: je,
|
|
54
|
+
loadingIconWrapper: Me,
|
|
55
|
+
fadeIn: Ve,
|
|
56
|
+
withSuccess: Ze,
|
|
57
|
+
withLoading: Pe,
|
|
58
|
+
errorText: ye,
|
|
59
|
+
successText: Ae,
|
|
60
|
+
inlineFileContainer: Ge,
|
|
61
|
+
inlineFileIcon: Je,
|
|
62
62
|
default: "_default_1vae9_666",
|
|
63
|
-
inlineFileInfo:
|
|
64
|
-
inlineFileName:
|
|
65
|
-
inlineErrorText:
|
|
66
|
-
inlineSuccessText:
|
|
67
|
-
inlineFileActions:
|
|
68
|
-
inlineActionIcon:
|
|
69
|
-
fadeInSlideUpCentered:
|
|
70
|
-
},
|
|
71
|
-
variant:
|
|
72
|
-
helperText:
|
|
63
|
+
inlineFileInfo: Ke,
|
|
64
|
+
inlineFileName: Qe,
|
|
65
|
+
inlineErrorText: Xe,
|
|
66
|
+
inlineSuccessText: Ye,
|
|
67
|
+
inlineFileActions: en,
|
|
68
|
+
inlineActionIcon: nn,
|
|
69
|
+
fadeInSlideUpCentered: tn
|
|
70
|
+
}, _n = ({
|
|
71
|
+
variant: L = "document",
|
|
72
|
+
helperText: q,
|
|
73
73
|
error: a,
|
|
74
|
-
success:
|
|
74
|
+
success: o,
|
|
75
75
|
loading: l = !1,
|
|
76
76
|
disabled: r = !1,
|
|
77
|
-
defaultFile:
|
|
78
|
-
inverted:
|
|
79
|
-
dragText:
|
|
80
|
-
browseText:
|
|
77
|
+
defaultFile: I = null,
|
|
78
|
+
inverted: U = !1,
|
|
79
|
+
dragText: B,
|
|
80
|
+
browseText: $ = "Seleccionar archivo",
|
|
81
81
|
allowedTypes: _,
|
|
82
|
-
inspectFileFunction:
|
|
82
|
+
inspectFileFunction: O = () => {
|
|
83
83
|
console.warn(
|
|
84
84
|
"No hay función asignada para ver el archivo. Hay que pasarla al componente como prop inspectFileFunction."
|
|
85
85
|
);
|
|
86
86
|
},
|
|
87
87
|
onInvalidTypeAction: f,
|
|
88
|
-
maxFileSize:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
maxFileSize: b,
|
|
89
|
+
onInvalidSizeAction: h,
|
|
90
|
+
onFileSelect: p,
|
|
91
|
+
fullWidth: x = !1,
|
|
92
|
+
style: k
|
|
92
93
|
}) => {
|
|
93
|
-
const [
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}, [
|
|
94
|
+
const [z, m] = g(!1), [i, w] = g(null), [N, D] = g(!1), F = A(null);
|
|
95
|
+
T(() => {
|
|
96
|
+
w(I ?? null);
|
|
97
|
+
}, [I]), T(() => {
|
|
97
98
|
if (!i) return;
|
|
98
99
|
const n = [];
|
|
99
|
-
a && n.push("error"),
|
|
100
|
+
a && n.push("error"), o && n.push("success"), l && n.push("loading"), n.length > 1 && console.warn(
|
|
100
101
|
`⚠️ FileUpload: Múltiples estados detectados (${n.join(", ")}). Solo un estado debe estar activo a la vez.`
|
|
101
102
|
);
|
|
102
|
-
}, [a,
|
|
103
|
-
const
|
|
104
|
-
n.preventDefault(), r ||
|
|
105
|
-
}, H = (n) => {
|
|
106
|
-
n.preventDefault(), p(!1);
|
|
103
|
+
}, [a, o, l, i]);
|
|
104
|
+
const R = q, H = (n) => {
|
|
105
|
+
n.preventDefault(), r || m(!0);
|
|
107
106
|
}, j = (n) => {
|
|
107
|
+
n.preventDefault(), m(!1);
|
|
108
|
+
}, M = (n) => {
|
|
108
109
|
n.preventDefault();
|
|
109
|
-
},
|
|
110
|
-
if (n.preventDefault(),
|
|
110
|
+
}, V = (n) => {
|
|
111
|
+
if (n.preventDefault(), m(!1), r) return;
|
|
111
112
|
const c = n.dataTransfer.files;
|
|
112
|
-
|
|
113
|
-
},
|
|
113
|
+
E(c);
|
|
114
|
+
}, Z = (n) => {
|
|
114
115
|
const c = n.target.files;
|
|
115
|
-
|
|
116
|
-
},
|
|
116
|
+
E(c);
|
|
117
|
+
}, E = (n) => {
|
|
117
118
|
if (!n) return;
|
|
118
119
|
if (_ && _.length > 0)
|
|
119
|
-
for (let
|
|
120
|
-
const d = n[
|
|
120
|
+
for (let s = 0; s < n.length; s++) {
|
|
121
|
+
const d = n[s];
|
|
121
122
|
if (!_.some(
|
|
122
|
-
(
|
|
123
|
+
(C) => C.startsWith(".") ? d.name.toLowerCase().endsWith(C.toLowerCase()) : d.type === C
|
|
123
124
|
)) {
|
|
124
125
|
f == null || f(), console.warn(`File ${d.name} is not an allowed type`);
|
|
125
126
|
return;
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
|
-
if (
|
|
129
|
-
for (let
|
|
130
|
-
const d = n[
|
|
131
|
-
if (d.size >
|
|
132
|
-
console.warn(`File ${d.name} exceeds maximum size`);
|
|
129
|
+
if (b)
|
|
130
|
+
for (let s = 0; s < n.length; s++) {
|
|
131
|
+
const d = n[s];
|
|
132
|
+
if (d.size > b) {
|
|
133
|
+
h == null || h(), console.warn(`File ${d.name} exceeds maximum size`);
|
|
133
134
|
return;
|
|
134
135
|
}
|
|
135
136
|
}
|
|
136
137
|
const c = n ? n[0] : null;
|
|
137
|
-
|
|
138
|
+
w(c), p == null || p(
|
|
138
139
|
c ? (() => {
|
|
139
|
-
const
|
|
140
|
-
return
|
|
140
|
+
const s = new DataTransfer();
|
|
141
|
+
return s.items.add(c), s.files;
|
|
141
142
|
})() : null
|
|
142
143
|
);
|
|
143
|
-
},
|
|
144
|
-
!r &&
|
|
145
|
-
},
|
|
144
|
+
}, P = () => {
|
|
145
|
+
!r && F.current && F.current.click();
|
|
146
|
+
}, y = [
|
|
146
147
|
e.fileUploadContainer,
|
|
147
|
-
|
|
148
|
-
e[`variant_${
|
|
148
|
+
x && e.fullWidth,
|
|
149
|
+
e[`variant_${L}`],
|
|
149
150
|
i && a ? e.error : "",
|
|
150
151
|
i && !a && l ? e.loading : "",
|
|
151
|
-
i && !a && !l &&
|
|
152
|
+
i && !a && !l && o ? e.success : "",
|
|
152
153
|
r ? e.disabled : "",
|
|
153
|
-
|
|
154
|
-
|
|
154
|
+
U ? e.inverted : "",
|
|
155
|
+
z ? e.dragOver : ""
|
|
155
156
|
].filter(Boolean).join(" ");
|
|
156
157
|
return /* @__PURE__ */ t(
|
|
157
158
|
"div",
|
|
158
159
|
{
|
|
159
|
-
className: `${e.inputContainer} ${
|
|
160
|
+
className: `${e.inputContainer} ${x ? e.fullWidth : ""}`,
|
|
160
161
|
children: /* @__PURE__ */ v(
|
|
161
162
|
"div",
|
|
162
163
|
{
|
|
163
|
-
className:
|
|
164
|
-
onDragEnter:
|
|
165
|
-
onDragLeave:
|
|
166
|
-
onDragOver:
|
|
167
|
-
onDrop:
|
|
168
|
-
onClick:
|
|
169
|
-
style: { cursor: r ? "not-allowed" : "pointer",
|
|
164
|
+
className: y,
|
|
165
|
+
onDragEnter: H,
|
|
166
|
+
onDragLeave: j,
|
|
167
|
+
onDragOver: M,
|
|
168
|
+
onDrop: V,
|
|
169
|
+
onClick: P,
|
|
170
|
+
style: { cursor: r ? "not-allowed" : "pointer", ...k },
|
|
170
171
|
onMouseEnter: () => {
|
|
171
|
-
|
|
172
|
+
D(!0);
|
|
172
173
|
},
|
|
173
174
|
onMouseLeave: () => {
|
|
174
|
-
|
|
175
|
+
D(!1);
|
|
175
176
|
},
|
|
176
177
|
children: [
|
|
177
178
|
/* @__PURE__ */ t(
|
|
178
179
|
"input",
|
|
179
180
|
{
|
|
180
|
-
ref:
|
|
181
|
+
ref: F,
|
|
181
182
|
type: "file",
|
|
182
183
|
className: e.hiddenInput,
|
|
183
|
-
onChange:
|
|
184
|
+
onChange: Z,
|
|
184
185
|
disabled: r,
|
|
185
186
|
accept: _ == null ? void 0 : _.join(",")
|
|
186
187
|
}
|
|
@@ -188,7 +189,7 @@ import '../../assets/FileUpload.css';const G = "_inputContainer_1vae9_1", J = "_
|
|
|
188
189
|
/* @__PURE__ */ v("div", { className: e.uploadContent, children: [
|
|
189
190
|
i && a && /* @__PURE__ */ t("div", { className: e.cancelIconWrapper, children: /* @__PURE__ */ t(u, { name: "CancelIcon", fill: "white", height: 30, width: 30 }) }),
|
|
190
191
|
i && !a && l && /* @__PURE__ */ t("div", { className: e.loadingIconWrapper, children: /* @__PURE__ */ t(
|
|
191
|
-
|
|
192
|
+
G,
|
|
192
193
|
{
|
|
193
194
|
size: 10,
|
|
194
195
|
color: "primary",
|
|
@@ -197,21 +198,21 @@ import '../../assets/FileUpload.css';const G = "_inputContainer_1vae9_1", J = "_
|
|
|
197
198
|
thickness: 3
|
|
198
199
|
}
|
|
199
200
|
) }),
|
|
200
|
-
i && !a && !l &&
|
|
201
|
+
i && !a && !l && o && /* @__PURE__ */ t("div", { className: e.successIconWrapper, children: /* @__PURE__ */ t(u, { name: "CheckIcon", fill: "white", height: 30, width: 30 }) }),
|
|
201
202
|
i ? (
|
|
202
203
|
// Default layout - full vertical layout
|
|
203
204
|
/* @__PURE__ */ v(
|
|
204
205
|
"div",
|
|
205
206
|
{
|
|
206
|
-
className: `${e.selectedFileContent} ${i && a ? e.withError : i && l ? e.withLoading : i &&
|
|
207
|
+
className: `${e.selectedFileContent} ${i && a ? e.withError : i && l ? e.withLoading : i && o ? e.withSuccess : e.withoutError}`,
|
|
207
208
|
children: [
|
|
208
209
|
/* @__PURE__ */ t("div", { className: e.selectedFileInfo, children: /* @__PURE__ */ v("span", { className: `bodyMedium ${e.selectedFileName}`, children: [
|
|
209
210
|
l && "Subiendo ",
|
|
210
211
|
i.name
|
|
211
212
|
] }) }),
|
|
212
|
-
i && a ? /* @__PURE__ */ t("p", { className: e.errorText, children: a }) : i && !l &&
|
|
213
|
-
i && !a && !l && !
|
|
214
|
-
|
|
213
|
+
i && a ? /* @__PURE__ */ t("p", { className: e.errorText, children: a }) : i && !l && o ? /* @__PURE__ */ t("p", { className: e.successText, children: o }) : null,
|
|
214
|
+
i && !a && !l && !o && /* @__PURE__ */ t(
|
|
215
|
+
W,
|
|
215
216
|
{
|
|
216
217
|
className: e.bigZIndex,
|
|
217
218
|
icon: {
|
|
@@ -219,7 +220,7 @@ import '../../assets/FileUpload.css';const G = "_inputContainer_1vae9_1", J = "_
|
|
|
219
220
|
position: "before"
|
|
220
221
|
},
|
|
221
222
|
onClick: (n) => {
|
|
222
|
-
n.stopPropagation(),
|
|
223
|
+
n.stopPropagation(), O();
|
|
223
224
|
},
|
|
224
225
|
size: "small",
|
|
225
226
|
children: "Ver archivo"
|
|
@@ -228,29 +229,29 @@ import '../../assets/FileUpload.css';const G = "_inputContainer_1vae9_1", J = "_
|
|
|
228
229
|
]
|
|
229
230
|
}
|
|
230
231
|
)
|
|
231
|
-
) : /* @__PURE__ */ t(
|
|
232
|
-
/* @__PURE__ */ t("span", { className: `bodyRegular ${e.dragText}`, children:
|
|
232
|
+
) : /* @__PURE__ */ t(S, { children: /* @__PURE__ */ v("div", { className: e.textContent, children: [
|
|
233
|
+
/* @__PURE__ */ t("span", { className: `bodyRegular ${e.dragText}`, children: B || R }),
|
|
233
234
|
/* @__PURE__ */ t(
|
|
234
|
-
|
|
235
|
+
W,
|
|
235
236
|
{
|
|
236
237
|
size: "small",
|
|
237
238
|
icon: {
|
|
238
239
|
name: "DownloadIcon",
|
|
239
240
|
position: "before"
|
|
240
241
|
},
|
|
241
|
-
children:
|
|
242
|
+
children: $
|
|
242
243
|
}
|
|
243
244
|
)
|
|
244
245
|
] }) })
|
|
245
246
|
] }),
|
|
246
|
-
/* @__PURE__ */ v(
|
|
247
|
+
/* @__PURE__ */ v(S, { children: [
|
|
247
248
|
/* @__PURE__ */ t("div", { className: e.iconContainerLeft, children: /* @__PURE__ */ t(
|
|
248
249
|
u,
|
|
249
250
|
{
|
|
250
251
|
name: "Documentos",
|
|
251
252
|
height: 140,
|
|
252
253
|
width: 140,
|
|
253
|
-
fill: i && a ? "#FEF2F2" :
|
|
254
|
+
fill: i && a ? "#FEF2F2" : N ? "#C4D5F1" : "#E0E9F8"
|
|
254
255
|
}
|
|
255
256
|
) }),
|
|
256
257
|
/* @__PURE__ */ t("div", { className: e.iconContainerRight, children: /* @__PURE__ */ t(
|
|
@@ -259,7 +260,7 @@ import '../../assets/FileUpload.css';const G = "_inputContainer_1vae9_1", J = "_
|
|
|
259
260
|
name: "Documentos",
|
|
260
261
|
height: 140,
|
|
261
262
|
width: 140,
|
|
262
|
-
fill: i && a ? "#FEF2F2" :
|
|
263
|
+
fill: i && a ? "#FEF2F2" : N ? "#C4D5F1" : "#E0E9F8"
|
|
263
264
|
}
|
|
264
265
|
) })
|
|
265
266
|
] })
|
|
@@ -270,5 +271,5 @@ import '../../assets/FileUpload.css';const G = "_inputContainer_1vae9_1", J = "_
|
|
|
270
271
|
);
|
|
271
272
|
};
|
|
272
273
|
export {
|
|
273
|
-
|
|
274
|
+
_n as FileUpload
|
|
274
275
|
};
|
package/package.json
CHANGED