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