@dbcdk/react-components 0.0.96 → 0.0.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/page/Page.d.ts +2 -1
- package/dist/components/page-layout/PageLayout.d.ts +0 -2
- package/dist/components/page-layout/components/page-layout-hero/PageLayoutHero.d.ts +1 -12
- package/dist/components/skeleton-loader/SkeletonLoader.d.ts +1 -1
- package/dist/components/table/Table.d.ts +1 -1
- package/dist/components/table/Table.types.d.ts +3 -0
- package/dist/components/table/components/TableHeader.d.ts +2 -1
- package/dist/components/tabs/Tabs.d.ts +2 -1
- package/dist/constants/chart-colors.d.ts +2 -0
- package/dist/constants/chart-colors.types.d.ts +3 -0
- package/dist/index.cjs +12830 -0
- package/dist/index.css +7084 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +12720 -79
- package/dist/styles/styles.css +6 -1
- package/dist/styles/themes/dbc/colors.css +14 -6
- package/dist/styles/themes/forfatterweb/light.css +17 -0
- package/dist/styles.css +6 -1
- package/dist/tanstack.cjs +2660 -0
- package/dist/tanstack.css +1267 -0
- package/dist/tanstack.js +2636 -3
- package/dist/themes/dbc.css +3 -0
- package/dist/themes/forfatterweb.css +2 -0
- package/package.json +11 -10
- package/dist/assets/logo.js +0 -2
- package/dist/components/__stories__/_data/table.d.ts +0 -15
- package/dist/components/__stories__/_data/table.js +0 -55
- package/dist/components/__stories__/_data/tabs.d.ts +0 -9
- package/dist/components/__stories__/_data/tabs.js +0 -31
- package/dist/components/__stories__/story-components/Colors.d.ts +0 -11
- package/dist/components/__stories__/story-components/Colors.js +0 -96
- package/dist/components/__stories__/story-components/Colors.module.css +0 -27
- package/dist/components/__stories__/story-components/ComponentSizes.d.ts +0 -2
- package/dist/components/__stories__/story-components/ComponentSizes.js +0 -26
- package/dist/components/__stories__/story-components/Elevation.d.ts +0 -2
- package/dist/components/__stories__/story-components/Elevation.js +0 -49
- package/dist/components/__stories__/story-components/Flex.d.ts +0 -2
- package/dist/components/__stories__/story-components/Flex.js +0 -177
- package/dist/components/__stories__/story-components/Flex.module.css +0 -317
- package/dist/components/__stories__/story-components/Spacing.d.ts +0 -6
- package/dist/components/__stories__/story-components/Spacing.js +0 -76
- package/dist/components/__stories__/story-components/Spacing.module.css +0 -154
- package/dist/components/accordion/Accordion.js +0 -70
- package/dist/components/accordion/Accordion.module.css +0 -28
- package/dist/components/accordion/components/AccordionRow.js +0 -53
- package/dist/components/accordion/components/AccordionRow.module.css +0 -90
- package/dist/components/alert/Alert.js +0 -17
- package/dist/components/alert/Alert.module.css +0 -98
- package/dist/components/app-header/AppHeader.js +0 -5
- package/dist/components/app-header/AppHeader.module.css +0 -74
- package/dist/components/attribute-chip/AttributeChip.js +0 -5
- package/dist/components/attribute-chip/AttributeChip.module.css +0 -65
- package/dist/components/avatar/Avatar.js +0 -48
- package/dist/components/avatar/Avatar.module.css +0 -91
- package/dist/components/breadcrumbs/Breadcrumbs.js +0 -6
- package/dist/components/breadcrumbs/Breadcrumbs.module.css +0 -80
- package/dist/components/button/Button.js +0 -81
- package/dist/components/button/Button.module.css +0 -249
- package/dist/components/button-select/ButtonSelect.js +0 -7
- package/dist/components/button-select/ButtonSelect.module.css +0 -40
- package/dist/components/card/Card.js +0 -71
- package/dist/components/card/Card.module.css +0 -160
- package/dist/components/card/components/CardMeta.js +0 -26
- package/dist/components/card/components/CardMeta.module.css +0 -55
- package/dist/components/card-container/CardContainer.js +0 -6
- package/dist/components/card-container/CardContainer.module.css +0 -61
- package/dist/components/chip/Chip.js +0 -31
- package/dist/components/chip/Chip.module.css +0 -236
- package/dist/components/circle/Circle.js +0 -5
- package/dist/components/circle/Circle.module.css +0 -128
- package/dist/components/clear-button/ClearButton.js +0 -13
- package/dist/components/clear-button/ClearButton.module.css +0 -26
- package/dist/components/code-block/CodeBlock.js +0 -58
- package/dist/components/code-block/CodeBlock.module.css +0 -124
- package/dist/components/copy-button/CopyButton.js +0 -78
- package/dist/components/copy-button/CopyButton.module.css +0 -22
- package/dist/components/datetime-picker/DateTimePicker.js +0 -403
- package/dist/components/datetime-picker/DateTimePicker.module.css +0 -155
- package/dist/components/datetime-picker/dateTimeHelpers.js +0 -248
- package/dist/components/divider/Divider.js +0 -12
- package/dist/components/filter-field/FilterField.js +0 -191
- package/dist/components/filter-field/FilterField.module.css +0 -379
- package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.js +0 -52
- package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.module.css +0 -59
- package/dist/components/forms/checkbox/Checkbox.js +0 -28
- package/dist/components/forms/checkbox/Checkbox.module.css +0 -103
- package/dist/components/forms/checkbox-group/CheckboxGroup.js +0 -75
- package/dist/components/forms/checkbox-group/CheckboxGroup.module.css +0 -115
- package/dist/components/forms/form-select/FormSelect.js +0 -86
- package/dist/components/forms/form-select/FormSelect.module.css +0 -236
- package/dist/components/forms/input/Input.js +0 -77
- package/dist/components/forms/input/Input.module.css +0 -468
- package/dist/components/forms/input-container/InputContainer.js +0 -15
- package/dist/components/forms/input-container/InputContainer.module.css +0 -60
- package/dist/components/forms/multi-select/MultiSelect.js +0 -122
- package/dist/components/forms/radio-buttons/RadioButton.js +0 -26
- package/dist/components/forms/radio-buttons/RadioButtonGroup.js +0 -19
- package/dist/components/forms/radio-buttons/RadioButtons.module.css +0 -118
- package/dist/components/forms/select/Select.js +0 -185
- package/dist/components/forms/select/Select.module.css +0 -32
- package/dist/components/forms/text-area/Textarea.js +0 -47
- package/dist/components/forms/text-area/Textarea.module.css +0 -70
- package/dist/components/forms/typeahead/Typeahead.js +0 -668
- package/dist/components/forms/typeahead/Typeahead.module.css +0 -38
- package/dist/components/grid/Grid.js +0 -23
- package/dist/components/grid/Grid.module.css +0 -35
- package/dist/components/headline/CollapsibleHeadline.js +0 -29
- package/dist/components/headline/Headline.js +0 -26
- package/dist/components/headline/Headline.module.css +0 -185
- package/dist/components/hyperlink/Hyperlink.js +0 -40
- package/dist/components/hyperlink/Hyperlink.module.css +0 -107
- package/dist/components/icon/Icon.js +0 -14
- package/dist/components/icon/Icon.module.css +0 -36
- package/dist/components/interval-select/IntervalSelect.js +0 -99
- package/dist/components/json-viewer/HighlightedText.js +0 -6
- package/dist/components/json-viewer/JsonNode.js +0 -30
- package/dist/components/json-viewer/JsonViewer.js +0 -68
- package/dist/components/json-viewer/JsonViewer.module.css +0 -346
- package/dist/components/json-viewer/types.js +0 -1
- package/dist/components/json-viewer/useClipboardStatus.js +0 -11
- package/dist/components/json-viewer/utils.js +0 -125
- package/dist/components/menu/Menu.js +0 -165
- package/dist/components/menu/Menu.module.css +0 -220
- package/dist/components/meta-bar/MetaBar.js +0 -9
- package/dist/components/meta-bar/MetaBar.module.css +0 -27
- package/dist/components/nav-bar/NavBar.js +0 -29
- package/dist/components/nav-bar/NavBar.module.css +0 -221
- package/dist/components/overlay/fade-overlay/FadeOverlay.js +0 -8
- package/dist/components/overlay/fade-overlay/FadeOverlay.module.css +0 -54
- package/dist/components/overlay/modal/Modal.js +0 -115
- package/dist/components/overlay/modal/Modal.module.css +0 -109
- package/dist/components/overlay/modal/provider/ModalProvider.js +0 -73
- package/dist/components/overlay/side-panel/SidePanel.js +0 -83
- package/dist/components/overlay/side-panel/SidePanel.module.css +0 -177
- package/dist/components/overlay/side-panel/useSidePanel.js +0 -11
- package/dist/components/overlay/tooltip/Tooltip.js +0 -17
- package/dist/components/overlay/tooltip/Tooltip.module.css +0 -104
- package/dist/components/overlay/tooltip/TooltipProvider.js +0 -255
- package/dist/components/overlay/tooltip/useTooltipTrigger.js +0 -118
- package/dist/components/page/Page.js +0 -11
- package/dist/components/page/Page.module.css +0 -89
- package/dist/components/page-layout/PageLayout.js +0 -76
- package/dist/components/page-layout/PageLayout.module.css +0 -236
- package/dist/components/page-layout/components/layout-footer/LayoutFooter.js +0 -27
- package/dist/components/page-layout/components/layout-footer/LayoutFooter.module.css +0 -89
- package/dist/components/page-layout/components/page-layout-hero/PageLayoutHero.js +0 -14
- package/dist/components/page-layout/components/page-layout-hero/PageLayoutHero.module.css +0 -84
- package/dist/components/pagination/Pagination.js +0 -56
- package/dist/components/pagination/Pagination.module.css +0 -25
- package/dist/components/panel/Panel.js +0 -7
- package/dist/components/panel/Panel.module.css +0 -29
- package/dist/components/popover/Popover.js +0 -257
- package/dist/components/popover/Popover.module.css +0 -54
- package/dist/components/search-box/SearchBox.js +0 -170
- package/dist/components/search-box/SearchBox.module.css +0 -21
- package/dist/components/segmented-progress-bar/SegmentedProgressBar.js +0 -48
- package/dist/components/segmented-progress-bar/SegmentedProgressBar.module.css +0 -167
- package/dist/components/sidebar/Sidebar.js +0 -6
- package/dist/components/sidebar/components/SidebarItem.js +0 -8
- package/dist/components/sidebar/components/SidebarItem.module.css +0 -0
- package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.js +0 -63
- package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.module.css +0 -29
- package/dist/components/sidebar/components/sidebar-container/SidebarContainer.js +0 -153
- package/dist/components/sidebar/components/sidebar-container/SidebarContainer.module.css +0 -260
- package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.js +0 -18
- package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.module.css +0 -106
- package/dist/components/sidebar/components/sidebar-items/SidebarItems.js +0 -26
- package/dist/components/sidebar/components/sidebar-items/SidebarItems.module.css +0 -20
- package/dist/components/sidebar/components/sidenav-filteirng/SidenavFiltering.js +0 -30
- package/dist/components/sidebar/providers/SidebarProvider.js +0 -229
- package/dist/components/skeleton-loader/SkeletonLoader.js +0 -73
- package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.js +0 -13
- package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.module.css +0 -51
- package/dist/components/split-button/SplitButton.js +0 -10
- package/dist/components/split-button/SplitButton.module.css +0 -32
- package/dist/components/split-pane/SplitPane.js +0 -107
- package/dist/components/split-pane/SplitPane.module.css +0 -111
- package/dist/components/split-pane/provider/SplitPaneContext.js +0 -124
- package/dist/components/stack/Stack.js +0 -33
- package/dist/components/stack/Stack.module.css +0 -61
- package/dist/components/state-page/StatePage.js +0 -20
- package/dist/components/state-page/StatePage.module.css +0 -9
- package/dist/components/state-page/empty.js +0 -2
- package/dist/components/state-page/error.js +0 -2
- package/dist/components/state-page/notFound.js +0 -2
- package/dist/components/sticky-footer-layout/StickyFooterLayout.js +0 -64
- package/dist/components/table/Table.js +0 -50
- package/dist/components/table/Table.module.css +0 -536
- package/dist/components/table/Table.types.js +0 -1
- package/dist/components/table/TanstackTable.js +0 -111
- package/dist/components/table/components/TableBody.js +0 -10
- package/dist/components/table/components/TableHeader.js +0 -7
- package/dist/components/table/components/TableHeaderCell.js +0 -24
- package/dist/components/table/components/TableLoadingBody.js +0 -26
- package/dist/components/table/components/TablePagination.js +0 -1
- package/dist/components/table/components/TableRow.js +0 -54
- package/dist/components/table/components/TableSelectionCell.js +0 -16
- package/dist/components/table/components/column-resizer/ColumnResizer.js +0 -5
- package/dist/components/table/components/column-resizer/ColumnResizer.module.css +0 -22
- package/dist/components/table/components/empty-state/EmptyState.js +0 -23
- package/dist/components/table/components/empty-state/EmptyState.module.css +0 -4
- package/dist/components/table/components/table-settings/TableSettings.js +0 -63
- package/dist/components/table/hooks/useTableRowInteractions.js +0 -30
- package/dist/components/table/table.classes.js +0 -23
- package/dist/components/table/table.utils.js +0 -47
- package/dist/components/table/tanstackTable.utils.js +0 -175
- package/dist/components/tabs/Tabs.js +0 -125
- package/dist/components/tabs/Tabs.module.css +0 -233
- package/dist/components/theme-button/ThemeButton.js +0 -23
- package/dist/components/toast/Toast.js +0 -20
- package/dist/components/toast/Toast.module.css +0 -161
- package/dist/components/toast/provider/ToastProvider.js +0 -70
- package/dist/components/user-display/UserDisplay.js +0 -6
- package/dist/components/user-display/UserDisplay.module.css +0 -25
- package/dist/constants/severity.js +0 -24
- package/dist/constants/severity.types.js +0 -1
- package/dist/constants/sizes.js +0 -7
- package/dist/hooks/useDeviceSize.js +0 -32
- package/dist/hooks/useListNavigation.js +0 -234
- package/dist/hooks/usePagination.js +0 -140
- package/dist/hooks/useSorting.js +0 -118
- package/dist/hooks/useTableData.js +0 -45
- package/dist/hooks/useTableSelection.js +0 -164
- package/dist/hooks/useTableSettings.js +0 -71
- package/dist/hooks/useTheme.js +0 -66
- package/dist/hooks/useTimeDuration.js +0 -68
- package/dist/hooks/useViewportFill.js +0 -77
- package/dist/styles/animation.js +0 -5
- package/dist/styles/themes/types.js +0 -1
- package/dist/types/a11y-props.types.js +0 -1
- package/dist/types/sizes.types.js +0 -1
- package/dist/utils/arrays/nested-filtering.js +0 -48
- package/dist/utils/date/formatDate.js +0 -51
- package/dist/utils/localStorage.utils.js +0 -78
- package/dist/utils/text/get-highlighted-segments.js +0 -46
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useReactTable, getCoreRowModel, getSortedRowModel, } from '@tanstack/react-table';
|
|
4
|
-
import * as React from 'react';
|
|
5
|
-
import ColumnResizer from './components/column-resizer/ColumnResizer';
|
|
6
|
-
import { Table } from './Table';
|
|
7
|
-
import { DEFAULT_COLUMN_PX } from './table.utils';
|
|
8
|
-
import { buildDistributedColumnWidths, buildColumnVisibilityFromVisibleIds, mapDefsToColumnItems, sortingEqual, getSortPropsFromSorting, } from './tanstackTable.utils';
|
|
9
|
-
export function TanstackTable(props) {
|
|
10
|
-
const { data, dataKey, columns, sorting: controlledSorting, onSortingChange, optimisticSortingUi = true, visibleColumnIds, manualSorting, selectedRows, onRowSelect, ...tableProps } = props;
|
|
11
|
-
const isControlledSorting = controlledSorting != null;
|
|
12
|
-
const [uiSorting, setUiSorting] = React.useState(controlledSorting !== null && controlledSorting !== void 0 ? controlledSorting : []);
|
|
13
|
-
React.useEffect(() => {
|
|
14
|
-
if (!isControlledSorting)
|
|
15
|
-
return;
|
|
16
|
-
if (sortingEqual(uiSorting, controlledSorting))
|
|
17
|
-
return;
|
|
18
|
-
setUiSorting(controlledSorting);
|
|
19
|
-
}, [isControlledSorting, controlledSorting, uiSorting]);
|
|
20
|
-
const columnVisibility = React.useMemo(() => buildColumnVisibilityFromVisibleIds(columns, visibleColumnIds), [columns, visibleColumnIds]);
|
|
21
|
-
const [columnSizing, setColumnSizing] = React.useState({});
|
|
22
|
-
const containerRef = React.useRef(null);
|
|
23
|
-
const [availableWidth, setAvailableWidth] = React.useState(undefined);
|
|
24
|
-
const table = useReactTable({
|
|
25
|
-
data,
|
|
26
|
-
columns: columns,
|
|
27
|
-
state: {
|
|
28
|
-
sorting: uiSorting,
|
|
29
|
-
columnSizing,
|
|
30
|
-
columnVisibility,
|
|
31
|
-
},
|
|
32
|
-
onSortingChange: updater => {
|
|
33
|
-
const next = typeof updater === 'function' ? updater(uiSorting) : updater;
|
|
34
|
-
if (optimisticSortingUi)
|
|
35
|
-
setUiSorting(next);
|
|
36
|
-
onSortingChange === null || onSortingChange === void 0 ? void 0 : onSortingChange(next);
|
|
37
|
-
},
|
|
38
|
-
onColumnSizingChange: setColumnSizing,
|
|
39
|
-
getCoreRowModel: getCoreRowModel(),
|
|
40
|
-
getSortedRowModel: getSortedRowModel(),
|
|
41
|
-
manualSorting: manualSorting !== null && manualSorting !== void 0 ? manualSorting : false,
|
|
42
|
-
enableColumnResizing: true,
|
|
43
|
-
columnResizeMode: 'onChange',
|
|
44
|
-
defaultColumn: {
|
|
45
|
-
enableResizing: true,
|
|
46
|
-
minSize: 80,
|
|
47
|
-
size: DEFAULT_COLUMN_PX,
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
React.useLayoutEffect(() => {
|
|
51
|
-
const el = containerRef.current;
|
|
52
|
-
if (!el)
|
|
53
|
-
return;
|
|
54
|
-
const updateWidth = () => {
|
|
55
|
-
const next = el.clientWidth;
|
|
56
|
-
setAvailableWidth(next > 0 ? next : undefined);
|
|
57
|
-
};
|
|
58
|
-
updateWidth();
|
|
59
|
-
if (typeof ResizeObserver === 'undefined') {
|
|
60
|
-
window.addEventListener('resize', updateWidth);
|
|
61
|
-
return () => window.removeEventListener('resize', updateWidth);
|
|
62
|
-
}
|
|
63
|
-
const observer = new ResizeObserver(() => updateWidth());
|
|
64
|
-
observer.observe(el);
|
|
65
|
-
return () => observer.disconnect();
|
|
66
|
-
}, []);
|
|
67
|
-
const distributedLayout = React.useMemo(() => {
|
|
68
|
-
if (availableWidth == null)
|
|
69
|
-
return null;
|
|
70
|
-
return buildDistributedColumnWidths({
|
|
71
|
-
table,
|
|
72
|
-
hasSelection: Boolean(selectedRows && onRowSelect && dataKey),
|
|
73
|
-
defaultMinPx: 80,
|
|
74
|
-
columnSizing,
|
|
75
|
-
availableWidth,
|
|
76
|
-
});
|
|
77
|
-
}, [table, selectedRows, onRowSelect, dataKey, columnSizing, availableWidth]);
|
|
78
|
-
const initialLayoutReady = availableWidth != null;
|
|
79
|
-
const resolvedLayout = React.useMemo(() => {
|
|
80
|
-
const next = {};
|
|
81
|
-
table.getVisibleLeafColumns().forEach((column) => {
|
|
82
|
-
next[column.id] = {
|
|
83
|
-
width: distributedLayout === null || distributedLayout === void 0 ? void 0 : distributedLayout.widths[column.id],
|
|
84
|
-
};
|
|
85
|
-
});
|
|
86
|
-
return next;
|
|
87
|
-
}, [table, distributedLayout]);
|
|
88
|
-
const columnItems = React.useMemo(() => mapDefsToColumnItems(columns, columnVisibility, resolvedLayout), [columns, columnVisibility, resolvedLayout]);
|
|
89
|
-
const visibleData = table.getRowModel().rows.map(r => r.original);
|
|
90
|
-
const { sortById, sortDirection } = getSortPropsFromSorting(uiSorting);
|
|
91
|
-
const handleSortChange = React.useCallback((column, direction) => {
|
|
92
|
-
const next = direction == null ? [] : [{ id: column.id, desc: direction === 'desc' }];
|
|
93
|
-
if (optimisticSortingUi)
|
|
94
|
-
setUiSorting(next);
|
|
95
|
-
onSortingChange === null || onSortingChange === void 0 ? void 0 : onSortingChange(next);
|
|
96
|
-
}, [optimisticSortingUi, onSortingChange]);
|
|
97
|
-
const headerExtras = React.useCallback(({ index }) => {
|
|
98
|
-
var _a, _b, _c, _d;
|
|
99
|
-
const headerGroups = table.getHeaderGroups();
|
|
100
|
-
const leafHeaders = headerGroups.length > 0 ? headerGroups[headerGroups.length - 1].headers : [];
|
|
101
|
-
const header = leafHeaders[index];
|
|
102
|
-
if (!header)
|
|
103
|
-
return null;
|
|
104
|
-
const canResize = (_c = (_b = (_a = header.column).getCanResize) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : false;
|
|
105
|
-
const handler = (_d = header.getResizeHandler) === null || _d === void 0 ? void 0 : _d.call(header);
|
|
106
|
-
if (!canResize || !handler)
|
|
107
|
-
return null;
|
|
108
|
-
return _jsx(ColumnResizer, { id: header.column.id, handler: handler });
|
|
109
|
-
}, [table]);
|
|
110
|
-
return (_jsx(Table, { ...tableProps, tableRootRef: containerRef, onSortChange: handleSortChange, dataKey: dataKey, data: visibleData, columns: columnItems, tableWidth: distributedLayout === null || distributedLayout === void 0 ? void 0 : distributedLayout.totalWidth, measuringLayout: !initialLayoutReady, sortById: sortById, sortDirection: sortDirection, headerExtras: headerExtras, selectedRows: selectedRows, onRowSelect: onRowSelect }));
|
|
111
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { cx } from '../table.classes';
|
|
3
|
-
import styles from '../Table.module.css';
|
|
4
|
-
import { TableRow } from './TableRow';
|
|
5
|
-
export function TableBody({ data, dataKey, columns, striped, selectedRows, hasSelection, selectionMode, selectionInputName, viewMode, getRowSeverity, onRowClick, onRowMouseEnter, onRowSelect, }) {
|
|
6
|
-
return (_jsx("tbody", { className: cx(styles.body, striped && styles.striped), children: data.map(row => {
|
|
7
|
-
const rowId = row[dataKey];
|
|
8
|
-
return (_jsx(TableRow, { row: row, rowId: rowId, columns: columns, selectedRows: selectedRows, hasSelection: hasSelection, selectionMode: selectionMode, selectionInputName: selectionInputName, viewMode: viewMode, getRowSeverity: getRowSeverity, onRowClick: onRowClick, onRowMouseEnter: onRowMouseEnter, onRowSelect: onRowSelect }, `gridRow-${rowId}`));
|
|
9
|
-
}) }));
|
|
10
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { TableHeaderCell } from './TableHeaderCell';
|
|
3
|
-
import { TableSelectionCell } from './TableSelectionCell';
|
|
4
|
-
import styles from '../Table.module.css';
|
|
5
|
-
export function TableHeader({ columns, hasSelection, selectionMode, allRowsSelected, onSelectAllRows, sortById, sortDirection, onSortChange, headerExtras, }) {
|
|
6
|
-
return (_jsx("thead", { className: styles.header, children: _jsxs("tr", { className: styles.headerRow, children: [hasSelection ? (_jsx(TableSelectionCell, { isHeader: true, multiple: selectionMode === 'multiple', checked: allRowsSelected, onToggle: checked => onSelectAllRows === null || onSelectAllRows === void 0 ? void 0 : onSelectAllRows(checked) })) : null, columns.map((column, index) => (_jsx(TableHeaderCell, { column: column, index: index, sortById: sortById, sortDirection: sortDirection, onSortChange: onSortChange, extraContent: headerExtras === null || headerExtras === void 0 ? void 0 : headerExtras({ column, index }) }, column.id)))] }) }));
|
|
7
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { ArrowDown, ArrowUp } from 'lucide-react';
|
|
3
|
-
import { cx, getAlignValue, getDividerClass, getHeaderAlignClasses } from '../table.classes';
|
|
4
|
-
import styles from '../Table.module.css';
|
|
5
|
-
import { getAriaSort, getHeaderLabel, getNextSortDirection, isActiveSort, shouldToggleOnKey, } from '../table.utils';
|
|
6
|
-
export function TableHeaderCell({ column, index, sortById, sortDirection, onSortChange, extraContent, }) {
|
|
7
|
-
const active = isActiveSort(sortById, column.id);
|
|
8
|
-
const ariaSort = getAriaSort(column.sortable, active, sortDirection !== null && sortDirection !== void 0 ? sortDirection : null);
|
|
9
|
-
const align = getAlignValue(column);
|
|
10
|
-
const dividerClass = getDividerClass(column);
|
|
11
|
-
const alignClasses = getHeaderAlignClasses(align);
|
|
12
|
-
const handleToggleSort = () => {
|
|
13
|
-
if (!column.sortable || !onSortChange)
|
|
14
|
-
return;
|
|
15
|
-
const nextDirection = getNextSortDirection(column.sortable, active, sortDirection !== null && sortDirection !== void 0 ? sortDirection : null);
|
|
16
|
-
onSortChange(column, nextDirection);
|
|
17
|
-
};
|
|
18
|
-
return (_jsxs("th", { className: cx(styles.headerCell, dividerClass), scope: "col", "aria-sort": ariaSort, "data-align": align, "data-divider": column.divider, "data-column-index": index, children: [_jsx("div", { className: alignClasses.inner, children: _jsx("div", { className: alignClasses.main, children: column.sortable ? (_jsxs("button", { type: "button", className: alignClasses.button, onClick: handleToggleSort, onKeyDown: e => {
|
|
19
|
-
if (!shouldToggleOnKey(e.key))
|
|
20
|
-
return;
|
|
21
|
-
e.preventDefault();
|
|
22
|
-
handleToggleSort();
|
|
23
|
-
}, children: [_jsx("span", { className: alignClasses.label, children: getHeaderLabel(column.header) }), _jsxs("span", { className: styles.sortIndicator, "aria-hidden": "true", children: [active && sortDirection === 'asc' && _jsx(ArrowUp, {}), active && sortDirection === 'desc' && _jsx(ArrowDown, {}), !active && _jsx(ArrowDown, { className: styles.inActiveSort })] })] })) : (_jsx("span", { className: alignClasses.label, children: getHeaderLabel(column.header) })) }) }), extraContent != null ? _jsx("div", { className: styles.thOverlayExtras, children: extraContent }) : null] }, column.id));
|
|
24
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { SkeletonLoaderItem } from '../../../components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem';
|
|
3
|
-
import { cx } from '../table.classes';
|
|
4
|
-
import styles from '../Table.module.css';
|
|
5
|
-
function getColumnWidth(column) {
|
|
6
|
-
// If column.width is defined and less than 150px, use 100%
|
|
7
|
-
if (typeof column.width === 'number' && column.width < 150) {
|
|
8
|
-
return '100%';
|
|
9
|
-
}
|
|
10
|
-
if (typeof column.width === 'string' && column.width.endsWith('px')) {
|
|
11
|
-
const px = parseInt(column.width, 10);
|
|
12
|
-
if (!isNaN(px) && px < 150) {
|
|
13
|
-
return '100%';
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
// Otherwise, random between 50% and 90%
|
|
17
|
-
const percent = Math.floor(Math.random() * (90 - 50 + 1)) + 50;
|
|
18
|
-
return `${percent}%`;
|
|
19
|
-
}
|
|
20
|
-
export function TableLoadingBody({ rows, columns, hasSelection }) {
|
|
21
|
-
const widths = Array.from({ length: rows }, () => columns.map(getColumnWidth));
|
|
22
|
-
return (_jsx("tbody", { className: styles.body, children: Array.from({ length: rows }).map((_, rowIndex) => (_jsxs("tr", { className: styles.row, children: [hasSelection ? (_jsx("td", { className: cx(styles.cell, styles.selectionCell), children: _jsx("div", { className: styles.cellContent, children: _jsx(SkeletonLoaderItem, { height: 20, width: 20 }) }) })) : null, columns.map((column, columnIndex) => {
|
|
23
|
-
var _a;
|
|
24
|
-
return (_jsx("td", { className: cx(styles.cell, column.divider === 'left' && styles.dividerLeft, column.divider === 'right' && styles.dividerRight), "data-align": (_a = column.align) !== null && _a !== void 0 ? _a : 'left', "data-divider": column.divider, children: _jsx("div", { className: styles.cellContent, children: _jsx("div", { className: styles.cellValueEllipsis, children: _jsx(SkeletonLoaderItem, { height: 16, width: widths[rowIndex][columnIndex] }) }) }) }, column.id));
|
|
25
|
-
})] }, `loading-row-${rowIndex}`))) }));
|
|
26
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Checkbox } from '../../../components/forms/checkbox/Checkbox';
|
|
3
|
-
import { RadioButton } from '../../../components/forms/radio-buttons/RadioButton';
|
|
4
|
-
import { SeverityBorderColor } from '../../../constants/severity';
|
|
5
|
-
import { useTableRowInteractions } from '../hooks/useTableRowInteractions';
|
|
6
|
-
import { cx } from '../table.classes';
|
|
7
|
-
import styles from '../Table.module.css';
|
|
8
|
-
import { getCellDisplayValue, shouldAllowWrap } from '../table.utils';
|
|
9
|
-
export function TableRow({ row, rowId, columns, selectedRows, hasSelection, selectionMode, selectionInputName, viewMode, getRowSeverity, onRowClick, onRowMouseEnter, onRowSelect, }) {
|
|
10
|
-
var _a;
|
|
11
|
-
const isSelected = (_a = selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.has(rowId)) !== null && _a !== void 0 ? _a : false;
|
|
12
|
-
const rowSeverity = getRowSeverity === null || getRowSeverity === void 0 ? void 0 : getRowSeverity(row);
|
|
13
|
-
const canSelect = Boolean(selectedRows && onRowSelect);
|
|
14
|
-
const { handleRowClick, handleRowKeyDown } = useTableRowInteractions({
|
|
15
|
-
row,
|
|
16
|
-
rowId,
|
|
17
|
-
isSelected,
|
|
18
|
-
canSelect,
|
|
19
|
-
onRowClick,
|
|
20
|
-
onRowSelect,
|
|
21
|
-
});
|
|
22
|
-
return (_jsxs("tr", { className: cx(styles.row, onRowClick && styles.clickableRow, isSelected && styles.selectedRow, rowSeverity && styles.severity), style: {
|
|
23
|
-
['--row-severity-color']: rowSeverity
|
|
24
|
-
? SeverityBorderColor[rowSeverity]
|
|
25
|
-
: undefined,
|
|
26
|
-
}, tabIndex: onRowClick ? 0 : -1, onKeyDown: handleRowKeyDown, onMouseEnter: () => onRowMouseEnter === null || onRowMouseEnter === void 0 ? void 0 : onRowMouseEnter(row), onClick: handleRowClick, children: [hasSelection ? (_jsx("td", { className: cx(styles.cell, styles.selectionCell), "data-selection-control": "true", children: _jsx("div", { className: styles.selectionHitArea, "data-selection-control": "true", onClick: e => {
|
|
27
|
-
if (e.target !== e.currentTarget)
|
|
28
|
-
return;
|
|
29
|
-
e.stopPropagation();
|
|
30
|
-
onRowSelect === null || onRowSelect === void 0 ? void 0 : onRowSelect(rowId, !isSelected);
|
|
31
|
-
}, children: _jsx("div", { className: styles.selectionControlWrap, "data-selection-control": "true", onMouseDown: e => {
|
|
32
|
-
if (selectionMode !== 'single' || !isSelected)
|
|
33
|
-
return;
|
|
34
|
-
e.preventDefault();
|
|
35
|
-
}, onClick: e => {
|
|
36
|
-
e.stopPropagation();
|
|
37
|
-
if (selectionMode === 'single' && isSelected) {
|
|
38
|
-
e.preventDefault();
|
|
39
|
-
onRowSelect === null || onRowSelect === void 0 ? void 0 : onRowSelect(rowId, false);
|
|
40
|
-
}
|
|
41
|
-
}, children: selectionMode === 'single' ? (_jsx(RadioButton, { noContainer: true, name: selectionInputName, value: String(rowId), checked: isSelected, size: "sm", variant: "primary", onChange: (_value, e) => {
|
|
42
|
-
e.stopPropagation();
|
|
43
|
-
onRowSelect === null || onRowSelect === void 0 ? void 0 : onRowSelect(rowId, true);
|
|
44
|
-
} })) : (_jsx(Checkbox, { noContainer: true, variant: "primary", checked: isSelected, size: "sm", onChange: (checked, e) => {
|
|
45
|
-
e.stopPropagation();
|
|
46
|
-
onRowSelect === null || onRowSelect === void 0 ? void 0 : onRowSelect(rowId, checked);
|
|
47
|
-
} })) }) }) })) : null, columns.map(column => {
|
|
48
|
-
var _a, _b, _c, _d;
|
|
49
|
-
const allowWrap = shouldAllowWrap(column.allowWrap, isSelected, viewMode);
|
|
50
|
-
const allowOverflow = column.allowOverflow;
|
|
51
|
-
const cellValue = getCellDisplayValue(row, column);
|
|
52
|
-
return (_jsx("td", { className: cx(styles.cell, allowWrap ? styles.allowWrap : styles.nowrap, column.divider === 'left' && styles.dividerLeft, column.divider === 'right' && styles.dividerRight), "data-align": (_a = column.align) !== null && _a !== void 0 ? _a : 'left', "data-vertical-align": (_b = column.verticalAlign) !== null && _b !== void 0 ? _b : 'top', "data-divider": column.divider, children: _jsx("div", { className: styles.cellContent, "data-align": (_c = column.align) !== null && _c !== void 0 ? _c : 'left', "data-vertical-align": (_d = column.verticalAlign) !== null && _d !== void 0 ? _d : 'top', children: allowWrap || allowOverflow ? (cellValue) : (_jsx("div", { className: styles.cellValueEllipsis, children: cellValue })) }) }, column.id));
|
|
53
|
-
})] }));
|
|
54
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Checkbox } from '../../../components/forms/checkbox/Checkbox';
|
|
3
|
-
import { cx } from '../table.classes';
|
|
4
|
-
import styles from '../Table.module.css';
|
|
5
|
-
export function TableSelectionCell({ checked, isHeader, multiple, onToggle }) {
|
|
6
|
-
const Tag = isHeader ? 'th' : 'td';
|
|
7
|
-
return (_jsx(Tag, { className: cx(styles.headerCell, styles.selectionCell), scope: isHeader ? 'col' : undefined, onClick: e => {
|
|
8
|
-
if (isHeader && !multiple)
|
|
9
|
-
return;
|
|
10
|
-
e.stopPropagation();
|
|
11
|
-
onToggle(!checked, e);
|
|
12
|
-
}, children: isHeader && !multiple ? null : (_jsx("div", { className: styles.selectionHitArea, children: _jsx(Checkbox, { noContainer: true, size: "sm", variant: "primary", checked: checked, onChange: (nextChecked, e) => {
|
|
13
|
-
e.stopPropagation();
|
|
14
|
-
onToggle(nextChecked, e);
|
|
15
|
-
} }) })) }));
|
|
16
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import styles from './ColumnResizer.module.css';
|
|
4
|
-
const ColumnResizer = ({ id, handler }) => (_jsx("span", { className: styles.resizer, "data-resizer": "true", onMouseDown: handler, onTouchStart: handler, role: "separator", "aria-orientation": "vertical", "aria-label": `Resize ${id}` }));
|
|
5
|
-
export default ColumnResizer;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
.resizer {
|
|
2
|
-
position: absolute;
|
|
3
|
-
right: 0;
|
|
4
|
-
top: 0;
|
|
5
|
-
height: 100%;
|
|
6
|
-
width: 10px;
|
|
7
|
-
cursor: col-resize;
|
|
8
|
-
user-select: none;
|
|
9
|
-
touch-action: none;
|
|
10
|
-
z-index: 20;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.resizer::after {
|
|
14
|
-
content: '';
|
|
15
|
-
position: absolute;
|
|
16
|
-
right: 0;
|
|
17
|
-
width: 1px; /* visual thickness */
|
|
18
|
-
height: 60%;
|
|
19
|
-
top: 50%;
|
|
20
|
-
transform: translateY(-50%);
|
|
21
|
-
background-color: var(--opac-bg-default);
|
|
22
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { ArrowLeft } from 'lucide-react';
|
|
3
|
-
const defaultEmptyConfig = {
|
|
4
|
-
enabled: true,
|
|
5
|
-
title: 'Ingen resultater',
|
|
6
|
-
description: _jsx("span", { children: "Ingen data at vise." }),
|
|
7
|
-
showBack: false,
|
|
8
|
-
showRefresh: false,
|
|
9
|
-
showClearFilters: true,
|
|
10
|
-
backLabel: (_jsxs(_Fragment, { children: [_jsx(ArrowLeft, { size: 16 }), "Tilbage"] })),
|
|
11
|
-
refreshLabel: _jsx(_Fragment, { children: "Indl\u00E6s igen" }),
|
|
12
|
-
clearFiltersLabel: _jsx(_Fragment, { children: "Nulstil alle filtre" }),
|
|
13
|
-
className: 'dbc-flex dbc-flex-column dbc-items-start dbc-justify-start dbc-text-left dbc-gap-sm dbc-py-lg',
|
|
14
|
-
};
|
|
15
|
-
export function TableEmptyState({ config }) {
|
|
16
|
-
const merged = {
|
|
17
|
-
...defaultEmptyConfig,
|
|
18
|
-
...(config !== null && config !== void 0 ? config : {}),
|
|
19
|
-
};
|
|
20
|
-
if (!merged.enabled)
|
|
21
|
-
return null;
|
|
22
|
-
return (_jsxs("div", { className: "dbc-flex dbc-flex-column dbc-gap-md dbc-pt-sm dbc-pb-sm", children: [_jsx("span", { className: "dbc-text-sm dbc-muted-text", children: merged.description }), merged.actions ? _jsx("span", { className: "dbc-flex dbc-gap-sm", children: merged.actions }) : null] }));
|
|
23
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _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
|
-
export function TableSettings({ viewMode, handleChangeViewMode, columns = [], visibleColumnIds = [], onVisibleColumnIdsChange, columnsLabel = 'Kolonner', allPresetLabel = 'Alle', standardPresetLabel = 'Standard', buttonSize = 'sm', additionalSettings, }) {
|
|
9
|
-
const handleViewModeChange = (mode, close) => {
|
|
10
|
-
handleChangeViewMode(mode === 'wrapped' ? 'compact' : 'wrapped');
|
|
11
|
-
close === null || close === void 0 ? void 0 : close();
|
|
12
|
-
};
|
|
13
|
-
const hideableColumns = useMemo(() => columns.filter(c => c.enableHiding !== false), [columns]);
|
|
14
|
-
const allPresetIds = useMemo(() => hideableColumns.map(c => c.id), [hideableColumns]);
|
|
15
|
-
const standardPresetIds = useMemo(() => hideableColumns.filter(c => { var _a; return ((_a = c.meta) === null || _a === void 0 ? void 0 : _a.hidden) !== true; }).map(c => c.id), [hideableColumns]);
|
|
16
|
-
const visibleSet = useMemo(() => new Set(visibleColumnIds), [visibleColumnIds]);
|
|
17
|
-
const visibleCount = useMemo(() => {
|
|
18
|
-
return hideableColumns.reduce((acc, c) => { var _a; return acc + (visibleSet.has((_a = c.id) !== null && _a !== void 0 ? _a : '') ? 1 : 0); }, 0);
|
|
19
|
-
}, [hideableColumns, visibleSet]);
|
|
20
|
-
const setVisibleIds = (nextIds) => {
|
|
21
|
-
if (!onVisibleColumnIdsChange)
|
|
22
|
-
return;
|
|
23
|
-
const safe = nextIds.length > 0 ? nextIds : standardPresetIds.length > 0 ? standardPresetIds : allPresetIds;
|
|
24
|
-
onVisibleColumnIdsChange(safe.filter((id) => typeof id === 'string' && Boolean(id)));
|
|
25
|
-
};
|
|
26
|
-
const toggleColumn = (id, nextVisible) => {
|
|
27
|
-
const next = new Set(visibleColumnIds);
|
|
28
|
-
if (nextVisible)
|
|
29
|
-
next.add(id);
|
|
30
|
-
else
|
|
31
|
-
next.delete(id);
|
|
32
|
-
setVisibleIds(Array.from(next));
|
|
33
|
-
};
|
|
34
|
-
const isAllActive = useMemo(() => {
|
|
35
|
-
if (!hideableColumns.length)
|
|
36
|
-
return false;
|
|
37
|
-
return hideableColumns.every(c => c.id && visibleSet.has(c.id));
|
|
38
|
-
}, [hideableColumns, visibleSet]);
|
|
39
|
-
const isStandardActive = useMemo(() => {
|
|
40
|
-
if (!hideableColumns.length)
|
|
41
|
-
return false;
|
|
42
|
-
const std = new Set(standardPresetIds);
|
|
43
|
-
return hideableColumns.every(c => c.id && visibleSet.has(c.id) === std.has(c.id));
|
|
44
|
-
}, [hideableColumns, visibleSet, standardPresetIds]);
|
|
45
|
-
// Required by your RadioButton component
|
|
46
|
-
const presetRadioName = 'table-columns-preset';
|
|
47
|
-
return (_jsx(Popover, { trigger: (onClick, icon) => (_jsxs(Button, { size: buttonSize, onClick: onClick, type: "button", children: [_jsx(Settings, {}), icon] })), children: close => (_jsxs(Menu, { children: [additionalSettings === null || additionalSettings === void 0 ? void 0 : additionalSettings(close), _jsx(Menu.Item, { active: viewMode === 'wrapped', children: _jsxs("button", { type: "button", onClick: () => handleViewModeChange(viewMode, close), children: [_jsx(ListChevronsDownUp, {}), "Ombryd tekst"] }) }), hideableColumns.length > 0 && onVisibleColumnIdsChange ? (_jsxs(_Fragment, { children: [_jsx(Menu.Separator, {}), _jsx("div", { style: { padding: '6px 10px', fontSize: 12, opacity: 0.7 }, children: columnsLabel }), _jsx(Menu.RadioItem, { name: presetRadioName, value: "all", checked: isAllActive, label: allPresetLabel, onValueChange: () => {
|
|
48
|
-
setVisibleIds(allPresetIds.filter((id) => typeof id === 'string' && Boolean(id)));
|
|
49
|
-
close === null || close === void 0 ? void 0 : close();
|
|
50
|
-
} }), _jsx(Menu.RadioItem, { name: presetRadioName, value: "standard", checked: isStandardActive, label: standardPresetLabel, onValueChange: () => {
|
|
51
|
-
setVisibleIds(standardPresetIds.filter((id) => typeof id === 'string' && Boolean(id)));
|
|
52
|
-
close === null || close === void 0 ? void 0 : close();
|
|
53
|
-
} }), _jsx(Menu.Separator, {}), hideableColumns.map(col => {
|
|
54
|
-
const isVisible = col.id ? visibleSet.has(col.id) : false;
|
|
55
|
-
const disableUncheckingLast = isVisible && visibleCount <= 1;
|
|
56
|
-
const label = col.header;
|
|
57
|
-
return (_jsx(Menu.CheckItem, { checked: isVisible, disabled: disableUncheckingLast, label: label, onCheckedChange: nextChecked => {
|
|
58
|
-
if (disableUncheckingLast)
|
|
59
|
-
return;
|
|
60
|
-
toggleColumn(col.id, nextChecked);
|
|
61
|
-
} }, col.id));
|
|
62
|
-
})] })) : null] })) }));
|
|
63
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { useCallback } from 'react';
|
|
2
|
-
import { isModifierClick, shouldToggleOnKey } from '../table.utils';
|
|
3
|
-
export function useTableRowInteractions({ row, rowId, isSelected, canSelect, onRowClick, onRowSelect, }) {
|
|
4
|
-
const handleRowClick = useCallback((e) => {
|
|
5
|
-
var _a;
|
|
6
|
-
const target = e.target;
|
|
7
|
-
if ((_a = target === null || target === void 0 ? void 0 : target.closest) === null || _a === void 0 ? void 0 : _a.call(target, '[data-selection-control="true"]')) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
if (isModifierClick(e) && canSelect) {
|
|
11
|
-
e.preventDefault();
|
|
12
|
-
e.stopPropagation();
|
|
13
|
-
onRowSelect === null || onRowSelect === void 0 ? void 0 : onRowSelect(rowId, !isSelected);
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(row);
|
|
17
|
-
}, [canSelect, isSelected, onRowClick, onRowSelect, row, rowId]);
|
|
18
|
-
const handleRowKeyDown = useCallback((e) => {
|
|
19
|
-
if (!onRowClick)
|
|
20
|
-
return;
|
|
21
|
-
if (!shouldToggleOnKey(e.key))
|
|
22
|
-
return;
|
|
23
|
-
e.preventDefault();
|
|
24
|
-
onRowClick(row);
|
|
25
|
-
}, [onRowClick, row]);
|
|
26
|
-
return {
|
|
27
|
-
handleRowClick,
|
|
28
|
-
handleRowKeyDown,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import styles from './Table.module.css';
|
|
2
|
-
export function cx(...values) {
|
|
3
|
-
return values.filter(Boolean).join(' ');
|
|
4
|
-
}
|
|
5
|
-
export function getDividerClass(column) {
|
|
6
|
-
if (column.divider === 'left')
|
|
7
|
-
return styles.dividerLeft;
|
|
8
|
-
if (column.divider === 'right')
|
|
9
|
-
return styles.dividerRight;
|
|
10
|
-
return '';
|
|
11
|
-
}
|
|
12
|
-
export function getAlignValue(column) {
|
|
13
|
-
var _a;
|
|
14
|
-
return (_a = column.align) !== null && _a !== void 0 ? _a : 'left';
|
|
15
|
-
}
|
|
16
|
-
export function getHeaderAlignClasses(align) {
|
|
17
|
-
return {
|
|
18
|
-
inner: cx(styles.thInner, align === 'right' && styles.thInnerRight, align === 'center' && styles.thInnerCenter),
|
|
19
|
-
main: cx(styles.thMain, align === 'right' && styles.thMainRight, align === 'center' && styles.thMainCenter),
|
|
20
|
-
button: cx(styles.thButton, align === 'right' && styles.thButtonRight, align === 'center' && styles.thButtonCenter),
|
|
21
|
-
label: cx(styles.thLabel, align === 'right' && styles.thLabelRight, align === 'center' && styles.thLabelCenter),
|
|
22
|
-
};
|
|
23
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
export const SELECTION_COLUMN_PX = 40;
|
|
2
|
-
export const DEFAULT_COLUMN_PX = 150;
|
|
3
|
-
export function getVisibleColumns(columns) {
|
|
4
|
-
return columns.filter(column => !column.hidden);
|
|
5
|
-
}
|
|
6
|
-
export function getHeaderLabel(header) {
|
|
7
|
-
return typeof header === 'function' ? header() : header;
|
|
8
|
-
}
|
|
9
|
-
export function isActiveSort(sortById, columnId) {
|
|
10
|
-
return sortById === columnId;
|
|
11
|
-
}
|
|
12
|
-
export function getAriaSort(sortable, active, direction) {
|
|
13
|
-
if (!sortable || !active || !direction)
|
|
14
|
-
return 'none';
|
|
15
|
-
return direction === 'asc' ? 'ascending' : 'descending';
|
|
16
|
-
}
|
|
17
|
-
export function getNextSortDirection(sortable, active, currentDirection) {
|
|
18
|
-
if (!sortable)
|
|
19
|
-
return null;
|
|
20
|
-
if (!active)
|
|
21
|
-
return 'asc';
|
|
22
|
-
if (currentDirection === 'asc')
|
|
23
|
-
return 'desc';
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
export function shouldToggleOnKey(key) {
|
|
27
|
-
return key === 'Enter' || key === ' ';
|
|
28
|
-
}
|
|
29
|
-
export function isModifierClick(e) {
|
|
30
|
-
return Boolean(e.metaKey || e.ctrlKey);
|
|
31
|
-
}
|
|
32
|
-
export function shouldAllowWrap(columnAllowWrap, isRowSelected, viewMode) {
|
|
33
|
-
return Boolean(columnAllowWrap || isRowSelected || viewMode === 'wrapped');
|
|
34
|
-
}
|
|
35
|
-
export function getCellDisplayValue(row, column) {
|
|
36
|
-
var _a;
|
|
37
|
-
const empty = (_a = column.emptyPlaceholder) !== null && _a !== void 0 ? _a : '';
|
|
38
|
-
if (column.render) {
|
|
39
|
-
const rendered = column.render(row);
|
|
40
|
-
return rendered !== null && rendered !== void 0 ? rendered : empty;
|
|
41
|
-
}
|
|
42
|
-
if (column.accessor) {
|
|
43
|
-
const value = row[column.accessor];
|
|
44
|
-
return value !== null && value !== void 0 ? value : empty;
|
|
45
|
-
}
|
|
46
|
-
return empty;
|
|
47
|
-
}
|