Skip to content

Commit 8b872c4

Browse files
chore(deps-dev): bump the npm-dependencies group with 4 updates (#1004)
* chore(deps-dev): bump the npm-dependencies group with 4 updates Bumps the npm-dependencies group with 4 updates: [@eslint/js](https://github.com/eslint/eslint/tree/HEAD/packages/js), [eslint](https://github.com/eslint/eslint), [react-dnd](https://github.com/react-dnd/react-dnd) and [react-dnd-html5-backend](https://github.com/react-dnd/react-dnd). Updates `@eslint/js` from 9.39.4 to 10.0.1 - [Release notes](https://github.com/eslint/eslint/releases) - [Commits](https://github.com/eslint/eslint/commits/v10.0.1/packages/js) Updates `eslint` from 9.39.4 to 10.6.0 - [Release notes](https://github.com/eslint/eslint/releases) - [Commits](eslint/eslint@v9.39.4...v10.6.0) Updates `react-dnd` from 10.0.2 to 16.0.1 - [Release notes](https://github.com/react-dnd/react-dnd/releases) - [Changelog](https://github.com/react-dnd/react-dnd/blob/main/CHANGELOG.md) - [Commits](https://github.com/react-dnd/react-dnd/commits) Updates `react-dnd-html5-backend` from 10.0.2 to 16.0.1 - [Release notes](https://github.com/react-dnd/react-dnd/releases) - [Changelog](https://github.com/react-dnd/react-dnd/blob/main/CHANGELOG.md) - [Commits](https://github.com/react-dnd/react-dnd/commits) --- updated-dependencies: - dependency-name: "@eslint/js" dependency-version: 10.0.1 dependency-type: direct:development update-type: version-update:semver-major dependency-group: npm-dependencies - dependency-name: eslint dependency-version: 10.6.0 dependency-type: direct:development update-type: version-update:semver-major dependency-group: npm-dependencies - dependency-name: react-dnd dependency-version: 16.0.1 dependency-type: direct:development update-type: version-update:semver-major dependency-group: npm-dependencies - dependency-name: react-dnd-html5-backend dependency-version: 16.0.1 dependency-type: direct:development update-type: version-update:semver-major dependency-group: npm-dependencies ... Signed-off-by: dependabot[bot] <support@github.com> * fix: support eslint 10 dependency update * fix: resolve eslint 10 lint errors * fix: support react dnd 16 demo --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: afc163 <afc163@gmail.com>
1 parent 781eae5 commit 8b872c4

5 files changed

Lines changed: 31 additions & 47 deletions

File tree

.github/workflows/surge-preview.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
- name: Build preview
3838
if: ${{ steps.surge-token.outputs.enabled == 'true' }}
3939
run: |
40-
npm install
40+
npm install --legacy-peer-deps
4141
npm run build
4242
- uses: afc163/surge-preview@bf90a5a86111f6311ca42f0a5a0f80fb0fb03cec
4343
if: ${{ steps.surge-token.outputs.enabled == 'true' }}

docs/examples/renderTabBar-dragable.tsx

Lines changed: 21 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,34 @@
11
import React from 'react';
2-
import { DndProvider, DragSource, DropTarget } from 'react-dnd';
3-
import HTML5Backend from 'react-dnd-html5-backend';
2+
import { DndProvider, useDrag, useDrop } from 'react-dnd';
3+
import { HTML5Backend } from 'react-dnd-html5-backend';
44
import Tabs from '@rc-component/tabs';
55
import type { TabsProps } from '@rc-component/tabs';
66
import '../../assets/index.less';
77

88
// Drag & Drop node
9-
class TabNode extends React.Component<any, any> {
10-
render() {
11-
const { connectDragSource, connectDropTarget, children } = this.props;
12-
13-
return connectDragSource(connectDropTarget(children));
14-
}
15-
}
16-
17-
const cardTarget = {
18-
drop(props, monitor) {
19-
const dragKey = monitor.getItem().index;
20-
const hoverKey = props.index;
21-
22-
if (dragKey === hoverKey) {
23-
return;
24-
}
9+
const WrapTabNode: React.FC<any> = ({ children, index, moveTabNode }) => {
10+
const [, drop] = useDrop({
11+
accept: 'DND_NODE',
12+
drop(item: { index: React.Key }) {
13+
const dragKey = item.index;
14+
const hoverKey = index;
15+
16+
if (dragKey === hoverKey) {
17+
return;
18+
}
2519

26-
props.moveTabNode(dragKey, hoverKey);
27-
monitor.getItem().index = hoverKey;
28-
},
29-
};
20+
moveTabNode(dragKey, hoverKey);
21+
item.index = hoverKey;
22+
},
23+
});
24+
const [, drag] = useDrag({
25+
type: 'DND_NODE',
26+
item: { index },
27+
});
3028

31-
const cardSource = {
32-
beginDrag(props) {
33-
return {
34-
id: props.id,
35-
index: props.index,
36-
};
37-
},
29+
return drag(drop(children));
3830
};
3931

40-
const WrapTabNode = DropTarget('DND_NODE', cardTarget, connect => ({
41-
connectDropTarget: connect.dropTarget(),
42-
}))(
43-
DragSource('DND_NODE', cardSource, (connect, monitor) => ({
44-
connectDragSource: connect.dragSource(),
45-
isDragging: monitor.isDragging(),
46-
}))(TabNode),
47-
);
48-
4932
class DraggableTabs extends React.Component<TabsProps> {
5033
state = {
5134
order: [],
@@ -111,7 +94,6 @@ class DraggableTabs extends React.Component<TabsProps> {
11194
});
11295

11396
return (
114-
// @ts-ignore https://github.com/react-dnd/react-dnd/issues/3636 需要升级 15.0.0 类型支持 children 但是写法需要重新调整验证
11597
<DndProvider backend={HTML5Backend}>
11698
<Tabs renderTabBar={this.renderTabBar} {...this.props} items={orderTabs} />
11799
</DndProvider>

eslint.config.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import js from '@eslint/js';
2+
import { fixupConfigRules } from '@eslint/compat';
23
import { defineConfig } from 'eslint/config';
34
import { dirname } from 'node:path';
45
import { fileURLToPath } from 'node:url';
@@ -40,8 +41,8 @@ export default defineConfig([
4041
files: ['**/*.{js,jsx,ts,tsx}'],
4142
extends: [
4243
js.configs.recommended,
43-
react.configs.flat.recommended,
44-
react.configs.flat['jsx-runtime'],
44+
...fixupConfigRules(react.configs.flat.recommended),
45+
...fixupConfigRules(react.configs.flat['jsx-runtime']),
4546
prettier,
4647
],
4748
plugins: {

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
"clsx": "^2.1.1"
5050
},
5151
"devDependencies": {
52-
"@eslint/js": "^9.39.4",
52+
"@eslint/js": "^10.0.1",
53+
"@eslint/compat": "^2.1.0",
5354
"@rc-component/father-plugin": "^2.2.0",
5455
"@rc-component/np": "^1.0.4",
5556
"@testing-library/dom": "^10.4.1",
@@ -63,7 +64,7 @@
6364
"@types/react-dom": "^19.2.3",
6465
"cross-env": "^10.1.0",
6566
"dumi": "^2.4.38",
66-
"eslint": "^9.39.4",
67+
"eslint": "^10.6.0",
6768
"eslint-config-prettier": "^10.1.8",
6869
"eslint-plugin-jest": "^29.15.4",
6970
"eslint-plugin-react": "^7.37.5",
@@ -77,8 +78,8 @@
7778
"prettier": "^3.9.4",
7879
"rc-test": "^7.1.3",
7980
"react": "^19.2.7",
80-
"react-dnd": "^10.0.0",
81-
"react-dnd-html5-backend": "^10.0.0",
81+
"react-dnd": "^16.0.1",
82+
"react-dnd-html5-backend": "^16.0.1",
8283
"react-dom": "^19.2.7",
8384
"react-sticky": "^6.0.3",
8485
"typescript": "^6.0.3",

src/hooks/useTouchMove.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export default function useTouchMove(
8282
const { deltaX, deltaY } = e;
8383

8484
// Convert both to x & y since wheel only happened on PC
85-
let mixed: number = 0;
85+
let mixed: number;
8686
const absX = Math.abs(deltaX);
8787
const absY = Math.abs(deltaY);
8888
if (absX === absY) {

0 commit comments

Comments
 (0)