@aereamart/design-system 0.2.0 → 0.3.0
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 +1 -1
- 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 +4 -4
- package/src/BottomSheet.tsx +60 -0
- package/src/Breadcrumb.tsx +48 -0
- package/src/Button.tsx +3 -3
- 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 +4 -4
- package/src/Link.tsx +22 -0
- package/src/Menu.tsx +73 -0
- package/src/Modal.tsx +3 -3
- 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 +4 -4
- package/src/Sidebar.tsx +73 -0
- package/src/Slider.tsx +33 -0
- package/src/Snackbar.tsx +72 -0
- package/src/Switch.tsx +40 -0
- package/src/Tabs.tsx +77 -0
- package/src/Tag.tsx +29 -0
- package/src/Textarea.tsx +4 -4
- package/src/Tooltip.tsx +25 -0
- package/src/TreeView.tsx +105 -0
- package/src/index.ts +38 -8
package/src/Textarea.tsx
CHANGED
|
@@ -9,17 +9,17 @@ export function Textarea({ label, error, className, id, ...props }: TextareaProp
|
|
|
9
9
|
return (
|
|
10
10
|
<div className="w-full">
|
|
11
11
|
{label && (
|
|
12
|
-
<label htmlFor={id} className="mb-1 block text-sm font-medium text-
|
|
12
|
+
<label htmlFor={id} className="mb-1 block text-sm font-medium text-slate-700">
|
|
13
13
|
{label}
|
|
14
14
|
</label>
|
|
15
15
|
)}
|
|
16
16
|
<textarea
|
|
17
17
|
id={id}
|
|
18
18
|
className={cn(
|
|
19
|
-
'w-full rounded-lg border bg-white px-4 py-2.5 text-sm text-
|
|
19
|
+
'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',
|
|
20
20
|
error
|
|
21
|
-
? 'border-red-
|
|
22
|
-
: 'border-
|
|
21
|
+
? 'border-red-600 focus:border-red-600 focus:ring-red-500/30'
|
|
22
|
+
: 'border-slate-500 focus:border-lime-600 focus:ring-lime-500/30',
|
|
23
23
|
className
|
|
24
24
|
)}
|
|
25
25
|
{...props}
|
package/src/Tooltip.tsx
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { cn } from './cn';
|
|
2
|
+
|
|
3
|
+
export interface TooltipProps {
|
|
4
|
+
content: React.ReactNode;
|
|
5
|
+
side?: 'top' | 'bottom';
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function Tooltip({ content, side = 'top', children, className }: TooltipProps) {
|
|
11
|
+
return (
|
|
12
|
+
<span className={cn('group relative inline-flex', className)}>
|
|
13
|
+
{children}
|
|
14
|
+
<span
|
|
15
|
+
role="tooltip"
|
|
16
|
+
className={cn(
|
|
17
|
+
'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',
|
|
18
|
+
side === 'top' ? 'bottom-full mb-2' : 'top-full mt-2'
|
|
19
|
+
)}
|
|
20
|
+
>
|
|
21
|
+
{content}
|
|
22
|
+
</span>
|
|
23
|
+
</span>
|
|
24
|
+
);
|
|
25
|
+
}
|
package/src/TreeView.tsx
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { useId, useState } from 'react';
|
|
2
|
+
import { ChevronRight } from 'lucide-react';
|
|
3
|
+
import { cn } from './cn';
|
|
4
|
+
|
|
5
|
+
export interface TreeNode {
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
children?: TreeNode[];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface TreeViewProps {
|
|
12
|
+
nodes: TreeNode[];
|
|
13
|
+
defaultExpanded?: string[];
|
|
14
|
+
defaultAllExpanded?: boolean;
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function Node({
|
|
19
|
+
node,
|
|
20
|
+
depth,
|
|
21
|
+
expanded,
|
|
22
|
+
onToggle,
|
|
23
|
+
}: {
|
|
24
|
+
node: TreeNode;
|
|
25
|
+
depth: number;
|
|
26
|
+
expanded: Set<string>;
|
|
27
|
+
onToggle: (id: string) => void;
|
|
28
|
+
}) {
|
|
29
|
+
const hasChildren = !!node.children?.length;
|
|
30
|
+
const isOpen = expanded.has(node.id);
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<li>
|
|
34
|
+
<div className={cn('flex items-center gap-1.5 rounded-lg py-1.5 pr-2')}>
|
|
35
|
+
<button
|
|
36
|
+
type="button"
|
|
37
|
+
aria-expanded={hasChildren ? isOpen : undefined}
|
|
38
|
+
onClick={() => hasChildren && onToggle(node.id)}
|
|
39
|
+
className={cn(
|
|
40
|
+
'inline-flex w-full items-center gap-1.5 rounded-lg py-1.5 pr-2 text-left text-sm font-medium transition-colors',
|
|
41
|
+
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-lime-500/40',
|
|
42
|
+
'hover:bg-slate-100'
|
|
43
|
+
)}
|
|
44
|
+
style={{ paddingLeft: `${8 + depth * 24}px` }}
|
|
45
|
+
>
|
|
46
|
+
{hasChildren ? (
|
|
47
|
+
<ChevronRight
|
|
48
|
+
className={cn('h-4 w-4 shrink-0 text-slate-400 transition-transform', isOpen && 'rotate-90')}
|
|
49
|
+
/>
|
|
50
|
+
) : (
|
|
51
|
+
<span className="ml-4 h-4 w-4 shrink-0" aria-hidden="true" />
|
|
52
|
+
)}
|
|
53
|
+
<span className={cn(isOpen && 'font-semibold text-slate-900')}>{node.label}</span>
|
|
54
|
+
</button>
|
|
55
|
+
</div>
|
|
56
|
+
{hasChildren && isOpen && (
|
|
57
|
+
<ul role="group">
|
|
58
|
+
{node.children!.map(child => (
|
|
59
|
+
<Node key={child.id} node={child} depth={depth + 1} expanded={expanded} onToggle={onToggle} />
|
|
60
|
+
))}
|
|
61
|
+
</ul>
|
|
62
|
+
)}
|
|
63
|
+
</li>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function TreeView({ nodes, defaultExpanded = [], defaultAllExpanded = false, className }: TreeViewProps) {
|
|
68
|
+
const [expanded, setExpanded] = useState<Set<string>>(() => {
|
|
69
|
+
if (defaultAllExpanded) {
|
|
70
|
+
const all = new Set<string>();
|
|
71
|
+
const walk = (list: TreeNode[]) => list.forEach(n => {
|
|
72
|
+
all.add(n.id);
|
|
73
|
+
if (n.children) walk(n.children);
|
|
74
|
+
});
|
|
75
|
+
walk(nodes);
|
|
76
|
+
return all;
|
|
77
|
+
}
|
|
78
|
+
return new Set(defaultExpanded);
|
|
79
|
+
});
|
|
80
|
+
const labelId = useId();
|
|
81
|
+
|
|
82
|
+
const toggle = (id: string) =>
|
|
83
|
+
setExpanded(prev => {
|
|
84
|
+
const next = new Set(prev);
|
|
85
|
+
if (next.has(id)) next.delete(id);
|
|
86
|
+
else next.add(id);
|
|
87
|
+
return next;
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<ul
|
|
92
|
+
role="tree"
|
|
93
|
+
aria-label="Tree"
|
|
94
|
+
aria-labelledby={labelId}
|
|
95
|
+
className={cn('space-y-0.5', className)}
|
|
96
|
+
>
|
|
97
|
+
<span id={labelId} className="sr-only">
|
|
98
|
+
Tree view
|
|
99
|
+
</span>
|
|
100
|
+
{nodes.map(node => (
|
|
101
|
+
<Node key={node.id} node={node} depth={0} expanded={expanded} onToggle={toggle} />
|
|
102
|
+
))}
|
|
103
|
+
</ul>
|
|
104
|
+
);
|
|
105
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,38 @@
|
|
|
1
|
-
export { cn } from './cn';
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
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';
|
|
6
|
+
export { Badge, type BadgeProps } from './Badge';
|
|
7
|
+
export { BottomSheet, type BottomSheetProps } from './BottomSheet';
|
|
8
|
+
export { Breadcrumb, type BreadcrumbProps, type Crumb } from './Breadcrumb';
|
|
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';
|
|
18
|
+
export { Input, type InputProps } from './Input';
|
|
19
|
+
export { Link, type LinkProps } from './Link';
|
|
20
|
+
export { Menu, type MenuProps, type MenuItem } from './Menu';
|
|
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';
|
|
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';
|