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