From 63c4886bfacaf39ce62cd9ebc6f1f6ea4494e8f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=B1=AA?= <1844749591@qq.com> Date: Sun, 23 Feb 2025 20:44:35 +0800 Subject: [PATCH 1/7] chore: update dependencies --- docs/examples/basic.tsx | 36 +--- package.json | 13 +- src/Mask.tsx | 2 +- src/Tour.tsx | 4 +- src/TourStep/DefaultPanel.tsx | 2 +- src/hooks/useTarget.ts | 4 +- tests/__snapshots__/index.test.tsx.snap | 210 ++++++++++++++++-------- tests/index.test.tsx | 4 +- 8 files changed, 167 insertions(+), 108 deletions(-) diff --git a/docs/examples/basic.tsx b/docs/examples/basic.tsx index 7710e82..77329b8 100644 --- a/docs/examples/basic.tsx +++ b/docs/examples/basic.tsx @@ -2,33 +2,22 @@ import React, { useRef } from 'react'; import Tour from '../../src/index'; import './basic.less'; -const App = () => { +const Demo = () => { const createBtnRef = useRef(null); const updateBtnRef = useRef(null); const deleteBtnRef = useRef(null); return (
- +
- - + +
-
{ ), target: () => updateBtnRef.current, }, - { - title: '更新(无阴影)', - description: ( -
- 更新一条数据 - -
- ), - mask: false, - target: () => updateBtnRef.current, - }, { title: '删除', description: (
- 危险操作:删除一条数据 + 危险操作:删除一条数据
), @@ -75,4 +53,4 @@ const App = () => { ); }; -export default App; +export default Demo; diff --git a/package.json b/package.json index 72dddd3..a428e21 100644 --- a/package.json +++ b/package.json @@ -36,15 +36,14 @@ "prepublishOnly": "npm run compile && rc-np", "prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"", "start": "dumi dev", - "test": "umi-test", + "test": "rc-test", "watch": "father dev" }, "dependencies": { - "@babel/runtime": "^7.18.0", "@rc-component/portal": "^1.0.0-9", - "@rc-component/trigger": "^2.0.0", - "classnames": "^2.3.2", - "rc-util": "^5.24.4" + "@rc-component/trigger": "^3.0.0", + "@rc-component/util": "^1.2.1", + "classnames": "^2.3.2" }, "devDependencies": { "@rc-component/father-plugin": "^2.0.3", @@ -61,10 +60,10 @@ "father": "^4.0.0", "gh-pages": "^3.1.0", "prettier": "^3.0.0", + "rc-test": "^7.1.2", "react": "^18.3.1", "react-dom": "^18.3.1", - "typescript": "^5.0.0", - "umi-test": "^1.9.7" + "typescript": "^5.0.0" }, "peerDependencies": { "react": ">=16.9.0", diff --git a/src/Mask.tsx b/src/Mask.tsx index b2ca95f..f157996 100644 --- a/src/Mask.tsx +++ b/src/Mask.tsx @@ -2,7 +2,7 @@ import React from 'react'; import classNames from 'classnames'; import Portal from '@rc-component/portal'; import type { PosInfo } from './hooks/useTarget'; -import useId from 'rc-util/lib/hooks/useId'; +import useId from '@rc-component/util/lib/hooks/useId'; import type { SemanticName, TourProps } from './interface'; const COVER_PROPS = { diff --git a/src/Tour.tsx b/src/Tour.tsx index 26b67d9..e950558 100644 --- a/src/Tour.tsx +++ b/src/Tour.tsx @@ -4,8 +4,8 @@ import Portal from '@rc-component/portal'; import type { TriggerRef } from '@rc-component/trigger'; import Trigger from '@rc-component/trigger'; import classNames from 'classnames'; -import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect'; -import useMergedState from 'rc-util/lib/hooks/useMergedState'; +import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect'; +import useMergedState from '@rc-component/util/lib/hooks/useMergedState'; import { useMemo } from 'react'; import { useClosable } from './hooks/useClosable'; import useTarget from './hooks/useTarget'; diff --git a/src/TourStep/DefaultPanel.tsx b/src/TourStep/DefaultPanel.tsx index caa0426..3eb01a4 100644 --- a/src/TourStep/DefaultPanel.tsx +++ b/src/TourStep/DefaultPanel.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import type { TourStepProps } from '../interface'; import classNames from 'classnames'; -import pickAttrs from 'rc-util/lib/pickAttrs'; +import pickAttrs from '@rc-component/util/lib/pickAttrs'; export type DefaultPanelProps = Exclude & { closable: Exclude; diff --git a/src/hooks/useTarget.ts b/src/hooks/useTarget.ts index 73976fa..840cbf3 100644 --- a/src/hooks/useTarget.ts +++ b/src/hooks/useTarget.ts @@ -1,5 +1,5 @@ -import useEvent from 'rc-util/lib/hooks/useEvent'; -import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect'; +import useEvent from '@rc-component/util/lib/hooks/useEvent'; +import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect'; import { useMemo, useState } from 'react'; import type { TourStepInfo } from '..'; import { isInViewPort } from '../util'; diff --git a/tests/__snapshots__/index.test.tsx.snap b/tests/__snapshots__/index.test.tsx.snap index 823f744..a6e4b53 100644 --- a/tests/__snapshots__/index.test.tsx.snap +++ b/tests/__snapshots__/index.test.tsx.snap @@ -93,7 +93,7 @@ exports[`Tour animated placeholder true 1`] = `
+
+
+
+
+
+ +
+
+ 删除 +
+
+
+
+ + 危险操作:删除一条数据 + + +
+
+ +
+
+
+
`; @@ -427,7 +509,7 @@ exports[`Tour renderPanel basic 1`] = `
-
-
- - - - - - - - -
-
-
-
-
- -`; - -exports[`Tour should return step 1 when reopen 1`] = ` - -
- -
+ +`; + +exports[`Tour should return step 1 when reopen 1`] = ` + +
+ +
+
+
+ + + + + + + + +
+
+
+
+
`; @@ -1220,7 +1302,7 @@ exports[`Tour should update position when window resize 1`] = `
{ expect(getByText('危险操作:删除一条数据')).toBeTruthy(); expect(document.querySelector('.rc-tour')).toBeTruthy(); fireEvent.click(screen.getByRole('button', { name: 'Finish' })); - expect(document.querySelector('.rc-tour')).toBeFalsy(); + expect(document.querySelector('.rc-tour-hidden')).toBeTruthy(); expect(baseElement).toMatchSnapshot(); }); From 471f50601d143dc18786757e93ff41d73e572629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=B1=AA?= <1844749591@qq.com> Date: Sun, 23 Feb 2025 20:46:21 +0800 Subject: [PATCH 2/7] revert doc --- docs/examples/basic.tsx | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/docs/examples/basic.tsx b/docs/examples/basic.tsx index 77329b8..69e796a 100644 --- a/docs/examples/basic.tsx +++ b/docs/examples/basic.tsx @@ -2,22 +2,33 @@ import React, { useRef } from 'react'; import Tour from '../../src/index'; import './basic.less'; -const Demo = () => { +const App = () => { const createBtnRef = useRef(null); const updateBtnRef = useRef(null); const deleteBtnRef = useRef(null); return (
- +
- - + +
+
{ ), target: () => updateBtnRef.current, }, + { + title: '更新(无阴影)', + description: ( +
+ 更新一条数据 + +
+ ), + mask: false, + target: () => updateBtnRef.current, + }, { title: '删除', description: (
- 危险操作:删除一条数据 + 危险操作:删除一条数据
), @@ -53,4 +75,4 @@ const Demo = () => { ); }; -export default Demo; +export default App; \ No newline at end of file From 6adf173b577c1ae5f1c52099b10cad004d890eef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Mon, 24 Feb 2025 21:05:23 +0800 Subject: [PATCH 3/7] chore: use new api --- src/Tour.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tour.tsx b/src/Tour.tsx index e950558..9e167a0 100644 --- a/src/Tour.tsx +++ b/src/Tour.tsx @@ -235,7 +235,7 @@ const Tour: React.FC = props => { prefixCls={prefixCls} popup={getPopupElement} forceRender={false} - destroyPopupOnHide + autoDestroy zIndex={zIndex} getTriggerDOMNode={getTriggerDOMNode} arrow={!!mergedArrow} From dc9264860aa1b406f301e1fc169187f24e67e545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Mon, 24 Feb 2025 21:18:26 +0800 Subject: [PATCH 4/7] test: update snapshot --- tests/__snapshots__/index.test.tsx.snap | 100 ++++++++++++------------ 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/tests/__snapshots__/index.test.tsx.snap b/tests/__snapshots__/index.test.tsx.snap index a6e4b53..f474916 100644 --- a/tests/__snapshots__/index.test.tsx.snap +++ b/tests/__snapshots__/index.test.tsx.snap @@ -985,6 +985,44 @@ exports[`Tour should keep current when controlled 1`] = ` open
+
+
+ + + + + + + + +
+
+
+
+
+ +`; + +exports[`Tour should return step 1 when reopen 1`] = ` + +
+ +
- -`; - -exports[`Tour should return step 1 when reopen 1`] = ` - -
- -
-
-
- - - - - - - - -
-
-
-
-
`; From e1626a5bee9f665bcfaabd3881dc51fcd46a922b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=B1=AA?= <1844749591@qq.com> Date: Mon, 24 Feb 2025 21:21:25 +0800 Subject: [PATCH 5/7] test: update test case --- tests/__snapshots__/index.test.tsx.snap | 182 +++++++----------------- tests/index.test.tsx | 2 +- 2 files changed, 51 insertions(+), 133 deletions(-) diff --git a/tests/__snapshots__/index.test.tsx.snap b/tests/__snapshots__/index.test.tsx.snap index a6e4b53..281c083 100644 --- a/tests/__snapshots__/index.test.tsx.snap +++ b/tests/__snapshots__/index.test.tsx.snap @@ -331,88 +331,6 @@ exports[`Tour basic 1`] = ` />
-
-
-
-
-
- -
-
- 删除 -
-
-
-
- - 危险操作:删除一条数据 - - -
-
- -
-
-
-
`; @@ -985,6 +903,44 @@ exports[`Tour should keep current when controlled 1`] = ` open
+
+
+ + + + + + + + +
+
+
+
+
+ +`; + +exports[`Tour should return step 1 when reopen 1`] = ` + +
+ +
- -`; - -exports[`Tour should return step 1 when reopen 1`] = ` - -
- -
-
-
- - - - - - - - -
-
-
-
-
`; diff --git a/tests/index.test.tsx b/tests/index.test.tsx index 962a481..0dffea0 100644 --- a/tests/index.test.tsx +++ b/tests/index.test.tsx @@ -208,7 +208,7 @@ describe('Tour', () => { expect(getByText('危险操作:删除一条数据')).toBeTruthy(); expect(document.querySelector('.rc-tour')).toBeTruthy(); fireEvent.click(screen.getByRole('button', { name: 'Finish' })); - expect(document.querySelector('.rc-tour-hidden')).toBeTruthy(); + expect(document.querySelector('.rc-tour')).toBeFalsy(); expect(baseElement).toMatchSnapshot(); }); From 53fade10ece65dcfb64853aacb720e71bfb9a5a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Mon, 24 Feb 2025 21:23:28 +0800 Subject: [PATCH 6/7] test: update snapshot --- tests/__snapshots__/index.test.tsx.snap | 2 +- tests/index.test.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/__snapshots__/index.test.tsx.snap b/tests/__snapshots__/index.test.tsx.snap index 281c083..a3ddb3e 100644 --- a/tests/__snapshots__/index.test.tsx.snap +++ b/tests/__snapshots__/index.test.tsx.snap @@ -306,7 +306,7 @@ exports[`Tour animated true 1`] = ` `; -exports[`Tour basic 1`] = ` +exports[`Tour basic1 1`] = `
{ }); }); - it('basic', () => { + it('basic1', () => { const Demo = () => { const createBtnRef = useRef(null); const updateBtnRef = useRef(null); From 32ba2ee2269534026f98b7710ff3f98d1dbdf332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Mon, 24 Feb 2025 21:26:22 +0800 Subject: [PATCH 7/7] test: update snapshot --- tests/__snapshots__/index.test.tsx.snap | 2 +- tests/index.test.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/__snapshots__/index.test.tsx.snap b/tests/__snapshots__/index.test.tsx.snap index a3ddb3e..281c083 100644 --- a/tests/__snapshots__/index.test.tsx.snap +++ b/tests/__snapshots__/index.test.tsx.snap @@ -306,7 +306,7 @@ exports[`Tour animated true 1`] = ` `; -exports[`Tour basic1 1`] = ` +exports[`Tour basic 1`] = `
{ }); }); - it('basic1', () => { + it('basic', () => { const Demo = () => { const createBtnRef = useRef(null); const updateBtnRef = useRef(null);