{"version":3,"sources":["../../../src/components/Tree/useTree.ts"],"sourcesContent":["'use client';\n\nimport type * as React from 'react';\nimport { useTreeBase_unstable, useTreeContextValues_unstable } from '@fluentui/react-tree';\n\nimport type { TreeContextValues, TreeProps, TreeState } from './Tree.types';\n\n/**\n * Returns the state for a Tree component, given its props and ref.\n * The returned state can be modified with hooks before being passed to `renderTree`.\n *\n * Arrow key navigation, type ahead and the roving tab index are managed by the root tree.\n */\nexport const useTree = (props: TreeProps, ref: React.Ref<HTMLElement>): TreeState => {\n  const state: TreeState = useTreeBase_unstable(props, ref);\n\n  // Set data attributes for the root tree modes to simplify styling of these states.\n  if (state.contextType !== 'subtree') {\n    // eslint-disable-next-line react-hooks/immutability\n    state.root['data-navigation-mode'] = state.navigationMode ?? 'tree';\n    // eslint-disable-next-line react-hooks/immutability\n    state.root['data-selection-mode'] = state.selectionMode === 'none' ? undefined : state.selectionMode;\n  }\n\n  return state;\n};\n\n/**\n * Returns a value from the context of the root tree, such as its open items, checked items or selection mode.\n */\nexport { useTreeContext_unstable as useTreeContext } from '@fluentui/react-tree';\n\n/**\n * Returns the context of the closest subtree, which exposes its nesting level.\n */\nexport { useSubtreeContext_unstable as useSubtreeContext } from '@fluentui/react-tree';\n\n/**\n * Maps the state of the tree to the values that are passed through context to its items.\n */\nexport const useTreeContextValues: (state: TreeState) => TreeContextValues = useTreeContextValues_unstable;\n"],"names":["useSubtreeContext","useSubtreeContext_unstable","useTree","useTreeContext","useTreeContext_unstable","useTreeContextValues","props","ref","state","useTreeBase_unstable","contextType","root","navigationMode","selectionMode","undefined","useTreeContextValues_unstable"],"mappings":"AAAA;;;;;;;;;;;;QAmCuCA;eAA9BC,qCAA0B;;QAtBtBC;eAAAA;;QAiBuBC;eAA3BC,kCAAuB;;QAUnBC;eAAAA;;;2BArCuD;AAU7D,MAAMH,UAAU,CAACI,OAAkBC;IACxC,MAAMC,QAAmBC,IAAAA,+BAAoB,EAACH,OAAOC;IAErD,mFAAmF;IACnF,IAAIC,MAAME,WAAW,KAAK,WAAW;QACnC,oDAAoD;QACpDF,MAAMG,IAAI,CAAC,uBAAuB,GAAGH,MAAMI,cAAc,IAAI;QAC7D,oDAAoD;QACpDJ,MAAMG,IAAI,CAAC,sBAAsB,GAAGH,MAAMK,aAAa,KAAK,SAASC,YAAYN,MAAMK,aAAa;IACtG;IAEA,OAAOL;AACT;AAeO,MAAMH,uBAAgEU,wCAA6B"}