@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,84 +0,0 @@
|
|
|
1
|
-
.menuItem {
|
|
2
|
-
display: flex;
|
|
3
|
-
align-items: center;
|
|
4
|
-
gap: var(--dimension-space-050);
|
|
5
|
-
padding: var(--dimension-space-075);
|
|
6
|
-
border: none;
|
|
7
|
-
cursor: pointer;
|
|
8
|
-
-webkit-user-select: none;
|
|
9
|
-
user-select: none;
|
|
10
|
-
text-align: left;
|
|
11
|
-
width: 100%;
|
|
12
|
-
min-height: var(--dimension-size-400);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.menuItem:has(.subtext) { align-items: flex-start; }
|
|
16
|
-
|
|
17
|
-
.iconPrefix {
|
|
18
|
-
flex-shrink: 0;
|
|
19
|
-
display: flex;
|
|
20
|
-
align-items: center;
|
|
21
|
-
color: var(--color-foreground-secondary);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.menuItemSelected .iconPrefix { color: var(--color-foreground-primary); }
|
|
25
|
-
|
|
26
|
-
.content {
|
|
27
|
-
flex: 1;
|
|
28
|
-
display: flex;
|
|
29
|
-
flex-direction: column;
|
|
30
|
-
gap: var(--dimension-space-025);
|
|
31
|
-
min-width: 0;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.label { color: var(--color-foreground-secondary); }
|
|
35
|
-
.menuItem:has(.subtext) .label { color: var(--color-foreground-primary); }
|
|
36
|
-
.menuItemSelected .label { color: var(--color-foreground-primary) !important; }
|
|
37
|
-
.menuItemLabelTertiary .label, .menuItemLabelTertiary .iconPrefix { color: var(--color-foreground-tertiary); }
|
|
38
|
-
.menuItemNegative .label { color: var(--color-foreground-bold-negative) !important; }
|
|
39
|
-
|
|
40
|
-
.subtext { color: var(--color-foreground-secondary); line-height: 1.4; }
|
|
41
|
-
|
|
42
|
-
.menuItemInactive { opacity: 0.5; cursor: default; pointer-events: none; }
|
|
43
|
-
|
|
44
|
-
.toggleSuffix { flex-shrink: 0; display: flex; align-items: center; }
|
|
45
|
-
|
|
46
|
-
.toggle {
|
|
47
|
-
width: calc(var(--dimension-size-400) + var(--dimension-size-050));
|
|
48
|
-
height: var(--dimension-size-250);
|
|
49
|
-
background-color: var(--color-background-translucent);
|
|
50
|
-
border-radius: var(--dimension-radius-125);
|
|
51
|
-
position: relative;
|
|
52
|
-
transition: var(--effect-transition-interaction-background-short-2);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.toggleOn { background-color: var(--color-background-medium-brand); }
|
|
56
|
-
|
|
57
|
-
.toggleThumb {
|
|
58
|
-
width: var(--dimension-size-200);
|
|
59
|
-
height: var(--dimension-size-200);
|
|
60
|
-
background-color: var(--color-foreground-on-bold-background-primary);
|
|
61
|
-
border-radius: 50%;
|
|
62
|
-
position: absolute;
|
|
63
|
-
top: var(--dimension-space-025);
|
|
64
|
-
left: var(--dimension-space-025);
|
|
65
|
-
transition: transform var(--effect-motion-short-2);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
.toggleOn .toggleThumb { transform: translateX(var(--dimension-offset-200)); }
|
|
69
|
-
|
|
70
|
-
.checkSuffix {
|
|
71
|
-
flex-shrink: 0;
|
|
72
|
-
display: flex;
|
|
73
|
-
align-items: center;
|
|
74
|
-
color: var(--color-foreground-primary);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.chevronSuffix {
|
|
78
|
-
flex-shrink: 0;
|
|
79
|
-
display: flex;
|
|
80
|
-
align-items: center;
|
|
81
|
-
color: var(--color-foreground-secondary);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.menuItemSelected .chevronSuffix { color: var(--color-foreground-primary); }
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef } from 'react';
|
|
2
|
-
import { Text } from '@/components/Text';
|
|
3
|
-
import { Surface } from '@/components/Surface';
|
|
4
|
-
import type { IconComponent } from '@/types';
|
|
5
|
-
import styles from './MenuItem.module.css';
|
|
6
|
-
|
|
7
|
-
export type MenuItemSelectionStyle = 'highlight' | 'radio' | 'noOverlay';
|
|
8
|
-
|
|
9
|
-
export interface MenuItemProps {
|
|
10
|
-
label: string;
|
|
11
|
-
onClick: () => void;
|
|
12
|
-
isSelected?: boolean;
|
|
13
|
-
isInactive?: boolean;
|
|
14
|
-
icon?: IconComponent;
|
|
15
|
-
labelColor?: 'primary' | 'secondary' | 'tertiary';
|
|
16
|
-
subtext?: string;
|
|
17
|
-
showToggle?: boolean;
|
|
18
|
-
toggleValue?: boolean;
|
|
19
|
-
intent?: 'negative';
|
|
20
|
-
selectionStyle?: MenuItemSelectionStyle;
|
|
21
|
-
showTrailingChevron?: boolean;
|
|
22
|
-
checkIcon?: IconComponent;
|
|
23
|
-
chevronIcon?: IconComponent;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export const MenuItem = forwardRef<HTMLButtonElement, MenuItemProps>(
|
|
27
|
-
({
|
|
28
|
-
label,
|
|
29
|
-
onClick,
|
|
30
|
-
isSelected = false,
|
|
31
|
-
isInactive = false,
|
|
32
|
-
icon: Icon,
|
|
33
|
-
labelColor,
|
|
34
|
-
subtext,
|
|
35
|
-
showToggle = false,
|
|
36
|
-
toggleValue = false,
|
|
37
|
-
intent,
|
|
38
|
-
selectionStyle = 'highlight',
|
|
39
|
-
showTrailingChevron = false,
|
|
40
|
-
checkIcon: CheckIcon,
|
|
41
|
-
chevronIcon: ChevronIcon,
|
|
42
|
-
}, ref) => {
|
|
43
|
-
const useRadioStyle = selectionStyle === 'radio';
|
|
44
|
-
const noOverlay = selectionStyle === 'noOverlay' || useRadioStyle;
|
|
45
|
-
const showSelectedOverlay = isSelected && !noOverlay;
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<Surface
|
|
49
|
-
ref={ref as React.Ref<HTMLElement>}
|
|
50
|
-
as="button"
|
|
51
|
-
interactive={!isInactive}
|
|
52
|
-
selected={showSelectedOverlay}
|
|
53
|
-
radius="sm"
|
|
54
|
-
className={`${styles.menuItem} ${isSelected ? styles.menuItemSelected : ''} ${isInactive ? styles.menuItemInactive : ''} ${intent === 'negative' ? styles.menuItemNegative : ''} ${labelColor === 'tertiary' ? styles.menuItemLabelTertiary : ''}`}
|
|
55
|
-
onClick={onClick}
|
|
56
|
-
type="button"
|
|
57
|
-
inactive={isInactive}
|
|
58
|
-
>
|
|
59
|
-
{Icon && (
|
|
60
|
-
<div className={styles.iconPrefix}>
|
|
61
|
-
<Icon size={20} />
|
|
62
|
-
</div>
|
|
63
|
-
)}
|
|
64
|
-
<div className={styles.content}>
|
|
65
|
-
<Text
|
|
66
|
-
variant={isSelected ? 'text-body-medium-emphasis' : 'text-body-medium'}
|
|
67
|
-
color={labelColor}
|
|
68
|
-
as="span"
|
|
69
|
-
className={styles.label}
|
|
70
|
-
>
|
|
71
|
-
{label}
|
|
72
|
-
</Text>
|
|
73
|
-
{subtext && (
|
|
74
|
-
<Text variant="text-body-small" as="span" className={styles.subtext}>
|
|
75
|
-
{subtext}
|
|
76
|
-
</Text>
|
|
77
|
-
)}
|
|
78
|
-
</div>
|
|
79
|
-
{showToggle && (
|
|
80
|
-
<div className={styles.toggleSuffix}>
|
|
81
|
-
<div className={`${styles.toggle} ${toggleValue ? styles.toggleOn : ''}`}>
|
|
82
|
-
<div className={styles.toggleThumb} />
|
|
83
|
-
</div>
|
|
84
|
-
</div>
|
|
85
|
-
)}
|
|
86
|
-
{useRadioStyle && isSelected && CheckIcon && (
|
|
87
|
-
<div className={styles.checkSuffix}>
|
|
88
|
-
<CheckIcon size={20} />
|
|
89
|
-
</div>
|
|
90
|
-
)}
|
|
91
|
-
{showTrailingChevron && ChevronIcon && (
|
|
92
|
-
<div className={styles.chevronSuffix}>
|
|
93
|
-
<ChevronIcon size={20} />
|
|
94
|
-
</div>
|
|
95
|
-
)}
|
|
96
|
-
</Surface>
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
MenuItem.displayName = 'MenuItem';
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { Menu } from './Menu';
|
|
2
|
-
export type { MenuProps, MenuSection, MenuItemData, MenuSide, MenuAlign } from './Menu';
|
|
3
|
-
export { MenuItem } from './MenuItem';
|
|
4
|
-
export type { MenuItemProps, MenuItemSelectionStyle } from './MenuItem';
|
|
5
|
-
export { DestructiveMenuItem } from './DestructiveMenuItem';
|
|
6
|
-
export type { DestructiveMenuItemProps } from './DestructiveMenuItem';
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
.backdrop {
|
|
2
|
-
position: fixed;
|
|
3
|
-
inset: 0;
|
|
4
|
-
display: flex;
|
|
5
|
-
align-items: center;
|
|
6
|
-
justify-content: center;
|
|
7
|
-
padding: var(--dimension-space-200);
|
|
8
|
-
background-color: var(--color-background-shade);
|
|
9
|
-
backdrop-filter: blur(var(--effect-blur-sm));
|
|
10
|
-
-webkit-backdrop-filter: blur(var(--effect-blur-sm));
|
|
11
|
-
animation: modalBackdropFadeIn var(--effect-motion-short-2) forwards;
|
|
12
|
-
z-index: 9999;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.backdrop.closing {
|
|
16
|
-
animation: modalBackdropFadeOut var(--effect-motion-short-3) forwards;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
@keyframes modalBackdropFadeIn {
|
|
20
|
-
from { opacity: 0; }
|
|
21
|
-
to { opacity: 1; }
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
@keyframes modalBackdropFadeOut {
|
|
25
|
-
from { opacity: 1; }
|
|
26
|
-
to { opacity: 0; }
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.dialog {
|
|
30
|
-
display: flex;
|
|
31
|
-
flex-direction: column;
|
|
32
|
-
max-height: calc(100vh - 32px);
|
|
33
|
-
overflow: hidden;
|
|
34
|
-
animation: modalDialogFadeIn var(--effect-motion-short-2) forwards;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.backdrop.closing .dialog {
|
|
38
|
-
animation: modalDialogFadeOut var(--effect-motion-short-3) forwards;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@keyframes modalDialogFadeIn {
|
|
42
|
-
from { opacity: 0; }
|
|
43
|
-
to { opacity: 1; }
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
@keyframes modalDialogFadeOut {
|
|
47
|
-
from { opacity: 1; }
|
|
48
|
-
to { opacity: 0; }
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.header {
|
|
52
|
-
padding: var(--dimension-space-200) var(--dimension-space-200) var(--dimension-space-100) var(--dimension-space-200);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.subtitle {
|
|
56
|
-
margin-top: var(--dimension-space-100);
|
|
57
|
-
text-wrap: balance;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.body {
|
|
61
|
-
padding: var(--dimension-space-100) var(--dimension-space-200);
|
|
62
|
-
overflow-y: auto;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.footer {
|
|
66
|
-
padding: var(--dimension-space-100) var(--dimension-space-200) var(--dimension-space-200) var(--dimension-space-200);
|
|
67
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
|
-
import { Modal } from './Modal';
|
|
4
|
-
import { Button } from '../Button';
|
|
5
|
-
|
|
6
|
-
const meta: Meta<typeof Modal> = {
|
|
7
|
-
title: 'Components/Modal',
|
|
8
|
-
component: Modal,
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export default meta;
|
|
12
|
-
type Story = StoryObj<typeof Modal>;
|
|
13
|
-
|
|
14
|
-
export const Default: Story = {
|
|
15
|
-
render: () => {
|
|
16
|
-
const [open, setOpen] = useState(false);
|
|
17
|
-
return (
|
|
18
|
-
<>
|
|
19
|
-
<Button variant="primary" label="Open Modal" onClick={() => setOpen(true)} />
|
|
20
|
-
<Modal isOpen={open} onClose={() => setOpen(false)} title="Confirm Action">
|
|
21
|
-
<p>Are you sure you want to proceed? This action cannot be undone.</p>
|
|
22
|
-
</Modal>
|
|
23
|
-
</>
|
|
24
|
-
);
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const WithSubtitleAndFooter: Story = {
|
|
29
|
-
render: () => {
|
|
30
|
-
const [open, setOpen] = useState(false);
|
|
31
|
-
return (
|
|
32
|
-
<>
|
|
33
|
-
<Button variant="primary" label="Open Modal" onClick={() => setOpen(true)} />
|
|
34
|
-
<Modal
|
|
35
|
-
isOpen={open}
|
|
36
|
-
onClose={() => setOpen(false)}
|
|
37
|
-
title="Edit Profile"
|
|
38
|
-
subtitle="Update your personal information"
|
|
39
|
-
footer={
|
|
40
|
-
<div style={{ display: 'flex', justifyContent: 'flex-end', gap: 8 }}>
|
|
41
|
-
<Button variant="secondary" label="Cancel" onClick={() => setOpen(false)} />
|
|
42
|
-
<Button variant="primary" label="Save Changes" onClick={() => setOpen(false)} />
|
|
43
|
-
</div>
|
|
44
|
-
}
|
|
45
|
-
>
|
|
46
|
-
<div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
|
|
47
|
-
<p>Form content would go here.</p>
|
|
48
|
-
</div>
|
|
49
|
-
</Modal>
|
|
50
|
-
</>
|
|
51
|
-
);
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export const Sizes: Story = {
|
|
56
|
-
render: () => {
|
|
57
|
-
const [size, setSize] = useState<'sm' | 'md' | 'lg' | null>(null);
|
|
58
|
-
return (
|
|
59
|
-
<>
|
|
60
|
-
<div style={{ display: 'flex', gap: 8 }}>
|
|
61
|
-
<Button variant="secondary" label="Small" onClick={() => setSize('sm')} />
|
|
62
|
-
<Button variant="secondary" label="Medium" onClick={() => setSize('md')} />
|
|
63
|
-
<Button variant="secondary" label="Large" onClick={() => setSize('lg')} />
|
|
64
|
-
</div>
|
|
65
|
-
<Modal isOpen={!!size} onClose={() => setSize(null)} title={`${size} modal`} width={size || 'md'}>
|
|
66
|
-
<p>This is a {size} width modal.</p>
|
|
67
|
-
</Modal>
|
|
68
|
-
</>
|
|
69
|
-
);
|
|
70
|
-
},
|
|
71
|
-
};
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useId, useMemo, useRef, useState } from 'react';
|
|
2
|
-
import { createPortal } from 'react-dom';
|
|
3
|
-
import { Surface } from '@/components/Surface';
|
|
4
|
-
import { Text } from '@/components/Text';
|
|
5
|
-
import styles from './Modal.module.css';
|
|
6
|
-
|
|
7
|
-
export type ModalWidth = 'sm' | 'md' | 'lg';
|
|
8
|
-
|
|
9
|
-
const WIDTH_MAP: Record<ModalWidth, string> = {
|
|
10
|
-
sm: 'var(--dimension-modal-width-sm, 400px)',
|
|
11
|
-
md: 'var(--dimension-modal-width-md, 560px)',
|
|
12
|
-
lg: 'var(--dimension-modal-width-lg, 720px)',
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const CLOSE_ANIMATION_MS = 220;
|
|
16
|
-
|
|
17
|
-
export interface ModalProps {
|
|
18
|
-
isOpen: boolean;
|
|
19
|
-
onClose: () => void;
|
|
20
|
-
title: string;
|
|
21
|
-
subtitle?: React.ReactNode;
|
|
22
|
-
children: React.ReactNode;
|
|
23
|
-
footer?: React.ReactNode;
|
|
24
|
-
width?: ModalWidth | string;
|
|
25
|
-
bodyClassName?: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const Modal: React.FC<ModalProps> = ({
|
|
29
|
-
isOpen,
|
|
30
|
-
onClose,
|
|
31
|
-
title,
|
|
32
|
-
subtitle,
|
|
33
|
-
children,
|
|
34
|
-
footer,
|
|
35
|
-
width = 'md',
|
|
36
|
-
bodyClassName,
|
|
37
|
-
}) => {
|
|
38
|
-
const dialogRef = useRef<HTMLDivElement>(null);
|
|
39
|
-
const titleId = useId();
|
|
40
|
-
const [isClosing, setIsClosing] = useState(false);
|
|
41
|
-
const [shouldRender, setShouldRender] = useState(isOpen);
|
|
42
|
-
|
|
43
|
-
const resolvedWidth = useMemo(() => {
|
|
44
|
-
if (width === 'sm' || width === 'md' || width === 'lg') {
|
|
45
|
-
return WIDTH_MAP[width];
|
|
46
|
-
}
|
|
47
|
-
return width;
|
|
48
|
-
}, [width]);
|
|
49
|
-
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
if (isOpen) {
|
|
52
|
-
setShouldRender(true);
|
|
53
|
-
setIsClosing(false);
|
|
54
|
-
} else if (shouldRender) {
|
|
55
|
-
setIsClosing(true);
|
|
56
|
-
const timer = setTimeout(() => {
|
|
57
|
-
setShouldRender(false);
|
|
58
|
-
setIsClosing(false);
|
|
59
|
-
}, CLOSE_ANIMATION_MS);
|
|
60
|
-
return () => clearTimeout(timer);
|
|
61
|
-
}
|
|
62
|
-
}, [isOpen, shouldRender]);
|
|
63
|
-
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
if (!isOpen) return;
|
|
66
|
-
const handleEscape = (e: KeyboardEvent) => {
|
|
67
|
-
if (e.key === 'Escape') onClose();
|
|
68
|
-
};
|
|
69
|
-
document.addEventListener('keydown', handleEscape);
|
|
70
|
-
return () => document.removeEventListener('keydown', handleEscape);
|
|
71
|
-
}, [isOpen, onClose]);
|
|
72
|
-
|
|
73
|
-
useEffect(() => {
|
|
74
|
-
if (!isOpen || !shouldRender) return;
|
|
75
|
-
const id = requestAnimationFrame(() => {
|
|
76
|
-
dialogRef.current?.focus();
|
|
77
|
-
});
|
|
78
|
-
return () => cancelAnimationFrame(id);
|
|
79
|
-
}, [isOpen, shouldRender]);
|
|
80
|
-
|
|
81
|
-
if (!shouldRender) return null;
|
|
82
|
-
|
|
83
|
-
return createPortal(
|
|
84
|
-
<div
|
|
85
|
-
className={`${styles.backdrop} ${isClosing ? styles.closing : ''}`}
|
|
86
|
-
onMouseDown={(e) => {
|
|
87
|
-
if (e.target === e.currentTarget) onClose();
|
|
88
|
-
}}
|
|
89
|
-
>
|
|
90
|
-
<Surface
|
|
91
|
-
ref={dialogRef}
|
|
92
|
-
background="primary"
|
|
93
|
-
elevation="floating"
|
|
94
|
-
radius="var(--dimension-radius-275, 22px)"
|
|
95
|
-
className={styles.dialog}
|
|
96
|
-
style={{ width: `min(${resolvedWidth}, calc(100vw - 32px))` }}
|
|
97
|
-
role="dialog"
|
|
98
|
-
aria-modal="true"
|
|
99
|
-
aria-labelledby={titleId}
|
|
100
|
-
tabIndex={-1}
|
|
101
|
-
>
|
|
102
|
-
<div className={styles.header}>
|
|
103
|
-
<Text id={titleId} as="h2" variant="text-title-small">
|
|
104
|
-
{title}
|
|
105
|
-
</Text>
|
|
106
|
-
{subtitle != null && (
|
|
107
|
-
<div className={styles.subtitle}>{subtitle}</div>
|
|
108
|
-
)}
|
|
109
|
-
</div>
|
|
110
|
-
<div className={`${styles.body} ${bodyClassName ?? ''}`.trim()}>
|
|
111
|
-
{children}
|
|
112
|
-
</div>
|
|
113
|
-
{footer != null && (
|
|
114
|
-
<div className={styles.footer}>{footer}</div>
|
|
115
|
-
)}
|
|
116
|
-
</Surface>
|
|
117
|
-
</div>,
|
|
118
|
-
document.body
|
|
119
|
-
);
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
Modal.displayName = 'Modal';
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
.pagination {
|
|
2
|
-
display: flex;
|
|
3
|
-
align-items: center;
|
|
4
|
-
gap: var(--dimension-space-025);
|
|
5
|
-
-webkit-user-select: none;
|
|
6
|
-
user-select: none;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.inactive {
|
|
10
|
-
opacity: 0.5;
|
|
11
|
-
pointer-events: none;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/* ─── Button ────────────────────────────────────────────────────────────────── */
|
|
15
|
-
|
|
16
|
-
.button {
|
|
17
|
-
display: flex;
|
|
18
|
-
align-items: center;
|
|
19
|
-
justify-content: center;
|
|
20
|
-
min-width: var(--dimension-size-300);
|
|
21
|
-
height: var(--dimension-size-300);
|
|
22
|
-
padding: 0 var(--dimension-space-050);
|
|
23
|
-
background: none;
|
|
24
|
-
border: none;
|
|
25
|
-
border-radius: var(--dimension-radius-075);
|
|
26
|
-
cursor: pointer;
|
|
27
|
-
color: var(--color-foreground-secondary);
|
|
28
|
-
transition: background-color var(--effect-motion-short-2), color var(--effect-motion-short-2);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.button:hover:not(:disabled) {
|
|
32
|
-
background-color: var(--color-interaction-hover);
|
|
33
|
-
color: var(--color-foreground-primary);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.button:active:not(:disabled) {
|
|
37
|
-
background-color: var(--color-interaction-pressed);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.button:disabled {
|
|
41
|
-
cursor: not-allowed;
|
|
42
|
-
opacity: 0.35;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.active {
|
|
46
|
-
background-color: var(--color-interaction-hover);
|
|
47
|
-
color: var(--color-foreground-primary);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/* ─── Nav arrows ────────────────────────────────────────────────────────────── */
|
|
51
|
-
|
|
52
|
-
.nav {
|
|
53
|
-
font-size: 18px;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/* ─── Ellipsis ──────────────────────────────────────────────────────────────── */
|
|
57
|
-
|
|
58
|
-
.ellipsis {
|
|
59
|
-
display: flex;
|
|
60
|
-
align-items: center;
|
|
61
|
-
justify-content: center;
|
|
62
|
-
min-width: var(--dimension-size-300);
|
|
63
|
-
height: var(--dimension-size-300);
|
|
64
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
|
-
import { Pagination } from './Pagination';
|
|
4
|
-
|
|
5
|
-
const meta: Meta<typeof Pagination> = {
|
|
6
|
-
title: 'Classic/Pagination',
|
|
7
|
-
component: Pagination,
|
|
8
|
-
args: {
|
|
9
|
-
inactive: false,
|
|
10
|
-
siblingCount: 1,
|
|
11
|
-
},
|
|
12
|
-
argTypes: {
|
|
13
|
-
inactive: { control: 'boolean' },
|
|
14
|
-
siblingCount: { control: { type: 'number', min: 0, max: 3 } },
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export default meta;
|
|
19
|
-
type Story = StoryObj<typeof Pagination>;
|
|
20
|
-
|
|
21
|
-
const Controlled = (props: Partial<React.ComponentProps<typeof Pagination>> & { totalPages?: number }) => {
|
|
22
|
-
const total = props.totalPages ?? 10;
|
|
23
|
-
const [page, setPage] = useState(1);
|
|
24
|
-
return <Pagination page={page} totalPages={total} onPageChange={setPage} {...props} />;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const Playground: Story = {
|
|
28
|
-
render: args => <Controlled totalPages={20} {...args} />,
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export const Default: Story = {
|
|
32
|
-
render: () => <Controlled totalPages={10} />,
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export const ManyPages: Story = {
|
|
36
|
-
render: () => <Controlled totalPages={100} />,
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export const FewPages: Story = {
|
|
40
|
-
render: () => <Controlled totalPages={3} />,
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const SinglePage: Story = {
|
|
44
|
-
render: () => <Controlled totalPages={1} />,
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export const Inactive: Story = {
|
|
48
|
-
render: () => (
|
|
49
|
-
<Pagination page={5} totalPages={20} onPageChange={() => {}} inactive />
|
|
50
|
-
),
|
|
51
|
-
};
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, useMemo } from 'react';
|
|
2
|
-
import { cn } from '@/utils/cn';
|
|
3
|
-
import { Text } from '@/components/Text';
|
|
4
|
-
import styles from './Pagination.module.css';
|
|
5
|
-
|
|
6
|
-
export interface PaginationProps {
|
|
7
|
-
/** Current page (1-based). */
|
|
8
|
-
page: number;
|
|
9
|
-
/** Total number of pages. */
|
|
10
|
-
totalPages: number;
|
|
11
|
-
/** Called when page changes. */
|
|
12
|
-
onPageChange: (page: number) => void;
|
|
13
|
-
/** Max page buttons visible (excluding prev/next). */
|
|
14
|
-
siblingCount?: number;
|
|
15
|
-
/** Disables all interaction. */
|
|
16
|
-
inactive?: boolean;
|
|
17
|
-
className?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function buildRange(start: number, end: number): (number | 'ellipsis')[] {
|
|
21
|
-
const items: (number | 'ellipsis')[] = [];
|
|
22
|
-
for (let i = start; i <= end; i++) items.push(i);
|
|
23
|
-
return items;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function buildPages(page: number, totalPages: number, siblings: number): (number | 'ellipsis')[] {
|
|
27
|
-
const totalSlots = siblings * 2 + 5; // siblings + boundaries + ellipses + current
|
|
28
|
-
|
|
29
|
-
if (totalPages <= totalSlots) return buildRange(1, totalPages);
|
|
30
|
-
|
|
31
|
-
const leftSibling = Math.max(page - siblings, 2);
|
|
32
|
-
const rightSibling = Math.min(page + siblings, totalPages - 1);
|
|
33
|
-
|
|
34
|
-
const showLeftEllipsis = leftSibling > 2;
|
|
35
|
-
const showRightEllipsis = rightSibling < totalPages - 1;
|
|
36
|
-
|
|
37
|
-
if (!showLeftEllipsis && showRightEllipsis) {
|
|
38
|
-
const left = buildRange(1, siblings * 2 + 3);
|
|
39
|
-
return [...left, 'ellipsis', totalPages];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (showLeftEllipsis && !showRightEllipsis) {
|
|
43
|
-
const right = buildRange(totalPages - (siblings * 2 + 2), totalPages);
|
|
44
|
-
return [1, 'ellipsis', ...right];
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return [1, 'ellipsis', ...buildRange(leftSibling, rightSibling), 'ellipsis', totalPages];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export const Pagination = forwardRef<HTMLElement, PaginationProps>(
|
|
51
|
-
({ page, totalPages, onPageChange, siblingCount = 1, inactive = false, className }, ref) => {
|
|
52
|
-
const pages = useMemo(() => buildPages(page, totalPages, siblingCount), [page, totalPages, siblingCount]);
|
|
53
|
-
|
|
54
|
-
if (totalPages <= 1) return null;
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<nav ref={ref} aria-label="Pagination" className={cn(styles.pagination, inactive && styles.inactive, className)}>
|
|
58
|
-
<button
|
|
59
|
-
type="button"
|
|
60
|
-
className={cn(styles.button, styles.nav)}
|
|
61
|
-
disabled={page <= 1 || inactive}
|
|
62
|
-
onClick={() => onPageChange(page - 1)}
|
|
63
|
-
aria-label="Previous page"
|
|
64
|
-
>
|
|
65
|
-
<Text variant="text-body-small" as="span" color="inherit">‹</Text>
|
|
66
|
-
</button>
|
|
67
|
-
|
|
68
|
-
{pages.map((item, i) =>
|
|
69
|
-
item === 'ellipsis' ? (
|
|
70
|
-
<span key={`e${i}`} className={styles.ellipsis}>
|
|
71
|
-
<Text variant="text-body-small" as="span" color="tertiary">…</Text>
|
|
72
|
-
</span>
|
|
73
|
-
) : (
|
|
74
|
-
<button
|
|
75
|
-
key={item}
|
|
76
|
-
type="button"
|
|
77
|
-
className={cn(styles.button, item === page && styles.active)}
|
|
78
|
-
onClick={() => onPageChange(item)}
|
|
79
|
-
aria-current={item === page ? 'page' : undefined}
|
|
80
|
-
disabled={inactive}
|
|
81
|
-
>
|
|
82
|
-
<Text variant={item === page ? 'text-body-small-emphasis' : 'text-body-small'} as="span" color="inherit">
|
|
83
|
-
{item}
|
|
84
|
-
</Text>
|
|
85
|
-
</button>
|
|
86
|
-
)
|
|
87
|
-
)}
|
|
88
|
-
|
|
89
|
-
<button
|
|
90
|
-
type="button"
|
|
91
|
-
className={cn(styles.button, styles.nav)}
|
|
92
|
-
disabled={page >= totalPages || inactive}
|
|
93
|
-
onClick={() => onPageChange(page + 1)}
|
|
94
|
-
aria-label="Next page"
|
|
95
|
-
>
|
|
96
|
-
<Text variant="text-body-small" as="span" color="inherit">›</Text>
|
|
97
|
-
</button>
|
|
98
|
-
</nav>
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
Pagination.displayName = 'Pagination';
|