triafly-ui-kit 1.0.80 → 1.0.82

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 +1 @@
1
- .dropdown-input{display:flex;flex-direction:column;min-width:200px}.dropdown-input.sm .input-box{height:36px}.dropdown-input__native{display:none}.dropdown-input label{margin:0 0 8px}.dropdown-input .input-box{position:relative;border:1px solid var(--color-border-primary-default);border-radius:8px;padding:10px 8px;cursor:pointer;display:flex;justify-content:space-between;align-items:center;outline:none;height:44px;background-color:var(--color-bg-neutral-basic-default)}.dropdown-input .input-box.opened{border:2px solid var(--color-border-primary-default);padding:9px 7px}.dropdown-input .input-box.disabled{background-color:var(--color-bg-island-disabled);pointer-events:none}.dropdown-input .input-box.invalid{border-color:var(--color-border-error-default)}.dropdown-input .input-box.invalid>span{color:var(--color-border-error-default)}.dropdown-input .input-box.invalid svg *{fill:var(--color-border-error-default)}.dropdown-input .input-box .placeholder,.dropdown-input .input-box .input-value,.dropdown-input .input-box .options li{color:var(--color-text-primary-default)}.dropdown-input .input-box .caret *{fill:var(--color-icon-secondary-default)}.dropdown-input .options{position:absolute;top:100%;bottom:auto;left:0;right:0;max-height:304px;overflow-y:auto;overflow-x:hidden;background-color:var(--color-bg-neutral-basic-default);border-radius:8px;border:1px solid var(--color-border-primary-default);margin:1px -1px 0;z-index:21}.dropdown-input .options.above{bottom:calc(100% + 1px);top:auto}.dropdown-input .options li{padding:0 8px;min-height:36px;cursor:pointer;display:flex;align-items:center}.dropdown-input .options li:hover,.dropdown-input .options li.dropdown-input__option--selected{background-color:var(--color-bg-neutral-lightest-default)}.dropdown-input .helper-text{font-size:12px;color:var(--color-text-secondary-default);margin:8px 0 0;display:flex;align-items:center}.dropdown-input .helper-text.error{color:var(--color-border-error-default)}.dropdown-input .helper-text.error .icon{margin:0 4px 0 0}.dropdown-input .helper-text.error .icon>*{fill:var(--color-border-error-default)}
1
+ .dropdown-input{display:flex;flex-direction:column;min-width:200px}.dropdown-input.sm .input-box{height:36px}.dropdown-input__native{display:none}.dropdown-input label{margin:0 0 8px}.dropdown-input .input-box{position:relative;border:1px solid var(--color-border-primary-default);border-radius:8px;padding:10px 8px;cursor:pointer;display:flex;justify-content:space-between;align-items:center;outline:none;height:44px;background-color:var(--color-bg-neutral-basic-default)}.dropdown-input .input-box.opened{border:2px solid var(--color-border-primary-default);padding:9px 7px}.dropdown-input .input-box.disabled{background-color:var(--color-bg-island-disabled);pointer-events:none}.dropdown-input .input-box.invalid{border-color:var(--color-border-error-default)}.dropdown-input .input-box.invalid>span{color:var(--color-border-error-default)}.dropdown-input .input-box.invalid svg *{fill:var(--color-border-error-default)}.dropdown-input .input-box .placeholder,.dropdown-input .input-box .input-value,.dropdown-input .input-box .options li{color:var(--color-text-primary-default)}.dropdown-input .input-box .caret *{fill:var(--color-icon-secondary-default)}.dropdown-input .optionsgg{position:absolute;top:100%;bottom:auto;left:0;right:0;max-height:304px;overflow-y:auto;overflow-x:hidden;background-color:var(--color-bg-neutral-basic-default);border-radius:8px;border:1px solid var(--color-border-primary-default);margin:1px -1px 0;z-index:21}.dropdown-input .optionsgg.above{bottom:calc(100% + 1px);top:auto}.dropdown-input .optionsgg li{padding:0 8px;min-height:36px;cursor:pointer;display:flex;align-items:center}.dropdown-input .optionsgg li:hover,.dropdown-input .optionsgg li.dropdown-input__option--selected{background-color:var(--color-bg-neutral-lightest-default)}.dropdown-input .helper-text{font-size:12px;color:var(--color-text-secondary-default);margin:8px 0 0;display:flex;align-items:center}.dropdown-input .helper-text.error{color:var(--color-border-error-default)}.dropdown-input .helper-text.error .icon{margin:0 4px 0 0}.dropdown-input .helper-text.error .icon>*{fill:var(--color-border-error-default)}.dropdown-portal{background-color:var(--color-bg-neutral-basic-default);border-radius:8px;border:1px solid var(--color-border-primary-default);box-shadow:0 2px 8px #00000026;overflow-y:auto}.dropdown-portal .options{list-style:none;padding:0;margin:0}.dropdown-portal .options li{padding:8px 12px;min-height:36px;cursor:pointer;display:flex;align-items:center}.dropdown-portal .options li:hover{background-color:var(--color-bg-neutral-lightest-default)}
@@ -1 +1 @@
1
- .search-input{border:1px solid var(--color-border-primary-default);border-radius:22px;margin:0 12px 0 0}.search-input:focus-within{border:2px solid var(--color-border-primary-default);margin:0 11px 0 -1px}.search-input:focus-within .text-input .input-container input{margin:-1px}.search-input .text-input .input-container input{border:none}.search-input .text-input .input-container input:focus{outline:none}.search-input__label{margin:0 0 8px}.search-input .guess-box{padding:0 12px 12px}.search-input .guess-box ul{border-top:1px solid var(--color-border-primary-default);padding:12px 0 0}.search-input .guess-box ul li{min-height:36px;display:flex;align-items:center;padding:0 8px;cursor:pointer}.search-input .guess-box ul li:hover{background-color:var(--color-bg-innerisland-default)}.dropdown-input-test{position:relative}.dropdown-input-test .caret{fill:var(--color-icon-secondary-default);position:absolute;bottom:9px;right:10px}.dropdown-input-test .input-box{position:relative;cursor:pointer;display:flex;justify-content:space-between;align-items:center;outline:none;background-color:var(--color-bg-neutral-basic-default)}.dropdown-input-test .input-box.disabled{background-color:var(--color-bg-island-disabled);pointer-events:none}.dropdown-input-test .input-box.invalid{border-color:var(--color-border-error-default)}.dropdown-input-test .input-box.invalid>span{color:var(--color-border-error-default)}.dropdown-input-test .input-box.invalid svg *{fill:var(--color-border-error-default)}.dropdown-input-test .input-box .placeholder{color:var(--color-text-secondary-default)}.dropdown-input-test .options{position:absolute;top:100%;bottom:auto;left:1%;right:1%;max-height:304px;overflow-y:auto;overflow-x:hidden;background-color:var(--color-bg-neutral-basic-default);border-radius:8px;border:1px solid var(--color-border-primary-default);margin:1px -1px 0;z-index:21}.dropdown-input-test .options.above{bottom:calc(100% + 1px);top:auto}.dropdown-input-test .options li{padding:0 8px;min-height:36px;cursor:pointer;display:flex;align-items:center}.dropdown-input-test .options li:hover,.dropdown-input-test .options li.dropdown-input__option--selected{background-color:var(--color-bg-neutral-lightest-default)}
1
+ .search-input{border:1px solid var(--color-border-primary-default);border-radius:22px;margin:0 12px 0 0}.search-input:focus-within{border:2px solid var(--color-border-primary-default);margin:0 11px 0 -1px}.search-input:focus-within .text-input .input-container input{margin:-1px}.search-input .text-input .input-container input{border:none}.search-input .text-input .input-container input:focus{outline:none}.search-input__label{margin:0 0 8px}.search-input .guess-box{padding:0 12px 12px}.search-input .guess-box ul{border-top:1px solid var(--color-border-primary-default);padding:12px 0 0}.search-input .guess-box ul li{min-height:36px;display:flex;align-items:center;padding:0 8px;cursor:pointer}.search-input .guess-box ul li:hover{background-color:var(--color-bg-innerisland-default)}.dropdown-input-test{position:relative}.dropdown-input-test .caret{fill:var(--color-icon-secondary-default);position:absolute;bottom:9px;right:10px}.dropdown-input-test .input-box{position:relative;cursor:pointer;display:flex;justify-content:space-between;align-items:center;outline:none;background-color:var(--color-bg-neutral-basic-default)}.dropdown-input-test .input-box.disabled{background-color:var(--color-bg-island-disabled);pointer-events:none}.dropdown-input-test .input-box.invalid{border-color:var(--color-border-error-default)}.dropdown-input-test .input-box.invalid>span{color:var(--color-border-error-default)}.dropdown-input-test .input-box.invalid svg *{fill:var(--color-border-error-default)}.dropdown-input-test .input-box .placeholder{color:var(--color-text-secondary-default)}.dropdown-input-test .options{position:absolute;top:100%;bottom:auto;left:1%;right:1%;max-height:304px;overflow-y:auto;overflow-x:hidden;background-color:var(--color-bg-neutral-basic-default);border-radius:8px;border:1px solid var(--color-border-primary-default);margin:1px -1px 0;z-index:21}.dropdown-input-test .options.above{bottom:calc(100% + 1px);top:auto}.dropdown-input-test .options li{padding:0 8px;min-height:36px;cursor:pointer;display:flex;align-items:center}.dropdown-input-test .options li:hover,.dropdown-input-test .options li.dropdown-input__option--selected{background-color:var(--color-bg-neutral-lightest-default)}.search-input-container{position:relative;display:inline-block;width:100%}.search-input-container .caret{position:absolute;right:10px;top:50%;transform:translateY(-50%);cursor:pointer;z-index:1;fill:var(--color-icon-secondary-default)}.suggestions-portal{background-color:var(--color-bg-neutral-basic-default);border-radius:8px;border:1px solid var(--color-border-primary-default);box-shadow:0 2px 8px #00000026;overflow-y:auto}.suggestions-portal .suggestions-list{list-style:none;padding:0;margin:0}.suggestions-portal .suggestions-list li{padding:8px 12px;min-height:36px;cursor:pointer;display:flex;align-items:center}.suggestions-portal .suggestions-list li:hover{background-color:var(--color-bg-neutral-lightest-default)}
@@ -1,92 +1,107 @@
1
- import { jsxs as c, jsx as n } from "react/jsx-runtime";
2
- import { useState as m, useRef as O, useEffect as g } from "react";
1
+ import { jsxs as s, jsx as n } from "react/jsx-runtime";
2
+ import { useState as h, useRef as P, useEffect as v } from "react";
3
+ import { createPortal as B } from "react-dom";
3
4
  import '../../../assets/src/components/Ui/DropdownInput/DropdownInput.css';/* empty css */
4
- import { IconCaretUpDown as E, IconWarningCircle as P } from "../Icons/Icons.js";
5
- const j = ({
6
- label: v,
7
- options: i,
8
- value: o,
9
- onChange: f,
10
- name: C = "DropdownInput",
11
- placeholder: r,
12
- errorMessage: d = !1,
13
- isDisabled: h = !1,
14
- className: k = ""
5
+ import { IconCaretUpDown as H, IconWarningCircle as L } from "../Icons/Icons.js";
6
+ import { getPortalContainer as _, releasePortal as j } from "../../../shared/utils/fn/portals.js";
7
+ const $ = "dropdown-input-global-portal", y = ({
8
+ label: w,
9
+ options: c,
10
+ value: d,
11
+ onChange: g,
12
+ name: k = "DropdownInput",
13
+ placeholder: p,
14
+ errorMessage: u = !1,
15
+ isDisabled: b = !1,
16
+ className: O = ""
15
17
  }) => {
16
- var w;
17
- const [p, u] = m(!1), [t, N] = m(o || ""), [I, x] = m(!1), s = O(null);
18
- g(() => {
19
- const e = (l) => {
20
- s.current && !s.current.contains(l.target) && u(!1);
18
+ var I;
19
+ const [m, f] = h(!1), [i, N] = h(d || ""), [x, R] = h(!1), o = P(null), r = P(null);
20
+ v(() => (r.current = _($), () => j($)), []), v(() => {
21
+ const e = (t) => {
22
+ o.current && !o.current.contains(t.target) && r.current && !r.current.contains(t.target) && f(!1);
21
23
  };
22
24
  return document.addEventListener("click", e), () => {
23
25
  document.removeEventListener("click", e);
24
26
  };
25
- }, []), g(() => {
26
- N(o || "");
27
- }, [o]);
28
- const b = (e) => {
29
- N(e), u(!1), f && f(e);
30
- }, $ = (e) => {
31
- var l;
32
- if (e.stopPropagation(), !p) {
33
- const a = (l = s.current) == null ? void 0 : l.getBoundingClientRect(), D = window.innerHeight - ((a == null ? void 0 : a.bottom) || 0);
34
- x(D < 304);
27
+ }, []), v(() => {
28
+ N(d || "");
29
+ }, [d]);
30
+ const C = (e) => {
31
+ N(e), f(!1), g && g(e);
32
+ }, D = (e) => {
33
+ var t;
34
+ if (e.stopPropagation(), !m) {
35
+ const l = (t = o.current) == null ? void 0 : t.getBoundingClientRect(), a = window.innerHeight - ((l == null ? void 0 : l.bottom) || 0);
36
+ R(a < 304);
35
37
  }
36
- u((a) => !a);
38
+ f((l) => !l);
39
+ }, E = () => {
40
+ var l;
41
+ if (!m || !r.current || !o.current) return null;
42
+ const e = (l = o.current) == null ? void 0 : l.getBoundingClientRect(), t = {
43
+ position: "fixed",
44
+ width: e == null ? void 0 : e.width,
45
+ left: e == null ? void 0 : e.left,
46
+ maxHeight: "304px",
47
+ zIndex: 9999
48
+ };
49
+ return x ? t.bottom = `${window.innerHeight - ((e == null ? void 0 : e.top) || 0)}px` : t.top = `${e == null ? void 0 : e.bottom}px`, B(
50
+ /* @__PURE__ */ n("div", { className: "dropdown-portal", style: t, children: /* @__PURE__ */ n("ul", { className: `options ${x ? "above" : ""}`, children: c.map((a) => /* @__PURE__ */ n(
51
+ "li",
52
+ {
53
+ onClick: (A) => {
54
+ A.stopPropagation(), C(a.value);
55
+ },
56
+ className: i === a.value ? "selected" : "",
57
+ children: a.label
58
+ },
59
+ a.value
60
+ )) }) }),
61
+ r.current
62
+ );
37
63
  };
38
- return /* @__PURE__ */ c("div", { className: `dropdown-input ${k}`, ref: s, children: [
39
- /* @__PURE__ */ c(
64
+ return /* @__PURE__ */ s("div", { className: `dropdown-input ${O}`, ref: o, children: [
65
+ /* @__PURE__ */ s(
40
66
  "select",
41
67
  {
42
- name: C,
43
- value: t,
44
- onChange: (e) => b(e.target.value),
68
+ name: k,
69
+ value: i,
70
+ onChange: (e) => C(e.target.value),
45
71
  className: "dropdown-input__native",
46
- disabled: h,
72
+ disabled: b,
47
73
  children: [
48
- /* @__PURE__ */ n("option", { value: "", disabled: !0, children: r }),
49
- i.map((e) => /* @__PURE__ */ n("option", { value: e.value, children: e.label }, e.value))
74
+ /* @__PURE__ */ n("option", { value: "", disabled: !0, children: p }),
75
+ c.map((e) => /* @__PURE__ */ n("option", { value: e.value, children: e.label }, e.value))
50
76
  ]
51
77
  }
52
78
  ),
53
- v && /* @__PURE__ */ n("label", { children: v }),
54
- /* @__PURE__ */ c(
79
+ w && /* @__PURE__ */ n("label", { children: w }),
80
+ /* @__PURE__ */ s(
55
81
  "div",
56
82
  {
57
83
  className: `input-box
58
- ${p ? "opened" : ""}
59
- ${h ? "disabled" : ""}
60
- ${d ? "invalid" : ""}`,
61
- onClick: $,
84
+ ${m ? "opened" : ""}
85
+ ${b ? "disabled" : ""}
86
+ ${u ? "invalid" : ""}`,
87
+ onClick: D,
62
88
  children: [
63
- /* @__PURE__ */ n("span", { className: "input-value", children: t === void 0 ? (
89
+ /* @__PURE__ */ n("span", { className: "input-value", children: i === void 0 ? (
64
90
  // Если значение не передано
65
- /* @__PURE__ */ n("span", { className: "placeholder", children: r })
66
- ) : ((w = i.find((e) => e.value === t)) == null ? void 0 : w.label) || /* @__PURE__ */ n("span", { className: "placeholder", children: r }) }),
67
- /* @__PURE__ */ n(E, { className: "caret" }),
68
- p && /* @__PURE__ */ n("ul", { className: `options ${I ? "above" : ""}`, children: i.map((e) => /* @__PURE__ */ n(
69
- "li",
70
- {
71
- onClick: (l) => {
72
- l.stopPropagation(), b(e.value);
73
- },
74
- className: t === e.value ? "option--selected" : "",
75
- children: e.label
76
- },
77
- e.value
78
- )) })
91
+ /* @__PURE__ */ n("span", { className: "placeholder", children: p })
92
+ ) : ((I = c.find((e) => e.value === i)) == null ? void 0 : I.label) || /* @__PURE__ */ n("span", { className: "placeholder", children: p }) }),
93
+ /* @__PURE__ */ n(H, { className: "caret" })
79
94
  ]
80
95
  }
81
96
  ),
82
- d && /* @__PURE__ */ c("span", { className: "helper-text error", children: [
83
- /* @__PURE__ */ n(P, { className: "icon", size: 12 }),
84
- d
85
- ] })
97
+ u && /* @__PURE__ */ s("span", { className: "helper-text error", children: [
98
+ /* @__PURE__ */ n(L, { className: "icon", size: 12 }),
99
+ u
100
+ ] }),
101
+ E()
86
102
  ] });
87
103
  };
88
- j.displayName = "DropdownInput";
104
+ y.displayName = "DropdownInput";
89
105
  export {
90
- j as DropdownInput,
91
- j as default
106
+ y as DropdownInput
92
107
  };
@@ -79,6 +79,5 @@ const W = ({
79
79
  ] });
80
80
  };
81
81
  export {
82
- W as DropdownMenu,
83
- W as default
82
+ W as DropdownMenu
84
83
  };
@@ -3,106 +3,106 @@ import p, { useContext as A, useMemo as C, useEffect as I, useCallback as E } fr
3
3
  import { FormContext as f } from "../FormContext/FormContext.js";
4
4
  import { validateRule as D } from "../utils/fn.js";
5
5
  import { getChildType as R } from "./fn.js";
6
- const B = p.memo(
6
+ const w = p.memo(
7
7
  ({
8
8
  name: o,
9
- children: t,
9
+ children: a,
10
10
  rules: l,
11
11
  label: d,
12
12
  isDisabled: h,
13
13
  style: b,
14
14
  classNameItem: v
15
15
  }) => {
16
- const e = A(f), [, m] = p.useReducer((a) => a + 1, 0), c = h || (e == null ? void 0 : e.disabled), u = C(() => Array.isArray(o) ? o : [o], [o]);
16
+ const e = A(f), [, m] = p.useReducer((t) => t + 1, 0), c = h || (e == null ? void 0 : e.disabled), u = C(() => Array.isArray(o) ? o : [o], [o]);
17
17
  I(() => {
18
18
  if (e)
19
19
  return e.setFieldRules(u, l || []), e.subscribe(u, m);
20
20
  }, [u, l, e]);
21
21
  const r = e == null ? void 0 : e.getFieldValue(u), i = e == null ? void 0 : e.getFieldError(u), n = E(
22
- (a) => {
23
- if (console.log(a), !c && (e == null || e.setFieldValue(u, a), l)) {
24
- const s = l.map((F) => D(F, a)).filter(Boolean);
22
+ (t) => {
23
+ if (!c && (e == null || e.setFieldValue(u, t), l)) {
24
+ const s = l.map((F) => D(F, t)).filter(Boolean);
25
25
  e == null || e.setFieldError(u, s);
26
26
  }
27
27
  },
28
28
  [u, l, c]
29
- ), g = R(t), y = C(() => {
30
- const a = {
29
+ ), g = R(a), y = C(() => {
30
+ const t = {
31
31
  name: u,
32
32
  label: d,
33
33
  isDisabled: c,
34
34
  hasError: !!(i != null && i.length),
35
- errorMessage: (i == null ? void 0 : i[0]) || t.props.errorMessage
35
+ errorMessage: (i == null ? void 0 : i[0]) || a.props.errorMessage
36
36
  };
37
37
  switch (g) {
38
38
  case "TextareaInput":
39
39
  return {
40
- ...a,
40
+ ...t,
41
41
  value: r || "",
42
42
  onChange: n
43
43
  };
44
44
  case "DropdownInput":
45
45
  return {
46
- ...a,
46
+ ...t,
47
47
  value: r,
48
48
  onChange: n
49
49
  };
50
50
  case "TextInput":
51
51
  return {
52
- ...a,
53
- ...t.props,
52
+ ...t,
53
+ ...a.props,
54
54
  value: r || "",
55
55
  onChange: (s) => n(s.target.value)
56
56
  };
57
57
  case "NumberInput":
58
58
  return {
59
- ...a,
60
- ...t.props,
61
- value: r || Number(r) || 0,
59
+ ...t,
60
+ ...a.props,
61
+ value: r || Number(r) || "",
62
62
  onChange: (s) => n(s.target.value)
63
63
  };
64
64
  case "ButtonsArray":
65
65
  return {
66
- ...a,
67
- ...t.props,
68
- tabs: t.props.tabs || [],
66
+ ...t,
67
+ ...a.props,
68
+ tabs: a.props.tabs || [],
69
69
  activeKey: r !== void 0 ? r : null,
70
70
  onChange: (s) => n(s)
71
71
  };
72
72
  case "Checkbox":
73
73
  return {
74
- ...a,
74
+ ...t,
75
75
  isChecked: !!r,
76
76
  onChange: (s) => n(s.target.checked)
77
77
  };
78
78
  case "Radio":
79
79
  return {
80
- ...a,
80
+ ...t,
81
81
  radioId: `radio-${Array.isArray(o) ? o.join("-") : o}`,
82
- value: t.props.value,
83
- isChecked: r === t.props.value,
84
- onChange: () => n(t.props.value)
82
+ value: a.props.value,
83
+ isChecked: r === a.props.value,
84
+ onChange: () => n(a.props.value)
85
85
  };
86
86
  case "SearchInput":
87
87
  return {
88
- ...a,
88
+ ...t,
89
89
  value: r,
90
90
  onChange: n
91
91
  };
92
92
  case "Switch":
93
93
  return {
94
- ...a,
94
+ ...t,
95
95
  isChecked: !!r,
96
96
  onChange: (s) => n(s.target.checked)
97
97
  };
98
98
  case "FileUpload":
99
99
  return {
100
- ...a,
100
+ ...t,
101
101
  value: Array.isArray(r) ? r : [],
102
102
  onChange: (s) => n(s)
103
103
  };
104
104
  default:
105
- return a;
105
+ return t;
106
106
  }
107
107
  }, [
108
108
  u,
@@ -111,13 +111,13 @@ const B = p.memo(
111
111
  r,
112
112
  g,
113
113
  n,
114
- t.props.value,
114
+ a.props.value,
115
115
  c
116
116
  ]);
117
- return /* @__PURE__ */ k("div", { className: v, style: b, children: p.cloneElement(t, y) });
117
+ return /* @__PURE__ */ k("div", { className: v, style: b, children: p.cloneElement(a, y) });
118
118
  },
119
- (o, t) => o.name === t.name && o.rules === t.rules && o.label === t.label && o.isDisabled === t.isDisabled
119
+ (o, a) => o.name === a.name && o.rules === a.rules && o.label === a.label && o.isDisabled === a.isDisabled
120
120
  );
121
121
  export {
122
- B as FormItem
122
+ w as FormItem
123
123
  };
@@ -1,7 +1,7 @@
1
1
  import { jsx as g } from "react/jsx-runtime";
2
- import { forwardRef as o } from "react";
3
- import { TextInput as h } from "../TextInput/TextInput.js";
4
- const l = [
2
+ import { forwardRef as h } from "react";
3
+ import { TextInput as o } from "../TextInput/TextInput.js";
4
+ const y = [
5
5
  "0",
6
6
  "1",
7
7
  "2",
@@ -17,33 +17,37 @@ const l = [
17
17
  "Tab",
18
18
  "ArrowLeft",
19
19
  "ArrowRight"
20
- ], s = o(
21
- ({ allowNegative: r = !1, allowDecimal: c = !1, ...n }, f) => /* @__PURE__ */ g(
22
- h,
20
+ ], d = h(
21
+ ({ allowNegative: l = !1, allowDecimal: r = !1, ...n }, f) => /* @__PURE__ */ g(
22
+ o,
23
23
  {
24
24
  ...n,
25
25
  ref: f,
26
26
  type: "text",
27
- onKeyDown: (t) => {
27
+ onKeyDown: (e) => {
28
28
  var a;
29
- c && t.key === "." && !t.currentTarget.value.includes(".") && l.push("."), r && t.key === "-" && (t.currentTarget.selectionStart === 0 || t.currentTarget.value === "") && l.push("-"), !l.includes(t.key) && !(t.ctrlKey && ["a", "c", "v", "x"].includes(t.key.toLowerCase())) && t.preventDefault(), (a = n.onKeyDown) == null || a.call(n, t);
29
+ r && e.key === "." && !e.currentTarget.value.includes(".") || l && e.key === "-" && (e.currentTarget.selectionStart === 0 || e.currentTarget.value === "") || (!y.includes(e.key) && !(e.ctrlKey && ["a", "c", "v", "x"].includes(e.key.toLowerCase())) && e.preventDefault(), (a = n.onKeyDown) == null || a.call(n, e));
30
30
  },
31
- onChange: (t) => {
32
- var u;
33
- const a = t.target.value;
34
- let e = a.replace(/[^-0-9.]/g, "");
35
- if (r ? (e.match(/-/g) || []).length > 1 && (e = e.replace(/-/g, ""), e.length > 0 && (e = "-" + e)) : e = e.replace(/-/g, ""), !c)
36
- e = e.replace(/\./g, "");
37
- else if ((e.match(/\./g) || []).length > 1) {
38
- const i = e.split(".");
39
- e = i[0] + "." + i.slice(1).join("");
31
+ onChange: (e) => {
32
+ var c, u;
33
+ const a = e.target.value;
34
+ if (a === "" || a === "-") {
35
+ (c = n.onChange) == null || c.call(n, e);
36
+ return;
40
37
  }
41
- a !== e && (t.target.value = e), (u = n.onChange) == null || u.call(n, t);
38
+ let t = a.replace(/[^-0-9.]/g, "");
39
+ if (l ? (t.match(/-/g) || []).length > 1 && (t = t.replace(/-/g, ""), t.length > 0 && (t = "-" + t)) : t = t.replace(/-/g, ""), !r)
40
+ t = t.replace(/\./g, "");
41
+ else if ((t.match(/\./g) || []).length > 1) {
42
+ const i = t.split(".");
43
+ t = i[0] + "." + i.slice(1).join("");
44
+ }
45
+ a !== t && (e.target.value = t), (u = n.onChange) == null || u.call(n, e);
42
46
  }
43
47
  }
44
48
  )
45
49
  );
46
- s.displayName = "NumberInput";
50
+ d.displayName = "NumberInput";
47
51
  export {
48
- s as NumberInput
52
+ d as NumberInput
49
53
  };
@@ -1,110 +1,115 @@
1
- import { jsxs as I, Fragment as T, jsx as l } from "react/jsx-runtime";
2
- import { useState as o, useRef as H, useEffect as w } from "react";
3
- import { TextInput as U } from "../TextInput/TextInput.js";
1
+ import { jsxs as z, jsx as c } from "react/jsx-runtime";
2
+ import { createPortal as U } from "react-dom";
3
+ import { useState as l, useRef as S, useEffect as p } from "react";
4
4
  import '../../../assets/src/components/Ui/SearchInput/SearchInput.css';/* empty css */
5
- import { IconCaretUpDown as q } from "../Icons/Icons.js";
6
- const z = ({
7
- name: k = "SearchInput",
8
- label: x,
5
+ import { getPortalContainer as Y, releasePortal as _ } from "../../../shared/utils/fn/portals.js";
6
+ import { TextInput as q } from "../TextInput/TextInput.js";
7
+ import { IconCaretUpDown as G } from "../Icons/Icons.js";
8
+ const I = "search-input-global-portal", J = ({
9
+ name: v = "SearchInput",
10
+ label: k,
9
11
  placeholder: y = "",
10
12
  type: N = "text",
11
- id: $,
12
- isDisabled: h = !1,
13
- errorMessage: F = "",
14
- hasError: V = !1,
15
- className: D = "",
16
- isClearable: E,
17
- isLoading: L,
18
- value: r = "",
19
- onChange: s,
20
- options: n = []
13
+ id: P,
14
+ isDisabled: R = !1,
15
+ errorMessage: D = "",
16
+ hasError: E = !1,
17
+ className: L = "",
18
+ isClearable: V,
19
+ isLoading: F,
20
+ value: n = "",
21
+ onChange: r,
22
+ options: o = []
21
23
  }) => {
22
- const [m, v] = o(r), [j, i] = o(""), [u, p] = o([]), [d, c] = o(!1), [g, A] = o(!1), [B, C] = o(!1), f = H(null);
23
- w(() => {
24
- if (r) {
25
- const e = n.find((t) => t.value === r);
26
- i(e ? e.label : r);
24
+ const [m, g] = l(n), [A, d] = l(""), [f, h] = l([]), [w, i] = l(!1), [x, B] = l(!1), [C, H] = l(!1), s = S(null), a = S(null);
25
+ p(() => (a.current = Y(I), () => _(I)), []), p(() => {
26
+ if (n) {
27
+ const e = o.find((t) => t.value === n);
28
+ d(e ? e.label : n), g(n);
27
29
  } else
28
- i("");
29
- }, [r, n]), w(() => {
30
- if (m.trim() === "" && g) {
31
- p(n);
30
+ d("");
31
+ }, [n, o]), p(() => {
32
+ if (m.trim() === "" && x) {
33
+ h(o);
32
34
  return;
33
35
  }
34
- const e = n.filter(
36
+ const e = o.filter(
35
37
  (t) => t.label.toLowerCase().includes(m.toLowerCase())
36
38
  );
37
- p(e);
38
- }, [m, n, g]), w(() => {
39
+ h(e);
40
+ }, [m, o, x]), p(() => {
39
41
  const e = (t) => {
40
- f.current && !f.current.contains(t.target) && c(!1);
42
+ s.current && !s.current.contains(t.target) && a.current && !a.current.contains(t.target) && i(!1);
41
43
  };
42
- return document.addEventListener("mousedown", e), () => {
43
- document.removeEventListener("mousedown", e);
44
+ return document.addEventListener("click", e), () => {
45
+ document.removeEventListener("click", e);
44
46
  };
45
47
  }, []);
46
48
  const K = (e) => {
47
49
  const t = e.target.value;
48
- v(t), i(t), s == null || s(t), c(!0);
50
+ g(t), d(t), r == null || r(t), i(!0);
49
51
  }, b = (e) => {
50
- v(e.value), i(e.label), s == null || s(e.value), c(!1);
52
+ g(e.value), d(e.label), r == null || r(e.value), i(!1);
51
53
  }, O = () => {
52
- A(!0), c(!0), p(n);
53
- }, P = (e) => {
54
- e.key === "Enter" && u.length > 0 && d && b(u[0]);
55
- }, S = (e) => {
56
- var t;
57
- if (e.stopPropagation(), !d) {
58
- const a = (t = f.current) == null ? void 0 : t.getBoundingClientRect(), R = window.innerHeight - ((a == null ? void 0 : a.bottom) || 0);
59
- C(R < 304);
54
+ B(!0), i(!0), h(o);
55
+ }, T = (e) => {
56
+ e.key === "Enter" && f.length > 0 && w && b(f[0]);
57
+ }, $ = (e) => {
58
+ if (e.stopPropagation(), !w && s.current) {
59
+ const t = s.current.getBoundingClientRect(), u = window.innerHeight - t.bottom;
60
+ H(u < 304 && t.top >= 304);
60
61
  }
61
- c((a) => !a);
62
+ i((t) => !t);
63
+ }, j = () => {
64
+ if (!w || !x || f.length === 0 || !s.current || !a.current)
65
+ return null;
66
+ const e = s.current.getBoundingClientRect(), t = {
67
+ position: "fixed",
68
+ width: e.width,
69
+ left: e.left,
70
+ maxHeight: "304px",
71
+ zIndex: 9999
72
+ };
73
+ return C ? t.bottom = `${window.innerHeight - e.top}px` : t.top = `${e.bottom}px`, U(
74
+ /* @__PURE__ */ c("div", { className: "suggestions-portal", style: t, children: /* @__PURE__ */ c("ul", { className: "suggestions-list", children: f.map((u) => /* @__PURE__ */ c(
75
+ "li",
76
+ {
77
+ onClick: () => {
78
+ b(u);
79
+ },
80
+ children: u.label
81
+ },
82
+ u.value
83
+ )) }) }),
84
+ a.current
85
+ );
62
86
  };
63
- return /* @__PURE__ */ I(T, { children: [
64
- /* @__PURE__ */ l(
65
- U,
87
+ return /* @__PURE__ */ z("div", { className: "search-input-container", ref: s, children: [
88
+ /* @__PURE__ */ c(
89
+ q,
66
90
  {
67
- name: k,
68
- label: x,
91
+ name: v,
92
+ label: k,
69
93
  type: N,
70
- className: `${D}`,
71
- value: j,
94
+ className: `${L}`,
95
+ value: A,
72
96
  onChange: K,
73
97
  placeholder: y,
74
- id: $,
75
- isDisabled: h,
76
- isClearable: E,
77
- hasError: V,
78
- errorMessage: F,
79
- isLoading: L,
98
+ id: P,
99
+ isDisabled: R,
100
+ isClearable: V,
101
+ hasError: E,
102
+ errorMessage: D,
103
+ isLoading: F,
80
104
  onFocus: O,
81
- onKeyDown: P
105
+ onKeyDown: T
82
106
  }
83
107
  ),
84
- /* @__PURE__ */ I("div", { className: "dropdown-input-test", children: [
85
- /* @__PURE__ */ l("div", { className: "caret", onClick: S, children: /* @__PURE__ */ l(q, {}) }),
86
- d && g && u.length > 0 && /* @__PURE__ */ l(
87
- "div",
88
- {
89
- className: `input-box
90
- ${d ? "opened" : ""}
91
- ${h ? "disabled" : ""}`,
92
- ref: f,
93
- onClick: S,
94
- children: /* @__PURE__ */ l("ul", { className: `options ${B ? "above" : ""}`, children: u.map((e, t) => /* @__PURE__ */ l(
95
- "li",
96
- {
97
- onClick: () => b(e),
98
- children: e.label
99
- },
100
- `${e.value}-${t}`
101
- )) })
102
- }
103
- )
104
- ] })
108
+ /* @__PURE__ */ c("div", { className: "caret", onClick: $, children: /* @__PURE__ */ c(G, {}) }),
109
+ j()
105
110
  ] });
106
111
  };
107
- z.displayName = "SearchInput";
112
+ J.displayName = "SearchInput";
108
113
  export {
109
- z as SearchInput
114
+ J as SearchInput
110
115
  };
@@ -0,0 +1,5 @@
1
+ import { getPortalContainer as o, releasePortal as t } from "./utils/fn/portals.js";
2
+ export {
3
+ o as getPortalContainer,
4
+ t as releasePortal
5
+ };
@@ -0,0 +1,5 @@
1
+ import { getPortalContainer as o, releasePortal as t } from "./portals.js";
2
+ export {
3
+ o as getPortalContainer,
4
+ t as releasePortal
5
+ };
@@ -0,0 +1,20 @@
1
+ const n = /* @__PURE__ */ new Map(), r = (t) => {
2
+ if (n.has(t)) {
3
+ const e = n.get(t);
4
+ n.set(t, { ...e, refCount: e.refCount + 1 });
5
+ } else {
6
+ const e = document.createElement("div");
7
+ document.body.appendChild(e), n.set(t, { element: e, refCount: 1 });
8
+ }
9
+ return n.get(t).element;
10
+ }, s = (t) => {
11
+ const e = n.get(t);
12
+ if (e) {
13
+ const o = e.refCount - 1;
14
+ o <= 0 ? (document.body.removeChild(e.element), n.delete(t)) : n.set(t, { ...e, refCount: o });
15
+ }
16
+ };
17
+ export {
18
+ r as getPortalContainer,
19
+ s as releasePortal
20
+ };
@@ -0,0 +1,5 @@
1
+ import { getPortalContainer as o, releasePortal as t } from "./fn/portals.js";
2
+ export {
3
+ o as getPortalContainer,
4
+ t as releasePortal
5
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triafly-ui-kit",
3
- "version": "1.0.80",
3
+ "version": "1.0.82",
4
4
  "description": "UI Kit from Triafly",
5
5
  "main": "./dist/main.js",
6
6
  "module": "./dist/main.js",