stone-kit 0.0.778 → 0.0.779

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.
@@ -7,9 +7,9 @@ export type TClickOptionProps = {
7
7
  selectedOptions: TOption[];
8
8
  setSelectedOptions: (value: SetStateAction<TOption[]>) => void;
9
9
  mode: TModeSelect;
10
- onChange?: ((selectedOptions: TOption[]) => unknown);
10
+ onChange?: (selectedOptions: TOption[]) => unknown;
11
11
  optionsParentArr?: TCategory[] | TOption[];
12
12
  };
13
- declare const handleClickModeOption: ({ option, setSelectedOptions, selectedOptions, disabledOptions, onChange, mode, optionsParentArr }: TClickOptionProps) => void;
14
- declare const handleClickModeCategory: ({ option, setSelectedOptions, selectedOptions, disabledOptions, onChange }: TClickOptionProps) => void;
13
+ declare const handleClickModeOption: ({ option, setSelectedOptions, selectedOptions, disabledOptions, onChange, mode, optionsParentArr, }: TClickOptionProps) => void;
14
+ declare const handleClickModeCategory: ({ option, setSelectedOptions, selectedOptions, disabledOptions, onChange, }: TClickOptionProps) => void;
15
15
  export { handleClickModeCategory, handleClickModeOption };
