Files
NapCatQQ/.pnpm-store/v3/files/f6/85f2d08d9291230b21c9a45c7f658566b79e72c9d85935c6daf6c43e9a8131f40b185c9c9850737b9a54183f46175f188ee06cbe80a5af9449b40f03e7030a
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

46 lines
1.8 KiB
Plaintext

"use client";
// src/tab-panel.tsx
import { forwardRef } from "@heroui/system";
import { useDOMRef } from "@heroui/react-utils";
import { clsx, getInertValue } from "@heroui/shared-utils";
import { mergeProps } from "@react-aria/utils";
import { useTabPanel } from "@react-aria/tabs";
import { useFocusRing } from "@react-aria/focus";
import { jsx } from "react/jsx-runtime";
var TabPanel = forwardRef((props, ref) => {
var _a, _b;
const { as, tabKey, destroyInactiveTabPanel, state, className, slots, classNames, ...otherProps } = props;
const Component = as || "div";
const domRef = useDOMRef(ref);
const { tabPanelProps } = useTabPanel({ ...props, id: String(tabKey) }, state, domRef);
const { focusProps, isFocused, isFocusVisible } = useFocusRing();
const selectedItem = state.selectedItem;
const content = state.collection.getItem(tabKey).props.children;
const tabPanelStyles = clsx(classNames == null ? void 0 : classNames.panel, className, (_a = selectedItem == null ? void 0 : selectedItem.props) == null ? void 0 : _a.className);
const isSelected = tabKey === (selectedItem == null ? void 0 : selectedItem.key);
if (!content || !isSelected && destroyInactiveTabPanel) {
return null;
}
return /* @__PURE__ */ jsx(
Component,
{
ref: domRef,
"data-focus": isFocused,
"data-focus-visible": isFocusVisible,
"data-inert": !isSelected ? "true" : void 0,
inert: getInertValue(!isSelected),
...isSelected && mergeProps(tabPanelProps, focusProps, otherProps),
className: (_b = slots.panel) == null ? void 0 : _b.call(slots, { class: tabPanelStyles }),
"data-slot": "panel",
children: content
}
);
});
TabPanel.displayName = "HeroUI.TabPanel";
var tab_panel_default = TabPanel;
export {
tab_panel_default
};