Skip to content

Commit 862effe

Browse files
committed
feat(ui): support custom dropdown for tabs
1 parent a59a1d3 commit 862effe

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

packages/ui/src/components/tabs/Tabs.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { DId, DSize } from '../../utils/types';
22
import type { DDropdownItem } from '../dropdown';
33

4-
import { nth } from 'lodash';
4+
import { isUndefined, nth } from 'lodash';
55
import React, { useEffect, useImperativeHandle, useRef, useState } from 'react';
66

77
import { useEventCallback, useId, useIsomorphicLayoutEffect, useResize } from '@react-devui/hooks';
@@ -21,6 +21,7 @@ export interface DTabItem<ID extends DId> {
2121
id: ID;
2222
title: React.ReactNode;
2323
panel: React.ReactNode;
24+
dropdownItem?: React.ReactNode;
2425
disabled?: boolean;
2526
closable?: boolean;
2627
}
@@ -343,7 +344,7 @@ function Tabs<ID extends DId, T extends DTabItem<ID>>(props: DTabsProps<ID, T>,
343344
{listOverflow && (
344345
<DDropdown
345346
dList={dropdownList.map<DDropdownItem<ID>>((tab) => {
346-
const { id: itemId, title: itemTitle, disabled: itemDisabled } = tab;
347+
const { id: itemId, title: itemTitle, dropdownItem: itemDropdownItem, disabled: itemDisabled } = tab;
347348

348349
return {
349350
id: itemId,
@@ -353,7 +354,7 @@ function Tabs<ID extends DId, T extends DTabItem<ID>>(props: DTabsProps<ID, T>,
353354
'is-active': itemId === activeId,
354355
})}
355356
>
356-
{itemTitle}
357+
{isUndefined(itemDropdownItem) ? itemTitle : itemDropdownItem}
357358
</span>
358359
),
359360
type: 'item',

0 commit comments

Comments
 (0)