@lp-labs/ui-components 0.0.0-stage → 1.0.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/CHANGELOG.md +41 -0
- package/LICENSE +21 -0
- package/README.md +256 -2
- package/dist/cjs/components/Accordion.d.ts +78 -0
- package/dist/cjs/components/Accordion.js +78 -0
- package/dist/cjs/components/AdvancedComponents.d.ts +353 -0
- package/dist/cjs/components/AdvancedComponents.js +353 -0
- package/dist/cjs/components/Alert.d.ts +102 -0
- package/dist/cjs/components/Alert.js +102 -0
- package/dist/cjs/components/Avatar.d.ts +89 -0
- package/dist/cjs/components/Avatar.js +89 -0
- package/dist/cjs/components/Badge.d.ts +57 -0
- package/dist/cjs/components/Badge.js +57 -0
- package/dist/cjs/components/Breadcrumb.d.ts +50 -0
- package/dist/cjs/components/Breadcrumb.js +50 -0
- package/dist/cjs/components/Button.d.ts +77 -0
- package/dist/cjs/components/Button.js +77 -0
- package/dist/cjs/components/ButtonVariants.d.ts +261 -0
- package/dist/cjs/components/ButtonVariants.js +261 -0
- package/dist/cjs/components/Card.d.ts +56 -0
- package/dist/cjs/components/Card.js +56 -0
- package/dist/cjs/components/CardVariants.d.ts +267 -0
- package/dist/cjs/components/CardVariants.js +267 -0
- package/dist/cjs/components/Checkbox.d.ts +50 -0
- package/dist/cjs/components/Checkbox.js +50 -0
- package/dist/cjs/components/Chip.d.ts +104 -0
- package/dist/cjs/components/Chip.js +104 -0
- package/dist/cjs/components/DataDisplayComponents.d.ts +275 -0
- package/dist/cjs/components/DataDisplayComponents.js +275 -0
- package/dist/cjs/components/Divider.d.ts +77 -0
- package/dist/cjs/components/Divider.js +77 -0
- package/dist/cjs/components/Drawer.d.ts +142 -0
- package/dist/cjs/components/Drawer.js +142 -0
- package/dist/cjs/components/Dropdown.d.ts +139 -0
- package/dist/cjs/components/Dropdown.js +139 -0
- package/dist/cjs/components/Form.d.ts +41 -0
- package/dist/cjs/components/Form.js +41 -0
- package/dist/cjs/components/FormGroup.d.ts +58 -0
- package/dist/cjs/components/FormGroup.js +58 -0
- package/dist/cjs/components/FormInputVariants.d.ts +298 -0
- package/dist/cjs/components/FormInputVariants.js +298 -0
- package/dist/cjs/components/Image.d.ts +106 -0
- package/dist/cjs/components/Image.js +106 -0
- package/dist/cjs/components/Input.d.ts +65 -0
- package/dist/cjs/components/Input.js +65 -0
- package/dist/cjs/components/LayoutComponents.d.ts +258 -0
- package/dist/cjs/components/LayoutComponents.js +258 -0
- package/dist/cjs/components/Link.d.ts +71 -0
- package/dist/cjs/components/Link.js +71 -0
- package/dist/cjs/components/LoadingFeedbackComponents.d.ts +230 -0
- package/dist/cjs/components/LoadingFeedbackComponents.js +230 -0
- package/dist/cjs/components/Menu.d.ts +167 -0
- package/dist/cjs/components/Menu.js +167 -0
- package/dist/cjs/components/Modal.d.ts +145 -0
- package/dist/cjs/components/Modal.js +145 -0
- package/dist/cjs/components/ModalTypes.d.ts +288 -0
- package/dist/cjs/components/ModalTypes.js +288 -0
- package/dist/cjs/components/Navbar.d.ts +181 -0
- package/dist/cjs/components/Navbar.js +181 -0
- package/dist/cjs/components/NavigationComponents.d.ts +276 -0
- package/dist/cjs/components/NavigationComponents.js +276 -0
- package/dist/cjs/components/Pagination.d.ts +94 -0
- package/dist/cjs/components/Pagination.js +94 -0
- package/dist/cjs/components/Popover.d.ts +108 -0
- package/dist/cjs/components/Popover.js +108 -0
- package/dist/cjs/components/Progress.d.ts +68 -0
- package/dist/cjs/components/Progress.js +68 -0
- package/dist/cjs/components/Radio.d.ts +93 -0
- package/dist/cjs/components/Radio.js +93 -0
- package/dist/cjs/components/Rating.d.ts +82 -0
- package/dist/cjs/components/Rating.js +82 -0
- package/dist/cjs/components/Select.d.ts +74 -0
- package/dist/cjs/components/Select.js +74 -0
- package/dist/cjs/components/Sidebar.d.ts +174 -0
- package/dist/cjs/components/Sidebar.js +174 -0
- package/dist/cjs/components/Skeleton.d.ts +57 -0
- package/dist/cjs/components/Skeleton.js +57 -0
- package/dist/cjs/components/Slider.d.ts +64 -0
- package/dist/cjs/components/Slider.js +64 -0
- package/dist/cjs/components/Spinner.d.ts +70 -0
- package/dist/cjs/components/Spinner.js +70 -0
- package/dist/cjs/components/Stack.d.ts +75 -0
- package/dist/cjs/components/Stack.js +75 -0
- package/dist/cjs/components/Stepper.d.ts +150 -0
- package/dist/cjs/components/Stepper.js +150 -0
- package/dist/cjs/components/Table.d.ts +173 -0
- package/dist/cjs/components/Table.js +173 -0
- package/dist/cjs/components/Tabs.d.ts +104 -0
- package/dist/cjs/components/Tabs.js +104 -0
- package/dist/cjs/components/Tag.d.ts +74 -0
- package/dist/cjs/components/Tag.js +74 -0
- package/dist/cjs/components/Textarea.d.ts +75 -0
- package/dist/cjs/components/Textarea.js +75 -0
- package/dist/cjs/components/Timeline.d.ts +124 -0
- package/dist/cjs/components/Timeline.js +124 -0
- package/dist/cjs/components/Toast.d.ts +155 -0
- package/dist/cjs/components/Toast.js +155 -0
- package/dist/cjs/components/Toggle.d.ts +75 -0
- package/dist/cjs/components/Toggle.js +75 -0
- package/dist/cjs/components/Tooltip.d.ts +80 -0
- package/dist/cjs/components/Tooltip.js +80 -0
- package/dist/cjs/components/TypographyComponents.d.ts +265 -0
- package/dist/cjs/components/TypographyComponents.js +265 -0
- package/dist/cjs/components/UtilityComponents.d.ts +345 -0
- package/dist/cjs/components/UtilityComponents.js +345 -0
- package/dist/cjs/components/Video.d.ts +82 -0
- package/dist/cjs/components/Video.js +82 -0
- package/dist/cjs/components/index.d.ts +311 -0
- package/dist/cjs/components/index.js +311 -0
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.js +5 -0
- package/dist/cjs/styles/main.css +493 -0
- package/dist/cjs/theme/ThemeProvider.d.ts +185 -0
- package/dist/cjs/theme/ThemeProvider.js +185 -0
- package/dist/cjs/theme/index.d.ts +2 -0
- package/dist/cjs/theme/index.js +2 -0
- package/dist/cjs/utilities/classNames.d.ts +200 -0
- package/dist/cjs/utilities/classNames.js +200 -0
- package/dist/cjs/utilities/index.d.ts +3 -0
- package/dist/cjs/utilities/index.js +3 -0
- package/dist/cjs/utilities/styles.d.ts +94 -0
- package/dist/cjs/utilities/styles.js +94 -0
- package/dist/esm/components/Accordion.d.ts +78 -0
- package/dist/esm/components/Accordion.js +78 -0
- package/dist/esm/components/AdvancedComponents.d.ts +353 -0
- package/dist/esm/components/AdvancedComponents.js +353 -0
- package/dist/esm/components/Alert.d.ts +102 -0
- package/dist/esm/components/Alert.js +102 -0
- package/dist/esm/components/Avatar.d.ts +89 -0
- package/dist/esm/components/Avatar.js +89 -0
- package/dist/esm/components/Badge.d.ts +57 -0
- package/dist/esm/components/Badge.js +57 -0
- package/dist/esm/components/Breadcrumb.d.ts +50 -0
- package/dist/esm/components/Breadcrumb.js +50 -0
- package/dist/esm/components/Button.d.ts +77 -0
- package/dist/esm/components/Button.js +77 -0
- package/dist/esm/components/ButtonVariants.d.ts +261 -0
- package/dist/esm/components/ButtonVariants.js +261 -0
- package/dist/esm/components/Card.d.ts +56 -0
- package/dist/esm/components/Card.js +56 -0
- package/dist/esm/components/CardVariants.d.ts +267 -0
- package/dist/esm/components/CardVariants.js +267 -0
- package/dist/esm/components/Checkbox.d.ts +50 -0
- package/dist/esm/components/Checkbox.js +50 -0
- package/dist/esm/components/Chip.d.ts +104 -0
- package/dist/esm/components/Chip.js +104 -0
- package/dist/esm/components/DataDisplayComponents.d.ts +275 -0
- package/dist/esm/components/DataDisplayComponents.js +275 -0
- package/dist/esm/components/Divider.d.ts +77 -0
- package/dist/esm/components/Divider.js +77 -0
- package/dist/esm/components/Drawer.d.ts +142 -0
- package/dist/esm/components/Drawer.js +142 -0
- package/dist/esm/components/Dropdown.d.ts +139 -0
- package/dist/esm/components/Dropdown.js +139 -0
- package/dist/esm/components/Form.d.ts +41 -0
- package/dist/esm/components/Form.js +41 -0
- package/dist/esm/components/FormGroup.d.ts +58 -0
- package/dist/esm/components/FormGroup.js +58 -0
- package/dist/esm/components/FormInputVariants.d.ts +298 -0
- package/dist/esm/components/FormInputVariants.js +298 -0
- package/dist/esm/components/Image.d.ts +106 -0
- package/dist/esm/components/Image.js +106 -0
- package/dist/esm/components/Input.d.ts +65 -0
- package/dist/esm/components/Input.js +65 -0
- package/dist/esm/components/LayoutComponents.d.ts +258 -0
- package/dist/esm/components/LayoutComponents.js +258 -0
- package/dist/esm/components/Link.d.ts +71 -0
- package/dist/esm/components/Link.js +71 -0
- package/dist/esm/components/LoadingFeedbackComponents.d.ts +230 -0
- package/dist/esm/components/LoadingFeedbackComponents.js +230 -0
- package/dist/esm/components/Menu.d.ts +167 -0
- package/dist/esm/components/Menu.js +167 -0
- package/dist/esm/components/Modal.d.ts +145 -0
- package/dist/esm/components/Modal.js +145 -0
- package/dist/esm/components/ModalTypes.d.ts +288 -0
- package/dist/esm/components/ModalTypes.js +288 -0
- package/dist/esm/components/Navbar.d.ts +181 -0
- package/dist/esm/components/Navbar.js +181 -0
- package/dist/esm/components/NavigationComponents.d.ts +276 -0
- package/dist/esm/components/NavigationComponents.js +276 -0
- package/dist/esm/components/Pagination.d.ts +94 -0
- package/dist/esm/components/Pagination.js +94 -0
- package/dist/esm/components/Popover.d.ts +108 -0
- package/dist/esm/components/Popover.js +108 -0
- package/dist/esm/components/Progress.d.ts +68 -0
- package/dist/esm/components/Progress.js +68 -0
- package/dist/esm/components/Radio.d.ts +93 -0
- package/dist/esm/components/Radio.js +93 -0
- package/dist/esm/components/Rating.d.ts +82 -0
- package/dist/esm/components/Rating.js +82 -0
- package/dist/esm/components/Select.d.ts +74 -0
- package/dist/esm/components/Select.js +74 -0
- package/dist/esm/components/Sidebar.d.ts +174 -0
- package/dist/esm/components/Sidebar.js +174 -0
- package/dist/esm/components/Skeleton.d.ts +57 -0
- package/dist/esm/components/Skeleton.js +57 -0
- package/dist/esm/components/Slider.d.ts +64 -0
- package/dist/esm/components/Slider.js +64 -0
- package/dist/esm/components/Spinner.d.ts +70 -0
- package/dist/esm/components/Spinner.js +70 -0
- package/dist/esm/components/Stack.d.ts +75 -0
- package/dist/esm/components/Stack.js +75 -0
- package/dist/esm/components/Stepper.d.ts +150 -0
- package/dist/esm/components/Stepper.js +150 -0
- package/dist/esm/components/Table.d.ts +173 -0
- package/dist/esm/components/Table.js +173 -0
- package/dist/esm/components/Tabs.d.ts +104 -0
- package/dist/esm/components/Tabs.js +104 -0
- package/dist/esm/components/Tag.d.ts +74 -0
- package/dist/esm/components/Tag.js +74 -0
- package/dist/esm/components/Textarea.d.ts +75 -0
- package/dist/esm/components/Textarea.js +75 -0
- package/dist/esm/components/Timeline.d.ts +124 -0
- package/dist/esm/components/Timeline.js +124 -0
- package/dist/esm/components/Toast.d.ts +155 -0
- package/dist/esm/components/Toast.js +155 -0
- package/dist/esm/components/Toggle.d.ts +75 -0
- package/dist/esm/components/Toggle.js +75 -0
- package/dist/esm/components/Tooltip.d.ts +80 -0
- package/dist/esm/components/Tooltip.js +80 -0
- package/dist/esm/components/TypographyComponents.d.ts +265 -0
- package/dist/esm/components/TypographyComponents.js +265 -0
- package/dist/esm/components/UtilityComponents.d.ts +345 -0
- package/dist/esm/components/UtilityComponents.js +345 -0
- package/dist/esm/components/Video.d.ts +82 -0
- package/dist/esm/components/Video.js +82 -0
- package/dist/esm/components/index.d.ts +311 -0
- package/dist/esm/components/index.js +311 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/styles/main.css +493 -0
- package/dist/esm/theme/ThemeProvider.d.ts +185 -0
- package/dist/esm/theme/ThemeProvider.js +185 -0
- package/dist/esm/theme/index.d.ts +2 -0
- package/dist/esm/theme/index.js +2 -0
- package/dist/esm/utilities/classNames.d.ts +200 -0
- package/dist/esm/utilities/classNames.js +200 -0
- package/dist/esm/utilities/index.d.ts +3 -0
- package/dist/esm/utilities/index.js +3 -0
- package/dist/esm/utilities/styles.d.ts +94 -0
- package/dist/esm/utilities/styles.js +94 -0
- package/dist/styles/main.css +493 -0
- package/package.json +124 -6
- package/src/styles/main.css +493 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
export interface DataDisplayProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface TableColumn {
|
|
8
|
+
key: string;
|
|
9
|
+
header: string;
|
|
10
|
+
width?: string;
|
|
11
|
+
sortable?: boolean;
|
|
12
|
+
filterable?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface TableData {
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const TableBasic: React.FC<
|
|
20
|
+
DataDisplayProps & {
|
|
21
|
+
columns: TableColumn[];
|
|
22
|
+
data: TableData[];
|
|
23
|
+
striped?: boolean;
|
|
24
|
+
bordered?: boolean;
|
|
25
|
+
}
|
|
26
|
+
> = ({ columns, data, striped = true, bordered = true, className = '', ...props }) => {
|
|
27
|
+
return (
|
|
28
|
+
<div className={`overflow-x-auto ${className}`} {...props}>
|
|
29
|
+
<table className={`w-full text-sm ${bordered ? 'border border-gray-300' : ''}`}>
|
|
30
|
+
<thead className="bg-gray-100 border-b border-gray-300">
|
|
31
|
+
<tr>
|
|
32
|
+
{columns.map((col) => (
|
|
33
|
+
<th key={col.key} className={`px-4 py-2 text-left font-semibold`} style={{ width: col.width }}>
|
|
34
|
+
{col.header}
|
|
35
|
+
</th>
|
|
36
|
+
))}
|
|
37
|
+
</tr>
|
|
38
|
+
</thead>
|
|
39
|
+
<tbody>
|
|
40
|
+
{data.map((row, idx) => (
|
|
41
|
+
<tr
|
|
42
|
+
key={idx}
|
|
43
|
+
className={`border-b border-gray-200 ${striped && idx % 2 === 0 ? 'bg-gray-50' : ''} hover:bg-gray-100`}
|
|
44
|
+
>
|
|
45
|
+
{columns.map((col) => (
|
|
46
|
+
<td key={col.key} className="px-4 py-2">
|
|
47
|
+
{row[col.key]}
|
|
48
|
+
</td>
|
|
49
|
+
))}
|
|
50
|
+
</tr>
|
|
51
|
+
))}
|
|
52
|
+
</tbody>
|
|
53
|
+
</table>
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const TableSortable: React.FC<
|
|
59
|
+
DataDisplayProps & {
|
|
60
|
+
columns: TableColumn[];
|
|
61
|
+
data: TableData[];
|
|
62
|
+
onSort?: (key: string, direction: 'asc' | 'desc') => void;
|
|
63
|
+
}
|
|
64
|
+
> = ({ columns, data, onSort, className = '', ...props }) => {
|
|
65
|
+
const [sortColumn, setSortColumn] = React.useState<string | null>(null);
|
|
66
|
+
const [sortDirection, setSortDirection] = React.useState<'asc' | 'desc'>('asc');
|
|
67
|
+
|
|
68
|
+
const handleSort = (key: string) => {
|
|
69
|
+
const newDirection = sortColumn === key && sortDirection === 'asc' ? 'desc' : 'asc';
|
|
70
|
+
setSortColumn(key);
|
|
71
|
+
setSortDirection(newDirection);
|
|
72
|
+
onSort?.(key, newDirection);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<div className={`overflow-x-auto ${className}`} {...props}>
|
|
77
|
+
<table className="w-full text-sm border border-gray-300">
|
|
78
|
+
<thead className="bg-gray-100 border-b border-gray-300">
|
|
79
|
+
<tr>
|
|
80
|
+
{columns.map((col) => (
|
|
81
|
+
<th
|
|
82
|
+
key={col.key}
|
|
83
|
+
className={`px-4 py-2 text-left font-semibold ${col.sortable ? 'cursor-pointer hover:bg-gray-200' : ''}`}
|
|
84
|
+
onClick={() => col.sortable && handleSort(col.key)}
|
|
85
|
+
style={{ width: col.width }}
|
|
86
|
+
>
|
|
87
|
+
<div className="flex items-center gap-2">
|
|
88
|
+
{col.header}
|
|
89
|
+
{col.sortable && sortColumn === col.key && (
|
|
90
|
+
<span>{sortDirection === 'asc' ? '↑' : '↓'}</span>
|
|
91
|
+
)}
|
|
92
|
+
</div>
|
|
93
|
+
</th>
|
|
94
|
+
))}
|
|
95
|
+
</tr>
|
|
96
|
+
</thead>
|
|
97
|
+
<tbody>
|
|
98
|
+
{data.map((row, idx) => (
|
|
99
|
+
<tr key={idx} className="border-b border-gray-200 hover:bg-gray-100">
|
|
100
|
+
{columns.map((col) => (
|
|
101
|
+
<td key={col.key} className="px-4 py-2">
|
|
102
|
+
{row[col.key]}
|
|
103
|
+
</td>
|
|
104
|
+
))}
|
|
105
|
+
</tr>
|
|
106
|
+
))}
|
|
107
|
+
</tbody>
|
|
108
|
+
</table>
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export const TableFilterable: React.FC<
|
|
114
|
+
DataDisplayProps & {
|
|
115
|
+
columns: TableColumn[];
|
|
116
|
+
data: TableData[];
|
|
117
|
+
onFilter?: (filters: Record<string, string>) => void;
|
|
118
|
+
}
|
|
119
|
+
> = ({ columns, data, onFilter, className = '', ...props }) => {
|
|
120
|
+
const [filters, setFilters] = React.useState<Record<string, string>>({});
|
|
121
|
+
|
|
122
|
+
const handleFilterChange = (key: string, value: string) => {
|
|
123
|
+
const newFilters = { ...filters, [key]: value };
|
|
124
|
+
setFilters(newFilters);
|
|
125
|
+
onFilter?.(newFilters);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const filteredData = data.filter((row) =>
|
|
129
|
+
Object.entries(filters).every(([key, value]) =>
|
|
130
|
+
!value || String(row[key]).toLowerCase().includes(value.toLowerCase()),
|
|
131
|
+
),
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
return (
|
|
135
|
+
<div className={`${className}`} {...props}>
|
|
136
|
+
<div className="mb-4 p-4 bg-gray-50 rounded-lg border border-gray-200">
|
|
137
|
+
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
|
|
138
|
+
{columns
|
|
139
|
+
.filter((col) => col.filterable)
|
|
140
|
+
.map((col) => (
|
|
141
|
+
<input
|
|
142
|
+
key={col.key}
|
|
143
|
+
type="text"
|
|
144
|
+
placeholder={`Filter ${col.header}...`}
|
|
145
|
+
value={filters[col.key] || ''}
|
|
146
|
+
onChange={(e) => handleFilterChange(col.key, e.target.value)}
|
|
147
|
+
className="px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:border-blue-500"
|
|
148
|
+
/>
|
|
149
|
+
))}
|
|
150
|
+
</div>
|
|
151
|
+
</div>
|
|
152
|
+
<div className="overflow-x-auto">
|
|
153
|
+
<table className="w-full text-sm border border-gray-300">
|
|
154
|
+
<thead className="bg-gray-100 border-b border-gray-300">
|
|
155
|
+
<tr>
|
|
156
|
+
{columns.map((col) => (
|
|
157
|
+
<th key={col.key} className="px-4 py-2 text-left font-semibold" style={{ width: col.width }}>
|
|
158
|
+
{col.header}
|
|
159
|
+
</th>
|
|
160
|
+
))}
|
|
161
|
+
</tr>
|
|
162
|
+
</thead>
|
|
163
|
+
<tbody>
|
|
164
|
+
{filteredData.map((row, idx) => (
|
|
165
|
+
<tr key={idx} className="border-b border-gray-200 hover:bg-gray-100">
|
|
166
|
+
{columns.map((col) => (
|
|
167
|
+
<td key={col.key} className="px-4 py-2">
|
|
168
|
+
{row[col.key]}
|
|
169
|
+
</td>
|
|
170
|
+
))}
|
|
171
|
+
</tr>
|
|
172
|
+
))}
|
|
173
|
+
</tbody>
|
|
174
|
+
</table>
|
|
175
|
+
</div>
|
|
176
|
+
{filteredData.length === 0 && <p className="text-center py-4 text-gray-500">No results found</p>}
|
|
177
|
+
</div>
|
|
178
|
+
);
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
export const TableExpandable: React.FC<
|
|
182
|
+
DataDisplayProps & {
|
|
183
|
+
columns: TableColumn[];
|
|
184
|
+
data: TableData[];
|
|
185
|
+
renderDetails?: (row: TableData) => React.ReactNode;
|
|
186
|
+
}
|
|
187
|
+
> = ({ columns, data, renderDetails, className = '', ...props }) => {
|
|
188
|
+
const [expandedRows, setExpandedRows] = React.useState<Set<number>>(new Set());
|
|
189
|
+
|
|
190
|
+
const toggleExpanded = (idx: number) => {
|
|
191
|
+
const newExpanded = new Set(expandedRows);
|
|
192
|
+
if (newExpanded.has(idx)) {
|
|
193
|
+
newExpanded.delete(idx);
|
|
194
|
+
} else {
|
|
195
|
+
newExpanded.add(idx);
|
|
196
|
+
}
|
|
197
|
+
setExpandedRows(newExpanded);
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
return (
|
|
201
|
+
<div className={`overflow-x-auto ${className}`} {...props}>
|
|
202
|
+
<table className="w-full text-sm border border-gray-300">
|
|
203
|
+
<thead className="bg-gray-100 border-b border-gray-300">
|
|
204
|
+
<tr>
|
|
205
|
+
<th className="px-4 py-2 w-10"></th>
|
|
206
|
+
{columns.map((col) => (
|
|
207
|
+
<th key={col.key} className="px-4 py-2 text-left font-semibold" style={{ width: col.width }}>
|
|
208
|
+
{col.header}
|
|
209
|
+
</th>
|
|
210
|
+
))}
|
|
211
|
+
</tr>
|
|
212
|
+
</thead>
|
|
213
|
+
<tbody>
|
|
214
|
+
{data.map((row, idx) => (
|
|
215
|
+
<React.Fragment key={idx}>
|
|
216
|
+
<tr className="border-b border-gray-200 hover:bg-gray-100">
|
|
217
|
+
<td className="px-4 py-2">
|
|
218
|
+
<button onClick={() => toggleExpanded(idx)} className="text-lg">
|
|
219
|
+
{expandedRows.has(idx) ? '▼' : '▶'}
|
|
220
|
+
</button>
|
|
221
|
+
</td>
|
|
222
|
+
{columns.map((col) => (
|
|
223
|
+
<td key={col.key} className="px-4 py-2">
|
|
224
|
+
{row[col.key]}
|
|
225
|
+
</td>
|
|
226
|
+
))}
|
|
227
|
+
</tr>
|
|
228
|
+
{expandedRows.has(idx) && (
|
|
229
|
+
<tr className="bg-blue-50 border-b border-gray-200">
|
|
230
|
+
<td colSpan={columns.length + 1} className="px-4 py-4">
|
|
231
|
+
{renderDetails?.(row)}
|
|
232
|
+
</td>
|
|
233
|
+
</tr>
|
|
234
|
+
)}
|
|
235
|
+
</React.Fragment>
|
|
236
|
+
))}
|
|
237
|
+
</tbody>
|
|
238
|
+
</table>
|
|
239
|
+
</div>
|
|
240
|
+
);
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
export const TableCompact: React.FC<
|
|
244
|
+
DataDisplayProps & {
|
|
245
|
+
columns: TableColumn[];
|
|
246
|
+
data: TableData[];
|
|
247
|
+
}
|
|
248
|
+
> = ({ columns, data, className = '', ...props }) => {
|
|
249
|
+
return (
|
|
250
|
+
<div className={`overflow-x-auto ${className}`} {...props}>
|
|
251
|
+
<table className="w-full text-xs border border-gray-300">
|
|
252
|
+
<thead className="bg-gray-100 border-b border-gray-300">
|
|
253
|
+
<tr>
|
|
254
|
+
{columns.map((col) => (
|
|
255
|
+
<th key={col.key} className="px-2 py-1 text-left font-semibold" style={{ width: col.width }}>
|
|
256
|
+
{col.header}
|
|
257
|
+
</th>
|
|
258
|
+
))}
|
|
259
|
+
</tr>
|
|
260
|
+
</thead>
|
|
261
|
+
<tbody>
|
|
262
|
+
{data.map((row, idx) => (
|
|
263
|
+
<tr key={idx} className="border-b border-gray-200 hover:bg-gray-100">
|
|
264
|
+
{columns.map((col) => (
|
|
265
|
+
<td key={col.key} className="px-2 py-1">
|
|
266
|
+
{row[col.key]}
|
|
267
|
+
</td>
|
|
268
|
+
))}
|
|
269
|
+
</tr>
|
|
270
|
+
))}
|
|
271
|
+
</tbody>
|
|
272
|
+
</table>
|
|
273
|
+
</div>
|
|
274
|
+
);
|
|
275
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { cn } from '../utilities/classNames';
|
|
3
|
+
|
|
4
|
+
export interface DividerProps extends React.HTMLAttributes<HTMLHRElement> {
|
|
5
|
+
orientation?: 'horizontal' | 'vertical';
|
|
6
|
+
variant?: 'solid' | 'dashed' | 'dotted';
|
|
7
|
+
label?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const variantStyles = {
|
|
11
|
+
solid: 'border-solid',
|
|
12
|
+
dashed: 'border-dashed',
|
|
13
|
+
dotted: 'border-dotted',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const Divider = React.forwardRef<HTMLHRElement, DividerProps>(
|
|
17
|
+
(
|
|
18
|
+
{
|
|
19
|
+
orientation = 'horizontal',
|
|
20
|
+
variant = 'solid',
|
|
21
|
+
label,
|
|
22
|
+
className,
|
|
23
|
+
...props
|
|
24
|
+
},
|
|
25
|
+
ref,
|
|
26
|
+
) => {
|
|
27
|
+
if (orientation === 'vertical') {
|
|
28
|
+
return (
|
|
29
|
+
<hr
|
|
30
|
+
ref={ref}
|
|
31
|
+
className={cn(
|
|
32
|
+
'h-full w-0 border-l border-gray-300',
|
|
33
|
+
variantStyles[variant],
|
|
34
|
+
className,
|
|
35
|
+
)}
|
|
36
|
+
{...props}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (label) {
|
|
42
|
+
return (
|
|
43
|
+
<div className={cn('relative flex items-center my-4', className)}>
|
|
44
|
+
<hr
|
|
45
|
+
ref={ref}
|
|
46
|
+
className={cn(
|
|
47
|
+
'flex-grow border-t border-gray-300',
|
|
48
|
+
variantStyles[variant],
|
|
49
|
+
)}
|
|
50
|
+
{...props}
|
|
51
|
+
/>
|
|
52
|
+
<span className="px-2 text-sm text-gray-600 bg-white">{label}</span>
|
|
53
|
+
<hr
|
|
54
|
+
className={cn(
|
|
55
|
+
'flex-grow border-t border-gray-300',
|
|
56
|
+
variantStyles[variant],
|
|
57
|
+
)}
|
|
58
|
+
/>
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<hr
|
|
65
|
+
ref={ref}
|
|
66
|
+
className={cn(
|
|
67
|
+
'border-t border-gray-300 my-4',
|
|
68
|
+
variantStyles[variant],
|
|
69
|
+
className,
|
|
70
|
+
)}
|
|
71
|
+
{...props}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
},
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
Divider.displayName = 'Divider';
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { cn } from '../utilities/classNames';
|
|
3
|
+
|
|
4
|
+
export interface DividerProps extends React.HTMLAttributes<HTMLHRElement> {
|
|
5
|
+
orientation?: 'horizontal' | 'vertical';
|
|
6
|
+
variant?: 'solid' | 'dashed' | 'dotted';
|
|
7
|
+
label?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const variantStyles = {
|
|
11
|
+
solid: 'border-solid',
|
|
12
|
+
dashed: 'border-dashed',
|
|
13
|
+
dotted: 'border-dotted',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const Divider = React.forwardRef<HTMLHRElement, DividerProps>(
|
|
17
|
+
(
|
|
18
|
+
{
|
|
19
|
+
orientation = 'horizontal',
|
|
20
|
+
variant = 'solid',
|
|
21
|
+
label,
|
|
22
|
+
className,
|
|
23
|
+
...props
|
|
24
|
+
},
|
|
25
|
+
ref,
|
|
26
|
+
) => {
|
|
27
|
+
if (orientation === 'vertical') {
|
|
28
|
+
return (
|
|
29
|
+
<hr
|
|
30
|
+
ref={ref}
|
|
31
|
+
className={cn(
|
|
32
|
+
'h-full w-0 border-l border-gray-300',
|
|
33
|
+
variantStyles[variant],
|
|
34
|
+
className,
|
|
35
|
+
)}
|
|
36
|
+
{...props}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (label) {
|
|
42
|
+
return (
|
|
43
|
+
<div className={cn('relative flex items-center my-4', className)}>
|
|
44
|
+
<hr
|
|
45
|
+
ref={ref}
|
|
46
|
+
className={cn(
|
|
47
|
+
'flex-grow border-t border-gray-300',
|
|
48
|
+
variantStyles[variant],
|
|
49
|
+
)}
|
|
50
|
+
{...props}
|
|
51
|
+
/>
|
|
52
|
+
<span className="px-2 text-sm text-gray-600 bg-white">{label}</span>
|
|
53
|
+
<hr
|
|
54
|
+
className={cn(
|
|
55
|
+
'flex-grow border-t border-gray-300',
|
|
56
|
+
variantStyles[variant],
|
|
57
|
+
)}
|
|
58
|
+
/>
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<hr
|
|
65
|
+
ref={ref}
|
|
66
|
+
className={cn(
|
|
67
|
+
'border-t border-gray-300 my-4',
|
|
68
|
+
variantStyles[variant],
|
|
69
|
+
className,
|
|
70
|
+
)}
|
|
71
|
+
{...props}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
},
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
Divider.displayName = 'Divider';
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { cn } from '../utilities/classNames';
|
|
3
|
+
|
|
4
|
+
export interface DrawerProps {
|
|
5
|
+
isOpen: boolean;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
title?: string;
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
position?: 'left' | 'right' | 'top' | 'bottom';
|
|
10
|
+
width?: string;
|
|
11
|
+
height?: string;
|
|
12
|
+
closeButton?: boolean;
|
|
13
|
+
overlay?: boolean;
|
|
14
|
+
className?: string;
|
|
15
|
+
headerClassName?: string;
|
|
16
|
+
bodyClassName?: string;
|
|
17
|
+
footerSlot?: React.ReactNode;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const Drawer = React.forwardRef<HTMLDivElement, DrawerProps>(
|
|
21
|
+
(
|
|
22
|
+
{
|
|
23
|
+
isOpen,
|
|
24
|
+
onClose,
|
|
25
|
+
title,
|
|
26
|
+
children,
|
|
27
|
+
position = 'left',
|
|
28
|
+
width = 'w-96',
|
|
29
|
+
height = 'h-96',
|
|
30
|
+
closeButton = true,
|
|
31
|
+
overlay = true,
|
|
32
|
+
className,
|
|
33
|
+
headerClassName,
|
|
34
|
+
bodyClassName,
|
|
35
|
+
footerSlot,
|
|
36
|
+
},
|
|
37
|
+
ref
|
|
38
|
+
) => {
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (isOpen) {
|
|
41
|
+
document.body.style.overflow = 'hidden';
|
|
42
|
+
} else {
|
|
43
|
+
document.body.style.overflow = 'unset';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return () => {
|
|
47
|
+
document.body.style.overflow = 'unset';
|
|
48
|
+
};
|
|
49
|
+
}, [isOpen]);
|
|
50
|
+
|
|
51
|
+
const positionClasses = {
|
|
52
|
+
left: 'left-0 top-0 h-full',
|
|
53
|
+
right: 'right-0 top-0 h-full',
|
|
54
|
+
top: 'top-0 left-0 w-full',
|
|
55
|
+
bottom: 'bottom-0 left-0 w-full',
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const widthClasses = {
|
|
59
|
+
left: width,
|
|
60
|
+
right: width,
|
|
61
|
+
top: width !== 'w-96' ? width : 'w-full',
|
|
62
|
+
bottom: width !== 'w-96' ? width : 'w-full',
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const heightClasses = {
|
|
66
|
+
left: 'h-full',
|
|
67
|
+
right: 'h-full',
|
|
68
|
+
top: height,
|
|
69
|
+
bottom: height,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const slideInClasses = {
|
|
73
|
+
left: 'translate-x-0 -translate-x-full',
|
|
74
|
+
right: '-translate-x-0 translate-x-full',
|
|
75
|
+
top: 'translate-y-0 -translate-y-full',
|
|
76
|
+
bottom: 'translate-y-0 translate-y-full',
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
if (!isOpen) return null;
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<>
|
|
83
|
+
{/* Overlay */}
|
|
84
|
+
{overlay && (
|
|
85
|
+
<div
|
|
86
|
+
className="fixed inset-0 bg-black bg-opacity-50 z-40 animate-in fade-in duration-300"
|
|
87
|
+
onClick={onClose}
|
|
88
|
+
/>
|
|
89
|
+
)}
|
|
90
|
+
|
|
91
|
+
{/* Drawer */}
|
|
92
|
+
<div
|
|
93
|
+
ref={ref}
|
|
94
|
+
className={cn(
|
|
95
|
+
'fixed bg-white shadow-lg transition-transform duration-300 z-50',
|
|
96
|
+
'animate-in',
|
|
97
|
+
positionClasses[position],
|
|
98
|
+
widthClasses,
|
|
99
|
+
heightClasses,
|
|
100
|
+
isOpen ? slideInClasses[position].split(' ')[0] : slideInClasses[position].split(' ')[1],
|
|
101
|
+
className
|
|
102
|
+
)}
|
|
103
|
+
>
|
|
104
|
+
{/* Header */}
|
|
105
|
+
{(title || closeButton) && (
|
|
106
|
+
<div
|
|
107
|
+
className={cn(
|
|
108
|
+
'flex items-center justify-between p-4 border-b border-gray-200',
|
|
109
|
+
headerClassName
|
|
110
|
+
)}
|
|
111
|
+
>
|
|
112
|
+
{title && <h2 className="text-lg font-semibold text-gray-900">{title}</h2>}
|
|
113
|
+
{closeButton && (
|
|
114
|
+
<button
|
|
115
|
+
onClick={onClose}
|
|
116
|
+
className="text-gray-500 hover:text-gray-700 text-2xl font-bold leading-none"
|
|
117
|
+
aria-label="Close drawer"
|
|
118
|
+
>
|
|
119
|
+
×
|
|
120
|
+
</button>
|
|
121
|
+
)}
|
|
122
|
+
</div>
|
|
123
|
+
)}
|
|
124
|
+
|
|
125
|
+
{/* Body */}
|
|
126
|
+
<div className={cn('flex-1 overflow-y-auto p-4', bodyClassName)}>
|
|
127
|
+
{children}
|
|
128
|
+
</div>
|
|
129
|
+
|
|
130
|
+
{/* Footer */}
|
|
131
|
+
{footerSlot && (
|
|
132
|
+
<div className="border-t border-gray-200 p-4">
|
|
133
|
+
{footerSlot}
|
|
134
|
+
</div>
|
|
135
|
+
)}
|
|
136
|
+
</div>
|
|
137
|
+
</>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
Drawer.displayName = 'Drawer';
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { cn } from '../utilities/classNames';
|
|
3
|
+
|
|
4
|
+
export interface DrawerProps {
|
|
5
|
+
isOpen: boolean;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
title?: string;
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
position?: 'left' | 'right' | 'top' | 'bottom';
|
|
10
|
+
width?: string;
|
|
11
|
+
height?: string;
|
|
12
|
+
closeButton?: boolean;
|
|
13
|
+
overlay?: boolean;
|
|
14
|
+
className?: string;
|
|
15
|
+
headerClassName?: string;
|
|
16
|
+
bodyClassName?: string;
|
|
17
|
+
footerSlot?: React.ReactNode;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const Drawer = React.forwardRef<HTMLDivElement, DrawerProps>(
|
|
21
|
+
(
|
|
22
|
+
{
|
|
23
|
+
isOpen,
|
|
24
|
+
onClose,
|
|
25
|
+
title,
|
|
26
|
+
children,
|
|
27
|
+
position = 'left',
|
|
28
|
+
width = 'w-96',
|
|
29
|
+
height = 'h-96',
|
|
30
|
+
closeButton = true,
|
|
31
|
+
overlay = true,
|
|
32
|
+
className,
|
|
33
|
+
headerClassName,
|
|
34
|
+
bodyClassName,
|
|
35
|
+
footerSlot,
|
|
36
|
+
},
|
|
37
|
+
ref
|
|
38
|
+
) => {
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (isOpen) {
|
|
41
|
+
document.body.style.overflow = 'hidden';
|
|
42
|
+
} else {
|
|
43
|
+
document.body.style.overflow = 'unset';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return () => {
|
|
47
|
+
document.body.style.overflow = 'unset';
|
|
48
|
+
};
|
|
49
|
+
}, [isOpen]);
|
|
50
|
+
|
|
51
|
+
const positionClasses = {
|
|
52
|
+
left: 'left-0 top-0 h-full',
|
|
53
|
+
right: 'right-0 top-0 h-full',
|
|
54
|
+
top: 'top-0 left-0 w-full',
|
|
55
|
+
bottom: 'bottom-0 left-0 w-full',
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const widthClasses = {
|
|
59
|
+
left: width,
|
|
60
|
+
right: width,
|
|
61
|
+
top: width !== 'w-96' ? width : 'w-full',
|
|
62
|
+
bottom: width !== 'w-96' ? width : 'w-full',
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const heightClasses = {
|
|
66
|
+
left: 'h-full',
|
|
67
|
+
right: 'h-full',
|
|
68
|
+
top: height,
|
|
69
|
+
bottom: height,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const slideInClasses = {
|
|
73
|
+
left: 'translate-x-0 -translate-x-full',
|
|
74
|
+
right: '-translate-x-0 translate-x-full',
|
|
75
|
+
top: 'translate-y-0 -translate-y-full',
|
|
76
|
+
bottom: 'translate-y-0 translate-y-full',
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
if (!isOpen) return null;
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<>
|
|
83
|
+
{/* Overlay */}
|
|
84
|
+
{overlay && (
|
|
85
|
+
<div
|
|
86
|
+
className="fixed inset-0 bg-black bg-opacity-50 z-40 animate-in fade-in duration-300"
|
|
87
|
+
onClick={onClose}
|
|
88
|
+
/>
|
|
89
|
+
)}
|
|
90
|
+
|
|
91
|
+
{/* Drawer */}
|
|
92
|
+
<div
|
|
93
|
+
ref={ref}
|
|
94
|
+
className={cn(
|
|
95
|
+
'fixed bg-white shadow-lg transition-transform duration-300 z-50',
|
|
96
|
+
'animate-in',
|
|
97
|
+
positionClasses[position],
|
|
98
|
+
widthClasses,
|
|
99
|
+
heightClasses,
|
|
100
|
+
isOpen ? slideInClasses[position].split(' ')[0] : slideInClasses[position].split(' ')[1],
|
|
101
|
+
className
|
|
102
|
+
)}
|
|
103
|
+
>
|
|
104
|
+
{/* Header */}
|
|
105
|
+
{(title || closeButton) && (
|
|
106
|
+
<div
|
|
107
|
+
className={cn(
|
|
108
|
+
'flex items-center justify-between p-4 border-b border-gray-200',
|
|
109
|
+
headerClassName
|
|
110
|
+
)}
|
|
111
|
+
>
|
|
112
|
+
{title && <h2 className="text-lg font-semibold text-gray-900">{title}</h2>}
|
|
113
|
+
{closeButton && (
|
|
114
|
+
<button
|
|
115
|
+
onClick={onClose}
|
|
116
|
+
className="text-gray-500 hover:text-gray-700 text-2xl font-bold leading-none"
|
|
117
|
+
aria-label="Close drawer"
|
|
118
|
+
>
|
|
119
|
+
×
|
|
120
|
+
</button>
|
|
121
|
+
)}
|
|
122
|
+
</div>
|
|
123
|
+
)}
|
|
124
|
+
|
|
125
|
+
{/* Body */}
|
|
126
|
+
<div className={cn('flex-1 overflow-y-auto p-4', bodyClassName)}>
|
|
127
|
+
{children}
|
|
128
|
+
</div>
|
|
129
|
+
|
|
130
|
+
{/* Footer */}
|
|
131
|
+
{footerSlot && (
|
|
132
|
+
<div className="border-t border-gray-200 p-4">
|
|
133
|
+
{footerSlot}
|
|
134
|
+
</div>
|
|
135
|
+
)}
|
|
136
|
+
</div>
|
|
137
|
+
</>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
Drawer.displayName = 'Drawer';
|