From 862effe59bf0945b43d200e6b65811528890e7d8 Mon Sep 17 00:00:00 2001 From: xiejay97 Date: Mon, 13 Feb 2023 11:03:52 +0800 Subject: [PATCH] feat(ui): support custom dropdown for tabs --- packages/ui/src/components/tabs/Tabs.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/ui/src/components/tabs/Tabs.tsx b/packages/ui/src/components/tabs/Tabs.tsx index a14a2016..71fdb678 100644 --- a/packages/ui/src/components/tabs/Tabs.tsx +++ b/packages/ui/src/components/tabs/Tabs.tsx @@ -1,7 +1,7 @@ import type { DId, DSize } from '../../utils/types'; import type { DDropdownItem } from '../dropdown'; -import { nth } from 'lodash'; +import { isUndefined, nth } from 'lodash'; import React, { useEffect, useImperativeHandle, useRef, useState } from 'react'; import { useEventCallback, useId, useIsomorphicLayoutEffect, useResize } from '@react-devui/hooks'; @@ -21,6 +21,7 @@ export interface DTabItem { id: ID; title: React.ReactNode; panel: React.ReactNode; + dropdownItem?: React.ReactNode; disabled?: boolean; closable?: boolean; } @@ -343,7 +344,7 @@ function Tabs>(props: DTabsProps, {listOverflow && ( >((tab) => { - const { id: itemId, title: itemTitle, disabled: itemDisabled } = tab; + const { id: itemId, title: itemTitle, dropdownItem: itemDropdownItem, disabled: itemDisabled } = tab; return { id: itemId, @@ -353,7 +354,7 @@ function Tabs>(props: DTabsProps, 'is-active': itemId === activeId, })} > - {itemTitle} + {isUndefined(itemDropdownItem) ? itemTitle : itemDropdownItem} ), type: 'item',