Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | 1x 150x 150x 150x 150x 150x 150x 150x 1x 150x 150x | import * as React from 'react';
import { Box as ReakitBox, TabProps as ReakitTabProps, useTab as useReakitTab } from 'reakit';
import { useClassName, createComponent, createElement, createHook } from '../utils';
import { Box, BoxProps } from '../Box';
import { TabsContext } from './Tabs';
import { TabsListContext } from './TabsList';
import * as styles from './styles';
export type LocalTabsTabProps = {
tabId?: string;
};
export type TabsTabProps = Partial<ReakitTabProps> & BoxProps & LocalTabsTabProps;
const useProps = createHook<TabsTabProps>(
(props, { themeKey, themeKeyOverride }) => {
let {
baseId,
currentId,
disabled,
first,
focusable,
id,
last,
manual,
move,
next,
orientation,
overrides,
previous,
register,
selectedId,
select,
tabId,
stops,
unregister,
unstable_clickOnEnter,
unstable_clickOnSpace,
unstable_idCountRef,
unstable_moves,
...htmlProps
} = props;
const { overrides: tabOverrides, tabs } = React.useContext(TabsContext);
const tabProps = useReakitTab(
{
baseId: 'test',
currentId,
disabled,
first,
focusable,
id,
last,
manual,
move,
next,
orientation,
previous,
register,
selectedId,
select,
stopId: tabId,
stops,
unregister,
unstable_clickOnEnter,
unstable_clickOnSpace,
unstable_idCountRef,
unstable_moves,
...tabs
},
htmlProps
);
const boxProps = Box.useProps({ ...htmlProps, ...tabProps });
const tabsListContext = React.useContext(TabsListContext);
const className = useClassName({
style: styles.Tab,
styleProps: {
...tabs,
...props,
...tabsListContext,
overrides: { ...tabOverrides, ...tabsListContext.overrides, ...overrides }
},
themeKey,
themeKeyOverride,
prevClassName: boxProps.className
});
return { ...boxProps, className };
},
{ themeKey: 'Tabs.Tab' }
);
export const Tab = createComponent<TabsTabProps>(
props => {
const tabProps = useProps(props);
return createElement({ children: props.children, component: ReakitBox, use: props.use, htmlProps: tabProps });
},
{
attach: {
useProps
},
themeKey: 'Tabs.Tab'
}
);
|