stone-kit 0.0.1097 → 0.0.1100
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,102 +1,117 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
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
3
|
import { c as L } from "../../../index-DIxK0V-G.js";
|
|
4
|
-
import { NewIcon as
|
|
5
|
-
const
|
|
6
|
-
multiSelectWrapper:
|
|
7
|
-
selectedOptions:
|
|
8
|
-
selectedOptionsOpened:
|
|
9
|
-
selectOptionsDisabled:
|
|
10
|
-
optionsList:
|
|
11
|
-
inputWrapper:
|
|
12
|
-
option:
|
|
13
|
-
icon:
|
|
14
|
-
},
|
|
15
|
-
options:
|
|
16
|
-
placeholder:
|
|
17
|
-
error:
|
|
18
|
-
disabled:
|
|
19
|
-
additionalClass:
|
|
20
|
-
onChange:
|
|
21
|
-
onBlur:
|
|
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
|
|
22
24
|
}) => {
|
|
23
|
-
const [s,
|
|
25
|
+
const [s, m] = h(i), [r, v] = h(!1), a = E(null), x = (e) => (n) => {
|
|
24
26
|
n.stopPropagation();
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
27
|
+
const O = s.some((l) => l.value === e.value) ? s.filter((l) => l.value !== e.value) : [...s, e];
|
|
28
|
+
if (m(O), d) {
|
|
27
29
|
const l = {
|
|
28
30
|
...n,
|
|
29
|
-
target: { value:
|
|
31
|
+
target: { value: O }
|
|
30
32
|
};
|
|
31
|
-
|
|
33
|
+
d(l);
|
|
32
34
|
}
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
if (
|
|
35
|
+
}, _ = (e) => {
|
|
36
|
+
a.current && !a.current.contains(e.target) && v(!1);
|
|
37
|
+
}, C = (e) => {
|
|
38
|
+
if (u) {
|
|
37
39
|
const n = {
|
|
38
40
|
...e,
|
|
39
41
|
target: { value: s }
|
|
40
42
|
};
|
|
41
|
-
|
|
43
|
+
u(n);
|
|
42
44
|
}
|
|
43
45
|
};
|
|
44
|
-
|
|
45
|
-
document.removeEventListener("click",
|
|
46
|
-
}), []),
|
|
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(
|
|
47
55
|
"div",
|
|
48
56
|
{
|
|
49
|
-
ref:
|
|
50
|
-
className:
|
|
57
|
+
ref: a,
|
|
58
|
+
className: o(t.multiSelectWrapper, { [t.multiSelectWrapperError]: W }, b),
|
|
51
59
|
tabIndex: 0,
|
|
52
|
-
onBlur:
|
|
60
|
+
onBlur: C,
|
|
53
61
|
children: [
|
|
54
|
-
/* @__PURE__ */
|
|
62
|
+
/* @__PURE__ */ p("div", { className: o(t.inputWrapper), children: [
|
|
55
63
|
/* @__PURE__ */ c(
|
|
56
64
|
"input",
|
|
57
65
|
{
|
|
58
66
|
type: "text",
|
|
59
67
|
readOnly: !0,
|
|
60
|
-
value: s.length === 0 ?
|
|
61
|
-
className:
|
|
62
|
-
onClick:
|
|
68
|
+
value: s.length === 0 ? k : "Выбрано " + s.length + " опции",
|
|
69
|
+
className: o(t.selectedOptions, { [t.selectOptionsDisabled]: N }),
|
|
70
|
+
onClick: D
|
|
63
71
|
}
|
|
64
72
|
),
|
|
65
73
|
/* @__PURE__ */ c(
|
|
66
|
-
|
|
74
|
+
S,
|
|
67
75
|
{
|
|
68
76
|
name: "arrowShort",
|
|
69
|
-
deg:
|
|
77
|
+
deg: r ? "180" : "0",
|
|
70
78
|
size: "24",
|
|
71
79
|
additionalClass: t.icon
|
|
72
80
|
}
|
|
73
81
|
)
|
|
74
82
|
] }),
|
|
75
|
-
|
|
83
|
+
r && /* @__PURE__ */ c(
|
|
76
84
|
"div",
|
|
77
85
|
{
|
|
78
|
-
className:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
+
)
|
|
95
110
|
]
|
|
96
111
|
}
|
|
97
112
|
);
|
|
98
113
|
};
|
|
99
|
-
|
|
114
|
+
U.displayName = "Select";
|
|
100
115
|
export {
|
|
101
|
-
|
|
116
|
+
U as Select
|
|
102
117
|
};
|