Skip to content

Commit 2680295

Browse files
committed
bump to 1.2.2
1 parent 6befa63 commit 2680295

File tree

11 files changed

+80
-146
lines changed

11 files changed

+80
-146
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# CHANGELOG
22

3+
## 1.2.2
4+
5+
_2024-12-19_
6+
7+
### Features
8+
9+
- explicit support for React 19
10+
- fixes horizontal scroll bug on iOS
11+
- fixes `footerComponent` regression
12+
313
## 1.2.1
414

515
_2024-12-19_

example/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"clsx": "^2.1.1",
3131
"country-flag-icons": "^1.5.13",
3232
"lodash": "^4.17.21",
33-
"lucide-react": "^0.465.0",
33+
"lucide-react": "^0.468.0",
3434
"react": "^18.2.0",
3535
"react-dom": "^18.2.0",
3636
"react-fluid-table": "link:..",
@@ -54,9 +54,9 @@
5454
"postcss": "^8.4.49",
5555
"prettier": "^3.4.2",
5656
"prettier-plugin-tailwindcss": "^0.6.9",
57-
"tailwindcss": "^3.4.16",
57+
"tailwindcss": "^3.4.17",
5858
"typescript": "^5.4.5",
59-
"vite": "^6.0.2"
59+
"vite": "^6.0.4"
6060
},
6161
"volta": {
6262
"node": "18.18.0",

example/vite.config.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
import path from "path"
1+
import path from "path";
22
import { defineConfig } from "vite";
33
import react from "@vitejs/plugin-react";
44

55
// https://vitejs.dev/config/
66
export default defineConfig({
77
plugins: [react()],
88
base: "/react-fluid-table/",
9+
server: {
10+
host: "0.0.0.0"
11+
},
912
resolve: {
1013
alias: {
11-
"@": path.resolve(__dirname, "./src"),
12-
},
13-
},
14+
"@": path.resolve(__dirname, "./src")
15+
}
16+
}
1417
});

example/yarn.lock

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,10 +2009,10 @@ lru-cache@^5.1.1:
20092009
dependencies:
20102010
yallist "^3.0.2"
20112011

2012-
lucide-react@^0.465.0:
2013-
version "0.465.0"
2014-
resolved "https://registry.yarnpkg.com/lucide-react/-/lucide-react-0.465.0.tgz#3f98d40f7b7ac5266c055aaf582c303b07f84de2"
2015-
integrity sha512-uV7WEqbwaCcc+QjAxIhAvkAr3kgwkkYID3XptCHll72/F7NZlk6ONmJYpk+Xqx5Q0r/8wiOjz73H1BYbl8Z8iw==
2012+
lucide-react@^0.468.0:
2013+
version "0.468.0"
2014+
resolved "https://registry.yarnpkg.com/lucide-react/-/lucide-react-0.468.0.tgz#830c1bfd905575ddd23b832baa420c87db166910"
2015+
integrity sha512-6koYRhnM2N0GGZIdXzSeiNwguv1gt/FAjZOiPl76roBi3xKEXa4WmfpxgQwTTL4KipXjefrnf3oV4IsYhi4JFA==
20162016

20172017
merge2@^1.3.0, merge2@^1.4.1:
20182018
version "1.4.1"
@@ -2365,10 +2365,10 @@ react-remove-scroll@2.6.0:
23652365
use-callback-ref "^1.3.0"
23662366
use-sidecar "^1.1.2"
23672367

2368-
react-resize-detector@^11.0.1:
2369-
version "11.0.1"
2370-
resolved "https://registry.yarnpkg.com/react-resize-detector/-/react-resize-detector-11.0.1.tgz#70684958ae82bc0deb240d133a1ee440e0624532"
2371-
integrity sha512-1Tdgu6Ou3vI3RQD+o2/kTvDibb4NRe7Oh83hIjNNEXb6WKKCQT99VQlh3Xlbdq2HtkUoFEMrgMMKkYI83YbD7Q==
2368+
react-resize-detector@^12.0.1:
2369+
version "12.0.1"
2370+
resolved "https://registry.yarnpkg.com/react-resize-detector/-/react-resize-detector-12.0.1.tgz#7d7eba49a538c32ba45f121b6dc9f28bf1dc4077"
2371+
integrity sha512-qOzOEn8AC4i60L29sPeUtw3RRsdDYZAGOBDwg3vzUQ34fpP+JOBlf1x0Q8Wv85IPQ3nBNL4NNr12e2caiIK1Lg==
23722372
dependencies:
23732373
lodash "^4.17.21"
23742374

@@ -2645,10 +2645,10 @@ tailwindcss-animate@^1.0.7:
26452645
resolved "https://registry.yarnpkg.com/tailwindcss-animate/-/tailwindcss-animate-1.0.7.tgz#318b692c4c42676cc9e67b19b78775742388bef4"
26462646
integrity sha512-bl6mpH3T7I3UFxuvDEXLxy/VuFxBk5bbzplh7tXI68mwMokNYd1t9qPBHlnyTwfa4JGC4zP516I1hYYtQ/vspA==
26472647

