@appdirect/design-system 0.0.10 → 0.0.12
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/README.md +85 -5
- package/dist/Buttons/ActionIcon.js +14 -0
- package/dist/Buttons/Button.js +66 -0
- package/dist/Buttons/CloseButton.js +48 -0
- package/dist/Buttons/index.js +13 -0
- package/dist/Combobox/AutocompleteClearable.js +36 -0
- package/dist/Combobox/Combobox.js +28 -0
- package/dist/Combobox/Multiselect.js +31 -0
- package/dist/Combobox/SearchableSelect.js +43 -0
- package/dist/Combobox/Select.js +72 -0
- package/dist/Combobox/index.js +10 -0
- package/dist/ComplexComponents/DashboardWidget/DashboardWidget.js +96 -0
- package/dist/ComplexComponents/DashboardWidget/index.js +1 -0
- package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.js +82 -0
- package/dist/ComplexComponents/DataTable/CustomBottomToolbar/utils.js +23 -0
- package/dist/ComplexComponents/DataTable/CustomToolbarAlertBannerContent/index.js +23 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/index.js +230 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterChip.js +30 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/DateRangeFilter.js +12 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/FilterRenderer.js +32 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/FilterSystem.js +90 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/MultiSelectFilter.js +43 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/SingleSelectFilter.js +30 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/index.js +39 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/types.js +9 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/ResultCount/index.js +31 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.js +42 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/SelectFilter.js +21 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/index.js +410 -0
- package/dist/ComplexComponents/DataTable/DataTable.js +405 -0
- package/dist/ComplexComponents/DataTable/ErrorOverlay/index.js +9 -0
- package/dist/ComplexComponents/DataTable/SortableHeaderCell/index.js +27 -0
- package/dist/ComplexComponents/DataTable/index.js +1 -0
- package/dist/ComplexComponents/DataTable/translations/en.js +99 -0
- package/dist/ComplexComponents/DataTable/translations/index.js +17 -0
- package/dist/ComplexComponents/KeyInsight/KeyInsights.js +176 -0
- package/dist/ComplexComponents/KeyInsight/index.js +1 -0
- package/dist/ComplexComponents/NameValue/NameValue.js +94 -0
- package/dist/ComplexComponents/NameValue/NameValueItem.js +59 -0
- package/dist/ComplexComponents/NameValue/index.js +2 -0
- package/dist/ComplexComponents/PageContentHeader/PageContentHeader.js +92 -0
- package/dist/ComplexComponents/PageContentHeader/PageContentHeader.tsx +24 -34
- package/dist/ComplexComponents/PageContentHeader/index.js +1 -0
- package/dist/ComplexComponents/PageContentHeader/index.ts +0 -2
- package/dist/ComplexComponents/Placeholder/Placeholder.js +51 -0
- package/dist/ComplexComponents/Placeholder/index.js +1 -0
- package/dist/ComplexComponents/Slat/Slat.js +53 -0
- package/dist/ComplexComponents/Slat/index.js +1 -0
- package/dist/ComplexComponents/Utilities/CopyButton.js +45 -0
- package/dist/ComplexComponents/Utilities/index.js +1 -0
- package/dist/DataDisplay/Alert.js +77 -0
- package/dist/DataDisplay/Avatar.js +157 -0
- package/dist/DataDisplay/Badge.js +78 -0
- package/dist/DataDisplay/Card.js +100 -0
- package/dist/DataDisplay/Chip.js +36 -0
- package/dist/DataDisplay/Indicator.js +59 -0
- package/dist/DataDisplay/List.js +60 -0
- package/dist/DataDisplay/Pill.js +81 -0
- package/dist/DataDisplay/Progress.js +42 -0
- package/dist/DataDisplay/Table.js +38 -0
- package/dist/DataDisplay/ThemeIcon.js +31 -0
- package/dist/DataDisplay/index.js +18 -0
- package/dist/Inputs/Checkbox.js +62 -0
- package/dist/Inputs/ColorInput.js +48 -0
- package/dist/Inputs/DropZone.js +12 -0
- package/dist/Inputs/FileInput.js +77 -0
- package/dist/Inputs/NumberInput.js +49 -0
- package/dist/Inputs/Radio.js +55 -0
- package/dist/Inputs/RadioGroup.js +59 -0
- package/dist/Inputs/SegmentedControl.js +50 -0
- package/dist/Inputs/Slider.js +50 -0
- package/dist/Inputs/SliderWithLabel.js +32 -0
- package/dist/Inputs/Switch.js +47 -0
- package/dist/Inputs/TextArea.js +50 -0
- package/dist/Inputs/TextInput.js +87 -0
- package/dist/Inputs/index.js +27 -0
- package/dist/Layout/Box.js +39 -0
- package/dist/Layout/Center.js +11 -0
- package/dist/Layout/Container.js +11 -0
- package/dist/Layout/Flex.js +12 -0
- package/dist/Layout/Grid.js +13 -0
- package/dist/Layout/Group.js +14 -0
- package/dist/Layout/Inline.js +46 -0
- package/dist/Layout/SimpleGrid.js +14 -0
- package/dist/Layout/Stack.js +45 -0
- package/dist/Layout/index.js +10 -0
- package/dist/Misc/Divider.js +8 -0
- package/dist/Misc/Paper.js +24 -0
- package/dist/Misc/index.js +10 -0
- package/dist/Navigation/Breadcrumb.js +60 -0
- package/dist/Navigation/NavLink.js +28 -0
- package/dist/Navigation/Stepper.js +8 -0
- package/dist/Navigation/Tabs.js +22 -0
- package/dist/Navigation/index.js +9 -0
- package/dist/Overlays/Drawer.js +63 -0
- package/dist/Overlays/Menu.js +85 -0
- package/dist/Overlays/Modal.js +61 -0
- package/dist/Overlays/Popover.js +118 -0
- package/dist/Overlays/Tooltip.js +71 -0
- package/dist/Overlays/index.js +12 -0
- package/dist/Shell/AppShellLayout.js +13 -0
- package/dist/Shell/HeaderBar.js +8 -0
- package/dist/Shell/SidebarNav.js +9 -0
- package/dist/Shell/SidebarNavLink.js +17 -0
- package/dist/Shell/SingleColumnLayout.js +11 -0
- package/dist/Shell/TertiaryColumnLayout.js +12 -0
- package/dist/Shell/index.js +6 -0
- package/dist/Typography/Code.js +8 -0
- package/dist/Typography/Kbd.js +58 -0
- package/dist/Typography/Text.js +8 -0
- package/dist/Typography/Title.js +11 -0
- package/dist/Typography/index.js +12 -0
- package/dist/config.js +202 -0
- package/dist/contracts/PageContentHeader.json +10 -5
- package/dist/contracts/index.json +1 -1
- package/dist/hooks/useTableHandlers.js +136 -0
- package/dist/hooks/useTableRenderFunctions.js +164 -0
- package/dist/hooks/useTableState.js +70 -0
- package/dist/index.js +162 -0
- package/dist/index.ts +3 -4
- package/dist/stories/Buttons/ActionIcon.stories.tsx +159 -0
- package/dist/stories/Buttons/Button.stories.tsx +145 -0
- package/dist/stories/Buttons/CloseButton.stories.tsx +121 -0
- package/dist/stories/Combobox/AutocompleteClearable.stories.tsx +554 -0
- package/dist/stories/Combobox/Combobox.stories.tsx +106 -0
- package/dist/stories/Combobox/Multiselect.stories.tsx +664 -0
- package/dist/stories/Combobox/SearchableSelect.stories.tsx +640 -0
- package/dist/stories/Combobox/Select.stories.tsx +311 -0
- package/dist/stories/ComplexComponents/DashboardWidget/DashboardWidget.stories.tsx +822 -0
- package/dist/stories/ComplexComponents/DataTable/DataTable.stories.tsx +502 -0
- package/dist/stories/ComplexComponents/KeyInsight/KeyInsights.stories.tsx +386 -0
- package/dist/stories/ComplexComponents/NameValue/NameValue.stories.tsx +405 -0
- package/dist/stories/ComplexComponents/PageContentHeader/PageContentHeader.stories.tsx +527 -0
- package/dist/stories/ComplexComponents/Placeholder/Placeholder.stories.tsx +76 -0
- package/dist/stories/ComplexComponents/Slat/Slat.stories.tsx +79 -0
- package/dist/stories/ComplexComponents/Utilities/CopyButton.stories.tsx +479 -0
- package/dist/stories/DataDisplay/Alert.stories.tsx +296 -0
- package/dist/stories/DataDisplay/Avatar.stories.tsx +251 -0
- package/dist/stories/DataDisplay/Badge.stories.tsx +176 -0
- package/dist/stories/DataDisplay/Card.stories.tsx +406 -0
- package/dist/stories/DataDisplay/Chip.stories.tsx +495 -0
- package/dist/stories/DataDisplay/Indicator.stories.tsx +571 -0
- package/dist/stories/DataDisplay/List.stories.tsx +376 -0
- package/dist/stories/DataDisplay/Pill.stories.tsx +506 -0
- package/dist/stories/DataDisplay/Progress.stories.tsx +352 -0
- package/dist/stories/DataDisplay/Table.stories.tsx +346 -0
- package/dist/stories/DataDisplay/ThemeIcon.stories.tsx +125 -0
- package/dist/stories/Inputs/Checkbox.stories.tsx +263 -0
- package/dist/stories/Inputs/ColorInput.stories.tsx +434 -0
- package/dist/stories/Inputs/DropZone.stories.tsx +401 -0
- package/dist/stories/Inputs/FileInput.stories.tsx +383 -0
- package/dist/stories/Inputs/NumberInput.stories.tsx +342 -0
- package/dist/stories/Inputs/Radio.stories.tsx +437 -0
- package/dist/stories/Inputs/RadioGroup.stories.tsx +526 -0
- package/dist/stories/Inputs/SegmentedControl.stories.tsx +60 -0
- package/dist/stories/Inputs/Slider.stories.tsx +22 -0
- package/dist/stories/Inputs/SliderWithLabel.stories.tsx +37 -0
- package/dist/stories/Inputs/Switch.stories.tsx +361 -0
- package/dist/stories/Inputs/TextArea.stories.tsx +355 -0
- package/dist/stories/Inputs/TextInput.stories.tsx +266 -0
- package/dist/stories/Misc/Divider.stories.tsx +581 -0
- package/dist/stories/Misc/Paper.stories.tsx +557 -0
- package/dist/stories/Navigation/Breadcrumb.stories.tsx +489 -0
- package/dist/stories/Navigation/NavLink.stories.tsx +601 -0
- package/dist/stories/Navigation/Stepper.stories.tsx +413 -0
- package/dist/stories/Navigation/Tabs.stories.tsx +528 -0
- package/dist/stories/Overlays/Drawer.stories.tsx +802 -0
- package/dist/stories/Overlays/Menu.stories.tsx +941 -0
- package/dist/stories/Overlays/Modal.stories.tsx +249 -0
- package/dist/stories/Overlays/Popover.stories.tsx +780 -0
- package/dist/stories/Overlays/Tooltip.stories.tsx +52 -0
- package/dist/stories/Typography/Code.stories.tsx +368 -0
- package/dist/stories/Typography/Kbd.stories.tsx +514 -0
- package/dist/stories/Typography/Text.stories.tsx +117 -0
- package/dist/stories/Typography/Title.stories.tsx +112 -0
- package/dist/stories/index.json +1435 -0
- package/dist/types.js +127 -0
- package/package.json +12 -7
- package/dist/ComplexComponents/PageContentHeader/DescriptionBlock.tsx +0 -65
|
@@ -0,0 +1,502 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/nextjs-vite';
|
|
2
|
+
import { useState, useMemo } from 'react';
|
|
3
|
+
import { Stack } from '@mantine/core';
|
|
4
|
+
import { Inline, DataTable, Title, Text, Button, Badge } from '@appdirect/design-system';
|
|
5
|
+
import {
|
|
6
|
+
MRT_ColumnDef as ColumnDef,
|
|
7
|
+
MRT_PaginationState as PaginationState,
|
|
8
|
+
MRT_RowSelectionState as RowSelectionState,
|
|
9
|
+
} from 'mantine-react-table-open';
|
|
10
|
+
|
|
11
|
+
// Sample data types
|
|
12
|
+
interface User {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
email: string;
|
|
16
|
+
status: 'Active' | 'Inactive' | 'Pending';
|
|
17
|
+
department: string;
|
|
18
|
+
role: string;
|
|
19
|
+
lastLogin: string;
|
|
20
|
+
joinDate: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface Product {
|
|
24
|
+
id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
category: string;
|
|
27
|
+
price: number;
|
|
28
|
+
stock: number;
|
|
29
|
+
status: 'In Stock' | 'Low Stock' | 'Out of Stock';
|
|
30
|
+
supplier: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Sample data generators
|
|
34
|
+
const generateUsers = (count: number): User[] => {
|
|
35
|
+
const departments = ['Engineering', 'Sales', 'Marketing', 'HR', 'Finance'];
|
|
36
|
+
const roles = ['Manager', 'Senior', 'Junior', 'Lead', 'Director'];
|
|
37
|
+
const statuses: User['status'][] = ['Active', 'Inactive', 'Pending'];
|
|
38
|
+
|
|
39
|
+
return Array.from({ length: count }, (_, i) => ({
|
|
40
|
+
id: `user-${i + 1}`,
|
|
41
|
+
name: `User ${i + 1}`,
|
|
42
|
+
email: `user${i + 1}@company.com`,
|
|
43
|
+
status: statuses[i % statuses.length],
|
|
44
|
+
department: departments[i % departments.length],
|
|
45
|
+
role: roles[i % roles.length],
|
|
46
|
+
lastLogin: new Date(Date.now() - Math.random() * 30 * 24 * 60 * 60 * 1000).toLocaleDateString(),
|
|
47
|
+
joinDate: new Date(Date.now() - Math.random() * 365 * 24 * 60 * 60 * 1000).toLocaleDateString(),
|
|
48
|
+
}));
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const generateProducts = (count: number): Product[] => {
|
|
52
|
+
const categories = ['Electronics', 'Clothing', 'Books', 'Home & Garden', 'Sports'];
|
|
53
|
+
const suppliers = ['Supplier A', 'Supplier B', 'Supplier C', 'Supplier D'];
|
|
54
|
+
const statuses: Product['status'][] = ['In Stock', 'Low Stock', 'Out of Stock'];
|
|
55
|
+
|
|
56
|
+
return Array.from({ length: count }, (_, i) => ({
|
|
57
|
+
id: `product-${i + 1}`,
|
|
58
|
+
name: `Product ${i + 1}`,
|
|
59
|
+
category: categories[i % categories.length],
|
|
60
|
+
price: Math.floor(Math.random() * 1000) + 10,
|
|
61
|
+
stock: Math.floor(Math.random() * 100),
|
|
62
|
+
status: statuses[i % statuses.length],
|
|
63
|
+
supplier: suppliers[i % suppliers.length],
|
|
64
|
+
}));
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const meta: Meta<typeof DataTable> = {
|
|
68
|
+
title: 'Design System/Complex Components/DataTable',
|
|
69
|
+
component: DataTable,
|
|
70
|
+
parameters: {
|
|
71
|
+
layout: 'padded',
|
|
72
|
+
docs: {
|
|
73
|
+
description: {
|
|
74
|
+
component: 'A powerful, feature-rich data table component built on top of Mantine React Table. Supports pagination, sorting, filtering, row selection, density controls, and more. Perfect for displaying large datasets with complex interaction requirements.',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
tags: ['autodocs', 'code-connected'],
|
|
79
|
+
argTypes: {
|
|
80
|
+
isLoading: {
|
|
81
|
+
control: 'boolean',
|
|
82
|
+
description: 'Whether the table is currently loading data',
|
|
83
|
+
},
|
|
84
|
+
isError: {
|
|
85
|
+
control: 'boolean',
|
|
86
|
+
description: 'Whether an error has occurred while loading data',
|
|
87
|
+
},
|
|
88
|
+
showFilters: {
|
|
89
|
+
control: 'boolean',
|
|
90
|
+
description: 'Whether to show the filters panel',
|
|
91
|
+
},
|
|
92
|
+
showSearch: {
|
|
93
|
+
control: 'boolean',
|
|
94
|
+
description: 'Whether to show the global search input',
|
|
95
|
+
},
|
|
96
|
+
showDensityToggle: {
|
|
97
|
+
control: 'boolean',
|
|
98
|
+
description: 'Whether to show the density toggle button',
|
|
99
|
+
},
|
|
100
|
+
showFullScreenToggle: {
|
|
101
|
+
control: 'boolean',
|
|
102
|
+
description: 'Whether to show the fullscreen toggle button',
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export default meta;
|
|
108
|
+
type Story = StoryObj<typeof meta>;
|
|
109
|
+
|
|
110
|
+
// User table columns
|
|
111
|
+
const userColumns: ColumnDef<User>[] = [
|
|
112
|
+
{
|
|
113
|
+
accessorKey: 'name',
|
|
114
|
+
header: 'Name',
|
|
115
|
+
size: 150,
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
accessorKey: 'email',
|
|
119
|
+
header: 'Email',
|
|
120
|
+
size: 200,
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
accessorKey: 'status',
|
|
124
|
+
header: 'Status',
|
|
125
|
+
size: 100,
|
|
126
|
+
Cell: ({ cell }) => {
|
|
127
|
+
const status = cell.getValue<string>();
|
|
128
|
+
const color = status === 'Active' ? 'success' : status === 'Pending' ? 'pending' : 'danger';
|
|
129
|
+
return <Badge color={color} size="sm">{status}</Badge>;
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
accessorKey: 'department',
|
|
134
|
+
header: 'Department',
|
|
135
|
+
size: 120,
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
accessorKey: 'role',
|
|
139
|
+
header: 'Role',
|
|
140
|
+
size: 100,
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
accessorKey: 'lastLogin',
|
|
144
|
+
header: 'Last Login',
|
|
145
|
+
size: 120,
|
|
146
|
+
},
|
|
147
|
+
];
|
|
148
|
+
|
|
149
|
+
// Product table columns
|
|
150
|
+
const productColumns: ColumnDef<Product>[] = [
|
|
151
|
+
{
|
|
152
|
+
accessorKey: 'name',
|
|
153
|
+
header: 'Product Name',
|
|
154
|
+
size: 200,
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
accessorKey: 'category',
|
|
158
|
+
header: 'Category',
|
|
159
|
+
size: 120,
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
accessorKey: 'price',
|
|
163
|
+
header: 'Price',
|
|
164
|
+
size: 100,
|
|
165
|
+
Cell: ({ cell }) => `$${cell.getValue<number>().toFixed(2)}`,
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
accessorKey: 'stock',
|
|
169
|
+
header: 'Stock',
|
|
170
|
+
size: 80,
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
accessorKey: 'status',
|
|
174
|
+
header: 'Status',
|
|
175
|
+
size: 120,
|
|
176
|
+
Cell: ({ cell }) => {
|
|
177
|
+
const status = cell.getValue<string>();
|
|
178
|
+
const color = status === 'In Stock' ? 'success' : status === 'Low Stock' ? 'pending' : 'danger';
|
|
179
|
+
return <Badge color={color} size="sm">{status}</Badge>;
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
accessorKey: 'supplier',
|
|
184
|
+
header: 'Supplier',
|
|
185
|
+
size: 120,
|
|
186
|
+
},
|
|
187
|
+
];
|
|
188
|
+
|
|
189
|
+
export const Default: Story = {
|
|
190
|
+
render: () => {
|
|
191
|
+
const data = useMemo(() => generateUsers(10), []);
|
|
192
|
+
|
|
193
|
+
return (
|
|
194
|
+
<Stack gap="lg" w="100%">
|
|
195
|
+
<Title order={3} size="md">Basic Table</Title>
|
|
196
|
+
<DataTable
|
|
197
|
+
data={data}
|
|
198
|
+
columns={userColumns}
|
|
199
|
+
totalCount={data.length}
|
|
200
|
+
/>
|
|
201
|
+
</Stack>
|
|
202
|
+
);
|
|
203
|
+
},
|
|
204
|
+
parameters: {
|
|
205
|
+
docs: {
|
|
206
|
+
description: {
|
|
207
|
+
story: 'Basic table with minimal configuration showing user data.',
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
export const WithPagination: Story = {
|
|
214
|
+
render: () => {
|
|
215
|
+
const allData = useMemo(() => generateUsers(50), []);
|
|
216
|
+
const [pagination, setPagination] = useState<PaginationState>({
|
|
217
|
+
pageIndex: 0,
|
|
218
|
+
pageSize: 10,
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
const data = useMemo(() => {
|
|
222
|
+
const start = pagination.pageIndex * pagination.pageSize;
|
|
223
|
+
const end = start + pagination.pageSize;
|
|
224
|
+
return allData.slice(start, end);
|
|
225
|
+
}, [allData, pagination]);
|
|
226
|
+
|
|
227
|
+
return (
|
|
228
|
+
<Stack gap="lg" w="100%">
|
|
229
|
+
<Title order={3} size="md">Table with Pagination</Title>
|
|
230
|
+
<Text size="sm" c="dimmed">
|
|
231
|
+
Showing {data.length} of {allData.length} users
|
|
232
|
+
</Text>
|
|
233
|
+
<DataTable
|
|
234
|
+
data={data}
|
|
235
|
+
columns={userColumns}
|
|
236
|
+
totalCount={allData.length}
|
|
237
|
+
onPaginationChange={setPagination}
|
|
238
|
+
defaultPageSize={10}
|
|
239
|
+
/>
|
|
240
|
+
</Stack>
|
|
241
|
+
);
|
|
242
|
+
},
|
|
243
|
+
parameters: {
|
|
244
|
+
docs: {
|
|
245
|
+
description: {
|
|
246
|
+
story: 'Table with pagination controls and page size selection.',
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
export const WithSelection: Story = {
|
|
253
|
+
render: () => {
|
|
254
|
+
const data = useMemo(() => generateUsers(15), []);
|
|
255
|
+
const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
|
|
256
|
+
|
|
257
|
+
const selectedCount = Object.keys(rowSelection).length;
|
|
258
|
+
|
|
259
|
+
return (
|
|
260
|
+
<Stack gap="lg" w="100%">
|
|
261
|
+
<Title order={3} size="md">Table with Row Selection</Title>
|
|
262
|
+
<Inline gap="sm">
|
|
263
|
+
<Text size="sm">Selected rows: {selectedCount}</Text>
|
|
264
|
+
{selectedCount > 0 && (
|
|
265
|
+
<Button
|
|
266
|
+
size="xs"
|
|
267
|
+
variant="outline"
|
|
268
|
+
onClick={() => setRowSelection({})}
|
|
269
|
+
>
|
|
270
|
+
Clear Selection
|
|
271
|
+
</Button>
|
|
272
|
+
)}
|
|
273
|
+
</Inline>
|
|
274
|
+
<DataTable
|
|
275
|
+
data={data}
|
|
276
|
+
columns={userColumns}
|
|
277
|
+
totalCount={data.length}
|
|
278
|
+
onRowSelectionChange={setRowSelection}
|
|
279
|
+
/>
|
|
280
|
+
</Stack>
|
|
281
|
+
);
|
|
282
|
+
},
|
|
283
|
+
parameters: {
|
|
284
|
+
docs: {
|
|
285
|
+
description: {
|
|
286
|
+
story: 'Table with row selection checkboxes and selection management.',
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
},
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
export const LoadingState: Story = {
|
|
293
|
+
render: () => {
|
|
294
|
+
const data = useMemo(() => generateUsers(5), []);
|
|
295
|
+
|
|
296
|
+
return (
|
|
297
|
+
<Stack gap="lg" w="100%">
|
|
298
|
+
<Title order={3} size="md">Loading State</Title>
|
|
299
|
+
<DataTable
|
|
300
|
+
data={data}
|
|
301
|
+
columns={userColumns}
|
|
302
|
+
totalCount={data.length}
|
|
303
|
+
isLoading={true}
|
|
304
|
+
/>
|
|
305
|
+
</Stack>
|
|
306
|
+
);
|
|
307
|
+
},
|
|
308
|
+
parameters: {
|
|
309
|
+
docs: {
|
|
310
|
+
description: {
|
|
311
|
+
story: 'Table in loading state with skeleton placeholders.',
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
export const ErrorState: Story = {
|
|
318
|
+
render: () => {
|
|
319
|
+
return (
|
|
320
|
+
<Stack gap="lg" w="100%">
|
|
321
|
+
<Title order={3} size="md">Error State</Title>
|
|
322
|
+
<DataTable
|
|
323
|
+
data={[]}
|
|
324
|
+
columns={userColumns}
|
|
325
|
+
totalCount={0}
|
|
326
|
+
isError={true}
|
|
327
|
+
error="Failed to load user data. Please try again."
|
|
328
|
+
onRetry={() => console.log('Retry clicked')}
|
|
329
|
+
/>
|
|
330
|
+
</Stack>
|
|
331
|
+
);
|
|
332
|
+
},
|
|
333
|
+
parameters: {
|
|
334
|
+
docs: {
|
|
335
|
+
description: {
|
|
336
|
+
story: 'Table in error state with retry functionality.',
|
|
337
|
+
},
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
export const EmptyState: Story = {
|
|
343
|
+
render: () => {
|
|
344
|
+
return (
|
|
345
|
+
<Stack gap="lg" w="100%">
|
|
346
|
+
<Title order={3} size="md">Empty State</Title>
|
|
347
|
+
<DataTable
|
|
348
|
+
data={[]}
|
|
349
|
+
columns={userColumns}
|
|
350
|
+
totalCount={0}
|
|
351
|
+
/>
|
|
352
|
+
</Stack>
|
|
353
|
+
);
|
|
354
|
+
},
|
|
355
|
+
parameters: {
|
|
356
|
+
docs: {
|
|
357
|
+
description: {
|
|
358
|
+
story: 'Table with no data showing empty state message.',
|
|
359
|
+
},
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
export const ProductTable: Story = {
|
|
365
|
+
render: () => {
|
|
366
|
+
const data = useMemo(() => generateProducts(20), []);
|
|
367
|
+
const [pagination, setPagination] = useState<PaginationState>({
|
|
368
|
+
pageIndex: 0,
|
|
369
|
+
pageSize: 8,
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
const paginatedData = useMemo(() => {
|
|
373
|
+
const start = pagination.pageIndex * pagination.pageSize;
|
|
374
|
+
const end = start + pagination.pageSize;
|
|
375
|
+
return data.slice(start, end);
|
|
376
|
+
}, [data, pagination]);
|
|
377
|
+
|
|
378
|
+
return (
|
|
379
|
+
<Stack gap="lg" w="100%">
|
|
380
|
+
<Title order={3} size="md">Product Inventory Table</Title>
|
|
381
|
+
<Text size="sm" c="dimmed">
|
|
382
|
+
Product catalog with pricing, stock levels, and supplier information
|
|
383
|
+
</Text>
|
|
384
|
+
<DataTable
|
|
385
|
+
data={paginatedData}
|
|
386
|
+
columns={productColumns}
|
|
387
|
+
totalCount={data.length}
|
|
388
|
+
onPaginationChange={setPagination}
|
|
389
|
+
defaultPageSize={8}
|
|
390
|
+
/>
|
|
391
|
+
</Stack>
|
|
392
|
+
);
|
|
393
|
+
},
|
|
394
|
+
parameters: {
|
|
395
|
+
docs: {
|
|
396
|
+
description: {
|
|
397
|
+
story: 'Product inventory table with custom cell renderers and formatting.',
|
|
398
|
+
},
|
|
399
|
+
},
|
|
400
|
+
},
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
export const FullFeatured: Story = {
|
|
404
|
+
render: () => {
|
|
405
|
+
const allData = useMemo(() => generateUsers(100), []);
|
|
406
|
+
const [pagination, setPagination] = useState<PaginationState>({
|
|
407
|
+
pageIndex: 0,
|
|
408
|
+
pageSize: 15,
|
|
409
|
+
});
|
|
410
|
+
const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
|
|
411
|
+
const [filters, setFilters] = useState({});
|
|
412
|
+
|
|
413
|
+
const data = useMemo(() => {
|
|
414
|
+
const start = pagination.pageIndex * pagination.pageSize;
|
|
415
|
+
const end = start + pagination.pageSize;
|
|
416
|
+
return allData.slice(start, end);
|
|
417
|
+
}, [allData, pagination]);
|
|
418
|
+
|
|
419
|
+
const selectedCount = Object.keys(rowSelection).length;
|
|
420
|
+
|
|
421
|
+
return (
|
|
422
|
+
<Stack gap="lg" w="100%">
|
|
423
|
+
<Title order={3} size="md">Full-Featured Table</Title>
|
|
424
|
+
<Text size="sm" c="dimmed">
|
|
425
|
+
Complete table with all features: pagination, selection, filtering, sorting, density controls, and fullscreen mode
|
|
426
|
+
</Text>
|
|
427
|
+
|
|
428
|
+
{selectedCount > 0 && (
|
|
429
|
+
<Inline gap="sm">
|
|
430
|
+
<Text size="sm" fw={500}>
|
|
431
|
+
{selectedCount} row{selectedCount !== 1 ? 's' : ''} selected
|
|
432
|
+
</Text>
|
|
433
|
+
<Button size="xs" variant="outline" onClick={() => setRowSelection({})}>
|
|
434
|
+
Clear Selection
|
|
435
|
+
</Button>
|
|
436
|
+
<Button size="xs" variant="primary">
|
|
437
|
+
Bulk Action
|
|
438
|
+
</Button>
|
|
439
|
+
</Inline>
|
|
440
|
+
)}
|
|
441
|
+
|
|
442
|
+
<DataTable
|
|
443
|
+
data={data}
|
|
444
|
+
columns={userColumns}
|
|
445
|
+
totalCount={allData.length}
|
|
446
|
+
onPaginationChange={setPagination}
|
|
447
|
+
onRowSelectionChange={setRowSelection}
|
|
448
|
+
filtersState={filters}
|
|
449
|
+
onFiltersChange={setFilters}
|
|
450
|
+
defaultPageSize={15}
|
|
451
|
+
showFilters={true}
|
|
452
|
+
showSearch={true}
|
|
453
|
+
showDensityToggle={true}
|
|
454
|
+
showFullScreenToggle={true}
|
|
455
|
+
/>
|
|
456
|
+
</Stack>
|
|
457
|
+
);
|
|
458
|
+
},
|
|
459
|
+
parameters: {
|
|
460
|
+
docs: {
|
|
461
|
+
description: {
|
|
462
|
+
story: 'Full-featured table demonstrating all available functionality and controls.',
|
|
463
|
+
},
|
|
464
|
+
},
|
|
465
|
+
},
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
export const Interactive: Story = {
|
|
469
|
+
args: {
|
|
470
|
+
isLoading: false,
|
|
471
|
+
isError: false,
|
|
472
|
+
showFilters: true,
|
|
473
|
+
showSearch: true,
|
|
474
|
+
showDensityToggle: true,
|
|
475
|
+
showFullScreenToggle: true,
|
|
476
|
+
},
|
|
477
|
+
render: (args) => {
|
|
478
|
+
const data = useMemo(() => generateUsers(12), []);
|
|
479
|
+
|
|
480
|
+
return (
|
|
481
|
+
<Stack gap="lg" w="100%">
|
|
482
|
+
<Title order={3} size="md">Interactive Table</Title>
|
|
483
|
+
<Text size="sm" c="dimmed">
|
|
484
|
+
Use the controls below to customize the table behavior and appearance
|
|
485
|
+
</Text>
|
|
486
|
+
<DataTable
|
|
487
|
+
{...args}
|
|
488
|
+
data={data}
|
|
489
|
+
columns={userColumns}
|
|
490
|
+
totalCount={data.length}
|
|
491
|
+
/>
|
|
492
|
+
</Stack>
|
|
493
|
+
);
|
|
494
|
+
},
|
|
495
|
+
parameters: {
|
|
496
|
+
docs: {
|
|
497
|
+
description: {
|
|
498
|
+
story: 'Use the controls below to interact with the Table and see different combinations.',
|
|
499
|
+
},
|
|
500
|
+
},
|
|
501
|
+
},
|
|
502
|
+
};
|