@reportportal/ui-kit 0.0.1-alpha.92 → 0.0.1-alpha.94

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 (39) hide show
  1. package/dist/attachedFile.js +9 -0
  2. package/dist/common/types.d.ts +1 -0
  3. package/dist/common/utils/getFileExtension.d.ts +1 -0
  4. package/dist/common/utils/index.d.ts +1 -0
  5. package/dist/components/attachedFile/attachedFile.d.ts +14 -0
  6. package/dist/components/attachedFile/index.d.ts +2 -0
  7. package/dist/components/fileDropArea/attachedFilesList/attachedFilesList.d.ts +20 -0
  8. package/dist/components/fileDropArea/attachedFilesList/index.d.ts +5 -0
  9. package/dist/components/fileDropArea/browseButton/browseButton.d.ts +9 -0
  10. package/dist/components/fileDropArea/browseButton/index.d.ts +4 -0
  11. package/dist/components/fileDropArea/constants.d.ts +2 -0
  12. package/dist/components/fileDropArea/dropZone/dropZone.d.ts +10 -0
  13. package/dist/components/fileDropArea/dropZone/index.d.ts +4 -0
  14. package/dist/components/fileDropArea/errorMessage/errorMessage.d.ts +5 -0
  15. package/dist/components/fileDropArea/errorMessage/index.d.ts +4 -0
  16. package/dist/components/fileDropArea/fileDropArea.d.ts +19 -0
  17. package/dist/components/fileDropArea/fileDropAreaProvider/fileDropAreaProvider.d.ts +17 -0
  18. package/dist/components/fileDropArea/fileDropAreaProvider/index.d.ts +1 -0
  19. package/dist/components/fileDropArea/fileDropAreaProvider/useFileDropAreaContext.d.ts +3 -0
  20. package/dist/components/fileDropArea/hooks/index.d.ts +1 -0
  21. package/dist/components/fileDropArea/hooks/useFileDropArea.d.ts +13 -0
  22. package/dist/components/fileDropArea/hooks/useFileProcessing.d.ts +13 -0
  23. package/dist/components/fileDropArea/hooks/useOverlayDropArea.d.ts +22 -0
  24. package/dist/components/fileDropArea/index.d.ts +2 -0
  25. package/dist/components/fileDropArea/types.d.ts +57 -0
  26. package/dist/components/fileDropArea/utils/getValidationErrorMessage.d.ts +3 -0
  27. package/dist/components/fileDropArea/utils/index.d.ts +2 -0
  28. package/dist/components/fileDropArea/utils/validateFile.d.ts +3 -0
  29. package/dist/components/icons/index.d.ts +11 -5
  30. package/dist/components/index.d.ts +15 -13
  31. package/dist/{datePicker-ff670fde.js → datePicker-0aca795c.js} +20 -20
  32. package/dist/datePicker.js +2 -2
  33. package/dist/fileDropArea.js +353 -0
  34. package/dist/icons.js +52 -45
  35. package/dist/index-b073dd45.js +99 -0
  36. package/dist/index.js +122 -110
  37. package/dist/style.css +1 -1
  38. package/dist/xls-995781cc.js +11 -0
  39. package/package.json +4 -2
