@shohojdhara/atomix 0.3.13 → 0.3.15
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 +39 -0
- package/README.md +2 -0
- package/build-tools/EXAMPLES.md +372 -0
- package/build-tools/README.md +242 -0
- package/build-tools/__tests__/error-handler.test.js +230 -0
- package/build-tools/__tests__/index.test.js +141 -0
- package/build-tools/__tests__/rollup-plugin.test.js +194 -0
- package/build-tools/__tests__/utils.test.js +161 -0
- package/build-tools/__tests__/vite-plugin.test.js +129 -0
- package/build-tools/__tests__/webpack-loader.test.js +190 -0
- package/build-tools/error-handler.js +308 -0
- package/build-tools/index.d.ts +43 -0
- package/build-tools/index.js +88 -0
- package/build-tools/package.json +67 -0
- package/build-tools/rollup-plugin.js +236 -0
- package/build-tools/types.d.ts +163 -0
- package/build-tools/utils.js +203 -0
- package/build-tools/vite-plugin.js +161 -0
- package/build-tools/webpack-loader.js +123 -0
- package/dist/atomix.css +298 -167
- package/dist/atomix.css.map +1 -1
- package/dist/atomix.min.css +3 -3
- package/dist/atomix.min.css.map +1 -1
- package/dist/build-tools/EXAMPLES.md +372 -0
- package/dist/build-tools/README.md +242 -0
- package/dist/build-tools/__tests__/error-handler.test.js +230 -0
- package/dist/build-tools/__tests__/index.test.js +141 -0
- package/dist/build-tools/__tests__/rollup-plugin.test.js +194 -0
- package/dist/build-tools/__tests__/utils.test.js +161 -0
- package/dist/build-tools/__tests__/vite-plugin.test.js +129 -0
- package/dist/build-tools/__tests__/webpack-loader.test.js +190 -0
- package/dist/build-tools/error-handler.js +308 -0
- package/dist/build-tools/index.d.ts +43 -0
- package/dist/build-tools/index.js +88 -0
- package/dist/build-tools/package.json +67 -0
- package/dist/build-tools/rollup-plugin.js +236 -0
- package/dist/build-tools/types.d.ts +163 -0
- package/dist/build-tools/utils.js +203 -0
- package/dist/build-tools/vite-plugin.js +161 -0
- package/dist/build-tools/webpack-loader.js +123 -0
- package/dist/charts.d.ts +2 -2
- package/dist/charts.js +87 -58
- package/dist/charts.js.map +1 -1
- package/dist/core.d.ts +42 -12
- package/dist/core.js +175 -135
- package/dist/core.js.map +1 -1
- package/dist/forms.d.ts +30 -16
- package/dist/forms.js +146 -131
- package/dist/forms.js.map +1 -1
- package/dist/heavy.d.ts +2 -2
- package/dist/heavy.js +151 -118
- package/dist/heavy.js.map +1 -1
- package/dist/index.d.ts +130 -106
- package/dist/index.esm.js +1083 -465
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1102 -483
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/theme.d.ts +27 -2
- package/dist/theme.js +721 -108
- package/dist/theme.js.map +1 -1
- package/package.json +23 -8
- package/scripts/atomix-cli.js +749 -1153
- package/scripts/cli/__tests__/README.md +81 -0
- package/scripts/cli/__tests__/basic.test.js +115 -0
- package/scripts/cli/__tests__/component-generator.test.js +332 -0
- package/scripts/cli/__tests__/integration.test.js +327 -0
- package/scripts/cli/__tests__/test-setup.js +133 -0
- package/scripts/cli/__tests__/token-manager.test.js +251 -0
- package/scripts/cli/__tests__/utils.test.js +78 -118
- package/scripts/cli/component-generator.js +564 -0
- package/scripts/cli/dependency-checker.js +355 -0
- package/scripts/cli/documentation-sync.js +542 -0
- package/scripts/cli/interactive-init.js +129 -292
- package/scripts/cli/mappings.js +211 -0
- package/scripts/cli/migration-tools.js +95 -288
- package/scripts/cli/template-manager.js +105 -0
- package/scripts/cli/templates/README.md +123 -0
- package/scripts/cli/templates/common-templates.js +636 -0
- package/scripts/cli/templates/composable-templates.js +171 -0
- package/scripts/cli/templates/config-templates.js +126 -0
- package/scripts/cli/templates/index.js +102 -0
- package/scripts/cli/templates/project-templates.js +342 -0
- package/scripts/cli/templates/react-templates.js +331 -0
- package/scripts/cli/templates/scss-templates.js +155 -0
- package/scripts/cli/templates/storybook-templates.js +236 -0
- package/scripts/cli/templates/testing-templates.js +224 -0
- package/scripts/cli/templates/testing-utils.js +278 -0
- package/scripts/cli/templates/token-templates.js +447 -0
- package/scripts/cli/templates/types-templates.js +147 -0
- package/scripts/cli/templates.js +35 -0
- package/scripts/cli/theme-bridge.js +28 -16
- package/scripts/cli/token-manager.js +432 -247
- package/scripts/cli/utils.js +37 -26
- package/src/components/Accordion/Accordion.stories.tsx +369 -870
- package/src/components/Accordion/Accordion.test.tsx +57 -0
- package/src/components/Accordion/Accordion.tsx +4 -0
- package/src/components/AtomixGlass/AtomixGlass.tsx +80 -39
- package/src/components/AtomixGlass/AtomixGlassContainer.tsx +103 -81
- package/src/components/AtomixGlass/__snapshots__/AtomixGlass.test.tsx.snap +8 -7
- package/src/components/AtomixGlass/glass-utils.ts +2 -2
- package/src/components/AtomixGlass/shader-utils.ts +5 -0
- package/src/components/AtomixGlass/stories/Customization.stories.tsx +131 -0
- package/src/components/AtomixGlass/stories/Examples.stories.tsx +2965 -2861
- package/src/components/AtomixGlass/stories/Modes.stories.tsx +1 -1
- package/src/components/AtomixGlass/stories/Overview.stories.tsx +348 -0
- package/src/components/AtomixGlass/stories/Performance.stories.tsx +103 -0
- package/src/components/AtomixGlass/stories/Playground.stories.tsx +73 -59
- package/src/components/AtomixGlass/stories/{ShaderVariants.stories.tsx → Shaders.stories.tsx} +1 -1
- package/src/components/AtomixGlass/stories/shared-components.tsx +90 -190
- package/src/components/Avatar/Avatar.stories.tsx +239 -27
- package/src/components/Badge/Badge.stories.tsx +132 -373
- package/src/components/Badge/Badge.test.tsx +51 -0
- package/src/components/Badge/Badge.tsx +20 -1
- package/src/components/Block/Block.stories.tsx +26 -17
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +141 -23
- package/src/components/Breadcrumb/Breadcrumb.tsx +2 -2
- package/src/components/Button/Button.stories.tsx +463 -1126
- package/src/components/Button/Button.test.tsx +107 -0
- package/src/components/Button/Button.tsx +50 -54
- package/src/components/Button/ButtonGroup.stories.tsx +373 -217
- package/src/components/Button/README.md +5 -0
- package/src/components/Callout/Callout.stories.tsx +299 -644
- package/src/components/Callout/Callout.test.tsx +10 -10
- package/src/components/Callout/Callout.tsx +7 -7
- package/src/components/Callout/README.md +9 -8
- package/src/components/Card/Card.stories.tsx +248 -68
- package/src/components/Card/Card.tsx +2 -2
- package/src/components/Chart/Chart.stories.tsx +156 -14
- package/src/components/Chart/Chart.tsx +1 -1
- package/src/components/ColorModeToggle/ColorModeToggle.stories.tsx +151 -69
- package/src/components/Countdown/Countdown.stories.tsx +115 -8
- package/src/components/DataTable/DataTable.stories.tsx +346 -146
- package/src/components/DataTable/DataTable.tsx +14 -12
- package/src/components/DatePicker/DatePicker.stories.tsx +325 -1066
- package/src/components/Dropdown/Dropdown.stories.tsx +157 -37
- package/src/components/EdgePanel/EdgePanel.stories.tsx +230 -21
- package/src/components/Footer/Footer.stories.tsx +392 -328
- package/src/components/Form/Checkbox.stories.tsx +143 -9
- package/src/components/Form/Checkbox.test.tsx +63 -0
- package/src/components/Form/Checkbox.tsx +90 -52
- package/src/components/Form/Form.stories.tsx +121 -22
- package/src/components/Form/FormGroup.stories.tsx +128 -5
- package/src/components/Form/Input.stories.tsx +28 -16
- package/src/components/Form/Input.test.tsx +59 -0
- package/src/components/Form/Input.tsx +97 -95
- package/src/components/Form/Radio.stories.tsx +232 -97
- package/src/components/Form/Radio.tsx +2 -2
- package/src/components/Form/Select.stories.tsx +144 -12
- package/src/components/Form/Select.tsx +2 -2
- package/src/components/Form/Textarea.stories.tsx +171 -13
- package/src/components/Form/Textarea.test.tsx +45 -0
- package/src/components/Form/Textarea.tsx +88 -86
- package/src/components/Hero/Hero.stories.tsx +333 -32
- package/src/components/List/List.stories.tsx +143 -5
- package/src/components/Modal/Modal.stories.tsx +185 -46
- package/src/components/Navigation/Navbar/Navbar.stories.tsx +5 -5
- package/src/components/Navigation/Navbar/Navbar.tsx +1 -1
- package/src/components/Navigation/README.md +1 -1
- package/src/components/Pagination/Pagination.stories.tsx +5 -2
- package/src/components/Pagination/Pagination.tsx +1 -1
- package/src/components/PhotoViewer/PhotoViewer.stories.tsx +10 -10
- package/src/components/Popover/Popover.stories.tsx +449 -99
- package/src/components/ProductReview/ProductReview.tsx +1 -1
- package/src/components/Progress/Progress.stories.tsx +167 -5
- package/src/components/Progress/Progress.tsx +46 -46
- package/src/components/Rating/Rating.stories.tsx +4 -4
- package/src/components/Rating/Rating.tsx +8 -8
- package/src/components/River/River.stories.tsx +1 -1
- package/src/components/SectionIntro/SectionIntro.stories.tsx +240 -48
- package/src/components/Slider/Slider.stories.tsx +63 -63
- package/src/components/Spinner/Spinner.stories.tsx +104 -10
- package/src/components/Spinner/Spinner.test.tsx +35 -0
- package/src/components/Spinner/Spinner.tsx +9 -2
- package/src/components/Steps/Steps.stories.tsx +172 -43
- package/src/components/Tabs/Tabs.stories.tsx +136 -10
- package/src/components/Testimonial/Testimonial.stories.tsx +121 -4
- package/src/components/Todo/Todo.stories.tsx +198 -9
- package/src/components/Toggle/Toggle.stories.tsx +153 -43
- package/src/components/Toggle/Toggle.test.tsx +91 -0
- package/src/components/Toggle/Toggle.tsx +44 -27
- package/src/components/Tooltip/Tooltip.stories.tsx +194 -104
- package/src/components/Tooltip/Tooltip.tsx +1 -1
- package/src/components/Upload/Upload.stories.tsx +113 -24
- package/src/layouts/Grid/Grid.stories.tsx +49 -49
- package/src/layouts/MasonryGrid/MasonryGrid.stories.tsx +2 -2
- package/src/lib/README.md +2 -2
- package/src/lib/__tests__/theme-tools.test.ts +193 -0
- package/src/lib/composables/index.ts +2 -2
- package/src/lib/composables/useAccordion.ts +12 -3
- package/src/lib/composables/useAtomixGlass.ts +28 -56
- package/src/lib/composables/useBreadcrumb.ts +2 -2
- package/src/lib/composables/useCallout.ts +7 -7
- package/src/lib/composables/useChartExport.ts +2 -7
- package/src/lib/composables/useDataTable.ts +46 -29
- package/src/lib/composables/useNavbar.ts +1 -1
- package/src/lib/constants/components.ts +10 -33
- package/src/lib/storybook/InteractiveDemo.tsx +113 -0
- package/src/lib/storybook/PreviewContainer.tsx +36 -0
- package/src/lib/storybook/VariantsGrid.tsx +21 -0
- package/src/lib/storybook/index.ts +3 -0
- package/src/lib/theme/core/createThemeObject.ts +9 -5
- package/src/lib/theme/devtools/CLI.ts +155 -0
- package/src/lib/theme/devtools/DesignTokensCustomizer.stories.tsx +213 -0
- package/src/lib/theme/devtools/DesignTokensCustomizer.tsx +566 -0
- package/src/lib/theme/devtools/LiveEditor.tsx +2 -1
- package/src/lib/theme/devtools/index.ts +3 -0
- package/src/lib/theme/errors/errors.ts +8 -0
- package/src/lib/theme/runtime/ThemeProvider.tsx +117 -57
- package/src/lib/theme/runtime/__tests__/ThemeProvider.integration.test.tsx +305 -0
- package/src/lib/theme/runtime/__tests__/ThemeProvider.test.tsx +588 -0
- package/src/lib/theme/utils/__tests__/themeValidation.test.ts +264 -0
- package/src/lib/theme/utils/index.ts +1 -0
- package/src/lib/theme/utils/themeValidation.ts +501 -0
- package/src/lib/theme-tools.ts +32 -3
- package/src/lib/types/components.ts +82 -27
- package/src/lib/utils/__tests__/csv.test.ts +45 -0
- package/src/lib/utils/csv.ts +17 -0
- package/src/lib/utils/dataTableExport.ts +1 -10
- package/src/lib/utils/themeNaming.ts +1 -1
- package/src/styles/01-settings/_index.scss +2 -1
- package/src/styles/01-settings/_settings.accordion.scss +28 -7
- package/src/styles/01-settings/_settings.colors.scss +11 -11
- package/src/styles/01-settings/_settings.typography.scss +5 -5
- package/src/styles/02-tools/_tools.utility-api.scss +14 -0
- package/src/styles/06-components/_components.accordion.scss +56 -14
- package/src/styles/06-components/_components.callout.scss +29 -33
- package/src/styles/06-components/_components.checkbox.scss +23 -17
- package/src/styles/06-components/_index.scss +1 -1
- package/src/styles/99-utilities/_index.scss +2 -0
- package/src/styles/99-utilities/_utilities.display.scss +14 -3
- package/src/styles/99-utilities/_utilities.flex.scss +10 -10
- package/src/styles/99-utilities/_utilities.scss +3 -1
- package/src/styles/99-utilities/_utilities.text-gradient.scss +45 -0
- package/src/styles/99-utilities/_utilities.text.scss +28 -8
- package/themes/dark-complementary/README.md +98 -0
- package/themes/dark-complementary/index.scss +158 -0
- package/themes/default-light/README.md +81 -0
- package/themes/default-light/index.scss +154 -0
- package/themes/high-contrast/README.md +105 -0
- package/themes/high-contrast/index.scss +172 -0
- package/themes/test-theme/README.md +38 -0
- package/themes/test-theme/index.scss +47 -0
- package/scripts/cli/__tests__/cli-commands.test.js +0 -204
- package/scripts/cli/__tests__/vitest.config.js +0 -26
- package/src/components/AtomixGlass/stories/AtomixGlass.stories.tsx +0 -1438
- package/src/lib/composables/useButton.ts +0 -93
- package/src/lib/composables/useCheckbox.ts +0 -70
|
@@ -1,33 +1,184 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { fn } from '@storybook/test';
|
|
2
3
|
import { useState } from 'react';
|
|
3
4
|
import { DataTableColumn } from '../../lib/types/components';
|
|
4
5
|
import { DataTable } from './DataTable';
|
|
5
6
|
|
|
6
|
-
const meta = {
|
|
7
|
+
const meta: Meta<typeof DataTable> = {
|
|
7
8
|
title: 'Components/DataTable',
|
|
8
9
|
component: DataTable,
|
|
9
10
|
parameters: {
|
|
10
11
|
layout: 'padded',
|
|
11
12
|
docs: {
|
|
12
13
|
description: {
|
|
13
|
-
component:
|
|
14
|
-
|
|
14
|
+
component: `
|
|
15
|
+
# DataTable
|
|
16
|
+
|
|
17
|
+
## Overview
|
|
18
|
+
|
|
19
|
+
DataTable provides a powerful and flexible way to display structured data in rows and columns. It supports sorting, filtering, pagination, selection, and various display options. DataTables are ideal for displaying large datasets, user lists, product catalogs, or any tabular information requiring advanced data manipulation.
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
- Sorting capability for columns
|
|
24
|
+
- Filtering functionality
|
|
25
|
+
- Pagination with configurable page size
|
|
26
|
+
- Row selection options
|
|
27
|
+
- Custom cell rendering
|
|
28
|
+
- Responsive design
|
|
29
|
+
- Loading states
|
|
30
|
+
- Empty state handling
|
|
31
|
+
|
|
32
|
+
## Accessibility
|
|
33
|
+
|
|
34
|
+
- Keyboard support: Navigate with arrow keys, select with Space/Enter
|
|
35
|
+
- Screen reader: Table headers and data cells announced properly
|
|
36
|
+
- ARIA support: Appropriate roles and properties for tables
|
|
37
|
+
- Focus management: Maintains focus within the table controls
|
|
38
|
+
|
|
39
|
+
## Usage Examples
|
|
40
|
+
|
|
41
|
+
### Basic Usage
|
|
42
|
+
|
|
43
|
+
\`\`\`tsx
|
|
44
|
+
<DataTable
|
|
45
|
+
data={data}
|
|
46
|
+
columns={columns}
|
|
47
|
+
/>
|
|
48
|
+
\`\`\`
|
|
49
|
+
|
|
50
|
+
### With Pagination
|
|
51
|
+
|
|
52
|
+
\`\`\`tsx
|
|
53
|
+
<DataTable
|
|
54
|
+
data={data}
|
|
55
|
+
columns={columns}
|
|
56
|
+
paginated={true}
|
|
57
|
+
pageSize={10}
|
|
58
|
+
/>
|
|
59
|
+
\`\`\`
|
|
60
|
+
|
|
61
|
+
## API Reference
|
|
62
|
+
|
|
63
|
+
### Props
|
|
64
|
+
|
|
65
|
+
| Prop | Type | Default | Description |
|
|
66
|
+
| ---- | ---- | ------- | ----------- |
|
|
67
|
+
| data | T[] | [] | Array of data objects to display |
|
|
68
|
+
| columns | DataTableColumn[] | [] | Column definitions for the table |
|
|
69
|
+
| sortable | boolean | false | Whether columns are sortable |
|
|
70
|
+
| filterable | boolean | false | Whether the table is filterable |
|
|
71
|
+
| paginated | boolean | false | Whether to enable pagination |
|
|
72
|
+
| pageSize | number | 10 | Number of rows per page |
|
|
73
|
+
| striped | boolean | false | Whether to apply striped row styling |
|
|
74
|
+
| bordered | boolean | false | Whether to show table borders |
|
|
75
|
+
| dense | boolean | false | Whether to use dense row spacing |
|
|
76
|
+
| loading | boolean | false | Whether the table is in loading state |
|
|
77
|
+
| emptyMessage | string | 'No records found' | Message to display when table is empty |
|
|
78
|
+
| onRowClick | (row: T) => void | - | Callback when a row is clicked |
|
|
79
|
+
| onSelectionChange | (selected: T[]) => void | - | Callback when selection changes |
|
|
80
|
+
`,
|
|
15
81
|
},
|
|
16
82
|
},
|
|
17
83
|
},
|
|
18
84
|
tags: ['autodocs'],
|
|
19
85
|
argTypes: {
|
|
20
|
-
data: {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
86
|
+
data: {
|
|
87
|
+
control: 'object',
|
|
88
|
+
description: 'Array of data objects to display',
|
|
89
|
+
table: {
|
|
90
|
+
type: { summary: 'T[]' },
|
|
91
|
+
defaultValue: { summary: '[]' },
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
columns: {
|
|
95
|
+
control: 'object',
|
|
96
|
+
description: 'Column definitions for the table',
|
|
97
|
+
table: {
|
|
98
|
+
type: { summary: 'DataTableColumn[]' },
|
|
99
|
+
defaultValue: { summary: '[]' },
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
sortable: {
|
|
103
|
+
control: 'boolean',
|
|
104
|
+
description: 'Whether columns are sortable',
|
|
105
|
+
table: {
|
|
106
|
+
type: { summary: 'boolean' },
|
|
107
|
+
defaultValue: { summary: 'false' },
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
filterable: {
|
|
111
|
+
control: 'boolean',
|
|
112
|
+
description: 'Whether the table is filterable',
|
|
113
|
+
table: {
|
|
114
|
+
type: { summary: 'boolean' },
|
|
115
|
+
defaultValue: { summary: 'false' },
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
paginated: {
|
|
119
|
+
control: 'boolean',
|
|
120
|
+
description: 'Whether to enable pagination',
|
|
121
|
+
table: {
|
|
122
|
+
type: { summary: 'boolean' },
|
|
123
|
+
defaultValue: { summary: 'false' },
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
pageSize: {
|
|
127
|
+
control: 'number',
|
|
128
|
+
description: 'Number of rows per page',
|
|
129
|
+
table: {
|
|
130
|
+
type: { summary: 'number' },
|
|
131
|
+
defaultValue: { summary: '10' },
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
striped: {
|
|
135
|
+
control: 'boolean',
|
|
136
|
+
description: 'Whether to apply striped row styling',
|
|
137
|
+
table: {
|
|
138
|
+
type: { summary: 'boolean' },
|
|
139
|
+
defaultValue: { summary: 'false' },
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
bordered: {
|
|
143
|
+
control: 'boolean',
|
|
144
|
+
description: 'Whether to show table borders',
|
|
145
|
+
table: {
|
|
146
|
+
type: { summary: 'boolean' },
|
|
147
|
+
defaultValue: { summary: 'false' },
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
dense: {
|
|
151
|
+
control: 'boolean',
|
|
152
|
+
description: 'Whether to use dense row spacing',
|
|
153
|
+
table: {
|
|
154
|
+
type: { summary: 'boolean' },
|
|
155
|
+
defaultValue: { summary: 'false' },
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
loading: {
|
|
159
|
+
control: 'boolean',
|
|
160
|
+
description: 'Whether the table is in loading state',
|
|
161
|
+
table: {
|
|
162
|
+
type: { summary: 'boolean' },
|
|
163
|
+
defaultValue: { summary: 'false' },
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
emptyMessage: {
|
|
167
|
+
control: 'text',
|
|
168
|
+
description: 'Message to display when table is empty',
|
|
169
|
+
table: {
|
|
170
|
+
type: { summary: 'string' },
|
|
171
|
+
defaultValue: { summary: 'No records found' },
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
onRowClick: {
|
|
175
|
+
action: 'row clicked',
|
|
176
|
+
description: 'Callback when a row is clicked',
|
|
177
|
+
},
|
|
178
|
+
onSelectionChange: {
|
|
179
|
+
action: 'selection changed',
|
|
180
|
+
description: 'Callback when selection changes',
|
|
181
|
+
},
|
|
31
182
|
},
|
|
32
183
|
} satisfies Meta<typeof DataTable>;
|
|
33
184
|
|
|
@@ -78,170 +229,167 @@ const columns: DataTableColumn[] = [
|
|
|
78
229
|
title: 'Status',
|
|
79
230
|
sortable: true,
|
|
80
231
|
render: (value, row) => {
|
|
81
|
-
let
|
|
232
|
+
let statusClass = '';
|
|
82
233
|
switch (value) {
|
|
83
234
|
case 'Active':
|
|
84
|
-
|
|
235
|
+
statusClass = 'u-text-success';
|
|
85
236
|
break;
|
|
86
237
|
case 'Inactive':
|
|
87
|
-
|
|
238
|
+
statusClass = 'u-text-error';
|
|
88
239
|
break;
|
|
89
240
|
case 'Pending':
|
|
90
|
-
|
|
241
|
+
statusClass = 'u-text-warning';
|
|
91
242
|
break;
|
|
92
243
|
case 'Suspended':
|
|
93
|
-
|
|
244
|
+
statusClass = 'u-text-gray';
|
|
94
245
|
break;
|
|
246
|
+
default:
|
|
247
|
+
statusClass = 'u-text-gray';
|
|
95
248
|
}
|
|
96
|
-
return <span
|
|
249
|
+
return <span className={statusClass}>{value}</span>;
|
|
97
250
|
},
|
|
98
251
|
},
|
|
99
252
|
];
|
|
100
253
|
|
|
101
|
-
//
|
|
102
|
-
|
|
254
|
+
// ========================================
|
|
255
|
+
// BASIC USAGE STORIES
|
|
256
|
+
// ========================================
|
|
257
|
+
|
|
258
|
+
export const BasicUsage: Story = {
|
|
103
259
|
args: {
|
|
104
260
|
data: users,
|
|
105
|
-
columns,
|
|
261
|
+
columns: columns,
|
|
262
|
+
},
|
|
263
|
+
parameters: {
|
|
264
|
+
docs: {
|
|
265
|
+
description: {
|
|
266
|
+
story: 'Basic DataTable component with sample user data.',
|
|
267
|
+
},
|
|
268
|
+
},
|
|
106
269
|
},
|
|
107
270
|
};
|
|
108
271
|
|
|
109
|
-
//
|
|
110
|
-
|
|
272
|
+
// ========================================
|
|
273
|
+
// VARIANTS & STATES STORIES
|
|
274
|
+
// ========================================
|
|
275
|
+
|
|
276
|
+
export const LoadingState: Story = {
|
|
111
277
|
args: {
|
|
112
278
|
data: users,
|
|
113
279
|
columns,
|
|
114
|
-
|
|
280
|
+
loading: true,
|
|
115
281
|
},
|
|
116
282
|
};
|
|
117
283
|
|
|
118
|
-
|
|
119
|
-
export const Filterable: Story = {
|
|
284
|
+
export const EmptyState: Story = {
|
|
120
285
|
args: {
|
|
121
|
-
data:
|
|
286
|
+
data: [],
|
|
122
287
|
columns,
|
|
123
|
-
|
|
288
|
+
emptyMessage: 'No users found',
|
|
124
289
|
},
|
|
125
290
|
};
|
|
126
291
|
|
|
127
|
-
|
|
128
|
-
export const Paginated: Story = {
|
|
292
|
+
export const WithStripedRows: Story = {
|
|
129
293
|
args: {
|
|
130
294
|
data: users,
|
|
131
|
-
columns,
|
|
132
|
-
|
|
133
|
-
pageSize: 5,
|
|
295
|
+
columns: columns,
|
|
296
|
+
striped: true,
|
|
134
297
|
},
|
|
135
298
|
parameters: {
|
|
136
299
|
docs: {
|
|
137
300
|
description: {
|
|
138
|
-
story: '
|
|
301
|
+
story: 'DataTable with striped row styling for improved readability.',
|
|
139
302
|
},
|
|
140
303
|
},
|
|
141
304
|
},
|
|
142
305
|
};
|
|
143
306
|
|
|
144
|
-
|
|
145
|
-
export const PaginatedLargeDataset: Story = {
|
|
307
|
+
export const WithBorderedTable: Story = {
|
|
146
308
|
args: {
|
|
147
|
-
data:
|
|
309
|
+
data: users,
|
|
148
310
|
columns,
|
|
149
|
-
|
|
150
|
-
pageSize: 10,
|
|
151
|
-
},
|
|
152
|
-
parameters: {
|
|
153
|
-
docs: {
|
|
154
|
-
description: {
|
|
155
|
-
story:
|
|
156
|
-
'Pagination with a large dataset (100 items) demonstrating first/last buttons and ellipsis.',
|
|
157
|
-
},
|
|
158
|
-
},
|
|
311
|
+
bordered: true,
|
|
159
312
|
},
|
|
160
313
|
};
|
|
161
314
|
|
|
162
|
-
|
|
163
|
-
export const CompleteFeatures: Story = {
|
|
315
|
+
export const DenseSpacing: Story = {
|
|
164
316
|
args: {
|
|
165
|
-
data:
|
|
317
|
+
data: users,
|
|
166
318
|
columns,
|
|
167
319
|
sortable: true,
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
320
|
+
dense: true,
|
|
321
|
+
},
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
// ========================================
|
|
325
|
+
// SORTING & FILTERING STORIES
|
|
326
|
+
// ========================================
|
|
327
|
+
|
|
328
|
+
export const WithSorting: Story = {
|
|
329
|
+
args: {
|
|
330
|
+
data: users,
|
|
331
|
+
columns: columns,
|
|
332
|
+
sortable: true,
|
|
173
333
|
},
|
|
174
334
|
parameters: {
|
|
175
335
|
docs: {
|
|
176
336
|
description: {
|
|
177
|
-
story: '
|
|
337
|
+
story: 'DataTable with column sorting functionality enabled.',
|
|
178
338
|
},
|
|
179
339
|
},
|
|
180
340
|
},
|
|
181
341
|
};
|
|
182
342
|
|
|
183
|
-
|
|
184
|
-
export const Styled: Story = {
|
|
343
|
+
export const WithFiltering: Story = {
|
|
185
344
|
args: {
|
|
186
345
|
data: users,
|
|
187
346
|
columns,
|
|
188
|
-
|
|
189
|
-
striped: true,
|
|
190
|
-
bordered: true,
|
|
347
|
+
filterable: true,
|
|
191
348
|
},
|
|
192
349
|
};
|
|
193
350
|
|
|
194
|
-
|
|
195
|
-
export const Dense: Story = {
|
|
351
|
+
export const WithColumnFilters: Story = {
|
|
196
352
|
args: {
|
|
197
353
|
data: users,
|
|
198
|
-
columns
|
|
354
|
+
columns: columns.map(col => ({
|
|
355
|
+
...col,
|
|
356
|
+
filterable: ['name', 'role', 'email'].includes(col.key),
|
|
357
|
+
})),
|
|
358
|
+
columnFilters: true,
|
|
199
359
|
sortable: true,
|
|
200
|
-
dense: true,
|
|
201
360
|
},
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
columns,
|
|
209
|
-
emptyMessage: 'No users found',
|
|
210
|
-
},
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
// Loading example
|
|
214
|
-
export const Loading: Story = {
|
|
215
|
-
args: {
|
|
216
|
-
data: users,
|
|
217
|
-
columns,
|
|
218
|
-
loading: true,
|
|
361
|
+
parameters: {
|
|
362
|
+
docs: {
|
|
363
|
+
description: {
|
|
364
|
+
story: 'DataTable with column-specific filters. Each filterable column has its own filter input.',
|
|
365
|
+
},
|
|
366
|
+
},
|
|
219
367
|
},
|
|
220
368
|
};
|
|
221
369
|
|
|
222
|
-
//
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
const [selectedUser, setSelectedUser] = useState<any>(null);
|
|
370
|
+
// ========================================
|
|
371
|
+
// ROW SELECTION STORIES
|
|
372
|
+
// ========================================
|
|
226
373
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
374
|
+
export const WithRowSelectionSingle: Story = {
|
|
375
|
+
render: (args) => {
|
|
376
|
+
const [selectedRow, setSelectedRow] = useState<any>(null);
|
|
230
377
|
|
|
231
378
|
return (
|
|
232
379
|
<div>
|
|
233
|
-
<DataTable
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
<
|
|
244
|
-
|
|
380
|
+
<DataTable
|
|
381
|
+
{...args}
|
|
382
|
+
data={args.data || users}
|
|
383
|
+
columns={args.columns || columns}
|
|
384
|
+
selectionMode="single"
|
|
385
|
+
onSelectionChange={(rows) => setSelectedRow(rows[0] || null)}
|
|
386
|
+
/>
|
|
387
|
+
{selectedRow && (
|
|
388
|
+
<div className="u-mt-4 u-p-4 u-bg-gray-100 u-rounded u-text-sm">
|
|
389
|
+
<strong>Selected:</strong>
|
|
390
|
+
<pre className="u-mt-2 u-text-xs">
|
|
391
|
+
{JSON.stringify(selectedRow, null, 2)}
|
|
392
|
+
</pre>
|
|
245
393
|
</div>
|
|
246
394
|
)}
|
|
247
395
|
</div>
|
|
@@ -252,24 +400,32 @@ export const Interactive: Story = {
|
|
|
252
400
|
columns,
|
|
253
401
|
sortable: true,
|
|
254
402
|
},
|
|
403
|
+
parameters: {
|
|
404
|
+
docs: {
|
|
405
|
+
description: {
|
|
406
|
+
story: 'DataTable with single row selection enabled. Select a row using radio buttons.',
|
|
407
|
+
},
|
|
408
|
+
},
|
|
409
|
+
},
|
|
255
410
|
};
|
|
256
411
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
render: args => {
|
|
412
|
+
export const WithRowSelectionMultiple: Story = {
|
|
413
|
+
render: (args) => {
|
|
260
414
|
const [selectedRows, setSelectedRows] = useState<any[]>([]);
|
|
261
415
|
|
|
262
416
|
return (
|
|
263
417
|
<div>
|
|
264
418
|
<DataTable
|
|
265
419
|
{...args}
|
|
420
|
+
data={args.data || users}
|
|
421
|
+
columns={args.columns || columns}
|
|
266
422
|
selectionMode="multiple"
|
|
267
423
|
onSelectionChange={(rows, ids) => setSelectedRows(rows)}
|
|
268
424
|
/>
|
|
269
425
|
{selectedRows.length > 0 && (
|
|
270
|
-
<div
|
|
426
|
+
<div className="u-mt-4 u-p-4 u-bg-gray-100 u-rounded u-text-sm">
|
|
271
427
|
<strong>Selected: {selectedRows.length} row(s)</strong>
|
|
272
|
-
<pre
|
|
428
|
+
<pre className="u-mt-2 u-text-xs">
|
|
273
429
|
{JSON.stringify(selectedRows.map(r => r.name), null, 2)}
|
|
274
430
|
</pre>
|
|
275
431
|
</div>
|
|
@@ -291,24 +447,30 @@ export const RowSelectionMultiple: Story = {
|
|
|
291
447
|
},
|
|
292
448
|
};
|
|
293
449
|
|
|
294
|
-
//
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
450
|
+
// ========================================
|
|
451
|
+
// ADVANCED FEATURES STORIES
|
|
452
|
+
// ========================================
|
|
453
|
+
|
|
454
|
+
export const WithInteractiveRows: Story = {
|
|
455
|
+
render: (args) => {
|
|
456
|
+
const [selectedUser, setSelectedUser] = useState<any>(null);
|
|
457
|
+
|
|
458
|
+
const handleRowClick = (row: any) => {
|
|
459
|
+
setSelectedUser(row);
|
|
460
|
+
};
|
|
298
461
|
|
|
299
462
|
return (
|
|
300
463
|
<div>
|
|
301
|
-
<DataTable
|
|
302
|
-
{...args}
|
|
303
|
-
|
|
304
|
-
|
|
464
|
+
<DataTable
|
|
465
|
+
{...args}
|
|
466
|
+
data={args.data || users}
|
|
467
|
+
columns={args.columns || columns}
|
|
468
|
+
onRowClick={handleRowClick}
|
|
305
469
|
/>
|
|
306
|
-
{
|
|
307
|
-
<div
|
|
308
|
-
<
|
|
309
|
-
<pre
|
|
310
|
-
{JSON.stringify(selectedRow, null, 2)}
|
|
311
|
-
</pre>
|
|
470
|
+
{selectedUser && (
|
|
471
|
+
<div className="u-mt-4 u-p-4 u-border u-border-gray-300 u-rounded u-bg-white">
|
|
472
|
+
<h3 className="u-m-0">Selected User:</h3>
|
|
473
|
+
<pre className="u-m-0">{JSON.stringify(selectedUser, null, 2)}</pre>
|
|
312
474
|
</div>
|
|
313
475
|
)}
|
|
314
476
|
</div>
|
|
@@ -319,37 +481,50 @@ export const RowSelectionSingle: Story = {
|
|
|
319
481
|
columns,
|
|
320
482
|
sortable: true,
|
|
321
483
|
},
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
// ========================================
|
|
487
|
+
// PAGINATION STORIES
|
|
488
|
+
// ========================================
|
|
489
|
+
|
|
490
|
+
export const WithPagination: Story = {
|
|
491
|
+
args: {
|
|
492
|
+
data: largeDataSet,
|
|
493
|
+
columns: columns,
|
|
494
|
+
paginated: true,
|
|
495
|
+
pageSize: 5,
|
|
496
|
+
},
|
|
322
497
|
parameters: {
|
|
323
498
|
docs: {
|
|
324
499
|
description: {
|
|
325
|
-
story: 'DataTable with
|
|
500
|
+
story: 'DataTable with pagination enabled to handle large datasets.',
|
|
326
501
|
},
|
|
327
502
|
},
|
|
328
503
|
},
|
|
329
504
|
};
|
|
330
505
|
|
|
331
|
-
|
|
332
|
-
export const ColumnFilters: Story = {
|
|
506
|
+
export const WithPaginationLargeDataset: Story = {
|
|
333
507
|
args: {
|
|
334
|
-
data:
|
|
335
|
-
columns
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
})),
|
|
339
|
-
columnFilters: true,
|
|
340
|
-
sortable: true,
|
|
508
|
+
data: largeDataSet,
|
|
509
|
+
columns,
|
|
510
|
+
paginated: true,
|
|
511
|
+
pageSize: 10,
|
|
341
512
|
},
|
|
342
513
|
parameters: {
|
|
343
514
|
docs: {
|
|
344
515
|
description: {
|
|
345
|
-
story:
|
|
516
|
+
story:
|
|
517
|
+
'Pagination with a large dataset (100 items) demonstrating first/last buttons and ellipsis.',
|
|
346
518
|
},
|
|
347
519
|
},
|
|
348
520
|
},
|
|
349
521
|
};
|
|
350
522
|
|
|
351
|
-
//
|
|
352
|
-
|
|
523
|
+
// ========================================
|
|
524
|
+
// COLUMN CONFIGURATION STORIES
|
|
525
|
+
// ========================================
|
|
526
|
+
|
|
527
|
+
export const WithResizableColumns: Story = {
|
|
353
528
|
args: {
|
|
354
529
|
data: users,
|
|
355
530
|
columns: columns.map(col => ({
|
|
@@ -369,8 +544,7 @@ export const ResizableColumns: Story = {
|
|
|
369
544
|
},
|
|
370
545
|
};
|
|
371
546
|
|
|
372
|
-
|
|
373
|
-
export const ReorderableColumns: Story = {
|
|
547
|
+
export const WithReorderableColumns: Story = {
|
|
374
548
|
args: {
|
|
375
549
|
data: users,
|
|
376
550
|
columns,
|
|
@@ -386,8 +560,7 @@ export const ReorderableColumns: Story = {
|
|
|
386
560
|
},
|
|
387
561
|
};
|
|
388
562
|
|
|
389
|
-
|
|
390
|
-
export const ColumnVisibility: Story = {
|
|
563
|
+
export const WithColumnVisibilityToggle: Story = {
|
|
391
564
|
args: {
|
|
392
565
|
data: users,
|
|
393
566
|
columns,
|
|
@@ -403,8 +576,11 @@ export const ColumnVisibility: Story = {
|
|
|
403
576
|
},
|
|
404
577
|
};
|
|
405
578
|
|
|
406
|
-
//
|
|
407
|
-
|
|
579
|
+
// ========================================
|
|
580
|
+
// EXPORT & CUSTOMIZATION STORIES
|
|
581
|
+
// ========================================
|
|
582
|
+
|
|
583
|
+
export const WithExportFunctionality: Story = {
|
|
408
584
|
args: {
|
|
409
585
|
data: users,
|
|
410
586
|
columns,
|
|
@@ -422,8 +598,7 @@ export const Exportable: Story = {
|
|
|
422
598
|
},
|
|
423
599
|
};
|
|
424
600
|
|
|
425
|
-
|
|
426
|
-
export const StickyHeaders: Story = {
|
|
601
|
+
export const WithStickyHeaders: Story = {
|
|
427
602
|
args: {
|
|
428
603
|
data: largeDataSet,
|
|
429
604
|
columns,
|
|
@@ -442,20 +617,45 @@ export const StickyHeaders: Story = {
|
|
|
442
617
|
},
|
|
443
618
|
};
|
|
444
619
|
|
|
445
|
-
//
|
|
620
|
+
// ========================================
|
|
621
|
+
// COMPREHENSIVE EXAMPLES
|
|
622
|
+
// ========================================
|
|
623
|
+
|
|
624
|
+
export const CompleteFeatures: Story = {
|
|
625
|
+
args: {
|
|
626
|
+
data: largeDataSet,
|
|
627
|
+
columns,
|
|
628
|
+
sortable: true,
|
|
629
|
+
filterable: true,
|
|
630
|
+
paginated: true,
|
|
631
|
+
pageSize: 10,
|
|
632
|
+
striped: true,
|
|
633
|
+
bordered: true,
|
|
634
|
+
},
|
|
635
|
+
parameters: {
|
|
636
|
+
docs: {
|
|
637
|
+
description: {
|
|
638
|
+
story: 'A complete data table with sorting, filtering, and pagination enabled.',
|
|
639
|
+
},
|
|
640
|
+
},
|
|
641
|
+
},
|
|
642
|
+
};
|
|
643
|
+
|
|
446
644
|
export const AllAdvancedFeatures: Story = {
|
|
447
|
-
render: args => {
|
|
645
|
+
render: (args) => {
|
|
448
646
|
const [selectedRows, setSelectedRows] = useState<any[]>([]);
|
|
449
647
|
|
|
450
648
|
return (
|
|
451
649
|
<div>
|
|
452
650
|
<DataTable
|
|
453
651
|
{...args}
|
|
652
|
+
data={args.data || largeDataSet}
|
|
653
|
+
columns={args.columns || columns}
|
|
454
654
|
selectionMode="multiple"
|
|
455
655
|
onSelectionChange={(rows) => setSelectedRows(rows)}
|
|
456
656
|
/>
|
|
457
657
|
{selectedRows.length > 0 && (
|
|
458
|
-
<div
|
|
658
|
+
<div className="u-mt-4 u-p-4 u-bg-gray-100 u-rounded">
|
|
459
659
|
<strong>Selected: {selectedRows.length} row(s)</strong>
|
|
460
660
|
</div>
|
|
461
661
|
)}
|