@nex-ui/react
Version:
🎉 A beautiful, modern, and reliable React component library.
38 lines (35 loc) • 1.01 kB
JavaScript
"use client";
import { jsx } from 'react/jsx-runtime';
import { useEvent } from '@nex-ui/hooks';
import { defineRecipe } from '@nex-ui/system';
import { useModal } from './ModalContext.mjs';
import { useSlot } from '../utils/useSlot.mjs';
const recipe = defineRecipe({
base: {
position: 'fixed',
inset: 0
}
});
const style = recipe();
const ModalPanel = (inProps)=>{
const { closeOnInteractOutside, setOpen } = useModal();
const props = inProps;
const handleClick = useEvent((e)=>{
if (closeOnInteractOutside && e.target === e.currentTarget) {
setOpen(false);
}
});
const [ModalPanelRoot, getModalPanelRootProps] = useSlot({
style,
elementType: 'div',
externalForwardedProps: props,
additionalProps: {
onClick: handleClick
}
});
return /*#__PURE__*/ jsx(ModalPanelRoot, {
...getModalPanelRootProps()
});
};
ModalPanel.displayName = 'ModalPanel';
export { ModalPanel };