@indico-data/design-system 2.60.12 → 2.60.13
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/lib/components/tanstackTable/TankstackTable.types.d.ts +2 -1
- package/lib/components/tanstackTable/TanstackTable.d.ts +1 -1
- package/lib/index.d.ts +3 -2
- package/lib/index.esm.js +2 -2
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/tanstackTable/TankstackTable.types.ts +2 -1
- package/src/components/tanstackTable/TanstackTable.stories.tsx +9 -0
- package/src/components/tanstackTable/TanstackTable.tsx +2 -1
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Row, ColumnDef } from '@tanstack/react-table';
|
|
1
|
+
import { Row, ColumnDef, SortingState } from '@tanstack/react-table';
|
|
2
2
|
|
|
3
3
|
export type WithPaginationProps = {
|
|
4
4
|
rowsPerPage: number;
|
|
@@ -42,4 +42,5 @@ export type Props<T extends object> = {
|
|
|
42
42
|
rowSelection?: Record<string, boolean>;
|
|
43
43
|
onRowSelectionChange?: (updater: Record<string, boolean>) => void;
|
|
44
44
|
onSelectAllChange?: (isSelected: boolean) => void;
|
|
45
|
+
defaultSorting?: SortingState;
|
|
45
46
|
} & PaginationProps;
|
|
@@ -25,6 +25,15 @@ const meta: Meta = {
|
|
|
25
25
|
isStriped: true,
|
|
26
26
|
},
|
|
27
27
|
argTypes: {
|
|
28
|
+
defaultSorting: {
|
|
29
|
+
description:
|
|
30
|
+
'You may pass a default sorting state to the table. This will be used to sort the table by default. This is useful if you want to sort the table by a column by default.',
|
|
31
|
+
control: false,
|
|
32
|
+
table: {
|
|
33
|
+
category: 'Props',
|
|
34
|
+
type: { summary: 'SortingState' },
|
|
35
|
+
},
|
|
36
|
+
},
|
|
28
37
|
isStriped: {
|
|
29
38
|
description: 'Striped rows',
|
|
30
39
|
defaultValue: { summary: 'true' },
|
|
@@ -38,6 +38,7 @@ export function TanstackTable<T extends object>({
|
|
|
38
38
|
activeRows = [],
|
|
39
39
|
isStriped = true,
|
|
40
40
|
actionBarClassName,
|
|
41
|
+
defaultSorting,
|
|
41
42
|
...rest
|
|
42
43
|
}: Props<T & { id: string }>) {
|
|
43
44
|
const {
|
|
@@ -53,7 +54,7 @@ export function TanstackTable<T extends object>({
|
|
|
53
54
|
});
|
|
54
55
|
|
|
55
56
|
// handles internal sorting state.
|
|
56
|
-
const [sorting, setSorting] = useState<SortingState>([]);
|
|
57
|
+
const [sorting, setSorting] = useState<SortingState>(defaultSorting ?? []);
|
|
57
58
|
const thRefs = useRef<Record<string, HTMLTableCellElement | null>>({});
|
|
58
59
|
|
|
59
60
|
// Auto-compute column widths based on current table header cell widths for columns without a defined size.
|