{"version":3,"file":"VaulContent.cjs","sources":["../../src/lib/VaulContent.tsx"],"sourcesContent":["import {\n  Box,\n  BoxProps,\n  CompoundStylesApiProps,\n  ElementProps,\n  ExtendComponent,\n  Factory,\n  FocusTrap,\n  MantineThemeComponent,\n  RemoveScroll,\n  factory,\n  useProps\n} from '@mantine/core'\nimport { useId } from '@mantine/hooks'\nimport { ComponentPropsWithRef } from 'react'\nimport { Drawer } from 'vaul'\nimport { useVaulContext } from './context'\nimport type { VaulClasses } from './types'\nimport classes from './vaul.module.css'\n\nexport interface VaulContentProps extends BoxProps, CompoundStylesApiProps<VaulContentFactory>, ElementProps<'div'> {\n  removeScrollProps?: Omit<ComponentPropsWithRef<typeof RemoveScroll>, 'children'>\n}\nexport type VaulContentStylesNames = 'content'\n\nexport type VaulContentFactory = Factory<{\n  props: VaulContentProps\n  ref: HTMLDivElement\n  stylesNames: VaulContentStylesNames\n  compound: true\n}>\n\nconst defaultProps: VaulContentProps = {}\n\nexport const VaulContent = factory<VaulContentFactory>((_props, ref) => {\n  const {\n    children,\n    style,\n    className: classNameProp,\n    classNames,\n    styles,\n    vars,\n    id: idProp,\n    mod,\n    onKeyDown,\n    removeScrollProps,\n    ...rest\n  } = useProps('VaulContent', defaultProps, _props)\n\n  const id = useId(idProp)\n\n  const {\n    opened,\n    setOpened,\n    trapFocus,\n    getStyles,\n    variant,\n    closeOnEscape,\n    removeScrollProps: removeScrollPropsProp,\n    lockScroll,\n    descriptionId\n  } = useVaulContext()\n\n  return (\n    <RemoveScroll\n      enabled={opened && lockScroll}\n      {...removeScrollProps}\n      {...(removeScrollPropsProp as Record<string, any>)}>\n      <FocusTrap active={opened && trapFocus}>\n        <Drawer.Content\n          asChild\n          aria-describedby={descriptionId}\n          onOpenAutoFocus={(event) => event.preventDefault()}\n          onCloseAutoFocus={(event) => event.preventDefault()}\n          onInteractOutside={(event) => event.preventDefault()}\n          onEscapeKeyDown={(event) => event.preventDefault()}>\n          <Box\n            ref={ref}\n            id={id}\n            role='dialog'\n            aria-modal\n            tabIndex={-1}\n            {...(rest as any)}\n            {...getStyles('content', { className: classNameProp, classNames, styles, style, variant })}\n            mod={[\n              {\n                part: 'content'\n              },\n              mod\n            ]}\n            onKeyDown={(event) => {\n              onKeyDown?.(event)\n              if (event.key === 'Escape' && closeOnEscape) {\n                setOpened(false)\n              }\n            }}>\n            {children}\n          </Box>\n        </Drawer.Content>\n      </FocusTrap>\n    </RemoveScroll>\n  )\n})\n\nconst extendVaulContent = (c: ExtendComponent<VaulContentFactory>): MantineThemeComponent => c\n\nVaulContent.displayName = 'mantine-vaul/VaulContent'\nVaulContent.classes = classes as VaulClasses\nVaulContent.extend = extendVaulContent\n"],"names":["defaultProps","VaulContent","factory","_props","ref","children","style","classNameProp","classNames","styles","vars","idProp","mod","onKeyDown","removeScrollProps","rest","useProps","id","useId","opened","setOpened","trapFocus","getStyles","variant","closeOnEscape","removeScrollPropsProp","lockScroll","descriptionId","useVaulContext","jsx","RemoveScroll","FocusTrap","Drawer","event","Box","extendVaulContent","c","classes"],"mappings":"4PAgCMA,EAAiC,CAAA,EAE1BC,EAAcC,EAAA,QAA4B,CAACC,EAAQC,IAAQ,CAChE,KAAA,CACJ,SAAAC,EACA,MAAAC,EACA,UAAWC,EACX,WAAAC,EACA,OAAAC,EACA,KAAAC,EACA,GAAIC,EACJ,IAAAC,EACA,UAAAC,EACA,kBAAAC,EACA,GAAGC,CACD,EAAAC,WAAS,cAAehB,EAAcG,CAAM,EAE1Cc,EAAKC,QAAMP,CAAM,EAEjB,CACJ,OAAAQ,EACA,UAAAC,EACA,UAAAC,EACA,UAAAC,EACA,QAAAC,EACA,cAAAC,EACA,kBAAmBC,EACnB,WAAAC,EACA,cAAAC,GACEC,EAAe,eAAA,EAGjB,OAAAC,EAAA,IAACC,EAAA,aAAA,CACC,QAASX,GAAUO,EAClB,GAAGZ,EACH,GAAIW,EACL,SAACI,EAAA,IAAAE,YAAA,CAAU,OAAQZ,GAAUE,EAC3B,SAAAQ,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