@galaxy-io/dls 2.8.1 → 2.9.0
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/README.md +2 -2
- package/dist/brand/internal/svg/GalaxyAlchemyWordmarkSvg.d.ts +1 -1
- package/dist/brand/internal/svg/GalaxyAlchemyWordmarkSvg.js +34 -8
- package/dist/styles.css +1 -1
- package/dist/table/InfiniteSpreadsheet.js +1 -1
- package/dist/table/InfiniteTable.d.ts +7 -0
- package/dist/table/InfiniteTable.js +3 -2
- package/dist/table/TableCore.d.ts +4 -1
- package/dist/table/TableCore.js +28 -17
- package/dist/table/VirtualizedInfiniteTable.d.ts +7 -0
- package/dist/table/VirtualizedInfiniteTable.js +3 -2
- package/dist/table/useTableColumnLayout.d.ts +8 -2
- package/dist/table/useTableColumnLayout.js +36 -13
- package/package.json +1 -1
|
@@ -754,7 +754,7 @@ var InfiniteSpreadsheetInner = forwardRef(function InfiniteSpreadsheet(props, re
|
|
|
754
754
|
}), showAddRow && isMounted && /* @__PURE__ */ jsx(AddRow, {
|
|
755
755
|
role: "row",
|
|
756
756
|
"aria-rowindex": rowCount + 2,
|
|
757
|
-
className: "gx-TableCore-VIRTUAL_ROW_CSS-
|
|
757
|
+
className: "gx-TableCore-VIRTUAL_ROW_CSS-vw38cm1",
|
|
758
758
|
style: startStyle(totalSize),
|
|
759
759
|
children: /* @__PURE__ */ jsx(AddRowCell, {
|
|
760
760
|
role: "gridcell",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type AriaAttributes, type CSSProperties, type KeyboardEvent, type MouseEvent, type ReactElement, type ReactNode, type RefAttributes } from "react";
|
|
2
|
+
import type { Space } from "../theme/enums.js";
|
|
2
3
|
import type { TableColumn, TableColumnLayout, TableSort } from "./types.js";
|
|
3
4
|
/** Row rung of the table (canonical subset; the 1.x TableDensity members). */
|
|
4
5
|
export declare enum InfiniteTableSize {
|
|
@@ -97,6 +98,12 @@ export interface InfiniteTableProps<TData> extends AriaAttributes {
|
|
|
97
98
|
* @default false
|
|
98
99
|
*/
|
|
99
100
|
canCustomizeColumns?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Space between the ends of each row and its first and last cell, on top of the cells' own padding; rows, hairlines and row fills still run the full width.
|
|
103
|
+
* For a table flush with a panel's edges whose content should sit on the page's padding line (a `SMALL` table takes `4`: 12px cell padding plus 4 is the island's 16), instead of a padded wrapper, which would cut the hairlines short.
|
|
104
|
+
* @default 0
|
|
105
|
+
*/
|
|
106
|
+
inset?: Space;
|
|
100
107
|
/** Accessible name of the table. Use `aria-labelledby` instead when a visible heading names it. */
|
|
101
108
|
ariaLabel?: string;
|
|
102
109
|
/** DOM id on the root `<div>`. */
|
|
@@ -52,7 +52,7 @@ function splitPassthrough(rest) {
|
|
|
52
52
|
}
|
|
53
53
|
/** The read-only data table. */
|
|
54
54
|
var InfiniteTableInner = forwardRef(function InfiniteTable(props, ref) {
|
|
55
|
-
const { columns, data, getRowId, size: sizeProp, isLoading: isLoadingProp, error: errorProp, emptyState, onEndReached, onRowClick, activeRowId, rowActions, sort, defaultSort, onSortChange, isSelectable: isSelectableProp, value, defaultValue, onChange, renderExpandedRow, expandedIds, defaultExpandedIds, onExpandedIdsChange, columnLayout, defaultColumnLayout, onColumnLayoutChange, canResizeColumns: canResizeColumnsProp, canCustomizeColumns: canCustomizeColumnsProp, ariaLabel, id, className, style, ...rest } = props;
|
|
55
|
+
const { columns, data, getRowId, size: sizeProp, isLoading: isLoadingProp, error: errorProp, emptyState, onEndReached, onRowClick, activeRowId, rowActions, sort, defaultSort, onSortChange, isSelectable: isSelectableProp, value, defaultValue, onChange, renderExpandedRow, expandedIds, defaultExpandedIds, onExpandedIdsChange, columnLayout, defaultColumnLayout, onColumnLayoutChange, canResizeColumns: canResizeColumnsProp, canCustomizeColumns: canCustomizeColumnsProp, inset: insetProp, ariaLabel, id, className, style, ...rest } = props;
|
|
56
56
|
const error = errorProp === "" ? void 0 : errorProp;
|
|
57
57
|
const size = sizeProp ?? "MEDIUM";
|
|
58
58
|
const isLoading = isLoadingProp ?? false;
|
|
@@ -135,7 +135,8 @@ var InfiniteTableInner = forwardRef(function InfiniteTable(props, ref) {
|
|
|
135
135
|
canCustomizeColumns,
|
|
136
136
|
leadingCount,
|
|
137
137
|
hasTrailing: hasTrailingColumn,
|
|
138
|
-
syntheticWidthPx: metrics.rowHeightPx
|
|
138
|
+
syntheticWidthPx: metrics.rowHeightPx,
|
|
139
|
+
insetPx: insetProp ?? 0
|
|
139
140
|
});
|
|
140
141
|
const latest = {
|
|
141
142
|
columns,
|
|
@@ -66,7 +66,10 @@ export declare const TABLE_LARGE_METRICS: TableMetrics;
|
|
|
66
66
|
export declare const TableRow: import("@linaria/react").StyledComponent<import("react").ClassAttributes<HTMLTableRowElement> & import("react").HTMLAttributes<HTMLTableRowElement> & Record<never, unknown>>;
|
|
67
67
|
/** @internal A body or footer cell. */
|
|
68
68
|
export declare const TableCell: import("@linaria/react").StyledComponent<import("react").ClassAttributes<HTMLTableDataCellElement> & import("react").TdHTMLAttributes<HTMLTableDataCellElement> & Record<never, unknown>>;
|
|
69
|
-
/**
|
|
69
|
+
/**
|
|
70
|
+
* @internal Select, expand and row-actions columns: a square of the row height, content centered.
|
|
71
|
+
* At an end of the row it also holds the table's inset (`--gx-table-cell-edge`, `TABLE_INSET_CSS`).
|
|
72
|
+
*/
|
|
70
73
|
export declare const SYNTHETIC_CELL_CSS: import("@linaria/core").LinariaClassName;
|
|
71
74
|
/** @internal Alignment of a column's header and cells. */
|
|
72
75
|
export declare const COLUMN_ALIGN_TO_CSS_MAP: Record<TableColumnAlign, string>;
|
package/dist/table/TableCore.js
CHANGED
|
@@ -261,7 +261,10 @@ var ExpandedBody = /*#__PURE__*/ styled("div")({
|
|
|
261
261
|
* set by `useTableSurface`) so its sticky parts stay opaque.
|
|
262
262
|
*/
|
|
263
263
|
var SURFACE_ANCESTOR_CSS = "gx-TableCore-SURFACE_ANCESTOR_CSS-s18ghmlo";
|
|
264
|
-
/**
|
|
264
|
+
/**
|
|
265
|
+
* @internal Select, expand and row-actions columns: a square of the row height, content centered.
|
|
266
|
+
* At an end of the row it also holds the table's inset (`--gx-table-cell-edge`, `TABLE_INSET_CSS`).
|
|
267
|
+
*/
|
|
265
268
|
var SYNTHETIC_CELL_CSS = "gx-TableCore-SYNTHETIC_CELL_CSS-s1g01kh5";
|
|
266
269
|
/** @internal Alignment of a column's header and cells. */
|
|
267
270
|
var COLUMN_ALIGN_TO_CSS_MAP = {
|
|
@@ -297,6 +300,14 @@ var ROW_NO_BORDER_CSS = "gx-TableCore-ROW_NO_BORDER_CSS-rpsswqs";
|
|
|
297
300
|
*/
|
|
298
301
|
var ROWS_END_ABOVE_BOTTOM_CSS = "gx-TableCore-ROWS_END_ABOVE_BOTTOM_CSS-rwbqwrq";
|
|
299
302
|
/**
|
|
303
|
+
* `inset`: the first and last cell of every header, body and footer row pad their outer side by
|
|
304
|
+
* `--gx-table-inset` and are that much wider (data columns through `useTableColumnLayout`,
|
|
305
|
+
* synthetic ones through `--gx-table-cell-edge`). The rows keep the full width, so hairlines, hover
|
|
306
|
+
* and selected fills and the active bar still run edge to edge, and a pinned edge column keeps its
|
|
307
|
+
* inset while the table scrolls sideways.
|
|
308
|
+
*/
|
|
309
|
+
var TABLE_INSET_CSS = "gx-TableCore-TABLE_INSET_CSS-t1jxalmm";
|
|
310
|
+
/**
|
|
300
311
|
* Whether the table's rows end above the bottom of its scroll box. The last row drops its hairline
|
|
301
312
|
* only when it lands on the box's bottom edge, where the container's frame (or a scrolled table's
|
|
302
313
|
* end) already draws the line; above the edge, the hairline closes the list. Watches the scroll box
|
|
@@ -335,25 +346,25 @@ function useRowsEndAboveBottom(scrollRef, tableRef, isEnabled, bodyKey) {
|
|
|
335
346
|
return isAbove;
|
|
336
347
|
}
|
|
337
348
|
/** The last expanded panel: no bottom hairline. */
|
|
338
|
-
var EXPANDED_LAST_CSS = "gx-TableCore-EXPANDED_LAST_CSS-
|
|
349
|
+
var EXPANDED_LAST_CSS = "gx-TableCore-EXPANDED_LAST_CSS-e1fx3qlj";
|
|
339
350
|
/** The dragged header while reordering. 0.5 is a state, not a color token. */
|
|
340
|
-
var HEADER_DRAGGING_CSS = "gx-TableCore-HEADER_DRAGGING_CSS-
|
|
351
|
+
var HEADER_DRAGGING_CSS = "gx-TableCore-HEADER_DRAGGING_CSS-h2nd1ne";
|
|
341
352
|
/** The label wrapper grows when a trailing control (column actions) follows it. */
|
|
342
|
-
var LABEL_GROW_CSS = "gx-TableCore-LABEL_GROW_CSS-
|
|
343
|
-
var DROP_START_CSS = "gx-TableCore-DROP_START_CSS-
|
|
344
|
-
var DROP_END_CSS = "gx-TableCore-DROP_END_CSS-
|
|
353
|
+
var LABEL_GROW_CSS = "gx-TableCore-LABEL_GROW_CSS-larqcf0";
|
|
354
|
+
var DROP_START_CSS = "gx-TableCore-DROP_START_CSS-d132cb1v";
|
|
355
|
+
var DROP_END_CSS = "gx-TableCore-DROP_END_CSS-d1vn45v6";
|
|
345
356
|
/** Shows on hover, while dragged and on keyboard focus; straddles the column edge. */
|
|
346
|
-
var COLUMN_RESIZE_HANDLE_CSS = "gx-TableCore-COLUMN_RESIZE_HANDLE_CSS-
|
|
357
|
+
var COLUMN_RESIZE_HANDLE_CSS = "gx-TableCore-COLUMN_RESIZE_HANDLE_CSS-c14za3v2";
|
|
347
358
|
/** Hovering a header cell reveals its resize handle. */
|
|
348
|
-
var HEADER_HOVER_CSS = "gx-TableCore-HEADER_HOVER_CSS-
|
|
359
|
+
var HEADER_HOVER_CSS = "gx-TableCore-HEADER_HOVER_CSS-h1w0t3ir";
|
|
349
360
|
/** The expand caret button: a square of its rung. */
|
|
350
|
-
var EXPAND_BUTTON_CSS = "gx-TableCore-EXPAND_BUTTON_CSS-
|
|
361
|
+
var EXPAND_BUTTON_CSS = "gx-TableCore-EXPAND_BUTTON_CSS-eb9km4t";
|
|
351
362
|
/** @internal A virtual body: as tall as every row, which are positioned inside it. */
|
|
352
|
-
var VIRTUAL_BODY_CSS = "gx-TableCore-VIRTUAL_BODY_CSS-
|
|
363
|
+
var VIRTUAL_BODY_CSS = "gx-TableCore-VIRTUAL_BODY_CSS-v1emgwoo";
|
|
353
364
|
/** @internal A virtual row, placed at `--gx-table-row-start`. */
|
|
354
|
-
var VIRTUAL_ROW_CSS = "gx-TableCore-VIRTUAL_ROW_CSS-
|
|
365
|
+
var VIRTUAL_ROW_CSS = "gx-TableCore-VIRTUAL_ROW_CSS-vw38cm1";
|
|
355
366
|
/** @internal Default cells and footer strings: shrink to truncate. */
|
|
356
|
-
var CELL_TEXT_CSS = "gx-TableCore-CELL_TEXT_CSS-
|
|
367
|
+
var CELL_TEXT_CSS = "gx-TableCore-CELL_TEXT_CSS-c1n5u17i";
|
|
357
368
|
/** "Oct 3, 2026": the DateInput default. */
|
|
358
369
|
var DATE_FORMAT_OPTIONS = { dateStyle: "medium" };
|
|
359
370
|
/** @internal The default cell renderer: one truncating line of formatted text. */
|
|
@@ -627,9 +638,9 @@ var TableBodyRow = memo(function TableBodyRow({ row, rowIndex, rowId, columns, m
|
|
|
627
638
|
]
|
|
628
639
|
});
|
|
629
640
|
});
|
|
630
|
-
/** The pinned offset of the k-th synthetic column from its edge. */
|
|
641
|
+
/** The pinned offset of the k-th synthetic column from its edge (past the inset of the edge cell before it). */
|
|
631
642
|
function syntheticOffset(index, metrics) {
|
|
632
|
-
return { "--gx-table-cell-offset":
|
|
643
|
+
return { "--gx-table-cell-offset": index === 0 ? "0px" : `calc(${index * metrics.rowHeightPx}px + var(--gx-table-inset, 0px))` };
|
|
633
644
|
}
|
|
634
645
|
/** @internal A placeholder row: a text skeleton in each data cell, synthetic cells empty. */
|
|
635
646
|
function TableSkeletonRow({ columns, metrics, leadingCount, hasTrailingColumn, isBorderless, ariaRowIndex, pending, className, style }) {
|
|
@@ -672,7 +683,7 @@ function TableSkeletonRow({ columns, metrics, leadingCount, hasTrailingColumn, i
|
|
|
672
683
|
}
|
|
673
684
|
/** @internal An expanded row's panel, under its row, as wide as the visible area. */
|
|
674
685
|
function TableExpandedRow({ panelId, colSpan, gutterPx, isLast, children }) {
|
|
675
|
-
const variables = { "--gx-table-expanded-gutter":
|
|
686
|
+
const variables = { "--gx-table-expanded-gutter": `calc(${gutterPx}px + var(--gx-table-inset, 0px))` };
|
|
676
687
|
return /* @__PURE__ */ jsx(ExpandedRowElement, {
|
|
677
688
|
role: "row",
|
|
678
689
|
className: cx(isLast && EXPANDED_LAST_CSS),
|
|
@@ -989,7 +1000,7 @@ function TableFrame({ metrics, columnLayout, leadingHeaders, trailingHeader, has
|
|
|
989
1000
|
return /* @__PURE__ */ jsxs(Root, {
|
|
990
1001
|
...rootProps,
|
|
991
1002
|
ref: mergedRootRef,
|
|
992
|
-
className: cx(metrics.css, surface !== null && SURFACE_ANCESTOR_CSS, className),
|
|
1003
|
+
className: cx(metrics.css, surface !== null && SURFACE_ANCESTOR_CSS, columnLayout.variables["--gx-table-inset"] !== void 0 && TABLE_INSET_CSS, className),
|
|
993
1004
|
style: {
|
|
994
1005
|
...variables,
|
|
995
1006
|
...style
|
|
@@ -1094,7 +1105,7 @@ function TableFrame({ metrics, columnLayout, leadingHeaders, trailingHeader, has
|
|
|
1094
1105
|
size: metrics.textSize,
|
|
1095
1106
|
weight: TextWeight.MEDIUM,
|
|
1096
1107
|
lineClamp: 1,
|
|
1097
|
-
className: "gx-TableCore-CELL_TEXT_CSS-
|
|
1108
|
+
className: "gx-TableCore-CELL_TEXT_CSS-c1n5u17i",
|
|
1098
1109
|
children: column.footer
|
|
1099
1110
|
}) : column.footer
|
|
1100
1111
|
}, column.id)),
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* never needs `@tanstack/react-table`.
|
|
13
13
|
*/
|
|
14
14
|
import { type AriaAttributes, type CSSProperties, type KeyboardEvent, type MouseEvent, type ReactElement, type ReactNode, type RefAttributes } from "react";
|
|
15
|
+
import type { Space } from "../theme/enums.js";
|
|
15
16
|
import type { TableColumn, TableColumnLayout, TableSort } from "./types.js";
|
|
16
17
|
/** Row rung of the table (canonical subset; the 1.x TableDensity members). Same rows as InfiniteTableSize. */
|
|
17
18
|
export declare enum VirtualizedInfiniteTableSize {
|
|
@@ -87,6 +88,12 @@ export interface VirtualizedInfiniteTableProps<TData> extends AriaAttributes {
|
|
|
87
88
|
* @default false
|
|
88
89
|
*/
|
|
89
90
|
canCustomizeColumns?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Space between the ends of each row and its first and last cell, on top of the cells' own padding; rows, hairlines and row fills still run the full width.
|
|
93
|
+
* For a table flush with a panel's edges whose content should sit on the page's padding line (a `SMALL` table takes `4`: 12px cell padding plus 4 is the island's 16), instead of a padded wrapper, which would cut the hairlines short.
|
|
94
|
+
* @default 0
|
|
95
|
+
*/
|
|
96
|
+
inset?: Space;
|
|
90
97
|
/** Accessible name of the table. Use `aria-labelledby` instead when a visible heading names it. */
|
|
91
98
|
ariaLabel?: string;
|
|
92
99
|
/** DOM id on the root `<div>`. */
|
|
@@ -53,7 +53,7 @@ function sortAnnouncement(sort, columns) {
|
|
|
53
53
|
}
|
|
54
54
|
/** InfiniteTable with a virtual body, for tens of thousands of rows. */
|
|
55
55
|
var VirtualizedInfiniteTableInner = forwardRef(function VirtualizedInfiniteTable(props, ref) {
|
|
56
|
-
const { columns, totalRowCount, getRowData, getRowId, size: sizeProp, isLoading: isLoadingProp, error: errorProp, emptyState, onEndReached, onRowClick, activeRowId, rowActions, sort, defaultSort, onSortChange, columnLayout, defaultColumnLayout, onColumnLayoutChange, canResizeColumns: canResizeColumnsProp, canCustomizeColumns: canCustomizeColumnsProp, ariaLabel, id, className, style, ...rest } = props;
|
|
56
|
+
const { columns, totalRowCount, getRowData, getRowId, size: sizeProp, isLoading: isLoadingProp, error: errorProp, emptyState, onEndReached, onRowClick, activeRowId, rowActions, sort, defaultSort, onSortChange, columnLayout, defaultColumnLayout, onColumnLayoutChange, canResizeColumns: canResizeColumnsProp, canCustomizeColumns: canCustomizeColumnsProp, inset: insetProp, ariaLabel, id, className, style, ...rest } = props;
|
|
57
57
|
const error = errorProp === "" ? void 0 : errorProp;
|
|
58
58
|
const size = sizeProp ?? "MEDIUM";
|
|
59
59
|
const isLoading = isLoadingProp ?? false;
|
|
@@ -95,7 +95,8 @@ var VirtualizedInfiniteTableInner = forwardRef(function VirtualizedInfiniteTable
|
|
|
95
95
|
canCustomizeColumns,
|
|
96
96
|
leadingCount: 0,
|
|
97
97
|
hasTrailing: hasTrailingColumn,
|
|
98
|
-
syntheticWidthPx: metrics.rowHeightPx
|
|
98
|
+
syntheticWidthPx: metrics.rowHeightPx,
|
|
99
|
+
insetPx: insetProp ?? 0
|
|
99
100
|
});
|
|
100
101
|
const visibleColumns = layout.visibleColumns;
|
|
101
102
|
const hasFooter = visibleColumns.some(({ column }) => column.footer !== void 0 && column.footer !== null);
|
|
@@ -63,6 +63,12 @@ export interface UseTableColumnLayoutOptions<TData> {
|
|
|
63
63
|
hasTrailing: boolean;
|
|
64
64
|
/** Width of a synthetic column, in pixels (the row height). */
|
|
65
65
|
syntheticWidthPx: number;
|
|
66
|
+
/**
|
|
67
|
+
* The table's `inset`, in pixels: added to the first and last cell of every row (padding and
|
|
68
|
+
* width), so the content moves in while rows, fills and hairlines keep the full width.
|
|
69
|
+
* @default 0
|
|
70
|
+
*/
|
|
71
|
+
insetPx?: number;
|
|
66
72
|
}
|
|
67
73
|
/** @internal What `useTableColumnLayout` returns. */
|
|
68
74
|
export interface TableColumnLayoutResult<TData> {
|
|
@@ -72,7 +78,7 @@ export interface TableColumnLayoutResult<TData> {
|
|
|
72
78
|
visibleColumns: TableResolvedColumn<TData>[];
|
|
73
79
|
/** Every column in display order with its visibility, for the Columns menu. */
|
|
74
80
|
menuEntries: TableColumnsMenuEntry[];
|
|
75
|
-
/** Custom properties for the table root: per-column flex, min, max and pinned offset,
|
|
81
|
+
/** Custom properties for the table root: per-column flex, min, max and pinned offset, the table min width and `--gx-table-inset`. */
|
|
76
82
|
variables: Record<`--gx-${string}`, string>;
|
|
77
83
|
/** Width of a resizable column for the resize handle: its resolved or measured width. */
|
|
78
84
|
getColumnWidth: (id: string) => number;
|
|
@@ -90,4 +96,4 @@ export interface TableColumnLayoutResult<TData> {
|
|
|
90
96
|
resetLayout: () => void;
|
|
91
97
|
}
|
|
92
98
|
/** Column arrangement state and the column custom properties. */
|
|
93
|
-
export declare function useTableColumnLayout<TData>({ columns, columnLayout, defaultColumnLayout, onColumnLayoutChange, canResizeColumns, canCustomizeColumns, leadingCount, hasTrailing, syntheticWidthPx, }: UseTableColumnLayoutOptions<TData>): TableColumnLayoutResult<TData>;
|
|
99
|
+
export declare function useTableColumnLayout<TData>({ columns, columnLayout, defaultColumnLayout, onColumnLayoutChange, canResizeColumns, canCustomizeColumns, leadingCount, hasTrailing, syntheticWidthPx, insetPx, }: UseTableColumnLayoutOptions<TData>): TableColumnLayoutResult<TData>;
|
|
@@ -33,7 +33,7 @@ function pinGroup(pin) {
|
|
|
33
33
|
return 1;
|
|
34
34
|
}
|
|
35
35
|
/** Column arrangement state and the column custom properties. */
|
|
36
|
-
function useTableColumnLayout({ columns, columnLayout, defaultColumnLayout, onColumnLayoutChange, canResizeColumns, canCustomizeColumns, leadingCount, hasTrailing, syntheticWidthPx }) {
|
|
36
|
+
function useTableColumnLayout({ columns, columnLayout, defaultColumnLayout, onColumnLayoutChange, canResizeColumns, canCustomizeColumns, leadingCount, hasTrailing, syntheticWidthPx, insetPx = 0 }) {
|
|
37
37
|
const [layout, setLayout] = useControlledState({
|
|
38
38
|
value: columnLayout,
|
|
39
39
|
defaultValue: defaultColumnLayout,
|
|
@@ -100,44 +100,55 @@ function useTableColumnLayout({ columns, columnLayout, defaultColumnLayout, onCo
|
|
|
100
100
|
console.warn(`[@galaxy-io/dls] Table column "${column.id}" is pinned without a \`width\`; it falls back to 150px.`);
|
|
101
101
|
}
|
|
102
102
|
}, [visibleColumns]);
|
|
103
|
+
/** The inset a column's cells carry: `insetPx` at each end of the row it sits on. */
|
|
104
|
+
const edgeInsetFor = useCallback((position) => ((leadingCount === 0 && position === 0 ? 1 : 0) + (!hasTrailing && position === visibleColumns.length - 1 ? 1 : 0)) * insetPx, [
|
|
105
|
+
leadingCount,
|
|
106
|
+
hasTrailing,
|
|
107
|
+
visibleColumns.length,
|
|
108
|
+
insetPx
|
|
109
|
+
]);
|
|
103
110
|
const variables = useMemo(() => {
|
|
104
111
|
const result = {};
|
|
105
|
-
let minTotal = (leadingCount + (hasTrailing ? 1 : 0)) * syntheticWidthPx;
|
|
106
|
-
let leftOffset = leadingCount * syntheticWidthPx;
|
|
112
|
+
let minTotal = (leadingCount + (hasTrailing ? 1 : 0)) * syntheticWidthPx + 2 * insetPx;
|
|
113
|
+
let leftOffset = leadingCount * syntheticWidthPx + (leadingCount > 0 ? insetPx : 0);
|
|
107
114
|
const rightColumns = [];
|
|
108
115
|
for (const resolved of visibleColumns) {
|
|
109
116
|
const { column, position, minWidth, pin } = resolved;
|
|
110
117
|
const width = resolvedWidths.get(column.id);
|
|
118
|
+
const edge = edgeInsetFor(position);
|
|
111
119
|
const prefix = `--gx-table-col-${position}`;
|
|
112
120
|
if (width !== void 0) {
|
|
113
|
-
result[`${prefix}-flex`] = `0 0 ${width}px`;
|
|
114
|
-
result[`${prefix}-min`] = `${width}px`;
|
|
115
|
-
result[`${prefix}-max`] = `${width}px`;
|
|
121
|
+
result[`${prefix}-flex`] = `0 0 ${width + edge}px`;
|
|
122
|
+
result[`${prefix}-min`] = `${width + edge}px`;
|
|
123
|
+
result[`${prefix}-max`] = `${width + edge}px`;
|
|
116
124
|
minTotal += width;
|
|
117
125
|
} else {
|
|
118
|
-
result[`${prefix}-flex`] =
|
|
119
|
-
result[`${prefix}-min`] = `${minWidth}px`;
|
|
126
|
+
result[`${prefix}-flex`] = `1 1 ${edge}px`;
|
|
127
|
+
result[`${prefix}-min`] = `${minWidth + edge}px`;
|
|
120
128
|
result[`${prefix}-max`] = "none";
|
|
121
129
|
minTotal += minWidth;
|
|
122
130
|
}
|
|
123
131
|
if (pin === Side.LEFT) {
|
|
124
132
|
result[`${prefix}-offset`] = `${leftOffset}px`;
|
|
125
|
-
leftOffset += width ?? 150;
|
|
133
|
+
leftOffset += (width ?? 150) + edge;
|
|
126
134
|
} else if (pin === Side.RIGHT) rightColumns.push(resolved);
|
|
127
135
|
}
|
|
128
|
-
let rightOffset = hasTrailing ? syntheticWidthPx : 0;
|
|
136
|
+
let rightOffset = hasTrailing ? syntheticWidthPx + insetPx : 0;
|
|
129
137
|
for (const { column, position } of [...rightColumns].reverse()) {
|
|
130
138
|
result[`--gx-table-col-${position}-offset`] = `${rightOffset}px`;
|
|
131
|
-
rightOffset += resolvedWidths.get(column.id) ?? 150;
|
|
139
|
+
rightOffset += (resolvedWidths.get(column.id) ?? 150) + edgeInsetFor(position);
|
|
132
140
|
}
|
|
133
141
|
result["--gx-table-min-width"] = `${minTotal}px`;
|
|
142
|
+
if (insetPx > 0) result["--gx-table-inset"] = `${insetPx}px`;
|
|
134
143
|
return result;
|
|
135
144
|
}, [
|
|
136
145
|
visibleColumns,
|
|
137
146
|
resolvedWidths,
|
|
138
147
|
leadingCount,
|
|
139
148
|
hasTrailing,
|
|
140
|
-
syntheticWidthPx
|
|
149
|
+
syntheticWidthPx,
|
|
150
|
+
insetPx,
|
|
151
|
+
edgeInsetFor
|
|
141
152
|
]);
|
|
142
153
|
const menuEntries = useMemo(() => {
|
|
143
154
|
const hidden = new Set(hiddenKey === "" ? [] : hiddenKey.split("\0"));
|
|
@@ -190,7 +201,19 @@ function useTableColumnLayout({ columns, columnLayout, defaultColumnLayout, onCo
|
|
|
190
201
|
observerRef.current.observe(element);
|
|
191
202
|
}, [measure]);
|
|
192
203
|
useEffect(() => () => observerRef.current?.disconnect(), []);
|
|
193
|
-
const getColumnWidth = useCallback((id) =>
|
|
204
|
+
const getColumnWidth = useCallback((id) => {
|
|
205
|
+
const resolved = resolvedWidths.get(id);
|
|
206
|
+
if (resolved !== void 0) return resolved;
|
|
207
|
+
const width = measured[id];
|
|
208
|
+
if (width === void 0) return 60;
|
|
209
|
+
const position = visibleColumns.findIndex(({ column }) => column.id === id);
|
|
210
|
+
return position === -1 ? width : width - edgeInsetFor(position);
|
|
211
|
+
}, [
|
|
212
|
+
resolvedWidths,
|
|
213
|
+
measured,
|
|
214
|
+
visibleColumns,
|
|
215
|
+
edgeInsetFor
|
|
216
|
+
]);
|
|
194
217
|
const resizeColumn = useCallback((id, width) => {
|
|
195
218
|
const current = layoutRef.current;
|
|
196
219
|
setLayout({
|