UNPKG

@nex-ui/react

Version:

🎉 A beautiful, modern, and reliable React component library.

54 lines (51 loc) • 1.72 kB
import { jsxs, jsx } from 'react/jsx-runtime'; import { useDrawer } from './DrawerContext.mjs'; import { useStyles } from '../utils/useStyles.mjs'; import { drawerRootRecipe } from '../../theme/recipes/drawer.mjs'; import { useSlotClasses } from '../utils/useSlotClasses.mjs'; import { useSlot } from '../utils/useSlot.mjs'; import { ModalRoot } from '../modal/ModalRoot.mjs'; import { ModalBackdrop } from '../modal/ModalBackdrop.mjs'; const slots = [ 'root', 'backdrop' ]; const DrawerRoot = ({ children })=>{ const ownerState = useDrawer(); const styles = useStyles({ name: 'Drawer', recipe: drawerRootRecipe, ownerState }); const { slotProps, classNames, hideBackdrop, ...remainingProps } = ownerState; const slotClasses = useSlotClasses({ name: 'Drawer', slots, classNames }); const [DrawerRootRoot, getDrawerRootRootProps] = useSlot({ elementType: ModalRoot, style: styles.root, externalForwardedProps: remainingProps, shouldForwardComponent: false, classNames: slotClasses.root }); const [DrawerBackdrop, getDrawerBackdropProps] = useSlot({ elementType: ModalBackdrop, style: styles.backdrop, externalSlotProps: slotProps?.backdrop, shouldForwardComponent: false, classNames: slotClasses.backdrop }); return /*#__PURE__*/ jsxs(DrawerRootRoot, { ...getDrawerRootRootProps(), children: [ !hideBackdrop && /*#__PURE__*/ jsx(DrawerBackdrop, { ...getDrawerBackdropProps() }), children ] }); }; DrawerRoot.displayName = 'DrawerRoot'; export { DrawerRoot };