stone-kit 0.0.1100 → 0.0.1102

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.
@@ -1,4 +1,4 @@
1
1
  import { default as React } from 'react';
2
2
  import { MultiSelectProps } from './Select.types';
3
3
 
4
- export declare const Select: React.FC<MultiSelectProps>;
4
+ export declare const Select: React.NamedExoticComponent<MultiSelectProps>;
@@ -1,117 +1,112 @@
1
- import { jsxs as p, jsx as c } from "react/jsx-runtime";
2
- import { useState as h, useRef as E, useEffect as f } from "react";
3
- import { c as L } from "../../../index-DIxK0V-G.js";
4
- import { NewIcon as S } from "../../NewIcon/ui/NewIcon.js";
5
- const w = "_multiSelectWrapper_1hlrv_1", y = "_selectedOptions_1hlrv_7", I = "_selectedOptionsOpened_1hlrv_28", P = "_selectOptionsDisabled_1hlrv_32", j = "_optionsList_1hlrv_39", z = "_inputWrapper_1hlrv_54", R = "_option_1hlrv_39", B = "_icon_1hlrv_76", t = {
6
- multiSelectWrapper: w,
7
- selectedOptions: y,
8
- selectedOptionsOpened: I,
9
- selectOptionsDisabled: P,
10
- optionsList: j,
11
- inputWrapper: z,
12
- option: R,
13
- icon: B
14
- }, o = L.bind(t), U = ({
15
- options: g,
16
- placeholder: k = "Выберите опции",
17
- error: W,
18
- disabled: N,
19
- additionalClass: b = "",
20
- onChange: d,
21
- onBlur: u,
22
- selectedValues: i = []
23
- // new prop
1
+ import { jsxs as v, jsx as c } from "react/jsx-runtime";
2
+ import { memo as L, useState as f, useRef as D, useCallback as _, useEffect as S } from "react";
3
+ import { c as w } from "../../../index-DIxK0V-G.js";
4
+ import { NewIcon as k } from "../../NewIcon/ui/NewIcon.js";
5
+ const y = "_multiSelectWrapper_1hlrv_1", I = "_selectedOptions_1hlrv_7", j = "_selectedOptionsOpened_1hlrv_28", z = "_selectOptionsDisabled_1hlrv_32", R = "_optionsList_1hlrv_39", P = "_inputWrapper_1hlrv_54", U = "_option_1hlrv_39", q = "_icon_1hlrv_76", s = {
6
+ multiSelectWrapper: y,
7
+ selectedOptions: I,
8
+ selectedOptionsOpened: j,
9
+ selectOptionsDisabled: z,
10
+ optionsList: R,
11
+ inputWrapper: P,
12
+ option: U,
13
+ icon: q
14
+ }, o = w.bind(s), A = ({
15
+ options: W,
16
+ placeholder: b = "Выберите опции",
17
+ error: N,
18
+ disabled: g,
19
+ additionalClass: x = "",
20
+ onChange: i,
21
+ onBlur: r,
22
+ selectedValues: a = []
24
23
  }) => {
25
- const [s, m] = h(i), [r, v] = h(!1), a = E(null), x = (e) => (n) => {
26
- n.stopPropagation();
27
- const O = s.some((l) => l.value === e.value) ? s.filter((l) => l.value !== e.value) : [...s, e];
28
- if (m(O), d) {
29
- const l = {
30
- ...n,
31
- target: { value: O }
32
- };
33
- d(l);
34
- }
35
- }, _ = (e) => {
36
- a.current && !a.current.contains(e.target) && v(!1);
37
- }, C = (e) => {
38
- if (u) {
39
- const n = {
40
- ...e,
41
- target: { value: s }
42
- };
43
- u(n);
44
- }
45
- };
46
- f(() => (document.addEventListener("click", _), () => {
47
- document.removeEventListener("click", _);
48
- }), []), f(() => {
49
- m(i);
50
- }, [i]);
51
- const D = (e) => {
52
- e.stopPropagation(), v(!r);
53
- };
54
- return /* @__PURE__ */ p(
24
+ const [t, O] = f(a), [p, h] = f(!1), d = D(null), C = _(
25
+ (e) => (n) => {
26
+ n.stopPropagation();
27
+ const u = t.some((l) => l.value === e.value) ? t.filter((l) => l.value !== e.value) : [...t, e];
28
+ if (O(u), i) {
29
+ console.log("Selected options:", u);
30
+ const l = {
31
+ ...n,
32
+ target: { value: u }
33
+ };
34
+ i(l);
35
+ }
36
+ },
37
+ [t, i]
38
+ ), m = _((e) => {
39
+ d.current && !d.current.contains(e.target) && h(!1);
40
+ }, []), E = _(
41
+ (e) => {
42
+ if (r) {
43
+ const n = {
44
+ ...e,
45
+ target: { value: t }
46
+ };
47
+ r(n);
48
+ }
49
+ },
50
+ [t, r]
51
+ );
52
+ return S(() => (document.addEventListener("click", m), () => {
53
+ document.removeEventListener("click", m);
54
+ }), [m]), S(() => {
55
+ O(a);
56
+ }, [a]), /* @__PURE__ */ v(
55
57
  "div",
56
58
  {
57
- ref: a,
58
- className: o(t.multiSelectWrapper, { [t.multiSelectWrapperError]: W }, b),
59
+ ref: d,
60
+ className: o(s.multiSelectWrapper, { [s.multiSelectWrapperError]: N }, x),
59
61
  tabIndex: 0,
60
- onBlur: C,
62
+ onBlur: E,
61
63
  children: [
62
- /* @__PURE__ */ p("div", { className: o(t.inputWrapper), children: [
64
+ /* @__PURE__ */ v("div", { className: o(s.inputWrapper), children: [
63
65
  /* @__PURE__ */ c(
64
66
  "input",
65
67
  {
66
68
  type: "text",
67
69
  readOnly: !0,
68
- value: s.length === 0 ? k : "Выбрано " + s.length + " опции",
69
- className: o(t.selectedOptions, { [t.selectOptionsDisabled]: N }),
70
- onClick: D
70
+ value: t.length === 0 ? b : "Выбрано " + t.length + " опции",
71
+ className: o(s.selectedOptions, { [s.selectOptionsDisabled]: g }),
72
+ onClick: () => h(!p)
71
73
  }
72
74
  ),
73
75
  /* @__PURE__ */ c(
74
- S,
76
+ k,
75
77
  {
76
78
  name: "arrowShort",
77
- deg: r ? "180" : "0",
79
+ deg: p ? "180" : "0",
78
80
  size: "24",
79
- additionalClass: t.icon
81
+ additionalClass: s.icon
80
82
  }
81
83
  )
82
84
  ] }),
83
- r && /* @__PURE__ */ c(
85
+ p && /* @__PURE__ */ c("div", { className: s.optionsList, children: W.map((e) => /* @__PURE__ */ v(
84
86
  "div",
85
87
  {
86
- className: t.optionsList,
87
- onClick: (e) => e.stopPropagation(),
88
- children: g.map((e) => /* @__PURE__ */ p(
89
- "div",
90
- {
91
- className: o(t.option, {
92
- [t.selected]: s.some((n) => n.value === e.value)
93
- }),
94
- onClick: x(e),
95
- children: [
96
- /* @__PURE__ */ c("div", { children: e.label }),
97
- /* @__PURE__ */ c(
98
- S,
99
- {
100
- size: "20",
101
- name: s.some((n) => n.value === e.value) ? "selectChecked" : "selectUnchecked"
102
- }
103
- )
104
- ]
105
- },
106
- e.value
107
- ))
108
- }
109
- )
88
+ className: o(s.option, {
89
+ [s.selected]: t.some((n) => n.value === e.value)
90
+ }),
91
+ onClick: C(e),
92
+ children: [
93
+ /* @__PURE__ */ c("div", { children: e.label }),
94
+ /* @__PURE__ */ c(
95
+ k,
96
+ {
97
+ size: "20",
98
+ name: t.some((n) => n.value === e.value) ? "selectChecked" : "selectUnchecked"
99
+ }
100
+ )
101
+ ]
102
+ },
103
+ e.value
104
+ )) })
110
105
  ]
111
106
  }
112
107
  );
113
- };
114
- U.displayName = "Select";
108
+ }, B = L(A);
109
+ B.displayName = "Select";
115
110
  export {
116
- U as Select
111
+ B as Select
117
112
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "stone-kit",
3
3
  "description": "uikit for redesign",
4
4
  "private": false,
5
- "version": "0.0.1100",
5
+ "version": "0.0.1102",
6
6
  "author": "Mollycodd1e",
7
7
  "license": "ISC",
8
8
  "type": "module",