@arthurzakharov/ui-kit 3.5.0 → 3.6.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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._Dropzone_e3zu0_1{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--rm-ui-padding-xs);width:100%;min-height:160px;padding:var(--rm-ui-padding-md);border:2px dashed var(--rm-ui-grey-300);border-radius:var(--rm-ui-border-radius-md, 8px);background-color:var(--rm-ui-grey-50);text-align:center;cursor:pointer;transition:border-color .12s ease,background-color .12s ease}._Dropzone_e3zu0_1:hover,._Active_e3zu0_21{border-color:var(--rm-ui-color-theme-primary);background-color:var(--rm-ui-color-background-primary, #fff)}._Dropzone_e3zu0_1:focus-visible{outline:2px solid var(--rm-ui-color-focus);outline-offset:2px}._Disabled_e3zu0_31{cursor:not-allowed;opacity:.5}._HiddenInput_e3zu0_36{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}._Title_e3zu0_48{font-size:var(--rm-ui-font-size-body);line-height:var(--rm-ui-line-height-body);color:var(--rm-ui-color-text-primary)}._Icon_e3zu0_54{color:var(--rm-ui-color-theme-primary)}._Invitation_e3zu0_58{font-size:var(--rm-ui-font-size-body);line-height:var(--rm-ui-line-height-body);color:var(--rm-ui-color-text-primary)}._HelpText_e3zu0_64{font-size:var(--rm-ui-font-size-body-small);line-height:var(--rm-ui-line-height-body-small);color:var(--rm-ui-color-text-secondary)}
|
|
@@ -6,9 +6,10 @@ export interface DropzoneProps extends Base {
|
|
|
6
6
|
multiple?: boolean;
|
|
7
7
|
maxSize?: number;
|
|
8
8
|
disabled?: boolean;
|
|
9
|
+
title?: ReactNode;
|
|
9
10
|
invitation: ReactNode;
|
|
10
11
|
helpText?: ReactNode;
|
|
11
12
|
onDrop: (files: File[]) => void;
|
|
12
13
|
onReject?: (files: File[], reason: DropzoneRejectionReason) => void;
|
|
13
14
|
}
|
|
14
|
-
export declare const Dropzone: ({ accept, multiple, maxSize, disabled, invitation, helpText, onDrop, onReject, ...base }: DropzoneProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare const Dropzone: ({ accept, multiple, maxSize, disabled, title, invitation, helpText, onDrop, onReject, ...base }: DropzoneProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,107 +1,110 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { Upload as
|
|
4
|
-
import { baseProps as I, clsx as
|
|
5
|
-
import '../../assets/dropzone-
|
|
6
|
-
Dropzone:
|
|
7
|
-
Active:
|
|
8
|
-
Disabled:
|
|
9
|
-
HiddenInput:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { jsxs as L, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as P, useState as W } from "react";
|
|
3
|
+
import { Upload as k } from "lucide-react";
|
|
4
|
+
import { baseProps as I, clsx as E } from "../../utils/functions/functions.util.js";
|
|
5
|
+
import '../../assets/dropzone-CxglLL5C.css';const K = "_Dropzone_e3zu0_1", O = "_Active_e3zu0_21", $ = "_Disabled_e3zu0_31", b = "_HiddenInput_e3zu0_36", B = "_Title_e3zu0_48", F = "_Icon_e3zu0_54", U = "_Invitation_e3zu0_58", q = "_HelpText_e3zu0_64", o = {
|
|
6
|
+
Dropzone: K,
|
|
7
|
+
Active: O,
|
|
8
|
+
Disabled: $,
|
|
9
|
+
HiddenInput: b,
|
|
10
|
+
Title: B,
|
|
11
|
+
Icon: F,
|
|
12
|
+
Invitation: U,
|
|
13
|
+
HelpText: q
|
|
14
|
+
}, G = (r, d) => {
|
|
15
|
+
const s = d.split(",").map((e) => e.trim()).filter(Boolean);
|
|
16
|
+
return s.length === 0 ? !0 : s.some((e) => {
|
|
17
|
+
if (e.startsWith("."))
|
|
18
|
+
return r.name.toLowerCase().endsWith(e.toLowerCase());
|
|
19
|
+
if (e.endsWith("/*")) {
|
|
20
|
+
const a = e.slice(0, -1);
|
|
21
|
+
return r.type.startsWith(a);
|
|
21
22
|
}
|
|
22
|
-
return r.type ===
|
|
23
|
+
return r.type === e;
|
|
23
24
|
});
|
|
24
|
-
},
|
|
25
|
+
}, V = ({
|
|
25
26
|
accept: r,
|
|
26
|
-
multiple:
|
|
27
|
+
multiple: d = !1,
|
|
27
28
|
maxSize: s,
|
|
28
|
-
disabled:
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
disabled: e = !1,
|
|
30
|
+
title: a,
|
|
31
|
+
invitation: z,
|
|
32
|
+
helpText: f,
|
|
31
33
|
onDrop: y,
|
|
32
|
-
onReject:
|
|
33
|
-
...
|
|
34
|
+
onReject: p,
|
|
35
|
+
...g
|
|
34
36
|
}) => {
|
|
35
|
-
const h =
|
|
36
|
-
const
|
|
37
|
-
for (const
|
|
38
|
-
if (!
|
|
39
|
-
|
|
37
|
+
const h = P(null), [T, _] = W(!1), D = I(g, "data-testid", "dropzone"), x = (t) => {
|
|
38
|
+
const u = [], i = [], c = [];
|
|
39
|
+
for (const n of t) {
|
|
40
|
+
if (!G(n, r)) {
|
|
41
|
+
c.push(n);
|
|
40
42
|
continue;
|
|
41
43
|
}
|
|
42
|
-
if (s !== void 0 &&
|
|
43
|
-
|
|
44
|
+
if (s !== void 0 && n.size > s) {
|
|
45
|
+
i.push(n);
|
|
44
46
|
continue;
|
|
45
47
|
}
|
|
46
|
-
|
|
48
|
+
u.push(n);
|
|
47
49
|
}
|
|
48
|
-
return { accepted:
|
|
50
|
+
return { accepted: u, tooLarge: i, wrongType: c };
|
|
49
51
|
}, m = (t) => {
|
|
50
52
|
if (!t || t.length === 0) return;
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
+
const u = Array.from(t), { accepted: i, tooLarge: c, wrongType: n } = x(u);
|
|
54
|
+
i.length > 0 && y(i), c.length > 0 && p && p(c, "tooLarge"), n.length > 0 && p && p(n, "wrongType");
|
|
53
55
|
}, A = () => {
|
|
54
|
-
|
|
56
|
+
e || h.current?.click();
|
|
55
57
|
}, H = (t) => {
|
|
56
|
-
|
|
58
|
+
e || (t.key === "Enter" || t.key === " ") && (t.preventDefault(), h.current?.click());
|
|
57
59
|
}, w = (t) => {
|
|
58
60
|
m(t.target.files), t.target.value = "";
|
|
59
61
|
}, v = (t) => {
|
|
60
|
-
t.preventDefault(), t.stopPropagation(), !
|
|
61
|
-
},
|
|
62
|
-
t.preventDefault(), t.stopPropagation(),
|
|
63
|
-
},
|
|
64
|
-
t.preventDefault(), t.stopPropagation(),
|
|
62
|
+
t.preventDefault(), t.stopPropagation(), !e && _(!0);
|
|
63
|
+
}, N = (t) => {
|
|
64
|
+
t.preventDefault(), t.stopPropagation(), _(!1);
|
|
65
|
+
}, C = (t) => {
|
|
66
|
+
t.preventDefault(), t.stopPropagation(), _(!1), !e && m(t.dataTransfer.files);
|
|
65
67
|
};
|
|
66
|
-
return /* @__PURE__ */
|
|
68
|
+
return /* @__PURE__ */ L(
|
|
67
69
|
"div",
|
|
68
70
|
{
|
|
69
|
-
"data-testid":
|
|
70
|
-
className:
|
|
71
|
-
[o.Active]:
|
|
72
|
-
[o.Disabled]:
|
|
71
|
+
"data-testid": D,
|
|
72
|
+
className: E(o.Dropzone, I(g, "className"), {
|
|
73
|
+
[o.Active]: T,
|
|
74
|
+
[o.Disabled]: e
|
|
73
75
|
}),
|
|
74
76
|
role: "button",
|
|
75
|
-
tabIndex:
|
|
76
|
-
"aria-disabled":
|
|
77
|
+
tabIndex: e ? -1 : 0,
|
|
78
|
+
"aria-disabled": e,
|
|
77
79
|
onClick: A,
|
|
78
80
|
onKeyDown: H,
|
|
79
81
|
onDragOver: v,
|
|
80
82
|
onDragEnter: v,
|
|
81
|
-
onDragLeave:
|
|
82
|
-
onDrop:
|
|
83
|
+
onDragLeave: N,
|
|
84
|
+
onDrop: C,
|
|
83
85
|
children: [
|
|
84
|
-
/* @__PURE__ */
|
|
86
|
+
/* @__PURE__ */ l(
|
|
85
87
|
"input",
|
|
86
88
|
{
|
|
87
89
|
ref: h,
|
|
88
90
|
type: "file",
|
|
89
91
|
className: o.HiddenInput,
|
|
90
92
|
accept: r,
|
|
91
|
-
multiple:
|
|
92
|
-
disabled:
|
|
93
|
+
multiple: d,
|
|
94
|
+
disabled: e,
|
|
93
95
|
onChange: w,
|
|
94
|
-
"data-testid": `${
|
|
96
|
+
"data-testid": `${D}-input`,
|
|
95
97
|
tabIndex: -1
|
|
96
98
|
}
|
|
97
99
|
),
|
|
98
|
-
/* @__PURE__ */
|
|
99
|
-
/* @__PURE__ */
|
|
100
|
-
|
|
100
|
+
a != null && /* @__PURE__ */ l("div", { className: o.Title, children: a }),
|
|
101
|
+
/* @__PURE__ */ l(k, { size: 32, className: o.Icon, "aria-hidden": !0 }),
|
|
102
|
+
/* @__PURE__ */ l("div", { className: o.Invitation, children: z }),
|
|
103
|
+
f != null && /* @__PURE__ */ l("div", { className: o.HelpText, children: f })
|
|
101
104
|
]
|
|
102
105
|
}
|
|
103
106
|
);
|
|
104
107
|
};
|
|
105
108
|
export {
|
|
106
|
-
|
|
109
|
+
V as Dropzone
|
|
107
110
|
};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
._Dropzone_14jbn_1{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--rm-ui-padding-xs);width:100%;min-height:160px;padding:var(--rm-ui-padding-md);border:2px dashed var(--rm-ui-grey-300);border-radius:var(--rm-ui-border-radius-md, 8px);background-color:var(--rm-ui-grey-50);text-align:center;cursor:pointer;transition:border-color .12s ease,background-color .12s ease}._Dropzone_14jbn_1:hover,._Active_14jbn_21{border-color:var(--rm-ui-color-theme-primary);background-color:var(--rm-ui-color-background-primary, #fff)}._Dropzone_14jbn_1:focus-visible{outline:2px solid var(--rm-ui-color-focus);outline-offset:2px}._Disabled_14jbn_31{cursor:not-allowed;opacity:.5}._HiddenInput_14jbn_36{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}._Icon_14jbn_48{color:var(--rm-ui-color-theme-primary)}._Invitation_14jbn_52{font-size:var(--rm-ui-font-size-body);line-height:var(--rm-ui-line-height-body);color:var(--rm-ui-color-text-primary)}._HelpText_14jbn_58{font-size:var(--rm-ui-font-size-body-small);line-height:var(--rm-ui-line-height-body-small);color:var(--rm-ui-color-text-secondary)}
|