stone-kit 0.0.131 → 0.0.136

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.
@@ -3,7 +3,7 @@ import { Option } from '../ui/SortSelect.types';
3
3
 
4
4
  interface IUseSortSelect {
5
5
  selectedOption: Option | null;
6
- setSelectedOption: React.Dispatch<React.SetStateAction<Option | null>>;
6
+ setSelectedOption?: (event: Option | null) => void;
7
7
  setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
8
8
  containerRef: React.RefObject<HTMLDivElement>;
9
9
  isOpen: boolean;
@@ -1,5 +1,5 @@
1
1
  import "react/jsx-runtime";
2
- import { u as m } from "../../../useSortSelect-C-PfwcIF.js";
2
+ import { u as m } from "../../../useSortSelect-BTrKnFKx.js";
3
3
  import "../../../index-DIxK0V-G.js";
4
4
  export {
5
5
  m as useSortSelect
@@ -1,7 +1,7 @@
1
1
  import { jsxs as r, jsx as t } from "react/jsx-runtime";
2
- import { useState as p, useRef as B, useEffect as E } from "react";
3
- import { c as L } from "../../../index-DIxK0V-G.js";
4
- import { s as e, u as M } from "../../../useSortSelect-C-PfwcIF.js";
2
+ import { useState as C, useRef as I, useEffect as B } from "react";
3
+ import { c as E } from "../../../index-DIxK0V-G.js";
4
+ import { s as e, u as L } from "../../../useSortSelect-BTrKnFKx.js";
5
5
  import { NewIcon as u } from "../../NewIcon/ui/NewIcon.js";
6
6
  import "../../Button/ui/Button.js";
7
7
  import "../../mobileButton/ui/MobileButton.js";
@@ -9,56 +9,57 @@ import "../../DestinationTab/ui/DestinationTab.js";
9
9
  import "../../RoundButton/ui/RoundButton.js";
10
10
  import "../../Tag/ui/Tag.js";
11
11
  import "../../Switcher/ui/Switcher.js";
12
- import { Text as W } from "../../Text/ui/Text.js";
12
+ import { Text as M } from "../../Text/ui/Text.js";
13
13
  import "../../Flex/ui/Flex.js";
14
14
  import "../../Input/ui/Input.js";
15
- import { Modal as j } from "../../Modal/ui/Modal.js";
15
+ import { Modal as W } from "../../Modal/ui/Modal.js";
16
16
  import "../../TabSwitcher/ui/TabSwitcher.js";
17
17
  import "../../GroupedInput/ui/GroupedInputs.js";
18
18
  import "../../MetroTag/ui/MetroTag.js";
19
19
  import "../../Select/ui/Select.js";
20
- import { useClientWidth as w } from "../../../shared/useClientWidth.js";
21
- const n = L.bind(e), D = ({
22
- options: s,
23
- placeholder: f = "",
20
+ import { useClientWidth as j } from "../../../shared/useClientWidth.js";
21
+ const l = E.bind(e), w = ({
22
+ options: n,
23
+ selectedOption: f,
24
+ placeholder: S = "",
24
25
  error: O,
25
- disabled: S,
26
- additionalClass: h = "",
27
- onChange: v,
26
+ disabled: h,
27
+ additionalClass: v = "",
28
+ onChange: c,
28
29
  onBlur: N,
29
30
  mini: b
30
31
  }) => {
31
- const [x, y] = p(s[0]), [o, i] = p(!1), c = B(null), { isMobile: m, isDesktop: k } = w(), { handleBlur: C, getInputValue: I, getOption: a, handleDocumentClick: d } = M({
32
- selectedOption: x,
33
- setSelectedOption: y,
32
+ const [o, i] = C(!1), m = I(null), { isMobile: a, isDesktop: x } = j(), { handleBlur: y, getInputValue: k, getOption: d, handleDocumentClick: p } = L({
33
+ selectedOption: f,
34
+ setSelectedOption: c,
34
35
  setIsOpen: i,
35
- containerRef: c,
36
+ containerRef: m,
36
37
  isOpen: o,
37
- isDesktop: k,
38
- placeholder: f,
39
- onChange: v,
38
+ isDesktop: x,
39
+ placeholder: S,
40
+ onChange: c,
40
41
  onBlur: N
41
42
  });
42
- return E(() => (document.addEventListener("click", d), () => {
43
- document.removeEventListener("click", d);
43
+ return B(() => (document.addEventListener("click", p), () => {
44
+ document.removeEventListener("click", p);
44
45
  }), []), /* @__PURE__ */ r(
45
46
  "div",
46
47
  {
47
- ref: c,
48
- className: n(e.sortSelectWrapper, { [e.sortSelectWrapperError]: O }, h),
48
+ ref: m,
49
+ className: l(e.sortSelectWrapper, { [e.sortSelectWrapperError]: O }, v),
49
50
  tabIndex: 0,
50
- onBlur: C,
51
+ onBlur: y,
51
52
  children: [
52
- /* @__PURE__ */ r("div", { className: n(e.inputWrapper), children: [
53
+ /* @__PURE__ */ r("div", { className: l(e.inputWrapper), children: [
53
54
  /* @__PURE__ */ t(
54
55
  "input",
55
56
  {
56
57
  type: "text",
57
58
  readOnly: !0,
58
- value: I(),
59
- className: n(
59
+ value: k(),
60
+ className: l(
60
61
  e.selectedOptions,
61
- { [e.selectOptionsDisabled]: S },
62
+ { [e.selectOptionsDisabled]: h },
62
63
  { [e.selectionOptionMini]: b }
63
64
  ),
64
65
  onClick: () => i(!o)
@@ -73,8 +74,8 @@ const n = L.bind(e), D = ({
73
74
  }
74
75
  )
75
76
  ] }),
76
- o && m && /* @__PURE__ */ r(
77
- j,
77
+ o && a && /* @__PURE__ */ r(
78
+ W,
78
79
  {
79
80
  isOpen: o,
80
81
  emitIsOpen: i,
@@ -82,7 +83,7 @@ const n = L.bind(e), D = ({
82
83
  createPortalObj: { domNode: document.querySelector("body") },
83
84
  children: [
84
85
  /* @__PURE__ */ r("div", { className: e.mobileSortHeader, children: [
85
- /* @__PURE__ */ t(W, { children: "Сортировка" }),
86
+ /* @__PURE__ */ t(M, { children: "Сортировка" }),
86
87
  /* @__PURE__ */ t("div", { onClick: () => i(!1), children: /* @__PURE__ */ t(
87
88
  u,
88
89
  {
@@ -91,16 +92,16 @@ const n = L.bind(e), D = ({
91
92
  }
92
93
  ) })
93
94
  ] }),
94
- /* @__PURE__ */ t("div", { className: e.mobileOptionList, children: s.map((l) => a(l)) })
95
+ /* @__PURE__ */ t("div", { className: e.mobileOptionList, children: n.map((s) => d(s)) })
95
96
  ]
96
97
  }
97
98
  ),
98
- o && !m && /* @__PURE__ */ t("div", { className: e.optionsList, children: s.map((l) => a(l)) })
99
+ o && !a && /* @__PURE__ */ t("div", { className: e.optionsList, children: n.map((s) => d(s)) })
99
100
  ]
100
101
  }
101
102
  );
102
103
  };
103
- D.displayName = "SortSelect";
104
+ w.displayName = "SortSelect";
104
105
  export {
105
- D as SortSelect
106
+ w as SortSelect
106
107
  };
@@ -4,10 +4,11 @@ export interface Option {
4
4
  }
5
5
  export interface SortSelectProps {
6
6
  options: Option[];
7
+ selectedOption: Option | null;
7
8
  placeholder?: string;
8
9
  error?: boolean;
9
10
  disabled?: boolean;
10
- onChange?: (event: Option) => void;
11
+ onChange?: (event: Option | null) => void;
11
12
  onBlur?: (event: Option) => void;
12
13
  additionalClass?: string;
13
14
  mini?: boolean;
@@ -16,42 +16,41 @@ const b = "_sortSelectWrapper_vmknt_1", x = "_selectedOptions_vmknt_10", B = "_s
16
16
  checkBox: A,
17
17
  checkBoxChecked: H,
18
18
  innerCheck: M
19
- }, _ = p.bind(e), q = ({
19
+ }, l = p.bind(e), q = ({
20
20
  selectedOption: n,
21
- setSelectedOption: m,
22
- setIsOpen: s,
23
- containerRef: i,
24
- onBlur: r,
21
+ setSelectedOption: s,
22
+ setIsOpen: m,
23
+ containerRef: r,
24
+ onBlur: i,
25
25
  onChange: a,
26
26
  isDesktop: k,
27
27
  placeholder: u
28
28
  }) => {
29
29
  const v = (t) => (o) => {
30
30
  o.stopPropagation();
31
- const l = (n == null ? void 0 : n.value) === t.value ? null : t;
32
- if (m(l), a) {
31
+ const _ = (n == null ? void 0 : n.value) === t.value ? null : t;
32
+ if (s && s(_), a) {
33
33
  const d = {
34
34
  ...o,
35
- target: { value: l }
35
+ target: { value: _ }
36
36
  };
37
37
  a(d);
38
38
  }
39
- s(!1);
40
39
  };
41
40
  return { handleDocumentClick: (t) => {
42
- i.current && !i.current.contains(t.target) && s(!1);
41
+ r.current && !r.current.contains(t.target) && m(!1);
43
42
  }, handleBlur: (t) => {
44
- if (r) {
43
+ if (i) {
45
44
  const o = {
46
45
  ...t,
47
46
  target: { value: n }
48
47
  };
49
- r(o);
48
+ i(o);
50
49
  }
51
50
  }, getInputValue: () => k ? n ? n.label : u : "", getOption: (t) => /* @__PURE__ */ h(
52
51
  "div",
53
52
  {
54
- className: _(e.option, {
53
+ className: l(e.option, {
55
54
  [e.selected]: (n == null ? void 0 : n.value) === t.value
56
55
  }),
57
56
  onClick: v(t),
@@ -60,7 +59,7 @@ const b = "_sortSelectWrapper_vmknt_1", x = "_selectedOptions_vmknt_10", B = "_s
60
59
  /* @__PURE__ */ c(
61
60
  "div",
62
61
  {
63
- className: _(e.checkBox, {
62
+ className: l(e.checkBox, {
64
63
  [e.checkBoxChecked]: (n == null ? void 0 : n.value) === t.value
65
64
  }),
66
65
  children: (n == null ? void 0 : n.value) === t.value && /* @__PURE__ */ c("div", { className: e.innerCheck })
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.131",
5
+ "version": "0.0.136",
6
6
  "author": "Mollycodd1e",
7
7
  "license": "ISC",
8
8
  "type": "module",