Skip to content

Commit

Permalink
feat: can use a wrapper on panel when using items props of collapse
Browse files Browse the repository at this point in the history
  • Loading branch information
Asanio06 committed Jan 8, 2024
1 parent 1def17f commit cb9d480
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
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 convertItemsToNodes = (items: ItemType[], props: Props) => {
const {
children,
label,
wrapper,
key: rawKey,
collapsible: rawCollapsible,
onItemClick: rawOnItemClick,
Expand All @@ -50,7 +51,7 @@ const convertItemsToNodes = (items: ItemType[], props: Props) => {
isActive = activeKey.indexOf(key) > -1;
}

return (
const collapsePanel = (
<CollapsePanel
{...restProps}
prefixCls={prefixCls}
Expand All @@ -68,6 +69,12 @@ const convertItemsToNodes = (items: ItemType[], props: Props) => {
{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

0 comments on commit cb9d480

Please sign in to comment.