UNPKG

@ntragas/pouncejstest

Version:

A collection of UI components from Panther labs

29 lines (27 loc) 1.09 kB
import _extends from "@babel/runtime/helpers/extends"; import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose"; import React from 'react'; import { TabList as ReachTabList, useTabsContext } from '@reach/tabs'; import Flex from '../Flex'; export var TabList = /*#__PURE__*/React.forwardRef(function TabList(_ref, ref) { var children = _ref.children, rest = _objectWithoutPropertiesLoose(_ref, ["children"]); var _useTabsContext = useTabsContext(), focusedIndex = _useTabsContext.focusedIndex, selectedIndex = _useTabsContext.selectedIndex; return ( /*#__PURE__*/ // @ts-ignore Typing is wrong on @reach-ui, allowing only div | undefined for `as` React.createElement(ReachTabList, _extends({ as: Flex, ref: ref, flexWrap: "wrap" }, rest), React.Children.toArray(children).map(function (child, index) { return /*#__PURE__*/React.cloneElement(child, { isSelected: selectedIndex === index, isFocused: focusedIndex === index }); })) ); }); export default TabList;