@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, title, invitation, helpText, onDrop, onReject, ...base }: DropzoneProps) => import("react/jsx-runtime").JSX.Element;
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 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);
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 r.name.toLowerCase().endsWith(e.toLowerCase());
20
+ return o.name.toLowerCase().endsWith(e.toLowerCase());
19
21
  if (e.endsWith("/*")) {
20
- const a = e.slice(0, -1);
21
- return r.type.startsWith(a);
22
+ const d = e.slice(0, -1);
23
+ return o.type.startsWith(d);
22
24
  }
23
- return r.type === e;
25
+ return o.type === e;
24
26
  });
25
- }, V = ({
26
- accept: r,
27
- multiple: d = !1,
27
+ }, Z = ({
28
+ accept: o,
29
+ multiple: u = !1,
28
30
  maxSize: s,
29
31
  disabled: e = !1,
30
- title: a,
31
- invitation: z,
32
+ invitation: d,
32
33
  helpText: f,
33
- onDrop: y,
34
+ children: c,
35
+ onDrop: N,
34
36
  onReject: p,
35
- ...g
37
+ ...m
36
38
  }) => {
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);
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 && n.size > s) {
45
- i.push(n);
46
+ if (s !== void 0 && r.size > s) {
47
+ a.push(r);
46
48
  continue;
47
49
  }
48
- u.push(n);
50
+ l.push(r);
49
51
  }
50
- return { accepted: u, tooLarge: i, wrongType: c };
51
- }, m = (t) => {
52
+ return { accepted: l, tooLarge: a, wrongType: i };
53
+ }, y = (t) => {
52
54
  if (!t || t.length === 0) return;
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");
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 || h.current?.click();
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
- }, N = (t) => {
65
+ }, P = (t) => {
64
66
  t.preventDefault(), t.stopPropagation(), _(!1);
65
- }, C = (t) => {
66
- t.preventDefault(), t.stopPropagation(), _(!1), !e && m(t.dataTransfer.files);
67
+ }, W = (t) => {
68
+ t.preventDefault(), t.stopPropagation(), _(!1), !e && y(t.dataTransfer.files);
67
69
  };
68
- return /* @__PURE__ */ L(
69
- "div",
70
- {
71
- "data-testid": D,
72
- className: E(o.Dropzone, I(g, "className"), {
73
- [o.Active]: T,
74
- [o.Disabled]: e
75
- }),
76
- role: "button",
77
- tabIndex: e ? -1 : 0,
78
- "aria-disabled": e,
79
- onClick: A,
80
- onKeyDown: H,
81
- onDragOver: v,
82
- onDragEnter: v,
83
- onDragLeave: N,
84
- onDrop: C,
85
- children: [
86
- /* @__PURE__ */ l(
87
- "input",
88
- {
89
- ref: h,
90
- type: "file",
91
- className: o.HiddenInput,
92
- accept: r,
93
- multiple: d,
94
- disabled: e,
95
- onChange: w,
96
- "data-testid": `${D}-input`,
97
- tabIndex: -1
98
- }
99
- ),
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 })
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
- V as Dropzone
122
+ Z as Dropzone
110
123
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@arthurzakharov/ui-kit",
3
3
  "private": false,
4
- "version": "3.11.0",
4
+ "version": "3.12.0",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
7
7
  "types": "dist/main.d.ts",
@@ -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)}