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