@aereamart/design-system 0.3.0 → 0.3.2

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/src/Card.tsx CHANGED
@@ -1,39 +1,39 @@
1
- import { cn } from './cn';
2
-
3
- export interface CardProps extends React.HTMLAttributes<HTMLDivElement> {
4
- title?: string;
5
- description?: string;
6
- footer?: React.ReactNode;
7
- hoverable?: boolean;
8
- }
9
-
10
- export function Card({
11
- title,
12
- description,
13
- footer,
14
- hoverable = false,
15
- className,
16
- children,
17
- ...props
18
- }: CardProps) {
19
- return (
20
- <div
21
- className={cn(
22
- 'rounded-xl border border-slate-200 bg-white',
23
- hoverable &&
24
- 'transition-all hover:-translate-y-0.5 hover:border-lime-300 hover:shadow-md',
25
- className
26
- )}
27
- {...props}
28
- >
29
- {(title || description) && (
30
- <div className="border-b border-slate-100 px-5 py-4">
31
- {title && <h3 className="text-base font-bold text-slate-900">{title}</h3>}
32
- {description && <p className="mt-0.5 text-sm text-slate-500">{description}</p>}
33
- </div>
34
- )}
35
- <div className="px-5 py-4">{children}</div>
36
- {footer && <div className="border-t border-slate-100 px-5 py-3">{footer}</div>}
37
- </div>
38
- );
1
+ import { cn } from './cn';
2
+
3
+ export interface CardProps extends React.HTMLAttributes<HTMLDivElement> {
4
+ title?: string;
5
+ description?: string;
6
+ footer?: React.ReactNode;
7
+ hoverable?: boolean;
8
+ }
9
+
10
+ export function Card({
11
+ title,
12
+ description,
13
+ footer,
14
+ hoverable = false,
15
+ className,
16
+ children,
17
+ ...props
18
+ }: CardProps) {
19
+ return (
20
+ <div
21
+ className={cn(
22
+ 'rounded-xl border border-slate-200 bg-white',
23
+ hoverable &&
24
+ 'transition-all hover:-translate-y-0.5 hover:border-lime-300 hover:shadow-md',
25
+ className
26
+ )}
27
+ {...props}
28
+ >
29
+ {(title || description) && (
30
+ <div className="border-b border-slate-100 px-5 py-4">
31
+ {title && <h3 className="text-base font-bold text-slate-900">{title}</h3>}
32
+ {description && <p className="mt-0.5 text-sm text-slate-500">{description}</p>}
33
+ </div>
34
+ )}
35
+ <div className="px-5 py-4">{children}</div>
36
+ {footer && <div className="border-t border-slate-100 px-5 py-3">{footer}</div>}
37
+ </div>
38
+ );
39
39
  }
package/src/DataTable.tsx CHANGED
@@ -1,64 +1,64 @@
1
- import { useId } from 'react';
2
- import { cn } from './cn';
3
-
4
- export interface Column<T> {
5
- key: string;
6
- label: string;
7
- render?: (row: T) => React.ReactNode;
8
- className?: string;
9
- }
10
-
11
- export interface DataTableProps<T> {
12
- columns: Column<T>[];
13
- rows: T[];
14
- rowKey: (row: T) => string;
15
- caption?: string;
16
- emptyText?: string;
17
- className?: string;
18
- }
19
-
20
- export function DataTable<T>({
21
- columns,
22
- rows,
23
- rowKey,
24
- caption,
25
- emptyText = 'No rows to show.',
26
- className,
27
- }: DataTableProps<T>) {
28
- const captionId = useId();
29
-
30
- return (
31
- <div className={cn('overflow-x-auto rounded-xl border border-slate-200 bg-white', className)}>
32
- <table className="w-full min-w-[480px] border-collapse text-left text-sm">
33
- {caption && <caption className="sr-only" id={captionId}>{caption}</caption>}
34
- <thead>
35
- <tr className="border-b border-slate-200 bg-slate-50 text-xs uppercase tracking-wider text-slate-500">
36
- {columns.map(col => (
37
- <th key={col.key} scope="col" className="px-4 py-3 font-semibold">
38
- {col.label}
39
- </th>
40
- ))}
41
- </tr>
42
- </thead>
43
- <tbody className="divide-y divide-slate-100">
44
- {rows.map(row => (
45
- <tr key={rowKey(row)} className="transition-colors hover:bg-slate-50">
46
- {columns.map(col => (
47
- <td key={col.key} className={cn('px-4 py-3 align-middle text-slate-700', col.className)}>
48
- {col.render ? col.render(row) : String((row as Record<string, unknown>)[col.key] ?? '')}
49
- </td>
50
- ))}
51
- </tr>
52
- ))}
53
- {rows.length === 0 && (
54
- <tr>
55
- <td colSpan={columns.length} className="px-4 py-10 text-center text-sm text-slate-400">
56
- {emptyText}
57
- </td>
58
- </tr>
59
- )}
60
- </tbody>
61
- </table>
62
- </div>
63
- );
1
+ import { useId } from 'react';
2
+ import { cn } from './cn';
3
+
4
+ export interface Column<T> {
5
+ key: string;
6
+ label: string;
7
+ render?: (row: T) => React.ReactNode;
8
+ className?: string;
9
+ }
10
+
11
+ export interface DataTableProps<T> {
12
+ columns: Column<T>[];
13
+ rows: T[];
14
+ rowKey: (row: T) => string;
15
+ caption?: string;
16
+ emptyText?: string;
17
+ className?: string;
18
+ }
19
+
20
+ export function DataTable<T>({
21
+ columns,
22
+ rows,
23
+ rowKey,
24
+ caption,
25
+ emptyText = 'No rows to show.',
26
+ className,
27
+ }: DataTableProps<T>) {
28
+ const captionId = useId();
29
+
30
+ return (
31
+ <div className={cn('overflow-x-auto rounded-xl border border-slate-200 bg-white', className)}>
32
+ <table className="w-full min-w-[480px] border-collapse text-left text-sm">
33
+ {caption && <caption className="sr-only" id={captionId}>{caption}</caption>}
34
+ <thead>
35
+ <tr className="border-b border-slate-200 bg-slate-50 text-xs uppercase tracking-wider text-slate-500">
36
+ {columns.map(col => (
37
+ <th key={col.key} scope="col" className="px-4 py-3 font-semibold">
38
+ {col.label}
39
+ </th>
40
+ ))}
41
+ </tr>
42
+ </thead>
43
+ <tbody className="divide-y divide-slate-100">
44
+ {rows.map(row => (
45
+ <tr key={rowKey(row)} className="transition-colors hover:bg-slate-50">
46
+ {columns.map(col => (
47
+ <td key={col.key} className={cn('px-4 py-3 align-middle text-slate-700', col.className)}>
48
+ {col.render ? col.render(row) : String((row as Record<string, unknown>)[col.key] ?? '')}
49
+ </td>
50
+ ))}
51
+ </tr>
52
+ ))}
53
+ {rows.length === 0 && (
54
+ <tr>
55
+ <td colSpan={columns.length} className="px-4 py-10 text-center text-sm text-slate-400">
56
+ {emptyText}
57
+ </td>
58
+ </tr>
59
+ )}
60
+ </tbody>
61
+ </table>
62
+ </div>
63
+ );
64
64
  }
@@ -1,44 +1,44 @@
1
- import { useId } from 'react';
2
- import { CalendarDays } from 'lucide-react';
3
- import { cn } from './cn';
4
-
5
- export interface DatePickerProps
6
- extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type'> {
7
- label?: string;
8
- error?: string;
9
- }
10
-
11
- export function DatePicker({ label, error, id, className, ...props }: DatePickerProps) {
12
- const autoId = useId();
13
- const inputId = id ?? autoId;
14
-
15
- return (
16
- <div>
17
- {label && (
18
- <label htmlFor={inputId} className="mb-1 block text-sm font-medium text-slate-700">
19
- {label}
20
- </label>
21
- )}
22
- <div className="relative">
23
- <CalendarDays
24
- aria-hidden="true"
25
- className="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"
26
- />
27
- <input
28
- id={inputId}
29
- type="date"
30
- className={cn(
31
- 'w-full rounded-lg border bg-white py-2.5 pl-9 pr-4 text-sm text-slate-700 shadow-xs',
32
- 'focus:outline-none focus:ring-2 focus:ring-lime-500/40 disabled:cursor-not-allowed disabled:bg-slate-100 disabled:text-slate-400',
33
- error
34
- ? 'border-red-400 focus:border-red-500'
35
- : 'border-slate-300 hover:border-slate-400',
36
- className
37
- )}
38
- {...props}
39
- />
40
- </div>
41
- {error && <p className="mt-1 text-xs text-red-600">{error}</p>}
42
- </div>
43
- );
1
+ import { useId } from 'react';
2
+ import { CalendarDays } from 'lucide-react';
3
+ import { cn } from './cn';
4
+
5
+ export interface DatePickerProps
6
+ extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type'> {
7
+ label?: string;
8
+ error?: string;
9
+ }
10
+
11
+ export function DatePicker({ label, error, id, className, ...props }: DatePickerProps) {
12
+ const autoId = useId();
13
+ const inputId = id ?? autoId;
14
+
15
+ return (
16
+ <div>
17
+ {label && (
18
+ <label htmlFor={inputId} className="mb-1 block text-sm font-medium text-slate-700">
19
+ {label}
20
+ </label>
21
+ )}
22
+ <div className="relative">
23
+ <CalendarDays
24
+ aria-hidden="true"
25
+ className="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"
26
+ />
27
+ <input
28
+ id={inputId}
29
+ type="date"
30
+ className={cn(
31
+ 'w-full rounded-lg border bg-white py-2.5 pl-9 pr-4 text-sm text-slate-700 shadow-xs',
32
+ 'focus:outline-none focus:ring-2 focus:ring-lime-500/40 disabled:cursor-not-allowed disabled:bg-slate-100 disabled:text-slate-400',
33
+ error
34
+ ? 'border-red-400 focus:border-red-500'
35
+ : 'border-slate-300 hover:border-slate-400',
36
+ className
37
+ )}
38
+ {...props}
39
+ />
40
+ </div>
41
+ {error && <p className="mt-1 text-xs text-red-600">{error}</p>}
42
+ </div>
43
+ );
44
44
  }
package/src/Drawer.tsx CHANGED
@@ -1,71 +1,71 @@
1
- import { useEffect } from 'react';
2
- import { createPortal } from 'react-dom';
3
- import { X } from 'lucide-react';
4
- import { cn } from './cn';
5
-
6
- export interface DrawerProps {
7
- open: boolean;
8
- onClose: () => void;
9
- title?: string;
10
- side?: 'right' | 'left';
11
- children?: React.ReactNode;
12
- footer?: React.ReactNode;
13
- className?: string;
14
- }
15
-
16
- export function Drawer({
17
- open,
18
- onClose,
19
- title,
20
- side = 'right',
21
- children,
22
- footer,
23
- className,
24
- }: DrawerProps) {
25
- useEffect(() => {
26
- if (!open) return;
27
- const onKey = (e: KeyboardEvent) => {
28
- if (e.key === 'Escape') onClose();
29
- };
30
- document.body.style.overflow = 'hidden';
31
- document.addEventListener('keydown', onKey);
32
- return () => {
33
- document.body.style.overflow = '';
34
- document.removeEventListener('keydown', onKey);
35
- };
36
- }, [open, onClose]);
37
-
38
- if (!open) return null;
39
-
40
- return createPortal(
41
- <div className="fixed inset-0 z-50">
42
- <div className="absolute inset-0 bg-black/50" onClick={onClose} aria-hidden="true" />
43
- <section
44
- role="dialog"
45
- aria-modal="true"
46
- aria-label={title}
47
- className={cn(
48
- 'absolute inset-y-0 flex w-full max-w-sm flex-col bg-white shadow-xl',
49
- side === 'right' ? 'right-0' : 'left-0',
50
- className
51
- )}
52
- >
53
- {title && (
54
- <div className="flex items-center justify-between border-b border-slate-100 px-6 py-4">
55
- <h2 className="text-lg font-bold text-slate-900">{title}</h2>
56
- <button
57
- onClick={onClose}
58
- className="rounded-lg p-1 text-slate-400 hover:bg-slate-100"
59
- aria-label="Close"
60
- >
61
- <X className="h-5 w-5" />
62
- </button>
63
- </div>
64
- )}
65
- <div className="flex-1 overflow-y-auto px-6 py-4">{children}</div>
66
- {footer && <div className="border-t border-slate-100 px-6 py-4">{footer}</div>}
67
- </section>
68
- </div>,
69
- document.body
70
- );
1
+ import { useEffect } from 'react';
2
+ import { createPortal } from 'react-dom';
3
+ import { X } from 'lucide-react';
4
+ import { cn } from './cn';
5
+
6
+ export interface DrawerProps {
7
+ open: boolean;
8
+ onClose: () => void;
9
+ title?: string;
10
+ side?: 'right' | 'left';
11
+ children?: React.ReactNode;
12
+ footer?: React.ReactNode;
13
+ className?: string;
14
+ }
15
+
16
+ export function Drawer({
17
+ open,
18
+ onClose,
19
+ title,
20
+ side = 'right',
21
+ children,
22
+ footer,
23
+ className,
24
+ }: DrawerProps) {
25
+ useEffect(() => {
26
+ if (!open) return;
27
+ const onKey = (e: KeyboardEvent) => {
28
+ if (e.key === 'Escape') onClose();
29
+ };
30
+ document.body.style.overflow = 'hidden';
31
+ document.addEventListener('keydown', onKey);
32
+ return () => {
33
+ document.body.style.overflow = '';
34
+ document.removeEventListener('keydown', onKey);
35
+ };
36
+ }, [open, onClose]);
37
+
38
+ if (!open) return null;
39
+
40
+ return createPortal(
41
+ <div className="fixed inset-0 z-50">
42
+ <div className="absolute inset-0 bg-black/50" onClick={onClose} aria-hidden="true" />
43
+ <section
44
+ role="dialog"
45
+ aria-modal="true"
46
+ aria-label={title}
47
+ className={cn(
48
+ 'absolute inset-y-0 flex w-full max-w-sm flex-col bg-white shadow-xl',
49
+ side === 'right' ? 'right-0' : 'left-0',
50
+ className
51
+ )}
52
+ >
53
+ {title && (
54
+ <div className="flex items-center justify-between border-b border-slate-100 px-6 py-4">
55
+ <h2 className="text-lg font-bold text-slate-900">{title}</h2>
56
+ <button
57
+ onClick={onClose}
58
+ className="rounded-lg p-1 text-slate-400 hover:bg-slate-100"
59
+ aria-label="Close"
60
+ >
61
+ <X className="h-5 w-5" />
62
+ </button>
63
+ </div>
64
+ )}
65
+ <div className="flex-1 overflow-y-auto px-6 py-4">{children}</div>
66
+ {footer && <div className="border-t border-slate-100 px-6 py-4">{footer}</div>}
67
+ </section>
68
+ </div>,
69
+ document.body
70
+ );
71
71
  }
@@ -1,37 +1,37 @@
1
- import { Inbox } from 'lucide-react';
2
- import { cn } from './cn';
3
-
4
- export interface EmptyStateProps extends React.HTMLAttributes<HTMLDivElement> {
5
- title: string;
6
- description?: string;
7
- icon?: React.ReactNode;
8
- action?: React.ReactNode;
9
- }
10
-
11
- export function EmptyState({
12
- title,
13
- description,
14
- icon,
15
- action,
16
- className,
17
- ...props
18
- }: EmptyStateProps) {
19
- return (
20
- <div
21
- className={cn(
22
- 'flex flex-col items-center justify-center rounded-xl border-2 border-dashed border-slate-200 bg-white px-8 py-12 text-center',
23
- className
24
- )}
25
- {...props}
26
- >
27
- <div className="mb-3 rounded-full bg-lime-50 p-3 text-lime-600">
28
- {icon ?? <Inbox aria-hidden="true" className="h-8 w-8" />}
29
- </div>
30
- <h3 className="text-base font-bold text-slate-900">{title}</h3>
31
- {description && (
32
- <p className="mt-1 max-w-sm text-sm text-slate-500">{description}</p>
33
- )}
34
- {action && <div className="mt-5">{action}</div>}
35
- </div>
36
- );
1
+ import { Inbox } from 'lucide-react';
2
+ import { cn } from './cn';
3
+
4
+ export interface EmptyStateProps extends React.HTMLAttributes<HTMLDivElement> {
5
+ title: string;
6
+ description?: string;
7
+ icon?: React.ReactNode;
8
+ action?: React.ReactNode;
9
+ }
10
+
11
+ export function EmptyState({
12
+ title,
13
+ description,
14
+ icon,
15
+ action,
16
+ className,
17
+ ...props
18
+ }: EmptyStateProps) {
19
+ return (
20
+ <div
21
+ className={cn(
22
+ 'flex flex-col items-center justify-center rounded-xl border-2 border-dashed border-slate-200 bg-white px-8 py-12 text-center',
23
+ className
24
+ )}
25
+ {...props}
26
+ >
27
+ <div className="mb-3 rounded-full bg-lime-50 p-3 text-lime-600">
28
+ {icon ?? <Inbox aria-hidden="true" className="h-8 w-8" />}
29
+ </div>
30
+ <h3 className="text-base font-bold text-slate-900">{title}</h3>
31
+ {description && (
32
+ <p className="mt-1 max-w-sm text-sm text-slate-500">{description}</p>
33
+ )}
34
+ {action && <div className="mt-5">{action}</div>}
35
+ </div>
36
+ );
37
37
  }
package/src/Input.tsx CHANGED
@@ -1,30 +1,30 @@
1
- import { cn } from './cn';
2
-
3
- export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
4
- label?: string;
5
- error?: string;
6
- }
7
-
8
- export function Input({ label, error, className, id, ...props }: InputProps) {
9
- return (
10
- <div className="w-full">
11
- {label && (
12
- <label htmlFor={id} className="mb-1 block text-sm font-medium text-slate-700">
13
- {label}
14
- </label>
15
- )}
16
- <input
17
- id={id}
18
- className={cn(
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
- error
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
- className
24
- )}
25
- {...props}
26
- />
27
- {error && <p className="mt-1 text-xs text-red-600">{error}</p>}
28
- </div>
29
- );
30
- }
1
+ import { cn } from './cn';
2
+
3
+ export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
4
+ label?: string;
5
+ error?: string;
6
+ }
7
+
8
+ export function Input({ label, error, className, id, ...props }: InputProps) {
9
+ return (
10
+ <div className="w-full">
11
+ {label && (
12
+ <label htmlFor={id} className="mb-1 block text-sm font-medium text-slate-700">
13
+ {label}
14
+ </label>
15
+ )}
16
+ <input
17
+ id={id}
18
+ className={cn(
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
+ error
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
+ className
24
+ )}
25
+ {...props}
26
+ />
27
+ {error && <p className="mt-1 text-xs text-red-600">{error}</p>}
28
+ </div>
29
+ );
30
+ }