@mantine/core
Version:
React components library focused on usability, accessibility and developer experience
50 lines (49 loc) • 1.84 kB
JavaScript
"use client";
import { useMantineEnv } from "../../../core/MantineProvider/Mantine.context.mjs";
import { useProps } from "../../../core/MantineProvider/use-props/use-props.mjs";
import { factory } from "../../../core/factory/factory.mjs";
import { Box } from "../../../core/Box/Box.mjs";
import { useTabsContext } from "../Tabs.context.mjs";
import Tabs_module_default from "../Tabs.module.mjs";
import { Activity, useEffect } from "react";
import { jsx } from "react/jsx-runtime";
//#region packages/@mantine/core/src/components/Tabs/TabsPanel/TabsPanel.tsx
const TabsPanel = factory((_props) => {
const props = useProps("TabsPanel", null, _props);
const { children, className, value, classNames, styles, style, mod, keepMounted, ...others } = props;
const env = useMantineEnv();
const ctx = useTabsContext();
useEffect(() => {
ctx.setMountedPanel(value, true);
return () => {
ctx.setMountedPanel(value, false);
};
}, [value]);
const active = ctx.value === value;
const shouldKeepMounted = ctx.keepMounted || keepMounted;
const useActivity = ctx.keepMountedMode !== "display-none";
const content = shouldKeepMounted && useActivity && env !== "test" ? /* @__PURE__ */ jsx(Activity, {
mode: active ? "visible" : "hidden",
children
}) : shouldKeepMounted ? children : active ? children : null;
return /* @__PURE__ */ jsx(Box, {
...ctx.getStyles("panel", {
className,
classNames,
styles,
style: [style, !active ? { display: "none" } : void 0],
props
}),
mod: [{ orientation: ctx.orientation }, mod],
role: "tabpanel",
id: ctx.getPanelId(value),
"aria-labelledby": ctx.getTabId(value),
...others,
children: content
});
});
TabsPanel.classes = Tabs_module_default;
TabsPanel.displayName = "@mantine/core/TabsPanel";
//#endregion
export { TabsPanel };
//# sourceMappingURL=TabsPanel.mjs.map