UNPKG

@wordpress/components

Version:
47 lines (44 loc) 1.26 kB
/** * WordPress dependencies */ import { forwardRef } from '@wordpress/element'; /** * Internal dependencies */ import warning from '@wordpress/warning'; import { useTabsContext } from './context'; import { Tab as StyledTab, TabChildren as StyledTabChildren, TabChevron as StyledTabChevron } from './styles'; import { chevronRight } from '@wordpress/icons'; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; export const Tab = forwardRef(function Tab({ children, tabId, disabled, render, ...otherProps }, ref) { var _useTabsContext; const { store, instanceId } = (_useTabsContext = useTabsContext()) !== null && _useTabsContext !== void 0 ? _useTabsContext : {}; if (!store) { globalThis.SCRIPT_DEBUG === true ? warning('`Tabs.Tab` must be wrapped in a `Tabs` component.') : void 0; return null; } const instancedTabId = `${instanceId}-${tabId}`; return /*#__PURE__*/_jsxs(StyledTab, { ref: ref, store: store, id: instancedTabId, disabled: disabled, render: render, ...otherProps, children: [/*#__PURE__*/_jsx(StyledTabChildren, { children: children }), /*#__PURE__*/_jsx(StyledTabChevron, { icon: chevronRight })] }); }); //# sourceMappingURL=tab.js.map