import * as React from 'react'; import * as PropTypes from 'prop-types'; import ReakitTabs from 'reakit/Tabs'; import { TabsProps as ReakitTabsProps } from 'reakit/ts/Tabs/Tabs'; import _Tabs from './styled'; import Tab, { TabProps } from './Tab'; import TabPanel, { TabPanelProps } from './TabPanel'; export type LocalTabsProps = { align?: 'left' | 'center' | 'right'; children: React.ReactNode; className?: string; isFitted?: boolean; /** Visual type of the tab */ type?: 'default' | 'boxed'; }; export type TabsProps = ReakitTabsProps & LocalTabsProps; export type TabsComponents = { Tab: React.FunctionComponent; Panel: React.FunctionComponent; Container: React.FunctionComponent<{ children: (...args: any) => React.ReactNode }>; }; export const Tabs: React.FunctionComponent & TabsComponents = ({ children, ...props }) => ( <_Tabs use={ReakitTabs} {...props}> {children} ); Tabs.Tab = Tab; Tabs.Panel = TabPanel; Tabs.Container = ReakitTabs.Container; export const tabsPropTypes = { align: PropTypes.oneOf(['left', 'center', 'right']) as PropTypes.Validator, children: PropTypes.node.isRequired, className: PropTypes.string, isFitted: PropTypes.bool, type: PropTypes.oneOf(['default', 'boxed']) as PropTypes.Validator }; Tabs.propTypes = tabsPropTypes; export const tabsDefaultProps: Partial = { align: undefined, className: undefined, isFitted: false, type: 'default' }; Tabs.defaultProps = tabsDefaultProps; const C: React.FunctionComponent & TabsComponents = Tabs; export default C;