stone-kit 0.0.487 → 0.0.488
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,3 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
1
|
import { MultiSelectProps } from './Select.types';
|
|
3
2
|
|
|
4
|
-
export declare const Select:
|
|
3
|
+
export declare const Select: ({ options, placeholder, error, disabled, disabledOptions, additionalClass, additionalClassOption, additionalClassBtn, onChange, onBlur, selectedValues, isBtn, btnName, clickableOptions, isListRight, sizeIcon, }: MultiSelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,137 +1,138 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import {
|
|
3
|
-
import { c as
|
|
4
|
-
import { NewIcon as
|
|
5
|
-
const
|
|
6
|
-
multiSelectWrapper:
|
|
7
|
-
selectedOptions:
|
|
8
|
-
selectedOptionsBtn:
|
|
9
|
-
selectedOptionsOpened:
|
|
10
|
-
selectedOptionsNotEmpty:
|
|
11
|
-
selectOptionsDisabled:
|
|
12
|
-
optionsList:
|
|
13
|
-
listRight:
|
|
14
|
-
inputWrapper:
|
|
15
|
-
option:
|
|
16
|
-
optionDisabled:
|
|
17
|
-
optionClickable:
|
|
18
|
-
icon:
|
|
19
|
-
}, c =
|
|
1
|
+
import { jsxs as a, Fragment as C, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { useState as S, useRef as D, useEffect as W } from "react";
|
|
3
|
+
import { c as F } from "../../../index-rKuIKazb.js";
|
|
4
|
+
import { NewIcon as O } from "../../NewIcon/ui/NewIcon.js";
|
|
5
|
+
const I = "_multiSelectWrapper_11it8_1", U = "_selectedOptions_11it8_8", $ = "_selectedOptionsBtn_11it8_27", q = "_selectedOptionsOpened_11it8_31", A = "_selectedOptionsNotEmpty_11it8_35", G = "_selectOptionsDisabled_11it8_40", H = "_optionsList_11it8_47", J = "_listRight_11it8_63", K = "_inputWrapper_11it8_67", M = "_option_11it8_47", P = "_optionDisabled_11it8_88", Q = "_optionClickable_11it8_92", T = "_icon_11it8_96", e = {
|
|
6
|
+
multiSelectWrapper: I,
|
|
7
|
+
selectedOptions: U,
|
|
8
|
+
selectedOptionsBtn: $,
|
|
9
|
+
selectedOptionsOpened: q,
|
|
10
|
+
selectedOptionsNotEmpty: A,
|
|
11
|
+
selectOptionsDisabled: G,
|
|
12
|
+
optionsList: H,
|
|
13
|
+
listRight: J,
|
|
14
|
+
inputWrapper: K,
|
|
15
|
+
option: M,
|
|
16
|
+
optionDisabled: P,
|
|
17
|
+
optionClickable: Q,
|
|
18
|
+
icon: T
|
|
19
|
+
}, c = F.bind(e), ee = ({
|
|
20
20
|
options: p,
|
|
21
|
-
placeholder:
|
|
22
|
-
error:
|
|
23
|
-
disabled:
|
|
24
|
-
disabledOptions:
|
|
25
|
-
additionalClass:
|
|
26
|
-
additionalClassOption:
|
|
27
|
-
additionalClassBtn:
|
|
28
|
-
onChange:
|
|
29
|
-
onBlur:
|
|
21
|
+
placeholder: E = "Выберите опции",
|
|
22
|
+
error: R,
|
|
23
|
+
disabled: h,
|
|
24
|
+
disabledOptions: v = [],
|
|
25
|
+
additionalClass: L = "",
|
|
26
|
+
additionalClassOption: x,
|
|
27
|
+
additionalClassBtn: y,
|
|
28
|
+
onChange: f,
|
|
29
|
+
onBlur: g,
|
|
30
30
|
selectedValues: l = [],
|
|
31
|
-
isBtn:
|
|
32
|
-
btnName:
|
|
33
|
-
clickableOptions:
|
|
34
|
-
isListRight:
|
|
35
|
-
sizeIcon:
|
|
31
|
+
isBtn: d = !1,
|
|
32
|
+
btnName: w,
|
|
33
|
+
clickableOptions: b,
|
|
34
|
+
isListRight: B = !1,
|
|
35
|
+
sizeIcon: _
|
|
36
36
|
}) => {
|
|
37
|
-
const [
|
|
38
|
-
(t)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
37
|
+
const [i, k] = S(l), [o, m] = S(!1), u = D(null), j = (t) => () => {
|
|
38
|
+
if (v.includes(t))
|
|
39
|
+
return;
|
|
40
|
+
const s = i.some((r) => r.value === t.value) ? i.filter((r) => r.value !== t.value) : [...i, t];
|
|
41
|
+
k(s), f && f(s);
|
|
42
|
+
}, z = () => {
|
|
43
|
+
g && g(i);
|
|
44
|
+
};
|
|
45
|
+
W(() => {
|
|
46
|
+
const t = (s) => {
|
|
47
|
+
const r = s.target;
|
|
48
|
+
if (u.current && !u.current.contains(s.target)) {
|
|
49
|
+
if (r.closest("svg"))
|
|
50
|
+
return;
|
|
51
|
+
m(!1);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
return document.addEventListener("click", t), () => {
|
|
55
|
+
document.removeEventListener("click", t);
|
|
56
|
+
};
|
|
57
|
+
}, []);
|
|
58
|
+
const N = D(l);
|
|
59
|
+
return W(() => {
|
|
60
|
+
l.length !== N.current.length && (k(l), N.current = l);
|
|
61
|
+
}, [l]), /* @__PURE__ */ a(
|
|
61
62
|
"div",
|
|
62
63
|
{
|
|
63
|
-
ref:
|
|
64
|
-
className: c(e.multiSelectWrapper, { [e.multiSelectWrapperError]:
|
|
64
|
+
ref: u,
|
|
65
|
+
className: c(e.multiSelectWrapper, { [e.multiSelectWrapperError]: R }, L),
|
|
65
66
|
tabIndex: 0,
|
|
66
|
-
onBlur:
|
|
67
|
+
onBlur: z,
|
|
67
68
|
children: [
|
|
68
|
-
/* @__PURE__ */
|
|
69
|
-
!
|
|
69
|
+
/* @__PURE__ */ a("div", { className: c(e.inputWrapper), children: [
|
|
70
|
+
!d && /* @__PURE__ */ a(C, { children: [
|
|
70
71
|
/* @__PURE__ */ n(
|
|
71
72
|
"div",
|
|
72
73
|
{
|
|
73
74
|
className: c(
|
|
74
75
|
e.selectedOptions,
|
|
75
|
-
{ [e.selectedOptionsNotEmpty]:
|
|
76
|
-
{ [e.selectOptionsDisabled]:
|
|
76
|
+
{ [e.selectedOptionsNotEmpty]: i.length > 0 },
|
|
77
|
+
{ [e.selectOptionsDisabled]: h }
|
|
77
78
|
),
|
|
78
|
-
onClick: () =>
|
|
79
|
-
children:
|
|
79
|
+
onClick: () => m(!o),
|
|
80
|
+
children: i.length === 0 ? E : "Выбрано " + i.length
|
|
80
81
|
}
|
|
81
82
|
),
|
|
82
83
|
/* @__PURE__ */ n(
|
|
83
|
-
|
|
84
|
+
O,
|
|
84
85
|
{
|
|
85
86
|
name: "arrowShort",
|
|
86
87
|
deg: o ? "180" : "0",
|
|
87
|
-
size:
|
|
88
|
+
size: _ ?? "24",
|
|
88
89
|
additionalClass: e.icon
|
|
89
90
|
}
|
|
90
91
|
)
|
|
91
92
|
] }),
|
|
92
|
-
|
|
93
|
+
d && /* @__PURE__ */ a(C, { children: [
|
|
93
94
|
/* @__PURE__ */ n(
|
|
94
95
|
"button",
|
|
95
96
|
{
|
|
96
97
|
className: c(
|
|
97
98
|
e.selectedOptions,
|
|
98
99
|
e.selectedOptionsBtn,
|
|
99
|
-
{ [e.selectOptionsDisabled]:
|
|
100
|
-
|
|
100
|
+
{ [e.selectOptionsDisabled]: h },
|
|
101
|
+
y
|
|
101
102
|
),
|
|
102
|
-
onClick: () =>
|
|
103
|
-
children:
|
|
103
|
+
onClick: () => m(!o),
|
|
104
|
+
children: w
|
|
104
105
|
}
|
|
105
106
|
),
|
|
106
107
|
/* @__PURE__ */ n(
|
|
107
|
-
|
|
108
|
+
O,
|
|
108
109
|
{
|
|
109
110
|
name: "filter",
|
|
110
111
|
deg: o ? "180" : "0",
|
|
111
|
-
size:
|
|
112
|
+
size: _ ?? "24",
|
|
112
113
|
additionalClass: e.icon
|
|
113
114
|
}
|
|
114
115
|
)
|
|
115
116
|
] })
|
|
116
117
|
] }),
|
|
117
|
-
o && /* @__PURE__ */ n("div", { className: c(e.optionsList, { [e.listRight]:
|
|
118
|
+
o && /* @__PURE__ */ n("div", { className: c(e.optionsList, { [e.listRight]: B }, x), children: p == null ? void 0 : p.map((t) => /* @__PURE__ */ a(
|
|
118
119
|
"div",
|
|
119
120
|
{
|
|
120
121
|
className: c(e.option, {
|
|
121
|
-
[e.selected]:
|
|
122
|
-
[e.optionDisabled]:
|
|
123
|
-
(
|
|
122
|
+
[e.selected]: i.some((s) => s.value === t.value),
|
|
123
|
+
[e.optionDisabled]: v.some(
|
|
124
|
+
(s) => s.value === t.value
|
|
124
125
|
),
|
|
125
|
-
[e.optionClickable]:
|
|
126
|
+
[e.optionClickable]: b && b.includes(`${t.value}`) || d
|
|
126
127
|
}),
|
|
127
|
-
onClick:
|
|
128
|
+
onClick: j(t),
|
|
128
129
|
children: [
|
|
129
130
|
/* @__PURE__ */ n("div", { children: t.label }),
|
|
130
131
|
/* @__PURE__ */ n(
|
|
131
|
-
|
|
132
|
+
O,
|
|
132
133
|
{
|
|
133
|
-
size:
|
|
134
|
-
name:
|
|
134
|
+
size: _ ?? "20",
|
|
135
|
+
name: i.some((s) => s.value === t.value) ? "selectChecked" : "selectUnchecked"
|
|
135
136
|
}
|
|
136
137
|
)
|
|
137
138
|
]
|
|
@@ -141,8 +142,7 @@ const q = "_multiSelectWrapper_11it8_1", A = "_selectedOptions_11it8_8", G = "_s
|
|
|
141
142
|
]
|
|
142
143
|
}
|
|
143
144
|
);
|
|
144
|
-
}
|
|
145
|
-
ee.displayName = "Select";
|
|
145
|
+
};
|
|
146
146
|
export {
|
|
147
147
|
ee as Select
|
|
148
148
|
};
|
|
@@ -1,24 +1,69 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type Option = {
|
|
2
2
|
value: string | number;
|
|
3
3
|
label: string;
|
|
4
|
-
}
|
|
4
|
+
};
|
|
5
|
+
export type Categories = {
|
|
6
|
+
options: Option[];
|
|
7
|
+
};
|
|
8
|
+
export type TModeSelect = 'options' | 'categories';
|
|
5
9
|
export interface MultiSelectProps {
|
|
10
|
+
/**
|
|
11
|
+
* Опции (могут быть опции или категории опций)
|
|
12
|
+
*
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
6
15
|
options?: Option[];
|
|
7
16
|
placeholder?: string;
|
|
8
17
|
error?: boolean;
|
|
9
18
|
disabled?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Доп стили для родителя-контейнера
|
|
21
|
+
*
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
10
24
|
additionalClass?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Доп стили для каждой опции
|
|
27
|
+
*
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
11
30
|
additionalClassOption?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Доп стили для кнопки-контейнера
|
|
33
|
+
*
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
12
36
|
additionalClassBtn?: string;
|
|
13
37
|
onChange?: (selectedOptions: Option[]) => unknown;
|
|
14
38
|
onBlur?: (selectedOptions: Option[]) => unknown;
|
|
39
|
+
/**
|
|
40
|
+
* Значения
|
|
41
|
+
*
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
15
44
|
selectedValues?: Option[];
|
|
16
45
|
isBtn?: boolean;
|
|
17
46
|
btnName?: string;
|
|
18
47
|
widthBtn?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Ширина
|
|
50
|
+
*
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
19
53
|
widthOptionList?: string;
|
|
20
54
|
isListRight?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Список опций которые будут задизейблены по умолчанию
|
|
57
|
+
*
|
|
58
|
+
* @default false
|
|
59
|
+
*/
|
|
21
60
|
disabledOptions?: Option[];
|
|
61
|
+
/**
|
|
62
|
+
* Да...
|
|
63
|
+
*
|
|
64
|
+
* @default false
|
|
65
|
+
*/
|
|
22
66
|
clickableOptions?: (string | undefined)[];
|
|
23
67
|
sizeIcon?: string;
|
|
68
|
+
mode?: TModeSelect;
|
|
24
69
|
}
|