@dbcdk/react-components 0.0.5 → 0.0.6
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/assets/logo.js +2 -85
- package/dist/components/__stories__/_data/table.d.ts +15 -0
- package/dist/components/__stories__/_data/table.js +49 -0
- package/dist/components/__stories__/story-components/Colors.d.ts +2 -1
- package/dist/components/__stories__/story-components/Colors.js +87 -142
- package/dist/components/__stories__/story-components/Spacing.d.ts +1 -0
- package/dist/components/__stories__/story-components/Spacing.js +58 -166
- package/dist/components/app-header/AppHeader.d.ts +4 -3
- package/dist/components/app-header/AppHeader.js +3 -6
- package/dist/components/attribute-chip/AttributeChip.d.ts +1 -0
- package/dist/components/attribute-chip/AttributeChip.js +3 -14
- package/dist/components/avatar/Avatar.d.ts +2 -2
- package/dist/components/avatar/Avatar.js +37 -71
- package/dist/components/breadcrumbs/Breadcrumbs.d.ts +4 -4
- package/dist/components/breadcrumbs/Breadcrumbs.js +4 -13
- package/dist/components/button/Button.d.ts +3 -2
- package/dist/components/button/Button.js +54 -56
- package/dist/components/button/Button.module.css +1 -1
- package/dist/components/card/Card.d.ts +8 -7
- package/dist/components/card/Card.js +19 -60
- package/dist/components/card-container/CardContainer.d.ts +3 -3
- package/dist/components/card-container/CardContainer.js +4 -16
- package/dist/components/chip/Chip.d.ts +6 -5
- package/dist/components/chip/Chip.js +14 -38
- package/dist/components/chip/Chip.module.css +9 -1
- package/dist/components/circle/Circle.d.ts +3 -2
- package/dist/components/circle/Circle.js +3 -10
- package/dist/components/clear-button/ClearButton.d.ts +2 -1
- package/dist/components/clear-button/ClearButton.js +6 -17
- package/dist/components/code-block/CodeBlock.d.ts +1 -0
- package/dist/components/code-block/CodeBlock.js +4 -10
- package/dist/components/copy-button/CopyButton.d.ts +4 -3
- package/dist/components/copy-button/CopyButton.js +19 -26
- package/dist/components/datetime-picker/DateTimePicker.d.ts +8 -5
- package/dist/components/datetime-picker/DateTimePicker.js +364 -459
- package/dist/components/filter-field/FilterField.d.ts +5 -2
- package/dist/components/filter-field/FilterField.js +130 -173
- package/dist/components/filter-field/FilterField.module.css +21 -5
- package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.d.ts +36 -0
- package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.js +53 -0
- package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.module.css +60 -0
- package/dist/components/forms/checkbox/Checkbox.d.ts +31 -0
- package/dist/components/forms/checkbox/Checkbox.js +27 -0
- package/dist/components/{checkbox → forms/checkbox}/Checkbox.module.css +0 -1
- package/dist/components/forms/checkbox-group/CheckboxGroup.d.ts +47 -0
- package/dist/components/forms/checkbox-group/CheckboxGroup.js +75 -0
- package/dist/components/forms/checkbox-group/CheckboxGroup.module.css +115 -0
- package/dist/components/{input → forms/input}/Input.d.ts +9 -5
- package/dist/components/forms/input/Input.js +70 -0
- package/dist/components/{input → forms/input}/Input.module.css +1 -0
- package/dist/components/forms/input-container/InputContainer.d.ts +15 -0
- package/dist/components/forms/input-container/InputContainer.js +15 -0
- package/dist/components/forms/input-container/InputContainer.module.css +34 -0
- package/dist/components/forms/multi-select/MultiSelect.d.ts +20 -0
- package/dist/components/forms/multi-select/MultiSelect.js +19 -0
- package/dist/components/forms/select/Select.d.ts +21 -0
- package/dist/components/forms/select/Select.js +94 -0
- package/dist/components/forms/text-area/Textarea.d.ts +17 -0
- package/dist/components/forms/text-area/Textarea.js +33 -0
- package/dist/components/forms/text-area/Textarea.module.css +26 -0
- package/dist/components/headline/Headline.js +18 -43
- package/dist/components/{link/Link.d.ts → hyperlink/Hyperlink.d.ts} +2 -2
- package/dist/components/hyperlink/Hyperlink.js +11 -0
- package/dist/components/{link/Link.module.css → hyperlink/Hyperlink.module.css} +5 -14
- package/dist/components/icon/Icon.d.ts +4 -3
- package/dist/components/icon/Icon.js +11 -17
- package/dist/components/menu/Menu.js +25 -67
- package/dist/components/meta-bar/MetaBar.d.ts +4 -4
- package/dist/components/meta-bar/MetaBar.js +7 -20
- package/dist/components/nav-bar/NavBar.d.ts +5 -5
- package/dist/components/nav-bar/NavBar.js +15 -45
- package/dist/components/{modal → overlay/modal}/Modal.d.ts +4 -2
- package/dist/components/overlay/modal/Modal.js +92 -0
- package/dist/components/{modal → overlay/modal}/provider/ModalProvider.d.ts +0 -1
- package/dist/components/overlay/modal/provider/ModalProvider.js +70 -0
- package/dist/components/overlay/side-panel/SidePanel.d.ts +16 -0
- package/dist/components/overlay/side-panel/SidePanel.js +10 -0
- package/dist/components/overlay/side-panel/SidePanel.module.css +56 -0
- package/dist/components/overlay/side-panel/useSidePanel.d.ts +5 -0
- package/dist/components/overlay/side-panel/useSidePanel.js +11 -0
- package/dist/components/overlay/tooltip/Tooltip.d.ts +13 -0
- package/dist/components/overlay/tooltip/Tooltip.js +17 -0
- package/dist/components/overlay/tooltip/Tooltip.module.css +106 -0
- package/dist/components/overlay/tooltip/TooltipProvider.d.ts +20 -0
- package/dist/components/overlay/tooltip/TooltipProvider.js +244 -0
- package/dist/components/overlay/tooltip/useTooltipTrigger.d.ts +24 -0
- package/dist/components/overlay/tooltip/useTooltipTrigger.js +108 -0
- package/dist/components/page/Page.d.ts +7 -6
- package/dist/components/page/Page.js +4 -21
- package/dist/components/page-layout/PageLayout.d.ts +11 -12
- package/dist/components/page-layout/PageLayout.js +35 -71
- package/dist/components/page-layout/components/page-layout-hero/PageLayoutHero.js +4 -22
- package/dist/components/pagination/Pagination.d.ts +2 -1
- package/dist/components/pagination/Pagination.js +38 -121
- package/dist/components/panel/Panel.d.ts +4 -3
- package/dist/components/panel/Panel.js +5 -10
- package/dist/components/popover/Popover.d.ts +1 -0
- package/dist/components/popover/Popover.js +116 -141
- package/dist/components/search-box/SearchBox.d.ts +2 -2
- package/dist/components/search-box/SearchBox.js +112 -162
- package/dist/components/segmented-progress-bar/SegmentedProgressBar.d.ts +1 -1
- package/dist/components/segmented-progress-bar/SegmentedProgressBar.js +47 -94
- package/dist/components/sidebar/Sidebar.d.ts +1 -0
- package/dist/components/sidebar/Sidebar.js +5 -7
- package/dist/components/sidebar/components/SidebarItem.js +6 -14
- package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.d.ts +1 -1
- package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.js +48 -88
- package/dist/components/sidebar/components/sidebar-container/SidebarContainer.d.ts +3 -2
- package/dist/components/sidebar/components/sidebar-container/SidebarContainer.js +11 -41
- package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.d.ts +1 -0
- package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.js +4 -25
- package/dist/components/sidebar/components/sidebar-items/SidebarItems.js +9 -23
- package/dist/components/sidebar/components/sidenav-filteirng/SidenavFiltering.js +19 -40
- package/dist/components/sidebar/providers/SidebarProvider.d.ts +2 -1
- package/dist/components/sidebar/providers/SidebarProvider.js +182 -165
- package/dist/components/skeleton-loader/SkeletonLoader.js +68 -266
- package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.js +11 -34
- package/dist/components/split-button/SplitButton.d.ts +7 -5
- package/dist/components/split-button/SplitButton.js +4 -27
- package/dist/components/split-pane/SplitPane.js +69 -105
- package/dist/components/split-pane/provider/SplitPaneContext.js +77 -71
- package/dist/components/table/Table.d.ts +9 -7
- package/dist/components/table/Table.js +115 -238
- package/dist/components/table/Table.module.css +5 -1
- package/dist/components/table/components/column-resizer/ColumnResizer.js +4 -15
- package/dist/components/table/components/empty-state/EmptyState.d.ts +6 -5
- package/dist/components/table/components/empty-state/EmptyState.js +22 -41
- package/dist/components/table/components/table-settings/TableSettings.d.ts +2 -1
- package/dist/components/table/components/table-settings/TableSettings.js +9 -27
- package/dist/components/table/tanstack.d.ts +1 -1
- package/dist/components/table/tanstack.js +154 -160
- package/dist/components/tabs/Tabs.d.ts +1 -0
- package/dist/components/tabs/Tabs.js +32 -81
- package/dist/components/toast/Toast.d.ts +1 -1
- package/dist/components/toast/Toast.js +4 -37
- package/dist/components/toast/Toast.module.css +1 -0
- package/dist/components/toast/provider/ToastProvider.d.ts +1 -1
- package/dist/components/toast/provider/ToastProvider.js +60 -87
- package/dist/components/user-display/UserDisplay.d.ts +2 -1
- package/dist/components/user-display/UserDisplay.js +4 -20
- package/dist/constants/severity.d.ts +1 -1
- package/dist/constants/severity.js +14 -16
- package/dist/constants/severity.types.d.ts +1 -1
- package/dist/constants/severity.types.js +1 -1
- package/dist/constants/sizes.js +6 -8
- package/dist/hooks/usePagination.d.ts +1 -1
- package/dist/hooks/usePagination.js +75 -82
- package/dist/hooks/useSorting.js +112 -110
- package/dist/hooks/useTableData.d.ts +1 -1
- package/dist/hooks/useTableData.js +42 -47
- package/dist/hooks/useTableSelection.js +121 -121
- package/dist/hooks/useTableSettings.js +23 -25
- package/dist/hooks/useTheme.d.ts +3 -7
- package/dist/hooks/useTheme.js +52 -47
- package/dist/hooks/useTimeDuration.d.ts +2 -2
- package/dist/hooks/useTimeDuration.js +33 -34
- package/dist/hooks/useViewportFill.d.ts +3 -2
- package/dist/hooks/useViewportFill.js +55 -48
- package/dist/index.d.ts +17 -8
- package/dist/index.js +18 -8
- package/dist/src/styles/styles.css +3 -3
- package/dist/styles/css-helper-classes/flex.css +4 -0
- package/dist/styles/styles.css +3 -3
- package/dist/styles/themes/dbc/dark.css +1 -1
- package/dist/styles/themes/dbc/light.css +2 -1
- package/dist/styles/themes/forfatterweb/light.css +1 -1
- package/dist/styles/themes/types.js +1 -1
- package/dist/types/a11y-props.types.d.ts +5 -5
- package/dist/types/a11y-props.types.js +1 -1
- package/dist/types/sizes.types.js +1 -1
- package/dist/utils/arrays/nested-filtering.js +43 -33
- package/dist/utils/date/formatDate.js +25 -16
- package/package.json +18 -9
- package/dist/assets/logo.cjs +0 -87
- package/dist/components/__stories__/story-components/Colors.cjs +0 -159
- package/dist/components/__stories__/story-components/Spacing.cjs +0 -190
- package/dist/components/app-header/AppHeader.cjs +0 -14
- package/dist/components/attribute-chip/AttributeChip.cjs +0 -22
- package/dist/components/avatar/Avatar.cjs +0 -101
- package/dist/components/breadcrumbs/Breadcrumbs.cjs +0 -22
- package/dist/components/button/Button.cjs +0 -87
- package/dist/components/card/Card.cjs +0 -69
- package/dist/components/card-container/CardContainer.cjs +0 -24
- package/dist/components/checkbox/Checkbox.cjs +0 -42
- package/dist/components/checkbox/Checkbox.d.ts +0 -12
- package/dist/components/checkbox/Checkbox.js +0 -36
- package/dist/components/chip/Chip.cjs +0 -50
- package/dist/components/circle/Circle.cjs +0 -18
- package/dist/components/clear-button/ClearButton.cjs +0 -26
- package/dist/components/code-block/CodeBlock.cjs +0 -18
- package/dist/components/copy-button/CopyButton.cjs +0 -35
- package/dist/components/datetime-picker/DateTimePicker.cjs +0 -504
- package/dist/components/filter-field/FilterField.cjs +0 -189
- package/dist/components/headline/Headline.cjs +0 -53
- package/dist/components/icon/Icon.cjs +0 -27
- package/dist/components/input/Input.cjs +0 -89
- package/dist/components/input/Input.js +0 -83
- package/dist/components/link/Link.cjs +0 -46
- package/dist/components/link/Link.js +0 -21
- package/dist/components/menu/Menu.cjs +0 -96
- package/dist/components/meta-bar/MetaBar.cjs +0 -29
- package/dist/components/modal/Modal.cjs +0 -134
- package/dist/components/modal/Modal.js +0 -128
- package/dist/components/modal/provider/ModalProvider.cjs +0 -80
- package/dist/components/modal/provider/ModalProvider.js +0 -77
- package/dist/components/multi-select/MultiSelect.cjs +0 -59
- package/dist/components/multi-select/MultiSelect.d.ts +0 -18
- package/dist/components/multi-select/MultiSelect.js +0 -57
- package/dist/components/nav-bar/NavBar.cjs +0 -55
- package/dist/components/page/Page.cjs +0 -30
- package/dist/components/page-layout/PageLayout.cjs +0 -84
- package/dist/components/page-layout/components/page-layout-hero/PageLayoutHero.cjs +0 -32
- package/dist/components/pagination/Pagination.cjs +0 -133
- package/dist/components/panel/Panel.cjs +0 -18
- package/dist/components/popover/Popover.cjs +0 -149
- package/dist/components/search-box/SearchBox.cjs +0 -175
- package/dist/components/segmented-progress-bar/SegmentedProgressBar.cjs +0 -103
- package/dist/components/select/Select.cjs +0 -121
- package/dist/components/select/Select.d.ts +0 -12
- package/dist/components/select/Select.js +0 -119
- package/dist/components/sidebar/Sidebar.cjs +0 -11
- package/dist/components/sidebar/components/SidebarItem.cjs +0 -18
- package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.cjs +0 -100
- package/dist/components/sidebar/components/sidebar-container/SidebarContainer.cjs +0 -50
- package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.cjs +0 -34
- package/dist/components/sidebar/components/sidebar-items/SidebarItems.cjs +0 -29
- package/dist/components/sidebar/components/sidenav-filteirng/SidenavFiltering.cjs +0 -52
- package/dist/components/sidebar/providers/SidebarProvider.cjs +0 -179
- package/dist/components/skeleton-loader/SkeletonLoader.cjs +0 -270
- package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.cjs +0 -42
- package/dist/components/split-button/SplitButton.cjs +0 -37
- package/dist/components/split-pane/SplitPane.cjs +0 -123
- package/dist/components/split-pane/provider/SplitPaneContext.cjs +0 -87
- package/dist/components/table/Table.cjs +0 -249
- package/dist/components/table/components/column-resizer/ColumnResizer.cjs +0 -22
- package/dist/components/table/components/empty-state/EmptyState.cjs +0 -52
- package/dist/components/table/components/table-settings/TableSettings.cjs +0 -32
- package/dist/components/table/tanstack.cjs +0 -193
- package/dist/components/tabs/Tabs.cjs +0 -90
- package/dist/components/text-area/Textarea.cjs +0 -62
- package/dist/components/text-area/Textarea.d.ts +0 -14
- package/dist/components/text-area/Textarea.js +0 -56
- package/dist/components/text-area/Textarea.module.css +0 -3
- package/dist/components/toast/Toast.cjs +0 -47
- package/dist/components/toast/provider/ToastProvider.cjs +0 -98
- package/dist/components/tooltip/Tooltip.cjs +0 -183
- package/dist/components/tooltip/Tooltip.d.ts +0 -11
- package/dist/components/tooltip/Tooltip.js +0 -177
- package/dist/components/tooltip/Tooltip.module.css +0 -66
- package/dist/components/user-display/UserDisplay.cjs +0 -28
- package/dist/constants/severity.cjs +0 -21
- package/dist/constants/severity.types.cjs +0 -2
- package/dist/constants/sizes.cjs +0 -11
- package/dist/hooks/usePagination.cjs +0 -88
- package/dist/hooks/useSorting.cjs +0 -118
- package/dist/hooks/useTableData.cjs +0 -52
- package/dist/hooks/useTableSelection.cjs +0 -130
- package/dist/hooks/useTableSettings.cjs +0 -28
- package/dist/hooks/useTheme.cjs +0 -58
- package/dist/hooks/useTimeDuration.cjs +0 -39
- package/dist/hooks/useViewportFill.cjs +0 -52
- package/dist/index.cjs +0 -383
- package/dist/styles/themes/types.cjs +0 -2
- package/dist/types/a11y-props.types.cjs +0 -2
- package/dist/types/assets.d.cjs +0 -2
- package/dist/types/assets.d.js +0 -1
- package/dist/types/css.d.cjs +0 -2
- package/dist/types/css.d.js +0 -1
- package/dist/types/sizes.types.cjs +0 -2
- package/dist/utils/arrays/nested-filtering.cjs +0 -40
- package/dist/utils/date/formatDate.cjs +0 -19
- /package/dist/components/{modal → overlay/modal}/Modal.module.css +0 -0
|
@@ -1,184 +1,76 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CopyButton } from '../../../components/copy-button/CopyButton';
|
|
3
|
+
import { Headline } from '../../../components/headline/Headline';
|
|
2
4
|
import styles from './Spacing.module.css';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const SIZES = ["xxs", "xs", "sm", "md", "lg", "xl", "2xl"];
|
|
7
|
-
const AXES = ["all", "block", "inline", "top", "bottom", "start", "end"];
|
|
5
|
+
const SIZES = ['xxs', 'xs', 'sm', 'md', 'lg', 'xl', '2xl'];
|
|
6
|
+
const AXES = ['all', 'block', 'inline', 'top', 'bottom', 'start', 'end'];
|
|
7
|
+
// Theme spacing values (px) to show in headers
|
|
8
8
|
const SIZE_PX = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
xxs: '4px',
|
|
10
|
+
xs: '8px',
|
|
11
|
+
sm: '12px',
|
|
12
|
+
md: '16px',
|
|
13
|
+
lg: '24px',
|
|
14
|
+
xl: '32px',
|
|
15
|
+
'2xl': '48px',
|
|
16
16
|
};
|
|
17
|
+
// map axis -> class fragment for each kind
|
|
17
18
|
const CLASS_PARTS = {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
19
|
+
padding: {
|
|
20
|
+
all: 'p',
|
|
21
|
+
block: 'py',
|
|
22
|
+
inline: 'px',
|
|
23
|
+
top: 'pt',
|
|
24
|
+
bottom: 'pb',
|
|
25
|
+
start: 'ps',
|
|
26
|
+
end: 'pe',
|
|
27
|
+
},
|
|
28
|
+
margin: {
|
|
29
|
+
all: 'm',
|
|
30
|
+
block: 'my',
|
|
31
|
+
inline: 'mx',
|
|
32
|
+
top: 'mt',
|
|
33
|
+
bottom: 'mb',
|
|
34
|
+
start: 'ms',
|
|
35
|
+
end: 'me',
|
|
36
|
+
},
|
|
36
37
|
};
|
|
37
|
-
|
|
38
|
+
// Single-side helpers only go up to xl
|
|
39
|
+
const HAS_SINGLE_SIDE_FOR = (size) => size !== '2xl';
|
|
38
40
|
function makeClass(kind, axis, size) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
if ((axis === 'top' || axis === 'bottom' || axis === 'start' || axis === 'end') &&
|
|
42
|
+
!HAS_SINGLE_SIDE_FOR(size)) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const part = CLASS_PARTS[kind][axis];
|
|
46
|
+
return `dbc-${part}-${size}`;
|
|
44
47
|
}
|
|
45
48
|
function Code({ children }) {
|
|
46
|
-
|
|
49
|
+
return _jsx("code", { className: styles.code, children: children });
|
|
47
50
|
}
|
|
48
|
-
const ContentBlock = ({ helperClass }) =>
|
|
49
|
-
"div",
|
|
50
|
-
{
|
|
51
|
-
className: `${styles.contentBlock} dbc-flex dbc-gap-xxs dbc-justify-center ${helperClass} dbc-items-center`,
|
|
52
|
-
children: [
|
|
53
|
-
helperClass,
|
|
54
|
-
" ",
|
|
55
|
-
/* @__PURE__ */ jsx(CopyButton, { text: helperClass, variant: "inline", size: "sm" })
|
|
56
|
-
]
|
|
57
|
-
}
|
|
58
|
-
);
|
|
51
|
+
const ContentBlock = ({ helperClass }) => (_jsxs("div", { className: `${styles.contentBlock} dbc-flex dbc-gap-xxs dbc-justify-center ${helperClass} dbc-items-center`, children: [helperClass, " ", _jsx(CopyButton, { text: helperClass, variant: "inline", size: "sm" })] }));
|
|
59
52
|
function PaddingPreview({ cls }) {
|
|
60
|
-
|
|
53
|
+
return (_jsx("div", { className: `${styles.paddingPreview} ${cls}`, children: _jsx(ContentBlock, { helperClass: cls }) }));
|
|
61
54
|
}
|
|
62
55
|
function MarginPreview({ cls }) {
|
|
63
|
-
|
|
56
|
+
return (_jsx("div", { className: styles.marginCanvas, children: _jsx("div", { className: `${styles.marginBlock} ${cls}`, children: _jsx(ContentBlock, { helperClass: cls }) }) }));
|
|
64
57
|
}
|
|
65
58
|
function Cell({ kind, axis, size }) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
59
|
+
const cls = makeClass(kind, axis, size);
|
|
60
|
+
if (!cls)
|
|
61
|
+
return _jsx("div", { className: styles.unavailable, children: "\u2014" });
|
|
62
|
+
return (_jsx("div", { className: styles.cellInner, children: _jsx("div", { className: styles.cellPreview, children: kind === 'padding' ? _jsx(PaddingPreview, { cls: cls }) : _jsx(MarginPreview, { cls: cls }) }) }));
|
|
69
63
|
}
|
|
70
64
|
function Grid({ kind, title, severity }) {
|
|
71
|
-
|
|
72
|
-
/* @__PURE__ */ jsx(Headline, { marker: true, severity, disableMargin: true, size: 2, children: title }),
|
|
73
|
-
/* @__PURE__ */ jsx("div", { className: styles.tableContainer, children: /* @__PURE__ */ jsxs("table", { className: styles.table, children: [
|
|
74
|
-
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
75
|
-
/* @__PURE__ */ jsx("th", { className: styles.axisCol, children: "Axis" }),
|
|
76
|
-
SIZES.map((size) => /* @__PURE__ */ jsxs("th", { className: styles.sizeHead, children: [
|
|
77
|
-
size,
|
|
78
|
-
" ",
|
|
79
|
-
/* @__PURE__ */ jsxs("span", { className: styles.sizePx, children: [
|
|
80
|
-
"(",
|
|
81
|
-
SIZE_PX[size],
|
|
82
|
-
")"
|
|
83
|
-
] })
|
|
84
|
-
] }, size))
|
|
85
|
-
] }) }),
|
|
86
|
-
/* @__PURE__ */ jsx("tbody", { children: AXES.map((axis) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
87
|
-
/* @__PURE__ */ jsx("th", { className: styles.axisHead, children: axis }),
|
|
88
|
-
SIZES.map((size) => /* @__PURE__ */ jsx("td", { className: styles.cell, children: /* @__PURE__ */ jsx(Cell, { kind, axis, size }) }, size))
|
|
89
|
-
] }, axis)) })
|
|
90
|
-
] }) })
|
|
91
|
-
] });
|
|
65
|
+
return (_jsxs("section", { className: styles.section, children: [_jsx(Headline, { marker: true, severity: severity, disableMargin: true, size: 2, children: title }), _jsx("div", { className: styles.tableContainer, children: _jsxs("table", { className: styles.table, children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { className: styles.axisCol, children: "Axis" }), SIZES.map(size => (_jsxs("th", { className: styles.sizeHead, children: [size, " ", _jsxs("span", { className: styles.sizePx, children: ["(", SIZE_PX[size], ")"] })] }, size)))] }) }), _jsx("tbody", { children: AXES.map(axis => (_jsxs("tr", { children: [_jsx("th", { className: styles.axisHead, children: axis }), SIZES.map(size => (_jsx("td", { className: styles.cell, children: _jsx(Cell, { kind: kind, axis: axis, size: size }) }, size)))] }, axis))) })] }) })] }));
|
|
92
66
|
}
|
|
93
|
-
function Spacing() {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
["
|
|
102
|
-
["--margin-border"]: "var(--color-warning)",
|
|
103
|
-
["--dot-pad"]: "var(--color-bg-selected)",
|
|
104
|
-
["--dot-mar"]: "var(--opac-bg-default)"
|
|
105
|
-
},
|
|
106
|
-
children: [
|
|
107
|
-
/* @__PURE__ */ jsx("header", { className: styles.header, children: /* @__PURE__ */ jsx(Headline, { disableMargin: true, children: "Spacing helpers" }) }),
|
|
108
|
-
/* @__PURE__ */ jsxs("section", { className: styles.intro, children: [
|
|
109
|
-
/* @__PURE__ */ jsx("h2", { className: styles.h2, children: "Naming Convention" }),
|
|
110
|
-
/* @__PURE__ */ jsxs("p", { className: styles.paragraph, children: [
|
|
111
|
-
"Spacing helpers follow a simple ",
|
|
112
|
-
/* @__PURE__ */ jsx("strong", { children: "prefix\u2013axis\u2013size" }),
|
|
113
|
-
" pattern:"
|
|
114
|
-
] }),
|
|
115
|
-
/* @__PURE__ */ jsx("div", { className: styles.example, children: /* @__PURE__ */ jsx(Code, { children: "dbc-[prefix][axis?]-[size]" }) }),
|
|
116
|
-
/* @__PURE__ */ jsxs("ul", { className: styles.list, children: [
|
|
117
|
-
/* @__PURE__ */ jsxs("li", { children: [
|
|
118
|
-
/* @__PURE__ */ jsx("strong", { children: "Prefix" }),
|
|
119
|
-
": ",
|
|
120
|
-
/* @__PURE__ */ jsx(Code, { children: "p" }),
|
|
121
|
-
" for ",
|
|
122
|
-
/* @__PURE__ */ jsx("em", { children: "padding" }),
|
|
123
|
-
", ",
|
|
124
|
-
/* @__PURE__ */ jsx(Code, { children: "m" }),
|
|
125
|
-
" for",
|
|
126
|
-
" ",
|
|
127
|
-
/* @__PURE__ */ jsx("em", { children: "margin" }),
|
|
128
|
-
"."
|
|
129
|
-
] }),
|
|
130
|
-
/* @__PURE__ */ jsxs("li", { children: [
|
|
131
|
-
/* @__PURE__ */ jsx("strong", { children: "Axis" }),
|
|
132
|
-
" (optional): ",
|
|
133
|
-
/* @__PURE__ */ jsx(Code, { children: "x" }),
|
|
134
|
-
" = inline (left + right), ",
|
|
135
|
-
/* @__PURE__ */ jsx(Code, { children: "y" }),
|
|
136
|
-
" ",
|
|
137
|
-
"= block (top + bottom), or single sides ",
|
|
138
|
-
/* @__PURE__ */ jsx(Code, { children: "t" }),
|
|
139
|
-
" / ",
|
|
140
|
-
/* @__PURE__ */ jsx(Code, { children: "b" }),
|
|
141
|
-
" / ",
|
|
142
|
-
/* @__PURE__ */ jsx(Code, { children: "s" }),
|
|
143
|
-
" ",
|
|
144
|
-
"/ ",
|
|
145
|
-
/* @__PURE__ */ jsx(Code, { children: "e" }),
|
|
146
|
-
"."
|
|
147
|
-
] }),
|
|
148
|
-
/* @__PURE__ */ jsxs("li", { children: [
|
|
149
|
-
/* @__PURE__ */ jsx("strong", { children: "Size" }),
|
|
150
|
-
": one of ",
|
|
151
|
-
/* @__PURE__ */ jsx(Code, { children: "xxs" }),
|
|
152
|
-
", ",
|
|
153
|
-
/* @__PURE__ */ jsx(Code, { children: "xs" }),
|
|
154
|
-
", ",
|
|
155
|
-
/* @__PURE__ */ jsx(Code, { children: "sm" }),
|
|
156
|
-
",",
|
|
157
|
-
" ",
|
|
158
|
-
/* @__PURE__ */ jsx(Code, { children: "md" }),
|
|
159
|
-
", ",
|
|
160
|
-
/* @__PURE__ */ jsx(Code, { children: "lg" }),
|
|
161
|
-
", ",
|
|
162
|
-
/* @__PURE__ */ jsx(Code, { children: "xl" }),
|
|
163
|
-
", ",
|
|
164
|
-
/* @__PURE__ */ jsx(Code, { children: "2xl" }),
|
|
165
|
-
"."
|
|
166
|
-
] })
|
|
167
|
-
] }),
|
|
168
|
-
/* @__PURE__ */ jsxs("p", { className: styles.paragraph, children: [
|
|
169
|
-
"For example: ",
|
|
170
|
-
/* @__PURE__ */ jsx(Code, { children: "dbc-px-md" }),
|
|
171
|
-
" adds medium horizontal padding, while",
|
|
172
|
-
" ",
|
|
173
|
-
/* @__PURE__ */ jsx(Code, { children: "dbc-mt-lg" }),
|
|
174
|
-
" adds a large top margin."
|
|
175
|
-
] })
|
|
176
|
-
] }),
|
|
177
|
-
/* @__PURE__ */ jsx(Grid, { kind: "padding", title: "Padding", severity: "info" }),
|
|
178
|
-
/* @__PURE__ */ jsx(Grid, { kind: "margin", title: "Margin", severity: "warning" })
|
|
179
|
-
]
|
|
180
|
-
}
|
|
181
|
-
);
|
|
67
|
+
export function Spacing() {
|
|
68
|
+
return (_jsxs("div", { className: styles.container, style: {
|
|
69
|
+
['--pad-indicator']: 'var(--color-bg-info)',
|
|
70
|
+
['--pad-border']: 'var(--color-info)',
|
|
71
|
+
['--margin-indicator']: 'var(--color-bg-warning)',
|
|
72
|
+
['--margin-border']: 'var(--color-warning)',
|
|
73
|
+
['--dot-pad']: 'var(--color-bg-selected)',
|
|
74
|
+
['--dot-mar']: 'var(--opac-bg-default)',
|
|
75
|
+
}, children: [_jsx("header", { className: styles.header, children: _jsx(Headline, { disableMargin: true, children: "Spacing helpers" }) }), _jsxs("section", { className: styles.intro, children: [_jsx("h2", { className: styles.h2, children: "Naming Convention" }), _jsxs("p", { className: styles.paragraph, children: ["Spacing helpers follow a simple ", _jsx("strong", { children: "prefix\u2013axis\u2013size" }), " pattern:"] }), _jsx("div", { className: styles.example, children: _jsx(Code, { children: "dbc-[prefix][axis?]-[size]" }) }), _jsxs("ul", { className: styles.list, children: [_jsxs("li", { children: [_jsx("strong", { children: "Prefix" }), ": ", _jsx(Code, { children: "p" }), " for ", _jsx("em", { children: "padding" }), ", ", _jsx(Code, { children: "m" }), " for", ' ', _jsx("em", { children: "margin" }), "."] }), _jsxs("li", { children: [_jsx("strong", { children: "Axis" }), " (optional): ", _jsx(Code, { children: "x" }), " = inline (left + right), ", _jsx(Code, { children: "y" }), ' ', "= block (top + bottom), or single sides ", _jsx(Code, { children: "t" }), " / ", _jsx(Code, { children: "b" }), " / ", _jsx(Code, { children: "s" }), ' ', "/ ", _jsx(Code, { children: "e" }), "."] }), _jsxs("li", { children: [_jsx("strong", { children: "Size" }), ": one of ", _jsx(Code, { children: "xxs" }), ", ", _jsx(Code, { children: "xs" }), ", ", _jsx(Code, { children: "sm" }), ",", ' ', _jsx(Code, { children: "md" }), ", ", _jsx(Code, { children: "lg" }), ", ", _jsx(Code, { children: "xl" }), ", ", _jsx(Code, { children: "2xl" }), "."] })] }), _jsxs("p", { className: styles.paragraph, children: ["For example: ", _jsx(Code, { children: "dbc-px-md" }), " adds medium horizontal padding, while", ' ', _jsx(Code, { children: "dbc-mt-lg" }), " adds a large top margin."] })] }), _jsx(Grid, { kind: "padding", title: "Padding", severity: "info" }), _jsx(Grid, { kind: "margin", title: "Margin", severity: "warning" })] }));
|
|
182
76
|
}
|
|
183
|
-
|
|
184
|
-
export { Spacing };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { ReactNode, JSX } from 'react';
|
|
2
|
+
interface AppHeaderProps {
|
|
3
|
+
children: ReactNode;
|
|
3
4
|
}
|
|
4
|
-
export declare function AppHeader({ children }:
|
|
5
|
+
export declare function AppHeader({ children }: AppHeaderProps): JSX.Element;
|
|
5
6
|
export {};
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { jsx } from
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import styles from './AppHeader.module.css';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return /* @__PURE__ */ jsx("header", { children: /* @__PURE__ */ jsx("div", { className: styles.container, children }) });
|
|
3
|
+
export function AppHeader({ children }) {
|
|
4
|
+
return (_jsx("header", { children: _jsx("div", { className: styles.container, children: children }) }));
|
|
6
5
|
}
|
|
7
|
-
|
|
8
|
-
export { AppHeader };
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import styles from './AttributeChip.module.css';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
label,
|
|
6
|
-
value,
|
|
7
|
-
size = "md",
|
|
8
|
-
loading
|
|
9
|
-
}) {
|
|
10
|
-
return /* @__PURE__ */ jsxs("div", { className: `${styles.container} ${styles[size]}`, "aria-busy": loading, children: [
|
|
11
|
-
/* @__PURE__ */ jsx("span", { className: styles.label, children: label }),
|
|
12
|
-
/* @__PURE__ */ jsx("span", { className: styles.value, children: loading ? "\u2014" : value == null ? void 0 : value.toString() })
|
|
13
|
-
] });
|
|
3
|
+
export function AttributeChip({ label, value, size = 'md', loading, }) {
|
|
4
|
+
return (_jsxs("div", { className: `${styles.container} ${styles[size]}`, "aria-busy": loading, children: [_jsx("span", { className: styles.label, children: label }), _jsx("span", { className: styles.value, children: loading ? '—' : value === null || value === void 0 ? void 0 : value.toString() })] }));
|
|
14
5
|
}
|
|
15
|
-
|
|
16
|
-
export { AttributeChip };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { ButtonHTMLAttributes } from 'react';
|
|
3
|
-
import type { Size } from '../../types/sizes.types';
|
|
2
|
+
import type { ButtonHTMLAttributes, JSX } from 'react';
|
|
4
3
|
import type { Severity } from '../../constants/severity.types';
|
|
4
|
+
import type { Size } from '../../types/sizes.types';
|
|
5
5
|
interface AvatarProps extends Partial<ButtonHTMLAttributes<HTMLButtonElement>> {
|
|
6
6
|
image?: React.ReactNode;
|
|
7
7
|
imgSrc?: string;
|
|
@@ -1,76 +1,42 @@
|
|
|
1
|
-
import { jsx, jsxs } from
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import styles from './Avatar.module.css';
|
|
4
|
+
import { SeverityBgColor, SeverityTextColor } from '../../constants/severity';
|
|
4
5
|
import { sizes } from '../../constants/sizes';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const renderImage = () => {
|
|
28
|
-
if (image) {
|
|
29
|
-
if (React.isValidElement(image)) {
|
|
30
|
-
const mergedClass = [image.props.className, styles.image].filter(Boolean).join(" ");
|
|
31
|
-
return React.cloneElement(image, { className: mergedClass });
|
|
32
|
-
}
|
|
33
|
-
return /* @__PURE__ */ jsx("span", { className: styles.imageSlot, children: image });
|
|
34
|
-
}
|
|
35
|
-
if (imgSrc) {
|
|
36
|
-
return /* @__PURE__ */ jsx("img", { className: styles.image, src: imgSrc, alt: imgAlt });
|
|
37
|
-
}
|
|
38
|
-
return /* @__PURE__ */ jsx("span", { className: styles.avatar, "aria-hidden": "true", children: text });
|
|
39
|
-
};
|
|
40
|
-
if (button) {
|
|
41
|
-
return /* @__PURE__ */ jsx(
|
|
42
|
-
"button",
|
|
43
|
-
{
|
|
44
|
-
type: "button",
|
|
45
|
-
...rest,
|
|
46
|
-
className: [styles.container, styles.button, className].filter(Boolean).join(" "),
|
|
47
|
-
style: styleVars,
|
|
48
|
-
children: renderImage()
|
|
49
|
-
}
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
return /* @__PURE__ */ jsxs("div", { className: [styles.wrapper, className].filter(Boolean).join(" "), style: styleVars, children: [
|
|
53
|
-
/* @__PURE__ */ jsx("div", { className: styles.container, children: renderImage() }),
|
|
54
|
-
photographerCredit && /* @__PURE__ */ jsxs(
|
|
55
|
-
"svg",
|
|
56
|
-
{
|
|
57
|
-
className: styles.creditText,
|
|
58
|
-
viewBox: "0 0 100 100",
|
|
59
|
-
"aria-hidden": "true",
|
|
60
|
-
focusable: "false",
|
|
61
|
-
children: [
|
|
62
|
-
/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx(
|
|
63
|
-
"path",
|
|
64
|
-
{
|
|
65
|
-
id: pathId,
|
|
66
|
-
d: "\n M 50, 50\n m -42, 0\n a 42,42 0 1,1 84,0\n a 42,42 0 1,1 -84,0\n "
|
|
6
|
+
export function Avatar({ image, imgSrc, imgAlt, fullName, color = 'brand', button, size = 'md', className, fullWidth = false, photographerCredit, ...rest }) {
|
|
7
|
+
const text = fullName
|
|
8
|
+
? fullName
|
|
9
|
+
.trim()
|
|
10
|
+
.split(/\s+/)
|
|
11
|
+
.map(name => name.charAt(0))
|
|
12
|
+
.join('')
|
|
13
|
+
.toUpperCase()
|
|
14
|
+
: '';
|
|
15
|
+
const styleVars = {
|
|
16
|
+
'--bg': SeverityBgColor[color],
|
|
17
|
+
'--text': SeverityTextColor[color],
|
|
18
|
+
'--size': fullWidth ? '100%' : sizes[size],
|
|
19
|
+
};
|
|
20
|
+
// Unique id per component instance so multiple avatars don't clash
|
|
21
|
+
const pathId = React.useId();
|
|
22
|
+
const renderImage = () => {
|
|
23
|
+
if (image) {
|
|
24
|
+
// If it's a valid React element, merge our className; otherwise render as-is
|
|
25
|
+
if (React.isValidElement(image)) {
|
|
26
|
+
const mergedClass = [image.props.className, styles.image].filter(Boolean).join(' ');
|
|
27
|
+
return React.cloneElement(image, { className: mergedClass });
|
|
67
28
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
29
|
+
return _jsx("span", { className: styles.imageSlot, children: image });
|
|
30
|
+
}
|
|
31
|
+
if (imgSrc) {
|
|
32
|
+
return _jsx("img", { className: styles.image, src: imgSrc, alt: imgAlt });
|
|
33
|
+
}
|
|
34
|
+
return (_jsx("span", { className: styles.avatar, "aria-hidden": "true", children: text }));
|
|
35
|
+
};
|
|
36
|
+
// Keep button behavior as before (no circular credit)
|
|
37
|
+
if (button) {
|
|
38
|
+
return (_jsx("button", { type: "button", ...rest, className: [styles.container, styles.button, className].filter(Boolean).join(' '), style: styleVars, children: renderImage() }));
|
|
39
|
+
}
|
|
40
|
+
// Non-button: wrapper to overlay circular credit SVG
|
|
41
|
+
return (_jsxs("div", { className: [styles.wrapper, className].filter(Boolean).join(' '), style: styleVars, children: [_jsx("div", { className: styles.container, children: renderImage() }), photographerCredit && (_jsxs("svg", { className: styles.creditText, viewBox: "0 0 100 100", "aria-hidden": "true", focusable: "false", children: [_jsx("defs", { children: _jsx("path", { id: pathId, d: "\n M 50, 50\n m -42, 0\n a 42,42 0 1,1 84,0\n a 42,42 0 1,1 -84,0\n " }) }), _jsx("text", { children: _jsx("textPath", { xlinkHref: `#${pathId}`, startOffset: "50%", textAnchor: "middle", children: photographerCredit }) })] }))] }));
|
|
74
42
|
}
|
|
75
|
-
|
|
76
|
-
export { Avatar };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { ReactNode, HTMLAttributes, JSX } from 'react';
|
|
2
2
|
export interface BreadcrumbItem {
|
|
3
|
-
label: string |
|
|
3
|
+
label: string | ReactNode;
|
|
4
4
|
onClick?: () => void;
|
|
5
|
-
icon?:
|
|
5
|
+
icon?: ReactNode;
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
hidden?: boolean;
|
|
8
8
|
}
|
|
9
9
|
export interface BreadcrumbsProps {
|
|
10
10
|
items: BreadcrumbItem[];
|
|
11
11
|
}
|
|
12
|
-
export declare function Breadcrumbs({ items }: BreadcrumbsProps): JSX.Element;
|
|
12
|
+
export declare function Breadcrumbs({ items, ...navProps }: BreadcrumbsProps & HTMLAttributes<HTMLElement>): JSX.Element;
|
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
import { jsx, jsxs } from
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment } from 'react';
|
|
2
3
|
import styles from './Breadcrumbs.module.css';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function Breadcrumbs({ items }) {
|
|
6
|
-
return /* @__PURE__ */ jsx("nav", { className: styles.breadcrumbs, "aria-label": "breadcrumb", children: /* @__PURE__ */ jsx("ul", { children: items.map((item, index) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
7
|
-
/* @__PURE__ */ jsxs("li", { children: [
|
|
8
|
-
item.icon && item.icon,
|
|
9
|
-
item.onClick ? /* @__PURE__ */ jsx("button", { onClick: item.onClick, children: item.label }) : /* @__PURE__ */ jsx("span", { children: item.label })
|
|
10
|
-
] }),
|
|
11
|
-
index < items.length - 1 && /* @__PURE__ */ jsx("span", { className: styles.separator, children: "/" })
|
|
12
|
-
] }, `breadcrumbItem-${item.label}-${index}`)) }) });
|
|
4
|
+
export function Breadcrumbs({ items, ...navProps }) {
|
|
5
|
+
return (_jsx("nav", { className: styles.breadcrumbs, "aria-label": "breadcrumb", ...navProps, children: _jsx("ul", { children: items.map((item, index) => (_jsxs(Fragment, { children: [_jsxs("li", { children: [item.icon && item.icon, item.onClick ? (_jsx("button", { onClick: item.onClick, children: item.label })) : (_jsx("span", { children: item.label }))] }), index < items.length - 1 && _jsx("span", { className: styles.separator, children: "/" })] }, `breadcrumbItem-${item.label}-${index}`))) }) }));
|
|
13
6
|
}
|
|
14
|
-
|
|
15
|
-
export { Breadcrumbs };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { Size } from '
|
|
2
|
+
import type { Size } from '../../types/sizes.types';
|
|
3
3
|
export type ButtonVariant = 'primary' | 'secondary' | 'outlined' | 'default' | 'inline' | 'success' | 'danger';
|
|
4
4
|
export type ButtonSize = Exclude<Size, 'xl'>;
|
|
5
5
|
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
@@ -10,7 +10,8 @@ export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElemen
|
|
|
10
10
|
loading?: boolean;
|
|
11
11
|
active?: boolean;
|
|
12
12
|
spinIcon?: boolean;
|
|
13
|
-
tooltip?:
|
|
13
|
+
tooltip?: React.ReactNode;
|
|
14
|
+
tooltipPlacement?: 'top' | 'right' | 'bottom' | 'left';
|
|
14
15
|
isLink?: boolean;
|
|
15
16
|
}
|
|
16
17
|
export declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -1,62 +1,60 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { LoaderCircle } from 'lucide-react';
|
|
2
4
|
import * as React from 'react';
|
|
5
|
+
import { useTooltipTrigger } from '../../components/overlay/tooltip/useTooltipTrigger';
|
|
3
6
|
import styles from './Button.module.css';
|
|
4
|
-
import { LoaderCircle } from 'lucide-react';
|
|
5
|
-
import { Tooltip } from '../tooltip/Tooltip';
|
|
6
|
-
|
|
7
7
|
function cx(...parts) {
|
|
8
|
-
|
|
8
|
+
return parts.filter(Boolean).join(' ');
|
|
9
|
+
}
|
|
10
|
+
function mergeRefs(...refs) {
|
|
11
|
+
return (node) => {
|
|
12
|
+
for (const ref of refs) {
|
|
13
|
+
if (!ref)
|
|
14
|
+
continue;
|
|
15
|
+
if (typeof ref === 'function')
|
|
16
|
+
ref(node);
|
|
17
|
+
else
|
|
18
|
+
ref.current = node;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
9
21
|
}
|
|
10
|
-
const Button = React.forwardRef(function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
tooltip,
|
|
20
|
-
isLink,
|
|
21
|
-
...rest
|
|
22
|
-
}, ref) {
|
|
23
|
-
const { className: userClassName, ...buttonProps } = rest;
|
|
24
|
-
const computedClassName = cx(
|
|
25
|
-
styles.button,
|
|
26
|
-
styles[variant],
|
|
27
|
-
styles[size],
|
|
28
|
-
fullWidth ? styles.fullWidth : "",
|
|
29
|
-
active ? styles.active : "",
|
|
30
|
-
loading ? styles.loading : "",
|
|
31
|
-
isLink ? styles.link : "",
|
|
32
|
-
userClassName
|
|
33
|
-
);
|
|
34
|
-
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
35
|
-
icon && /* @__PURE__ */ jsx("span", { className: cx(styles.icon, spinIcon ? "spin" : ""), children: icon }),
|
|
36
|
-
children,
|
|
37
|
-
loading && /* @__PURE__ */ jsx("span", { style: { display: "flex", opacity: 0.5 }, className: "spin", children: /* @__PURE__ */ jsx(LoaderCircle, {}) })
|
|
38
|
-
] });
|
|
39
|
-
let buttonEl;
|
|
40
|
-
if (isLink && React.isValidElement(children)) {
|
|
41
|
-
const childClassName = typeof children.props.className === "string" ? children.props.className : "";
|
|
42
|
-
buttonEl = React.cloneElement(children, {
|
|
43
|
-
...buttonProps,
|
|
44
|
-
ref,
|
|
45
|
-
className: cx(childClassName, computedClassName),
|
|
46
|
-
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
47
|
-
icon && /* @__PURE__ */ jsx("span", { className: cx(styles.icon, spinIcon ? "spin" : ""), children: icon }),
|
|
48
|
-
children.props.children,
|
|
49
|
-
loading && /* @__PURE__ */ jsx("span", { style: { display: "flex", opacity: 0.5 }, className: "spin", children: /* @__PURE__ */ jsx(LoaderCircle, {}) })
|
|
50
|
-
] })
|
|
22
|
+
export const Button = React.forwardRef(function Button({ variant = 'outlined', size = 'md', fullWidth, icon, children, loading, active, spinIcon, tooltip, tooltipPlacement = 'top', isLink, type = 'button', ...rest }, ref) {
|
|
23
|
+
const { className: userClassName, ...buttonProps } = rest;
|
|
24
|
+
const computedClassName = cx(styles.button, styles[variant], styles[size], fullWidth ? styles.fullWidth : '', active ? styles.active : '', loading ? styles.loading : '', isLink ? styles.link : '', userClassName);
|
|
25
|
+
const tooltipEnabled = Boolean(tooltip);
|
|
26
|
+
// Tooltip anchored to the actual clickable element (button or link element)
|
|
27
|
+
const { triggerProps, id: tooltipId } = useTooltipTrigger({
|
|
28
|
+
content: tooltipEnabled ? tooltip : null,
|
|
29
|
+
placement: tooltipPlacement,
|
|
30
|
+
offset: 8,
|
|
51
31
|
});
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
32
|
+
// Merge aria-describedby (button may already have one)
|
|
33
|
+
const describedBy = (() => {
|
|
34
|
+
const existing = typeof buttonProps['aria-describedby'] === 'string'
|
|
35
|
+
? buttonProps['aria-describedby']
|
|
36
|
+
: '';
|
|
37
|
+
const ids = [existing, tooltipEnabled ? tooltipId : ''].filter(Boolean);
|
|
38
|
+
return ids.length ? ids.join(' ') : undefined;
|
|
39
|
+
})();
|
|
40
|
+
const content = (_jsxs(_Fragment, { children: [icon && _jsx("span", { className: cx(styles.icon, spinIcon ? 'spin' : ''), children: icon }), children, loading && (_jsx("span", { style: { display: 'flex', opacity: 0.5 }, className: "spin", children: _jsx(LoaderCircle, {}) }))] }));
|
|
41
|
+
let buttonEl;
|
|
42
|
+
if (isLink && React.isValidElement(children)) {
|
|
43
|
+
// If this is a link-style button, we need to attach tooltip handlers + ref to the child.
|
|
44
|
+
const childClassName = typeof children.props.className === 'string' ? children.props.className : '';
|
|
45
|
+
const childRef = children.ref;
|
|
46
|
+
buttonEl = React.cloneElement(children, {
|
|
47
|
+
...buttonProps,
|
|
48
|
+
ref: mergeRefs(childRef, ref),
|
|
49
|
+
className: cx(childClassName, computedClassName),
|
|
50
|
+
...(tooltipEnabled ? triggerProps : {}),
|
|
51
|
+
'aria-describedby': describedBy,
|
|
52
|
+
children: (_jsxs(_Fragment, { children: [icon && _jsx("span", { className: cx(styles.icon, spinIcon ? 'spin' : ''), children: icon }), children.props.children, loading && (_jsx("span", { style: { display: 'flex', opacity: 0.5 }, className: "spin", children: _jsx(LoaderCircle, {}) }))] })),
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
buttonEl = (_jsx("button", { className: computedClassName, type: type, ...buttonProps, ...(tooltipEnabled ? triggerProps : {}), "aria-describedby": describedBy, children: content }));
|
|
57
|
+
}
|
|
58
|
+
return buttonEl;
|
|
59
59
|
});
|
|
60
|
-
Button.displayName =
|
|
61
|
-
|
|
62
|
-
export { Button };
|
|
60
|
+
Button.displayName = 'Button';
|