This commit is contained in:
2025-09-19 14:25:20 +08:00
parent 269893a435
commit fbf3f77229
24949 changed files with 2839404 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
import Tabs from './src/tabs';
import TabPane from './src/tab-pane.vue';
import type { SFCWithInstall } from 'element-plus/es/utils';
export declare const ElTabs: SFCWithInstall<typeof Tabs> & {
TabPane: typeof TabPane;
};
export declare const ElTabPane: SFCWithInstall<typeof TabPane>;
export default ElTabs;
export * from './src/tabs';
export * from './src/tab-bar';
export * from './src/tab-nav';
export * from './src/tab-pane';
export * from './src/constants';

16
node_modules/element-plus/es/components/tabs/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,16 @@
import Tabs from './src/tabs.mjs';
export { tabsEmits, tabsProps } from './src/tabs.mjs';
import TabPane from './src/tab-pane.mjs';
export { tabBarProps } from './src/tab-bar.mjs';
export { tabNavEmits, tabNavProps } from './src/tab-nav.mjs';
export { tabPaneProps } from './src/tab-pane2.mjs';
export { tabsRootContextKey } from './src/constants.mjs';
import { withInstall, withNoopInstall } from '../../utils/vue/install.mjs';
const ElTabs = withInstall(Tabs, {
TabPane
});
const ElTabPane = withNoopInstall(TabPane);
export { ElTabPane, ElTabs, ElTabs as default };
//# sourceMappingURL=index.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":["../../../../../packages/components/tabs/index.ts"],"sourcesContent":["import { withInstall, withNoopInstall } from '@element-plus/utils'\nimport Tabs from './src/tabs'\nimport TabPane from './src/tab-pane.vue'\n\nimport type { SFCWithInstall } from '@element-plus/utils'\n\nexport const ElTabs: SFCWithInstall<typeof Tabs> & {\n TabPane: typeof TabPane\n} = withInstall(Tabs, {\n TabPane,\n})\nexport const ElTabPane: SFCWithInstall<typeof TabPane> =\n withNoopInstall(TabPane)\nexport default ElTabs\n\nexport * from './src/tabs'\nexport * from './src/tab-bar'\nexport * from './src/tab-nav'\nexport * from './src/tab-pane'\nexport * from './src/constants'\n"],"names":[],"mappings":";;;;;;;;;AAGY,MAAC,MAAM,GAAG,WAAW,CAAC,IAAI,EAAE;AACxC,EAAE,OAAO;AACT,CAAC,EAAE;AACS,MAAC,SAAS,GAAG,eAAe,CAAC,OAAO;;;;"}

View File

@@ -0,0 +1,24 @@
import type { ComputedRef, InjectionKey, Ref, Slots, UnwrapRef, VNode } from 'vue';
import type { TabsProps } from './tabs';
import type { TabPaneProps } from './tab-pane';
import type { TabNavInstance } from './tab-nav';
export type TabPaneName = string | number;
export type TabsPaneContext = UnwrapRef<{
uid: number;
getVnode: () => VNode;
slots: Slots;
props: TabPaneProps;
paneName: ComputedRef<TabPaneName | undefined>;
active: ComputedRef<boolean>;
index: Ref<string | undefined>;
isClosable: ComputedRef<boolean>;
isFocusInsidePane: () => boolean | undefined;
}>;
export interface TabsRootContext {
props: TabsProps;
currentName: Ref<TabPaneName>;
registerPane: (pane: TabsPaneContext) => void;
unregisterPane: (pane: TabsPaneContext) => void;
nav$: Ref<TabNavInstance | undefined>;
}
export declare const tabsRootContextKey: InjectionKey<TabsRootContext>;

View File

@@ -0,0 +1,4 @@
const tabsRootContextKey = Symbol("tabsRootContextKey");
export { tabsRootContextKey };
//# sourceMappingURL=constants.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.mjs","sources":["../../../../../../packages/components/tabs/src/constants.ts"],"sourcesContent":["import type {\n ComputedRef,\n InjectionKey,\n Ref,\n Slots,\n UnwrapRef,\n VNode,\n} from 'vue'\nimport type { TabsProps } from './tabs'\nimport type { TabPaneProps } from './tab-pane'\nimport type { TabNavInstance } from './tab-nav'\n\nexport type TabPaneName = string | number\n\nexport type TabsPaneContext = UnwrapRef<{\n uid: number\n getVnode: () => VNode\n slots: Slots\n props: TabPaneProps\n paneName: ComputedRef<TabPaneName | undefined>\n active: ComputedRef<boolean>\n index: Ref<string | undefined>\n isClosable: ComputedRef<boolean>\n isFocusInsidePane: () => boolean | undefined\n}>\n\nexport interface TabsRootContext {\n props: TabsProps\n currentName: Ref<TabPaneName>\n registerPane: (pane: TabsPaneContext) => void\n unregisterPane: (pane: TabsPaneContext) => void\n nav$: Ref<TabNavInstance | undefined>\n}\n\nexport const tabsRootContextKey: InjectionKey<TabsRootContext> =\n Symbol('tabsRootContextKey')\n"],"names":[],"mappings":"AAAY,MAAC,kBAAkB,GAAG,MAAM,CAAC,oBAAoB;;;;"}

View File

@@ -0,0 +1,86 @@
import type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue';
import type { TabPaneName } from './constants';
import type TabBar from './tab-bar.vue';
export declare const tabBarProps: {
readonly tabs: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => {
uid: number;
getVnode: () => import("vue").VNode;
slots: import("vue").Slots;
props: {
readonly label: string;
readonly disabled: boolean;
readonly lazy: boolean;
readonly name?: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
readonly closable?: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown> | undefined;
};
paneName: TabPaneName | undefined;
active: boolean;
index: string | undefined;
isClosable: boolean;
isFocusInsidePane: () => boolean | undefined;
}[]) | (() => {
uid: number;
getVnode: () => import("vue").VNode;
slots: import("vue").Slots;
props: {
readonly label: string;
readonly disabled: boolean;
readonly lazy: boolean;
readonly name?: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
readonly closable?: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown> | undefined;
};
paneName: TabPaneName | undefined;
active: boolean;
index: string | undefined;
isClosable: boolean;
isFocusInsidePane: () => boolean | undefined;
}[]) | ((new (...args: any[]) => {
uid: number;
getVnode: () => import("vue").VNode;
slots: import("vue").Slots;
props: {
readonly label: string;
readonly disabled: boolean;
readonly lazy: boolean;
readonly name?: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
readonly closable?: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown> | undefined;
};
paneName: TabPaneName | undefined;
active: boolean;
index: string | undefined;
isClosable: boolean;
isFocusInsidePane: () => boolean | undefined;
}[]) | (() => {
uid: number;
getVnode: () => import("vue").VNode;
slots: import("vue").Slots;
props: {
readonly label: string;
readonly disabled: boolean;
readonly lazy: boolean;
readonly name?: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
readonly closable?: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown> | undefined;
};
paneName: TabPaneName | undefined;
active: boolean;
index: string | undefined;
isClosable: boolean;
isFocusInsidePane: () => boolean | undefined;
}[]))[], unknown, unknown, () => [], boolean>;
readonly tabRefs: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => {
[key: string]: HTMLDivElement;
[key: number]: HTMLDivElement;
}) | (() => {
[key: string]: HTMLDivElement;
[key: number]: HTMLDivElement;
}) | ((new (...args: any[]) => {
[key: string]: HTMLDivElement;
[key: number]: HTMLDivElement;
}) | (() => {
[key: string]: HTMLDivElement;
[key: number]: HTMLDivElement;
}))[], unknown, unknown, () => import("element-plus/es/utils").Mutable<{}>, boolean>;
};
export type TabBarProps = ExtractPropTypes<typeof tabBarProps>;
export type TabBarPropsPublic = __ExtractPublicPropTypes<typeof tabBarProps>;
export type TabBarInstance = InstanceType<typeof TabBar> & unknown;

View File

