This commit is contained in:
2026-05-25 17:08:18 +08:00
parent df501f6151
commit f1259b71b5
9178 changed files with 1626125 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
import type * as React from 'react';
import type { TabPaneProps as RcTabPaneProps } from '@rc-component/tabs/lib/TabPanelList/TabPane';
import type { CompatibilityProps } from '.';
type TabPaneProps = CompatibilityProps & Omit<RcTabPaneProps, 'destroyInactiveTabPane'>;
declare const TabPane: React.FC<TabPaneProps>;
export type { TabPaneProps };
export default TabPane;
+11
View File
@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
const TabPane = () => null;
if (process.env.NODE_ENV !== 'production') {
TabPane.displayName = 'DeprecatedTabPane';
}
var _default = exports.default = TabPane;
@@ -0,0 +1,3 @@
import type { AnimatedConfig } from '@rc-component/tabs/lib/interface';
import type { TabsProps } from '..';
export default function useAnimateConfig(prefixCls: string, animated?: TabsProps['animated']): AnimatedConfig;
+42
View File
@@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useAnimateConfig;
var _is = require("../../_util/is");
var _motion = require("../../_util/motion");
const motion = {
motionAppear: false,
motionEnter: true,
motionLeave: true
};
function useAnimateConfig(prefixCls, animated = {
inkBar: true,
tabPane: false
}) {
let mergedAnimated;
if (animated === false) {
mergedAnimated = {
inkBar: false,
tabPane: false
};
} else if (animated === true) {
mergedAnimated = {
inkBar: true,
tabPane: true
};
} else {
mergedAnimated = {
inkBar: true,
...((0, _is.isPlainObject)(animated) ? animated : {})
};
}
if (mergedAnimated.tabPane) {
mergedAnimated.tabPaneMotion = {
...motion,
motionName: (0, _motion.getTransitionName)(prefixCls, 'switch')
};
}
return mergedAnimated;
}
+5
View File
@@ -0,0 +1,5 @@
import * as React from 'react';
import type { Tab } from '@rc-component/tabs/lib/interface';
import type { TabsProps } from '..';
declare function useLegacyItems(items?: TabsProps['items'], children?: React.ReactNode): Tab[];
export default useLegacyItems;
+46
View File
@@ -0,0 +1,46 @@
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
var _util = require("@rc-component/util");
var _warning = require("../../_util/warning");
function filter(items) {
return items.filter(item => item);
}
function useLegacyItems(items, children) {
if (process.env.NODE_ENV !== 'production') {
const warning = (0, _warning.devUseWarning)('Tabs');
warning.deprecated(!children, 'Tabs.TabPane', 'items');
}
if (items) {
return items.map(item => ({
...item,
destroyOnHidden: item.destroyOnHidden ?? item.destroyInactiveTabPane
}));
}
const childrenItems = (0, _util.toArray)(children).map(node => {
if (/*#__PURE__*/React.isValidElement(node)) {
const {
key,
props
} = node;
const {
tab,
...restProps
} = props || {};
const item = {
key: String(key),
...restProps,
label: tab
};
return item;
}
return null;
});
return filter(childrenItems);
}
var _default = exports.default = useLegacyItems;
+79
View File
@@ -0,0 +1,79 @@
import * as React from 'react';
import type { TabsProps as RcTabsProps } from '@rc-component/tabs';
import RcTabs from '@rc-component/tabs';
import type { GetIndicatorSize } from '@rc-component/tabs/lib/hooks/useIndicator';
import type { MoreProps, Tab } from '@rc-component/tabs/lib/interface';
import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks';
import type { SizeType } from '../config-provider/SizeContext';
import TabPane from './TabPane';
import type { TabPaneProps } from './TabPane';
export type TabsType = 'line' | 'card' | 'editable-card';
export type TabPosition = 'top' | 'right' | 'bottom' | 'left';
export type TabPlacement = 'top' | 'end' | 'bottom' | 'start';
export type { TabPaneProps };
export type TabsSemanticName = keyof TabsSemanticClassNames & keyof TabsSemanticStyles;
export type TabsSemanticClassNames = {
root?: string;
item?: string;
indicator?: string;
content?: string;
header?: string;
};
export type TabsSemanticStyles = {
root?: React.CSSProperties;
item?: React.CSSProperties;
indicator?: React.CSSProperties;
content?: React.CSSProperties;
header?: React.CSSProperties;
};
export type TabsClassNamesType = SemanticClassNamesType<TabsProps, TabsSemanticClassNames, {
popup?: {
root?: string;
};
}>;
export type TabsStylesType = SemanticStylesType<TabsProps, TabsSemanticStyles, {
popup?: {
root?: React.CSSProperties;
};
}>;
export interface CompatibilityProps {
/** @deprecated Please use `destroyOnHidden` instead */
destroyInactiveTabPane?: boolean;
}
export interface TabsRef {
nativeElement: React.ComponentRef<typeof RcTabs> | null;
}
export interface BaseTabsProps {
type?: TabsType;
size?: SizeType;
hideAdd?: boolean;
centered?: boolean;
className?: string;
rootClassName?: string;
classNames?: TabsClassNamesType;
styles?: TabsStylesType;
/** @deprecated please use `tabPlacement` instead */
tabPosition?: TabPosition;
tabPlacement?: TabPlacement;
onEdit?: (e: React.MouseEvent | React.KeyboardEvent | string, action: 'add' | 'remove') => void;
children?: React.ReactNode;
/** @deprecated Please use `indicator={{ size: ... }}` instead */
indicatorSize?: GetIndicatorSize;
items?: (Tab & CompatibilityProps)[];
}
export interface TabsProps extends BaseTabsProps, CompatibilityProps, Omit<RcTabsProps, 'editable' | 'items' | 'classNames' | 'styles' | 'popupClassName'> {
addIcon?: React.ReactNode;
moreIcon?: React.ReactNode;
more?: MoreProps;
removeIcon?: React.ReactNode;
styles?: TabsStylesType;
classNames?: TabsClassNamesType;
/** @deprecated Please use `classNames.popup` instead */
popupClassName?: string;
}
declare const InternalTabs: React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<TabsRef>>;
type CompoundedComponent = typeof InternalTabs & {
TabPane: typeof TabPane;
};
declare const Tabs: CompoundedComponent;
export default Tabs;
+175
View File
@@ -0,0 +1,175 @@
"use strict";
"use client";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
var _CloseOutlined = _interopRequireDefault(require("@ant-design/icons/CloseOutlined"));
var _EllipsisOutlined = _interopRequireDefault(require("@ant-design/icons/EllipsisOutlined"));
var _PlusOutlined = _interopRequireDefault(require("@ant-design/icons/PlusOutlined"));
var _tabs = _interopRequireDefault(require("@rc-component/tabs"));
var _clsx = require("clsx");
var _hooks = require("../_util/hooks");
var _warning = require("../_util/warning");
var _configProvider = require("../config-provider");
var _context = require("../config-provider/context");
var _useCSSVarCls = _interopRequireDefault(require("../config-provider/hooks/useCSSVarCls"));
var _useSize = _interopRequireDefault(require("../config-provider/hooks/useSize"));
var _useAnimateConfig = _interopRequireDefault(require("./hooks/useAnimateConfig"));
var _useLegacyItems = _interopRequireDefault(require("./hooks/useLegacyItems"));
var _style = _interopRequireDefault(require("./style"));
var _TabPane = _interopRequireDefault(require("./TabPane"));
const InternalTabs = /*#__PURE__*/React.forwardRef((props, ref) => {
const {
type,
className,
rootClassName,
size: customSize,
onEdit,
hideAdd,
centered,
addIcon,
removeIcon,
moreIcon,
more,
popupClassName,
children,
items,
animated,
style,
indicatorSize,
indicator,
classNames,
styles,
destroyInactiveTabPane,
destroyOnHidden,
tabPlacement,
tabPosition,
...restProps
} = props;
const {
prefixCls: customizePrefixCls
} = restProps;
const {
getPrefixCls,
direction,
getPopupContainer,
className: contextClassName,
style: contextStyle,
classNames: contextClassNames,
styles: contextStyles
} = (0, _context.useComponentConfig)('tabs');
const {
tabs
} = React.useContext(_configProvider.ConfigContext);
const prefixCls = getPrefixCls('tabs', customizePrefixCls);
const rootCls = (0, _useCSSVarCls.default)(prefixCls);
const [hashId, cssVarCls] = (0, _style.default)(prefixCls, rootCls);
const tabsRef = React.useRef(null);
React.useImperativeHandle(ref, () => ({
nativeElement: tabsRef.current
}));
let editable;
if (type === 'editable-card') {
editable = {
onEdit: (editType, {
key,
event
}) => {
onEdit?.(editType === 'add' ? event : key, editType);
},
removeIcon: removeIcon ?? tabs?.removeIcon ?? /*#__PURE__*/React.createElement(_CloseOutlined.default, null),
addIcon: (addIcon ?? tabs?.addIcon) || /*#__PURE__*/React.createElement(_PlusOutlined.default, null),
showAdd: hideAdd !== true
};
}
const rootPrefixCls = getPrefixCls();
if (process.env.NODE_ENV !== 'production') {
const warning = (0, _warning.devUseWarning)('Tabs');
[['popupClassName', 'classNames.popup'], ['tabPosition', 'tabPlacement']].forEach(([deprecatedName, newName]) => {
warning.deprecated(!(deprecatedName in props), deprecatedName, newName);
});
process.env.NODE_ENV !== "production" ? warning(!('onPrevClick' in props) && !('onNextClick' in props), 'breaking', '`onPrevClick` and `onNextClick` has been removed. Please use `onTabScroll` instead.') : void 0;
process.env.NODE_ENV !== "production" ? warning(!(indicatorSize || tabs?.indicatorSize), 'deprecated', '`indicatorSize` has been deprecated. Please use `indicator={{ size: ... }}` instead.') : void 0;
warning.deprecated(!('destroyInactiveTabPane' in props || items?.some(item => 'destroyInactiveTabPane' in item)), 'destroyInactiveTabPane', 'destroyOnHidden');
}
const size = (0, _useSize.default)(customSize);
const mergedItems = (0, _useLegacyItems.default)(items, children);
const mergedAnimated = (0, _useAnimateConfig.default)(prefixCls, animated);
const mergedIndicator = {
align: indicator?.align ?? tabs?.indicator?.align,
size: indicator?.size ?? indicatorSize ?? tabs?.indicator?.size ?? tabs?.indicatorSize
};
const mergedPlacement = React.useMemo(() => {
const placement = tabPlacement ?? tabPosition ?? undefined;
const isRTL = direction === 'rtl';
switch (placement) {
case 'start':
return isRTL ? 'right' : 'left';
case 'end':
return isRTL ? 'left' : 'right';
default:
return placement;
}
}, [tabPlacement, tabPosition, direction]);
// =========== Merged Props for Semantic ===========
const mergedProps = {
...props,
size,
tabPlacement: mergedPlacement,
items: mergedItems
};
// ========================= Style ==========================
const [mergedClassNames, mergedStyles] = (0, _hooks.useMergeSemantic)([contextClassNames, classNames], [contextStyles, styles], {
props: mergedProps
}, {
popup: {
_default: 'root'
}
});
return /*#__PURE__*/React.createElement(_tabs.default, {
ref: tabsRef,
direction: direction,
getPopupContainer: getPopupContainer,
...restProps,
items: mergedItems,
className: (0, _clsx.clsx)({
[`${prefixCls}-large`]: size === 'large',
[`${prefixCls}-small`]: size === 'small',
[`${prefixCls}-card`]: ['card', 'editable-card'].includes(type),
[`${prefixCls}-editable-card`]: type === 'editable-card',
[`${prefixCls}-centered`]: centered
}, contextClassName, className, rootClassName, mergedClassNames.root, hashId, cssVarCls, rootCls),
classNames: {
...mergedClassNames,
popup: (0, _clsx.clsx)(popupClassName, hashId, cssVarCls, rootCls, mergedClassNames.popup?.root)
},
styles: mergedStyles,
style: {
...mergedStyles.root,
...contextStyle,
...style
},
editable: editable,
more: {
icon: tabs?.more?.icon ?? tabs?.moreIcon ?? moreIcon ?? /*#__PURE__*/React.createElement(_EllipsisOutlined.default, null),
transitionName: `${rootPrefixCls}-slide-up`,
...more
},
prefixCls: prefixCls,
animated: mergedAnimated,
indicator: mergedIndicator,
destroyOnHidden: destroyOnHidden ?? destroyInactiveTabPane,
tabPosition: mergedPlacement
});
});
const Tabs = InternalTabs;
Tabs.TabPane = _TabPane.default;
if (process.env.NODE_ENV !== 'production') {
Tabs.displayName = 'Tabs';
}
var _default = exports.default = Tabs;
+145
View File
@@ -0,0 +1,145 @@
import type { FullToken, GetDefaultToken } from '../../theme/internal';
export interface ComponentToken {
/**
* @desc 下拉菜单 z-index
* @descEN z-index of dropdown menu
*/
zIndexPopup: number;
/**
* @desc 卡片标签页背景色
* @descEN Background color of card tab
*/
cardBg: string;
/**
* @desc 卡片标签页高度
* @descEN Height of card tab
*/
cardHeight: number;
/**
* @desc 小尺寸卡片标签页高度
* @descEN Height of small card tab
*/
cardHeightSM: number;
/**
* @desc 大尺寸卡片标签页高度
* @descEN Height of large card tab
*/
cardHeightLG: number;
/**
* @desc 卡片标签页内间距
* @descEN Padding of card tab
*/
cardPadding: string;
/**
* @desc 小号卡片标签页内间距
* @descEN Padding of small card tab
*/
cardPaddingSM: string;
/**
* @desc 大号卡片标签页内间距
* @descEN Padding of large card tab
*/
cardPaddingLG: string;
/**
* @desc 标签页标题文本大小
* @descEN Font size of title
*/
titleFontSize: number;
/**
* @desc 大号标签页标题文本大小
* @descEN Font size of large title
*/
titleFontSizeLG: number;
/**
* @desc 小号标签页标题文本大小
* @descEN Font size of small title
*/
titleFontSizeSM: number;
/**
* @desc 指示条颜色
* @descEN Color of indicator
*/
inkBarColor: string;
/**
* @desc 横向标签页外间距
* @descEN Horizontal margin of horizontal tab
*/
horizontalMargin: string;
/**
* @desc 横向标签页标签间距
* @descEN Horizontal gutter of horizontal tab
*/
horizontalItemGutter: number;
/**
* @desc 横向标签页标签外间距
* @descEN Horizontal margin of horizontal tab item
*/
horizontalItemMargin: string;
/**
* @desc 横向标签页标签外间距(RTL)
* @descEN Horizontal margin of horizontal tab item (RTL)
*/
horizontalItemMarginRTL: string;
/**
* @desc 横向标签页标签内间距
* @descEN Horizontal padding of horizontal tab item
*/
horizontalItemPadding: string;
/**
* @desc 大号横向标签页标签内间距
* @descEN Horizontal padding of large horizontal tab item
*/
horizontalItemPaddingLG: string;
/**
* @desc 小号横向标签页标签内间距
* @descEN Horizontal padding of small horizontal tab item
*/
horizontalItemPaddingSM: string;
/**
* @desc 纵向标签页标签内间距
* @descEN Vertical padding of vertical tab item
*/
verticalItemPadding: string;
/**
* @desc 纵向标签页标签外间距
* @descEN Vertical margin of vertical tab item
*/
verticalItemMargin: string;
/**
* @desc 标签文本颜色
* @descEN Text color of tab
*/
itemColor: string;
/**
* @desc 标签激活态文本颜色
* @descEN Text color of active tab
*/
itemActiveColor: string;
/**
* @desc 标签悬浮态文本颜色
* @descEN Text color of hover tab
*/
itemHoverColor: string;
/**
* @desc 标签选中态文本颜色
* @descEN Text color of selected tab
*/
itemSelectedColor: string;
/**
* @desc 卡片标签间距
* @descEN Gutter of card tab
*/
cardGutter: number;
}
export interface TabsToken extends FullToken<'Tabs'> {
tabsCardPadding: string;
dropdownEdgeChildVerticalPadding: number;
tabsNavWrapPseudoWidth: number;
tabsDropdownHeight: number | string;
tabsDropdownWidth: number | string;
tabsHorizontalItemMargin: string;
tabsHorizontalItemMarginRTL: string;
}
export declare const prepareComponentToken: GetDefaultToken<'Tabs'>;
declare const _default: (prefixCls: string, rootCls?: string) => readonly [string, string];
export default _default;
+877
View File
@@ -0,0 +1,877 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.prepareComponentToken = exports.default = void 0;
var _cssinjs = require("@ant-design/cssinjs");
var _style = require("../../style");
var _internal = require("../../theme/internal");
var _motion = _interopRequireDefault(require("./motion"));
const genCardStyle = token => {
const {
componentCls,
tabsCardPadding,
cardBg,
cardGutter,
colorBorderSecondary,
itemSelectedColor
} = token;
return {
[`${componentCls}-card`]: {
[`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
[`${componentCls}-tab`]: {
margin: 0,
padding: tabsCardPadding,
background: cardBg,
border: `${(0, _cssinjs.unit)(token.lineWidth)} ${token.lineType} ${colorBorderSecondary}`,
transition: `all ${token.motionDurationSlow} ${token.motionEaseInOut}`
},
[`${componentCls}-tab-active`]: {
color: itemSelectedColor,
background: token.colorBgContainer
},
[`${componentCls}-tab-focus:has(${componentCls}-tab-btn:focus-visible)`]: (0, _style.genFocusOutline)(token, -3),
[`& ${componentCls}-tab${componentCls}-tab-focus ${componentCls}-tab-btn:focus-visible`]: {
outline: 'none'
},
[`${componentCls}-ink-bar`]: {
visibility: 'hidden'
}
},
// ========================== Top & Bottom ==========================
[`&${componentCls}-top, &${componentCls}-bottom`]: {
[`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
[`${componentCls}-tab + ${componentCls}-tab`]: {
marginLeft: {
_skip_check_: true,
value: (0, _cssinjs.unit)(cardGutter)
}
}
}
},
[`&${componentCls}-top`]: {
[`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
[`${componentCls}-tab`]: {
borderRadius: `${(0, _cssinjs.unit)(token.borderRadiusLG)} ${(0, _cssinjs.unit)(token.borderRadiusLG)} 0 0`
},
[`${componentCls}-tab-active`]: {
borderBottomColor: token.colorBgContainer
}
}
},
[`&${componentCls}-bottom`]: {
[`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
[`${componentCls}-tab`]: {
borderRadius: `0 0 ${(0, _cssinjs.unit)(token.borderRadiusLG)} ${(0, _cssinjs.unit)(token.borderRadiusLG)}`
},
[`${componentCls}-tab-active`]: {
borderTopColor: token.colorBgContainer
}
}
},
// ========================== Left & Right ==========================
[`&${componentCls}-left, &${componentCls}-right`]: {
[`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
[`${componentCls}-tab + ${componentCls}-tab`]: {
marginTop: (0, _cssinjs.unit)(cardGutter)
}
}
},
[`&${componentCls}-left`]: {
[`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
[`${componentCls}-tab`]: {
borderRadius: {
_skip_check_: true,
value: `${(0, _cssinjs.unit)(token.borderRadiusLG)} 0 0 ${(0, _cssinjs.unit)(token.borderRadiusLG)}`
}
},
[`${componentCls}-tab-active`]: {
borderRightColor: {
_skip_check_: true,
value: token.colorBgContainer
}
}
}
},
[`&${componentCls}-right`]: {
[`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
[`${componentCls}-tab`]: {
borderRadius: {
_skip_check_: true,
value: `0 ${(0, _cssinjs.unit)(token.borderRadiusLG)} ${(0, _cssinjs.unit)(token.borderRadiusLG)} 0`
}
},
[`${componentCls}-tab-active`]: {
borderLeftColor: {
_skip_check_: true,
value: token.colorBgContainer
}
}
}
}
}
};
};
const genDropdownStyle = token => {
const {
componentCls,
itemHoverColor,
dropdownEdgeChildVerticalPadding
} = token;
return {
[`${componentCls}-dropdown`]: {
...(0, _style.resetComponent)(token),
position: 'absolute',
top: -9999,
left: {
_skip_check_: true,
value: -9999
},
zIndex: token.zIndexPopup,
display: 'block',
'&-hidden': {
display: 'none'
},
[`${componentCls}-dropdown-menu`]: {
maxHeight: token.tabsDropdownHeight,
margin: 0,
padding: `${(0, _cssinjs.unit)(dropdownEdgeChildVerticalPadding)} 0`,
overflowX: 'hidden',
overflowY: 'auto',
textAlign: {
_skip_check_: true,
value: 'left'
},
listStyleType: 'none',
backgroundColor: token.colorBgContainer,
backgroundClip: 'padding-box',
borderRadius: token.borderRadiusLG,
outline: 'none',
boxShadow: token.boxShadowSecondary,
'&-item': {
..._style.textEllipsis,
display: 'flex',
alignItems: 'center',
minWidth: token.tabsDropdownWidth,
margin: 0,
padding: `${(0, _cssinjs.unit)(token.paddingXXS)} ${(0, _cssinjs.unit)(token.paddingSM)}`,
color: token.colorText,
fontWeight: 'normal',
fontSize: token.fontSize,
lineHeight: token.lineHeight,
cursor: 'pointer',
transition: `all ${token.motionDurationSlow}`,
'> span': {
flex: 1,
whiteSpace: 'nowrap'
},
'&-remove': {
flex: 'none',
marginLeft: {
_skip_check_: true,
value: token.marginSM
},
color: token.colorIcon,
fontSize: token.fontSizeSM,
background: 'transparent',
border: 0,
cursor: 'pointer',
'&:hover': {
color: itemHoverColor
}
},
'&:hover': {
background: token.controlItemBgHover
},
'&-disabled': {
'&, &:hover': {
color: token.colorTextDisabled,
background: 'transparent',
cursor: 'not-allowed'
}
}
}
}
}
};
};
const genPositionStyle = token => {
const {
componentCls,
margin,
colorBorderSecondary,
horizontalMargin,
verticalItemPadding,
verticalItemMargin,
motionDurationSlow,
calc
} = token;
return {
// ========================== Top & Bottom ==========================
[`${componentCls}-top, ${componentCls}-bottom`]: {
flexDirection: 'column',
[`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
margin: horizontalMargin,
'&::before': {
position: 'absolute',
right: {
_skip_check_: true,
value: 0
},
left: {
_skip_check_: true,
value: 0
},
borderBottom: `${(0, _cssinjs.unit)(token.lineWidth)} ${token.lineType} ${colorBorderSecondary}`,
content: "''"
},
[`${componentCls}-ink-bar`]: {
height: token.lineWidthBold,
'&-animated': {
transition: ['width', 'left', 'right'].map(prop => `${prop} ${motionDurationSlow}`).join(', ')
}
},
[`${componentCls}-nav-wrap`]: {
'&::before, &::after': {
top: 0,
bottom: 0,
width: token.controlHeight
},
'&::before': {
left: {
_skip_check_: true,
value: 0
},
boxShadow: token.boxShadowTabsOverflowLeft
},
'&::after': {
right: {
_skip_check_: true,
value: 0
},
boxShadow: token.boxShadowTabsOverflowRight
},
[`&${componentCls}-nav-wrap-ping-left::before`]: {
opacity: 1
},
[`&${componentCls}-nav-wrap-ping-right::after`]: {
opacity: 1
}
}
}
},
[`${componentCls}-top`]: {
[`> ${componentCls}-nav,
> div > ${componentCls}-nav`]: {
'&::before': {
bottom: 0
},
[`${componentCls}-ink-bar`]: {
bottom: 0
}
}
},
[`${componentCls}-bottom`]: {
[`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
order: 1,
marginTop: margin,
marginBottom: 0,
'&::before': {
top: 0
},
[`${componentCls}-ink-bar`]: {
top: 0
}
},
[`> ${componentCls}-content-holder, > div > ${componentCls}-content-holder`]: {
order: 0
}
},
// ========================== Left & Right ==========================
[`${componentCls}-left, ${componentCls}-right`]: {
[`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
flexDirection: 'column',
minWidth: calc(token.controlHeight).mul(1.25).equal(),
// >>>>>>>>>>> Tab
[`${componentCls}-tab`]: {
padding: verticalItemPadding,
textAlign: 'center'
},
[`${componentCls}-tab + ${componentCls}-tab`]: {
margin: verticalItemMargin
},
// >>>>>>>>>>> Nav
[`${componentCls}-nav-wrap`]: {
flexDirection: 'column',
'&::before, &::after': {
right: {
_skip_check_: true,
value: 0
},
left: {
_skip_check_: true,
value: 0
},
height: token.controlHeight
},
'&::before': {
top: 0,
boxShadow: token.boxShadowTabsOverflowTop
},
'&::after': {
bottom: 0,
boxShadow: token.boxShadowTabsOverflowBottom
},
[`&${componentCls}-nav-wrap-ping-top::before`]: {
opacity: 1
},
[`&${componentCls}-nav-wrap-ping-bottom::after`]: {
opacity: 1
}
},
// >>>>>>>>>>> Ink Bar
[`${componentCls}-ink-bar`]: {
width: token.lineWidthBold,
'&-animated': {
transition: ['height', 'top'].map(prop => `${prop} ${motionDurationSlow}`).join(', ')
}
},
[`${componentCls}-nav-list, ${componentCls}-nav-operations`]: {
flex: '1 0 auto',
// fix safari scroll problem
flexDirection: 'column'
}
}
},
[`${componentCls}-left`]: {
[`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
[`${componentCls}-ink-bar`]: {
right: {
_skip_check_: true,
value: 0
}
}
},
[`> ${componentCls}-content-holder, > div > ${componentCls}-content-holder`]: {
marginLeft: {
_skip_check_: true,
value: (0, _cssinjs.unit)(calc(token.lineWidth).mul(-1).equal())
},
borderLeft: {
_skip_check_: true,
value: `${(0, _cssinjs.unit)(token.lineWidth)} ${token.lineType} ${token.colorBorder}`
},
[`> ${componentCls}-content > ${componentCls}-tabpane`]: {
paddingLeft: {
_skip_check_: true,
value: token.paddingLG
}
}
}
},
[`${componentCls}-right`]: {
[`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
order: 1,
[`${componentCls}-ink-bar`]: {
left: {
_skip_check_: true,
value: 0
}
}
},
[`> ${componentCls}-content-holder, > div > ${componentCls}-content-holder`]: {
order: 0,
marginRight: {
_skip_check_: true,
value: calc(token.lineWidth).mul(-1).equal()
},
borderRight: {
_skip_check_: true,
value: `${(0, _cssinjs.unit)(token.lineWidth)} ${token.lineType} ${token.colorBorder}`
},
[`> ${componentCls}-content > ${componentCls}-tabpane`]: {
paddingRight: {
_skip_check_: true,
value: token.paddingLG
}
}
}
}
};
};
const genSizeStyle = token => {
const {
componentCls,
cardPaddingSM,
cardPaddingLG,
cardHeightSM,
cardHeightLG,
horizontalItemPaddingSM,
horizontalItemPaddingLG
} = token;
return {
// >>>>> shared
[componentCls]: {
'&-small': {
[`> ${componentCls}-nav`]: {
[`${componentCls}-tab`]: {
padding: horizontalItemPaddingSM,
fontSize: token.titleFontSizeSM
}
}
},
'&-large': {
[`> ${componentCls}-nav`]: {
[`${componentCls}-tab`]: {
padding: horizontalItemPaddingLG,
fontSize: token.titleFontSizeLG,
lineHeight: token.lineHeightLG
}
}
}
},
// >>>>> card
[`${componentCls}-card`]: {
// Small
[`&${componentCls}-small`]: {
[`> ${componentCls}-nav`]: {
[`${componentCls}-tab`]: {
padding: cardPaddingSM
},
[`${componentCls}-nav-add`]: {
minWidth: cardHeightSM,
minHeight: cardHeightSM
}
},
[`&${componentCls}-bottom`]: {
[`> ${componentCls}-nav ${componentCls}-tab`]: {
borderRadius: `0 0 ${(0, _cssinjs.unit)(token.borderRadius)} ${(0, _cssinjs.unit)(token.borderRadius)}`
}
},
[`&${componentCls}-top`]: {
[`> ${componentCls}-nav ${componentCls}-tab`]: {
borderRadius: `${(0, _cssinjs.unit)(token.borderRadius)} ${(0, _cssinjs.unit)(token.borderRadius)} 0 0`
}
},
[`&${componentCls}-right`]: {
[`> ${componentCls}-nav ${componentCls}-tab`]: {
borderRadius: {
_skip_check_: true,
value: `0 ${(0, _cssinjs.unit)(token.borderRadius)} ${(0, _cssinjs.unit)(token.borderRadius)} 0`
}
}
},
[`&${componentCls}-left`]: {
[`> ${componentCls}-nav ${componentCls}-tab`]: {
borderRadius: {
_skip_check_: true,
value: `${(0, _cssinjs.unit)(token.borderRadius)} 0 0 ${(0, _cssinjs.unit)(token.borderRadius)}`
}
}
}
},
// Large
[`&${componentCls}-large`]: {
[`> ${componentCls}-nav`]: {
[`${componentCls}-tab`]: {
padding: cardPaddingLG
},
[`${componentCls}-nav-add`]: {
minWidth: cardHeightLG,
minHeight: cardHeightLG
}
}
}
}
};
};
const genTabStyle = token => {
const {
componentCls,
itemActiveColor,
itemHoverColor,
iconCls,
tabsHorizontalItemMargin,
horizontalItemPadding,
itemSelectedColor,
itemColor
} = token;
const tabCls = `${componentCls}-tab`;
return {
[tabCls]: {
position: 'relative',
WebkitTouchCallout: 'none',
WebkitTapHighlightColor: 'transparent',
display: 'inline-flex',
alignItems: 'center',
padding: horizontalItemPadding,
fontSize: token.titleFontSize,
background: 'transparent',
border: 0,
outline: 'none',
cursor: 'pointer',
color: itemColor,
'&-btn, &-remove': {
'&:focus:not(:focus-visible), &:active': {
color: itemActiveColor
}
},
'&-btn': {
outline: 'none',
transition: `all ${token.motionDurationSlow}`,
[`${tabCls}-icon:not(:last-child)`]: {
marginInlineEnd: token.marginSM
}
},
'&-remove': {
flex: 'none',
lineHeight: 1,
marginRight: {
_skip_check_: true,
value: token.calc(token.marginXXS).mul(-1).equal()
},
marginLeft: {
_skip_check_: true,
value: token.marginXS
},
color: token.colorIcon,
fontSize: token.fontSizeSM,
background: 'transparent',
border: 'none',
outline: 'none',
cursor: 'pointer',
transition: `all ${token.motionDurationSlow}`,
'&:hover': {
color: token.colorTextHeading
},
...(0, _style.genFocusStyle)(token)
},
'&:hover': {
color: itemHoverColor
},
[`&${tabCls}-active ${tabCls}-btn`]: {
color: itemSelectedColor
},
[`&${tabCls}-focus ${tabCls}-btn:focus-visible`]: (0, _style.genFocusOutline)(token),
[`&${tabCls}-disabled`]: {
color: token.colorTextDisabled,
cursor: 'not-allowed'
},
[`&${tabCls}-disabled ${tabCls}-btn, &${tabCls}-disabled ${componentCls}-remove`]: {
'&:focus, &:active': {
color: token.colorTextDisabled
}
},
[`& ${tabCls}-remove ${iconCls}`]: {
margin: 0,
verticalAlign: 'middle'
},
[`${iconCls}:not(:last-child)`]: {
marginRight: {
_skip_check_: true,
value: token.marginSM
}
}
},
[`${tabCls} + ${tabCls}`]: {
margin: {
_skip_check_: true,
value: tabsHorizontalItemMargin
}
}
};
};
const genRtlStyle = token => {
const {
componentCls,
tabsHorizontalItemMarginRTL,
iconCls,
cardGutter,
calc
} = token;
const rtlCls = `${componentCls}-rtl`;
return {
[rtlCls]: {
direction: 'rtl',
[`${componentCls}-nav`]: {
[`${componentCls}-tab`]: {
margin: {
_skip_check_: true,
value: tabsHorizontalItemMarginRTL
},
[`${componentCls}-tab:last-of-type`]: {
marginLeft: {
_skip_check_: true,
value: 0
}
},
[iconCls]: {
marginRight: {
_skip_check_: true,
value: 0
},
marginLeft: {
_skip_check_: true,
value: token.marginSM
}
},
[`${componentCls}-tab-remove`]: {
marginRight: {
_skip_check_: true,
value: token.marginXS
},
marginLeft: {
_skip_check_: true,
value: calc(token.marginXXS).mul(-1).equal()
},
[iconCls]: {
margin: 0
}
}
}
},
[`&${componentCls}-left`]: {
[`> ${componentCls}-nav`]: {
order: 1
},
[`> ${componentCls}-content-holder`]: {
order: 0
}
},
[`&${componentCls}-right`]: {
[`> ${componentCls}-nav`]: {
order: 0
},
[`> ${componentCls}-content-holder`]: {
order: 1
}
},
// ====================== Card ======================
[`&${componentCls}-card${componentCls}-top, &${componentCls}-card${componentCls}-bottom`]: {
[`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
[`${componentCls}-tab + ${componentCls}-tab`]: {
marginRight: {
_skip_check_: true,
value: cardGutter
},
marginLeft: {
_skip_check_: true,
value: 0
}
}
}
}
},
[`${componentCls}-dropdown-rtl`]: {
direction: 'rtl'
},
[`${componentCls}-menu-item`]: {
[`${componentCls}-dropdown-rtl`]: {
textAlign: {
_skip_check_: true,
value: 'right'
}
}
}
};
};
const genTabsStyle = token => {
const {
componentCls,
tabsCardPadding,
cardHeight,
cardGutter,
itemHoverColor,
itemActiveColor,
colorBorderSecondary
} = token;
return {
[componentCls]: {
...(0, _style.resetComponent)(token),
display: 'flex',
// ========================== Navigation ==========================
[`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
position: 'relative',
display: 'flex',
flex: 'none',
alignItems: 'center',
[`${componentCls}-nav-wrap`]: {
position: 'relative',
display: 'flex',
flex: 'auto',
alignSelf: 'stretch',
overflow: 'hidden',
whiteSpace: 'nowrap',
transform: 'translate(0)',
// Fix chrome render bug
// >>>>> Ping shadow
'&::before, &::after': {
position: 'absolute',
zIndex: 1,
opacity: 0,
transition: `opacity ${token.motionDurationSlow}`,
content: "''",
pointerEvents: 'none'
}
},
[`${componentCls}-nav-list`]: {
position: 'relative',
display: 'flex',
transition: `opacity ${token.motionDurationSlow}`
},
// >>>>>>>> Operations
[`${componentCls}-nav-operations`]: {
display: 'flex',
alignSelf: 'stretch'
},
[`${componentCls}-nav-operations-hidden`]: {
position: 'absolute',
visibility: 'hidden',
pointerEvents: 'none'
},
[`${componentCls}-nav-more`]: {
position: 'relative',
padding: tabsCardPadding,
background: 'transparent',
border: 0,
color: token.colorText,
'&::after': {
position: 'absolute',
right: {
_skip_check_: true,
value: 0
},
bottom: 0,
left: {
_skip_check_: true,
value: 0
},
height: token.calc(token.controlHeightLG).div(8).equal(),
transform: 'translateY(100%)',
content: "''"
}
},
[`${componentCls}-nav-add`]: {
minWidth: cardHeight,
minHeight: cardHeight,
marginLeft: {
_skip_check_: true,
value: cardGutter
},
background: 'transparent',
border: `${(0, _cssinjs.unit)(token.lineWidth)} ${token.lineType} ${colorBorderSecondary}`,
borderRadius: `${(0, _cssinjs.unit)(token.borderRadiusLG)} ${(0, _cssinjs.unit)(token.borderRadiusLG)} 0 0`,
outline: 'none',
cursor: 'pointer',
color: token.colorText,
transition: `all ${token.motionDurationSlow} ${token.motionEaseInOut}`,
'&:hover': {
color: itemHoverColor
},
'&:active, &:focus:not(:focus-visible)': {
color: itemActiveColor
},
...(0, _style.genFocusStyle)(token, -3)
}
},
[`${componentCls}-extra-content`]: {
flex: 'none'
},
// ============================ InkBar ============================
[`${componentCls}-ink-bar`]: {
position: 'absolute',
background: token.inkBarColor,
pointerEvents: 'none'
},
// ============================= Tabs =============================
...genTabStyle(token),
// =========================== TabPanes ===========================
[`${componentCls}-content`]: {
position: 'relative',
width: '100%'
},
[`${componentCls}-content-holder`]: {
flex: 'auto',
minWidth: 0,
minHeight: 0
},
[`${componentCls}-tabpane`]: {
...(0, _style.genFocusStyle)(token),
'&-hidden': {
display: 'none'
}
}
},
[`${componentCls}-centered`]: {
[`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
[`${componentCls}-nav-wrap`]: {
[`&:not([class*='${componentCls}-nav-wrap-ping']) > ${componentCls}-nav-list`]: {
margin: 'auto'
}
}
}
}
};
};
const prepareComponentToken = token => {
const {
cardHeight,
cardHeightSM,
cardHeightLG,
controlHeight,
controlHeightLG
} = token;
const mergedCardHeight = cardHeight || controlHeightLG;
const mergedCardHeightSM = cardHeightSM || controlHeight;
// `controlHeight` missing XL variable, so we directly write it here:
const mergedCardHeightLG = cardHeightLG || controlHeightLG + 8;
return {
zIndexPopup: token.zIndexPopupBase + 50,
cardBg: token.colorFillAlter,
// We can not pass this as valid value,
// Since `cardHeight` will lock nav add button height.
cardHeight: mergedCardHeight,
cardHeightSM: mergedCardHeightSM,
cardHeightLG: mergedCardHeightLG,
// Initialize with empty string, because cardPadding will be calculated with cardHeight by default.
cardPadding: `${(mergedCardHeight - token.fontHeight) / 2 - token.lineWidth}px ${token.padding}px`,
cardPaddingSM: `${(mergedCardHeightSM - token.fontHeight) / 2 - token.lineWidth}px ${token.paddingXS}px`,
cardPaddingLG: `${(mergedCardHeightLG - token.fontHeightLG) / 2 - token.lineWidth}px ${token.padding}px`,
titleFontSize: token.fontSize,
titleFontSizeLG: token.fontSizeLG,
titleFontSizeSM: token.fontSize,
inkBarColor: token.colorPrimary,
horizontalMargin: `0 0 ${token.margin}px 0`,
horizontalItemGutter: 32,
// Fixed Value
// Initialize with empty string, because horizontalItemMargin will be calculated with horizontalItemGutter by default.
horizontalItemMargin: ``,
horizontalItemMarginRTL: ``,
horizontalItemPadding: `${token.paddingSM}px 0`,
horizontalItemPaddingSM: `${token.paddingXS}px 0`,
horizontalItemPaddingLG: `${token.padding}px 0`,
verticalItemPadding: `${token.paddingXS}px ${token.paddingLG}px`,
verticalItemMargin: `${token.margin}px 0 0 0`,
itemColor: token.colorText,
itemSelectedColor: token.colorPrimary,
itemHoverColor: token.colorPrimaryHover,
itemActiveColor: token.colorPrimaryActive,
cardGutter: token.marginXXS / 2
};
};
// ============================== Export ==============================
exports.prepareComponentToken = prepareComponentToken;
var _default = exports.default = (0, _internal.genStyleHooks)('Tabs', token => {
const tabsToken = (0, _internal.mergeToken)(token, {
// `cardPadding` is empty by default, so we could calculate with dynamic `cardHeight`
tabsCardPadding: token.cardPadding,
dropdownEdgeChildVerticalPadding: token.paddingXXS,
tabsDropdownHeight: 200,
tabsDropdownWidth: 120,
tabsHorizontalItemMargin: `0 0 0 ${(0, _cssinjs.unit)(token.horizontalItemGutter)}`,
tabsHorizontalItemMarginRTL: `0 0 0 ${(0, _cssinjs.unit)(token.horizontalItemGutter)}`
});
return [genSizeStyle(tabsToken), genRtlStyle(tabsToken), genPositionStyle(tabsToken), genDropdownStyle(tabsToken), genCardStyle(tabsToken), genTabsStyle(tabsToken), (0, _motion.default)(tabsToken)];
}, prepareComponentToken);
+4
View File
@@ -0,0 +1,4 @@
import type { TabsToken } from '.';
import type { GenerateStyle } from '../../theme/internal';
declare const genMotionStyle: GenerateStyle<TabsToken>;
export default genMotionStyle;
+44
View File
@@ -0,0 +1,44 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _motion = require("../../style/motion");
const genMotionStyle = token => {
const {
componentCls,
motionDurationSlow
} = token;
return [{
[componentCls]: {
[`${componentCls}-switch`]: {
'&-appear, &-enter': {
transition: 'none',
'&-start': {
opacity: 0
},
'&-active': {
opacity: 1,
transition: `opacity ${motionDurationSlow}`
}
},
'&-leave': {
position: 'absolute',
transition: 'none',
inset: 0,
'&-start': {
opacity: 1
},
'&-active': {
opacity: 0,
transition: `opacity ${motionDurationSlow}`
}
}
}
}
},
// Follow code may reuse in other components
[(0, _motion.initSlideMotion)(token, 'slide-up'), (0, _motion.initSlideMotion)(token, 'slide-down')]];
};
var _default = exports.default = genMotionStyle;