@ds-mo/ui 0.2.4 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ds-accordion.d.ts +11 -0
- package/dist/components/ds-accordion.js +2 -0
- package/dist/components/ds-accordion.js.map +1 -0
- package/dist/components/ds-badge.d.ts +11 -0
- package/dist/components/ds-badge.js +2 -0
- package/dist/components/ds-badge.js.map +1 -0
- package/dist/components/ds-banner.d.ts +11 -0
- package/dist/components/ds-banner.js +2 -0
- package/dist/components/ds-banner.js.map +1 -0
- package/dist/components/ds-breadcrumb.d.ts +11 -0
- package/dist/components/ds-breadcrumb.js +2 -0
- package/dist/components/ds-breadcrumb.js.map +1 -0
- package/dist/components/ds-button.d.ts +11 -0
- package/dist/components/ds-button.js +2 -0
- package/dist/components/ds-button.js.map +1 -0
- package/dist/components/ds-card.d.ts +11 -0
- package/dist/components/ds-card.js +2 -0
- package/dist/components/ds-card.js.map +1 -0
- package/dist/components/ds-checkbox.d.ts +11 -0
- package/dist/components/ds-checkbox.js +2 -0
- package/dist/components/ds-checkbox.js.map +1 -0
- package/dist/components/ds-divider.d.ts +11 -0
- package/dist/components/ds-divider.js +2 -0
- package/dist/components/ds-divider.js.map +1 -0
- package/dist/components/ds-empty-state.d.ts +11 -0
- package/dist/components/ds-empty-state.js +2 -0
- package/dist/components/ds-empty-state.js.map +1 -0
- package/dist/components/ds-fade.d.ts +11 -0
- package/dist/components/ds-fade.js +2 -0
- package/dist/components/ds-fade.js.map +1 -0
- package/dist/components/ds-field.d.ts +11 -0
- package/dist/components/ds-field.js +2 -0
- package/dist/components/ds-field.js.map +1 -0
- package/dist/components/ds-header.d.ts +11 -0
- package/dist/components/ds-header.js +2 -0
- package/dist/components/ds-header.js.map +1 -0
- package/dist/components/ds-input.d.ts +11 -0
- package/dist/components/ds-input.js +2 -0
- package/dist/components/ds-input.js.map +1 -0
- package/dist/components/ds-loader.d.ts +11 -0
- package/dist/components/ds-loader.js +2 -0
- package/dist/components/ds-loader.js.map +1 -0
- package/dist/components/ds-menu.d.ts +11 -0
- package/dist/components/ds-menu.js +2 -0
- package/dist/components/ds-menu.js.map +1 -0
- package/dist/components/ds-modal.d.ts +11 -0
- package/dist/components/ds-modal.js +2 -0
- package/dist/components/ds-modal.js.map +1 -0
- package/dist/components/ds-pagination.d.ts +11 -0
- package/dist/components/ds-pagination.js +2 -0
- package/dist/components/ds-pagination.js.map +1 -0
- package/dist/components/ds-radio-group.d.ts +11 -0
- package/dist/components/ds-radio-group.js +2 -0
- package/dist/components/ds-radio-group.js.map +1 -0
- package/dist/components/ds-scrollbar.d.ts +11 -0
- package/dist/components/ds-scrollbar.js +2 -0
- package/dist/components/ds-scrollbar.js.map +1 -0
- package/dist/components/ds-sidebar.d.ts +11 -0
- package/dist/components/ds-sidebar.js +2 -0
- package/dist/components/ds-sidebar.js.map +1 -0
- package/dist/components/ds-skeleton.d.ts +11 -0
- package/dist/components/ds-skeleton.js +2 -0
- package/dist/components/ds-skeleton.js.map +1 -0
- package/dist/components/ds-slider.d.ts +11 -0
- package/dist/components/ds-slider.js +2 -0
- package/dist/components/ds-slider.js.map +1 -0
- package/dist/components/ds-surface.d.ts +11 -0
- package/dist/components/ds-surface.js +2 -0
- package/dist/components/ds-surface.js.map +1 -0
- package/dist/components/ds-tab-group.d.ts +11 -0
- package/dist/components/ds-tab-group.js +2 -0
- package/dist/components/ds-tab-group.js.map +1 -0
- package/dist/components/ds-table.d.ts +11 -0
- package/dist/components/ds-table.js +2 -0
- package/dist/components/ds-table.js.map +1 -0
- package/dist/components/ds-tag.d.ts +11 -0
- package/dist/components/ds-tag.js +2 -0
- package/dist/components/ds-tag.js.map +1 -0
- package/dist/components/ds-text.d.ts +11 -0
- package/dist/components/ds-text.js +2 -0
- package/dist/components/ds-text.js.map +1 -0
- package/dist/components/ds-toast-provider.d.ts +11 -0
- package/dist/components/ds-toast-provider.js +2 -0
- package/dist/components/ds-toast-provider.js.map +1 -0
- package/dist/components/ds-toggle.d.ts +11 -0
- package/dist/components/ds-toggle.js +2 -0
- package/dist/components/ds-toggle.js.map +1 -0
- package/dist/components/ds-tooltip.d.ts +11 -0
- package/dist/components/ds-tooltip.js +2 -0
- package/dist/components/ds-tooltip.js.map +1 -0
- package/dist/components/index.d.ts +33 -0
- package/dist/components/index.js +2 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/p-BcuUR5Ao.js +2 -0
- package/dist/components/p-BcuUR5Ao.js.map +1 -0
- package/dist/types/.stencil/Accordion/Accordion.d.ts +28 -0
- package/dist/types/.stencil/Badge/Badge.d.ts +8 -0
- package/dist/types/.stencil/Badge/index.d.ts +2 -0
- package/dist/types/.stencil/Banner/Banner.d.ts +29 -0
- package/dist/types/.stencil/Breadcrumb/Breadcrumb.d.ts +16 -0
- package/dist/types/.stencil/Button/Button.d.ts +38 -0
- package/dist/types/.stencil/Button/index.d.ts +2 -0
- package/dist/types/.stencil/Card/Card.d.ts +8 -0
- package/dist/types/.stencil/Checkbox/Checkbox.d.ts +13 -0
- package/dist/types/.stencil/Checkbox/index.d.ts +2 -0
- package/dist/types/.stencil/Divider/Divider.d.ts +7 -0
- package/dist/types/.stencil/Divider/index.d.ts +2 -0
- package/dist/types/.stencil/EmptyState/EmptyState.d.ts +7 -0
- package/dist/types/.stencil/Fade/Fade.d.ts +10 -0
- package/dist/types/.stencil/Fade/index.d.ts +2 -0
- package/dist/types/.stencil/Field/Field.d.ts +8 -0
- package/dist/types/.stencil/Header/Header.d.ts +7 -0
- package/dist/types/.stencil/Input/Input.d.ts +26 -0
- package/dist/types/.stencil/Input/index.d.ts +2 -0
- package/dist/types/.stencil/Loader/Loader.d.ts +12 -0
- package/dist/types/.stencil/Loader/index.d.ts +2 -0
- package/dist/types/.stencil/Menu/Menu.d.ts +60 -0
- package/dist/types/.stencil/Modal/Modal.d.ts +31 -0
- package/dist/types/.stencil/Pagination/Pagination.d.ts +11 -0
- package/dist/types/.stencil/RadioGroup/RadioGroup.d.ts +21 -0
- package/dist/types/.stencil/RadioGroup/index.d.ts +2 -0
- package/dist/types/.stencil/Scrollbar/Scrollbar.d.ts +27 -0
- package/dist/types/.stencil/Sidebar/Sidebar.d.ts +29 -0
- package/dist/types/.stencil/Skeleton/Skeleton.d.ts +16 -0
- package/dist/types/.stencil/Skeleton/index.d.ts +2 -0
- package/dist/types/.stencil/Slider/Slider.d.ts +18 -0
- package/dist/types/.stencil/Slider/index.d.ts +2 -0
- package/dist/types/.stencil/Surface/Surface.d.ts +22 -0
- package/dist/types/.stencil/TabGroup/TabGroup.d.ts +29 -0
- package/dist/types/.stencil/Table/Table.d.ts +50 -0
- package/dist/types/.stencil/Tag/Tag.d.ts +32 -0
- package/dist/types/.stencil/Tag/index.d.ts +2 -0
- package/dist/types/.stencil/Text/Text.d.ts +22 -0
- package/dist/types/.stencil/Text/index.d.ts +2 -0
- package/dist/types/.stencil/Toast/Toast.d.ts +15 -0
- package/dist/types/.stencil/Toast/toast-service.d.ts +24 -0
- package/dist/types/.stencil/Toggle/Toggle.d.ts +10 -0
- package/dist/types/.stencil/Toggle/index.d.ts +2 -0
- package/dist/types/.stencil/Tooltip/Tooltip.d.ts +36 -0
- package/dist/types/components.d.ts +2024 -0
- package/dist/types/stencil-public-runtime.d.ts +1860 -0
- package/package.json +33 -29
- package/src/angular/angular-component-lib/utils.ts +65 -0
- package/src/angular/index.ts +35 -0
- package/src/angular/proxies.ts +819 -0
- package/dist/index.css +0 -2
- package/dist/index.d.ts +0 -969
- package/dist/index.js +0 -2492
- package/dist/index.js.map +0 -1
- package/dist/r/accordion.json +0 -79
- package/dist/r/badge.json +0 -69
- package/dist/r/banner.json +0 -90
- package/dist/r/breadcrumb.json +0 -70
- package/dist/r/button-group.json +0 -65
- package/dist/r/button.json +0 -137
- package/dist/r/card.json +0 -82
- package/dist/r/checkbox.json +0 -91
- package/dist/r/divider.json +0 -57
- package/dist/r/empty-state.json +0 -69
- package/dist/r/error-boundary.json +0 -66
- package/dist/r/fade.json +0 -65
- package/dist/r/field.json +0 -71
- package/dist/r/header.json +0 -67
- package/dist/r/input.json +0 -77
- package/dist/r/loader.json +0 -54
- package/dist/r/menu.json +0 -130
- package/dist/r/modal.json +0 -93
- package/dist/r/pagination.json +0 -80
- package/dist/r/radio.json +0 -85
- package/dist/r/registry.json +0 -1600
- package/dist/r/scrollbar.json +0 -68
- package/dist/r/select.json +0 -93
- package/dist/r/sidebar.json +0 -105
- package/dist/r/skeleton.json +0 -72
- package/dist/r/slider.json +0 -87
- package/dist/r/surface.json +0 -97
- package/dist/r/tab-group.json +0 -72
- package/dist/r/tab.json +0 -71
- package/dist/r/table.json +0 -110
- package/dist/r/tag.json +0 -110
- package/dist/r/text.json +0 -94
- package/dist/r/toast.json +0 -77
- package/dist/r/toggle-button-group.json +0 -65
- package/dist/r/toggle-button.json +0 -94
- package/dist/r/toggle.json +0 -65
- package/dist/r/tooltip.json +0 -86
- package/src/components/Accordion/Accordion.module.css +0 -66
- package/src/components/Accordion/Accordion.stories.tsx +0 -95
- package/src/components/Accordion/Accordion.tsx +0 -122
- package/src/components/Accordion/index.ts +0 -2
- package/src/components/Badge/Badge.module.css +0 -6
- package/src/components/Badge/Badge.stories.tsx +0 -99
- package/src/components/Badge/Badge.tsx +0 -23
- package/src/components/Badge/index.ts +0 -2
- package/src/components/Banner/Banner.module.css +0 -67
- package/src/components/Banner/Banner.stories.tsx +0 -81
- package/src/components/Banner/Banner.tsx +0 -109
- package/src/components/Banner/index.ts +0 -2
- package/src/components/Breadcrumb/Breadcrumb.module.css +0 -46
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +0 -72
- package/src/components/Breadcrumb/Breadcrumb.tsx +0 -68
- package/src/components/Breadcrumb/index.ts +0 -2
- package/src/components/Button/Button.mdx +0 -143
- package/src/components/Button/Button.module.css +0 -343
- package/src/components/Button/Button.stories.tsx +0 -575
- package/src/components/Button/Button.tsx +0 -201
- package/src/components/Button/index.ts +0 -10
- package/src/components/ButtonGroup/ButtonGroup.module.css +0 -157
- package/src/components/ButtonGroup/ButtonGroup.stories.tsx +0 -384
- package/src/components/ButtonGroup/ButtonGroup.tsx +0 -122
- package/src/components/ButtonGroup/index.ts +0 -2
- package/src/components/Card/Card.module.css +0 -36
- package/src/components/Card/Card.stories.tsx +0 -78
- package/src/components/Card/Card.tsx +0 -53
- package/src/components/Card/index.ts +0 -2
- package/src/components/Checkbox/Checkbox.module.css +0 -47
- package/src/components/Checkbox/Checkbox.stories.tsx +0 -129
- package/src/components/Checkbox/Checkbox.tsx +0 -68
- package/src/components/Checkbox/index.ts +0 -2
- package/src/components/Divider/Divider.module.css +0 -19
- package/src/components/Divider/Divider.stories.tsx +0 -55
- package/src/components/Divider/Divider.tsx +0 -28
- package/src/components/Divider/index.ts +0 -2
- package/src/components/EmptyState/EmptyState.module.css +0 -8
- package/src/components/EmptyState/EmptyState.stories.tsx +0 -53
- package/src/components/EmptyState/EmptyState.tsx +0 -31
- package/src/components/EmptyState/index.ts +0 -2
- package/src/components/ErrorBoundary/ErrorBoundary.module.css +0 -18
- package/src/components/ErrorBoundary/ErrorBoundary.stories.tsx +0 -38
- package/src/components/ErrorBoundary/ErrorBoundary.tsx +0 -50
- package/src/components/ErrorBoundary/index.ts +0 -2
- package/src/components/Fade/Fade.module.css +0 -31
- package/src/components/Fade/Fade.stories.tsx +0 -35
- package/src/components/Fade/Fade.tsx +0 -33
- package/src/components/Fade/index.ts +0 -2
- package/src/components/Field/Field.module.css +0 -5
- package/src/components/Field/Field.stories.tsx +0 -111
- package/src/components/Field/Field.tsx +0 -22
- package/src/components/Field/index.ts +0 -2
- package/src/components/Header/Header.module.css +0 -33
- package/src/components/Header/Header.stories.tsx +0 -52
- package/src/components/Header/Header.tsx +0 -42
- package/src/components/Header/index.ts +0 -2
- package/src/components/Input/Input.module.css +0 -71
- package/src/components/Input/Input.stories.tsx +0 -135
- package/src/components/Input/Input.tsx +0 -76
- package/src/components/Input/index.ts +0 -2
- package/src/components/LabelWrap/LabelWrap.module.css +0 -34
- package/src/components/LabelWrap/LabelWrap.tsx +0 -32
- package/src/components/LabelWrap/index.ts +0 -1
- package/src/components/Loader/Loader.module.css +0 -9
- package/src/components/Loader/Loader.stories.tsx +0 -44
- package/src/components/Loader/Loader.tsx +0 -43
- package/src/components/Loader/index.ts +0 -2
- package/src/components/Menu/DestructiveMenuItem.module.css +0 -57
- package/src/components/Menu/DestructiveMenuItem.tsx +0 -64
- package/src/components/Menu/Menu.module.css +0 -49
- package/src/components/Menu/Menu.stories.tsx +0 -129
- package/src/components/Menu/Menu.tsx +0 -269
- package/src/components/Menu/MenuItem.module.css +0 -84
- package/src/components/Menu/MenuItem.tsx +0 -101
- package/src/components/Menu/index.ts +0 -6
- package/src/components/Modal/Modal.module.css +0 -67
- package/src/components/Modal/Modal.stories.tsx +0 -71
- package/src/components/Modal/Modal.tsx +0 -122
- package/src/components/Modal/index.ts +0 -2
- package/src/components/Pagination/Pagination.module.css +0 -64
- package/src/components/Pagination/Pagination.stories.tsx +0 -51
- package/src/components/Pagination/Pagination.tsx +0 -103
- package/src/components/Pagination/index.ts +0 -2
- package/src/components/Radio/Radio.module.css +0 -61
- package/src/components/Radio/Radio.stories.tsx +0 -101
- package/src/components/Radio/Radio.tsx +0 -108
- package/src/components/Radio/index.ts +0 -2
- package/src/components/Scrollbar/Scrollbar.module.css +0 -81
- package/src/components/Scrollbar/Scrollbar.stories.tsx +0 -46
- package/src/components/Scrollbar/Scrollbar.tsx +0 -187
- package/src/components/Scrollbar/index.ts +0 -2
- package/src/components/Select/Select.module.css +0 -31
- package/src/components/Select/Select.stories.tsx +0 -59
- package/src/components/Select/Select.tsx +0 -92
- package/src/components/Select/index.ts +0 -2
- package/src/components/Sidebar/Sidebar.module.css +0 -161
- package/src/components/Sidebar/Sidebar.stories.tsx +0 -125
- package/src/components/Sidebar/Sidebar.tsx +0 -129
- package/src/components/Sidebar/SidebarItem.tsx +0 -57
- package/src/components/Sidebar/SidebarSection.tsx +0 -42
- package/src/components/Sidebar/index.ts +0 -6
- package/src/components/Skeleton/Skeleton.module.css +0 -53
- package/src/components/Skeleton/Skeleton.stories.tsx +0 -89
- package/src/components/Skeleton/Skeleton.tsx +0 -66
- package/src/components/Skeleton/index.ts +0 -2
- package/src/components/Slider/Slider.module.css +0 -62
- package/src/components/Slider/Slider.stories.tsx +0 -120
- package/src/components/Slider/Slider.tsx +0 -74
- package/src/components/Slider/index.ts +0 -2
- package/src/components/Surface/Surface.module.css +0 -222
- package/src/components/Surface/Surface.stories.tsx +0 -213
- package/src/components/Surface/Surface.tsx +0 -219
- package/src/components/Surface/index.ts +0 -12
- package/src/components/Tab/Tab.module.css +0 -66
- package/src/components/Tab/Tab.stories.tsx +0 -103
- package/src/components/Tab/Tab.tsx +0 -41
- package/src/components/Tab/index.ts +0 -2
- package/src/components/TabGroup/TabGroup.module.css +0 -26
- package/src/components/TabGroup/TabGroup.stories.tsx +0 -60
- package/src/components/TabGroup/TabGroup.tsx +0 -83
- package/src/components/TabGroup/index.ts +0 -2
- package/src/components/Table/Table.module.css +0 -130
- package/src/components/Table/Table.stories.tsx +0 -111
- package/src/components/Table/Table.tsx +0 -226
- package/src/components/Table/index.ts +0 -11
- package/src/components/Tag/Tag.module.css +0 -270
- package/src/components/Tag/Tag.stories.tsx +0 -399
- package/src/components/Tag/Tag.tsx +0 -162
- package/src/components/Tag/index.ts +0 -2
- package/src/components/Text/Text.module.css +0 -166
- package/src/components/Text/Text.stories.tsx +0 -212
- package/src/components/Text/Text.tsx +0 -181
- package/src/components/Text/index.ts +0 -13
- package/src/components/Toast/Toast.module.css +0 -91
- package/src/components/Toast/Toast.stories.tsx +0 -66
- package/src/components/Toast/Toast.tsx +0 -182
- package/src/components/Toast/index.ts +0 -8
- package/src/components/Toggle/Toggle.module.css +0 -87
- package/src/components/Toggle/Toggle.stories.tsx +0 -85
- package/src/components/Toggle/Toggle.tsx +0 -52
- package/src/components/Toggle/index.ts +0 -2
- package/src/components/ToggleButton/ToggleButton.module.css +0 -172
- package/src/components/ToggleButton/ToggleButton.stories.tsx +0 -299
- package/src/components/ToggleButton/ToggleButton.tsx +0 -118
- package/src/components/ToggleButton/index.ts +0 -2
- package/src/components/ToggleButtonGroup/ToggleButtonGroup.module.css +0 -163
- package/src/components/ToggleButtonGroup/ToggleButtonGroup.stories.tsx +0 -341
- package/src/components/ToggleButtonGroup/ToggleButtonGroup.tsx +0 -111
- package/src/components/ToggleButtonGroup/index.ts +0 -2
- package/src/components/Tooltip/Tooltip.module.css +0 -45
- package/src/components/Tooltip/Tooltip.stories.tsx +0 -46
- package/src/components/Tooltip/Tooltip.tsx +0 -224
- package/src/components/Tooltip/index.ts +0 -2
- package/src/css-modules.d.ts +0 -4
- package/src/docs/ColorUsage.mdx +0 -195
- package/src/docs/ElevationUsage.mdx +0 -95
- package/src/docs/Introduction.mdx +0 -97
- package/src/docs/OpticalSizing.mdx +0 -178
- package/src/docs/TypographyUsage.mdx +0 -121
- package/src/index.ts +0 -154
- package/src/stories/Colors.stories.tsx +0 -528
- package/src/stories/Dimensions.stories.tsx +0 -200
- package/src/stories/Effects.stories.tsx +0 -231
- package/src/stories/Icons.stories.tsx +0 -159
- package/src/stories/Typography.stories.tsx +0 -157
- package/src/types/icons.ts +0 -15
- package/src/types/index.ts +0 -1
- package/src/utils/cn.ts +0 -6
- package/src/utils/css-tokens.ts +0 -22
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
|
-
import { TabGroup } from './TabGroup';
|
|
4
|
-
|
|
5
|
-
const meta: Meta<typeof TabGroup> = {
|
|
6
|
-
title: 'Classic/TabGroup',
|
|
7
|
-
component: TabGroup,
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export default meta;
|
|
11
|
-
type Story = StoryObj<typeof TabGroup>;
|
|
12
|
-
|
|
13
|
-
const TABS = [
|
|
14
|
-
{ label: 'Overview', id: 'overview' },
|
|
15
|
-
{ label: 'Activity', id: 'activity' },
|
|
16
|
-
{ label: 'Settings', id: 'settings' },
|
|
17
|
-
{ label: 'Members', id: 'members' },
|
|
18
|
-
];
|
|
19
|
-
|
|
20
|
-
const Controlled = (props: Partial<React.ComponentProps<typeof TabGroup>>) => {
|
|
21
|
-
const [active, setActive] = useState(0);
|
|
22
|
-
return (
|
|
23
|
-
<div>
|
|
24
|
-
<TabGroup tabs={TABS} activeIndex={active} onTabChange={setActive} {...props} />
|
|
25
|
-
<div style={{ padding: '16px 0', color: 'var(--color-foreground-secondary)', fontSize: 14 }}>
|
|
26
|
-
Content for: <strong>{TABS[active].label}</strong>
|
|
27
|
-
</div>
|
|
28
|
-
</div>
|
|
29
|
-
);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export const Playground: Story = {
|
|
33
|
-
render: () => <Controlled />,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const Default: Story = {
|
|
37
|
-
render: () => <Controlled />,
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export const ManyTabs: Story = {
|
|
41
|
-
render: () => (
|
|
42
|
-
<Controlled
|
|
43
|
-
tabs={[
|
|
44
|
-
{ label: 'Dashboard' },
|
|
45
|
-
{ label: 'Analytics' },
|
|
46
|
-
{ label: 'Reports' },
|
|
47
|
-
{ label: 'Users' },
|
|
48
|
-
{ label: 'Settings' },
|
|
49
|
-
{ label: 'Billing' },
|
|
50
|
-
{ label: 'Integrations' },
|
|
51
|
-
]}
|
|
52
|
-
/>
|
|
53
|
-
),
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export const TwoTabs: Story = {
|
|
57
|
-
render: () => (
|
|
58
|
-
<Controlled tabs={[{ label: 'Active' }, { label: 'Archived' }]} />
|
|
59
|
-
),
|
|
60
|
-
};
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, useRef, useEffect, useState, useCallback } from 'react';
|
|
2
|
-
import { cn } from '@/utils/cn';
|
|
3
|
-
import { Tab } from '@/components/Tab';
|
|
4
|
-
import styles from './TabGroup.module.css';
|
|
5
|
-
|
|
6
|
-
export interface TabGroupTab {
|
|
7
|
-
label: string;
|
|
8
|
-
id?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface TabGroupProps {
|
|
12
|
-
/** Tab definitions. */
|
|
13
|
-
tabs: TabGroupTab[];
|
|
14
|
-
/** Index of the active tab. */
|
|
15
|
-
activeIndex?: number;
|
|
16
|
-
/** Called when a tab is clicked. */
|
|
17
|
-
onTabChange?: (index: number) => void;
|
|
18
|
-
className?: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const TabGroup = forwardRef<HTMLDivElement, TabGroupProps>(
|
|
22
|
-
({ tabs, activeIndex = 0, onTabChange, className }, ref) => {
|
|
23
|
-
const tabsRef = useRef<(HTMLButtonElement | null)[]>([]);
|
|
24
|
-
const [indicator, setIndicator] = useState({ left: 0, width: 0 });
|
|
25
|
-
|
|
26
|
-
const updateIndicator = useCallback(() => {
|
|
27
|
-
const el = tabsRef.current[activeIndex];
|
|
28
|
-
if (el) {
|
|
29
|
-
const parent = el.parentElement;
|
|
30
|
-
if (parent) {
|
|
31
|
-
setIndicator({
|
|
32
|
-
left: el.offsetLeft,
|
|
33
|
-
width: el.offsetWidth,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}, [activeIndex]);
|
|
38
|
-
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
updateIndicator();
|
|
41
|
-
}, [updateIndicator]);
|
|
42
|
-
|
|
43
|
-
// Recalculate on resize
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
const observer = new ResizeObserver(updateIndicator);
|
|
46
|
-
const container = tabsRef.current[0]?.parentElement;
|
|
47
|
-
if (container) observer.observe(container);
|
|
48
|
-
return () => observer.disconnect();
|
|
49
|
-
}, [updateIndicator]);
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<div
|
|
53
|
-
ref={ref}
|
|
54
|
-
role="tablist"
|
|
55
|
-
className={cn(styles.tabGroup, className)}
|
|
56
|
-
>
|
|
57
|
-
<div className={styles.tabsRow}>
|
|
58
|
-
{tabs.map((tab, i) => (
|
|
59
|
-
<Tab
|
|
60
|
-
key={tab.id ?? i}
|
|
61
|
-
ref={el => { tabsRef.current[i] = el; }}
|
|
62
|
-
id={tab.id}
|
|
63
|
-
label={tab.label}
|
|
64
|
-
isSelected={i === activeIndex}
|
|
65
|
-
onClick={() => onTabChange?.(i)}
|
|
66
|
-
/>
|
|
67
|
-
))}
|
|
68
|
-
</div>
|
|
69
|
-
<div className={styles.track}>
|
|
70
|
-
<div
|
|
71
|
-
className={styles.indicator}
|
|
72
|
-
style={{
|
|
73
|
-
transform: `translateX(${indicator.left}px)`,
|
|
74
|
-
width: indicator.width,
|
|
75
|
-
}}
|
|
76
|
-
/>
|
|
77
|
-
</div>
|
|
78
|
-
</div>
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
TabGroup.displayName = 'TabGroup';
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
.tableWrapper {
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: column;
|
|
4
|
-
width: 100%;
|
|
5
|
-
overflow: hidden;
|
|
6
|
-
border-radius: var(--dimension-radius-075);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.tableScroll {
|
|
10
|
-
overflow-x: auto;
|
|
11
|
-
width: 100%;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.table {
|
|
15
|
-
display: grid;
|
|
16
|
-
width: 100%;
|
|
17
|
-
min-width: max-content;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.headerRow {
|
|
21
|
-
display: contents;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.headerCell {
|
|
25
|
-
display: flex;
|
|
26
|
-
align-items: center;
|
|
27
|
-
gap: var(--dimension-space-050);
|
|
28
|
-
padding: var(--dimension-space-075) var(--dimension-space-100);
|
|
29
|
-
background-color: var(--color-background-secondary);
|
|
30
|
-
border-bottom: var(--dimension-stroke-width-015) solid var(--color-border-primary);
|
|
31
|
-
-webkit-user-select: none;
|
|
32
|
-
user-select: none;
|
|
33
|
-
position: sticky;
|
|
34
|
-
top: 0;
|
|
35
|
-
z-index: 2;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.headerCell.sortable {
|
|
39
|
-
cursor: pointer;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.headerCell.sortable:hover {
|
|
43
|
-
background-color: var(--color-background-translucent);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.sortIndicator {
|
|
47
|
-
font-size: 12px;
|
|
48
|
-
color: var(--color-foreground-secondary);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.row {
|
|
52
|
-
display: contents;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.row:hover .cell {
|
|
56
|
-
background-color: var(--color-interaction-hover);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.rowSelected .cell {
|
|
60
|
-
background-color: var(--color-background-faint-brand);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.rowClickable {
|
|
64
|
-
cursor: pointer;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.cell {
|
|
68
|
-
display: flex;
|
|
69
|
-
align-items: center;
|
|
70
|
-
padding: var(--dimension-space-075) var(--dimension-space-100);
|
|
71
|
-
border-bottom: var(--dimension-stroke-width-015) solid var(--color-border-primary);
|
|
72
|
-
min-height: var(--dimension-size-500);
|
|
73
|
-
background-color: var(--color-background-primary);
|
|
74
|
-
transition: background-color var(--effect-motion-short-2);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.alignRight { justify-content: flex-end; text-align: right; }
|
|
78
|
-
.alignCenter { justify-content: center; text-align: center; }
|
|
79
|
-
|
|
80
|
-
.emptyRow {
|
|
81
|
-
display: flex;
|
|
82
|
-
align-items: center;
|
|
83
|
-
justify-content: center;
|
|
84
|
-
padding: var(--dimension-space-400);
|
|
85
|
-
background-color: var(--color-background-primary);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.skeleton {
|
|
89
|
-
height: 14px;
|
|
90
|
-
width: 60%;
|
|
91
|
-
background-color: var(--color-background-translucent);
|
|
92
|
-
border-radius: var(--dimension-radius-050);
|
|
93
|
-
animation: shimmer 1.5s infinite;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
@keyframes shimmer {
|
|
97
|
-
0% { opacity: 0.5; }
|
|
98
|
-
50% { opacity: 1; }
|
|
99
|
-
100% { opacity: 0.5; }
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
.pagination {
|
|
103
|
-
display: flex;
|
|
104
|
-
align-items: center;
|
|
105
|
-
justify-content: center;
|
|
106
|
-
gap: var(--dimension-space-100);
|
|
107
|
-
padding: var(--dimension-space-100);
|
|
108
|
-
border-top: var(--dimension-stroke-width-015) solid var(--color-border-primary);
|
|
109
|
-
background-color: var(--color-background-primary);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
.pageButton {
|
|
113
|
-
display: flex;
|
|
114
|
-
align-items: center;
|
|
115
|
-
padding: var(--dimension-space-050) var(--dimension-space-100);
|
|
116
|
-
background-color: transparent;
|
|
117
|
-
border: none;
|
|
118
|
-
border-radius: var(--dimension-radius-075);
|
|
119
|
-
cursor: pointer;
|
|
120
|
-
transition: background-color var(--effect-motion-short-2);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
.pageButton:hover:not(:disabled) {
|
|
124
|
-
background-color: var(--color-interaction-hover);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
.pageButton:disabled {
|
|
128
|
-
opacity: 0.4;
|
|
129
|
-
cursor: not-allowed;
|
|
130
|
-
}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
|
-
import { Table } from './Table';
|
|
4
|
-
|
|
5
|
-
interface User {
|
|
6
|
-
id: number;
|
|
7
|
-
name: string;
|
|
8
|
-
email: string;
|
|
9
|
-
role: string;
|
|
10
|
-
status: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const sampleData: User[] = [
|
|
14
|
-
{ id: 1, name: 'Alice Johnson', email: 'alice@example.com', role: 'Admin', status: 'Active' },
|
|
15
|
-
{ id: 2, name: 'Bob Smith', email: 'bob@example.com', role: 'Editor', status: 'Active' },
|
|
16
|
-
{ id: 3, name: 'Carol White', email: 'carol@example.com', role: 'Viewer', status: 'Inactive' },
|
|
17
|
-
{ id: 4, name: 'Dan Brown', email: 'dan@example.com', role: 'Editor', status: 'Active' },
|
|
18
|
-
{ id: 5, name: 'Eva Green', email: 'eva@example.com', role: 'Admin', status: 'Active' },
|
|
19
|
-
{ id: 6, name: 'Frank Lee', email: 'frank@example.com', role: 'Viewer', status: 'Inactive' },
|
|
20
|
-
{ id: 7, name: 'Grace Kim', email: 'grace@example.com', role: 'Editor', status: 'Active' },
|
|
21
|
-
{ id: 8, name: 'Hank Miller', email: 'hank@example.com', role: 'Viewer', status: 'Active' },
|
|
22
|
-
];
|
|
23
|
-
|
|
24
|
-
const columns = [
|
|
25
|
-
{ id: 'name', header: 'Name', accessorKey: 'name', sortable: true },
|
|
26
|
-
{ id: 'email', header: 'Email', accessorKey: 'email' },
|
|
27
|
-
{ id: 'role', header: 'Role', accessorKey: 'role', sortable: true },
|
|
28
|
-
{ id: 'status', header: 'Status', accessorKey: 'status' },
|
|
29
|
-
];
|
|
30
|
-
|
|
31
|
-
const meta: Meta<typeof Table> = {
|
|
32
|
-
title: 'Components/Table',
|
|
33
|
-
component: Table,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export default meta;
|
|
37
|
-
type Story = StoryObj<typeof Table>;
|
|
38
|
-
|
|
39
|
-
export const Default: Story = {
|
|
40
|
-
render: () => (
|
|
41
|
-
<div style={{ padding: 24 }}>
|
|
42
|
-
<Table columns={columns} data={sampleData} />
|
|
43
|
-
</div>
|
|
44
|
-
),
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export const WithSorting: Story = {
|
|
48
|
-
render: () => {
|
|
49
|
-
const [sortState, setSortState] = useState<{ columnId: string; direction: 'asc' | 'desc' }>({ columnId: 'name', direction: 'asc' });
|
|
50
|
-
return (
|
|
51
|
-
<div style={{ padding: 24 }}>
|
|
52
|
-
<Table
|
|
53
|
-
columns={columns}
|
|
54
|
-
data={sampleData}
|
|
55
|
-
sortState={sortState}
|
|
56
|
-
onSort={(columnId) => {
|
|
57
|
-
setSortState(prev =>
|
|
58
|
-
prev.columnId === columnId
|
|
59
|
-
? { columnId, direction: prev.direction === 'asc' ? 'desc' : 'asc' }
|
|
60
|
-
: { columnId, direction: 'asc' }
|
|
61
|
-
);
|
|
62
|
-
}}
|
|
63
|
-
/>
|
|
64
|
-
</div>
|
|
65
|
-
);
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export const WithPagination: Story = {
|
|
70
|
-
render: () => {
|
|
71
|
-
const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 3 });
|
|
72
|
-
return (
|
|
73
|
-
<div style={{ padding: 24 }}>
|
|
74
|
-
<Table
|
|
75
|
-
columns={columns}
|
|
76
|
-
data={sampleData}
|
|
77
|
-
pagination={pagination}
|
|
78
|
-
onPaginationChange={(pageIndex, pageSize) => setPagination({ pageIndex, pageSize })}
|
|
79
|
-
/>
|
|
80
|
-
</div>
|
|
81
|
-
);
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export const ClickableRows: Story = {
|
|
86
|
-
render: () => (
|
|
87
|
-
<div style={{ padding: 24 }}>
|
|
88
|
-
<Table
|
|
89
|
-
columns={columns}
|
|
90
|
-
data={sampleData.slice(0, 4)}
|
|
91
|
-
onRowClick={(row) => alert(`Clicked: ${(row as User).name}`)}
|
|
92
|
-
/>
|
|
93
|
-
</div>
|
|
94
|
-
),
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
export const Loading: Story = {
|
|
98
|
-
render: () => (
|
|
99
|
-
<div style={{ padding: 24 }}>
|
|
100
|
-
<Table columns={columns} data={[]} loading />
|
|
101
|
-
</div>
|
|
102
|
-
),
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export const Empty: Story = {
|
|
106
|
-
render: () => (
|
|
107
|
-
<div style={{ padding: 24 }}>
|
|
108
|
-
<Table columns={columns} data={[]} emptyMessage="No users found." />
|
|
109
|
-
</div>
|
|
110
|
-
),
|
|
111
|
-
};
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import React, { useMemo, useState, useCallback } from 'react';
|
|
2
|
-
import { cn } from '@/utils/cn';
|
|
3
|
-
import { Text } from '@/components/Text';
|
|
4
|
-
import styles from './Table.module.css';
|
|
5
|
-
|
|
6
|
-
export type SortDirection = 'asc' | 'desc';
|
|
7
|
-
export type CellType = 'string' | 'numbers' | 'tag' | 'checkbox' | 'button' | 'spacer' | 'image' | 'icon' | 'empty';
|
|
8
|
-
export type FilterValue = string | number | Array<string | number> | undefined;
|
|
9
|
-
export type FilterState = Record<string, FilterValue>;
|
|
10
|
-
|
|
11
|
-
export interface SortState {
|
|
12
|
-
columnId: string;
|
|
13
|
-
direction: SortDirection;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface PaginationState {
|
|
17
|
-
pageIndex: number;
|
|
18
|
-
pageSize: number;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface TableColumn<T = unknown> {
|
|
22
|
-
id: string;
|
|
23
|
-
header: string | React.ReactNode;
|
|
24
|
-
accessorKey?: string;
|
|
25
|
-
accessor?: (row: T) => unknown;
|
|
26
|
-
sortable?: boolean;
|
|
27
|
-
align?: 'left' | 'right' | 'center';
|
|
28
|
-
width?: string | number;
|
|
29
|
-
minWidth?: string | number;
|
|
30
|
-
maxWidth?: string | number;
|
|
31
|
-
renderCell?: (row: T, rowIndex: number) => React.ReactNode;
|
|
32
|
-
cellType?: CellType;
|
|
33
|
-
hide?: boolean;
|
|
34
|
-
pinned?: 'left' | 'right';
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface TableProps<T = unknown> {
|
|
38
|
-
columns: TableColumn<T>[];
|
|
39
|
-
data: T[];
|
|
40
|
-
sortState?: SortState;
|
|
41
|
-
onSort?: (columnId: string) => void;
|
|
42
|
-
className?: string;
|
|
43
|
-
onRowClick?: (row: T, rowIndex: number) => void;
|
|
44
|
-
selectedRows?: Set<number>;
|
|
45
|
-
loading?: boolean;
|
|
46
|
-
pagination?: PaginationState;
|
|
47
|
-
onPaginationChange?: (pageIndex: number, pageSize: number) => void;
|
|
48
|
-
emptyMessage?: string;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function getColumnValue<T>(column: TableColumn<T>, row: T): unknown {
|
|
52
|
-
if (column.accessorKey) return (row as Record<string, unknown>)[column.accessorKey];
|
|
53
|
-
if (column.accessor) return column.accessor(row);
|
|
54
|
-
return undefined;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function compareValues(a: unknown, b: unknown, direction: SortDirection): number {
|
|
58
|
-
const mult = direction === 'asc' ? 1 : -1;
|
|
59
|
-
if (a == null && b == null) return 0;
|
|
60
|
-
if (a == null) return mult;
|
|
61
|
-
if (b == null) return -mult;
|
|
62
|
-
if (typeof a === 'number' && typeof b === 'number') return (a - b) * mult;
|
|
63
|
-
return String(a).localeCompare(String(b)) * mult;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function Table<T>({
|
|
67
|
-
columns,
|
|
68
|
-
data,
|
|
69
|
-
sortState,
|
|
70
|
-
onSort,
|
|
71
|
-
className,
|
|
72
|
-
onRowClick,
|
|
73
|
-
selectedRows,
|
|
74
|
-
loading = false,
|
|
75
|
-
pagination,
|
|
76
|
-
onPaginationChange,
|
|
77
|
-
emptyMessage = 'No results found.',
|
|
78
|
-
}: TableProps<T>) {
|
|
79
|
-
const visibleColumns = useMemo(() => columns.filter(c => !c.hide), [columns]);
|
|
80
|
-
|
|
81
|
-
const gridTemplateColumns = useMemo(() =>
|
|
82
|
-
visibleColumns.map(col => {
|
|
83
|
-
if (col.width) return typeof col.width === 'number' ? `${col.width}px` : col.width;
|
|
84
|
-
return 'minmax(120px, 1fr)';
|
|
85
|
-
}).join(' '),
|
|
86
|
-
[visibleColumns]
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
const sortedData = useMemo(() => {
|
|
90
|
-
if (!sortState) return data;
|
|
91
|
-
const col = columns.find(c => c.id === sortState.columnId);
|
|
92
|
-
if (!col) return data;
|
|
93
|
-
return [...data].sort((a, b) =>
|
|
94
|
-
compareValues(getColumnValue(col, a), getColumnValue(col, b), sortState.direction)
|
|
95
|
-
);
|
|
96
|
-
}, [data, columns, sortState]);
|
|
97
|
-
|
|
98
|
-
const pagedData = useMemo(() => {
|
|
99
|
-
if (!pagination) return sortedData;
|
|
100
|
-
const start = pagination.pageIndex * pagination.pageSize;
|
|
101
|
-
return sortedData.slice(start, start + pagination.pageSize);
|
|
102
|
-
}, [sortedData, pagination]);
|
|
103
|
-
|
|
104
|
-
const totalPages = pagination ? Math.ceil(sortedData.length / pagination.pageSize) : 1;
|
|
105
|
-
const isEmpty = !loading && pagedData.length === 0;
|
|
106
|
-
|
|
107
|
-
const handleSort = (columnId: string) => {
|
|
108
|
-
if (onSort) onSort(columnId);
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
return (
|
|
112
|
-
<div className={cn(styles.tableWrapper, className)}>
|
|
113
|
-
<div className={styles.tableScroll}>
|
|
114
|
-
<div className={styles.table} style={{ gridTemplateColumns }} role="table">
|
|
115
|
-
{/* Header */}
|
|
116
|
-
<div className={styles.headerRow} role="row">
|
|
117
|
-
{visibleColumns.map(col => (
|
|
118
|
-
<div
|
|
119
|
-
key={col.id}
|
|
120
|
-
className={cn(
|
|
121
|
-
styles.headerCell,
|
|
122
|
-
col.sortable && styles.sortable,
|
|
123
|
-
col.align === 'right' && styles.alignRight,
|
|
124
|
-
col.align === 'center' && styles.alignCenter
|
|
125
|
-
)}
|
|
126
|
-
role="columnheader"
|
|
127
|
-
onClick={() => col.sortable && handleSort(col.id)}
|
|
128
|
-
style={col.minWidth ? { minWidth: typeof col.minWidth === 'number' ? `${col.minWidth}px` : col.minWidth } : undefined}
|
|
129
|
-
>
|
|
130
|
-
{typeof col.header === 'string' ? (
|
|
131
|
-
<Text variant="text-body-small-emphasis" as="span" color="secondary">
|
|
132
|
-
{col.header}
|
|
133
|
-
</Text>
|
|
134
|
-
) : col.header}
|
|
135
|
-
{sortState?.columnId === col.id && (
|
|
136
|
-
<span className={styles.sortIndicator} aria-hidden>
|
|
137
|
-
{sortState.direction === 'asc' ? '\u2191' : '\u2193'}
|
|
138
|
-
</span>
|
|
139
|
-
)}
|
|
140
|
-
</div>
|
|
141
|
-
))}
|
|
142
|
-
</div>
|
|
143
|
-
|
|
144
|
-
{/* Loading skeleton */}
|
|
145
|
-
{loading && Array.from({ length: 5 }).map((_, i) => (
|
|
146
|
-
<div key={`skeleton-${i}`} className={styles.row} role="row">
|
|
147
|
-
{visibleColumns.map(col => (
|
|
148
|
-
<div key={col.id} className={styles.cell} role="cell">
|
|
149
|
-
<div className={styles.skeleton} />
|
|
150
|
-
</div>
|
|
151
|
-
))}
|
|
152
|
-
</div>
|
|
153
|
-
))}
|
|
154
|
-
|
|
155
|
-
{/* Empty state */}
|
|
156
|
-
{isEmpty && (
|
|
157
|
-
<div className={styles.emptyRow} style={{ gridColumn: `1 / -1` }}>
|
|
158
|
-
<Text variant="text-body-medium" as="p" color="secondary">{emptyMessage}</Text>
|
|
159
|
-
</div>
|
|
160
|
-
)}
|
|
161
|
-
|
|
162
|
-
{/* Data rows */}
|
|
163
|
-
{!loading && pagedData.map((row, rowIndex) => {
|
|
164
|
-
const isSelected = selectedRows?.has(rowIndex);
|
|
165
|
-
return (
|
|
166
|
-
<div
|
|
167
|
-
key={rowIndex}
|
|
168
|
-
className={cn(
|
|
169
|
-
styles.row,
|
|
170
|
-
isSelected && styles.rowSelected,
|
|
171
|
-
onRowClick && styles.rowClickable
|
|
172
|
-
)}
|
|
173
|
-
role="row"
|
|
174
|
-
onClick={() => onRowClick?.(row, rowIndex)}
|
|
175
|
-
>
|
|
176
|
-
{visibleColumns.map(col => (
|
|
177
|
-
<div
|
|
178
|
-
key={col.id}
|
|
179
|
-
className={cn(
|
|
180
|
-
styles.cell,
|
|
181
|
-
col.align === 'right' && styles.alignRight,
|
|
182
|
-
col.align === 'center' && styles.alignCenter
|
|
183
|
-
)}
|
|
184
|
-
role="cell"
|
|
185
|
-
>
|
|
186
|
-
{col.renderCell
|
|
187
|
-
? col.renderCell(row, rowIndex)
|
|
188
|
-
: <Text variant="text-body-medium" as="span" lineTruncation={1}>{String(getColumnValue(col, row) ?? '')}</Text>
|
|
189
|
-
}
|
|
190
|
-
</div>
|
|
191
|
-
))}
|
|
192
|
-
</div>
|
|
193
|
-
);
|
|
194
|
-
})}
|
|
195
|
-
</div>
|
|
196
|
-
</div>
|
|
197
|
-
|
|
198
|
-
{/* Pagination */}
|
|
199
|
-
{pagination && onPaginationChange && totalPages > 1 && (
|
|
200
|
-
<div className={styles.pagination}>
|
|
201
|
-
<button
|
|
202
|
-
className={styles.pageButton}
|
|
203
|
-
disabled={pagination.pageIndex === 0}
|
|
204
|
-
onClick={() => onPaginationChange(pagination.pageIndex - 1, pagination.pageSize)}
|
|
205
|
-
type="button"
|
|
206
|
-
>
|
|
207
|
-
<Text variant="text-body-small" as="span">Previous</Text>
|
|
208
|
-
</button>
|
|
209
|
-
<Text variant="text-body-small" as="span" color="secondary">
|
|
210
|
-
{`Page ${pagination.pageIndex + 1} of ${totalPages}`}
|
|
211
|
-
</Text>
|
|
212
|
-
<button
|
|
213
|
-
className={styles.pageButton}
|
|
214
|
-
disabled={pagination.pageIndex >= totalPages - 1}
|
|
215
|
-
onClick={() => onPaginationChange(pagination.pageIndex + 1, pagination.pageSize)}
|
|
216
|
-
type="button"
|
|
217
|
-
>
|
|
218
|
-
<Text variant="text-body-small" as="span">Next</Text>
|
|
219
|
-
</button>
|
|
220
|
-
</div>
|
|
221
|
-
)}
|
|
222
|
-
</div>
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
Table.displayName = 'Table';
|