Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: can use a wrapper on panel when using items props of collapse #335

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/hooks/useItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
const {
children,
label,
wrapper,
key: rawKey,
collapsible: rawCollapsible,
onItemClick: rawOnItemClick,
Expand All @@ -50,7 +51,7 @@
isActive = activeKey.indexOf(key) > -1;
}

return (
const collapsePanel = (
<CollapsePanel
{...restProps}
prefixCls={prefixCls}
Expand All @@ -68,6 +69,12 @@
{children}
</CollapsePanel>
);

if (wrapper) {
return wrapper(collapsePanel);

Check warning on line 74 in src/hooks/useItems.tsx

View check run for this annotation

Codecov / codecov/patch

src/hooks/useItems.tsx#L74

Added line #L74 was not covered by tests
}

return collapsePanel;
});
};

Expand Down
2 changes: 2 additions & 0 deletions src/interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { CSSMotionProps } from 'rc-motion';
import type * as React from 'react';
import type { ReactNode } from 'react';

export type CollapsibleType = 'header' | 'icon' | 'disabled';

Expand All @@ -16,6 +17,7 @@ export interface ItemType
> {
key?: CollapsePanelProps['panelKey'];
label?: CollapsePanelProps['header'];
wrapper?: ReactNode;
ref?: React.RefObject<HTMLDivElement>;
}

Expand Down
Loading