@konstructio/ui 0.1.2-alpha.24 → 0.1.2-alpha.25
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/components/Dropdown/components/List/List.js +82 -90
- package/dist/components/Dropdown/components/ListItem/ListItem.js +48 -44
- package/dist/components/Dropdown/components/Wrapper.js +1 -2
- package/dist/components/Dropdown/contexts/dropdown.context.js +1 -0
- package/dist/components/Dropdown/contexts/dropdown.provider.js +45 -40
- package/dist/package.json +1 -1
- package/package.json +1 -1
|
@@ -1,145 +1,137 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { S as
|
|
3
|
-
import { d as
|
|
4
|
-
import { forwardRef as
|
|
5
|
-
import { Loading as
|
|
6
|
-
import { cn as
|
|
7
|
-
import { useNavigationUlList as
|
|
8
|
-
import { ListItem as
|
|
9
|
-
import { listVariants as
|
|
10
|
-
import { DEFAULT_LIST_SIZE as
|
|
11
|
-
import { useDropdownContext as
|
|
12
|
-
const
|
|
1
|
+
import { jsxs as H, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { S as V } from "../../../../index-BtQfgaSF.js";
|
|
3
|
+
import { d as Z } from "../../../../debounce-BFejQm9P.js";
|
|
4
|
+
import { forwardRef as B, useRef as w, useState as G, useImperativeHandle as J, useMemo as K, useEffect as M } from "react";
|
|
5
|
+
import { Loading as Q } from "../../../Loading/Loading.js";
|
|
6
|
+
import { cn as a } from "../../../../utils/index.js";
|
|
7
|
+
import { useNavigationUlList as R } from "../../hooks/useNavigationList.js";
|
|
8
|
+
import { ListItem as v } from "../ListItem/ListItem.js";
|
|
9
|
+
import { listVariants as W } from "./List.variants.js";
|
|
10
|
+
import { DEFAULT_LIST_SIZE as X } from "../../constants/pagination.js";
|
|
11
|
+
import { useDropdownContext as Y } from "../../contexts/dropdown.hook.js";
|
|
12
|
+
const ue = B(
|
|
13
13
|
({
|
|
14
14
|
additionalOptions: k,
|
|
15
15
|
className: C,
|
|
16
|
-
inputRef:
|
|
17
|
-
isLoading:
|
|
18
|
-
itemClassName:
|
|
19
|
-
name:
|
|
20
|
-
searchable:
|
|
21
|
-
listItemSecondRowClassName:
|
|
16
|
+
inputRef: i,
|
|
17
|
+
isLoading: F,
|
|
18
|
+
itemClassName: l,
|
|
19
|
+
name: N,
|
|
20
|
+
searchable: b = !1,
|
|
21
|
+
listItemSecondRowClassName: c,
|
|
22
22
|
wrapperInputRef: I,
|
|
23
|
-
isInfiniteScrollEnabled:
|
|
24
|
-
onFetchMoreOptions:
|
|
25
|
-
},
|
|
26
|
-
const
|
|
27
|
-
isOpen:
|
|
28
|
-
searchTerm:
|
|
29
|
-
canFilter:
|
|
30
|
-
canContinueFetching:
|
|
31
|
-
page:
|
|
32
|
-
options:
|
|
23
|
+
isInfiniteScrollEnabled: u,
|
|
24
|
+
onFetchMoreOptions: f
|
|
25
|
+
}, O) => {
|
|
26
|
+
const s = w(null), m = w(null), [p, L] = G(!1), {
|
|
27
|
+
isOpen: T,
|
|
28
|
+
searchTerm: g,
|
|
29
|
+
canFilter: j,
|
|
30
|
+
canContinueFetching: n,
|
|
31
|
+
page: E,
|
|
32
|
+
options: x,
|
|
33
|
+
isTyping: y,
|
|
33
34
|
setOptions: P,
|
|
34
35
|
setPage: S,
|
|
35
|
-
setCanContinueFetching:
|
|
36
|
-
} =
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
const t =
|
|
36
|
+
setCanContinueFetching: D
|
|
37
|
+
} = Y();
|
|
38
|
+
J(O, () => s.current, [s]);
|
|
39
|
+
const d = b && j ? x.filter((e) => {
|
|
40
|
+
const t = g.toLowerCase();
|
|
40
41
|
return (typeof e.label == "string" ? e.label.toLowerCase() : "").includes(t);
|
|
41
|
-
}) :
|
|
42
|
-
|
|
43
|
-
ulRef:
|
|
42
|
+
}) : x;
|
|
43
|
+
R({
|
|
44
|
+
ulRef: s,
|
|
44
45
|
wrapperInputRef: I,
|
|
45
|
-
searchable:
|
|
46
|
-
filteredOptions:
|
|
46
|
+
searchable: b,
|
|
47
|
+
filteredOptions: d
|
|
47
48
|
});
|
|
48
|
-
const
|
|
49
|
-
(e, t,
|
|
50
|
-
),
|
|
51
|
-
|
|
49
|
+
const U = d.filter(
|
|
50
|
+
(e, t, r) => t === r.findIndex((h) => h.value === e.value)
|
|
51
|
+
), _ = d.length === 0, q = K(
|
|
52
|
+
() => Z(async (e) => {
|
|
52
53
|
const [t] = e;
|
|
53
|
-
if (t.isIntersecting)
|
|
54
|
+
if (t.isIntersecting && !p && f && n)
|
|
54
55
|
try {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
S(s), T(q), P([...h, ...v]);
|
|
63
|
-
}
|
|
56
|
+
L(!0);
|
|
57
|
+
const r = E + 1, { data: h, hasMore: z } = await f({
|
|
58
|
+
page: r,
|
|
59
|
+
pageSize: X,
|
|
60
|
+
termOfSearch: g
|
|
61
|
+
});
|
|
62
|
+
S(r), D(z), P((A) => [...A, ...h]);
|
|
64
63
|
} catch {
|
|
65
64
|
console.error("Error fetching more options");
|
|
66
65
|
} finally {
|
|
67
|
-
|
|
66
|
+
L(!1);
|
|
68
67
|
}
|
|
69
68
|
}, 100),
|
|
70
|
-
[
|
|
69
|
+
[p, f, g]
|
|
71
70
|
);
|
|
72
|
-
return
|
|
73
|
-
if (
|
|
74
|
-
const e = new IntersectionObserver(
|
|
71
|
+
return M(() => {
|
|
72
|
+
if (u && n && m.current && !y) {
|
|
73
|
+
const e = new IntersectionObserver(q, {
|
|
75
74
|
threshold: 0.1
|
|
76
75
|
});
|
|
77
|
-
return e.observe(
|
|
76
|
+
return e.observe(m.current), () => e.disconnect();
|
|
78
77
|
}
|
|
79
|
-
}, [
|
|
80
|
-
d,
|
|
81
|
-
l,
|
|
82
|
-
m,
|
|
83
|
-
n,
|
|
84
|
-
o,
|
|
85
|
-
g
|
|
86
|
-
]), /* @__PURE__ */ z(
|
|
78
|
+
}, [u, n, p, y]), /* @__PURE__ */ H(
|
|
87
79
|
"ul",
|
|
88
80
|
{
|
|
89
|
-
ref:
|
|
90
|
-
title:
|
|
81
|
+
ref: s,
|
|
82
|
+
title: N,
|
|
91
83
|
role: "listbox",
|
|
92
|
-
className:
|
|
93
|
-
"data-state":
|
|
84
|
+
className: a(W({ className: C })),
|
|
85
|
+
"data-state": T ? "open" : "closed",
|
|
94
86
|
children: [
|
|
95
|
-
|
|
96
|
-
|
|
87
|
+
F ? /* @__PURE__ */ o(
|
|
88
|
+
v,
|
|
97
89
|
{
|
|
98
|
-
className:
|
|
90
|
+
className: a("select-none", l),
|
|
99
91
|
isClickable: !1,
|
|
100
|
-
inputRef:
|
|
92
|
+
inputRef: i,
|
|
101
93
|
value: "Loading...",
|
|
102
94
|
label: "Loading...",
|
|
103
|
-
listItemSecondRowClassName:
|
|
95
|
+
listItemSecondRowClassName: c
|
|
104
96
|
}
|
|
105
|
-
) :
|
|
106
|
-
|
|
97
|
+
) : _ ? /* @__PURE__ */ o(
|
|
98
|
+
v,
|
|
107
99
|
{
|
|
108
|
-
className:
|
|
100
|
+
className: a("select-none", l),
|
|
109
101
|
isClickable: !1,
|
|
110
|
-
inputRef:
|
|
102
|
+
inputRef: i,
|
|
111
103
|
value: "No options",
|
|
112
104
|
label: "No options",
|
|
113
|
-
listItemSecondRowClassName:
|
|
105
|
+
listItemSecondRowClassName: c
|
|
114
106
|
}
|
|
115
|
-
) :
|
|
116
|
-
|
|
107
|
+
) : U.map((e) => /* @__PURE__ */ o(
|
|
108
|
+
v,
|
|
117
109
|
{
|
|
118
|
-
className:
|
|
110
|
+
className: a("select-none", l),
|
|
119
111
|
isClickable: !0,
|
|
120
|
-
inputRef:
|
|
121
|
-
listItemSecondRowClassName:
|
|
112
|
+
inputRef: i,
|
|
113
|
+
listItemSecondRowClassName: c,
|
|
122
114
|
...e
|
|
123
115
|
},
|
|
124
116
|
e.value
|
|
125
117
|
)),
|
|
126
|
-
|
|
118
|
+
u && n && /* @__PURE__ */ o(
|
|
127
119
|
"li",
|
|
128
120
|
{
|
|
129
|
-
ref:
|
|
121
|
+
ref: m,
|
|
130
122
|
role: "option",
|
|
131
123
|
"data-action": "true",
|
|
132
124
|
className: "flex items-center justify-center py-3",
|
|
133
125
|
onClick: (e) => e.stopPropagation(),
|
|
134
|
-
children: /* @__PURE__ */
|
|
126
|
+
children: /* @__PURE__ */ o(Q, { className: "w-4 h-4 text-aurora-500 select-none" })
|
|
135
127
|
}
|
|
136
128
|
),
|
|
137
|
-
k?.map((e, t) => /* @__PURE__ */
|
|
129
|
+
k?.map((e, t) => /* @__PURE__ */ o("li", { role: "option", "data-action": "true", children: /* @__PURE__ */ o(V, { className: "flex p-2 w-full h-full gap-1 items-center text-sm [&>svg]:w-3.5 [&>svg]:h-3.5 [&>svg]:shrink-0 cursor-pointer select-none hover:bg-gray-50 hover:dark:bg-slate-700 focus:outline-0", children: e }) }, t))
|
|
138
130
|
]
|
|
139
131
|
}
|
|
140
132
|
);
|
|
141
133
|
}
|
|
142
134
|
);
|
|
143
135
|
export {
|
|
144
|
-
|
|
136
|
+
ue as List
|
|
145
137
|
};
|
|
@@ -1,89 +1,93 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { Typography as
|
|
4
|
-
import { cn as
|
|
5
|
-
import { listItemVariants as
|
|
6
|
-
import { useDropdownContext as
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { jsxs as g, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as y, useCallback as m } from "react";
|
|
3
|
+
import { Typography as w } from "../../../Typography/Typography.js";
|
|
4
|
+
import { cn as f } from "../../../../utils/index.js";
|
|
5
|
+
import { listItemVariants as C } from "./ListItem.variants.js";
|
|
6
|
+
import { useDropdownContext as L } from "../../contexts/dropdown.hook.js";
|
|
7
|
+
function I(r, n) {
|
|
8
|
+
const o = n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), c = new RegExp(`(${o})`, "gi");
|
|
9
|
+
return r.split(c).map((t, a) => t.toLowerCase() === n.toLowerCase() ? /* @__PURE__ */ l(
|
|
10
|
+
"mark",
|
|
11
|
+
{
|
|
12
|
+
className: "bg-transparent font-semibold text-slate-800 dark:text-slate-50",
|
|
13
|
+
children: t
|
|
14
|
+
},
|
|
15
|
+
a
|
|
16
|
+
) : /* @__PURE__ */ l("span", { children: t }, a));
|
|
17
|
+
}
|
|
18
|
+
const $ = ({
|
|
19
|
+
isClickable: r,
|
|
20
|
+
className: n,
|
|
21
|
+
inputRef: o,
|
|
22
|
+
listItemSecondRowClassName: c,
|
|
12
23
|
...t
|
|
13
24
|
}) => {
|
|
14
|
-
const { searchTerm: a, highlightSearchEnabled:
|
|
25
|
+
const { searchTerm: a, highlightSearchEnabled: d, setValue: h, toggleOpen: u } = L(), p = y(null), i = m(
|
|
15
26
|
(e) => {
|
|
16
|
-
|
|
27
|
+
h(e.value, o), u(!1);
|
|
17
28
|
},
|
|
18
|
-
[
|
|
19
|
-
),
|
|
20
|
-
(e,
|
|
21
|
-
e.key === "Enter" && (e.stopPropagation(),
|
|
29
|
+
[h, u]
|
|
30
|
+
), x = m(
|
|
31
|
+
(e, s) => {
|
|
32
|
+
e.key === "Enter" && (e.stopPropagation(), i(s));
|
|
22
33
|
},
|
|
23
|
-
[
|
|
24
|
-
),
|
|
25
|
-
(e,
|
|
34
|
+
[i]
|
|
35
|
+
), b = m(
|
|
36
|
+
(e, s) => {
|
|
26
37
|
if (typeof e != "string")
|
|
27
38
|
return e;
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
className: "bg-transparent font-semibold text-slate-800 dark:text-slate-50",
|
|
32
|
-
children: s
|
|
33
|
-
},
|
|
34
|
-
s
|
|
35
|
-
) : s) : [e];
|
|
36
|
-
return /* @__PURE__ */ d(
|
|
37
|
-
C,
|
|
39
|
+
const k = d && a.length > 0 ? I(e, a) : [e];
|
|
40
|
+
return /* @__PURE__ */ g(
|
|
41
|
+
w,
|
|
38
42
|
{
|
|
39
43
|
variant: "body2",
|
|
40
44
|
className: "text-zinc-700 dark:text-slate-50 font-medium",
|
|
41
45
|
children: [
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
k,
|
|
47
|
+
s ? /* @__PURE__ */ l(
|
|
44
48
|
"span",
|
|
45
49
|
{
|
|
46
|
-
className:
|
|
50
|
+
className: f(
|
|
47
51
|
"block font-normal text-sm text-slate-800 dark:text-slate-50",
|
|
48
|
-
|
|
52
|
+
c
|
|
49
53
|
),
|
|
50
|
-
children:
|
|
54
|
+
children: s
|
|
51
55
|
}
|
|
52
56
|
) : null
|
|
53
57
|
]
|
|
54
58
|
}
|
|
55
59
|
);
|
|
56
60
|
},
|
|
57
|
-
[
|
|
61
|
+
[d, a]
|
|
58
62
|
);
|
|
59
|
-
return /* @__PURE__ */
|
|
63
|
+
return /* @__PURE__ */ g(
|
|
60
64
|
"li",
|
|
61
65
|
{
|
|
62
|
-
ref:
|
|
66
|
+
ref: p,
|
|
63
67
|
role: "option",
|
|
64
68
|
"data-action": "false",
|
|
65
|
-
className:
|
|
69
|
+
className: f(C({ className: n })),
|
|
66
70
|
tabIndex: 0,
|
|
67
71
|
onClick: (e) => {
|
|
68
|
-
|
|
72
|
+
r && (i(t), e.stopPropagation());
|
|
69
73
|
},
|
|
70
|
-
onKeyDown: (e) =>
|
|
74
|
+
onKeyDown: (e) => x(e, t),
|
|
71
75
|
children: [
|
|
72
76
|
t.leftIcon ? /* @__PURE__ */ l(
|
|
73
77
|
"span",
|
|
74
78
|
{
|
|
75
|
-
className:
|
|
79
|
+
className: f("w-4 h-4 flex justify-center", {
|
|
76
80
|
"items-center": !t.subLabel,
|
|
77
81
|
"items-baseline -translate-y-2": !!t.subLabel
|
|
78
82
|
}),
|
|
79
83
|
children: t.leftIcon
|
|
80
84
|
}
|
|
81
85
|
) : null,
|
|
82
|
-
|
|
86
|
+
b(t.label, t.subLabel)
|
|
83
87
|
]
|
|
84
88
|
}
|
|
85
89
|
);
|
|
86
90
|
};
|
|
87
91
|
export {
|
|
88
|
-
|
|
92
|
+
$ as ListItem
|
|
89
93
|
};
|
|
@@ -44,7 +44,6 @@ const fe = [
|
|
|
44
44
|
isOpen: f,
|
|
45
45
|
searchTerm: G,
|
|
46
46
|
value: o,
|
|
47
|
-
// canFilter,
|
|
48
47
|
options: n,
|
|
49
48
|
setValue: c,
|
|
50
49
|
setSearchTerm: J,
|
|
@@ -64,7 +63,7 @@ const fe = [
|
|
|
64
63
|
}, [x, n, c, o]);
|
|
65
64
|
const S = (r) => {
|
|
66
65
|
const p = r.target.value;
|
|
67
|
-
K(!0),
|
|
66
|
+
K(!0), c(""), J(p ?? ""), q?.(p);
|
|
68
67
|
const b = n.find(
|
|
69
68
|
(X) => X.value.toLocaleLowerCase() === p.toLocaleLowerCase()
|
|
70
69
|
);
|
|
@@ -1,53 +1,58 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as e, useRef as
|
|
3
|
-
import { DropdownContext as
|
|
4
|
-
import { useToggle as
|
|
5
|
-
const
|
|
6
|
-
children:
|
|
7
|
-
value:
|
|
8
|
-
name:
|
|
9
|
-
highlightSearch:
|
|
10
|
-
options:
|
|
1
|
+
import { jsx as G } from "react/jsx-runtime";
|
|
2
|
+
import { useState as e, useRef as f, useCallback as p, useEffect as T } from "react";
|
|
3
|
+
import { DropdownContext as L } from "./dropdown.context.js";
|
|
4
|
+
import { useToggle as N } from "../../../hooks/useToggle.js";
|
|
5
|
+
const c = 1, O = 300, U = ({
|
|
6
|
+
children: d,
|
|
7
|
+
value: C,
|
|
8
|
+
name: i,
|
|
9
|
+
highlightSearch: E = !1,
|
|
10
|
+
options: n,
|
|
11
11
|
onChange: a,
|
|
12
|
-
onBlur:
|
|
12
|
+
onBlur: u
|
|
13
13
|
}) => {
|
|
14
|
-
const [
|
|
15
|
-
(
|
|
16
|
-
|
|
14
|
+
const [v, l] = e(n), F = f(E), [P, g] = N(!1), [D, I] = e(""), [S, b] = e(!0), [x, o] = e(!0), [A, s] = e(c), [_, h] = e(!1), t = f(void 0), w = p(
|
|
15
|
+
(r, m) => {
|
|
16
|
+
m?.current && (m.current.value = r), t.current && clearTimeout(t.current), h(!0), o(!0), s(c), a?.({ target: { value: r, name: i ?? "" } }), u?.(), t.current = setTimeout(() => {
|
|
17
|
+
h(!1);
|
|
18
|
+
}, O);
|
|
17
19
|
},
|
|
18
|
-
[a,
|
|
19
|
-
),
|
|
20
|
-
(
|
|
21
|
-
|
|
20
|
+
[a, i, u]
|
|
21
|
+
), y = p(
|
|
22
|
+
(r) => {
|
|
23
|
+
g(r), o(!0), s(c);
|
|
22
24
|
},
|
|
23
|
-
[
|
|
25
|
+
[g]
|
|
24
26
|
);
|
|
25
|
-
return
|
|
26
|
-
|
|
27
|
-
}, [
|
|
28
|
-
|
|
27
|
+
return T(() => {
|
|
28
|
+
l(n);
|
|
29
|
+
}, [n.length]), T(() => () => {
|
|
30
|
+
t.current && clearTimeout(t.current);
|
|
31
|
+
}, []), /* @__PURE__ */ G(
|
|
32
|
+
L.Provider,
|
|
29
33
|
{
|
|
30
34
|
value: {
|
|
31
|
-
highlightSearchEnabled:
|
|
32
|
-
isOpen:
|
|
33
|
-
searchTerm:
|
|
34
|
-
value:
|
|
35
|
-
canFilter:
|
|
36
|
-
canContinueFetching:
|
|
37
|
-
page:
|
|
38
|
-
options:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
highlightSearchEnabled: F.current,
|
|
36
|
+
isOpen: P,
|
|
37
|
+
searchTerm: D,
|
|
38
|
+
value: C,
|
|
39
|
+
canFilter: S,
|
|
40
|
+
canContinueFetching: x,
|
|
41
|
+
page: A,
|
|
42
|
+
options: v,
|
|
43
|
+
isTyping: _,
|
|
44
|
+
setOptions: l,
|
|
45
|
+
setPage: s,
|
|
46
|
+
setCanContinueFetching: o,
|
|
47
|
+
setCanFilter: b,
|
|
48
|
+
setSearchTerm: I,
|
|
49
|
+
setValue: w,
|
|
50
|
+
toggleOpen: y
|
|
46
51
|
},
|
|
47
|
-
children:
|
|
52
|
+
children: d
|
|
48
53
|
}
|
|
49
54
|
);
|
|
50
55
|
};
|
|
51
56
|
export {
|
|
52
|
-
|
|
57
|
+
U as DropdownProvider
|
|
53
58
|
};
|
package/dist/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@konstructio/ui",
|
|
3
3
|
"description": "A set of reusable and customizable React components built for konstruct.io",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "0.1.2-alpha.
|
|
5
|
+
"version": "0.1.2-alpha.24",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "dist/index.js",
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@konstructio/ui",
|
|
3
3
|
"description": "A set of reusable and customizable React components built for konstruct.io",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "0.1.2-alpha.
|
|
5
|
+
"version": "0.1.2-alpha.25",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "dist/index.js",
|