{"version":3,"sources":["../src/drawer.tsx"],"sourcesContent":["import { createContext } from \"@chakra-ui/react-context\"\nimport { ThemingProps, useTheme } from \"@chakra-ui/system\"\nimport { SlideOptions } from \"@chakra-ui/transition\"\nimport { Modal, ModalProps } from \"./modal\"\n\nconst [DrawerContextProvider, useDrawerContext] = createContext()\n\ntype LogicalPlacement = \"start\" | \"end\"\ntype LogicalPlacementMap = Record<\n LogicalPlacement,\n { ltr: SlideOptions[\"direction\"]; rtl: SlideOptions[\"direction\"] }\n>\ntype DrawerPlacement = SlideOptions[\"direction\"] | LogicalPlacement\n\nconst placementMap: LogicalPlacementMap = {\n start: { ltr: \"left\", rtl: \"right\" },\n end: { ltr: \"right\", rtl: \"left\" },\n}\n\nfunction getDrawerPlacement(\n placement: DrawerPlacement | undefined,\n dir: \"ltr\" | \"rtl\",\n) {\n if (!placement) return\n //@ts-expect-error\n return placementMap[placement]?.[dir] ?? placement\n}\n\ninterface DrawerOptions {\n /**\n * The placement of the drawer\n * @default \"right\"\n */\n placement?: DrawerPlacement\n /**\n * If `true` and drawer's placement is `top` or `bottom`,\n * the drawer will occupy the viewport height (100vh)\n */\n isFullHeight?: boolean\n}\n\nexport interface DrawerProps\n extends DrawerOptions,\n ThemingProps<\"Drawer\">,\n Omit<\n ModalProps,\n \"scrollBehavior\" | \"motionPreset\" | \"isCentered\" | keyof ThemingProps\n > {}\n\n/**\n * The Drawer component is a panel that slides out from the edge of the screen.\n * It can be useful when you need users to complete a task or view some details without leaving the current page.\n *\n * @see Docs https://chakra-ui.com/docs/components/drawer\n */\nexport function Drawer(props: DrawerProps) {\n const {\n isOpen,\n onClose,\n placement: placementProp = \"right\",\n children,\n ...rest\n } = props\n\n const theme = useTheme()\n const drawerStyleConfig = theme.components?.Drawer\n const placement = getDrawerPlacement(placementProp, theme.direction)\n\n return (\n \n \n {children}\n \n \n )\n}\n\nexport { ModalBody as DrawerBody } from \"./modal-body\"\nexport { ModalCloseButton as DrawerCloseButton } from \"./modal-close-button\"\nexport { ModalFooter as DrawerFooter } from \"./modal-footer\"\nexport { ModalHeader as DrawerHeader } from \"./modal-header\"\nexport { ModalOverlay as DrawerOverlay } from \"./modal-overlay\"\n\nexport { useDrawerContext }\n"],"mappings":";;;;;;AAAA,SAAS,qBAAqB;AAC9B,SAAuB,gBAAgB;AAqEjC;AAjEN,IAAM,CAAC,uBAAuB,gBAAgB,IAAI,cAA6B;AAS/E,IAAM,eAAoC;AAAA,EACxC,OAAO,EAAE,KAAK,QAAQ,KAAK,QAAQ;AAAA,EACnC,KAAK,EAAE,KAAK,SAAS,KAAK,OAAO;AACnC;AAEA,SAAS,mBACP,WACA,KACA;AAtBF;AAuBE,MAAI,CAAC;AAAW;AAEhB,UAAO,wBAAa,SAAS,MAAtB,mBAA0B,SAA1B,YAAkC;AAC3C;AA6BO,SAAS,OAAO,OAAoB;AAvD3C;AAwDE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,WAAW,gBAAgB;AAAA,IAC3B;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AAEJ,QAAM,QAAQ,SAAS;AACvB,QAAM,qBAAoB,WAAM,eAAN,mBAAkB;AAC5C,QAAM,YAAY,mBAAmB,eAAe,MAAM,SAAS;AAEnE,SACE,oBAAC,yBAAsB,OAAO,EAAE,UAAU,GACxC;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA,aAAa;AAAA,MACZ,GAAG;AAAA,MAEH;AAAA;AAAA,EACH,GACF;AAEJ;","names":[]}