@@ -0,0 +1,16 @@
import { buildProps, definePropType } from '../../../utils/vue/props/runtime.mjs';
import { mutable } from '../../../utils/typescript.mjs';
const tabBarProps = buildProps({
tabs: {
type: definePropType(Array),
default: () => mutable([])
},
tabRefs: {
type: definePropType(Object),
default: () => mutable({})
}
});
export { tabBarProps };
//# sourceMappingURL=tab-bar.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"tab-bar.mjs","sources":["../../../../../../packages/components/tabs/src/tab-bar.ts"],"sourcesContent":["import { buildProps, definePropType, mutable } from '@element-plus/utils'\n\nimport type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue'\nimport type { TabPaneName, TabsPaneContext } from './constants'\nimport type TabBar from './tab-bar.vue'\n\nexport const tabBarProps = buildProps({\n tabs: {\n type: definePropType<TabsPaneContext[]>(Array),\n default: () => mutable([] as const),\n },\n tabRefs: {\n type: definePropType<{ [key: TabPaneName]: HTMLDivElement }>(Object),\n default: () => mutable({} as const),\n },\n} as const)\n\nexport type TabBarProps = ExtractPropTypes<typeof tabBarProps>\nexport type TabBarPropsPublic = __ExtractPublicPropTypes<typeof tabBarProps>\nexport type TabBarInstance = InstanceType<typeof TabBar> & unknown\n"],"names":[],"mappings":";;;AACY,MAAC,WAAW,GAAG,UAAU,CAAC;AACtC,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAE,cAAc,CAAC,KAAK,CAAC;AAC/B,IAAI,OAAO,EAAE,MAAM,OAAO,CAAC,EAAE,CAAC;AAC9B,GAAG;AACH,EAAE,OAAO,EAAE;AACX,IAAI,IAAI,EAAE,cAAc,CAAC,MAAM,CAAC;AAChC,IAAI,OAAO,EAAE,MAAM,OAAO,CAAC,EAAE,CAAC;AAC9B,GAAG;AACH,CAAC;;;;"}

View File

@@ -0,0 +1,188 @@
import type { CSSProperties } from 'vue';
declare const _default: import("vue").DefineComponent<{
readonly tabs: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => {
uid: number;
getVnode: () => import("vue").VNode;
slots: import("vue").Slots;
props: {
readonly label: string;
readonly disabled: boolean;
readonly lazy: boolean;
readonly name?: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
readonly closable?: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown> | undefined;
};
paneName: import("./constants").TabPaneName | undefined;
active: boolean;
index: string | undefined;
isClosable: boolean;
isFocusInsidePane: () => boolean | undefined;
}[]) | (() => {
uid: number;
getVnode: () => import("vue").VNode;
slots: import("vue").Slots;
props: {
readonly label: string;
readonly disabled: boolean;
readonly lazy: boolean;
readonly name?: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
readonly closable?: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown> | undefined;
};
paneName: import("./constants").TabPaneName | undefined;
active: boolean;
index: string | undefined;
isClosable: boolean;
isFocusInsidePane: () => boolean | undefined;
}[]) | ((new (...args: any[]) => {
uid: number;
getVnode: () => import("vue").VNode;
slots: import("vue").Slots;
props: {
readonly label: string;
readonly disabled: boolean;
readonly lazy: boolean;
readonly name?: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
readonly closable?: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown> | undefined;
};
paneName: import("./constants").TabPaneName | undefined;
active: boolean;
index: string | undefined;
isClosable: boolean;
isFocusInsidePane: () => boolean | undefined;
}[]) | (() => {
uid: number;
getVnode: () => import("vue").VNode;
slots: import("vue").Slots;
props: {
readonly label: string;
readonly disabled: boolean;
readonly lazy: boolean;
readonly name?: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
readonly closable?: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown> | undefined;
};
paneName: import("./constants").TabPaneName | undefined;
active: boolean;
index: string | undefined;
isClosable: boolean;
isFocusInsidePane: () => boolean | undefined;
}[]))[], unknown, unknown, () => [], boolean>;
readonly tabRefs: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => {
[key: string]: HTMLDivElement;
[key: number]: HTMLDivElement;
}) | (() => {
[key: string]: HTMLDivElement;
[key: number]: HTMLDivElement;
}) | ((new (...args: any[]) => {
[key: string]: HTMLDivElement;
[key: number]: HTMLDivElement;
}) | (() => {
[key: string]: HTMLDivElement;
[key: number]: HTMLDivElement;
}))[], unknown, unknown, () => import("element-plus/es/utils").Mutable<{}>, boolean>;
}, {
/** @description tab root html element */
ref: import("vue").Ref<HTMLDivElement | undefined>;
/** @description method to manually update tab bar style */
update: () => CSSProperties;
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
readonly tabs: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => {
uid: number;
getVnode: () => import("vue").VNode;
slots: import("vue").Slots;
props: {
readonly label: string;
readonly disabled: boolean;
readonly lazy: boolean;
readonly name?: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
readonly closable?: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown> | undefined;
};
paneName: import("./constants").TabPaneName | undefined;
active: boolean;
index: string | undefined;
isClosable: boolean;
isFocusInsidePane: () => boolean | undefined;
}[]) | (() => {
uid: number;
getVnode: () => import("vue").VNode;
slots: import("vue").Slots;
props: {
readonly label: string;
readonly disabled: boolean;
readonly lazy: boolean;
readonly name?: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
readonly closable?: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown> | undefined;
};
paneName: import("./constants").TabPaneName | undefined;
active: boolean;
index: string | undefined;
isClosable: boolean;
isFocusInsidePane: () => boolean | undefined;
}[]) | ((new (...args: any[]) => {
uid: number;
getVnode: () => import("vue").VNode;
slots: import("vue").Slots;
props: {
readonly label: string;
readonly disabled: boolean;
readonly lazy: boolean;
readonly name?: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
readonly closable?: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown> | undefined;
};
paneName: import("./constants").TabPaneName | undefined;
active: boolean;
index: string | undefined;
isClosable: boolean;
isFocusInsidePane: () => boolean | undefined;
}[]) | (() => {
uid: number;
getVnode: () => import("vue").VNode;
slots: import("vue").Slots;
props: {
readonly label: string;
readonly disabled: boolean;
readonly lazy: boolean;
readonly name?: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
readonly closable?: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown> | undefined;
};
paneName: import("./constants").TabPaneName | undefined;
active: boolean;
index: string | undefined;
isClosable: boolean;
isFocusInsidePane: () => boolean | undefined;
}[]))[], unknown, unknown, () => [], boolean>;
readonly tabRefs: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => {
[key: string]: HTMLDivElement;
[key: number]: HTMLDivElement;
}) | (() => {
[key: string]: HTMLDivElement;
[key: number]: HTMLDivElement;
}) | ((new (...args: any[]) => {
[key: string]: HTMLDivElement;
[key: number]: HTMLDivElement;
}) | (() => {
[key: string]: HTMLDivElement;
[key: number]: HTMLDivElement;
}))[], unknown, unknown, () => import("element-plus/es/utils").Mutable<{}>, boolean>;
}>>, {
readonly tabs: {
uid: number;
getVnode: () => import("vue").VNode;
slots: import("vue").Slots;
props: {
readonly label: string;
readonly disabled: boolean;
readonly lazy: boolean;
readonly name?: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
readonly closable?: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown> | undefined;
};
paneName: import("./constants").TabPaneName | undefined;
active: boolean;
index: string | undefined;
isClosable: boolean;
isFocusInsidePane: () => boolean | undefined;
}[];
readonly tabRefs: {
[key: string]: HTMLDivElement;
[key: number]: HTMLDivElement;
};
}>;
export default _default;

View File

