Skip to content

Commit

Permalink
feat: add wrapTo method for action panel items (#191)
Browse files Browse the repository at this point in the history
* feat: add render item method for action panel items

* fix: callback types

* fix: rename render item method to wrap to
  • Loading branch information
flops authored Sep 16, 2024
1 parent a21ae82 commit 1dab089
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/components/ActionPanel/ActionPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ export const ActionPanel = (props: ActionPanelProps) => {

const content = (
<div ref={nodeRef} className={b(null, props.className)}>
{props.items.map((item) => (
<ActionPanelItemContainer key={`dk-action-panel-${item.id}`} item={item} />
))}
{props.items.map(({wrapTo, ...item}) => {
const key = `dk-action-panel-${item.id}`;
const children = <ActionPanelItemContainer key={key} item={item} />;

return wrapTo ? wrapTo({...item, key, children}) : children;
})}
</div>
);

Expand Down
3 changes: 3 additions & 0 deletions src/components/ActionPanel/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export type ActionPanelItem = {
qa?: string;
onClick?: () => void;
dragProps?: ItemDragProps;
wrapTo?: (
props: Omit<ActionPanelItem, 'wrapTo'> & {key: React.Key; children: React.ReactNode},
) => React.ReactNode;
};

export type ActionPanelProps = {
Expand Down

0 comments on commit 1dab089

Please sign in to comment.