@dbcdk/react-components 0.0.34 → 0.0.36
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/button/Button.module.css +1 -0
- package/dist/components/card/components/CardMeta.js +2 -2
- package/dist/components/card/components/CardMeta.module.css +3 -3
- package/dist/components/code-block/CodeBlock.js +13 -2
- package/dist/components/datetime-picker/DateTimePicker.d.ts +1 -0
- package/dist/components/datetime-picker/DateTimePicker.js +2 -2
- package/dist/components/forms/checkbox/Checkbox.module.css +8 -2
- package/dist/components/forms/multi-select/MultiSelect.d.ts +4 -1
- package/dist/components/forms/multi-select/MultiSelect.js +69 -23
- package/dist/components/menu/Menu.module.css +10 -2
- package/dist/components/pagination/Pagination.js +7 -5
- package/dist/components/table/Table.d.ts +2 -1
- package/dist/components/table/Table.js +4 -11
- package/dist/components/table/Table.module.css +107 -182
- package/dist/components/table/Table.types.d.ts +3 -1
- package/dist/components/table/TanstackTable.js +75 -32
- package/dist/components/table/components/TableBody.d.ts +2 -3
- package/dist/components/table/components/TableBody.js +3 -3
- package/dist/components/table/components/TableHeader.d.ts +2 -3
- package/dist/components/table/components/TableHeader.js +2 -2
- package/dist/components/table/components/TableHeaderCell.js +2 -2
- package/dist/components/table/components/TableLoadingBody.d.ts +2 -3
- package/dist/components/table/components/TableLoadingBody.js +3 -3
- package/dist/components/table/components/TableRow.d.ts +1 -3
- package/dist/components/table/components/TableRow.js +8 -7
- package/dist/components/table/components/TableSelectionCell.js +3 -2
- package/dist/components/table/components/column-resizer/ColumnResizer.module.css +4 -5
- package/dist/components/table/table.utils.d.ts +0 -4
- package/dist/components/table/table.utils.js +0 -8
- package/dist/components/table/tanstackTable.utils.d.ts +11 -6
- package/dist/components/table/tanstackTable.utils.js +91 -82
- package/dist/src/styles/styles.css +1 -5
- package/dist/styles/styles.css +1 -5
- package/package.json +2 -1
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
2
|
import type { ColumnItem } from '../Table.types';
|
|
3
3
|
type Props<T> = {
|
|
4
4
|
rows: number;
|
|
5
5
|
columns: ColumnItem<T>[];
|
|
6
6
|
hasSelection: boolean;
|
|
7
|
-
gridStyle: CSSProperties;
|
|
8
7
|
};
|
|
9
|
-
export declare function TableLoadingBody<T>({ rows, columns, hasSelection
|
|
8
|
+
export declare function TableLoadingBody<T>({ rows, columns, hasSelection }: Props<T>): ReactNode;
|
|
10
9
|
export {};
|
|
@@ -2,9 +2,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { SkeletonLoaderItem } from '../../../components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem';
|
|
3
3
|
import { cx } from '../table.classes';
|
|
4
4
|
import styles from '../Table.module.css';
|
|
5
|
-
export function TableLoadingBody({ rows, columns, hasSelection
|
|
6
|
-
return (_jsx("
|
|
5
|
+
export function TableLoadingBody({ rows, columns, hasSelection }) {
|
|
6
|
+
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) }) : null, columns.map(column => {
|
|
7
7
|
var _a;
|
|
8
|
-
return (_jsx("
|
|
8
|
+
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: 20, width: "100%" }) }) }) }, column.id));
|
|
9
9
|
})] }, `loading-row-${rowIndex}`))) }));
|
|
10
10
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { CSSProperties } from 'react';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import type { ViewMode } from '../../../hooks/useTableSettings';
|
|
4
3
|
import type { ColumnItem } from '../Table.types';
|
|
@@ -6,7 +5,6 @@ type Props<T extends Record<string, any>> = {
|
|
|
6
5
|
row: T;
|
|
7
6
|
rowId: string | number;
|
|
8
7
|
columns: ColumnItem<T>[];
|
|
9
|
-
gridStyle: CSSProperties;
|
|
10
8
|
selectedRows?: Set<number | string>;
|
|
11
9
|
hasSelection: boolean;
|
|
12
10
|
selectionMode: 'single' | 'multiple';
|
|
@@ -17,5 +15,5 @@ type Props<T extends Record<string, any>> = {
|
|
|
17
15
|
onRowMouseEnter?: (row: T) => void;
|
|
18
16
|
onRowSelect?: (rowId: number | string, isSelected: boolean) => void;
|
|
19
17
|
};
|
|
20
|
-
export declare function TableRow<T extends Record<string, any>>({ row, rowId, columns,
|
|
18
|
+
export declare function TableRow<T extends Record<string, any>>({ row, rowId, columns, selectedRows, hasSelection, selectionMode, selectionInputName, viewMode, getRowSeverity, onRowClick, onRowMouseEnter, onRowSelect, }: Props<T>): React.ReactNode;
|
|
21
19
|
export {};
|
|
@@ -6,7 +6,7 @@ import { useTableRowInteractions } from '../hooks/useTableRowInteractions';
|
|
|
6
6
|
import { cx } from '../table.classes';
|
|
7
7
|
import styles from '../Table.module.css';
|
|
8
8
|
import { getCellDisplayValue, shouldAllowWrap } from '../table.utils';
|
|
9
|
-
export function TableRow({ row, rowId, columns,
|
|
9
|
+
export function TableRow({ row, rowId, columns, selectedRows, hasSelection, selectionMode, selectionInputName, viewMode, getRowSeverity, onRowClick, onRowMouseEnter, onRowSelect, }) {
|
|
10
10
|
var _a;
|
|
11
11
|
const isSelected = (_a = selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.has(rowId)) !== null && _a !== void 0 ? _a : false;
|
|
12
12
|
const rowSeverity = getRowSeverity === null || getRowSeverity === void 0 ? void 0 : getRowSeverity(row);
|
|
@@ -19,12 +19,11 @@ export function TableRow({ row, rowId, columns, gridStyle, selectedRows, hasSele
|
|
|
19
19
|
onRowClick,
|
|
20
20
|
onRowSelect,
|
|
21
21
|
});
|
|
22
|
-
return (_jsxs("
|
|
23
|
-
...gridStyle,
|
|
22
|
+
return (_jsxs("tr", { className: cx(styles.row, onRowClick && styles.clickableRow, isSelected && styles.selectedRow, rowSeverity && styles.severity), style: {
|
|
24
23
|
['--row-severity-color']: rowSeverity
|
|
25
24
|
? SeverityBgColor[rowSeverity]
|
|
26
25
|
: undefined,
|
|
27
|
-
},
|
|
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 => {
|
|
28
27
|
if (e.target !== e.currentTarget)
|
|
29
28
|
return;
|
|
30
29
|
e.stopPropagation();
|
|
@@ -42,13 +41,15 @@ export function TableRow({ row, rowId, columns, gridStyle, selectedRows, hasSele
|
|
|
42
41
|
}, children: selectionMode === 'single' ? (_jsx(RadioButton, { noContainer: true, name: selectionInputName, value: String(rowId), checked: isSelected, size: "sm", variant: "primary", onChange: (_value, e) => {
|
|
43
42
|
e.stopPropagation();
|
|
44
43
|
onRowSelect === null || onRowSelect === void 0 ? void 0 : onRowSelect(rowId, true);
|
|
45
|
-
} })) : (_jsx(Checkbox, { variant: "primary", checked: isSelected, size: "sm", onChange: (checked, e) => {
|
|
44
|
+
} })) : (_jsx(Checkbox, { noContainer: true, variant: "primary", checked: isSelected, size: "sm", onChange: (checked, e) => {
|
|
46
45
|
e.stopPropagation();
|
|
47
46
|
onRowSelect === null || onRowSelect === void 0 ? void 0 : onRowSelect(rowId, checked);
|
|
48
47
|
} })) }) }) })) : null, columns.map(column => {
|
|
49
48
|
var _a;
|
|
50
|
-
const allowWrap =
|
|
49
|
+
const allowWrap = column.fitContent
|
|
50
|
+
? false
|
|
51
|
+
: shouldAllowWrap(column.allowWrap, isSelected, viewMode);
|
|
51
52
|
const cellValue = getCellDisplayValue(row, column);
|
|
52
|
-
return (_jsx("
|
|
53
|
+
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-divider": column.divider, "data-column-id": column.id, "data-fit-content-column": column.fitContent || undefined, children: _jsx("div", { className: styles.cellContent, children: allowWrap ? cellValue : _jsx("div", { className: styles.cellValueEllipsis, children: cellValue }) }) }, column.id));
|
|
53
54
|
})] }));
|
|
54
55
|
}
|
|
@@ -3,12 +3,13 @@ import { Checkbox } from '../../../components/forms/checkbox/Checkbox';
|
|
|
3
3
|
import { cx } from '../table.classes';
|
|
4
4
|
import styles from '../Table.module.css';
|
|
5
5
|
export function TableSelectionCell({ checked, isHeader, multiple, onToggle }) {
|
|
6
|
-
|
|
6
|
+
const Tag = isHeader ? 'th' : 'td';
|
|
7
|
+
return (_jsx(Tag, { className: cx(styles.headerCell, styles.selectionCell), scope: isHeader ? 'col' : undefined, onClick: e => {
|
|
7
8
|
if (isHeader && !multiple)
|
|
8
9
|
return;
|
|
9
10
|
e.stopPropagation();
|
|
10
11
|
onToggle(!checked, e);
|
|
11
|
-
}, children: isHeader && !multiple ? null : (_jsx("div", { className: styles.selectionHitArea, children: _jsx(Checkbox, { size: "sm", variant: "primary", checked: checked, onChange: (nextChecked, 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) => {
|
|
12
13
|
e.stopPropagation();
|
|
13
14
|
onToggle(nextChecked, e);
|
|
14
15
|
} }) })) }));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
.resizer {
|
|
2
2
|
position: absolute;
|
|
3
|
-
right:
|
|
3
|
+
right: 0;
|
|
4
4
|
top: 0;
|
|
5
5
|
height: 100%;
|
|
6
|
-
width:
|
|
6
|
+
width: 10px;
|
|
7
7
|
cursor: col-resize;
|
|
8
8
|
user-select: none;
|
|
9
9
|
touch-action: none;
|
|
@@ -13,11 +13,10 @@
|
|
|
13
13
|
.resizer::after {
|
|
14
14
|
content: '';
|
|
15
15
|
position: absolute;
|
|
16
|
-
|
|
17
|
-
transform: translateX(-50%);
|
|
16
|
+
right: 0;
|
|
18
17
|
width: 1px; /* visual thickness */
|
|
19
18
|
height: 60%;
|
|
20
19
|
top: 50%;
|
|
21
|
-
transform:
|
|
20
|
+
transform: translateY(-50%);
|
|
22
21
|
background-color: var(--opac-bg-default);
|
|
23
22
|
}
|
|
@@ -15,7 +15,3 @@ export declare function isModifierClick(e: {
|
|
|
15
15
|
}): boolean;
|
|
16
16
|
export declare function shouldAllowWrap(columnAllowWrap: boolean | undefined, isRowSelected: boolean, viewMode?: 'wrapped' | string): boolean;
|
|
17
17
|
export declare function getCellDisplayValue<T extends Record<string, any>>(row: T, column: ColumnItem<T>): ReactNode;
|
|
18
|
-
export declare function buildDefaultGridTemplate(args: {
|
|
19
|
-
hasSelection: boolean;
|
|
20
|
-
colCount: number;
|
|
21
|
-
}): string;
|
|
@@ -45,11 +45,3 @@ export function getCellDisplayValue(row, column) {
|
|
|
45
45
|
}
|
|
46
46
|
return empty;
|
|
47
47
|
}
|
|
48
|
-
export function buildDefaultGridTemplate(args) {
|
|
49
|
-
const parts = [];
|
|
50
|
-
if (args.hasSelection)
|
|
51
|
-
parts.push(`${SELECTION_COLUMN_PX}px`);
|
|
52
|
-
for (let i = 0; i < args.colCount; i++)
|
|
53
|
-
parts.push('minmax(120px, 1fr)');
|
|
54
|
-
return parts.join(' ');
|
|
55
|
-
}
|
|
@@ -3,19 +3,24 @@ import { ColumnItem } from './Table.types';
|
|
|
3
3
|
type AnyRecord = Record<string, any>;
|
|
4
4
|
export declare function getColumnId<T>(def: ColumnDef<T, any>, index: number): string;
|
|
5
5
|
export declare function buildColumnVisibilityFromVisibleIds<T>(defs: ReadonlyArray<ColumnDef<T, any>>, visibleColumnIds?: string[]): VisibilityState;
|
|
6
|
-
export declare function mapDefsToColumnItems<T extends AnyRecord>(defs: ReadonlyArray<ColumnDef<T, any>>, columnVisibility: VisibilityState
|
|
6
|
+
export declare function mapDefsToColumnItems<T extends AnyRecord>(defs: ReadonlyArray<ColumnDef<T, any>>, columnVisibility: VisibilityState, resolvedLayout?: Record<string, {
|
|
7
|
+
width?: number | string;
|
|
8
|
+
}>): ColumnItem<T>[];
|
|
7
9
|
export declare function sortingEqual(a: SortingState, b: SortingState): boolean;
|
|
8
10
|
export declare function getSortPropsFromSorting(sorting: SortingState): {
|
|
9
11
|
sortById?: string;
|
|
10
12
|
sortDirection: 'asc' | 'desc' | null;
|
|
11
13
|
};
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function buildDistributedGridTemplateColumns(args: {
|
|
14
|
+
export declare function buildDistributedColumnWidths(args: {
|
|
14
15
|
table: any;
|
|
15
|
-
allowedIds: Set<string>;
|
|
16
16
|
hasSelection: boolean;
|
|
17
17
|
defaultMinPx: number;
|
|
18
18
|
columnSizing: ColumnSizingState;
|
|
19
|
-
availableWidth
|
|
20
|
-
|
|
19
|
+
availableWidth: number;
|
|
20
|
+
measuredFitContentWidths?: Record<string, number>;
|
|
21
|
+
}): {
|
|
22
|
+
selectionWidth?: number;
|
|
23
|
+
widths: Record<string, number>;
|
|
24
|
+
totalWidth: number;
|
|
25
|
+
};
|
|
21
26
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SELECTION_COLUMN_PX } from './table.utils';
|
|
1
|
+
import { DEFAULT_COLUMN_PX, SELECTION_COLUMN_PX } from './table.utils';
|
|
2
2
|
export function getColumnId(def, index) {
|
|
3
3
|
const d = def;
|
|
4
4
|
if (d.id != null && String(d.id).length > 0)
|
|
@@ -18,9 +18,9 @@ export function buildColumnVisibilityFromVisibleIds(defs, visibleColumnIds) {
|
|
|
18
18
|
});
|
|
19
19
|
return next;
|
|
20
20
|
}
|
|
21
|
-
export function mapDefsToColumnItems(defs, columnVisibility) {
|
|
21
|
+
export function mapDefsToColumnItems(defs, columnVisibility, resolvedLayout = {}) {
|
|
22
22
|
return defs.map((def, index) => {
|
|
23
|
-
var _a, _b, _c, _d, _e, _f;
|
|
23
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
24
24
|
const id = getColumnId(def, index);
|
|
25
25
|
const accessorKey = def.accessorKey;
|
|
26
26
|
const accessorFn = def.accessorFn;
|
|
@@ -54,10 +54,12 @@ export function mapDefsToColumnItems(defs, columnVisibility) {
|
|
|
54
54
|
sortable: (_d = def.enableSorting) !== null && _d !== void 0 ? _d : !!accessorKey,
|
|
55
55
|
render,
|
|
56
56
|
hidden: !isVisible,
|
|
57
|
+
width: (_e = resolvedLayout[id]) === null || _e === void 0 ? void 0 : _e.width,
|
|
58
|
+
fitContent: (_f = meta.fitContent) !== null && _f !== void 0 ? _f : false,
|
|
57
59
|
align: meta.align,
|
|
58
60
|
verticalAlign: meta.verticalAlign,
|
|
59
|
-
emptyPlaceholder: (
|
|
60
|
-
allowWrap: (
|
|
61
|
+
emptyPlaceholder: (_g = meta.emptyPlaceholder) !== null && _g !== void 0 ? _g : '-',
|
|
62
|
+
allowWrap: (_h = meta.allowWrap) !== null && _h !== void 0 ? _h : false,
|
|
61
63
|
severity: meta.severity,
|
|
62
64
|
divider: meta.divider,
|
|
63
65
|
};
|
|
@@ -79,100 +81,107 @@ export function getSortPropsFromSorting(sorting) {
|
|
|
79
81
|
sortDirection: s ? (s.desc ? 'desc' : 'asc') : null,
|
|
80
82
|
};
|
|
81
83
|
}
|
|
82
|
-
export function columnItemsToIdSet(items) {
|
|
83
|
-
const s = new Set();
|
|
84
|
-
for (const c of items)
|
|
85
|
-
s.add(c.id);
|
|
86
|
-
return s;
|
|
87
|
-
}
|
|
88
84
|
function clamp(value, min, max) {
|
|
89
85
|
const lowerBounded = Math.max(min, value);
|
|
90
86
|
if (max == null || !Number.isFinite(max))
|
|
91
87
|
return lowerBounded;
|
|
92
88
|
return Math.min(lowerBounded, max);
|
|
93
89
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
let
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
90
|
+
function toIntegerTrackWidths(tracks, targetWidth) {
|
|
91
|
+
const floored = tracks.map(track => ({
|
|
92
|
+
id: track.id,
|
|
93
|
+
width: Math.floor(track.width),
|
|
94
|
+
fraction: track.width - Math.floor(track.width),
|
|
95
|
+
}));
|
|
96
|
+
const baseTotal = floored.reduce((sum, track) => sum + track.width, 0);
|
|
97
|
+
let remainder = Math.max(0, targetWidth - baseTotal);
|
|
98
|
+
floored
|
|
99
|
+
.slice()
|
|
100
|
+
.sort((a, b) => b.fraction - a.fraction)
|
|
101
|
+
.forEach(track => {
|
|
102
|
+
if (remainder <= 0)
|
|
103
|
+
return;
|
|
104
|
+
track.width += 1;
|
|
105
|
+
remainder -= 1;
|
|
106
|
+
});
|
|
107
|
+
return Object.fromEntries(floored.map(track => [track.id, track.width]));
|
|
108
|
+
}
|
|
109
|
+
export function buildDistributedColumnWidths(args) {
|
|
110
|
+
const { table, hasSelection, defaultMinPx, columnSizing, availableWidth, measuredFitContentWidths = {}, } = args;
|
|
111
|
+
const leaf = table.getVisibleLeafColumns();
|
|
112
|
+
const selectionWidth = hasSelection ? SELECTION_COLUMN_PX : 0;
|
|
113
|
+
const tracks = leaf.map((c) => {
|
|
114
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
105
115
|
const def = c.columnDef;
|
|
106
116
|
const meta = ((_b = ((_a = def.meta) !== null && _a !== void 0 ? _a : {})) !== null && _b !== void 0 ? _b : {});
|
|
107
117
|
const min = Math.max(1, Number((_c = def.minSize) !== null && _c !== void 0 ? _c : defaultMinPx));
|
|
108
|
-
const
|
|
109
|
-
const hasMax = def.maxSize != null;
|
|
110
|
-
const max = hasMax ? Math.max(min, Number(def.maxSize)) : undefined;
|
|
111
|
-
const weight = Math.max(1, Number((_g = meta.weight) !== null && _g !== void 0 ? _g : 1));
|
|
118
|
+
const max = def.maxSize != null ? Math.max(min, Number(def.maxSize)) : undefined;
|
|
112
119
|
const resizedPxRaw = columnSizing[c.id];
|
|
113
120
|
const resizedPx = resizedPxRaw != null ? Math.round(clamp(Number(resizedPxRaw), min, max)) : undefined;
|
|
114
121
|
if (resizedPx != null) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
122
|
+
return {
|
|
123
|
+
id: c.id,
|
|
124
|
+
width: resizedPx,
|
|
125
|
+
weight: 0,
|
|
126
|
+
max: resizedPx,
|
|
127
|
+
fixed: true,
|
|
128
|
+
};
|
|
118
129
|
}
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
130
|
+
if (meta.fitContent) {
|
|
131
|
+
const preferredRaw = Number((_g = (_f = (_e = (_d = measuredFitContentWidths[c.id]) !== null && _d !== void 0 ? _d : def.size) !== null && _e !== void 0 ? _e : def.maxSize) !== null && _f !== void 0 ? _f : def.minSize) !== null && _g !== void 0 ? _g : defaultMinPx);
|
|
132
|
+
const preferred = Number.isFinite(preferredRaw) && preferredRaw > 0 ? preferredRaw : defaultMinPx;
|
|
133
|
+
const fitWidth = Math.round(clamp(preferred, min, max));
|
|
134
|
+
return {
|
|
135
|
+
id: c.id,
|
|
136
|
+
width: fitWidth,
|
|
137
|
+
weight: 0,
|
|
138
|
+
max: fitWidth,
|
|
139
|
+
fixed: true,
|
|
140
|
+
};
|
|
123
141
|
}
|
|
124
|
-
|
|
125
|
-
|
|
142
|
+
const rawWeight = Number((_j = (_h = meta.weight) !== null && _h !== void 0 ? _h : def.size) !== null && _j !== void 0 ? _j : DEFAULT_COLUMN_PX);
|
|
143
|
+
const weight = Number.isFinite(rawWeight) && rawWeight > 0 ? rawWeight : DEFAULT_COLUMN_PX;
|
|
144
|
+
return {
|
|
145
|
+
id: c.id,
|
|
146
|
+
width: min,
|
|
126
147
|
weight,
|
|
127
148
|
max,
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
nextActive.push(track);
|
|
149
|
-
}
|
|
149
|
+
fixed: false,
|
|
150
|
+
};
|
|
151
|
+
});
|
|
152
|
+
const fixedWidth = selectionWidth + tracks.reduce((sum, track) => sum + track.width, 0);
|
|
153
|
+
let remaining = Math.max(0, availableWidth - fixedWidth);
|
|
154
|
+
let active = tracks.filter(track => !track.fixed && (track.max == null || track.width < track.max));
|
|
155
|
+
while (remaining > 0.5 && active.length > 0) {
|
|
156
|
+
const totalWeight = active.reduce((sum, track) => sum + track.weight, 0);
|
|
157
|
+
if (totalWeight <= 0)
|
|
158
|
+
break;
|
|
159
|
+
let consumed = 0;
|
|
160
|
+
const nextActive = [];
|
|
161
|
+
for (const track of active) {
|
|
162
|
+
const share = (remaining * track.weight) / totalWeight;
|
|
163
|
+
const maxGrow = track.max == null ? share : Math.max(0, track.max - track.width);
|
|
164
|
+
const growth = Math.min(share, maxGrow);
|
|
165
|
+
track.width += growth;
|
|
166
|
+
consumed += growth;
|
|
167
|
+
if (track.max == null || track.width < track.max - 0.5) {
|
|
168
|
+
nextActive.push(track);
|
|
150
169
|
}
|
|
151
|
-
if (consumed <= 0.5)
|
|
152
|
-
break;
|
|
153
|
-
remaining -= consumed;
|
|
154
|
-
active = nextActive;
|
|
155
170
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
return part;
|
|
161
|
-
const track = flexTracks[flexIndex++];
|
|
162
|
-
return `${Math.round(track.width)}px`;
|
|
163
|
-
})
|
|
164
|
-
.join(' ');
|
|
171
|
+
if (consumed <= 0.5)
|
|
172
|
+
break;
|
|
173
|
+
remaining -= consumed;
|
|
174
|
+
active = nextActive;
|
|
165
175
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
.join(' ');
|
|
176
|
+
const floatTrackTotal = tracks.reduce((sum, track) => sum + track.width, 0);
|
|
177
|
+
const targetTrackWidth = floatTrackTotal <= availableWidth - selectionWidth
|
|
178
|
+
? Math.floor(floatTrackTotal)
|
|
179
|
+
: Math.ceil(floatTrackTotal);
|
|
180
|
+
const widths = toIntegerTrackWidths(tracks, targetTrackWidth);
|
|
181
|
+
const totalWidth = selectionWidth + Object.values(widths).reduce((sum, width) => sum + width, 0);
|
|
182
|
+
return {
|
|
183
|
+
selectionWidth: hasSelection ? SELECTION_COLUMN_PX : undefined,
|
|
184
|
+
widths,
|
|
185
|
+
totalWidth,
|
|
186
|
+
};
|
|
178
187
|
}
|
|
@@ -101,15 +101,11 @@ body.dbc-app {
|
|
|
101
101
|
margin: 0; /* harmless on td, keeps parity with metaValue */
|
|
102
102
|
font-size: var(--font-size-sm);
|
|
103
103
|
color: var(--color-fg-default);
|
|
104
|
-
font-weight: var(--font-weight-
|
|
104
|
+
font-weight: var(--font-weight-default);
|
|
105
105
|
|
|
106
106
|
word-break: break-word;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
.dbc-table.dbc-table--plain-values td {
|
|
110
|
-
font-weight: var(--font-weight-default);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
109
|
/* Optional: baseline alignment closer to metaRow */
|
|
114
110
|
.dbc-table th,
|
|
115
111
|
.dbc-table td {
|
package/dist/styles/styles.css
CHANGED
|
@@ -101,15 +101,11 @@ body.dbc-app {
|
|
|
101
101
|
margin: 0; /* harmless on td, keeps parity with metaValue */
|
|
102
102
|
font-size: var(--font-size-sm);
|
|
103
103
|
color: var(--color-fg-default);
|
|
104
|
-
font-weight: var(--font-weight-
|
|
104
|
+
font-weight: var(--font-weight-default);
|
|
105
105
|
|
|
106
106
|
word-break: break-word;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
.dbc-table.dbc-table--plain-values td {
|
|
110
|
-
font-weight: var(--font-weight-default);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
109
|
/* Optional: baseline alignment closer to metaRow */
|
|
114
110
|
.dbc-table th,
|
|
115
111
|
.dbc-table td {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dbcdk/react-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.36",
|
|
4
4
|
"description": "Reusable React components for DBC projects",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"dev": "tsc -p tsconfig.build.json --watch",
|
|
49
49
|
"test": "jest",
|
|
50
50
|
"format": "prettier . --write",
|
|
51
|
+
"format:fix": "prettier . --write",
|
|
51
52
|
"lint": "eslint \"src/**/*.{ts,tsx}\" --max-warnings=0",
|
|
52
53
|
"lint:fix": "eslint \"src/**/*.{ts,tsx}\" --fix",
|
|
53
54
|
"storybook": "storybook dev -p 6006 --no-open",
|