@bzync/rui 0.0.3
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/LICENSE +15 -0
- package/README.md +115 -0
- package/dist/autocomplete-CaysJRpk.cjs +1 -0
- package/dist/autocomplete-CfbfpcO4.js +453 -0
- package/dist/calendar-Bnld4G59.cjs +1 -0
- package/dist/calendar-CdICOROs.js +573 -0
- package/dist/charts-CxEy2c3M.js +1248 -0
- package/dist/charts-UDqS1BH1.cjs +1 -0
- package/dist/cn-BdjraxxU.cjs +1 -0
- package/dist/cn-DpgY2leY.js +1736 -0
- package/dist/component-styles-Ce56hn9T.js +16 -0
- package/dist/component-styles-TkZ7v6Ef.cjs +1 -0
- package/dist/components/accordion.cjs +1 -0
- package/dist/components/accordion.d.ts +22 -0
- package/dist/components/accordion.js +122 -0
- package/dist/components/alert.cjs +1 -0
- package/dist/components/alert.d.ts +13 -0
- package/dist/components/alert.js +165 -0
- package/dist/components/auth-backdrop.cjs +1 -0
- package/dist/components/auth-backdrop.d.ts +7 -0
- package/dist/components/auth-backdrop.js +10 -0
- package/dist/components/autocomplete/dropdown.d.ts +21 -0
- package/dist/components/autocomplete/icons.d.ts +8 -0
- package/dist/components/autocomplete/multi-trigger.d.ts +25 -0
- package/dist/components/autocomplete/single-trigger.d.ts +21 -0
- package/dist/components/autocomplete/types.d.ts +34 -0
- package/dist/components/autocomplete.cjs +1 -0
- package/dist/components/autocomplete.d.ts +5 -0
- package/dist/components/autocomplete.js +3 -0
- package/dist/components/avatar.cjs +1 -0
- package/dist/components/avatar.d.ts +17 -0
- package/dist/components/avatar.js +56 -0
- package/dist/components/badge.cjs +1 -0
- package/dist/components/badge.d.ts +12 -0
- package/dist/components/badge.js +32 -0
- package/dist/components/billing-interval-toggle.cjs +1 -0
- package/dist/components/billing-interval-toggle.d.ts +18 -0
- package/dist/components/billing-interval-toggle.js +39 -0
- package/dist/components/breadcrumb.cjs +1 -0
- package/dist/components/breadcrumb.d.ts +11 -0
- package/dist/components/breadcrumb.js +52 -0
- package/dist/components/button.cjs +1 -0
- package/dist/components/button.d.ts +17 -0
- package/dist/components/button.js +90 -0
- package/dist/components/calendar/month-view.d.ts +17 -0
- package/dist/components/calendar/types.d.ts +54 -0
- package/dist/components/calendar/week-view.d.ts +17 -0
- package/dist/components/calendar.cjs +1 -0
- package/dist/components/calendar.d.ts +3 -0
- package/dist/components/calendar.js +3 -0
- package/dist/components/callout.cjs +1 -0
- package/dist/components/callout.d.ts +9 -0
- package/dist/components/callout.js +131 -0
- package/dist/components/card.cjs +1 -0
- package/dist/components/card.d.ts +17 -0
- package/dist/components/card.js +59 -0
- package/dist/components/charts/bar-chart.d.ts +16 -0
- package/dist/components/charts/donut-chart.d.ts +10 -0
- package/dist/components/charts/funnel-chart.d.ts +8 -0
- package/dist/components/charts/gantt-chart.d.ts +15 -0
- package/dist/components/charts/heatmap-chart.d.ts +10 -0
- package/dist/components/charts/index.d.ts +11 -0
- package/dist/components/charts/line-chart.d.ts +16 -0
- package/dist/components/charts/multi-line-chart.d.ts +18 -0
- package/dist/components/charts/radar-chart.d.ts +13 -0
- package/dist/components/charts/scatter-chart.d.ts +24 -0
- package/dist/components/charts/shared.d.ts +15 -0
- package/dist/components/charts/waterfall-chart.d.ts +14 -0
- package/dist/components/charts.cjs +1 -0
- package/dist/components/charts.d.ts +2 -0
- package/dist/components/charts.js +2 -0
- package/dist/components/checkbox.cjs +1 -0
- package/dist/components/checkbox.d.ts +9 -0
- package/dist/components/checkbox.js +135 -0
- package/dist/components/code.cjs +7 -0
- package/dist/components/code.d.ts +23 -0
- package/dist/components/code.js +276 -0
- package/dist/components/command.cjs +1 -0
- package/dist/components/command.d.ts +29 -0
- package/dist/components/command.js +208 -0
- package/dist/components/confirm-dialog.cjs +1 -0
- package/dist/components/confirm-dialog.d.ts +14 -0
- package/dist/components/confirm-dialog.js +69 -0
- package/dist/components/copy-button.cjs +1 -0
- package/dist/components/copy-button.d.ts +8 -0
- package/dist/components/copy-button.js +87 -0
- package/dist/components/datatable/pagination-footer.d.ts +10 -0
- package/dist/components/datatable/rows-dropdown.d.ts +5 -0
- package/dist/components/datatable/skeleton-row.d.ts +3 -0
- package/dist/components/datatable/sort-icon.d.ts +4 -0
- package/dist/components/datatable/types.d.ts +30 -0
- package/dist/components/datatable.cjs +1 -0
- package/dist/components/datatable.d.ts +9 -0
- package/dist/components/datatable.js +3 -0
- package/dist/components/datepicker.cjs +1 -0
- package/dist/components/datepicker.d.ts +14 -0
- package/dist/components/datepicker.js +267 -0
- package/dist/components/drawer.cjs +1 -0
- package/dist/components/drawer.d.ts +18 -0
- package/dist/components/drawer.js +3 -0
- package/dist/components/dropdown-menu.cjs +1 -0
- package/dist/components/dropdown-menu.d.ts +26 -0
- package/dist/components/dropdown-menu.js +122 -0
- package/dist/components/empty-state.cjs +1 -0
- package/dist/components/empty-state.d.ts +10 -0
- package/dist/components/empty-state.js +68 -0
- package/dist/components/error-state.cjs +1 -0
- package/dist/components/error-state.d.ts +10 -0
- package/dist/components/error-state.js +80 -0
- package/dist/components/file-upload.cjs +1 -0
- package/dist/components/file-upload.d.ts +10 -0
- package/dist/components/file-upload.js +173 -0
- package/dist/components/form-field.cjs +1 -0
- package/dist/components/form-field.d.ts +10 -0
- package/dist/components/form-field.js +36 -0
- package/dist/components/info-button.cjs +1 -0
- package/dist/components/info-button.d.ts +4 -0
- package/dist/components/info-button.js +32 -0
- package/dist/components/input.cjs +1 -0
- package/dist/components/input.d.ts +19 -0
- package/dist/components/input.js +117 -0
- package/dist/components/kbd.cjs +1 -0
- package/dist/components/kbd.d.ts +6 -0
- package/dist/components/kbd.js +16 -0
- package/dist/components/label.cjs +1 -0
- package/dist/components/label.d.ts +6 -0
- package/dist/components/label.js +31 -0
- package/dist/components/layout.cjs +1 -0
- package/dist/components/layout.d.ts +51 -0
- package/dist/components/layout.js +117 -0
- package/dist/components/link.cjs +1 -0
- package/dist/components/link.d.ts +9 -0
- package/dist/components/link.js +48 -0
- package/dist/components/list.cjs +1 -0
- package/dist/components/list.d.ts +13 -0
- package/dist/components/list.js +46 -0
- package/dist/components/modal.cjs +1 -0
- package/dist/components/modal.d.ts +31 -0
- package/dist/components/modal.js +219 -0
- package/dist/components/navigation.cjs +1 -0
- package/dist/components/navigation.d.ts +42 -0
- package/dist/components/navigation.js +127 -0
- package/dist/components/number-input.cjs +1 -0
- package/dist/components/number-input.d.ts +16 -0
- package/dist/components/number-input.js +142 -0
- package/dist/components/otp-input.cjs +1 -0
- package/dist/components/otp-input.d.ts +13 -0
- package/dist/components/otp-input.js +71 -0
- package/dist/components/pagination.cjs +1 -0
- package/dist/components/pagination.d.ts +8 -0
- package/dist/components/pagination.js +77 -0
- package/dist/components/popover.cjs +1 -0
- package/dist/components/popover.d.ts +16 -0
- package/dist/components/popover.js +115 -0
- package/dist/components/progressbar.cjs +1 -0
- package/dist/components/progressbar.d.ts +15 -0
- package/dist/components/progressbar.js +108 -0
- package/dist/components/radio.cjs +1 -0
- package/dist/components/radio.d.ts +22 -0
- package/dist/components/radio.js +96 -0
- package/dist/components/richtext.cjs +1 -0
- package/dist/components/richtext.d.ts +10 -0
- package/dist/components/richtext.js +370 -0
- package/dist/components/select/option-list.d.ts +16 -0
- package/dist/components/select/select-multi.d.ts +2 -0
- package/dist/components/select/select-single.d.ts +2 -0
- package/dist/components/select/types.d.ts +54 -0
- package/dist/components/select/utils.d.ts +10 -0
- package/dist/components/select.cjs +1 -0
- package/dist/components/select.d.ts +3 -0
- package/dist/components/select.js +2 -0
- package/dist/components/seo.cjs +1 -0
- package/dist/components/seo.d.ts +45 -0
- package/dist/components/seo.js +64 -0
- package/dist/components/separator.cjs +1 -0
- package/dist/components/separator.d.ts +6 -0
- package/dist/components/separator.js +25 -0
- package/dist/components/skeleton.cjs +1 -0
- package/dist/components/skeleton.d.ts +37 -0
- package/dist/components/skeleton.js +146 -0
- package/dist/components/slider.cjs +1 -0
- package/dist/components/slider.d.ts +12 -0
- package/dist/components/slider.js +72 -0
- package/dist/components/snackbar.cjs +1 -0
- package/dist/components/snackbar.d.ts +35 -0
- package/dist/components/snackbar.js +220 -0
- package/dist/components/spinner.cjs +1 -0
- package/dist/components/spinner.d.ts +7 -0
- package/dist/components/spinner.js +31 -0
- package/dist/components/stat.cjs +1 -0
- package/dist/components/stat.d.ts +18 -0
- package/dist/components/stat.js +90 -0
- package/dist/components/status-dot.cjs +1 -0
- package/dist/components/status-dot.d.ts +10 -0
- package/dist/components/status-dot.js +29 -0
- package/dist/components/stepper.cjs +1 -0
- package/dist/components/stepper.d.ts +11 -0
- package/dist/components/stepper.js +67 -0
- package/dist/components/switch.cjs +1 -0
- package/dist/components/switch.d.ts +8 -0
- package/dist/components/switch.js +79 -0
- package/dist/components/table.cjs +1 -0
- package/dist/components/table.d.ts +12 -0
- package/dist/components/table.js +54 -0
- package/dist/components/tabs.cjs +1 -0
- package/dist/components/tabs.d.ts +22 -0
- package/dist/components/tabs.js +120 -0
- package/dist/components/tag.cjs +1 -0
- package/dist/components/tag.d.ts +12 -0
- package/dist/components/tag.js +58 -0
- package/dist/components/terminal/fs.d.ts +10 -0
- package/dist/components/terminal/shell-commands-sim.d.ts +5 -0
- package/dist/components/terminal/shell-commands.d.ts +16 -0
- package/dist/components/terminal/shell-run.d.ts +11 -0
- package/dist/components/terminal/terminal-block.d.ts +13 -0
- package/dist/components/terminal/terminal-emulator.d.ts +10 -0
- package/dist/components/terminal/types.d.ts +35 -0
- package/dist/components/terminal.cjs +1 -0
- package/dist/components/terminal.d.ts +2 -0
- package/dist/components/terminal.js +2 -0
- package/dist/components/textarea.cjs +1 -0
- package/dist/components/textarea.d.ts +13 -0
- package/dist/components/textarea.js +54 -0
- package/dist/components/theme-provider.cjs +1 -0
- package/dist/components/theme-provider.d.ts +89 -0
- package/dist/components/theme-provider.js +93 -0
- package/dist/components/theme-toggle.cjs +1 -0
- package/dist/components/theme-toggle.d.ts +9 -0
- package/dist/components/theme-toggle.js +4 -0
- package/dist/components/timeline.cjs +1 -0
- package/dist/components/timeline.d.ts +14 -0
- package/dist/components/timeline.js +54 -0
- package/dist/components/tooltip.cjs +1 -0
- package/dist/components/tooltip.d.ts +11 -0
- package/dist/components/tooltip.js +84 -0
- package/dist/components/tree.cjs +1 -0
- package/dist/components/tree.d.ts +16 -0
- package/dist/components/tree.js +92 -0
- package/dist/createLucideIcon-DDY8HuQR.js +42 -0
- package/dist/createLucideIcon-b_X_3fj-.cjs +1 -0
- package/dist/datatable-BB3v__r5.cjs +1 -0
- package/dist/datatable-DlBhUhuO.js +316 -0
- package/dist/drawer-Cbuh6qdL.cjs +1 -0
- package/dist/drawer-CqkVZT9Y.js +189 -0
- package/dist/focus-Dk1YWVPN.js +42 -0
- package/dist/focus-DmG6Ge7X.cjs +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +70 -0
- package/dist/index.js +215 -0
- package/dist/lib/cn.d.ts +2 -0
- package/dist/lib/component-styles.d.ts +10 -0
- package/dist/select-Ch5fp1GT.js +461 -0
- package/dist/select-q0YCMhBP.cjs +1 -0
- package/dist/styles.css +3 -0
- package/dist/terminal-BOR2cFi1.js +1060 -0
- package/dist/terminal-CpraMs50.cjs +77 -0
- package/dist/theme-toggle-CnoiorKV.js +71 -0
- package/dist/theme-toggle-Dp1-24zH.cjs +1 -0
- package/dist/use-event-callback-DGkfO_uu.js +10 -0
- package/dist/use-event-callback-Du9_9eAi.cjs +1 -0
- package/dist/utils-CQ8pvCtk.js +72 -0
- package/dist/utils-DOFJTw8o.cjs +1 -0
- package/package.json +88 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface CommandItem {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
icon?: ReactNode;
|
|
7
|
+
shortcut?: string[];
|
|
8
|
+
group?: string;
|
|
9
|
+
keywords?: string[];
|
|
10
|
+
onSelect: () => void;
|
|
11
|
+
}
|
|
12
|
+
interface CommandContextValue {
|
|
13
|
+
open: boolean;
|
|
14
|
+
setOpen: (v: boolean) => void;
|
|
15
|
+
}
|
|
16
|
+
export declare function useCommand(): CommandContextValue;
|
|
17
|
+
export interface CommandProviderProps {
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
shortcut?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function CommandProvider({ children, shortcut }: CommandProviderProps): import("react").JSX.Element;
|
|
22
|
+
export interface CommandPaletteProps {
|
|
23
|
+
items: CommandItem[];
|
|
24
|
+
placeholder?: string;
|
|
25
|
+
emptyText?: string;
|
|
26
|
+
ariaLabel?: string;
|
|
27
|
+
}
|
|
28
|
+
export declare function CommandPalette({ items, placeholder, emptyText, ariaLabel, }: CommandPaletteProps): import("react").JSX.Element;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as e } from "../cn-DpgY2leY.js";
|
|
3
|
+
import "../component-styles-Ce56hn9T.js";
|
|
4
|
+
import { t } from "../focus-Dk1YWVPN.js";
|
|
5
|
+
import { AnimatePresence as n, motion as r } from "framer-motion";
|
|
6
|
+
import { createContext as i, useContext as a, useEffect as o, useId as s, useMemo as c, useRef as l, useState as u } from "react";
|
|
7
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/command.tsx
|
|
9
|
+
var p = i(null);
|
|
10
|
+
function m() {
|
|
11
|
+
let e = a(p);
|
|
12
|
+
if (!e) throw Error("useCommand must be inside <CommandProvider>");
|
|
13
|
+
return e;
|
|
14
|
+
}
|
|
15
|
+
function h({ children: e, shortcut: t = "k" }) {
|
|
16
|
+
let [n, r] = u(!1);
|
|
17
|
+
return o(() => {
|
|
18
|
+
function e(e) {
|
|
19
|
+
(e.metaKey || e.ctrlKey) && e.key === t && (e.preventDefault(), r((e) => !e));
|
|
20
|
+
}
|
|
21
|
+
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
22
|
+
}, [t]), /* @__PURE__ */ d(p.Provider, {
|
|
23
|
+
value: {
|
|
24
|
+
open: n,
|
|
25
|
+
setOpen: r
|
|
26
|
+
},
|
|
27
|
+
children: e
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function g({ items: i, placeholder: a = "Search commands…", emptyText: p = "No results found.", ariaLabel: h = "Command palette" }) {
|
|
31
|
+
let { open: g, setOpen: _ } = m(), [v, y] = u(""), [b, x] = u(0), S = l(null), C = l(null), w = l(null), T = s();
|
|
32
|
+
o(() => {
|
|
33
|
+
if (!g) return;
|
|
34
|
+
let e = document.activeElement instanceof HTMLElement ? document.activeElement : null, n = document.body.style.overflow, r = window.setTimeout(() => S.current?.focus(), 0), i = (e) => {
|
|
35
|
+
if (e.key === "Escape") {
|
|
36
|
+
e.preventDefault(), _(!1);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (e.key !== "Tab" || !w.current) return;
|
|
40
|
+
let n = t(w.current);
|
|
41
|
+
if (n.length === 0) {
|
|
42
|
+
e.preventDefault(), w.current.focus();
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
let r = n[0], i = n[n.length - 1];
|
|
46
|
+
e.shiftKey && document.activeElement === r ? (e.preventDefault(), i.focus()) : !e.shiftKey && document.activeElement === i && (e.preventDefault(), r.focus());
|
|
47
|
+
};
|
|
48
|
+
return y(""), x(0), document.body.style.overflow = "hidden", document.addEventListener("keydown", i), () => {
|
|
49
|
+
window.clearTimeout(r), document.body.style.overflow = n, document.removeEventListener("keydown", i), e?.focus();
|
|
50
|
+
};
|
|
51
|
+
}, [g, _]);
|
|
52
|
+
let E = c(() => {
|
|
53
|
+
if (!v) return i;
|
|
54
|
+
let e = v.toLowerCase();
|
|
55
|
+
return i.filter((t) => t.label.toLowerCase().includes(e) || t.description?.toLowerCase().includes(e) || t.keywords?.some((t) => t.toLowerCase().includes(e)));
|
|
56
|
+
}, [v, i]), D = c(() => {
|
|
57
|
+
let e = /* @__PURE__ */ new Map();
|
|
58
|
+
for (let t of E) {
|
|
59
|
+
let n = t.group ?? "";
|
|
60
|
+
e.has(n) || e.set(n, []), e.get(n).push(t);
|
|
61
|
+
}
|
|
62
|
+
return e;
|
|
63
|
+
}, [E]), O = c(() => Array.from(D.values()).flat(), [D]);
|
|
64
|
+
function k(e) {
|
|
65
|
+
e.key === "ArrowDown" ? (e.preventDefault(), x((e) => Math.min(e + 1, Math.max(O.length - 1, 0)))) : e.key === "ArrowUp" ? (e.preventDefault(), x((e) => Math.max(e - 1, 0))) : e.key === "Enter" ? (e.preventDefault(), O[b]?.onSelect(), _(!1)) : e.key === "Escape" && _(!1);
|
|
66
|
+
}
|
|
67
|
+
o(() => {
|
|
68
|
+
C.current && C.current.querySelector("[data-active=\"true\"]")?.scrollIntoView({ block: "nearest" });
|
|
69
|
+
}, [b]);
|
|
70
|
+
let A = 0;
|
|
71
|
+
return /* @__PURE__ */ d(n, { children: g && /* @__PURE__ */ f("div", {
|
|
72
|
+
className: "fixed inset-0 z-[200] flex items-start justify-center pt-[15vh] p-4",
|
|
73
|
+
children: [/* @__PURE__ */ d(r.div, {
|
|
74
|
+
initial: { opacity: 0 },
|
|
75
|
+
animate: { opacity: 1 },
|
|
76
|
+
exit: { opacity: 0 },
|
|
77
|
+
transition: { duration: .15 },
|
|
78
|
+
className: "absolute inset-0 bg-overlay",
|
|
79
|
+
onClick: () => _(!1),
|
|
80
|
+
"aria-hidden": "true"
|
|
81
|
+
}), /* @__PURE__ */ f(r.div, {
|
|
82
|
+
ref: w,
|
|
83
|
+
tabIndex: -1,
|
|
84
|
+
role: "dialog",
|
|
85
|
+
"aria-modal": "true",
|
|
86
|
+
"aria-label": h,
|
|
87
|
+
initial: {
|
|
88
|
+
opacity: 0,
|
|
89
|
+
scale: .96,
|
|
90
|
+
y: -8
|
|
91
|
+
},
|
|
92
|
+
animate: {
|
|
93
|
+
opacity: 1,
|
|
94
|
+
scale: 1,
|
|
95
|
+
y: 0
|
|
96
|
+
},
|
|
97
|
+
exit: {
|
|
98
|
+
opacity: 0,
|
|
99
|
+
scale: .96,
|
|
100
|
+
y: -8
|
|
101
|
+
},
|
|
102
|
+
transition: {
|
|
103
|
+
type: "spring",
|
|
104
|
+
stiffness: 400,
|
|
105
|
+
damping: 30
|
|
106
|
+
},
|
|
107
|
+
className: "relative w-full max-w-lg overflow-hidden rounded-[var(--radius-xl)] border border-border bg-surface-raised shadow-overlay",
|
|
108
|
+
children: [/* @__PURE__ */ f("div", {
|
|
109
|
+
className: "flex items-center gap-3 border-b border-border px-4",
|
|
110
|
+
children: [
|
|
111
|
+
/* @__PURE__ */ f("svg", {
|
|
112
|
+
width: "16",
|
|
113
|
+
height: "16",
|
|
114
|
+
viewBox: "0 0 24 24",
|
|
115
|
+
fill: "none",
|
|
116
|
+
stroke: "currentColor",
|
|
117
|
+
strokeWidth: "2",
|
|
118
|
+
strokeLinecap: "round",
|
|
119
|
+
strokeLinejoin: "round",
|
|
120
|
+
className: "text-slate-400 shrink-0",
|
|
121
|
+
children: [/* @__PURE__ */ d("circle", {
|
|
122
|
+
cx: "11",
|
|
123
|
+
cy: "11",
|
|
124
|
+
r: "8"
|
|
125
|
+
}), /* @__PURE__ */ d("path", { d: "m21 21-4.35-4.35" })]
|
|
126
|
+
}),
|
|
127
|
+
/* @__PURE__ */ d("input", {
|
|
128
|
+
ref: S,
|
|
129
|
+
type: "search",
|
|
130
|
+
role: "combobox",
|
|
131
|
+
"aria-label": h,
|
|
132
|
+
"aria-autocomplete": "list",
|
|
133
|
+
"aria-expanded": "true",
|
|
134
|
+
"aria-controls": T,
|
|
135
|
+
"aria-activedescendant": O[b] ? `${T}-option-${b}` : void 0,
|
|
136
|
+
value: v,
|
|
137
|
+
onChange: (e) => {
|
|
138
|
+
y(e.target.value), x(0);
|
|
139
|
+
},
|
|
140
|
+
onKeyDown: k,
|
|
141
|
+
placeholder: a,
|
|
142
|
+
className: "min-w-0 flex-1 bg-transparent py-3.5 text-sm text-foreground outline-none placeholder:text-muted-foreground"
|
|
143
|
+
}),
|
|
144
|
+
/* @__PURE__ */ d("kbd", {
|
|
145
|
+
className: "shrink-0 rounded-[var(--radius-sm)] border border-border-strong bg-surface-muted px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground",
|
|
146
|
+
children: "ESC"
|
|
147
|
+
})
|
|
148
|
+
]
|
|
149
|
+
}), /* @__PURE__ */ d("div", {
|
|
150
|
+
id: T,
|
|
151
|
+
ref: C,
|
|
152
|
+
role: "listbox",
|
|
153
|
+
"aria-label": "Commands",
|
|
154
|
+
className: "max-h-80 overflow-y-auto py-1.5",
|
|
155
|
+
children: E.length === 0 ? /* @__PURE__ */ d("p", {
|
|
156
|
+
className: "py-10 text-center text-sm text-muted-foreground",
|
|
157
|
+
children: p
|
|
158
|
+
}) : Array.from(D.entries()).map(([t, n]) => /* @__PURE__ */ f("div", {
|
|
159
|
+
role: "group",
|
|
160
|
+
"aria-label": t || void 0,
|
|
161
|
+
children: [t && /* @__PURE__ */ d("p", {
|
|
162
|
+
className: "px-4 py-1 text-[10px] font-semibold text-slate-500 uppercase tracking-widest",
|
|
163
|
+
children: t
|
|
164
|
+
}), n.map((t) => {
|
|
165
|
+
let n = A++, r = n === b;
|
|
166
|
+
return /* @__PURE__ */ f("button", {
|
|
167
|
+
id: `${T}-option-${n}`,
|
|
168
|
+
type: "button",
|
|
169
|
+
role: "option",
|
|
170
|
+
"aria-selected": r,
|
|
171
|
+
"data-active": r,
|
|
172
|
+
onClick: () => {
|
|
173
|
+
t.onSelect(), _(!1);
|
|
174
|
+
},
|
|
175
|
+
onMouseEnter: () => x(n),
|
|
176
|
+
className: e("flex w-full items-center gap-3 px-4 py-2.5 text-left transition-colors", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring/35 focus-visible:ring-offset-2 focus-visible:ring-offset-bg", r ? "bg-surface-muted" : "hover:bg-surface-muted/70"),
|
|
177
|
+
children: [
|
|
178
|
+
t.icon && /* @__PURE__ */ d("span", {
|
|
179
|
+
className: "shrink-0 text-slate-500 dark:text-slate-400 w-5 flex items-center justify-center",
|
|
180
|
+
children: t.icon
|
|
181
|
+
}),
|
|
182
|
+
/* @__PURE__ */ f("div", {
|
|
183
|
+
className: "flex-1 min-w-0",
|
|
184
|
+
children: [/* @__PURE__ */ d("p", {
|
|
185
|
+
className: "truncate text-sm text-foreground",
|
|
186
|
+
children: t.label
|
|
187
|
+
}), t.description && /* @__PURE__ */ d("p", {
|
|
188
|
+
className: "truncate text-xs text-muted-foreground",
|
|
189
|
+
children: t.description
|
|
190
|
+
})]
|
|
191
|
+
}),
|
|
192
|
+
t.shortcut && /* @__PURE__ */ d("div", {
|
|
193
|
+
className: "flex items-center gap-0.5 shrink-0",
|
|
194
|
+
children: t.shortcut.map((e, t) => /* @__PURE__ */ d("kbd", {
|
|
195
|
+
className: "rounded-[var(--radius-sm)] border border-border bg-surface-muted px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground",
|
|
196
|
+
children: e
|
|
197
|
+
}, t))
|
|
198
|
+
})
|
|
199
|
+
]
|
|
200
|
+
}, t.id);
|
|
201
|
+
})]
|
|
202
|
+
}, t))
|
|
203
|
+
})]
|
|
204
|
+
})]
|
|
205
|
+
}) });
|
|
206
|
+
}
|
|
207
|
+
//#endregion
|
|
208
|
+
export { g as CommandPalette, h as CommandProvider, m as useCommand };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./button.cjs"),t=require("./modal.cjs");let n=require("react/jsx-runtime");function r({open:r,onClose:i,onConfirm:a,title:o=`Are you sure?`,description:s,confirmLabel:c=`Confirm`,cancelLabel:l=`Cancel`,destructive:u=!1,loading:d=!1,icon:f}){return(0,n.jsxs)(t.Modal,{open:r,onClose:i,size:`sm`,title:o,description:typeof s==`string`?s:void 0,icon:f??(u?(0,n.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`text-red-600 dark:text-red-400`,children:[(0,n.jsx)(`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z`}),(0,n.jsx)(`path`,{d:`M12 9v4`}),(0,n.jsx)(`path`,{d:`M12 17h.01`})]}):(0,n.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`text-info`,children:[(0,n.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,n.jsx)(`path`,{d:`M12 16v-4`}),(0,n.jsx)(`path`,{d:`M12 8h.01`})]})),children:[typeof s!=`string`&&s&&(0,n.jsx)(`div`,{className:`text-sm leading-relaxed text-slate-600 dark:text-slate-400`,children:s}),(0,n.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2.5 pt-2`,children:[(0,n.jsx)(e.Button,{variant:`ghost`,onClick:i,disabled:d,children:l}),(0,n.jsx)(e.Button,{variant:u?`destructive`:`primary`,onClick:a,loading:d,autoFocus:!0,children:c})]})]})}exports.ConfirmDialog=r;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface ConfirmDialogProps {
|
|
3
|
+
open: boolean;
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
onConfirm: () => void;
|
|
6
|
+
title?: string;
|
|
7
|
+
description?: ReactNode;
|
|
8
|
+
confirmLabel?: string;
|
|
9
|
+
cancelLabel?: string;
|
|
10
|
+
destructive?: boolean;
|
|
11
|
+
loading?: boolean;
|
|
12
|
+
icon?: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
export declare function ConfirmDialog({ open, onClose, onConfirm, title, description, confirmLabel, cancelLabel, destructive, loading, icon, }: ConfirmDialogProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Button as e } from "./button.js";
|
|
3
|
+
import { Modal as t } from "./modal.js";
|
|
4
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/confirm-dialog.tsx
|
|
6
|
+
function i({ open: i, onClose: a, onConfirm: o, title: s = "Are you sure?", description: c, confirmLabel: l = "Confirm", cancelLabel: u = "Cancel", destructive: d = !1, loading: f = !1, icon: p }) {
|
|
7
|
+
return /* @__PURE__ */ r(t, {
|
|
8
|
+
open: i,
|
|
9
|
+
onClose: a,
|
|
10
|
+
size: "sm",
|
|
11
|
+
title: s,
|
|
12
|
+
description: typeof c == "string" ? c : void 0,
|
|
13
|
+
icon: p ?? (d ? /* @__PURE__ */ r("svg", {
|
|
14
|
+
width: "20",
|
|
15
|
+
height: "20",
|
|
16
|
+
viewBox: "0 0 24 24",
|
|
17
|
+
fill: "none",
|
|
18
|
+
stroke: "currentColor",
|
|
19
|
+
strokeWidth: "1.75",
|
|
20
|
+
strokeLinecap: "round",
|
|
21
|
+
strokeLinejoin: "round",
|
|
22
|
+
className: "text-red-600 dark:text-red-400",
|
|
23
|
+
children: [
|
|
24
|
+
/* @__PURE__ */ n("path", { d: "m21.73 18-8-14a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z" }),
|
|
25
|
+
/* @__PURE__ */ n("path", { d: "M12 9v4" }),
|
|
26
|
+
/* @__PURE__ */ n("path", { d: "M12 17h.01" })
|
|
27
|
+
]
|
|
28
|
+
}) : /* @__PURE__ */ r("svg", {
|
|
29
|
+
width: "20",
|
|
30
|
+
height: "20",
|
|
31
|
+
viewBox: "0 0 24 24",
|
|
32
|
+
fill: "none",
|
|
33
|
+
stroke: "currentColor",
|
|
34
|
+
strokeWidth: "1.75",
|
|
35
|
+
strokeLinecap: "round",
|
|
36
|
+
strokeLinejoin: "round",
|
|
37
|
+
className: "text-info",
|
|
38
|
+
children: [
|
|
39
|
+
/* @__PURE__ */ n("circle", {
|
|
40
|
+
cx: "12",
|
|
41
|
+
cy: "12",
|
|
42
|
+
r: "10"
|
|
43
|
+
}),
|
|
44
|
+
/* @__PURE__ */ n("path", { d: "M12 16v-4" }),
|
|
45
|
+
/* @__PURE__ */ n("path", { d: "M12 8h.01" })
|
|
46
|
+
]
|
|
47
|
+
})),
|
|
48
|
+
children: [typeof c != "string" && c && /* @__PURE__ */ n("div", {
|
|
49
|
+
className: "text-sm leading-relaxed text-slate-600 dark:text-slate-400",
|
|
50
|
+
children: c
|
|
51
|
+
}), /* @__PURE__ */ r("div", {
|
|
52
|
+
className: "flex flex-wrap justify-end gap-2.5 pt-2",
|
|
53
|
+
children: [/* @__PURE__ */ n(e, {
|
|
54
|
+
variant: "ghost",
|
|
55
|
+
onClick: a,
|
|
56
|
+
disabled: f,
|
|
57
|
+
children: u
|
|
58
|
+
}), /* @__PURE__ */ n(e, {
|
|
59
|
+
variant: d ? "destructive" : "primary",
|
|
60
|
+
onClick: o,
|
|
61
|
+
loading: f,
|
|
62
|
+
autoFocus: !0,
|
|
63
|
+
children: l
|
|
64
|
+
})]
|
|
65
|
+
})]
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { i as ConfirmDialog };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../cn-BdjraxxU.cjs");let t=require("framer-motion"),n=require("react"),r=require("react/jsx-runtime");var i=()=>(0,r.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,r.jsx)(`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`}),(0,r.jsx)(`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`})]}),a=()=>(0,r.jsx)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,r.jsx)(`path`,{d:`m20 6-11 11-5-5`})});function o({value:o,timeout:s=2e3,label:c,size:l=`sm`,className:u,...d}){let[f,p]=(0,n.useState)(!1);async function m(){try{await navigator.clipboard.writeText(o),p(!0),setTimeout(()=>p(!1),s)}catch{}}return(0,r.jsx)(`button`,{type:`button`,onClick:m,className:e.t(`inline-flex items-center font-medium transition-colors select-none`,`border border-black/10 dark:border-white/10`,f?`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`:`bg-black/4 dark:bg-white/4 text-slate-500 dark:text-slate-400 hover:text-slate-700 dark:hover:text-slate-200 hover:bg-black/8 dark:hover:bg-white/8`,l===`sm`?`h-6 px-2 text-xs gap-1 rounded-md`:`h-8 px-3 text-sm gap-1.5 rounded-lg`,u),...d,children:(0,r.jsx)(t.AnimatePresence,{mode:`wait`,initial:!1,children:f?(0,r.jsxs)(t.motion.span,{initial:{scale:.8,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.8,opacity:0},transition:{duration:.1},className:`flex items-center gap-1`,children:[(0,r.jsx)(a,{}),c&&`Copied`]},`check`):(0,r.jsxs)(t.motion.span,{initial:{scale:.8,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.8,opacity:0},transition:{duration:.1},className:`flex items-center gap-1`,children:[(0,r.jsx)(i,{}),c&&c]},`copy`)})})}exports.CopyButton=o;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ButtonHTMLAttributes } from 'react';
|
|
2
|
+
export interface CopyButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children"> {
|
|
3
|
+
value: string;
|
|
4
|
+
timeout?: number;
|
|
5
|
+
label?: string;
|
|
6
|
+
size?: "sm" | "md";
|
|
7
|
+
}
|
|
8
|
+
export declare function CopyButton({ value, timeout, label, size, className, ...props }: CopyButtonProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as e } from "../cn-DpgY2leY.js";
|
|
3
|
+
import { AnimatePresence as t, motion as n } from "framer-motion";
|
|
4
|
+
import { useState as r } from "react";
|
|
5
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/copy-button.tsx
|
|
7
|
+
var o = () => /* @__PURE__ */ a("svg", {
|
|
8
|
+
width: "13",
|
|
9
|
+
height: "13",
|
|
10
|
+
viewBox: "0 0 24 24",
|
|
11
|
+
fill: "none",
|
|
12
|
+
stroke: "currentColor",
|
|
13
|
+
strokeWidth: "2",
|
|
14
|
+
strokeLinecap: "round",
|
|
15
|
+
strokeLinejoin: "round",
|
|
16
|
+
children: [/* @__PURE__ */ i("rect", {
|
|
17
|
+
width: "14",
|
|
18
|
+
height: "14",
|
|
19
|
+
x: "8",
|
|
20
|
+
y: "8",
|
|
21
|
+
rx: "2",
|
|
22
|
+
ry: "2"
|
|
23
|
+
}), /* @__PURE__ */ i("path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" })]
|
|
24
|
+
}), s = () => /* @__PURE__ */ i("svg", {
|
|
25
|
+
width: "13",
|
|
26
|
+
height: "13",
|
|
27
|
+
viewBox: "0 0 24 24",
|
|
28
|
+
fill: "none",
|
|
29
|
+
stroke: "currentColor",
|
|
30
|
+
strokeWidth: "2.5",
|
|
31
|
+
strokeLinecap: "round",
|
|
32
|
+
strokeLinejoin: "round",
|
|
33
|
+
children: /* @__PURE__ */ i("path", { d: "m20 6-11 11-5-5" })
|
|
34
|
+
});
|
|
35
|
+
function c({ value: c, timeout: l = 2e3, label: u, size: d = "sm", className: f, ...p }) {
|
|
36
|
+
let [m, h] = r(!1);
|
|
37
|
+
async function g() {
|
|
38
|
+
try {
|
|
39
|
+
await navigator.clipboard.writeText(c), h(!0), setTimeout(() => h(!1), l);
|
|
40
|
+
} catch {}
|
|
41
|
+
}
|
|
42
|
+
return /* @__PURE__ */ i("button", {
|
|
43
|
+
type: "button",
|
|
44
|
+
onClick: g,
|
|
45
|
+
className: e("inline-flex items-center font-medium transition-colors select-none", "border border-black/10 dark:border-white/10", m ? "bg-emerald-500/10 text-emerald-400 border-emerald-500/20" : "bg-black/4 dark:bg-white/4 text-slate-500 dark:text-slate-400 hover:text-slate-700 dark:hover:text-slate-200 hover:bg-black/8 dark:hover:bg-white/8", d === "sm" ? "h-6 px-2 text-xs gap-1 rounded-md" : "h-8 px-3 text-sm gap-1.5 rounded-lg", f),
|
|
46
|
+
...p,
|
|
47
|
+
children: /* @__PURE__ */ i(t, {
|
|
48
|
+
mode: "wait",
|
|
49
|
+
initial: !1,
|
|
50
|
+
children: m ? /* @__PURE__ */ a(n.span, {
|
|
51
|
+
initial: {
|
|
52
|
+
scale: .8,
|
|
53
|
+
opacity: 0
|
|
54
|
+
},
|
|
55
|
+
animate: {
|
|
56
|
+
scale: 1,
|
|
57
|
+
opacity: 1
|
|
58
|
+
},
|
|
59
|
+
exit: {
|
|
60
|
+
scale: .8,
|
|
61
|
+
opacity: 0
|
|
62
|
+
},
|
|
63
|
+
transition: { duration: .1 },
|
|
64
|
+
className: "flex items-center gap-1",
|
|
65
|
+
children: [/* @__PURE__ */ i(s, {}), u && "Copied"]
|
|
66
|
+
}, "check") : /* @__PURE__ */ a(n.span, {
|
|
67
|
+
initial: {
|
|
68
|
+
scale: .8,
|
|
69
|
+
opacity: 0
|
|
70
|
+
},
|
|
71
|
+
animate: {
|
|
72
|
+
scale: 1,
|
|
73
|
+
opacity: 1
|
|
74
|
+
},
|
|
75
|
+
exit: {
|
|
76
|
+
scale: .8,
|
|
77
|
+
opacity: 0
|
|
78
|
+
},
|
|
79
|
+
transition: { duration: .1 },
|
|
80
|
+
className: "flex items-center gap-1",
|
|
81
|
+
children: [/* @__PURE__ */ i(o, {}), u && u]
|
|
82
|
+
}, "copy")
|
|
83
|
+
})
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
export { c as CopyButton };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function PaginationFooter({ loading, sortedLength, pageSizeOptions, pageSize, page, totalPages, hasPagination, setPage, }: {
|
|
2
|
+
loading: boolean;
|
|
3
|
+
sortedLength: number;
|
|
4
|
+
pageSizeOptions: number[] | false;
|
|
5
|
+
pageSize: number;
|
|
6
|
+
page: number;
|
|
7
|
+
totalPages: number;
|
|
8
|
+
hasPagination: boolean;
|
|
9
|
+
setPage: (p: number | ((prev: number) => number)) => void;
|
|
10
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export type SortDir = "asc" | "desc" | null;
|
|
3
|
+
export interface ColumnDef<T> {
|
|
4
|
+
key: string;
|
|
5
|
+
header: ReactNode;
|
|
6
|
+
cell: (row: T) => ReactNode;
|
|
7
|
+
sortable?: boolean;
|
|
8
|
+
searchable?: boolean;
|
|
9
|
+
width?: string;
|
|
10
|
+
align?: "left" | "center" | "right";
|
|
11
|
+
}
|
|
12
|
+
export interface DataTableProps<T extends {
|
|
13
|
+
id: string | number;
|
|
14
|
+
}> {
|
|
15
|
+
columns: ColumnDef<T>[];
|
|
16
|
+
data: T[];
|
|
17
|
+
loading?: boolean;
|
|
18
|
+
emptyMessage?: string;
|
|
19
|
+
onRowClick?: (row: T) => void;
|
|
20
|
+
className?: string;
|
|
21
|
+
/** Show search bar. Pass column keys to search — defaults to all searchable columns */
|
|
22
|
+
searchable?: boolean;
|
|
23
|
+
searchPlaceholder?: string;
|
|
24
|
+
/** Rows per page options. Pass false to disable pagination entirely. Default: [10, 25, 50] */
|
|
25
|
+
pageSizeOptions?: number[] | false;
|
|
26
|
+
defaultPageSize?: number;
|
|
27
|
+
density?: "compact" | "comfortable";
|
|
28
|
+
ariaLabel?: string;
|
|
29
|
+
getRowLabel?: (row: T) => string;
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../datatable-BB3v__r5.cjs");exports.DataTable=e.t;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DataTableProps } from './datatable/types';
|
|
2
|
+
export type { SortDir, ColumnDef, DataTableProps } from './datatable/types';
|
|
3
|
+
export declare function DataTable<T extends {
|
|
4
|
+
id: string | number;
|
|
5
|
+
}>({ columns, data, loading, emptyMessage, onRowClick, className, toolbarClassName, tableClassName, searchable, searchPlaceholder, pageSizeOptions, defaultPageSize, density, ariaLabel, getRowLabel, unstyled, }: DataTableProps<T> & {
|
|
6
|
+
toolbarClassName?: string;
|
|
7
|
+
tableClassName?: string;
|
|
8
|
+
unstyled?: boolean;
|
|
9
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../cn-BdjraxxU.cjs"),t=require("../component-styles-TkZ7v6Ef.cjs");let n=require("framer-motion"),r=require("react"),i=require("react/jsx-runtime");var a=[`Su`,`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`],o=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`];function s(e){return`${o[e.getMonth()].slice(0,3)} ${e.getDate()}, ${e.getFullYear()}`}function c(e,t){return new Date(e,t+1,0).getDate()}function l(e,t){return new Date(e,t,1).getDay()}function u(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function d({value:d,onChange:f,label:p,hint:m,error:h,placeholder:g=`Select date…`,disabled:_,clearable:v=!0,minDate:y,maxDate:b,className:x}){let[S,C]=(0,r.useState)(null),w=d===void 0?S:d,T=new Date,[E,D]=(0,r.useState)(!1),[O,k]=(0,r.useState)((w??T).getFullYear()),[A,j]=(0,r.useState)((w??T).getMonth()),M=(0,r.useRef)(null),N=(0,r.useId)(),P=`${N}-message`;function F(e){d===void 0&&C(e),f?.(e),D(!1)}function I(e){e.stopPropagation(),d===void 0&&C(null),f?.(null)}function L(){A===0?(j(11),k(e=>e-1)):j(e=>e-1)}function R(){A===11?(j(0),k(e=>e+1)):j(e=>e+1)}(0,r.useEffect)(()=>{function e(e){M.current?.contains(e.target)||D(!1)}function t(e){e.key===`Escape`&&D(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[]);let z=c(O,A),B=l(O,A),V=[...Array(B).fill(null),...Array.from({length:z},(e,t)=>t+1)];return(0,i.jsxs)(`div`,{ref:M,className:e.t(`relative`,t.o,x),children:[p&&(0,i.jsx)(`label`,{htmlFor:N,className:`text-sm font-medium leading-5 text-foreground`,children:p}),(0,i.jsxs)(`button`,{type:`button`,id:N,"aria-expanded":E,"aria-haspopup":`dialog`,"aria-invalid":h?!0:void 0,"aria-describedby":h||m?P:void 0,disabled:_,onClick:()=>D(e=>!e),className:e.t(`flex h-9 w-full items-center gap-2 rounded-[var(--radius-md)] px-3 text-left outline-none`,t.t,`focus:border-accent-500 focus:ring-2 focus:ring-focus-ring/20`,h&&`border-destructive/60 hover:border-destructive/70 focus-within:border-destructive focus-within:ring-destructive/20`,_&&`opacity-50 cursor-not-allowed`),children:[(0,i.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`text-slate-500 shrink-0`,children:[(0,i.jsx)(`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,ry:`2`}),(0,i.jsx)(`line`,{x1:`16`,x2:`16`,y1:`2`,y2:`6`}),(0,i.jsx)(`line`,{x1:`8`,x2:`8`,y1:`2`,y2:`6`}),(0,i.jsx)(`line`,{x1:`3`,x2:`21`,y1:`10`,y2:`10`})]}),(0,i.jsx)(`span`,{className:e.t(`flex-1 text-sm truncate`,w?`text-foreground`:`text-muted-foreground`),children:w?s(w):g}),v&&w&&!_&&(0,i.jsx)(`span`,{role:`button`,tabIndex:-1,onClick:I,className:`shrink-0 text-slate-500 hover:text-slate-700 dark:hover:text-slate-300 transition-colors`,children:(0,i.jsx)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,i.jsx)(`path`,{d:`M18 6 6 18M6 6l12 12`})})})]}),(0,i.jsx)(n.AnimatePresence,{children:E&&(0,i.jsxs)(n.motion.div,{initial:{opacity:0,y:-4,scaleY:.97},animate:{opacity:1,y:0,scaleY:1},exit:{opacity:0,y:-4,scaleY:.97},transition:{duration:.13},style:{originY:0},role:`dialog`,"aria-label":`Choose date`,className:`absolute left-0 top-full z-50 mt-1.5 w-[min(18rem,calc(100vw-2rem))] rounded-[var(--radius-lg)] border border-border bg-surface-raised p-3 shadow-floating`,children:[(0,i.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,i.jsx)(`button`,{type:`button`,onClick:L,"aria-label":`Previous month`,className:e.t(t.c,`size-7`),children:(0,i.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,i.jsx)(`path`,{d:`m15 18-6-6 6-6`})})}),(0,i.jsxs)(`span`,{"aria-live":`polite`,className:`text-sm font-semibold text-foreground`,children:[o[A],` `,O]}),(0,i.jsx)(`button`,{type:`button`,onClick:R,"aria-label":`Next month`,className:e.t(t.c,`size-7`),children:(0,i.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,i.jsx)(`path`,{d:`m9 18 6-6-6-6`})})})]}),(0,i.jsx)(`div`,{className:`grid grid-cols-7 gap-0.5 mb-1`,children:a.map(e=>(0,i.jsx)(`div`,{"aria-hidden":`true`,className:`text-center text-[10px] font-semibold text-muted-foreground py-1`,children:e},e))}),(0,i.jsx)(`div`,{className:`grid grid-cols-7 gap-0.5`,children:V.map((t,n)=>{if(!t)return(0,i.jsx)(`div`,{},`empty-${n}`);let r=new Date(O,A,t),a=w?u(r,w):!1,o=u(r,T),s=y&&r<y||b&&r>b;return(0,i.jsx)(`button`,{type:`button`,disabled:!!s,onClick:()=>F(r),"aria-label":r.toLocaleDateString(void 0,{weekday:`long`,year:`numeric`,month:`long`,day:`numeric`}),"aria-pressed":a,"aria-current":o?`date`:void 0,className:e.t(`h-8 w-full rounded-md text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring/35`,a?`bg-primary text-primary-foreground font-medium`:o?`border border-accent-500/40 text-accent-400 hover:bg-accent-500/10`:`text-slate-700 dark:text-slate-200 hover:bg-black/6 dark:hover:bg-white/6`,s&&`opacity-30 cursor-not-allowed`),children:t},t)})})]})}),h&&(0,i.jsx)(`p`,{id:P,"aria-live":`polite`,className:`text-xs leading-5 text-destructive`,children:h}),m&&!h&&(0,i.jsx)(`p`,{id:P,className:`text-xs leading-5 text-muted-foreground`,children:m})]})}exports.DatePicker=d;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface DatePickerProps {
|
|
2
|
+
value?: Date | null;
|
|
3
|
+
onChange?: (date: Date | null) => void;
|
|
4
|
+
label?: string;
|
|
5
|
+
hint?: string;
|
|
6
|
+
error?: string;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
clearable?: boolean;
|
|
10
|
+
minDate?: Date;
|
|
11
|
+
maxDate?: Date;
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function DatePicker({ value: controlledValue, onChange, label, hint, error, placeholder, disabled, clearable, minDate, maxDate, className, }: DatePickerProps): import("react").JSX.Element;
|