Skip to content

Commit

Permalink
feat(ui): support custom dropdown for tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
xiejay97 committed Feb 13, 2023
1 parent a59a1d3 commit 862effe
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/ui/src/components/tabs/Tabs.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -21,6 +21,7 @@ export interface DTabItem<ID extends DId> {
id: ID;
title: React.ReactNode;
panel: React.ReactNode;
dropdownItem?: React.ReactNode;
disabled?: boolean;
closable?: boolean;
}
Expand Down Expand Up @@ -343,7 +344,7 @@ function Tabs<ID extends DId, T extends DTabItem<ID>>(props: DTabsProps<ID, T>,
{listOverflow && (
<DDropdown
dList={dropdownList.map<DDropdownItem<ID>>((tab) => {
const { id: itemId, title: itemTitle, disabled: itemDisabled } = tab;
const { id: itemId, title: itemTitle, dropdownItem: itemDropdownItem, disabled: itemDisabled } = tab;

return {
id: itemId,
Expand All @@ -353,7 +354,7 @@ function Tabs<ID extends DId, T extends DTabItem<ID>>(props: DTabsProps<ID, T>,
'is-active': itemId === activeId,
})}
>
{itemTitle}
{isUndefined(itemDropdownItem) ? itemTitle : itemDropdownItem}
</span>
),
type: 'item',
Expand Down

0 comments on commit 862effe

Please sign in to comment.