@@ -1,46 +1,49 @@
1
- const d = ({
1
+ const J = ({
2
2
  option: e,
3
- setSelectedOptions: y,
4
- selectedOptions: f,
5
- disabledOptions: s,
3
+ setSelectedOptions: s,
4
+ selectedOptions: l,
5
+ disabledOptions: u,
6
6
  onChange: c,
7
- mode: S,
8
- optionsParentArr: r
7
+ mode: y,
8
+ optionsParentArr: f
9
9
  }) => {
10
10
  if (!Array.isArray(e)) {
11
- if (s.includes(e))
11
+ if (u.includes(e))
12
12
  return;
13
- let i = f.some((l) => l.value === e.value) ? f.filter((l) => l.value !== e.value) : [...f, e];
14
- if (S === "double") {
15
- "options" in e && (f.map((t) => JSON.stringify(t)).includes(JSON.stringify(e)) ? i = i.filter((t) => !e.options.map((a) => JSON.stringify(a)).includes(JSON.stringify(t))) : Array.isArray(e.options) && (i = [...i, ...e.options]));
16
- const l = r == null ? void 0 : r.filter((u) => "options" in u && u.options.includes(e))[0];
17
- !(l && f.map((u) => JSON.stringify(u)).includes(JSON.stringify(l))) && l && i.push(l);
13
+ let i = l.some((r) => r.value === e.value) ? l.filter((r) => r.value !== e.value) : [...l, e];
14
+ if (y === "single") {
15
+ const r = [e];
16
+ s(r), c && c(r);
17
+ return;
18
+ }
19
+ if (y === "double") {
20
+ "options" in e && (l.map((t) => JSON.stringify(t)).includes(JSON.stringify(e)) ? i = i.filter(
21
+ (t) => !e.options.map((a) => JSON.stringify(a)).includes(JSON.stringify(t))
22
+ ) : Array.isArray(e.options) && (i = [...i, ...e.options]));
23
+ const r = f == null ? void 0 : f.filter((S) => "options" in S && S.options.includes(e))[0];
24
+ !(r && l.map((S) => JSON.stringify(S)).includes(JSON.stringify(r))) && r && i.push(r);
18
25
  }
19
- y(i), c && c(i);
26
+ s(i), c && c(i);
20
27
  }
21
- }, m = ({
28
+ }, N = ({
22
29
  option: e,
23
- setSelectedOptions: y,
24
- selectedOptions: f,
25
- disabledOptions: s,
30
+ setSelectedOptions: s,
31
+ selectedOptions: l,
32
+ disabledOptions: u,
26
33
  onChange: c
27
34
  }) => {
28
35
  if (Array.isArray(e)) {
29
- const S = e.filter((r) => !(s != null && s.includes(r)));
30
- if (S.every((r) => f.map((i) => i).includes(r))) {
31
- const r = f.filter(
32
- (i) => !e.includes(i)
33
- );
34
- y(r), c && c(r);
36
+ const y = e.filter((f) => !(u != null && u.includes(f)));
37
+ if (y.every((f) => l.map((i) => i).includes(f))) {
38
+ const f = l.filter((i) => !e.includes(i));
39
+ s(f), c && c(f);
35
40
  } else {
36
- const r = S.filter(
37
- (l) => !f.includes(l)
38
- ), i = [...f, ...r];
39
- y(i), c && c(i);
41
+ const f = y.filter((r) => !l.includes(r)), i = [...l, ...f];
42
+ s(i), c && c(i);
40
43
  }
41
44
  }
42
45
  };
43
46
  export {
44
- m as handleClickModeCategory,
45
- d as handleClickModeOption
47
+ N as handleClickModeCategory,
48
+ J as handleClickModeOption
46
49
  };
@@ -1,4 +1,4 @@
1
- import { jsxs as m, Fragment as w, jsx as s } from "react/jsx-runtime";
1
+ import { jsxs as m, Fragment as w, jsx as i } from "react/jsx-runtime";
2
2
  import { useState as L, useRef as W, useEffect as j } from "react";
3
3
  import { c as K } from "../../../index-rKuIKazb.js";
4
4
  import { s as e, O as Q } from "../../../Option-BVIm7wOW.js";
@@ -9,7 +9,7 @@ const a = K.bind(e), te = ({
9
9
  options: t,
10
10
  placeholder: B = "Выберите опции",
11
11
  error: D,
12
- disabled: g,
12
+ disabled: p,
13
13
  disabledOptions: f = [],
14
14
  additionalClass: M = "",
15
15
  additionalClassOption: F,
@@ -22,7 +22,7 @@ const a = K.bind(e), te = ({
22
22
  clickableOptions: v,
23
23
  isListRight: q = !1,
24
24
  sizeIcon: d,
25
- mode: i = "options",
25
+ mode: s = "options",
26
26
  onClickItem: C,
27
27
  onCLickSelect: S,
28
28
  size_s: N = "large",
@@ -32,7 +32,7 @@ const a = K.bind(e), te = ({
32
32
  isLast: G
33
33
  }) => {
34
34
  t = Array.isArray(t) ? [.../* @__PURE__ */ new Set([...t])] : [];
35
- const [l, A] = L(c), [o, h] = L(!1), p = W(null), E = (r) => {
35
+ const [l, A] = L(c), [o, g] = L(!1), h = W(null), E = (r) => {
36
36
  C && C(r);
37
37
  const n = {
38
38
  option: r,
@@ -40,7 +40,7 @@ const a = K.bind(e), te = ({
40
40
  disabledOptions: f,
41
41
  setSelectedOptions: A,
42
42
  onChange: _,
43
- mode: i,
43
+ mode: s,
44
44
  optionsParentArr: t
45
45
  };
46
46
  Array.isArray(r) ? X(n) : U(n);
@@ -50,10 +50,10 @@ const a = K.bind(e), te = ({
50
50
  j(() => {
51
51
  const r = (n) => {
52
52
  const J = n.target;
53
- if (p.current && !p.current.contains(n.target)) {
53
+ if (h.current && !h.current.contains(n.target)) {
54
54
  if (J.closest("svg"))
55
55
  return;
56
- h(!1);
56
+ g(!1);
57
57
  }
58
58
  };
59
59
  return document.addEventListener("click", r), () => {
@@ -66,14 +66,14 @@ const a = K.bind(e), te = ({
66
66
  }, [c]), /* @__PURE__ */ m(
67
67
  "div",
68
68
  {
69
- ref: p,
69
+ ref: h,
70
70
  className: a(e.multiSelectWrapper, { [e.multiSelectWrapperError]: D }, M),
71
71
  tabIndex: 0,
72
72
  onBlur: H,
73
73
  children: [
74
74
  /* @__PURE__ */ m("div", { className: a(e.inputWrapper), children: [
75
75
  !O && /* @__PURE__ */ m(w, { children: [
76
- /* @__PURE__ */ s(
76
+ /* @__PURE__ */ i(
77
77
  "div",
78
78
  {
79
79
  className: a(
@@ -82,13 +82,13 @@ const a = K.bind(e), te = ({
82
82
  e[`${$}-size_m`],
83
83
  e[`${k}-size)_l`],
84
84
  { [e.selectedOptionsNotEmpty]: l.length > 0 },
85
- { [e.selectOptionsDisabled]: g }
85
+ { [e.selectOptionsDisabled]: p }
86
86
  ),
87
- onClick: () => h(!o),
87
+ onClick: () => g(!o),
88
88
  children: l.length === 0 ? B : "Выбрано " + l.length
89
89
  }
90
90
  ),
91
- /* @__PURE__ */ s(
91
+ /* @__PURE__ */ i(
92
92
  z,
93
93
  {
94
94
  name: "arrowShort",
@@ -99,7 +99,7 @@ const a = K.bind(e), te = ({
99
99
  )
100
100
  ] }),
101
101
  O && /* @__PURE__ */ m(w, { children: [
102
- /* @__PURE__ */ s(
102
+ /* @__PURE__ */ i(
103
103
  "button",
104
104
  {
105
105
  className: a(
@@ -108,16 +108,16 @@ const a = K.bind(e), te = ({
108
108
  e[`${$}-size_m`],
109
109
  e[`${k}-size_l`],
110
110
  e.selectedOptionsBtn,
111
- { [e.selectOptionsDisabled]: g },
111
+ { [e.selectOptionsDisabled]: p },
112
112
  P
113
113
  ),
114
114
  onClick: () => {
115
- S && S(), h(!o);
115
+ S && S(), g(!o);
116
116
  },
117
117
  children: y
118
118
  }
119
119
  ),
120
- /* @__PURE__ */ s(
120
+ /* @__PURE__ */ i(
121
121
  z,
122
122
  {
123
123
  name: "filter",
@@ -138,7 +138,7 @@ const a = K.bind(e), te = ({
138
138
  F
139
139
  ),
140
140
  children: [
141
- i === "options" && (t == null ? void 0 : t.map((r, n) => /* @__PURE__ */ s(
141
+ (s === "options" || s === "single") && (t == null ? void 0 : t.map((r, n) => /* @__PURE__ */ i(
142
142
  Q,
143
143
  {
144
144
  disabledOptions: f,
@@ -151,7 +151,7 @@ const a = K.bind(e), te = ({
151
151
  },
152
152
  n
153
153
  ))),
154
- (i === "category" || i === "double") && (t == null ? void 0 : t.map((r, n) => "options" in r ? /* @__PURE__ */ s(
154
+ (s === "category" || s === "double") && (t == null ? void 0 : t.map((r, n) => "options" in r ? /* @__PURE__ */ i(
155
155
  T,
156
156
  {
157
157
  disabledOptions: f,
@@ -159,7 +159,7 @@ const a = K.bind(e), te = ({
159
159
  selectedOptions: l,
160
160
  sizeIcon: d,
161
161
  category: r,
162
- mode: i,
162
+ mode: s,
163
163
  selectedValues: c,
164
164
  handleOptionClick: E,
165
165
  isDisabledNotClickable: x
@@ -9,7 +9,7 @@ export type TCategory = {
9
9
  label: string;
10
10
  options: TOption[];
11
11
  };
12
- export type TModeSelect = 'options' | 'category' | 'double';
12
+ export type TModeSelect = 'options' | 'category' | 'double' | 'single';
13
13
  type SelectSizes = 'medium' | 'small' | 'large';
14
14
  export interface MultiSelectProps {
15
15
  options: TOption[] | TCategory[];
@@ -1,10 +1,10 @@
1
1
  import { jsxs as s, jsx as l } from "react/jsx-runtime";
2
2
  import { NewIcon as d } from "../../NewIcon/ui/NewIcon.js";
3
3
  import { Select as O } from "../../Select/ui/Select.js";
4
- const N = "_root_156r8_1", p = "_nameWrapper_156r8_8", f = "_clearBtn_156r8_18", S = "_summaryList_156r8_33", V = "_summaryOption_156r8_40", B = "_categoryOption_156r8_62", b = "_summaryCategory_156r8_71", k = "_headerCategory_156r8_81", T = "_categoryTitle_156r8_87", W = "_categoryOptions_156r8_95", t = {
4
+ const N = "_root_156r8_1", f = "_nameWrapper_156r8_8", p = "_clearBtn_156r8_18", S = "_summaryList_156r8_33", V = "_summaryOption_156r8_40", B = "_categoryOption_156r8_62", b = "_summaryCategory_156r8_71", k = "_headerCategory_156r8_81", T = "_categoryTitle_156r8_87", W = "_categoryOptions_156r8_95", t = {
5
5
  root: N,
6
- nameWrapper: p,
7
- clearBtn: f,
6
+ nameWrapper: f,
7
+ clearBtn: p,
8
8
  summaryList: S,
9
9
  summaryOption: V,
10
10
  categoryOption: B,
@@ -28,7 +28,11 @@ const N = "_root_156r8_1", p = "_nameWrapper_156r8_8", f = "_clearBtn_156r8_18",
28
28
  c([]);
29
29
  }, v = (e) => {
30
30
  var o;
31
- c(((o = a.selectedValues) == null ? void 0 : o.filter((r) => r.value !== e.value).filter((r) => !e.options.some((n) => n.value === r.value))) ?? []);
31
+ c(
32
+ ((o = a.selectedValues) == null ? void 0 : o.filter((r) => r.value !== e.value).filter(
33
+ (r) => !e.options.some((n) => n.value === r.value)
34
+ )) ?? []
35
+ );
32
36
  }, m = (y = a.selectedValues) == null ? void 0 : y.filter((e) => "options" in e);
33
37
  return /* @__PURE__ */ s("div", { className: t.root, children: [
34
38
  /* @__PURE__ */ s("div", { className: t.nameWrapper, children: [
@@ -49,7 +53,7 @@ const N = "_root_156r8_1", p = "_nameWrapper_156r8_8", f = "_clearBtn_156r8_18",
49
53
  onChange: c
50
54
  }
51
55
  ),
52
- a.mode === "options" && a.selectedValues && a.selectedValues.length > 0 && /* @__PURE__ */ l("div", { className: t.summaryList, children: a.selectedValues.map((e) => /* @__PURE__ */ s(
56
+ (a.mode === "options" || a.mode === "single") && a.selectedValues && a.selectedValues.length > 0 && /* @__PURE__ */ l("div", { className: t.summaryList, children: a.selectedValues.map((e) => /* @__PURE__ */ s(
53
57
  "div",
54
58
  {
55
59
  onClick: () => u(e.value.toString()),
@@ -69,39 +73,53 @@ const N = "_root_156r8_1", p = "_nameWrapper_156r8_8", f = "_clearBtn_156r8_18",
69
73
  )) }),
70
74
  a.mode === "double" && (m == null ? void 0 : m.map((e, o) => {
71
75
  const r = e;
72
- return /* @__PURE__ */ s("div", { className: t.summaryCategory, children: [
73
- /* @__PURE__ */ s("div", { className: t.headerCategory, children: [
74
- /* @__PURE__ */ l("div", { className: t.categoryTitle, children: r.label }),
75
- /* @__PURE__ */ l("div", { onClick: () => v(e), className: t.clearBtn, children: /* @__PURE__ */ l(
76
- d,
77
- {
78
- name: "close",
79
- size: "16"
80
- }
81
- ) })
82
- ] }),
83
- /* @__PURE__ */ l("div", { className: t.categoryOptions, children: r.options.filter((n) => {
84
- var i;
85
- return (i = a.selectedValues) == null ? void 0 : i.some((C) => n.value === C.value);
86
- }).map((n, i) => /* @__PURE__ */ s(
87
- "div",
88
- {
89
- onClick: () => u(n.value.toString()),
90
- className: `${t.summaryOption} ${t.categoryOption}`,
91
- children: [
92
- n.label,
76
+ return /* @__PURE__ */ s(
77
+ "div",
78
+ {
79
+ className: t.summaryCategory,
80
+ children: [
81
+ /* @__PURE__ */ s("div", { className: t.headerCategory, children: [
82
+ /* @__PURE__ */ l("div", { className: t.categoryTitle, children: r.label }),
93
83
  /* @__PURE__ */ l(
94
- d,
84
+ "div",
95
85
  {
96
- name: "close",
97
- size: "16"
86
+ onClick: () => v(e),
87
+ className: t.clearBtn,
88
+ children: /* @__PURE__ */ l(
89
+ d,
90
+ {
91
+ name: "close",
92
+ size: "16"
93
+ }
94
+ )
98
95
  }
99
96
  )
100
- ]
101
- },
102
- i
103
- )) })
104
- ] }, o);
97
+ ] }),
98
+ /* @__PURE__ */ l("div", { className: t.categoryOptions, children: r.options.filter((n) => {
99
+ var i;
100
+ return (i = a.selectedValues) == null ? void 0 : i.some((C) => n.value === C.value);
101
+ }).map((n, i) => /* @__PURE__ */ s(
102
+ "div",
103
+ {
104
+ onClick: () => u(n.value.toString()),
105
+ className: `${t.summaryOption} ${t.categoryOption}`,
106
+ children: [
107
+ n.label,
108
+ /* @__PURE__ */ l(
109
+ d,
110
+ {
111
+ name: "close",
112
+ size: "16"
113
+ }
114
+ )
115
+ ]
116
+ },
117
+ i
118
+ )) })
119
+ ]
120
+ },
121
+ o
122
+ );
105
123
  }))
106
124
  ] });
107
125
  };
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.778",
5
+ "version": "0.0.779",
6
6
  "author": "Mollycodd1e",
7
7
  "license": "ISC",
8
8
  "type": "module",