@@ -0,0 +1,353 @@
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-b073dd45.js";
5
+ import { B as S } from "./button-97d9e587.js";
6
+ import w from "react-dropzone";
7
+ import "./close-4d480ef7.js";
8
+ import "./xls-995781cc.js";
9
+ function P(e) {
10
+ return Number.isSafeInteger(e) && e >= 0;
11
+ }
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);
17
+ }
18
+ function V(e) {
19
+ return ArrayBuffer.isView(e) && !(e instanceof DataView);
20
+ }
21
+ function $(e) {
22
+ return e !== null && typeof e == "object" && Z(e) === "[object Arguments]";
23
+ }
24
+ function W(e) {
25
+ const r = e == null ? void 0 : e.constructor, t = typeof r == "function" ? r.prototype : Object.prototype;
26
+ return e === t;
27
+ }
28
+ function X(e) {
29
+ return V(e);
30
+ }
31
+ function E(e) {
32
+ if (e == null)
33
+ return !0;
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;
36
+ if (typeof e == "object") {
37
+ if (e instanceof Map || e instanceof Set)
38
+ return e.size === 0;
39
+ const r = Object.keys(e);
40
+ return W(e) ? r.filter((t) => t !== "constructor").length === 0 : r.length === 0;
41
+ }
42
+ return !0;
43
+ }
44
+ const me = {
45
+ png: "image/png",
46
+ jpeg: "image/jpeg",
47
+ gif: "image/gif",
48
+ svg: "image/svg+xml",
49
+ webp: "image/webp",
50
+ pdf: "application/pdf",
51
+ doc: "application/msword",
52
+ docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
53
+ xls: "application/vnd.ms-excel",
54
+ xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
55
+ csv: "text/csv",
56
+ txt: "text/plain",
57
+ zip: "application/zip",
58
+ mp4: "video/mp4",
59
+ mov: "video/quicktime",
60
+ avi: "video/x-msvideo",
61
+ xml: "application/xml",
62
+ html: "text/html",
63
+ javascript: "application/javascript",
64
+ json: "application/json",
65
+ css: "text/css",
66
+ php: "application/x-httpd-php",
67
+ har: "application/json",
68
+ rar: "application/vnd.rar",
69
+ tgz: "application/gzip",
70
+ taz: "application/x-compress",
71
+ tar: "application/x-tar",
72
+ gzip: "application/gzip",
73
+ plain: "text/plain",
74
+ image: "image/*",
75
+ jar: "application/java-archive",
76
+ gtar: "application/x-gtar",
77
+ kml: "application/vnd.google-earth.kml+xml"
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);
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 = ({
93
+ maxFileSize: e = b,
94
+ acceptFileMimeTypes: r = [],
95
+ onFilesAdded: t
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 })
103
+ }));
104
+ t(p);
105
+ const m = p.find(
106
+ ({ validationErrors: u }) => !E(u)
107
+ );
108
+ m && n(m.validationErrors[0]);
109
+ },
110
+ [e, r, t]
111
+ ), l = d(
112
+ (a) => {
113
+ s(a);
114
+ },
115
+ [s]
116
+ ), o = d(
117
+ (a) => {
118
+ const { files: p } = a.currentTarget;
119
+ p && s([...p]), a.currentTarget.value = "";
120
+ },
121
+ [s]
122
+ ), c = d(() => {
123
+ n(null);
124
+ }, []);
125
+ return {
126
+ onDrop: l,
127
+ handleFileInputChange: o,
128
+ error: i,
129
+ clearError: c
130
+ };
131
+ }, H = ({
132
+ maxFileSize: e = b,
133
+ acceptFileMimeTypes: r = [],
134
+ onFilesAdded: t
135
+ }) => {
136
+ const { onDrop: i, handleFileInputChange: n, error: s, clearError: l } = G({
137
+ maxFileSize: e,
138
+ acceptFileMimeTypes: r,
139
+ onFilesAdded: t
140
+ }), o = d(() => {
141
+ l();
142
+ }, [l]);
143
+ return {
144
+ error: s,
145
+ onDrop: i,
146
+ handleDropzoneClick: o,
147
+ handleFileInputChange: n,
148
+ clearError: l
149
+ };
150
+ }, J = ({ isOverlay: e = !1 }) => {
151
+ const [r, t] = C(!1), i = A(null), n = d((a) => {
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);
160
+ }, []);
161
+ return {
162
+ handlers: e ? {
163
+ ref: i,
164
+ onDragEnter: n,
165
+ onDragLeave: s,
166
+ onDragOver: l,
167
+ onDrop: o
168
+ } : {},
169
+ ...e && { isDragActive: r }
170
+ };
171
+ }, y = L(null);
172
+ y.displayName = "FileDropAreaContext";
173
+ const K = ({
174
+ children: e,
175
+ ...r
176
+ }) => {
177
+ const t = A(null), i = d((l) => {
178
+ t.current = l;
179
+ }, []), n = d(() => {
180
+ r.isDisabled || !t.current || (r.clearError(), t.current());
181
+ }, [r]), s = z(
182
+ () => ({ ...r, registerOpenFunction: i, openFileDialog: n }),
183
+ [r, i, n]
184
+ );
185
+ return /* @__PURE__ */ f(y.Provider, { value: s, children: e });
186
+ }, v = () => {
187
+ const e = M(y);
188
+ if (!e)
189
+ throw new Error("useFileDropAreaContext must be used within a FileDropAreaProvider");
190
+ return e;
191
+ }, Q = ({
192
+ children: e,
193
+ className: r,
194
+ variant: t = "text",
195
+ ...i
196
+ }) => {
197
+ const { openFileDialog: n, isDisabled: s } = v();
198
+ return /* @__PURE__ */ f(
199
+ S,
200
+ {
201
+ ...i,
202
+ variant: t,
203
+ adjustWidthOn: "content",
204
+ disabled: s,
205
+ className: r,
206
+ onClick: (o) => {
207
+ o.stopPropagation(), n();
208
+ },
209
+ children: e
210
+ }
211
+ );
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 }) => {
228
+ const { error: r, messages: t } = v();
229
+ return r ? /* @__PURE__ */ f(
230
+ "div",
231
+ {
232
+ className: ee("file-drop-area__error-message", e),
233
+ role: "alert",
234
+ "aria-live": "assertive",
235
+ "aria-atomic": "true",
236
+ children: I([r], t) || r
237
+ }
238
+ ) : null;
239
+ }, _ = h.bind(D), te = ({ icon: e, description: r, fileSizeMessage: t, className: i }) => {
240
+ const {
241
+ variant: n = "default",
242
+ error: s,
243
+ isDisabled: l,
244
+ isMultipleFiles: o,
245
+ overlayProps: c,
246
+ onDrop: a,
247
+ handleDropzoneClick: p,
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 }) => {
251
+ m(O);
252
+ const j = u ? !!(c != null && c.isDragActive) : N;
253
+ return /* @__PURE__ */ F(
254
+ "div",
255
+ {
256
+ ...R({
257
+ className: _("file-drop-area", i, {
258
+ "file-drop-area--active": j,
259
+ "file-drop-area--disabled": l,
260
+ "file-drop-area--error": !!s,
261
+ "file-drop-area--overlay-mode": u
262
+ }),
263
+ onClick: u ? void 0 : p
264
+ }),
265
+ children: [
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 })
272
+ ] })
273
+ ] })
274
+ ]
275
+ }
276
+ );
277
+ } });
278
+ }, oe = {
279
+ "attached-files-list": "_attached-files-list_lg6ri_16"
280
+ }, ie = h.bind(oe), ne = ({
281
+ files: e,
282
+ className: r,
283
+ onRemoveFile: t,
284
+ onDownloadFile: i
285
+ }) => {
286
+ const { messages: n } = v(), s = d(
287
+ (o) => () => t(o.id),
288
+ [t]
289
+ ), l = d(
290
+ (o) => () => i == null ? void 0 : i(o),
291
+ [i]
292
+ );
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;
298
+ return /* @__PURE__ */ f(
299
+ B,
300
+ {
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) }
309
+ },
310
+ o.id
311
+ );
312
+ }) });
313
+ }, ae = h.bind(D), x = ({
314
+ maxFileSize: e,
315
+ acceptFileMimeTypes: r,
316
+ isMultipleFiles: t,
317
+ isDisabled: i,
318
+ variant: n = "default",
319
+ children: s,
320
+ messages: l,
321
+ onFilesAdded: o
322
+ }) => {
323
+ const c = n === "overlay", a = H({
324
+ maxFileSize: e,
325
+ acceptFileMimeTypes: r,
326
+ messages: l,
327
+ isMultipleFiles: t,
328
+ isDisabled: i,
329
+ onFilesAdded: o
330
+ }), p = J({
331
+ isOverlay: c
332
+ });
333
+ return /* @__PURE__ */ f(
334
+ K,
335
+ {
336
+ ...a,
337
+ variant: n,
338
+ messages: l,
339
+ overlayProps: p,
340
+ isDisabled: i,
341
+ isMultipleFiles: t,
342
+ children: (() => c ? /* @__PURE__ */ f("div", { className: ae("file-drop-area--overlay"), ...p.handlers, children: s }) : s)()
343
+ }
344
+ );
345
+ };
346
+ x.DropZone = te;
347
+ x.BrowseButton = Q;
348
+ x.Error = re;
349
+ x.AttachedFilesList = ne;
350
+ export {
351
+ x as FileDropArea,
352
+ me as MIME_TYPES
353
+ };