{"version":3,"file":"drawer.mjs","names":[],"sources":["../../../../package/common/drawer/drawer.tsx"],"sourcesContent":["import type { ReactElement, CSSProperties } from 'react';\nimport { useRef, useEffect } from 'react';\nimport { DrawerProps } from './drawer.types';\nimport cx from 'classnames';\n\nimport styles from './drawer.module.pcss';\n\nfunction Drawer({\n  className,\n  isOpen = false,\n  closedWidth,\n  openedWidth,\n  children,\n  style,\n  classNames,\n  styles: slotStyles,\n  ...rest\n}: DrawerProps): ReactElement {\n  const containerRef = useRef<HTMLDivElement>(null);\n  const contentRef = useRef<HTMLDivElement>(null);\n\n  useEffect(() => {\n    const observer = new ResizeObserver(() => {\n      if (containerRef.current && contentRef.current) {\n        containerRef.current.style.setProperty('--drawer-content-width', `${contentRef.current.scrollWidth}px`);\n      }\n    });\n    if (contentRef.current) observer.observe(contentRef.current);\n    return () => observer.disconnect();\n  }, []);\n\n  return (\n    <div\n      {...rest}\n      ref={containerRef}\n      className={cx(styles.drawer, isOpen && styles.drawerOpen, className, classNames?.root)}\n      style={\n        {\n          ...(closedWidth !== undefined && { '--drawer-closed-width': closedWidth }),\n          ...(openedWidth !== undefined && { '--drawer-opened-width': openedWidth }),\n          ...style,\n          ...slotStyles?.root,\n        } as CSSProperties\n      }\n    >\n      <div ref={contentRef} className={cx(styles.drawerContent, classNames?.content)} style={slotStyles?.content}>\n        <div className={cx(styles.drawerContentInner, classNames?.inner)} style={slotStyles?.inner}>\n          {children}\n        </div>\n      </div>\n    </div>\n  );\n}\n\nexport default Drawer;\n"],"mappings":"gKAOA,SAAS,EAAO,CACd,YACA,SAAS,GACT,cACA,cACA,WACA,QACA,aACA,OAAQ,EACR,GAAG,GACyB,CAC5B,IAAM,EAAe,EAAuB,IAAI,EAC1C,EAAa,EAAuB,IAAI,EAY9C,OAVA,MAAgB,CACd,IAAM,EAAW,IAAI,mBAAqB,CACpC,EAAa,SAAW,EAAW,SACrC,EAAa,QAAQ,MAAM,YAAY,yBAA0B,GAAG,EAAW,QAAQ,YAAY,GAAG,CAE1G,CAAC,EAED,OADI,EAAW,SAAS,EAAS,QAAQ,EAAW,OAAO,MAC9C,EAAS,WAAW,CACnC,EAAG,CAAC,CAAC,EAGH,EAAC,MAAD,CACE,GAAI,EACJ,IAAK,EACL,UAAW,EAAG,EAAO,OAAQ,GAAU,EAAO,WAAY,EAAW,GAAY,IAAI,EACrF,MACE,CACE,GAAI,IAAgB,IAAA,IAAa,CAAE,wBAAyB,CAAY,EACxE,GAAI,IAAgB,IAAA,IAAa,CAAE,wBAAyB,CAAY,EACxE,GAAG,EACH,GAAG,GAAY,IACjB,EAGF,SAAA,EAAC,MAAD,CAAK,IAAK,EAAY,UAAW,EAAG,EAAO,cAAe,GAAY,OAAO,EAAG,MAAO,GAAY,QACjG,SAAA,EAAC,MAAD,CAAK,UAAW,EAAG,EAAO,mBAAoB,GAAY,KAAK,EAAG,MAAO,GAAY,MAClF,UACE,CAAA,CACF,CAAA,CACF,CAAA,CAET"}