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.
- package/dist/assets/src/components/Ui/DropdownInput/DropdownInput.css +1 -1
- package/dist/assets/src/components/Ui/SearchInput/SearchInput.css +1 -1
- package/dist/components/Ui/DropdownInput/DropdownInput.js +80 -65
- package/dist/components/Ui/DropdownMenu/DropdownMenu.js +1 -2
- package/dist/components/Ui/Form/FormItem/FormItem.js +32 -32
- package/dist/components/Ui/NumberInput/NumberInput.js +24 -20
- package/dist/components/Ui/SearchInput/SearchInput.js +85 -80
- package/dist/shared/index.js +5 -0
- package/dist/shared/utils/fn/index.js +5 -0
- package/dist/shared/utils/fn/portals.js +20 -0
- package/dist/shared/utils/index.js +5 -0
- package/package.json +1 -1
|
@@ -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 .
|
|
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
|
|
2
|
-
import { useState as
|
|
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
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
|
17
|
-
const [
|
|
18
|
-
|
|
19
|
-
const e = (
|
|
20
|
-
|
|
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
|
-
}, []),
|
|
26
|
-
N(
|
|
27
|
-
}, [
|
|
28
|
-
const
|
|
29
|
-
N(e),
|
|
30
|
-
},
|
|
31
|
-
var
|
|
32
|
-
if (e.stopPropagation(), !
|
|
33
|
-
const
|
|
34
|
-
|
|
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
|
-
|
|
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__ */
|
|
39
|
-
/* @__PURE__ */
|
|
64
|
+
return /* @__PURE__ */ s("div", { className: `dropdown-input ${O}`, ref: o, children: [
|
|
65
|
+
/* @__PURE__ */ s(
|
|
40
66
|
"select",
|
|
41
67
|
{
|
|
42
|
-
name:
|
|
43
|
-
value:
|
|
44
|
-
onChange: (e) =>
|
|
68
|
+
name: k,
|
|
69
|
+
value: i,
|
|
70
|
+
onChange: (e) => C(e.target.value),
|
|
45
71
|
className: "dropdown-input__native",
|
|
46
|
-
disabled:
|
|
72
|
+
disabled: b,
|
|
47
73
|
children: [
|
|
48
|
-
/* @__PURE__ */ n("option", { value: "", disabled: !0, children:
|
|
49
|
-
|
|
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
|
-
|
|
54
|
-
/* @__PURE__ */
|
|
79
|
+
w && /* @__PURE__ */ n("label", { children: w }),
|
|
80
|
+
/* @__PURE__ */ s(
|
|
55
81
|
"div",
|
|
56
82
|
{
|
|
57
83
|
className: `input-box
|
|
58
|
-
${
|
|
59
|
-
${
|
|
60
|
-
${
|
|
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:
|
|
89
|
+
/* @__PURE__ */ n("span", { className: "input-value", children: i === void 0 ? (
|
|
64
90
|
// Если значение не передано
|
|
65
|
-
/* @__PURE__ */ n("span", { className: "placeholder", children:
|
|
66
|
-
) : ((
|
|
67
|
-
/* @__PURE__ */ n(
|
|
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
|
-
|
|
83
|
-
/* @__PURE__ */ n(
|
|
84
|
-
|
|
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
|
-
|
|
104
|
+
y.displayName = "DropdownInput";
|
|
89
105
|
export {
|
|
90
|
-
|
|
91
|
-
j as default
|
|
106
|
+
y as DropdownInput
|
|
92
107
|
};
|
|
@@ -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
|
|
6
|
+
const w = p.memo(
|
|
7
7
|
({
|
|
8
8
|
name: o,
|
|
9
|
-
children:
|
|
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((
|
|
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
|
-
(
|
|
23
|
-
if (
|
|
24
|
-
const s = l.map((F) => D(F,
|
|
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(
|
|
30
|
-
const
|
|
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]) ||
|
|
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
|
-
...
|
|
40
|
+
...t,
|
|
41
41
|
value: r || "",
|
|
42
42
|
onChange: n
|
|
43
43
|
};
|
|
44
44
|
case "DropdownInput":
|
|
45
45
|
return {
|
|
46
|
-
...
|
|
46
|
+
...t,
|
|
47
47
|
value: r,
|
|
48
48
|
onChange: n
|
|
49
49
|
};
|
|
50
50
|
case "TextInput":
|
|
51
51
|
return {
|
|
52
|
-
...
|
|
53
|
-
...
|
|
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
|
-
...
|
|
60
|
-
...
|
|
61
|
-
value: r || Number(r) ||
|
|
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
|
-
...
|
|
67
|
-
...
|
|
68
|
-
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
|
-
...
|
|
74
|
+
...t,
|
|
75
75
|
isChecked: !!r,
|
|
76
76
|
onChange: (s) => n(s.target.checked)
|
|
77
77
|
};
|
|
78
78
|
case "Radio":
|
|
79
79
|
return {
|
|
80
|
-
...
|
|
80
|
+
...t,
|
|
81
81
|
radioId: `radio-${Array.isArray(o) ? o.join("-") : o}`,
|
|
82
|
-
value:
|
|
83
|
-
isChecked: r ===
|
|
84
|
-
onChange: () => n(
|
|
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
|
-
...
|
|
88
|
+
...t,
|
|
89
89
|
value: r,
|
|
90
90
|
onChange: n
|
|
91
91
|
};
|
|
92
92
|
case "Switch":
|
|
93
93
|
return {
|
|
94
|
-
...
|
|
94
|
+
...t,
|
|
95
95
|
isChecked: !!r,
|
|
96
96
|
onChange: (s) => n(s.target.checked)
|
|
97
97
|
};
|
|
98
98
|
case "FileUpload":
|
|
99
99
|
return {
|
|
100
|
-
...
|
|
100
|
+
...t,
|
|
101
101
|
value: Array.isArray(r) ? r : [],
|
|
102
102
|
onChange: (s) => n(s)
|
|
103
103
|
};
|
|
104
104
|
default:
|
|
105
|
-
return
|
|
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
|
-
|
|
114
|
+
a.props.value,
|
|
115
115
|
c
|
|
116
116
|
]);
|
|
117
|
-
return /* @__PURE__ */ k("div", { className: v, style: b, children: p.cloneElement(
|
|
117
|
+
return /* @__PURE__ */ k("div", { className: v, style: b, children: p.cloneElement(a, y) });
|
|
118
118
|
},
|
|
119
|
-
(o,
|
|
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
|
-
|
|
122
|
+
w as FormItem
|
|
123
123
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as g } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { TextInput as
|
|
4
|
-
const
|
|
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
|
-
],
|
|
21
|
-
({ allowNegative:
|
|
22
|
-
|
|
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: (
|
|
27
|
+
onKeyDown: (e) => {
|
|
28
28
|
var a;
|
|
29
|
-
|
|
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: (
|
|
32
|
-
var u;
|
|
33
|
-
const a =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
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
|
-
|
|
50
|
+
d.displayName = "NumberInput";
|
|
47
51
|
export {
|
|
48
|
-
|
|
52
|
+
d as NumberInput
|
|
49
53
|
};
|
|
@@ -1,110 +1,115 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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 {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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:
|
|
13
|
-
errorMessage:
|
|
14
|
-
hasError:
|
|
15
|
-
className:
|
|
16
|
-
isClearable:
|
|
17
|
-
isLoading:
|
|
18
|
-
value:
|
|
19
|
-
onChange:
|
|
20
|
-
options:
|
|
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,
|
|
23
|
-
|
|
24
|
-
if (
|
|
25
|
-
const e =
|
|
26
|
-
|
|
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
|
-
|
|
29
|
-
}, [
|
|
30
|
-
if (m.trim() === "" &&
|
|
31
|
-
|
|
30
|
+
d("");
|
|
31
|
+
}, [n, o]), p(() => {
|
|
32
|
+
if (m.trim() === "" && x) {
|
|
33
|
+
h(o);
|
|
32
34
|
return;
|
|
33
35
|
}
|
|
34
|
-
const e =
|
|
36
|
+
const e = o.filter(
|
|
35
37
|
(t) => t.label.toLowerCase().includes(m.toLowerCase())
|
|
36
38
|
);
|
|
37
|
-
|
|
38
|
-
}, [m,
|
|
39
|
+
h(e);
|
|
40
|
+
}, [m, o, x]), p(() => {
|
|
39
41
|
const e = (t) => {
|
|
40
|
-
|
|
42
|
+
s.current && !s.current.contains(t.target) && a.current && !a.current.contains(t.target) && i(!1);
|
|
41
43
|
};
|
|
42
|
-
return document.addEventListener("
|
|
43
|
-
document.removeEventListener("
|
|
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
|
-
|
|
50
|
+
g(t), d(t), r == null || r(t), i(!0);
|
|
49
51
|
}, b = (e) => {
|
|
50
|
-
|
|
52
|
+
g(e.value), d(e.label), r == null || r(e.value), i(!1);
|
|
51
53
|
}, O = () => {
|
|
52
|
-
|
|
53
|
-
},
|
|
54
|
-
e.key === "Enter" &&
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
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__ */
|
|
64
|
-
/* @__PURE__ */
|
|
65
|
-
|
|
87
|
+
return /* @__PURE__ */ z("div", { className: "search-input-container", ref: s, children: [
|
|
88
|
+
/* @__PURE__ */ c(
|
|
89
|
+
q,
|
|
66
90
|
{
|
|
67
|
-
name:
|
|
68
|
-
label:
|
|
91
|
+
name: v,
|
|
92
|
+
label: k,
|
|
69
93
|
type: N,
|
|
70
|
-
className: `${
|
|
71
|
-
value:
|
|
94
|
+
className: `${L}`,
|
|
95
|
+
value: A,
|
|
72
96
|
onChange: K,
|
|
73
97
|
placeholder: y,
|
|
74
|
-
id:
|
|
75
|
-
isDisabled:
|
|
76
|
-
isClearable:
|
|
77
|
-
hasError:
|
|
78
|
-
errorMessage:
|
|
79
|
-
isLoading:
|
|
98
|
+
id: P,
|
|
99
|
+
isDisabled: R,
|
|
100
|
+
isClearable: V,
|
|
101
|
+
hasError: E,
|
|
102
|
+
errorMessage: D,
|
|
103
|
+
isLoading: F,
|
|
80
104
|
onFocus: O,
|
|
81
|
-
onKeyDown:
|
|
105
|
+
onKeyDown: T
|
|
82
106
|
}
|
|
83
107
|
),
|
|
84
|
-
/* @__PURE__ */
|
|
85
|
-
|
|
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
|
-
|
|
112
|
+
J.displayName = "SearchInput";
|
|
108
113
|
export {
|
|
109
|
-
|
|
114
|
+
J as SearchInput
|
|
110
115
|
};
|
|
@@ -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
|
+
};
|