@gaulatti/bleecker 0.1.6 → 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/alert.d.ts +12 -0
- package/dist/components/alert.js +94 -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/field-help-tooltip.d.ts +5 -0
- package/dist/components/field-help-tooltip.js +9 -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 +26 -1
- package/dist/index.js +26 -1
- package/dist/styles.css +2 -0
- package/dist/theme/theme-script.d.ts +1 -1
- package/package.json +4 -4
- package/src/styles/compiled.css +0 -2
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface MenubarItemBase {
|
|
3
|
+
label: string;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
shortcut?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface MenubarActionItem extends MenubarItemBase {
|
|
8
|
+
type: 'item';
|
|
9
|
+
onSelect: () => void;
|
|
10
|
+
icon?: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
export interface MenubarCheckboxItem extends MenubarItemBase {
|
|
13
|
+
type: 'checkbox';
|
|
14
|
+
checked: boolean;
|
|
15
|
+
onCheckedChange: (checked: boolean) => void;
|
|
16
|
+
}
|
|
17
|
+
export interface MenubarRadioItem extends MenubarItemBase {
|
|
18
|
+
type: 'radio';
|
|
19
|
+
value: string;
|
|
20
|
+
}
|
|
21
|
+
export interface MenubarRadioGroup {
|
|
22
|
+
type: 'radioGroup';
|
|
23
|
+
value: string;
|
|
24
|
+
onValueChange: (value: string) => void;
|
|
25
|
+
items: MenubarRadioItem[];
|
|
26
|
+
}
|
|
27
|
+
export interface MenubarSeparator {
|
|
28
|
+
type: 'separator';
|
|
29
|
+
}
|
|
30
|
+
export interface MenubarSubMenu extends MenubarItemBase {
|
|
31
|
+
type: 'sub';
|
|
32
|
+
items: MenubarMenuItem[];
|
|
33
|
+
}
|
|
34
|
+
export type MenubarMenuItem = MenubarActionItem | MenubarCheckboxItem | MenubarRadioGroup | MenubarSeparator | MenubarSubMenu;
|
|
35
|
+
export interface MenubarMenu {
|
|
36
|
+
trigger: string;
|
|
37
|
+
items: MenubarMenuItem[];
|
|
38
|
+
}
|
|
39
|
+
export interface MenubarProps {
|
|
40
|
+
className?: string;
|
|
41
|
+
menus: MenubarMenu[];
|
|
42
|
+
}
|
|
43
|
+
export declare function Menubar({ className, menus }: MenubarProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Check, ChevronRight } from 'lucide-react';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { cn } from '../utils/cn.js';
|
|
5
|
+
// ─── MenuItem renderer ───────────────────────────────────────────────────────
|
|
6
|
+
function MenuItems({ items, radioGroupValue, onClose }) {
|
|
7
|
+
const [openSub, setOpenSub] = React.useState(null);
|
|
8
|
+
return (_jsx("div", { className: 'flex flex-col py-1', children: items.map((item, i) => {
|
|
9
|
+
if (item.type === 'separator') {
|
|
10
|
+
return _jsx("div", { className: 'my-1 h-px bg-sand/15 dark:bg-sand/25', role: 'separator' }, i);
|
|
11
|
+
}
|
|
12
|
+
if (item.type === 'radioGroup') {
|
|
13
|
+
return (_jsx("div", { role: 'group', children: item.items.map((rItem) => {
|
|
14
|
+
const isChecked = item.value === rItem.value;
|
|
15
|
+
return (_jsxs("button", { type: 'button', role: 'menuitemradio', "aria-checked": isChecked, disabled: rItem.disabled, onClick: () => {
|
|
16
|
+
item.onValueChange(rItem.value);
|
|
17
|
+
onClose();
|
|
18
|
+
}, className: 'flex w-full items-center gap-2 rounded-lg px-3 py-1.5 text-sm text-text-primary transition-colors hover:bg-sand/10 disabled:opacity-50 dark:text-text-primary dark:hover:bg-sand/15', children: [_jsx("span", { className: 'flex h-4 w-4 items-center justify-center', children: isChecked ? _jsx("span", { className: 'h-2 w-2 rounded-full bg-sea dark:bg-accent-blue' }) : null }), rItem.label, rItem.shortcut ? _jsx("span", { className: 'ml-auto text-xs text-text-secondary', children: rItem.shortcut }) : null] }, rItem.value));
|
|
19
|
+
}) }, i));
|
|
20
|
+
}
|
|
21
|
+
if (item.type === 'checkbox') {
|
|
22
|
+
return (_jsxs("button", { type: 'button', role: 'menuitemcheckbox', "aria-checked": item.checked, disabled: item.disabled, onClick: () => {
|
|
23
|
+
item.onCheckedChange(!item.checked);
|
|
24
|
+
onClose();
|
|
25
|
+
}, className: 'flex w-full items-center gap-2 rounded-lg px-3 py-1.5 text-sm text-text-primary transition-colors hover:bg-sand/10 disabled:opacity-50 dark:text-text-primary dark:hover:bg-sand/15', children: [_jsx("span", { className: 'flex h-4 w-4 items-center justify-center', children: item.checked ? _jsx(Check, { size: 12, className: 'text-sea dark:text-accent-blue' }) : null }), item.label, item.shortcut ? _jsx("span", { className: 'ml-auto text-xs text-text-secondary', children: item.shortcut }) : null] }, i));
|
|
26
|
+
}
|
|
27
|
+
if (item.type === 'sub') {
|
|
28
|
+
const isSubOpen = openSub === i;
|
|
29
|
+
return (_jsxs("div", { className: 'relative', children: [_jsxs("button", { type: 'button', role: 'menuitem', "aria-haspopup": 'menu', "aria-expanded": isSubOpen, disabled: item.disabled, onPointerEnter: () => setOpenSub(i), onPointerLeave: () => setOpenSub(null), className: 'flex w-full items-center rounded-lg px-3 py-1.5 text-sm text-text-primary transition-colors hover:bg-sand/10 disabled:opacity-50 dark:text-text-primary dark:hover:bg-sand/15', children: [_jsx("span", { className: 'flex-1', children: item.label }), _jsx(ChevronRight, { size: 14, className: 'text-text-secondary' })] }), isSubOpen && (_jsx("div", { className: 'absolute left-full top-0 z-10 min-w-[12rem] rounded-xl border border-sand/10 bg-white shadow-xl dark:border-sand/20 dark:bg-dark-sand', onPointerEnter: () => setOpenSub(i), onPointerLeave: () => setOpenSub(null), children: _jsx(MenuItems, { items: item.items, onClose: onClose }) }))] }, i));
|
|
30
|
+
}
|
|
31
|
+
// type === 'item'
|
|
32
|
+
return (_jsxs("button", { type: 'button', role: 'menuitem', disabled: item.disabled, onClick: () => {
|
|
33
|
+
item.onSelect();
|
|
34
|
+
onClose();
|
|
35
|
+
}, className: 'flex w-full items-center gap-2 rounded-lg px-3 py-1.5 text-sm text-text-primary transition-colors hover:bg-sand/10 disabled:opacity-50 dark:text-text-primary dark:hover:bg-sand/15', children: [item.icon ? _jsx("span", { className: 'flex-shrink-0 text-text-secondary', children: item.icon }) : _jsx("span", { className: 'w-4' }), _jsx("span", { className: 'flex-1', children: item.label }), item.shortcut ? _jsx("span", { className: 'ml-auto text-xs text-text-secondary', children: item.shortcut }) : null] }, i));
|
|
36
|
+
}) }));
|
|
37
|
+
}
|
|
38
|
+
// ─── Menubar ─────────────────────────────────────────────────────────────────
|
|
39
|
+
export function Menubar({ className, menus }) {
|
|
40
|
+
const [activeIndex, setActiveIndex] = React.useState(null);
|
|
41
|
+
const barRef = React.useRef(null);
|
|
42
|
+
React.useEffect(() => {
|
|
43
|
+
if (activeIndex === null)
|
|
44
|
+
return;
|
|
45
|
+
const handler = (e) => {
|
|
46
|
+
if (!barRef.current?.contains(e.target))
|
|
47
|
+
setActiveIndex(null);
|
|
48
|
+
};
|
|
49
|
+
document.addEventListener('pointerdown', handler);
|
|
50
|
+
return () => document.removeEventListener('pointerdown', handler);
|
|
51
|
+
}, [activeIndex]);
|
|
52
|
+
return (_jsx("div", { ref: barRef, role: 'menubar', className: cn('flex items-center gap-1 rounded-xl border border-sand/10 bg-white/80 px-1 py-1 shadow-sm backdrop-blur-md dark:border-sand/20 dark:bg-dark-sand/80', className), children: menus.map((menu, i) => {
|
|
53
|
+
const isOpen = activeIndex === i;
|
|
54
|
+
return (_jsxs("div", { className: 'relative', children: [_jsx("button", { type: 'button', role: 'menuitem', "aria-haspopup": 'menu', "aria-expanded": isOpen, onClick: () => setActiveIndex(isOpen ? null : i), className: cn('rounded-lg px-3 py-1.5 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
|
|
55
|
+
? 'bg-sea text-white dark:bg-accent-blue'
|
|
56
|
+
: '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: menu.trigger }), isOpen && (_jsx("div", { role: 'menu', className: 'absolute left-0 top-full z-50 mt-1 min-w-[14rem] rounded-xl border border-sand/10 bg-white p-1 shadow-xl dark:border-sand/20 dark:bg-dark-sand', children: _jsx(MenuItems, { items: menu.items, onClose: () => setActiveIndex(null) }) }))] }, menu.trigger));
|
|
57
|
+
}) }));
|
|
58
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type NavItem, type RenderLink } from './nav-menu';
|
|
2
|
+
export interface NavigationMenuLink extends NavItem {
|
|
3
|
+
description?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface NavigationMenuGroup {
|
|
6
|
+
trigger: string;
|
|
7
|
+
href?: string;
|
|
8
|
+
items: NavigationMenuLink[];
|
|
9
|
+
}
|
|
10
|
+
export type NavigationMenuEntry = NavigationMenuLink | NavigationMenuGroup;
|
|
11
|
+
export interface NavigationMenuProps<TLink extends NavigationMenuLink = NavigationMenuLink> {
|
|
12
|
+
className?: string;
|
|
13
|
+
entries: NavigationMenuEntry[];
|
|
14
|
+
renderLink?: RenderLink<TLink>;
|
|
15
|
+
}
|
|
16
|
+
export declare function NavigationMenu<TLink extends NavigationMenuLink>({ className, entries, renderLink }: NavigationMenuProps<TLink>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -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;
|