Skip to content

Commit 27c636e

Browse files
committed
fix(Virtualized): use version which supports React 19
1 parent 2ec9cf2 commit 27c636e

File tree

5 files changed

+30
-25
lines changed

5 files changed

+30
-25
lines changed

Diff for: package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
},
1313
"dependencies": {
1414
"clsx": "1.1.1",
15-
"react-virtualized-auto-sizer": "1.0.7",
15+
"react-virtualized-auto-sizer": "1.0.26",
1616
"react-window": "1.8.7"
1717
},
1818
"devDependencies": {
@@ -53,7 +53,7 @@
5353
"@types/node": "17.0.14",
5454
"@types/react": "17.0.38",
5555
"@types/react-dom": "17.0.11",
56-
"@types/react-virtualized-auto-sizer": "1.0.1",
56+
"@types/react-virtualized-auto-sizer": "1.0.8",
5757
"@types/react-window": "1.8.5",
5858
"@typescript-eslint/eslint-plugin": "5.10.2",
5959
"@typescript-eslint/parser": "5.10.2",

Diff for: src/common/util/useIdReducer/index.ts

+15-12
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
MiddlewareFunction,
1313
IdReducerFunctions,
1414
} from '@table-library/react-table-library/types/common';
15-
import { Data, TableNode } from '@table-library/react-table-library/types/table';
15+
import { Data, Identifier, TableNode } from '@table-library/react-table-library/types/table';
1616

