Skip to content

Commit f8ac9ab

Browse files
committed
fix: 解决冲突
2 parents 20ea000 + da6f7fa commit f8ac9ab

File tree

13 files changed

+61
-59
lines changed

13 files changed

+61
-59
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'

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: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rc-component/collapse",
3-
"version": "1.0.1",
3+
"version": "1.1.0",
44
"description": "rc-collapse ui component for react",
55
"keywords": [
66
"react",
@@ -31,11 +31,11 @@
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",
38-
"prepublishOnly": "npm run compile && np --yolo --no-publish",
38+
"prepublishOnly": "npm run compile && rc-np",
3939
"prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
4040
"postpublish": "npm run docs:deploy",
4141
"start": "dumi dev",
@@ -46,20 +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.3",
55+
"@rc-component/np": "^1.0.4",
5656
"@testing-library/jest-dom": "^6.1.4",
57-
"@testing-library/react": "^14.1.2",
57+
"@testing-library/react": "^16.3.0",
5858
"@testing-library/user-event": "^14.5.2",
5959
"@types/classnames": "^2.2.9",
6060
"@types/jest": "^29.4.0",
61-
"@types/react": "^18.0.0",
62-
"@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",
6364
"@umijs/fabric": "^4.0.0",
6465
"dumi": "^2.1.1",
6566
"eslint": "^8.55.0",
@@ -71,15 +72,14 @@
7172
"jest": "^29.1.2",
7273
"less": "^4.2.0",
7374
"lint-staged": "^15.0.2",
74-
"np": "^9.1.0",
7575
"prettier": "^3.0.3",
7676
"rc-test": "^7.0.14",
77-
"react": "^18.2.0",
78-
"react-dom": "^18.2.0",
77+
"react": "^19.1.0",
78+
"react-dom": "^19.1.0",
7979
"typescript": "^5.0.0"
8080
},
8181
"peerDependencies": {
82-
"react": ">=16.9.0",
83-
"react-dom": ">=16.9.0"
82+
"react": ">=18.0.0",
83+
"react-dom": ">=18.0.0"
8484
}
8585
}

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,
@@ -76,7 +76,7 @@ const Collapse = React.forwardRef<HTMLDivElement, CollapseProps>((props, ref) =>
7676
openMotion,
7777
expandIcon,
7878
collapsible,
79-
destroyInactivePanel,
79+
destroyOnHidden,
8080
onItemClick,
8181
activeKey,
8282
classNames: customizeClassNames,

src/Panel.tsx

Lines changed: 6 additions & 6 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, { useMemo } from 'react';
55
import type { CollapsePanelProps } from './interface';
@@ -23,7 +23,7 @@ const CollapsePanel = React.forwardRef<HTMLDetailsElement, CollapsePanelProps>((
2323
header,
2424
expandIcon,
2525
openMotion,
26-
destroyInactivePanel,
26+
destroyOnHidden,
2727
children,
2828
...resetProps
2929
} = props;
@@ -104,7 +104,7 @@ const CollapsePanel = React.forwardRef<HTMLDetailsElement, CollapsePanelProps>((
104104
options: Partial<{
105105
motionClassName: string;
106106
style: React.CSSProperties;
107-
motionRef: (node: HTMLDivElement) => void;
107+
motionRef: React.Ref<any>;
108108
}>,
109109
) => {
110110
const { motionClassName, style, motionRef } = options;
@@ -131,7 +131,7 @@ const CollapsePanel = React.forwardRef<HTMLDetailsElement, CollapsePanelProps>((
131131
leavedClassName={leavedClassName}
132132
{...openMotion}
133133
forceRender={forceRender}
134-
removeOnLeave={destroyInactivePanel}
134+
removeOnLeave={destroyOnHidden}
135135
>
136136
{({ className: motionClassName, style }, motionRef) =>
137137
createPanelContent({
@@ -147,11 +147,11 @@ const CollapsePanel = React.forwardRef<HTMLDetailsElement, CollapsePanelProps>((
147147
if (supportsDetailsContentSelector) {
148148
if (isActive) {
149149
detailsChildren = createPanelContent({});
150-
} else if (!destroyInactivePanel && leavedClassName) {
150+
} else if (!destroyOnHidden && leavedClassName) {
151151
detailsChildren = createPanelContent({
152152
motionClassName: leavedClassName,
153153
});
154-
} else if (forceRender || (!destroyInactivePanel && !leavedClassName)) {
154+
} else if (forceRender || (!destroyOnHidden && !leavedClassName)) {
155155
detailsChildren = createPanelContent({
156156
style: { display: 'none' },
157157
});

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,

src/hooks/useItems.tsx

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ type Props = Pick<
77
CollapsePanelProps,
88
'prefixCls' | 'onItemClick' | 'openMotion' | 'expandIcon' | 'classNames' | 'styles'
99
> &
10-
Pick<CollapseProps, 'accordion' | 'collapsible' | 'destroyInactivePanel'> & {
10+
Pick<CollapseProps, 'accordion' | 'collapsible' | 'destroyOnHidden'> & {
1111
activeKey: React.Key[];
1212
};
1313

@@ -16,7 +16,7 @@ const convertItemsToNodes = (items: ItemType[], props: Props) => {
1616
prefixCls,
1717
accordion,
1818
collapsible,
19-
destroyInactivePanel,
19+
destroyOnHidden,
2020
onItemClick,
2121
activeKey,
2222
openMotion,
@@ -32,18 +32,20 @@ const convertItemsToNodes = (items: ItemType[], props: Props) => {
3232
key: rawKey,
3333
collapsible: rawCollapsible,
3434
onItemClick: rawOnItemClick,
35-
destroyInactivePanel: rawDestroyInactivePanel,
35+
destroyOnHidden: rawDestroyOnHidden,
3636
...restProps
3737
} = item;
3838

3939
// You may be puzzled why you want to convert them all into strings, me too.
4040
// Maybe: https://github.com/react-component/collapse/blob/aac303a8b6ff30e35060b4f8fecde6f4556fcbe2/src/Collapse.tsx#L15
4141
const key = String(rawKey ?? index);
4242
const mergeCollapsible = rawCollapsible ?? collapsible;
43-
const mergeDestroyInactivePanel = rawDestroyInactivePanel ?? destroyInactivePanel;
43+
const mergedDestroyOnHidden = rawDestroyOnHidden ?? destroyOnHidden;
4444

4545
const handleItemClick = (value: React.Key) => {
46-
if (mergeCollapsible === 'disabled') return;
46+
if (mergeCollapsible === 'disabled') {
47+
return;
48+
}
4749
onItemClick(value);
4850
rawOnItemClick?.(value);
4951
};
@@ -70,7 +72,7 @@ const convertItemsToNodes = (items: ItemType[], props: Props) => {
7072
header={label}
7173
collapsible={mergeCollapsible}
7274
onItemClick={handleItemClick}
73-
destroyInactivePanel={mergeDestroyInactivePanel}
75+
destroyOnHidden={mergedDestroyOnHidden}
7476
>
7577
{children}
7678
</CollapsePanel>
@@ -86,13 +88,15 @@ const getNewChild = (
8688
index: number,
8789
props: Props,
8890
) => {
89-
if (!child) return null;
91+
if (!child) {
92+
return null;
93+
}
9094

9195
const {
9296
prefixCls,
9397
accordion,
9498
collapsible,
95-
destroyInactivePanel,
99+
destroyOnHidden,
96100
onItemClick,
97101
activeKey,
98102
openMotion,
@@ -106,7 +110,7 @@ const getNewChild = (
106110
const {
107111
header,
108112
headerClass,
109-
destroyInactivePanel: childDestroyInactivePanel,
113+
destroyOnHidden: childDestroyOnHidden,
110114
collapsible: childCollapsible,
111115
onItemClick: childOnItemClick,
112116
} = child.props;
@@ -121,7 +125,9 @@ const getNewChild = (
121125
const mergeCollapsible = childCollapsible ?? collapsible;
122126

123127
const handleItemClick = (value: React.Key) => {
124-
if (mergeCollapsible === 'disabled') return;
128+
if (mergeCollapsible === 'disabled') {
129+
return;
130+
}
125131
onItemClick(value);
126132
childOnItemClick?.(value);
127133
};
@@ -135,7 +141,7 @@ const getNewChild = (
135141
styles,
136142
isActive,
137143
prefixCls,
138-
destroyInactivePanel: childDestroyInactivePanel ?? destroyInactivePanel,
144+
destroyOnHidden: childDestroyOnHidden ?? destroyOnHidden,
139145
openMotion,
140146
accordion,
141147
children: child.props.children,
@@ -155,7 +161,7 @@ const getNewChild = (
155161
}
156162
});
157163

158-
return React.cloneElement(child, childProps);
164+
return React.cloneElement<CollapsePanelProps>(child, childProps);
159165
};
160166

161167
function useItems(
@@ -166,8 +172,9 @@ function useItems(
166172
if (Array.isArray(items)) {
167173
return convertItemsToNodes(items, props);
168174
}
169-
170-
return toArray(rawChildren).map((child, index) => getNewChild(child, index, props));
175+
return toArray(rawChildren).map((child, index) =>
176+
getNewChild(child as React.ReactElement<CollapsePanelProps>, index, props),
177+
);
171178
}
172179

173180
export default useItems;

0 commit comments

Comments
 (0)