@konstructio/ui 0.1.2-alpha.3 → 0.1.2-alpha.30
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/DatePicker.css +1 -1
- package/dist/Modal-5xSxFoaD.js +99 -0
- package/dist/_commonjsHelpers-DaMA6jEr.js +8 -0
- package/dist/chevron-down-DgT-uSF9.js +5 -0
- package/dist/chevron-right-DYvXLeql.js +7 -0
- package/dist/chevron-up-DrQr2Fwd.js +5 -0
- package/dist/components/Alert/Alert.js +2 -2
- package/dist/components/AlertDialog/AlertDialog.js +1 -1
- package/dist/components/AlertDialog/components/AlertDialogTrigger.js +1 -1
- package/dist/components/AlertDialog/components/index.js +1 -1
- package/dist/components/Badge/Badge.js +30 -33
- package/dist/components/Badge/Badge.variants.js +8 -6
- package/dist/components/Breadcrumb/Breadcrumb.js +1 -1
- package/dist/components/Breadcrumb/components/Item/Item.js +24 -23
- package/dist/components/Breadcrumb/hooks/useBreadcrumb.js +1 -1
- package/dist/components/Button/Button.js +1 -1
- package/dist/components/Button/Button.variants.js +1 -1
- package/dist/components/Card/Card.variants.js +5 -9
- package/dist/components/Checkbox/Checkbox.js +6 -6
- package/dist/components/Command/Command.js +2 -2
- package/dist/components/Command/components/Command.js +1 -1
- package/dist/components/Command/components/CommandEmpty.js +1 -1
- package/dist/components/Command/components/CommandGroup.js +1 -1
- package/dist/components/Command/components/CommandInput.js +2 -2
- package/dist/components/Command/components/CommandItem.js +1 -1
- package/dist/components/Command/components/CommandList.js +1 -1
- package/dist/components/Command/components/CommandSeparator.js +1 -1
- package/dist/components/Command/components/DialogContent.js +2 -2
- package/dist/components/Command/components/DialogOverlay.js +1 -1
- package/dist/components/Datepicker/DatePicker.js +1209 -1147
- package/dist/components/Divider/Divider.variants.js +1 -1
- package/dist/components/Dropdown/Dropdown.js +46 -28
- package/dist/components/Dropdown/Dropdown.variants.js +32 -9
- package/dist/components/Dropdown/components/List/List.js +133 -54
- package/dist/components/Dropdown/components/List/List.variants.js +9 -7
- package/dist/components/Dropdown/components/ListItem/ListItem.js +74 -24
- package/dist/components/Dropdown/components/ListItem/ListItem.variants.js +9 -7
- package/dist/components/Dropdown/components/Wrapper.js +144 -109
- package/dist/components/Dropdown/constants/index.js +4 -0
- package/dist/components/Dropdown/constants/pagination.js +4 -0
- package/dist/components/Dropdown/contexts/dropdown.context.js +26 -8
- package/dist/components/Dropdown/contexts/dropdown.provider.js +48 -19
- package/dist/components/Dropdown/hooks/useDropdown.js +83 -39
- package/dist/components/Dropdown/hooks/useNavigationList.js +28 -36
- package/dist/components/DropdownButton/DropdownButton.js +1 -1
- package/dist/components/Filter/Filter.variants.js +2 -2
- package/dist/components/Filter/components/BadgeDropdown/BadgeMultiSelect.js +1 -1
- package/dist/components/Filter/components/DateFilterDropdown/DateFilterDropdown.js +1 -1
- package/dist/components/Input/Input.js +1 -1
- package/dist/components/Input/Input.variants.js +1 -1
- package/dist/components/Loading/Loading.js +1 -7
- package/dist/components/Modal/Modal.js +2 -2
- package/dist/components/Modal/components/Body/Body.js +1 -1
- package/dist/components/Modal/components/Footer/Footer.js +1 -1
- package/dist/components/Modal/components/Header/Header.js +1 -1
- package/dist/components/Modal/components/Wrapper/Wrapper.js +3 -3
- package/dist/components/Modal/components/index.js +1 -1
- package/dist/components/NumberInput/NumberInput.js +2 -2
- package/dist/components/PhoneNumberInput/PhoneNumberInput.js +8 -0
- package/dist/components/PhoneNumberInput/PhoneNumberInput.variants.js +45 -0
- package/dist/components/PhoneNumberInput/components/FlagContent/FlagContent.js +27 -0
- package/dist/components/PhoneNumberInput/components/FlagSelectorList/FlagSelectorList.js +629 -0
- package/dist/components/PhoneNumberInput/components/FlagSelectorWrapper/FlagSelectorWrapper.js +36 -0
- package/dist/components/PhoneNumberInput/components/TruncateText/TruncateText.js +45 -0
- package/dist/components/PhoneNumberInput/components/Wrapper.js +625 -0
- package/dist/components/PhoneNumberInput/components/index.js +6 -0
- package/dist/components/PhoneNumberInput/contexts/index.js +8 -0
- package/dist/components/PhoneNumberInput/contexts/phone-number.context.js +28 -0
- package/dist/components/PhoneNumberInput/contexts/phone-number.hook.js +13 -0
- package/dist/components/PhoneNumberInput/contexts/phone-number.provider.js +6137 -0
- package/dist/components/PhoneNumberInput/utils/index.js +11 -0
- package/dist/components/PieChart/PieChart.js +647 -664
- package/dist/components/RadioCard/RadioCard.variants.js +1 -6
- package/dist/components/RadioGroup/RadioGroup.js +1 -1
- package/dist/components/Range/Range.js +1 -1
- package/dist/components/Sidebar/Sidebar.variants.js +2 -2
- package/dist/components/Sidebar/components/Wrapper/Wrapper.js +29 -28
- package/dist/components/Slider/Slider.js +1 -1
- package/dist/components/Switch/Switch.js +8 -8
- package/dist/components/Switch/Switch.variants.js +4 -4
- package/dist/components/Tabs/Tabs.js +1 -1
- package/dist/components/Tabs/Tabs.variants.js +45 -24
- package/dist/components/Tabs/components/Content.js +1 -1
- package/dist/components/Tabs/components/List.js +1 -1
- package/dist/components/Tabs/components/Trigger.js +9 -8
- package/dist/components/Tag/Tag.js +1 -1
- package/dist/components/TagSelect/components/Wrapper/Wrapper.js +98 -49
- package/dist/components/TimePicker/TimePicker.variants.js +2 -2
- package/dist/components/TimePicker/components/Wrapper/Wrapper.js +2 -2
- package/dist/components/Toast/Toast.js +206 -181
- package/dist/components/Tooltip/Tooltip.js +1 -1
- package/dist/components/Typography/Typography.variants.js +18 -23
- package/dist/components/VirtualizedTable/VirtualizedTable.js +119 -0
- package/dist/components/VirtualizedTable/VirtualizedTable.variants.js +5 -0
- package/dist/components/VirtualizedTable/assets/chevron-down.js +25 -0
- package/dist/components/VirtualizedTable/assets/chevron-up.js +25 -0
- package/dist/components/VirtualizedTable/assets/index.js +6 -0
- package/dist/components/VirtualizedTable/components/Actions/Actions.js +72 -0
- package/dist/components/VirtualizedTable/components/Body/Body.js +51 -0
- package/dist/components/VirtualizedTable/components/DotPaginate/DotPaginate.js +165 -0
- package/dist/components/VirtualizedTable/components/DropdownPaginate/DropdownPaginate.js +34 -0
- package/dist/components/VirtualizedTable/components/Filter/Filter.js +88 -0
- package/dist/components/VirtualizedTable/components/FormPaginate/FormPaginate.js +48 -0
- package/dist/components/VirtualizedTable/components/Header/Header.js +84 -0
- package/dist/components/VirtualizedTable/components/Pagination/Pagination.js +53 -0
- package/dist/components/VirtualizedTable/components/Skeleton/Skeleton.js +67 -0
- package/dist/components/VirtualizedTable/components/TruncateText/TruncateText.js +34 -0
- package/dist/components/VirtualizedTable/components/WrapperBody/WrapperBody.js +27 -0
- package/dist/components/VirtualizedTable/components/index.js +16 -0
- package/dist/components/VirtualizedTable/constants/index.js +5 -0
- package/dist/components/VirtualizedTable/constants/pagination.js +5 -0
- package/dist/components/VirtualizedTable/contexts/index.js +8 -0
- package/dist/components/VirtualizedTable/contexts/table.context.js +32 -0
- package/dist/components/VirtualizedTable/contexts/table.hook.js +11 -0
- package/dist/components/VirtualizedTable/contexts/table.provider.js +85 -0
- package/dist/components/index.js +79 -73
- package/dist/contexts/theme.provider.js +0 -1
- package/dist/{createLucideIcon-DbC6TvM5.js → createLucideIcon-D4r5Phnh.js} +0 -24
- package/dist/debounce-BFejQm9P.js +200 -0
- package/dist/ellipsis-vertical-BVPtjl5f.js +9 -0
- package/dist/{index-h-Ul0anl.js → index--V_ZsiQe.js} +1 -22
- package/dist/index-2hB40Iuc.js +1873 -0
- package/dist/index-BZPx6jYI.js +8 -0
- package/dist/{index-bwWKd82e.js → index-BbQkJE5L.js} +1 -1
- package/dist/index-BtQfgaSF.js +60 -0
- package/dist/index-C3tHPg8y.js +662 -0
- package/dist/index-CIAmiWcw.js +200 -0
- package/dist/index-CSFe9uC5.js +14 -0
- package/dist/index-CSWGJT-v.js +1722 -0
- package/dist/index-CigKKiZS.js +91 -0
- package/dist/index-DDByhzds.js +137 -0
- package/dist/{index-BAraV3ai.js → index-DH2Fnov1.js} +11 -12
- package/dist/index-DLcqcWxM.js +29 -0
- package/dist/index-Dbt2vBmS.js +136 -0
- package/dist/{index-DB2XhXHn.js → index-DpW9ExsS.js} +7 -7
- package/dist/index-DrWQH0QF.js +55 -0
- package/dist/{index-D3xzCzcO.js → index-X4k_cU8k.js} +4 -4
- package/dist/index-kyuBfLcN.js +479 -0
- package/dist/{index-C1g_chDT.js → index-mPY_8Y5v.js} +2 -2
- package/dist/index-ohdbKsws.js +27 -0
- package/dist/index.d.ts +184 -18
- package/dist/index.js +106 -98
- package/dist/libphonenumber-_7ZyKWA7.js +11549 -0
- package/dist/package.json +46 -32
- package/dist/styles.css +1 -1
- package/dist/ui/civo-theme.css +191 -167
- package/dist/{useBreadcrumb-B8DnuqkR.js → useBreadcrumb-BAHbGQ_O.js} +0 -10
- package/dist/utils/index.js +534 -501
- package/dist/{x-BPcqkRZd.js → x-DPU9OdYH.js} +1 -1
- package/package.json +46 -32
- package/dist/Modal-V67Uz78z.js +0 -98
- package/dist/_commonjsHelpers-C6fGbg64.js +0 -6
- package/dist/chevron-down-BLZPftpV.js +0 -11
- package/dist/chevron-up-RLP4nX7V.js +0 -54
- package/dist/index-BXuxPoz7.js +0 -435
- package/dist/index-BfXxHr_2.js +0 -125
- package/dist/index-C9T9HQaa.js +0 -423
- package/dist/index-CZnD2QxM.js +0 -32
- package/dist/index-CrBonFvu.js +0 -144
- package/dist/index-Cvx4lqTq.js +0 -47
- package/dist/index-DQH6odE9.js +0 -82
- package/dist/index-Oq5GlCHP.js +0 -131
- package/dist/index-iXyXtdgP.js +0 -31
|
@@ -1,133 +1,161 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { Loading as
|
|
4
|
-
import { Typography as
|
|
1
|
+
import { jsxs as d, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as Y, useId as Z, useRef as C, useMemo as ee, useImperativeHandle as te, useEffect as ae } from "react";
|
|
3
|
+
import { Loading as re } from "../../Loading/Loading.js";
|
|
4
|
+
import { Typography as ne } from "../../Typography/Typography.js";
|
|
5
5
|
import { cn as s } from "../../../utils/index.js";
|
|
6
|
-
import { labelVariants as
|
|
7
|
-
import { useDropdown as
|
|
8
|
-
import { List as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
6
|
+
import { labelVariants as oe, inputVariants as se, dropdownVariants as le } from "../Dropdown.variants.js";
|
|
7
|
+
import { useDropdown as ie } from "../hooks/useDropdown.js";
|
|
8
|
+
import { List as ce } from "./List/List.js";
|
|
9
|
+
import { c as pe } from "../../../createLucideIcon-D4r5Phnh.js";
|
|
10
|
+
import { C as ue } from "../../../chevron-up-DrQr2Fwd.js";
|
|
11
|
+
import { useDropdownContext as fe } from "../contexts/dropdown.hook.js";
|
|
12
|
+
const me = [
|
|
13
|
+
["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
|
|
14
|
+
["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
|
|
15
|
+
], de = pe("search", me), je = Y(
|
|
12
16
|
({
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
additionalOptions: V,
|
|
18
|
+
className: O,
|
|
19
|
+
defaultValue: x,
|
|
20
|
+
disabled: a = !1,
|
|
15
21
|
error: f,
|
|
16
|
-
iconClassName:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
iconClassName: R,
|
|
23
|
+
inputClassName: F,
|
|
24
|
+
isLoading: k,
|
|
25
|
+
isRequired: h,
|
|
26
|
+
label: v,
|
|
27
|
+
labelClassName: T,
|
|
20
28
|
listClassName: D,
|
|
21
|
-
listItemClassName:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
placeholder:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
theme:
|
|
28
|
-
wrapperClassName:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
listItemClassName: E,
|
|
30
|
+
listItemSecondRowClassName: M,
|
|
31
|
+
name: m,
|
|
32
|
+
placeholder: N,
|
|
33
|
+
searchable: g = !1,
|
|
34
|
+
showSearchIcon: w,
|
|
35
|
+
theme: W,
|
|
36
|
+
wrapperClassName: _,
|
|
37
|
+
isInfiniteScrollEnabled: $ = !1,
|
|
38
|
+
onFetchMoreOptions: H,
|
|
39
|
+
onBlur: P,
|
|
40
|
+
onSearchChange: U,
|
|
41
|
+
...y
|
|
42
|
+
}, q) => {
|
|
43
|
+
const I = Z(), l = C(null), L = C(null), A = C(0), {
|
|
44
|
+
isOpen: i,
|
|
45
|
+
searchTerm: B,
|
|
46
|
+
value: o,
|
|
47
|
+
options: n,
|
|
48
|
+
setValue: c,
|
|
49
|
+
setSearchTerm: G,
|
|
50
|
+
setCanFilter: J,
|
|
51
|
+
toggleOpen: K
|
|
52
|
+
} = fe(), e = ee(() => n.find(({ value: r }) => r === o), [n, o]), { wrapperRef: Q, wrapperInputRef: j, handleOpen: z } = ie({
|
|
53
|
+
ulRef: L,
|
|
54
|
+
inputRef: l,
|
|
55
|
+
disabled: a,
|
|
56
|
+
internalValue: e,
|
|
57
|
+
onBlur: P
|
|
58
|
+
}), p = m ? `${I}-${m}` : I;
|
|
59
|
+
te(q, () => l.current, [l]), ae(() => {
|
|
60
|
+
if (x && !o) {
|
|
61
|
+
const r = n && n.find((u) => u.value === x);
|
|
62
|
+
r && c(r.value);
|
|
40
63
|
}
|
|
41
|
-
}, [
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
e.abort();
|
|
48
|
-
};
|
|
49
|
-
}, [E, c, w, I, r]);
|
|
50
|
-
const S = (e) => {
|
|
51
|
-
const o = e.target.value;
|
|
52
|
-
w(o);
|
|
53
|
-
const d = a.find(
|
|
54
|
-
(U) => U.value.toLocaleLowerCase() === o.toLocaleLowerCase()
|
|
64
|
+
}, [x, n, c, o]);
|
|
65
|
+
const S = (r) => {
|
|
66
|
+
const u = r.target.value;
|
|
67
|
+
J(!0), c(""), G(u ?? ""), U?.(u);
|
|
68
|
+
const b = n.find(
|
|
69
|
+
(X) => X.value.toLocaleLowerCase() === u.toLocaleLowerCase()
|
|
55
70
|
);
|
|
56
|
-
|
|
71
|
+
c(b ? b.value : e?.value ?? "");
|
|
57
72
|
};
|
|
58
|
-
return /* @__PURE__ */
|
|
73
|
+
return /* @__PURE__ */ d(
|
|
59
74
|
"div",
|
|
60
75
|
{
|
|
61
|
-
ref:
|
|
62
|
-
className: s("flex flex-col w-full relative",
|
|
63
|
-
"data-theme":
|
|
76
|
+
ref: Q,
|
|
77
|
+
className: s("flex flex-col w-full relative", _),
|
|
78
|
+
"data-theme": W,
|
|
64
79
|
children: [
|
|
65
|
-
|
|
80
|
+
v ? /* @__PURE__ */ d(
|
|
66
81
|
"label",
|
|
67
82
|
{
|
|
68
|
-
id:
|
|
69
|
-
className: s(
|
|
70
|
-
htmlFor:
|
|
71
|
-
onClick:
|
|
83
|
+
id: p,
|
|
84
|
+
className: s(oe({ className: T })),
|
|
85
|
+
htmlFor: p,
|
|
86
|
+
onClick: () => !a && z(),
|
|
72
87
|
children: [
|
|
73
|
-
|
|
74
|
-
|
|
88
|
+
v,
|
|
89
|
+
h && /* @__PURE__ */ t("span", { className: "text-red-600 ml-1", children: "*" })
|
|
75
90
|
]
|
|
76
91
|
}
|
|
77
92
|
) : null,
|
|
78
|
-
/* @__PURE__ */
|
|
93
|
+
/* @__PURE__ */ d(
|
|
79
94
|
"div",
|
|
80
95
|
{
|
|
81
|
-
ref:
|
|
82
|
-
id:
|
|
83
|
-
className: s(
|
|
96
|
+
ref: j,
|
|
97
|
+
id: p,
|
|
98
|
+
className: s(
|
|
99
|
+
le({ className: O, hasError: !!f, disabled: a })
|
|
100
|
+
),
|
|
84
101
|
role: "combobox",
|
|
85
|
-
onClick:
|
|
86
|
-
"aria-expanded":
|
|
87
|
-
tabIndex:
|
|
88
|
-
"aria-labelledby":
|
|
102
|
+
onClick: () => !a && K(!i),
|
|
103
|
+
"aria-expanded": i,
|
|
104
|
+
tabIndex: A.current,
|
|
105
|
+
"aria-labelledby": p,
|
|
89
106
|
children: [
|
|
90
|
-
/* @__PURE__ */
|
|
91
|
-
|
|
92
|
-
|
|
107
|
+
/* @__PURE__ */ d("div", { className: "flex gap-2.5 items-center flex-1", children: [
|
|
108
|
+
e?.leftIcon && !w && /* @__PURE__ */ t("span", { className: "w-4 h-4 flex justify-center items-center dark:text-slate-50", children: e.leftIcon }),
|
|
109
|
+
w && /* @__PURE__ */ t(de, { className: "w-4 h-4 text-zinc-500 select-none dark:text-slate-300 dark:group-focus-within:text-slate-50 transition-colors duration-300" }),
|
|
110
|
+
g ? /* @__PURE__ */ t(
|
|
93
111
|
"input",
|
|
94
112
|
{
|
|
95
113
|
type: "text",
|
|
96
|
-
value:
|
|
114
|
+
value: i ? B : e?.label ?? o ?? "",
|
|
97
115
|
onChange: S,
|
|
98
|
-
placeholder:
|
|
99
|
-
className: s(
|
|
100
|
-
"
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
),
|
|
105
|
-
onClick: (e) => {
|
|
106
|
-
e.stopPropagation(), z();
|
|
116
|
+
placeholder: N,
|
|
117
|
+
className: s(se({ className: F }), {
|
|
118
|
+
"text-red-700 placeholder:text-red-700": !!f
|
|
119
|
+
}),
|
|
120
|
+
onClick: (r) => {
|
|
121
|
+
r.stopPropagation(), a || z();
|
|
107
122
|
},
|
|
108
|
-
"aria-label":
|
|
109
|
-
"aria-labelledby":
|
|
123
|
+
"aria-label": v || N,
|
|
124
|
+
"aria-labelledby": p,
|
|
125
|
+
required: h,
|
|
126
|
+
autoComplete: "off",
|
|
127
|
+
autoCapitalize: "words",
|
|
128
|
+
disabled: a,
|
|
129
|
+
tabIndex: -1,
|
|
130
|
+
...y
|
|
110
131
|
}
|
|
111
132
|
) : /* @__PURE__ */ t(
|
|
112
|
-
|
|
133
|
+
ne,
|
|
113
134
|
{
|
|
114
135
|
variant: "body2",
|
|
115
|
-
className: s(
|
|
116
|
-
"text-
|
|
117
|
-
|
|
118
|
-
|
|
136
|
+
className: s(
|
|
137
|
+
"flex-1 text-zinc-400 text-sm dark:text-slate-400",
|
|
138
|
+
{
|
|
139
|
+
"text-red-700": !!f,
|
|
140
|
+
"select-none": !e,
|
|
141
|
+
"text-slate-800 dark:text-slate-50": e,
|
|
142
|
+
"text-slate-400/50 dark:text-slate-50/50": a
|
|
143
|
+
}
|
|
144
|
+
),
|
|
145
|
+
children: e?.label || N
|
|
119
146
|
}
|
|
120
147
|
)
|
|
121
148
|
] }),
|
|
122
|
-
|
|
123
|
-
|
|
149
|
+
k ? /* @__PURE__ */ t(re, { className: "w-4 h-4 text-zinc-500 select-none" }) : !w && /* @__PURE__ */ t(
|
|
150
|
+
ue,
|
|
124
151
|
{
|
|
125
|
-
"data-state":
|
|
152
|
+
"data-state": i ? "open" : "closed",
|
|
126
153
|
className: s(
|
|
127
|
-
"w-4 h-4 text-zinc-500 transition-all duration-
|
|
128
|
-
|
|
154
|
+
"w-4 h-4 text-zinc-500 transition-all duration-100 data-[state=open]:rotate-0 data-[state=closed]:rotate-180 select-none dark:group-focus-within:text-slate-50",
|
|
155
|
+
R,
|
|
129
156
|
{
|
|
130
|
-
"text-red-700": !!f
|
|
157
|
+
"text-red-700": !!f,
|
|
158
|
+
"text-slate-400/50 dark:group-focus-within:text-zinc-500": a
|
|
131
159
|
}
|
|
132
160
|
)
|
|
133
161
|
}
|
|
@@ -138,26 +166,33 @@ const fe = W(
|
|
|
138
166
|
/* @__PURE__ */ t(
|
|
139
167
|
"input",
|
|
140
168
|
{
|
|
141
|
-
ref:
|
|
169
|
+
ref: l,
|
|
142
170
|
type: "text",
|
|
143
|
-
name:
|
|
171
|
+
name: m,
|
|
144
172
|
className: "hidden",
|
|
145
173
|
"aria-hidden": "true",
|
|
146
|
-
required:
|
|
174
|
+
required: h,
|
|
175
|
+
inert: !0,
|
|
176
|
+
defaultValue: e?.value ?? o ?? void 0,
|
|
177
|
+
...y
|
|
147
178
|
}
|
|
148
179
|
),
|
|
149
|
-
/* @__PURE__ */ t(
|
|
150
|
-
|
|
180
|
+
i && /* @__PURE__ */ t(
|
|
181
|
+
ce,
|
|
151
182
|
{
|
|
152
|
-
ref:
|
|
183
|
+
ref: L,
|
|
184
|
+
additionalOptions: V,
|
|
153
185
|
className: D,
|
|
154
|
-
itemClassName:
|
|
155
|
-
name:
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
options:
|
|
159
|
-
isLoading: !!
|
|
160
|
-
searchable:
|
|
186
|
+
itemClassName: E,
|
|
187
|
+
name: m,
|
|
188
|
+
wrapperInputRef: j,
|
|
189
|
+
inputRef: l,
|
|
190
|
+
options: n,
|
|
191
|
+
isLoading: !!k,
|
|
192
|
+
searchable: g,
|
|
193
|
+
listItemSecondRowClassName: M,
|
|
194
|
+
isInfiniteScrollEnabled: $,
|
|
195
|
+
onFetchMoreOptions: H
|
|
161
196
|
}
|
|
162
197
|
)
|
|
163
198
|
]
|
|
@@ -166,5 +201,5 @@ const fe = W(
|
|
|
166
201
|
}
|
|
167
202
|
);
|
|
168
203
|
export {
|
|
169
|
-
|
|
204
|
+
je as Wrapper
|
|
170
205
|
};
|
|
@@ -1,18 +1,36 @@
|
|
|
1
1
|
import { createContext as e } from "react";
|
|
2
|
-
const
|
|
2
|
+
const t = e({
|
|
3
|
+
highlightSearchEnabled: !1,
|
|
3
4
|
isOpen: !1,
|
|
4
|
-
|
|
5
|
-
throw new Error("toggleOpen function must be overridden");
|
|
6
|
-
},
|
|
5
|
+
searchTerm: "",
|
|
7
6
|
value: void 0,
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
canFilter: !0,
|
|
8
|
+
canContinueFetching: !0,
|
|
9
|
+
page: 1,
|
|
10
|
+
options: [],
|
|
11
|
+
isTyping: !1,
|
|
12
|
+
setOptions() {
|
|
13
|
+
throw new Error("setOptions function must be overridden");
|
|
14
|
+
},
|
|
15
|
+
setPage() {
|
|
16
|
+
throw new Error("setPage function must be overridden");
|
|
17
|
+
},
|
|
18
|
+
setCanContinueFetching() {
|
|
19
|
+
throw new Error("setCanContinueFetching function must be overridden");
|
|
20
|
+
},
|
|
21
|
+
setCanFilter() {
|
|
22
|
+
throw new Error("setCanFilter function must be overridden");
|
|
10
23
|
},
|
|
11
|
-
searchTerm: "",
|
|
12
24
|
setSearchTerm() {
|
|
13
25
|
throw new Error("setSearchTerm function must be overridden");
|
|
26
|
+
},
|
|
27
|
+
setValue() {
|
|
28
|
+
throw new Error("setValue function must be overridden");
|
|
29
|
+
},
|
|
30
|
+
toggleOpen() {
|
|
31
|
+
throw new Error("toggleOpen function must be overridden");
|
|
14
32
|
}
|
|
15
33
|
});
|
|
16
34
|
export {
|
|
17
|
-
|
|
35
|
+
t as DropdownContext
|
|
18
36
|
};
|
|
@@ -1,29 +1,58 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { DropdownContext as
|
|
4
|
-
import { useToggle as
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
+
onChange: a,
|
|
12
|
+
onBlur: u
|
|
13
|
+
}) => {
|
|
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);
|
|
9
19
|
},
|
|
10
|
-
[
|
|
20
|
+
[a, i, u]
|
|
21
|
+
), y = p(
|
|
22
|
+
(r) => {
|
|
23
|
+
g(r), o(!0), s(c);
|
|
24
|
+
},
|
|
25
|
+
[g]
|
|
11
26
|
);
|
|
12
|
-
return
|
|
13
|
-
|
|
27
|
+
return T(() => {
|
|
28
|
+
l(n);
|
|
29
|
+
}, [n.length]), T(() => () => {
|
|
30
|
+
t.current && clearTimeout(t.current);
|
|
31
|
+
}, []), /* @__PURE__ */ G(
|
|
32
|
+
L.Provider,
|
|
14
33
|
{
|
|
15
34
|
value: {
|
|
16
|
-
|
|
17
|
-
isOpen:
|
|
18
|
-
searchTerm:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
|
22
51
|
},
|
|
23
|
-
children:
|
|
52
|
+
children: d
|
|
24
53
|
}
|
|
25
54
|
);
|
|
26
55
|
};
|
|
27
56
|
export {
|
|
28
|
-
|
|
57
|
+
U as DropdownProvider
|
|
29
58
|
};
|
|
@@ -1,59 +1,103 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
import { useDropdownContext as
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { useRef as m, useEffect as c, useCallback as b } from "react";
|
|
2
|
+
import { useDropdownContext as L } from "../contexts/dropdown.hook.js";
|
|
3
|
+
const p = ({
|
|
4
|
+
ulRef: f,
|
|
5
|
+
inputRef: t,
|
|
6
|
+
disabled: w,
|
|
7
|
+
internalValue: u,
|
|
8
|
+
onBlur: g
|
|
9
|
+
}) => {
|
|
10
|
+
const r = m(null), a = m(null), { value: i, setSearchTerm: v, setCanFilter: d, toggleOpen: n } = L();
|
|
11
|
+
c(() => {
|
|
12
|
+
const e = new AbortController(), o = (l) => {
|
|
13
|
+
l.key === "Escape" && n(!1);
|
|
14
|
+
}, s = (l) => {
|
|
15
|
+
r.current?.contains(l.target) || n(!1);
|
|
10
16
|
};
|
|
11
|
-
return document.addEventListener("keydown",
|
|
12
|
-
signal:
|
|
13
|
-
}), document.addEventListener("mousedown",
|
|
14
|
-
signal:
|
|
17
|
+
return document.addEventListener("keydown", o, {
|
|
18
|
+
signal: e.signal
|
|
19
|
+
}), document.addEventListener("mousedown", s, {
|
|
20
|
+
signal: e.signal
|
|
15
21
|
}), document.addEventListener(
|
|
16
22
|
"visibilitychange",
|
|
17
23
|
() => {
|
|
18
|
-
document.hidden &&
|
|
24
|
+
document.hidden && n(!1);
|
|
19
25
|
},
|
|
20
26
|
{
|
|
21
|
-
signal:
|
|
27
|
+
signal: e.signal
|
|
22
28
|
}
|
|
23
|
-
),
|
|
24
|
-
"
|
|
25
|
-
() => {
|
|
26
|
-
|
|
29
|
+
), a.current?.addEventListener(
|
|
30
|
+
"focusin",
|
|
31
|
+
(l) => {
|
|
32
|
+
!w && l.target?.matches(":focus-visible") && n(!0);
|
|
27
33
|
},
|
|
28
|
-
{ signal:
|
|
34
|
+
{ signal: e.signal }
|
|
29
35
|
), () => {
|
|
30
|
-
|
|
36
|
+
e.abort();
|
|
31
37
|
};
|
|
32
|
-
}, [
|
|
33
|
-
const
|
|
34
|
-
return
|
|
38
|
+
}, [n, r]), c(() => {
|
|
39
|
+
const e = new AbortController();
|
|
40
|
+
return a.current?.addEventListener(
|
|
35
41
|
"keydown",
|
|
36
|
-
(
|
|
37
|
-
if (
|
|
38
|
-
const
|
|
39
|
-
|
|
42
|
+
(o) => {
|
|
43
|
+
if (o.key === "ArrowDown") {
|
|
44
|
+
const s = f.current?.querySelector("li");
|
|
45
|
+
s && s.focus();
|
|
40
46
|
}
|
|
41
47
|
},
|
|
42
|
-
{ signal:
|
|
48
|
+
{ signal: e.signal }
|
|
43
49
|
), () => {
|
|
44
|
-
|
|
50
|
+
e.abort();
|
|
51
|
+
};
|
|
52
|
+
}, [a, f]), c(() => {
|
|
53
|
+
const e = new AbortController();
|
|
54
|
+
return t?.current?.addEventListener(
|
|
55
|
+
"focusin",
|
|
56
|
+
() => {
|
|
57
|
+
v(u?.value ?? ""), d(!1);
|
|
58
|
+
},
|
|
59
|
+
{ signal: e.signal }
|
|
60
|
+
), t?.current?.addEventListener(
|
|
61
|
+
"focusout",
|
|
62
|
+
() => {
|
|
63
|
+
d(!0);
|
|
64
|
+
},
|
|
65
|
+
{ signal: e.signal }
|
|
66
|
+
), a.current?.addEventListener(
|
|
67
|
+
"focus",
|
|
68
|
+
() => {
|
|
69
|
+
d(!1);
|
|
70
|
+
},
|
|
71
|
+
{ signal: e.signal }
|
|
72
|
+
), r.current?.addEventListener(
|
|
73
|
+
"focusout",
|
|
74
|
+
(o) => {
|
|
75
|
+
r.current?.contains(o.relatedTarget) || n(!1);
|
|
76
|
+
},
|
|
77
|
+
{ signal: e.signal }
|
|
78
|
+
), () => {
|
|
79
|
+
e.abort();
|
|
80
|
+
};
|
|
81
|
+
}, [i]), c(() => {
|
|
82
|
+
t?.current && (t.current.value = i && u?.value || "");
|
|
83
|
+
}, [u, i]), c(() => {
|
|
84
|
+
const e = new AbortController();
|
|
85
|
+
return r.current?.addEventListener("focusout", (o) => {
|
|
86
|
+
const s = o.relatedTarget;
|
|
87
|
+
(!s || !r.current?.contains(s)) && (t?.current?.value || g?.());
|
|
88
|
+
}), () => {
|
|
89
|
+
e.abort();
|
|
45
90
|
};
|
|
46
|
-
}, [
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
}, [
|
|
91
|
+
}, [n, r, v, g, i]);
|
|
92
|
+
const E = b(() => {
|
|
93
|
+
n(!0), requestAnimationFrame(() => t?.current?.focus());
|
|
94
|
+
}, [t, n]);
|
|
50
95
|
return {
|
|
51
|
-
wrapperRef:
|
|
52
|
-
wrapperInputRef:
|
|
53
|
-
handleOpen:
|
|
54
|
-
handleOpenIfClosed: p
|
|
96
|
+
wrapperRef: r,
|
|
97
|
+
wrapperInputRef: a,
|
|
98
|
+
handleOpen: E
|
|
55
99
|
};
|
|
56
100
|
};
|
|
57
101
|
export {
|
|
58
|
-
|
|
102
|
+
p as useDropdown
|
|
59
103
|
};
|