@dbcdk/react-components 0.0.103 → 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.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 -12908
- package/dist/index.css +67 -7357
- package/dist/index.d.ts +0 -58
- package/dist/index.js +24 -12809
- 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 -2717
- package/dist/tanstack.js +3 -2701
- 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 -1385
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import { ListChevronsDownUp, Settings } from 'lucide-react';
|
|
4
|
+
import { useMemo } from 'react';
|
|
5
|
+
import { Button } from '../../../button/Button';
|
|
6
|
+
import { Menu } from '../../../menu/Menu';
|
|
7
|
+
import { Popover } from '../../../popover/Popover';
|
|
8
|
+
|
|
9
|
+
function TableSettings({
|
|
10
|
+
viewMode,
|
|
11
|
+
handleChangeViewMode,
|
|
12
|
+
columns = [],
|
|
13
|
+
visibleColumnIds = [],
|
|
14
|
+
onVisibleColumnIdsChange,
|
|
15
|
+
columnsLabel = "Kolonner",
|
|
16
|
+
allPresetLabel = "Alle",
|
|
17
|
+
standardPresetLabel = "Standard",
|
|
18
|
+
buttonSize = "sm",
|
|
19
|
+
additionalSettings
|
|
20
|
+
}) {
|
|
21
|
+
const handleViewModeChange = (mode, close) => {
|
|
22
|
+
handleChangeViewMode(mode === "wrapped" ? "compact" : "wrapped");
|
|
23
|
+
close == null ? void 0 : close();
|
|
24
|
+
};
|
|
25
|
+
const hideableColumns = useMemo(() => columns.filter((c) => c.enableHiding !== false), [columns]);
|
|
26
|
+
const allPresetIds = useMemo(() => hideableColumns.map((c) => c.id), [hideableColumns]);
|
|
27
|
+
const standardPresetIds = useMemo(
|
|
28
|
+
() => hideableColumns.filter((c) => {
|
|
29
|
+
var _a;
|
|
30
|
+
return ((_a = c.meta) == null ? void 0 : _a.hidden) !== true;
|
|
31
|
+
}).map((c) => c.id),
|
|
32
|
+
[hideableColumns]
|
|
33
|
+
);
|
|
34
|
+
const visibleSet = useMemo(() => new Set(visibleColumnIds), [visibleColumnIds]);
|
|
35
|
+
const visibleCount = useMemo(() => {
|
|
36
|
+
return hideableColumns.reduce((acc, c) => {
|
|
37
|
+
var _a;
|
|
38
|
+
return acc + (visibleSet.has((_a = c.id) != null ? _a : "") ? 1 : 0);
|
|
39
|
+
}, 0);
|
|
40
|
+
}, [hideableColumns, visibleSet]);
|
|
41
|
+
const setVisibleIds = (nextIds) => {
|
|
42
|
+
if (!onVisibleColumnIdsChange) return;
|
|
43
|
+
const safe = nextIds.length > 0 ? nextIds : standardPresetIds.length > 0 ? standardPresetIds : allPresetIds;
|
|
44
|
+
onVisibleColumnIdsChange(
|
|
45
|
+
safe.filter((id) => typeof id === "string" && Boolean(id))
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
const toggleColumn = (id, nextVisible) => {
|
|
49
|
+
const next = new Set(visibleColumnIds);
|
|
50
|
+
if (nextVisible) next.add(id);
|
|
51
|
+
else next.delete(id);
|
|
52
|
+
setVisibleIds(Array.from(next));
|
|
53
|
+
};
|
|
54
|
+
const isAllActive = useMemo(() => {
|
|
55
|
+
if (!hideableColumns.length) return false;
|
|
56
|
+
return hideableColumns.every((c) => c.id && visibleSet.has(c.id));
|
|
57
|
+
}, [hideableColumns, visibleSet]);
|
|
58
|
+
const isStandardActive = useMemo(() => {
|
|
59
|
+
if (!hideableColumns.length) return false;
|
|
60
|
+
const std = new Set(standardPresetIds);
|
|
61
|
+
return hideableColumns.every((c) => c.id && visibleSet.has(c.id) === std.has(c.id));
|
|
62
|
+
}, [hideableColumns, visibleSet, standardPresetIds]);
|
|
63
|
+
const presetRadioName = "table-columns-preset";
|
|
64
|
+
return /* @__PURE__ */ jsx(
|
|
65
|
+
Popover,
|
|
66
|
+
{
|
|
67
|
+
trigger: (onClick, icon) => /* @__PURE__ */ jsxs(Button, { size: buttonSize, onClick, type: "button", children: [
|
|
68
|
+
/* @__PURE__ */ jsx(Settings, {}),
|
|
69
|
+
icon
|
|
70
|
+
] }),
|
|
71
|
+
children: (close) => /* @__PURE__ */ jsxs(Menu, { children: [
|
|
72
|
+
additionalSettings == null ? void 0 : additionalSettings(close),
|
|
73
|
+
/* @__PURE__ */ jsx(Menu.Item, { active: viewMode === "wrapped", children: /* @__PURE__ */ jsxs("button", { type: "button", onClick: () => handleViewModeChange(viewMode, close), children: [
|
|
74
|
+
/* @__PURE__ */ jsx(ListChevronsDownUp, {}),
|
|
75
|
+
"Ombryd tekst"
|
|
76
|
+
] }) }),
|
|
77
|
+
hideableColumns.length > 0 && onVisibleColumnIdsChange ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
78
|
+
/* @__PURE__ */ jsx(Menu.Separator, {}),
|
|
79
|
+
/* @__PURE__ */ jsx("div", { style: { padding: "6px 10px", fontSize: 12, opacity: 0.7 }, children: columnsLabel }),
|
|
80
|
+
/* @__PURE__ */ jsx(
|
|
81
|
+
Menu.RadioItem,
|
|
82
|
+
{
|
|
83
|
+
name: presetRadioName,
|
|
84
|
+
value: "all",
|
|
85
|
+
checked: isAllActive,
|
|
86
|
+
label: allPresetLabel,
|
|
87
|
+
onValueChange: () => {
|
|
88
|
+
setVisibleIds(
|
|
89
|
+
allPresetIds.filter((id) => typeof id === "string" && Boolean(id))
|
|
90
|
+
);
|
|
91
|
+
close == null ? void 0 : close();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
),
|
|
95
|
+
/* @__PURE__ */ jsx(
|
|
96
|
+
Menu.RadioItem,
|
|
97
|
+
{
|
|
98
|
+
name: presetRadioName,
|
|
99
|
+
value: "standard",
|
|
100
|
+
checked: isStandardActive,
|
|
101
|
+
label: standardPresetLabel,
|
|
102
|
+
onValueChange: () => {
|
|
103
|
+
setVisibleIds(
|
|
104
|
+
standardPresetIds.filter(
|
|
105
|
+
(id) => typeof id === "string" && Boolean(id)
|
|
106
|
+
)
|
|
107
|
+
);
|
|
108
|
+
close == null ? void 0 : close();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
),
|
|
112
|
+
/* @__PURE__ */ jsx(Menu.Separator, {}),
|
|
113
|
+
hideableColumns.map((col) => {
|
|
114
|
+
const isVisible = col.id ? visibleSet.has(col.id) : false;
|
|
115
|
+
const disableUncheckingLast = isVisible && visibleCount <= 1;
|
|
116
|
+
const label = col.header;
|
|
117
|
+
return /* @__PURE__ */ jsx(
|
|
118
|
+
Menu.CheckItem,
|
|
119
|
+
{
|
|
120
|
+
checked: isVisible,
|
|
121
|
+
disabled: disableUncheckingLast,
|
|
122
|
+
label,
|
|
123
|
+
onCheckedChange: (nextChecked) => {
|
|
124
|
+
if (disableUncheckingLast) return;
|
|
125
|
+
toggleColumn(col.id, nextChecked);
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
col.id
|
|
129
|
+
);
|
|
130
|
+
})
|
|
131
|
+
] }) : null
|
|
132
|
+
] })
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export { TableSettings };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var table_utils = require('../table.utils');
|
|
5
|
+
|
|
6
|
+
function useTableRowInteractions({
|
|
7
|
+
row,
|
|
8
|
+
rowId,
|
|
9
|
+
isSelected,
|
|
10
|
+
canSelect,
|
|
11
|
+
onRowClick,
|
|
12
|
+
onRowSelect
|
|
13
|
+
}) {
|
|
14
|
+
const handleRowClick = react.useCallback(
|
|
15
|
+
(e) => {
|
|
16
|
+
var _a;
|
|
17
|
+
const target = e.target;
|
|
18
|
+
if ((_a = target == null ? void 0 : target.closest) == null ? void 0 : _a.call(target, '[data-selection-control="true"]')) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (table_utils.isModifierClick(e) && canSelect) {
|
|
22
|
+
e.preventDefault();
|
|
23
|
+
e.stopPropagation();
|
|
24
|
+
onRowSelect == null ? void 0 : onRowSelect(rowId, !isSelected);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
onRowClick == null ? void 0 : onRowClick(row);
|
|
28
|
+
},
|
|
29
|
+
[canSelect, isSelected, onRowClick, onRowSelect, row, rowId]
|
|
30
|
+
);
|
|
31
|
+
const handleRowKeyDown = react.useCallback(
|
|
32
|
+
(e) => {
|
|
33
|
+
if (!onRowClick) return;
|
|
34
|
+
if (!table_utils.shouldToggleOnKey(e.key)) return;
|
|
35
|
+
e.preventDefault();
|
|
36
|
+
onRowClick(row);
|
|
37
|
+
},
|
|
38
|
+
[onRowClick, row]
|
|
39
|
+
);
|
|
40
|
+
return {
|
|
41
|
+
handleRowClick,
|
|
42
|
+
handleRowKeyDown
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
exports.useTableRowInteractions = useTableRowInteractions;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { isModifierClick, shouldToggleOnKey } from '../table.utils';
|
|
3
|
+
|
|
4
|
+
function useTableRowInteractions({
|
|
5
|
+
row,
|
|
6
|
+
rowId,
|
|
7
|
+
isSelected,
|
|
8
|
+
canSelect,
|
|
9
|
+
onRowClick,
|
|
10
|
+
onRowSelect
|
|
11
|
+
}) {
|
|
12
|
+
const handleRowClick = useCallback(
|
|
13
|
+
(e) => {
|
|
14
|
+
var _a;
|
|
15
|
+
const target = e.target;
|
|
16
|
+
if ((_a = target == null ? void 0 : target.closest) == null ? void 0 : _a.call(target, '[data-selection-control="true"]')) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (isModifierClick(e) && canSelect) {
|
|
20
|
+
e.preventDefault();
|
|
21
|
+
e.stopPropagation();
|
|
22
|
+
onRowSelect == null ? void 0 : onRowSelect(rowId, !isSelected);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
onRowClick == null ? void 0 : onRowClick(row);
|
|
26
|
+
},
|
|
27
|
+
[canSelect, isSelected, onRowClick, onRowSelect, row, rowId]
|
|
28
|
+
);
|
|
29
|
+
const handleRowKeyDown = useCallback(
|
|
30
|
+
(e) => {
|
|
31
|
+
if (!onRowClick) return;
|
|
32
|
+
if (!shouldToggleOnKey(e.key)) return;
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
onRowClick(row);
|
|
35
|
+
},
|
|
36
|
+
[onRowClick, row]
|
|
37
|
+
);
|
|
38
|
+
return {
|
|
39
|
+
handleRowClick,
|
|
40
|
+
handleRowKeyDown
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { useTableRowInteractions };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var styles = require('./Table.module.css');
|
|
4
|
+
|
|
5
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
|
+
|
|
7
|
+
var styles__default = /*#__PURE__*/_interopDefault(styles);
|
|
8
|
+
|
|
9
|
+
function cx(...values) {
|
|
10
|
+
return values.filter(Boolean).join(" ");
|
|
11
|
+
}
|
|
12
|
+
function getDividerClass(column) {
|
|
13
|
+
if (column.divider === "left") return styles__default.default.dividerLeft;
|
|
14
|
+
if (column.divider === "right") return styles__default.default.dividerRight;
|
|
15
|
+
return "";
|
|
16
|
+
}
|
|
17
|
+
function getAlignValue(column) {
|
|
18
|
+
var _a;
|
|
19
|
+
return (_a = column.align) != null ? _a : "left";
|
|
20
|
+
}
|
|
21
|
+
function getHeaderAlignClasses(align) {
|
|
22
|
+
return {
|
|
23
|
+
inner: cx(
|
|
24
|
+
styles__default.default.thInner,
|
|
25
|
+
align === "right" && styles__default.default.thInnerRight,
|
|
26
|
+
align === "center" && styles__default.default.thInnerCenter
|
|
27
|
+
),
|
|
28
|
+
main: cx(
|
|
29
|
+
styles__default.default.thMain,
|
|
30
|
+
align === "right" && styles__default.default.thMainRight,
|
|
31
|
+
align === "center" && styles__default.default.thMainCenter
|
|
32
|
+
),
|
|
33
|
+
button: cx(
|
|
34
|
+
styles__default.default.thButton,
|
|
35
|
+
align === "right" && styles__default.default.thButtonRight,
|
|
36
|
+
align === "center" && styles__default.default.thButtonCenter
|
|
37
|
+
),
|
|
38
|
+
label: cx(
|
|
39
|
+
styles__default.default.thLabel,
|
|
40
|
+
align === "right" && styles__default.default.thLabelRight,
|
|
41
|
+
align === "center" && styles__default.default.thLabelCenter
|
|
42
|
+
)
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
exports.cx = cx;
|
|
47
|
+
exports.getAlignValue = getAlignValue;
|
|
48
|
+
exports.getDividerClass = getDividerClass;
|
|
49
|
+
exports.getHeaderAlignClasses = getHeaderAlignClasses;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import styles from './Table.module.css';
|
|
2
|
+
|
|
3
|
+
function cx(...values) {
|
|
4
|
+
return values.filter(Boolean).join(" ");
|
|
5
|
+
}
|
|
6
|
+
function getDividerClass(column) {
|
|
7
|
+
if (column.divider === "left") return styles.dividerLeft;
|
|
8
|
+
if (column.divider === "right") return styles.dividerRight;
|
|
9
|
+
return "";
|
|
10
|
+
}
|
|
11
|
+
function getAlignValue(column) {
|
|
12
|
+
var _a;
|
|
13
|
+
return (_a = column.align) != null ? _a : "left";
|
|
14
|
+
}
|
|
15
|
+
function getHeaderAlignClasses(align) {
|
|
16
|
+
return {
|
|
17
|
+
inner: cx(
|
|
18
|
+
styles.thInner,
|
|
19
|
+
align === "right" && styles.thInnerRight,
|
|
20
|
+
align === "center" && styles.thInnerCenter
|
|
21
|
+
),
|
|
22
|
+
main: cx(
|
|
23
|
+
styles.thMain,
|
|
24
|
+
align === "right" && styles.thMainRight,
|
|
25
|
+
align === "center" && styles.thMainCenter
|
|
26
|
+
),
|
|
27
|
+
button: cx(
|
|
28
|
+
styles.thButton,
|
|
29
|
+
align === "right" && styles.thButtonRight,
|
|
30
|
+
align === "center" && styles.thButtonCenter
|
|
31
|
+
),
|
|
32
|
+
label: cx(
|
|
33
|
+
styles.thLabel,
|
|
34
|
+
align === "right" && styles.thLabelRight,
|
|
35
|
+
align === "center" && styles.thLabelCenter
|
|
36
|
+
)
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { cx, getAlignValue, getDividerClass, getHeaderAlignClasses };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const SELECTION_COLUMN_PX = 40;
|
|
4
|
+
const DEFAULT_COLUMN_PX = 150;
|
|
5
|
+
function getVisibleColumns(columns) {
|
|
6
|
+
return columns.filter((column) => !column.hidden);
|
|
7
|
+
}
|
|
8
|
+
function getHeaderLabel(header) {
|
|
9
|
+
return typeof header === "function" ? header() : header;
|
|
10
|
+
}
|
|
11
|
+
function isActiveSort(sortById, columnId) {
|
|
12
|
+
return sortById === columnId;
|
|
13
|
+
}
|
|
14
|
+
function getAriaSort(sortable, active, direction) {
|
|
15
|
+
if (!sortable || !active || !direction) return "none";
|
|
16
|
+
return direction === "asc" ? "ascending" : "descending";
|
|
17
|
+
}
|
|
18
|
+
function getNextSortDirection(sortable, active, currentDirection) {
|
|
19
|
+
if (!sortable) return null;
|
|
20
|
+
if (!active) return "asc";
|
|
21
|
+
if (currentDirection === "asc") return "desc";
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
function shouldToggleOnKey(key) {
|
|
25
|
+
return key === "Enter" || key === " ";
|
|
26
|
+
}
|
|
27
|
+
function isModifierClick(e) {
|
|
28
|
+
return Boolean(e.metaKey || e.ctrlKey);
|
|
29
|
+
}
|
|
30
|
+
function shouldAllowWrap(columnAllowWrap, isRowSelected, viewMode) {
|
|
31
|
+
return Boolean(columnAllowWrap || isRowSelected || viewMode === "wrapped");
|
|
32
|
+
}
|
|
33
|
+
function getCellDisplayValue(row, column) {
|
|
34
|
+
var _a;
|
|
35
|
+
const empty = (_a = column.emptyPlaceholder) != null ? _a : "";
|
|
36
|
+
if (column.render) {
|
|
37
|
+
const rendered = column.render(row);
|
|
38
|
+
return rendered != null ? rendered : empty;
|
|
39
|
+
}
|
|
40
|
+
if (column.accessor) {
|
|
41
|
+
const value = row[column.accessor];
|
|
42
|
+
return value != null ? value : empty;
|
|
43
|
+
}
|
|
44
|
+
return empty;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
exports.DEFAULT_COLUMN_PX = DEFAULT_COLUMN_PX;
|
|
48
|
+
exports.SELECTION_COLUMN_PX = SELECTION_COLUMN_PX;
|
|
49
|
+
exports.getAriaSort = getAriaSort;
|
|
50
|
+
exports.getCellDisplayValue = getCellDisplayValue;
|
|
51
|
+
exports.getHeaderLabel = getHeaderLabel;
|
|
52
|
+
exports.getNextSortDirection = getNextSortDirection;
|
|
53
|
+
exports.getVisibleColumns = getVisibleColumns;
|
|
54
|
+
exports.isActiveSort = isActiveSort;
|
|
55
|
+
exports.isModifierClick = isModifierClick;
|
|
56
|
+
exports.shouldAllowWrap = shouldAllowWrap;
|
|
57
|
+
exports.shouldToggleOnKey = shouldToggleOnKey;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const SELECTION_COLUMN_PX = 40;
|
|
2
|
+
const DEFAULT_COLUMN_PX = 150;
|
|
3
|
+
function getVisibleColumns(columns) {
|
|
4
|
+
return columns.filter((column) => !column.hidden);
|
|
5
|
+
}
|
|
6
|
+
function getHeaderLabel(header) {
|
|
7
|
+
return typeof header === "function" ? header() : header;
|
|
8
|
+
}
|
|
9
|
+
function isActiveSort(sortById, columnId) {
|
|
10
|
+
return sortById === columnId;
|
|
11
|
+
}
|
|
12
|
+
function getAriaSort(sortable, active, direction) {
|
|
13
|
+
if (!sortable || !active || !direction) return "none";
|
|
14
|
+
return direction === "asc" ? "ascending" : "descending";
|
|
15
|
+
}
|
|
16
|
+
function getNextSortDirection(sortable, active, currentDirection) {
|
|
17
|
+
if (!sortable) return null;
|
|
18
|
+
if (!active) return "asc";
|
|
19
|
+
if (currentDirection === "asc") return "desc";
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
function shouldToggleOnKey(key) {
|
|
23
|
+
return key === "Enter" || key === " ";
|
|
24
|
+
}
|
|
25
|
+
function isModifierClick(e) {
|
|
26
|
+
return Boolean(e.metaKey || e.ctrlKey);
|
|
27
|
+
}
|
|
28
|
+
function shouldAllowWrap(columnAllowWrap, isRowSelected, viewMode) {
|
|
29
|
+
return Boolean(columnAllowWrap || isRowSelected || viewMode === "wrapped");
|
|
30
|
+
}
|
|
31
|
+
function getCellDisplayValue(row, column) {
|
|
32
|
+
var _a;
|
|
33
|
+
const empty = (_a = column.emptyPlaceholder) != null ? _a : "";
|
|
34
|
+
if (column.render) {
|
|
35
|
+
const rendered = column.render(row);
|
|
36
|
+
return rendered != null ? rendered : empty;
|
|
37
|
+
}
|
|
38
|
+
if (column.accessor) {
|
|
39
|
+
const value = row[column.accessor];
|
|
40
|
+
return value != null ? value : empty;
|
|
41
|
+
}
|
|
42
|
+
return empty;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { DEFAULT_COLUMN_PX, SELECTION_COLUMN_PX, getAriaSort, getCellDisplayValue, getHeaderLabel, getNextSortDirection, getVisibleColumns, isActiveSort, isModifierClick, shouldAllowWrap, shouldToggleOnKey };
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var table_utils = require('./table.utils');
|
|
4
|
+
|
|
5
|
+
function getColumnId(def, index) {
|
|
6
|
+
const d = def;
|
|
7
|
+
if (d.id != null && String(d.id).length > 0) return String(d.id);
|
|
8
|
+
if (d.accessorKey != null && String(d.accessorKey).length > 0) return String(d.accessorKey);
|
|
9
|
+
return `col_${index}`;
|
|
10
|
+
}
|
|
11
|
+
function buildColumnVisibilityFromVisibleIds(defs, visibleColumnIds) {
|
|
12
|
+
if (!(visibleColumnIds == null ? void 0 : visibleColumnIds.length)) return {};
|
|
13
|
+
const visible = new Set(visibleColumnIds);
|
|
14
|
+
const next = {};
|
|
15
|
+
defs.forEach((def, index) => {
|
|
16
|
+
const id = getColumnId(def, index);
|
|
17
|
+
next[id] = visible.has(id);
|
|
18
|
+
});
|
|
19
|
+
return next;
|
|
20
|
+
}
|
|
21
|
+
function mapDefsToColumnItems(defs, columnVisibility, resolvedLayout = {}) {
|
|
22
|
+
return defs.map((def, index) => {
|
|
23
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
24
|
+
const id = getColumnId(def, index);
|
|
25
|
+
const accessorKey = def.accessorKey;
|
|
26
|
+
const accessorFn = def.accessorFn;
|
|
27
|
+
const cell = def.cell;
|
|
28
|
+
const meta = (_a = def.meta) != null ? _a : {};
|
|
29
|
+
let render;
|
|
30
|
+
if (typeof cell === "function") {
|
|
31
|
+
render = (row) => cell({
|
|
32
|
+
row: { original: row },
|
|
33
|
+
getValue: () => accessorKey != null ? row[accessorKey] : accessorFn ? accessorFn(row) : void 0
|
|
34
|
+
});
|
|
35
|
+
} else if (accessorFn) {
|
|
36
|
+
render = (row) => accessorFn(row);
|
|
37
|
+
} else if (accessorKey != null) {
|
|
38
|
+
render = (row) => row[accessorKey];
|
|
39
|
+
} else {
|
|
40
|
+
render = () => null;
|
|
41
|
+
}
|
|
42
|
+
const isVisible = (_b = columnVisibility[id]) != null ? _b : true;
|
|
43
|
+
return {
|
|
44
|
+
id,
|
|
45
|
+
header: def.header,
|
|
46
|
+
accessor: accessorKey,
|
|
47
|
+
sortable: (_c = def.enableSorting) != null ? _c : !!accessorKey,
|
|
48
|
+
render,
|
|
49
|
+
hidden: !isVisible,
|
|
50
|
+
width: (_d = resolvedLayout[id]) == null ? void 0 : _d.width,
|
|
51
|
+
align: meta.align,
|
|
52
|
+
verticalAlign: meta.verticalAlign,
|
|
53
|
+
emptyPlaceholder: (_e = meta.emptyPlaceholder) != null ? _e : "-",
|
|
54
|
+
allowWrap: (_f = meta.allowWrap) != null ? _f : false,
|
|
55
|
+
severity: meta.severity,
|
|
56
|
+
divider: meta.divider,
|
|
57
|
+
allowOverflow: (_g = meta.allowOverflow) != null ? _g : false
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function sortingEqual(a, b) {
|
|
62
|
+
const A = a == null ? void 0 : a[0];
|
|
63
|
+
const B = b == null ? void 0 : b[0];
|
|
64
|
+
if (!A && !B) return true;
|
|
65
|
+
if (!A || !B) return false;
|
|
66
|
+
return A.id === B.id && A.desc === B.desc;
|
|
67
|
+
}
|
|
68
|
+
function getSortPropsFromSorting(sorting) {
|
|
69
|
+
const s = sorting == null ? void 0 : sorting[0];
|
|
70
|
+
return {
|
|
71
|
+
sortById: s == null ? void 0 : s.id,
|
|
72
|
+
sortDirection: s ? s.desc ? "desc" : "asc" : null
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function clamp(value, min, max) {
|
|
76
|
+
const lowerBounded = Math.max(min, value);
|
|
77
|
+
if (max == null || !Number.isFinite(max)) return lowerBounded;
|
|
78
|
+
return Math.min(lowerBounded, max);
|
|
79
|
+
}
|
|
80
|
+
function toIntegerTrackWidths(tracks, targetWidth) {
|
|
81
|
+
const floored = tracks.map((track) => ({
|
|
82
|
+
id: track.id,
|
|
83
|
+
width: Math.floor(track.width),
|
|
84
|
+
fraction: track.width - Math.floor(track.width)
|
|
85
|
+
}));
|
|
86
|
+
const baseTotal = floored.reduce((sum, track) => sum + track.width, 0);
|
|
87
|
+
let remainder = Math.max(0, targetWidth - baseTotal);
|
|
88
|
+
floored.slice().sort((a, b) => b.fraction - a.fraction).forEach((track) => {
|
|
89
|
+
if (remainder <= 0) return;
|
|
90
|
+
track.width += 1;
|
|
91
|
+
remainder -= 1;
|
|
92
|
+
});
|
|
93
|
+
return Object.fromEntries(floored.map((track) => [track.id, track.width]));
|
|
94
|
+
}
|
|
95
|
+
function buildDistributedColumnWidths(args) {
|
|
96
|
+
const { table, hasSelection, defaultMinPx, columnSizing, availableWidth } = args;
|
|
97
|
+
const leaf = table.getVisibleLeafColumns();
|
|
98
|
+
const selectionWidth = hasSelection ? table_utils.SELECTION_COLUMN_PX : 0;
|
|
99
|
+
const tracks = leaf.map((c) => {
|
|
100
|
+
var _a, _b, _c, _d;
|
|
101
|
+
const def = c.columnDef;
|
|
102
|
+
const meta = (_a = def.meta) != null ? _a : {};
|
|
103
|
+
const min = Math.max(1, Number((_b = def.minSize) != null ? _b : defaultMinPx));
|
|
104
|
+
const max = def.maxSize != null ? Math.max(min, Number(def.maxSize)) : void 0;
|
|
105
|
+
const resizedPxRaw = columnSizing[c.id];
|
|
106
|
+
const resizedPx = resizedPxRaw != null ? Math.round(clamp(Number(resizedPxRaw), min, max)) : void 0;
|
|
107
|
+
if (resizedPx != null) {
|
|
108
|
+
return {
|
|
109
|
+
id: c.id,
|
|
110
|
+
width: resizedPx,
|
|
111
|
+
weight: 0,
|
|
112
|
+
max: resizedPx,
|
|
113
|
+
fixed: true
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
const rawWeight = Number((_d = (_c = meta.weight) != null ? _c : def.size) != null ? _d : table_utils.DEFAULT_COLUMN_PX);
|
|
117
|
+
const weight = Number.isFinite(rawWeight) && rawWeight > 0 ? rawWeight : table_utils.DEFAULT_COLUMN_PX;
|
|
118
|
+
return {
|
|
119
|
+
id: c.id,
|
|
120
|
+
width: min,
|
|
121
|
+
weight,
|
|
122
|
+
max,
|
|
123
|
+
fixed: false
|
|
124
|
+
};
|
|
125
|
+
});
|
|
126
|
+
const fixedWidth = selectionWidth + tracks.reduce((sum, track) => sum + track.width, 0);
|
|
127
|
+
let remaining = Math.max(0, availableWidth - fixedWidth);
|
|
128
|
+
let active = tracks.filter(
|
|
129
|
+
(track) => !track.fixed && (track.max == null || track.width < track.max)
|
|
130
|
+
);
|
|
131
|
+
while (remaining > 0.5 && active.length > 0) {
|
|
132
|
+
const totalWeight = active.reduce((sum, track) => sum + track.weight, 0);
|
|
133
|
+
if (totalWeight <= 0) break;
|
|
134
|
+
let consumed = 0;
|
|
135
|
+
const nextActive = [];
|
|
136
|
+
for (const track of active) {
|
|
137
|
+
const share = remaining * track.weight / totalWeight;
|
|
138
|
+
const maxGrow = track.max == null ? share : Math.max(0, track.max - track.width);
|
|
139
|
+
const growth = Math.min(share, maxGrow);
|
|
140
|
+
track.width += growth;
|
|
141
|
+
consumed += growth;
|
|
142
|
+
if (track.max == null || track.width < track.max - 0.5) {
|
|
143
|
+
nextActive.push(track);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (consumed <= 0.5) break;
|
|
147
|
+
remaining -= consumed;
|
|
148
|
+
active = nextActive;
|
|
149
|
+
}
|
|
150
|
+
const floatTrackTotal = tracks.reduce((sum, track) => sum + track.width, 0);
|
|
151
|
+
const targetTrackWidth = floatTrackTotal <= availableWidth - selectionWidth ? Math.floor(floatTrackTotal) : Math.ceil(floatTrackTotal);
|
|
152
|
+
const widths = toIntegerTrackWidths(tracks, targetTrackWidth);
|
|
153
|
+
const totalWidth = selectionWidth + Object.values(widths).reduce((sum, width) => sum + width, 0);
|
|
154
|
+
return {
|
|
155
|
+
selectionWidth: hasSelection ? table_utils.SELECTION_COLUMN_PX : void 0,
|
|
156
|
+
widths,
|
|
157
|
+
totalWidth
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
exports.buildColumnVisibilityFromVisibleIds = buildColumnVisibilityFromVisibleIds;
|
|
162
|
+
exports.buildDistributedColumnWidths = buildDistributedColumnWidths;
|
|
163
|
+
exports.getColumnId = getColumnId;
|
|
164
|
+
exports.getSortPropsFromSorting = getSortPropsFromSorting;
|
|
165
|
+
exports.mapDefsToColumnItems = mapDefsToColumnItems;
|
|
166
|
+
exports.sortingEqual = sortingEqual;
|