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: React.NamedExoticComponent<MultiSelectProps>;
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 r, Fragment as D, jsx as n } from "react/jsx-runtime";
2
- import { memo as U, useState as W, useRef as E, useCallback as h, useEffect as R } from "react";
3
- import { c as $ } from "../../../index-rKuIKazb.js";
4
- import { NewIcon as b } from "../../NewIcon/ui/NewIcon.js";
5
- const q = "_multiSelectWrapper_11it8_1", A = "_selectedOptions_11it8_8", G = "_selectedOptionsBtn_11it8_27", H = "_selectedOptionsOpened_11it8_31", J = "_selectedOptionsNotEmpty_11it8_35", K = "_selectOptionsDisabled_11it8_40", M = "_optionsList_11it8_47", P = "_listRight_11it8_63", Q = "_inputWrapper_11it8_67", T = "_option_11it8_47", X = "_optionDisabled_11it8_88", Y = "_optionClickable_11it8_92", Z = "_icon_11it8_96", e = {
6
- multiSelectWrapper: q,
7
- selectedOptions: A,
8
- selectedOptionsBtn: G,
9
- selectedOptionsOpened: H,
10
- selectedOptionsNotEmpty: J,
11
- selectOptionsDisabled: K,
12
- optionsList: M,
13
- listRight: P,
14
- inputWrapper: Q,
15
- option: T,
16
- optionDisabled: X,
17
- optionClickable: Y,
18
- icon: Z
19
- }, c = $.bind(e), V = ({
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: L = "Выберите опции",
22
- error: x,
23
- disabled: g,
24
- disabledOptions: k = [],
25
- additionalClass: y = "",
26
- additionalClassOption: w,
27
- additionalClassBtn: j,
28
- onChange: d,
29
- onBlur: m,
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: _ = !1,
32
- btnName: B,
33
- clickableOptions: N,
34
- isListRight: z = !1,
35
- sizeIcon: u
31
+ isBtn: d = !1,
32
+ btnName: w,
33
+ clickableOptions: b,
34
+ isListRight: B = !1,
35
+ sizeIcon: _
36
36
  }) => {
37
- const [s, S] = W(l), [o, O] = W(!1), v = E(null), F = h(
38
- (t) => () => {
39
- if (k.some((a) => a.value === t.value))
40
- return;
41
- const i = s.some((a) => a.value === t.value) ? s.filter((a) => a.value !== t.value) : [...s, t];
42
- S(i), d && d(i);
43
- },
44
- [s, d]
45
- ), f = h((t) => {
46
- if (v.current && !v.current.contains(t.target)) {
47
- if (t.target.closest("svg"))
48
- return;
49
- O(!1);
50
- }
51
- }, []), I = h(() => {
52
- m && m(s);
53
- }, [s, m]);
54
- R(() => (document.addEventListener("click", f), () => {
55
- document.removeEventListener("click", f);
56
- }), [f]);
57
- const C = E(l);
58
- return R(() => {
59
- l.length !== C.current.length && (S(l), C.current = l);
60
- }, [l]), /* @__PURE__ */ r(
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: v,
64
- className: c(e.multiSelectWrapper, { [e.multiSelectWrapperError]: x }, y),
64
+ ref: u,
65
+ className: c(e.multiSelectWrapper, { [e.multiSelectWrapperError]: R }, L),
65
66
  tabIndex: 0,
66
- onBlur: I,
67
+ onBlur: z,
67
68
  children: [
68
- /* @__PURE__ */ r("div", { className: c(e.inputWrapper), children: [
69
- !_ && /* @__PURE__ */ r(D, { children: [
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]: s.length > 0 },
76
- { [e.selectOptionsDisabled]: g }
76
+ { [e.selectedOptionsNotEmpty]: i.length > 0 },
77
+ { [e.selectOptionsDisabled]: h }
77
78
  ),
78
- onClick: () => O(!o),
79
- children: s.length === 0 ? L : "Выбрано " + s.length
79
+ onClick: () => m(!o),
80
+ children: i.length === 0 ? E : "Выбрано " + i.length
80
81
  }
81
82
  ),
82
83
  /* @__PURE__ */ n(
83
- b,
84
+ O,
84
85
  {
85
86
  name: "arrowShort",
86
87
  deg: o ? "180" : "0",
87
- size: u ?? "24",
88
+ size: _ ?? "24",
88
89
  additionalClass: e.icon
89
90
  }
90
91
  )
91
92
  ] }),
92
- _ && /* @__PURE__ */ r(D, { children: [
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]: g },
100
- j
100
+ { [e.selectOptionsDisabled]: h },
101
+ y
101
102
  ),
102
- onClick: () => O(!o),
103
- children: B
103
+ onClick: () => m(!o),
104
+ children: w
104
105
  }
105
106
  ),
106
107
  /* @__PURE__ */ n(
107
- b,
108
+ O,
108
109
  {
109
110
  name: "filter",
110
111
  deg: o ? "180" : "0",
111
- size: u ?? "24",
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]: z }, w), children: p == null ? void 0 : p.map((t) => /* @__PURE__ */ r(
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]: s.some((i) => i.value === t.value),
122
- [e.optionDisabled]: k.some(
123
- (i) => i.value === t.value
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]: N && N.includes(`${t.value}`) || _
126
+ [e.optionClickable]: b && b.includes(`${t.value}`) || d
126
127
  }),
127
- onClick: F(t),
128
+ onClick: j(t),
128
129
  children: [
129
130
  /* @__PURE__ */ n("div", { children: t.label }),
130
131
  /* @__PURE__ */ n(
131
- b,
132
+ O,
132
133
  {
133
- size: u ?? "20",
134
- name: s.some((i) => i.value === t.value) ? "selectChecked" : "selectUnchecked"
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
- }, ee = U(V);
145
- ee.displayName = "Select";
145
+ };
146
146
  export {
147
147
  ee as Select
148
148
  };
@@ -1,24 +1,69 @@
1
- export interface Option {
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
  }
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.487",
5
+ "version": "0.0.488",
6
6
  "author": "Mollycodd1e",
7
7
  "license": "ISC",
8
8
  "type": "module",