@gaulatti/bleecker 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/accordion.js +2 -2
- package/dist/components/alert-dialog.d.ts +13 -0
- package/dist/components/alert-dialog.js +42 -0
- package/dist/components/avatar.d.ts +16 -0
- package/dist/components/avatar.js +36 -0
- package/dist/components/breadcrumb.d.ts +15 -0
- package/dist/components/breadcrumb.js +24 -0
- package/dist/components/button-group.d.ts +15 -0
- package/dist/components/button-group.js +23 -0
- package/dist/components/collection-filters.d.ts +1 -1
- package/dist/components/collection-filters.js +1 -1
- package/dist/components/date-picker.d.ts +20 -0
- package/dist/components/date-picker.js +97 -0
- package/dist/components/drawer.d.ts +11 -0
- package/dist/components/drawer.js +42 -0
- package/dist/components/empty.d.ts +9 -0
- package/dist/components/empty.js +6 -0
- package/dist/components/hover-card.d.ts +12 -0
- package/dist/components/hover-card.js +9 -0
- package/dist/components/kbd.d.ts +7 -0
- package/dist/components/kbd.js +10 -0
- package/dist/components/menubar.d.ts +43 -0
- package/dist/components/menubar.js +58 -0
- package/dist/components/navigation-menu.d.ts +16 -0
- package/dist/components/navigation-menu.js +41 -0
- package/dist/components/otp-input.d.ts +11 -0
- package/dist/components/otp-input.js +53 -0
- package/dist/components/popover.d.ts +14 -0
- package/dist/components/popover.js +93 -0
- package/dist/components/progress.d.ts +11 -0
- package/dist/components/progress.js +17 -0
- package/dist/components/radio-group.d.ts +16 -0
- package/dist/components/radio-group.js +14 -0
- package/dist/components/scroll-area.d.ts +11 -0
- package/dist/components/scroll-area.js +12 -0
- package/dist/components/sheet.d.ts +12 -0
- package/dist/components/sheet.js +53 -0
- package/dist/components/slider.d.ts +11 -0
- package/dist/components/slider.js +9 -0
- package/dist/components/sonner.d.ts +29 -0
- package/dist/components/sonner.js +76 -0
- package/dist/components/sortable-table-header.js +4 -3
- package/dist/components/switch.d.ts +7 -0
- package/dist/components/switch.js +7 -0
- package/dist/components/table.d.ts +60 -0
- package/dist/components/table.js +92 -0
- package/dist/components/toggle-group.d.ts +26 -0
- package/dist/components/toggle-group.js +32 -0
- package/dist/components/toggle.d.ts +8 -0
- package/dist/components/toggle.js +26 -0
- package/dist/components/tooltip.d.ts +9 -0
- package/dist/components/tooltip.js +24 -0
- package/dist/index.d.ts +24 -1
- package/dist/index.js +24 -1
- package/dist/styles.css +1 -1
- package/dist/theme/theme-script.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { ChevronDown } from 'lucide-react';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { cn } from '../utils/cn.js';
|
|
5
|
+
import { renderDefaultLink } from './nav-menu.js';
|
|
6
|
+
function isGroup(entry) {
|
|
7
|
+
return 'items' in entry;
|
|
8
|
+
}
|
|
9
|
+
export function NavigationMenu({ className, entries, renderLink }) {
|
|
10
|
+
const [activeIndex, setActiveIndex] = React.useState(null);
|
|
11
|
+
const linkRenderer = (renderLink ?? renderDefaultLink);
|
|
12
|
+
const containerRef = React.useRef(null);
|
|
13
|
+
React.useEffect(() => {
|
|
14
|
+
if (activeIndex === null)
|
|
15
|
+
return;
|
|
16
|
+
const handler = (e) => {
|
|
17
|
+
if (!containerRef.current?.contains(e.target))
|
|
18
|
+
setActiveIndex(null);
|
|
19
|
+
};
|
|
20
|
+
document.addEventListener('pointerdown', handler);
|
|
21
|
+
return () => document.removeEventListener('pointerdown', handler);
|
|
22
|
+
}, [activeIndex]);
|
|
23
|
+
return (_jsx("div", { ref: containerRef, className: cn('relative flex items-center gap-1', className), children: entries.map((entry, i) => {
|
|
24
|
+
if (!isGroup(entry)) {
|
|
25
|
+
return (_jsx(React.Fragment, { children: linkRenderer({
|
|
26
|
+
item: entry,
|
|
27
|
+
className: 'px-3 py-2 text-sm font-medium text-text-secondary transition-colors duration-200 hover:text-text-primary rounded-lg hover:bg-sand/10 dark:text-text-secondary dark:hover:text-text-primary dark:hover:bg-sand/15',
|
|
28
|
+
children: entry.label
|
|
29
|
+
}) }, entry.href));
|
|
30
|
+
}
|
|
31
|
+
const isOpen = activeIndex === i;
|
|
32
|
+
return (_jsxs("div", { className: 'relative', children: [_jsxs("button", { type: 'button', onClick: () => setActiveIndex(isOpen ? null : i), "aria-expanded": isOpen, className: cn('flex items-center gap-1 rounded-lg px-3 py-2 text-sm font-medium transition-colors duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-sea dark:focus-visible:ring-accent-blue', isOpen
|
|
33
|
+
? 'bg-sand/10 text-text-primary dark:bg-sand/15 dark:text-text-primary'
|
|
34
|
+
: 'text-text-secondary hover:bg-sand/10 hover:text-text-primary dark:text-text-secondary dark:hover:bg-sand/15 dark:hover:text-text-primary'), children: [entry.trigger, _jsx(ChevronDown, { size: 14, className: cn('transition-transform duration-200', isOpen ? 'rotate-180' : 'rotate-0') })] }), isOpen && (_jsx("div", { className: 'absolute left-0 top-full z-50 mt-1.5 min-w-[16rem] rounded-2xl border border-sand/10 bg-white p-2 shadow-xl dark:border-sand/20 dark:bg-dark-sand', children: entry.items.map((item) => (_jsx(React.Fragment, { children: linkRenderer({
|
|
35
|
+
item,
|
|
36
|
+
className: 'flex flex-col rounded-lg px-3 py-2.5 hover:bg-sand/10 dark:hover:bg-sand/15 transition-colors duration-200',
|
|
37
|
+
children: (_jsxs(_Fragment, { children: [_jsx("span", { className: 'text-sm font-medium text-text-primary dark:text-text-primary', children: item.label }), item.description ? (_jsx("span", { className: 'mt-0.5 text-xs leading-relaxed text-text-secondary dark:text-text-secondary', children: item.description })) : null] })),
|
|
38
|
+
onClick: () => setActiveIndex(null)
|
|
39
|
+
}) }, item.href))) }))] }, entry.trigger));
|
|
40
|
+
}) }));
|
|
41
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface OtpInputProps {
|
|
2
|
+
className?: string;
|
|
3
|
+
disabled?: boolean;
|
|
4
|
+
/** Number of digits (default 6) */
|
|
5
|
+
length?: number;
|
|
6
|
+
onChange?: (value: string) => void;
|
|
7
|
+
/** Whether to mask input like a password */
|
|
8
|
+
secure?: boolean;
|
|
9
|
+
value?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function OtpInput({ className, disabled, length, onChange, secure, value }: OtpInputProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { cn } from '../utils/cn.js';
|
|
4
|
+
export function OtpInput({ className, disabled = false, length = 6, onChange, secure = false, value = '' }) {
|
|
5
|
+
const inputRefs = React.useRef([]);
|
|
6
|
+
const digits = value.padEnd(length, '').slice(0, length).split('');
|
|
7
|
+
const notify = (newDigits) => {
|
|
8
|
+
onChange?.(newDigits.join('').replace(/\s/g, ''));
|
|
9
|
+
};
|
|
10
|
+
const handleChange = (index, char) => {
|
|
11
|
+
const next = [...digits];
|
|
12
|
+
// Accept only one digit at a time; handle paste below
|
|
13
|
+
const clean = char.replace(/\D/g, '').slice(-1);
|
|
14
|
+
next[index] = clean;
|
|
15
|
+
notify(next);
|
|
16
|
+
if (clean && index < length - 1) {
|
|
17
|
+
inputRefs.current[index + 1]?.focus();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const handleKeyDown = (index, event) => {
|
|
21
|
+
if (event.key === 'Backspace') {
|
|
22
|
+
event.preventDefault();
|
|
23
|
+
const next = [...digits];
|
|
24
|
+
if (next[index]) {
|
|
25
|
+
next[index] = ' ';
|
|
26
|
+
notify(next);
|
|
27
|
+
}
|
|
28
|
+
else if (index > 0) {
|
|
29
|
+
next[index - 1] = ' ';
|
|
30
|
+
notify(next);
|
|
31
|
+
inputRefs.current[index - 1]?.focus();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (event.key === 'ArrowLeft' && index > 0)
|
|
35
|
+
inputRefs.current[index - 1]?.focus();
|
|
36
|
+
if (event.key === 'ArrowRight' && index < length - 1)
|
|
37
|
+
inputRefs.current[index + 1]?.focus();
|
|
38
|
+
};
|
|
39
|
+
const handlePaste = (event) => {
|
|
40
|
+
event.preventDefault();
|
|
41
|
+
const pasted = event.clipboardData.getData('text').replace(/\D/g, '').slice(0, length);
|
|
42
|
+
const next = pasted.padEnd(length, ' ').split('');
|
|
43
|
+
notify(next);
|
|
44
|
+
const focusIndex = Math.min(pasted.length, length - 1);
|
|
45
|
+
inputRefs.current[focusIndex]?.focus();
|
|
46
|
+
};
|
|
47
|
+
return (_jsx("div", { className: cn('flex items-center gap-2', className), role: 'group', "aria-label": 'One-time password input', children: Array.from({ length }, (_, i) => {
|
|
48
|
+
const digit = digits[i]?.trim() ?? '';
|
|
49
|
+
return (_jsx("input", { ref: (el) => {
|
|
50
|
+
inputRefs.current[i] = el;
|
|
51
|
+
}, type: secure ? 'password' : 'text', inputMode: 'numeric', maxLength: 1, value: digit, disabled: disabled, "aria-label": `Digit ${i + 1}`, onChange: (e) => handleChange(i, e.target.value), onKeyDown: (e) => handleKeyDown(i, e), onPaste: handlePaste, onFocus: (e) => e.target.select(), className: cn('h-12 w-10 rounded-xl border bg-white text-center text-lg font-semibold tracking-widest text-text-primary caret-sea transition-all duration-200 outline-none dark:bg-dark-sand dark:text-text-primary dark:caret-accent-blue', digit ? 'border-sea dark:border-accent-blue' : 'border-sand/30 dark:border-sand/50', 'focus:border-sea focus:ring-2 focus:ring-sea/30 dark:focus:border-accent-blue dark:focus:ring-accent-blue/30', disabled && 'cursor-not-allowed opacity-50') }, i));
|
|
52
|
+
}) }));
|
|
53
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type PopoverSide = 'top' | 'bottom' | 'left' | 'right';
|
|
3
|
+
export type PopoverAlign = 'start' | 'center' | 'end';
|
|
4
|
+
export interface PopoverProps {
|
|
5
|
+
align?: PopoverAlign;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
content: React.ReactNode;
|
|
9
|
+
/** Controlled open state */
|
|
10
|
+
open?: boolean;
|
|
11
|
+
onOpenChange?: (open: boolean) => void;
|
|
12
|
+
side?: PopoverSide;
|
|
13
|
+
}
|
|
14
|
+
export declare function Popover({ align, children, className, content, onOpenChange, open: controlledOpen, side }: PopoverProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
4
|
+
import { cn } from '../utils/cn.js';
|
|
5
|
+
export function Popover({ align = 'center', children, className, content, onOpenChange, open: controlledOpen, side = 'bottom' }) {
|
|
6
|
+
const [internalOpen, setInternalOpen] = React.useState(false);
|
|
7
|
+
const isOpen = controlledOpen !== undefined ? controlledOpen : internalOpen;
|
|
8
|
+
const setOpen = (v) => {
|
|
9
|
+
setInternalOpen(v);
|
|
10
|
+
onOpenChange?.(v);
|
|
11
|
+
};
|
|
12
|
+
const triggerRef = React.useRef(null);
|
|
13
|
+
const panelRef = React.useRef(null);
|
|
14
|
+
const [coords, setCoords] = React.useState({ top: 0, left: 0 });
|
|
15
|
+
const reposition = React.useCallback(() => {
|
|
16
|
+
if (!triggerRef.current)
|
|
17
|
+
return;
|
|
18
|
+
const rect = triggerRef.current.getBoundingClientRect();
|
|
19
|
+
const scroll = { x: window.scrollX, y: window.scrollY };
|
|
20
|
+
let top = 0;
|
|
21
|
+
let left = 0;
|
|
22
|
+
const panelW = panelRef.current?.offsetWidth ?? 220;
|
|
23
|
+
const panelH = panelRef.current?.offsetHeight ?? 100;
|
|
24
|
+
const gap = 8;
|
|
25
|
+
if (side === 'bottom')
|
|
26
|
+
top = rect.bottom + scroll.y + gap;
|
|
27
|
+
if (side === 'top')
|
|
28
|
+
top = rect.top + scroll.y - panelH - gap;
|
|
29
|
+
if (side === 'left') {
|
|
30
|
+
top = rect.top + scroll.y;
|
|
31
|
+
left = rect.left + scroll.x - panelW - gap;
|
|
32
|
+
}
|
|
33
|
+
if (side === 'right') {
|
|
34
|
+
top = rect.top + scroll.y;
|
|
35
|
+
left = rect.right + scroll.x + gap;
|
|
36
|
+
}
|
|
37
|
+
if (side === 'bottom' || side === 'top') {
|
|
38
|
+
if (align === 'start')
|
|
39
|
+
left = rect.left + scroll.x;
|
|
40
|
+
else if (align === 'end')
|
|
41
|
+
left = rect.right + scroll.x - panelW;
|
|
42
|
+
else
|
|
43
|
+
left = rect.left + scroll.x + rect.width / 2 - panelW / 2;
|
|
44
|
+
}
|
|
45
|
+
if (side === 'left' || side === 'right') {
|
|
46
|
+
if (align === 'start')
|
|
47
|
+
top = rect.top + scroll.y;
|
|
48
|
+
else if (align === 'end')
|
|
49
|
+
top = rect.bottom + scroll.y - panelH;
|
|
50
|
+
else
|
|
51
|
+
top = rect.top + scroll.y + rect.height / 2 - panelH / 2;
|
|
52
|
+
}
|
|
53
|
+
setCoords({ top, left });
|
|
54
|
+
}, [side, align]);
|
|
55
|
+
React.useEffect(() => {
|
|
56
|
+
if (!isOpen)
|
|
57
|
+
return;
|
|
58
|
+
reposition();
|
|
59
|
+
window.addEventListener('resize', reposition);
|
|
60
|
+
window.addEventListener('scroll', reposition, true);
|
|
61
|
+
return () => {
|
|
62
|
+
window.removeEventListener('resize', reposition);
|
|
63
|
+
window.removeEventListener('scroll', reposition, true);
|
|
64
|
+
};
|
|
65
|
+
}, [isOpen, reposition]);
|
|
66
|
+
// Close on outside click
|
|
67
|
+
React.useEffect(() => {
|
|
68
|
+
if (!isOpen)
|
|
69
|
+
return;
|
|
70
|
+
const handlePointerDown = (e) => {
|
|
71
|
+
if (!triggerRef.current?.contains(e.target) && !panelRef.current?.contains(e.target)) {
|
|
72
|
+
setOpen(false);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
document.addEventListener('pointerdown', handlePointerDown);
|
|
76
|
+
return () => document.removeEventListener('pointerdown', handlePointerDown);
|
|
77
|
+
}, [isOpen]);
|
|
78
|
+
// Close on Escape
|
|
79
|
+
React.useEffect(() => {
|
|
80
|
+
if (!isOpen)
|
|
81
|
+
return;
|
|
82
|
+
const handleKey = (e) => {
|
|
83
|
+
if (e.key === 'Escape')
|
|
84
|
+
setOpen(false);
|
|
85
|
+
};
|
|
86
|
+
document.addEventListener('keydown', handleKey);
|
|
87
|
+
return () => document.removeEventListener('keydown', handleKey);
|
|
88
|
+
}, [isOpen]);
|
|
89
|
+
const panel = isOpen && typeof document !== 'undefined'
|
|
90
|
+
? createPortal(_jsx("div", { ref: panelRef, role: 'dialog', className: cn('absolute z-50 min-w-[14rem] rounded-2xl border border-sand/10 bg-white p-1 shadow-xl outline-none dark:border-sand/20 dark:bg-dark-sand', 'animate-in fade-in-0 zoom-in-95', className), style: { top: coords.top, left: coords.left }, children: content }), document.body)
|
|
91
|
+
: null;
|
|
92
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: triggerRef, className: 'inline-flex', onClick: () => setOpen(!isOpen), children: children }), panel] }));
|
|
93
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface ProgressProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
/** 0–100 */
|
|
4
|
+
value?: number;
|
|
5
|
+
max?: number;
|
|
6
|
+
/** Show the numeric label inside/next to the bar */
|
|
7
|
+
showLabel?: boolean;
|
|
8
|
+
size?: 'sm' | 'md' | 'lg';
|
|
9
|
+
variant?: 'default' | 'success' | 'warning' | 'destructive';
|
|
10
|
+
}
|
|
11
|
+
export declare function Progress({ className, max, showLabel, size, value, variant, ...props }: ProgressProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../utils/cn.js';
|
|
3
|
+
const sizeClasses = {
|
|
4
|
+
sm: 'h-1.5',
|
|
5
|
+
md: 'h-2.5',
|
|
6
|
+
lg: 'h-4'
|
|
7
|
+
};
|
|
8
|
+
const variantFill = {
|
|
9
|
+
default: 'bg-sea dark:bg-accent-blue',
|
|
10
|
+
success: 'bg-sea dark:bg-accent-blue',
|
|
11
|
+
warning: 'bg-sunset dark:bg-accent-gold',
|
|
12
|
+
destructive: 'bg-terracotta'
|
|
13
|
+
};
|
|
14
|
+
export function Progress({ className, max = 100, showLabel = false, size = 'md', value = 0, variant = 'default', ...props }) {
|
|
15
|
+
const pct = Math.min(100, Math.max(0, (value / max) * 100));
|
|
16
|
+
return (_jsxs("div", { className: cn('flex items-center gap-3', className), ...props, children: [_jsx("div", { role: 'progressbar', "aria-valuenow": value, "aria-valuemin": 0, "aria-valuemax": max, className: cn('flex-1 overflow-hidden rounded-full bg-sand/15 dark:bg-sand/20', sizeClasses[size]), children: _jsx("div", { className: cn('h-full rounded-full transition-[width] duration-500 ease-out', variantFill[variant]), style: { width: `${pct}%` } }) }), showLabel && (_jsxs("span", { className: 'min-w-[2.5rem] text-right text-xs font-medium tabular-nums text-text-secondary dark:text-text-primary', children: [Math.round(pct), "%"] }))] }));
|
|
17
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface RadioOption {
|
|
2
|
+
description?: string;
|
|
3
|
+
disabled?: boolean;
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}
|
|
7
|
+
export interface RadioGroupProps {
|
|
8
|
+
className?: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
name?: string;
|
|
11
|
+
onChange?: (value: string) => void;
|
|
12
|
+
options: RadioOption[];
|
|
13
|
+
orientation?: 'vertical' | 'horizontal';
|
|
14
|
+
value?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function RadioGroup({ className, disabled, name, onChange, options, orientation, value }: RadioGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { cn } from '../utils/cn.js';
|
|
4
|
+
export function RadioGroup({ className, disabled, name, onChange, options, orientation = 'vertical', value }) {
|
|
5
|
+
const groupName = name ?? React.useId();
|
|
6
|
+
return (_jsx("div", { role: 'radiogroup', className: cn('flex', orientation === 'horizontal' ? 'flex-row flex-wrap gap-4' : 'flex-col gap-3', className), children: options.map((option) => {
|
|
7
|
+
const isChecked = option.value === value;
|
|
8
|
+
const isDisabled = disabled || option.disabled;
|
|
9
|
+
const id = `${groupName}-${option.value}`;
|
|
10
|
+
return (_jsxs("label", { htmlFor: id, className: cn('group flex cursor-pointer select-none items-start gap-3', isDisabled && 'cursor-not-allowed opacity-50'), children: [_jsxs("span", { className: 'relative mt-0.5 flex-shrink-0', children: [_jsx("input", { id: id, type: 'radio', name: groupName, value: option.value, checked: isChecked, disabled: isDisabled, onChange: () => onChange?.(option.value), className: 'sr-only' }), _jsx("span", { className: cn('flex h-4.5 w-4.5 items-center justify-center rounded-full border-2 transition-colors duration-200', isChecked
|
|
11
|
+
? 'border-sea dark:border-accent-blue'
|
|
12
|
+
: 'border-sand/40 group-hover:border-sea/60 dark:border-sand/60 dark:group-hover:border-accent-blue/60'), children: _jsx("span", { className: cn('h-2 w-2 rounded-full bg-sea transition-transform duration-200 dark:bg-accent-blue', isChecked ? 'scale-100' : 'scale-0') }) })] }), _jsxs("span", { children: [_jsx("span", { className: 'block text-sm font-medium text-text-primary dark:text-text-primary', children: option.label }), option.description ? (_jsx("span", { className: 'block text-xs leading-relaxed text-text-secondary dark:text-text-secondary', children: option.description })) : null] })] }, option.value));
|
|
13
|
+
}) }));
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface ScrollAreaProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
/** max-height applied to the viewport only. Use any valid CSS value. */
|
|
4
|
+
maxHeight?: string;
|
|
5
|
+
orientation?: 'vertical' | 'horizontal' | 'both';
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A thin wrapper that applies custom-styled scrollbars while keeping the
|
|
9
|
+
* inner content naturally sized. Use `maxHeight` to constrain height.
|
|
10
|
+
*/
|
|
11
|
+
export declare function ScrollArea({ children, className, maxHeight, orientation, style, ...props }: ScrollAreaProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../utils/cn.js';
|
|
3
|
+
/**
|
|
4
|
+
* A thin wrapper that applies custom-styled scrollbars while keeping the
|
|
5
|
+
* inner content naturally sized. Use `maxHeight` to constrain height.
|
|
6
|
+
*/
|
|
7
|
+
export function ScrollArea({ children, className, maxHeight, orientation = 'vertical', style, ...props }) {
|
|
8
|
+
const overflowClass = orientation === 'both' ? 'overflow-auto' : orientation === 'horizontal' ? 'overflow-x-auto overflow-y-hidden' : 'overflow-y-auto overflow-x-hidden';
|
|
9
|
+
return (_jsx("div", { ...props, className: cn(overflowClass,
|
|
10
|
+
// Custom scrollbar styling via Tailwind arbitrary variants
|
|
11
|
+
'[&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-track]:rounded-full [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-sand/30 [&::-webkit-scrollbar-thumb:hover]:bg-sand/50 dark:[&::-webkit-scrollbar-thumb]:bg-sand/40 dark:[&::-webkit-scrollbar-thumb:hover]:bg-sand/60', className), style: { maxHeight, ...style }, children: children }));
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type SheetSide = 'left' | 'right' | 'top' | 'bottom';
|
|
3
|
+
export interface SheetProps {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
isOpen: boolean;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
side?: SheetSide;
|
|
9
|
+
title?: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function Sheet({ children, className, description, isOpen, onClose, side, title }: SheetProps): React.ReactPortal | null;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { X } from 'lucide-react';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { createPortal } from 'react-dom';
|
|
5
|
+
import { cn } from '../utils/cn.js';
|
|
6
|
+
const sideStyles = {
|
|
7
|
+
right: {
|
|
8
|
+
panel: 'inset-y-0 right-0 h-full w-full max-w-sm',
|
|
9
|
+
enter: 'translate-x-0',
|
|
10
|
+
leave: 'translate-x-full'
|
|
11
|
+
},
|
|
12
|
+
left: {
|
|
13
|
+
panel: 'inset-y-0 left-0 h-full w-full max-w-sm',
|
|
14
|
+
enter: 'translate-x-0',
|
|
15
|
+
leave: '-translate-x-full'
|
|
16
|
+
},
|
|
17
|
+
top: {
|
|
18
|
+
panel: 'inset-x-0 top-0 w-full',
|
|
19
|
+
enter: 'translate-y-0',
|
|
20
|
+
leave: '-translate-y-full'
|
|
21
|
+
},
|
|
22
|
+
bottom: {
|
|
23
|
+
panel: 'inset-x-0 bottom-0 w-full',
|
|
24
|
+
enter: 'translate-y-0',
|
|
25
|
+
leave: 'translate-y-full'
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
export function Sheet({ children, className, description, isOpen, onClose, side = 'right', title }) {
|
|
29
|
+
const [visible, setVisible] = React.useState(false);
|
|
30
|
+
const { panel, enter, leave } = sideStyles[side];
|
|
31
|
+
React.useEffect(() => {
|
|
32
|
+
if (isOpen) {
|
|
33
|
+
requestAnimationFrame(() => setVisible(true));
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
setVisible(false);
|
|
37
|
+
}
|
|
38
|
+
}, [isOpen]);
|
|
39
|
+
// Close on Escape
|
|
40
|
+
React.useEffect(() => {
|
|
41
|
+
if (!isOpen)
|
|
42
|
+
return;
|
|
43
|
+
const handler = (e) => {
|
|
44
|
+
if (e.key === 'Escape')
|
|
45
|
+
onClose();
|
|
46
|
+
};
|
|
47
|
+
document.addEventListener('keydown', handler);
|
|
48
|
+
return () => document.removeEventListener('keydown', handler);
|
|
49
|
+
}, [isOpen, onClose]);
|
|
50
|
+
if (typeof document === 'undefined' || !isOpen)
|
|
51
|
+
return null;
|
|
52
|
+
return createPortal(_jsxs("div", { className: 'fixed inset-0 z-50 flex', children: [_jsx("div", { className: cn('absolute inset-0 bg-black/50 backdrop-blur-sm transition-opacity duration-300', visible ? 'opacity-100' : 'opacity-0'), onClick: onClose, "aria-hidden": 'true' }), _jsxs("div", { role: 'dialog', "aria-modal": 'true', "aria-label": title, className: cn('absolute flex flex-col border border-sand/10 bg-white shadow-2xl transition-transform duration-300 ease-in-out dark:border-sand/20 dark:bg-dark-sand', panel, visible ? enter : leave, (side === 'left' || side === 'right') && 'rounded-none', side === 'top' && 'rounded-b-2xl', side === 'bottom' && 'rounded-t-2xl', className), children: [_jsxs("div", { className: 'flex items-center justify-between border-b border-sand/10 px-6 py-4 dark:border-sand/20', children: [_jsxs("div", { children: [title ? _jsx("h2", { className: 'text-base font-semibold text-text-primary dark:text-text-primary', children: title }) : null, description ? _jsx("p", { className: 'mt-0.5 text-sm text-text-secondary dark:text-text-secondary', children: description }) : null] }), _jsx("button", { type: 'button', onClick: onClose, className: 'inline-flex items-center justify-center rounded-full p-2 text-text-secondary transition-colors duration-200 hover:bg-sand/10 hover:text-text-primary dark:text-text-secondary dark:hover:bg-sand/20 dark:hover:text-text-primary', "aria-label": 'Close', children: _jsx(X, { size: 18 }) })] }), _jsx("div", { className: 'flex-1 overflow-y-auto p-6', children: children })] })] }), document.body);
|
|
53
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface SliderProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'onChange'> {
|
|
3
|
+
label?: string;
|
|
4
|
+
max?: number;
|
|
5
|
+
min?: number;
|
|
6
|
+
onChange?: (value: number) => void;
|
|
7
|
+
showValue?: boolean;
|
|
8
|
+
step?: number;
|
|
9
|
+
value?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare const Slider: React.ForwardRefExoticComponent<SliderProps & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { cn } from '../utils/cn.js';
|
|
4
|
+
export const Slider = React.forwardRef(function Slider({ className, disabled, label, max = 100, min = 0, onChange, showValue = false, step = 1, value = 0, ...props }, ref) {
|
|
5
|
+
const pct = ((value - min) / (max - min)) * 100;
|
|
6
|
+
return (_jsxs("div", { className: cn('space-y-2', className), children: [(label || showValue) && (_jsxs("div", { className: 'flex items-center justify-between', children: [label ? _jsx("span", { className: 'text-sm font-medium text-text-primary dark:text-text-primary', children: label }) : _jsx("span", {}), showValue && _jsx("span", { className: 'text-sm tabular-nums text-text-secondary dark:text-text-primary', children: value })] })), _jsxs("div", { className: 'relative flex h-5 items-center', children: [_jsx("div", { className: 'pointer-events-none absolute inset-y-0 flex w-full items-center', children: _jsx("div", { className: 'h-2 w-full overflow-hidden rounded-full bg-sand/20 dark:bg-sand/30', children: _jsx("div", { className: 'h-full rounded-full bg-sea transition-[width] duration-150 dark:bg-accent-blue', style: { width: `${pct}%` } }) }) }), _jsx("input", { ref: ref, type: 'range', min: min, max: max, step: step, value: value, disabled: disabled, onChange: (e) => onChange?.(Number(e.target.value)), className: cn('relative h-2 w-full cursor-pointer appearance-none rounded-full bg-transparent',
|
|
7
|
+
// Thumb styling via arbitrary CSS
|
|
8
|
+
'[&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:h-5 [&::-webkit-slider-thumb]:w-5 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:border-2 [&::-webkit-slider-thumb]:border-sea [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:shadow-sm [&::-webkit-slider-thumb]:transition-transform [&::-webkit-slider-thumb]:duration-150 [&::-webkit-slider-thumb]:hover:scale-110 dark:[&::-webkit-slider-thumb]:border-accent-blue', '[&::-moz-range-thumb]:h-5 [&::-moz-range-thumb]:w-5 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-2 [&::-moz-range-thumb]:border-sea [&::-moz-range-thumb]:bg-white [&::-moz-range-thumb]:shadow-sm dark:[&::-moz-range-thumb]:border-accent-blue', 'focus:outline-none focus-visible:ring-2 focus-visible:ring-sea focus-visible:ring-offset-2 dark:focus-visible:ring-accent-blue', disabled && 'cursor-not-allowed opacity-50'), ...props })] })] }));
|
|
9
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type SonnerVariant = 'default' | 'success' | 'error' | 'warning' | 'info';
|
|
3
|
+
export type SonnerPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
4
|
+
export interface SonnerToast {
|
|
5
|
+
id: string;
|
|
6
|
+
title: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
duration?: number;
|
|
9
|
+
variant?: SonnerVariant;
|
|
10
|
+
action?: {
|
|
11
|
+
label: string;
|
|
12
|
+
onClick: () => void;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/** Call outside React to fire a toast — only works when <Sonner> is mounted. */
|
|
16
|
+
export declare const toast: {
|
|
17
|
+
show: (t: Omit<SonnerToast, "id">) => string;
|
|
18
|
+
success: (title: string, rest?: Partial<Omit<SonnerToast, "id" | "title" | "variant">>) => string;
|
|
19
|
+
error: (title: string, rest?: Partial<Omit<SonnerToast, "id" | "title" | "variant">>) => string;
|
|
20
|
+
warning: (title: string, rest?: Partial<Omit<SonnerToast, "id" | "title" | "variant">>) => string;
|
|
21
|
+
info: (title: string, rest?: Partial<Omit<SonnerToast, "id" | "title" | "variant">>) => string;
|
|
22
|
+
dismiss: (id: string) => void | undefined;
|
|
23
|
+
};
|
|
24
|
+
export interface SonnerProps {
|
|
25
|
+
position?: SonnerPosition;
|
|
26
|
+
/** Default duration in ms (0 = persistent) */
|
|
27
|
+
duration?: number;
|
|
28
|
+
}
|
|
29
|
+
export declare function Sonner({ duration, position }: SonnerProps): React.ReactPortal | null;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { AlertCircle, AlertTriangle, CheckCircle, Info, X } from 'lucide-react';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { createPortal } from 'react-dom';
|
|
5
|
+
import { cn } from '../utils/cn.js';
|
|
6
|
+
const ToastContext = React.createContext(null);
|
|
7
|
+
let externalAdd = null;
|
|
8
|
+
let externalDismiss = null;
|
|
9
|
+
/** Call outside React to fire a toast — only works when <Sonner> is mounted. */
|
|
10
|
+
export const toast = {
|
|
11
|
+
show: (t) => externalAdd?.(t) ?? '',
|
|
12
|
+
success: (title, rest) => externalAdd?.({ title, variant: 'success', ...rest }) ?? '',
|
|
13
|
+
error: (title, rest) => externalAdd?.({ title, variant: 'error', ...rest }) ?? '',
|
|
14
|
+
warning: (title, rest) => externalAdd?.({ title, variant: 'warning', ...rest }) ?? '',
|
|
15
|
+
info: (title, rest) => externalAdd?.({ title, variant: 'info', ...rest }) ?? '',
|
|
16
|
+
dismiss: (id) => externalDismiss?.(id)
|
|
17
|
+
};
|
|
18
|
+
// ─── Variant config ─────────────────────────────────────────────────────────
|
|
19
|
+
const variantConfig = {
|
|
20
|
+
default: { icon: Info, color: 'text-text-secondary' },
|
|
21
|
+
info: { icon: Info, color: 'text-desert dark:text-accent-gold' },
|
|
22
|
+
success: { icon: CheckCircle, color: 'text-sea dark:text-accent-blue' },
|
|
23
|
+
warning: { icon: AlertTriangle, color: 'text-sunset dark:text-accent-gold' },
|
|
24
|
+
error: { icon: AlertCircle, color: 'text-terracotta' }
|
|
25
|
+
};
|
|
26
|
+
// ─── Single toast item ───────────────────────────────────────────────────────
|
|
27
|
+
function ToastItem({ toast, onDismiss }) {
|
|
28
|
+
const [visible, setVisible] = React.useState(false);
|
|
29
|
+
const { icon: Icon, color } = variantConfig[toast.variant ?? 'default'];
|
|
30
|
+
React.useEffect(() => {
|
|
31
|
+
requestAnimationFrame(() => setVisible(true));
|
|
32
|
+
if (!toast.duration || toast.duration <= 0)
|
|
33
|
+
return;
|
|
34
|
+
const t = setTimeout(() => {
|
|
35
|
+
setVisible(false);
|
|
36
|
+
setTimeout(onDismiss, 300);
|
|
37
|
+
}, toast.duration);
|
|
38
|
+
return () => clearTimeout(t);
|
|
39
|
+
}, []);
|
|
40
|
+
return (_jsxs("div", { className: cn('flex w-full items-start gap-3 rounded-2xl border border-sand/10 bg-white/90 p-4 shadow-xl backdrop-blur-md transition-all duration-300 dark:border-sand/20 dark:bg-dark-sand/90', visible ? 'translate-y-0 opacity-100' : 'translate-y-2 opacity-0'), role: 'alert', children: [_jsx(Icon, { size: 18, className: cn('mt-0.5 flex-shrink-0', color) }), _jsxs("div", { className: 'min-w-0 flex-1', children: [_jsx("p", { className: 'text-sm font-medium text-text-primary dark:text-text-primary', children: toast.title }), toast.description ? _jsx("p", { className: 'mt-0.5 text-xs text-text-secondary dark:text-text-secondary', children: toast.description }) : null, toast.action ? (_jsx("button", { type: 'button', onClick: toast.action.onClick, className: 'mt-2 text-xs font-medium text-sea underline-offset-2 hover:underline dark:text-accent-blue', children: toast.action.label })) : null] }), _jsx("button", { type: 'button', onClick: () => {
|
|
41
|
+
setVisible(false);
|
|
42
|
+
setTimeout(onDismiss, 300);
|
|
43
|
+
}, className: 'flex-shrink-0 rounded-md p-0.5 text-text-secondary transition-colors hover:bg-sand/10 hover:text-text-primary dark:hover:bg-sand/20', "aria-label": 'Dismiss', children: _jsx(X, { size: 14 }) })] }));
|
|
44
|
+
}
|
|
45
|
+
// ─── Position classes ────────────────────────────────────────────────────────
|
|
46
|
+
const positionClasses = {
|
|
47
|
+
'top-left': 'top-4 left-4 items-start',
|
|
48
|
+
'top-center': 'top-4 left-1/2 -translate-x-1/2 items-center',
|
|
49
|
+
'top-right': 'top-4 right-4 items-end',
|
|
50
|
+
'bottom-left': 'bottom-4 left-4 items-start',
|
|
51
|
+
'bottom-center': 'bottom-4 left-1/2 -translate-x-1/2 items-center',
|
|
52
|
+
'bottom-right': 'bottom-4 right-4 items-end'
|
|
53
|
+
};
|
|
54
|
+
export function Sonner({ duration = 4000, position = 'bottom-right' }) {
|
|
55
|
+
const [toasts, setToasts] = React.useState([]);
|
|
56
|
+
const add = React.useCallback((t) => {
|
|
57
|
+
const id = Math.random().toString(36).slice(2);
|
|
58
|
+
setToasts((prev) => [...prev, { duration, ...t, id }]);
|
|
59
|
+
return id;
|
|
60
|
+
}, [duration]);
|
|
61
|
+
const dismiss = React.useCallback((id) => {
|
|
62
|
+
setToasts((prev) => prev.filter((t) => t.id !== id));
|
|
63
|
+
}, []);
|
|
64
|
+
// Wire up external API
|
|
65
|
+
React.useEffect(() => {
|
|
66
|
+
externalAdd = add;
|
|
67
|
+
externalDismiss = dismiss;
|
|
68
|
+
return () => {
|
|
69
|
+
externalAdd = null;
|
|
70
|
+
externalDismiss = null;
|
|
71
|
+
};
|
|
72
|
+
}, [add, dismiss]);
|
|
73
|
+
if (typeof document === 'undefined')
|
|
74
|
+
return null;
|
|
75
|
+
return createPortal(_jsx("div", { "aria-live": 'polite', "aria-label": 'Notifications', className: cn('pointer-events-none fixed z-[9999] flex flex-col gap-2 p-4', positionClasses[position]), style: { maxWidth: '22rem', width: '100%' }, children: toasts.map((t) => (_jsx("div", { className: 'pointer-events-auto w-full', children: _jsx(ToastItem, { toast: t, onDismiss: () => dismiss(t.id) }) }, t.id))) }), document.body);
|
|
76
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { ArrowUpDown } from 'lucide-react';
|
|
2
|
+
import { ArrowDown, ArrowUp, ArrowUpDown } from 'lucide-react';
|
|
3
3
|
import { cn } from '../utils/cn.js';
|
|
4
4
|
export function SortableTableHeader({ align = 'left', className, currentSort, field, label, onSort, sortable = true }) {
|
|
5
5
|
const isSorted = currentSort.field === field;
|
|
6
6
|
if (!sortable) {
|
|
7
|
-
return (_jsx("th", { className: cn(align === 'right' ? 'text-right' : 'text-left', '
|
|
7
|
+
return (_jsx("th", { className: cn(align === 'right' ? 'text-right' : 'text-left', 'h-11 px-4 text-xs font-semibold uppercase tracking-wider text-text-secondary dark:text-text-secondary', className), children: label }));
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
const SortIcon = isSorted ? (currentSort.order === 'asc' ? ArrowUp : ArrowDown) : ArrowUpDown;
|
|
10
|
+
return (_jsx("th", { className: cn(align === 'right' ? 'text-right' : 'text-left', 'h-11 px-4', className), children: _jsxs("button", { type: 'button', onClick: () => onSort(field, isSorted && currentSort.order === 'asc' ? 'desc' : 'asc'), className: cn('inline-flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wider transition-colors duration-150 focus:outline-none focus-visible:underline', isSorted ? 'text-sea dark:text-accent-blue' : 'text-text-secondary hover:text-text-primary dark:text-text-secondary dark:hover:text-text-primary'), children: [label, _jsx(SortIcon, { size: 12, className: cn('flex-shrink-0 transition-opacity duration-150', isSorted ? 'opacity-100' : 'opacity-40') })] }) }));
|
|
10
11
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface SwitchProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'onChange'> {
|
|
3
|
+
checked?: boolean;
|
|
4
|
+
label?: string;
|
|
5
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const Switch: React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { cn } from '../utils/cn.js';
|
|
4
|
+
export const Switch = React.forwardRef(function Switch({ checked = false, className, disabled, id, label, onCheckedChange, ...props }, ref) {
|
|
5
|
+
const inputId = id ?? React.useId();
|
|
6
|
+
return (_jsxs("label", { htmlFor: inputId, className: cn('inline-flex cursor-pointer select-none items-center gap-3', disabled && 'cursor-not-allowed opacity-50', className), children: [_jsxs("span", { className: 'relative inline-flex', children: [_jsx("input", { ref: ref, id: inputId, type: 'checkbox', role: 'switch', checked: checked, disabled: disabled, onChange: (e) => onCheckedChange?.(e.target.checked), className: 'sr-only', "aria-checked": checked, ...props }), _jsx("span", { className: cn('block h-6 w-11 rounded-full border-2 border-transparent transition-colors duration-300', checked ? 'bg-sea dark:bg-accent-blue' : 'bg-sand/30 dark:bg-sand/40') }), _jsx("span", { className: cn('absolute top-0.5 left-0.5 block h-5 w-5 rounded-full bg-white shadow-sm transition-transform duration-300', checked ? 'translate-x-5' : 'translate-x-0') })] }), label ? _jsx("span", { className: 'text-sm font-medium text-text-primary dark:text-text-primary', children: label }) : null] }));
|
|
7
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface SortState {
|
|
3
|
+
field: string;
|
|
4
|
+
order: 'asc' | 'desc';
|
|
5
|
+
}
|
|
6
|
+
export interface SortableTableHeaderProps {
|
|
7
|
+
align?: 'left' | 'right';
|
|
8
|
+
className?: string;
|
|
9
|
+
currentSort: SortState;
|
|
10
|
+
field: string;
|
|
11
|
+
label: string;
|
|
12
|
+
onSort: (field: string, order: 'asc' | 'desc') => void;
|
|
13
|
+
sortable?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function SortableTableHeader({ align, className, currentSort, field, label, onSort, sortable }: SortableTableHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export interface TableProps extends React.HTMLAttributes<HTMLTableElement> {
|
|
17
|
+
/** Wraps the table in a horizontally-scrollable container */
|
|
18
|
+
containerClassName?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare const Table: React.ForwardRefExoticComponent<TableProps & React.RefAttributes<HTMLTableElement>>;
|
|
21
|
+
export declare const TableHeader: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLTableSectionElement> & React.RefAttributes<HTMLTableSectionElement>>;
|
|
22
|
+
export declare const TableBody: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLTableSectionElement> & React.RefAttributes<HTMLTableSectionElement>>;
|
|
23
|
+
export declare const TableFooter: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLTableSectionElement> & React.RefAttributes<HTMLTableSectionElement>>;
|
|
24
|
+
export declare const TableRow: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLTableRowElement> & React.RefAttributes<HTMLTableRowElement>>;
|
|
25
|
+
export declare const TableHead: React.ForwardRefExoticComponent<React.ThHTMLAttributes<HTMLTableCellElement> & React.RefAttributes<HTMLTableCellElement>>;
|
|
26
|
+
export declare const TableCell: React.ForwardRefExoticComponent<React.TdHTMLAttributes<HTMLTableCellElement> & React.RefAttributes<HTMLTableCellElement>>;
|
|
27
|
+
export declare const TableCaption: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLTableCaptionElement> & React.RefAttributes<HTMLTableCaptionElement>>;
|
|
28
|
+
export interface ColumnDef<TData> {
|
|
29
|
+
/** Unique key matching a property of TData, or an arbitrary id for computed columns */
|
|
30
|
+
key: string;
|
|
31
|
+
header: string;
|
|
32
|
+
/** Render the cell value. Defaults to `String(row[key])`. */
|
|
33
|
+
cell?: (row: TData, index: number) => React.ReactNode;
|
|
34
|
+
sortable?: boolean;
|
|
35
|
+
/** Custom compare when sort is uncontrolled. Defaults to string/number comparison. */
|
|
36
|
+
sortFn?: (a: TData, b: TData) => number;
|
|
37
|
+
align?: 'left' | 'right' | 'center';
|
|
38
|
+
className?: string;
|
|
39
|
+
headerClassName?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface DataTableProps<TData> {
|
|
42
|
+
caption?: string;
|
|
43
|
+
className?: string;
|
|
44
|
+
columns: ColumnDef<TData>[];
|
|
45
|
+
containerClassName?: string;
|
|
46
|
+
data: TData[];
|
|
47
|
+
emptyMessage?: string;
|
|
48
|
+
/** Required so selection and keying work correctly */
|
|
49
|
+
getRowKey: (row: TData, index: number) => string;
|
|
50
|
+
/** Footer row — receives the current (sorted) data */
|
|
51
|
+
footer?: (data: TData[]) => React.ReactNode;
|
|
52
|
+
/** Controlled sort. If omitted, sort is managed internally. */
|
|
53
|
+
sort?: SortState;
|
|
54
|
+
onSortChange?: (sort: SortState) => void;
|
|
55
|
+
/** Enable checkbox selection */
|
|
56
|
+
selectable?: boolean;
|
|
57
|
+
selectedKeys?: Set<string>;
|
|
58
|
+
onSelectionChange?: (keys: Set<string>) => void;
|
|
59
|
+
}
|
|
60
|
+
export declare function DataTable<TData>({ caption, className, columns, containerClassName, data, emptyMessage, getRowKey, footer, sort: controlledSort, onSortChange, selectable, selectedKeys: controlledSelected, onSelectionChange }: DataTableProps<TData>): import("react/jsx-runtime").JSX.Element;
|