@@ -0,0 +1,92 @@
import { defineComponent, inject, ref, watch, nextTick, onBeforeUnmount, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle } from 'vue';
import { useResizeObserver } from '@vueuse/core';
import { tabsRootContextKey } from './constants.mjs';
import { tabBarProps } from './tab-bar.mjs';
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
import { capitalize } from '../../../utils/strings.mjs';
import { throwError } from '../../../utils/error.mjs';
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
import { isUndefined } from '../../../utils/types.mjs';
const COMPONENT_NAME = "ElTabBar";
const __default__ = defineComponent({
name: COMPONENT_NAME
});
const _sfc_main = /* @__PURE__ */ defineComponent({
...__default__,
props: tabBarProps,
setup(__props, { expose }) {
const props = __props;
const rootTabs = inject(tabsRootContextKey);
if (!rootTabs)
throwError(COMPONENT_NAME, "<el-tabs><el-tab-bar /></el-tabs>");
const ns = useNamespace("tabs");
const barRef = ref();
const barStyle = ref();
const getBarStyle = () => {
let offset = 0;
let tabSize = 0;
const sizeName = ["top", "bottom"].includes(rootTabs.props.tabPosition) ? "width" : "height";
const sizeDir = sizeName === "width" ? "x" : "y";
const position = sizeDir === "x" ? "left" : "top";
props.tabs.every((tab) => {
if (isUndefined(tab.paneName))
return false;
const $el = props.tabRefs[tab.paneName];
if (!$el)
return false;
if (!tab.active) {
return true;
}
offset = $el[`offset${capitalize(position)}`];
tabSize = $el[`client${capitalize(sizeName)}`];
const tabStyles = window.getComputedStyle($el);
if (sizeName === "width") {
tabSize -= Number.parseFloat(tabStyles.paddingLeft) + Number.parseFloat(tabStyles.paddingRight);
offset += Number.parseFloat(tabStyles.paddingLeft);
}
return false;
});
return {
[sizeName]: `${tabSize}px`,
transform: `translate${capitalize(sizeDir)}(${offset}px)`
};
};
const update = () => barStyle.value = getBarStyle();
const tabObservers = [];
const observerTabs = () => {
tabObservers.forEach((observer) => observer.stop());
tabObservers.length = 0;
Object.values(props.tabRefs).forEach((tab) => {
tabObservers.push(useResizeObserver(tab, update));
});
};
watch(() => props.tabs, async () => {
await nextTick();
update();
observerTabs();
}, { immediate: true });
const barObserver = useResizeObserver(barRef, () => update());
onBeforeUnmount(() => {
tabObservers.forEach((observer) => observer.stop());
tabObservers.length = 0;
barObserver.stop();
});
expose({
ref: barRef,
update
});
return (_ctx, _cache) => {
return openBlock(), createElementBlock("div", {
ref_key: "barRef",
ref: barRef,
class: normalizeClass([unref(ns).e("active-bar"), unref(ns).is(unref(rootTabs).props.tabPosition)]),
style: normalizeStyle(barStyle.value)
}, null, 6);
};
}
});
var TabBar = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "tab-bar.vue"]]);
export { TabBar as default };
//# sourceMappingURL=tab-bar2.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,291 @@
import type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue';
import type { TabBarInstance } from './tab-bar';
import type { TabPaneName, TabsPaneContext } from './constants';
export declare const tabNavProps: {
readonly panes: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => {
uid: number;
getVnode: () => import("vue").VNode;
slots: import("vue").Slots;
props: {
readonly label: string;
readonly disabled: boolean;
readonly lazy: boolean;
readonly name?: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
readonly closable?: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown> | undefined;
};
paneName: TabPaneName | undefined;
active: boolean;
index: string | undefined;
isClosable: boolean;
isFocusInsidePane: () => boolean | undefined;
}[]) | (() => {
uid: number;
getVnode: () => import("vue").VNode;
slots: import("vue").Slots;
props: {
readonly label: string;
readonly disabled: boolean;
readonly lazy: boolean;
readonly name?: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
readonly closable?: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown> | undefined;
};
paneName: TabPaneName | undefined;
active: boolean;
index: string | undefined;
isClosable: boolean;
isFocusInsidePane: () => boolean | undefined;
}[]) | ((new (...args: any[]) => {
uid: number;
getVnode: () => import("vue").VNode;
slots: import("vue").Slots;
props: {
readonly label: string;
readonly disabled: boolean;
readonly lazy: boolean;
readonly name?: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
readonly closable?: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown> | undefined;
};
paneName: TabPaneName | undefined;
active: boolean;
index: string | undefined;
isClosable: boolean;
isFocusInsidePane: () => boolean | undefined;
}[]) | (() => {
uid: number;
getVnode: () => import("vue").VNode;
slots: import("vue").Slots;
props: {
readonly label: string;
readonly disabled: boolean;
readonly lazy: boolean;
readonly name?: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
readonly closable?: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown> | undefined;
};
paneName: TabPaneName | undefined;
active: boolean;
index: string | undefined;
isClosable: boolean;
isFocusInsidePane: () => boolean | undefined;
}[]))[], unknown, unknown, () => [], boolean>;
readonly currentName: import("element-plus/es/utils").EpPropFinalized<readonly [StringConstructor, NumberConstructor], unknown, unknown, "", boolean>;
readonly editable: BooleanConstructor;
readonly type: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "" | "card" | "border-card", unknown, "", boolean>;
readonly stretch: BooleanConstructor;
};
export declare const tabNavEmits: {
tabClick: (tab: TabsPaneContext, tabName: TabPaneName, ev: Event) => boolean;
tabRemove: (tab: TabsPaneContext, ev: Event) => boolean;
};
export type TabNavProps = ExtractPropTypes<typeof tabNavProps>;
export type TabNavPropsPublic = __ExtractPublicPropTypes<typeof tabNavProps>;
export type TabNavEmits = typeof tabNavEmits;
declare const TabNav: import("vue").DefineComponent<{
readonly panes: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => {
uid: number;
getVnode: () => import("vue").VNode;
slots: import("vue").Slots;
props: {
readonly label: string;
readonly disabled: boolean;
readonly lazy: boolean;
readonly name?: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
readonly closable?: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown> | undefined;
};
paneName: TabPaneName | undefined;
active: boolean;
index: string | undefined;
isClosable: boolean;
isFocusInsidePane: () => boolean | undefined;
}[]) | (() => {
uid: number;
getVnode: () => import("vue").VNode;
slots: import("vue").Slots;
props: {
readonly label: string;
readonly disabled: boolean;
readonly lazy: boolean;
readonly name?: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
readonly closable?: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown> | undefined;
};
paneName: TabPaneName | undefined;
active: boolean;
index: string | undefined;
isClosable: boolean;
isFocusInsidePane: () => boolean | undefined;
}[]) | ((new (...args: any[]) => {
uid: number;
getVnode: () => import("vue").VNode;
slots: import("vue").Slots;
props: {
readonly label: string;
readonly disabled: boolean;
readonly lazy: boolean;
readonly name?: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
readonly closable?: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown> | undefined;
};
paneName: TabPaneName | undefined;
active: boolean;
index: string | undefined;
isClosable: boolean;
isFocusInsidePane: () => boolean | undefined;
}[]) | (() => {
uid: number;
getVnode: () => import("vue").VNode;
slots: import("vue").Slots;
props: {
readonly label: string;
readonly disabled: boolean;
readonly lazy: boolean;
readonly name?: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
readonly closable?: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown> | undefined;
};
paneName: TabPaneName | undefined;
active: boolean;
index: string | undefined;
isClosable: boolean;
isFocusInsidePane: () => boolean | undefined;
}[]))[], unknown, unknown, () => [], boolean>;
readonly currentName: import("element-plus/es/utils").EpPropFinalized<readonly [StringConstructor, NumberConstructor], unknown, unknown, "", boolean>;
readonly editable: BooleanConstructor;
readonly type: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "" | "card" | "border-card", unknown, "", boolean>;
readonly stretch: BooleanConstructor;
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
tabClick: (tab: TabsPaneContext, tabName: TabPaneName, ev: Event) => boolean;
tabRemove: (tab: TabsPaneContext, ev: Event) => boolean;
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<ExtractPropTypes<{
readonly panes: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => {
uid: number;
getVnode: () => import("vue").VNode;
slots: import("vue").Slots;
props: {
readonly label: string;
readonly disabled: boolean;
readonly lazy: boolean;
readonly name?: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
readonly closable?: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown> | undefined;
};
paneName: TabPaneName | undefined;
active: boolean;
index: string | undefined;
isClosable: boolean;
isFocusInsidePane: () => boolean | undefined;
}[]) | (() => {
uid: number;
getVnode: () => import("vue").VNode;
slots: import("vue").Slots;
props: {
readonly label: string;
readonly disabled: boolean;
readonly lazy: boolean;
readonly name?: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
readonly closable?: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown> | undefined;
};
paneName: TabPaneName | undefined;
active: boolean;
index: string | undefined;
isClosable: boolean;
isFocusInsidePane: () => boolean | undefined;
}[]) | ((new (...args: any[]) => {
uid: number;
getVnode: () => import("vue").VNode;
slots: import("vue").Slots;
props: {
readonly label: string;
readonly disabled: boolean;
readonly lazy: boolean;
readonly name?: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
readonly closable?: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown> | undefined;
};
paneName: TabPaneName | undefined;
active: boolean;
index: string | undefined;
isClosable: boolean;
isFocusInsidePane: () => boolean | undefined;
}[]) | (() => {
uid: number;
getVnode: () => import("vue").VNode;
slots: import("vue").Slots;
props: {
readonly label: string;
readonly disabled: boolean;
readonly lazy: boolean;
readonly name?: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
readonly closable?: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown> | undefined;
};
paneName: TabPaneName | undefined;
active: boolean;
index: string | undefined;
isClosable: boolean;
isFocusInsidePane: () => boolean | undefined;
}[]))[], unknown, unknown, () => [], boolean>;
readonly currentName: import("element-plus/es/utils").EpPropFinalized<readonly [StringConstructor, NumberConstructor], unknown, unknown, "", boolean>;
readonly editable: BooleanConstructor;
readonly type: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "" | "card" | "border-card", unknown, "", boolean>;
readonly stretch: BooleanConstructor;
}>> & {
onTabClick?: ((tab: {
uid: number;
getVnode: () => import("vue").VNode;
slots: import("vue").Slots;
props: {
readonly label: string;
readonly disabled: boolean;
readonly lazy: boolean;
readonly name?: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
readonly closable?: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown> | undefined;
};
paneName: TabPaneName | undefined;
active: boolean;
index: string | undefined;
isClosable: boolean;
isFocusInsidePane: () => boolean | undefined;
}, tabName: TabPaneName, ev: Event) => any) | undefined;
onTabRemove?: ((tab: {
uid: number;
getVnode: () => import("vue").VNode;
slots: import("vue").Slots;
props: {
readonly label: string;
readonly disabled: boolean;
readonly lazy: boolean;
readonly name?: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
readonly closable?: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown> | undefined;
};
paneName: TabPaneName | undefined;
active: boolean;
index: string | undefined;
isClosable: boolean;
isFocusInsidePane: () => boolean | undefined;
}, ev: Event) => any) | undefined;
}, {
readonly stretch: boolean;
readonly type: import("element-plus/es/utils").EpPropMergeType<StringConstructor, "" | "card" | "border-card", unknown>;
readonly editable: boolean;
readonly panes: {
uid: number;
getVnode: () => import("vue").VNode;
slots: import("vue").Slots;
props: {
readonly label: string;
readonly disabled: boolean;
readonly lazy: boolean;
readonly name?: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
readonly closable?: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown> | undefined;
};
paneName: TabPaneName | undefined;
active: boolean;
index: string | undefined;
isClosable: boolean;
isFocusInsidePane: () => boolean | undefined;
}[];
readonly currentName: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown>;
}>;
export type TabNavInstance = InstanceType<typeof TabNav> & {
scrollToActiveTab: () => Promise<void>;
removeFocus: () => void;
focusActiveTab: () => void;
scheduleRender: () => void;
tabListRef: HTMLDivElement | undefined;
tabBarRef: TabBarInstance | undefined;
};
export default TabNav;

