-
- {React.Children.map(children as React.ReactElement[], (item: React.ReactElement, key: number) => {
- if (!item) {
- return null;
- }
- const divProps: HTMLDivProps = {
- className: [
- `${prefixCls}-item`,
- item.key === activeKey ? 'active' : null,
- item.props.disabled ? 'disabled' : null,
- ]
- .filter(Boolean)
- .join(' ')
- .trim(),
- children: item.props.label,
- };
- if (!item.props.disabled) {
- divProps.onClick = (e: React.MouseEvent) => {
- setActiveKey(item.key as string);
- onTabClick && onTabClick(item.key as string, item, e);
- calcSlideStyle();
- };
- }
- return (
-
{
- if (node && item.key === activeKey) {
- activeItem.current = node;
- }
- }}
- {...divProps}
- />
- );
- })}
+
+
+
+
+ {renderNav(children)}
+
+
+ {hiddenNav.length > 0 && (
+
+ {renderNav(hiddenNav.map((idx) => (children as Array)[idx]))}
+
+ }
+ >
+
+ …
+
+
+ )}
{React.Children.map(children, (item: any) => {
if (!item || activeKey !== item.key) {
@@ -91,4 +146,31 @@ export default function Tabs(props: TabsProps) {
})}
);
+
+ function renderNav(children: React.ReactNode): React.ReactNode {
+ return React.Children.map(children as React.ReactElement[], (item: React.ReactElement, key: number) => {
+ if (!item) {
+ return null;
+ }
+ const divProps: HTMLDivProps = {
+ className: [
+ `${prefixCls}-item`,
+ item.key === activeKey ? 'active' : null,
+ item.props.disabled ? 'disabled' : null,
+ ]
+ .filter(Boolean)
+ .join(' ')
+ .trim(),
+ children: item.props.label,
+ };
+ if (!item.props.disabled) {
+ divProps.onClick = (e: React.MouseEvent) => {
+ setActiveKey(item.key as string);
+ onTabClick && onTabClick(item.key as string, item, e);
+ calcSlideStyle();
+ };
+ }
+ return
divNavRef(ref, key)} {...divProps} />;
+ });
+ }
}
diff --git a/packages/react-tabs/src/style/index.less b/packages/react-tabs/src/style/index.less
index 09ab8a4feb..6c884d76fb 100644
--- a/packages/react-tabs/src/style/index.less
+++ b/packages/react-tabs/src/style/index.less
@@ -3,10 +3,19 @@
.@{w-tabs} {
&-bar {
position: relative;
+ overflow-x: auto;
+ height: calc(100% + 17px);
}
&-nav {
position: relative;
}
+ &-nav-hidden {
+ display: flex;
+ overflow-x: scroll;
+ padding: 5px 30px 5px 5px;
+ max-height: 200px;
+ flex-direction: column;
+ }
&-item {
padding: 7px 10px;
display: inline-block;
@@ -26,6 +35,12 @@
color: rgba(0, 0, 0, 0.25);
}
}
+ &-flow-content {
+ margin-left: 5px;
+ padding: 0px 10px 0px 10px;
+ box-shadow: 1px 0px 0px #d9d9d9 inset;
+ cursor: pointer;
+ }
}
.@{w-tabs} {