@aereamart/design-system 0.2.0 → 0.3.1
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/Accordion.d.ts +10 -0
- package/dist/Accordion.js +12 -0
- package/dist/AlertBanner.d.ts +9 -0
- package/dist/AlertBanner.js +21 -0
- package/dist/AppBar.d.ts +7 -0
- package/dist/AppBar.js +5 -0
- package/dist/Avatar.d.ts +6 -0
- package/dist/Avatar.js +20 -0
- package/dist/Badge.js +4 -4
- package/dist/BottomSheet.d.ts +8 -0
- package/dist/BottomSheet.js +24 -0
- package/dist/Breadcrumb.d.ts +8 -0
- package/dist/Breadcrumb.js +9 -0
- package/dist/Button.js +3 -3
- package/dist/Card.d.ts +7 -0
- package/dist/Card.js +6 -0
- package/dist/Checkbox.d.ts +5 -0
- package/dist/Checkbox.js +5 -0
- package/dist/Chip.d.ts +7 -0
- package/dist/Chip.js +15 -0
- package/dist/DataTable.d.ts +15 -0
- package/dist/DataTable.js +7 -0
- package/dist/DatePicker.d.ts +5 -0
- package/dist/DatePicker.js +11 -0
- package/dist/Divider.d.ts +5 -0
- package/dist/Divider.js +11 -0
- package/dist/Drawer.d.ts +10 -0
- package/dist/Drawer.js +24 -0
- package/dist/EmptyState.d.ts +7 -0
- package/dist/EmptyState.js +6 -0
- package/dist/Input.js +3 -3
- package/dist/Link.d.ts +4 -0
- package/dist/Link.js +6 -0
- package/dist/Menu.d.ts +14 -0
- package/dist/Menu.js +29 -0
- package/dist/Modal.js +1 -1
- package/dist/NavigationBar.d.ts +14 -0
- package/dist/NavigationBar.js +22 -0
- package/dist/Pagination.d.ts +7 -0
- package/dist/Pagination.js +24 -0
- package/dist/Popover.d.ts +7 -0
- package/dist/Popover.js +9 -0
- package/dist/Progress.d.ts +8 -0
- package/dist/Progress.js +15 -0
- package/dist/Radio.d.ts +15 -0
- package/dist/Radio.js +8 -0
- package/dist/SegmentedControl.d.ts +13 -0
- package/dist/SegmentedControl.js +18 -0
- package/dist/Select.js +3 -3
- package/dist/Sidebar.d.ts +16 -0
- package/dist/Sidebar.js +19 -0
- package/dist/Slider.d.ts +5 -0
- package/dist/Slider.js +5 -0
- package/dist/Snackbar.d.ts +12 -0
- package/dist/Snackbar.js +20 -0
- package/dist/Switch.d.ts +4 -0
- package/dist/Switch.js +5 -0
- package/dist/Tabs.d.ts +14 -0
- package/dist/Tabs.js +24 -0
- package/dist/Tag.d.ts +6 -0
- package/dist/Tag.js +11 -0
- package/dist/Textarea.js +3 -3
- package/dist/Tooltip.d.ts +7 -0
- package/dist/Tooltip.js +5 -0
- package/dist/TreeView.d.ts +12 -0
- package/dist/TreeView.js +34 -0
- package/dist/index.d.ts +32 -2
- package/dist/index.js +32 -2
- package/package.json +43 -43
- package/src/Accordion.tsx +58 -0
- package/src/AlertBanner.tsx +62 -0
- package/src/AppBar.tsx +29 -0
- package/src/Avatar.tsx +42 -0
- package/src/Badge.tsx +27 -27
- package/src/BottomSheet.tsx +60 -0
- package/src/Breadcrumb.tsx +48 -0
- package/src/Button.tsx +54 -54
- package/src/Card.tsx +39 -0
- package/src/Checkbox.tsx +31 -0
- package/src/Chip.tsx +44 -0
- package/src/DataTable.tsx +64 -0
- package/src/DatePicker.tsx +44 -0
- package/src/Divider.tsx +33 -0
- package/src/Drawer.tsx +71 -0
- package/src/EmptyState.tsx +37 -0
- package/src/Input.tsx +30 -30
- package/src/Link.tsx +22 -0
- package/src/Menu.tsx +73 -0
- package/src/Modal.tsx +62 -62
- package/src/NavigationBar.tsx +68 -0
- package/src/Pagination.tsx +69 -0
- package/src/Popover.tsx +34 -0
- package/src/Progress.tsx +53 -0
- package/src/Radio.tsx +49 -0
- package/src/SegmentedControl.tsx +63 -0
- package/src/Select.tsx +32 -32
- package/src/Sidebar.tsx +73 -0
- package/src/Slider.tsx +33 -0
- package/src/Snackbar.tsx +72 -0
- package/src/Spinner.tsx +19 -19
- package/src/Switch.tsx +40 -0
- package/src/Tabs.tsx +77 -0
- package/src/Tag.tsx +29 -0
- package/src/Textarea.tsx +30 -30
- package/src/Tooltip.tsx +25 -0
- package/src/TreeView.tsx +105 -0
- package/src/cn.ts +2 -2
- package/src/index.ts +38 -8
package/dist/Radio.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from './cn';
|
|
3
|
+
export function Radio({ label, id, className, ...props }) {
|
|
4
|
+
return (_jsxs("label", { htmlFor: id, className: cn('inline-flex cursor-pointer items-center gap-2.5 text-sm', className), children: [_jsx("input", { id: id, type: "radio", className: "h-4 w-4 shrink-0 cursor-pointer accent-lime-600 focus:outline-none focus:ring-2 focus:ring-lime-500/40", ...props }), label && _jsx("span", { className: "font-medium text-slate-700", children: label })] }));
|
|
5
|
+
}
|
|
6
|
+
export function RadioGroup({ name, value, onChange, options, className, ...props }) {
|
|
7
|
+
return (_jsx("div", { className: cn('flex flex-wrap gap-x-5 gap-y-2.5', className), ...props, children: options.map(opt => (_jsx(Radio, { id: `${name}-${opt.value}`, name: name, value: opt.value, label: opt.label, checked: value === opt.value, disabled: opt.disabled, onChange: e => onChange?.(e.target.value) }, opt.value))) }));
|
|
8
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface SegmentedOption<T extends string | number> {
|
|
2
|
+
value: T;
|
|
3
|
+
label: string;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface SegmentedControlProps<T extends string | number> {
|
|
7
|
+
options: SegmentedOption<T>[];
|
|
8
|
+
value?: T;
|
|
9
|
+
defaultValue?: T;
|
|
10
|
+
onChange?: (value: T) => void;
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function SegmentedControl<T extends string | number>({ options, value, defaultValue, onChange, className, }: SegmentedControlProps<T>): import("react").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { cn } from './cn';
|
|
4
|
+
export function SegmentedControl({ options, value, defaultValue, onChange, className, }) {
|
|
5
|
+
const isControlled = value !== undefined;
|
|
6
|
+
const [inner, setInner] = useState(defaultValue);
|
|
7
|
+
const active = isControlled ? value : inner;
|
|
8
|
+
return (_jsx("div", { role: "tablist", className: cn('inline-flex items-center gap-1 rounded-lg border border-slate-200 bg-white p-1', className), children: options.map(opt => {
|
|
9
|
+
const selected = active === opt.value;
|
|
10
|
+
return (_jsx("button", { type: "button", role: "tab", "aria-selected": selected, disabled: opt.disabled, onClick: () => {
|
|
11
|
+
if (!isControlled)
|
|
12
|
+
setInner(opt.value);
|
|
13
|
+
onChange?.(opt.value);
|
|
14
|
+
}, className: cn('rounded-md px-4 py-1.5 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-lime-500/40 disabled:opacity-50', selected
|
|
15
|
+
? 'bg-lime-600 text-white'
|
|
16
|
+
: 'text-slate-600 hover:bg-slate-100 hover:text-slate-900'), children: opt.label }, String(opt.value)));
|
|
17
|
+
}) }));
|
|
18
|
+
}
|
package/dist/Select.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from './cn';
|
|
3
3
|
export function Select({ label, error, className, id, children, ...props }) {
|
|
4
|
-
return (_jsxs("div", { className: "w-full", children: [label && (_jsx("label", { htmlFor: id, className: "mb-1 block text-sm font-medium text-
|
|
5
|
-
? 'border-red-
|
|
6
|
-
: 'border-
|
|
4
|
+
return (_jsxs("div", { className: "w-full", children: [label && (_jsx("label", { htmlFor: id, className: "mb-1 block text-sm font-medium text-slate-700", children: label })), _jsx("select", { id: id, className: cn('w-full rounded-lg border bg-white px-3 py-2.5 text-sm text-slate-900 focus:outline-none focus:ring-2', error
|
|
5
|
+
? 'border-red-600 focus:border-red-600 focus:ring-red-500/30'
|
|
6
|
+
: 'border-slate-500 focus:border-lime-600 focus:ring-lime-500/30', className), ...props, children: children }), error && _jsx("p", { className: "mt-1 text-xs text-red-600", children: error })] }));
|
|
7
7
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface SidebarItem {
|
|
2
|
+
value: string;
|
|
3
|
+
label: string;
|
|
4
|
+
icon?: React.ReactNode;
|
|
5
|
+
badge?: React.ReactNode;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface SidebarProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onChange'> {
|
|
9
|
+
items: SidebarItem[];
|
|
10
|
+
value?: string;
|
|
11
|
+
defaultValue?: string;
|
|
12
|
+
onChange?: (value: string) => void;
|
|
13
|
+
header?: React.ReactNode;
|
|
14
|
+
footer?: React.ReactNode;
|
|
15
|
+
}
|
|
16
|
+
export declare function Sidebar({ items, value, defaultValue, onChange, header, footer, className, ...props }: SidebarProps): import("react").JSX.Element;
|
package/dist/Sidebar.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { cn } from './cn';
|
|
4
|
+
export function Sidebar({ items, value, defaultValue, onChange, header, footer, className, ...props }) {
|
|
5
|
+
const controlled = value !== undefined;
|
|
6
|
+
const [active, setActive] = useState(defaultValue);
|
|
7
|
+
return (_jsxs("nav", { className: cn('flex w-64 flex-col gap-2 rounded-xl border border-slate-200 bg-white p-3', className), ...props, children: [header && _jsx("div", { className: "border-b border-slate-100 pb-2", children: header }), _jsx("ul", { className: "flex-1 space-y-0.5", children: items.map(item => {
|
|
8
|
+
const isActive = controlled ? value === item.value : active === item.value;
|
|
9
|
+
return (_jsx("li", { children: _jsxs("button", { type: "button", disabled: item.disabled, onClick: () => {
|
|
10
|
+
if (!controlled)
|
|
11
|
+
setActive(item.value);
|
|
12
|
+
onChange?.(item.value);
|
|
13
|
+
}, className: cn('flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-left text-sm font-medium transition-colors', 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-lime-500/40 disabled:cursor-not-allowed', item.disabled
|
|
14
|
+
? 'cursor-not-allowed text-slate-300'
|
|
15
|
+
: isActive
|
|
16
|
+
? 'bg-lime-600 text-white'
|
|
17
|
+
: 'text-slate-700 hover:bg-lime-50 hover:text-lime-800'), children: [item.icon, _jsx("span", { className: "flex-1 truncate", children: item.label }), item.badge] }) }, item.value));
|
|
18
|
+
}) }), footer && _jsx("div", { className: "border-t border-slate-100 pt-2", children: footer })] }));
|
|
19
|
+
}
|
package/dist/Slider.d.ts
ADDED
package/dist/Slider.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from './cn';
|
|
3
|
+
export function Slider({ label, valueLabel, id, className, ...props }) {
|
|
4
|
+
return (_jsxs("div", { className: cn('w-full max-w-md', className), children: [(label || valueLabel) && (_jsxs("div", { className: "mb-2 flex items-center justify-between", children: [label && (_jsx("label", { htmlFor: id, className: "text-sm font-medium text-slate-700", children: label })), valueLabel && (_jsx("span", { className: "text-sm font-semibold tabular-nums text-slate-600", children: valueLabel }))] })), _jsx("input", { id: id, type: "range", className: "h-2 w-full cursor-pointer appearance-none rounded-full bg-slate-200 accent-lime-600 focus:outline-none focus:ring-2 focus:ring-lime-500/40", ...props })] }));
|
|
5
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type SnackbarTone = 'success' | 'error' | 'warning' | 'info';
|
|
2
|
+
export interface SnackbarProps {
|
|
3
|
+
open?: boolean;
|
|
4
|
+
tone?: SnackbarTone;
|
|
5
|
+
message: string;
|
|
6
|
+
actionLabel?: string;
|
|
7
|
+
onAction?: () => void;
|
|
8
|
+
onClose?: () => void;
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function Snackbar({ open, tone, message, actionLabel, onAction, onClose, className, }: SnackbarProps): import("react").JSX.Element | null;
|
|
12
|
+
export {};
|
package/dist/Snackbar.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CheckCircle2, XCircle, AlertTriangle, Info, X } from 'lucide-react';
|
|
3
|
+
import { cn } from './cn';
|
|
4
|
+
const toneIcon = {
|
|
5
|
+
success: _jsx(CheckCircle2, { className: "h-5 w-5 shrink-0" }),
|
|
6
|
+
error: _jsx(XCircle, { className: "h-5 w-5 shrink-0" }),
|
|
7
|
+
warning: _jsx(AlertTriangle, { className: "h-5 w-5 shrink-0" }),
|
|
8
|
+
info: _jsx(Info, { className: "h-5 w-5 shrink-0" }),
|
|
9
|
+
};
|
|
10
|
+
const toneText = {
|
|
11
|
+
success: 'text-lime-600',
|
|
12
|
+
error: 'text-red-600',
|
|
13
|
+
warning: 'text-purple-600',
|
|
14
|
+
info: 'text-sky-600',
|
|
15
|
+
};
|
|
16
|
+
export function Snackbar({ open = true, tone = 'info', message, actionLabel, onAction, onClose, className, }) {
|
|
17
|
+
if (!open)
|
|
18
|
+
return null;
|
|
19
|
+
return (_jsxs("div", { role: "status", "aria-live": "polite", className: cn('pointer-events-auto flex items-center gap-3 rounded-xl border border-slate-200 bg-white px-4 py-3 shadow-lg', className), children: [_jsx("span", { className: toneText[tone], children: toneIcon[tone] }), _jsx("p", { className: "min-w-0 flex-1 text-sm font-medium text-slate-800", children: message }), actionLabel && (_jsx("button", { type: "button", onClick: onAction, className: "shrink-0 text-sm font-semibold text-lime-700 hover:text-lime-800 hover:underline", children: actionLabel })), onClose && (_jsx("button", { type: "button", "aria-label": "Close", onClick: onClose, className: "shrink-0 rounded-full p-1 text-slate-400 hover:bg-slate-100", children: _jsx(X, { className: "h-4 w-4" }) }))] }));
|
|
20
|
+
}
|
package/dist/Switch.d.ts
ADDED
package/dist/Switch.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from './cn';
|
|
3
|
+
export function Switch({ label, id, className, checked, onChange, ...props }) {
|
|
4
|
+
return (_jsxs("label", { htmlFor: id, className: cn('inline-flex cursor-pointer items-center gap-3', className), children: [_jsx("input", { id: id, type: "checkbox", role: "switch", checked: checked, onChange: onChange, className: "sr-only", ...props }), _jsx("span", { "aria-hidden": "true", className: cn('relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors', checked ? 'bg-lime-600' : 'bg-slate-300'), children: _jsx("span", { className: cn('inline-block h-4 w-4 transform rounded-full bg-white shadow transition-transform', checked ? 'translate-x-6' : 'translate-x-1') }) }), label && _jsx("span", { className: "text-sm font-medium text-slate-700", children: label })] }));
|
|
5
|
+
}
|
package/dist/Tabs.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface Tab<T extends string | number> {
|
|
2
|
+
value: T;
|
|
3
|
+
label: string;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface TabsProps<T extends string | number> {
|
|
7
|
+
tabs: Tab<T>[];
|
|
8
|
+
value?: T;
|
|
9
|
+
defaultValue?: T;
|
|
10
|
+
onChange?: (value: T) => void;
|
|
11
|
+
variant?: 'underline' | 'pill';
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function Tabs<T extends string | number>({ tabs, value, defaultValue, onChange, variant, className, }: TabsProps<T>): import("react").JSX.Element;
|
package/dist/Tabs.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { cn } from './cn';
|
|
4
|
+
export function Tabs({ tabs, value, defaultValue, onChange, variant = 'underline', className, }) {
|
|
5
|
+
const isControlled = value !== undefined;
|
|
6
|
+
const [inner, setInner] = useState(defaultValue);
|
|
7
|
+
const active = isControlled ? value : inner;
|
|
8
|
+
return (_jsx("div", { role: "tablist", className: cn(variant === 'underline'
|
|
9
|
+
? 'flex gap-1 border-b border-slate-200'
|
|
10
|
+
: 'inline-flex items-center gap-1 rounded-lg border border-slate-200 bg-white p-1', className), children: tabs.map(tab => {
|
|
11
|
+
const selected = active === tab.value;
|
|
12
|
+
return (_jsx("button", { type: "button", role: "tab", "aria-selected": selected, disabled: tab.disabled, onClick: () => {
|
|
13
|
+
if (!isControlled)
|
|
14
|
+
setInner(tab.value);
|
|
15
|
+
onChange?.(tab.value);
|
|
16
|
+
}, className: cn('px-4 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-lime-500/40 disabled:opacity-50', variant === 'underline'
|
|
17
|
+
? cn('-mb-px border-b-2', selected
|
|
18
|
+
? 'border-lime-600 text-lime-700'
|
|
19
|
+
: 'border-transparent text-slate-500 hover:border-slate-300 hover:text-slate-900')
|
|
20
|
+
: cn('rounded-md', selected
|
|
21
|
+
? 'bg-lime-600 text-white'
|
|
22
|
+
: 'text-slate-600 hover:bg-slate-100 hover:text-slate-900')), children: tab.label }, String(tab.value)));
|
|
23
|
+
}) }));
|
|
24
|
+
}
|
package/dist/Tag.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type TagTone = 'primary' | 'accent' | 'neutral' | 'danger';
|
|
2
|
+
export interface TagProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
3
|
+
tone?: TagTone;
|
|
4
|
+
}
|
|
5
|
+
export declare function Tag({ tone, className, children, ...props }: TagProps): import("react").JSX.Element;
|
|
6
|
+
export {};
|
package/dist/Tag.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from './cn';
|
|
3
|
+
const toneClasses = {
|
|
4
|
+
primary: 'border-lime-300 bg-white text-lime-800',
|
|
5
|
+
accent: 'border-purple-300 bg-white text-purple-900',
|
|
6
|
+
neutral: 'border-slate-300 bg-white text-slate-700',
|
|
7
|
+
danger: 'border-red-300 bg-white text-red-800',
|
|
8
|
+
};
|
|
9
|
+
export function Tag({ tone = 'neutral', className, children, ...props }) {
|
|
10
|
+
return (_jsx("span", { className: cn('inline-flex items-center gap-1 rounded-md border px-2 py-0.5 text-xs font-semibold', toneClasses[tone], className), ...props, children: children }));
|
|
11
|
+
}
|
package/dist/Textarea.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from './cn';
|
|
3
3
|
export function Textarea({ label, error, className, id, ...props }) {
|
|
4
|
-
return (_jsxs("div", { className: "w-full", children: [label && (_jsx("label", { htmlFor: id, className: "mb-1 block text-sm font-medium text-
|
|
5
|
-
? 'border-red-
|
|
6
|
-
: 'border-
|
|
4
|
+
return (_jsxs("div", { className: "w-full", children: [label && (_jsx("label", { htmlFor: id, className: "mb-1 block text-sm font-medium text-slate-700", children: label })), _jsx("textarea", { id: id, className: cn('w-full rounded-lg border bg-white px-4 py-2.5 text-sm text-slate-900 placeholder:text-slate-500 focus:outline-none focus:ring-2', error
|
|
5
|
+
? 'border-red-600 focus:border-red-600 focus:ring-red-500/30'
|
|
6
|
+
: 'border-slate-500 focus:border-lime-600 focus:ring-lime-500/30', className), ...props }), error && _jsx("p", { className: "mt-1 text-xs text-red-600", children: error })] }));
|
|
7
7
|
}
|
package/dist/Tooltip.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from './cn';
|
|
3
|
+
export function Tooltip({ content, side = 'top', children, className }) {
|
|
4
|
+
return (_jsxs("span", { className: cn('group relative inline-flex', className), children: [children, _jsx("span", { role: "tooltip", className: cn('pointer-events-none absolute left-1/2 z-50 w-max max-w-xs -translate-x-1/2 rounded-lg bg-slate-900 px-3 py-1.5 text-xs font-medium text-white opacity-0 shadow-lg transition-opacity duration-200 group-hover:opacity-100 group-focus-within:opacity-100', side === 'top' ? 'bottom-full mb-2' : 'top-full mt-2'), children: content })] }));
|
|
5
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface TreeNode {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
children?: TreeNode[];
|
|
5
|
+
}
|
|
6
|
+
export interface TreeViewProps {
|
|
7
|
+
nodes: TreeNode[];
|
|
8
|
+
defaultExpanded?: string[];
|
|
9
|
+
defaultAllExpanded?: boolean;
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function TreeView({ nodes, defaultExpanded, defaultAllExpanded, className }: TreeViewProps): import("react").JSX.Element;
|
package/dist/TreeView.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useState } from 'react';
|
|
3
|
+
import { ChevronRight } from 'lucide-react';
|
|
4
|
+
import { cn } from './cn';
|
|
5
|
+
function Node({ node, depth, expanded, onToggle, }) {
|
|
6
|
+
const hasChildren = !!node.children?.length;
|
|
7
|
+
const isOpen = expanded.has(node.id);
|
|
8
|
+
return (_jsxs("li", { children: [_jsx("div", { className: cn('flex items-center gap-1.5 rounded-lg py-1.5 pr-2'), children: _jsxs("button", { type: "button", "aria-expanded": hasChildren ? isOpen : undefined, onClick: () => hasChildren && onToggle(node.id), className: cn('inline-flex w-full items-center gap-1.5 rounded-lg py-1.5 pr-2 text-left text-sm font-medium transition-colors', 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-lime-500/40', 'hover:bg-slate-100'), style: { paddingLeft: `${8 + depth * 24}px` }, children: [hasChildren ? (_jsx(ChevronRight, { className: cn('h-4 w-4 shrink-0 text-slate-400 transition-transform', isOpen && 'rotate-90') })) : (_jsx("span", { className: "ml-4 h-4 w-4 shrink-0", "aria-hidden": "true" })), _jsx("span", { className: cn(isOpen && 'font-semibold text-slate-900'), children: node.label })] }) }), hasChildren && isOpen && (_jsx("ul", { role: "group", children: node.children.map(child => (_jsx(Node, { node: child, depth: depth + 1, expanded: expanded, onToggle: onToggle }, child.id))) }))] }));
|
|
9
|
+
}
|
|
10
|
+
export function TreeView({ nodes, defaultExpanded = [], defaultAllExpanded = false, className }) {
|
|
11
|
+
const [expanded, setExpanded] = useState(() => {
|
|
12
|
+
if (defaultAllExpanded) {
|
|
13
|
+
const all = new Set();
|
|
14
|
+
const walk = (list) => list.forEach(n => {
|
|
15
|
+
all.add(n.id);
|
|
16
|
+
if (n.children)
|
|
17
|
+
walk(n.children);
|
|
18
|
+
});
|
|
19
|
+
walk(nodes);
|
|
20
|
+
return all;
|
|
21
|
+
}
|
|
22
|
+
return new Set(defaultExpanded);
|
|
23
|
+
});
|
|
24
|
+
const labelId = useId();
|
|
25
|
+
const toggle = (id) => setExpanded(prev => {
|
|
26
|
+
const next = new Set(prev);
|
|
27
|
+
if (next.has(id))
|
|
28
|
+
next.delete(id);
|
|
29
|
+
else
|
|
30
|
+
next.add(id);
|
|
31
|
+
return next;
|
|
32
|
+
});
|
|
33
|
+
return (_jsxs("ul", { role: "tree", "aria-label": "Tree", "aria-labelledby": labelId, className: cn('space-y-0.5', className), children: [_jsx("span", { id: labelId, className: "sr-only", children: "Tree view" }), nodes.map(node => (_jsx(Node, { node: node, depth: 0, expanded: expanded, onToggle: toggle }, node.id)))] }));
|
|
34
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,38 @@
|
|
|
1
1
|
export { cn } from './cn';
|
|
2
|
+
export { Accordion, type AccordionProps, type AccordionItem } from './Accordion';
|
|
3
|
+
export { AlertBanner, type AlertBannerProps } from './AlertBanner';
|
|
4
|
+
export { AppBar, type AppBarProps } from './AppBar';
|
|
5
|
+
export { Avatar, type AvatarProps } from './Avatar';
|
|
2
6
|
export { Badge, type BadgeProps } from './Badge';
|
|
7
|
+
export { BottomSheet, type BottomSheetProps } from './BottomSheet';
|
|
8
|
+
export { Breadcrumb, type BreadcrumbProps, type Crumb } from './Breadcrumb';
|
|
3
9
|
export { Button, type ButtonProps } from './Button';
|
|
10
|
+
export { Card, type CardProps } from './Card';
|
|
11
|
+
export { Checkbox, type CheckboxProps } from './Checkbox';
|
|
12
|
+
export { Chip, type ChipProps } from './Chip';
|
|
13
|
+
export { DataTable, type DataTableProps, type Column } from './DataTable';
|
|
14
|
+
export { DatePicker, type DatePickerProps } from './DatePicker';
|
|
15
|
+
export { Divider, type DividerProps } from './Divider';
|
|
16
|
+
export { Drawer, type DrawerProps } from './Drawer';
|
|
17
|
+
export { EmptyState, type EmptyStateProps } from './EmptyState';
|
|
4
18
|
export { Input, type InputProps } from './Input';
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
19
|
+
export { Link, type LinkProps } from './Link';
|
|
20
|
+
export { Menu, type MenuProps, type MenuItem } from './Menu';
|
|
7
21
|
export { Modal, type ModalProps } from './Modal';
|
|
22
|
+
export { NavigationBar, type NavigationBarProps, type NavItem } from './NavigationBar';
|
|
23
|
+
export { Pagination, type PaginationProps } from './Pagination';
|
|
24
|
+
export { Popover, type PopoverProps } from './Popover';
|
|
25
|
+
export { Progress, type ProgressProps } from './Progress';
|
|
26
|
+
export { Radio, RadioGroup, type RadioProps, type RadioGroupProps } from './Radio';
|
|
27
|
+
export { SegmentedControl, type SegmentedControlProps, type SegmentedOption } from './SegmentedControl';
|
|
28
|
+
export { Select, type SelectProps } from './Select';
|
|
29
|
+
export { Sidebar, type SidebarProps, type SidebarItem } from './Sidebar';
|
|
30
|
+
export { Slider, type SliderProps } from './Slider';
|
|
31
|
+
export { Snackbar, type SnackbarProps } from './Snackbar';
|
|
8
32
|
export { Spinner } from './Spinner';
|
|
33
|
+
export { Switch, type SwitchProps } from './Switch';
|
|
34
|
+
export { Tabs, type TabsProps, type Tab } from './Tabs';
|
|
35
|
+
export { Tag, type TagProps } from './Tag';
|
|
36
|
+
export { Textarea, type TextareaProps } from './Textarea';
|
|
37
|
+
export { Tooltip, type TooltipProps } from './Tooltip';
|
|
38
|
+
export { TreeView, type TreeViewProps, type TreeNode } from './TreeView';
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,38 @@
|
|
|
1
1
|
export { cn } from './cn';
|
|
2
|
+
export { Accordion } from './Accordion';
|
|
3
|
+
export { AlertBanner } from './AlertBanner';
|
|
4
|
+
export { AppBar } from './AppBar';
|
|
5
|
+
export { Avatar } from './Avatar';
|
|
2
6
|
export { Badge } from './Badge';
|
|
7
|
+
export { BottomSheet } from './BottomSheet';
|
|
8
|
+
export { Breadcrumb } from './Breadcrumb';
|
|
3
9
|
export { Button } from './Button';
|
|
10
|
+
export { Card } from './Card';
|
|
11
|
+
export { Checkbox } from './Checkbox';
|
|
12
|
+
export { Chip } from './Chip';
|
|
13
|
+
export { DataTable } from './DataTable';
|
|
14
|
+
export { DatePicker } from './DatePicker';
|
|
15
|
+
export { Divider } from './Divider';
|
|
16
|
+
export { Drawer } from './Drawer';
|
|
17
|
+
export { EmptyState } from './EmptyState';
|
|
4
18
|
export { Input } from './Input';
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
19
|
+
export { Link } from './Link';
|
|
20
|
+
export { Menu } from './Menu';
|
|
7
21
|
export { Modal } from './Modal';
|
|
22
|
+
export { NavigationBar } from './NavigationBar';
|
|
23
|
+
export { Pagination } from './Pagination';
|
|
24
|
+
export { Popover } from './Popover';
|
|
25
|
+
export { Progress } from './Progress';
|
|
26
|
+
export { Radio, RadioGroup } from './Radio';
|
|
27
|
+
export { SegmentedControl } from './SegmentedControl';
|
|
28
|
+
export { Select } from './Select';
|
|
29
|
+
export { Sidebar } from './Sidebar';
|
|
30
|
+
export { Slider } from './Slider';
|
|
31
|
+
export { Snackbar } from './Snackbar';
|
|
8
32
|
export { Spinner } from './Spinner';
|
|
33
|
+
export { Switch } from './Switch';
|
|
34
|
+
export { Tabs } from './Tabs';
|
|
35
|
+
export { Tag } from './Tag';
|
|
36
|
+
export { Textarea } from './Textarea';
|
|
37
|
+
export { Tooltip } from './Tooltip';
|
|
38
|
+
export { TreeView } from './TreeView';
|
package/package.json
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@aereamart/design-system",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Aereamart shared React UI primitives (Badge, Button, Input, Select, Textarea, Modal, Spinner)",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "./dist/index.js",
|
|
7
|
-
"module": "./dist/index.js",
|
|
8
|
-
"types": "./dist/index.d.ts",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"types": "./dist/index.d.ts",
|
|
12
|
-
"import": "./dist/index.js"
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"files": [
|
|
16
|
-
"dist",
|
|
17
|
-
"src"
|
|
18
|
-
],
|
|
19
|
-
"scripts": {
|
|
20
|
-
"build": "tsc -p tsconfig.json",
|
|
21
|
-
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
22
|
-
"lint": "oxlint src"
|
|
23
|
-
},
|
|
24
|
-
"peerDependencies": {
|
|
25
|
-
"react": "^19.2.8",
|
|
26
|
-
"react-dom": "^19.2.8"
|
|
27
|
-
},
|
|
28
|
-
"dependencies": {
|
|
29
|
-
"lucide-react": "^1.30.0"
|
|
30
|
-
},
|
|
31
|
-
"devDependencies": {
|
|
32
|
-
"@types/react": "^19.2.17",
|
|
33
|
-
"@types/react-dom": "^19.2.3",
|
|
34
|
-
"oxlint": "^1.75.0",
|
|
35
|
-
"typescript": "~6.0.2"
|
|
36
|
-
},
|
|
37
|
-
"keywords": [
|
|
38
|
-
"ui",
|
|
39
|
-
"components",
|
|
40
|
-
"aereamart"
|
|
41
|
-
],
|
|
42
|
-
"license": "MIT"
|
|
43
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@aereamart/design-system",
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"description": "Aereamart shared React UI primitives (Badge, Button, Input, Select, Textarea, Modal, Spinner)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"src"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc -p tsconfig.json",
|
|
21
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
22
|
+
"lint": "oxlint src"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"react": "^19.2.8",
|
|
26
|
+
"react-dom": "^19.2.8"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"lucide-react": "^1.30.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/react": "^19.2.17",
|
|
33
|
+
"@types/react-dom": "^19.2.3",
|
|
34
|
+
"oxlint": "^1.75.0",
|
|
35
|
+
"typescript": "~6.0.2"
|
|
36
|
+
},
|
|
37
|
+
"keywords": [
|
|
38
|
+
"ui",
|
|
39
|
+
"components",
|
|
40
|
+
"aereamart"
|
|
41
|
+
],
|
|
42
|
+
"license": "MIT"
|
|
43
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { ChevronDown } from 'lucide-react';
|
|
3
|
+
import { cn } from './cn';
|
|
4
|
+
|
|
5
|
+
export interface AccordionItem {
|
|
6
|
+
title: string;
|
|
7
|
+
content: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface AccordionProps {
|
|
11
|
+
items: AccordionItem[];
|
|
12
|
+
defaultOpen?: number | null;
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function Accordion({ items, defaultOpen = null, className }: AccordionProps) {
|
|
17
|
+
const [open, setOpen] = useState<number | null>(defaultOpen);
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<div
|
|
21
|
+
className={cn(
|
|
22
|
+
'divide-y divide-slate-200 overflow-hidden rounded-xl border border-slate-200 bg-white',
|
|
23
|
+
className
|
|
24
|
+
)}
|
|
25
|
+
>
|
|
26
|
+
{items.map((item, i) => {
|
|
27
|
+
const isOpen = open === i;
|
|
28
|
+
const uid = `accordion-${i}`;
|
|
29
|
+
return (
|
|
30
|
+
<div key={uid}>
|
|
31
|
+
<button
|
|
32
|
+
type="button"
|
|
33
|
+
aria-expanded={isOpen}
|
|
34
|
+
aria-controls={`${uid}-panel`}
|
|
35
|
+
onClick={() => setOpen(isOpen ? null : i)}
|
|
36
|
+
className="flex w-full items-center justify-between gap-4 px-5 py-4 text-left text-sm font-semibold text-slate-900 transition-colors hover:bg-slate-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-lime-500/40"
|
|
37
|
+
>
|
|
38
|
+
{item.title}
|
|
39
|
+
<ChevronDown
|
|
40
|
+
aria-hidden="true"
|
|
41
|
+
className={cn('h-4 w-4 shrink-0 text-slate-400 transition-transform', isOpen && 'rotate-180')}
|
|
42
|
+
/>
|
|
43
|
+
</button>
|
|
44
|
+
{isOpen && (
|
|
45
|
+
<div
|
|
46
|
+
id={`${uid}-panel`}
|
|
47
|
+
role="region"
|
|
48
|
+
className="border-t border-slate-100 px-5 py-4 text-sm leading-relaxed text-slate-600"
|
|
49
|
+
>
|
|
50
|
+
{item.content}
|
|
51
|
+
</div>
|
|
52
|
+
)}
|
|
53
|
+
</div>
|
|
54
|
+
);
|
|
55
|
+
})}
|
|
56
|
+
</div>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Info, AlertTriangle, CheckCircle2, XCircle, X } from 'lucide-react';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { cn } from './cn';
|
|
4
|
+
|
|
5
|
+
type AlertTone = 'info' | 'primary' | 'accent' | 'danger' | 'neutral';
|
|
6
|
+
|
|
7
|
+
export interface AlertBannerProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
8
|
+
tone?: AlertTone;
|
|
9
|
+
title?: string;
|
|
10
|
+
dismissible?: boolean;
|
|
11
|
+
onDismiss?: () => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const toneRecord: Record<AlertTone, { wrap: string; icon: React.ReactNode; label: string }> = {
|
|
15
|
+
info: { wrap: 'border-sky-300 bg-sky-50 text-sky-900', icon: <Info className="h-4 w-4" />, label: 'Info' },
|
|
16
|
+
primary: { wrap: 'border-lime-300 bg-lime-50 text-lime-900', icon: <CheckCircle2 className="h-4 w-4" />, label: 'Success' },
|
|
17
|
+
accent: { wrap: 'border-purple-300 bg-purple-50 text-purple-900', icon: <AlertTriangle className="h-4 w-4" />, label: 'Warning' },
|
|
18
|
+
danger: { wrap: 'border-red-300 bg-red-50 text-red-900', icon: <XCircle className="h-4 w-4" />, label: 'Error' },
|
|
19
|
+
neutral: { wrap: 'border-slate-300 bg-slate-50 text-slate-800', icon: <Info className="h-4 w-4" />, label: 'Notice' },
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export function AlertBanner({
|
|
23
|
+
tone = 'primary',
|
|
24
|
+
title,
|
|
25
|
+
dismissible = false,
|
|
26
|
+
onDismiss,
|
|
27
|
+
className,
|
|
28
|
+
children,
|
|
29
|
+
...props
|
|
30
|
+
}: AlertBannerProps) {
|
|
31
|
+
const [hidden, setHidden] = useState(false);
|
|
32
|
+
if (hidden) return null;
|
|
33
|
+
const t = toneRecord[tone];
|
|
34
|
+
return (
|
|
35
|
+
<div
|
|
36
|
+
role="alert"
|
|
37
|
+
className={cn('flex items-start gap-3 rounded-lg border px-4 py-3 text-sm', t.wrap, className)}
|
|
38
|
+
{...props}
|
|
39
|
+
>
|
|
40
|
+
<span className="mt-0.5 shrink-0" aria-label={t.label}>
|
|
41
|
+
{t.icon}
|
|
42
|
+
</span>
|
|
43
|
+
<div className="min-w-0 flex-1">
|
|
44
|
+
{title && <p className="font-bold">{title}</p>}
|
|
45
|
+
<div className={cn(title && 'mt-0.5 text-sm opacity-90')}>{children}</div>
|
|
46
|
+
</div>
|
|
47
|
+
{dismissible && (
|
|
48
|
+
<button
|
|
49
|
+
type="button"
|
|
50
|
+
aria-label="Dismiss"
|
|
51
|
+
onClick={() => {
|
|
52
|
+
setHidden(true);
|
|
53
|
+
onDismiss?.();
|
|
54
|
+
}}
|
|
55
|
+
className="-mr-1 -mt-1 shrink-0 rounded-full p-1 hover:bg-black/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-current"
|
|
56
|
+
>
|
|
57
|
+
<X aria-hidden="true" className="h-4 w-4" />
|
|
58
|
+
</button>
|
|
59
|
+
)}
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
}
|
package/src/AppBar.tsx
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { cn } from './cn';
|
|
2
|
+
|
|
3
|
+
export interface AppBarProps extends React.HTMLAttributes<HTMLElement> {
|
|
4
|
+
title: string;
|
|
5
|
+
subtitle?: string;
|
|
6
|
+
leading?: React.ReactNode;
|
|
7
|
+
actions?: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function AppBar({ title, subtitle, leading, actions, className, ...props }: AppBarProps) {
|
|
11
|
+
return (
|
|
12
|
+
<header
|
|
13
|
+
className={cn(
|
|
14
|
+
'flex items-center justify-between gap-4 border-b border-slate-200 bg-white px-6 py-4',
|
|
15
|
+
className
|
|
16
|
+
)}
|
|
17
|
+
{...props}
|
|
18
|
+
>
|
|
19
|
+
<div className="flex min-w-0 items-center gap-3">
|
|
20
|
+
{leading}
|
|
21
|
+
<div className="min-w-0">
|
|
22
|
+
<h1 className="truncate text-lg font-bold text-slate-900">{title}</h1>
|
|
23
|
+
{subtitle && <p className="truncate text-sm text-slate-500">{subtitle}</p>}
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
{actions && <div className="flex shrink-0 items-center gap-2">{actions}</div>}
|
|
27
|
+
</header>
|
|
28
|
+
);
|
|
29
|
+
}
|