Skip to content

Commit aa64cf5

Browse files
committed
feat: 更新滚动行为和添加wrapperRef支持
- 添加scrollIntoViewV2函数,改进滚动居中行为 - 为DataGrid组件添加wrapperRef支持 - 更新依赖版本和配置 - 调整路由文件结构
1 parent 618b729 commit aa64cf5

File tree

7 files changed

+2224
-1224
lines changed

7 files changed

+2224
-1224
lines changed

biome.json

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
{
22
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3-
"assist": { "actions": { "source": { "organizeImports": "off" } } },
3+
"assist": {
4+
"actions": {
5+
"source": {
6+
"organizeImports": "off"
7+
}
8+
}
9+
},
410
"files": {
511
"includes": [
612
"**",
@@ -17,7 +23,15 @@
1723
]
1824
},
1925
"formatter": {
20-
"enabled": false
26+
"enabled": false,
27+
"includes": [
28+
"**",
29+
"!**/*.ts",
30+
"!**/*.tsx",
31+
"!package.json"
32+
],
33+
"indentStyle": "space",
34+
"lineWidth": 100
2135
},
2236
"json": {
2337
"parser": {
@@ -218,11 +232,15 @@
218232
"options": {
219233
"paths": {
220234
"react": {
221-
"importNames": ["default"],
235+
"importNames": [
236+
"default"
237+
],
222238
"message": "Use named imports instead."
223239
},
224240
"react-dom": {
225-
"importNames": ["default"],
241+
"importNames": [
242+
"default"
243+
],
226244
"message": "Use named imports instead."
227245
}
228246
}
@@ -351,7 +369,9 @@
351369
},
352370
"overrides": [
353371
{
354-
"includes": ["**/*.test.*"],
372+
"includes": [
373+
"**/*.test.*"
374+
],
355375
"linter": {
356376
"rules": {
357377
"performance": {
@@ -361,7 +381,10 @@
361381
}
362382
},
363383
{
364-
"includes": ["**/*.js", "**/rolldown.config.ts"],
384+
"includes": [
385+
"**/*.js",
386+
"**/rolldown.config.ts"
387+
],
365388
"linter": {
366389
"rules": {
367390
"correctness": {
@@ -376,10 +399,14 @@
376399
{
377400
"assist": {
378401
"actions": {
379-
"source": { "useSortedKeys": "on" }
402+
"source": {
403+
"useSortedKeys": "on"
404+
}
380405
}
381406
},
382-
"includes": ["./biome.json"]
407+
"includes": [
408+
"./biome.json"
409+
]
383410
}
384411
]
385-
}
412+
}

package.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-data-grid",
3-
"version": "7.0.11",
3+
"version": "7.0.14",
44
"license": "MIT",
55
"description": "Feature-rich and customizable data grid React component",
66
"keywords": [
@@ -52,8 +52,11 @@
5252
"postpublish": "git push --follow-tags origin HEAD"
5353
},
5454
"dependencies": {
55+
"@dnd-kit/core": "^6.3.1",
56+
"@dnd-kit/modifiers": "^9.0.0",
5557
"antd": "^5.27.0",
5658
"clsx": "^2.0.0",
59+
"react-refresh": "^0.17.0",
5760
"react-window": "^1.8.11"
5861
},
5962
"dependencies": {
@@ -88,6 +91,14 @@
8891
"clsx": "^2.1.1",
8992
"ecij": "^0.3.0",
9093
"eslint": "^9.39.1",
94+
"@linaria/babel-preset": "^5.0.4",
95+
"@linaria/core": "^6.3.0",
96+
"@linaria/react": "^6.3.0",
97+
"@linaria/vite": "^5.0.4",
98+
"@vitest/browser": "^3.2.4",
99+
"@wyw-in-js/babel-preset": "^0.7.0",
100+
"@wyw-in-js/rollup": "^0.7.0",
101+
"@wyw-in-js/vite": "^0.7.0",
91102
"eslint-plugin-jest-dom": "^5.5.0",
92103
"eslint-plugin-react": "^7.37.5",
93104
"eslint-plugin-react-hooks": "^7.0.1",

src/DataGrid.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ type SharedDivProps = Pick<
127127

128128
export interface DataGridProps<R, SR = unknown, K extends Key = Key> extends SharedDivProps {
129129
ref?: Maybe<React.Ref<DataGridHandle>>;
130+
wrapperRef?: Maybe<React.Ref<DataGridHandle>>;
130131
/**
131132
* Grid and data Props
132133
*/
@@ -249,6 +250,7 @@ export interface DataGridProps<R, SR = unknown, K extends Key = Key> extends Sha
249250
export function DataGrid<R, SR = unknown, K extends Key = Key>(props: DataGridProps<R, SR, K>) {
250251
const {
251252
ref,
253+
wrapperRef,
252254
// Grid and data Props
253255
columns: rawColumns,
254256
rows,

src/ScrollToCell.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useLayoutEffect, useRef } from 'react';
22

3-
import { scrollIntoView } from './utils';
3+
import { scrollIntoView, scrollIntoViewV2 } from './utils';
44

55
export interface PartialPosition {
66
readonly idx?: number | undefined;
@@ -22,7 +22,7 @@ export default function ScrollToCell({
2222
// scroll until the cell is completely visible
2323
// this is needed if the grid has auto-sized columns
2424
// setting the behavior to auto so it can be overridden
25-
scrollIntoView(ref.current, 'auto');
25+
scrollIntoViewV2(ref.current, 'auto');
2626
});
2727

2828
useLayoutEffect(() => {

src/utils/domUtils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ export function stopPropagation(event: React.SyntheticEvent) {
77
export function scrollIntoView(element: Maybe<Element>, behavior: ScrollBehavior = 'instant') {
88
element?.scrollIntoView({ inline: 'nearest', block: 'nearest', behavior });
99
}
10+
11+
export function scrollIntoViewV2(element: Maybe<Element>, behavior: ScrollBehavior = 'instant') {
12+
element?.scrollIntoView({ inline: 'center', block: 'center', behavior });
13+
}

website/routeTree.gen.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -635,15 +635,6 @@ declare module './routes/ScrollToCell' {
635635
FileRoutesByPath['/ScrollToCell']['fullPath']
636636
>
637637
}
638-
declare module './routes/Tree' {
639-
const createFileRoute: CreateFileRoute<
640-
'/Tree',
641-
FileRoutesByPath['/Tree']['parentRoute'],
642-
FileRoutesByPath['/Tree']['id'],
643-
FileRoutesByPath['/Tree']['path'],
644-
FileRoutesByPath['/Tree']['fullPath']
645-
>
646-
}
647638
declare module './routes/TreeView' {
648639
const createFileRoute: CreateFileRoute<
649640
'/TreeView',

0 commit comments

Comments
 (0)