2648-
tailwindcss@^3.4.16:
2649-
version "3.4.16"
2650-
resolved "https://registry.yarnpkg.com/tailwindcss/-/tailwindcss-3.4.16.tgz#35a7c3030844d6000fc271878db4096b6a8d2ec9"
2651-
integrity sha512-TI4Cyx7gDiZ6r44ewaJmt0o6BrMCT5aK5e0rmJ/G9Xq3w7CX/5VXl/zIPEJZFUK5VEqwByyhqNPycPlvcK4ZNw==
2648+
tailwindcss@^3.4.17:
2649+
version "3.4.17"
2650+
resolved "https://registry.yarnpkg.com/tailwindcss/-/tailwindcss-3.4.17.tgz#ae8406c0f96696a631c790768ff319d46d5e5a63"
2651+
integrity sha512-w33E2aCvSDP0tW9RZuNXadXlkHXqFzSkQew/aIa2i/Sj8fThxwovwlXHSPXTbAHwEIhBFXAedUhP2tueAKP8Og==
26522652
dependencies:
26532653
"@alloc/quick-lru" "^5.2.0"
26542654
arg "^5.0.2"
@@ -2781,10 +2781,10 @@ uuid@8.3.2:
27812781
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
27822782
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
27832783

2784-
vite@^6.0.2:
2785-
version "6.0.2"
2786-
resolved "https://registry.yarnpkg.com/vite/-/vite-6.0.2.tgz#7a22630c73c7b663335ddcdb2390971ffbc14993"
2787-
integrity sha512-XdQ+VsY2tJpBsKGs0wf3U/+azx8BBpYRHFAyKm5VeEZNOJZRB63q7Sc8Iup3k0TrN3KO6QgyzFf+opSbfY1y0g==
2784+
vite@^6.0.4:
2785+
version "6.0.4"
2786+
resolved "https://registry.yarnpkg.com/vite/-/vite-6.0.4.tgz#fe7cfaedff7c701d5582be5c4ed6a2150538ea9d"
2787+
integrity sha512-zwlH6ar+6o6b4Wp+ydhtIKLrGM/LoqZzcdVmkGAFun0KHTzIzjh+h0kungEx7KJg/PYnC80I4TII9WkjciSR6Q==
27882788
dependencies:
27892789
esbuild "^0.24.0"
27902790
postcss "^8.4.49"

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-fluid-table",
3-
"version": "1.2.1",
3+
"version": "1.2.2",
44
"description": "A React table inspired by @tanstack/react-virtual",
55
"author": "Mckervin Ceme <mckervinc@live.com>",
66
"license": "MIT",
@@ -35,8 +35,8 @@
3535
"site:build": "cd example && yarn install && yarn build"
3636
},
3737
"peerDependencies": {
38-
"react": ">=16.8.0",
39-
"react-dom": ">=16.8.0"
38+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
39+
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
4040
},
4141
"devDependencies": {
4242
"@babel/core": "^7.26.0",

src/Table.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { positive, randomString } from "./util";
66

77
let warned = false;
88

9-
const Table = forwardRef(function <T>(
9+
function BaseTable<T>(
1010
{
1111
id,
1212
rowHeight,
@@ -83,15 +83,19 @@ const Table = forwardRef(function <T>(
8383
rowRenderer={rowRenderer}
8484
onExpandRow={onExpandRow}
8585
subComponent={subComponent}
86+
footerComponent={footerComponent}
8687
columns={columns}
8788
{...props}
8889
/>
8990
);
9091
}}
9192
</AutoSizer>
9293
);
93-
});
94+
}
9495

95-
Table.displayName = "Table";
96+
const Table = forwardRef(BaseTable) as <T>(
97+
props: TableProps<T> & { ref?: React.ForwardedRef<TableRef> }
98+
) => React.JSX.Element;
99+
(Table as React.FC).displayName = "Table";
96100

97101
export default Table;

src/components/Footer.tsx

Lines changed: 6 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import React, { memo, useCallback, useEffect, useRef } from "react";
1+
import React, { memo } from "react";
22
import { ColumnProps, FooterProps } from "../..";
3-
import { cx, findTableByUuid } from "../util";
3+
import { cx } from "../util";
44

