@mci-ui/mci-ui 0.0.87 → 0.0.89
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/index.css +1 -1
- package/dist/shared/ui/MciModal/MciModal.js +30 -28
- package/dist/shared/ui/mciAccordion/MciAccordion.js +97 -64
- package/dist/shared/ui/mciBreadcrumb/MciBreadcrumb.js +45 -25
- package/dist/shared/ui/mciButton/MciButton.js +39 -31
- package/dist/shared/ui/mciCheck/MciCheck.js +86 -76
- package/dist/shared/ui/mciDrawer/MciDrawer.js +78 -54
- package/dist/shared/ui/mciInput/MciInput.js +39 -40
- package/dist/shared/ui/mciLoader/MciLoader.js +14 -14
- package/dist/shared/ui/mciPagination/MciPagination.js +28 -18
- package/dist/shared/ui/mciPicker/MciPicker.js +53 -53
- package/dist/shared/ui/mciSelect/MciSelect.js +42 -41
- package/dist/shared/ui/mciTable/MciTable.js +97 -90
- package/dist/shared/ui/mciTable/MciTableClamp2.js +4 -3
- package/dist/shared/ui/mciTable/MciTableColumnsPanel.js +100 -79
- package/dist/shared/ui/mciTabs/MciTabs.js +66 -55
- package/dist/shared/ui/mciToggle/MciToggle.js +51 -43
- package/dist/shared/ui/mciUpload/MciUpload.js +129 -107
- package/dist/types/shared/types/mci-table.types.d.ts +2 -0
- package/dist/types/shared/types/ui/accordion.types.d.ts +1 -0
- package/dist/types/shared/types/ui/breadcrumb.types.d.ts +1 -1
- package/dist/types/shared/types/ui/button.types.d.ts +1 -1
- package/dist/types/shared/types/ui/check.types.d.ts +1 -1
- package/dist/types/shared/types/ui/drawer.types.d.ts +2 -0
- package/dist/types/shared/types/ui/loader.types.d.ts +1 -1
- package/dist/types/shared/types/ui/pagination.types.d.ts +1 -1
- package/dist/types/shared/types/ui/toggle.types.d.ts +1 -1
- package/dist/types/shared/types/ui/upload.types.d.ts +1 -1
- package/dist/types/shared/ui/mciAccordion/MciAccordion.d.ts +5 -3
- package/dist/types/shared/ui/mciDrawer/MciDrawer.d.ts +1 -1
- package/dist/types/shared/ui/mciTable/MciTable.d.ts +1 -1
- package/dist/types/shared/ui/mciTable/MciTableColumnsPanel.d.ts +3 -2
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@ import _e from "../mciInput/MciInput.js";
|
|
|
8
8
|
import { toSafeDate as D, formatDateByPattern as qe, isDateOutsideBounds as Ge, normalizeDate as F, isSameCalendarDay as He, parseDateFromInput as he, formatManualDateInput as Je, getCalendarDays as Qe, shiftYear as Ue, shiftMonth as Xe } from "./mci-picker.utils.js";
|
|
9
9
|
const Ze = $e(
|
|
10
10
|
({
|
|
11
|
-
type:
|
|
11
|
+
type: o = "date",
|
|
12
12
|
value: T,
|
|
13
13
|
onChange: u,
|
|
14
14
|
placeholder: K,
|
|
@@ -29,38 +29,38 @@ const Ze = $e(
|
|
|
29
29
|
align: V = "auto"
|
|
30
30
|
}, ve) => {
|
|
31
31
|
const [f, W] = w(!1), [re, p] = w(
|
|
32
|
-
|
|
33
|
-
), [I, R] = w([null, null]), [m, b] = w(/* @__PURE__ */ new Date()), [le, Y] = w(y), [we, _] = w(0), [j, d] = w(""), [q,
|
|
32
|
+
o === "range" ? [null, null] : null
|
|
33
|
+
), [I, R] = w([null, null]), [m, b] = w(/* @__PURE__ */ new Date()), [le, Y] = w(y), [we, _] = w(0), [j, d] = w(""), [q, oe] = w(!1), [G, se] = w(V), E = Te(null), g = de(() => {
|
|
34
34
|
const e = T !== void 0 ? T : re;
|
|
35
|
-
if (
|
|
35
|
+
if (o === "date") return D(e);
|
|
36
36
|
const t = e;
|
|
37
37
|
return [D(t[0]), D(t[1])];
|
|
38
|
-
}, [T, re,
|
|
38
|
+
}, [T, re, o]), H = We[xe], c = N(
|
|
39
39
|
(e) => qe(e, k),
|
|
40
40
|
[k]
|
|
41
41
|
), S = N(
|
|
42
42
|
(e) => Ge(e, M, ee),
|
|
43
43
|
[M, ee]
|
|
44
44
|
), C = de(() => {
|
|
45
|
-
if (
|
|
45
|
+
if (o === "date") return c(g);
|
|
46
46
|
const [e, t] = g;
|
|
47
47
|
return !e && !t ? "" : e && t ? `${c(e)} - ${c(t)}` : e ? `${c(e)} - ...` : "...";
|
|
48
|
-
}, [
|
|
48
|
+
}, [o, g, c]);
|
|
49
49
|
$(() => {
|
|
50
50
|
(!f && !q || j === "" && C !== "") && d(C);
|
|
51
51
|
}, [C, f, j, q]), $(() => {
|
|
52
52
|
if (f)
|
|
53
|
-
if (
|
|
53
|
+
if (o === "range") {
|
|
54
54
|
const e = g;
|
|
55
55
|
R(e), e[0] ? b(e[0]) : e[1] ? b(e[1]) : b(/* @__PURE__ */ new Date());
|
|
56
56
|
} else {
|
|
57
57
|
const e = g;
|
|
58
58
|
b(e || /* @__PURE__ */ new Date());
|
|
59
59
|
}
|
|
60
|
-
}, [f,
|
|
60
|
+
}, [f, o, g]), $(() => {
|
|
61
61
|
if (f && V === "auto" && E.current) {
|
|
62
62
|
const e = E.current.getBoundingClientRect(), t = window.innerWidth - e.right, n = e.left;
|
|
63
|
-
t < 300 && n > 300 ?
|
|
63
|
+
t < 300 && n > 300 ? se("right") : se("left");
|
|
64
64
|
}
|
|
65
65
|
}, [f, V]);
|
|
66
66
|
const x = N(() => {
|
|
@@ -75,9 +75,9 @@ const Ze = $e(
|
|
|
75
75
|
};
|
|
76
76
|
}, [f, J, Q]);
|
|
77
77
|
const De = () => {
|
|
78
|
-
|
|
78
|
+
oe(!0), !(A || f) && (o === "range" || !te) && (W(!0), Y(y));
|
|
79
79
|
}, ye = () => {
|
|
80
|
-
if (
|
|
80
|
+
if (oe(!1), o !== "date") return;
|
|
81
81
|
const e = j.trim();
|
|
82
82
|
if (!e) {
|
|
83
83
|
p(null), u?.(null);
|
|
@@ -91,69 +91,69 @@ const Ze = $e(
|
|
|
91
91
|
}
|
|
92
92
|
d(C);
|
|
93
93
|
}, Ie = (e) => {
|
|
94
|
-
if (
|
|
94
|
+
if (o !== "date") return;
|
|
95
95
|
const t = e.target.value, n = Je(t), i = n.replace(/\D/g, "");
|
|
96
96
|
if (!(i.length >= 1 && Number.parseInt(i[0] ?? "0", 10) > 3)) {
|
|
97
97
|
if (i.length >= 2) {
|
|
98
|
-
const
|
|
99
|
-
if (
|
|
98
|
+
const s = Number.parseInt(i.slice(0, 2), 10);
|
|
99
|
+
if (s < 1 || s > 31) return;
|
|
100
100
|
}
|
|
101
101
|
if (!(i.length >= 3 && Number.parseInt(i[2] ?? "0", 10) > 1)) {
|
|
102
102
|
if (i.length >= 4) {
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
103
|
+
const s = Number.parseInt(i.slice(2, 4), 10);
|
|
104
|
+
if (s < 1 || s > 12) return;
|
|
105
105
|
}
|
|
106
106
|
if (d(n), n.length === 10) {
|
|
107
|
-
const
|
|
108
|
-
|
|
107
|
+
const s = he(n);
|
|
108
|
+
s && !S(s) && (p(s), u?.(s), b(s));
|
|
109
109
|
} else n === "" && (p(null), u?.(null));
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
}, Ce = N(() => {
|
|
113
|
-
const e =
|
|
113
|
+
const e = o === "range" ? [null, null] : null;
|
|
114
114
|
p(e), R([null, null]), u?.(e), d("");
|
|
115
|
-
}, [
|
|
115
|
+
}, [o, u]), ze = N(
|
|
116
116
|
(e) => {
|
|
117
117
|
if (S(e)) return;
|
|
118
118
|
const t = F(e);
|
|
119
|
-
if (
|
|
119
|
+
if (o === "date")
|
|
120
120
|
p(t), u?.(t), d(c(t)), x();
|
|
121
121
|
else {
|
|
122
122
|
const [n, i] = I;
|
|
123
123
|
if (!n && !i || n && i)
|
|
124
124
|
R([t, null]), d(`${c(t)} - ...`);
|
|
125
125
|
else if (n && !i) {
|
|
126
|
-
const
|
|
127
|
-
R(
|
|
128
|
-
const [z, v] =
|
|
126
|
+
const s = t < n ? [t, n] : [n, t];
|
|
127
|
+
R(s), p(s), u?.(s);
|
|
128
|
+
const [z, v] = s;
|
|
129
129
|
d(`${c(z)} - ${c(v)}`), x();
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
},
|
|
133
|
-
[
|
|
133
|
+
[o, I, S, u, x, c]
|
|
134
134
|
), Fe = N((e) => {
|
|
135
135
|
const t = new Date(m.getFullYear(), e, 1);
|
|
136
|
-
b(t), y === "month" &&
|
|
137
|
-
}, [m, y, u, x,
|
|
136
|
+
b(t), y === "month" && o === "date" ? (p(t), u?.(t), d(c(t)), x()) : Y("day");
|
|
137
|
+
}, [m, y, u, x, o, c]), Ye = N((e) => {
|
|
138
138
|
const t = new Date(e, m.getMonth(), 1);
|
|
139
|
-
b(t), y === "year" &&
|
|
140
|
-
}, [m, y, u, x,
|
|
139
|
+
b(t), y === "year" && o === "date" ? (p(t), u?.(t), d(c(t)), x()) : Y("month");
|
|
140
|
+
}, [m, y, u, x, o, c]), ae = (e) => {
|
|
141
141
|
b((t) => Xe(t, e));
|
|
142
142
|
}, L = (e) => {
|
|
143
143
|
b((t) => Ue(t, e));
|
|
144
144
|
}, O = N((e, t) => He(e, t), []), Ae = (e) => {
|
|
145
145
|
const t = F(e);
|
|
146
|
-
if (
|
|
146
|
+
if (o === "date") return g && O(t, g);
|
|
147
147
|
const [n] = I[0] ? I : g;
|
|
148
148
|
return D(n) && O(t, D(n));
|
|
149
149
|
}, Se = (e) => {
|
|
150
|
-
if (
|
|
150
|
+
if (o !== "range") return !1;
|
|
151
151
|
const t = F(e), [, n] = I[1] ? I : g;
|
|
152
152
|
return D(n) && O(t, D(n));
|
|
153
153
|
}, Re = (e) => {
|
|
154
|
-
if (
|
|
155
|
-
const t = F(e), [n, i] = I[0] ? I : g,
|
|
156
|
-
return
|
|
154
|
+
if (o !== "range") return !1;
|
|
155
|
+
const t = F(e), [n, i] = I[0] ? I : g, s = D(n), z = D(i);
|
|
156
|
+
return s && !z ? !1 : s && z && t > F(s) && t < F(z);
|
|
157
157
|
}, ie = (e, t, n) => {
|
|
158
158
|
const i = Qe(e);
|
|
159
159
|
return /* @__PURE__ */ h("div", { className: "w-[300px] p-2 select-none", children: [
|
|
@@ -165,7 +165,7 @@ const Ze = $e(
|
|
|
165
165
|
onClick: () => L(-1),
|
|
166
166
|
type: "button",
|
|
167
167
|
className: a(
|
|
168
|
-
"rounded p-1 transition-colors",
|
|
168
|
+
"cursor-pointer rounded p-1 transition-colors",
|
|
169
169
|
l ? "text-neutral-100 hover:bg-neutral-300 hover:text-white" : "text-slate-500 hover:bg-slate-100"
|
|
170
170
|
),
|
|
171
171
|
children: /* @__PURE__ */ r(Pe, { size: 18 })
|
|
@@ -177,7 +177,7 @@ const Ze = $e(
|
|
|
177
177
|
onClick: () => ae(-1),
|
|
178
178
|
type: "button",
|
|
179
179
|
className: a(
|
|
180
|
-
"rounded p-1 transition-colors",
|
|
180
|
+
"cursor-pointer rounded p-1 transition-colors",
|
|
181
181
|
l ? "text-neutral-100 hover:bg-neutral-300 hover:text-white" : "text-slate-500 hover:bg-slate-100"
|
|
182
182
|
),
|
|
183
183
|
children: /* @__PURE__ */ r(X, { size: 18 })
|
|
@@ -224,7 +224,7 @@ const Ze = $e(
|
|
|
224
224
|
onClick: () => ae(1),
|
|
225
225
|
type: "button",
|
|
226
226
|
className: a(
|
|
227
|
-
"rounded p-1 transition-colors",
|
|
227
|
+
"cursor-pointer rounded p-1 transition-colors",
|
|
228
228
|
l ? "text-neutral-100 hover:bg-neutral-300 hover:text-white" : "text-slate-500 hover:bg-slate-100"
|
|
229
229
|
),
|
|
230
230
|
children: /* @__PURE__ */ r(Z, { size: 18 })
|
|
@@ -236,7 +236,7 @@ const Ze = $e(
|
|
|
236
236
|
onClick: () => L(1),
|
|
237
237
|
type: "button",
|
|
238
238
|
className: a(
|
|
239
|
-
"rounded p-1 transition-colors",
|
|
239
|
+
"cursor-pointer rounded p-1 transition-colors",
|
|
240
240
|
l ? "text-neutral-100 hover:bg-neutral-300 hover:text-white" : "text-slate-500 hover:bg-slate-100"
|
|
241
241
|
),
|
|
242
242
|
children: /* @__PURE__ */ r(Be, { size: 18 })
|
|
@@ -251,19 +251,19 @@ const Ze = $e(
|
|
|
251
251
|
"mb-1 grid grid-cols-7 text-center text-[11px] font-bold uppercase",
|
|
252
252
|
l ? "text-blue-500" : "text-blue-600"
|
|
253
253
|
),
|
|
254
|
-
children: H.weekdaysShort.map((
|
|
254
|
+
children: H.weekdaysShort.map((s) => /* @__PURE__ */ r("div", { className: "py-1", children: s }, s))
|
|
255
255
|
}
|
|
256
256
|
),
|
|
257
|
-
/* @__PURE__ */ r("div", { className: "grid grid-cols-7 gap-y-1 relative", children: i.map((
|
|
258
|
-
const v =
|
|
257
|
+
/* @__PURE__ */ r("div", { className: "grid grid-cols-7 gap-y-1 relative", children: i.map((s, z) => {
|
|
258
|
+
const v = s.date, ue = S(v), P = Ae(v), B = Se(v), Le = Re(v);
|
|
259
259
|
return /* @__PURE__ */ r(
|
|
260
260
|
"div",
|
|
261
261
|
{
|
|
262
262
|
className: a(
|
|
263
263
|
"relative flex h-10 items-center justify-center",
|
|
264
264
|
Le && (l ? "bg-blue-500/15" : "bg-blue-50"),
|
|
265
|
-
P &&
|
|
266
|
-
B &&
|
|
265
|
+
P && o === "range" && B ? l ? "rounded-full bg-blue-500" : "rounded-full bg-blue-50" : P && o === "range" ? l ? "rounded-l-full bg-gradient-to-r from-transparent to-blue-500/15" : "rounded-l-full bg-gradient-to-r from-transparent to-blue-50" : "",
|
|
266
|
+
B && o === "range" ? l ? "rounded-r-full bg-gradient-to-l from-transparent to-blue-500/15" : "rounded-r-full bg-gradient-to-l from-transparent to-blue-50" : ""
|
|
267
267
|
),
|
|
268
268
|
children: /* @__PURE__ */ r(
|
|
269
269
|
"button",
|
|
@@ -273,7 +273,7 @@ const Ze = $e(
|
|
|
273
273
|
disabled: ue,
|
|
274
274
|
className: a(
|
|
275
275
|
"z-10 flex h-9 w-9 cursor-pointer items-center justify-center rounded-full text-sm font-medium transition-all",
|
|
276
|
-
|
|
276
|
+
s.isCurrentMonth ? l ? "text-neutral-50" : "text-slate-700" : l ? "text-neutral-100/40" : "text-slate-300",
|
|
277
277
|
ue && "cursor-not-allowed opacity-20",
|
|
278
278
|
P || B ? "bg-blue-600 text-white shadow-md shadow-blue-200 hover:bg-blue-700" : l ? "hover:bg-neutral-300 hover:text-white" : "hover:bg-blue-50",
|
|
279
279
|
O(v, /* @__PURE__ */ new Date()) && !P && !B && (l ? "border border-blue-500 text-blue-500" : "border border-blue-600 text-blue-600")
|
|
@@ -294,7 +294,7 @@ const Ze = $e(
|
|
|
294
294
|
type: "button",
|
|
295
295
|
onClick: () => L(-1),
|
|
296
296
|
className: a(
|
|
297
|
-
"rounded p-1",
|
|
297
|
+
"cursor-pointer rounded p-1",
|
|
298
298
|
l ? "text-neutral-100 hover:bg-neutral-300 hover:text-white" : "text-slate-500 hover:bg-slate-100"
|
|
299
299
|
),
|
|
300
300
|
children: /* @__PURE__ */ r(X, { size: 20 })
|
|
@@ -307,7 +307,7 @@ const Ze = $e(
|
|
|
307
307
|
type: "button",
|
|
308
308
|
onClick: () => L(1),
|
|
309
309
|
className: a(
|
|
310
|
-
"rounded p-1",
|
|
310
|
+
"cursor-pointer rounded p-1",
|
|
311
311
|
l ? "text-neutral-100 hover:bg-neutral-300 hover:text-white" : "text-slate-500 hover:bg-slate-100"
|
|
312
312
|
),
|
|
313
313
|
children: /* @__PURE__ */ r(Z, { size: 20 })
|
|
@@ -325,7 +325,7 @@ const Ze = $e(
|
|
|
325
325
|
type: "button",
|
|
326
326
|
onClick: () => _((n) => n - 1),
|
|
327
327
|
className: a(
|
|
328
|
-
"rounded p-1",
|
|
328
|
+
"cursor-pointer rounded p-1",
|
|
329
329
|
l ? "text-neutral-100 hover:bg-neutral-300 hover:text-white" : "text-slate-500 hover:bg-slate-100"
|
|
330
330
|
),
|
|
331
331
|
children: /* @__PURE__ */ r(X, { size: 20 })
|
|
@@ -342,7 +342,7 @@ const Ze = $e(
|
|
|
342
342
|
type: "button",
|
|
343
343
|
onClick: () => _((n) => n + 1),
|
|
344
344
|
className: a(
|
|
345
|
-
"rounded p-1",
|
|
345
|
+
"cursor-pointer rounded p-1",
|
|
346
346
|
l ? "text-neutral-100 hover:bg-neutral-300 hover:text-white" : "text-slate-500 hover:bg-slate-100"
|
|
347
347
|
),
|
|
348
348
|
children: /* @__PURE__ */ r(Z, { size: 20 })
|
|
@@ -385,10 +385,10 @@ const Ze = $e(
|
|
|
385
385
|
required: me,
|
|
386
386
|
error: ge,
|
|
387
387
|
darkMode: l,
|
|
388
|
-
maxLength:
|
|
388
|
+
maxLength: o === "date" ? 10 : void 0,
|
|
389
389
|
onFocus: De,
|
|
390
390
|
onBlur: ye,
|
|
391
|
-
readOnly: !te ||
|
|
391
|
+
readOnly: !te || o === "range",
|
|
392
392
|
showClearButton: pe,
|
|
393
393
|
onClear: Ce
|
|
394
394
|
}
|
|
@@ -407,8 +407,8 @@ const Ze = $e(
|
|
|
407
407
|
style: { width: "max-content" },
|
|
408
408
|
onMouseDown: (e) => e.stopPropagation(),
|
|
409
409
|
children: le === "day" ? /* @__PURE__ */ h(U, { children: [
|
|
410
|
-
ie(m, !0,
|
|
411
|
-
|
|
410
|
+
ie(m, !0, o !== "range"),
|
|
411
|
+
o === "range" && /* @__PURE__ */ r("div", { className: a(
|
|
412
412
|
"hidden border-l md:block",
|
|
413
413
|
l ? "border-neutral-200" : "border-slate-100"
|
|
414
414
|
), children: ie(new Date(m.getFullYear(), m.getMonth() + 1, 1), !1, !0) })
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsxs as _, jsx as a } from "react/jsx-runtime";
|
|
2
2
|
import { AltArrowDown as st } from "@solar-icons/react";
|
|
3
3
|
import ot from "../../../assets/icons/close.svg.js";
|
|
4
|
-
import { forwardRef as ct, useState as w, useRef as G, useMemo as O, useCallback as
|
|
4
|
+
import { forwardRef as ct, useState as w, useRef as G, useMemo as O, useCallback as p, useEffect as J } from "react";
|
|
5
5
|
import { useClickOutside as it, useEscapeKey as ut, cn as s } from "../../lib/utils.js";
|
|
6
|
-
import { getFilteredOptions as ft, getSelectStateStyles as mt, getSelectIconColor as
|
|
6
|
+
import { getFilteredOptions as ft, getSelectStateStyles as mt, getSelectIconColor as pt, SELECT_SIZES as ht } from "./mci-select.utils.js";
|
|
7
7
|
const xt = ct(
|
|
8
8
|
({
|
|
9
9
|
label: U,
|
|
@@ -14,7 +14,7 @@ const xt = ct(
|
|
|
14
14
|
size: l = "base",
|
|
15
15
|
darkMode: e = !1,
|
|
16
16
|
error: o,
|
|
17
|
-
disabled:
|
|
17
|
+
disabled: n = !1,
|
|
18
18
|
required: Q = !1,
|
|
19
19
|
value: m,
|
|
20
20
|
onChange: b,
|
|
@@ -22,45 +22,45 @@ const xt = ct(
|
|
|
22
22
|
onBlur: y,
|
|
23
23
|
className: X,
|
|
24
24
|
clearable: Y = !1,
|
|
25
|
-
searchable:
|
|
25
|
+
searchable: h = !1,
|
|
26
26
|
onSearch: N,
|
|
27
27
|
name: k
|
|
28
28
|
}, z) => {
|
|
29
|
-
const [
|
|
29
|
+
const [r, S] = w(!1), [i, F] = w(!1), [M, $] = w(""), [T, x] = w(""), [C, u] = w(-1), H = G(null), K = G(null), g = m !== void 0 ? m : M, Z = L.find((t) => t.value === g), E = g !== "" && g !== void 0, D = Y && E && !n, I = !!(v && R === "right"), c = ht[l], tt = O(() => I && D ? l === "sm" || l === "md" ? "pr-16" : "pr-20" : I || D ? l === "sm" ? "pr-11" : l === "md" ? "pr-12" : "pr-14" : l === "sm" ? "pr-8" : l === "md" ? "pr-9" : "pr-10", [I, D, l]), f = O(() => ft(L, T, h, !!N), [L, T, h, N]), q = p(() => {
|
|
30
30
|
S(!1), F(!1), x(""), u(-1), y?.();
|
|
31
31
|
}, [y]), { handleClick: V } = it(H, q), { handleEscape: j } = ut(q);
|
|
32
32
|
J(() => {
|
|
33
|
-
if (
|
|
33
|
+
if (r)
|
|
34
34
|
return document.addEventListener("mousedown", V), document.addEventListener("keydown", j), () => {
|
|
35
35
|
document.removeEventListener("mousedown", V), document.removeEventListener("keydown", j);
|
|
36
36
|
};
|
|
37
|
-
}, [
|
|
38
|
-
|
|
39
|
-
}, [
|
|
40
|
-
const et =
|
|
41
|
-
|
|
42
|
-
}, [
|
|
37
|
+
}, [r, V, j]), J(() => {
|
|
38
|
+
r && h && K.current && K.current.focus();
|
|
39
|
+
}, [r, h]);
|
|
40
|
+
const et = p(() => {
|
|
41
|
+
n || (S((t) => !t), r ? (x(""), u(-1)) : (F(!0), W?.()));
|
|
42
|
+
}, [n, r, W]), P = p(
|
|
43
43
|
(t) => {
|
|
44
44
|
m === void 0 && $(t), b?.(t), S(!1), F(!1), x(""), u(-1), y?.();
|
|
45
45
|
},
|
|
46
46
|
[m, b, y]
|
|
47
|
-
), nt =
|
|
47
|
+
), nt = p(
|
|
48
48
|
(t) => {
|
|
49
|
-
if (!
|
|
50
|
-
if (!
|
|
49
|
+
if (!n) {
|
|
50
|
+
if (!r && (t.key === "ArrowDown" || t.key === "ArrowUp" || t.key === "Enter")) {
|
|
51
51
|
t.preventDefault(), S(!0);
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
-
if (
|
|
54
|
+
if (r)
|
|
55
55
|
switch (t.key) {
|
|
56
56
|
case "ArrowDown":
|
|
57
57
|
t.preventDefault(), u(
|
|
58
|
-
(
|
|
58
|
+
(d) => d < f.length - 1 ? d + 1 : 0
|
|
59
59
|
);
|
|
60
60
|
break;
|
|
61
61
|
case "ArrowUp":
|
|
62
62
|
t.preventDefault(), u(
|
|
63
|
-
(
|
|
63
|
+
(d) => d > 0 ? d - 1 : f.length - 1
|
|
64
64
|
);
|
|
65
65
|
break;
|
|
66
66
|
case "Enter":
|
|
@@ -69,23 +69,23 @@ const xt = ct(
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
|
-
[
|
|
73
|
-
), rt =
|
|
72
|
+
[r, f, C, n, P]
|
|
73
|
+
), rt = p(
|
|
74
74
|
(t) => {
|
|
75
|
-
t.stopPropagation(), !
|
|
75
|
+
t.stopPropagation(), !n && (m === void 0 && $(""), b?.(""), x(""), u(-1));
|
|
76
76
|
},
|
|
77
|
-
[m, b,
|
|
78
|
-
), lt =
|
|
77
|
+
[m, b, n]
|
|
78
|
+
), lt = p(
|
|
79
79
|
(t) => {
|
|
80
80
|
x(t), N?.(t), u(0);
|
|
81
81
|
},
|
|
82
82
|
[N]
|
|
83
83
|
), at = O(
|
|
84
|
-
() => mt(
|
|
85
|
-
[o,
|
|
84
|
+
() => mt(n, o, e),
|
|
85
|
+
[o, n, e]
|
|
86
86
|
), B = O(
|
|
87
|
-
() =>
|
|
88
|
-
[
|
|
87
|
+
() => pt(n, o, r, i, e),
|
|
88
|
+
[n, o, r, i, e]
|
|
89
89
|
);
|
|
90
90
|
return /* @__PURE__ */ _("div", { className: s("w-full", X), ref: z, children: [
|
|
91
91
|
U && /* @__PURE__ */ _(
|
|
@@ -114,22 +114,23 @@ const xt = ct(
|
|
|
114
114
|
"div",
|
|
115
115
|
{
|
|
116
116
|
role: "combobox",
|
|
117
|
-
"aria-expanded":
|
|
117
|
+
"aria-expanded": r,
|
|
118
118
|
"aria-haspopup": "listbox",
|
|
119
119
|
"aria-controls": `${k}-listbox`,
|
|
120
|
-
"aria-disabled":
|
|
121
|
-
tabIndex:
|
|
120
|
+
"aria-disabled": n,
|
|
121
|
+
tabIndex: n ? -1 : 0,
|
|
122
122
|
onClick: et,
|
|
123
123
|
className: s(
|
|
124
124
|
"flex w-full items-center border font-normal transition-all duration-300 ease-in-out",
|
|
125
|
+
n ? "cursor-not-allowed" : "cursor-pointer",
|
|
125
126
|
l === "base" ? "rounded-xl" : "rounded-lg",
|
|
126
127
|
c.container,
|
|
127
128
|
v && R === "left" ? c.iconPaddingLeft : c.padding,
|
|
128
129
|
tt,
|
|
129
130
|
at,
|
|
130
|
-
e && !
|
|
131
|
-
e && !
|
|
132
|
-
!e && !
|
|
131
|
+
e && !n && (i || r) && !o && "border-blue-500 shadow-[0_0_0_2px_var(--opacity-25,rgba(21,93,252,0.25))] text-white",
|
|
132
|
+
e && !n && (i || r) && o && "border-red-500 shadow-[0_0_0_2px_rgba(231,0,11,0.25)]",
|
|
133
|
+
!e && !n && i && "shadow-blue border-blue-600"
|
|
133
134
|
),
|
|
134
135
|
children: [
|
|
135
136
|
v && /* @__PURE__ */ a(
|
|
@@ -143,7 +144,7 @@ const xt = ct(
|
|
|
143
144
|
children: v
|
|
144
145
|
}
|
|
145
146
|
),
|
|
146
|
-
|
|
147
|
+
h && r ? /* @__PURE__ */ a(
|
|
147
148
|
"input",
|
|
148
149
|
{
|
|
149
150
|
ref: K,
|
|
@@ -163,9 +164,9 @@ const xt = ct(
|
|
|
163
164
|
title: Z?.label || A,
|
|
164
165
|
className: s(
|
|
165
166
|
"block min-w-0 flex-1 truncate select-none",
|
|
166
|
-
!E && !
|
|
167
|
-
e && E && (i ||
|
|
168
|
-
e && E && !i && !
|
|
167
|
+
!E && !n && (e ? "text-neutral-100" : "text-slate-400"),
|
|
168
|
+
e && E && (i || r) && "text-white",
|
|
169
|
+
e && E && !i && !r && "text-neutral-50"
|
|
169
170
|
),
|
|
170
171
|
children: Z?.label || A
|
|
171
172
|
}
|
|
@@ -190,7 +191,7 @@ const xt = ct(
|
|
|
190
191
|
className: s(
|
|
191
192
|
"absolute top-1/2 -translate-y-1/2 pointer-events-none transition-all duration-300",
|
|
192
193
|
l === "sm" ? "right-2" : "right-3",
|
|
193
|
-
|
|
194
|
+
r && "rotate-180",
|
|
194
195
|
B
|
|
195
196
|
),
|
|
196
197
|
children: /* @__PURE__ */ a(st, { className: c.iconSize })
|
|
@@ -199,7 +200,7 @@ const xt = ct(
|
|
|
199
200
|
]
|
|
200
201
|
}
|
|
201
202
|
),
|
|
202
|
-
|
|
203
|
+
r && !n && /* @__PURE__ */ a(
|
|
203
204
|
"div",
|
|
204
205
|
{
|
|
205
206
|
id: `${k}-listbox`,
|
|
@@ -216,12 +217,12 @@ const xt = ct(
|
|
|
216
217
|
"div",
|
|
217
218
|
{
|
|
218
219
|
role: "option",
|
|
219
|
-
"aria-selected":
|
|
220
|
+
"aria-selected": g === t.value,
|
|
220
221
|
onClick: () => P(t.value),
|
|
221
222
|
title: t.label,
|
|
222
223
|
className: s(
|
|
223
224
|
"cursor-pointer truncate rounded-sm px-3 py-2 font-normal transition-colors",
|
|
224
|
-
|
|
225
|
+
g === t.value ? e ? "bg-neutral-300 text-white" : "bg-slate-100" : e ? "hover:bg-neutral-300 hover:text-white" : "hover:bg-slate-100"
|
|
225
226
|
),
|
|
226
227
|
children: t.label
|
|
227
228
|
},
|