UNPKG

@gravity-ui/uikit

Version:

Gravity UI base styling and components

40 lines (39 loc) 1.95 kB
'use client'; import { jsx as _jsx } from "react/jsx-runtime"; import * as React from 'react'; import { MenuItem } from "../lab/Menu/index.js"; import { useDefaultProps } from "../theme/useDefaultProps.js"; import { getLinkRelWithFallback } from "../utils/getLinkRelWithFallback.js"; import { TabContent } from "./TabContent.js"; import { useTab } from "./hooks/useTab.js"; import { isTabComponentProps, isTabLinkProps } from "./utils.js"; import "./Tab.css"; export const TabInner = React.forwardRef(function TabInner(rawProps, ref) { const props = useDefaultProps('Tab', rawProps); const tabProps = useTab(props); const content = (_jsx(TabContent, { icon: props.icon, value: props.value, counter: props.counter, label: props.label, children: props.children })); if (isTabComponentProps(props)) { if (props.isMenuItem) { const MenuItemComponent = MenuItem; return (_jsx(MenuItemComponent, { ...tabProps, ref: ref, component: props.component, children: content })); } return React.createElement(props.component, { ...tabProps, ref }, content); } if (isTabLinkProps(props)) { const rel = getLinkRelWithFallback(props); if (props.isMenuItem) { return (_jsx(MenuItem, { ...tabProps, ref: ref, href: props.href, rel: rel, children: content })); } return (_jsx("a", { ...tabProps, ref: ref, href: props.href, rel: rel, children: content })); } if (props.isMenuItem) { return (_jsx(MenuItem, { ...tabProps, ref: ref, type: props.type || 'button', disabled: props.disabled, children: content })); } return (_jsx("button", { ...tabProps, ref: ref, type: props.type || 'button', children: content })); }); TabInner.displayName = 'TabInner'; export const Tab = React.forwardRef(function Tab(rawProps, ref) { return _jsx(TabInner, { ref: ref, ...rawProps }); }); Tab.displayName = 'Tab'; //# sourceMappingURL=Tab.js.map