{"version":3,"sources":["../../../../src/components/Nav/NavDrawer/useNavDrawer.ts"],"sourcesContent":["'use client';\n\nimport type * as React from 'react';\nimport { slot } from '@fluentui/react-utilities';\n\nimport { Drawer } from '../../Drawer';\nimport { useNav } from '../useNav';\nimport type { NavDrawerProps, NavDrawerState } from './NavDrawer.types';\n\n/**\n * Create the state required to render NavDrawer.\n *\n * Combines headless Nav state with a headless Drawer as root.\n *\n * @param props - props from this instance of NavDrawer\n * @param ref - reference to the root element of NavDrawer, which is either a `dialog` or a `div` depending on the Drawer type\n */\nexport const useNavDrawer = (\n  props: NavDrawerProps,\n  ref: React.Ref<HTMLDialogElement | HTMLDivElement>,\n): NavDrawerState => {\n  // The Drawer root is a `dialog` or a `div`, while the Nav state and the Drawer slot are typed for the `div` case.\n  const divRef = ref as React.Ref<HTMLDivElement>;\n  const navState = useNav(props, divRef);\n\n  const type = props.type ?? 'overlay';\n\n  const root: NavDrawerState['root'] = slot.always(\n    { ref: divRef, ...props },\n    {\n      elementType: Drawer,\n    },\n  );\n\n  root['data-type'] = type;\n\n  return {\n    ...navState,\n    components: {\n      root: Drawer,\n    },\n    root,\n  };\n};\n"],"names":["useNavDrawer","props","ref","divRef","navState","useNav","type","root","slot","always","elementType","Drawer","components"],"mappings":"AAAA;;;;;+BAiBaA;;;eAAAA;;;gCAdQ;wBAEE;wBACA;AAWhB,MAAMA,eAAe,CAC1BC,OACAC;IAEA,kHAAkH;IAClH,MAAMC,SAASD;IACf,MAAME,WAAWC,IAAAA,cAAM,EAACJ,OAAOE;IAE/B,MAAMG,OAAOL,MAAMK,IAAI,IAAI;IAE3B,MAAMC,OAA+BC,oBAAI,CAACC,MAAM,CAC9C;QAAEP,KAAKC;QAAQ,GAAGF,KAAK;IAAC,GACxB;QACES,aAAaC,cAAM;IACrB;IAGFJ,IAAI,CAAC,YAAY,GAAGD;IAEpB,OAAO;QACL,GAAGF,QAAQ;QACXQ,YAAY;YACVL,MAAMI,cAAM;QACd;QACAJ;IACF;AACF"}