View File

@@ -0,0 +1,310 @@
import { defineComponent, inject, ref, shallowRef, computed, watch, onMounted, onUpdated, triggerRef, createVNode, nextTick } from 'vue';
import { useDocumentVisibility, useWindowFocus, useElementSize, useResizeObserver } from '@vueuse/core';
import { ElIcon } from '../../icon/index.mjs';
import { ArrowLeft, ArrowRight, Close } from '@element-plus/icons-vue';
import useWheel from '../../virtual-list/src/hooks/use-wheel.mjs';
import { clamp } from 'lodash-unified';
import TabBar from './tab-bar2.mjs';
import { tabsRootContextKey } from './constants.mjs';
import { buildProps, definePropType } from '../../../utils/vue/props/runtime.mjs';
import { mutable } from '../../../utils/typescript.mjs';
import { throwError } from '../../../utils/error.mjs';
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
import { EVENT_CODE } from '../../../constants/aria.mjs';
import { capitalize } from '../../../utils/strings.mjs';
const tabNavProps = buildProps({
panes: {
type: definePropType(Array),
default: () => mutable([])
},
currentName: {
type: [String, Number],
default: ""
},
editable: Boolean,
type: {
type: String,
values: ["card", "border-card", ""],
default: ""
},
stretch: Boolean
});
const tabNavEmits = {
tabClick: (tab, tabName, ev) => ev instanceof Event,
tabRemove: (tab, ev) => ev instanceof Event
};
const COMPONENT_NAME = "ElTabNav";
const TabNav = defineComponent({
name: COMPONENT_NAME,
props: tabNavProps,
emits: tabNavEmits,
setup(props, {
expose,
emit
}) {
const rootTabs = inject(tabsRootContextKey);
if (!rootTabs)
throwError(COMPONENT_NAME, `<el-tabs><tab-nav /></el-tabs>`);
const ns = useNamespace("tabs");
const visibility = useDocumentVisibility();
const focused = useWindowFocus();
const navScroll$ = ref();
const nav$ = ref();
const el$ = ref();
const tabRefsMap = ref({});
const tabBarRef = ref();
const scrollable = ref(false);
const navOffset = ref(0);
const isFocus = ref(false);
const focusable = ref(true);
const tracker = shallowRef();
const isHorizontal = computed(() => ["top", "bottom"].includes(rootTabs.props.tabPosition));
const sizeName = computed(() => isHorizontal.value ? "width" : "height");
const navStyle = computed(() => {
const dir = sizeName.value === "width" ? "X" : "Y";
return {
transform: `translate${dir}(-${navOffset.value}px)`
};
});
const {
width: navContainerWidth,
height: navContainerHeight
} = useElementSize(navScroll$);
const {
width: navWidth,
height: navHeight
} = useElementSize(nav$, {
width: 0,
height: 0
}, {
box: "border-box"
});
const navContainerSize = computed(() => isHorizontal.value ? navContainerWidth.value : navContainerHeight.value);
const navSize = computed(() => isHorizontal.value ? navWidth.value : navHeight.value);
const {
onWheel
} = useWheel({
atStartEdge: computed(() => navOffset.value <= 0),
atEndEdge: computed(() => navSize.value - navOffset.value <= navContainerSize.value),
layout: computed(() => isHorizontal.value ? "horizontal" : "vertical")
}, (offset) => {
navOffset.value = clamp(navOffset.value + offset, 0, navSize.value - navContainerSize.value);
});
const scrollPrev = () => {
if (!navScroll$.value)
return;
const containerSize = navScroll$.value[`offset${capitalize(sizeName.value)}`];
const currentOffset = navOffset.value;
if (!currentOffset)
return;
const newOffset = currentOffset > containerSize ? currentOffset - containerSize : 0;
navOffset.value = newOffset;
};
const scrollNext = () => {
if (!navScroll$.value || !nav$.value)
return;
const navSize2 = nav$.value[`offset${capitalize(sizeName.value)}`];
const containerSize = navScroll$.value[`offset${capitalize(sizeName.value)}`];
const currentOffset = navOffset.value;
if (navSize2 - currentOffset <= containerSize)
return;
const newOffset = navSize2 - currentOffset > containerSize * 2 ? currentOffset + containerSize : navSize2 - containerSize;
navOffset.value = newOffset;
};
const scrollToActiveTab = async () => {
const nav = nav$.value;
if (!scrollable.value || !el$.value || !navScroll$.value || !nav)
return;
await nextTick();
const activeTab = tabRefsMap.value[props.currentName];
if (!activeTab)
return;
const navScroll = navScroll$.value;
const activeTabBounding = activeTab.getBoundingClientRect();
const navScrollBounding = navScroll.getBoundingClientRect();
const maxOffset = isHorizontal.value ? nav.offsetWidth - navScrollBounding.width : nav.offsetHeight - navScrollBounding.height;
const currentOffset = navOffset.value;
let newOffset = currentOffset;
if (isHorizontal.value) {
if (activeTabBounding.left < navScrollBounding.left) {
newOffset = currentOffset - (navScrollBounding.left - activeTabBounding.left);
}
if (activeTabBounding.right > navScrollBounding.right) {
newOffset = currentOffset + activeTabBounding.right - navScrollBounding.right;
}
} else {
if (activeTabBounding.top < navScrollBounding.top) {
newOffset = currentOffset - (navScrollBounding.top - activeTabBounding.top);
}
if (activeTabBounding.bottom > navScrollBounding.bottom) {
newOffset = currentOffset + (activeTabBounding.bottom - navScrollBounding.bottom);
}
}
newOffset = Math.max(newOffset, 0);
navOffset.value = Math.min(newOffset, maxOffset);
};
const update = () => {
var _a;
if (!nav$.value || !navScroll$.value)
return;
props.stretch && ((_a = tabBarRef.value) == null ? void 0 : _a.update());
const navSize2 = nav$.value[`offset${capitalize(sizeName.value)}`];
const containerSize = navScroll$.value[`offset${capitalize(sizeName.value)}`];
const currentOffset = navOffset.value;
if (containerSize < navSize2) {
scrollable.value = scrollable.value || {};
scrollable.value.prev = currentOffset;
scrollable.value.next = currentOffset + containerSize < navSize2;
if (navSize2 - currentOffset < containerSize) {
navOffset.value = navSize2 - containerSize;
}
} else {
scrollable.value = false;
if (currentOffset > 0) {
navOffset.value = 0;
}
}
};
const changeTab = (event) => {
let step = 0;
switch (event.code) {
case EVENT_CODE.left:
case EVENT_CODE.up:
step = -1;
break;
case EVENT_CODE.right:
case EVENT_CODE.down:
step = 1;
break;
default:
return;
}
const tabList = Array.from(event.currentTarget.querySelectorAll("[role=tab]:not(.is-disabled)"));
const currentIndex = tabList.indexOf(event.target);
let nextIndex = currentIndex + step;
if (nextIndex < 0) {
nextIndex = tabList.length - 1;
} else if (nextIndex >= tabList.length) {
nextIndex = 0;
}
tabList[nextIndex].focus({
preventScroll: true
});
tabList[nextIndex].click();
setFocus();
};
const setFocus = () => {
if (focusable.value)
isFocus.value = true;
};
const removeFocus = () => isFocus.value = false;
const setRefs = (el, key) => {
tabRefsMap.value[key] = el;
};
const focusActiveTab = async () => {
await nextTick();
const activeTab = tabRefsMap.value[props.currentName];
activeTab == null ? void 0 : activeTab.focus({
preventScroll: true
});
};
watch(visibility, (visibility2) => {
if (visibility2 === "hidden") {
focusable.value = false;
} else if (visibility2 === "visible") {
setTimeout(() => focusable.value = true, 50);
}
});
watch(focused, (focused2) => {
if (focused2) {
setTimeout(() => focusable.value = true, 50);
} else {
focusable.value = false;
}
});
useResizeObserver(el$, update);
onMounted(() => setTimeout(() => scrollToActiveTab(), 0));
onUpdated(() => update());
expose({
scrollToActiveTab,
removeFocus,
focusActiveTab,
tabListRef: nav$,
tabBarRef,
scheduleRender: () => triggerRef(tracker)
});
return () => {
const scrollBtn = scrollable.value ? [createVNode("span", {
"class": [ns.e("nav-prev"), ns.is("disabled", !scrollable.value.prev)],
"onClick": scrollPrev
}, [createVNode(ElIcon, null, {
default: () => [createVNode(ArrowLeft, null, null)]
})]), createVNode("span", {
"class": [ns.e("nav-next"), ns.is("disabled", !scrollable.value.next)],
"onClick": scrollNext
}, [createVNode(ElIcon, null, {
default: () => [createVNode(ArrowRight, null, null)]
})])] : null;
const tabs = props.panes.map((pane, index) => {
var _a, _b, _c, _d;
const uid = pane.uid;
const disabled = pane.props.disabled;
const tabName = (_b = (_a = pane.props.name) != null ? _a : pane.index) != null ? _b : `${index}`;
const closable = !disabled && (pane.isClosable || pane.props.closable !== false && props.editable);
pane.index = `${index}`;
const btnClose = closable ? createVNode(ElIcon, {
"class": "is-icon-close",
"onClick": (ev) => emit("tabRemove", pane, ev)
}, {
default: () => [createVNode(Close, null, null)]
}) : null;
const tabLabelContent = ((_d = (_c = pane.slots).label) == null ? void 0 : _d.call(_c)) || pane.props.label;
const tabindex = !disabled && pane.active ? 0 : -1;
return createVNode("div", {
"ref": (el) => setRefs(el, tabName),
"class": [ns.e("item"), ns.is(rootTabs.props.tabPosition), ns.is("active", pane.active), ns.is("disabled", disabled), ns.is("closable", closable), ns.is("focus", isFocus.value)],
"id": `tab-${tabName}`,
"key": `tab-${uid}`,
"aria-controls": `pane-${tabName}`,
"role": "tab",
"aria-selected": pane.active,
"tabindex": tabindex,
"onFocus": () => setFocus(),
"onBlur": () => removeFocus(),
"onClick": (ev) => {
removeFocus();
emit("tabClick", pane, tabName, ev);
},
"onKeydown": (ev) => {
if (closable && (ev.code === EVENT_CODE.delete || ev.code === EVENT_CODE.backspace)) {
emit("tabRemove", pane, ev);
}
}
}, [...[tabLabelContent, btnClose]]);
});
tracker.value;
return createVNode("div", {
"ref": el$,
"class": [ns.e("nav-wrap"), ns.is("scrollable", !!scrollable.value), ns.is(rootTabs.props.tabPosition)]
}, [scrollBtn, createVNode("div", {
"class": ns.e("nav-scroll"),
"ref": navScroll$
}, [props.panes.length > 0 ? createVNode("div", {
"class": [ns.e("nav"), ns.is(rootTabs.props.tabPosition), ns.is("stretch", props.stretch && ["top", "bottom"].includes(rootTabs.props.tabPosition))],
"ref": nav$,
"style": navStyle.value,
"role": "tablist",
"onKeydown": changeTab,
"onWheel": onWheel
}, [...[!props.type ? createVNode(TabBar, {
"ref": tabBarRef,
"tabs": [...props.panes],
"tabRefs": tabRefsMap.value
}, null) : null, tabs]]) : null])]);
};
}
});
export { TabNav as default, tabNavEmits, tabNavProps };
//# sourceMappingURL=tab-nav.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,17 @@
import type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue';
import type TabPane from './tab-pane.vue';
export declare const tabPaneProps: {
readonly label: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly name: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly closable: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, undefined, boolean>;
readonly disabled: BooleanConstructor;
readonly lazy: BooleanConstructor;
};
export type TabPaneProps = ExtractPropTypes<typeof tabPaneProps>;
export type TabPanePropsPublic = __ExtractPublicPropTypes<typeof tabPaneProps>;
export type TabPaneInstance = InstanceType<typeof TabPane> & unknown;

