@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 C, jsx as p } from "react/jsx-runtime";
2
- import { useRef as N, useState as T } from "react";
3
- import { Upload as L } from "lucide-react";
4
- import { baseProps as I, clsx as P } from "../../utils/functions/functions.util.js";
5
- import '../../assets/dropzone-iRe6v-43.css';const W = "_Dropzone_14jbn_1", k = "_Active_14jbn_21", E = "_Disabled_14jbn_31", K = "_HiddenInput_14jbn_36", O = "_Icon_14jbn_48", $ = "_Invitation_14jbn_52", B = "_HelpText_14jbn_58", o = {
6
- Dropzone: W,
7
- Active: k,
8
- Disabled: E,
9
- HiddenInput: K,
10
- Icon: O,
11
- Invitation: $,
12
- HelpText: B
13
- }, F = (r, u) => {
14
- const s = u.split(",").map((n) => n.trim()).filter(Boolean);
15
- return s.length === 0 ? !0 : s.some((n) => {
16
- if (n.startsWith("."))
17
- return r.name.toLowerCase().endsWith(n.toLowerCase());
18
- if (n.endsWith("/*")) {
19
- const f = n.slice(0, -1);
20
- return r.type.startsWith(f);
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 === n;
23
+ return r.type === e;
23
24
  });
24
- }, M = ({
25
+ }, V = ({
25
26
  accept: r,
26
- multiple: u = !1,
27
+ multiple: d = !1,
27
28
  maxSize: s,
28
- disabled: n = !1,
29
- invitation: f,
30
- helpText: d,
29
+ disabled: e = !1,
30
+ title: a,
31
+ invitation: z,
32
+ helpText: f,
31
33
  onDrop: y,
32
- onReject: c,
33
- ...D
34
+ onReject: p,
35
+ ...g
34
36
  }) => {
35
- const h = N(null), [b, g] = T(!1), _ = I(D, "data-testid", "dropzone"), x = (t) => {
36
- const l = [], a = [], i = [];
37
- for (const e of t) {
38
- if (!F(e, r)) {
39
- i.push(e);
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 && e.size > s) {
43
- a.push(e);
44
+ if (s !== void 0 && n.size > s) {
45
+ i.push(n);
44
46
  continue;
45
47
  }
46
- l.push(e);
48
+ u.push(n);
47
49
  }
48
- return { accepted: l, tooLarge: a, wrongType: i };
50
+ return { accepted: u, tooLarge: i, wrongType: c };
49
51
  }, m = (t) => {
50
52
  if (!t || t.length === 0) return;
51
- const l = Array.from(t), { accepted: a, tooLarge: i, wrongType: e } = x(l);
52
- a.length > 0 && y(a), i.length > 0 && c && c(i, "tooLarge"), e.length > 0 && c && c(e, "wrongType");
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
- n || h.current?.click();
56
+ e || h.current?.click();
55
57
  }, H = (t) => {
56
- n || (t.key === "Enter" || t.key === " ") && (t.preventDefault(), h.current?.click());
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(), !n && g(!0);
61
- }, z = (t) => {
62
- t.preventDefault(), t.stopPropagation(), g(!1);
63
- }, j = (t) => {
64
- t.preventDefault(), t.stopPropagation(), g(!1), !n && m(t.dataTransfer.files);
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__ */ C(
68
+ return /* @__PURE__ */ L(
67
69
  "div",
68
70
  {
69
- "data-testid": _,
70
- className: P(o.Dropzone, I(D, "className"), {
71
- [o.Active]: b,
72
- [o.Disabled]: n
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: n ? -1 : 0,
76
- "aria-disabled": n,
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: z,
82
- onDrop: j,
83
+ onDragLeave: N,
84
+ onDrop: C,
83
85
  children: [
84
- /* @__PURE__ */ p(
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: u,
92
- disabled: n,
93
+ multiple: d,
94
+ disabled: e,
93
95
  onChange: w,
94
- "data-testid": `${_}-input`,
96
+ "data-testid": `${D}-input`,
95
97
  tabIndex: -1
96
98
  }
97
99
  ),
98
- /* @__PURE__ */ p(L, { size: 32, className: o.Icon, "aria-hidden": !0 }),
99
- /* @__PURE__ */ p("div", { className: o.Invitation, children: f }),
100
- d != null && /* @__PURE__ */ p("div", { className: o.HelpText, children: d })
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
- M as Dropzone
109
+ V as Dropzone
107
110
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@arthurzakharov/ui-kit",
3
3
  "private": false,
4
- "version": "3.5.0",
4
+ "version": "3.6.0",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
7
7
  "types": "dist/main.d.ts",
@@ -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)}