diff --git a/packages/components/tabs/__tests__/tabs.test.tsx b/packages/components/tabs/__tests__/tabs.test.tsx index a063c3573b..4204208a20 100644 --- a/packages/components/tabs/__tests__/tabs.test.tsx +++ b/packages/components/tabs/__tests__/tabs.test.tsx @@ -6,8 +6,10 @@ import Tabs from '../src/tabs' import TabPane from '../src/tab-pane.vue' import TabNav from '../src/tab-nav' -import type { TabPaneName } from '../src/tabs' -import type { TabsPaneContext } from '@element-plus/components/tabs' +import type { + TabPaneName, + TabsPaneContext, +} from '@element-plus/components/tabs' const Comp = defineComponent({ components: { diff --git a/packages/components/tabs/src/constants.ts b/packages/components/tabs/src/constants.ts index c25e95ad18..c891311a96 100644 --- a/packages/components/tabs/src/constants.ts +++ b/packages/components/tabs/src/constants.ts @@ -2,19 +2,22 @@ import type { ComputedRef, InjectionKey, Ref, Slots, UnwrapRef } from 'vue' import type { TabsProps } from './tabs' import type { TabPaneProps } from './tab-pane' +export type TabPaneName = string | number + export type TabsPaneContext = UnwrapRef<{ uid: number slots: Slots props: TabPaneProps - paneName: ComputedRef + paneName: ComputedRef active: ComputedRef index: Ref isClosable: ComputedRef + isFocusInsidePane: () => boolean | undefined }> export interface TabsRootContext { props: TabsProps - currentName: Ref + currentName: Ref registerPane: (pane: TabsPaneContext) => void unregisterPane: (pane: TabsPaneContext) => void } diff --git a/packages/components/tabs/src/tab-bar.ts b/packages/components/tabs/src/tab-bar.ts index 4c62a59a2e..0183d10d59 100644 --- a/packages/components/tabs/src/tab-bar.ts +++ b/packages/components/tabs/src/tab-bar.ts @@ -1,7 +1,7 @@ import { buildProps, definePropType, mutable } from '@element-plus/utils' import type { ExtractPropTypes } from 'vue' -import type { TabsPaneContext } from './constants' +import type { TabPaneName, TabsPaneContext } from './constants' import type TabBar from './tab-bar.vue' export const tabBarProps = buildProps({ @@ -9,6 +9,10 @@ export const tabBarProps = buildProps({ type: definePropType(Array), default: () => mutable([] as const), }, + tabRefs: { + type: definePropType<{ [key: TabPaneName]: HTMLDivElement }>(Object), + default: () => mutable({} as const), + }, } as const) export type TabBarProps = ExtractPropTypes diff --git a/packages/components/tabs/src/tab-bar.vue b/packages/components/tabs/src/tab-bar.vue index 4faf220a9f..742d11f297 100644 --- a/packages/components/tabs/src/tab-bar.vue +++ b/packages/components/tabs/src/tab-bar.vue @@ -7,16 +7,9 @@