@dbcdk/react-components 0.0.5 → 0.0.7
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 +262 -475
- package/dist/components/datetime-picker/dateTimeHelpers.d.ts +13 -0
- package/dist/components/datetime-picker/dateTimeHelpers.js +119 -0
- 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/interval-select/IntervalSelect.d.ts +30 -0
- package/dist/components/interval-select/IntervalSelect.js +82 -0
- 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,3 +1,4 @@
|
|
|
1
|
+
import type { ReactNode, JSX } from 'react';
|
|
1
2
|
export type TableEmptyConfig = {
|
|
2
3
|
/**
|
|
3
4
|
* Whether to show the empty state at all.
|
|
@@ -7,13 +8,13 @@ export type TableEmptyConfig = {
|
|
|
7
8
|
/**
|
|
8
9
|
* Title + description text (defaults are your current Danish copy)
|
|
9
10
|
*/
|
|
10
|
-
title?:
|
|
11
|
-
description?:
|
|
11
|
+
title?: ReactNode;
|
|
12
|
+
description?: ReactNode;
|
|
12
13
|
/**
|
|
13
14
|
* Optional custom actions area. If provided, it will be rendered first.
|
|
14
15
|
* Useful for passing your own buttons/links/etc.
|
|
15
16
|
*/
|
|
16
|
-
actions?:
|
|
17
|
+
actions?: ReactNode;
|
|
17
18
|
/**
|
|
18
19
|
* Convenience callbacks for built-in default buttons.
|
|
19
20
|
* If provided, the corresponding button is shown (unless hidden via showBack/showRefresh).
|
|
@@ -28,8 +29,8 @@ export type TableEmptyConfig = {
|
|
|
28
29
|
/**
|
|
29
30
|
* Override default labels for default buttons
|
|
30
31
|
*/
|
|
31
|
-
backLabel?:
|
|
32
|
-
refreshLabel?:
|
|
32
|
+
backLabel?: ReactNode;
|
|
33
|
+
refreshLabel?: ReactNode;
|
|
33
34
|
/**
|
|
34
35
|
* Wrapper className for layout styling
|
|
35
36
|
*/
|
|
@@ -1,46 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ArrowLeft, RefreshCw, SearchX } from 'lucide-react';
|
|
3
|
+
import styles from './EmptyState.module.css';
|
|
2
4
|
import { Button } from '../../../button/Button';
|
|
3
5
|
import { Headline } from '../../../headline/Headline';
|
|
4
|
-
import { SearchX, RefreshCw, ArrowLeft } from 'lucide-react';
|
|
5
|
-
import styles from './EmptyState.module.css';
|
|
6
|
-
|
|
7
6
|
const defaultEmptyConfig = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
] }),
|
|
17
|
-
refreshLabel: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
18
|
-
/* @__PURE__ */ jsx(RefreshCw, {}),
|
|
19
|
-
"Indl\xE6s igen"
|
|
20
|
-
] }),
|
|
21
|
-
className: "dbc-flex dbc-flex-column dbc-justify-center dbc-items-center dbc-flex-grow "
|
|
7
|
+
enabled: true,
|
|
8
|
+
title: (_jsx(Headline, { disableMargin: true, size: 3, children: "Hov, der er ingen data" })),
|
|
9
|
+
description: _jsx("span", { children: "Pr\u00F8v at \u00E6ndre dine filtre eller tilf\u00F8je data." }),
|
|
10
|
+
showBack: true,
|
|
11
|
+
showRefresh: true,
|
|
12
|
+
backLabel: (_jsxs(_Fragment, { children: [_jsx(ArrowLeft, {}), "Tilbage"] })),
|
|
13
|
+
refreshLabel: (_jsxs(_Fragment, { children: [_jsx(RefreshCw, {}), "Indl\u00E6s igen"] })),
|
|
14
|
+
className: 'dbc-flex dbc-flex-column dbc-justify-center dbc-items-center dbc-flex-grow ',
|
|
22
15
|
};
|
|
23
|
-
function TableEmptyState({ config }) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
/* @__PURE__ */ jsx(SearchX, { className: styles.icon }),
|
|
35
|
-
merged.title,
|
|
36
|
-
merged.description
|
|
37
|
-
] }),
|
|
38
|
-
hasAnyActions && /* @__PURE__ */ jsxs("div", { className: "dbc-flex dbc-gap-sm", children: [
|
|
39
|
-
merged.actions,
|
|
40
|
-
showBack && /* @__PURE__ */ jsx(Button, { onClick: merged.onBack, className: "dbc-mr-xxs", children: merged.backLabel }),
|
|
41
|
-
showRefresh && /* @__PURE__ */ jsx(Button, { onClick: merged.onRefresh, children: merged.refreshLabel })
|
|
42
|
-
] })
|
|
43
|
-
] });
|
|
16
|
+
export function TableEmptyState({ config }) {
|
|
17
|
+
const merged = {
|
|
18
|
+
...defaultEmptyConfig,
|
|
19
|
+
...(config !== null && config !== void 0 ? config : {}),
|
|
20
|
+
};
|
|
21
|
+
if (!merged.enabled)
|
|
22
|
+
return null;
|
|
23
|
+
const showBack = merged.showBack && typeof merged.onBack === 'function';
|
|
24
|
+
const showRefresh = merged.showRefresh && typeof merged.onRefresh === 'function';
|
|
25
|
+
const hasAnyActions = Boolean(merged.actions) || showBack || showRefresh;
|
|
26
|
+
return (_jsxs("div", { className: `${merged.className} ${styles.container}`, children: [_jsxs("span", { className: "dbc-flex dbc-flex-column dbc-gap-sm dbc-items-center", children: [_jsx(SearchX, { className: styles.icon }), merged.title, merged.description] }), hasAnyActions && (_jsxs("div", { className: "dbc-flex dbc-gap-sm", children: [merged.actions, showBack && (_jsx(Button, { onClick: merged.onBack, className: "dbc-mr-xxs", children: merged.backLabel })), showRefresh && _jsx(Button, { onClick: merged.onRefresh, children: merged.refreshLabel })] }))] }));
|
|
44
27
|
}
|
|
45
|
-
|
|
46
|
-
export { TableEmptyState };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { JSX } from 'react';
|
|
1
2
|
import { ViewMode } from '../../../../hooks/useTableSettings';
|
|
2
3
|
interface TableSettingsProps {
|
|
3
4
|
handleChangeViewMode: (mode: ViewMode) => void;
|
|
4
5
|
viewMode: ViewMode;
|
|
5
6
|
}
|
|
6
|
-
export declare function TableSettings({ viewMode, handleChangeViewMode
|
|
7
|
+
export declare function TableSettings({ viewMode, handleChangeViewMode }: TableSettingsProps): JSX.Element;
|
|
7
8
|
export {};
|
|
@@ -1,30 +1,12 @@
|
|
|
1
|
-
import { jsx, jsxs } from
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ListChevronsDownUp, Settings } from 'lucide-react';
|
|
2
3
|
import { Button } from '../../../button/Button';
|
|
3
|
-
import { Popover } from '../../../popover/Popover';
|
|
4
4
|
import { Menu } from '../../../menu/Menu';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
handleChangeViewMode("compact" );
|
|
13
|
-
close == null ? void 0 : close();
|
|
14
|
-
};
|
|
15
|
-
return /* @__PURE__ */ jsx(
|
|
16
|
-
Popover,
|
|
17
|
-
{
|
|
18
|
-
trigger: (onClick, icon) => /* @__PURE__ */ jsxs(Button, { onClick, children: [
|
|
19
|
-
/* @__PURE__ */ jsx(Settings, {}),
|
|
20
|
-
icon
|
|
21
|
-
] }),
|
|
22
|
-
children: (close) => /* @__PURE__ */ jsx(Menu, { children: /* @__PURE__ */ jsx(Menu.Item, { active: viewMode === "compact", children: /* @__PURE__ */ jsxs("button", { onClick: () => handleViewModeChange("compact", close), children: [
|
|
23
|
-
/* @__PURE__ */ jsx(ListChevronsDownUp, {}),
|
|
24
|
-
"Kompakt"
|
|
25
|
-
] }) }) })
|
|
26
|
-
}
|
|
27
|
-
);
|
|
5
|
+
import { Popover } from '../../../popover/Popover';
|
|
6
|
+
export function TableSettings({ viewMode, handleChangeViewMode }) {
|
|
7
|
+
const handleViewModeChange = (mode, close) => {
|
|
8
|
+
handleChangeViewMode(mode === 'compact' ? 'compact' : 'comfortable');
|
|
9
|
+
close === null || close === void 0 ? void 0 : close();
|
|
10
|
+
};
|
|
11
|
+
return (_jsx(Popover, { trigger: (onClick, icon) => (_jsxs(Button, { onClick: onClick, children: [_jsx(Settings, {}), icon] })), children: close => (_jsx(Menu, { children: _jsx(Menu.Item, { active: viewMode === 'compact', children: _jsxs("button", { type: "button", onClick: () => handleViewModeChange('compact', close), children: [_jsx(ListChevronsDownUp, {}), "Kompakt"] }) }) })) }));
|
|
28
12
|
}
|
|
29
|
-
|
|
30
|
-
export { TableSettings };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
1
|
import { type ColumnDef } from '@tanstack/react-table';
|
|
2
|
+
import * as React from 'react';
|
|
3
3
|
import { type TableProps, type TableVariant } from './Table';
|
|
4
4
|
import { ViewMode } from '../../hooks/useTableSettings';
|
|
5
5
|
type Filterable<T> = Array<keyof T>;
|
|
@@ -1,168 +1,162 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useReactTable, getCoreRowModel, getSortedRowModel, getFilteredRowModel, } from '@tanstack/react-table';
|
|
2
4
|
import * as React from 'react';
|
|
3
|
-
import { useReactTable, getFilteredRowModel, getSortedRowModel, getCoreRowModel } from '@tanstack/react-table';
|
|
4
|
-
import { Table } from './Table';
|
|
5
5
|
import ColumnResizer from './components/column-resizer/ColumnResizer';
|
|
6
|
-
|
|
6
|
+
import { Table } from './Table';
|
|
7
7
|
function getColumnId(def, index) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const d = def;
|
|
9
|
+
if (d.id != null && String(d.id).length)
|
|
10
|
+
return String(d.id);
|
|
11
|
+
if (d.accessorKey != null && String(d.accessorKey).length)
|
|
12
|
+
return String(d.accessorKey);
|
|
13
|
+
return `col_${index}`;
|
|
12
14
|
}
|
|
13
15
|
function mapDefsToColumnItems(defs) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
16
|
+
return defs.map((def, index) => {
|
|
17
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
18
|
+
const id = getColumnId(def, index);
|
|
19
|
+
const accessorKey = def.accessorKey;
|
|
20
|
+
const accessorFn = def.accessorFn;
|
|
21
|
+
const cell = def.cell;
|
|
22
|
+
let render;
|
|
23
|
+
if (typeof cell === 'function') {
|
|
24
|
+
render = (row) => cell({
|
|
25
|
+
row: { original: row },
|
|
26
|
+
getValue: () => accessorKey != null
|
|
27
|
+
? row[accessorKey]
|
|
28
|
+
: accessorFn
|
|
29
|
+
? accessorFn(row)
|
|
30
|
+
: undefined,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
else if (accessorFn) {
|
|
34
|
+
render = (row) => accessorFn(row);
|
|
35
|
+
}
|
|
36
|
+
else if (accessorKey != null) {
|
|
37
|
+
render = (row) => row[accessorKey];
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
render = () => null;
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
id,
|
|
44
|
+
header: def.header,
|
|
45
|
+
accessor: accessorKey,
|
|
46
|
+
sortable: (_a = def.enableSorting) !== null && _a !== void 0 ? _a : !!accessorKey,
|
|
47
|
+
render,
|
|
48
|
+
hidden: (_c = (_b = def.meta) === null || _b === void 0 ? void 0 : _b.hidden) !== null && _c !== void 0 ? _c : false,
|
|
49
|
+
align: (_e = (_d = def.meta) === null || _d === void 0 ? void 0 : _d.align) !== null && _e !== void 0 ? _e : undefined,
|
|
50
|
+
verticalAlign: (_g = (_f = def.meta) === null || _f === void 0 ? void 0 : _f.verticalAlign) !== null && _g !== void 0 ? _g : undefined,
|
|
51
|
+
fitContent: (_j = (_h = def.meta) === null || _h === void 0 ? void 0 : _h.fitContent) !== null && _j !== void 0 ? _j : false,
|
|
52
|
+
emptyPlaceholder: (_l = (_k = def.meta) === null || _k === void 0 ? void 0 : _k.emptyPlaceholder) !== null && _l !== void 0 ? _l : '-',
|
|
53
|
+
allowWrap: (_o = (_m = def.meta) === null || _m === void 0 ? void 0 : _m.allowWrap) !== null && _o !== void 0 ? _o : false,
|
|
54
|
+
fillWidth: (_q = (_p = def.meta) === null || _p === void 0 ? void 0 : _p.fillWidth) !== null && _q !== void 0 ? _q : false,
|
|
55
|
+
severity: (_s = (_r = def.meta) === null || _r === void 0 ? void 0 : _r.severity) !== null && _s !== void 0 ? _s : undefined,
|
|
56
|
+
};
|
|
57
|
+
});
|
|
49
58
|
}
|
|
50
|
-
function TanstackTable(props) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
const columnItems = React.useMemo(() => mapDefsToColumnItems(columns), [columns]);
|
|
76
|
-
const visibleData = React.useMemo(
|
|
77
|
-
() => table.getRowModel().rows.map((r) => r.original),
|
|
78
|
-
[table, data]
|
|
79
|
-
);
|
|
80
|
-
const s = (_a = table.getState().sorting) == null ? void 0 : _a[0];
|
|
81
|
-
const sortById = (_b = s == null ? void 0 : s.id) != null ? _b : void 0;
|
|
82
|
-
const sortDirection = s ? s.desc ? "desc" : "asc" : null;
|
|
83
|
-
const gridTemplateColumns = React.useMemo(() => {
|
|
84
|
-
return columnItems.filter((ci) => !ci.hidden).map((ci) => {
|
|
85
|
-
var _a2;
|
|
86
|
-
const col = table.getColumn(ci.id);
|
|
87
|
-
const w = (_a2 = col == null ? void 0 : col.getSize) == null ? void 0 : _a2.call(col);
|
|
88
|
-
if (ci.fillWidth) return "1fr";
|
|
89
|
-
if (ci.fitContent) return "1%";
|
|
90
|
-
return `${w != null ? w : 180}px`;
|
|
91
|
-
}).join(" ");
|
|
92
|
-
}, [columnItems, table, table.getState().columnSizing]);
|
|
93
|
-
const columnStyles = React.useMemo(() => {
|
|
94
|
-
const styles = {};
|
|
95
|
-
for (const c of table.getAllLeafColumns()) {
|
|
96
|
-
const id = c.id;
|
|
97
|
-
const ci = columnItems.find((x) => x.id === id);
|
|
98
|
-
if (ci == null ? void 0 : ci.fillWidth) {
|
|
99
|
-
styles[id] = { width: "auto", minWidth: 0 };
|
|
100
|
-
} else if (ci == null ? void 0 : ci.fitContent) {
|
|
101
|
-
styles[id] = { width: "1%", whiteSpace: "nowrap" };
|
|
102
|
-
} else {
|
|
103
|
-
const w = c.getSize();
|
|
104
|
-
styles[id] = { width: w, minWidth: w, maxWidth: w };
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return styles;
|
|
108
|
-
}, [table, table.getState().columnSizing, columnItems]);
|
|
109
|
-
const headerExtras = React.useCallback(
|
|
110
|
-
({ index }) => {
|
|
111
|
-
var _a2, _b2, _c, _d;
|
|
112
|
-
const headerGroups = table.getHeaderGroups();
|
|
113
|
-
const leafHeaders = headerGroups.length > 0 ? headerGroups[headerGroups.length - 1].headers : [];
|
|
114
|
-
const header = leafHeaders[index];
|
|
115
|
-
if (!header) return null;
|
|
116
|
-
const canResize = (_c = (_b2 = (_a2 = header.column).getCanResize) == null ? void 0 : _b2.call(_a2)) != null ? _c : false;
|
|
117
|
-
const handler = (_d = header.getResizeHandler) == null ? void 0 : _d.call(header);
|
|
118
|
-
if (!canResize || !handler) return null;
|
|
119
|
-
return /* @__PURE__ */ jsx(ColumnResizer, { id: header.column.id, handler });
|
|
120
|
-
},
|
|
121
|
-
[table]
|
|
122
|
-
);
|
|
123
|
-
const headerBelowRow = React.useMemo(() => {
|
|
124
|
-
if (!(filterable == null ? void 0 : filterable.length)) return null;
|
|
125
|
-
return /* @__PURE__ */ jsx("div", { style: { display: "grid", gridTemplateColumns, gap: 8 }, children: columnItems.filter((ci) => !ci.hidden).map((ci) => {
|
|
126
|
-
var _a2;
|
|
127
|
-
const id = ci.id;
|
|
128
|
-
const isFilterable = filterable.includes(id);
|
|
129
|
-
if (!isFilterable) return /* @__PURE__ */ jsx("div", {}, id);
|
|
130
|
-
const col = table.getColumn(id);
|
|
131
|
-
const value = (_a2 = col == null ? void 0 : col.getFilterValue()) != null ? _a2 : "";
|
|
132
|
-
return /* @__PURE__ */ jsx(
|
|
133
|
-
"input",
|
|
134
|
-
{
|
|
135
|
-
value,
|
|
136
|
-
placeholder: `Filter ${String(ci.header)}`,
|
|
137
|
-
onChange: (e) => col == null ? void 0 : col.setFilterValue(e.target.value),
|
|
138
|
-
style: { width: "100%", padding: "4px 6px" }
|
|
59
|
+
export function TanstackTable(props) {
|
|
60
|
+
var _a, _b;
|
|
61
|
+
const { data, dataKey, columns, filterable = [], onSortingChange, ...tableProps } = props;
|
|
62
|
+
const [sorting, setSorting] = React.useState([]);
|
|
63
|
+
const [columnFilters, setColumnFilters] = React.useState([]);
|
|
64
|
+
const [columnSizing, setColumnSizing] = React.useState({});
|
|
65
|
+
const table = useReactTable({
|
|
66
|
+
data,
|
|
67
|
+
columns: columns,
|
|
68
|
+
state: { sorting, columnFilters, columnSizing },
|
|
69
|
+
onSortingChange: setSorting,
|
|
70
|
+
onColumnFiltersChange: setColumnFilters,
|
|
71
|
+
onColumnSizingChange: setColumnSizing,
|
|
72
|
+
getCoreRowModel: getCoreRowModel(),
|
|
73
|
+
getSortedRowModel: getSortedRowModel(),
|
|
74
|
+
getFilteredRowModel: getFilteredRowModel(),
|
|
75
|
+
enableColumnResizing: true,
|
|
76
|
+
columnResizeMode: 'onChange',
|
|
77
|
+
defaultColumn: {
|
|
78
|
+
enableResizing: true,
|
|
79
|
+
minSize: 80,
|
|
80
|
+
size: 180,
|
|
81
|
+
maxSize: 800,
|
|
139
82
|
},
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
{
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
83
|
+
});
|
|
84
|
+
const columnItems = React.useMemo(() => mapDefsToColumnItems(columns), [columns]);
|
|
85
|
+
const visibleData = React.useMemo(() => table.getRowModel().rows.map(r => r.original), [table]);
|
|
86
|
+
const s = (_a = table.getState().sorting) === null || _a === void 0 ? void 0 : _a[0];
|
|
87
|
+
const sortById = (_b = s === null || s === void 0 ? void 0 : s.id) !== null && _b !== void 0 ? _b : undefined;
|
|
88
|
+
const sortDirection = s ? (s.desc ? 'desc' : 'asc') : null;
|
|
89
|
+
const gridTemplateColumns = React.useMemo(() => {
|
|
90
|
+
return columnItems
|
|
91
|
+
.filter(ci => !ci.hidden)
|
|
92
|
+
.map(ci => {
|
|
93
|
+
var _a;
|
|
94
|
+
const col = table.getColumn(ci.id);
|
|
95
|
+
const w = (_a = col === null || col === void 0 ? void 0 : col.getSize) === null || _a === void 0 ? void 0 : _a.call(col);
|
|
96
|
+
if (ci.fillWidth)
|
|
97
|
+
return '1fr';
|
|
98
|
+
if (ci.fitContent)
|
|
99
|
+
return '1%';
|
|
100
|
+
return `${w !== null && w !== void 0 ? w : 180}px`;
|
|
101
|
+
})
|
|
102
|
+
.join(' ');
|
|
103
|
+
}, [columnItems, table]);
|
|
104
|
+
const columnStyles = React.useMemo(() => {
|
|
105
|
+
const styles = {};
|
|
106
|
+
for (const c of table.getAllLeafColumns()) {
|
|
107
|
+
const id = c.id;
|
|
108
|
+
const ci = columnItems.find(x => x.id === id);
|
|
109
|
+
if (ci === null || ci === void 0 ? void 0 : ci.fillWidth) {
|
|
110
|
+
styles[id] = { width: 'auto', minWidth: 0 };
|
|
111
|
+
}
|
|
112
|
+
else if (ci === null || ci === void 0 ? void 0 : ci.fitContent) {
|
|
113
|
+
styles[id] = { width: '1%', whiteSpace: 'nowrap' };
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
const w = c.getSize();
|
|
117
|
+
styles[id] = { width: w, minWidth: w, maxWidth: w };
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return styles;
|
|
121
|
+
}, [table, columnItems]);
|
|
122
|
+
const headerExtras = React.useCallback(({ index }) => {
|
|
123
|
+
var _a, _b, _c, _d;
|
|
124
|
+
const headerGroups = table.getHeaderGroups();
|
|
125
|
+
const leafHeaders = headerGroups.length > 0 ? headerGroups[headerGroups.length - 1].headers : [];
|
|
126
|
+
const header = leafHeaders[index];
|
|
127
|
+
if (!header)
|
|
128
|
+
return null;
|
|
129
|
+
const canResize = (_c = (_b = (_a = header.column).getCanResize) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : false;
|
|
130
|
+
const handler = (_d = header.getResizeHandler) === null || _d === void 0 ? void 0 : _d.call(header);
|
|
131
|
+
if (!canResize || !handler)
|
|
132
|
+
return null;
|
|
133
|
+
return _jsx(ColumnResizer, { id: header.column.id, handler: handler });
|
|
134
|
+
}, [table]);
|
|
135
|
+
const headerBelowRow = React.useMemo(() => {
|
|
136
|
+
if (!(filterable === null || filterable === void 0 ? void 0 : filterable.length))
|
|
137
|
+
return null;
|
|
138
|
+
return (_jsx("div", { style: { display: 'grid', gridTemplateColumns, gap: 8 }, children: columnItems
|
|
139
|
+
.filter(ci => !ci.hidden)
|
|
140
|
+
.map(ci => {
|
|
141
|
+
var _a;
|
|
142
|
+
const id = ci.id;
|
|
143
|
+
const isFilterable = filterable.includes(id);
|
|
144
|
+
if (!isFilterable)
|
|
145
|
+
return _jsx("div", {}, id);
|
|
146
|
+
const col = table.getColumn(id);
|
|
147
|
+
const value = (_a = col === null || col === void 0 ? void 0 : col.getFilterValue()) !== null && _a !== void 0 ? _a : '';
|
|
148
|
+
return (_jsx("input", { value: value, placeholder: `Filter ${String(ci.header)}`, onChange: e => col === null || col === void 0 ? void 0 : col.setFilterValue(e.target.value), style: { width: '100%', padding: '4px 6px' } }, id));
|
|
149
|
+
}) }));
|
|
150
|
+
}, [columnItems, filterable, table, gridTemplateColumns]);
|
|
151
|
+
return (_jsx(Table, { ...tableProps, dataKey: dataKey, data: visibleData, columns: columnItems, sortById: sortById, sortDirection: sortDirection, onSortChange: (col, dir) => {
|
|
152
|
+
var _a, _b, _c;
|
|
153
|
+
const id = String(col.id);
|
|
154
|
+
if (!id)
|
|
155
|
+
return;
|
|
156
|
+
if (!dir)
|
|
157
|
+
table.setSorting([]);
|
|
158
|
+
else
|
|
159
|
+
table.setSorting([{ id, desc: dir === 'desc' }]);
|
|
160
|
+
onSortingChange === null || onSortingChange === void 0 ? void 0 : onSortingChange((_c = (_b = (_a = table.getState().sorting) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : null, dir);
|
|
161
|
+
}, headerExtras: headerExtras, columnStyles: columnStyles, headerBelowRow: headerBelowRow }));
|
|
166
162
|
}
|
|
167
|
-
|
|
168
|
-
export { TanstackTable };
|
|
@@ -1,84 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
3
4
|
import styles from './Tabs.module.css';
|
|
4
|
-
import { Headline } from '../headline/Headline';
|
|
5
5
|
import { Chip } from '../chip/Chip';
|
|
6
|
-
|
|
7
|
-
function Tabs({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
[
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
onTabChange == null ? void 0 : onTabChange(index, tab);
|
|
36
|
-
},
|
|
37
|
-
[onTabChange, manuallySetActiveTab, setActiveTab]
|
|
38
|
-
);
|
|
39
|
-
const filteredTabs = useMemo(() => tabs.filter((tab) => !tab.hidden), [tabs]);
|
|
40
|
-
const activeIndex = useMemo(() => {
|
|
41
|
-
var _a2, _b;
|
|
42
|
-
return (_b = filteredTabs.findIndex((tab) => tab.id === currentId)) != null ? _b : (_a2 = filteredTabs[0]) == null ? void 0 : _a2.id;
|
|
43
|
-
}, [currentId, filteredTabs]);
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
if (activeIndex === -1 && filteredTabs.length > 0) {
|
|
46
|
-
setActiveTab(filteredTabs[0].id);
|
|
47
|
-
}
|
|
48
|
-
}, [activeIndex, filteredTabs, setActiveTab]);
|
|
49
|
-
return /* @__PURE__ */ jsxs("div", { className: "grow-container", children: [
|
|
50
|
-
header && /* @__PURE__ */ jsxs("div", { className: styles.headerContainer, children: [
|
|
51
|
-
/* @__PURE__ */ jsx(Headline, { disableMargin: true, size: 2, children: header }),
|
|
52
|
-
addition
|
|
53
|
-
] }),
|
|
54
|
-
/* @__PURE__ */ jsxs("div", { className: `${styles.tabs} ${styles[variant]} ${panelStyle ? styles.panelStyle : ""}`, children: [
|
|
55
|
-
/* @__PURE__ */ jsx("div", { className: styles.tabList, children: filteredTabs.map((tab, index) => /* @__PURE__ */ jsx(
|
|
56
|
-
"div",
|
|
57
|
-
{
|
|
58
|
-
"data-index": index,
|
|
59
|
-
className: `${styles.tab} ${activeIndex === index ? styles.active : ""}`,
|
|
60
|
-
children: /* @__PURE__ */ jsxs(
|
|
61
|
-
"button",
|
|
62
|
-
{
|
|
63
|
-
className: `${styles.tabButton}`,
|
|
64
|
-
onClick: () => handleTabChange(index, tab),
|
|
65
|
-
disabled: tab.disabled,
|
|
66
|
-
children: [
|
|
67
|
-
/* @__PURE__ */ jsx("span", { className: styles.icon, children: tab.headerIcon }),
|
|
68
|
-
/* @__PURE__ */ jsx("span", { className: styles.header, children: tab.header }),
|
|
69
|
-
tab.badge !== void 0 && tab.badge > 0 && /* @__PURE__ */ jsxs("span", { className: styles.badge, children: [
|
|
70
|
-
" ",
|
|
71
|
-
/* @__PURE__ */ jsx(Chip, { severity: "info", size: "sm", children: tab.badge.toLocaleString("da-DK") })
|
|
72
|
-
] })
|
|
73
|
-
]
|
|
74
|
-
}
|
|
75
|
-
)
|
|
76
|
-
},
|
|
77
|
-
index
|
|
78
|
-
)) }),
|
|
79
|
-
/* @__PURE__ */ jsx("div", { className: `${styles.tabContent} scrollable`, children: (_a = filteredTabs[activeIndex]) == null ? void 0 : _a.content })
|
|
80
|
-
] })
|
|
81
|
-
] });
|
|
6
|
+
import { Headline } from '../headline/Headline';
|
|
7
|
+
export function Tabs({ variant, header, tabs, activeId, onTabChange, manuallySetActiveTab, addition, panelStyle, }) {
|
|
8
|
+
var _a;
|
|
9
|
+
const [currentId, setCurrentId] = useState(activeId);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (activeId !== undefined) {
|
|
12
|
+
setCurrentId(activeId);
|
|
13
|
+
}
|
|
14
|
+
}, [activeId]);
|
|
15
|
+
const setActiveTab = useCallback((id) => {
|
|
16
|
+
setCurrentId(id);
|
|
17
|
+
}, [setCurrentId]);
|
|
18
|
+
const handleTabChange = useCallback((index, tab) => {
|
|
19
|
+
if (!manuallySetActiveTab) {
|
|
20
|
+
setActiveTab(tab.id);
|
|
21
|
+
}
|
|
22
|
+
onTabChange === null || onTabChange === void 0 ? void 0 : onTabChange(index, tab);
|
|
23
|
+
}, [onTabChange, manuallySetActiveTab, setActiveTab]);
|
|
24
|
+
const filteredTabs = useMemo(() => tabs.filter(tab => !tab.hidden), [tabs]);
|
|
25
|
+
const activeIndex = useMemo(() => {
|
|
26
|
+
var _a, _b;
|
|
27
|
+
return (_a = filteredTabs.findIndex(tab => tab.id === currentId)) !== null && _a !== void 0 ? _a : (_b = filteredTabs[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
28
|
+
}, [currentId, filteredTabs]);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (activeIndex === -1 && filteredTabs.length > 0) {
|
|
31
|
+
setActiveTab(filteredTabs[0].id);
|
|
32
|
+
}
|
|
33
|
+
}, [activeIndex, filteredTabs, setActiveTab]);
|
|
34
|
+
return (_jsxs("div", { className: "grow-container", children: [header && (_jsxs("div", { className: styles.headerContainer, children: [_jsx(Headline, { disableMargin: true, size: 2, children: header }), addition] })), _jsxs("div", { className: `${styles.tabs} ${styles[variant]} ${panelStyle ? styles.panelStyle : ''}`, children: [_jsx("div", { className: styles.tabList, children: filteredTabs.map((tab, index) => (_jsx("div", { "data-index": index, className: `${styles.tab} ${activeIndex === index ? styles.active : ''}`, children: _jsxs("button", { className: `${styles.tabButton}`, onClick: () => handleTabChange(index, tab), disabled: tab.disabled, children: [_jsx("span", { className: styles.icon, children: tab.headerIcon }), _jsx("span", { className: styles.header, children: tab.header }), tab.badge !== undefined && tab.badge > 0 && (_jsxs("span", { className: styles.badge, children: [' ', _jsx(Chip, { severity: "info", size: "sm", children: tab.badge.toLocaleString('da-DK') })] }))] }) }, index))) }), _jsx("div", { className: `${styles.tabContent} scrollable`, children: (_a = filteredTabs[activeIndex]) === null || _a === void 0 ? void 0 : _a.content })] })] }));
|
|
82
35
|
}
|
|
83
|
-
|
|
84
|
-
export { Tabs };
|