@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.
- package/CHANGELOG.md +11 -2
- package/dist/index.d.cts +83 -6
- package/dist/index.d.ts +83 -6
- package/lib/Tree.js +1 -1
- package/lib/Tree.js.map +1 -1
- package/lib/TreeItemLayout.js +1 -1
- package/lib/TreeItemLayout.js.map +1 -1
- package/lib/components/FlatTree/useFlatTree.js +28 -3
- package/lib/components/FlatTree/useFlatTree.js.map +1 -1
- package/lib/components/Tree/Tree.types.js +1 -1
- package/lib/components/Tree/Tree.types.js.map +1 -1
- package/lib/components/Tree/index.js +1 -1
- package/lib/components/Tree/index.js.map +1 -1
- package/lib/components/Tree/renderTree.js +6 -2
- package/lib/components/Tree/renderTree.js.map +1 -1
- package/lib/components/Tree/useTree.js +75 -6
- package/lib/components/Tree/useTree.js.map +1 -1
- package/lib/components/Tree/useTreeContextValues.js +4 -1
- package/lib/components/Tree/useTreeContextValues.js.map +1 -1
- package/lib/components/TreeItemLayout/TreeItemLayout.types.js +1 -1
- package/lib/components/TreeItemLayout/TreeItemLayout.types.js.map +1 -1
- package/lib/components/TreeItemLayout/index.js +1 -1
- package/lib/components/TreeItemLayout/index.js.map +1 -1
- package/lib/components/TreeItemLayout/renderTreeItemLayout.js +13 -7
- package/lib/components/TreeItemLayout/renderTreeItemLayout.js.map +1 -1
- package/lib/components/TreeItemLayout/useTreeItemLayout.js +201 -30
- package/lib/components/TreeItemLayout/useTreeItemLayout.js.map +1 -1
- package/lib/hooks/useFlatTreeNavigation.js +3 -4
- package/lib/hooks/useFlatTreeNavigation.js.map +1 -1
- package/lib/hooks/useRootTree.js +3 -8
- package/lib/hooks/useRootTree.js.map +1 -1
- package/lib/hooks/useRovingTabIndexBase.js +108 -0
- package/lib/hooks/useRovingTabIndexBase.js.map +1 -0
- package/lib/hooks/useRovingTabIndexes.js +2 -61
- package/lib/hooks/useRovingTabIndexes.js.map +1 -1
- package/lib/hooks/useSubtree.js +1 -11
- package/lib/hooks/useSubtree.js.map +1 -1
- package/lib/hooks/useTreeNavigation.js +6 -84
- package/lib/hooks/useTreeNavigation.js.map +1 -1
- package/lib/hooks/useTreeNavigationBase.js +131 -0
- package/lib/hooks/useTreeNavigationBase.js.map +1 -0
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/utils/queryTreeItemActions.js +29 -0
- package/lib/utils/queryTreeItemActions.js.map +1 -0
- package/lib-commonjs/Tree.cjs +3 -0
- package/lib-commonjs/Tree.cjs.map +1 -1
- package/lib-commonjs/TreeItemLayout.cjs +3 -0
- package/lib-commonjs/TreeItemLayout.cjs.map +1 -1
- package/lib-commonjs/components/FlatTree/useFlatTree.cjs +28 -3
- package/lib-commonjs/components/FlatTree/useFlatTree.cjs.map +1 -1
- package/lib-commonjs/components/Tree/Tree.types.cjs +1 -1
- package/lib-commonjs/components/Tree/Tree.types.cjs.map +1 -1
- package/lib-commonjs/components/Tree/index.cjs +3 -0
- package/lib-commonjs/components/Tree/index.cjs.map +1 -1
- package/lib-commonjs/components/Tree/renderTree.cjs +1 -1
- package/lib-commonjs/components/Tree/renderTree.cjs.map +1 -1
- package/lib-commonjs/components/Tree/useTree.cjs +68 -8
- package/lib-commonjs/components/Tree/useTree.cjs.map +1 -1
- package/lib-commonjs/components/Tree/useTreeContextValues.cjs +4 -1
- package/lib-commonjs/components/Tree/useTreeContextValues.cjs.map +1 -1
- package/lib-commonjs/components/TreeItemLayout/TreeItemLayout.types.cjs +1 -1
- package/lib-commonjs/components/TreeItemLayout/TreeItemLayout.types.cjs.map +1 -1
- package/lib-commonjs/components/TreeItemLayout/index.cjs +3 -0
- package/lib-commonjs/components/TreeItemLayout/index.cjs.map +1 -1
- package/lib-commonjs/components/TreeItemLayout/renderTreeItemLayout.cjs +9 -6
- package/lib-commonjs/components/TreeItemLayout/renderTreeItemLayout.cjs.map +1 -1
- package/lib-commonjs/components/TreeItemLayout/useTreeItemLayout.cjs +200 -32
- package/lib-commonjs/components/TreeItemLayout/useTreeItemLayout.cjs.map +1 -1
- package/lib-commonjs/hooks/useFlatTreeNavigation.cjs +3 -4
- package/lib-commonjs/hooks/useFlatTreeNavigation.cjs.map +1 -1
- package/lib-commonjs/hooks/useRootTree.cjs +3 -8
- package/lib-commonjs/hooks/useRootTree.cjs.map +1 -1
- package/lib-commonjs/hooks/useRovingTabIndexBase.cjs +116 -0
- package/lib-commonjs/hooks/useRovingTabIndexBase.cjs.map +1 -0
- package/lib-commonjs/hooks/useRovingTabIndexes.cjs +2 -62
- package/lib-commonjs/hooks/useRovingTabIndexes.cjs.map +1 -1
- package/lib-commonjs/hooks/useSubtree.cjs +1 -11
- package/lib-commonjs/hooks/useSubtree.cjs.map +1 -1
- package/lib-commonjs/hooks/useTreeNavigation.cjs +5 -84
- package/lib-commonjs/hooks/useTreeNavigation.cjs.map +1 -1
- package/lib-commonjs/hooks/useTreeNavigationBase.cjs +140 -0
- package/lib-commonjs/hooks/useTreeNavigationBase.cjs.map +1 -0
- package/lib-commonjs/index.cjs +6 -0
- package/lib-commonjs/index.cjs.map +1 -1
- package/lib-commonjs/utils/queryTreeItemActions.cjs +38 -0
- package/lib-commonjs/utils/queryTreeItemActions.cjs.map +1 -0
- 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;;;;;+BAeac;;;;;;;iEAbU,QAAQ;gCACiB,4BAA4B;0CAEd,0CAAuC;mDACjC,yCAAsC;gCAC3E,mCAAgC;6BACnC,6BAA0B;4BAC3B,4BAAyB;mCAClB,mCAAgC;6BAC1B,gCAA6B;8BACxC,8BAA2B;8BAC3B,8BAA2B;AAEjD,yBAAyB,CAACC,OAAkBC;IACjD,MAAMC,SAASjB,OAAMkB,UAAU,CAACX,8BAAAA,MAAoBY;IACpD,uDAAuD;IACvD,sEAAsE;IACtE,sDAAsD;IACtD,OAAOF,SAASG,kBAAkBL,OAAOC,OAAOK,iBAAiBN,OAAOC;AAC1E,EAAE;AAEF,SAASI,kBAAkBL,KAAgB,EAAEC,GAA2B;IACtE,eAAe,qGAAqG;IAEpH,MAAM,CAACM,WAAWC,aAAa,OAAGnB,kDAAAA,EAAyBW;IAC3D,MAAMS,mBAAelB,wDAAAA,EAAsBS;IAC3C,MAAMU,aAAaf,wCAAAA,EAAkBK,MAAMW,cAAc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e;QAC1C,qEAAqE;QACrE,sDAAsD;QACtD,MAAMJ,eAAWhC,oCAAAA,EAAwBqC,CAAAA,MAAOA,IAAIL,QAAQ;QAC5D,IAAIA,aAAa,QAAQ;YACvB,MAAM,IAAIM,MAA2B,CAAC;;mEAItC,CAAC;QACH;IACF;IACA,WAAOxC,sBAAAA,EAAWM,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;;;;;;;;;;;;;eAoEasC;;QAvCAlB;;;;;iEA3BU,QAAQ;gCACiB,4BAA4B;8BACnB,0BAA0B;6BAChD,yBAAyB;8CACnC,4CAA4C;0CAEP,0CAAuC;mDACjC,yCAAsC;gCAC3E,mCAAgC;6BACnC,6BAA0B;4BAC3B,4BAAyB;uCACS,uCAAoC;uCAEtD,uCAAoC;6BACvC,gCAA6B;8BACxC,8BAA2B;8BAC3B,8BAA2B;AAWjD,yBAAyB,CAACC,OAAkBC;IACjD,MAAM,EAAEC,aAAa,QAAQ,EAAEC,OAAO,QAAQ,EAAEC,cAAc,EAAE,GAAGC,WAAW,GAAGL;IACjF,uFAAuF;IACvF,MAAMM,QAAQC,gBAAgBF,WAAWJ,KAAKO;IAE9C,IAAIF,MAAMG,WAAW,KAAK,WAAW;QACnC,OAAO;YACL,GAAGH,KAAK;YACR,4DAA4D;YAC5DI,YAAY;gBAAE,GAAGJ,MAAMI,UAAU;gBAAEN,gBAAgBnB,sCAAAA;YAAS;YAC5DmB,oBAAgBpB,+BAAAA,EAAmBoB,gBAAgB;gBACjDO,aAAa1B,sCAAAA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AA2B,CAAC;;mEAItC,CAAC;QACH;IACF;IACA,WAAO7D,sBAAAA,EAAWQ,OAAOC;AAC3B"}
|
|
@@ -13,7 +13,10 @@ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildc
|
|
|
13
13
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
14
14
|
function useTreeContextValues_unstable(state) {
|
|
15
15
|
if (state.contextType === 'root') {
|
|
16
|
-
const { openItems, level, contextType, treeType, checkedItems, selectionMode, navigationMode,
|
|
16
|
+
const { openItems, level, contextType, treeType, checkedItems, selectionMode, navigationMode, requestTreeResponse, forceUpdateRovingTabIndex } = state;
|
|
17
|
+
// Base state carries no design props, the context falls back to the default design values.
|
|
18
|
+
const appearance = 'appearance' in state ? state.appearance : 'subtle';
|
|
19
|
+
const size = 'size' in state ? state.size : 'medium';
|
|
17
20
|
// contextType is statically determined by the context
|
|
18
21
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
19
22
|
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
|
|
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;;;;;+BAMgBC;;;;;;;iEAJO,QAAQ;AAIxB,uCAAuCC,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,OAAMe,OAAO,CACxB,IAAO,CAAA;gBACLT;gBACAO;gBACAT;gBACAQ;gBACAL;gBACAC;gBACAC;gBACAN;gBACAE;gBACAK;gBACAC;aACF,CAAA,EACA;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,OAAMe,OAAO,CAAC,IAAO,CAAA;gBAAEV,OAAOH,MAAMG,KAAK;gBAAEF,aAAa;aAAU,CAAA,EAAI;YAACD,MAAMG,KAAK;SAAC;IAC3F;AACF"}
|
|
@@ -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":"
|
|
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"}
|
|
@@ -18,6 +18,9 @@ _export(exports, {
|
|
|
18
18
|
get treeItemLayoutClassNames () {
|
|
19
19
|
return _useTreeItemLayoutStylesstyles.treeItemLayoutClassNames;
|
|
20
20
|
},
|
|
21
|
+
get useTreeItemLayoutBase_unstable () {
|
|
22
|
+
return _useTreeItemLayout.useTreeItemLayoutBase_unstable;
|
|
23
|
+
},
|
|
21
24
|
get useTreeItemLayoutStyles_unstable () {
|
|
22
25
|
return _useTreeItemLayoutStylesstyles.useTreeItemLayoutStyles_unstable;
|
|
23
26
|
},
|
|
@@ -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":";;;;;;;;;;;;eAASA,8BAAc;;;
|
|
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":";;;;;;;;;;;;eAASA,8BAAc;;;eAWdC,mDAA6B;;;eAE7BG,uDAAwB;;;eADxBF,iDAA8B;;;eACJG,+DAAgC;;;eAD1BF,6CAA0B;;;gCAZpC,sBAAmB;sCAWJ,4BAAyB;mCACI,yBAAsB;+CACtB,sCAAmC"}
|
|
@@ -13,6 +13,12 @@ const _reactutilities = require("@fluentui/react-utilities");
|
|
|
13
13
|
const _reactbutton = require("@fluentui/react-button");
|
|
14
14
|
const renderTreeItemLayout_unstable = (state)=>{
|
|
15
15
|
(0, _reactutilities.assertSlots)(state);
|
|
16
|
+
const actionsAndAside = /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
17
|
+
children: [
|
|
18
|
+
state.actions && /*#__PURE__*/ (0, _jsxruntime.jsx)(state.actions, {}),
|
|
19
|
+
state.aside && /*#__PURE__*/ (0, _jsxruntime.jsx)(state.aside, {})
|
|
20
|
+
]
|
|
21
|
+
});
|
|
16
22
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(state.root, {
|
|
17
23
|
children: [
|
|
18
24
|
state.expandIcon && /*#__PURE__*/ (0, _jsxruntime.jsx)(state.expandIcon, {}),
|
|
@@ -22,13 +28,10 @@ const renderTreeItemLayout_unstable = (state)=>{
|
|
|
22
28
|
children: state.root.children
|
|
23
29
|
}),
|
|
24
30
|
state.iconAfter && /*#__PURE__*/ (0, _jsxruntime.jsx)(state.iconAfter, {}),
|
|
25
|
-
/*#__PURE__*/ (0, _jsxruntime.
|
|
31
|
+
'buttonContextValue' in state ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactbutton.ButtonContextProvider, {
|
|
26
32
|
value: state.buttonContextValue,
|
|
27
|
-
children:
|
|
28
|
-
|
|
29
|
-
state.aside && /*#__PURE__*/ (0, _jsxruntime.jsx)(state.aside, {})
|
|
30
|
-
]
|
|
31
|
-
})
|
|
33
|
+
children: actionsAndAside
|
|
34
|
+
}) : actionsAndAside
|
|
32
35
|
]
|
|
33
36
|
});
|
|
34
37
|
};
|
|
@@ -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
|
|
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":";;;;+BAaaE;;;;;;;gCAZb,gDAAiD,GACjD,SAASF,WAAW,QAAQ,4BAA4B;6BAGlB,yBAAyB;AAQxD,sCAAsC,CAACG;QAC5CH,2BAAAA,EAAiCG;IAEjC,MAAMC,kBAAAA,WAAAA,OACJ,gBAAA,EAAA,oBAAA,EAAA;;YACGD,MAAME,OAAO,IAAA,WAAA,OAAI,eAAA,EAACF,MAAME,OAAO,EAAA,CAAA;YAC/BF,MAAMG,KAAK,IAAA,WAAA,OAAI,eAAA,EAACH,MAAMG,KAAK,EAAA,CAAA;;;IAIhC,OAAA,WAAA,OACE,gBAAA,EAACH,MAAMI,IAAI,EAAA;;YACRJ,MAAMK,UAAU,IAAA,WAAA,OAAI,eAAA,EAACL,MAAMK,UAAU,EAAA,CAAA;YACrCL,MAAMM,QAAQ,IAAA,WAAA,GAAI,mBAAA,EAACN,MAAMM,QAAQ,EAAA,CAAA;YACjCN,MAAMO,UAAU,IAAA,WAAA,OAAI,eAAA,EAACP,MAAMO,UAAU,EAAA,CAAA;8BACtC,eAAA,EAACP,MAAMQ,IAAI,EAAA;0BAAER,MAAMI,IAAI,CAACK,QAAQ;;YAC/BT,MAAMU,SAAS,IAAA,WAAA,OAAI,eAAA,EAACV,MAAMU,SAAS,EAAA,CAAA;YACnC,wBAAwBV,QAAAA,WAAAA,OACvB,eAAA,EAACF,kCAAAA,EAAAA;gBAAsBa,OAAOX,MAAMY,kBAAkB;0BAAGX;iBAEzDA;;;AAIR,EAAE"}
|
|
@@ -3,9 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
function _export(target, all) {
|
|
7
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
get useTreeItemLayoutBase_unstable () {
|
|
14
|
+
return useTreeItemLayoutBase_unstable;
|
|
15
|
+
},
|
|
16
|
+
get useTreeItemLayout_unstable () {
|
|
9
17
|
return useTreeItemLayout_unstable;
|
|
10
18
|
}
|
|
11
19
|
});
|
|
@@ -18,14 +26,91 @@ const _reactradio = require("@fluentui/react-radio");
|
|
|
18
26
|
const _TreeItemChevron = require("../TreeItemChevron.cjs");
|
|
19
27
|
const _reacttabster = require("@fluentui/react-tabster");
|
|
20
28
|
const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
|
|
29
|
+
const _queryTreeItemActions = require("../../utils/queryTreeItemActions.cjs");
|
|
21
30
|
const useTreeItemLayout_unstable = (props, ref)=>{
|
|
22
|
-
const {
|
|
23
|
-
const
|
|
31
|
+
const { selector: selectorProp, ...baseProps } = props;
|
|
32
|
+
const isNavigatingWithKeyboard = (0, _reacttabster.useIsNavigatingWithKeyboard)();
|
|
33
|
+
const { targetDocument } = (0, _reactsharedcontexts.useFluent_unstable)();
|
|
34
|
+
const state = useTreeItemLayoutBase(// the Fluent selector itself is resolved below.
|
|
35
|
+
{
|
|
36
|
+
...baseProps,
|
|
37
|
+
selector: selectorProp === undefined || selectorProp === null ? selectorProp : {}
|
|
38
|
+
}, ref, targetDocument, isNavigatingWithKeyboard);
|
|
24
39
|
const selectionMode = (0, _index.useTreeContext_unstable)((ctx)=>ctx.selectionMode);
|
|
25
40
|
const navigationMode = (0, _index.useTreeContext_unstable)((ctx)=>{
|
|
26
41
|
var _ctx_navigationMode;
|
|
27
42
|
return (_ctx_navigationMode = ctx.navigationMode) !== null && _ctx_navigationMode !== void 0 ? _ctx_navigationMode : 'tree';
|
|
28
43
|
});
|
|
44
|
+
const selectionRef = (0, _index.useTreeItemContext_unstable)((ctx)=>ctx.selectionRef);
|
|
45
|
+
const checked = (0, _index.useTreeItemContext_unstable)((ctx)=>ctx.checked);
|
|
46
|
+
const expandIconRef = (0, _index.useTreeItemContext_unstable)((ctx)=>ctx.expandIconRef);
|
|
47
|
+
// Link the selector to the main content unless the consumer provided an accessible name
|
|
48
|
+
const selectorShorthand = (0, _reactutilities.isResolvedShorthand)(selectorProp) ? selectorProp : undefined;
|
|
49
|
+
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;
|
|
50
|
+
const selector = _reactutilities.slot.optional(selectorProp, {
|
|
51
|
+
renderByDefault: selectionMode !== 'none',
|
|
52
|
+
defaultProps: {
|
|
53
|
+
checked,
|
|
54
|
+
tabIndex: -1,
|
|
55
|
+
ref: selectionRef,
|
|
56
|
+
'aria-labelledby': selectorAriaLabelledBy
|
|
57
|
+
},
|
|
58
|
+
elementType: selectionMode === 'multiselect' ? _reactcheckbox.Checkbox : _reactradio.Radio
|
|
59
|
+
});
|
|
60
|
+
// Checkbox and Radio slot props omit `ref` from their type, but consumers can still provide it.
|
|
61
|
+
const selectorConsumerRef = selector && selector.ref;
|
|
62
|
+
const selectorRef = (0, _reactutilities.useMergedRefs)(selectorConsumerRef, selectionRef);
|
|
63
|
+
const selectorWithRef = selector && {
|
|
64
|
+
...selector,
|
|
65
|
+
ref: selectorRef
|
|
66
|
+
};
|
|
67
|
+
const arrowNavigationProps = (0, _reacttabster.useArrowNavigationGroup)({
|
|
68
|
+
circular: navigationMode === 'tree',
|
|
69
|
+
axis: 'horizontal'
|
|
70
|
+
});
|
|
71
|
+
const expandIcon = state.expandIcon ? _reactutilities.slot.optional(props.expandIcon, {
|
|
72
|
+
renderByDefault: true,
|
|
73
|
+
defaultProps: {
|
|
74
|
+
'aria-hidden': true,
|
|
75
|
+
children: /*#__PURE__*/ _react.createElement(_TreeItemChevron.TreeItemChevron, null),
|
|
76
|
+
ref: expandIconRef
|
|
77
|
+
},
|
|
78
|
+
elementType: 'div'
|
|
79
|
+
}) : undefined;
|
|
80
|
+
const expandIconRefWithConsumer = (0, _reactutilities.useMergedRefs)(expandIcon === null || expandIcon === void 0 ? void 0 : expandIcon.ref, expandIconRef);
|
|
81
|
+
const expandIconWithRef = expandIcon && {
|
|
82
|
+
...expandIcon,
|
|
83
|
+
ref: expandIconRefWithConsumer
|
|
84
|
+
};
|
|
85
|
+
return {
|
|
86
|
+
...state,
|
|
87
|
+
components: {
|
|
88
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
89
|
+
...state.components,
|
|
90
|
+
// Casting here to a union between checkbox and radio
|
|
91
|
+
selector: selectionMode === 'multiselect' ? _reactcheckbox.Checkbox : _reactradio.Radio
|
|
92
|
+
},
|
|
93
|
+
buttonContextValue: {
|
|
94
|
+
size: 'small'
|
|
95
|
+
},
|
|
96
|
+
// Consumer props keep winning over the navigation attributes, matching the base slot ordering.
|
|
97
|
+
actions: state.actions && {
|
|
98
|
+
...arrowNavigationProps,
|
|
99
|
+
...state.actions
|
|
100
|
+
},
|
|
101
|
+
expandIcon: expandIconWithRef,
|
|
102
|
+
selector: selectorWithRef
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
const useTreeItemLayoutBase_unstable = (props, ref)=>{
|
|
106
|
+
const { targetDocument } = (0, _reactsharedcontexts.useFluent_unstable)();
|
|
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 = (0, _index.useTreeItemContext_unstable)((ctx)=>ctx.layoutRef);
|
|
113
|
+
const selectionMode = (0, _index.useTreeContext_unstable)((ctx)=>ctx.selectionMode);
|
|
29
114
|
const [isActionsVisibleFromProps, onActionVisibilityChange] = (0, _reactutilities.isResolvedShorthand)(props.actions) ? [
|
|
30
115
|
props.actions.visible,
|
|
31
116
|
props.actions.onVisibilityChange
|
|
@@ -50,16 +135,37 @@ const useTreeItemLayout_unstable = (props, ref)=>{
|
|
|
50
135
|
// Link the selector to the main content unless the consumer provided an accessible name
|
|
51
136
|
const selectorShorthand = (0, _reactutilities.isResolvedShorthand)(props.selector) ? props.selector : undefined;
|
|
52
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;
|
|
53
|
-
|
|
138
|
+
// The mixed state of a native checkbox can only be set through its `indeterminate` DOM property.
|
|
139
|
+
const selectorInputRef = _react.useRef(null);
|
|
140
|
+
(0, _reactutilities.useIsomorphicLayoutEffect)(()=>{
|
|
141
|
+
if (selectorInputRef.current) {
|
|
142
|
+
selectorInputRef.current.indeterminate = checked === 'mixed';
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
const selectorSlot = _reactutilities.slot.optional(props.selector, {
|
|
54
146
|
renderByDefault: selectionMode !== 'none',
|
|
55
147
|
defaultProps: {
|
|
56
|
-
|
|
148
|
+
type: selectionMode === 'multiselect' ? 'checkbox' : 'radio',
|
|
149
|
+
checked: checked === true,
|
|
57
150
|
tabIndex: -1,
|
|
58
|
-
|
|
59
|
-
|
|
151
|
+
'aria-labelledby': selectorAriaLabelledBy,
|
|
152
|
+
// Changes bubble up to the tree item, which owns the selection state.
|
|
153
|
+
onChange: noop
|
|
60
154
|
},
|
|
61
|
-
elementType:
|
|
155
|
+
elementType: 'input'
|
|
156
|
+
});
|
|
157
|
+
const selectorRef = (0, _reactutilities.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 = (0, _reactutilities.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';
|
|
62
163
|
});
|
|
164
|
+
const selector = selectorSlot && {
|
|
165
|
+
...selectorSlot,
|
|
166
|
+
ref: selectorRef,
|
|
167
|
+
onChange: handleSelectorChange
|
|
168
|
+
};
|
|
63
169
|
const mainSlot = _reactutilities.slot.always(main, {
|
|
64
170
|
defaultProps: {
|
|
65
171
|
id: selector ? mainContentId : undefined
|
|
@@ -90,8 +196,7 @@ const useTreeItemLayout_unstable = (props, ref)=>{
|
|
|
90
196
|
setIsActionsVisible,
|
|
91
197
|
onActionVisibilityChange
|
|
92
198
|
]);
|
|
93
|
-
const
|
|
94
|
-
const isNavigatingWithKeyboard = (0, _reacttabster.useIsNavigatingWithKeyboard)();
|
|
199
|
+
const hasActions = Boolean(props.actions);
|
|
95
200
|
const setActionsInvisibleIfNotFromSubtree = _react.useCallback((event)=>{
|
|
96
201
|
const isRelatedTargetFromActions = ()=>Boolean(actionsRefInternal.current && (0, _reactutilities.elementContains)(actionsRefInternal.current, event.relatedTarget));
|
|
97
202
|
const isRelatedTargetFromTreeItem = ()=>Boolean(treeItemRef.current && (0, _reactutilities.elementContains)(treeItemRef.current, event.relatedTarget));
|
|
@@ -136,20 +241,18 @@ const useTreeItemLayout_unstable = (props, ref)=>{
|
|
|
136
241
|
isNavigatingWithKeyboard,
|
|
137
242
|
targetDocument
|
|
138
243
|
]);
|
|
139
|
-
const
|
|
140
|
-
const expandIcon = _reactutilities.slot.optional(props.expandIcon, {
|
|
244
|
+
const expandIconSlot = _reactutilities.slot.optional(props.expandIcon, {
|
|
141
245
|
renderByDefault: isBranch,
|
|
142
246
|
defaultProps: {
|
|
143
|
-
|
|
144
|
-
'aria-hidden': true,
|
|
145
|
-
ref: expandIconRefs
|
|
247
|
+
'aria-hidden': true
|
|
146
248
|
},
|
|
147
249
|
elementType: 'div'
|
|
148
250
|
});
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
251
|
+
const expandIconRefs = (0, _reactutilities.useMergedRefs)(expandIconSlot === null || expandIconSlot === void 0 ? void 0 : expandIconSlot.ref, expandIconRef);
|
|
252
|
+
const expandIcon = expandIconSlot && {
|
|
253
|
+
...expandIconSlot,
|
|
254
|
+
ref: expandIconRefs
|
|
255
|
+
};
|
|
153
256
|
const handleActionsBlur = (0, _reactutilities.useEventCallback)((event)=>{
|
|
154
257
|
if ((0, _reactutilities.isResolvedShorthand)(props.actions)) {
|
|
155
258
|
var _props_actions_onBlur, _props_actions;
|
|
@@ -163,17 +266,24 @@ const useTreeItemLayout_unstable = (props, ref)=>{
|
|
|
163
266
|
});
|
|
164
267
|
setIsActionsVisible(isRelatedTargetFromActions);
|
|
165
268
|
});
|
|
166
|
-
const
|
|
167
|
-
const actions = isActionsVisible ? _reactutilities.slot.optional(props.actions, {
|
|
269
|
+
const actionsSlot = isActionsVisible ? _reactutilities.slot.optional(props.actions, {
|
|
168
270
|
defaultProps: {
|
|
169
|
-
...arrowNavigationProps,
|
|
170
271
|
role: 'toolbar',
|
|
171
|
-
ref: actionsRefs,
|
|
172
272
|
onBlur: handleActionsBlur
|
|
173
273
|
},
|
|
174
274
|
elementType: 'div'
|
|
175
275
|
}) : undefined;
|
|
176
|
-
|
|
276
|
+
// The internal refs are merged after slot resolution, so that a consumer provided ref does not override them
|
|
277
|
+
const actionsRefs = (0, _reactutilities.useMergedRefs)(actionsSlot === null || actionsSlot === void 0 ? void 0 : actionsSlot.ref, actionsRef, actionsRefInternal, _queryTreeItemActions.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
|
+
}
|
|
177
287
|
_react.useEffect(()=>{
|
|
178
288
|
if (treeItemRef.current && hasActions) {
|
|
179
289
|
const treeItemElement = treeItemRef.current;
|
|
@@ -207,11 +317,7 @@ const useTreeItemLayout_unstable = (props, ref)=>{
|
|
|
207
317
|
iconAfter: 'div',
|
|
208
318
|
actions: 'div',
|
|
209
319
|
aside: 'div',
|
|
210
|
-
|
|
211
|
-
selector: selectionMode === 'multiselect' ? _reactcheckbox.Checkbox : _reactradio.Radio
|
|
212
|
-
},
|
|
213
|
-
buttonContextValue: {
|
|
214
|
-
size: 'small'
|
|
320
|
+
selector: 'input'
|
|
215
321
|
},
|
|
216
322
|
root: _reactutilities.slot.always((0, _reactutilities.getIntrinsicElementProps)('div', {
|
|
217
323
|
...props,
|
|
@@ -236,7 +342,69 @@ const useTreeItemLayout_unstable = (props, ref)=>{
|
|
|
236
342
|
expandIcon,
|
|
237
343
|
selector
|
|
238
344
|
};
|
|
239
|
-
}
|
|
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 */ }
|
|
240
408
|
function assertIsRefObject(ref) {
|
|
241
409
|
if (process.env.NODE_ENV !== 'production') {
|
|
242
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;;;;;+BAqCakB;;;;;;;iEAnCU,QAAQ;gCAUxB,4BAA4B;uBACkC,0BAAiB;+BAQ7D,2BAA2B;4BAE9B,wBAAwB;iCACd,wBAAqB;8BACgB,0BAA0B;qCAC/C,kCAAkC;AAW3E,mCAAmC,CACxCC,OACAC;IAEA,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAEC,UAAU,EAAE,GAAGJ;IAExC,MAAMK,YAAYf,sCAAAA,EAA4BgB,CAAAA,MAAOA,IAAID,SAAS;IAClE,MAAME,oBAAgBh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,OAAO,CAACpE,mBAAmB9B,oBAAAA,CAAKkD,QAAQ,CAACnC,MAAMmF,KAAK,EAAE;YAAE5C,aAAa;QAAM,KAAKzB;QAChFH;QACAmD;QACA7B;IACF;AACF,EAAE;AAEF,SAASS,kBAAyBzC,GAAsB;IACtD,IAAIqF,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,IAAI,OAAOvF,QAAQ,YAAYA,QAAQ,QAAQ,CAAE,CAAA,aAAaA,GAAAA,CAAE,EAAI;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;;;;;;;;;;;;;eAgIa4D;;QAvFAxC;;;;;iEAvCU,QAAQ;gCAWxB,4BAA4B;uBACkC,0BAAiB;+BAU7D,2BAA2B;4BAE9B,wBAAwB;iCACd,wBAAqB;8BACgB,0BAA0B;qCAC/C,kCAAkC;sCAC1C,sCAAmC;AAWpE,mCAAmC,CACxCC,OACAC;IAEA,MAAM,EAAEC,UAAUC,YAAY,EAAE,GAAGC,WAAW,GAAGJ;IACjD,MAAMK,+BAA2BV,yCAAAA;IACjC,MAAM,EAAEW,cAAc,EAAE,OAAGT,uCAAAA;IAC3B,MAAMU,QAAQC,sBACZ,AACA,gDAAgD,2CAD2C;IAE3F;QAAE,GAAGJ,SAAS;QAAEF,UAAUC,iBAAiBM,aAAaN,iBAAiB,OAAOA,eAAe,CAAC;IAAE,GAClGF,KACAK,gBACAD;IAGF,MAAMK,oBAAgBpB,8BAAAA,EAAwBqB,CAAAA,MAAOA,IAAID,aAAa;IACtE,MAAME,qBAAiBtB,8BAAAA,EAAwBqB,CAAAA;YAAOA;gBAAAA,sBAAAA,IAAIC,cAAAA,AAAc,MAAA,QAAlBD,wBAAAA,KAAAA,IAAAA,sBAAsB;;IAC5E,MAAME,mBAAexB,kCAAAA,EAA4BsB,CAAAA,MAAOA,IAAIE,YAAY;IACxE,MAAMC,cAAUzB,kCAAAA,EAA4BsB,CAAAA,MAAOA,IAAIG,OAAO;IAC9D,MAAMC,oBAAgB1B,kCAAAA,EAA4BsB,CAAAA,MAAOA,IAAII,aAAa;IAE1E,wFAAwF;IACxF,MAAMC,wBAAoBnC,mCAAAA,E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