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