@fluentui/react-tree 9.16.10 → 9.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/CHANGELOG.md +11 -2
  2. package/dist/index.d.cts +83 -6
  3. package/dist/index.d.ts +83 -6
  4. package/lib/Tree.js +1 -1
  5. package/lib/Tree.js.map +1 -1
  6. package/lib/TreeItemLayout.js +1 -1
  7. package/lib/TreeItemLayout.js.map +1 -1
  8. package/lib/components/FlatTree/useFlatTree.js +28 -3
  9. package/lib/components/FlatTree/useFlatTree.js.map +1 -1
  10. package/lib/components/Tree/Tree.types.js +1 -1
  11. package/lib/components/Tree/Tree.types.js.map +1 -1
  12. package/lib/components/Tree/index.js +1 -1
  13. package/lib/components/Tree/index.js.map +1 -1
  14. package/lib/components/Tree/renderTree.js +6 -2
  15. package/lib/components/Tree/renderTree.js.map +1 -1
  16. package/lib/components/Tree/useTree.js +75 -6
  17. package/lib/components/Tree/useTree.js.map +1 -1
  18. package/lib/components/Tree/useTreeContextValues.js +4 -1
  19. package/lib/components/Tree/useTreeContextValues.js.map +1 -1
  20. package/lib/components/TreeItemLayout/TreeItemLayout.types.js +1 -1
  21. package/lib/components/TreeItemLayout/TreeItemLayout.types.js.map +1 -1
  22. package/lib/components/TreeItemLayout/index.js +1 -1
  23. package/lib/components/TreeItemLayout/index.js.map +1 -1
  24. package/lib/components/TreeItemLayout/renderTreeItemLayout.js +13 -7
  25. package/lib/components/TreeItemLayout/renderTreeItemLayout.js.map +1 -1
  26. package/lib/components/TreeItemLayout/useTreeItemLayout.js +201 -30
  27. package/lib/components/TreeItemLayout/useTreeItemLayout.js.map +1 -1
  28. package/lib/hooks/useFlatTreeNavigation.js +3 -4
  29. package/lib/hooks/useFlatTreeNavigation.js.map +1 -1
  30. package/lib/hooks/useRootTree.js +3 -8
  31. package/lib/hooks/useRootTree.js.map +1 -1
  32. package/lib/hooks/useRovingTabIndexBase.js +108 -0
  33. package/lib/hooks/useRovingTabIndexBase.js.map +1 -0
  34. package/lib/hooks/useRovingTabIndexes.js +2 -61
  35. package/lib/hooks/useRovingTabIndexes.js.map +1 -1
  36. package/lib/hooks/useSubtree.js +1 -11
  37. package/lib/hooks/useSubtree.js.map +1 -1
  38. package/lib/hooks/useTreeNavigation.js +6 -84
  39. package/lib/hooks/useTreeNavigation.js.map +1 -1
  40. package/lib/hooks/useTreeNavigationBase.js +131 -0
  41. package/lib/hooks/useTreeNavigationBase.js.map +1 -0
  42. package/lib/index.js +2 -2
  43. package/lib/index.js.map +1 -1
  44. package/lib/utils/queryTreeItemActions.js +29 -0
  45. package/lib/utils/queryTreeItemActions.js.map +1 -0
  46. package/lib-commonjs/Tree.cjs +3 -0
  47. package/lib-commonjs/Tree.cjs.map +1 -1
  48. package/lib-commonjs/TreeItemLayout.cjs +3 -0
  49. package/lib-commonjs/TreeItemLayout.cjs.map +1 -1
  50. package/lib-commonjs/components/FlatTree/useFlatTree.cjs +28 -3
  51. package/lib-commonjs/components/FlatTree/useFlatTree.cjs.map +1 -1
  52. package/lib-commonjs/components/Tree/Tree.types.cjs +1 -1
  53. package/lib-commonjs/components/Tree/Tree.types.cjs.map +1 -1
  54. package/lib-commonjs/components/Tree/index.cjs +3 -0
  55. package/lib-commonjs/components/Tree/index.cjs.map +1 -1
  56. package/lib-commonjs/components/Tree/renderTree.cjs +1 -1
  57. package/lib-commonjs/components/Tree/renderTree.cjs.map +1 -1
  58. package/lib-commonjs/components/Tree/useTree.cjs +68 -8
  59. package/lib-commonjs/components/Tree/useTree.cjs.map +1 -1
  60. package/lib-commonjs/components/Tree/useTreeContextValues.cjs +4 -1
  61. package/lib-commonjs/components/Tree/useTreeContextValues.cjs.map +1 -1
  62. package/lib-commonjs/components/TreeItemLayout/TreeItemLayout.types.cjs +1 -1
  63. package/lib-commonjs/components/TreeItemLayout/TreeItemLayout.types.cjs.map +1 -1
  64. package/lib-commonjs/components/TreeItemLayout/index.cjs +3 -0
  65. package/lib-commonjs/components/TreeItemLayout/index.cjs.map +1 -1
  66. package/lib-commonjs/components/TreeItemLayout/renderTreeItemLayout.cjs +9 -6
  67. package/lib-commonjs/components/TreeItemLayout/renderTreeItemLayout.cjs.map +1 -1
  68. package/lib-commonjs/components/TreeItemLayout/useTreeItemLayout.cjs +200 -32
  69. package/lib-commonjs/components/TreeItemLayout/useTreeItemLayout.cjs.map +1 -1
  70. package/lib-commonjs/hooks/useFlatTreeNavigation.cjs +3 -4
  71. package/lib-commonjs/hooks/useFlatTreeNavigation.cjs.map +1 -1
  72. package/lib-commonjs/hooks/useRootTree.cjs +3 -8
  73. package/lib-commonjs/hooks/useRootTree.cjs.map +1 -1
  74. package/lib-commonjs/hooks/useRovingTabIndexBase.cjs +116 -0
  75. package/lib-commonjs/hooks/useRovingTabIndexBase.cjs.map +1 -0
  76. package/lib-commonjs/hooks/useRovingTabIndexes.cjs +2 -62
  77. package/lib-commonjs/hooks/useRovingTabIndexes.cjs.map +1 -1
  78. package/lib-commonjs/hooks/useSubtree.cjs +1 -11
  79. package/lib-commonjs/hooks/useSubtree.cjs.map +1 -1
  80. package/lib-commonjs/hooks/useTreeNavigation.cjs +5 -84
  81. package/lib-commonjs/hooks/useTreeNavigation.cjs.map +1 -1
  82. package/lib-commonjs/hooks/useTreeNavigationBase.cjs +140 -0
  83. package/lib-commonjs/hooks/useTreeNavigationBase.cjs.map +1 -0
  84. package/lib-commonjs/index.cjs +6 -0
  85. package/lib-commonjs/index.cjs.map +1 -1
  86. package/lib-commonjs/utils/queryTreeItemActions.cjs +38 -0
  87. package/lib-commonjs/utils/queryTreeItemActions.cjs.map +1 -0
  88. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Tree/useTree.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useEventCallback, useMergedRefs } from '@fluentui/react-utilities';\nimport type { TreeProps, TreeState } from './Tree.types';\nimport { createNextOpenItems, useControllableOpenItems } from '../../hooks/useControllableOpenItems';\nimport { createNextNestedCheckedItems, useNestedCheckedItems } from './useNestedControllableCheckedItems';\nimport { SubtreeContext } from '../../contexts/subtreeContext';\nimport { useRootTree } from '../../hooks/useRootTree';\nimport { useSubtree } from '../../hooks/useSubtree';\nimport { useTreeNavigation } from '../../hooks/useTreeNavigation';\nimport { useTreeContext_unstable } from '../../contexts/treeContext';\nimport { ImmutableSet } from '../../utils/ImmutableSet';\nimport { ImmutableMap } from '../../utils/ImmutableMap';\n\nexport const useTree_unstable = (props: TreeProps, ref: React.Ref<HTMLElement>): TreeState => {\n const isRoot = React.useContext(SubtreeContext) === undefined;\n // as level is static, this doesn't break rule of hooks\n // and if this becomes an issue later on, this can be easily converted\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return isRoot ? useNestedRootTree(props, ref) : useNestedSubtree(props, ref);\n};\n\nfunction useNestedRootTree(props: TreeProps, ref: React.Ref<HTMLElement>): TreeState {\n 'use no memo'; // justified: compiler would optimize useNestedRootTree — manual opt-out to preserve runtime behavior\n\n const [openItems, setOpenItems] = useControllableOpenItems(props);\n const checkedItems = useNestedCheckedItems(props);\n const navigation = useTreeNavigation(props.navigationMode);\n\n return Object.assign(\n useRootTree(\n {\n ...props,\n openItems,\n checkedItems,\n onOpenChange: useEventCallback((event, data) => {\n const nextOpenItems = createNextOpenItems(data, openItems);\n props.onOpenChange?.(event, {\n ...data,\n openItems: ImmutableSet.dangerouslyGetInternalSet(nextOpenItems),\n });\n setOpenItems(nextOpenItems);\n }),\n onNavigation: useEventCallback((event, data) => {\n props.onNavigation?.(event, data);\n if (!event.isDefaultPrevented()) {\n navigation.navigate(data, {\n preventScroll: data.isScrollPrevented(),\n });\n }\n }),\n onCheckedChange: useEventCallback((event, data) => {\n const nextCheckedItems = createNextNestedCheckedItems(data, checkedItems);\n props.onCheckedChange?.(event, {\n ...data,\n checkedItems: ImmutableMap.dangerouslyGetInternalMap(nextCheckedItems),\n });\n }),\n },\n useMergedRefs(ref, navigation.treeRef),\n ),\n {\n treeType: 'nested',\n forceUpdateRovingTabIndex: navigation.forceUpdateRovingTabIndex,\n } as const,\n );\n}\n\nfunction useNestedSubtree(props: TreeProps, ref: React.Ref<HTMLElement>): TreeState {\n if (process.env.NODE_ENV === 'development') {\n // this doesn't break rule of hooks, as environment is a static value\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const treeType = useTreeContext_unstable(ctx => ctx.treeType);\n if (treeType === 'flat') {\n throw new Error(/* #__DE-INDENT__ */ `\n @fluentui/react-tree [useTree]:\n Subtrees are not allowed in a FlatTree!\n You cannot use a <Tree> component inside of a <FlatTree> component!\n `);\n }\n }\n return useSubtree(props, ref);\n}\n"],"names":["React","useEventCallback","useMergedRefs","createNextOpenItems","useControllableOpenItems","createNextNestedCheckedItems","useNestedCheckedItems","SubtreeContext","useRootTree","useSubtree","useTreeNavigation","useTreeContext_unstable","ImmutableSet","ImmutableMap","useTree_unstable","props","ref","isRoot","useContext","undefined","useNestedRootTree","useNestedSubtree","openItems","setOpenItems","checkedItems","navigation","navigationMode","Object","assign","onOpenChange","event","data","nextOpenItems","dangerouslyGetInternalSet","onNavigation","isDefaultPrevented","navigate","preventScroll","isScrollPrevented","onCheckedChange","nextCheckedItems","dangerouslyGetInternalMap","treeRef","treeType","forceUpdateRovingTabIndex","process","env","NODE_ENV","ctx","Error"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,gBAAgB,EAAEC,aAAa,QAAQ,4BAA4B;AAE5E,SAASC,mBAAmB,EAAEC,wBAAwB,QAAQ,0CAAuC;AACrG,SAASC,4BAA4B,EAAEC,qBAAqB,QAAQ,yCAAsC;AAC1G,SAASC,cAAc,QAAQ,mCAAgC;AAC/D,SAASC,WAAW,QAAQ,6BAA0B;AACtD,SAASC,UAAU,QAAQ,4BAAyB;AACpD,SAASC,iBAAiB,QAAQ,mCAAgC;AAClE,SAASC,uBAAuB,QAAQ,gCAA6B;AACrE,SAASC,YAAY,QAAQ,8BAA2B;AACxD,SA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KAAKS,WAAWiB,OAAO,IAEvC;QACEC,UAAU;QACVC,2BAA2BnB,WAAWmB,yBAAyB;IACjE;AAEJ;AAEA,SAASvB,iBAAiBN,KAAgB,EAAEC,GAA2B;IACrE,IAAI6B,QAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;QAC1C,qEAAqE;QACrE,sDAAsD;QACtD,MAAMJ,WAAWhC,wBAAwBqC,CAAAA,MAAOA,IAAIL,QAAQ;QAC5D,IAAIA,aAAa,QAAQ;YACvB,MAAM,IAAIM,MAA2B,CAAC;;mEAItC,CAAC;QACH;IACF;IACA,OAAOxC,WAAWM,OAAOC;AAC3B"}
1
+ {"version":3,"sources":["../../../src/components/Tree/useTree.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useEventCallback, useMergedRefs } from '@fluentui/react-utilities';\nimport { useFocusFinders, useFocusedElementChange } from '@fluentui/react-tabster';\nimport { presenceMotionSlot } from '@fluentui/react-motion';\nimport { Collapse } from '@fluentui/react-motion-components-preview';\nimport type { TreeBaseProps, TreeBaseState, TreeProps, TreeState } from './Tree.types';\nimport { createNextOpenItems, useControllableOpenItems } from '../../hooks/useControllableOpenItems';\nimport { createNextNestedCheckedItems, useNestedCheckedItems } from './useNestedControllableCheckedItems';\nimport { SubtreeContext } from '../../contexts/subtreeContext';\nimport { useRootTree } from '../../hooks/useRootTree';\nimport { useSubtree } from '../../hooks/useSubtree';\nimport { findFirstFocusableDOM, useTreeNavigationBase } from '../../hooks/useTreeNavigationBase';\nimport type { TreeNavigationOptions } from '../../hooks/useTreeNavigationBase';\nimport { useDOMFocusedElementChange } from '../../hooks/useRovingTabIndexBase';\nimport { useTreeContext_unstable } from '../../contexts/treeContext';\nimport { ImmutableSet } from '../../utils/ImmutableSet';\nimport { ImmutableMap } from '../../utils/ImmutableMap';\n\n/**\n * Create the state required to render Tree.\n *\n * The returned state can be modified with hooks such as useTreeStyles_unstable,\n * before being passed to renderTree_unstable.\n *\n * @param props - props from this instance of Tree\n * @param ref - reference to root HTMLElement of Tree\n */\nexport const useTree_unstable = (props: TreeProps, ref: React.Ref<HTMLElement>): TreeState => {\n const { appearance = 'subtle', size = 'medium', collapseMotion, ...baseProps } = props;\n // Tabster aware focus management, superseding the plain DOM one used by the base hook.\n const state = useTreeInternal(baseProps, ref, useTabsterNavigationOptions);\n\n if (state.contextType === 'subtree') {\n return {\n ...state,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n components: { ...state.components, collapseMotion: Collapse },\n collapseMotion: presenceMotionSlot(collapseMotion, {\n elementType: Collapse,\n defaultProps: {\n visible: state.open,\n unmountOnExit: true,\n },\n }),\n };\n }\n\n return {\n ...state,\n appearance,\n size,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n components: { ...state.components, collapseMotion: Collapse },\n collapseMotion: undefined,\n };\n};\n\n/**\n * Base state hook for Tree, free of any design props, motion or focus management runtime.\n *\n * Arrow key navigation and the roving tab index are driven by plain DOM focus handling, and closed\n * subtrees are not rendered as there is no collapse motion to unmount them.\n *\n * @param props - props from this instance of Tree\n * @param ref - reference to root HTMLElement of Tree\n */\nexport const useTreeBase_unstable = (props: TreeBaseProps, ref: React.Ref<HTMLElement>): TreeBaseState => {\n return useTreeInternal(props, ref, useDOMNavigationOptions);\n};\n\nconst domNavigationOptions: TreeNavigationOptions = {\n findFirstFocusable: findFirstFocusableDOM,\n useFocusedElementChange: useDOMFocusedElementChange,\n};\n\nconst useDOMNavigationOptions = (): TreeNavigationOptions => domNavigationOptions;\n\nconst useTabsterNavigationOptions = (): TreeNavigationOptions => {\n const { findFirstFocusable } = useFocusFinders();\n return { findFirstFocusable, useFocusedElementChange };\n};\n\nfunction useTreeInternal(\n props: TreeBaseProps,\n ref: React.Ref<HTMLElement>,\n // Only the root tree drives navigation, so subtrees never pay for the focus management runtime.\n useNavigationOptions: () => TreeNavigationOptions,\n): TreeBaseState {\n const isRoot = React.useContext(SubtreeContext) === undefined;\n // as level is static, this doesn't break rule of hooks\n // and if this becomes an issue later on, this can be easily converted\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return isRoot ? useNestedRootTree(props, ref, useNavigationOptions) : useNestedSubtree(props, ref);\n}\n\nfunction useNestedRootTree(\n props: TreeBaseProps,\n ref: React.Ref<HTMLElement>,\n useNavigationOptions: () => TreeNavigationOptions,\n): TreeBaseState {\n 'use no memo'; // justified: compiler would optimize useNestedRootTree — manual opt-out to preserve runtime behavior\n\n const [openItems, setOpenItems] = useControllableOpenItems(props);\n const checkedItems = useNestedCheckedItems(props);\n const navigation = useTreeNavigationBase(props.navigationMode, useNavigationOptions());\n\n return Object.assign(\n useRootTree(\n {\n ...props,\n openItems,\n checkedItems,\n onOpenChange: useEventCallback((event, data) => {\n const nextOpenItems = createNextOpenItems(data, openItems);\n props.onOpenChange?.(event, {\n ...data,\n openItems: ImmutableSet.dangerouslyGetInternalSet(nextOpenItems),\n });\n setOpenItems(nextOpenItems);\n }),\n onNavigation: useEventCallback((event, data) => {\n props.onNavigation?.(event, data);\n if (!event.isDefaultPrevented()) {\n navigation.navigate(data, {\n preventScroll: data.isScrollPrevented(),\n });\n }\n }),\n onCheckedChange: useEventCallback((event, data) => {\n const nextCheckedItems = createNextNestedCheckedItems(data, checkedItems);\n props.onCheckedChange?.(event, {\n ...data,\n checkedItems: ImmutableMap.dangerouslyGetInternalMap(nextCheckedItems),\n });\n }),\n },\n useMergedRefs(ref, navigation.treeRef),\n ),\n {\n treeType: 'nested',\n forceUpdateRovingTabIndex: navigation.forceUpdateRovingTabIndex,\n } as const,\n );\n}\n\nfunction useNestedSubtree(props: TreeBaseProps, ref: React.Ref<HTMLElement>): TreeBaseState {\n if (process.env.NODE_ENV === 'development') {\n // this doesn't break rule of hooks, as environment is a static value\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const treeType = useTreeContext_unstable(ctx => ctx.treeType);\n if (treeType === 'flat') {\n throw new Error(/* #__DE-INDENT__ */ `\n @fluentui/react-tree [useTree]:\n Subtrees are not allowed in a FlatTree!\n You cannot use a <Tree> component inside of a <FlatTree> component!\n `);\n }\n }\n return useSubtree(props, ref);\n}\n"],"names":["React","useEventCallback","useMergedRefs","useFocusFinders","useFocusedElementChange","presenceMotionSlot","Collapse","createNextOpenItems","useControllableOpenItems","createNextNestedCheckedItems","useNestedCheckedItems","SubtreeContext","useRootTree","useSubtree","findFirstFocusableDOM","useTreeNavigationBase","useDOMFocusedElementChange","useTreeContext_unstable","ImmutableSet","ImmutableMap","useTree_unstable","props","ref","appearance","size","collapseMotion","baseProps","state","useTreeInternal","useTabsterNavigationOptions","contextType","components","elementType","defaultProps","visible","open","unmountOnExit","undefined","useTreeBase_unstable","useDOMNavigationOptions","domNavigationOptions","findFirstFocusable","useNavigationOptions","isRoot","useContext","useNestedRootTree","useNestedSubtree","openItems","setOpenItems","checkedItems","navigation","navigationMode","Object","assign","onOpenChange","event","data","nextOpenItems","dangerouslyGetInternalSet","onNavigation","isDefaultPrevented","navigate","preventScroll","isScrollPrevented","onCheckedChange","nextCheckedItems","dangerouslyGetInternalMap","treeRef","treeType","forceUpdateRovingTabIndex","process","env","NODE_ENV","ctx","Error"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,gBAAgB,EAAEC,aAAa,QAAQ,4BAA4B;AAC5E,SAASC,eAAe,EAAEC,uBAAuB,QAAQ,0BAA0B;AACnF,SAASC,kBAAkB,QAAQ,yBAAyB;AAC5D,SAASC,QAAQ,QAAQ,4CAA4C;AAErE,SAASC,mBAAmB,EAAEC,wBAAwB,QAAQ,0CAAuC;AACrG,SAASC,4BAA4B,EAAEC,qBAAqB,QAAQ,yCAAsC;AAC1G,SAASC,cAAc,QAAQ,mCAAgC;AAC/D,SAASC,WAAW,QAAQ,6BAA0B;AACtD,SAASC,UAAU,QAAQ,4BAAyB;AACpD,SAASC,qBAAqB,EAAEC,qBAAqB,QAAQ,uCAAoC;AAEjG,SAASC,0BAA0B,QAAQ,uCAAoC;AAC/E,SAASC,uBAAuB,QAAQ,gCAA6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,GAA2B;IACzE,IAAIgD,QAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;QAC1C,qEAAqE;QACrE,sDAAsD;QACtD,MAAMJ,WAAWnD,wBAAwBwD,CAAAA,MAAOA,IAAIL,QAAQ;QAC5D,IAAIA,aAAa,QAAQ;YACvB,MAAM,IAAIM,MAA2B,CAAC;;mEAItC,CAAC;QACH;IACF;IACA,OAAO7D,WAAWQ,OAAOC;AAC3B"}
@@ -2,7 +2,10 @@
2
2
  import * as React from "react";
3
3
  export function useTreeContextValues_unstable(state) {
4
4
  if (state.contextType === 'root') {
5
- const { openItems, level, contextType, treeType, checkedItems, selectionMode, navigationMode, appearance, size, requestTreeResponse, forceUpdateRovingTabIndex } = state;
5
+ const { openItems, level, contextType, treeType, checkedItems, selectionMode, navigationMode, requestTreeResponse, forceUpdateRovingTabIndex } = state;
6
+ // Base state carries no design props, the context falls back to the default design values.
7
+ const appearance = 'appearance' in state ? state.appearance : 'subtle';
8
+ const size = 'size' in state ? state.size : 'medium';
6
9
  // contextType is statically determined by the context
7
10
  // eslint-disable-next-line react-hooks/rules-of-hooks
8
11
  const tree = React.useMemo(()=>({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Tree/useTreeContextValues.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { TreeContextValue } from '../../contexts';\nimport type { TreeContextValues, TreeState } from './Tree.types';\n\nexport function useTreeContextValues_unstable(state: TreeState): TreeContextValues {\n if (state.contextType === 'root') {\n const {\n openItems,\n level,\n contextType,\n treeType,\n checkedItems,\n selectionMode,\n navigationMode,\n appearance,\n size,\n requestTreeResponse,\n forceUpdateRovingTabIndex,\n } = state;\n // contextType is statically determined by the context\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const tree = React.useMemo<TreeContextValue>(\n () => ({\n treeType,\n size,\n openItems,\n appearance,\n checkedItems,\n selectionMode,\n navigationMode,\n contextType,\n level,\n requestTreeResponse,\n forceUpdateRovingTabIndex,\n }),\n [\n treeType,\n size,\n openItems,\n appearance,\n checkedItems,\n selectionMode,\n navigationMode,\n contextType,\n level,\n requestTreeResponse,\n forceUpdateRovingTabIndex,\n ],\n );\n\n return { tree };\n }\n return {\n // contextType is statically determined by the context\n // eslint-disable-next-line react-hooks/rules-of-hooks\n tree: React.useMemo(() => ({ level: state.level, contextType: 'subtree' }), [state.level]),\n };\n}\n"],"names":["React","useTreeContextValues_unstable","state","contextType","openItems","level","treeType","checkedItems","selectionMode","navigationMode","appearance","size","requestTreeResponse","forceUpdateRovingTabIndex","tree","useMemo"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAI/B,OAAO,SAASC,8BAA8BC,KAAgB;IAC5D,IAAIA,MAAMC,WAAW,KAAK,QAAQ;QAChC,MAAM,EACJC,SAAS,EACTC,KAAK,EACLF,WAAW,EACXG,QAAQ,EACRC,YAAY,EACZC,aAAa,EACbC,cAAc,EACdC,UAAU,EACVC,IAAI,EACJC,mBAAmB,EACnBC,yBAAyB,EAC1B,GAAGX;QACJ,sDAAsD;QACtD,sDAAsD;QACtD,MAAMY,OAAOd,MAAMe,OAAO,CACxB,IAAO,CAAA;gBACLT;gBACAK;gBACAP;gBACAM;gBACAH;gBACAC;gBACAC;gBACAN;gBACAE;gBACAO;gBACAC;YACF,CAAA,GACA;YACEP;YACAK;YACAP;YACAM;YACAH;YACAC;YACAC;YACAN;YACAE;YACAO;YACAC;SACD;QAGH,OAAO;YAAEC;QAAK;IAChB;IACA,OAAO;QACL,sDAAsD;QACtD,sDAAsD;QACtDA,MAAMd,MAAMe,OAAO,CAAC,IAAO,CAAA;gBAAEV,OAAOH,MAAMG,KAAK;gBAAEF,aAAa;YAAU,CAAA,GAAI;YAACD,MAAMG,KAAK;SAAC;IAC3F;AACF"}
1
+ {"version":3,"sources":["../../../src/components/Tree/useTreeContextValues.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { TreeContextValue } from '../../contexts';\nimport type { TreeBaseState, TreeContextValues, TreeState } from './Tree.types';\n\nexport function useTreeContextValues_unstable(state: TreeState | TreeBaseState): TreeContextValues {\n if (state.contextType === 'root') {\n const {\n openItems,\n level,\n contextType,\n treeType,\n checkedItems,\n selectionMode,\n navigationMode,\n requestTreeResponse,\n forceUpdateRovingTabIndex,\n } = state;\n // Base state carries no design props, the context falls back to the default design values.\n const appearance = 'appearance' in state ? state.appearance : 'subtle';\n const size = 'size' in state ? state.size : 'medium';\n // contextType is statically determined by the context\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const tree = React.useMemo<TreeContextValue>(\n () => ({\n treeType,\n size,\n openItems,\n appearance,\n checkedItems,\n selectionMode,\n navigationMode,\n contextType,\n level,\n requestTreeResponse,\n forceUpdateRovingTabIndex,\n }),\n [\n treeType,\n size,\n openItems,\n appearance,\n checkedItems,\n selectionMode,\n navigationMode,\n contextType,\n level,\n requestTreeResponse,\n forceUpdateRovingTabIndex,\n ],\n );\n\n return { tree };\n }\n return {\n // contextType is statically determined by the context\n // eslint-disable-next-line react-hooks/rules-of-hooks\n tree: React.useMemo(() => ({ level: state.level, contextType: 'subtree' }), [state.level]),\n };\n}\n"],"names":["React","useTreeContextValues_unstable","state","contextType","openItems","level","treeType","checkedItems","selectionMode","navigationMode","requestTreeResponse","forceUpdateRovingTabIndex","appearance","size","tree","useMemo"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAI/B,OAAO,SAASC,8BAA8BC,KAAgC;IAC5E,IAAIA,MAAMC,WAAW,KAAK,QAAQ;QAChC,MAAM,EACJC,SAAS,EACTC,KAAK,EACLF,WAAW,EACXG,QAAQ,EACRC,YAAY,EACZC,aAAa,EACbC,cAAc,EACdC,mBAAmB,EACnBC,yBAAyB,EAC1B,GAAGT;QACJ,2FAA2F;QAC3F,MAAMU,aAAa,gBAAgBV,QAAQA,MAAMU,UAAU,GAAG;QAC9D,MAAMC,OAAO,UAAUX,QAAQA,MAAMW,IAAI,GAAG;QAC5C,sDAAsD;QACtD,sDAAsD;QACtD,MAAMC,OAAOd,MAAMe,OAAO,CACxB,IAAO,CAAA;gBACLT;gBACAO;gBACAT;gBACAQ;gBACAL;gBACAC;gBACAC;gBACAN;gBACAE;gBACAK;gBACAC;YACF,CAAA,GACA;YACEL;YACAO;YACAT;YACAQ;YACAL;YACAC;YACAC;YACAN;YACAE;YACAK;YACAC;SACD;QAGH,OAAO;YAAEG;QAAK;IAChB;IACA,OAAO;QACL,sDAAsD;QACtD,sDAAsD;QACtDA,MAAMd,MAAMe,OAAO,CAAC,IAAO,CAAA;gBAAEV,OAAOH,MAAMG,KAAK;gBAAEF,aAAa;YAAU,CAAA,GAAI;YAACD,MAAMG,KAAK;SAAC;IAC3F;AACF"}
@@ -1,3 +1,3 @@
1
1
  /**
2
- * State used in rendering TreeItemLayout
2
+ * State returned by `useTreeItemLayoutBase_unstable`.
3
3
  */ export { };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/TreeItemLayout/TreeItemLayout.types.ts"],"sourcesContent":["import type * as React from 'react';\nimport type {\n Slot,\n ComponentProps,\n ComponentState,\n ExtractSlotProps,\n EventData,\n EventHandler,\n} from '@fluentui/react-utilities';\nimport type { ButtonContextValue } from '@fluentui/react-button';\nimport type { Checkbox } from '@fluentui/react-checkbox';\nimport type { Radio } from '@fluentui/react-radio';\n\nexport type TreeItemLayoutActionVisibilityChangeData = (\n | EventData<'mouseover' | 'mouseout', MouseEvent>\n | EventData<'focus' | 'blur', FocusEvent>\n | EventData<'blur', React.FocusEvent>\n) & { visible: boolean };\n\nexport type TreeItemLayoutActionSlotProps = ExtractSlotProps<\n Slot<'div'> & {\n /**\n * Forces visibility of the aside/action content\n */\n visible?: boolean;\n onVisibilityChange?: EventHandler<TreeItemLayoutActionVisibilityChangeData>;\n }\n>;\n\nexport type TreeItemLayoutSlots = {\n root: Slot<'div'>;\n /**\n * Content. Children of the root slot are automatically rendered here\n */\n main: NonNullable<Slot<'div'>>;\n /**\n * Icon slot that renders right before main content\n */\n iconBefore?: Slot<'div'>;\n /**\n * Icon slot that renders right after main content\n */\n iconAfter?: Slot<'div'>;\n /**\n * Expand icon slot,\n * by default renders a chevron icon to indicate opening and closing\n */\n expandIcon?: Slot<'div'>;\n /**\n * Aside content is normally used to render a badge or other non-actionable content\n */\n aside?: Slot<'div'>;\n /**\n * Actionable elements are normally buttons, menus, or other focusable elements.\n * Those elements are only visibly available if the given tree item is currently active.\n *\n * `actions` and `aside` slots are positioned on the exact same spot,\n * so they won't be visible at the same time.\n * `aside` slot is visible by default meanwhile `actions` slot are only visible when the tree item is active.\n *\n * `actions` slot supports a `visible` prop to force visibility of the actions.\n */\n actions?: Slot<TreeItemLayoutActionSlotProps>;\n selector?: Slot<typeof Checkbox> | Slot<typeof Radio>;\n};\n\n/**\n * TreeItemLayout Props\n */\nexport type TreeItemLayoutProps = ComponentProps<Partial<TreeItemLayoutSlots>>;\n\n/**\n * State used in rendering TreeItemLayout\n */\nexport type TreeItemLayoutState = ComponentState<TreeItemLayoutSlots> & {\n buttonContextValue: ButtonContextValue;\n};\n"],"names":[],"mappings":"AAuEA;;CAEC,GACD,WAEE"}
1
+ {"version":3,"sources":["../../../src/components/TreeItemLayout/TreeItemLayout.types.ts"],"sourcesContent":["import type * as React from 'react';\nimport type {\n Slot,\n ComponentProps,\n ComponentState,\n ExtractSlotProps,\n EventData,\n EventHandler,\n} from '@fluentui/react-utilities';\nimport type { ButtonContextValue } from '@fluentui/react-button';\nimport type { Checkbox } from '@fluentui/react-checkbox';\nimport type { Radio } from '@fluentui/react-radio';\n\nexport type TreeItemLayoutActionVisibilityChangeData = (\n | EventData<'mouseover' | 'mouseout', MouseEvent>\n | EventData<'focus' | 'blur', FocusEvent>\n | EventData<'blur', React.FocusEvent>\n) & { visible: boolean };\n\nexport type TreeItemLayoutActionSlotProps = ExtractSlotProps<\n Slot<'div'> & {\n /**\n * Forces visibility of the aside/action content\n */\n visible?: boolean;\n onVisibilityChange?: EventHandler<TreeItemLayoutActionVisibilityChangeData>;\n }\n>;\n\nexport type TreeItemLayoutSlots = {\n root: Slot<'div'>;\n /**\n * Content. Children of the root slot are automatically rendered here\n */\n main: NonNullable<Slot<'div'>>;\n /**\n * Icon slot that renders right before main content\n */\n iconBefore?: Slot<'div'>;\n /**\n * Icon slot that renders right after main content\n */\n iconAfter?: Slot<'div'>;\n /**\n * Expand icon slot,\n * by default renders a chevron icon to indicate opening and closing\n */\n expandIcon?: Slot<'div'>;\n /**\n * Aside content is normally used to render a badge or other non-actionable content\n */\n aside?: Slot<'div'>;\n /**\n * Actionable elements are normally buttons, menus, or other focusable elements.\n * Those elements are only visibly available if the given tree item is currently active.\n *\n * `actions` and `aside` slots are positioned on the exact same spot,\n * so they won't be visible at the same time.\n * `aside` slot is visible by default meanwhile `actions` slot are only visible when the tree item is active.\n *\n * `actions` slot supports a `visible` prop to force visibility of the actions.\n */\n actions?: Slot<TreeItemLayoutActionSlotProps>;\n selector?: Slot<typeof Checkbox> | Slot<typeof Radio>;\n};\n\n/**\n * TreeItemLayout Props\n */\nexport type TreeItemLayoutProps = ComponentProps<Partial<TreeItemLayoutSlots>>;\n\n/**\n * State used in rendering TreeItemLayout\n */\nexport type TreeItemLayoutState = ComponentState<TreeItemLayoutSlots> & {\n buttonContextValue: ButtonContextValue;\n};\n\n/**\n * TreeItemLayout slots without any design dependency, used by `useTreeItemLayoutBase_unstable`.\n *\n * The selector renders as a native `input`, of type `checkbox` or `radio` depending on the tree selection mode.\n */\nexport type TreeItemLayoutBaseSlots = Omit<TreeItemLayoutSlots, 'selector'> & {\n selector?: Slot<'input'>;\n};\n\n/**\n * TreeItemLayout props accepted by `useTreeItemLayoutBase_unstable`.\n */\nexport type TreeItemLayoutBaseProps = ComponentProps<Partial<TreeItemLayoutBaseSlots>>;\n\n/**\n * State returned by `useTreeItemLayoutBase_unstable`.\n */\nexport type TreeItemLayoutBaseState = ComponentState<TreeItemLayoutBaseSlots>;\n"],"names":[],"mappings":"AA4FA;;CAEC,GACD,WAA8E"}
@@ -1,4 +1,4 @@
1
1
  export { TreeItemLayout } from "./TreeItemLayout.js";
2
2
  export { renderTreeItemLayout_unstable } from "./renderTreeItemLayout.js";
3
- export { useTreeItemLayout_unstable } from "./useTreeItemLayout.js";
3
+ export { useTreeItemLayoutBase_unstable, useTreeItemLayout_unstable } from "./useTreeItemLayout.js";
4
4
  export { treeItemLayoutClassNames, useTreeItemLayoutStyles_unstable } from "./useTreeItemLayoutStyles.styles.js";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/TreeItemLayout/index.ts"],"sourcesContent":["export { TreeItemLayout } from './TreeItemLayout';\nexport type {\n TreeItemLayoutActionSlotProps,\n TreeItemLayoutActionVisibilityChangeData,\n TreeItemLayoutProps,\n TreeItemLayoutSlots,\n TreeItemLayoutState,\n} from './TreeItemLayout.types';\nexport { renderTreeItemLayout_unstable } from './renderTreeItemLayout';\nexport { useTreeItemLayout_unstable } from './useTreeItemLayout';\nexport { treeItemLayoutClassNames, useTreeItemLayoutStyles_unstable } from './useTreeItemLayoutStyles.styles';\n"],"names":["TreeItemLayout","renderTreeItemLayout_unstable","useTreeItemLayout_unstable","treeItemLayoutClassNames","useTreeItemLayoutStyles_unstable"],"mappings":"AAAA,SAASA,cAAc,QAAQ,sBAAmB;AAQlD,SAASC,6BAA6B,QAAQ,4BAAyB;AACvE,SAASC,0BAA0B,QAAQ,yBAAsB;AACjE,SAASC,wBAAwB,EAAEC,gCAAgC,QAAQ,sCAAmC"}
1
+ {"version":3,"sources":["../../../src/components/TreeItemLayout/index.ts"],"sourcesContent":["export { TreeItemLayout } from './TreeItemLayout';\nexport type {\n TreeItemLayoutActionSlotProps,\n TreeItemLayoutActionVisibilityChangeData,\n TreeItemLayoutBaseProps,\n TreeItemLayoutBaseSlots,\n TreeItemLayoutBaseState,\n TreeItemLayoutProps,\n TreeItemLayoutSlots,\n TreeItemLayoutState,\n} from './TreeItemLayout.types';\nexport { renderTreeItemLayout_unstable } from './renderTreeItemLayout';\nexport { useTreeItemLayoutBase_unstable, useTreeItemLayout_unstable } from './useTreeItemLayout';\nexport { treeItemLayoutClassNames, useTreeItemLayoutStyles_unstable } from './useTreeItemLayoutStyles.styles';\n"],"names":["TreeItemLayout","renderTreeItemLayout_unstable","useTreeItemLayoutBase_unstable","useTreeItemLayout_unstable","treeItemLayoutClassNames","useTreeItemLayoutStyles_unstable"],"mappings":"AAAA,SAASA,cAAc,QAAQ,sBAAmB;AAWlD,SAASC,6BAA6B,QAAQ,4BAAyB;AACvE,SAASC,8BAA8B,EAAEC,0BAA0B,QAAQ,yBAAsB;AACjG,SAASC,wBAAwB,EAAEC,gCAAgC,QAAQ,sCAAmC"}
@@ -1,10 +1,19 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "@fluentui/react-jsx-runtime/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@fluentui/react-jsx-runtime/jsx-runtime";
2
2
  import { assertSlots } from "@fluentui/react-utilities";
3
3
  import { ButtonContextProvider } from "@fluentui/react-button";
4
4
  /**
5
5
  * Render the final JSX of TreeItemLayout
6
+ *
7
+ * The button context is only provided when the state carries one, which is not the case for the
8
+ * state produced by `useTreeItemLayoutBase_unstable`.
6
9
  */ export const renderTreeItemLayout_unstable = (state)=>{
7
10
  assertSlots(state);
11
+ const actionsAndAside = /*#__PURE__*/ _jsxs(_Fragment, {
12
+ children: [
13
+ state.actions && /*#__PURE__*/ _jsx(state.actions, {}),
14
+ state.aside && /*#__PURE__*/ _jsx(state.aside, {})
15
+ ]
16
+ });
8
17
  return /*#__PURE__*/ _jsxs(state.root, {
9
18
  children: [
10
19
  state.expandIcon && /*#__PURE__*/ _jsx(state.expandIcon, {}),
@@ -14,13 +23,10 @@ import { ButtonContextProvider } from "@fluentui/react-button";
14
23
  children: state.root.children
15
24
  }),
16
25
  state.iconAfter && /*#__PURE__*/ _jsx(state.iconAfter, {}),
17
- /*#__PURE__*/ _jsxs(ButtonContextProvider, {
26
+ 'buttonContextValue' in state ? /*#__PURE__*/ _jsx(ButtonContextProvider, {
18
27
  value: state.buttonContextValue,
19
- children: [
20
- state.actions && /*#__PURE__*/ _jsx(state.actions, {}),
21
- state.aside && /*#__PURE__*/ _jsx(state.aside, {})
22
- ]
23
- })
28
+ children: actionsAndAside
29
+ }) : actionsAndAside
24
30
  ]
25
31
  });
26
32
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/TreeItemLayout/renderTreeItemLayout.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport type { TreeItemLayoutState, TreeItemLayoutSlots } from './TreeItemLayout.types';\nimport { ButtonContextProvider } from '@fluentui/react-button';\n\n/**\n * Render the final JSX of TreeItemLayout\n */\nexport const renderTreeItemLayout_unstable = (state: TreeItemLayoutState): JSXElement => {\n assertSlots<TreeItemLayoutSlots>(state);\n\n return (\n <state.root>\n {state.expandIcon && <state.expandIcon />}\n {state.selector && <state.selector />}\n {state.iconBefore && <state.iconBefore />}\n <state.main>{state.root.children}</state.main>\n {state.iconAfter && <state.iconAfter />}\n <ButtonContextProvider value={state.buttonContextValue}>\n {state.actions && <state.actions />}\n {state.aside && <state.aside />}\n </ButtonContextProvider>\n </state.root>\n );\n};\n"],"names":["assertSlots","ButtonContextProvider","renderTreeItemLayout_unstable","state","root","expandIcon","selector","iconBefore","main","children","iconAfter","value","buttonContextValue","actions","aside"],"mappings":";AAAA,0BAA0B,GAC1B,iDAAiD,GACjD,SAASA,WAAW,QAAQ,4BAA4B;AAGxD,SAASC,qBAAqB,QAAQ,yBAAyB;AAE/D;;CAEC,GACD,OAAO,MAAMC,gCAAgC,CAACC;IAC5CH,YAAiCG;IAEjC,qBACE,MAACA,MAAMC,IAAI;;YACRD,MAAME,UAAU,kBAAI,KAACF,MAAME,UAAU;YACrCF,MAAMG,QAAQ,kBAAI,KAACH,MAAMG,QAAQ;YACjCH,MAAMI,UAAU,kBAAI,KAACJ,MAAMI,UAAU;0BACtC,KAACJ,MAAMK,IAAI;0BAAEL,MAAMC,IAAI,CAACK,QAAQ;;YAC/BN,MAAMO,SAAS,kBAAI,KAACP,MAAMO,SAAS;0BACpC,MAACT;gBAAsBU,OAAOR,MAAMS,kBAAkB;;oBACnDT,MAAMU,OAAO,kBAAI,KAACV,MAAMU,OAAO;oBAC/BV,MAAMW,KAAK,kBAAI,KAACX,MAAMW,KAAK;;;;;AAIpC,EAAE"}
1
+ {"version":3,"sources":["../../../src/components/TreeItemLayout/renderTreeItemLayout.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport type { TreeItemLayoutBaseState, TreeItemLayoutState, TreeItemLayoutSlots } from './TreeItemLayout.types';\nimport { ButtonContextProvider } from '@fluentui/react-button';\n\n/**\n * Render the final JSX of TreeItemLayout\n *\n * The button context is only provided when the state carries one, which is not the case for the\n * state produced by `useTreeItemLayoutBase_unstable`.\n */\nexport const renderTreeItemLayout_unstable = (state: TreeItemLayoutState | TreeItemLayoutBaseState): JSXElement => {\n assertSlots<TreeItemLayoutSlots>(state);\n\n const actionsAndAside = (\n <>\n {state.actions && <state.actions />}\n {state.aside && <state.aside />}\n </>\n );\n\n return (\n <state.root>\n {state.expandIcon && <state.expandIcon />}\n {state.selector && <state.selector />}\n {state.iconBefore && <state.iconBefore />}\n <state.main>{state.root.children}</state.main>\n {state.iconAfter && <state.iconAfter />}\n {'buttonContextValue' in state ? (\n <ButtonContextProvider value={state.buttonContextValue}>{actionsAndAside}</ButtonContextProvider>\n ) : (\n actionsAndAside\n )}\n </state.root>\n );\n};\n"],"names":["assertSlots","ButtonContextProvider","renderTreeItemLayout_unstable","state","actionsAndAside","actions","aside","root","expandIcon","selector","iconBefore","main","children","iconAfter","value","buttonContextValue"],"mappings":";AAAA,0BAA0B,GAC1B,iDAAiD,GACjD,SAASA,WAAW,QAAQ,4BAA4B;AAGxD,SAASC,qBAAqB,QAAQ,yBAAyB;AAE/D;;;;;CAKC,GACD,OAAO,MAAMC,gCAAgC,CAACC;IAC5CH,YAAiCG;IAEjC,MAAMC,gCACJ;;YACGD,MAAME,OAAO,kBAAI,KAACF,MAAME,OAAO;YAC/BF,MAAMG,KAAK,kBAAI,KAACH,MAAMG,KAAK;;;IAIhC,qBACE,MAACH,MAAMI,IAAI;;YACRJ,MAAMK,UAAU,kBAAI,KAACL,MAAMK,UAAU;YACrCL,MAAMM,QAAQ,kBAAI,KAACN,MAAMM,QAAQ;YACjCN,MAAMO,UAAU,kBAAI,KAACP,MAAMO,UAAU;0BACtC,KAACP,MAAMQ,IAAI;0BAAER,MAAMI,IAAI,CAACK,QAAQ;;YAC/BT,MAAMU,SAAS,kBAAI,KAACV,MAAMU,SAAS;YACnC,wBAAwBV,sBACvB,KAACF;gBAAsBa,OAAOX,MAAMY,kBAAkB;0BAAGX;iBAEzDA;;;AAIR,EAAE"}
@@ -1,12 +1,13 @@
1
1
  'use client';
2
2
  import * as React from "react";
3
- import { getIntrinsicElementProps, isResolvedShorthand, useMergedRefs, slot, useEventCallback, elementContains, useControllableState, useId } from "@fluentui/react-utilities";
3
+ import { getIntrinsicElementProps, isResolvedShorthand, useMergedRefs, slot, useEventCallback, elementContains, useControllableState, useId, useIsomorphicLayoutEffect } from "@fluentui/react-utilities";
4
4
  import { useTreeItemContext_unstable, useTreeContext_unstable } from "../../contexts/index.js";
5
5
  import { Checkbox } from "@fluentui/react-checkbox";
6
6
  import { Radio } from "@fluentui/react-radio";
7
7
  import { TreeItemChevron } from "../TreeItemChevron.js";
8
8
  import { useArrowNavigationGroup, useIsNavigatingWithKeyboard } from "@fluentui/react-tabster";
9
9
  import { useFluent_unstable as useFluent } from "@fluentui/react-shared-contexts";
10
+ import { registerTreeItemActions } from "../../utils/queryTreeItemActions.js";
10
11
  /**
11
12
  * Create the state required to render TreeItemLayout.
12
13
  *
@@ -16,13 +17,100 @@ import { useFluent_unstable as useFluent } from "@fluentui/react-shared-contexts
16
17
  * @param props - props from this instance of TreeItemLayout
17
18
  * @param ref - reference to root HTMLElement of TreeItemLayout
18
19
  */ export const useTreeItemLayout_unstable = (props, ref)=>{
19
- const { main, iconAfter, iconBefore } = props;
20
- const layoutRef = useTreeItemContext_unstable((ctx)=>ctx.layoutRef);
20
+ const { selector: selectorProp, ...baseProps } = props;
21
+ const isNavigatingWithKeyboard = useIsNavigatingWithKeyboard();
22
+ const { targetDocument } = useFluent();
23
+ const state = useTreeItemLayoutBase(// The base hook only needs to know whether the consumer provided or disabled the selector,
24
+ // the Fluent selector itself is resolved below.
25
+ {
26
+ ...baseProps,
27
+ selector: selectorProp === undefined || selectorProp === null ? selectorProp : {}
28
+ }, ref, targetDocument, isNavigatingWithKeyboard);
21
29
  const selectionMode = useTreeContext_unstable((ctx)=>ctx.selectionMode);
22
30
  const navigationMode = useTreeContext_unstable((ctx)=>{
23
31
  var _ctx_navigationMode;
24
32
  return (_ctx_navigationMode = ctx.navigationMode) !== null && _ctx_navigationMode !== void 0 ? _ctx_navigationMode : 'tree';
25
33
  });
34
+ const selectionRef = useTreeItemContext_unstable((ctx)=>ctx.selectionRef);
35
+ const checked = useTreeItemContext_unstable((ctx)=>ctx.checked);
36
+ const expandIconRef = useTreeItemContext_unstable((ctx)=>ctx.expandIconRef);
37
+ // Link the selector to the main content unless the consumer provided an accessible name
38
+ const selectorShorthand = isResolvedShorthand(selectorProp) ? selectorProp : undefined;
39
+ const selectorAriaLabelledBy = (selectorShorthand === null || selectorShorthand === void 0 ? void 0 : selectorShorthand['aria-label']) || (selectorShorthand === null || selectorShorthand === void 0 ? void 0 : selectorShorthand['aria-labelledby']) ? undefined : state.main.id;
40
+ const selector = slot.optional(selectorProp, {
41
+ renderByDefault: selectionMode !== 'none',
42
+ defaultProps: {
43
+ checked,
44
+ tabIndex: -1,
45
+ ref: selectionRef,
46
+ 'aria-labelledby': selectorAriaLabelledBy
47
+ },
48
+ elementType: selectionMode === 'multiselect' ? Checkbox : Radio
49
+ });
50
+ // Checkbox and Radio slot props omit `ref` from their type, but consumers can still provide it.
51
+ const selectorConsumerRef = selector && selector.ref;
52
+ const selectorRef = useMergedRefs(selectorConsumerRef, selectionRef);
53
+ const selectorWithRef = selector && {
54
+ ...selector,
55
+ ref: selectorRef
56
+ };
57
+ const arrowNavigationProps = useArrowNavigationGroup({
58
+ circular: navigationMode === 'tree',
59
+ axis: 'horizontal'
60
+ });
61
+ const expandIcon = state.expandIcon ? slot.optional(props.expandIcon, {
62
+ renderByDefault: true,
63
+ defaultProps: {
64
+ 'aria-hidden': true,
65
+ children: /*#__PURE__*/ React.createElement(TreeItemChevron, null),
66
+ ref: expandIconRef
67
+ },
68
+ elementType: 'div'
69
+ }) : undefined;
70
+ const expandIconRefWithConsumer = useMergedRefs(expandIcon === null || expandIcon === void 0 ? void 0 : expandIcon.ref, expandIconRef);
71
+ const expandIconWithRef = expandIcon && {
72
+ ...expandIcon,
73
+ ref: expandIconRefWithConsumer
74
+ };
75
+ return {
76
+ ...state,
77
+ components: {
78
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
79
+ ...state.components,
80
+ // Casting here to a union between checkbox and radio
81
+ selector: selectionMode === 'multiselect' ? Checkbox : Radio
82
+ },
83
+ buttonContextValue: {
84
+ size: 'small'
85
+ },
86
+ // Consumer props keep winning over the navigation attributes, matching the base slot ordering.
87
+ actions: state.actions && {
88
+ ...arrowNavigationProps,
89
+ ...state.actions
90
+ },
91
+ expandIcon: expandIconWithRef,
92
+ selector: selectorWithRef
93
+ };
94
+ };
95
+ /**
96
+ * Base state hook for TreeItemLayout, free of any focus management runtime and of the Fluent
97
+ * components used for the selector, the expand icon and the actions.
98
+ *
99
+ * The selector slot is rendered as a native `input`, of type `checkbox` in multiselect mode and
100
+ * `radio` in single selection mode, the expand icon has no default content, and the Tabster driven
101
+ * arrow key navigation of the actions is layered on by the wrapping `useTreeItemLayout_unstable` hook.
102
+ *
103
+ * @param props - props from this instance of TreeItemLayout
104
+ * @param ref - reference to root HTMLElement of TreeItemLayout
105
+ */ export const useTreeItemLayoutBase_unstable = (props, ref)=>{
106
+ const { targetDocument } = useFluent();
107
+ const isNavigatingWithKeyboard = useDOMKeyboardNavigation(targetDocument, Boolean(props.actions));
108
+ return useTreeItemLayoutBase(props, ref, targetDocument, isNavigatingWithKeyboard);
109
+ };
110
+ function useTreeItemLayoutBase(props, ref, targetDocument, isNavigatingWithKeyboard) {
111
+ const { main, iconAfter, iconBefore } = props;
112
+ const layoutRef = useTreeItemContext_unstable((ctx)=>ctx.layoutRef);
113
+ const selectionMode = useTreeContext_unstable((ctx)=>ctx.selectionMode);
26
114
  const [isActionsVisibleFromProps, onActionVisibilityChange] = isResolvedShorthand(props.actions) ? [
27
115
  props.actions.visible,
28
116
  props.actions.onVisibilityChange
@@ -47,16 +135,37 @@ import { useFluent_unstable as useFluent } from "@fluentui/react-shared-contexts
47
135
  // Link the selector to the main content unless the consumer provided an accessible name
48
136
  const selectorShorthand = isResolvedShorthand(props.selector) ? props.selector : undefined;
49
137
  const selectorAriaLabelledBy = (selectorShorthand === null || selectorShorthand === void 0 ? void 0 : selectorShorthand['aria-label']) || (selectorShorthand === null || selectorShorthand === void 0 ? void 0 : selectorShorthand['aria-labelledby']) ? undefined : mainContentId;
50
- const selector = slot.optional(props.selector, {
138
+ // The mixed state of a native checkbox can only be set through its `indeterminate` DOM property.
139
+ const selectorInputRef = React.useRef(null);
140
+ useIsomorphicLayoutEffect(()=>{
141
+ if (selectorInputRef.current) {
142
+ selectorInputRef.current.indeterminate = checked === 'mixed';
143
+ }
144
+ });
145
+ const selectorSlot = slot.optional(props.selector, {
51
146
  renderByDefault: selectionMode !== 'none',
52
147
  defaultProps: {
53
- checked,
148
+ type: selectionMode === 'multiselect' ? 'checkbox' : 'radio',
149
+ checked: checked === true,
54
150
  tabIndex: -1,
55
- ref: selectionRef,
56
- 'aria-labelledby': selectorAriaLabelledBy
151
+ 'aria-labelledby': selectorAriaLabelledBy,
152
+ // Changes bubble up to the tree item, which owns the selection state.
153
+ onChange: noop
57
154
  },
58
- elementType: selectionMode === 'multiselect' ? Checkbox : Radio
155
+ elementType: 'input'
59
156
  });
157
+ const selectorRef = useMergedRefs(selectorSlot === null || selectorSlot === void 0 ? void 0 : selectorSlot.ref, selectionRef, selectorInputRef);
158
+ // Clicking a native checkbox clears `indeterminate`, which no commit restores if the change is rejected
159
+ const handleSelectorChange = useEventCallback((event)=>{
160
+ var _selectorSlot_onChange;
161
+ selectorSlot === null || selectorSlot === void 0 ? void 0 : (_selectorSlot_onChange = selectorSlot.onChange) === null || _selectorSlot_onChange === void 0 ? void 0 : _selectorSlot_onChange.call(selectorSlot, event);
162
+ event.currentTarget.indeterminate = checked === 'mixed';
163
+ });
164
+ const selector = selectorSlot && {
165
+ ...selectorSlot,
166
+ ref: selectorRef,
167
+ onChange: handleSelectorChange
168
+ };
60
169
  const mainSlot = slot.always(main, {
61
170
  defaultProps: {
62
171
  id: selector ? mainContentId : undefined
@@ -87,8 +196,7 @@ import { useFluent_unstable as useFluent } from "@fluentui/react-shared-contexts
87
196
  setIsActionsVisible,
88
197
  onActionVisibilityChange
89
198
  ]);
90
- const { targetDocument } = useFluent();
91
- const isNavigatingWithKeyboard = useIsNavigatingWithKeyboard();
199
+ const hasActions = Boolean(props.actions);
92
200
  const setActionsInvisibleIfNotFromSubtree = React.useCallback((event)=>{
93
201
  const isRelatedTargetFromActions = ()=>Boolean(actionsRefInternal.current && elementContains(actionsRefInternal.current, event.relatedTarget));
94
202
  const isRelatedTargetFromTreeItem = ()=>Boolean(treeItemRef.current && elementContains(treeItemRef.current, event.relatedTarget));
@@ -133,20 +241,18 @@ import { useFluent_unstable as useFluent } from "@fluentui/react-shared-contexts
133
241
  isNavigatingWithKeyboard,
134
242
  targetDocument
135
243
  ]);
136
- const expandIconRefs = useMergedRefs(expandIconRef);
137
- const expandIcon = slot.optional(props.expandIcon, {
244
+ const expandIconSlot = slot.optional(props.expandIcon, {
138
245
  renderByDefault: isBranch,
139
246
  defaultProps: {
140
- children: /*#__PURE__*/ React.createElement(TreeItemChevron, null),
141
- 'aria-hidden': true,
142
- ref: expandIconRefs
247
+ 'aria-hidden': true
143
248
  },
144
249
  elementType: 'div'
145
250
  });
146
- const arrowNavigationProps = useArrowNavigationGroup({
147
- circular: navigationMode === 'tree',
148
- axis: 'horizontal'
149
- });
251
+ const expandIconRefs = useMergedRefs(expandIconSlot === null || expandIconSlot === void 0 ? void 0 : expandIconSlot.ref, expandIconRef);
252
+ const expandIcon = expandIconSlot && {
253
+ ...expandIconSlot,
254
+ ref: expandIconRefs
255
+ };
150
256
  const handleActionsBlur = useEventCallback((event)=>{
151
257
  if (isResolvedShorthand(props.actions)) {
152
258
  var _props_actions_onBlur, _props_actions;
@@ -160,17 +266,24 @@ import { useFluent_unstable as useFluent } from "@fluentui/react-shared-contexts
160
266
  });
161
267
  setIsActionsVisible(isRelatedTargetFromActions);
162
268
  });
163
- const actionsRefs = useMergedRefs(actionsRef, actionsRefInternal);
164
- const actions = isActionsVisible ? slot.optional(props.actions, {
269
+ const actionsSlot = isActionsVisible ? slot.optional(props.actions, {
165
270
  defaultProps: {
166
- ...arrowNavigationProps,
167
271
  role: 'toolbar',
168
- ref: actionsRefs,
169
272
  onBlur: handleActionsBlur
170
273
  },
171
274
  elementType: 'div'
172
275
  }) : undefined;
173
- const hasActions = Boolean(props.actions);
276
+ // The internal refs are merged after slot resolution, so that a consumer provided ref does not override them
277
+ const actionsRefs = useMergedRefs(actionsSlot === null || actionsSlot === void 0 ? void 0 : actionsSlot.ref, actionsRef, actionsRefInternal, registerTreeItemActions);
278
+ const actions = actionsSlot && {
279
+ ...actionsSlot,
280
+ ref: actionsRefs
281
+ };
282
+ if (actions) {
283
+ // .visible .onVisibilityChange are consumed above and should not be propagated to the DOM
284
+ delete actions.visible;
285
+ delete actions.onVisibilityChange;
286
+ }
174
287
  React.useEffect(()=>{
175
288
  if (treeItemRef.current && hasActions) {
176
289
  const treeItemElement = treeItemRef.current;
@@ -204,11 +317,7 @@ import { useFluent_unstable as useFluent } from "@fluentui/react-shared-contexts
204
317
  iconAfter: 'div',
205
318
  actions: 'div',
206
319
  aside: 'div',
207
- // Casting here to a union between checkbox and radio
208
- selector: selectionMode === 'multiselect' ? Checkbox : Radio
209
- },
210
- buttonContextValue: {
211
- size: 'small'
320
+ selector: 'input'
212
321
  },
213
322
  root: slot.always(getIntrinsicElementProps('div', {
214
323
  ...props,
@@ -233,7 +342,69 @@ import { useFluent_unstable as useFluent } from "@fluentui/react-shared-contexts
233
342
  expandIcon,
234
343
  selector
235
344
  };
236
- };
345
+ }
346
+ /**
347
+ * Keyboard modality trackers shared by every base layout of a document, so that the number of
348
+ * document listeners does not grow with the number of mounted tree items.
349
+ */ const domKeyboardNavigationTrackers = new WeakMap();
350
+ // Only pointer activation switches the modality, so that hovering does not discard keyboard focus
351
+ const DOM_POINTER_EVENTS = [
352
+ 'pointerdown',
353
+ 'mousedown',
354
+ 'touchstart'
355
+ ];
356
+ function subscribeToDOMKeyboardNavigation(targetDocument) {
357
+ let tracker = domKeyboardNavigationTrackers.get(targetDocument);
358
+ if (!tracker) {
359
+ const onKeyDown = ()=>{
360
+ state.isNavigatingWithKeyboard = true;
361
+ };
362
+ const onPointerInteraction = ()=>{
363
+ state.isNavigatingWithKeyboard = false;
364
+ };
365
+ const state = {
366
+ isNavigatingWithKeyboard: false,
367
+ subscribers: 0,
368
+ dispose: ()=>{
369
+ targetDocument.removeEventListener('keydown', onKeyDown, true);
370
+ DOM_POINTER_EVENTS.forEach((type)=>targetDocument.removeEventListener(type, onPointerInteraction, true));
371
+ domKeyboardNavigationTrackers.delete(targetDocument);
372
+ }
373
+ };
374
+ targetDocument.addEventListener('keydown', onKeyDown, true);
375
+ DOM_POINTER_EVENTS.forEach((type)=>targetDocument.addEventListener(type, onPointerInteraction, true));
376
+ domKeyboardNavigationTrackers.set(targetDocument, state);
377
+ tracker = state;
378
+ }
379
+ tracker.subscribers++;
380
+ return tracker;
381
+ }
382
+ function useDOMKeyboardNavigation(targetDocument, enabled) {
383
+ const trackerRef = React.useRef(null);
384
+ React.useEffect(()=>{
385
+ if (!targetDocument || !enabled) {
386
+ return;
387
+ }
388
+ const tracker = subscribeToDOMKeyboardNavigation(targetDocument);
389
+ trackerRef.current = tracker;
390
+ return ()=>{
391
+ trackerRef.current = null;
392
+ if (--tracker.subscribers === 0) {
393
+ tracker.dispose();
394
+ }
395
+ };
396
+ }, [
397
+ targetDocument,
398
+ enabled
399
+ ]);
400
+ return React.useCallback(()=>{
401
+ var _ref;
402
+ var _trackerRef_current;
403
+ return (_ref = (_trackerRef_current = trackerRef.current) === null || _trackerRef_current === void 0 ? void 0 : _trackerRef_current.isNavigatingWithKeyboard) !== null && _ref !== void 0 ? _ref : false;
404
+ }, []);
405
+ }
406
+ function noop() {
407
+ /* noop */ }
237
408
  function assertIsRefObject(ref) {
238
409
  if (process.env.NODE_ENV !== 'production') {
239
410
  if (typeof ref !== 'object' || ref === null || !('current' in ref)) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/TreeItemLayout/useTreeItemLayout.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport {\n getIntrinsicElementProps,\n isResolvedShorthand,\n useMergedRefs,\n slot,\n useEventCallback,\n elementContains,\n useControllableState,\n useId,\n} from '@fluentui/react-utilities';\nimport { useTreeItemContext_unstable, useTreeContext_unstable } from '../../contexts';\nimport type {\n TreeItemLayoutActionSlotProps,\n TreeItemLayoutActionVisibilityChangeData,\n TreeItemLayoutProps,\n TreeItemLayoutState,\n} from './TreeItemLayout.types';\nimport type { CheckboxProps } from '@fluentui/react-checkbox';\nimport { Checkbox } from '@fluentui/react-checkbox';\nimport type { RadioProps } from '@fluentui/react-radio';\nimport { Radio } from '@fluentui/react-radio';\nimport { TreeItemChevron } from '../TreeItemChevron';\nimport { useArrowNavigationGroup, useIsNavigatingWithKeyboard } from '@fluentui/react-tabster';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\n\n/**\n * Create the state required to render TreeItemLayout.\n *\n * The returned state can be modified with hooks such as useTreeItemLayoutStyles_unstable,\n * before being passed to renderTreeItemLayout_unstable.\n *\n * @param props - props from this instance of TreeItemLayout\n * @param ref - reference to root HTMLElement of TreeItemLayout\n */\nexport const useTreeItemLayout_unstable = (\n props: TreeItemLayoutProps,\n ref: React.Ref<HTMLElement>,\n): TreeItemLayoutState => {\n const { main, iconAfter, iconBefore } = props;\n\n const layoutRef = useTreeItemContext_unstable(ctx => ctx.layoutRef);\n const selectionMode = useTreeContext_unstable(ctx => ctx.selectionMode);\n const navigationMode = useTreeContext_unstable(ctx => ctx.navigationMode ?? 'tree');\n\n const [isActionsVisibleFromProps, onActionVisibilityChange]: [\n TreeItemLayoutActionSlotProps['visible'],\n TreeItemLayoutActionSlotProps['onVisibilityChange'],\n ] = isResolvedShorthand(props.actions)\n ? // .visible .onVisibilityChange prop should not be propagated to the DOM\n [props.actions.visible, props.actions.onVisibilityChange]\n : [undefined, undefined];\n\n const [isActionsVisible, setIsActionsVisible] = useControllableState({\n state: isActionsVisibleFromProps,\n initialState: false,\n });\n\n const selectionRef = useTreeItemContext_unstable(ctx => ctx.selectionRef);\n const expandIconRef = useTreeItemContext_unstable(ctx => ctx.expandIconRef);\n const actionsRef = useTreeItemContext_unstable(ctx => ctx.actionsRef);\n const actionsRefInternal = React.useRef<HTMLDivElement>(null);\n const treeItemRef = useTreeItemContext_unstable(ctx => ctx.treeItemRef);\n const subtreeRef = useTreeItemContext_unstable(ctx => ctx.subtreeRef);\n const checked = useTreeItemContext_unstable(ctx => ctx.checked);\n const isBranch = useTreeItemContext_unstable(ctx => ctx.itemType === 'branch');\n\n const mainShorthand = isResolvedShorthand(main) ? main : undefined;\n const mainContentId = useId('fui-TreeItemLayout__main-', mainShorthand?.id);\n\n // Link the selector to the main content unless the consumer provided an accessible name\n const selectorShorthand = isResolvedShorthand(props.selector) ? props.selector : undefined;\n const selectorAriaLabelledBy =\n selectorShorthand?.['aria-label'] || selectorShorthand?.['aria-labelledby'] ? undefined : mainContentId;\n\n const selector = slot.optional(props.selector, {\n renderByDefault: selectionMode !== 'none',\n defaultProps: {\n checked,\n tabIndex: -1,\n ref: selectionRef,\n 'aria-labelledby': selectorAriaLabelledBy,\n // casting here to a union between checkbox and radio\n // since ref is not present on the selector signature\n // FIXME: look into Slot type to see if we can make this work\n } as CheckboxProps | RadioProps,\n elementType: (selectionMode === 'multiselect' ? Checkbox : Radio) as React.ElementType<CheckboxProps | RadioProps>,\n });\n const mainSlot = slot.always(main, {\n defaultProps: { id: selector ? mainContentId : undefined },\n elementType: 'div',\n });\n\n // FIXME: Asserting is required here, as converting this to RefObject on context type would be a breaking change\n // eslint-disable-next-line react-hooks/refs\n assertIsRefObject(treeItemRef);\n // FIXME: Asserting is required here, as converting this to RefObject on context type would be a breaking change\n // eslint-disable-next-line react-hooks/refs\n assertIsRefObject(subtreeRef);\n\n const setActionsVisibleIfNotFromSubtree = React.useCallback(\n (event: MouseEvent | FocusEvent) => {\n const isTargetFromSubtree = Boolean(\n subtreeRef.current && elementContains(subtreeRef.current, event.target as Node),\n );\n if (!isTargetFromSubtree) {\n onActionVisibilityChange?.(event, {\n visible: true,\n event,\n type: event.type,\n } as Extract<TreeItemLayoutActionVisibilityChangeData, { event: typeof event }>);\n if (event.defaultPrevented) {\n return;\n }\n setIsActionsVisible(true);\n }\n },\n [subtreeRef, setIsActionsVisible, onActionVisibilityChange],\n );\n\n const { targetDocument } = useFluent();\n const isNavigatingWithKeyboard = useIsNavigatingWithKeyboard();\n\n const setActionsInvisibleIfNotFromSubtree = React.useCallback(\n (event: FocusEvent | MouseEvent) => {\n const isRelatedTargetFromActions = () =>\n Boolean(actionsRefInternal.current && elementContains(actionsRefInternal.current, event.relatedTarget as Node));\n const isRelatedTargetFromTreeItem = () =>\n Boolean(treeItemRef.current && elementContains(treeItemRef.current, event.relatedTarget as Node));\n const isTargetFromActions = () => Boolean(actionsRefInternal.current?.contains(event.target as Node));\n if (isRelatedTargetFromActions()) {\n onActionVisibilityChange?.(event, {\n visible: true,\n event,\n type: event.type,\n } as Extract<TreeItemLayoutActionVisibilityChangeData, { event: typeof event }>);\n if (event.defaultPrevented) {\n return;\n }\n setIsActionsVisible(true);\n return;\n }\n if (isTargetFromActions() && isRelatedTargetFromTreeItem()) {\n return;\n }\n // when a mouseout event happens during keyboard interaction\n // we should not hide the actions if the activeElement is the treeitem or an action\n // as the focus on the treeitem takes precedence over the mouseout event\n if (\n event.type === 'mouseout' &&\n isNavigatingWithKeyboard() &&\n (targetDocument?.activeElement === treeItemRef.current ||\n elementContains(actionsRefInternal.current, targetDocument?.activeElement as Node))\n ) {\n return;\n }\n onActionVisibilityChange?.(event, {\n visible: false,\n event,\n type: event.type,\n } as Extract<TreeItemLayoutActionVisibilityChangeData, { event: typeof event }>);\n if (event.defaultPrevented) {\n return;\n }\n setIsActionsVisible(false);\n },\n [setIsActionsVisible, onActionVisibilityChange, treeItemRef, isNavigatingWithKeyboard, targetDocument],\n );\n\n const expandIconRefs = useMergedRefs(expandIconRef);\n const expandIcon = slot.optional(props.expandIcon, {\n renderByDefault: isBranch,\n defaultProps: {\n children: <TreeItemChevron />,\n 'aria-hidden': true,\n ref: expandIconRefs,\n },\n elementType: 'div',\n });\n const arrowNavigationProps = useArrowNavigationGroup({ circular: navigationMode === 'tree', axis: 'horizontal' });\n\n const handleActionsBlur = useEventCallback((event: React.FocusEvent<HTMLDivElement>) => {\n if (isResolvedShorthand(props.actions)) {\n props.actions.onBlur?.(event);\n }\n const isRelatedTargetFromActions = Boolean(elementContains(event.currentTarget, event.relatedTarget as Node));\n onActionVisibilityChange?.(event, {\n visible: isRelatedTargetFromActions,\n event,\n type: event.type,\n } as Extract<TreeItemLayoutActionVisibilityChangeData, { event: typeof event }>);\n setIsActionsVisible(isRelatedTargetFromActions);\n });\n\n const actionsRefs = useMergedRefs(actionsRef, actionsRefInternal);\n const actions = isActionsVisible\n ? slot.optional(props.actions, {\n defaultProps: {\n ...arrowNavigationProps,\n role: 'toolbar',\n ref: actionsRefs,\n onBlur: handleActionsBlur,\n },\n elementType: 'div',\n })\n : undefined;\n\n const hasActions = Boolean(props.actions);\n\n React.useEffect(() => {\n if (treeItemRef.current && hasActions) {\n const treeItemElement = treeItemRef.current;\n\n const handleMouseOver = setActionsVisibleIfNotFromSubtree;\n const handleMouseOut = setActionsInvisibleIfNotFromSubtree;\n const handleFocus = setActionsVisibleIfNotFromSubtree;\n const handleBlur = setActionsInvisibleIfNotFromSubtree;\n\n treeItemElement.addEventListener('mouseover', handleMouseOver);\n treeItemElement.addEventListener('mouseout', handleMouseOut);\n treeItemElement.addEventListener('focus', handleFocus);\n treeItemElement.addEventListener('blur', handleBlur);\n\n return () => {\n treeItemElement.removeEventListener('mouseover', handleMouseOver);\n treeItemElement.removeEventListener('mouseout', handleMouseOut);\n treeItemElement.removeEventListener('focus', handleFocus);\n treeItemElement.removeEventListener('blur', handleBlur);\n };\n }\n }, [hasActions, treeItemRef, setActionsVisibleIfNotFromSubtree, setActionsInvisibleIfNotFromSubtree]);\n\n return {\n components: {\n root: 'div',\n expandIcon: 'div',\n iconBefore: 'div',\n main: 'div',\n iconAfter: 'div',\n actions: 'div',\n aside: 'div',\n // Casting here to a union between checkbox and radio\n selector: (selectionMode === 'multiselect' ? Checkbox : Radio) as React.ElementType<CheckboxProps | RadioProps>,\n },\n buttonContextValue: { size: 'small' },\n root: slot.always(\n getIntrinsicElementProps('div', {\n ...props,\n // FIXME:\n // `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLDivElement`\n // but since it would be a breaking change to fix it, we are casting ref to it's proper type\n ref: useMergedRefs(ref, layoutRef) as React.Ref<HTMLDivElement>,\n }),\n {\n elementType: 'div',\n },\n ),\n iconBefore: slot.optional(iconBefore, { elementType: 'div' }),\n main: mainSlot,\n iconAfter: slot.optional(iconAfter, { elementType: 'div' }),\n aside: !isActionsVisible ? slot.optional(props.aside, { elementType: 'div' }) : undefined,\n actions,\n expandIcon,\n selector,\n };\n};\n\nfunction assertIsRefObject<Value>(ref?: React.Ref<Value>): asserts ref is React.RefObject<Value> {\n if (process.env.NODE_ENV !== 'production') {\n if (typeof ref !== 'object' || ref === null || !('current' in ref)) {\n throw new Error(`\n @fluentui/react-tree [${useTreeItemLayout_unstable.name}]:\n Internal Error: contextual ref is not a RefObject! Please report this bug immediately, as contextual refs should be RefObjects.\n `);\n }\n }\n}\n"],"names":["React","getIntrinsicElementProps","isResolvedShorthand","useMergedRefs","slot","useEventCallback","elementContains","useControllableState","useId","useTreeItemContext_unstable","useTreeContext_unstable","Checkbox","Radio","TreeItemChevron","useArrowNavigationGroup","useIsNavigatingWithKeyboard","useFluent_unstable","useFluent","useTreeItemLayout_unstable","props","ref","main","iconAfter","iconBefore","layoutRef","ctx","selectionMode","navigationMode","isActionsVisibleFromProps","onActionVisibilityChange","actions","visible","onVisibilityChange","undefined","isActionsVisible","setIsActionsVisible","state","initialState","selectionRef","expandIconRef","actionsRef","actionsRefInternal","useRef","treeItemRef","subtreeRef","checked","isBranch","itemType","mainShorthand","mainContentId","id","selectorShorthand","selector","selectorAriaLabelledBy","optional","renderByDefault","defaultProps","tabIndex","elementType","mainSlot","always","assertIsRefObject","setActionsVisibleIfNotFromSubtree","useCallback","event","isTargetFromSubtree","Boolean","current","target","type","defaultPrevented","targetDocument","isNavigatingWithKeyboard","setActionsInvisibleIfNotFromSubtree","isRelatedTargetFromActions","relatedTarget","isRelatedTargetFromTreeItem","isTargetFromActions","contains","activeElement","expandIconRefs","expandIcon","children","arrowNavigationProps","circular","axis","handleActionsBlur","onBlur","currentTarget","actionsRefs","role","hasActions","useEffect","treeItemElement","handleMouseOver","handleMouseOut","handleFocus","handleBlur","addEventListener","removeEventListener","components","root","aside","buttonContextValue","size","process","env","NODE_ENV","Error","name"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ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AQ,YAAYA,QAAQ,QAAQ,CAAE,CAAA,aAAaA,GAAE,GAAI;YAClE,MAAM,IAAIwF,MAAM,CAAC;8BACO,EAAE1F,2BAA2B2F,IAAI,CAAC;;MAE1D,CAAC;QACH;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/components/TreeItemLayout/useTreeItemLayout.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport {\n getIntrinsicElementProps,\n isResolvedShorthand,\n useMergedRefs,\n slot,\n useEventCallback,\n elementContains,\n useControllableState,\n useId,\n useIsomorphicLayoutEffect,\n} from '@fluentui/react-utilities';\nimport { useTreeItemContext_unstable, useTreeContext_unstable } from '../../contexts';\nimport type {\n TreeItemLayoutActionSlotProps,\n TreeItemLayoutActionVisibilityChangeData,\n TreeItemLayoutBaseProps,\n TreeItemLayoutBaseState,\n TreeItemLayoutProps,\n TreeItemLayoutState,\n} from './TreeItemLayout.types';\nimport type { CheckboxProps } from '@fluentui/react-checkbox';\nimport { Checkbox } from '@fluentui/react-checkbox';\nimport type { RadioProps } from '@fluentui/react-radio';\nimport { Radio } from '@fluentui/react-radio';\nimport { TreeItemChevron } from '../TreeItemChevron';\nimport { useArrowNavigationGroup, useIsNavigatingWithKeyboard } from '@fluentui/react-tabster';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { registerTreeItemActions } from '../../utils/queryTreeItemActions';\n\n/**\n * Create the state required to render TreeItemLayout.\n *\n * The returned state can be modified with hooks such as useTreeItemLayoutStyles_unstable,\n * before being passed to renderTreeItemLayout_unstable.\n *\n * @param props - props from this instance of TreeItemLayout\n * @param ref - reference to root HTMLElement of TreeItemLayout\n */\nexport const useTreeItemLayout_unstable = (\n props: TreeItemLayoutProps,\n ref: React.Ref<HTMLElement>,\n): TreeItemLayoutState => {\n const { selector: selectorProp, ...baseProps } = props;\n const isNavigatingWithKeyboard = useIsNavigatingWithKeyboard();\n const { targetDocument } = useFluent();\n const state = useTreeItemLayoutBase(\n // The base hook only needs to know whether the consumer provided or disabled the selector,\n // the Fluent selector itself is resolved below.\n { ...baseProps, selector: selectorProp === undefined || selectorProp === null ? selectorProp : {} },\n ref,\n targetDocument,\n isNavigatingWithKeyboard,\n );\n\n const selectionMode = useTreeContext_unstable(ctx => ctx.selectionMode);\n const navigationMode = useTreeContext_unstable(ctx => ctx.navigationMode ?? 'tree');\n const selectionRef = useTreeItemContext_unstable(ctx => ctx.selectionRef);\n const checked = useTreeItemContext_unstable(ctx => ctx.checked);\n const expandIconRef = useTreeItemContext_unstable(ctx => ctx.expandIconRef);\n\n // Link the selector to the main content unless the consumer provided an accessible name\n const selectorShorthand = isResolvedShorthand(selectorProp) ? selectorProp : undefined;\n const selectorAriaLabelledBy =\n selectorShorthand?.['aria-label'] || selectorShorthand?.['aria-labelledby'] ? undefined : state.main.id;\n\n const selector = slot.optional(selectorProp, {\n renderByDefault: selectionMode !== 'none',\n defaultProps: {\n checked,\n tabIndex: -1,\n ref: selectionRef,\n 'aria-labelledby': selectorAriaLabelledBy,\n // casting here to a union between checkbox and radio\n // since ref is not present on the selector signature\n // FIXME: look into Slot type to see if we can make this work\n } as CheckboxProps | RadioProps,\n elementType: (selectionMode === 'multiselect' ? Checkbox : Radio) as React.ElementType<CheckboxProps | RadioProps>,\n });\n // Checkbox and Radio slot props omit `ref` from their type, but consumers can still provide it.\n const selectorConsumerRef = selector && (selector as typeof selector & { ref?: React.Ref<HTMLInputElement> }).ref;\n const selectorRef = useMergedRefs(selectorConsumerRef, selectionRef);\n const selectorWithRef = selector && { ...selector, ref: selectorRef };\n\n const arrowNavigationProps = useArrowNavigationGroup({ circular: navigationMode === 'tree', axis: 'horizontal' });\n const expandIcon = state.expandIcon\n ? slot.optional(props.expandIcon, {\n renderByDefault: true,\n defaultProps: {\n 'aria-hidden': true,\n children: <TreeItemChevron />,\n ref: expandIconRef,\n },\n elementType: 'div',\n })\n : undefined;\n const expandIconRefWithConsumer = useMergedRefs(expandIcon?.ref, expandIconRef);\n const expandIconWithRef = expandIcon && { ...expandIcon, ref: expandIconRefWithConsumer };\n\n return {\n ...state,\n components: {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ...state.components,\n // Casting here to a union between checkbox and radio\n selector: (selectionMode === 'multiselect' ? Checkbox : Radio) as React.ElementType<CheckboxProps | RadioProps>,\n },\n buttonContextValue: { size: 'small' },\n // Consumer props keep winning over the navigation attributes, matching the base slot ordering.\n actions: state.actions && { ...arrowNavigationProps, ...state.actions },\n expandIcon: expandIconWithRef,\n selector: selectorWithRef,\n };\n};\n\n/**\n * Base state hook for TreeItemLayout, free of any focus management runtime and of the Fluent\n * components used for the selector, the expand icon and the actions.\n *\n * The selector slot is rendered as a native `input`, of type `checkbox` in multiselect mode and\n * `radio` in single selection mode, the expand icon has no default content, and the Tabster driven\n * arrow key navigation of the actions is layered on by the wrapping `useTreeItemLayout_unstable` hook.\n *\n * @param props - props from this instance of TreeItemLayout\n * @param ref - reference to root HTMLElement of TreeItemLayout\n */\nexport const useTreeItemLayoutBase_unstable = (\n props: TreeItemLayoutBaseProps,\n ref: React.Ref<HTMLElement>,\n): TreeItemLayoutBaseState => {\n const { targetDocument } = useFluent();\n const isNavigatingWithKeyboard = useDOMKeyboardNavigation(targetDocument, Boolean(props.actions));\n\n return useTreeItemLayoutBase(props, ref, targetDocument, isNavigatingWithKeyboard);\n};\n\nfunction useTreeItemLayoutBase(\n props: TreeItemLayoutBaseProps,\n ref: React.Ref<HTMLElement>,\n targetDocument: Document | undefined,\n isNavigatingWithKeyboard: () => boolean,\n): TreeItemLayoutBaseState {\n const { main, iconAfter, iconBefore } = props;\n\n const layoutRef = useTreeItemContext_unstable(ctx => ctx.layoutRef);\n const selectionMode = useTreeContext_unstable(ctx => ctx.selectionMode);\n\n const [isActionsVisibleFromProps, onActionVisibilityChange]: [\n TreeItemLayoutActionSlotProps['visible'],\n TreeItemLayoutActionSlotProps['onVisibilityChange'],\n ] = isResolvedShorthand(props.actions)\n ? // .visible .onVisibilityChange prop should not be propagated to the DOM\n [props.actions.visible, props.actions.onVisibilityChange]\n : [undefined, undefined];\n\n const [isActionsVisible, setIsActionsVisible] = useControllableState({\n state: isActionsVisibleFromProps,\n initialState: false,\n });\n\n const selectionRef = useTreeItemContext_unstable(ctx => ctx.selectionRef);\n const expandIconRef = useTreeItemContext_unstable(ctx => ctx.expandIconRef);\n const actionsRef = useTreeItemContext_unstable(ctx => ctx.actionsRef);\n const actionsRefInternal = React.useRef<HTMLDivElement>(null);\n const treeItemRef = useTreeItemContext_unstable(ctx => ctx.treeItemRef);\n const subtreeRef = useTreeItemContext_unstable(ctx => ctx.subtreeRef);\n const checked = useTreeItemContext_unstable(ctx => ctx.checked);\n const isBranch = useTreeItemContext_unstable(ctx => ctx.itemType === 'branch');\n\n const mainShorthand = isResolvedShorthand(main) ? main : undefined;\n const mainContentId = useId('fui-TreeItemLayout__main-', mainShorthand?.id);\n\n // Link the selector to the main content unless the consumer provided an accessible name\n const selectorShorthand = isResolvedShorthand(props.selector) ? props.selector : undefined;\n const selectorAriaLabelledBy =\n selectorShorthand?.['aria-label'] || selectorShorthand?.['aria-labelledby'] ? undefined : mainContentId;\n\n // The mixed state of a native checkbox can only be set through its `indeterminate` DOM property.\n const selectorInputRef = React.useRef<HTMLInputElement>(null);\n useIsomorphicLayoutEffect(() => {\n if (selectorInputRef.current) {\n selectorInputRef.current.indeterminate = checked === 'mixed';\n }\n });\n\n const selectorSlot = slot.optional(props.selector, {\n renderByDefault: selectionMode !== 'none',\n defaultProps: {\n type: selectionMode === 'multiselect' ? 'checkbox' : 'radio',\n checked: checked === true,\n tabIndex: -1,\n 'aria-labelledby': selectorAriaLabelledBy,\n // Changes bubble up to the tree item, which owns the selection state.\n onChange: noop,\n },\n elementType: 'input',\n });\n const selectorRef = useMergedRefs(selectorSlot?.ref, selectionRef, selectorInputRef);\n // Clicking a native checkbox clears `indeterminate`, which no commit restores if the change is rejected\n const handleSelectorChange = useEventCallback((event: React.ChangeEvent<HTMLInputElement>) => {\n selectorSlot?.onChange?.(event);\n event.currentTarget.indeterminate = checked === 'mixed';\n });\n const selector = selectorSlot && { ...selectorSlot, ref: selectorRef, onChange: handleSelectorChange };\n const mainSlot = slot.always(main, {\n defaultProps: { id: selector ? mainContentId : undefined },\n elementType: 'div',\n });\n\n // FIXME: Asserting is required here, as converting this to RefObject on context type would be a breaking change\n // eslint-disable-next-line react-hooks/refs\n assertIsRefObject(treeItemRef);\n // FIXME: Asserting is required here, as converting this to RefObject on context type would be a breaking change\n // eslint-disable-next-line react-hooks/refs\n assertIsRefObject(subtreeRef);\n\n const setActionsVisibleIfNotFromSubtree = React.useCallback(\n (event: MouseEvent | FocusEvent) => {\n const isTargetFromSubtree = Boolean(\n subtreeRef.current && elementContains(subtreeRef.current, event.target as Node),\n );\n if (!isTargetFromSubtree) {\n onActionVisibilityChange?.(event, {\n visible: true,\n event,\n type: event.type,\n } as Extract<TreeItemLayoutActionVisibilityChangeData, { event: typeof event }>);\n if (event.defaultPrevented) {\n return;\n }\n setIsActionsVisible(true);\n }\n },\n [subtreeRef, setIsActionsVisible, onActionVisibilityChange],\n );\n\n const hasActions = Boolean(props.actions);\n\n const setActionsInvisibleIfNotFromSubtree = React.useCallback(\n (event: FocusEvent | MouseEvent) => {\n const isRelatedTargetFromActions = () =>\n Boolean(actionsRefInternal.current && elementContains(actionsRefInternal.current, event.relatedTarget as Node));\n const isRelatedTargetFromTreeItem = () =>\n Boolean(treeItemRef.current && elementContains(treeItemRef.current, event.relatedTarget as Node));\n const isTargetFromActions = () => Boolean(actionsRefInternal.current?.contains(event.target as Node));\n if (isRelatedTargetFromActions()) {\n onActionVisibilityChange?.(event, {\n visible: true,\n event,\n type: event.type,\n } as Extract<TreeItemLayoutActionVisibilityChangeData, { event: typeof event }>);\n if (event.defaultPrevented) {\n return;\n }\n setIsActionsVisible(true);\n return;\n }\n if (isTargetFromActions() && isRelatedTargetFromTreeItem()) {\n return;\n }\n // when a mouseout event happens during keyboard interaction\n // we should not hide the actions if the activeElement is the treeitem or an action\n // as the focus on the treeitem takes precedence over the mouseout event\n if (\n event.type === 'mouseout' &&\n isNavigatingWithKeyboard() &&\n (targetDocument?.activeElement === treeItemRef.current ||\n elementContains(actionsRefInternal.current, targetDocument?.activeElement as Node))\n ) {\n return;\n }\n onActionVisibilityChange?.(event, {\n visible: false,\n event,\n type: event.type,\n } as Extract<TreeItemLayoutActionVisibilityChangeData, { event: typeof event }>);\n if (event.defaultPrevented) {\n return;\n }\n setIsActionsVisible(false);\n },\n [setIsActionsVisible, onActionVisibilityChange, treeItemRef, isNavigatingWithKeyboard, targetDocument],\n );\n\n const expandIconSlot = slot.optional(props.expandIcon, {\n renderByDefault: isBranch,\n defaultProps: {\n 'aria-hidden': true,\n },\n elementType: 'div',\n });\n const expandIconRefs = useMergedRefs(expandIconSlot?.ref, expandIconRef);\n const expandIcon = expandIconSlot && { ...expandIconSlot, ref: expandIconRefs };\n const handleActionsBlur = useEventCallback((event: React.FocusEvent<HTMLDivElement>) => {\n if (isResolvedShorthand(props.actions)) {\n props.actions.onBlur?.(event);\n }\n const isRelatedTargetFromActions = Boolean(elementContains(event.currentTarget, event.relatedTarget as Node));\n onActionVisibilityChange?.(event, {\n visible: isRelatedTargetFromActions,\n event,\n type: event.type,\n } as Extract<TreeItemLayoutActionVisibilityChangeData, { event: typeof event }>);\n setIsActionsVisible(isRelatedTargetFromActions);\n });\n\n const actionsSlot = isActionsVisible\n ? slot.optional(props.actions, {\n defaultProps: {\n role: 'toolbar',\n onBlur: handleActionsBlur,\n },\n elementType: 'div',\n })\n : undefined;\n // The internal refs are merged after slot resolution, so that a consumer provided ref does not override them\n const actionsRefs = useMergedRefs(actionsSlot?.ref, actionsRef, actionsRefInternal, registerTreeItemActions);\n const actions = actionsSlot && { ...actionsSlot, ref: actionsRefs };\n if (actions) {\n // .visible .onVisibilityChange are consumed above and should not be propagated to the DOM\n delete actions.visible;\n delete actions.onVisibilityChange;\n }\n\n React.useEffect(() => {\n if (treeItemRef.current && hasActions) {\n const treeItemElement = treeItemRef.current;\n\n const handleMouseOver = setActionsVisibleIfNotFromSubtree;\n const handleMouseOut = setActionsInvisibleIfNotFromSubtree;\n const handleFocus = setActionsVisibleIfNotFromSubtree;\n const handleBlur = setActionsInvisibleIfNotFromSubtree;\n\n treeItemElement.addEventListener('mouseover', handleMouseOver);\n treeItemElement.addEventListener('mouseout', handleMouseOut);\n treeItemElement.addEventListener('focus', handleFocus);\n treeItemElement.addEventListener('blur', handleBlur);\n\n return () => {\n treeItemElement.removeEventListener('mouseover', handleMouseOver);\n treeItemElement.removeEventListener('mouseout', handleMouseOut);\n treeItemElement.removeEventListener('focus', handleFocus);\n treeItemElement.removeEventListener('blur', handleBlur);\n };\n }\n }, [hasActions, treeItemRef, setActionsVisibleIfNotFromSubtree, setActionsInvisibleIfNotFromSubtree]);\n\n return {\n components: {\n root: 'div',\n expandIcon: 'div',\n iconBefore: 'div',\n main: 'div',\n iconAfter: 'div',\n actions: 'div',\n aside: 'div',\n selector: 'input',\n },\n root: slot.always(\n getIntrinsicElementProps('div', {\n ...props,\n // FIXME:\n // `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLDivElement`\n // but since it would be a breaking change to fix it, we are casting ref to it's proper type\n ref: useMergedRefs(ref, layoutRef) as React.Ref<HTMLDivElement>,\n }),\n {\n elementType: 'div',\n },\n ),\n iconBefore: slot.optional(iconBefore, { elementType: 'div' }),\n main: mainSlot,\n iconAfter: slot.optional(iconAfter, { elementType: 'div' }),\n aside: !isActionsVisible ? slot.optional(props.aside, { elementType: 'div' }) : undefined,\n actions,\n expandIcon,\n selector,\n };\n}\n\ntype DOMKeyboardNavigationTracker = {\n isNavigatingWithKeyboard: boolean;\n subscribers: number;\n dispose: () => void;\n};\n\n/**\n * Keyboard modality trackers shared by every base layout of a document, so that the number of\n * document listeners does not grow with the number of mounted tree items.\n */\nconst domKeyboardNavigationTrackers = new WeakMap<Document, DOMKeyboardNavigationTracker>();\n\n// Only pointer activation switches the modality, so that hovering does not discard keyboard focus\nconst DOM_POINTER_EVENTS = ['pointerdown', 'mousedown', 'touchstart'] as const;\n\nfunction subscribeToDOMKeyboardNavigation(targetDocument: Document): DOMKeyboardNavigationTracker {\n let tracker = domKeyboardNavigationTrackers.get(targetDocument);\n if (!tracker) {\n const onKeyDown = () => {\n state.isNavigatingWithKeyboard = true;\n };\n const onPointerInteraction = () => {\n state.isNavigatingWithKeyboard = false;\n };\n const state: DOMKeyboardNavigationTracker = {\n isNavigatingWithKeyboard: false,\n subscribers: 0,\n dispose: () => {\n targetDocument.removeEventListener('keydown', onKeyDown, true);\n DOM_POINTER_EVENTS.forEach(type => targetDocument.removeEventListener(type, onPointerInteraction, true));\n domKeyboardNavigationTrackers.delete(targetDocument);\n },\n };\n\n targetDocument.addEventListener('keydown', onKeyDown, true);\n DOM_POINTER_EVENTS.forEach(type => targetDocument.addEventListener(type, onPointerInteraction, true));\n domKeyboardNavigationTrackers.set(targetDocument, state);\n tracker = state;\n }\n tracker.subscribers++;\n return tracker;\n}\n\nfunction useDOMKeyboardNavigation(targetDocument: Document | undefined, enabled: boolean): () => boolean {\n const trackerRef = React.useRef<DOMKeyboardNavigationTracker | null>(null);\n\n React.useEffect(() => {\n if (!targetDocument || !enabled) {\n return;\n }\n\n const tracker = subscribeToDOMKeyboardNavigation(targetDocument);\n trackerRef.current = tracker;\n\n return () => {\n trackerRef.current = null;\n if (--tracker.subscribers === 0) {\n tracker.dispose();\n }\n };\n }, [targetDocument, enabled]);\n\n return React.useCallback(() => trackerRef.current?.isNavigatingWithKeyboard ?? false, []);\n}\n\nfunction noop() {\n /* noop */\n}\n\nfunction assertIsRefObject<Value>(ref?: React.Ref<Value>): asserts ref is React.RefObject<Value> {\n if (process.env.NODE_ENV !== 'production') {\n if (typeof ref !== 'object' || ref === null || !('current' in ref)) {\n throw new Error(`\n @fluentui/react-tree [${useTreeItemLayout_unstable.name}]:\n Internal Error: contextual ref is not a RefObject! Please report this bug immediately, as contextual refs should be RefObjects.\n `);\n }\n }\n}\n"],"names":["React","getIntrinsicElementProps","isResolvedShorthand","useMergedRefs","slot","useEventCallback","elementContains","useControllableState","useId","useIsomorphicLayoutEffect","useTreeItemContext_unstable","useTreeContext_unstable","Checkbox","Radio","TreeItemChevron","useArrowNavigationGroup","useIsNavigatingWithKeyboard","useFluent_unstable","useFluent","registerTreeItemActions","useTreeItemLayout_unstable","props","ref","selector","selectorProp","baseProps","isNavigatingWithKeyboard","targetDocument","state","useTreeItemLayoutBase","undefined","selectionMode","ctx","navigationMode","selectionRef","checked","expandIconRef","selectorShorthand","selectorAriaLabelledBy","main","id","optional","renderByDefault","defaultProps","tabIndex","elementType","selectorConsumerRef","selectorRef","selectorWithRef","arrowNavigationProps","circular","axis","expandIcon","children","expandIconRefWithConsumer","expandIconWithRef","components","buttonContextValue","size","actions","useTreeItemLayoutBase_unstable","useDOMKeyboardNavigation","Boolean","iconAfter","iconBefore","layoutRef","isActionsVisibleFromProps","onActionVisibilityChange","visible","onVisibilityChange","isActionsVisible","setIsActionsVisible","initialState","actionsRef","actionsRefInternal","useRef","treeItemRef","subtreeRef","isBranch","itemType","mainShorthand","mainContentId","selectorInputRef","current","indeterminate","selectorSlot","type","onChange","noop","handleSelectorChange","event","currentTarget","mainSlot","always","assertIsRefObject","setActionsVisibleIfNotFromSubtree","useCallback","isTargetFromSubtree","target","defaultPrevented","hasActions","setActionsInvisibleIfNotFromSubtree","isRelatedTargetFromActions","relatedTarget","isRelatedTargetFromTreeItem","isTargetFromActions","contains","activeElement","expandIconSlot","expandIconRefs","handleActionsBlur","onBlur","actionsSlot","role","actionsRefs","useEffect","treeItemElement","handleMouseOver","handleMouseOut","handleFocus","handleBlur","addEventListener","removeEventListener","root","aside","domKeyboardNavigationTrackers","WeakMap","DOM_POINTER_EVENTS","subscribeToDOMKeyboardNavigation","tracker","get","onKeyDown","onPointerInteraction","subscribers","dispose","forEach","delete","set","enabled","trackerRef","process","env","NODE_ENV","Error","name"],"mappings":"AAAA;AAEA,YAA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