@companix/uikit 0.0.15 → 0.0.16
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.
|
@@ -12,5 +12,6 @@ export interface SelectTagsProps<T> {
|
|
|
12
12
|
size?: 'sm' | 'md' | 'lg';
|
|
13
13
|
fill?: boolean;
|
|
14
14
|
inputRef?: React.Ref<HTMLInputElement>;
|
|
15
|
+
required?: boolean;
|
|
15
16
|
}
|
|
16
17
|
export declare const SelectTags: <T extends string | number>(props: SelectTagsProps<T>) => import("react/jsx-runtime").JSX.Element;
|
package/dist/bundle.es24.js
CHANGED
|
@@ -1,94 +1,96 @@
|
|
|
1
1
|
import { jsx as o, jsxs as c } from "react/jsx-runtime";
|
|
2
|
-
import { useFroozeClosing as
|
|
3
|
-
import { Popover as
|
|
4
|
-
import { OptionItem as
|
|
5
|
-
import { OptionsList as
|
|
6
|
-
import { useState as
|
|
2
|
+
import { useFroozeClosing as M } from "./bundle.es31.js";
|
|
3
|
+
import { Popover as j } from "./bundle.es6.js";
|
|
4
|
+
import { OptionItem as q } from "./bundle.es10.js";
|
|
5
|
+
import { OptionsList as V } from "./bundle.es12.js";
|
|
6
|
+
import { useState as B, useRef as d, useMemo as h } from "react";
|
|
7
7
|
import { Icon as g } from "./bundle.es35.js";
|
|
8
|
-
import { faClose as
|
|
9
|
-
import { attr as
|
|
10
|
-
import { mergeRefs as
|
|
11
|
-
const
|
|
8
|
+
import { faClose as H, faChevronDown as Q } from "@fortawesome/free-solid-svg-icons";
|
|
9
|
+
import { attr as v, getActiveElementByAnotherElement as G, contains as J } from "@companix/utils-browser";
|
|
10
|
+
import { mergeRefs as K } from "react-merge-refs";
|
|
11
|
+
const re = (x) => {
|
|
12
12
|
const {
|
|
13
13
|
options: r,
|
|
14
|
-
closeAfterSelect:
|
|
15
|
-
placeholder:
|
|
14
|
+
closeAfterSelect: C,
|
|
15
|
+
placeholder: N,
|
|
16
16
|
onChange: l,
|
|
17
|
-
emptyText:
|
|
17
|
+
emptyText: R = "Ничего не найдено",
|
|
18
18
|
readOnly: m,
|
|
19
|
-
size:
|
|
19
|
+
size: z = "md",
|
|
20
20
|
value: n,
|
|
21
|
-
inputRef:
|
|
22
|
-
disabled: f
|
|
23
|
-
|
|
21
|
+
inputRef: A,
|
|
22
|
+
disabled: f,
|
|
23
|
+
required: y
|
|
24
|
+
} = x, [i, D] = B(""), a = d(null), b = d(null), { popoverRef: u, froozePopoverPosition: w, handleAnimationEnd: E } = M(), O = h(() => {
|
|
24
25
|
const e = {};
|
|
25
26
|
return r.forEach((t) => {
|
|
26
27
|
e[t.value] = t;
|
|
27
28
|
}), e;
|
|
28
|
-
}, [r]),
|
|
29
|
-
|
|
29
|
+
}, [r]), P = (e) => n.includes(e) ? [...n] : [...n, e], T = (e) => n.filter((t) => e !== t), k = (e, t) => {
|
|
30
|
+
C ? (w(), l(e), t()) : l(e);
|
|
30
31
|
}, p = h(() => i.trim() ? r.filter(({ title: e }) => {
|
|
31
32
|
const t = e.toLowerCase(), s = i.trim().toLowerCase();
|
|
32
33
|
return t.indexOf(s) >= 0;
|
|
33
|
-
}) : r, [i, r]),
|
|
34
|
+
}) : r, [i, r]), I = (e) => {
|
|
34
35
|
if (f) return;
|
|
35
36
|
u.current && u.current.getAttribute("data-state") === "open" && e.preventDefault();
|
|
36
|
-
const t =
|
|
37
|
-
e.defaultPrevented ||
|
|
38
|
-
},
|
|
37
|
+
const t = G(e.currentTarget);
|
|
38
|
+
e.defaultPrevented || J(e.currentTarget, t) || a.current && a.current.focus();
|
|
39
|
+
}, S = (e) => {
|
|
39
40
|
e.target !== a.current && e.preventDefault();
|
|
40
|
-
},
|
|
41
|
-
e.stopPropagation(), l(
|
|
41
|
+
}, $ = (e, t) => {
|
|
42
|
+
e.stopPropagation(), l(T(t));
|
|
42
43
|
};
|
|
43
44
|
return /* @__PURE__ */ o(
|
|
44
|
-
|
|
45
|
+
j,
|
|
45
46
|
{
|
|
46
47
|
minimal: !0,
|
|
47
48
|
ref: u,
|
|
48
49
|
sideOffset: 0,
|
|
49
50
|
matchTarget: "width",
|
|
50
|
-
onAnimationEnd:
|
|
51
|
+
onAnimationEnd: E,
|
|
51
52
|
onOpenAutoFocus: (e) => e.preventDefault(),
|
|
52
53
|
onCloseAutoFocus: (e) => e.preventDefault(),
|
|
53
|
-
content: ({ close: e }) => /* @__PURE__ */ c(
|
|
54
|
-
p.length === 0 && /* @__PURE__ */ o("div", { className: "select-tags-empty", children:
|
|
55
|
-
p.map(({ value: t, title: s, icon:
|
|
56
|
-
|
|
54
|
+
content: ({ close: e }) => /* @__PURE__ */ c(V, { maxHeight: 300, children: [
|
|
55
|
+
p.length === 0 && /* @__PURE__ */ o("div", { className: "select-tags-empty", children: R }),
|
|
56
|
+
p.map(({ value: t, title: s, icon: F }, L) => /* @__PURE__ */ o(
|
|
57
|
+
q,
|
|
57
58
|
{
|
|
58
59
|
active: n.includes(t),
|
|
59
|
-
onClick: () => P(
|
|
60
|
+
onClick: () => k(P(t), e),
|
|
60
61
|
title: s,
|
|
61
|
-
icon:
|
|
62
|
+
icon: F
|
|
62
63
|
},
|
|
63
|
-
`option-item-${t}-${
|
|
64
|
+
`option-item-${t}-${L}`
|
|
64
65
|
))
|
|
65
66
|
] }),
|
|
66
67
|
children: /* @__PURE__ */ o(
|
|
67
68
|
"div",
|
|
68
69
|
{
|
|
69
70
|
className: "form",
|
|
70
|
-
onClick:
|
|
71
|
-
onMouseDown:
|
|
72
|
-
"data-size":
|
|
71
|
+
onClick: I,
|
|
72
|
+
onMouseDown: S,
|
|
73
|
+
"data-size": z,
|
|
74
|
+
"data-required": v(y),
|
|
73
75
|
children: /* @__PURE__ */ c("div", { className: "select-tags-container", children: [
|
|
74
76
|
/* @__PURE__ */ c("div", { className: "select-tags", children: [
|
|
75
77
|
n.length > 0 && /* @__PURE__ */ o(
|
|
76
78
|
"div",
|
|
77
79
|
{
|
|
78
80
|
className: "tag-container",
|
|
79
|
-
ref:
|
|
81
|
+
ref: b,
|
|
80
82
|
role: "listbox",
|
|
81
|
-
"data-readonly":
|
|
83
|
+
"data-readonly": v(m),
|
|
82
84
|
children: n.map((e, t) => /* @__PURE__ */ c("div", { className: "tag", children: [
|
|
83
|
-
/* @__PURE__ */ o("span", { className: "tag-name", children:
|
|
84
|
-
/* @__PURE__ */ o("button", { className: "tag-close-button", onClick: (s) =>
|
|
85
|
+
/* @__PURE__ */ o("span", { className: "tag-name", children: O[e].title }),
|
|
86
|
+
/* @__PURE__ */ o("button", { className: "tag-close-button", onClick: (s) => $(s, e), children: /* @__PURE__ */ o(g, { className: "tag-close-icon", icon: H, size: "xxxs" }) })
|
|
85
87
|
] }, `tag-option-${e}-${t}`))
|
|
86
88
|
}
|
|
87
89
|
),
|
|
88
90
|
(!m || n.length === 0) && /* @__PURE__ */ o(
|
|
89
91
|
"input",
|
|
90
92
|
{
|
|
91
|
-
ref:
|
|
93
|
+
ref: K([A, a]),
|
|
92
94
|
type: "text",
|
|
93
95
|
autoCapitalize: "none",
|
|
94
96
|
autoComplete: "off",
|
|
@@ -98,12 +100,12 @@ const ne = (v) => {
|
|
|
98
100
|
value: i,
|
|
99
101
|
disabled: f,
|
|
100
102
|
readOnly: m,
|
|
101
|
-
placeholder:
|
|
102
|
-
onChange: ({ target: e }) =>
|
|
103
|
+
placeholder: N,
|
|
104
|
+
onChange: ({ target: e }) => D(e.value)
|
|
103
105
|
}
|
|
104
106
|
)
|
|
105
107
|
] }),
|
|
106
|
-
/* @__PURE__ */ o(g, { className: "expand-icon", icon:
|
|
108
|
+
/* @__PURE__ */ o(g, { className: "expand-icon", icon: Q, size: "xxxs" })
|
|
107
109
|
] })
|
|
108
110
|
}
|
|
109
111
|
)
|
|
@@ -111,5 +113,5 @@ const ne = (v) => {
|
|
|
111
113
|
);
|
|
112
114
|
};
|
|
113
115
|
export {
|
|
114
|
-
|
|
116
|
+
re as SelectTags
|
|
115
117
|
};
|