View File

@@ -0,0 +1,89 @@
import { defineComponent, getCurrentInstance, useSlots, inject, ref, computed, watch, reactive, onBeforeUnmount, onBeforeUpdate, unref, withDirectives, openBlock, createElementBlock, normalizeClass, renderSlot, vShow, createCommentVNode } from 'vue';
import { eagerComputed } from '@vueuse/core';
import { tabsRootContextKey } from './constants.mjs';
import { tabPaneProps } from './tab-pane2.mjs';
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
import { throwError } from '../../../utils/error.mjs';
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
const COMPONENT_NAME = "ElTabPane";
const __default__ = defineComponent({
name: COMPONENT_NAME
});
const _sfc_main = /* @__PURE__ */ defineComponent({
...__default__,
props: tabPaneProps,
setup(__props) {
const props = __props;
const instance = getCurrentInstance();
const slots = useSlots();
const tabsRoot = inject(tabsRootContextKey);
if (!tabsRoot)
throwError(COMPONENT_NAME, "usage: <el-tabs><el-tab-pane /></el-tabs/>");
const ns = useNamespace("tab-pane");
const paneRef = ref();
const index = ref();
const isClosable = computed(() => {
var _a;
return (_a = props.closable) != null ? _a : tabsRoot.props.closable;
});
const active = eagerComputed(() => {
var _a;
return tabsRoot.currentName.value === ((_a = props.name) != null ? _a : index.value);
});
const loaded = ref(active.value);
const paneName = computed(() => {
var _a;
return (_a = props.name) != null ? _a : index.value;
});
const shouldBeRender = eagerComputed(() => !props.lazy || loaded.value || active.value);
const isFocusInsidePane = () => {
var _a;
return (_a = paneRef.value) == null ? void 0 : _a.contains(document.activeElement);
};
watch(active, (val) => {
if (val)
loaded.value = true;
});
const pane = reactive({
uid: instance.uid,
getVnode: () => instance.vnode,
slots,
props,
paneName,
active,
index,
isClosable,
isFocusInsidePane
});
tabsRoot.registerPane(pane);
onBeforeUnmount(() => {
tabsRoot.unregisterPane(pane);
});
onBeforeUpdate(() => {
var _a;
if (slots.label)
(_a = tabsRoot.nav$.value) == null ? void 0 : _a.scheduleRender();
});
return (_ctx, _cache) => {
return unref(shouldBeRender) ? withDirectives((openBlock(), createElementBlock("div", {
key: 0,
id: `pane-${unref(paneName)}`,
ref_key: "paneRef",
ref: paneRef,
class: normalizeClass(unref(ns).b()),
role: "tabpanel",
"aria-hidden": !unref(active),
"aria-labelledby": `tab-${unref(paneName)}`
}, [
renderSlot(_ctx.$slots, "default")
], 10, ["id", "aria-hidden", "aria-labelledby"])), [
[vShow, unref(active)]
]) : createCommentVNode("v-if", true);
};
}
});
var TabPane = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "tab-pane.vue"]]);
export { TabPane as default };
//# sourceMappingURL=tab-pane.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"tab-pane.mjs","sources":["../../../../../../packages/components/tabs/src/tab-pane.vue"],"sourcesContent":["<template>\n <div\n v-if=\"shouldBeRender\"\n v-show=\"active\"\n :id=\"`pane-${paneName}`\"\n ref=\"paneRef\"\n :class=\"ns.b()\"\n role=\"tabpanel\"\n :aria-hidden=\"!active\"\n :aria-labelledby=\"`tab-${paneName}`\"\n >\n <slot />\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport {\n computed,\n getCurrentInstance,\n inject,\n onBeforeUnmount,\n onBeforeUpdate,\n reactive,\n ref,\n useSlots,\n watch,\n} from 'vue'\nimport { eagerComputed } from '@vueuse/core'\nimport { throwError } from '@element-plus/utils'\nimport { useNamespace } from '@element-plus/hooks'\nimport { tabsRootContextKey } from './constants'\nimport { tabPaneProps } from './tab-pane'\n\nconst COMPONENT_NAME = 'ElTabPane'\ndefineOptions({\n name: COMPONENT_NAME,\n})\nconst props = defineProps(tabPaneProps)\n\nconst instance = getCurrentInstance()!\nconst slots = useSlots()\n\nconst tabsRoot = inject(tabsRootContextKey)\nif (!tabsRoot)\n throwError(COMPONENT_NAME, 'usage: <el-tabs><el-tab-pane /></el-tabs/>')\n\nconst ns = useNamespace('tab-pane')\n\nconst paneRef = ref<HTMLDivElement>()\nconst index = ref<string>()\nconst isClosable = computed(() => props.closable ?? tabsRoot.props.closable)\nconst active = eagerComputed(\n () => tabsRoot.currentName.value === (props.name ?? index.value)\n)\nconst loaded = ref(active.value)\nconst paneName = computed(() => props.name ?? index.value)\nconst shouldBeRender = eagerComputed(\n () => !props.lazy || loaded.value || active.value\n)\n\nconst isFocusInsidePane = () => {\n return paneRef.value?.contains(document.activeElement)\n}\n\nwatch(active, (val) => {\n if (val) loaded.value = true\n})\n\nconst pane = reactive({\n uid: instance.uid,\n getVnode: () => instance.vnode,\n slots,\n props,\n paneName,\n active,\n index,\n isClosable,\n isFocusInsidePane,\n})\n\ntabsRoot.registerPane(pane)\n\nonBeforeUnmount(() => {\n tabsRoot.unregisterPane(pane)\n})\n\nonBeforeUpdate(() => {\n if (slots.label) tabsRoot.nav$.value?.scheduleRender()\n})\n</script>\n"],"names":[],"mappings":";;;;;;;;;mCAkCc,CAAA;AAAA,EACZ,IAAM,EAAA,cAAA;AACR;;;;;;AAGA,IAAA,MAAM,WAAW,kBAAmB,EAAA,CAAA;AACpC,IAAA,MAAM,QAAQ,QAAS,EAAA,CAAA;AAEvB,IAAM,MAAA,QAAA,GAAW,OAAO,kBAAkB,CAAA,CAAA;AAC1C,IAAA,IAAI,CAAC,QAAA;AACH,MAAA,UAAA,CAAW,gBAAgB,4CAA4C,CAAA,CAAA;AAEzE,IAAM,MAAA,EAAA,GAAK,aAAa,UAAU,CAAA,CAAA;AAElC,IAAA,MAAM,UAAU,GAAoB,EAAA,CAAA;AACpC,IAAA,MAAM,QAAQ,GAAY,EAAA,CAAA;AAC1B,IAAA,MAAM,aAAa,QAAS,CAAA,MAAM;AAClC,MAAA,IAAM,EAAS,CAAA;AAAA,MACb,OAAe,CAAA,EAAA,GAAA,KAAA,CAAA,QAAY,KAAW,IAAA,GAAA,EAAA,GAAM,QAAQ,CAAM,KAAA,CAAA,QAAA,CAAA;AAAA,KAC5D,CAAA,CAAA;AACA,IAAM,MAAA,MAAA,GAAS,aAAgB,CAAA,MAAA;AAC/B,MAAA,IAAM;AACN,MAAA,OAAuB,QAAA,CAAA,WAAA,CAAA,KAAA,MAAA,CAAA,EAAA,GAAA,KAAA,CAAA,IAAA,KAAA,IAAA,GAAA,EAAA,GAAA,KAAA,CAAA,KAAA,CAAA,CAAA;AAAA,KAAA,CACrB;AAA4C,IAC9C,MAAA,MAAA,GAAA,GAAA,CAAA,MAAA,CAAA,KAAA,CAAA,CAAA;AAEA,IAAA,MAAM,oBAAoB,MAAM;AAC9B,MAAA,IAAA,EAAA,CAAO;AAA8C,MACvD,OAAA,CAAA,EAAA,GAAA,KAAA,CAAA,IAAA,KAAA,IAAA,GAAA,EAAA,GAAA,KAAA,CAAA,KAAA,CAAA;AAEA,KAAM,CAAA,CAAA;AACJ,IAAI,MAAA,cAAoB,GAAA,aAAA,CAAA,MAAA,CAAA,KAAA,CAAA,IAAA,IAAA,MAAA,CAAA,KAAA,IAAA,MAAA,CAAA,KAAA,CAAA,CAAA;AAAA,IAC1B,MAAC,iBAAA,GAAA,MAAA;AAED,MAAA,IAAM;AAAgB,MACpB,OAAc,CAAA,EAAA,GAAA,OAAA,CAAA,KAAA,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,QAAA,CAAA,QAAA,CAAA,aAAA,CAAA,CAAA;AAAA,KACd,CAAA;AAAyB,IACzB,KAAA,CAAA,MAAA,EAAA,CAAA,GAAA,KAAA;AAAA,MACA,IAAA,GAAA;AAAA,QACA,MAAA,CAAA,KAAA,GAAA,IAAA,CAAA;AAAA,KACA,CAAA,CAAA;AAAA,IACA,MAAA,IAAA,GAAA,QAAA,CAAA;AAAA,MACA,GAAA,EAAA,QAAA,CAAA,GAAA;AAAA,MACA,QAAA,EAAA,MAAA,QAAA,CAAA,KAAA;AAAA,MACD,KAAA;AAED,MAAA,KAAA;AAEA,MAAA,QAAA;AACE,MAAA,MAAA;AAA4B,MAC7B,KAAA;AAED,MAAA,UAAA;AACE,MAAA,iBAA0B;AAA2B,KACtD,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}

