@la-batcave/ui 3.1.2
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/README.md +95 -0
- package/dist/Alert.d.ts +27 -0
- package/dist/Alert.js +56 -0
- package/dist/Avatar.d.ts +20 -0
- package/dist/Avatar.js +40 -0
- package/dist/Badge.d.ts +56 -0
- package/dist/Badge.js +74 -0
- package/dist/Button.d.ts +53 -0
- package/dist/Button.js +66 -0
- package/dist/Card.d.ts +18 -0
- package/dist/Card.js +98 -0
- package/dist/CodeBlock.d.ts +45 -0
- package/dist/CodeBlock.js +306 -0
- package/dist/Collapse.d.ts +58 -0
- package/dist/Collapse.js +89 -0
- package/dist/Combobox.d.ts +44 -0
- package/dist/Combobox.js +409 -0
- package/dist/DarkMode.d.ts +59 -0
- package/dist/DarkMode.js +56 -0
- package/dist/DatePicker.d.ts +48 -0
- package/dist/DatePicker.js +2954 -0
- package/dist/Dialog.d.ts +119 -0
- package/dist/Dialog.js +337 -0
- package/dist/Drawer.d.ts +28 -0
- package/dist/Drawer.js +1126 -0
- package/dist/Dropdown.d.ts +23 -0
- package/dist/Dropdown.js +247 -0
- package/dist/EasyForm.d.ts +138 -0
- package/dist/EasyForm.js +286 -0
- package/dist/HoverCard.d.ts +10 -0
- package/dist/HoverCard.js +195 -0
- package/dist/Input.d.ts +230 -0
- package/dist/Input.js +2216 -0
- package/dist/LogViewer.d.ts +57 -0
- package/dist/LogViewer.js +120 -0
- package/dist/Menubar.d.ts +32 -0
- package/dist/Menubar.js +398 -0
- package/dist/Navbar.d.ts +20 -0
- package/dist/Navbar.js +31 -0
- package/dist/Pagination.d.ts +78 -0
- package/dist/Pagination.js +106 -0
- package/dist/Popover.d.ts +11 -0
- package/dist/Popover.js +28 -0
- package/dist/ProgressBar.d.ts +35 -0
- package/dist/ProgressBar.js +210 -0
- package/dist/Resizable.d.ts +23 -0
- package/dist/Resizable.js +1532 -0
- package/dist/Separator.d.ts +4 -0
- package/dist/Separator.js +46 -0
- package/dist/Sheet.d.ts +29 -0
- package/dist/Sheet.js +104 -0
- package/dist/Sidebar.d.ts +117 -0
- package/dist/Sidebar.js +237 -0
- package/dist/Skeleton.d.ts +57 -0
- package/dist/Skeleton.js +47 -0
- package/dist/Table.d.ts +71 -0
- package/dist/Table.js +94 -0
- package/dist/Tabs.d.ts +76 -0
- package/dist/Tabs.js +202 -0
- package/dist/Toast.d.ts +54 -0
- package/dist/Toast.js +827 -0
- package/dist/Tooltip.d.ts +29 -0
- package/dist/Tooltip.js +352 -0
- package/dist/Typography.d.ts +101 -0
- package/dist/Typography.js +123 -0
- package/dist/Widget.d.ts +133 -0
- package/dist/Widget.js +207 -0
- package/dist/_shared/Combination-D_l4PLF_.js +676 -0
- package/dist/_shared/index-B03TCNO5.js +142 -0
- package/dist/_shared/index-B1f-hyuh.js +31 -0
- package/dist/_shared/index-BC7vfx-u.js +13 -0
- package/dist/_shared/index-BrLJJgkl.js +67 -0
- package/dist/_shared/index-C0gNQvxa.js +269 -0
- package/dist/_shared/index-C3aZemLI.js +268 -0
- package/dist/_shared/index-CXeb1OMI.js +198 -0
- package/dist/_shared/index-CukUn3R0.js +626 -0
- package/dist/_shared/index-DLcqcWxM.js +29 -0
- package/dist/_shared/index-DlSuDb9N.js +283 -0
- package/dist/_shared/index-V-Ajw7Ac.js +79 -0
- package/dist/_shared/index-uPOYJZpG.js +34 -0
- package/dist/_shared/index-uu9PT5Nu.js +1588 -0
- package/dist/_shared/utils-eGXXUFl7.js +2935 -0
- package/dist/backgrounds/Aurora.d.ts +7 -0
- package/dist/backgrounds/Aurora.js +126 -0
- package/dist/backgrounds/Iridescence.d.ts +7 -0
- package/dist/backgrounds/Iridescence.js +77 -0
- package/dist/backgrounds/Lightning.d.ts +8 -0
- package/dist/backgrounds/Lightning.js +75 -0
- package/dist/backgrounds/LiquidChrome.d.ts +9 -0
- package/dist/backgrounds/LiquidChrome.js +89 -0
- package/dist/backgrounds/Particles.d.ts +15 -0
- package/dist/backgrounds/Particles.js +137 -0
- package/dist/backgrounds/PixelSnow.d.ts +9 -0
- package/dist/backgrounds/PixelSnow.js +52 -0
- package/dist/backgrounds/Silk.d.ts +8 -0
- package/dist/backgrounds/Silk.js +92 -0
- package/dist/backgrounds/Squares.d.ts +9 -0
- package/dist/backgrounds/Squares.js +75 -0
- package/dist/backgrounds/Threads.d.ts +7 -0
- package/dist/backgrounds/Threads.js +110 -0
- package/dist/backgrounds/Waves.d.ts +14 -0
- package/dist/backgrounds/Waves.js +139 -0
- package/dist/fonts/inter-latin-wght-normal.woff2 +0 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -0
- package/package.json +318 -0
package/dist/Combobox.js
ADDED
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as $, jsx as S } from "react/jsx-runtime";
|
|
3
|
+
import * as l from "react";
|
|
4
|
+
import { R as Se, P as Ie, O as Re, C as Ae } from "./_shared/index-DlSuDb9N.js";
|
|
5
|
+
import { P as A } from "./_shared/index-V-Ajw7Ac.js";
|
|
6
|
+
import { u as j } from "./_shared/index-BC7vfx-u.js";
|
|
7
|
+
import { c as L } from "./_shared/index-DLcqcWxM.js";
|
|
8
|
+
import { R as Me, T as Ne, P as $e, C as De } from "./_shared/index-C3aZemLI.js";
|
|
9
|
+
import { ChevronsUpDown as Pe, Search as ze, Check as Oe } from "lucide-react";
|
|
10
|
+
import { c as U } from "./_shared/utils-eGXXUFl7.js";
|
|
11
|
+
var pe = 1, je = 0.9, Fe = 0.8, Ke = 0.17, te = 0.1, re = 0.999, qe = 0.9999, Le = 0.99, Ve = /[\\\/_+.#"@\[\(\{&]/, Be = /[\\\/_+.#"@\[\(\{&]/g, Te = /[\s-]/, ge = /[\s-]/g;
|
|
12
|
+
function le(t, n, r, f, u, o, s) {
|
|
13
|
+
if (o === n.length) return u === t.length ? pe : Le;
|
|
14
|
+
var m = `${u},${o}`;
|
|
15
|
+
if (s[m] !== void 0) return s[m];
|
|
16
|
+
for (var h = f.charAt(o), i = r.indexOf(h, u), d = 0, g, C, w, I; i >= 0; ) g = le(t, n, r, f, i + 1, o + 1, s), g > d && (i === u ? g *= pe : Ve.test(t.charAt(i - 1)) ? (g *= Fe, w = t.slice(u, i - 1).match(Be), w && u > 0 && (g *= Math.pow(re, w.length))) : Te.test(t.charAt(i - 1)) ? (g *= je, I = t.slice(u, i - 1).match(ge), I && u > 0 && (g *= Math.pow(re, I.length))) : (g *= Ke, u > 0 && (g *= Math.pow(re, i - u))), t.charAt(i) !== n.charAt(o) && (g *= qe)), (g < te && r.charAt(i - 1) === f.charAt(o + 1) || f.charAt(o + 1) === f.charAt(o) && r.charAt(i - 1) !== f.charAt(o)) && (C = le(t, n, r, f, i + 1, o + 2, s), C * te > g && (g = C * te)), g > d && (d = g), i = r.indexOf(h, i + 1);
|
|
17
|
+
return s[m] = d, d;
|
|
18
|
+
}
|
|
19
|
+
function ve(t) {
|
|
20
|
+
return t.toLowerCase().replace(ge, " ");
|
|
21
|
+
}
|
|
22
|
+
function Ue(t, n, r) {
|
|
23
|
+
return t = r && r.length > 0 ? `${t + " " + r.join(" ")}` : t, le(t, n, ve(t), ve(n), 0, 0, {});
|
|
24
|
+
}
|
|
25
|
+
var K = '[cmdk-group=""]', ne = '[cmdk-group-items=""]', He = '[cmdk-group-heading=""]', be = '[cmdk-item=""]', he = `${be}:not([aria-disabled="true"])`, ae = "cmdk-item-select", z = "data-value", We = (t, n, r) => Ue(t, n, r), xe = l.createContext(void 0), V = () => l.useContext(xe), ye = l.createContext(void 0), ue = () => l.useContext(ye), we = l.createContext(void 0), ke = l.forwardRef((t, n) => {
|
|
26
|
+
let r = O(() => {
|
|
27
|
+
var e, c;
|
|
28
|
+
return { search: "", value: (c = (e = t.value) != null ? e : t.defaultValue) != null ? c : "", selectedItemId: void 0, filtered: { count: 0, items: /* @__PURE__ */ new Map(), groups: /* @__PURE__ */ new Set() } };
|
|
29
|
+
}), f = O(() => /* @__PURE__ */ new Set()), u = O(() => /* @__PURE__ */ new Map()), o = O(() => /* @__PURE__ */ new Map()), s = O(() => /* @__PURE__ */ new Set()), m = Ee(t), { label: h, children: i, value: d, onValueChange: g, filter: C, shouldFilter: w, loop: I, disablePointerSelection: W = !1, vimBindings: M = !0, ...B } = t, G = j(), ie = j(), J = j(), N = l.useRef(null), x = nt();
|
|
30
|
+
D(() => {
|
|
31
|
+
if (d !== void 0) {
|
|
32
|
+
let e = d.trim();
|
|
33
|
+
r.current.value = e, k.emit();
|
|
34
|
+
}
|
|
35
|
+
}, [d]), D(() => {
|
|
36
|
+
x(6, ce);
|
|
37
|
+
}, []);
|
|
38
|
+
let k = l.useMemo(() => ({ subscribe: (e) => (s.current.add(e), () => s.current.delete(e)), snapshot: () => r.current, setState: (e, c, p) => {
|
|
39
|
+
var a, v, b, E;
|
|
40
|
+
if (!Object.is(r.current[e], c)) {
|
|
41
|
+
if (r.current[e] = c, e === "search") Z(), Y(), x(1, Q);
|
|
42
|
+
else if (e === "value") {
|
|
43
|
+
if (document.activeElement.hasAttribute("cmdk-input") || document.activeElement.hasAttribute("cmdk-root")) {
|
|
44
|
+
let y = document.getElementById(J);
|
|
45
|
+
y ? y.focus() : (a = document.getElementById(G)) == null || a.focus();
|
|
46
|
+
}
|
|
47
|
+
if (x(7, () => {
|
|
48
|
+
var y;
|
|
49
|
+
r.current.selectedItemId = (y = P()) == null ? void 0 : y.id, k.emit();
|
|
50
|
+
}), p || x(5, ce), ((v = m.current) == null ? void 0 : v.value) !== void 0) {
|
|
51
|
+
let y = c ?? "";
|
|
52
|
+
(E = (b = m.current).onValueChange) == null || E.call(b, y);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
k.emit();
|
|
57
|
+
}
|
|
58
|
+
}, emit: () => {
|
|
59
|
+
s.current.forEach((e) => e());
|
|
60
|
+
} }), []), X = l.useMemo(() => ({ value: (e, c, p) => {
|
|
61
|
+
var a;
|
|
62
|
+
c !== ((a = o.current.get(e)) == null ? void 0 : a.value) && (o.current.set(e, { value: c, keywords: p }), r.current.filtered.items.set(e, oe(c, p)), x(2, () => {
|
|
63
|
+
Y(), k.emit();
|
|
64
|
+
}));
|
|
65
|
+
}, item: (e, c) => (f.current.add(e), c && (u.current.has(c) ? u.current.get(c).add(e) : u.current.set(c, /* @__PURE__ */ new Set([e]))), x(3, () => {
|
|
66
|
+
Z(), Y(), r.current.value || Q(), k.emit();
|
|
67
|
+
}), () => {
|
|
68
|
+
o.current.delete(e), f.current.delete(e), r.current.filtered.items.delete(e);
|
|
69
|
+
let p = P();
|
|
70
|
+
x(4, () => {
|
|
71
|
+
Z(), p?.getAttribute("id") === e && Q(), k.emit();
|
|
72
|
+
});
|
|
73
|
+
}), group: (e) => (u.current.has(e) || u.current.set(e, /* @__PURE__ */ new Set()), () => {
|
|
74
|
+
o.current.delete(e), u.current.delete(e);
|
|
75
|
+
}), filter: () => m.current.shouldFilter, label: h || t["aria-label"], getDisablePointerSelection: () => m.current.disablePointerSelection, listId: G, inputId: J, labelId: ie, listInnerRef: N }), []);
|
|
76
|
+
function oe(e, c) {
|
|
77
|
+
var p, a;
|
|
78
|
+
let v = (a = (p = m.current) == null ? void 0 : p.filter) != null ? a : We;
|
|
79
|
+
return e ? v(e, r.current.search, c) : 0;
|
|
80
|
+
}
|
|
81
|
+
function Y() {
|
|
82
|
+
if (!r.current.search || m.current.shouldFilter === !1) return;
|
|
83
|
+
let e = r.current.filtered.items, c = [];
|
|
84
|
+
r.current.filtered.groups.forEach((a) => {
|
|
85
|
+
let v = u.current.get(a), b = 0;
|
|
86
|
+
v.forEach((E) => {
|
|
87
|
+
let y = e.get(E);
|
|
88
|
+
b = Math.max(y, b);
|
|
89
|
+
}), c.push([a, b]);
|
|
90
|
+
});
|
|
91
|
+
let p = N.current;
|
|
92
|
+
F().sort((a, v) => {
|
|
93
|
+
var b, E;
|
|
94
|
+
let y = a.getAttribute("id"), T = v.getAttribute("id");
|
|
95
|
+
return ((b = e.get(T)) != null ? b : 0) - ((E = e.get(y)) != null ? E : 0);
|
|
96
|
+
}).forEach((a) => {
|
|
97
|
+
let v = a.closest(ne);
|
|
98
|
+
v ? v.appendChild(a.parentElement === v ? a : a.closest(`${ne} > *`)) : p.appendChild(a.parentElement === p ? a : a.closest(`${ne} > *`));
|
|
99
|
+
}), c.sort((a, v) => v[1] - a[1]).forEach((a) => {
|
|
100
|
+
var v;
|
|
101
|
+
let b = (v = N.current) == null ? void 0 : v.querySelector(`${K}[${z}="${encodeURIComponent(a[0])}"]`);
|
|
102
|
+
b?.parentElement.appendChild(b);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function Q() {
|
|
106
|
+
let e = F().find((p) => p.getAttribute("aria-disabled") !== "true"), c = e?.getAttribute(z);
|
|
107
|
+
k.setState("value", c || void 0);
|
|
108
|
+
}
|
|
109
|
+
function Z() {
|
|
110
|
+
var e, c, p, a;
|
|
111
|
+
if (!r.current.search || m.current.shouldFilter === !1) {
|
|
112
|
+
r.current.filtered.count = f.current.size;
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
r.current.filtered.groups = /* @__PURE__ */ new Set();
|
|
116
|
+
let v = 0;
|
|
117
|
+
for (let b of f.current) {
|
|
118
|
+
let E = (c = (e = o.current.get(b)) == null ? void 0 : e.value) != null ? c : "", y = (a = (p = o.current.get(b)) == null ? void 0 : p.keywords) != null ? a : [], T = oe(E, y);
|
|
119
|
+
r.current.filtered.items.set(b, T), T > 0 && v++;
|
|
120
|
+
}
|
|
121
|
+
for (let [b, E] of u.current) for (let y of E) if (r.current.filtered.items.get(y) > 0) {
|
|
122
|
+
r.current.filtered.groups.add(b);
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
r.current.filtered.count = v;
|
|
126
|
+
}
|
|
127
|
+
function ce() {
|
|
128
|
+
var e, c, p;
|
|
129
|
+
let a = P();
|
|
130
|
+
a && (((e = a.parentElement) == null ? void 0 : e.firstChild) === a && ((p = (c = a.closest(K)) == null ? void 0 : c.querySelector(He)) == null || p.scrollIntoView({ block: "nearest" })), a.scrollIntoView({ block: "nearest" }));
|
|
131
|
+
}
|
|
132
|
+
function P() {
|
|
133
|
+
var e;
|
|
134
|
+
return (e = N.current) == null ? void 0 : e.querySelector(`${be}[aria-selected="true"]`);
|
|
135
|
+
}
|
|
136
|
+
function F() {
|
|
137
|
+
var e;
|
|
138
|
+
return Array.from(((e = N.current) == null ? void 0 : e.querySelectorAll(he)) || []);
|
|
139
|
+
}
|
|
140
|
+
function _(e) {
|
|
141
|
+
let c = F()[e];
|
|
142
|
+
c && k.setState("value", c.getAttribute(z));
|
|
143
|
+
}
|
|
144
|
+
function ee(e) {
|
|
145
|
+
var c;
|
|
146
|
+
let p = P(), a = F(), v = a.findIndex((E) => E === p), b = a[v + e];
|
|
147
|
+
(c = m.current) != null && c.loop && (b = v + e < 0 ? a[a.length - 1] : v + e === a.length ? a[0] : a[v + e]), b && k.setState("value", b.getAttribute(z));
|
|
148
|
+
}
|
|
149
|
+
function se(e) {
|
|
150
|
+
let c = P(), p = c?.closest(K), a;
|
|
151
|
+
for (; p && !a; ) p = e > 0 ? tt(p, K) : rt(p, K), a = p?.querySelector(he);
|
|
152
|
+
a ? k.setState("value", a.getAttribute(z)) : ee(e);
|
|
153
|
+
}
|
|
154
|
+
let de = () => _(F().length - 1), fe = (e) => {
|
|
155
|
+
e.preventDefault(), e.metaKey ? de() : e.altKey ? se(1) : ee(1);
|
|
156
|
+
}, me = (e) => {
|
|
157
|
+
e.preventDefault(), e.metaKey ? _(0) : e.altKey ? se(-1) : ee(-1);
|
|
158
|
+
};
|
|
159
|
+
return l.createElement(A.div, { ref: n, tabIndex: -1, ...B, "cmdk-root": "", onKeyDown: (e) => {
|
|
160
|
+
var c;
|
|
161
|
+
(c = B.onKeyDown) == null || c.call(B, e);
|
|
162
|
+
let p = e.nativeEvent.isComposing || e.keyCode === 229;
|
|
163
|
+
if (!(e.defaultPrevented || p)) switch (e.key) {
|
|
164
|
+
case "n":
|
|
165
|
+
case "j": {
|
|
166
|
+
M && e.ctrlKey && fe(e);
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
case "ArrowDown": {
|
|
170
|
+
fe(e);
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
case "p":
|
|
174
|
+
case "k": {
|
|
175
|
+
M && e.ctrlKey && me(e);
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
case "ArrowUp": {
|
|
179
|
+
me(e);
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
case "Home": {
|
|
183
|
+
e.preventDefault(), _(0);
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
case "End": {
|
|
187
|
+
e.preventDefault(), de();
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
case "Enter": {
|
|
191
|
+
e.preventDefault();
|
|
192
|
+
let a = P();
|
|
193
|
+
if (a) {
|
|
194
|
+
let v = new Event(ae);
|
|
195
|
+
a.dispatchEvent(v);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
} }, l.createElement("label", { "cmdk-label": "", htmlFor: X.inputId, id: X.labelId, style: at }, h), H(t, (e) => l.createElement(ye.Provider, { value: k }, l.createElement(xe.Provider, { value: X }, e))));
|
|
200
|
+
}), Ge = l.forwardRef((t, n) => {
|
|
201
|
+
var r, f;
|
|
202
|
+
let u = j(), o = l.useRef(null), s = l.useContext(we), m = V(), h = Ee(t), i = (f = (r = h.current) == null ? void 0 : r.forceMount) != null ? f : s?.forceMount;
|
|
203
|
+
D(() => {
|
|
204
|
+
if (!i) return m.item(u, s?.id);
|
|
205
|
+
}, [i]);
|
|
206
|
+
let d = Ce(u, o, [t.value, t.children, o], t.keywords), g = ue(), C = R((x) => x.value && x.value === d.current), w = R((x) => i || m.filter() === !1 ? !0 : x.search ? x.filtered.items.get(u) > 0 : !0);
|
|
207
|
+
l.useEffect(() => {
|
|
208
|
+
let x = o.current;
|
|
209
|
+
if (!(!x || t.disabled)) return x.addEventListener(ae, I), () => x.removeEventListener(ae, I);
|
|
210
|
+
}, [w, t.onSelect, t.disabled]);
|
|
211
|
+
function I() {
|
|
212
|
+
var x, k;
|
|
213
|
+
W(), (k = (x = h.current).onSelect) == null || k.call(x, d.current);
|
|
214
|
+
}
|
|
215
|
+
function W() {
|
|
216
|
+
g.setState("value", d.current, !0);
|
|
217
|
+
}
|
|
218
|
+
if (!w) return null;
|
|
219
|
+
let { disabled: M, value: B, onSelect: G, forceMount: ie, keywords: J, ...N } = t;
|
|
220
|
+
return l.createElement(A.div, { ref: L(o, n), ...N, id: u, "cmdk-item": "", role: "option", "aria-disabled": !!M, "aria-selected": !!C, "data-disabled": !!M, "data-selected": !!C, onPointerMove: M || m.getDisablePointerSelection() ? void 0 : W, onClick: M ? void 0 : I }, t.children);
|
|
221
|
+
}), Je = l.forwardRef((t, n) => {
|
|
222
|
+
let { heading: r, children: f, forceMount: u, ...o } = t, s = j(), m = l.useRef(null), h = l.useRef(null), i = j(), d = V(), g = R((w) => u || d.filter() === !1 ? !0 : w.search ? w.filtered.groups.has(s) : !0);
|
|
223
|
+
D(() => d.group(s), []), Ce(s, m, [t.value, t.heading, h]);
|
|
224
|
+
let C = l.useMemo(() => ({ id: s, forceMount: u }), [u]);
|
|
225
|
+
return l.createElement(A.div, { ref: L(m, n), ...o, "cmdk-group": "", role: "presentation", hidden: g ? void 0 : !0 }, r && l.createElement("div", { ref: h, "cmdk-group-heading": "", "aria-hidden": !0, id: i }, r), H(t, (w) => l.createElement("div", { "cmdk-group-items": "", role: "group", "aria-labelledby": r ? i : void 0 }, l.createElement(we.Provider, { value: C }, w))));
|
|
226
|
+
}), Xe = l.forwardRef((t, n) => {
|
|
227
|
+
let { alwaysRender: r, ...f } = t, u = l.useRef(null), o = R((s) => !s.search);
|
|
228
|
+
return !r && !o ? null : l.createElement(A.div, { ref: L(u, n), ...f, "cmdk-separator": "", role: "separator" });
|
|
229
|
+
}), Ye = l.forwardRef((t, n) => {
|
|
230
|
+
let { onValueChange: r, ...f } = t, u = t.value != null, o = ue(), s = R((i) => i.search), m = R((i) => i.selectedItemId), h = V();
|
|
231
|
+
return l.useEffect(() => {
|
|
232
|
+
t.value != null && o.setState("search", t.value);
|
|
233
|
+
}, [t.value]), l.createElement(A.input, { ref: n, ...f, "cmdk-input": "", autoComplete: "off", autoCorrect: "off", spellCheck: !1, "aria-autocomplete": "list", role: "combobox", "aria-expanded": !0, "aria-controls": h.listId, "aria-labelledby": h.labelId, "aria-activedescendant": m, id: h.inputId, type: "text", value: u ? t.value : s, onChange: (i) => {
|
|
234
|
+
u || o.setState("search", i.target.value), r?.(i.target.value);
|
|
235
|
+
} });
|
|
236
|
+
}), Qe = l.forwardRef((t, n) => {
|
|
237
|
+
let { children: r, label: f = "Suggestions", ...u } = t, o = l.useRef(null), s = l.useRef(null), m = R((i) => i.selectedItemId), h = V();
|
|
238
|
+
return l.useEffect(() => {
|
|
239
|
+
if (s.current && o.current) {
|
|
240
|
+
let i = s.current, d = o.current, g, C = new ResizeObserver(() => {
|
|
241
|
+
g = requestAnimationFrame(() => {
|
|
242
|
+
let w = i.offsetHeight;
|
|
243
|
+
d.style.setProperty("--cmdk-list-height", w.toFixed(1) + "px");
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
return C.observe(i), () => {
|
|
247
|
+
cancelAnimationFrame(g), C.unobserve(i);
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
}, []), l.createElement(A.div, { ref: L(o, n), ...u, "cmdk-list": "", role: "listbox", tabIndex: -1, "aria-activedescendant": m, "aria-label": f, id: h.listId }, H(t, (i) => l.createElement("div", { ref: L(s, h.listInnerRef), "cmdk-list-sizer": "" }, i)));
|
|
251
|
+
}), Ze = l.forwardRef((t, n) => {
|
|
252
|
+
let { open: r, onOpenChange: f, overlayClassName: u, contentClassName: o, container: s, ...m } = t;
|
|
253
|
+
return l.createElement(Se, { open: r, onOpenChange: f }, l.createElement(Ie, { container: s }, l.createElement(Re, { "cmdk-overlay": "", className: u }), l.createElement(Ae, { "aria-label": t.label, "cmdk-dialog": "", className: o }, l.createElement(ke, { ref: n, ...m }))));
|
|
254
|
+
}), _e = l.forwardRef((t, n) => R((r) => r.filtered.count === 0) ? l.createElement(A.div, { ref: n, ...t, "cmdk-empty": "", role: "presentation" }) : null), et = l.forwardRef((t, n) => {
|
|
255
|
+
let { progress: r, children: f, label: u = "Loading...", ...o } = t;
|
|
256
|
+
return l.createElement(A.div, { ref: n, ...o, "cmdk-loading": "", role: "progressbar", "aria-valuenow": r, "aria-valuemin": 0, "aria-valuemax": 100, "aria-label": u }, H(t, (s) => l.createElement("div", { "aria-hidden": !0 }, s)));
|
|
257
|
+
}), q = Object.assign(ke, { List: Qe, Item: Ge, Input: Ye, Group: Je, Separator: Xe, Dialog: Ze, Empty: _e, Loading: et });
|
|
258
|
+
function tt(t, n) {
|
|
259
|
+
let r = t.nextElementSibling;
|
|
260
|
+
for (; r; ) {
|
|
261
|
+
if (r.matches(n)) return r;
|
|
262
|
+
r = r.nextElementSibling;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
function rt(t, n) {
|
|
266
|
+
let r = t.previousElementSibling;
|
|
267
|
+
for (; r; ) {
|
|
268
|
+
if (r.matches(n)) return r;
|
|
269
|
+
r = r.previousElementSibling;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
function Ee(t) {
|
|
273
|
+
let n = l.useRef(t);
|
|
274
|
+
return D(() => {
|
|
275
|
+
n.current = t;
|
|
276
|
+
}), n;
|
|
277
|
+
}
|
|
278
|
+
var D = typeof window > "u" ? l.useEffect : l.useLayoutEffect;
|
|
279
|
+
function O(t) {
|
|
280
|
+
let n = l.useRef();
|
|
281
|
+
return n.current === void 0 && (n.current = t()), n;
|
|
282
|
+
}
|
|
283
|
+
function R(t) {
|
|
284
|
+
let n = ue(), r = () => t(n.snapshot());
|
|
285
|
+
return l.useSyncExternalStore(n.subscribe, r, r);
|
|
286
|
+
}
|
|
287
|
+
function Ce(t, n, r, f = []) {
|
|
288
|
+
let u = l.useRef(), o = V();
|
|
289
|
+
return D(() => {
|
|
290
|
+
var s;
|
|
291
|
+
let m = (() => {
|
|
292
|
+
var i;
|
|
293
|
+
for (let d of r) {
|
|
294
|
+
if (typeof d == "string") return d.trim();
|
|
295
|
+
if (typeof d == "object" && "current" in d) return d.current ? (i = d.current.textContent) == null ? void 0 : i.trim() : u.current;
|
|
296
|
+
}
|
|
297
|
+
})(), h = f.map((i) => i.trim());
|
|
298
|
+
o.value(t, m, h), (s = n.current) == null || s.setAttribute(z, m), u.current = m;
|
|
299
|
+
}), u;
|
|
300
|
+
}
|
|
301
|
+
var nt = () => {
|
|
302
|
+
let [t, n] = l.useState(), r = O(() => /* @__PURE__ */ new Map());
|
|
303
|
+
return D(() => {
|
|
304
|
+
r.current.forEach((f) => f()), r.current = /* @__PURE__ */ new Map();
|
|
305
|
+
}, [t]), (f, u) => {
|
|
306
|
+
r.current.set(f, u), n({});
|
|
307
|
+
};
|
|
308
|
+
};
|
|
309
|
+
function lt(t) {
|
|
310
|
+
let n = t.type;
|
|
311
|
+
return typeof n == "function" ? n(t.props) : "render" in n ? n.render(t.props) : t;
|
|
312
|
+
}
|
|
313
|
+
function H({ asChild: t, children: n }, r) {
|
|
314
|
+
return t && l.isValidElement(n) ? l.cloneElement(lt(n), { ref: n.ref }, r(n.props.children)) : r(n);
|
|
315
|
+
}
|
|
316
|
+
var at = { position: "absolute", width: "1px", height: "1px", padding: "0", margin: "-1px", overflow: "hidden", clip: "rect(0, 0, 0, 0)", whiteSpace: "nowrap", borderWidth: "0" };
|
|
317
|
+
function pt({
|
|
318
|
+
options: t,
|
|
319
|
+
value: n,
|
|
320
|
+
onChange: r,
|
|
321
|
+
placeholder: f = "Rechercher...",
|
|
322
|
+
emptyMessage: u = "Aucun resultat.",
|
|
323
|
+
disabled: o = !1,
|
|
324
|
+
className: s
|
|
325
|
+
}) {
|
|
326
|
+
const [m, h] = l.useState(!1), i = t.find((d) => d.value === n);
|
|
327
|
+
return /* @__PURE__ */ $(Me, { open: m, onOpenChange: h, children: [
|
|
328
|
+
/* @__PURE__ */ S(Ne, { asChild: !0, children: /* @__PURE__ */ $(
|
|
329
|
+
"button",
|
|
330
|
+
{
|
|
331
|
+
type: "button",
|
|
332
|
+
role: "combobox",
|
|
333
|
+
"aria-expanded": m,
|
|
334
|
+
disabled: o,
|
|
335
|
+
className: U(
|
|
336
|
+
"flex items-center justify-between gap-2 w-full bg-secondary border border-border rounded-md px-3 py-2 text-sm text-foreground transition-all cursor-pointer",
|
|
337
|
+
"focus:border-primary focus:ring-2 focus:ring-ring focus:outline-none",
|
|
338
|
+
"disabled:opacity-50 disabled:cursor-not-allowed",
|
|
339
|
+
!n && "text-muted-foreground",
|
|
340
|
+
s
|
|
341
|
+
),
|
|
342
|
+
children: [
|
|
343
|
+
/* @__PURE__ */ $("span", { className: "flex items-center gap-2 truncate", children: [
|
|
344
|
+
i?.icon && /* @__PURE__ */ S(i.icon, { className: "size-4 shrink-0" }),
|
|
345
|
+
i ? i.label : f
|
|
346
|
+
] }),
|
|
347
|
+
/* @__PURE__ */ S(Pe, { size: 16, className: "text-muted-foreground shrink-0" })
|
|
348
|
+
]
|
|
349
|
+
}
|
|
350
|
+
) }),
|
|
351
|
+
/* @__PURE__ */ S($e, { children: /* @__PURE__ */ S(
|
|
352
|
+
De,
|
|
353
|
+
{
|
|
354
|
+
sideOffset: 4,
|
|
355
|
+
align: "start",
|
|
356
|
+
className: U(
|
|
357
|
+
"z-50 w-[var(--radix-popover-trigger-width)] overflow-hidden rounded-md border border-border bg-card/95 backdrop-blur-md shadow-lg",
|
|
358
|
+
"animate-in fade-in-0 zoom-in-95"
|
|
359
|
+
),
|
|
360
|
+
children: /* @__PURE__ */ $(q, { className: "flex flex-col", children: [
|
|
361
|
+
/* @__PURE__ */ $("div", { className: "flex items-center gap-2 border-b border-border px-3", children: [
|
|
362
|
+
/* @__PURE__ */ S(ze, { size: 16, className: "text-muted-foreground shrink-0" }),
|
|
363
|
+
/* @__PURE__ */ S(
|
|
364
|
+
q.Input,
|
|
365
|
+
{
|
|
366
|
+
placeholder: f,
|
|
367
|
+
className: "flex-1 bg-transparent py-2 text-sm text-foreground placeholder:text-muted-foreground outline-none"
|
|
368
|
+
}
|
|
369
|
+
)
|
|
370
|
+
] }),
|
|
371
|
+
/* @__PURE__ */ $(q.List, { className: "max-h-[300px] overflow-y-auto p-1", children: [
|
|
372
|
+
/* @__PURE__ */ S(q.Empty, { className: "px-2 py-6 text-center text-sm text-muted-foreground", children: u }),
|
|
373
|
+
t.map((d) => /* @__PURE__ */ $(
|
|
374
|
+
q.Item,
|
|
375
|
+
{
|
|
376
|
+
value: d.label,
|
|
377
|
+
onSelect: () => {
|
|
378
|
+
r(d.value === n ? "" : d.value), h(!1);
|
|
379
|
+
},
|
|
380
|
+
className: U(
|
|
381
|
+
"flex items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-foreground cursor-pointer select-none outline-none transition-colors",
|
|
382
|
+
"data-[selected=true]:bg-primary/10 data-[selected=true]:text-foreground"
|
|
383
|
+
),
|
|
384
|
+
children: [
|
|
385
|
+
d.icon && /* @__PURE__ */ S(d.icon, { className: "size-4 shrink-0" }),
|
|
386
|
+
/* @__PURE__ */ S("span", { className: "flex-1 truncate", children: d.label }),
|
|
387
|
+
/* @__PURE__ */ S(
|
|
388
|
+
Oe,
|
|
389
|
+
{
|
|
390
|
+
size: 14,
|
|
391
|
+
className: U(
|
|
392
|
+
"shrink-0 text-primary",
|
|
393
|
+
n === d.value ? "opacity-100" : "opacity-0"
|
|
394
|
+
)
|
|
395
|
+
}
|
|
396
|
+
)
|
|
397
|
+
]
|
|
398
|
+
},
|
|
399
|
+
d.value
|
|
400
|
+
))
|
|
401
|
+
] })
|
|
402
|
+
] })
|
|
403
|
+
}
|
|
404
|
+
) })
|
|
405
|
+
] });
|
|
406
|
+
}
|
|
407
|
+
export {
|
|
408
|
+
pt as Combobox
|
|
409
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
type Theme = "dark" | "light";
|
|
3
|
+
export interface ThemeToggleProps extends Omit<React.ComponentPropsWithoutRef<"button">, "children" | "onChange"> {
|
|
4
|
+
/**
|
|
5
|
+
* @description Size of the toggle button.
|
|
6
|
+
* @default "md"
|
|
7
|
+
* @example <ThemeToggle size="sm" />
|
|
8
|
+
*/
|
|
9
|
+
size?: "sm" | "md" | "lg";
|
|
10
|
+
/**
|
|
11
|
+
* @description Callback fired after the theme changes. Receives the new theme.
|
|
12
|
+
* @example <ThemeToggle onChange={(theme) => console.log(theme)} />
|
|
13
|
+
*/
|
|
14
|
+
onChange?: (theme: Theme) => void;
|
|
15
|
+
/**
|
|
16
|
+
* @description Additional CSS classes.
|
|
17
|
+
* @example <ThemeToggle className="ml-2" />
|
|
18
|
+
*/
|
|
19
|
+
className?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @description Set the theme to "dark" or "light".
|
|
23
|
+
* Persists the choice in localStorage and applies it to the document.
|
|
24
|
+
* Safe to call in SSR environments (no-op when window/document are unavailable).
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* setTheme("light");
|
|
28
|
+
* setTheme("dark");
|
|
29
|
+
*/
|
|
30
|
+
declare function setTheme(theme: Theme): void;
|
|
31
|
+
/**
|
|
32
|
+
* @description Toggle between dark and light theme.
|
|
33
|
+
* Reads the current stored theme, switches to the opposite, and applies it.
|
|
34
|
+
* Returns the new theme.
|
|
35
|
+
* Safe to call in SSR environments.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* const newTheme = toggleTheme();
|
|
39
|
+
* console.log(newTheme); // "light" or "dark"
|
|
40
|
+
*/
|
|
41
|
+
declare function toggleTheme(): Theme;
|
|
42
|
+
/**
|
|
43
|
+
* @description A button that toggles between dark and light theme.
|
|
44
|
+
* Shows a Sun icon in dark mode and a Moon icon in light mode.
|
|
45
|
+
* Persists the choice in localStorage under the key "btcv-theme".
|
|
46
|
+
* On mount, reads the stored theme and applies it to the document.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* // In a Navbar
|
|
50
|
+
* <Navbar appName="APP" actions={<ThemeToggle />}>
|
|
51
|
+
* ...
|
|
52
|
+
* </Navbar>
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* // Standalone
|
|
56
|
+
* <ThemeToggle size="sm" className="fixed bottom-4 right-4" />
|
|
57
|
+
*/
|
|
58
|
+
declare function ThemeToggle({ size, onChange, className, ...props }: ThemeToggleProps): import("react/jsx-runtime").JSX.Element;
|
|
59
|
+
export { ThemeToggle, setTheme, toggleTheme };
|
package/dist/DarkMode.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
3
|
+
import { useState as m, useEffect as a } from "react";
|
|
4
|
+
import { c as g } from "./_shared/utils-eGXXUFl7.js";
|
|
5
|
+
import { Sun as h, Moon as p } from "lucide-react";
|
|
6
|
+
const i = "btcv-theme";
|
|
7
|
+
function c() {
|
|
8
|
+
return typeof window > "u" ? "dark" : localStorage.getItem(i) || "dark";
|
|
9
|
+
}
|
|
10
|
+
function d(e) {
|
|
11
|
+
typeof document > "u" || (document.documentElement.className = e);
|
|
12
|
+
}
|
|
13
|
+
function b(e) {
|
|
14
|
+
typeof window < "u" && localStorage.setItem(i, e), d(e);
|
|
15
|
+
}
|
|
16
|
+
function T() {
|
|
17
|
+
const n = c() === "dark" ? "light" : "dark";
|
|
18
|
+
return b(n), n;
|
|
19
|
+
}
|
|
20
|
+
function E({ size: e = "md", onChange: n, className: u, ...l }) {
|
|
21
|
+
const [f, r] = m("dark");
|
|
22
|
+
a(() => {
|
|
23
|
+
const t = c();
|
|
24
|
+
r(t), d(t);
|
|
25
|
+
}, []);
|
|
26
|
+
const s = e === "sm" ? 14 : e === "lg" ? 18 : 16;
|
|
27
|
+
return /* @__PURE__ */ o(
|
|
28
|
+
"button",
|
|
29
|
+
{
|
|
30
|
+
type: "button",
|
|
31
|
+
onClick: () => {
|
|
32
|
+
const t = T();
|
|
33
|
+
r(t), n?.(t);
|
|
34
|
+
},
|
|
35
|
+
className: g(
|
|
36
|
+
"inline-flex items-center justify-center cursor-pointer transition-all select-none outline-none",
|
|
37
|
+
"bg-transparent text-muted-foreground border border-transparent",
|
|
38
|
+
"hover:bg-accent hover:text-foreground",
|
|
39
|
+
"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
|
|
40
|
+
{
|
|
41
|
+
sm: "h-7 w-7 rounded-md",
|
|
42
|
+
md: "h-9 w-9 rounded-md",
|
|
43
|
+
lg: "h-11 w-11 rounded-md"
|
|
44
|
+
}[e],
|
|
45
|
+
u
|
|
46
|
+
),
|
|
47
|
+
...l,
|
|
48
|
+
children: f === "dark" ? /* @__PURE__ */ o(h, { size: s }) : /* @__PURE__ */ o(p, { size: s })
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
export {
|
|
53
|
+
E as ThemeToggle,
|
|
54
|
+
b as setTheme,
|
|
55
|
+
T as toggleTheme
|
|
56
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { DayPickerProps } from "react-day-picker";
|
|
2
|
+
export interface DatePickerProps {
|
|
3
|
+
/** Currently selected date (controlled). */
|
|
4
|
+
value?: Date;
|
|
5
|
+
/** Callback fired when the selected date changes. */
|
|
6
|
+
onChange?: (date: Date | undefined) => void;
|
|
7
|
+
/** Placeholder text shown when no date is selected. @default "Choisir une date" */
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
/** Optional label text displayed above the trigger. */
|
|
10
|
+
label?: string;
|
|
11
|
+
/** Additional CSS classes for the trigger button. */
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Standalone calendar component wrapping react-day-picker with BTCV styling.
|
|
16
|
+
* Uses custom navigation buttons with ChevronLeft/ChevronRight icons.
|
|
17
|
+
*
|
|
18
|
+
* @description Renders a month view with day selection. Styling uses BTCV
|
|
19
|
+
* design tokens (primary, muted, foreground, etc.) through Tailwind classes.
|
|
20
|
+
* Accepts the same props as DayPicker.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* <Calendar
|
|
24
|
+
* mode="single"
|
|
25
|
+
* selected={date}
|
|
26
|
+
* onSelect={setDate}
|
|
27
|
+
* />
|
|
28
|
+
*/
|
|
29
|
+
declare function Calendar(props: DayPickerProps & {
|
|
30
|
+
className?: string;
|
|
31
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
/**
|
|
33
|
+
* Date picker input that opens a calendar popover on click.
|
|
34
|
+
* The trigger is styled to match the Input component.
|
|
35
|
+
* Uses Intl.DateTimeFormat for locale-aware date formatting.
|
|
36
|
+
*
|
|
37
|
+
* @description Combines a Radix Popover with the Calendar component.
|
|
38
|
+
* The popover closes automatically when a date is selected.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* const [date, setDate] = React.useState<Date>();
|
|
42
|
+
* <DatePicker label="Date de naissance" value={date} onChange={setDate} />
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* <DatePicker placeholder="Selectionner..." />
|
|
46
|
+
*/
|
|
47
|
+
declare function DatePicker({ value, onChange, placeholder, label, className, }: DatePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
48
|
+
export { Calendar, DatePicker };
|