55
type InnerFooterCellProps<T> = {
66
width: number;
@@ -32,6 +32,7 @@ const FooterCell = memo(BaseFooterCell) as <T>(props: InnerFooterCellProps<T>) =
3232
type InnerFooterProps<T> = {
3333
uuid: string;
3434
rows: T[];
35+
isScrollHorizontal: boolean;
3536
columns: ColumnProps<T>[];
3637
pixelWidths: number[];
3738
className?: string;
@@ -47,12 +48,10 @@ function Footer<T>({
4748
pixelWidths,
4849
sticky,
4950
className,
51+
isScrollHorizontal,
5052
style: footerStyle = {},
5153
component: Component
5254
}: InnerFooterProps<T>) {
53-
const scroll = useRef(false);
54-
const ref = useRef<HTMLDivElement>(null);
55-
5655
// constants
5756
const hasFooter = !!Component || columns.some(c => !!c.footer);
5857
const style: React.CSSProperties = {
@@ -64,60 +63,14 @@ function Footer<T>({
6463
style.minWidth = 0;
6564
}
6665

67-
// functions
68-
const onScroll = useCallback(
69-
(target: HTMLElement | null, element: HTMLElement | null) => {
70-
if (scroll.current || !element || !sticky) {
71-
return;
72-
}
73-
74-
const left = target?.scrollLeft || 0;
75-
scroll.current = true;
76-
element.scrollLeft = left;
77-
setTimeout(() => {
78-
scroll.current = false;
79-
}, 0);
80-
},
81-
[uuid, sticky]
82-
);
83-
84-
const listener = useCallback(
85-
(ev: Event) => {
86-
onScroll(ev.target as HTMLDivElement, ref.current);
87-
},
88-
[onScroll]
89-
);
90-
91-
// effects
92-
// add scroll listener
93-
useEffect(() => {
94-
if (uuid) {
95-
const e = findTableByUuid(uuid);
96-
if (e) {
97-
e.addEventListener("scroll", listener);
98-
}
99-
}
100-
101-
return () => {
102-
if (uuid) {
103-
const e = findTableByUuid(uuid);
104-
if (e) {
105-
e.removeEventListener("scroll", listener);
106-
}
107-
}
108-
};
109-
}, [uuid, listener]);
110-
11166
// render
11267
if (!Component) {
11368
const hasFooter = columns.some(c => !!c.footer);
11469
return (
11570
<div
116-
ref={ref}
11771
style={{ border: !hasFooter ? "none" : undefined, ...style }}
11872
data-footer-key={`${uuid}-footer`}
119-
className={cx("rft-footer", sticky && "sticky", className)}
120-
onScroll={e => onScroll(e.target as HTMLDivElement, findTableByUuid(uuid))}
73+
className={cx("rft-footer", sticky && "sticky", isScrollHorizontal && "scroll", className)}
12174
>
12275
<div className="rft-row">
12376
{columns.map((c, i) => (
@@ -136,11 +89,9 @@ function Footer<T>({
13689

13790
return (
13891
<div
139-
ref={ref}
14092
style={style}
14193
data-footer-key={`${uuid}-footer`}
142-
className={cx("rft-footer", sticky && "sticky", className)}
143-
onScroll={e => onScroll(e.target as HTMLDivElement, findTableByUuid(uuid))}
94+
className={cx("rft-footer", sticky && "sticky", isScrollHorizontal && "scroll", className)}
14495
>
14596
<Component rows={rows} widths={pixelWidths} />
14697
</div>

src/components/Header.tsx

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { forwardRef, memo, useCallback, useEffect, useState } from "react";
1+
import React, { memo, useCallback, useEffect, useState } from "react";
22
import { ColumnProps, SortDirection } from "../..";
33
import { cx } from "../util";
44

@@ -62,28 +62,25 @@ type HeaderProps<T> = {
6262
uuid: string;
6363
columns: ColumnProps<T>[];
6464
pixelWidths: number[];
65-
showRowWrapper: boolean;
65+
isScrollHorizontal: boolean;
6666
className?: string;
6767
style?: React.CSSProperties;
6868
sortColumn?: string;
6969
sortDirection?: SortDirection | null;
7070
onSort?: (col: string, dir: SortDirection | null) => void;
7171
};
7272

73-
const Header = forwardRef(function <T>(
74-
{
75-
uuid,
76-
columns,
77-
showRowWrapper,
78-
pixelWidths,
79-
className,
80-
style,
81-
sortColumn,
82-
sortDirection,
83-
onSort
84-
}: HeaderProps<T>,
85-
ref: React.ForwardedRef<HTMLDivElement>
86-
) {
73+
function Header<T>({
74+
uuid,
75+
columns,
76+
isScrollHorizontal,
77+
pixelWidths,
78+
className,
79+
style,
80+
sortColumn,
81+
sortDirection,
82+
onSort
83+
}: HeaderProps<T>) {
8784
// hooks
8885
const [sortedCol, setSortedCol] = useState(sortColumn);
8986
const [sortedDir, setSortedDir] = useState(sortDirection);
@@ -116,8 +113,11 @@ const Header = forwardRef(function <T>(
116113
}, [sortColumn, sortDirection]);
117114

118115
return (
119-
<div ref={ref} className="rft-sticky-header" data-header-key={`${uuid}-header`}>
120-
<div className={cx(showRowWrapper && "rft-row-wrapper")}>
116+
<div
117+
className={cx("rft-sticky-header", isScrollHorizontal && "scroll")}
118+
data-header-key={`${uuid}-header`}
119+
>
120+
<div className={cx(isScrollHorizontal && "rft-row-wrapper")}>
121121
<div className={cx("rft-header", className)} style={style}>
122122
{columns.map((c, i) => (
123123
<HeaderCell
@@ -134,7 +134,7 @@ const Header = forwardRef(function <T>(
134134
</div>
135135
</div>
136136
);
137-
});
137+
}
138138

139139
Header.displayName = "Header";
140140

0 commit comments

Comments
 (0)