@companix/uikit 0.0.49 → 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/Select/Select.scss +7 -0
- package/dist/Select/index.d.ts +1 -0
- package/dist/SelectTags/index.d.ts +1 -0
- package/dist/bundle.es12.js +29 -27
- package/dist/bundle.es27.js +47 -45
- 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;
|
|
@@ -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.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,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
|
};
|
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 },
|