@trail-ui/react
Version:
35 lines (32 loc) • 1.07 kB
JavaScript
import {
InternalModalContext
} from "./chunk-66DN4CGG.mjs";
import {
_CloseButton
} from "./chunk-6APYGYMC.mjs";
// src/modal/modal-close-button.tsx
import { callAllHandlers, clsx } from "@trail-ui/shared-utils";
import { forwardRef, useContext } from "react";
import { OverlayTriggerStateContext } from "react-aria-components";
import { jsx } from "react/jsx-runtime";
function ModalCloseButton(props, ref) {
const { children, className, onPress, ...otherProps } = props;
const state = useContext(OverlayTriggerStateContext);
const { slots, classNames } = useContext(InternalModalContext);
return /* @__PURE__ */ jsx(
_CloseButton,
{
ref,
className: slots.closeButton({ class: clsx(classNames == null ? void 0 : classNames.closeButton, className) }),
onPress: callAllHandlers(onPress, () => state == null ? void 0 : state.close()),
appearance: "transparent",
spacing: "compact",
...otherProps,
children
}
);
}
var _ModalCloseButton = forwardRef(ModalCloseButton);
export {
_ModalCloseButton
};