View File

@@ -0,0 +1,38 @@
declare function __VLS_template(): {
default?(_: {}): any;
};
declare const __VLS_component: import("vue").DefineComponent<{
readonly label: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly name: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly closable: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, undefined, boolean>;
readonly disabled: BooleanConstructor;
readonly lazy: BooleanConstructor;
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
readonly label: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly name: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly closable: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, undefined, boolean>;
readonly disabled: BooleanConstructor;
readonly lazy: BooleanConstructor;
}>>, {
readonly label: string;
readonly disabled: boolean;
readonly closable: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown>;
readonly lazy: boolean;
}>;
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
export default _default;
type __VLS_WithTemplateSlots<T, S> = T & {
new (): {
$slots: S;
};
};

View File

@@ -0,0 +1,20 @@
import { buildProps } from '../../../utils/vue/props/runtime.mjs';
const tabPaneProps = buildProps({
label: {
type: String,
default: ""
},
name: {
type: [String, Number]
},
closable: {
type: Boolean,
default: void 0
},
disabled: Boolean,
lazy: Boolean
});
export { tabPaneProps };
//# sourceMappingURL=tab-pane2.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"tab-pane2.mjs","sources":["../../../../../../packages/components/tabs/src/tab-pane.ts"],"sourcesContent":["import { buildProps } from '@element-plus/utils'\n\nimport type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue'\nimport type TabPane from './tab-pane.vue'\n\nexport const tabPaneProps = buildProps({\n /**\n * @description title of the tab\n */\n label: {\n type: String,\n default: '',\n },\n /**\n * @description identifier corresponding to the name of Tabs, representing the alias of the tab-pane, the default is ordinal number of the tab-pane in the sequence, e.g. the first tab-pane is '0'\n */\n name: {\n type: [String, Number],\n },\n /**\n * @description whether Tab is closable\n */\n closable: {\n type: Boolean,\n default: undefined,\n },\n /**\n * @description whether Tab is disabled\n */\n disabled: Boolean,\n /**\n * @description whether Tab is lazily rendered\n */\n lazy: Boolean,\n} as const)\n\nexport type TabPaneProps = ExtractPropTypes<typeof tabPaneProps>\nexport type TabPanePropsPublic = __ExtractPublicPropTypes<typeof tabPaneProps>\n\nexport type TabPaneInstance = InstanceType<typeof TabPane> & unknown\n"],"names":[],"mappings":";;AACY,MAAC,YAAY,GAAG,UAAU,CAAC;AACvC,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;AAC1B,GAAG;AACH,EAAE,QAAQ,EAAE;AACZ,IAAI,IAAI,EAAE,OAAO;AACjB,IAAI,OAAO,EAAE,KAAK,CAAC;AACnB,GAAG;AACH,EAAE,QAAQ,EAAE,OAAO;AACnB,EAAE,IAAI,EAAE,OAAO;AACf,CAAC;;;;"}

