1 line
2.9 KiB
JSON
1 line
2.9 KiB
JSON
{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _objectWithoutPropertiesLoose from \"@babel/runtime/helpers/esm/objectWithoutPropertiesLoose\";\nimport React from 'react';\nimport requiredForA11y from 'prop-types-extra/lib/isRequiredForA11y';\nimport { useUncontrolled } from 'uncontrollable';\nimport Nav from './Nav';\nimport NavLink from './NavLink';\nimport NavItem from './NavItem';\nimport TabContainer from './TabContainer';\nimport TabContent from './TabContent';\nimport TabPane from './TabPane';\nimport { forEach, map } from './ElementChildren';\nvar defaultProps = {\n variant: 'tabs',\n mountOnEnter: false,\n unmountOnExit: false\n};\n\nfunction getDefaultActiveKey(children) {\n var defaultActiveKey;\n forEach(children, function (child) {\n if (defaultActiveKey == null) {\n defaultActiveKey = child.props.eventKey;\n }\n });\n return defaultActiveKey;\n}\n\nfunction renderTab(child) {\n var _child$props = child.props,\n title = _child$props.title,\n eventKey = _child$props.eventKey,\n disabled = _child$props.disabled,\n tabClassName = _child$props.tabClassName;\n\n if (title == null) {\n return null;\n }\n\n return React.createElement(NavItem, {\n as: NavLink,\n eventKey: eventKey,\n disabled: disabled,\n className: tabClassName\n }, title);\n}\n\nvar Tabs = React.forwardRef(function (props, ref) {\n var _useUncontrolled = useUncontrolled(props, {\n activeKey: 'onSelect'\n }),\n id = _useUncontrolled.id,\n onSelect = _useUncontrolled.onSelect,\n transition = _useUncontrolled.transition,\n mountOnEnter = _useUncontrolled.mountOnEnter,\n unmountOnExit = _useUncontrolled.unmountOnExit,\n children = _useUncontrolled.children,\n _useUncontrolled$acti = _useUncontrolled.activeKey,\n activeKey = _useUncontrolled$acti === void 0 ? getDefaultActiveKey(children) : _useUncontrolled$acti,\n controlledProps = _objectWithoutPropertiesLoose(_useUncontrolled, [\"id\", \"onSelect\", \"transition\", \"mountOnEnter\", \"unmountOnExit\", \"children\", \"activeKey\"]);\n\n return React.createElement(TabContainer, {\n ref: ref,\n id: id,\n activeKey: activeKey,\n onSelect: onSelect,\n transition: transition,\n mountOnEnter: mountOnEnter,\n unmountOnExit: unmountOnExit\n }, React.createElement(Nav, _extends({}, controlledProps, {\n role: \"tablist\",\n as: \"nav\"\n }), map(children, renderTab)), React.createElement(TabContent, null, map(children, function (child) {\n var childProps = _extends({}, child.props);\n\n delete childProps.title;\n delete childProps.disabled;\n delete childProps.tabClassName;\n return React.createElement(TabPane, childProps);\n })));\n});\nTabs.defaultProps = defaultProps;\nTabs.displayName = 'Tabs';\nexport default Tabs;","map":null,"metadata":{},"sourceType":"module"} |