@dbcdk/react-components 0.0.102 → 0.0.104
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.cjs +87 -0
- package/dist/assets/logo.js +85 -0
- package/dist/client.cjs +587 -0
- package/dist/client.d.ts +83 -0
- package/dist/client.js +84 -0
- package/dist/components/accordion/Accordion.cjs +103 -0
- package/dist/components/accordion/Accordion.js +97 -0
- package/dist/components/accordion/Accordion.module.css +41 -0
- package/dist/components/accordion/components/AccordionRow.cjs +115 -0
- package/dist/components/accordion/components/AccordionRow.js +109 -0
- package/dist/components/accordion/components/AccordionRow.module.css +99 -0
- package/dist/components/alert/Alert.cjs +52 -0
- package/dist/components/alert/Alert.d.ts +2 -1
- package/dist/components/alert/Alert.js +46 -0
- package/dist/components/alert/Alert.module.css +97 -0
- package/dist/components/app-header/AppHeader.cjs +14 -0
- package/dist/components/app-header/AppHeader.js +8 -0
- package/dist/components/app-header/AppHeader.module.css +74 -0
- package/dist/components/attribute-chip/AttributeChip.cjs +22 -0
- package/dist/components/attribute-chip/AttributeChip.js +16 -0
- package/dist/components/attribute-chip/AttributeChip.module.css +65 -0
- package/dist/components/avatar/Avatar.cjs +111 -0
- package/dist/components/avatar/Avatar.js +86 -0
- package/dist/components/avatar/Avatar.module.css +91 -0
- package/dist/components/breadcrumbs/Breadcrumbs.cjs +24 -0
- package/dist/components/breadcrumbs/Breadcrumbs.js +18 -0
- package/dist/components/breadcrumbs/Breadcrumbs.module.css +80 -0
- package/dist/components/button/Button.cjs +149 -0
- package/dist/components/button/Button.js +124 -0
- package/dist/components/button/Button.module.css +260 -0
- package/dist/components/button-select/ButtonSelect.cjs +35 -0
- package/dist/components/button-select/ButtonSelect.js +29 -0
- package/dist/components/button-select/ButtonSelect.module.css +40 -0
- package/dist/components/card/Card.cjs +112 -0
- package/dist/components/card/Card.d.ts +2 -1
- package/dist/components/card/Card.js +106 -0
- package/dist/components/card/Card.module.css +187 -0
- package/dist/components/card/components/CardMeta.cjs +62 -0
- package/dist/components/card/components/CardMeta.js +55 -0
- package/dist/components/card/components/CardMeta.module.css +55 -0
- package/dist/components/card-container/CardContainer.cjs +34 -0
- package/dist/components/card-container/CardContainer.js +28 -0
- package/dist/components/card-container/CardContainer.module.css +63 -0
- package/dist/components/chip/Chip.cjs +65 -0
- package/dist/components/chip/Chip.js +59 -0
- package/dist/components/chip/Chip.module.css +236 -0
- package/dist/components/circle/Circle.cjs +33 -0
- package/dist/components/circle/Circle.js +27 -0
- package/dist/components/circle/Circle.module.css +128 -0
- package/dist/components/clear-button/ClearButton.cjs +33 -0
- package/dist/components/clear-button/ClearButton.d.ts +2 -1
- package/dist/components/clear-button/ClearButton.js +27 -0
- package/dist/components/clear-button/ClearButton.module.css +26 -0
- package/dist/components/code-block/CodeBlock.cjs +97 -0
- package/dist/components/code-block/CodeBlock.js +91 -0
- package/dist/components/code-block/CodeBlock.module.css +124 -0
- package/dist/components/copy-button/CopyButton.cjs +139 -0
- package/dist/components/copy-button/CopyButton.js +133 -0
- package/dist/components/copy-button/CopyButton.module.css +22 -0
- package/dist/components/datetime-picker/DateTimePicker.cjs +559 -0
- package/dist/components/datetime-picker/DateTimePicker.js +553 -0
- package/dist/components/datetime-picker/DateTimePicker.module.css +155 -0
- package/dist/components/datetime-picker/dateTimeHelpers.cjs +179 -0
- package/dist/components/datetime-picker/dateTimeHelpers.js +160 -0
- package/dist/components/divider/Divider.cjs +22 -0
- package/dist/components/divider/Divider.js +20 -0
- package/dist/components/filter-field/FilterField.cjs +296 -0
- package/dist/components/filter-field/FilterField.js +289 -0
- package/dist/components/filter-field/FilterField.module.css +379 -0
- package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.cjs +115 -0
- package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.js +108 -0
- package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.module.css +59 -0
- package/dist/components/forms/checkbox/Checkbox.cjs +88 -0
- package/dist/components/forms/checkbox/Checkbox.js +82 -0
- package/dist/components/forms/checkbox/Checkbox.module.css +104 -0
- package/dist/components/forms/checkbox-group/CheckboxGroup.cjs +121 -0
- package/dist/components/forms/checkbox-group/CheckboxGroup.js +115 -0
- package/dist/components/forms/checkbox-group/CheckboxGroup.module.css +115 -0
- package/dist/components/forms/form-select/FormSelect.cjs +191 -0
- package/dist/components/forms/form-select/FormSelect.js +166 -0
- package/dist/components/forms/form-select/FormSelect.module.css +236 -0
- package/dist/components/forms/input/Input.cjs +188 -0
- package/dist/components/forms/input/Input.d.ts +1 -0
- package/dist/components/forms/input/Input.js +182 -0
- package/dist/components/forms/input/Input.module.css +468 -0
- package/dist/components/forms/input-container/InputContainer.cjs +72 -0
- package/dist/components/forms/input-container/InputContainer.js +66 -0
- package/dist/components/forms/input-container/InputContainer.module.css +59 -0
- package/dist/components/forms/multi-select/MultiSelect.cjs +227 -0
- package/dist/components/forms/multi-select/MultiSelect.js +225 -0
- package/dist/components/forms/radio-buttons/RadioButton.cjs +91 -0
- package/dist/components/forms/radio-buttons/RadioButton.js +85 -0
- package/dist/components/forms/radio-buttons/RadioButtonGroup.cjs +74 -0
- package/dist/components/forms/radio-buttons/RadioButtonGroup.js +72 -0
- package/dist/components/forms/radio-buttons/RadioButtons.module.css +118 -0
- package/dist/components/forms/select/Select.cjs +286 -0
- package/dist/components/forms/select/Select.js +280 -0
- package/dist/components/forms/select/Select.module.css +32 -0
- package/dist/components/forms/text-area/Textarea.cjs +116 -0
- package/dist/components/forms/text-area/Textarea.js +110 -0
- package/dist/components/forms/text-area/Textarea.module.css +70 -0
- package/dist/components/forms/typeahead/Typeahead.cjs +792 -0
- package/dist/components/forms/typeahead/Typeahead.js +768 -0
- package/dist/components/forms/typeahead/Typeahead.module.css +38 -0
- package/dist/components/grid/Grid.cjs +45 -0
- package/dist/components/grid/Grid.js +38 -0
- package/dist/components/grid/Grid.module.css +35 -0
- package/dist/components/headline/CollapsibleHeadline.cjs +80 -0
- package/dist/components/headline/CollapsibleHeadline.js +74 -0
- package/dist/components/headline/Headline.cjs +59 -0
- package/dist/components/headline/Headline.js +53 -0
- package/dist/components/headline/Headline.module.css +185 -0
- package/dist/components/hyperlink/Hyperlink.cjs +107 -0
- package/dist/components/hyperlink/Hyperlink.d.ts +1 -0
- package/dist/components/hyperlink/Hyperlink.js +82 -0
- package/dist/components/hyperlink/Hyperlink.module.css +121 -0
- package/dist/components/icon/Icon.cjs +27 -0
- package/dist/components/icon/Icon.js +20 -0
- package/dist/components/icon/Icon.module.css +36 -0
- package/dist/components/inline-status/InlineStatus.cjs +39 -0
- package/dist/components/inline-status/InlineStatus.js +33 -0
- package/dist/components/inline-status/InlineStatus.module.css +92 -0
- package/dist/components/interval-select/IntervalSelect.cjs +203 -0
- package/dist/components/interval-select/IntervalSelect.js +201 -0
- package/dist/components/json-viewer/HighlightedText.cjs +13 -0
- package/dist/components/json-viewer/HighlightedText.js +11 -0
- package/dist/components/json-viewer/JsonNode.cjs +124 -0
- package/dist/components/json-viewer/JsonNode.js +118 -0
- package/dist/components/json-viewer/JsonViewer.cjs +164 -0
- package/dist/components/json-viewer/JsonViewer.js +158 -0
- package/dist/components/json-viewer/JsonViewer.module.css +346 -0
- package/dist/components/json-viewer/types.cjs +2 -0
- package/dist/components/json-viewer/types.js +1 -0
- package/dist/components/json-viewer/useClipboardStatus.cjs +15 -0
- package/dist/components/json-viewer/useClipboardStatus.js +13 -0
- package/dist/components/json-viewer/utils.cjs +126 -0
- package/dist/components/json-viewer/utils.js +111 -0
- package/dist/components/media-card/MediaCard.cjs +60 -0
- package/dist/components/media-card/MediaCard.d.ts +19 -0
- package/dist/components/media-card/MediaCard.js +54 -0
- package/dist/components/media-card/MediaCard.module.css +92 -0
- package/dist/components/menu/Menu.cjs +287 -0
- package/dist/components/menu/Menu.js +262 -0
- package/dist/components/menu/Menu.module.css +220 -0
- package/dist/components/meta-bar/MetaBar.cjs +28 -0
- package/dist/components/meta-bar/MetaBar.js +22 -0
- package/dist/components/meta-bar/MetaBar.module.css +27 -0
- package/dist/components/nav-bar/NavBar.cjs +95 -0
- package/dist/components/nav-bar/NavBar.d.ts +1 -1
- package/dist/components/nav-bar/NavBar.js +89 -0
- package/dist/components/nav-bar/NavBar.module.css +225 -0
- package/dist/components/overlay/fade-overlay/FadeOverlay.cjs +30 -0
- package/dist/components/overlay/fade-overlay/FadeOverlay.js +24 -0
- package/dist/components/overlay/fade-overlay/FadeOverlay.module.css +54 -0
- package/dist/components/overlay/modal/Modal.cjs +189 -0
- package/dist/components/overlay/modal/Modal.d.ts +2 -1
- package/dist/components/overlay/modal/Modal.js +183 -0
- package/dist/components/overlay/modal/Modal.module.css +112 -0
- package/dist/components/overlay/modal/provider/ModalProvider.cjs +98 -0
- package/dist/components/overlay/modal/provider/ModalProvider.js +95 -0
- package/dist/components/overlay/side-panel/SidePanel.cjs +173 -0
- package/dist/components/overlay/side-panel/SidePanel.js +167 -0
- package/dist/components/overlay/side-panel/SidePanel.module.css +177 -0
- package/dist/components/overlay/side-panel/useSidePanel.cjs +16 -0
- package/dist/components/overlay/side-panel/useSidePanel.js +14 -0
- package/dist/components/overlay/tooltip/Tooltip.cjs +34 -0
- package/dist/components/overlay/tooltip/Tooltip.js +32 -0
- package/dist/components/overlay/tooltip/Tooltip.module.css +104 -0
- package/dist/components/overlay/tooltip/TooltipProvider.cjs +238 -0
- package/dist/components/overlay/tooltip/TooltipProvider.js +231 -0
- package/dist/components/overlay/tooltip/useTooltipTrigger.cjs +117 -0
- package/dist/components/overlay/tooltip/useTooltipTrigger.js +115 -0
- package/dist/components/page/Page.cjs +63 -0
- package/dist/components/page/Page.js +57 -0
- package/dist/components/page/Page.module.css +95 -0
- package/dist/components/page-layout/PageLayout.cjs +97 -0
- package/dist/components/page-layout/PageLayout.d.ts +0 -5
- package/dist/components/page-layout/PageLayout.js +91 -0
- package/dist/components/page-layout/PageLayout.module.css +236 -0
- package/dist/components/page-layout/components/footer/Footer.cjs +53 -0
- package/dist/components/page-layout/components/footer/Footer.js +47 -0
- package/dist/components/page-layout/components/footer/Footer.module.css +89 -0
- package/dist/components/pagination/Pagination.cjs +160 -0
- package/dist/components/pagination/Pagination.js +154 -0
- package/dist/components/pagination/Pagination.module.css +25 -0
- package/dist/components/panel/Panel.cjs +38 -0
- package/dist/components/panel/Panel.js +32 -0
- package/dist/components/panel/Panel.module.css +30 -0
- package/dist/components/popover/Popover.cjs +331 -0
- package/dist/components/popover/Popover.js +307 -0
- package/dist/components/popover/Popover.module.css +52 -0
- package/dist/components/search-box/SearchBox.cjs +274 -0
- package/dist/components/search-box/SearchBox.js +268 -0
- package/dist/components/search-box/SearchBox.module.css +27 -0
- package/dist/components/segmented-progress-bar/SegmentedProgressBar.cjs +127 -0
- package/dist/components/segmented-progress-bar/SegmentedProgressBar.js +121 -0
- package/dist/components/segmented-progress-bar/SegmentedProgressBar.module.css +174 -0
- package/dist/components/sidebar/Sidebar.cjs +39 -0
- package/dist/components/sidebar/Sidebar.js +37 -0
- package/dist/components/sidebar/components/SidebarItem.cjs +29 -0
- package/dist/components/sidebar/components/SidebarItem.js +27 -0
- package/dist/components/sidebar/components/SidebarItem.module.css +0 -0
- package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.cjs +133 -0
- package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.js +127 -0
- package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.module.css +29 -0
- package/dist/components/sidebar/components/sidebar-container/SidebarContainer.cjs +214 -0
- package/dist/components/sidebar/components/sidebar-container/SidebarContainer.js +207 -0
- package/dist/components/sidebar/components/sidebar-container/SidebarContainer.module.css +260 -0
- package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.cjs +54 -0
- package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.js +47 -0
- package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.module.css +106 -0
- package/dist/components/sidebar/components/sidebar-items/SidebarItems.cjs +61 -0
- package/dist/components/sidebar/components/sidebar-items/SidebarItems.js +55 -0
- package/dist/components/sidebar/components/sidebar-items/SidebarItems.module.css +20 -0
- package/dist/components/sidebar/components/sidenav-filteirng/SidenavFiltering.cjs +97 -0
- package/dist/components/sidebar/components/sidenav-filteirng/SidenavFiltering.js +91 -0
- package/dist/components/sidebar/providers/SidebarProvider.cjs +223 -0
- package/dist/components/sidebar/providers/SidebarProvider.js +220 -0
- package/dist/components/skeleton-loader/SkeletonLoader.cjs +442 -0
- package/dist/components/skeleton-loader/SkeletonLoader.js +440 -0
- package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.cjs +42 -0
- package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.js +36 -0
- package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.module.css +51 -0
- package/dist/components/split-button/SplitButton.cjs +46 -0
- package/dist/components/split-button/SplitButton.js +40 -0
- package/dist/components/split-button/SplitButton.module.css +32 -0
- package/dist/components/split-pane/SplitPane.cjs +177 -0
- package/dist/components/split-pane/SplitPane.js +168 -0
- package/dist/components/split-pane/SplitPane.module.css +111 -0
- package/dist/components/split-pane/provider/SplitPaneContext.cjs +129 -0
- package/dist/components/split-pane/provider/SplitPaneContext.js +121 -0
- package/dist/components/stack/Stack.cjs +47 -0
- package/dist/components/stack/Stack.d.ts +1 -1
- package/dist/components/stack/Stack.js +41 -0
- package/dist/components/stack/Stack.module.css +61 -0
- package/dist/components/state-page/StatePage.cjs +48 -0
- package/dist/components/state-page/StatePage.js +42 -0
- package/dist/components/state-page/StatePage.module.css +9 -0
- package/dist/components/state-page/empty.cjs +664 -0
- package/dist/components/state-page/empty.js +662 -0
- package/dist/components/state-page/error.cjs +310 -0
- package/dist/components/state-page/error.js +308 -0
- package/dist/components/state-page/notFound.cjs +243 -0
- package/dist/components/state-page/notFound.js +241 -0
- package/dist/components/sticky-footer-layout/StickyFooterLayout.cjs +98 -0
- package/dist/components/sticky-footer-layout/StickyFooterLayout.js +96 -0
- package/dist/components/table/Table.cjs +216 -0
- package/dist/components/table/Table.js +210 -0
- package/dist/components/table/Table.module.css +534 -0
- package/dist/components/table/Table.types.cjs +2 -0
- package/dist/components/table/Table.types.js +1 -0
- package/dist/components/table/TanstackTable.cjs +172 -0
- package/dist/components/table/TanstackTable.js +147 -0
- package/dist/components/table/components/TableBody.cjs +50 -0
- package/dist/components/table/components/TableBody.js +44 -0
- package/dist/components/table/components/TableHeader.cjs +56 -0
- package/dist/components/table/components/TableHeader.js +50 -0
- package/dist/components/table/components/TableHeaderCell.cjs +69 -0
- package/dist/components/table/components/TableHeaderCell.js +63 -0
- package/dist/components/table/components/TableLoadingBody.cjs +35 -0
- package/dist/components/table/components/TableLoadingBody.js +29 -0
- package/dist/components/table/components/TablePagination.cjs +2 -0
- package/dist/components/table/components/TablePagination.js +1 -0
- package/dist/components/table/components/TableRow.cjs +151 -0
- package/dist/components/table/components/TableRow.js +145 -0
- package/dist/components/table/components/TableSelectionCell.cjs +41 -0
- package/dist/components/table/components/TableSelectionCell.js +35 -0
- package/dist/components/table/components/column-resizer/ColumnResizer.cjs +25 -0
- package/dist/components/table/components/column-resizer/ColumnResizer.js +19 -0
- package/dist/components/table/components/column-resizer/ColumnResizer.module.css +22 -0
- package/dist/components/table/components/empty-state/EmptyState.cjs +33 -0
- package/dist/components/table/components/empty-state/EmptyState.js +31 -0
- package/dist/components/table/components/empty-state/EmptyState.module.css +4 -0
- package/dist/components/table/components/table-settings/TableSettings.cjs +139 -0
- package/dist/components/table/components/table-settings/TableSettings.js +137 -0
- package/dist/components/table/hooks/useTableRowInteractions.cjs +46 -0
- package/dist/components/table/hooks/useTableRowInteractions.js +44 -0
- package/dist/components/table/table.classes.cjs +49 -0
- package/dist/components/table/table.classes.js +40 -0
- package/dist/components/table/table.utils.cjs +57 -0
- package/dist/components/table/table.utils.js +45 -0
- package/dist/components/table/tanstackTable.utils.cjs +166 -0
- package/dist/components/table/tanstackTable.utils.js +159 -0
- package/dist/components/tabs/Tabs.cjs +172 -0
- package/dist/components/tabs/Tabs.js +166 -0
- package/dist/components/tabs/Tabs.module.css +261 -0
- package/dist/components/theme-button/ThemeButton.cjs +78 -0
- package/dist/components/theme-button/ThemeButton.js +75 -0
- package/dist/components/toast/Toast.cjs +68 -0
- package/dist/components/toast/Toast.js +62 -0
- package/dist/components/toast/Toast.module.css +161 -0
- package/dist/components/toast/provider/ToastProvider.cjs +105 -0
- package/dist/components/toast/provider/ToastProvider.js +97 -0
- package/dist/components/user-display/UserDisplay.cjs +22 -0
- package/dist/components/user-display/UserDisplay.js +16 -0
- package/dist/components/user-display/UserDisplay.module.css +25 -0
- package/dist/constants/chart-colors.cjs +10 -0
- package/dist/constants/chart-colors.js +8 -0
- package/dist/constants/chart-colors.types.cjs +2 -0
- package/dist/constants/chart-colors.types.js +1 -0
- package/dist/constants/severity.cjs +30 -0
- package/dist/constants/severity.js +26 -0
- package/dist/constants/severity.types.cjs +2 -0
- package/dist/constants/severity.types.js +1 -0
- package/dist/constants/sizes.cjs +11 -0
- package/dist/constants/sizes.js +9 -0
- package/dist/hooks/useDeviceSize.cjs +35 -0
- package/dist/hooks/useDeviceSize.js +33 -0
- package/dist/hooks/useListNavigation.cjs +237 -0
- package/dist/hooks/useListNavigation.js +235 -0
- package/dist/hooks/usePagination.cjs +144 -0
- package/dist/hooks/usePagination.js +142 -0
- package/dist/hooks/useSorting.cjs +119 -0
- package/dist/hooks/useSorting.js +117 -0
- package/dist/hooks/useTableData.cjs +53 -0
- package/dist/hooks/useTableData.js +51 -0
- package/dist/hooks/useTableSelection.cjs +172 -0
- package/dist/hooks/useTableSelection.js +170 -0
- package/dist/hooks/useTableSettings.cjs +90 -0
- package/dist/hooks/useTableSettings.js +87 -0
- package/dist/hooks/useTheme.cjs +64 -0
- package/dist/hooks/useTheme.js +62 -0
- package/dist/hooks/useTimeDuration.cjs +72 -0
- package/dist/hooks/useTimeDuration.js +70 -0
- package/dist/hooks/useViewportFill.cjs +82 -0
- package/dist/hooks/useViewportFill.js +80 -0
- package/dist/index.cjs +161 -12901
- package/dist/index.css +67 -7228
- package/dist/index.d.ts +0 -58
- package/dist/index.js +24 -12802
- package/dist/styles/animation.cjs +9 -0
- package/dist/styles/animation.js +7 -0
- package/dist/styles/themes/dbc/colors.css +5 -0
- package/dist/styles/themes/types.cjs +2 -0
- package/dist/styles/themes/types.js +1 -0
- package/dist/tanstack.cjs +18 -2652
- package/dist/tanstack.js +3 -2636
- package/dist/types/a11y-props.types.cjs +2 -0
- package/dist/types/a11y-props.types.js +1 -0
- package/dist/types/assets.d.cjs +2 -0
- package/dist/types/assets.d.js +1 -0
- package/dist/types/css.d.cjs +2 -0
- package/dist/types/css.d.js +1 -0
- package/dist/types/sizes.types.cjs +2 -0
- package/dist/types/sizes.types.js +1 -0
- package/dist/utils/arrays/nested-filtering.cjs +40 -0
- package/dist/utils/arrays/nested-filtering.js +38 -0
- package/dist/utils/date/formatDate.cjs +35 -0
- package/dist/utils/date/formatDate.js +33 -0
- package/dist/utils/localStorage.utils.cjs +53 -0
- package/dist/utils/localStorage.utils.js +49 -0
- package/dist/utils/text/get-highlighted-segments.cjs +49 -0
- package/dist/utils/text/get-highlighted-segments.js +47 -0
- package/package.json +8 -3
- package/dist/tanstack.css +0 -1271
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { DEFAULT_COLUMN_PX, SELECTION_COLUMN_PX } from './table.utils';
|
|
2
|
+
|
|
3
|
+
function getColumnId(def, index) {
|
|
4
|
+
const d = def;
|
|
5
|
+
if (d.id != null && String(d.id).length > 0) return String(d.id);
|
|
6
|
+
if (d.accessorKey != null && String(d.accessorKey).length > 0) return String(d.accessorKey);
|
|
7
|
+
return `col_${index}`;
|
|
8
|
+
}
|
|
9
|
+
function buildColumnVisibilityFromVisibleIds(defs, visibleColumnIds) {
|
|
10
|
+
if (!(visibleColumnIds == null ? void 0 : visibleColumnIds.length)) return {};
|
|
11
|
+
const visible = new Set(visibleColumnIds);
|
|
12
|
+
const next = {};
|
|
13
|
+
defs.forEach((def, index) => {
|
|
14
|
+
const id = getColumnId(def, index);
|
|
15
|
+
next[id] = visible.has(id);
|
|
16
|
+
});
|
|
17
|
+
return next;
|
|
18
|
+
}
|
|
19
|
+
function mapDefsToColumnItems(defs, columnVisibility, resolvedLayout = {}) {
|
|
20
|
+
return defs.map((def, index) => {
|
|
21
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
22
|
+
const id = getColumnId(def, index);
|
|
23
|
+
const accessorKey = def.accessorKey;
|
|
24
|
+
const accessorFn = def.accessorFn;
|
|
25
|
+
const cell = def.cell;
|
|
26
|
+
const meta = (_a = def.meta) != null ? _a : {};
|
|
27
|
+
let render;
|
|
28
|
+
if (typeof cell === "function") {
|
|
29
|
+
render = (row) => cell({
|
|
30
|
+
row: { original: row },
|
|
31
|
+
getValue: () => accessorKey != null ? row[accessorKey] : accessorFn ? accessorFn(row) : void 0
|
|
32
|
+
});
|
|
33
|
+
} else if (accessorFn) {
|
|
34
|
+
render = (row) => accessorFn(row);
|
|
35
|
+
} else if (accessorKey != null) {
|
|
36
|
+
render = (row) => row[accessorKey];
|
|
37
|
+
} else {
|
|
38
|
+
render = () => null;
|
|
39
|
+
}
|
|
40
|
+
const isVisible = (_b = columnVisibility[id]) != null ? _b : true;
|
|
41
|
+
return {
|
|
42
|
+
id,
|
|
43
|
+
header: def.header,
|
|
44
|
+
accessor: accessorKey,
|
|
45
|
+
sortable: (_c = def.enableSorting) != null ? _c : !!accessorKey,
|
|
46
|
+
render,
|
|
47
|
+
hidden: !isVisible,
|
|
48
|
+
width: (_d = resolvedLayout[id]) == null ? void 0 : _d.width,
|
|
49
|
+
align: meta.align,
|
|
50
|
+
verticalAlign: meta.verticalAlign,
|
|
51
|
+
emptyPlaceholder: (_e = meta.emptyPlaceholder) != null ? _e : "-",
|
|
52
|
+
allowWrap: (_f = meta.allowWrap) != null ? _f : false,
|
|
53
|
+
severity: meta.severity,
|
|
54
|
+
divider: meta.divider,
|
|
55
|
+
allowOverflow: (_g = meta.allowOverflow) != null ? _g : false
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function sortingEqual(a, b) {
|
|
60
|
+
const A = a == null ? void 0 : a[0];
|
|
61
|
+
const B = b == null ? void 0 : b[0];
|
|
62
|
+
if (!A && !B) return true;
|
|
63
|
+
if (!A || !B) return false;
|
|
64
|
+
return A.id === B.id && A.desc === B.desc;
|
|
65
|
+
}
|
|
66
|
+
function getSortPropsFromSorting(sorting) {
|
|
67
|
+
const s = sorting == null ? void 0 : sorting[0];
|
|
68
|
+
return {
|
|
69
|
+
sortById: s == null ? void 0 : s.id,
|
|
70
|
+
sortDirection: s ? s.desc ? "desc" : "asc" : null
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function clamp(value, min, max) {
|
|
74
|
+
const lowerBounded = Math.max(min, value);
|
|
75
|
+
if (max == null || !Number.isFinite(max)) return lowerBounded;
|
|
76
|
+
return Math.min(lowerBounded, max);
|
|
77
|
+
}
|
|
78
|
+
function toIntegerTrackWidths(tracks, targetWidth) {
|
|
79
|
+
const floored = tracks.map((track) => ({
|
|
80
|
+
id: track.id,
|
|
81
|
+
width: Math.floor(track.width),
|
|
82
|
+
fraction: track.width - Math.floor(track.width)
|
|
83
|
+
}));
|
|
84
|
+
const baseTotal = floored.reduce((sum, track) => sum + track.width, 0);
|
|
85
|
+
let remainder = Math.max(0, targetWidth - baseTotal);
|
|
86
|
+
floored.slice().sort((a, b) => b.fraction - a.fraction).forEach((track) => {
|
|
87
|
+
if (remainder <= 0) return;
|
|
88
|
+
track.width += 1;
|
|
89
|
+
remainder -= 1;
|
|
90
|
+
});
|
|
91
|
+
return Object.fromEntries(floored.map((track) => [track.id, track.width]));
|
|
92
|
+
}
|
|
93
|
+
function buildDistributedColumnWidths(args) {
|
|
94
|
+
const { table, hasSelection, defaultMinPx, columnSizing, availableWidth } = args;
|
|
95
|
+
const leaf = table.getVisibleLeafColumns();
|
|
96
|
+
const selectionWidth = hasSelection ? SELECTION_COLUMN_PX : 0;
|
|
97
|
+
const tracks = leaf.map((c) => {
|
|
98
|
+
var _a, _b, _c, _d;
|
|
99
|
+
const def = c.columnDef;
|
|
100
|
+
const meta = (_a = def.meta) != null ? _a : {};
|
|
101
|
+
const min = Math.max(1, Number((_b = def.minSize) != null ? _b : defaultMinPx));
|
|
102
|
+
const max = def.maxSize != null ? Math.max(min, Number(def.maxSize)) : void 0;
|
|
103
|
+
const resizedPxRaw = columnSizing[c.id];
|
|
104
|
+
const resizedPx = resizedPxRaw != null ? Math.round(clamp(Number(resizedPxRaw), min, max)) : void 0;
|
|
105
|
+
if (resizedPx != null) {
|
|
106
|
+
return {
|
|
107
|
+
id: c.id,
|
|
108
|
+
width: resizedPx,
|
|
109
|
+
weight: 0,
|
|
110
|
+
max: resizedPx,
|
|
111
|
+
fixed: true
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
const rawWeight = Number((_d = (_c = meta.weight) != null ? _c : def.size) != null ? _d : DEFAULT_COLUMN_PX);
|
|
115
|
+
const weight = Number.isFinite(rawWeight) && rawWeight > 0 ? rawWeight : DEFAULT_COLUMN_PX;
|
|
116
|
+
return {
|
|
117
|
+
id: c.id,
|
|
118
|
+
width: min,
|
|
119
|
+
weight,
|
|
120
|
+
max,
|
|
121
|
+
fixed: false
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
const fixedWidth = selectionWidth + tracks.reduce((sum, track) => sum + track.width, 0);
|
|
125
|
+
let remaining = Math.max(0, availableWidth - fixedWidth);
|
|
126
|
+
let active = tracks.filter(
|
|
127
|
+
(track) => !track.fixed && (track.max == null || track.width < track.max)
|
|
128
|
+
);
|
|
129
|
+
while (remaining > 0.5 && active.length > 0) {
|
|
130
|
+
const totalWeight = active.reduce((sum, track) => sum + track.weight, 0);
|
|
131
|
+
if (totalWeight <= 0) break;
|
|
132
|
+
let consumed = 0;
|
|
133
|
+
const nextActive = [];
|
|
134
|
+
for (const track of active) {
|
|
135
|
+
const share = remaining * track.weight / totalWeight;
|
|
136
|
+
const maxGrow = track.max == null ? share : Math.max(0, track.max - track.width);
|
|
137
|
+
const growth = Math.min(share, maxGrow);
|
|
138
|
+
track.width += growth;
|
|
139
|
+
consumed += growth;
|
|
140
|
+
if (track.max == null || track.width < track.max - 0.5) {
|
|
141
|
+
nextActive.push(track);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (consumed <= 0.5) break;
|
|
145
|
+
remaining -= consumed;
|
|
146
|
+
active = nextActive;
|
|
147
|
+
}
|
|
148
|
+
const floatTrackTotal = tracks.reduce((sum, track) => sum + track.width, 0);
|
|
149
|
+
const targetTrackWidth = floatTrackTotal <= availableWidth - selectionWidth ? Math.floor(floatTrackTotal) : Math.ceil(floatTrackTotal);
|
|
150
|
+
const widths = toIntegerTrackWidths(tracks, targetTrackWidth);
|
|
151
|
+
const totalWidth = selectionWidth + Object.values(widths).reduce((sum, width) => sum + width, 0);
|
|
152
|
+
return {
|
|
153
|
+
selectionWidth: hasSelection ? SELECTION_COLUMN_PX : void 0,
|
|
154
|
+
widths,
|
|
155
|
+
totalWidth
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export { buildColumnVisibilityFromVisibleIds, buildDistributedColumnWidths, getColumnId, getSortPropsFromSorting, mapDefsToColumnItems, sortingEqual };
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var styles = require('./Tabs.module.css');
|
|
6
|
+
var Chip = require('../chip/Chip');
|
|
7
|
+
var Headline = require('../headline/Headline');
|
|
8
|
+
var SkeletonLoader = require('../skeleton-loader/SkeletonLoader');
|
|
9
|
+
|
|
10
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
|
|
12
|
+
var styles__default = /*#__PURE__*/_interopDefault(styles);
|
|
13
|
+
|
|
14
|
+
const TabsItem = (_props) => {
|
|
15
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
16
|
+
};
|
|
17
|
+
TabsItem.__TABS_SLOT__ = "Item";
|
|
18
|
+
function getFirstEnabledId(items) {
|
|
19
|
+
var _a;
|
|
20
|
+
return (_a = items.find((t) => !t.hidden && !t.disabled)) == null ? void 0 : _a.id;
|
|
21
|
+
}
|
|
22
|
+
function normalizeFromChildren(children) {
|
|
23
|
+
const items = [];
|
|
24
|
+
react.Children.forEach(children, (child) => {
|
|
25
|
+
if (!react.isValidElement(child)) return;
|
|
26
|
+
const t = child.type;
|
|
27
|
+
if ((t == null ? void 0 : t.__TABS_SLOT__) !== "Item") return;
|
|
28
|
+
const props = child.props;
|
|
29
|
+
items.push({
|
|
30
|
+
id: props.id,
|
|
31
|
+
header: props.header,
|
|
32
|
+
headerIcon: props.headerIcon,
|
|
33
|
+
disabled: props.disabled,
|
|
34
|
+
hidden: props.hidden,
|
|
35
|
+
badge: props.badge,
|
|
36
|
+
content: props.children
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
return items;
|
|
40
|
+
}
|
|
41
|
+
function Tabs({
|
|
42
|
+
header,
|
|
43
|
+
subheader,
|
|
44
|
+
variant,
|
|
45
|
+
panelStyle = false,
|
|
46
|
+
tabs,
|
|
47
|
+
value,
|
|
48
|
+
defaultValue,
|
|
49
|
+
onValueChange,
|
|
50
|
+
addition,
|
|
51
|
+
disableTopPadding,
|
|
52
|
+
loading = false,
|
|
53
|
+
children
|
|
54
|
+
}) {
|
|
55
|
+
const uid = react.useId();
|
|
56
|
+
const sourceTabs = react.useMemo(() => {
|
|
57
|
+
if (tabs && tabs.length) return tabs;
|
|
58
|
+
return normalizeFromChildren(children);
|
|
59
|
+
}, [tabs, children]);
|
|
60
|
+
const visibleTabs = react.useMemo(() => sourceTabs.filter((t) => !t.hidden), [sourceTabs]);
|
|
61
|
+
const isControlled = value !== void 0;
|
|
62
|
+
const [internalValue, setInternalValue] = react.useState(() => {
|
|
63
|
+
return defaultValue != null ? defaultValue : getFirstEnabledId(visibleTabs);
|
|
64
|
+
});
|
|
65
|
+
const currentValue = isControlled ? value : internalValue;
|
|
66
|
+
const activeIndex = react.useMemo(() => {
|
|
67
|
+
if (!visibleTabs.length) return -1;
|
|
68
|
+
const idx = visibleTabs.findIndex((t) => t.id === currentValue);
|
|
69
|
+
return idx >= 0 ? idx : 0;
|
|
70
|
+
}, [visibleTabs, currentValue]);
|
|
71
|
+
const activeTab = activeIndex >= 0 ? visibleTabs[activeIndex] : void 0;
|
|
72
|
+
const setValue = react.useCallback(
|
|
73
|
+
(nextId) => {
|
|
74
|
+
const idx = visibleTabs.findIndex((t) => t.id === nextId);
|
|
75
|
+
const tab = idx >= 0 ? visibleTabs[idx] : void 0;
|
|
76
|
+
if (!tab || tab.disabled) return;
|
|
77
|
+
if (!isControlled) setInternalValue(nextId);
|
|
78
|
+
onValueChange == null ? void 0 : onValueChange(nextId, tab, idx);
|
|
79
|
+
},
|
|
80
|
+
[visibleTabs, isControlled, onValueChange]
|
|
81
|
+
);
|
|
82
|
+
react.useEffect(() => {
|
|
83
|
+
if (!visibleTabs.length) return;
|
|
84
|
+
const current = currentValue;
|
|
85
|
+
const stillValid = visibleTabs.some((t) => t.id === current && !t.disabled);
|
|
86
|
+
if (stillValid) return;
|
|
87
|
+
const next = getFirstEnabledId(visibleTabs);
|
|
88
|
+
if (next === void 0) return;
|
|
89
|
+
setValue(next);
|
|
90
|
+
}, [visibleTabs, currentValue, setValue]);
|
|
91
|
+
const onKeyDownTab = react.useCallback(
|
|
92
|
+
(e, index) => {
|
|
93
|
+
var _a;
|
|
94
|
+
const enabled = visibleTabs.filter((t) => !t.disabled);
|
|
95
|
+
if (!enabled.length) return;
|
|
96
|
+
const currentId = (_a = visibleTabs[index]) == null ? void 0 : _a.id;
|
|
97
|
+
const currentEnabledIndex = enabled.findIndex((t) => t.id === currentId);
|
|
98
|
+
const focusAndSelect = (enabledIndex) => {
|
|
99
|
+
const nextTab = enabled[enabledIndex];
|
|
100
|
+
if (!nextTab) return;
|
|
101
|
+
const btn = document.getElementById(
|
|
102
|
+
`${uid}-tab-${String(nextTab.id)}`
|
|
103
|
+
);
|
|
104
|
+
btn == null ? void 0 : btn.focus();
|
|
105
|
+
setValue(nextTab.id);
|
|
106
|
+
};
|
|
107
|
+
if (e.key === "ArrowRight") {
|
|
108
|
+
e.preventDefault();
|
|
109
|
+
focusAndSelect((currentEnabledIndex + 1) % enabled.length);
|
|
110
|
+
} else if (e.key === "ArrowLeft") {
|
|
111
|
+
e.preventDefault();
|
|
112
|
+
focusAndSelect((currentEnabledIndex - 1 + enabled.length) % enabled.length);
|
|
113
|
+
} else if (e.key === "Home") {
|
|
114
|
+
e.preventDefault();
|
|
115
|
+
focusAndSelect(0);
|
|
116
|
+
} else if (e.key === "End") {
|
|
117
|
+
e.preventDefault();
|
|
118
|
+
focusAndSelect(enabled.length - 1);
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
[uid, visibleTabs, setValue]
|
|
122
|
+
);
|
|
123
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles__default.default.root, children: [
|
|
124
|
+
header ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
125
|
+
"div",
|
|
126
|
+
{
|
|
127
|
+
className: [styles__default.default.headerContainer, disableTopPadding ? styles__default.default.disableTopPadding : ""].filter(Boolean).join(" "),
|
|
128
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Headline.Headline, { disableMargin: true, size: 1, subheader, addition, children: header })
|
|
129
|
+
}
|
|
130
|
+
) : null,
|
|
131
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${styles__default.default.tabs} ${styles__default.default[variant]} ${panelStyle ? styles__default.default.panelStyle : ""}`, children: [
|
|
132
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: styles__default.default.tabList, role: "tablist", "aria-label": header != null ? header : "Tabs", children: visibleTabs.map((tab, index) => {
|
|
133
|
+
const selected = index === activeIndex;
|
|
134
|
+
const tabDomId = `${uid}-tab-${String(tab.id)}`;
|
|
135
|
+
const panelDomId = `${uid}-panel-${String(tab.id)}`;
|
|
136
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${styles__default.default.tab} ${selected ? styles__default.default.active : ""}`, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
137
|
+
"button",
|
|
138
|
+
{
|
|
139
|
+
id: tabDomId,
|
|
140
|
+
type: "button",
|
|
141
|
+
className: styles__default.default.tabButton,
|
|
142
|
+
role: "tab",
|
|
143
|
+
"aria-selected": selected,
|
|
144
|
+
"aria-controls": panelDomId,
|
|
145
|
+
tabIndex: selected ? 0 : -1,
|
|
146
|
+
disabled: tab.disabled,
|
|
147
|
+
onClick: () => setValue(tab.id),
|
|
148
|
+
onKeyDown: (e) => onKeyDownTab(e, index),
|
|
149
|
+
children: [
|
|
150
|
+
tab.headerIcon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles__default.default.icon, children: tab.headerIcon }) : null,
|
|
151
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: styles__default.default.label, children: tab.header }),
|
|
152
|
+
tab.badge ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles__default.default.badge, children: /* @__PURE__ */ jsxRuntime.jsx(Chip.Chip, { size: "sm", children: tab.badge.toLocaleString("da-DK") }) }) : null
|
|
153
|
+
]
|
|
154
|
+
}
|
|
155
|
+
) }, tab.id);
|
|
156
|
+
}) }),
|
|
157
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
158
|
+
"div",
|
|
159
|
+
{
|
|
160
|
+
id: activeTab ? `${uid}-panel-${String(activeTab.id)}` : void 0,
|
|
161
|
+
role: "tabpanel",
|
|
162
|
+
"aria-labelledby": activeTab ? `${uid}-tab-${String(activeTab.id)}` : void 0,
|
|
163
|
+
className: styles__default.default.tabContent,
|
|
164
|
+
children: loading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles__default.default.loadingContent, children: /* @__PURE__ */ jsxRuntime.jsx(SkeletonLoader.SkeletonLoader, { type: "squares", rows: 1, columns: 1 }) }) : activeTab == null ? void 0 : activeTab.content
|
|
165
|
+
}
|
|
166
|
+
)
|
|
167
|
+
] })
|
|
168
|
+
] });
|
|
169
|
+
}
|
|
170
|
+
Tabs.Item = TabsItem;
|
|
171
|
+
|
|
172
|
+
exports.Tabs = Tabs;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { useId, useMemo, useState, useCallback, useEffect, Children, isValidElement } from 'react';
|
|
3
|
+
import styles from './Tabs.module.css';
|
|
4
|
+
import { Chip } from '../chip/Chip';
|
|
5
|
+
import { Headline } from '../headline/Headline';
|
|
6
|
+
import { SkeletonLoader } from '../skeleton-loader/SkeletonLoader';
|
|
7
|
+
|
|
8
|
+
const TabsItem = (_props) => {
|
|
9
|
+
return /* @__PURE__ */ jsx(Fragment, {});
|
|
10
|
+
};
|
|
11
|
+
TabsItem.__TABS_SLOT__ = "Item";
|
|
12
|
+
function getFirstEnabledId(items) {
|
|
13
|
+
var _a;
|
|
14
|
+
return (_a = items.find((t) => !t.hidden && !t.disabled)) == null ? void 0 : _a.id;
|
|
15
|
+
}
|
|
16
|
+
function normalizeFromChildren(children) {
|
|
17
|
+
const items = [];
|
|
18
|
+
Children.forEach(children, (child) => {
|
|
19
|
+
if (!isValidElement(child)) return;
|
|
20
|
+
const t = child.type;
|
|
21
|
+
if ((t == null ? void 0 : t.__TABS_SLOT__) !== "Item") return;
|
|
22
|
+
const props = child.props;
|
|
23
|
+
items.push({
|
|
24
|
+
id: props.id,
|
|
25
|
+
header: props.header,
|
|
26
|
+
headerIcon: props.headerIcon,
|
|
27
|
+
disabled: props.disabled,
|
|
28
|
+
hidden: props.hidden,
|
|
29
|
+
badge: props.badge,
|
|
30
|
+
content: props.children
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
return items;
|
|
34
|
+
}
|
|
35
|
+
function Tabs({
|
|
36
|
+
header,
|
|
37
|
+
subheader,
|
|
38
|
+
variant,
|
|
39
|
+
panelStyle = false,
|
|
40
|
+
tabs,
|
|
41
|
+
value,
|
|
42
|
+
defaultValue,
|
|
43
|
+
onValueChange,
|
|
44
|
+
addition,
|
|
45
|
+
disableTopPadding,
|
|
46
|
+
loading = false,
|
|
47
|
+
children
|
|
48
|
+
}) {
|
|
49
|
+
const uid = useId();
|
|
50
|
+
const sourceTabs = useMemo(() => {
|
|
51
|
+
if (tabs && tabs.length) return tabs;
|
|
52
|
+
return normalizeFromChildren(children);
|
|
53
|
+
}, [tabs, children]);
|
|
54
|
+
const visibleTabs = useMemo(() => sourceTabs.filter((t) => !t.hidden), [sourceTabs]);
|
|
55
|
+
const isControlled = value !== void 0;
|
|
56
|
+
const [internalValue, setInternalValue] = useState(() => {
|
|
57
|
+
return defaultValue != null ? defaultValue : getFirstEnabledId(visibleTabs);
|
|
58
|
+
});
|
|
59
|
+
const currentValue = isControlled ? value : internalValue;
|
|
60
|
+
const activeIndex = useMemo(() => {
|
|
61
|
+
if (!visibleTabs.length) return -1;
|
|
62
|
+
const idx = visibleTabs.findIndex((t) => t.id === currentValue);
|
|
63
|
+
return idx >= 0 ? idx : 0;
|
|
64
|
+
}, [visibleTabs, currentValue]);
|
|
65
|
+
const activeTab = activeIndex >= 0 ? visibleTabs[activeIndex] : void 0;
|
|
66
|
+
const setValue = useCallback(
|
|
67
|
+
(nextId) => {
|
|
68
|
+
const idx = visibleTabs.findIndex((t) => t.id === nextId);
|
|
69
|
+
const tab = idx >= 0 ? visibleTabs[idx] : void 0;
|
|
70
|
+
if (!tab || tab.disabled) return;
|
|
71
|
+
if (!isControlled) setInternalValue(nextId);
|
|
72
|
+
onValueChange == null ? void 0 : onValueChange(nextId, tab, idx);
|
|
73
|
+
},
|
|
74
|
+
[visibleTabs, isControlled, onValueChange]
|
|
75
|
+
);
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (!visibleTabs.length) return;
|
|
78
|
+
const current = currentValue;
|
|
79
|
+
const stillValid = visibleTabs.some((t) => t.id === current && !t.disabled);
|
|
80
|
+
if (stillValid) return;
|
|
81
|
+
const next = getFirstEnabledId(visibleTabs);
|
|
82
|
+
if (next === void 0) return;
|
|
83
|
+
setValue(next);
|
|
84
|
+
}, [visibleTabs, currentValue, setValue]);
|
|
85
|
+
const onKeyDownTab = useCallback(
|
|
86
|
+
(e, index) => {
|
|
87
|
+
var _a;
|
|
88
|
+
const enabled = visibleTabs.filter((t) => !t.disabled);
|
|
89
|
+
if (!enabled.length) return;
|
|
90
|
+
const currentId = (_a = visibleTabs[index]) == null ? void 0 : _a.id;
|
|
91
|
+
const currentEnabledIndex = enabled.findIndex((t) => t.id === currentId);
|
|
92
|
+
const focusAndSelect = (enabledIndex) => {
|
|
93
|
+
const nextTab = enabled[enabledIndex];
|
|
94
|
+
if (!nextTab) return;
|
|
95
|
+
const btn = document.getElementById(
|
|
96
|
+
`${uid}-tab-${String(nextTab.id)}`
|
|
97
|
+
);
|
|
98
|
+
btn == null ? void 0 : btn.focus();
|
|
99
|
+
setValue(nextTab.id);
|
|
100
|
+
};
|
|
101
|
+
if (e.key === "ArrowRight") {
|
|
102
|
+
e.preventDefault();
|
|
103
|
+
focusAndSelect((currentEnabledIndex + 1) % enabled.length);
|
|
104
|
+
} else if (e.key === "ArrowLeft") {
|
|
105
|
+
e.preventDefault();
|
|
106
|
+
focusAndSelect((currentEnabledIndex - 1 + enabled.length) % enabled.length);
|
|
107
|
+
} else if (e.key === "Home") {
|
|
108
|
+
e.preventDefault();
|
|
109
|
+
focusAndSelect(0);
|
|
110
|
+
} else if (e.key === "End") {
|
|
111
|
+
e.preventDefault();
|
|
112
|
+
focusAndSelect(enabled.length - 1);
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
[uid, visibleTabs, setValue]
|
|
116
|
+
);
|
|
117
|
+
return /* @__PURE__ */ jsxs("div", { className: styles.root, children: [
|
|
118
|
+
header ? /* @__PURE__ */ jsx(
|
|
119
|
+
"div",
|
|
120
|
+
{
|
|
121
|
+
className: [styles.headerContainer, disableTopPadding ? styles.disableTopPadding : ""].filter(Boolean).join(" "),
|
|
122
|
+
children: /* @__PURE__ */ jsx(Headline, { disableMargin: true, size: 1, subheader, addition, children: header })
|
|
123
|
+
}
|
|
124
|
+
) : null,
|
|
125
|
+
/* @__PURE__ */ jsxs("div", { className: `${styles.tabs} ${styles[variant]} ${panelStyle ? styles.panelStyle : ""}`, children: [
|
|
126
|
+
/* @__PURE__ */ jsx("div", { className: styles.tabList, role: "tablist", "aria-label": header != null ? header : "Tabs", children: visibleTabs.map((tab, index) => {
|
|
127
|
+
const selected = index === activeIndex;
|
|
128
|
+
const tabDomId = `${uid}-tab-${String(tab.id)}`;
|
|
129
|
+
const panelDomId = `${uid}-panel-${String(tab.id)}`;
|
|
130
|
+
return /* @__PURE__ */ jsx("div", { className: `${styles.tab} ${selected ? styles.active : ""}`, children: /* @__PURE__ */ jsxs(
|
|
131
|
+
"button",
|
|
132
|
+
{
|
|
133
|
+
id: tabDomId,
|
|
134
|
+
type: "button",
|
|
135
|
+
className: styles.tabButton,
|
|
136
|
+
role: "tab",
|
|
137
|
+
"aria-selected": selected,
|
|
138
|
+
"aria-controls": panelDomId,
|
|
139
|
+
tabIndex: selected ? 0 : -1,
|
|
140
|
+
disabled: tab.disabled,
|
|
141
|
+
onClick: () => setValue(tab.id),
|
|
142
|
+
onKeyDown: (e) => onKeyDownTab(e, index),
|
|
143
|
+
children: [
|
|
144
|
+
tab.headerIcon ? /* @__PURE__ */ jsx("span", { className: styles.icon, children: tab.headerIcon }) : null,
|
|
145
|
+
/* @__PURE__ */ jsx("span", { className: styles.label, children: tab.header }),
|
|
146
|
+
tab.badge ? /* @__PURE__ */ jsx("span", { className: styles.badge, children: /* @__PURE__ */ jsx(Chip, { size: "sm", children: tab.badge.toLocaleString("da-DK") }) }) : null
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
) }, tab.id);
|
|
150
|
+
}) }),
|
|
151
|
+
/* @__PURE__ */ jsx(
|
|
152
|
+
"div",
|
|
153
|
+
{
|
|
154
|
+
id: activeTab ? `${uid}-panel-${String(activeTab.id)}` : void 0,
|
|
155
|
+
role: "tabpanel",
|
|
156
|
+
"aria-labelledby": activeTab ? `${uid}-tab-${String(activeTab.id)}` : void 0,
|
|
157
|
+
className: styles.tabContent,
|
|
158
|
+
children: loading ? /* @__PURE__ */ jsx("div", { className: styles.loadingContent, children: /* @__PURE__ */ jsx(SkeletonLoader, { type: "squares", rows: 1, columns: 1 }) }) : activeTab == null ? void 0 : activeTab.content
|
|
159
|
+
}
|
|
160
|
+
)
|
|
161
|
+
] })
|
|
162
|
+
] });
|
|
163
|
+
}
|
|
164
|
+
Tabs.Item = TabsItem;
|
|
165
|
+
|
|
166
|
+
export { Tabs };
|