Skip to content

Commit 2647759

Browse files
committed
feat(resize) initial resized layout
1 parent b6f7693 commit 2647759

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

.storybook/stories/Types/layout.story.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export type Layout = {
1010
horizontalScroll: boolean;
1111
hiddenColumns: string[];
1212
fullHeight?: boolean;
13+
resizedLayout?: string[];
1314
inheritLayout?: boolean;
1415
};
1516
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@table-library/react-table-library",
3-
"version": "2.0.15",
3+
"version": "2.0.16",
44
"description": "react-table-library",
55
"type": "module",
66
"main": "main.js",

src/table/Table/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { useShiftDown } from '@table-library/react-table-library/common/hooks/us
1717
import { Nullish } from '@table-library/react-table-library/types/common';
1818
import { TableProps } from '@table-library/react-table-library/types/table';
1919
import {
20+
Layout,
2021
TableMemory,
2122
TableMemoryRef,
2223
TableElementRef,
@@ -33,12 +34,12 @@ const useTableElementRef = (ref: TableElementRef | Nullish): TableElementRef =>
3334
return tableElementRef;
3435
};
3536

36-
const useTableMemoryRef = (): TableMemoryRef => {
37+
const useTableMemoryRef = (layout: Layout | Nullish): TableMemoryRef => {
3738
const tableMemoryRef = React.useRef<TableMemory | null>(null);
3839

3940
if (!tableMemoryRef.current) {
4041
tableMemoryRef.current = {
41-
resizedLayout: [],
42+
resizedLayout: layout?.resizedLayout ?? [],
4243
hiddenSpacesInMemory: [],
4344
};
4445
}
@@ -63,7 +64,7 @@ const Table: React.FC<TableProps> = React.forwardRef(
6364
ref: any,
6465
) => {
6566
const tableElementRef = useTableElementRef(ref);
66-
const tableMemoryRef = useTableMemoryRef();
67+
const tableMemoryRef = useTableMemoryRef(layout);
6768

6869
// if changed, adjust useFeatures hook
6970
const modifiedNodes = applyModifiers({

src/types/layout.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export type Layout = {
55
horizontalScroll: boolean;
66
hiddenColumns: string[];
77
fullHeight?: boolean;
8+
resizedLayout?: string[];
89
inheritLayout?: boolean;
910
};
1011

0 commit comments

Comments
 (0)