1717
const addById = (state: State, action: Action) => {
1818
return {
@@ -142,7 +142,7 @@ const getMergedOptions = (options: Record<string, any>) => ({
142142
...options,
143143
});
144144

145-
const getRecursiveIds = (id: string, nodes: TableNode[]) => {
145+
const getRecursiveIds = (id: Identifier, nodes: TableNode[]) => {
146146
const node = findNodeById(nodes, id);
147147

148148
return [node, ...fromTreeToList(node?.nodes)].map((item) => item!.id);
@@ -163,7 +163,10 @@ const useIdReducer = <T extends TableNode>(
163163
);
164164

165165
// exclusive for select feature
166-
const shiftToggle = React.useRef({
166+
const shiftToggle = React.useRef<{
167+
lastToggledId: Identifier | null;
168+
currentShiftIds: Identifier[];
169+
}>({
167170
lastToggledId: null,
168171
currentShiftIds: [],
169172
});
@@ -178,7 +181,7 @@ const useIdReducer = <T extends TableNode>(
178181
);
179182

180183
const onAddById = React.useCallback(
181-
(id) =>
184+
(id: Identifier) =>
182185
dispatchWithMiddleware({
183186
type: ADD_BY_ID,
184187
payload: { id },
@@ -187,7 +190,7 @@ const useIdReducer = <T extends TableNode>(
187190
);
188191

189192
const onRemoveById = React.useCallback(
190-
(id) =>
193+
(id: Identifier) =>
191194
dispatchWithMiddleware({
192195
type: REMOVE_BY_ID,
193196
payload: { id },
@@ -196,7 +199,7 @@ const useIdReducer = <T extends TableNode>(
196199
);
197200

198201
const onToggleById = React.useCallback(
199-
(id) => {
202+
(id: Identifier) => {
200203
if (state.ids.includes(id)) {
201204
onRemoveById(id);
202205
} else {
@@ -210,7 +213,7 @@ const useIdReducer = <T extends TableNode>(
210213
);
211214

212215
const onAddByIds = React.useCallback(
213-
(ids, options) => {
216+
(ids: Identifier[], options) => {
214217
const mergedOptions = getMergedOptions(options);
215218

216219
dispatchWithMiddleware({
@@ -225,7 +228,7 @@ const useIdReducer = <T extends TableNode>(
225228
);
226229

227230
const onRemoveByIds = React.useCallback(
228-
(ids) => {
231+
(ids: Identifier[]) => {
229232
dispatchWithMiddleware({
230233
type: REMOVE_BY_IDS,
231234
payload: { ids },
@@ -235,7 +238,7 @@ const useIdReducer = <T extends TableNode>(
235238
);
236239

237240
const onToggleByIdRecursively = React.useCallback(
238-
(id, options) => {
241+
(id: Identifier, options) => {
239242
const mergedOptions = getMergedOptions(options);
240243

241244
const ids = getRecursiveIds(id, data.nodes);
@@ -274,7 +277,7 @@ const useIdReducer = <T extends TableNode>(
274277
);
275278

276279
const onRemoveByIdRecursively = React.useCallback(
277-
(id) => {
280+
(id: Identifier) => {
278281
const ids = getRecursiveIds(id, data.nodes);
279282

280283
onRemoveByIds(ids);
@@ -283,7 +286,7 @@ const useIdReducer = <T extends TableNode>(
283286
);
284287

285288
const onAddByIdExclusively = React.useCallback(
286-
(id) => {
289+
(id: Identifier) => {
287290
dispatchWithMiddleware({
288291
type: ADD_BY_ID_EXCLUSIVELY,
289292
payload: { id },
@@ -299,7 +302,7 @@ const useIdReducer = <T extends TableNode>(
299302
}, [dispatchWithMiddleware]);
300303

301304
const onToggleByIdExclusively = React.useCallback(
302-
(id) => {
305+
(id: Identifier) => {
303306
if (id === state.id) {
304307
onRemoveByIdExclusively();
305308
} else {

Diff for: src/compact/VirtualizedTable.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ export const VirtualizedTable = <T extends TableNode>({
8585
...tableProps
8686
}: VirtualizedTableProps<T>) => {
8787
return (
88+
// @ts-ignore
8889
<AutoSizer>
89-
{({ width, height }: { width: any; height: any }) => (
90+
{({ width, height }: { width: number; height: number }) => (
9091
<VariableSizeList
9192
height={height}
9293
width={width}

Diff for: src/virtualized/Virtualized.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ const Virtualized = <T extends TableNode>({
2121
return (
2222
<>
2323
{tableOptions?.renderBeforeTable && tableOptions.renderBeforeTable()}
24+
{/* @ts-ignore */}
2425
<AutoSizer>
25-
{({ width, height }) => (
26+
{({ width, height }: { width: number; height: number }) => (
2627
<VariableSizeList
2728
height={height}
2829
width={width}

Diff for: yarn.lock

+9-9
Original file line numberDiff line numberDiff line change
@@ -4682,12 +4682,12 @@
46824682
dependencies:
46834683
"@types/react" "*"
46844684

4685-
"@types/[email protected].1":
4686-
version "1.0.1"
4687-
resolved "https://registry.yarnpkg.com/@types/react-virtualized-auto-sizer/-/react-virtualized-auto-sizer-1.0.1.tgz#b3187dae1dfc4c15880c9cfc5b45f2719ea6ebd4"
4688-
integrity sha512-GH8sAnBEM5GV9LTeiz56r4ZhMOUSrP43tAQNSRVxNexDjcNKLCEtnxusAItg1owFUFE6k0NslV26gqVClVvong==
4685+
"@types/[email protected].8":
4686+
version "1.0.8"
4687+
resolved "https://registry.yarnpkg.com/@types/react-virtualized-auto-sizer/-/react-virtualized-auto-sizer-1.0.8.tgz#97d6b8e403450483b3d5e452a64729273e662109"
4688+
integrity sha512-keJpNyhiwfl2+N12G1ocCVA5ZDBArbPLe/S90X3kt7fam9naeHdaYYWbpe2sHczp70JWJ+2QLhBE8kLvLuVNjA==
46894689
dependencies:
4690-
"@types/react" "*"
4690+
react-virtualized-auto-sizer "*"
46914691

46924692
46934693
version "1.8.5"
@@ -14833,10 +14833,10 @@ react-transition-group@^4.4.2:
1483314833
loose-envify "^1.4.0"
1483414834
prop-types "^15.6.2"
1483514835

14836-
14837-
version "1.0.7"
14838-
resolved "https://registry.yarnpkg.com/react-virtualized-auto-sizer/-/react-virtualized-auto-sizer-1.0.7.tgz#bfb8414698ad1597912473de3e2e5f82180c1195"
14839-
integrity sha512-Mxi6lwOmjwIjC1X4gABXMJcKHsOo0xWl3E3ugOgufB8GJU+MqrtY35aBuvCYv/razQ1Vbp7h1gWJjGjoNN5pmA==
14836+
react-virtualized-auto-sizer@*, react-virtualized-auto-sizer@1.0.26:
14837+
version "1.0.26"
14838+
resolved "https://registry.yarnpkg.com/react-virtualized-auto-sizer/-/react-virtualized-auto-sizer-1.0.26.tgz#e9470ef6a778dc4f1d5fd76305fa2d8b610c357a"
14839+
integrity sha512-CblNyiNVw2o+hsa5/49NH2ogGxZ+t+3aweRvNSq7TVjDIlwk7ir4lencEg5HxHeSzwNarSkNkiu0qJSOXtxm5A==
1484014840

1484114841
1484214842
version "1.8.7"

0 commit comments

Comments
 (0)