stone-kit 0.0.652 → 0.0.654

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,46 +1,46 @@
1
- const d = ({
2
- option: i,
1
+ const t = ({
2
+ option: e,
3
3
  setSelectedOptions: s,
4
- selectedOptions: f,
5
- disabledOptions: u,
4
+ selectedOptions: u,
5
+ disabledOptions: i,
6
6
  onChange: r,
7
7
  mode: y,
8
8
  optionsParentArr: l
9
9
  }) => {
10
- if (!Array.isArray(i)) {
11
- if (u.includes(i))
10
+ if (!Array.isArray(e)) {
11
+ if (i.includes(e))
12
12
  return;
13
- let e = f.some((c) => c.value === i.value) ? f.filter((c) => c.value !== i.value) : [...f, i];
13
+ let c = u.some((f) => f.value === e.value) ? u.filter((f) => f.value !== e.value) : [...u, e];
14
14
  if (y === "double") {
15
- "options" in i && f.includes(i) && (e = e.filter((n) => !i.options.includes(n)));
16
- const c = l == null ? void 0 : l.filter((S) => "options" in S && S.options.includes(i))[0];
17
- !(c && f.includes(c)) && c && e.push(c);
15
+ "options" in e && u.includes(e) && (c = c.filter((d) => !e.options.includes(d)));
16
+ const f = l == null ? void 0 : l.filter((S) => "options" in S && S.options.includes(e))[0];
17
+ !(f && u.includes(f)) && f && c.push(f);
18
18
  }
19
- s(e), console.log(e), r && r(e);
19
+ s(c), r && r(c);
20
20
  }
21
- }, g = ({
22
- option: i,
21
+ }, a = ({
22
+ option: e,
23
23
  setSelectedOptions: s,
24
- selectedOptions: f,
25
- disabledOptions: u,
24
+ selectedOptions: u,
25
+ disabledOptions: i,
26
26
  onChange: r
27
27
  }) => {
28
- if (Array.isArray(i)) {
29
- const y = i.filter((l) => !(u != null && u.includes(l)));
30
- if (y.every((l) => f.map((e) => JSON.stringify(e)).includes(JSON.stringify(l)))) {
31
- const l = f.filter(
32
- (e) => !i.map((c) => JSON.stringify(c)).includes(JSON.stringify(e))
28
+ if (Array.isArray(e)) {
29
+ const y = e.filter((l) => !(i != null && i.includes(l)));
30
+ if (y.every((l) => u.map((c) => c).includes(l))) {
31
+ const l = u.filter(
32
+ (c) => !e.includes(c)
33
33
  );
34
34
  s(l), r && r(l);
35
35
  } else {
36
36
  const l = y.filter(
37
- (c) => !f.map((t) => JSON.stringify(t)).includes(JSON.stringify(c))
38
- ), e = [...f, ...l];
39
- s(e), console.log(e), r && r(e);
37
+ (f) => !u.includes(f)
38
+ ), c = [...u, ...l];
39
+ s(c), r && r(c);
40
40
  }
41
41
  }
42
42
  };
43
43
  export {
44
- g as handleClickModeCategory,
45
- d as handleClickModeOption
44
+ a as handleClickModeCategory,
45
+ t as handleClickModeOption
46
46
  };
@@ -1,12 +1,12 @@
1
- import { jsxs as m, Fragment as A, jsx as l } from "react/jsx-runtime";
2
- import { useState as D, useRef as W, useEffect as j } from "react";
1
+ import { jsxs as m, Fragment as R, jsx as i } from "react/jsx-runtime";
2
+ import { useState as w, useRef as D, useEffect as W } from "react";
3
3
  import { c as G } from "../../../index-rKuIKazb.js";
4
4
  import { s as e, O as H } from "../../../Option-a48eBPyn.js";
5
- import { NewIcon as w } from "../../NewIcon/ui/NewIcon.js";
5
+ import { NewIcon as j } from "../../NewIcon/ui/NewIcon.js";
6
6
  import { Category as J } from "./Category.js";
7
7
  import { handleClickModeOption as K, handleClickModeCategory as Q } from "../model/selectMode.js";
8
- const s = G.bind(e), ee = ({
9
- options: n,
8
+ const a = G.bind(e), ee = ({
9
+ options: t,
10
10
  placeholder: z = "Выберите опции",
11
11
  error: B,
12
12
  disabled: g,
@@ -16,77 +16,78 @@ const s = G.bind(e), ee = ({
16
16
  additionalClassBtn: b,
17
17
  onChange: F,
18
18
  onBlur: u,
19
- selectedValues: i = [],
19
+ selectedValues: c = [],
20
20
  isBtn: O = !1,
21
- btnName: C,
22
- clickableOptions: v,
21
+ btnName: y,
22
+ clickableOptions: C,
23
23
  isListRight: P = !1,
24
24
  sizeIcon: d,
25
- mode: a = "options",
26
- onClickItem: y,
25
+ mode: s = "options",
26
+ onClickItem: v,
27
27
  onCLickSelect: N,
28
- size_s: k = "large",
29
- size_m: S,
28
+ size_s: S = "large",
29
+ size_m: k,
30
30
  size_l: $
31
31
  }) => {
32
- const [c, x] = D(i), [o, p] = D(!1), h = W(null), E = (t) => {
33
- y && y(t);
34
- const r = {
35
- option: t,
36
- selectedOptions: c,
32
+ t = Array.isArray(t) ? [.../* @__PURE__ */ new Set([...t])] : [];
33
+ const [l, x] = w(c), [o, h] = w(!1), p = D(null), A = (r) => {
34
+ v && v(r);
35
+ const n = {
36
+ option: r,
37
+ selectedOptions: l,
37
38
  disabledOptions: f,
38
39
  setSelectedOptions: x,
39
40
  onChange: F,
40
- mode: a,
41
- optionsParentArr: n
41
+ mode: s,
42
+ optionsParentArr: t
42
43
  };
43
- Array.isArray(t) ? Q(r) : K(r);
44
+ Array.isArray(r) ? Q(n) : K(n);
44
45
  }, _ = () => {
45
- u && u(c);
46
+ u && u(l);
46
47
  };
47
- j(() => {
48
- const t = (r) => {
49
- const q = r.target;
50
- if (h.current && !h.current.contains(r.target)) {
48
+ W(() => {
49
+ const r = (n) => {
50
+ const q = n.target;
51
+ if (p.current && !p.current.contains(n.target)) {
51
52
  if (q.closest("svg"))
52
53
  return;
53
- p(!1);
54
+ h(!1);
54
55
  }
55
56
  };
56
- return document.addEventListener("click", t), () => {
57
- document.removeEventListener("click", t);
57
+ return document.addEventListener("click", r), () => {
58
+ document.removeEventListener("click", r);
58
59
  };
59
60
  }, []);
60
- const R = W(i);
61
- return j(() => {
62
- i.length !== R.current.length && (x(i), R.current = i);
63
- }, [i]), /* @__PURE__ */ m(
61
+ const E = D(c);
62
+ return W(() => {
63
+ c.length !== E.current.length && (x(c), E.current = c);
64
+ }, [c]), /* @__PURE__ */ m(
64
65
  "div",
65
66
  {
66
- ref: h,
67
- className: s(e.multiSelectWrapper, { [e.multiSelectWrapperError]: B }, L),
67
+ ref: p,
68
+ className: a(e.multiSelectWrapper, { [e.multiSelectWrapperError]: B }, L),
68
69
  tabIndex: 0,
69
70
  onBlur: _,
70
71
  children: [
71
- /* @__PURE__ */ m("div", { className: s(e.inputWrapper), children: [
72
- !O && /* @__PURE__ */ m(A, { children: [
73
- /* @__PURE__ */ l(
72
+ /* @__PURE__ */ m("div", { className: a(e.inputWrapper), children: [
73
+ !O && /* @__PURE__ */ m(R, { children: [
74
+ /* @__PURE__ */ i(
74
75
  "div",
75
76
  {
76
- className: s(
77
+ className: a(
77
78
  e.selectedOptions,
78
- e[`${k}-size`],
79
- e[`${S}-size_m`],
79
+ e[`${S}-size`],
80
+ e[`${k}-size_m`],
80
81
  e[`${$}-size)_l`],
81
- { [e.selectedOptionsNotEmpty]: c.length > 0 },
82
+ { [e.selectedOptionsNotEmpty]: l.length > 0 },
82
83
  { [e.selectOptionsDisabled]: g }
83
84
  ),
84
- onClick: () => p(!o),
85
- children: c.length === 0 ? z : "Выбрано " + c.length
85
+ onClick: () => h(!o),
86
+ children: l.length === 0 ? z : "Выбрано " + l.length
86
87
  }
87
88
  ),
88
- /* @__PURE__ */ l(
89
- w,
89
+ /* @__PURE__ */ i(
90
+ j,
90
91
  {
91
92
  name: "arrowShort",
92
93
  deg: o ? "180" : "0",
@@ -95,63 +96,63 @@ const s = G.bind(e), ee = ({
95
96
  }
96
97
  )
97
98
  ] }),
98
- O && /* @__PURE__ */ m(A, { children: [
99
- /* @__PURE__ */ l(
99
+ O && /* @__PURE__ */ m(R, { children: [
100
+ /* @__PURE__ */ i(
100
101
  "button",
101
102
  {
102
- className: s(
103
+ className: a(
103
104
  e.selectedOptions,
104
- e[`${k}-size`],
105
- e[`${S}-size_m`],
105
+ e[`${S}-size`],
106
+ e[`${k}-size_m`],
106
107
  e[`${$}-size_l`],
107
108
  e.selectedOptionsBtn,
108
109
  { [e.selectOptionsDisabled]: g },
109
110
  b
110
111
  ),
111
112
  onClick: () => {
112
- N && N(), p(!o);
113
+ N && N(), h(!o);
113
114
  },
114
- children: C
115
+ children: y
115
116
  }
116
117
  ),
117
- /* @__PURE__ */ l(
118
- w,
118
+ /* @__PURE__ */ i(
119
+ j,
119
120
  {
120
121
  name: "filter",
121
122
  deg: o ? "180" : "0",
122
123
  size: d ?? "24",
123
- additionalClass: s(e.icon, { [e.iconBtn]: !C })
124
+ additionalClass: a(e.icon, { [e.iconBtn]: !y })
124
125
  }
125
126
  )
126
127
  ] })
127
128
  ] }),
128
- o && /* @__PURE__ */ m("div", { className: s(e.optionsList, { [e.listRight]: P }, M), children: [
129
- a === "options" && (n == null ? void 0 : n.map((t, r) => /* @__PURE__ */ l(
129
+ o && /* @__PURE__ */ m("div", { className: a(e.optionsList, { [e.listRight]: P }, M), children: [
130
+ s === "options" && (t == null ? void 0 : t.map((r, n) => /* @__PURE__ */ i(
130
131
  H,
131
132
  {
132
133
  disabledOptions: f,
133
- clickableOptions: v,
134
- selectedOptions: c,
134
+ clickableOptions: C,
135
+ selectedOptions: l,
135
136
  sizeIcon: d,
136
- option: t,
137
- handleOptionClick: E
137
+ option: r,
138
+ handleOptionClick: A
138
139
  },
139
- r
140
+ n
140
141
  ))),
141
- (a === "category" || a === "double") && (n == null ? void 0 : n.map(
142
- (t, r) => "options" in t ? /* @__PURE__ */ l(
142
+ (s === "category" || s === "double") && (t == null ? void 0 : t.map(
143
+ (r, n) => "options" in r ? /* @__PURE__ */ i(
143
144
  J,
144
145
  {
145
146
  disabledOptions: f,
146
- clickableOptions: v,
147
- selectedOptions: c,
147
+ clickableOptions: C,
148
+ selectedOptions: l,
148
149
  sizeIcon: d,
149
- category: t,
150
- mode: a,
151
- selectedValues: i,
152
- handleOptionClick: E
150
+ category: r,
151
+ mode: s,
152
+ selectedValues: c,
153
+ handleOptionClick: A
153
154
  },
154
- r
155
+ n
155
156
  ) : null
156
157
  ))
157
158
  ] })
@@ -11,7 +11,7 @@ export type TCategory = {
11
11
  export type TModeSelect = 'options' | 'category' | 'double';
12
12
  type SelectSizes = 'medium' | 'small' | 'large';
13
13
  export interface MultiSelectProps {
14
- options?: TOption[] | TCategory[];
14
+ options: TOption[] | TCategory[];
15
15
  category?: TCategory[];
16
16
  placeholder?: string;
17
17
  error?: boolean;
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.652",
5
+ "version": "0.0.654",
6
6
  "author": "Mollycodd1e",
7
7
  "license": "ISC",
8
8
  "type": "module",