Skip to content

Commit cf0fa80

Browse files
li-jia-nanzombieJ
andauthored
refactor: Replace with destroyOnHidden (#364)
* Refactoring * Refactoring * Refactoring * chore: update vercel * chore: fix peer * chore: update build config --------- Co-authored-by: 二货机器人 <[email protected]>
1 parent 74a99fe commit cf0fa80

File tree

14 files changed

+59
-54
lines changed

14 files changed

+59
-54
lines changed

.dumirc.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export default defineConfig({
1616
name: 'Collapse',
1717
logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
1818
},
19-
outputPath: '.doc',
2019
base: basePath,
2120
publicPath,
2221
});

.github/workflows/site-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
uses: peaceiris/actions-gh-pages@v3
3434
with:
3535
github_token: ${{ secrets.GITHUB_TOKEN }}
36-
publish_dir: ./.doc
36+
publish_dir: ./dist
3737
force_orphan: true
3838
user_name: 'github-actions[bot]'
3939
user_email: 'github-actions[bot]@users.noreply.github.com'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ coverage
2828
es
2929
yarn.lock
3030
package-lock.json
31+
pnpm-lock.yaml
3132
.storybook
3233
.doc
3334

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ ReactDOM.render(App, container);
7878
<td>default active key</td>
7979
</tr>
8080
<tr>
81-
<td>destroyInactivePanel</td>
81+
<td>destroyOnHidden</td>
8282
<td>Boolean</td>
8383
<th>false</th>
8484
<td>If destroy the panel which not active, default false. </td>

docs/examples/_util/motionUtil.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import type { CSSMotionProps, MotionEndEventHandler, MotionEventHandler } from 'rc-motion';
1+
import type {
2+
CSSMotionProps,
3+
MotionEndEventHandler,
4+
MotionEventHandler,
5+
} from '@rc-component/motion';
26

37
const getCollapsedHeight: MotionEventHandler = () => ({ height: 0, opacity: 0 });
48
const getRealHeight: MotionEventHandler = (node) => ({ height: node.scrollHeight, opacity: 1 });

now.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

package.json

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"compile": "father build && lessc assets/index.less assets/index.css",
3232
"coverage": "rc-test --coverage",
3333
"docs:build": "dumi build",
34-
"docs:deploy": "npm run docs:build && gh-pages -d .doc",
34+
"docs:deploy": "npm run docs:build && gh-pages -d dist",
3535
"lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md",
3636
"prepare": "husky",
3737
"now-build": "npm run docs:build",
@@ -46,19 +46,21 @@
4646
},
4747
"dependencies": {
4848
"@babel/runtime": "^7.10.1",
49+
"@rc-component/motion": "^1.1.4",
4950
"@rc-component/util": "^1.0.1",
50-
"classnames": "2.x",
51-
"rc-motion": "^2.3.4"
51+
"classnames": "2.x"
5252
},
5353
"devDependencies": {
5454
"@rc-component/father-plugin": "^2.0.1",
55+
"@rc-component/np": "^1.0.4",
5556
"@testing-library/jest-dom": "^6.1.4",
56-
"@testing-library/react": "^14.1.2",
57+
"@testing-library/react": "^16.3.0",
5758
"@testing-library/user-event": "^14.5.2",
5859
"@types/classnames": "^2.2.9",
5960
"@types/jest": "^29.4.0",
60-
"@types/react": "^18.0.0",
61-
"@types/react-dom": "^18.0.0",
61+
"@types/node": "^22.15.18",
62+
"@types/react": "^19.1.4",
63+
"@types/react-dom": "^19.1.5",
6264
"@umijs/fabric": "^4.0.0",
6365
"dumi": "^2.1.1",
6466
"eslint": "^8.55.0",
@@ -70,15 +72,14 @@
7072
"jest": "^29.1.2",
7173
"less": "^4.2.0",
7274
"lint-staged": "^15.0.2",
73-
"np": "^9.1.0",
7475
"prettier": "^3.0.3",
7576
"rc-test": "^7.0.14",
76-
"react": "^18.2.0",
77-
"react-dom": "^18.2.0",
77+
"react": "^19.1.0",
78+
"react-dom": "^19.1.0",
7879
"typescript": "^5.0.0"
7980
},
8081
"peerDependencies": {
81-
"react": ">=16.9.0",
82-
"react-dom": ">=16.9.0"
82+
"react": ">=18.0.0",
83+
"react-dom": ">=18.0.0"
8384
}
8485
}

src/Collapse.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function getActiveKeysArray(activeKey: React.Key | React.Key[]) {
2020
const Collapse = React.forwardRef<HTMLDivElement, CollapseProps>((props, ref) => {
2121
const {
2222
prefixCls = 'rc-collapse',
23-
destroyInactivePanel = false,
23+
destroyOnHidden = false,
2424
style,
2525
accordion,
2626
className,
@@ -72,7 +72,7 @@ const Collapse = React.forwardRef<HTMLDivElement, CollapseProps>((props, ref) =>
7272
openMotion,
7373
expandIcon,
7474
collapsible,
75-
destroyInactivePanel,
75+
destroyOnHidden,
7676
onItemClick,
7777
activeKey,
7878
classNames: customizeClassNames,

src/Panel.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import classNames from 'classnames';
2-
import CSSMotion from 'rc-motion';
2+
import CSSMotion from '@rc-component/motion';
33
import KeyCode from '@rc-component/util/lib/KeyCode';
44
import React from 'react';
55
import type { CollapsePanelProps } from './interface';
@@ -23,7 +23,7 @@ const CollapsePanel = React.forwardRef<HTMLDivElement, CollapsePanelProps>((prop
2323
header,
2424
expandIcon,
2525
openMotion,
26-
destroyInactivePanel,
26+
destroyOnHidden,
2727
children,
2828
...resetProps
2929
} = props;
@@ -104,7 +104,7 @@ const CollapsePanel = React.forwardRef<HTMLDivElement, CollapsePanelProps>((prop
104104
leavedClassName={`${prefixCls}-panel-hidden`}
105105
{...openMotion}
106106
forceRender={forceRender}
107-
removeOnLeave={destroyInactivePanel}
107+
removeOnLeave={destroyOnHidden}
108108
>
109109
{({ className: motionClassName, style: motionStyle }, motionRef) => {
110110
return (
@@ -117,7 +117,7 @@ const CollapsePanel = React.forwardRef<HTMLDivElement, CollapsePanelProps>((prop
117117
styles={styles}
118118
isActive={isActive}
119119
forceRender={forceRender}
120-
role={accordion ? 'tabpanel' : void 0}
120+
role={accordion ? 'tabpanel' : undefined}
121121
>
122122
{children}
123123
</PanelContent>

src/PanelContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { CollapsePanelProps } from './interface';
44

55
const PanelContent = React.forwardRef<
66
HTMLDivElement,
7-
CollapsePanelProps & { children: React.ReactNode }
7+
React.PropsWithChildren<Readonly<CollapsePanelProps>>
88
>((props, ref) => {
99
const {
1010
prefixCls,

0 commit comments

Comments
 (0)