View File

@@ -0,0 +1,127 @@
import type { ExtractPropTypes, VNode, __ExtractPublicPropTypes } from 'vue';
import type { Awaitable } from 'element-plus/es/utils';
import type { TabNavInstance } from './tab-nav';
import type { TabPaneName, TabsPaneContext } from './constants';
export declare const tabsProps: {
readonly type: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "" | "card" | "border-card", unknown, "", boolean>;
readonly closable: BooleanConstructor;
readonly addable: BooleanConstructor;
readonly modelValue: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly editable: BooleanConstructor;
readonly tabPosition: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "top" | "bottom" | "left" | "right", unknown, "top", boolean>;
readonly beforeLeave: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (newName: TabPaneName, oldName: TabPaneName) => Awaitable<void | boolean>) | (() => (newName: TabPaneName, oldName: TabPaneName) => Awaitable<void | boolean>) | {
(): (newName: TabPaneName, oldName: TabPaneName) => Awaitable<void | boolean>;
new (): any;
readonly prototype: any;
} | ((new (...args: any[]) => (newName: TabPaneName, oldName: TabPaneName) => Awaitable<void | boolean>) | (() => (newName: TabPaneName, oldName: TabPaneName) => Awaitable<void | boolean>) | {
(): (newName: TabPaneName, oldName: TabPaneName) => Awaitable<void | boolean>;
new (): any;
readonly prototype: any;
})[], unknown, unknown, () => true, boolean>;
readonly stretch: BooleanConstructor;
};
export type TabsProps = ExtractPropTypes<typeof tabsProps>;
export type TabsPropsPublic = __ExtractPublicPropTypes<typeof tabsProps>;
export declare const tabsEmits: {
"update:modelValue": (name: TabPaneName) => name is string | number;
tabClick: (pane: TabsPaneContext, ev: Event) => boolean;
tabChange: (name: TabPaneName) => name is string | number;
edit: (paneName: TabPaneName | undefined, action: "remove" | "add") => boolean;
tabRemove: (name: TabPaneName) => name is string | number;
tabAdd: () => boolean;
};
export type TabsEmits = typeof tabsEmits;
export type TabsPanes = Record<number, TabsPaneContext>;
declare const Tabs: import("vue").DefineComponent<{
readonly type: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "" | "card" | "border-card", unknown, "", boolean>;
readonly closable: BooleanConstructor;
readonly addable: BooleanConstructor;
readonly modelValue: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly editable: BooleanConstructor;
readonly tabPosition: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "top" | "bottom" | "left" | "right", unknown, "top", boolean>;
readonly beforeLeave: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (newName: TabPaneName, oldName: TabPaneName) => Awaitable<void | boolean>) | (() => (newName: TabPaneName, oldName: TabPaneName) => Awaitable<void | boolean>) | {
(): (newName: TabPaneName, oldName: TabPaneName) => Awaitable<void | boolean>;
new (): any;
readonly prototype: any;
} | ((new (...args: any[]) => (newName: TabPaneName, oldName: TabPaneName) => Awaitable<void | boolean>) | (() => (newName: TabPaneName, oldName: TabPaneName) => Awaitable<void | boolean>) | {
(): (newName: TabPaneName, oldName: TabPaneName) => Awaitable<void | boolean>;
new (): any;
readonly prototype: any;
})[], unknown, unknown, () => true, boolean>;
readonly stretch: BooleanConstructor;
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
"update:modelValue": (name: TabPaneName) => name is string | number;
tabClick: (pane: TabsPaneContext, ev: Event) => boolean;
tabChange: (name: TabPaneName) => name is string | number;
edit: (paneName: TabPaneName | undefined, action: "remove" | "add") => boolean;
tabRemove: (name: TabPaneName) => name is string | number;
tabAdd: () => boolean;
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<ExtractPropTypes<{
readonly type: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "" | "card" | "border-card", unknown, "", boolean>;
readonly closable: BooleanConstructor;
readonly addable: BooleanConstructor;
readonly modelValue: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly editable: BooleanConstructor;
readonly tabPosition: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "top" | "bottom" | "left" | "right", unknown, "top", boolean>;
readonly beforeLeave: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (newName: TabPaneName, oldName: TabPaneName) => Awaitable<void | boolean>) | (() => (newName: TabPaneName, oldName: TabPaneName) => Awaitable<void | boolean>) | {
(): (newName: TabPaneName, oldName: TabPaneName) => Awaitable<void | boolean>;
new (): any;
readonly prototype: any;
} | ((new (...args: any[]) => (newName: TabPaneName, oldName: TabPaneName) => Awaitable<void | boolean>) | (() => (newName: TabPaneName, oldName: TabPaneName) => Awaitable<void | boolean>) | {
(): (newName: TabPaneName, oldName: TabPaneName) => Awaitable<void | boolean>;
new (): any;
readonly prototype: any;
})[], unknown, unknown, () => true, boolean>;
readonly stretch: BooleanConstructor;
}>> & {
"onUpdate:modelValue"?: ((name: TabPaneName) => any) | undefined;
onTabClick?: ((pane: {
uid: number;
getVnode: () => VNode;
slots: import("vue").Slots;
props: {
readonly label: string;
readonly disabled: boolean;
readonly lazy: boolean;
readonly name?: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
readonly closable?: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown> | undefined;
};
paneName: TabPaneName | undefined;
active: boolean;
index: string | undefined;
isClosable: boolean;
isFocusInsidePane: () => boolean | undefined;
}, ev: Event) => any) | undefined;
onTabRemove?: ((name: TabPaneName) => any) | undefined;
onTabChange?: ((name: TabPaneName) => any) | undefined;
onEdit?: ((paneName: TabPaneName | undefined, action: "add" | "remove") => any) | undefined;
onTabAdd?: (() => any) | undefined;
}, {
readonly stretch: boolean;
readonly type: import("element-plus/es/utils").EpPropMergeType<StringConstructor, "" | "card" | "border-card", unknown>;
readonly closable: boolean;
readonly beforeLeave: (newName: TabPaneName, oldName: TabPaneName) => Awaitable<void | boolean>;
readonly editable: boolean;
readonly tabPosition: import("element-plus/es/utils").EpPropMergeType<StringConstructor, "top" | "bottom" | "left" | "right", unknown>;
readonly addable: boolean;
}>;
export type TabsInstance = InstanceType<typeof Tabs> & {
currentName: TabPaneName;
tabNavRef: TabNavInstance | undefined;
};
export default Tabs;

