Comparing version 12.14.0 to 12.14.1
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray"; | ||
import raf from "rc-util/es/raf"; | ||
import { useEffect, useRef, useState } from 'react'; | ||
import raf from "rc-util/es/raf"; | ||
var useIndicator = function useIndicator(_ref) { | ||
@@ -5,0 +5,0 @@ var activeTabOffset = _ref.activeTabOffset, |
@@ -1,2 +0,2 @@ | ||
import type { TabSizeMap, TabOffsetMap, Tab } from '../interface'; | ||
import type { Tab, TabOffsetMap, TabSizeMap } from '../interface'; | ||
export default function useOffsets(tabs: Tab[], tabSizes: TabSizeMap, holderScrollWidth: number): TabOffsetMap; |
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray"; | ||
import * as React from 'react'; | ||
import { useState, useRef } from 'react'; | ||
import { useRef, useState } from 'react'; | ||
var MIN_SWIPE_DISTANCE = 0.1; | ||
@@ -5,0 +5,0 @@ var STOP_SWIPE_DISTANCE = 0.01; |
@@ -21,3 +21,3 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray"; | ||
var _callbackRef$current; | ||
(_callbackRef$current = callbackRef.current) === null || _callbackRef$current === void 0 ? void 0 : _callbackRef$current.call(callbackRef); | ||
(_callbackRef$current = callbackRef.current) === null || _callbackRef$current === void 0 || _callbackRef$current.call(callbackRef); | ||
}, [count]); | ||
@@ -24,0 +24,0 @@ |
@@ -0,4 +1,4 @@ | ||
import type { TabsProps } from './Tabs'; | ||
import Tabs from './Tabs'; | ||
import type { TabsProps } from './Tabs'; | ||
export type { TabsProps }; | ||
export default Tabs; |
@@ -0,3 +1,3 @@ | ||
import type { CSSMotionProps } from 'rc-motion'; | ||
import type React from 'react'; | ||
import type { CSSMotionProps } from 'rc-motion'; | ||
import type { TabNavListProps } from './TabNavList'; | ||
@@ -4,0 +4,0 @@ import type { TabPaneProps } from './TabPanelList/TabPane'; |
@@ -9,3 +9,3 @@ import * as React from 'react'; | ||
} | ||
declare const _default: React.ForwardRefExoticComponent<AddButtonProps & React.RefAttributes<HTMLButtonElement>>; | ||
export default _default; | ||
declare const AddButton: React.ForwardRefExoticComponent<AddButtonProps & React.RefAttributes<HTMLButtonElement>>; | ||
export default AddButton; |
import * as React from 'react'; | ||
function AddButton(_ref, ref) { | ||
var prefixCls = _ref.prefixCls, | ||
editable = _ref.editable, | ||
locale = _ref.locale, | ||
style = _ref.style; | ||
var AddButton = /*#__PURE__*/React.forwardRef(function (props, ref) { | ||
var prefixCls = props.prefixCls, | ||
editable = props.editable, | ||
locale = props.locale, | ||
style = props.style; | ||
if (!editable || editable.showAdd === false) { | ||
@@ -22,3 +22,3 @@ return null; | ||
}, editable.addIcon || '+'); | ||
} | ||
export default /*#__PURE__*/React.forwardRef(AddButton); | ||
}); | ||
export default AddButton; |
import * as React from 'react'; | ||
import type { TabBarExtraPosition, TabBarExtraContent } from '../interface'; | ||
import type { TabBarExtraContent, TabBarExtraPosition } from '../interface'; | ||
interface ExtraContentProps { | ||
@@ -4,0 +4,0 @@ position: TabBarExtraPosition; |
import _typeof from "@babel/runtime/helpers/esm/typeof"; | ||
import * as React from 'react'; | ||
var ExtraContent = /*#__PURE__*/React.forwardRef(function (_ref, ref) { | ||
var position = _ref.position, | ||
prefixCls = _ref.prefixCls, | ||
extra = _ref.extra; | ||
if (!extra) return null; | ||
var ExtraContent = /*#__PURE__*/React.forwardRef(function (props, ref) { | ||
var position = props.position, | ||
prefixCls = props.prefixCls, | ||
extra = props.extra; | ||
if (!extra) { | ||
return null; | ||
} | ||
var content; | ||
@@ -9,0 +11,0 @@ |
@@ -27,3 +27,3 @@ import * as React from 'react'; | ||
} | ||
declare const _default: React.ForwardRefExoticComponent<TabNavListProps & React.RefAttributes<HTMLDivElement>>; | ||
export default _default; | ||
declare const TabNavList: React.ForwardRefExoticComponent<TabNavListProps & React.RefAttributes<HTMLDivElement>>; | ||
export default TabNavList; |
@@ -67,7 +67,4 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
}; | ||
function TabNavList(props, ref) { | ||
var TabNavList = /*#__PURE__*/React.forwardRef(function (props, ref) { | ||
var _classNames; | ||
var _React$useContext = React.useContext(TabContext), | ||
prefixCls = _React$useContext.prefixCls, | ||
tabs = _React$useContext.tabs; | ||
var className = props.className, | ||
@@ -88,11 +85,12 @@ style = props.style, | ||
indicatorSize = props.indicatorSize; | ||
var containerRef = useRef(); | ||
var extraLeftRef = useRef(); | ||
var extraRightRef = useRef(); | ||
var tabsWrapperRef = useRef(); | ||
var tabListRef = useRef(); | ||
var operationsRef = useRef(); | ||
var innerAddButtonRef = useRef(); | ||
// const [getBtnRef, removeBtnRef] = useRefs<HTMLDivElement>(); | ||
var _React$useContext = React.useContext(TabContext), | ||
prefixCls = _React$useContext.prefixCls, | ||
tabs = _React$useContext.tabs; | ||
var containerRef = useRef(null); | ||
var extraLeftRef = useRef(null); | ||
var extraRightRef = useRef(null); | ||
var tabsWrapperRef = useRef(null); | ||
var tabListRef = useRef(null); | ||
var operationsRef = useRef(null); | ||
var innerAddButtonRef = useRef(null); | ||
var tabPositionTopOrBottom = tabPosition === 'top' || tabPosition === 'bottom'; | ||
@@ -174,3 +172,3 @@ var _useSyncState = useSyncState(0, function (next, prev) { | ||
// ========================= Mobile ======================== | ||
var touchMovingRef = useRef(); | ||
var touchMovingRef = useRef(null); | ||
var _useState9 = useState(), | ||
@@ -184,3 +182,5 @@ _useState10 = _slicedToArray(_useState9, 2), | ||
function clearTouchMoving() { | ||
window.clearTimeout(touchMovingRef.current); | ||
if (touchMovingRef.current) { | ||
clearTimeout(touchMovingRef.current); | ||
} | ||
} | ||
@@ -211,3 +211,3 @@ useTouchMove(tabsWrapperRef, function (offsetX, offsetY) { | ||
if (lockAnimation) { | ||
touchMovingRef.current = window.setTimeout(function () { | ||
touchMovingRef.current = setTimeout(function () { | ||
setLockAnimation(0); | ||
@@ -473,4 +473,4 @@ }, 100); | ||
/* eslint-enable */ | ||
} | ||
}); | ||
export default /*#__PURE__*/React.forwardRef(TabNavList); | ||
export default TabNavList; |
@@ -9,22 +9,22 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
import { useEffect, useState } from 'react'; | ||
import { getRemovable } from "../util"; | ||
import AddButton from "./AddButton"; | ||
import { getRemovable } from "../util"; | ||
function OperationNode(_ref, ref) { | ||
var prefixCls = _ref.prefixCls, | ||
id = _ref.id, | ||
tabs = _ref.tabs, | ||
locale = _ref.locale, | ||
mobile = _ref.mobile, | ||
_ref$moreIcon = _ref.moreIcon, | ||
moreIcon = _ref$moreIcon === void 0 ? 'More' : _ref$moreIcon, | ||
moreTransitionName = _ref.moreTransitionName, | ||
style = _ref.style, | ||
className = _ref.className, | ||
editable = _ref.editable, | ||
tabBarGutter = _ref.tabBarGutter, | ||
rtl = _ref.rtl, | ||
removeAriaLabel = _ref.removeAriaLabel, | ||
onTabClick = _ref.onTabClick, | ||
getPopupContainer = _ref.getPopupContainer, | ||
popupClassName = _ref.popupClassName; | ||
var OperationNode = /*#__PURE__*/React.forwardRef(function (props, ref) { | ||
var prefixCls = props.prefixCls, | ||
id = props.id, | ||
tabs = props.tabs, | ||
locale = props.locale, | ||
mobile = props.mobile, | ||
_props$moreIcon = props.moreIcon, | ||
moreIcon = _props$moreIcon === void 0 ? 'More' : _props$moreIcon, | ||
moreTransitionName = props.moreTransitionName, | ||
style = props.style, | ||
className = props.className, | ||
editable = props.editable, | ||
tabBarGutter = props.tabBarGutter, | ||
rtl = props.rtl, | ||
removeAriaLabel = props.removeAriaLabel, | ||
onTabClick = props.onTabClick, | ||
getPopupContainer = props.getPopupContainer, | ||
popupClassName = props.popupClassName; | ||
// ======================== Dropdown ======================== | ||
@@ -52,5 +52,5 @@ var _useState = useState(false), | ||
var menu = /*#__PURE__*/React.createElement(Menu, { | ||
onClick: function onClick(_ref2) { | ||
var key = _ref2.key, | ||
domEvent = _ref2.domEvent; | ||
onClick: function onClick(_ref) { | ||
var key = _ref.key, | ||
domEvent = _ref.domEvent; | ||
onTabClick(key, domEvent); | ||
@@ -130,3 +130,5 @@ setOpen(false); | ||
case KeyCode.ENTER: | ||
if (selectedKey !== null) onTabClick(selectedKey, e); | ||
if (selectedKey !== null) { | ||
onTabClick(selectedKey, e); | ||
} | ||
break; | ||
@@ -189,4 +191,4 @@ } | ||
})); | ||
} | ||
export default /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(OperationNode), function (_, next) { | ||
}); | ||
export default /*#__PURE__*/React.memo(OperationNode, function (_, next) { | ||
return ( | ||
@@ -193,0 +195,0 @@ // https://github.com/ant-design/ant-design/issues/32544 |
@@ -18,3 +18,3 @@ import * as React from 'react'; | ||
} | ||
declare function TabNode({ prefixCls, id, active, tab: { key, label, disabled, closeIcon, icon }, closable, renderWrapper, removeAriaLabel, editable, onClick, onFocus, style, }: TabNodeProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>; | ||
declare const TabNode: React.FC<TabNodeProps>; | ||
export default TabNode; |
@@ -6,20 +6,20 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
import { genDataNodeKey, getRemovable } from "../util"; | ||
function TabNode(_ref) { | ||
var TabNode = function TabNode(props) { | ||
var _classNames; | ||
var prefixCls = _ref.prefixCls, | ||
id = _ref.id, | ||
active = _ref.active, | ||
_ref$tab = _ref.tab, | ||
key = _ref$tab.key, | ||
label = _ref$tab.label, | ||
disabled = _ref$tab.disabled, | ||
closeIcon = _ref$tab.closeIcon, | ||
icon = _ref$tab.icon, | ||
closable = _ref.closable, | ||
renderWrapper = _ref.renderWrapper, | ||
removeAriaLabel = _ref.removeAriaLabel, | ||
editable = _ref.editable, | ||
onClick = _ref.onClick, | ||
onFocus = _ref.onFocus, | ||
style = _ref.style; | ||
var prefixCls = props.prefixCls, | ||
id = props.id, | ||
active = props.active, | ||
_props$tab = props.tab, | ||
key = _props$tab.key, | ||
label = _props$tab.label, | ||
disabled = _props$tab.disabled, | ||
closeIcon = _props$tab.closeIcon, | ||
icon = _props$tab.icon, | ||
closable = props.closable, | ||
renderWrapper = props.renderWrapper, | ||
removeAriaLabel = props.removeAriaLabel, | ||
editable = props.editable, | ||
onClick = props.onClick, | ||
onFocus = props.onFocus, | ||
style = props.style; | ||
var tabPrefix = "".concat(prefixCls, "-tab"); | ||
@@ -41,2 +41,5 @@ var removable = getRemovable(closable, closeIcon, editable, disabled); | ||
} | ||
var labelNode = React.useMemo(function () { | ||
return icon && typeof label === 'string' ? /*#__PURE__*/React.createElement("span", null, label) : label; | ||
}, [label, icon]); | ||
var node = /*#__PURE__*/React.createElement("div", { | ||
@@ -71,3 +74,3 @@ key: key | ||
className: "".concat(tabPrefix, "-icon") | ||
}, icon), label), removable && /*#__PURE__*/React.createElement("button", { | ||
}, icon), label && labelNode), removable && /*#__PURE__*/React.createElement("button", { | ||
type: "button", | ||
@@ -83,3 +86,3 @@ "aria-label": removeAriaLabel || 'remove', | ||
return renderWrapper ? renderWrapper(node) : node; | ||
} | ||
}; | ||
export default TabNode; |
import * as React from 'react'; | ||
import type { TabNavListProps } from '.'; | ||
export type TabNavListWrapperProps = Required<Omit<TabNavListProps, 'children' | 'className'>> & TabNavListProps; | ||
export default function TabNavListWrapper({ renderTabBar, ...restProps }: TabNavListWrapperProps): React.JSX.Element; | ||
declare const TabNavListWrapper: React.FC<TabNavListWrapperProps>; | ||
export default TabNavListWrapper; |
@@ -13,3 +13,3 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
// We have to create a TabNavList components. | ||
export default function TabNavListWrapper(_ref) { | ||
var TabNavListWrapper = function TabNavListWrapper(_ref) { | ||
var renderTabBar = _ref.renderTabBar, | ||
@@ -36,2 +36,6 @@ restProps = _objectWithoutProperties(_ref, _excluded); | ||
return /*#__PURE__*/React.createElement(TabNavList, restProps); | ||
} | ||
}; | ||
if (process.env.NODE_ENV !== 'production') { | ||
TabNavListWrapper.displayName = 'TabNavListWrapper'; | ||
} | ||
export default TabNavListWrapper; |
import * as React from 'react'; | ||
import type { TabPosition, AnimatedConfig } from '../interface'; | ||
import type { AnimatedConfig, TabPosition } from '../interface'; | ||
export interface TabPanelListProps { | ||
@@ -10,2 +10,3 @@ activeKey: string; | ||
} | ||
export default function TabPanelList({ id, activeKey, animated, tabPosition, destroyInactiveTabPane, }: TabPanelListProps): React.JSX.Element; | ||
declare const TabPanelList: React.FC<TabPanelListProps>; | ||
export default TabPanelList; |
@@ -6,13 +6,13 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
var _excluded = ["key", "forceRender", "style", "className", "destroyInactiveTabPane"]; | ||
import * as React from 'react'; | ||
import classNames from 'classnames'; | ||
import CSSMotion from 'rc-motion'; | ||
import * as React from 'react'; | ||
import TabContext from "../TabContext"; | ||
import TabPane from "./TabPane"; | ||
export default function TabPanelList(_ref) { | ||
var id = _ref.id, | ||
activeKey = _ref.activeKey, | ||
animated = _ref.animated, | ||
tabPosition = _ref.tabPosition, | ||
destroyInactiveTabPane = _ref.destroyInactiveTabPane; | ||
var TabPanelList = function TabPanelList(props) { | ||
var id = props.id, | ||
activeKey = props.activeKey, | ||
animated = props.animated, | ||
tabPosition = props.tabPosition, | ||
destroyInactiveTabPane = props.destroyInactiveTabPane; | ||
var _React$useContext = React.useContext(TabContext), | ||
@@ -27,9 +27,9 @@ prefixCls = _React$useContext.prefixCls, | ||
className: classNames("".concat(prefixCls, "-content"), "".concat(prefixCls, "-content-").concat(tabPosition), _defineProperty({}, "".concat(prefixCls, "-content-animated"), tabPaneAnimated)) | ||
}, tabs.map(function (_ref2) { | ||
var key = _ref2.key, | ||
forceRender = _ref2.forceRender, | ||
paneStyle = _ref2.style, | ||
paneClassName = _ref2.className, | ||
itemDestroyInactiveTabPane = _ref2.destroyInactiveTabPane, | ||
restTabProps = _objectWithoutProperties(_ref2, _excluded); | ||
}, tabs.map(function (item) { | ||
var key = item.key, | ||
forceRender = item.forceRender, | ||
paneStyle = item.style, | ||
paneClassName = item.className, | ||
itemDestroyInactiveTabPane = item.destroyInactiveTabPane, | ||
restTabProps = _objectWithoutProperties(item, _excluded); | ||
var active = key === activeKey; | ||
@@ -42,5 +42,5 @@ return /*#__PURE__*/React.createElement(CSSMotion, _extends({ | ||
leavedClassName: "".concat(tabPanePrefixCls, "-hidden") | ||
}, animated.tabPaneMotion), function (_ref3, ref) { | ||
var motionStyle = _ref3.style, | ||
motionClassName = _ref3.className; | ||
}, animated.tabPaneMotion), function (_ref, ref) { | ||
var motionStyle = _ref.style, | ||
motionClassName = _ref.className; | ||
return /*#__PURE__*/React.createElement(TabPane, _extends({}, restTabProps, { | ||
@@ -58,2 +58,3 @@ prefixCls: tabPanePrefixCls, | ||
}))); | ||
} | ||
}; | ||
export default TabPanelList; |
import classNames from 'classnames'; | ||
import * as React from 'react'; | ||
var TabPane = /*#__PURE__*/React.forwardRef(function (_ref, ref) { | ||
var prefixCls = _ref.prefixCls, | ||
className = _ref.className, | ||
style = _ref.style, | ||
id = _ref.id, | ||
active = _ref.active, | ||
tabKey = _ref.tabKey, | ||
children = _ref.children; | ||
var TabPane = /*#__PURE__*/React.forwardRef(function (props, ref) { | ||
var prefixCls = props.prefixCls, | ||
className = props.className, | ||
style = props.style, | ||
id = props.id, | ||
active = props.active, | ||
tabKey = props.tabKey, | ||
children = props.children; | ||
return /*#__PURE__*/React.createElement("div", { | ||
@@ -12,0 +12,0 @@ id: id && "".concat(id, "-panel-").concat(tabKey), |
import * as React from 'react'; | ||
import type { GetIndicatorSize } from './hooks/useIndicator'; | ||
import type { AnimatedConfig, EditableConfig, OnTabScroll, RenderTabBar, Tab, TabBarExtraContent, TabPosition, TabsLocale } from './interface'; | ||
import type { GetIndicatorSize } from './hooks/useIndicator'; | ||
export interface TabsProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'children'> { | ||
@@ -32,3 +32,3 @@ prefixCls?: string; | ||
} | ||
declare const ForwardTabs: React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLDivElement>>; | ||
export default ForwardTabs; | ||
declare const Tabs: React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLDivElement>>; | ||
export default Tabs; |
@@ -9,11 +9,12 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
// Accessibility https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Tab_Role | ||
import classNames from 'classnames'; | ||
import useMergedState from "rc-util/es/hooks/useMergedState"; | ||
import isMobile from "rc-util/es/isMobile"; | ||
import * as React from 'react'; | ||
import { useEffect, useState } from 'react'; | ||
import classNames from 'classnames'; | ||
import isMobile from "rc-util/es/isMobile"; | ||
import useMergedState from "rc-util/es/hooks/useMergedState"; | ||
import TabPanelList from "./TabPanelList"; | ||
import useAnimateConfig from "./hooks/useAnimateConfig"; | ||
import TabContext from "./TabContext"; | ||
import TabNavListWrapper from "./TabNavList/Wrapper"; | ||
import useAnimateConfig from "./hooks/useAnimateConfig"; | ||
import TabPanelList from "./TabPanelList"; | ||
/** | ||
@@ -27,33 +28,35 @@ * Should added antd: | ||
* - keyboard | ||
*/ // Used for accessibility | ||
*/ | ||
// Used for accessibility | ||
var uuid = 0; | ||
function Tabs(_ref, ref) { | ||
var Tabs = /*#__PURE__*/React.forwardRef(function (props, ref) { | ||
var _classNames; | ||
var id = _ref.id, | ||
_ref$prefixCls = _ref.prefixCls, | ||
prefixCls = _ref$prefixCls === void 0 ? 'rc-tabs' : _ref$prefixCls, | ||
className = _ref.className, | ||
items = _ref.items, | ||
direction = _ref.direction, | ||
activeKey = _ref.activeKey, | ||
defaultActiveKey = _ref.defaultActiveKey, | ||
editable = _ref.editable, | ||
animated = _ref.animated, | ||
_ref$tabPosition = _ref.tabPosition, | ||
tabPosition = _ref$tabPosition === void 0 ? 'top' : _ref$tabPosition, | ||
tabBarGutter = _ref.tabBarGutter, | ||
tabBarStyle = _ref.tabBarStyle, | ||
tabBarExtraContent = _ref.tabBarExtraContent, | ||
locale = _ref.locale, | ||
moreIcon = _ref.moreIcon, | ||
moreTransitionName = _ref.moreTransitionName, | ||
destroyInactiveTabPane = _ref.destroyInactiveTabPane, | ||
renderTabBar = _ref.renderTabBar, | ||
onChange = _ref.onChange, | ||
onTabClick = _ref.onTabClick, | ||
onTabScroll = _ref.onTabScroll, | ||
getPopupContainer = _ref.getPopupContainer, | ||
popupClassName = _ref.popupClassName, | ||
indicatorSize = _ref.indicatorSize, | ||
restProps = _objectWithoutProperties(_ref, _excluded); | ||
var id = props.id, | ||
_props$prefixCls = props.prefixCls, | ||
prefixCls = _props$prefixCls === void 0 ? 'rc-tabs' : _props$prefixCls, | ||
className = props.className, | ||
items = props.items, | ||
direction = props.direction, | ||
activeKey = props.activeKey, | ||
defaultActiveKey = props.defaultActiveKey, | ||
editable = props.editable, | ||
animated = props.animated, | ||
_props$tabPosition = props.tabPosition, | ||
tabPosition = _props$tabPosition === void 0 ? 'top' : _props$tabPosition, | ||
tabBarGutter = props.tabBarGutter, | ||
tabBarStyle = props.tabBarStyle, | ||
tabBarExtraContent = props.tabBarExtraContent, | ||
locale = props.locale, | ||
moreIcon = props.moreIcon, | ||
moreTransitionName = props.moreTransitionName, | ||
destroyInactiveTabPane = props.destroyInactiveTabPane, | ||
renderTabBar = props.renderTabBar, | ||
onChange = props.onChange, | ||
onTabClick = props.onTabClick, | ||
onTabScroll = props.onTabScroll, | ||
getPopupContainer = props.getPopupContainer, | ||
popupClassName = props.popupClassName, | ||
indicatorSize = props.indicatorSize, | ||
restProps = _objectWithoutProperties(props, _excluded); | ||
var tabs = React.useMemo(function () { | ||
@@ -130,7 +133,7 @@ return (items || []).filter(function (item) { | ||
function onInternalTabClick(key, e) { | ||
onTabClick === null || onTabClick === void 0 ? void 0 : onTabClick(key, e); | ||
onTabClick === null || onTabClick === void 0 || onTabClick(key, e); | ||
var isActiveChanged = key !== mergedActiveKey; | ||
setMergedActiveKey(key); | ||
if (isActiveChanged) { | ||
onChange === null || onChange === void 0 ? void 0 : onChange(key); | ||
onChange === null || onChange === void 0 || onChange(key); | ||
} | ||
@@ -179,7 +182,6 @@ } | ||
})))); | ||
} | ||
var ForwardTabs = /*#__PURE__*/React.forwardRef(Tabs); | ||
}); | ||
if (process.env.NODE_ENV !== 'production') { | ||
ForwardTabs.displayName = 'Tabs'; | ||
Tabs.displayName = 'Tabs'; | ||
} | ||
export default ForwardTabs; | ||
export default Tabs; |
@@ -9,4 +9,4 @@ "use strict"; | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
var _raf = _interopRequireDefault(require("rc-util/lib/raf")); | ||
var _react = require("react"); | ||
var _raf = _interopRequireDefault(require("rc-util/lib/raf")); | ||
var useIndicator = function useIndicator(_ref) { | ||
@@ -64,3 +64,2 @@ var activeTabOffset = _ref.activeTabOffset, | ||
}; | ||
var _default = useIndicator; | ||
exports.default = _default; | ||
var _default = exports.default = useIndicator; |
@@ -1,2 +0,2 @@ | ||
import type { TabSizeMap, TabOffsetMap, Tab } from '../interface'; | ||
import type { Tab, TabOffsetMap, TabSizeMap } from '../interface'; | ||
export default function useOffsets(tabs: Tab[], tabSizes: TabSizeMap, holderScrollWidth: number): TabOffsetMap; |
@@ -11,4 +11,4 @@ "use strict"; | ||
var React = _interopRequireWildcard(require("react")); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
function useSyncState(defaultState, onChange) { | ||
@@ -15,0 +15,0 @@ var stateRef = React.useRef(defaultState); |
@@ -10,5 +10,6 @@ "use strict"; | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
var React = _interopRequireWildcard(require("react")); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
var _react = _interopRequireWildcard(require("react")); | ||
var React = _react; | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
var MIN_SWIPE_DISTANCE = 0.1; | ||
@@ -21,19 +22,19 @@ var STOP_SWIPE_DISTANCE = 0.01; | ||
function useTouchMove(ref, onOffset) { | ||
var _useState = (0, React.useState)(), | ||
var _useState = (0, _react.useState)(), | ||
_useState2 = (0, _slicedToArray2.default)(_useState, 2), | ||
touchPosition = _useState2[0], | ||
setTouchPosition = _useState2[1]; | ||
var _useState3 = (0, React.useState)(0), | ||
var _useState3 = (0, _react.useState)(0), | ||
_useState4 = (0, _slicedToArray2.default)(_useState3, 2), | ||
lastTimestamp = _useState4[0], | ||
setLastTimestamp = _useState4[1]; | ||
var _useState5 = (0, React.useState)(0), | ||
var _useState5 = (0, _react.useState)(0), | ||
_useState6 = (0, _slicedToArray2.default)(_useState5, 2), | ||
lastTimeDiff = _useState6[0], | ||
setLastTimeDiff = _useState6[1]; | ||
var _useState7 = (0, React.useState)(), | ||
var _useState7 = (0, _react.useState)(), | ||
_useState8 = (0, _slicedToArray2.default)(_useState7, 2), | ||
lastOffset = _useState8[0], | ||
setLastOffset = _useState8[1]; | ||
var motionRef = (0, React.useRef)(); | ||
var motionRef = (0, _react.useRef)(); | ||
@@ -102,3 +103,3 @@ // ========================= Events ========================= | ||
// >>> Wheel event | ||
var lastWheelDirectionRef = (0, React.useRef)(); | ||
var lastWheelDirectionRef = (0, _react.useRef)(); | ||
function onWheel(e) { | ||
@@ -127,3 +128,3 @@ var deltaX = e.deltaX, | ||
// ========================= Effect ========================= | ||
var touchEventsRef = (0, React.useRef)(null); | ||
var touchEventsRef = (0, _react.useRef)(null); | ||
touchEventsRef.current = { | ||
@@ -130,0 +131,0 @@ onTouchStart: onTouchStart, |
@@ -28,3 +28,3 @@ "use strict"; | ||
var _callbackRef$current; | ||
(_callbackRef$current = callbackRef.current) === null || _callbackRef$current === void 0 ? void 0 : _callbackRef$current.call(callbackRef); | ||
(_callbackRef$current = callbackRef.current) === null || _callbackRef$current === void 0 || _callbackRef$current.call(callbackRef); | ||
}, [count]); | ||
@@ -31,0 +31,0 @@ |
@@ -0,4 +1,4 @@ | ||
import type { TabsProps } from './Tabs'; | ||
import Tabs from './Tabs'; | ||
import type { TabsProps } from './Tabs'; | ||
export type { TabsProps }; | ||
export default Tabs; |
@@ -9,3 +9,2 @@ "use strict"; | ||
var _Tabs = _interopRequireDefault(require("./Tabs")); | ||
var _default = _Tabs.default; | ||
exports.default = _default; | ||
var _default = exports.default = _Tabs.default; |
@@ -0,3 +1,3 @@ | ||
import type { CSSMotionProps } from 'rc-motion'; | ||
import type React from 'react'; | ||
import type { CSSMotionProps } from 'rc-motion'; | ||
import type { TabNavListProps } from './TabNavList'; | ||
@@ -4,0 +4,0 @@ import type { TabPaneProps } from './TabPanelList/TabPane'; |
@@ -8,3 +8,2 @@ "use strict"; | ||
var _react = require("react"); | ||
var _default = /*#__PURE__*/(0, _react.createContext)(null); | ||
exports.default = _default; | ||
var _default = exports.default = /*#__PURE__*/(0, _react.createContext)(null); |
@@ -9,3 +9,3 @@ import * as React from 'react'; | ||
} | ||
declare const _default: React.ForwardRefExoticComponent<AddButtonProps & React.RefAttributes<HTMLButtonElement>>; | ||
export default _default; | ||
declare const AddButton: React.ForwardRefExoticComponent<AddButtonProps & React.RefAttributes<HTMLButtonElement>>; | ||
export default AddButton; |
@@ -9,9 +9,9 @@ "use strict"; | ||
var React = _interopRequireWildcard(require("react")); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function AddButton(_ref, ref) { | ||
var prefixCls = _ref.prefixCls, | ||
editable = _ref.editable, | ||
locale = _ref.locale, | ||
style = _ref.style; | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
var AddButton = /*#__PURE__*/React.forwardRef(function (props, ref) { | ||
var prefixCls = props.prefixCls, | ||
editable = props.editable, | ||
locale = props.locale, | ||
style = props.style; | ||
if (!editable || editable.showAdd === false) { | ||
@@ -32,4 +32,3 @@ return null; | ||
}, editable.addIcon || '+'); | ||
} | ||
var _default = /*#__PURE__*/React.forwardRef(AddButton); | ||
exports.default = _default; | ||
}); | ||
var _default = exports.default = AddButton; |
import * as React from 'react'; | ||
import type { TabBarExtraPosition, TabBarExtraContent } from '../interface'; | ||
import type { TabBarExtraContent, TabBarExtraPosition } from '../interface'; | ||
interface ExtraContentProps { | ||
@@ -4,0 +4,0 @@ position: TabBarExtraPosition; |
@@ -11,9 +11,11 @@ "use strict"; | ||
var React = _interopRequireWildcard(require("react")); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
var ExtraContent = /*#__PURE__*/React.forwardRef(function (_ref, ref) { | ||
var position = _ref.position, | ||
prefixCls = _ref.prefixCls, | ||
extra = _ref.extra; | ||
if (!extra) return null; | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
var ExtraContent = /*#__PURE__*/React.forwardRef(function (props, ref) { | ||
var position = props.position, | ||
prefixCls = props.prefixCls, | ||
extra = props.extra; | ||
if (!extra) { | ||
return null; | ||
} | ||
var content; | ||
@@ -42,3 +44,2 @@ | ||
} | ||
var _default = ExtraContent; | ||
exports.default = _default; | ||
var _default = exports.default = ExtraContent; |
@@ -27,3 +27,3 @@ import * as React from 'react'; | ||
} | ||
declare const _default: React.ForwardRefExoticComponent<TabNavListProps & React.RefAttributes<HTMLDivElement>>; | ||
export default _default; | ||
declare const TabNavList: React.ForwardRefExoticComponent<TabNavListProps & React.RefAttributes<HTMLDivElement>>; | ||
export default TabNavList; |
@@ -18,3 +18,4 @@ "use strict"; | ||
var _ref3 = require("rc-util/lib/ref"); | ||
var React = _interopRequireWildcard(require("react")); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var React = _react; | ||
var _useIndicator2 = _interopRequireDefault(require("../hooks/useIndicator")); | ||
@@ -32,4 +33,4 @@ var _useOffsets = _interopRequireDefault(require("../hooks/useOffsets")); | ||
var _TabNode = _interopRequireDefault(require("./TabNode")); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
var getTabSize = function getTabSize(tab, containerRect) { | ||
@@ -78,7 +79,4 @@ // tabListRef | ||
}; | ||
function TabNavList(props, ref) { | ||
var TabNavList = /*#__PURE__*/React.forwardRef(function (props, ref) { | ||
var _classNames; | ||
var _React$useContext = React.useContext(_TabContext.default), | ||
prefixCls = _React$useContext.prefixCls, | ||
tabs = _React$useContext.tabs; | ||
var className = props.className, | ||
@@ -99,11 +97,12 @@ style = props.style, | ||
indicatorSize = props.indicatorSize; | ||
var containerRef = (0, React.useRef)(); | ||
var extraLeftRef = (0, React.useRef)(); | ||
var extraRightRef = (0, React.useRef)(); | ||
var tabsWrapperRef = (0, React.useRef)(); | ||
var tabListRef = (0, React.useRef)(); | ||
var operationsRef = (0, React.useRef)(); | ||
var innerAddButtonRef = (0, React.useRef)(); | ||
// const [getBtnRef, removeBtnRef] = useRefs<HTMLDivElement>(); | ||
var _React$useContext = React.useContext(_TabContext.default), | ||
prefixCls = _React$useContext.prefixCls, | ||
tabs = _React$useContext.tabs; | ||
var containerRef = (0, _react.useRef)(null); | ||
var extraLeftRef = (0, _react.useRef)(null); | ||
var extraRightRef = (0, _react.useRef)(null); | ||
var tabsWrapperRef = (0, _react.useRef)(null); | ||
var tabListRef = (0, _react.useRef)(null); | ||
var operationsRef = (0, _react.useRef)(null); | ||
var innerAddButtonRef = (0, _react.useRef)(null); | ||
var tabPositionTopOrBottom = tabPosition === 'top' || tabPosition === 'bottom'; | ||
@@ -130,15 +129,15 @@ var _useSyncState = (0, _useSyncState5.default)(0, function (next, prev) { | ||
setTransformTop = _useSyncState4[1]; | ||
var _useState = (0, React.useState)([0, 0]), | ||
var _useState = (0, _react.useState)([0, 0]), | ||
_useState2 = (0, _slicedToArray2.default)(_useState, 2), | ||
containerExcludeExtraSize = _useState2[0], | ||
setContainerExcludeExtraSize = _useState2[1]; | ||
var _useState3 = (0, React.useState)([0, 0]), | ||
var _useState3 = (0, _react.useState)([0, 0]), | ||
_useState4 = (0, _slicedToArray2.default)(_useState3, 2), | ||
tabContentSize = _useState4[0], | ||
setTabContentSize = _useState4[1]; | ||
var _useState5 = (0, React.useState)([0, 0]), | ||
var _useState5 = (0, _react.useState)([0, 0]), | ||
_useState6 = (0, _slicedToArray2.default)(_useState5, 2), | ||
addSize = _useState6[0], | ||
setAddSize = _useState6[1]; | ||
var _useState7 = (0, React.useState)([0, 0]), | ||
var _useState7 = (0, _react.useState)([0, 0]), | ||
_useState8 = (0, _slicedToArray2.default)(_useState7, 2), | ||
@@ -186,4 +185,4 @@ operationSize = _useState8[0], | ||
// ========================= Mobile ======================== | ||
var touchMovingRef = (0, React.useRef)(); | ||
var _useState9 = (0, React.useState)(), | ||
var touchMovingRef = (0, _react.useRef)(null); | ||
var _useState9 = (0, _react.useState)(), | ||
_useState10 = (0, _slicedToArray2.default)(_useState9, 2), | ||
@@ -196,3 +195,5 @@ lockAnimation = _useState10[0], | ||
function clearTouchMoving() { | ||
window.clearTimeout(touchMovingRef.current); | ||
if (touchMovingRef.current) { | ||
clearTimeout(touchMovingRef.current); | ||
} | ||
} | ||
@@ -220,6 +221,6 @@ (0, _useTouchMove.default)(tabsWrapperRef, function (offsetX, offsetY) { | ||
}); | ||
(0, React.useEffect)(function () { | ||
(0, _react.useEffect)(function () { | ||
clearTouchMoving(); | ||
if (lockAnimation) { | ||
touchMovingRef.current = window.setTimeout(function () { | ||
touchMovingRef.current = setTimeout(function () { | ||
setLockAnimation(0); | ||
@@ -360,3 +361,3 @@ }, 100); | ||
}; | ||
(0, React.useEffect)(function () { | ||
(0, _react.useEffect)(function () { | ||
updateTabSizes(); | ||
@@ -401,3 +402,3 @@ }, [tabs.map(function (tab) { | ||
// ========================= Effect ======================== | ||
(0, React.useEffect)(function () { | ||
(0, _react.useEffect)(function () { | ||
scrollToTab(); | ||
@@ -408,3 +409,3 @@ // eslint-disable-next-line | ||
// Should recalculate when rtl changed | ||
(0, React.useEffect)(function () { | ||
(0, _react.useEffect)(function () { | ||
onListHolderResize(); | ||
@@ -488,4 +489,3 @@ // eslint-disable-next-line | ||
/* eslint-enable */ | ||
} | ||
var _default = /*#__PURE__*/React.forwardRef(TabNavList); | ||
exports.default = _default; | ||
}); | ||
var _default = exports.default = TabNavList; |
@@ -15,31 +15,32 @@ "use strict"; | ||
var _KeyCode = _interopRequireDefault(require("rc-util/lib/KeyCode")); | ||
var React = _interopRequireWildcard(require("react")); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var React = _react; | ||
var _util = require("../util"); | ||
var _AddButton = _interopRequireDefault(require("./AddButton")); | ||
var _util = require("../util"); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function OperationNode(_ref, ref) { | ||
var prefixCls = _ref.prefixCls, | ||
id = _ref.id, | ||
tabs = _ref.tabs, | ||
locale = _ref.locale, | ||
mobile = _ref.mobile, | ||
_ref$moreIcon = _ref.moreIcon, | ||
moreIcon = _ref$moreIcon === void 0 ? 'More' : _ref$moreIcon, | ||
moreTransitionName = _ref.moreTransitionName, | ||
style = _ref.style, | ||
className = _ref.className, | ||
editable = _ref.editable, | ||
tabBarGutter = _ref.tabBarGutter, | ||
rtl = _ref.rtl, | ||
removeAriaLabel = _ref.removeAriaLabel, | ||
onTabClick = _ref.onTabClick, | ||
getPopupContainer = _ref.getPopupContainer, | ||
popupClassName = _ref.popupClassName; | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
var OperationNode = /*#__PURE__*/React.forwardRef(function (props, ref) { | ||
var prefixCls = props.prefixCls, | ||
id = props.id, | ||
tabs = props.tabs, | ||
locale = props.locale, | ||
mobile = props.mobile, | ||
_props$moreIcon = props.moreIcon, | ||
moreIcon = _props$moreIcon === void 0 ? 'More' : _props$moreIcon, | ||
moreTransitionName = props.moreTransitionName, | ||
style = props.style, | ||
className = props.className, | ||
editable = props.editable, | ||
tabBarGutter = props.tabBarGutter, | ||
rtl = props.rtl, | ||
removeAriaLabel = props.removeAriaLabel, | ||
onTabClick = props.onTabClick, | ||
getPopupContainer = props.getPopupContainer, | ||
popupClassName = props.popupClassName; | ||
// ======================== Dropdown ======================== | ||
var _useState = (0, React.useState)(false), | ||
var _useState = (0, _react.useState)(false), | ||
_useState2 = (0, _slicedToArray2.default)(_useState, 2), | ||
open = _useState2[0], | ||
setOpen = _useState2[1]; | ||
var _useState3 = (0, React.useState)(null), | ||
var _useState3 = (0, _react.useState)(null), | ||
_useState4 = (0, _slicedToArray2.default)(_useState3, 2), | ||
@@ -61,5 +62,5 @@ selectedKey = _useState4[0], | ||
var menu = /*#__PURE__*/React.createElement(_rcMenu.default, { | ||
onClick: function onClick(_ref2) { | ||
var key = _ref2.key, | ||
domEvent = _ref2.domEvent; | ||
onClick: function onClick(_ref) { | ||
var key = _ref.key, | ||
domEvent = _ref.domEvent; | ||
onTabClick(key, domEvent); | ||
@@ -139,3 +140,5 @@ setOpen(false); | ||
case _KeyCode.default.ENTER: | ||
if (selectedKey !== null) onTabClick(selectedKey, e); | ||
if (selectedKey !== null) { | ||
onTabClick(selectedKey, e); | ||
} | ||
break; | ||
@@ -146,3 +149,3 @@ } | ||
// ========================= Effect ========================= | ||
(0, React.useEffect)(function () { | ||
(0, _react.useEffect)(function () { | ||
// We use query element here to avoid React strict warning | ||
@@ -154,3 +157,3 @@ var ele = document.getElementById(selectedItemId); | ||
}, [selectedKey]); | ||
(0, React.useEffect)(function () { | ||
(0, _react.useEffect)(function () { | ||
if (!open) { | ||
@@ -200,4 +203,4 @@ setSelectedKey(null); | ||
})); | ||
} | ||
var _default = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(OperationNode), function (_, next) { | ||
}); | ||
var _default = exports.default = /*#__PURE__*/React.memo(OperationNode, function (_, next) { | ||
return ( | ||
@@ -208,3 +211,2 @@ // https://github.com/ant-design/ant-design/issues/32544 | ||
); | ||
}); | ||
exports.default = _default; | ||
}); |
@@ -18,3 +18,3 @@ import * as React from 'react'; | ||
} | ||
declare function TabNode({ prefixCls, id, active, tab: { key, label, disabled, closeIcon, icon }, closable, renderWrapper, removeAriaLabel, editable, onClick, onFocus, style, }: TabNodeProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>; | ||
declare const TabNode: React.FC<TabNodeProps>; | ||
export default TabNode; |
@@ -14,22 +14,22 @@ "use strict"; | ||
var _util = require("../util"); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function TabNode(_ref) { | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
var TabNode = function TabNode(props) { | ||
var _classNames; | ||
var prefixCls = _ref.prefixCls, | ||
id = _ref.id, | ||
active = _ref.active, | ||
_ref$tab = _ref.tab, | ||
key = _ref$tab.key, | ||
label = _ref$tab.label, | ||
disabled = _ref$tab.disabled, | ||
closeIcon = _ref$tab.closeIcon, | ||
icon = _ref$tab.icon, | ||
closable = _ref.closable, | ||
renderWrapper = _ref.renderWrapper, | ||
removeAriaLabel = _ref.removeAriaLabel, | ||
editable = _ref.editable, | ||
onClick = _ref.onClick, | ||
onFocus = _ref.onFocus, | ||
style = _ref.style; | ||
var prefixCls = props.prefixCls, | ||
id = props.id, | ||
active = props.active, | ||
_props$tab = props.tab, | ||
key = _props$tab.key, | ||
label = _props$tab.label, | ||
disabled = _props$tab.disabled, | ||
closeIcon = _props$tab.closeIcon, | ||
icon = _props$tab.icon, | ||
closable = props.closable, | ||
renderWrapper = props.renderWrapper, | ||
removeAriaLabel = props.removeAriaLabel, | ||
editable = props.editable, | ||
onClick = props.onClick, | ||
onFocus = props.onFocus, | ||
style = props.style; | ||
var tabPrefix = "".concat(prefixCls, "-tab"); | ||
@@ -51,2 +51,5 @@ var removable = (0, _util.getRemovable)(closable, closeIcon, editable, disabled); | ||
} | ||
var labelNode = React.useMemo(function () { | ||
return icon && typeof label === 'string' ? /*#__PURE__*/React.createElement("span", null, label) : label; | ||
}, [label, icon]); | ||
var node = /*#__PURE__*/React.createElement("div", { | ||
@@ -81,3 +84,3 @@ key: key | ||
className: "".concat(tabPrefix, "-icon") | ||
}, icon), label), removable && /*#__PURE__*/React.createElement("button", { | ||
}, icon), label && labelNode), removable && /*#__PURE__*/React.createElement("button", { | ||
type: "button", | ||
@@ -93,4 +96,3 @@ "aria-label": removeAriaLabel || 'remove', | ||
return renderWrapper ? renderWrapper(node) : node; | ||
} | ||
var _default = TabNode; | ||
exports.default = _default; | ||
}; | ||
var _default = exports.default = TabNode; |
import * as React from 'react'; | ||
import type { TabNavListProps } from '.'; | ||
export type TabNavListWrapperProps = Required<Omit<TabNavListProps, 'children' | 'className'>> & TabNavListProps; | ||
export default function TabNavListWrapper({ renderTabBar, ...restProps }: TabNavListWrapperProps): React.JSX.Element; | ||
declare const TabNavListWrapper: React.FC<TabNavListWrapperProps>; | ||
export default TabNavListWrapper; |
@@ -8,3 +8,3 @@ "use strict"; | ||
}); | ||
exports.default = TabNavListWrapper; | ||
exports.default = void 0; | ||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); | ||
@@ -19,6 +19,6 @@ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2")); | ||
_excluded2 = ["label", "key"]; // zombieJ: To compatible with `renderTabBar` usage. | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
// We have to create a TabNavList components. | ||
function TabNavListWrapper(_ref) { | ||
var TabNavListWrapper = function TabNavListWrapper(_ref) { | ||
var renderTabBar = _ref.renderTabBar, | ||
@@ -45,2 +45,6 @@ restProps = (0, _objectWithoutProperties2.default)(_ref, _excluded); | ||
return /*#__PURE__*/React.createElement(_.default, restProps); | ||
} | ||
}; | ||
if (process.env.NODE_ENV !== 'production') { | ||
TabNavListWrapper.displayName = 'TabNavListWrapper'; | ||
} | ||
var _default = exports.default = TabNavListWrapper; |
import * as React from 'react'; | ||
import type { TabPosition, AnimatedConfig } from '../interface'; | ||
import type { AnimatedConfig, TabPosition } from '../interface'; | ||
export interface TabPanelListProps { | ||
@@ -10,2 +10,3 @@ activeKey: string; | ||
} | ||
export default function TabPanelList({ id, activeKey, animated, tabPosition, destroyInactiveTabPane, }: TabPanelListProps): React.JSX.Element; | ||
declare const TabPanelList: React.FC<TabPanelListProps>; | ||
export default TabPanelList; |
@@ -8,3 +8,3 @@ "use strict"; | ||
}); | ||
exports.default = TabPanelList; | ||
exports.default = void 0; | ||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); | ||
@@ -14,16 +14,16 @@ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var React = _interopRequireWildcard(require("react")); | ||
var _classnames = _interopRequireDefault(require("classnames")); | ||
var _rcMotion = _interopRequireDefault(require("rc-motion")); | ||
var React = _interopRequireWildcard(require("react")); | ||
var _TabContext = _interopRequireDefault(require("../TabContext")); | ||
var _TabPane = _interopRequireDefault(require("./TabPane")); | ||
var _excluded = ["key", "forceRender", "style", "className", "destroyInactiveTabPane"]; | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function TabPanelList(_ref) { | ||
var id = _ref.id, | ||
activeKey = _ref.activeKey, | ||
animated = _ref.animated, | ||
tabPosition = _ref.tabPosition, | ||
destroyInactiveTabPane = _ref.destroyInactiveTabPane; | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
var TabPanelList = function TabPanelList(props) { | ||
var id = props.id, | ||
activeKey = props.activeKey, | ||
animated = props.animated, | ||
tabPosition = props.tabPosition, | ||
destroyInactiveTabPane = props.destroyInactiveTabPane; | ||
var _React$useContext = React.useContext(_TabContext.default), | ||
@@ -38,9 +38,9 @@ prefixCls = _React$useContext.prefixCls, | ||
className: (0, _classnames.default)("".concat(prefixCls, "-content"), "".concat(prefixCls, "-content-").concat(tabPosition), (0, _defineProperty2.default)({}, "".concat(prefixCls, "-content-animated"), tabPaneAnimated)) | ||
}, tabs.map(function (_ref2) { | ||
var key = _ref2.key, | ||
forceRender = _ref2.forceRender, | ||
paneStyle = _ref2.style, | ||
paneClassName = _ref2.className, | ||
itemDestroyInactiveTabPane = _ref2.destroyInactiveTabPane, | ||
restTabProps = (0, _objectWithoutProperties2.default)(_ref2, _excluded); | ||
}, tabs.map(function (item) { | ||
var key = item.key, | ||
forceRender = item.forceRender, | ||
paneStyle = item.style, | ||
paneClassName = item.className, | ||
itemDestroyInactiveTabPane = item.destroyInactiveTabPane, | ||
restTabProps = (0, _objectWithoutProperties2.default)(item, _excluded); | ||
var active = key === activeKey; | ||
@@ -53,5 +53,5 @@ return /*#__PURE__*/React.createElement(_rcMotion.default, (0, _extends2.default)({ | ||
leavedClassName: "".concat(tabPanePrefixCls, "-hidden") | ||
}, animated.tabPaneMotion), function (_ref3, ref) { | ||
var motionStyle = _ref3.style, | ||
motionClassName = _ref3.className; | ||
}, animated.tabPaneMotion), function (_ref, ref) { | ||
var motionStyle = _ref.style, | ||
motionClassName = _ref.className; | ||
return /*#__PURE__*/React.createElement(_TabPane.default, (0, _extends2.default)({}, restTabProps, { | ||
@@ -69,2 +69,3 @@ prefixCls: tabPanePrefixCls, | ||
}))); | ||
} | ||
}; | ||
var _default = exports.default = TabPanelList; |
@@ -11,12 +11,12 @@ "use strict"; | ||
var React = _interopRequireWildcard(require("react")); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
var TabPane = /*#__PURE__*/React.forwardRef(function (_ref, ref) { | ||
var prefixCls = _ref.prefixCls, | ||
className = _ref.className, | ||
style = _ref.style, | ||
id = _ref.id, | ||
active = _ref.active, | ||
tabKey = _ref.tabKey, | ||
children = _ref.children; | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
var TabPane = /*#__PURE__*/React.forwardRef(function (props, ref) { | ||
var prefixCls = props.prefixCls, | ||
className = props.className, | ||
style = props.style, | ||
id = props.id, | ||
active = props.active, | ||
tabKey = props.tabKey, | ||
children = props.children; | ||
return /*#__PURE__*/React.createElement("div", { | ||
@@ -36,3 +36,2 @@ id: id && "".concat(id, "-panel-").concat(tabKey), | ||
} | ||
var _default = TabPane; | ||
exports.default = _default; | ||
var _default = exports.default = TabPane; |
import * as React from 'react'; | ||
import type { GetIndicatorSize } from './hooks/useIndicator'; | ||
import type { AnimatedConfig, EditableConfig, OnTabScroll, RenderTabBar, Tab, TabBarExtraContent, TabPosition, TabsLocale } from './interface'; | ||
import type { GetIndicatorSize } from './hooks/useIndicator'; | ||
export interface TabsProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'children'> { | ||
@@ -32,3 +32,3 @@ prefixCls?: string; | ||
} | ||
declare const ForwardTabs: React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLDivElement>>; | ||
export default ForwardTabs; | ||
declare const Tabs: React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLDivElement>>; | ||
export default Tabs; |
@@ -15,13 +15,14 @@ "use strict"; | ||
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); | ||
var React = _interopRequireWildcard(require("react")); | ||
var _classnames = _interopRequireDefault(require("classnames")); | ||
var _useMergedState5 = _interopRequireDefault(require("rc-util/lib/hooks/useMergedState")); | ||
var _isMobile = _interopRequireDefault(require("rc-util/lib/isMobile")); | ||
var _useMergedState5 = _interopRequireDefault(require("rc-util/lib/hooks/useMergedState")); | ||
var _TabPanelList = _interopRequireDefault(require("./TabPanelList")); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var React = _react; | ||
var _useAnimateConfig = _interopRequireDefault(require("./hooks/useAnimateConfig")); | ||
var _TabContext = _interopRequireDefault(require("./TabContext")); | ||
var _Wrapper = _interopRequireDefault(require("./TabNavList/Wrapper")); | ||
var _useAnimateConfig = _interopRequireDefault(require("./hooks/useAnimateConfig")); | ||
var _TabPanelList = _interopRequireDefault(require("./TabPanelList")); | ||
var _excluded = ["id", "prefixCls", "className", "items", "direction", "activeKey", "defaultActiveKey", "editable", "animated", "tabPosition", "tabBarGutter", "tabBarStyle", "tabBarExtraContent", "locale", "moreIcon", "moreTransitionName", "destroyInactiveTabPane", "renderTabBar", "onChange", "onTabClick", "onTabScroll", "getPopupContainer", "popupClassName", "indicatorSize"]; // Accessibility https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Tab_Role | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
/** | ||
@@ -37,31 +38,31 @@ * Should added antd: | ||
var uuid = 0; | ||
function Tabs(_ref, ref) { | ||
var Tabs = /*#__PURE__*/React.forwardRef(function (props, ref) { | ||
var _classNames; | ||
var id = _ref.id, | ||
_ref$prefixCls = _ref.prefixCls, | ||
prefixCls = _ref$prefixCls === void 0 ? 'rc-tabs' : _ref$prefixCls, | ||
className = _ref.className, | ||
items = _ref.items, | ||
direction = _ref.direction, | ||
activeKey = _ref.activeKey, | ||
defaultActiveKey = _ref.defaultActiveKey, | ||
editable = _ref.editable, | ||
animated = _ref.animated, | ||
_ref$tabPosition = _ref.tabPosition, | ||
tabPosition = _ref$tabPosition === void 0 ? 'top' : _ref$tabPosition, | ||
tabBarGutter = _ref.tabBarGutter, | ||
tabBarStyle = _ref.tabBarStyle, | ||
tabBarExtraContent = _ref.tabBarExtraContent, | ||
locale = _ref.locale, | ||
moreIcon = _ref.moreIcon, | ||
moreTransitionName = _ref.moreTransitionName, | ||
destroyInactiveTabPane = _ref.destroyInactiveTabPane, | ||
renderTabBar = _ref.renderTabBar, | ||
onChange = _ref.onChange, | ||
onTabClick = _ref.onTabClick, | ||
onTabScroll = _ref.onTabScroll, | ||
getPopupContainer = _ref.getPopupContainer, | ||
popupClassName = _ref.popupClassName, | ||
indicatorSize = _ref.indicatorSize, | ||
restProps = (0, _objectWithoutProperties2.default)(_ref, _excluded); | ||
var id = props.id, | ||
_props$prefixCls = props.prefixCls, | ||
prefixCls = _props$prefixCls === void 0 ? 'rc-tabs' : _props$prefixCls, | ||
className = props.className, | ||
items = props.items, | ||
direction = props.direction, | ||
activeKey = props.activeKey, | ||
defaultActiveKey = props.defaultActiveKey, | ||
editable = props.editable, | ||
animated = props.animated, | ||
_props$tabPosition = props.tabPosition, | ||
tabPosition = _props$tabPosition === void 0 ? 'top' : _props$tabPosition, | ||
tabBarGutter = props.tabBarGutter, | ||
tabBarStyle = props.tabBarStyle, | ||
tabBarExtraContent = props.tabBarExtraContent, | ||
locale = props.locale, | ||
moreIcon = props.moreIcon, | ||
moreTransitionName = props.moreTransitionName, | ||
destroyInactiveTabPane = props.destroyInactiveTabPane, | ||
renderTabBar = props.renderTabBar, | ||
onChange = props.onChange, | ||
onTabClick = props.onTabClick, | ||
onTabScroll = props.onTabScroll, | ||
getPopupContainer = props.getPopupContainer, | ||
popupClassName = props.popupClassName, | ||
indicatorSize = props.indicatorSize, | ||
restProps = (0, _objectWithoutProperties2.default)(props, _excluded); | ||
var tabs = React.useMemo(function () { | ||
@@ -76,7 +77,7 @@ return (items || []).filter(function (item) { | ||
// ======================== Mobile ======================== | ||
var _useState = (0, React.useState)(false), | ||
var _useState = (0, _react.useState)(false), | ||
_useState2 = (0, _slicedToArray2.default)(_useState, 2), | ||
mobile = _useState2[0], | ||
setMobile = _useState2[1]; | ||
(0, React.useEffect)(function () { | ||
(0, _react.useEffect)(function () { | ||
// Only update on the client side | ||
@@ -97,3 +98,3 @@ setMobile((0, _isMobile.default)()); | ||
setMergedActiveKey = _useMergedState2[1]; | ||
var _useState3 = (0, React.useState)(function () { | ||
var _useState3 = (0, _react.useState)(function () { | ||
return tabs.findIndex(function (tab) { | ||
@@ -108,3 +109,3 @@ return tab.key === mergedActiveKey; | ||
// Reset active key if not exist anymore | ||
(0, React.useEffect)(function () { | ||
(0, _react.useEffect)(function () { | ||
var newActiveIndex = tabs.findIndex(function (tab) { | ||
@@ -132,3 +133,3 @@ return tab.key === mergedActiveKey; | ||
// Async generate id to avoid ssr mapping failed | ||
(0, React.useEffect)(function () { | ||
(0, _react.useEffect)(function () { | ||
if (!id) { | ||
@@ -142,7 +143,7 @@ setMergedId("rc-tabs-".concat(process.env.NODE_ENV === 'test' ? 'test' : uuid)); | ||
function onInternalTabClick(key, e) { | ||
onTabClick === null || onTabClick === void 0 ? void 0 : onTabClick(key, e); | ||
onTabClick === null || onTabClick === void 0 || onTabClick(key, e); | ||
var isActiveChanged = key !== mergedActiveKey; | ||
setMergedActiveKey(key); | ||
if (isActiveChanged) { | ||
onChange === null || onChange === void 0 ? void 0 : onChange(key); | ||
onChange === null || onChange === void 0 || onChange(key); | ||
} | ||
@@ -191,8 +192,6 @@ } | ||
})))); | ||
} | ||
var ForwardTabs = /*#__PURE__*/React.forwardRef(Tabs); | ||
}); | ||
if (process.env.NODE_ENV !== 'production') { | ||
ForwardTabs.displayName = 'Tabs'; | ||
Tabs.displayName = 'Tabs'; | ||
} | ||
var _default = ForwardTabs; | ||
exports.default = _default; | ||
var _default = exports.default = Tabs; |
{ | ||
"name": "rc-tabs", | ||
"version": "12.14.0", | ||
"version": "12.14.1", | ||
"description": "tabs ui component for react", | ||
"engines": { | ||
"node": ">=8.x" | ||
}, | ||
"keywords": [ | ||
@@ -13,11 +10,6 @@ "react", | ||
], | ||
"files": [ | ||
"lib", | ||
"es", | ||
"assets/index.css" | ||
], | ||
"main": "./lib/index", | ||
"module": "./es/index", | ||
"homepage": "http://github.com/react-component/tabs", | ||
"author": "yiminghe@gmail.com", | ||
"bugs": { | ||
"url": "http://github.com/react-component/tabs/issues" | ||
}, | ||
"repository": { | ||
@@ -27,22 +19,36 @@ "type": "git", | ||
}, | ||
"bugs": { | ||
"url": "http://github.com/react-component/tabs/issues" | ||
}, | ||
"license": "MIT", | ||
"author": "yiminghe@gmail.com", | ||
"main": "./lib/index", | ||
"module": "./es/index", | ||
"files": [ | ||
"lib", | ||
"es", | ||
"assets/index.css" | ||
], | ||
"scripts": { | ||
"start": "dumi dev", | ||
"build": "dumi build", | ||
"docs:deploy": "gh-pages -d .doc", | ||
"compile": "father build && npm run compile:style", | ||
"test": "rc-test", | ||
"compile:style": "lessc --js assets/index.less assets/index.css", | ||
"coverage": "father test --coverage", | ||
"docs:deploy": "gh-pages -d .doc", | ||
"lint": "eslint src/ docs/examples/ --ext .tsx,.ts,.jsx,.js", | ||
"now-build": "npm run build", | ||
"lint": "eslint src/ docs/examples/ --ext .tsx,.ts,.jsx,.js", | ||
"compile:style": "lessc --js assets/index.less assets/index.css", | ||
"prepublishOnly": "npm run lint && npm run test && npm run compile && np --yolo --no-publish" | ||
"prepublishOnly": "npm run lint && npm run test && npm run compile && np --yolo --no-publish", | ||
"start": "dumi dev", | ||
"test": "rc-test" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime": "^7.11.2", | ||
"classnames": "2.x", | ||
"rc-dropdown": "~4.1.0", | ||
"rc-menu": "~9.12.0", | ||
"rc-motion": "^2.6.2", | ||
"rc-resize-observer": "^1.0.0", | ||
"rc-util": "^5.34.1" | ||
}, | ||
"devDependencies": { | ||
"@rc-component/father-plugin": "^1.0.0", | ||
"@rc-component/trigger": "^1.10.0", | ||
"@testing-library/jest-dom": "^5.16.4", | ||
"@testing-library/jest-dom": "^6.1.4", | ||
"@testing-library/react": "^13.0.0", | ||
@@ -59,3 +65,5 @@ "@types/classnames": "^2.2.10", | ||
"dumi": "^2.0.0", | ||
"eslint": "^7.0.0", | ||
"eslint": "^8.54.0", | ||
"eslint-plugin-jest": "^27.6.0", | ||
"eslint-plugin-unicorn": "^49.0.0", | ||
"fastclick": "~1.0.6", | ||
@@ -76,17 +84,11 @@ "father": "^4.0.0", | ||
"sortablejs": "^1.7.0", | ||
"typescript": "^4.0.5" | ||
"typescript": "^5.3.2" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime": "^7.11.2", | ||
"classnames": "2.x", | ||
"rc-dropdown": "~4.1.0", | ||
"rc-menu": "~9.12.0", | ||
"rc-motion": "^2.6.2", | ||
"rc-resize-observer": "^1.0.0", | ||
"rc-util": "^5.34.1" | ||
}, | ||
"peerDependencies": { | ||
"react": ">=16.9.0", | ||
"react-dom": ">=16.9.0" | ||
}, | ||
"engines": { | ||
"node": ">=8.x" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3916
161163
33
12