@wordpress/components
Version:
UI components for WordPress.
42 lines (41 loc) • 1.18 kB
JavaScript
import { forwardRef } from "@wordpress/element";
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";
const Tab = forwardRef(function Tab2({
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,
store,
id: instancedTabId,
disabled,
render,
...otherProps,
children: [/* @__PURE__ */ _jsx(StyledTabChildren, {
children
}), /* @__PURE__ */ _jsx(StyledTabChevron, {
icon: chevronRight
})]
});
});
export {
Tab
};
//# sourceMappingURL=tab.js.map