View File

@@ -0,0 +1,185 @@
import { defineComponent, computed, getCurrentInstance, ref, watch, nextTick, provide, createVNode, renderSlot } from 'vue';
import { omit } from 'lodash-unified';
import { ElIcon } from '../../icon/index.mjs';
import { Plus } from '@element-plus/icons-vue';
import { tabsRootContextKey } from './constants.mjs';
import TabNav from './tab-nav.mjs';
import { buildProps, definePropType } from '../../../utils/vue/props/runtime.mjs';
import { UPDATE_MODEL_EVENT } from '../../../constants/event.mjs';
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
import { useOrderedChildren } from '../../../hooks/use-ordered-children/index.mjs';
import { EVENT_CODE } from '../../../constants/aria.mjs';
import { isString } from '@vue/shared';
import { isNumber, isUndefined } from '../../../utils/types.mjs';
const tabsProps = buildProps({
type: {
type: String,
values: ["card", "border-card", ""],
default: ""
},
closable: Boolean,
addable: Boolean,
modelValue: {
type: [String, Number]
},
editable: Boolean,
tabPosition: {
type: String,
values: ["top", "right", "bottom", "left"],
default: "top"
},
beforeLeave: {
type: definePropType(Function),
default: () => true
},
stretch: Boolean
});
const isPaneName = (value) => isString(value) || isNumber(value);
const tabsEmits = {
[UPDATE_MODEL_EVENT]: (name) => isPaneName(name),
tabClick: (pane, ev) => ev instanceof Event,
tabChange: (name) => isPaneName(name),
edit: (paneName, action) => ["remove", "add"].includes(action),
tabRemove: (name) => isPaneName(name),
tabAdd: () => true
};
const Tabs = defineComponent({
name: "ElTabs",
props: tabsProps,
emits: tabsEmits,
setup(props, {
emit,
slots,
expose
}) {
var _a;
const ns = useNamespace("tabs");
const isVertical = computed(() => ["left", "right"].includes(props.tabPosition));
const {
children: panes,
addChild: registerPane,
removeChild: unregisterPane,
ChildrenSorter: PanesSorter
} = useOrderedChildren(getCurrentInstance(), "ElTabPane");
const nav$ = ref();
const currentName = ref((_a = props.modelValue) != null ? _a : "0");
const setCurrentName = async (value, trigger = false) => {
var _a2, _b, _c, _d;
if (currentName.value === value || isUndefined(value))
return;
try {
let canLeave;
if (props.beforeLeave) {
const result = props.beforeLeave(value, currentName.value);
canLeave = result instanceof Promise ? await result : result;
} else {
canLeave = true;
}
if (canLeave !== false) {
const isFocusInsidePane = (_a2 = panes.value.find((item) => item.paneName === currentName.value)) == null ? void 0 : _a2.isFocusInsidePane();
currentName.value = value;
if (trigger) {
emit(UPDATE_MODEL_EVENT, value);
emit("tabChange", value);
}
(_c = (_b = nav$.value) == null ? void 0 : _b.removeFocus) == null ? void 0 : _c.call(_b);
if (isFocusInsidePane) {
(_d = nav$.value) == null ? void 0 : _d.focusActiveTab();
}
}
} catch (e) {
}
};
const handleTabClick = (tab, tabName, event) => {
if (tab.props.disabled)
return;
emit("tabClick", tab, event);
setCurrentName(tabName, true);
};
const handleTabRemove = (pane, ev) => {
if (pane.props.disabled || isUndefined(pane.props.name))
return;
ev.stopPropagation();
emit("edit", pane.props.name, "remove");
emit("tabRemove", pane.props.name);
};
const handleTabAdd = () => {
emit("edit", void 0, "add");
emit("tabAdd");
};
const swapChildren = (vnode) => {
const actualFirstChild = vnode.el.firstChild;
const firstChild = ["bottom", "right"].includes(props.tabPosition) ? vnode.children[0].el : vnode.children[1].el;
if (actualFirstChild !== firstChild) {
actualFirstChild.before(firstChild);
}
};
watch(() => props.modelValue, (modelValue) => setCurrentName(modelValue));
watch(currentName, async () => {
var _a2;
await nextTick();
(_a2 = nav$.value) == null ? void 0 : _a2.scrollToActiveTab();
});
provide(tabsRootContextKey, {
props,
currentName,
registerPane,
unregisterPane,
nav$
});
expose({
currentName,
get tabNavRef() {
return omit(nav$.value, ["scheduleRender"]);
}
});
return () => {
const addSlot = slots["add-icon"];
const newButton = props.editable || props.addable ? createVNode("div", {
"class": [ns.e("new-tab"), isVertical.value && ns.e("new-tab-vertical")],
"tabindex": "0",
"onClick": handleTabAdd,
"onKeydown": (ev) => {
if ([EVENT_CODE.enter, EVENT_CODE.numpadEnter].includes(ev.code))
handleTabAdd();
}
}, [addSlot ? renderSlot(slots, "add-icon") : createVNode(ElIcon, {
"class": ns.is("icon-plus")
}, {
default: () => [createVNode(Plus, null, null)]
})]) : null;
const tabNav = () => createVNode(TabNav, {
"ref": nav$,
"currentName": currentName.value,
"editable": props.editable,
"type": props.type,
"panes": panes.value,
"stretch": props.stretch,
"onTabClick": handleTabClick,
"onTabRemove": handleTabRemove
}, null);
const header = createVNode("div", {
"class": [ns.e("header"), isVertical.value && ns.e("header-vertical"), ns.is(props.tabPosition)]
}, [createVNode(PanesSorter, null, {
default: tabNav,
$stable: true
}), newButton]);
const panels = createVNode("div", {
"class": ns.e("content")
}, [renderSlot(slots, "default")]);
return createVNode("div", {
"class": [ns.b(), ns.m(props.tabPosition), {
[ns.m("card")]: props.type === "card",
[ns.m("border-card")]: props.type === "border-card"
}],
"onVnodeMounted": swapChildren,
"onVnodeUpdated": swapChildren
}, [panels, header]);
};
}
});
var Tabs$1 = Tabs;
export { Tabs$1 as default, tabsEmits, tabsProps };
//# sourceMappingURL=tabs.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
import 'element-plus/es/components/base/style/css';
import 'element-plus/theme-chalk/el-tabs.css';

View File

@@ -0,0 +1,3 @@
import '../../base/style/css.mjs';
import 'element-plus/theme-chalk/el-tabs.css';
//# sourceMappingURL=css.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"css.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}

View File

@@ -0,0 +1,2 @@
import 'element-plus/es/components/base/style';
import 'element-plus/theme-chalk/src/tabs.scss';

View File

@@ -0,0 +1,3 @@
import '../../base/style/index.mjs';
import 'element-plus/theme-chalk/src/tabs.scss';
//# sourceMappingURL=index.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}