@reportportal/ui-kit 0.0.1-alpha.102 → 0.0.1-alpha.103

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,4 +1,4 @@
1
- import { A as a } from "./index-e27a72a8.js";
1
+ import { A as a } from "./index-803576c3.js";
2
2
  import "react/jsx-runtime";
3
3
  import "react";
4
4
  import "./bind-06a7ff84.js";
@@ -9,6 +9,7 @@ export interface AttachmentFile {
9
9
  isUploadFailed?: boolean;
10
10
  isUploading?: boolean;
11
11
  validationErrors?: FileValidationError[];
12
+ customErrorMessage?: string;
12
13
  }
13
14
  interface AttachedFilesListProps {
14
15
  files: AttachmentFile[];
@@ -5,9 +5,9 @@ interface FileProcessingOptions extends FileValidationOptions {
5
5
  onFilesAdded: (files: FileWithValidation[]) => void;
6
6
  }
7
7
  export declare const useFileProcessing: ({ maxFileSize, acceptFileMimeTypes, onFilesAdded, }: FileProcessingOptions) => {
8
- onDrop: (acceptedFiles: File[]) => void;
9
- handleFileInputChange: (event: ChangeEvent<HTMLInputElement>) => void;
10
8
  error: ValidationError | null;
9
+ handleFileInputChange: (event: ChangeEvent<HTMLInputElement>) => void;
11
10
  clearError: () => void;
11
+ onDrop: (acceptedFiles: File[]) => void;
12
12
  };
13
13
  export {};
@@ -49,6 +49,7 @@ export interface FileValidationOptions {
49
49
  export interface FileWithValidation {
50
50
  file: File;
51
51
  validationErrors: FileValidationError[];
52
+ customErrorMessage?: string;
52
53
  }
53
54
  export interface FileDropAreaBaseConfig extends FileValidationOptions {
54
55
  messages: FileValidationMessages;
@@ -1,3 +1,3 @@
1
1
  import { FileValidationError, FileValidationMessages } from '../types';
2
2
 
3
- export declare const getValidationErrorMessage: (errors: FileValidationError[], messages: FileValidationMessages) => string | null;
3
+ export declare const getValidationErrorMessage: (errors: FileValidationError[], messages: FileValidationMessages, customErrorMessage?: string) => string | null;
@@ -1,47 +1,47 @@
1
1
  import { jsx as f, jsxs as F } from "react/jsx-runtime";
2
- import { c as h } from "./bind-06a7ff84.js";
3
- import { useState as C, useCallback as d, useRef as A, createContext as L, useMemo as z, useContext as M } from "react";
4
- import { g as k, A as B } from "./index-e27a72a8.js";
5
- import { B as S } from "./button-97d9e587.js";
2
+ import { c as E } from "./bind-06a7ff84.js";
3
+ import { useState as C, useCallback as d, useRef as A, createContext as L, useMemo as z, useContext as M, useEffect as k } from "react";
4
+ import { g as B, A as S } from "./index-803576c3.js";
5
+ import { B as P } from "./button-97d9e587.js";
6
6
  import w from "react-dropzone";
7
7
  import "./close-4d480ef7.js";
8
8
  import "./xls-995781cc.js";
9
- function P(e) {
9
+ function Z(e) {
10
10
  return Number.isSafeInteger(e) && e >= 0;
11
11
  }
12
12
  function U(e) {
13
- return e != null && typeof e != "function" && P(e.length);
14
- }
15
- function Z(e) {
16
- return e == null ? e === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(e);
13
+ return e != null && typeof e != "function" && Z(e.length);
17
14
  }
18
15
  function V(e) {
19
- return ArrayBuffer.isView(e) && !(e instanceof DataView);
16
+ return e == null ? e === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(e);
20
17
  }
21
18
  function $(e) {
22
- return e !== null && typeof e == "object" && Z(e) === "[object Arguments]";
19
+ return ArrayBuffer.isView(e) && !(e instanceof DataView);
23
20
  }
24
21
  function W(e) {
22
+ return e !== null && typeof e == "object" && V(e) === "[object Arguments]";
23
+ }
24
+ function X(e) {
25
25
  const r = e == null ? void 0 : e.constructor, t = typeof r == "function" ? r.prototype : Object.prototype;
26
26
  return e === t;
27
27
  }
28
- function X(e) {
29
- return V(e);
28
+ function q(e) {
29
+ return $(e);
30
30
  }
31
- function E(e) {
31
+ function g(e) {
32
32
  if (e == null)
33
33
  return !0;
34
34
  if (U(e))
35
- return typeof e.splice != "function" && typeof e != "string" && (typeof Buffer > "u" || !Buffer.isBuffer(e)) && !X(e) && !$(e) ? !1 : e.length === 0;
35
+ return typeof e.splice != "function" && typeof e != "string" && (typeof Buffer > "u" || !Buffer.isBuffer(e)) && !q(e) && !W(e) ? !1 : e.length === 0;
36
36
  if (typeof e == "object") {
37
37
  if (e instanceof Map || e instanceof Set)
38
38
  return e.size === 0;
39
39
  const r = Object.keys(e);
40
- return W(e) ? r.filter((t) => t !== "constructor").length === 0 : r.length === 0;
40
+ return X(e) ? r.filter((t) => t !== "constructor").length === 0 : r.length === 0;
41
41
  }
42
42
  return !0;
43
43
  }
44
- const me = {
44
+ const ge = {
45
45
  png: "image/png",
46
46
  jpeg: "image/jpeg",
47
47
  gif: "image/gif",
@@ -76,111 +76,111 @@ const me = {
76
76
  gtar: "application/x-gtar",
77
77
  kml: "application/vnd.google-earth.kml+xml"
78
78
  };
79
- var g = /* @__PURE__ */ ((e) => (e.INCORRECT_FILE_SIZE = "INCORRECT_FILE_SIZE", e.INCORRECT_FILE_FORMAT = "INCORRECT_FILE_FORMAT", e))(g || {});
80
- const q = (e, r) => {
81
- const { maxFileSize: t, acceptFileMimeTypes: i = [] } = r, n = [];
82
- if (t && e.size > t && n.push(g.INCORRECT_FILE_SIZE), !E(i)) {
83
- const s = k(e.name);
84
- i.some(
85
- (o) => o.startsWith(".") ? s === o.slice(1) : e.type === o
86
- ) || n.push(g.INCORRECT_FILE_FORMAT);
79
+ var h = /* @__PURE__ */ ((e) => (e.INCORRECT_FILE_SIZE = "INCORRECT_FILE_SIZE", e.INCORRECT_FILE_FORMAT = "INCORRECT_FILE_FORMAT", e))(h || {});
80
+ const Y = (e, r) => {
81
+ const { maxFileSize: t, acceptFileMimeTypes: o = [] } = r, a = [];
82
+ if (t && e.size > t && a.push(h.INCORRECT_FILE_SIZE), !g(o)) {
83
+ const s = B(e.name);
84
+ o.some(
85
+ (c) => c.startsWith(".") ? s === c.slice(1) : e.type === c
86
+ ) || a.push(h.INCORRECT_FILE_FORMAT);
87
87
  }
88
- return n;
89
- }, I = (e, r) => E(e) ? null : {
90
- [g.INCORRECT_FILE_SIZE]: r.incorrectFileSize,
91
- [g.INCORRECT_FILE_FORMAT]: r.incorrectFileFormat
92
- }[e[0]], Y = 128, b = Y * 1024 * 1024, G = ({
88
+ return a;
89
+ }, I = (e, r, t) => t || (g(e) ? null : {
90
+ [h.INCORRECT_FILE_SIZE]: r.incorrectFileSize,
91
+ [h.INCORRECT_FILE_FORMAT]: r.incorrectFileFormat
92
+ }[e[0]]), G = 128, b = G * 1024 * 1024, H = ({
93
93
  maxFileSize: e = b,
94
94
  acceptFileMimeTypes: r = [],
95
95
  onFilesAdded: t
96
96
  }) => {
97
- const [i, n] = C(null), s = d(
98
- (a) => {
99
- n(null);
100
- const p = a.map((u) => ({
101
- file: u,
102
- validationErrors: q(u, { maxFileSize: e, acceptFileMimeTypes: r })
97
+ const [o, a] = C(null), s = d(
98
+ (i) => {
99
+ a(null);
100
+ const p = i.map((_) => ({
101
+ file: _,
102
+ validationErrors: Y(_, { maxFileSize: e, acceptFileMimeTypes: r })
103
103
  }));
104
104
  t(p);
105
105
  const m = p.find(
106
- ({ validationErrors: u }) => !E(u)
106
+ ({ validationErrors: _ }) => !g(_)
107
107
  );
108
- m && n(m.validationErrors[0]);
108
+ m && a(m.validationErrors[0]);
109
109
  },
110
110
  [e, r, t]
111
111
  ), l = d(
112
- (a) => {
113
- s(a);
112
+ (i) => {
113
+ s(i);
114
114
  },
115
115
  [s]
116
- ), o = d(
117
- (a) => {
118
- const { files: p } = a.currentTarget;
119
- p && s([...p]), a.currentTarget.value = "";
116
+ ), c = d(
117
+ (i) => {
118
+ const { files: p } = i.currentTarget;
119
+ p && s([...p]), i.currentTarget.value = "";
120
120
  },
121
121
  [s]
122
- ), c = d(() => {
123
- n(null);
122
+ ), n = d(() => {
123
+ a(null);
124
124
  }, []);
125
125
  return {
126
- onDrop: l,
127
- handleFileInputChange: o,
128
- error: i,
129
- clearError: c
126
+ error: o,
127
+ handleFileInputChange: c,
128
+ clearError: n,
129
+ onDrop: l
130
130
  };
131
- }, H = ({
131
+ }, J = ({
132
132
  maxFileSize: e = b,
133
133
  acceptFileMimeTypes: r = [],
134
134
  onFilesAdded: t
135
135
  }) => {
136
- const { onDrop: i, handleFileInputChange: n, error: s, clearError: l } = G({
136
+ const { onDrop: o, handleFileInputChange: a, error: s, clearError: l } = H({
137
137
  maxFileSize: e,
138
138
  acceptFileMimeTypes: r,
139
139
  onFilesAdded: t
140
- }), o = d(() => {
140
+ }), c = d(() => {
141
141
  l();
142
142
  }, [l]);
143
143
  return {
144
144
  error: s,
145
- onDrop: i,
146
- handleDropzoneClick: o,
147
- handleFileInputChange: n,
145
+ onDrop: o,
146
+ handleDropzoneClick: c,
147
+ handleFileInputChange: a,
148
148
  clearError: l
149
149
  };
150
- }, J = ({ isOverlay: e = !1 }) => {
151
- const [r, t] = C(!1), i = A(null), n = d((a) => {
150
+ }, K = ({ isOverlay: e = !1 }) => {
151
+ const [r, t] = C(!1), o = A(null), a = d((i) => {
152
152
  var p;
153
- a.preventDefault(), (p = a.dataTransfer) != null && p.types.includes("Files") && t(!0);
154
- }, []), s = d((a) => {
155
- a.preventDefault(), i.current && !i.current.contains(a.relatedTarget) && t(!1);
156
- }, []), l = d((a) => {
157
- a.preventDefault();
158
- }, []), o = d((a) => {
159
- a.preventDefault(), t(!1);
153
+ i.preventDefault(), (p = i.dataTransfer) != null && p.types.includes("Files") && t(!0);
154
+ }, []), s = d((i) => {
155
+ i.preventDefault(), o.current && !o.current.contains(i.relatedTarget) && t(!1);
156
+ }, []), l = d((i) => {
157
+ i.preventDefault();
158
+ }, []), c = d((i) => {
159
+ i.preventDefault(), t(!1);
160
160
  }, []);
161
161
  return {
162
162
  handlers: e ? {
163
- ref: i,
164
- onDragEnter: n,
163
+ ref: o,
164
+ onDragEnter: a,
165
165
  onDragLeave: s,
166
166
  onDragOver: l,
167
- onDrop: o
167
+ onDrop: c
168
168
  } : {},
169
169
  ...e && { isDragActive: r }
170
170
  };
171
171
  }, y = L(null);
172
172
  y.displayName = "FileDropAreaContext";
173
- const K = ({
173
+ const Q = ({
174
174
  children: e,
175
175
  ...r
176
176
  }) => {
177
- const t = A(null), i = d((l) => {
177
+ const t = A(null), o = d((l) => {
178
178
  t.current = l;
179
- }, []), n = d(() => {
179
+ }, []), a = d(() => {
180
180
  r.isDisabled || !t.current || (r.clearError(), t.current());
181
181
  }, [r]), s = z(
182
- () => ({ ...r, registerOpenFunction: i, openFileDialog: n }),
183
- [r, i, n]
182
+ () => ({ ...r, registerOpenFunction: o, openFileDialog: a }),
183
+ [r, o, a]
184
184
  );
185
185
  return /* @__PURE__ */ f(y.Provider, { value: s, children: e });
186
186
  }, v = () => {
@@ -188,166 +188,171 @@ const K = ({
188
188
  if (!e)
189
189
  throw new Error("useFileDropAreaContext must be used within a FileDropAreaProvider");
190
190
  return e;
191
- }, Q = ({
191
+ }, ee = ({
192
192
  children: e,
193
193
  className: r,
194
194
  variant: t = "text",
195
- ...i
195
+ ...o
196
196
  }) => {
197
- const { openFileDialog: n, isDisabled: s } = v();
197
+ const { openFileDialog: a, isDisabled: s } = v();
198
198
  return /* @__PURE__ */ f(
199
- S,
199
+ P,
200
200
  {
201
- ...i,
201
+ ...o,
202
202
  variant: t,
203
203
  adjustWidthOn: "content",
204
204
  disabled: s,
205
205
  className: r,
206
- onClick: (o) => {
207
- o.stopPropagation(), n();
206
+ onClick: (c) => {
207
+ c.stopPropagation(), a();
208
208
  },
209
209
  children: e
210
210
  }
211
211
  );
212
212
  }, D = {
213
- "file-drop-area": "_file-drop-area_1fufl_16",
214
- "file-drop-area--active": "_file-drop-area--active_1fufl_27",
215
- "file-drop-area--disabled": "_file-drop-area--disabled_1fufl_31",
216
- "file-drop-area--error": "_file-drop-area--error_1fufl_35",
217
- "file-drop-area__content": "_file-drop-area__content_1fufl_38",
218
- "file-drop-area__icon": "_file-drop-area__icon_1fufl_45",
219
- "file-drop-area__text": "_file-drop-area__text_1fufl_53",
220
- "file-drop-area__description": "_file-drop-area__description_1fufl_59",
221
- "file-drop-area__browse-button": "_file-drop-area__browse-button_1fufl_72",
222
- "file-drop-area__file-size-info": "_file-drop-area__file-size-info_1fufl_75",
223
- "file-drop-area__hidden-input": "_file-drop-area__hidden-input_1fufl_79",
224
- "file-drop-area__error-message": "_file-drop-area__error-message_1fufl_82",
225
- "file-drop-area--overlay": "_file-drop-area--overlay_1fufl_88",
226
- "file-drop-area--overlay-mode": "_file-drop-area--overlay-mode_1fufl_106"
227
- }, ee = h.bind(D), re = ({ className: e }) => {
213
+ "file-drop-area": "_file-drop-area_1s34r_16",
214
+ "file-drop-area--active": "_file-drop-area--active_1s34r_28",
215
+ "file-drop-area--disabled": "_file-drop-area--disabled_1s34r_32",
216
+ "file-drop-area--error": "_file-drop-area--error_1s34r_36",
217
+ "file-drop-area__content": "_file-drop-area__content_1s34r_39",
218
+ "file-drop-area__icon": "_file-drop-area__icon_1s34r_46",
219
+ "file-drop-area__text": "_file-drop-area__text_1s34r_54",
220
+ "file-drop-area__description": "_file-drop-area__description_1s34r_60",
221
+ "file-drop-area__browse-button": "_file-drop-area__browse-button_1s34r_73",
222
+ "file-drop-area__file-size-info": "_file-drop-area__file-size-info_1s34r_76",
223
+ "file-drop-area__hidden-input": "_file-drop-area__hidden-input_1s34r_80",
224
+ "file-drop-area__error-message": "_file-drop-area__error-message_1s34r_83",
225
+ "file-drop-area--overlay": "_file-drop-area--overlay_1s34r_89",
226
+ "file-drop-area--overlay-mode": "_file-drop-area--overlay-mode_1s34r_107"
227
+ }, re = E.bind(D), te = ({ className: e }) => {
228
228
  const { error: r, messages: t } = v();
229
229
  return r ? /* @__PURE__ */ f(
230
230
  "div",
231
231
  {
232
- className: ee("file-drop-area__error-message", e),
232
+ className: re("file-drop-area__error-message", e),
233
233
  role: "alert",
234
234
  "aria-live": "assertive",
235
235
  "aria-atomic": "true",
236
236
  children: I([r], t) || r
237
237
  }
238
238
  ) : null;
239
- }, _ = h.bind(D), te = ({ icon: e, description: r, fileSizeMessage: t, className: i }) => {
239
+ }, u = E.bind(D), oe = ({ icon: e, description: r, fileSizeMessage: t, className: o }) => {
240
240
  const {
241
- variant: n = "default",
241
+ variant: a = "default",
242
242
  error: s,
243
243
  isDisabled: l,
244
- isMultipleFiles: o,
245
- overlayProps: c,
246
- onDrop: a,
244
+ isMultipleFiles: c,
245
+ overlayProps: n,
246
+ onDrop: i,
247
247
  handleDropzoneClick: p,
248
248
  registerOpenFunction: m
249
- } = v(), u = n === "overlay";
250
- return /* @__PURE__ */ f(w, { multiple: o, disabled: l, noClick: u, onDrop: a, children: ({ getRootProps: R, getInputProps: T, isDragActive: N, open: O }) => {
249
+ } = v(), _ = a === "overlay";
250
+ return /* @__PURE__ */ f(w, { multiple: c, disabled: l, noClick: _, onDrop: i, children: ({ getRootProps: R, getInputProps: T, isDragActive: N, open: O }) => {
251
251
  m(O);
252
- const j = u ? !!(c != null && c.isDragActive) : N;
252
+ const j = _ ? !!(n != null && n.isDragActive) : N;
253
253
  return /* @__PURE__ */ F(
254
254
  "div",
255
255
  {
256
256
  ...R({
257
- className: _("file-drop-area", i, {
257
+ className: u("file-drop-area", o, {
258
258
  "file-drop-area--active": j,
259
259
  "file-drop-area--disabled": l,
260
260
  "file-drop-area--error": !!s,
261
- "file-drop-area--overlay-mode": u
261
+ "file-drop-area--overlay-mode": _
262
262
  }),
263
- onClick: u ? void 0 : p
263
+ onClick: _ ? void 0 : p
264
264
  }),
265
265
  children: [
266
266
  /* @__PURE__ */ f("input", { ...T() }),
267
- /* @__PURE__ */ F("div", { className: _("file-drop-area__content"), children: [
268
- /* @__PURE__ */ f("div", { className: _("file-drop-area__icon"), children: e }),
269
- /* @__PURE__ */ F("div", { className: _("file-drop-area__text"), children: [
270
- r && /* @__PURE__ */ f("div", { className: _("file-drop-area__description"), children: r }),
271
- t && /* @__PURE__ */ f("div", { className: _("file-drop-area__file-size-info"), children: t })
267
+ /* @__PURE__ */ F("div", { className: u("file-drop-area__content"), children: [
268
+ /* @__PURE__ */ f("div", { className: u("file-drop-area__icon"), children: e }),
269
+ /* @__PURE__ */ F("div", { className: u("file-drop-area__text"), children: [
270
+ r && /* @__PURE__ */ f("div", { className: u("file-drop-area__description"), children: r }),
271
+ t && /* @__PURE__ */ f("div", { className: u("file-drop-area__file-size-info"), children: t })
272
272
  ] })
273
273
  ] })
274
274
  ]
275
275
  }
276
276
  );
277
277
  } });
278
- }, oe = {
279
- "attached-files-list": "_attached-files-list_lg6ri_16"
280
- }, ie = h.bind(oe), ne = ({
278
+ }, ie = {
279
+ "attached-files-list": "_attached-files-list_14nn3_16"
280
+ }, ne = E.bind(ie), ae = ({
281
281
  files: e,
282
282
  className: r,
283
283
  onRemoveFile: t,
284
- onDownloadFile: i
284
+ onDownloadFile: o
285
285
  }) => {
286
- const { messages: n } = v(), s = d(
287
- (o) => () => t(o.id),
286
+ const { messages: a, clearError: s } = v();
287
+ k(() => {
288
+ e.some((i) => !g(i.validationErrors)) && s();
289
+ }, [e, s]);
290
+ const l = d(
291
+ (n) => () => t(n.id),
288
292
  [t]
289
- ), l = d(
290
- (o) => () => i == null ? void 0 : i(o),
291
- [i]
293
+ ), c = d(
294
+ (n) => () => o == null ? void 0 : o(n),
295
+ [o]
292
296
  );
293
- return E(e) ? null : /* @__PURE__ */ f("div", { className: ie("attached-files-list", r), children: e.map((o) => {
294
- const c = I(
295
- o.validationErrors ?? [],
296
- n
297
- ), a = !o.isUploadFailed && c;
297
+ return g(e) ? null : /* @__PURE__ */ f("div", { className: ne("attached-files-list", r), children: e.map((n) => {
298
+ const i = I(
299
+ n.validationErrors ?? [],
300
+ a,
301
+ n.customErrorMessage
302
+ );
298
303
  return /* @__PURE__ */ f(
299
- B,
304
+ S,
300
305
  {
301
- fileName: o.fileName,
302
- size: o.size,
303
- uploadingProgress: o.uploadingProgress,
304
- isUploadFailed: o.isUploadFailed || !!c,
305
- isUploading: o.isUploading,
306
- onRemove: s(o),
307
- ...a && { uploadFailedMessage: c },
308
- ...i && { onDownload: l(o) }
306
+ fileName: n.fileName,
307
+ size: n.size,
308
+ uploadingProgress: n.uploadingProgress,
309
+ isUploadFailed: n.isUploadFailed || !!i,
310
+ isUploading: n.isUploading,
311
+ onRemove: l(n),
312
+ ...i && { uploadFailedMessage: i },
313
+ ...o && { onDownload: c(n) }
309
314
  },
310
- o.id
315
+ n.id
311
316
  );
312
317
  }) });
313
- }, ae = h.bind(D), x = ({
318
+ }, se = E.bind(D), x = ({
314
319
  maxFileSize: e,
315
320
  acceptFileMimeTypes: r,
316
321
  isMultipleFiles: t,
317
- isDisabled: i,
318
- variant: n = "default",
322
+ isDisabled: o,
323
+ variant: a = "default",
319
324
  children: s,
320
325
  messages: l,
321
- onFilesAdded: o
326
+ onFilesAdded: c
322
327
  }) => {
323
- const c = n === "overlay", a = H({
328
+ const n = a === "overlay", i = J({
324
329
  maxFileSize: e,
325
330
  acceptFileMimeTypes: r,
326
331
  messages: l,
327
332
  isMultipleFiles: t,
328
- isDisabled: i,
329
- onFilesAdded: o
330
- }), p = J({
331
- isOverlay: c
333
+ isDisabled: o,
334
+ onFilesAdded: c
335
+ }), p = K({
336
+ isOverlay: n
332
337
  });
333
338
  return /* @__PURE__ */ f(
334
- K,
339
+ Q,
335
340
  {
336
- ...a,
337
- variant: n,
341
+ ...i,
342
+ variant: a,
338
343
  messages: l,
339
344
  overlayProps: p,
340
- isDisabled: i,
345
+ isDisabled: o,
341
346
  isMultipleFiles: t,
342
- children: (() => c ? /* @__PURE__ */ f("div", { className: ae("file-drop-area--overlay"), ...p.handlers, children: s }) : s)()
347
+ children: (() => n ? /* @__PURE__ */ f("div", { className: se("file-drop-area--overlay"), ...p.handlers, children: s }) : s)()
343
348
  }
344
349
  );
345
350
  };
346
- x.DropZone = te;
347
- x.BrowseButton = Q;
348
- x.Error = re;
349
- x.AttachedFilesList = ne;
351
+ x.DropZone = oe;
352
+ x.BrowseButton = ee;
353
+ x.Error = te;
354
+ x.AttachedFilesList = ae;
350
355
  export {
351
356
  x as FileDropArea,
352
- me as MIME_TYPES
357
+ ge as MIME_TYPES
353
358
  };
@@ -0,0 +1,110 @@
1
+ import { jsxs as h, jsx as t } from "react/jsx-runtime";
2
+ import { useMemo as o, useCallback as m } from "react";
3
+ import { c as C } from "./bind-06a7ff84.js";
4
+ import { S } from "./close-4d480ef7.js";
5
+ import { a as w, b as E, S as j, d as y, e as I, c as l, f as x } from "./xls-995781cc.js";
6
+ const k = (_) => {
7
+ var c;
8
+ const d = _.split(".");
9
+ return d.length > 1 && ((c = d.at(-1)) == null ? void 0 : c.toLowerCase()) || "";
10
+ }, L = {
11
+ "attached-file": "_attached-file_1x0ei_16",
12
+ "attached-file__file-name": "_attached-file__file-name_1x0ei_29",
13
+ "attached-file--failed": "_attached-file--failed_1x0ei_32",
14
+ "attached-file__name-text": "_attached-file__name-text_1x0ei_36",
15
+ "attached-file__icon": "_attached-file__icon_1x0ei_39",
16
+ "attached-file--uploading": "_attached-file--uploading_1x0ei_45",
17
+ "attached-file--full-width": "_attached-file--full-width_1x0ei_57",
18
+ "attached-file__file-icon": "_attached-file__file-icon_1x0ei_66",
19
+ "attached-file__info": "_attached-file__info_1x0ei_78",
20
+ "attached-file__download-icon": "_attached-file__download-icon_1x0ei_108",
21
+ "attached-file__file-details": "_attached-file__file-details_1x0ei_117",
22
+ "attached-file__error-message": "_attached-file__error-message_1x0ei_122",
23
+ "attached-file__upload-progress": "_attached-file__upload-progress_1x0ei_127",
24
+ "attached-file__upload-progress-bar": "_attached-file__upload-progress-bar_1x0ei_137",
25
+ "attached-file__remove-button": "_attached-file__remove-button_1x0ei_141",
26
+ "attached-file__remove-button--disabled": "_attached-file__remove-button--disabled_1x0ei_163"
27
+ }, e = C.bind(L), A = {
28
+ csv: j,
29
+ jar: y,
30
+ pdf: I,
31
+ jpg: l,
32
+ jpeg: l,
33
+ png: l,
34
+ gif: l,
35
+ svg: l,
36
+ webp: l,
37
+ xls: x,
38
+ xlsx: x
39
+ }, M = (_) => A[_.toLowerCase()] ?? E, X = ({
40
+ fileName: _,
41
+ size: d,
42
+ uploadingProgress: c = 0,
43
+ isUploadFailed: i = !1,
44
+ uploadFailedMessage: p,
45
+ isUploading: a = !1,
46
+ isFullWidth: u = !1,
47
+ onDownload: f,
48
+ onRemove: s
49
+ }) => {
50
+ const r = o(() => k(_), [_]), g = r.toUpperCase(), b = o(() => M(r), [r]), v = m(
51
+ (n) => {
52
+ n.stopPropagation(), a || s == null || s();
53
+ },
54
+ [a, s]
55
+ ), N = m(
56
+ (n) => {
57
+ n.stopPropagation(), !i && !a && f && f();
58
+ },
59
+ [i, a, f]
60
+ );
61
+ return /* @__PURE__ */ h(
62
+ "div",
63
+ {
64
+ className: e("attached-file", {
65
+ "attached-file--failed": i,
66
+ "attached-file--uploading": a,
67
+ "attached-file--full-width": u
68
+ }),
69
+ children: [
70
+ /* @__PURE__ */ t("div", { className: e("attached-file__icon"), children: /* @__PURE__ */ t("div", { className: e("attached-file__file-icon"), children: /* @__PURE__ */ t(b, {}) }) }),
71
+ /* @__PURE__ */ h("div", { className: e("attached-file__info"), children: [
72
+ f ? /* @__PURE__ */ h("button", { type: "button", className: e("attached-file__file-name"), onClick: N, children: [
73
+ /* @__PURE__ */ t("span", { className: e("attached-file__name-text"), children: _ }),
74
+ !a && !i && /* @__PURE__ */ t("span", { className: e("attached-file__download-icon"), children: /* @__PURE__ */ t(w, {}) })
75
+ ] }) : /* @__PURE__ */ t("div", { className: e("attached-file__file-name"), children: /* @__PURE__ */ t("span", { className: e("attached-file__name-text"), children: _ }) }),
76
+ !i && /* @__PURE__ */ h("div", { className: e("attached-file__file-details"), children: [
77
+ g,
78
+ ", ",
79
+ d,
80
+ " MB"
81
+ ] }),
82
+ i && /* @__PURE__ */ t("div", { className: e("attached-file__error-message"), children: p })
83
+ ] }),
84
+ s && /* @__PURE__ */ t(
85
+ "button",
86
+ {
87
+ type: "button",
88
+ className: e("attached-file__remove-button", {
89
+ "attached-file__remove-button--disabled": a
90
+ }),
91
+ disabled: a,
92
+ onClick: v,
93
+ children: /* @__PURE__ */ t(S, {})
94
+ }
95
+ ),
96
+ a && c > 0 && /* @__PURE__ */ t("div", { className: e("attached-file__upload-progress"), children: /* @__PURE__ */ t(
97
+ "div",
98
+ {
99
+ className: e("attached-file__upload-progress-bar"),
100
+ style: { width: `${c}%` }
101
+ }
102
+ ) })
103
+ ]
104
+ }
105
+ );
106
+ };
107
+ export {
108
+ X as A,
109
+ k as g
110
+ };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as u } from "./index-e27a72a8.js";
1
+ import { A as u } from "./index-803576c3.js";
2
2
  import { B as F } from "./baseIconButton-251479f7.js";
3
3
  import { B as D } from "./breadcrumbs-8e5ca8d7.js";
4
4
  import { B as g } from "./bubblesLoader-f3ffa240.js";