@wonderflow/react-components 14.5.0 → 16.0.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/dist/components/table/table-cell/index.d.ts +1 -1
- package/dist/components/table/table-cell/index.d.ts.map +1 -1
- package/dist/components/table/table-cell/index.js +2 -2
- package/dist/components/table/table-cell/table-cell.d.ts +1 -0
- package/dist/components/table/table-cell/table-cell.d.ts.map +1 -1
- package/dist/components/table/table-cell/table-cell.js +3 -2
- package/dist/components/table/table-checkbox/table-checkbox.module.css +1 -1
- package/dist/components/table/table-controls/table-controls.test.js +10 -9
- package/dist/components/table/table-controls/toggle-columns.js +7 -7
- package/dist/components/table/table-row/index.d.ts +1 -1
- package/dist/components/table/table-row/index.d.ts.map +1 -1
- package/dist/components/table/table-row/index.js +2 -2
- package/dist/components/table/table-row/table-row.d.ts +14 -3
- package/dist/components/table/table-row/table-row.d.ts.map +1 -1
- package/dist/components/table/table-row/table-row.js +29 -22
- package/dist/components/table/table-row/table-row.test.js +1 -1
- package/dist/components/table/table.d.ts +25 -4
- package/dist/components/table/table.d.ts.map +1 -1
- package/dist/components/table/table.js +177 -92
- package/dist/components/table/table.stories.d.ts +17 -16
- package/dist/components/table/table.stories.d.ts.map +1 -1
- package/dist/components/table/table.stories.js +20 -0
- package/dist/components/table/table.test.d.ts +1 -1
- package/dist/components/table/table.test.d.ts.map +1 -1
- package/dist/components/table/table.test.js +197 -1
- package/dist/components/table/to-tanstack-columns.d.ts +4 -0
- package/dist/components/table/to-tanstack-columns.d.ts.map +1 -0
- package/dist/components/table/to-tanstack-columns.js +62 -0
- package/dist/components/table/to-tanstack-columns.test.d.ts +2 -0
- package/dist/components/table/to-tanstack-columns.test.d.ts.map +1 -0
- package/dist/components/table/to-tanstack-columns.test.js +93 -0
- package/dist/components/table/types.d.ts +55 -5
- package/dist/components/table/types.d.ts.map +1 -1
- package/dist/components/table/types.js +1 -1
- package/package.json +5 -6
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { TableCell } from './table-cell';
|
|
1
|
+
export { MemoTableCell, TableCell } from './table-cell';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-cell/index.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-cell/index.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2022-
|
|
2
|
+
* Copyright 2022-2026 Wonderflow Design Team
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -14,4 +14,4 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
'use client';
|
|
17
|
-
export { TableCell } from './table-cell';
|
|
17
|
+
export { MemoTableCell, TableCell } from './table-cell';
|
|
@@ -10,5 +10,6 @@ declare type TableCellProps = {
|
|
|
10
10
|
};
|
|
11
11
|
declare type PolymorphicCell = Polymorphic.ForwardRefComponent<'td', TableCellProps>;
|
|
12
12
|
export declare const TableCell: PolymorphicCell;
|
|
13
|
+
export declare const MemoTableCell: PolymorphicCell;
|
|
13
14
|
export {};
|
|
14
15
|
//# sourceMappingURL=table-cell.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-cell.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-cell/table-cell.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAE,WAAW,EAAU,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,aAAK,cAAc,GAAG;IACpB,SAAS,CAAC,EAAE,mBAAmB,CAAC,aAAa,CAAC,CAAC;IAC/C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACrC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB,CAAA;AAED,aAAK,eAAe,GAAG,WAAW,CAAC,mBAAmB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;AAE7E,eAAO,MAAM,SAAS,iBA8CD,CAAC"}
|
|
1
|
+
{"version":3,"file":"table-cell.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-cell/table-cell.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAE,WAAW,EAAU,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,aAAK,cAAc,GAAG;IACpB,SAAS,CAAC,EAAE,mBAAmB,CAAC,aAAa,CAAC,CAAC;IAC/C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACrC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB,CAAA;AAED,aAAK,eAAe,GAAG,WAAW,CAAC,mBAAmB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;AAE7E,eAAO,MAAM,SAAS,iBA8CD,CAAC;AAEtB,eAAO,MAAM,aAAa,iBAAsC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright 2022-
|
|
3
|
+
* Copyright 2022-2026 Wonderflow Design Team
|
|
4
4
|
*
|
|
5
5
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
6
|
* you may not use this file except in compliance with the License.
|
|
@@ -15,7 +15,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import clsx from 'clsx';
|
|
18
|
-
import { forwardRef } from 'react';
|
|
18
|
+
import { forwardRef, memo } from 'react';
|
|
19
19
|
import { Symbol } from '../../..';
|
|
20
20
|
import * as styles from './table-cell.module.css';
|
|
21
21
|
export const TableCell = forwardRef(({ children, className, collapsed, isSorted, align = 'start', style, isSortedDesc, as: Wrapper = 'td', padding = true, width, ...otherProps }, forwardedRef) => {
|
|
@@ -31,3 +31,4 @@ export const TableCell = forwardRef(({ children, className, collapsed, isSorted,
|
|
|
31
31
|
userSelect: Wrapper === 'td' ? undefined : 'none',
|
|
32
32
|
}, ...otherProps, children: [children, isSorted && (_jsx(Symbol, { dimension: 12, className: styles.HeadCellIcon, fill: "var(--highlight-red-foreground)", source: isSortedDesc ? 'bars-sort-down' : 'bars-sort-up' }))] }));
|
|
33
33
|
});
|
|
34
|
+
export const MemoTableCell = memo(TableCell);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer components{.TableCheckbox{display:block}}
|
|
1
|
+
@layer components{.TableCheckbox{display:block}.TableCheckbox [data-inner-element=Checkbox]{-webkit-backdrop-filter:none;backdrop-filter:none}.TableCheckbox [data-inner-element=Checkbox]:not(:checked):not(:indeterminate){background-color:var(--global-background)}.TableCheckbox [data-inner-element=Checkbox]:active:not(:checked):not(:indeterminate){background-color:var(--dimmed-1)}}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { fireEvent, render } from '@testing-library/react';
|
|
3
3
|
import { ToggleColumnsControl } from './toggle-columns';
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const makeColumn = (id) => ({
|
|
5
|
+
id,
|
|
6
|
+
columnDef: {
|
|
7
|
+
id,
|
|
8
|
+
header: id,
|
|
9
|
+
meta: { isToggable: false },
|
|
8
10
|
},
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
];
|
|
11
|
+
getIsVisible: () => true,
|
|
12
|
+
toggleVisibility: jest.fn(),
|
|
13
|
+
});
|
|
14
|
+
const COLUMNS = [makeColumn('firstName'), makeColumn('lastName')];
|
|
14
15
|
describe('<ToggleColumnsControl>', () => {
|
|
15
16
|
test('it should render properly', () => {
|
|
16
17
|
const { container, getByTestId } = render(_jsx(ToggleColumnsControl, { columns: COLUMNS, visibleColumns: COLUMNS }));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright 2022-
|
|
3
|
+
* Copyright 2022-2026 Wonderflow Design Team
|
|
4
4
|
*
|
|
5
5
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
6
|
* you may not use this file except in compliance with the License.
|
|
@@ -18,21 +18,21 @@ import { useCallback, useMemo } from 'react';
|
|
|
18
18
|
import { Button, Menu, Popover } from '../../..';
|
|
19
19
|
export const ToggleColumnsControl = ({ columns, visibleColumns, }) => {
|
|
20
20
|
const hasSomeVisibleColums = useMemo(() => visibleColumns.length !== 0, [visibleColumns]);
|
|
21
|
-
const filteredColumns = useMemo(() => columns.filter(col => !col.isToggable), [columns]);
|
|
21
|
+
const filteredColumns = useMemo(() => columns.filter(col => !col.columnDef.meta?.isToggable), [columns]);
|
|
22
22
|
const handleToggleAll = useCallback(() => {
|
|
23
23
|
/**
|
|
24
24
|
* If there are visible columns (excluding artificial ones),
|
|
25
|
-
* hide them all by calling `
|
|
25
|
+
* hide them all by calling `toggleVisibility(false)` for each column
|
|
26
26
|
*/
|
|
27
27
|
if (hasSomeVisibleColums) {
|
|
28
|
-
visibleColumns.forEach(col => col.
|
|
28
|
+
visibleColumns.forEach(col => col.toggleVisibility(false));
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* If there are no visible columns (excluding artificial ones), call
|
|
33
|
-
*
|
|
33
|
+
* toggleVisibility(true) for each column
|
|
34
34
|
*/
|
|
35
|
-
filteredColumns.forEach(col => col.
|
|
35
|
+
filteredColumns.forEach(col => col.toggleVisibility(true));
|
|
36
36
|
}, [hasSomeVisibleColums, filteredColumns, visibleColumns]);
|
|
37
|
-
return (_jsx(Popover, { placement: "bottom-start", trigger: _jsx(Button, { kind: "secondary", children: "Toggle columns" }), children: _jsxs(Menu, { maxHeight: "350px", children: [_jsx(Menu.ItemCheckbox, { value: "toggle-all", onClick: () => handleToggleAll(), checked: true, icon: visibleColumns.length === 0 ? 'check' : 'minus', "data-testid": "ColumnCheckbox", children: "Toggle All" }),
|
|
37
|
+
return (_jsx(Popover, { placement: "bottom-start", trigger: _jsx(Button, { kind: "secondary", children: "Toggle columns" }), children: _jsxs(Menu, { maxHeight: "350px", children: [_jsx(Menu.ItemCheckbox, { value: "toggle-all", onClick: () => handleToggleAll(), checked: true, icon: visibleColumns.length === 0 ? 'check' : 'minus', "data-testid": "ColumnCheckbox", children: "Toggle All" }), filteredColumns.map((column, i) => (_jsx(Menu.ItemCheckbox, { value: column.id, autoFocus: i === 0, checked: column.getIsVisible(), icon: column.getIsVisible() ? 'check' : undefined, onClick: () => column.toggleVisibility(), "data-testid": "ColumnCheckboxInner", children: column.columnDef.header }, column.id)))] }) }));
|
|
38
38
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { TableRow } from './table-row';
|
|
1
|
+
export { MemoTableRow, TableRow } from './table-row';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-row/index.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-row/index.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2022-
|
|
2
|
+
* Copyright 2022-2026 Wonderflow Design Team
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -14,4 +14,4 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
'use client';
|
|
17
|
-
export { TableRow } from './table-row';
|
|
17
|
+
export { MemoTableRow, TableRow } from './table-row';
|
|
@@ -1,10 +1,21 @@
|
|
|
1
|
+
import { Row } from '@tanstack/react-table';
|
|
1
2
|
import { PropsWithChildren } from 'react';
|
|
2
|
-
import { IdType, Row } from 'react-table';
|
|
3
3
|
declare type TableRowProps<T extends Record<string, unknown>> = PropsWithChildren<PropsWithClass<{
|
|
4
4
|
expanded?: boolean;
|
|
5
5
|
rowData?: Row<T>;
|
|
6
|
-
|
|
6
|
+
expandedRowsKey?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Cheap, stable signature (e.g. `${row.id}:${isSelected}:${isExpanded}`)
|
|
9
|
+
* computed by the parent `Table`. `@tanstack/react-table` returns new
|
|
10
|
+
* `row`/cell objects (and new rendered cell elements) on most renders,
|
|
11
|
+
* even for rows whose own state did not change, which defeats
|
|
12
|
+
* `React.memo`'s default shallow comparison. `MemoTableRow` uses this
|
|
13
|
+
* signature instead of `rowData`/`children` identity to decide whether a
|
|
14
|
+
* row actually needs to re-render.
|
|
15
|
+
*/
|
|
16
|
+
rowSignature?: string;
|
|
7
17
|
}>>;
|
|
8
|
-
export declare const TableRow: <T extends Record<string, unknown>>({ children, className, expanded, rowData,
|
|
18
|
+
export declare const TableRow: <T extends Record<string, unknown>>({ children, className, expanded, rowData, expandedRowsKey, rowSignature: _rowSignature, ...otherProps }: TableRowProps<T>) => JSX.Element;
|
|
19
|
+
export declare const MemoTableRow: <T extends Record<string, unknown>>({ children, className, expanded, rowData, expandedRowsKey, rowSignature: _rowSignature, ...otherProps }: TableRowProps<T>) => JSX.Element;
|
|
9
20
|
export {};
|
|
10
21
|
//# sourceMappingURL=table-row.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-row.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-row/table-row.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"table-row.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-row/table-row.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAQ,iBAAiB,EAAW,MAAM,OAAO,CAAC;AAIzD,aAAK,aAAa,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,iBAAiB,CAAC,cAAc,CAAC;IACvF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;;OAQG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC,CAAC,CAAA;AAEH,eAAO,MAAM,QAAQ,+KAgCpB,CAAC;AAwBF,eAAO,MAAM,YAAY,+KAAsD,CAAC"}
|
|
@@ -1,30 +1,37 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2022-2023 Wonderflow Design Team
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
2
|
import clsx from 'clsx';
|
|
18
|
-
import { useMemo } from 'react';
|
|
3
|
+
import { memo, useMemo } from 'react';
|
|
19
4
|
import * as styles from './table-row.module.css';
|
|
20
|
-
export const TableRow = ({ children, className, expanded, rowData,
|
|
5
|
+
export const TableRow = ({ children, className, expanded, rowData, expandedRowsKey, rowSignature: _rowSignature, ...otherProps }) => {
|
|
21
6
|
const shouldHighlightRow = useMemo(() => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
7
|
+
if (!expandedRowsKey || !rowData)
|
|
8
|
+
return false;
|
|
9
|
+
const [currentParentRowId] = (/.*(?=\.)/.exec(rowData.id)) ?? [];
|
|
10
|
+
if (!currentParentRowId)
|
|
11
|
+
return false;
|
|
12
|
+
const expandedIds = expandedRowsKey.split('|');
|
|
13
|
+
const isHighlight = expandedIds.includes(currentParentRowId) && expandedIds.every((rowId) => {
|
|
14
|
+
const [parentRowMatch] = (/.*(?=\.)/.exec(rowId)) ?? [];
|
|
25
15
|
return parentRowMatch !== currentParentRowId;
|
|
26
16
|
});
|
|
27
|
-
return
|
|
28
|
-
}, [
|
|
17
|
+
return isHighlight;
|
|
18
|
+
}, [expandedRowsKey, rowData]);
|
|
29
19
|
return (_jsx("tr", { className: clsx(styles.TableRow, className), "data-table-row-expanded": expanded, "data-table-row-highlight": shouldHighlightRow || undefined, ...otherProps, children: children }));
|
|
30
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* `@tanstack/react-table` recomputes the `rows` array (new object refs +
|
|
23
|
+
* new rendered cell elements per row) on every selection/expansion change,
|
|
24
|
+
* even for rows that did not actually change. That defeats `React.memo`'s
|
|
25
|
+
* default shallow comparison, so clicking one checkbox re-renders all 500
|
|
26
|
+
* rows instead of the 1 or 2 that changed — the visible lag on
|
|
27
|
+
* select/select-all.
|
|
28
|
+
*
|
|
29
|
+
* Comparing on `rowSignature` (and the other primitive props) instead of
|
|
30
|
+
* `rowData`/`children` identity lets a row skip re-rendering when nothing
|
|
31
|
+
* that affects its output actually changed.
|
|
32
|
+
*/
|
|
33
|
+
const areRowPropsEqual = (prevProps, nextProps) => (prevProps.rowSignature === nextProps.rowSignature
|
|
34
|
+
&& prevProps.expandedRowsKey === nextProps.expandedRowsKey
|
|
35
|
+
&& prevProps.expanded === nextProps.expanded
|
|
36
|
+
&& prevProps.className === nextProps.className);
|
|
37
|
+
export const MemoTableRow = memo(TableRow, areRowPropsEqual);
|
|
@@ -3,7 +3,7 @@ import { render } from '@testing-library/react';
|
|
|
3
3
|
import { TableRow } from './table-row';
|
|
4
4
|
describe('<TableRow>', () => {
|
|
5
5
|
test('it should render properly', () => {
|
|
6
|
-
const { container } = render(_jsx("table", { children: _jsx("tbody", { children: _jsx(TableRow, { rowData: undefined,
|
|
6
|
+
const { container } = render(_jsx("table", { children: _jsx("tbody", { children: _jsx(TableRow, { rowData: undefined, expandedRowsKey: "test" }) }) }));
|
|
7
7
|
expect(container).not.toBeNull();
|
|
8
8
|
});
|
|
9
9
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { Row } from '@tanstack/react-table';
|
|
1
2
|
import { ComponentType, ReactNode } from 'react';
|
|
2
|
-
import { IdType, Row, SortingRule } from 'react-table';
|
|
3
3
|
import { TableHeaderProps } from './table-header';
|
|
4
4
|
import { TablePaginationProps } from './table-pagination';
|
|
5
|
-
import { CustomColumnsType, CustomSortingRule, OptionalDataTypes, PaginationPageType } from './types';
|
|
5
|
+
import { CustomColumnsType, CustomSortingRule, IdType, OptionalDataTypes, PaginationPageType } from './types';
|
|
6
6
|
export declare type TableProps<T extends Record<string, unknown>> = PropsWithClass & {
|
|
7
7
|
/**
|
|
8
8
|
* Define the columns and headers of the table.
|
|
@@ -29,6 +29,27 @@ export declare type TableProps<T extends Record<string, unknown>> = PropsWithCla
|
|
|
29
29
|
* A function to trigger every time a row changes its selection status
|
|
30
30
|
*/
|
|
31
31
|
onSelectedRowsChange?: (selectedRowIds: Array<IdType<T>>) => void;
|
|
32
|
+
/**
|
|
33
|
+
* When `true`, `Table` stops clearing `selectedRowIds` whenever `data`
|
|
34
|
+
* changes (e.g. navigating to a different server-fetched page). This lets
|
|
35
|
+
* a consumer-owned superset selection list persist across pages.
|
|
36
|
+
*
|
|
37
|
+
* This only concerns *persisting* previously-known selected ids: the
|
|
38
|
+
* header "select all" checkbox always stays scoped to the currently
|
|
39
|
+
* loaded rows. See `packages/TABLE_CROSS_PAGE_SELECTION.md` for the
|
|
40
|
+
* consumer-side requirements before enabling this.
|
|
41
|
+
*
|
|
42
|
+
* Defaults to `false`, matching `Table`'s historical behavior of
|
|
43
|
+
* resetting selection whenever `data` changes.
|
|
44
|
+
*/
|
|
45
|
+
persistSelectionAcrossPages?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Resolve a stable, unique id for each row. Defaults to `row._id`,
|
|
48
|
+
* falling back to a page-relative index when absent (unstable across
|
|
49
|
+
* pages — only safe for tables that never use `persistSelectionAcrossPages`
|
|
50
|
+
* or cross-page id lookups).
|
|
51
|
+
*/
|
|
52
|
+
getRowId?: (originalRow: T & OptionalDataTypes<T>, relativeIndex: number, parent?: Row<T>) => string;
|
|
32
53
|
/**
|
|
33
54
|
* Add an alternate style to the table rows
|
|
34
55
|
*/
|
|
@@ -130,7 +151,7 @@ export declare type TableProps<T extends Record<string, unknown>> = PropsWithCla
|
|
|
130
151
|
/**
|
|
131
152
|
* Set the initial sorted column and order by passing column id and order.
|
|
132
153
|
*/
|
|
133
|
-
initialSortBy?: Array<
|
|
154
|
+
initialSortBy?: Array<CustomSortingRule<T>>;
|
|
134
155
|
/**
|
|
135
156
|
* Callback run when a column is sorted
|
|
136
157
|
*/
|
|
@@ -140,5 +161,5 @@ export declare type TableProps<T extends Record<string, unknown>> = PropsWithCla
|
|
|
140
161
|
*/
|
|
141
162
|
onRowExpandChange?: (row: Row<T>) => void;
|
|
142
163
|
};
|
|
143
|
-
export declare const Table: <T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: TableProps<T>) => JSX.Element;
|
|
164
|
+
export declare const Table: <T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, persistSelectionAcrossPages, getRowId, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: TableProps<T>) => JSX.Element;
|
|
144
165
|
//# sourceMappingURL=table.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../src/components/table/table.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../src/components/table/table.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAUL,GAAG,EAKJ,MAAM,uBAAuB,CAAC;AAM/B,OAAO,EACL,aAAa,EAAuB,SAAS,EAC9C,MAAM,OAAO,CAAC;AAaf,OAAO,EA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