@fluentui/react-tree 9.16.9 → 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 +20 -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/FlatTree.js.map +1 -1
- package/lib/components/FlatTree/FlatTree.types.js.map +1 -1
- package/lib/components/FlatTree/index.js.map +1 -1
- package/lib/components/FlatTree/renderFlatTree.js.map +1 -1
- package/lib/components/FlatTree/useFlatControllableCheckedItems.js.map +1 -1
- package/lib/components/FlatTree/useFlatTree.js +28 -3
- package/lib/components/FlatTree/useFlatTree.js.map +1 -1
- package/lib/components/FlatTree/useFlatTreeContextValues.js.map +1 -1
- package/lib/components/FlatTree/useFlatTreeStyles.styles.raw.js.map +1 -1
- package/lib/components/FlatTree/useHeadlessFlatTree.js.map +1 -1
- package/lib/components/FlatTreeItem/FlatTreeItem.js.map +1 -1
- package/lib/components/FlatTreeItem/FlatTreeItem.types.js.map +1 -1
- package/lib/components/FlatTreeItem/index.js.map +1 -1
- package/lib/components/Tree/Tree.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 +8 -4
- package/lib/components/Tree/renderTree.js.map +1 -1
- package/lib/components/Tree/useNestedControllableCheckedItems.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/Tree/useTreeStyles.styles.raw.js.map +1 -1
- package/lib/components/TreeItem/TreeItem.js.map +1 -1
- package/lib/components/TreeItem/TreeItem.types.js.map +1 -1
- package/lib/components/TreeItem/index.js.map +1 -1
- package/lib/components/TreeItem/renderTreeItem.js +2 -2
- package/lib/components/TreeItem/renderTreeItem.js.map +1 -1
- package/lib/components/TreeItem/useTreeItem.js +1 -1
- package/lib/components/TreeItem/useTreeItem.js.map +1 -1
- package/lib/components/TreeItem/useTreeItemContextValues.js.map +1 -1
- package/lib/components/TreeItem/useTreeItemStyles.styles.raw.js.map +1 -1
- package/lib/components/TreeItemChevron.js.map +1 -1
- package/lib/components/TreeItemLayout/TreeItemLayout.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 +14 -8
- 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/components/TreeItemLayout/useTreeItemLayoutStyles.styles.raw.js.map +1 -1
- package/lib/components/TreeItemPersonaLayout/TreeItemPersonaLayout.js.map +1 -1
- package/lib/components/TreeItemPersonaLayout/TreeItemPersonaLayout.types.js.map +1 -1
- package/lib/components/TreeItemPersonaLayout/index.js.map +1 -1
- package/lib/components/TreeItemPersonaLayout/renderTreeItemPersonaLayout.js +2 -2
- package/lib/components/TreeItemPersonaLayout/renderTreeItemPersonaLayout.js.map +1 -1
- package/lib/components/TreeItemPersonaLayout/useTreeItemPersonaLayout.js.map +1 -1
- package/lib/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutContextValues.js.map +1 -1
- package/lib/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.styles.raw.js.map +1 -1
- package/lib/components/TreeProvider.js.map +1 -1
- package/lib/contexts/index.js.map +1 -1
- package/lib/contexts/subtreeContext.js.map +1 -1
- package/lib/contexts/treeContext.js.map +1 -1
- package/lib/contexts/treeItemContext.js.map +1 -1
- package/lib/hooks/useControllableOpenItems.js.map +1 -1
- package/lib/hooks/useFlatTreeNavigation.js +3 -4
- package/lib/hooks/useFlatTreeNavigation.js.map +1 -1
- package/lib/hooks/useHTMLElementWalkerRef.js.map +1 -1
- package/lib/hooks/useRootTree.js +4 -9
- 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/ImmutableMap.js.map +1 -1
- package/lib/utils/ImmutableSet.js.map +1 -1
- package/lib/utils/assert.js.map +1 -1
- package/lib/utils/createCheckedItems.js.map +1 -1
- package/lib/utils/createHTMLElementWalker.js +2 -2
- package/lib/utils/createHTMLElementWalker.js.map +1 -1
- package/lib/utils/createHeadlessTree.js +4 -4
- package/lib/utils/createHeadlessTree.js.map +1 -1
- package/lib/utils/flattenTree.js.map +1 -1
- package/lib/utils/getTreeItemValueFromElement.js.map +1 -1
- package/lib/utils/nextTypeAheadElement.js.map +1 -1
- package/lib/utils/normalizeOpenItems.js.map +1 -1
- package/lib/utils/queryTreeItemActions.js +29 -0
- package/lib/utils/queryTreeItemActions.js.map +1 -0
- package/lib/utils/tokens.js.map +1 -1
- package/lib/utils/treeItemFilter.js.map +1 -1
- package/lib-commonjs/FlatTree.cjs +8 -8
- package/lib-commonjs/Tree.cjs +10 -7
- package/lib-commonjs/Tree.cjs.map +1 -1
- package/lib-commonjs/TreeItem.cjs +7 -7
- package/lib-commonjs/TreeItemLayout.cjs +9 -6
- package/lib-commonjs/TreeItemLayout.cjs.map +1 -1
- package/lib-commonjs/TreeItemPersonaLayout.cjs +6 -6
- package/lib-commonjs/components/FlatTree/FlatTree.cjs.map +1 -1
- package/lib-commonjs/components/FlatTree/FlatTree.types.cjs.map +1 -1
- package/lib-commonjs/components/FlatTree/index.cjs +8 -8
- package/lib-commonjs/components/FlatTree/index.cjs.map +1 -1
- package/lib-commonjs/components/FlatTree/renderFlatTree.cjs.map +1 -1
- package/lib-commonjs/components/FlatTree/useFlatControllableCheckedItems.cjs +3 -3
- package/lib-commonjs/components/FlatTree/useFlatControllableCheckedItems.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/FlatTree/useFlatTreeContextValues.cjs.map +1 -1
- package/lib-commonjs/components/FlatTree/useFlatTreeStyles.styles.cjs +3 -3
- package/lib-commonjs/components/FlatTree/useFlatTreeStyles.styles.cjs.map +1 -1
- package/lib-commonjs/components/FlatTree/useFlatTreeStyles.styles.raw.cjs +3 -3
- package/lib-commonjs/components/FlatTree/useFlatTreeStyles.styles.raw.cjs.map +1 -1
- package/lib-commonjs/components/FlatTree/useHeadlessFlatTree.cjs.map +1 -1
- package/lib-commonjs/components/FlatTreeItem/FlatTreeItem.cjs.map +1 -1
- package/lib-commonjs/components/FlatTreeItem/FlatTreeItem.types.cjs.map +1 -1
- package/lib-commonjs/components/FlatTreeItem/index.cjs.map +1 -1
- package/lib-commonjs/components/Tree/Tree.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 +10 -7
- 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/useNestedControllableCheckedItems.cjs +3 -3
- package/lib-commonjs/components/Tree/useNestedControllableCheckedItems.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/Tree/useTreeStyles.styles.cjs +3 -3
- package/lib-commonjs/components/Tree/useTreeStyles.styles.cjs.map +1 -1
- package/lib-commonjs/components/Tree/useTreeStyles.styles.raw.cjs +3 -3
- package/lib-commonjs/components/Tree/useTreeStyles.styles.raw.cjs.map +1 -1
- package/lib-commonjs/components/TreeItem/TreeItem.cjs.map +1 -1
- package/lib-commonjs/components/TreeItem/TreeItem.types.cjs.map +1 -1
- package/lib-commonjs/components/TreeItem/index.cjs +7 -7
- package/lib-commonjs/components/TreeItem/index.cjs.map +1 -1
- package/lib-commonjs/components/TreeItem/renderTreeItem.cjs.map +1 -1
- package/lib-commonjs/components/TreeItem/useTreeItem.cjs +1 -1
- package/lib-commonjs/components/TreeItem/useTreeItem.cjs.map +1 -1
- package/lib-commonjs/components/TreeItem/useTreeItemContextValues.cjs.map +1 -1
- package/lib-commonjs/components/TreeItem/useTreeItemStyles.styles.cjs +3 -3
- package/lib-commonjs/components/TreeItem/useTreeItemStyles.styles.cjs.map +1 -1
- package/lib-commonjs/components/TreeItem/useTreeItemStyles.styles.raw.cjs +3 -3
- package/lib-commonjs/components/TreeItem/useTreeItemStyles.styles.raw.cjs.map +1 -1
- package/lib-commonjs/components/TreeItemChevron.cjs.map +1 -1
- package/lib-commonjs/components/TreeItemLayout/TreeItemLayout.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 +9 -6
- 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/components/TreeItemLayout/useTreeItemLayoutStyles.styles.cjs +3 -3
- package/lib-commonjs/components/TreeItemLayout/useTreeItemLayoutStyles.styles.cjs.map +1 -1
- package/lib-commonjs/components/TreeItemLayout/useTreeItemLayoutStyles.styles.raw.cjs +3 -3
- package/lib-commonjs/components/TreeItemLayout/useTreeItemLayoutStyles.styles.raw.cjs.map +1 -1
- package/lib-commonjs/components/TreeItemPersonaLayout/TreeItemPersonaLayout.cjs.map +1 -1
- package/lib-commonjs/components/TreeItemPersonaLayout/TreeItemPersonaLayout.types.cjs.map +1 -1
- package/lib-commonjs/components/TreeItemPersonaLayout/index.cjs +6 -6
- package/lib-commonjs/components/TreeItemPersonaLayout/index.cjs.map +1 -1
- package/lib-commonjs/components/TreeItemPersonaLayout/renderTreeItemPersonaLayout.cjs.map +1 -1
- package/lib-commonjs/components/TreeItemPersonaLayout/useTreeItemPersonaLayout.cjs.map +1 -1
- package/lib-commonjs/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutContextValues.cjs.map +1 -1
- package/lib-commonjs/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.styles.cjs +3 -3
- package/lib-commonjs/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.styles.cjs.map +1 -1
- package/lib-commonjs/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.styles.raw.cjs +3 -3
- package/lib-commonjs/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.styles.raw.cjs.map +1 -1
- package/lib-commonjs/components/TreeProvider.cjs +3 -3
- package/lib-commonjs/components/TreeProvider.cjs.map +1 -1
- package/lib-commonjs/contexts/index.cjs +7 -7
- package/lib-commonjs/contexts/index.cjs.map +1 -1
- package/lib-commonjs/contexts/subtreeContext.cjs +3 -3
- package/lib-commonjs/contexts/subtreeContext.cjs.map +1 -1
- package/lib-commonjs/contexts/treeContext.cjs +3 -3
- package/lib-commonjs/contexts/treeContext.cjs.map +1 -1
- package/lib-commonjs/contexts/treeItemContext.cjs +3 -3
- package/lib-commonjs/contexts/treeItemContext.cjs.map +1 -1
- package/lib-commonjs/hooks/useControllableOpenItems.cjs +3 -3
- package/lib-commonjs/hooks/useControllableOpenItems.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/useHTMLElementWalkerRef.cjs.map +1 -1
- package/lib-commonjs/hooks/useRootTree.cjs +4 -9
- 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 +46 -40
- package/lib-commonjs/index.cjs.map +1 -1
- package/lib-commonjs/utils/ImmutableMap.cjs.map +1 -1
- package/lib-commonjs/utils/ImmutableSet.cjs.map +1 -1
- package/lib-commonjs/utils/assert.cjs.map +1 -1
- package/lib-commonjs/utils/createCheckedItems.cjs.map +1 -1
- package/lib-commonjs/utils/createHTMLElementWalker.cjs +2 -2
- package/lib-commonjs/utils/createHTMLElementWalker.cjs.map +1 -1
- package/lib-commonjs/utils/createHeadlessTree.cjs +7 -7
- package/lib-commonjs/utils/createHeadlessTree.cjs.map +1 -1
- package/lib-commonjs/utils/flattenTree.cjs.map +1 -1
- package/lib-commonjs/utils/getTreeItemValueFromElement.cjs +3 -3
- package/lib-commonjs/utils/getTreeItemValueFromElement.cjs.map +1 -1
- package/lib-commonjs/utils/nextTypeAheadElement.cjs.map +1 -1
- package/lib-commonjs/utils/normalizeOpenItems.cjs.map +1 -1
- package/lib-commonjs/utils/queryTreeItemActions.cjs +38 -0
- package/lib-commonjs/utils/queryTreeItemActions.cjs.map +1 -0
- package/lib-commonjs/utils/tokens.cjs +4 -4
- package/lib-commonjs/utils/tokens.cjs.map +1 -1
- package/lib-commonjs/utils/treeItemFilter.cjs.map +1 -1
- package/package.json +2 -2
|
@@ -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;AAC/B,SACEC,wBAAwB,EAC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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,YAAYA,WAAW,QA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,IAAI,CAACxF,kBAAkB,CAAC+G,SAAS;YAC/B;QACF;QAEA,MAAMT,UAAUD,iCAAiCrG;QACjDgH,WAAWxD,OAAO,GAAG8C;QAErB,OAAO;YACLU,WAAWxD,OAAO,GAAG;YACrB,IAAI,EAAE8C,QAAQI,WAAW,KAAK,GAAG;gBAC/BJ,QAAQK,OAAO;YACjB;QACF;IACF,GAAG;QAAC3G;QAAgB+G;KAAQ;IAE5B,OAAO1I,MAAMgG,WAAW,CAAC;;YAAM2C;wBAAAA,sBAAAA,WAAWxD,OAAO,cAAlBwD,0CAAAA,oBAAoBjH,wBAAwB,uCAAI;OAAO,EAAE;AAC1F;AAEA,SAAS8D;AACP,QAAQ,GACV;AAEA,SAASM,kBAAyBxE,GAAsB;IACtD,IAAIsH,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,IAAI,OAAOxH,QAAQ,YAAYA,QAAQ,QAAQ,CAAE,CAAA,aAAaA,GAAE,GAAI;YAClE,MAAM,IAAIyH,MAAM,CAAC;8BACO,EAAE3H,2BAA2B4H,IAAI,CAAC;;MAE1D,CAAC;QACH;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/TreeItemLayout/useTreeItemLayoutStyles.styles.ts"],"sourcesContent":["'use client';\n\nimport { makeResetStyles, makeStyles, mergeClasses } from '@griffel/react';\nimport type { TreeItemLayoutSlots, TreeItemLayoutState } from './TreeItemLayout.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport { tokens, typographyStyles } from '@fluentui/react-theme';\nimport { useTreeContext_unstable } from '../../contexts/treeContext';\nimport { treeItemLevelToken } from '../../utils/tokens';\nimport { useTreeItemContext_unstable } from '../../contexts/treeItemContext';\n\nexport const treeItemLayoutClassNames: SlotClassNames<TreeItemLayoutSlots> = {\n root: 'fui-TreeItemLayout',\n iconBefore: 'fui-TreeItemLayout__iconBefore',\n main: 'fui-TreeItemLayout__main',\n iconAfter: 'fui-TreeItemLayout__iconAfter',\n expandIcon: 'fui-TreeItemLayout__expandIcon',\n aside: 'fui-TreeItemLayout__aside',\n actions: 'fui-TreeItemLayout__actions',\n selector: 'fui-TreeItemLayout__selector',\n};\n\nconst useRootBaseStyles = makeResetStyles({\n display: 'flex',\n alignItems: 'center',\n minHeight: '32px',\n boxSizing: 'border-box',\n gridArea: 'layout',\n ':hover': {\n color: tokens.colorNeutralForeground2Hover,\n backgroundColor: tokens.colorSubtleBackgroundHover,\n // TODO: stop using treeItemLayoutClassNames.expandIcon for styling\n [`& .${treeItemLayoutClassNames.expandIcon}`]: {\n color: tokens.colorNeutralForeground3Hover,\n },\n },\n ':active': {\n color: tokens.colorNeutralForeground2Pressed,\n backgroundColor: tokens.colorSubtleBackgroundPressed,\n // TODO: stop using treeItemLayoutClassNames.expandIcon for styling\n [`& .${treeItemLayoutClassNames.expandIcon}`]: {\n color: tokens.colorNeutralForeground3Pressed,\n },\n },\n});\n\n/**\n * Styles for the root slot\n */\nconst useRootStyles = makeStyles({\n leaf: {\n paddingLeft: `calc(var(${treeItemLevelToken}, 1) * ${tokens.spacingHorizontalXXL})`,\n },\n branch: {\n paddingLeft: `calc((var(${treeItemLevelToken}, 1) - 1) * ${tokens.spacingHorizontalXXL})`,\n },\n medium: {\n ...typographyStyles.body1,\n },\n small: {\n minHeight: '24px',\n ...typographyStyles.caption1,\n },\n // Appearance variations\n subtle: {},\n 'subtle-alpha': {\n ':hover': {\n backgroundColor: tokens.colorSubtleBackgroundLightAlphaHover,\n },\n ':active': {\n backgroundColor: tokens.colorSubtleBackgroundLightAlphaPressed,\n },\n },\n transparent: {\n backgroundColor: tokens.colorTransparentBackground,\n ':hover': {\n backgroundColor: tokens.colorTransparentBackgroundHover,\n },\n ':active': {\n backgroundColor: tokens.colorTransparentBackgroundPressed,\n },\n },\n});\n\n/**\n * Styles for the action icon slot\n */\nconst useActionsBaseStyles = makeResetStyles({\n display: 'flex',\n marginLeft: 'auto',\n position: 'relative',\n zIndex: 1,\n gridArea: 'aside',\n padding: `0 ${tokens.spacingHorizontalS}`,\n});\n/**\n * Styles for the action icon slot\n */\nconst useAsideBaseStyles = makeResetStyles({\n display: 'flex',\n marginLeft: 'auto',\n alignItems: 'center',\n zIndex: 0,\n gridArea: 'aside',\n padding: `0 ${tokens.spacingHorizontalM}`,\n gap: tokens.spacingHorizontalXS,\n});\n\n/**\n * Styles for the expand icon slot\n */\nconst useExpandIconBaseStyles = makeResetStyles({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minWidth: '24px',\n boxSizing: 'border-box',\n color: tokens.colorNeutralForeground3,\n flex: `0 0 auto`,\n padding: `${tokens.spacingVerticalXS} 0`,\n});\n\n/**\n * Styles for the content slot\n */\nconst useMainBaseStyles = makeResetStyles({\n padding: `0 ${tokens.spacingHorizontalXXS}`,\n});\n\n/**\n * Styles for the before/after icon slot\n */\nconst useIconBaseStyles = makeResetStyles({\n display: 'flex',\n alignItems: 'center',\n color: tokens.colorNeutralForeground2,\n lineHeight: tokens.lineHeightBase500,\n fontSize: tokens.fontSizeBase500,\n});\n\nconst useIconBeforeStyles = makeStyles({\n medium: {\n paddingRight: tokens.spacingHorizontalXS,\n },\n small: {\n paddingRight: tokens.spacingHorizontalXXS,\n },\n});\n\nconst useIconAfterStyles = makeStyles({\n medium: {\n paddingLeft: tokens.spacingHorizontalXS,\n },\n small: {\n paddingLeft: tokens.spacingHorizontalXXS,\n },\n});\n\n/**\n * Apply styling to the TreeItemLayout slots based on the state\n */\nexport const useTreeItemLayoutStyles_unstable = (state: TreeItemLayoutState): TreeItemLayoutState => {\n const { main, iconAfter, iconBefore, expandIcon, root, aside, actions, selector } = state;\n const rootStyles = useRootStyles();\n const rootBaseStyles = useRootBaseStyles();\n const actionsBaseStyles = useActionsBaseStyles();\n const asideBaseStyles = useAsideBaseStyles();\n\n const mainBaseStyles = useMainBaseStyles();\n\n const expandIconBaseStyles = useExpandIconBaseStyles();\n const iconBaseStyles = useIconBaseStyles();\n const iconBeforeStyles = useIconBeforeStyles();\n const iconAfterStyles = useIconAfterStyles();\n\n const size = useTreeContext_unstable(ctx => ctx.size);\n const appearance = useTreeContext_unstable(ctx => ctx.appearance);\n const itemType = useTreeItemContext_unstable(ctx => ctx.itemType);\n\n // eslint-disable-next-line react-hooks/immutability\n root.className = mergeClasses(\n treeItemLayoutClassNames.root,\n rootBaseStyles,\n rootStyles[appearance],\n rootStyles[size],\n rootStyles[itemType],\n root.className,\n );\n\n // eslint-disable-next-line react-hooks/immutability\n main.className = mergeClasses(treeItemLayoutClassNames.main, mainBaseStyles, main.className);\n\n if (expandIcon) {\n // eslint-disable-next-line react-hooks/immutability\n expandIcon.className = mergeClasses(\n treeItemLayoutClassNames.expandIcon,\n expandIconBaseStyles,\n expandIcon.className,\n );\n }\n\n if (iconBefore) {\n // eslint-disable-next-line react-hooks/immutability\n iconBefore.className = mergeClasses(\n treeItemLayoutClassNames.iconBefore,\n iconBaseStyles,\n iconBeforeStyles[size],\n iconBefore.className,\n );\n }\n\n if (iconAfter) {\n // eslint-disable-next-line react-hooks/immutability\n iconAfter.className = mergeClasses(\n treeItemLayoutClassNames.iconAfter,\n iconBaseStyles,\n iconAfterStyles[size],\n iconAfter.className,\n );\n }\n\n if (actions) {\n // eslint-disable-next-line react-hooks/immutability\n actions.className = mergeClasses(treeItemLayoutClassNames.actions, actionsBaseStyles, actions.className);\n }\n if (aside) {\n // eslint-disable-next-line react-hooks/immutability\n aside.className = mergeClasses(treeItemLayoutClassNames.aside, asideBaseStyles, aside.className);\n }\n if (selector) {\n // eslint-disable-next-line react-hooks/immutability\n selector.className = mergeClasses(treeItemLayoutClassNames.selector, selector.className);\n }\n\n return state;\n};\n"],"names":["makeResetStyles","makeStyles","mergeClasses","tokens","typographyStyles","useTreeContext_unstable","treeItemLevelToken","useTreeItemContext_unstable","treeItemLayoutClassNames","root","iconBefore","main","iconAfter","expandIcon","aside","actions","selector","useRootBaseStyles","display","alignItems","minHeight","boxSizing","gridArea","color","colorNeutralForeground2Hover","backgroundColor","colorSubtleBackgroundHover","colorNeutralForeground3Hover","colorNeutralForeground2Pressed","colorSubtleBackgroundPressed","colorNeutralForeground3Pressed","useRootStyles","leaf","paddingLeft","spacingHorizontalXXL","branch","medium","body1","small","caption1","subtle","colorSubtleBackgroundLightAlphaHover","colorSubtleBackgroundLightAlphaPressed","transparent","colorTransparentBackground","colorTransparentBackgroundHover","colorTransparentBackgroundPressed","useActionsBaseStyles","marginLeft","position","zIndex","padding","spacingHorizontalS","useAsideBaseStyles","spacingHorizontalM","gap","spacingHorizontalXS","useExpandIconBaseStyles","justifyContent","minWidth","colorNeutralForeground3","flex","spacingVerticalXS","useMainBaseStyles","spacingHorizontalXXS","useIconBaseStyles","colorNeutralForeground2","lineHeight","lineHeightBase500","fontSize","fontSizeBase500","useIconBeforeStyles","paddingRight","useIconAfterStyles","useTreeItemLayoutStyles_unstable","state","rootStyles","rootBaseStyles","actionsBaseStyles","asideBaseStyles","mainBaseStyles","expandIconBaseStyles","iconBaseStyles","iconBeforeStyles","iconAfterStyles","size","ctx","appearance","itemType","className"],"mappings":"AAAA;AAEA,SAASA,eAAe,EAAEC,UAAU,EAAEC,YAAY,QAAQ,iBAAiB;AAG3E,SAASC,MAAM,EAAEC,gBAAgB,QAAQ,wBAAwB;AACjE,SAASC,uBAAuB,QAAQ,gCAA6B;AACrE,SAASC,kBAAkB,QAAQ,wBAAqB;AACxD,SAASC,2BAA2B,QAAQ,oCAAiC;AAE7E,OAAO,MAAMC,2BAAgE;IAC3EC,MAAM;IACNC,YAAY;IACZC,MAAM;IACNC,WAAW;IACXC,YAAY;IACZC,OAAO;IACPC,SAAS;IACTC,UAAU;AACZ,EAAE;AAEF,MAAMC,oBAAoBjB,gBAAgB;IACxCkB,SAAS;IACTC,YAAY;IACZC,WAAW;IACXC,WAAW;IACXC,UAAU;IACV,UAAU;QACRC,OAAOpB,OAAOqB,4BAA4B;QAC1CC,iBAAiBtB,OAAOuB,0BAA0B;QAClD,oEAAoE;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AAyBM,KAAK,EAAEiE,iBAAiBjE,MAAM2E,SAAS;IACjG;IACA,IAAIzE,UAAU;QACZ,oDAAoD;QACpDA,SAASyE,SAAS,GAAGvF,aAAaM,yBAAyBQ,QAAQ,EAAEA,SAASyE,SAAS;IACzF;IAEA,OAAOd;AACT,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/TreeItemLayout/useTreeItemLayoutStyles.styles.ts"],"sourcesContent":["'use client';\n\nimport { makeResetStyles, makeStyles, mergeClasses } from '@griffel/react';\nimport type { TreeItemLayoutSlots, TreeItemLayoutState } from './TreeItemLayout.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport { tokens, typographyStyles } from '@fluentui/react-theme';\nimport { useTreeContext_unstable } from '../../contexts/treeContext';\nimport { treeItemLevelToken } from '../../utils/tokens';\nimport { useTreeItemContext_unstable } from '../../contexts/treeItemContext';\n\nexport const treeItemLayoutClassNames: SlotClassNames<TreeItemLayoutSlots> = {\n root: 'fui-TreeItemLayout',\n iconBefore: 'fui-TreeItemLayout__iconBefore',\n main: 'fui-TreeItemLayout__main',\n iconAfter: 'fui-TreeItemLayout__iconAfter',\n expandIcon: 'fui-TreeItemLayout__expandIcon',\n aside: 'fui-TreeItemLayout__aside',\n actions: 'fui-TreeItemLayout__actions',\n selector: 'fui-TreeItemLayout__selector',\n};\n\nconst useRootBaseStyles = makeResetStyles({\n display: 'flex',\n alignItems: 'center',\n minHeight: '32px',\n boxSizing: 'border-box',\n gridArea: 'layout',\n ':hover': {\n color: tokens.colorNeutralForeground2Hover,\n backgroundColor: tokens.colorSubtleBackgroundHover,\n // TODO: stop using treeItemLayoutClassNames.expandIcon for styling\n [`& .${treeItemLayoutClassNames.expandIcon}`]: {\n color: tokens.colorNeutralForeground3Hover,\n },\n },\n ':active': {\n color: tokens.colorNeutralForeground2Pressed,\n backgroundColor: tokens.colorSubtleBackgroundPressed,\n // TODO: stop using treeItemLayoutClassNames.expandIcon for styling\n [`& .${treeItemLayoutClassNames.expandIcon}`]: {\n color: tokens.colorNeutralForeground3Pressed,\n },\n },\n});\n\n/**\n * Styles for the root slot\n */\nconst useRootStyles = makeStyles({\n leaf: {\n paddingLeft: `calc(var(${treeItemLevelToken}, 1) * ${tokens.spacingHorizontalXXL})`,\n },\n branch: {\n paddingLeft: `calc((var(${treeItemLevelToken}, 1) - 1) * ${tokens.spacingHorizontalXXL})`,\n },\n medium: {\n ...typographyStyles.body1,\n },\n small: {\n minHeight: '24px',\n ...typographyStyles.caption1,\n },\n // Appearance variations\n subtle: {},\n 'subtle-alpha': {\n ':hover': {\n backgroundColor: tokens.colorSubtleBackgroundLightAlphaHover,\n },\n ':active': {\n backgroundColor: tokens.colorSubtleBackgroundLightAlphaPressed,\n },\n },\n transparent: {\n backgroundColor: tokens.colorTransparentBackground,\n ':hover': {\n backgroundColor: tokens.colorTransparentBackgroundHover,\n },\n ':active': {\n backgroundColor: tokens.colorTransparentBackgroundPressed,\n },\n },\n});\n\n/**\n * Styles for the action icon slot\n */\nconst useActionsBaseStyles = makeResetStyles({\n display: 'flex',\n marginLeft: 'auto',\n position: 'relative',\n zIndex: 1,\n gridArea: 'aside',\n padding: `0 ${tokens.spacingHorizontalS}`,\n});\n/**\n * Styles for the action icon slot\n */\nconst useAsideBaseStyles = makeResetStyles({\n display: 'flex',\n marginLeft: 'auto',\n alignItems: 'center',\n zIndex: 0,\n gridArea: 'aside',\n padding: `0 ${tokens.spacingHorizontalM}`,\n gap: tokens.spacingHorizontalXS,\n});\n\n/**\n * Styles for the expand icon slot\n */\nconst useExpandIconBaseStyles = makeResetStyles({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minWidth: '24px',\n boxSizing: 'border-box',\n color: tokens.colorNeutralForeground3,\n flex: `0 0 auto`,\n padding: `${tokens.spacingVerticalXS} 0`,\n});\n\n/**\n * Styles for the content slot\n */\nconst useMainBaseStyles = makeResetStyles({\n padding: `0 ${tokens.spacingHorizontalXXS}`,\n});\n\n/**\n * Styles for the before/after icon slot\n */\nconst useIconBaseStyles = makeResetStyles({\n display: 'flex',\n alignItems: 'center',\n color: tokens.colorNeutralForeground2,\n lineHeight: tokens.lineHeightBase500,\n fontSize: tokens.fontSizeBase500,\n});\n\nconst useIconBeforeStyles = makeStyles({\n medium: {\n paddingRight: tokens.spacingHorizontalXS,\n },\n small: {\n paddingRight: tokens.spacingHorizontalXXS,\n },\n});\n\nconst useIconAfterStyles = makeStyles({\n medium: {\n paddingLeft: tokens.spacingHorizontalXS,\n },\n small: {\n paddingLeft: tokens.spacingHorizontalXXS,\n },\n});\n\n/**\n * Apply styling to the TreeItemLayout slots based on the state\n */\nexport const useTreeItemLayoutStyles_unstable = (state: TreeItemLayoutState): TreeItemLayoutState => {\n const { main, iconAfter, iconBefore, expandIcon, root, aside, actions, selector } = state;\n const rootStyles = useRootStyles();\n const rootBaseStyles = useRootBaseStyles();\n const actionsBaseStyles = useActionsBaseStyles();\n const asideBaseStyles = useAsideBaseStyles();\n\n const mainBaseStyles = useMainBaseStyles();\n\n const expandIconBaseStyles = useExpandIconBaseStyles();\n const iconBaseStyles = useIconBaseStyles();\n const iconBeforeStyles = useIconBeforeStyles();\n const iconAfterStyles = useIconAfterStyles();\n\n const size = useTreeContext_unstable(ctx => ctx.size);\n const appearance = useTreeContext_unstable(ctx => ctx.appearance);\n const itemType = useTreeItemContext_unstable(ctx => ctx.itemType);\n\n // eslint-disable-next-line react-hooks/immutability\n root.className = mergeClasses(\n treeItemLayoutClassNames.root,\n rootBaseStyles,\n rootStyles[appearance],\n rootStyles[size],\n rootStyles[itemType],\n root.className,\n );\n\n // eslint-disable-next-line react-hooks/immutability\n main.className = mergeClasses(treeItemLayoutClassNames.main, mainBaseStyles, main.className);\n\n if (expandIcon) {\n // eslint-disable-next-line react-hooks/immutability\n expandIcon.className = mergeClasses(\n treeItemLayoutClassNames.expandIcon,\n expandIconBaseStyles,\n expandIcon.className,\n );\n }\n\n if (iconBefore) {\n // eslint-disable-next-line react-hooks/immutability\n iconBefore.className = mergeClasses(\n treeItemLayoutClassNames.iconBefore,\n iconBaseStyles,\n iconBeforeStyles[size],\n iconBefore.className,\n );\n }\n\n if (iconAfter) {\n // eslint-disable-next-line react-hooks/immutability\n iconAfter.className = mergeClasses(\n treeItemLayoutClassNames.iconAfter,\n iconBaseStyles,\n iconAfterStyles[size],\n iconAfter.className,\n );\n }\n\n if (actions) {\n // eslint-disable-next-line react-hooks/immutability\n actions.className = mergeClasses(treeItemLayoutClassNames.actions, actionsBaseStyles, actions.className);\n }\n if (aside) {\n // eslint-disable-next-line react-hooks/immutability\n aside.className = mergeClasses(treeItemLayoutClassNames.aside, asideBaseStyles, aside.className);\n }\n if (selector) {\n // eslint-disable-next-line react-hooks/immutability\n selector.className = mergeClasses(treeItemLayoutClassNames.selector, selector.className);\n }\n\n return state;\n};\n"],"names":["makeResetStyles","makeStyles","mergeClasses","tokens","typographyStyles","useTreeContext_unstable","treeItemLevelToken","useTreeItemContext_unstable","treeItemLayoutClassNames","root","iconBefore","main","iconAfter","expandIcon","aside","actions","selector","useRootBaseStyles","display","alignItems","minHeight","boxSizing","gridArea","color","colorNeutralForeground2Hover","backgroundColor","colorSubtleBackgroundHover","colorNeutralForeground3Hover","colorNeutralForeground2Pressed","colorSubtleBackgroundPressed","colorNeutralForeground3Pressed","useRootStyles","leaf","paddingLeft","spacingHorizontalXXL","branch","medium","body1","small","caption1","subtle","colorSubtleBackgroundLightAlphaHover","colorSubtleBackgroundLightAlphaPressed","transparent","colorTransparentBackground","colorTransparentBackgroundHover","colorTransparentBackgroundPressed","useActionsBaseStyles","marginLeft","position","zIndex","padding","spacingHorizontalS","useAsideBaseStyles","spacingHorizontalM","gap","spacingHorizontalXS","useExpandIconBaseStyles","justifyContent","minWidth","colorNeutralForeground3","flex","spacingVerticalXS","useMainBaseStyles","spacingHorizontalXXS","useIconBaseStyles","colorNeutralForeground2","lineHeight","lineHeightBase500","fontSize","fontSizeBase500","useIconBeforeStyles","paddingRight","useIconAfterStyles","useTreeItemLayoutStyles_unstable","state","rootStyles","rootBaseStyles","actionsBaseStyles","asideBaseStyles","mainBaseStyles","expandIconBaseStyles","iconBaseStyles","iconBeforeStyles","iconAfterStyles","size","ctx","appearance","itemType","className"],"mappings":"AAAA;AAEA,SAASA,eAAe,EAAEC,UAAU,EAAEC,YAAY,QAAQ,iBAAiB;AAG3E,SAASC,MAAM,EAAEC,gBAAgB,QAAQ,wBAAwB;AACjE,SAASC,uBAAuB,QAAQ,gCAA6B;AACrE,SAASC,kBAAkB,QAAQ,wBAAqB;AACxD,SAASC,2BAA2B,QAAQ,oCAAiC;AAE7E,OAAO,MAAMC,2BAAgE;IAC3EC,MAAM;IACNC,YAAY;IACZC,MAAM;IACNC,WAAW;IACXC,YAAY;IACZC,OAAO;IACPC,SAAS;IACTC,UAAU;AACZ,EAAE;AAEF,MAAMC,oBAAoBjB,gBAAgB;IACxCkB,SAAS;IACTC,YAAY;IACZC,WAAW;IACXC,WAAW;IACXC,UAAU;IACV,UAAU;QACRC,OAAOpB,OAAOqB,4BAA4B;QAC1CC,iBAAiBtB,OAAOuB,0BAA0B;QAClD,oEAAoE;QACpE,CAAC,CAAC,GAAG,EAAElB,yBAAyBK,UAAU,EAAE,CAAC,EAAE;YAC7CU,OAAOpB,OAAOwB,4BAA4B;QAC5C;IACF;IACA,WAAW;QACTJ,OAAOpB,OAAOyB,8BAA8B;QAC5CH,iBAAiBtB,OAAO0B,4BAA4B;QACpD,mEAAmE;QACnE,CAAC,CAAC,GAAG,EAAErB,yBAAyBK,UAAU,EAAE,CAAC,EAAE;YAC7CU,OAAOpB,OAAO2B,8BAA8B;QAC9C;IACF;AACF;AAEA;;CAEC,GACD,MAAMC,gBAAgB9B,WAAW;IAC/B+B,MAAM;QACJC,aAAa,CAAC,SAAS,EAAE3B,mBAAmB,OAAO,EAAEH,OAAO+B,oBAAoB,CAAC,CAAC,CAAC;IACrF;IACAC,QAAQ;QACNF,aAAa,CAAC,UAAU,EAAE3B,mBAAmB,YA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K8E,SAAS,GAAGvF,aAAaM,yBAAyBG,IAAI,EAAEqE,gBAAgBrE,KAAK8E,SAAS;IAE3F,IAAI5E,YAAY;QACd,oDAAoD;QACpDA,WAAW4E,SAAS,GAAGvF,aACrBM,yBAAyBK,UAAU,EACnCoE,sBACApE,WAAW4E,SAAS;IAExB;IAEA,IAAI/E,YAAY;QACd,oDAAoD;QACpDA,WAAW+E,SAAS,GAAGvF,aACrBM,yBAAyBE,UAAU,EACnCwE,gBACAC,gBAAgB,CAACE,KAAK,EACtB3E,WAAW+E,SAAS;IAExB;IAEA,IAAI7E,WAAW;QACb,oDAAoD;QACpDA,UAAU6E,SAAS,GAAGvF,aACpBM,yBAAyBI,SAAS,EAClCsE,gBACAE,eAAe,CAACC,KAAK,EACrBzE,UAAU6E,SAAS;IAEvB;IAEA,IAAI1E,SAAS;QACX,oDAAoD;QACpDA,QAAQ0E,SAAS,GAAGvF,aAAaM,yBAAyBO,OAAO,EAAE+D,mBAAmB/D,QAAQ0E,SAAS;IACzG;IACA,IAAI3E,OAAO;QACT,oDAAoD;QACpDA,MAAM2E,SAAS,GAAGvF,aAAaM,yBAAyBM,KAAK,EAAEiE,iBAAiBjE,MAAM2E,SAAS;IACjG;IACA,IAAIzE,UAAU;QACZ,oDAAoD;QACpDA,SAASyE,SAAS,GAAGvF,aAAaM,yBAAyBQ,QAAQ,EAAEA,SAASyE,SAAS;IACzF;IAEA,OAAOd;AACT,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../../../src/components/TreeItemPersonaLayout/TreeItemPersonaLayout.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useTreeItemPersonaLayout_unstable } from './useTreeItemPersonaLayout';\nimport { renderTreeItemPersonaLayout_unstable } from './renderTreeItemPersonaLayout';\nimport { useTreeItemPersonaLayoutStyles_unstable } from './useTreeItemPersonaLayoutStyles.styles';\nimport type { TreeItemPersonaLayoutProps } from './TreeItemPersonaLayout.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { useTreeItemPersonaLayoutContextValues_unstable } from './useTreeItemPersonaLayoutContextValues';\nimport { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';\n\n/**\n * The `TreeItemPersonaLayout` component is used as a child of `TreeItem` to display a `TreeItem` with a media (typically an avatar) and a description.\n * It provides a more visually appealing representation of a `TreeItem` and is typically used to display a list of people or topics.\n * This component should only be used as a direct child of `TreeItem`.\n */\nexport const TreeItemPersonaLayout: ForwardRefComponent<TreeItemPersonaLayoutProps> = React.forwardRef((props, ref) => {\n const state = useTreeItemPersonaLayout_unstable(props, ref);\n\n useTreeItemPersonaLayoutStyles_unstable(state);\n useCustomStyleHook_unstable('useTreeItemPersonaLayoutStyles_unstable')(state);\n\n const contextValues = useTreeItemPersonaLayoutContextValues_unstable(state);\n\n return renderTreeItemPersonaLayout_unstable(state, contextValues);\n});\n\nTreeItemPersonaLayout.displayName = 'TreeItemPersonaLayout';\n"],"names":["React","useTreeItemPersonaLayout_unstable","renderTreeItemPersonaLayout_unstable","useTreeItemPersonaLayoutStyles_unstable","useTreeItemPersonaLayoutContextValues_unstable","useCustomStyleHook_unstable","TreeItemPersonaLayout","forwardRef","props","ref","state","contextValues","displayName"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,iCAAiC,QAAQ,gCAA6B;AAC/E,SAASC,oCAAoC,QAAQ,mCAAgC;AACrF,SAASC,uCAAuC,QAAQ,6CAA0C;AAGlG,SAASC,8CAA8C,QAAQ,6CAA0C;AACzG,SAASC,2BAA2B,QAAQ,kCAAkC;AAE9E;;;;CAIC,GACD,OAAO,MAAMC,sCAAyEN,MAAMO,UAAU,CAAC,CAACC,OAAOC;IAC7G,MAAMC,QAAQT,kCAAkCO,OAAOC;IAEvDN,wCAAwCO;IACxCL,4BAA4B,2CAA2CK;IAEvE,MAAMC,gBAAgBP,+CAA+CM;IAErE,OAAOR,qCAAqCQ,OAAOC;AACrD,GAAG;AAEHL,sBAAsBM,WAAW,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../../../src/components/TreeItemPersonaLayout/TreeItemPersonaLayout.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport type { AvatarContextValue, AvatarSize } from '@fluentui/react-avatar';\nimport type { ButtonContextValue } from '@fluentui/react-button';\nimport type { TreeItemLayoutSlots } from '../TreeItemLayout/TreeItemLayout.types';\n\nexport type TreeItemPersonaLayoutContextValues = {\n avatar: AvatarContextValue;\n};\n\nexport type TreeItemPersonaLayoutSlots = Pick<TreeItemLayoutSlots, 'actions' | 'aside' | 'expandIcon' | 'selector'> & {\n root: NonNullable<Slot<'div'>>;\n /**\n * Avatar to display.\n */\n media: NonNullable<Slot<'div'>>;\n /**\n * Content. Children of the root slot are automatically rendered here\n */\n main: NonNullable<Slot<'div'>>;\n /**\n * Secondary text that describes or complements the content\n */\n description?: Slot<'div'>;\n};\n\n/**\n * TreeItemPersonaLayout Props\n */\nexport type TreeItemPersonaLayoutProps = ComponentProps<Partial<TreeItemPersonaLayoutSlots>>;\n\n/**\n * State used in rendering TreeItemPersonaLayout\n */\nexport type TreeItemPersonaLayoutState = ComponentState<TreeItemPersonaLayoutSlots> & {\n avatarSize: AvatarSize;\n buttonContextValue: ButtonContextValue;\n};\n"],"names":[],"mappings":"AA8BA;;CAEC,GACD,WAGE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../../../src/components/TreeItemPersonaLayout/index.ts"],"sourcesContent":["export { TreeItemPersonaLayout } from './TreeItemPersonaLayout';\nexport type {\n TreeItemPersonaLayoutContextValues,\n TreeItemPersonaLayoutProps,\n TreeItemPersonaLayoutSlots,\n TreeItemPersonaLayoutState,\n} from './TreeItemPersonaLayout.types';\nexport { renderTreeItemPersonaLayout_unstable } from './renderTreeItemPersonaLayout';\nexport { useTreeItemPersonaLayout_unstable } from './useTreeItemPersonaLayout';\nexport {\n treeItemPersonaLayoutClassNames,\n useTreeItemPersonaLayoutStyles_unstable,\n} from './useTreeItemPersonaLayoutStyles.styles';\n"],"names":["TreeItemPersonaLayout","renderTreeItemPersonaLayout_unstable","useTreeItemPersonaLayout_unstable","treeItemPersonaLayoutClassNames","useTreeItemPersonaLayoutStyles_unstable"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,6BAA0B;AAOhE,SAASC,oCAAoC,QAAQ,mCAAgC;AACrF,SAASC,iCAAiC,QAAQ,gCAA6B;AAC/E,SACEC,+BAA+B,EAC/BC,uCAAuC,QAClC,6CAA0C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import { assertSlots } from "@fluentui/react-utilities";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@fluentui/react-jsx-runtime/jsx-runtime";
|
|
2
|
+
import { assertSlots } from "@fluentui/react-utilities";
|
|
3
3
|
import { AvatarContextProvider } from "@fluentui/react-avatar";
|
|
4
4
|
import { ButtonContextProvider } from "@fluentui/react-button";
|
|
5
5
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../../../src/components/TreeItemPersonaLayout/renderTreeItemPersonaLayout.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 {\n TreeItemPersonaLayoutState,\n TreeItemPersonaLayoutContextValues,\n TreeItemPersonaLayoutSlots,\n} from './TreeItemPersonaLayout.types';\nimport { AvatarContextProvider } from '@fluentui/react-avatar';\nimport { ButtonContextProvider } from '@fluentui/react-button';\n\n/**\n * Render the final JSX of TreeItemPersonaLayout\n */\nexport const renderTreeItemPersonaLayout_unstable = (\n state: TreeItemPersonaLayoutState,\n contextValues: TreeItemPersonaLayoutContextValues,\n): JSXElement => {\n assertSlots<TreeItemPersonaLayoutSlots>(state);\n\n return (\n <state.root>\n {state.expandIcon && <state.expandIcon />}\n {state.selector && <state.selector />}\n <AvatarContextProvider value={contextValues.avatar}>\n <state.media />\n </AvatarContextProvider>\n <state.main />\n {state.description && <state.description />}\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","AvatarContextProvider","ButtonContextProvider","renderTreeItemPersonaLayout_unstable","state","contextValues","root","expandIcon","selector","value","avatar","media","main","description","buttonContextValue","actions","aside"],"mappings":";AAAA,0BAA0B,GAC1B,iDAAiD,GACjD,SAASA,WAAW,QAAQ,4BAA4B;AAOxD,SAASC,qBAAqB,QAAQ,yBAAyB;AAC/D,SAASC,qBAAqB,QAAQ,yBAAyB;AAE/D;;CAEC,GACD,OAAO,MAAMC,uCAAuC,CAClDC,OACAC;IAEAL,YAAwCI;IAExC,qBACE,MAACA,MAAME,IAAI;;YACRF,MAAMG,UAAU,kBAAI,KAACH,MAAMG,UAAU;YACrCH,MAAMI,QAAQ,kBAAI,KAACJ,MAAMI,QAAQ;0BAClC,KAACP;gBAAsBQ,OAAOJ,cAAcK,MAAM;0BAChD,cAAA,KAACN,MAAMO,KAAK;;0BAEd,KAACP,MAAMQ,IAAI;YACVR,MAAMS,WAAW,kBAAI,KAACT,MAAMS,WAAW;0BACxC,MAACX;gBAAsBO,OAAOL,MAAMU,kBAAkB;;oBACnDV,MAAMW,OAAO,kBAAI,KAACX,MAAMW,OAAO;oBAC/BX,MAAMY,KAAK,kBAAI,KAACZ,MAAMY,KAAK;;;;;AAIpC,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../../../src/components/TreeItemPersonaLayout/useTreeItemPersonaLayout.ts"],"sourcesContent":["'use client';\n\nimport type * as React from 'react';\nimport type { TreeItemPersonaLayoutProps, TreeItemPersonaLayoutState } from './TreeItemPersonaLayout.types';\nimport { slot } from '@fluentui/react-utilities';\nimport { useTreeContext_unstable } from '../../contexts';\nimport { treeAvatarSize } from '../../utils/tokens';\nimport { useTreeItemLayout_unstable } from '../TreeItemLayout/useTreeItemLayout';\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';\n\n/**\n * Create the state required to render TreeItemPersonaLayout.\n *\n * The returned state can be modified with hooks such as useTreeItemPersonaLayoutStyles_unstable,\n * before being passed to renderTreeItemPersonaLayout_unstable.\n *\n * @param props - props from this instance of TreeItemPersonaLayout\n * @param ref - reference to root HTMLElement of TreeItemPersonaLayout\n */\nexport const useTreeItemPersonaLayout_unstable = (\n props: TreeItemPersonaLayoutProps,\n ref: React.Ref<HTMLSpanElement>,\n): TreeItemPersonaLayoutState => {\n const { media, children, main, description } = props;\n\n const treeItemLayoutState = useTreeItemLayout_unstable(\n {\n ...props,\n iconBefore: null,\n iconAfter: null,\n },\n ref,\n );\n\n const size = useTreeContext_unstable(ctx => ctx.size);\n const selectionMode = useTreeContext_unstable(ctx => ctx.selectionMode);\n\n return {\n ...treeItemLayoutState,\n components: {\n expandIcon: 'div',\n main: 'div',\n description: 'div',\n root: 'div',\n media: 'div',\n aside: 'div',\n actions: 'div',\n // Casting here to a union between checkbox and radio\n selector: (selectionMode === 'multiselect' ? Checkbox : Radio) as React.ElementType<CheckboxProps | RadioProps>,\n },\n avatarSize: treeAvatarSize[size],\n main: slot.always(main, {\n defaultProps: { children, id: treeItemLayoutState.main.id },\n elementType: 'div',\n }),\n media: slot.always(media, { elementType: 'div' }),\n description: slot.optional(description, { elementType: 'div' }),\n };\n};\n"],"names":["slot","useTreeContext_unstable","treeAvatarSize","useTreeItemLayout_unstable","Checkbox","Radio","useTreeItemPersonaLayout_unstable","props","ref","media","children","main","description","treeItemLayoutState","iconBefore","iconAfter","size","ctx","selectionMode","components","expandIcon","root","aside","actions","selector","avatarSize","always","defaultProps","id","elementType","optional"],"mappings":"AAAA;AAIA,SAASA,IAAI,QAAQ,4BAA4B;AACjD,SAASC,uBAAuB,QAAQ,0BAAiB;AACzD,SAASC,cAAc,QAAQ,wBAAqB;AACpD,SAASC,0BAA0B,QAAQ,yCAAsC;AAEjF,SAASC,QAAQ,QAAQ,2BAA2B;AAEpD,SAASC,KAAK,QAAQ,wBAAwB;AAE9C;;;;;;;;CAQC,GACD,OAAO,MAAMC,oCAAoC,CAC/CC,OACAC;IAEA,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,IAAI,EAAEC,WAAW,EAAE,GAAGL;IAE/C,MAAMM,sBAAsBV,2BAC1B;QACE,GAAGI,KAAK;QACRO,YAAY;QACZC,WAAW;IACb,GACAP;IAGF,MAAMQ,OAAOf,wBAAwBgB,CAAAA,MAAOA,IAAID,IAAI;IACpD,MAAME,gBAAgBjB,wBAAwBgB,CAAAA,MAAOA,IAAIC,aAAa;IAEtE,OAAO;QACL,GAAGL,mBAAmB;QACtBM,YAAY;YACVC,YAAY;YACZT,MAAM;YACNC,aAAa;YACbS,MAAM;YACNZ,OAAO;YACPa,OAAO;YACPC,SAAS;YACT,qDAAqD;YACrDC,UAAWN,kBAAkB,gBAAgBd,WAAWC;QAC1D;QACAoB,YAAYvB,cAAc,CAACc,KAAK;QAChCL,MAAMX,KAAK0B,MAAM,CAACf,MAAM;YACtBgB,cAAc;gBAAEjB;gBAAUkB,IAAIf,oBAAoBF,IAAI,CAACiB,EAAE;YAAC;YAC1DC,aAAa;QACf;QACApB,OAAOT,KAAK0B,MAAM,CAACjB,OAAO;YAAEoB,aAAa;QAAM;QAC/CjB,aAAaZ,KAAK8B,QAAQ,CAAClB,aAAa;YAAEiB,aAAa;QAAM;IAC/D;AACF,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../../../src/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutContextValues.ts"],"sourcesContent":["'use client';\n\nimport type { AvatarContextValue } from '@fluentui/react-avatar';\nimport * as React from 'react';\nimport type { TreeItemPersonaLayoutState, TreeItemPersonaLayoutContextValues } from './TreeItemPersonaLayout.types';\n\nexport function useTreeItemPersonaLayoutContextValues_unstable(\n state: TreeItemPersonaLayoutState,\n): TreeItemPersonaLayoutContextValues {\n const { avatarSize } = state;\n\n const avatar = React.useMemo<AvatarContextValue>(() => ({ size: avatarSize }), [avatarSize]);\n\n return { avatar };\n}\n"],"names":["React","useTreeItemPersonaLayoutContextValues_unstable","state","avatarSize","avatar","useMemo","size"],"mappings":"AAAA;AAGA,YAAYA,WAAW,QAAQ;AAG/B,OAAO,SAASC,+CACdC,KAAiC;IAEjC,MAAM,EAAEC,UAAU,EAAE,GAAGD;IAEvB,MAAME,SAASJ,MAAMK,OAAO,CAAqB,IAAO,CAAA;YAAEC,MAAMH;QAAW,CAAA,GAAI;QAACA;KAAW;IAE3F,OAAO;QAAEC;IAAO;AAClB"}
|
package/lib/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.styles.raw.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.styles.ts"],"sourcesContent":["'use client';\n\nimport type { TreeItemPersonaLayoutSlots, TreeItemPersonaLayoutState } from './TreeItemPersonaLayout.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport { makeResetStyles, makeStyles, mergeClasses } from '@griffel/react';\nimport { tokens, typographyStyles } from '@fluentui/react-theme';\nimport { treeItemLevelToken } from '../../utils/tokens';\nimport { useTreeItemContext_unstable } from '../../contexts/treeItemContext';\nimport { useTreeContext_unstable } from '../../contexts/treeContext';\n\nexport const treeItemPersonaLayoutClassNames: SlotClassNames<TreeItemPersonaLayoutSlots> = {\n root: 'fui-TreeItemPersonaLayout',\n media: 'fui-TreeItemPersonaLayout__media',\n description: 'fui-TreeItemPersonaLayout__description',\n main: 'fui-TreeItemPersonaLayout__main',\n expandIcon: 'fui-TreeItemPersonaLayout__expandIcon',\n aside: 'fui-TreeItemPersonaLayout__aside',\n actions: 'fui-TreeItemPersonaLayout__actions',\n selector: 'fui-TreeItemPersonaLayout__selector',\n};\n\nconst useRootBaseStyles = makeResetStyles({\n display: 'grid',\n gridTemplateRows: '1fr auto',\n gridTemplateColumns: 'auto auto 1fr auto',\n gridTemplateAreas: `\n \"expandIcon media main aside\"\n \"expandIcon media description aside\"\n `,\n alignItems: 'center',\n ...typographyStyles.body1,\n ':active': {\n color: tokens.colorNeutralForeground2Pressed,\n backgroundColor: tokens.colorSubtleBackgroundPressed,\n // TODO: stop using treeItemPersonaLayoutClassNames.expandIcon for styling\n [`& .${treeItemPersonaLayoutClassNames.expandIcon}`]: {\n color: tokens.colorNeutralForeground3Pressed,\n },\n },\n ':hover': {\n color: tokens.colorNeutralForeground2Hover,\n backgroundColor: tokens.colorSubtleBackgroundHover,\n // TODO: stop using treeItemPersonaLayoutClassNames.expandIcon for styling\n [`& .${treeItemPersonaLayoutClassNames.expandIcon}`]: {\n color: tokens.colorNeutralForeground3Hover,\n },\n },\n});\n\n/**\n * Styles for the root slot\n */\nconst useRootStyles = makeStyles({\n leaf: {\n paddingLeft: `calc(var(${treeItemLevelToken}, 1) * ${tokens.spacingHorizontalXXL})`,\n },\n branch: {\n paddingLeft: `calc((var(${treeItemLevelToken}, 1) - 1) * ${tokens.spacingHorizontalXXL})`,\n },\n // Size variations\n medium: {\n ...typographyStyles.body1,\n },\n small: {\n minHeight: '24px',\n ...typographyStyles.caption1,\n },\n // Appearance variations\n subtle: {},\n 'subtle-alpha': {\n ':hover': {\n backgroundColor: tokens.colorSubtleBackgroundLightAlphaHover,\n },\n ':active': {\n backgroundColor: tokens.colorSubtleBackgroundLightAlphaPressed,\n },\n },\n transparent: {\n backgroundColor: tokens.colorTransparentBackground,\n ':hover': {\n backgroundColor: tokens.colorTransparentBackgroundHover,\n },\n ':active': {\n backgroundColor: tokens.colorTransparentBackgroundPressed,\n },\n },\n});\n\n/**\n * Styles for the expand icon slot\n */\nconst useMediaBaseStyles = makeResetStyles({\n display: 'flex',\n alignItems: 'center',\n width: '32px',\n height: '32px',\n gridArea: 'media',\n padding: `0 ${tokens.spacingHorizontalXS} 0 ${tokens.spacingHorizontalXXS}`,\n});\n\nconst useMainBaseStyles = makeResetStyles({\n gridArea: 'main',\n padding: `${tokens.spacingVerticalMNudge} ${tokens.spacingHorizontalXS} ${tokens.spacingVerticalMNudge} ${tokens.spacingHorizontalS}`,\n});\n\nconst useMainStyles = makeStyles({\n withDescription: {\n padding: `${tokens.spacingVerticalMNudge} ${tokens.spacingHorizontalXS} 0 ${tokens.spacingHorizontalS}`,\n },\n});\n\nconst useDescriptionBaseStyles = makeResetStyles({\n gridArea: 'description',\n ...typographyStyles.caption1,\n padding: `0 ${tokens.spacingHorizontalXS} ${tokens.spacingVerticalMNudge} ${tokens.spacingHorizontalS}`,\n});\n\n/**\n * Styles for the action icon slot\n */\nconst useActionsBaseStyles = makeResetStyles({\n display: 'flex',\n marginLeft: 'auto',\n position: 'relative',\n zIndex: 1,\n gridArea: 'aside',\n padding: `0 ${tokens.spacingHorizontalS}`,\n});\n/**\n * Styles for the action icon slot\n */\nconst useAsideBaseStyles = makeResetStyles({\n display: 'flex',\n marginLeft: 'auto',\n alignItems: 'center',\n zIndex: 0,\n gridArea: 'aside',\n padding: `0 ${tokens.spacingHorizontalM}`,\n gap: tokens.spacingHorizontalXS,\n});\n\n/**\n * Styles for the expand icon slot\n */\nconst useExpandIconBaseStyles = makeResetStyles({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minWidth: '24px',\n boxSizing: 'border-box',\n color: tokens.colorNeutralForeground3,\n gridArea: 'expandIcon',\n flex: `0 0 auto`,\n padding: `${tokens.spacingVerticalXS} 0`,\n});\n\n/**\n * Apply styling to the TreeItemPersonaLayout slots based on the state\n */\nexport const useTreeItemPersonaLayoutStyles_unstable = (\n state: TreeItemPersonaLayoutState,\n): TreeItemPersonaLayoutState => {\n const rootBaseStyles = useRootBaseStyles();\n const rootStyles = useRootStyles();\n const mediaBaseStyles = useMediaBaseStyles();\n const descriptionBaseStyles = useDescriptionBaseStyles();\n const actionsBaseStyles = useActionsBaseStyles();\n const asideBaseStyles = useAsideBaseStyles();\n const expandIconBaseStyles = useExpandIconBaseStyles();\n const mainBaseStyles = useMainBaseStyles();\n const mainStyles = useMainStyles();\n\n const size = useTreeContext_unstable(ctx => ctx.size);\n const appearance = useTreeContext_unstable(ctx => ctx.appearance);\n const itemType = useTreeItemContext_unstable(ctx => ctx.itemType);\n\n // eslint-disable-next-line react-hooks/immutability\n state.root.className = mergeClasses(\n treeItemPersonaLayoutClassNames.root,\n rootBaseStyles,\n rootStyles[itemType],\n rootStyles[appearance],\n rootStyles[size],\n state.root.className,\n );\n\n // eslint-disable-next-line react-hooks/immutability\n state.media.className = mergeClasses(treeItemPersonaLayoutClassNames.media, mediaBaseStyles, state.media.className);\n\n if (state.main) {\n // eslint-disable-next-line react-hooks/immutability\n state.main.className = mergeClasses(\n treeItemPersonaLayoutClassNames.main,\n mainBaseStyles,\n state.description && mainStyles.withDescription,\n state.main.className,\n );\n }\n if (state.description) {\n // eslint-disable-next-line react-hooks/immutability\n state.description.className = mergeClasses(\n treeItemPersonaLayoutClassNames.description,\n descriptionBaseStyles,\n state.description.className,\n );\n }\n if (state.actions) {\n // eslint-disable-next-line react-hooks/immutability\n state.actions.className = mergeClasses(\n treeItemPersonaLayoutClassNames.actions,\n actionsBaseStyles,\n state.actions.className,\n );\n }\n if (state.aside) {\n // eslint-disable-next-line react-hooks/immutability\n state.aside.className = mergeClasses(treeItemPersonaLayoutClassNames.aside, asideBaseStyles, state.aside.className);\n }\n if (state.expandIcon) {\n // eslint-disable-next-line react-hooks/immutability\n state.expandIcon.className = mergeClasses(\n treeItemPersonaLayoutClassNames.expandIcon,\n expandIconBaseStyles,\n state.expandIcon.className,\n );\n }\n\n if (state.selector) {\n // eslint-disable-next-line react-hooks/immutability\n state.selector.className = mergeClasses(treeItemPersonaLayoutClassNames.selector, state.selector.className);\n }\n\n return state;\n};\n"],"names":["makeResetStyles","makeStyles","mergeClasses","tokens","typographyStyles","treeItemLevelToken","useTreeItemContext_unstable","useTreeContext_unstable","treeItemPersonaLayoutClassNames","root","media","description","main","expandIcon","aside","actions","selector","useRootBaseStyles","display","gridTemplateRows","gridTemplateColumns","gridTemplateAreas","alignItems","body1","color","colorNeutralForeground2Pressed","backgroundColor","colorSubtleBackgroundPressed","colorNeutralForeground3Pressed","colorNeutralForeground2Hover","colorSubtleBackgroundHover","colorNeutralForeground3Hover","useRootStyles","leaf","paddingLeft","spacingHorizontalXXL","branch","medium","small","minHeight","caption1","subtle","colorSubtleBackgroundLightAlphaHover","colorSubtleBackgroundLightAlphaPressed","transparent","colorTransparentBackground","colorTransparentBackgroundHover","colorTransparentBackgroundPressed","useMediaBaseStyles","width","height","gridArea","padding","spacingHorizontalXS","spacingHorizontalXXS","useMainBaseStyles","spacingVerticalMNudge","spacingHorizontalS","useMainStyles","withDescription","useDescriptionBaseStyles","useActionsBaseStyles","marginLeft","position","zIndex","useAsideBaseStyles","spacingHorizontalM","gap","useExpandIconBaseStyles","justifyContent","minWidth","boxSizing","colorNeutralForeground3","flex","spacingVerticalXS","useTreeItemPersonaLayoutStyles_unstable","state","rootBaseStyles","rootStyles","mediaBaseStyles","descriptionBaseStyles","actionsBaseStyles","asideBaseStyles","expandIconBaseStyles","mainBaseStyles","mainStyles","size","ctx","appearance","itemType","className"],"mappings":"AAAA;AAIA,SAASA,eAAe,EAAEC,UAAU,EAAEC,YAAY,QAAQ,iBAAiB;AAC3E,SAASC,MAAM,EAAEC,gBAAgB,QAAQ,wBAAwB;AACjE,SAASC,kBAAkB,QAAQ,wBAAqB;AACxD,SAAS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F,SAAS;IAElH,IAAId,MAAMhE,IAAI,EAAE;QACd,oDAAoD;QACpDgE,MAAMhE,IAAI,CAAC8E,SAAS,GAAGxF,aACrBM,gCAAgCI,IAAI,EACpCwE,gBACAR,MAAMjE,WAAW,IAAI0E,WAAW1B,eAAe,EAC/CiB,MAAMhE,IAAI,CAAC8E,SAAS;IAExB;IACA,IAAId,MAAMjE,WAAW,EAAE;QACrB,oDAAoD;QACpDiE,MAAMjE,WAAW,CAAC+E,SAAS,GAAGxF,aAC5BM,gCAAgCG,WAAW,EAC3CqE,uBACAJ,MAAMjE,WAAW,CAAC+E,SAAS;IAE/B;IACA,IAAId,MAAM7D,OAAO,EAAE;QACjB,oDAAoD;QACpD6D,MAAM7D,OAAO,CAAC2E,SAAS,GAAGxF,aACxBM,gCAAgCO,OAAO,EACvCkE,mBACAL,MAAM7D,OAAO,CAAC2E,SAAS;IAE3B;IACA,IAAId,MAAM9D,KAAK,EAAE;QACf,oDAAoD;QACpD8D,MAAM9D,KAAK,CAAC4E,SAAS,GAAGxF,aAAaM,gCAAgCM,KAAK,EAAEoE,iBAAiBN,MAAM9D,KAAK,CAAC4E,SAAS;IACpH;IACA,IAAId,MAAM/D,UAAU,EAAE;QACpB,oDAAoD;QACpD+D,MAAM/D,UAAU,CAAC6E,SAAS,GAAGxF,aAC3BM,gCAAgCK,UAAU,EAC1CsE,sBACAP,MAAM/D,UAAU,CAAC6E,SAAS;IAE9B;IAEA,IAAId,MAAM5D,QAAQ,EAAE;QAClB,oDAAoD;QACpD4D,MAAM5D,QAAQ,CAAC0E,SAAS,GAAGxF,aAAaM,gCAAgCQ,QAAQ,EAAE4D,MAAM5D,QAAQ,CAAC0E,SAAS;IAC5G;IAEA,OAAOd;AACT,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.styles.ts"],"sourcesContent":["'use client';\n\nimport type { TreeItemPersonaLayoutSlots, TreeItemPersonaLayoutState } from './TreeItemPersonaLayout.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport { makeResetStyles, makeStyles, mergeClasses } from '@griffel/react';\nimport { tokens, typographyStyles } from '@fluentui/react-theme';\nimport { treeItemLevelToken } from '../../utils/tokens';\nimport { useTreeItemContext_unstable } from '../../contexts/treeItemContext';\nimport { useTreeContext_unstable } from '../../contexts/treeContext';\n\nexport const treeItemPersonaLayoutClassNames: SlotClassNames<TreeItemPersonaLayoutSlots> = {\n root: 'fui-TreeItemPersonaLayout',\n media: 'fui-TreeItemPersonaLayout__media',\n description: 'fui-TreeItemPersonaLayout__description',\n main: 'fui-TreeItemPersonaLayout__main',\n expandIcon: 'fui-TreeItemPersonaLayout__expandIcon',\n aside: 'fui-TreeItemPersonaLayout__aside',\n actions: 'fui-TreeItemPersonaLayout__actions',\n selector: 'fui-TreeItemPersonaLayout__selector',\n};\n\nconst useRootBaseStyles = makeResetStyles({\n display: 'grid',\n gridTemplateRows: '1fr auto',\n gridTemplateColumns: 'auto auto 1fr auto',\n gridTemplateAreas: `\n \"expandIcon media main aside\"\n \"expandIcon media description aside\"\n `,\n alignItems: 'center',\n ...typographyStyles.body1,\n ':active': {\n color: tokens.colorNeutralForeground2Pressed,\n backgroundColor: tokens.colorSubtleBackgroundPressed,\n // TODO: stop using treeItemPersonaLayoutClassNames.expandIcon for styling\n [`& .${treeItemPersonaLayoutClassNames.expandIcon}`]: {\n color: tokens.colorNeutralForeground3Pressed,\n },\n },\n ':hover': {\n color: tokens.colorNeutralForeground2Hover,\n backgroundColor: tokens.colorSubtleBackgroundHover,\n // TODO: stop using treeItemPersonaLayoutClassNames.expandIcon for styling\n [`& .${treeItemPersonaLayoutClassNames.expandIcon}`]: {\n color: tokens.colorNeutralForeground3Hover,\n },\n },\n});\n\n/**\n * Styles for the root slot\n */\nconst useRootStyles = makeStyles({\n leaf: {\n paddingLeft: `calc(var(${treeItemLevelToken}, 1) * ${tokens.spacingHorizontalXXL})`,\n },\n branch: {\n paddingLeft: `calc((var(${treeItemLevelToken}, 1) - 1) * ${tokens.spacingHorizontalXXL})`,\n },\n // Size variations\n medium: {\n ...typographyStyles.body1,\n },\n small: {\n minHeight: '24px',\n ...typographyStyles.caption1,\n },\n // Appearance variations\n subtle: {},\n 'subtle-alpha': {\n ':hover': {\n backgroundColor: tokens.colorSubtleBackgroundLightAlphaHover,\n },\n ':active': {\n backgroundColor: tokens.colorSubtleBackgroundLightAlphaPressed,\n },\n },\n transparent: {\n backgroundColor: tokens.colorTransparentBackground,\n ':hover': {\n backgroundColor: tokens.colorTransparentBackgroundHover,\n },\n ':active': {\n backgroundColor: tokens.colorTransparentBackgroundPressed,\n },\n },\n});\n\n/**\n * Styles for the expand icon slot\n */\nconst useMediaBaseStyles = makeResetStyles({\n display: 'flex',\n alignItems: 'center',\n width: '32px',\n height: '32px',\n gridArea: 'media',\n padding: `0 ${tokens.spacingHorizontalXS} 0 ${tokens.spacingHorizontalXXS}`,\n});\n\nconst useMainBaseStyles = makeResetStyles({\n gridArea: 'main',\n padding: `${tokens.spacingVerticalMNudge} ${tokens.spacingHorizontalXS} ${tokens.spacingVerticalMNudge} ${tokens.spacingHorizontalS}`,\n});\n\nconst useMainStyles = makeStyles({\n withDescription: {\n padding: `${tokens.spacingVerticalMNudge} ${tokens.spacingHorizontalXS} 0 ${tokens.spacingHorizontalS}`,\n },\n});\n\nconst useDescriptionBaseStyles = makeResetStyles({\n gridArea: 'description',\n ...typographyStyles.caption1,\n padding: `0 ${tokens.spacingHorizontalXS} ${tokens.spacingVerticalMNudge} ${tokens.spacingHorizontalS}`,\n});\n\n/**\n * Styles for the action icon slot\n */\nconst useActionsBaseStyles = makeResetStyles({\n display: 'flex',\n marginLeft: 'auto',\n position: 'relative',\n zIndex: 1,\n gridArea: 'aside',\n padding: `0 ${tokens.spacingHorizontalS}`,\n});\n/**\n * Styles for the action icon slot\n */\nconst useAsideBaseStyles = makeResetStyles({\n display: 'flex',\n marginLeft: 'auto',\n alignItems: 'center',\n zIndex: 0,\n gridArea: 'aside',\n padding: `0 ${tokens.spacingHorizontalM}`,\n gap: tokens.spacingHorizontalXS,\n});\n\n/**\n * Styles for the expand icon slot\n */\nconst useExpandIconBaseStyles = makeResetStyles({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minWidth: '24px',\n boxSizing: 'border-box',\n color: tokens.colorNeutralForeground3,\n gridArea: 'expandIcon',\n flex: `0 0 auto`,\n padding: `${tokens.spacingVerticalXS} 0`,\n});\n\n/**\n * Apply styling to the TreeItemPersonaLayout slots based on the state\n */\nexport const useTreeItemPersonaLayoutStyles_unstable = (\n state: TreeItemPersonaLayoutState,\n): TreeItemPersonaLayoutState => {\n const rootBaseStyles = useRootBaseStyles();\n const rootStyles = useRootStyles();\n const mediaBaseStyles = useMediaBaseStyles();\n const descriptionBaseStyles = useDescriptionBaseStyles();\n const actionsBaseStyles = useActionsBaseStyles();\n const asideBaseStyles = useAsideBaseStyles();\n const expandIconBaseStyles = useExpandIconBaseStyles();\n const mainBaseStyles = useMainBaseStyles();\n const mainStyles = useMainStyles();\n\n const size = useTreeContext_unstable(ctx => ctx.size);\n const appearance = useTreeContext_unstable(ctx => ctx.appearance);\n const itemType = useTreeItemContext_unstable(ctx => ctx.itemType);\n\n // eslint-disable-next-line react-hooks/immutability\n state.root.className = mergeClasses(\n treeItemPersonaLayoutClassNames.root,\n rootBaseStyles,\n rootStyles[itemType],\n rootStyles[appearance],\n rootStyles[size],\n state.root.className,\n );\n\n // eslint-disable-next-line react-hooks/immutability\n state.media.className = mergeClasses(treeItemPersonaLayoutClassNames.media, mediaBaseStyles, state.media.className);\n\n if (state.main) {\n // eslint-disable-next-line react-hooks/immutability\n state.main.className = mergeClasses(\n treeItemPersonaLayoutClassNames.main,\n mainBaseStyles,\n state.description && mainStyles.withDescription,\n state.main.className,\n );\n }\n if (state.description) {\n // eslint-disable-next-line react-hooks/immutability\n state.description.className = mergeClasses(\n treeItemPersonaLayoutClassNames.description,\n descriptionBaseStyles,\n state.description.className,\n );\n }\n if (state.actions) {\n // eslint-disable-next-line react-hooks/immutability\n state.actions.className = mergeClasses(\n treeItemPersonaLayoutClassNames.actions,\n actionsBaseStyles,\n state.actions.className,\n );\n }\n if (state.aside) {\n // eslint-disable-next-line react-hooks/immutability\n state.aside.className = mergeClasses(treeItemPersonaLayoutClassNames.aside, asideBaseStyles, state.aside.className);\n }\n if (state.expandIcon) {\n // eslint-disable-next-line react-hooks/immutability\n state.expandIcon.className = mergeClasses(\n treeItemPersonaLayoutClassNames.expandIcon,\n expandIconBaseStyles,\n state.expandIcon.className,\n );\n }\n\n if (state.selector) {\n // eslint-disable-next-line react-hooks/immutability\n state.selector.className = mergeClasses(treeItemPersonaLayoutClassNames.selector, state.selector.className);\n }\n\n return state;\n};\n"],"names":["makeResetStyles","makeStyles","mergeClasses","tokens","typographyStyles","treeItemLevelToken","useTreeItemContext_unstable","useTreeContext_unstable","treeItemPersonaLayoutClassNames","root","media","description","main","expandIcon","aside","actions","selector","useRootBaseStyles","display","gridTemplateRows","gridTemplateColumns","gridTemplateAreas","alignItems","body1","color","colorNeutralForeground2Pressed","backgroundColor","colorSubtleBackgroundPressed","colorNeutralForeground3Pressed","colorNeutralForeground2Hover","colorSubtleBackgroundHover","colorNeutralForeground3Hover","useRootStyles","leaf","paddingLeft","spacingHorizontalXXL","branch","medium","small","minHeight","caption1","subtle","colorSubtleBackgroundLightAlphaHover","colorSubtleBackgroundLightAlphaPressed","transparent","colorTransparentBackground","colorTransparentBackgroundHover","colorTransparentBackgroundPressed","useMediaBaseStyles","width","height","gridArea","padding","spacingHorizontalXS","spacingHorizontalXXS","useMainBaseStyles","spacingVerticalMNudge","spacingHorizontalS","useMainStyles","withDescription","useDescriptionBaseStyles","useActionsBaseStyles","marginLeft","position","zIndex","useAsideBaseStyles","spacingHorizontalM","gap","useExpandIconBaseStyles","justifyContent","minWidth","boxSizing","colorNeutralForeground3","flex","spacingVerticalXS","useTreeItemPersonaLayoutStyles_unstable","state","rootBaseStyles","rootStyles","mediaBaseStyles","descriptionBaseStyles","actionsBaseStyles","asideBaseStyles","expandIconBaseStyles","mainBaseStyles","mainStyles","size","ctx","appearance","itemType","className"],"mappings":"AAAA;AAIA,SAASA,eAAe,EAAEC,UAAU,EAAEC,YAAY,QAAQ,iBAAiB;AAC3E,SAASC,MAAM,EAAEC,gBAAgB,QAAQ,wBAAwB;AACjE,SAASC,kBAAkB,QAAQ,wBAAqB;AACxD,SAASC,2BAA2B,QAAQ,oCAAiC;AAC7E,SAASC,uBAAuB,QAAQ,gCAA6B;AAErE,OAAO,MAAMC,kCAA8E;IACzFC,MAAM;IACNC,OAAO;IACPC,aAAa;IACbC,MAAM;IACNC,YAAY;IACZC,OAAO;IACPC,SAAS;IACTC,UAAU;AACZ,EAAE;AAEF,MAAMC,oBAAoBjB,gBAAgB;IACxCkB,SAAS;IACTC,kBAAkB;IAClBC,qBAAqB;IACrBC,mBAAmB,CAAC;;;EAGpB,CAAC;IACDC,YAAY;IACZ,GAAGlB,iBAAiBmB,KAAK;IACzB,WAAW;QACTC,OAAOrB,OAAOsB,8BAA8B;QAC5CC,iBAAiBvB,OAAOwB,4BAA4B;QACpD,0EAA0E;QAC1E,CAAC,CAAC,GAAG,EAAEnB,gCAAgCK,UAAU,EAAE,CAAC,EAAE;YACpDW,OAAOrB,OAAOyB,8BAA8B;QAC9C;IACF;IACA,UAAU;QACRJ,OAAOrB,OAAO0B,4BAA4B;QAC1CH,iBAAiBvB,OAAO2B,0BAA0B;QAClD,0EAA0E;QAC1E,CAAC,CAAC,GAAG,EAAEtB,gCAAgCK,UAAU,EAAE,CAAC,EAAE;YACpDW,OAAOrB,OAAO4B,4BAA4B;QAC5C;IACF;AACF;AAEA;;CAEC,GACD,MAAMC,gBAAgB/B,WAAW;IAC/BgC,MAAM;QACJC,aAAa,CAAC,SAAS,EAAE7B,mBAAmB,OAAO,EAAEF,OAAOgC,oBAAoB,CAAC,CAAC,CAAC;IACrF;IACAC,QAAQ;QACNF,aAAa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5D,QAAQ,CAAC0E,SAAS,GAAGxF,aAAaM,gCAAgCQ,QAAQ,EAAE4D,MAAM5D,QAAQ,CAAC0E,SAAS;IAC5G;IAEA,OAAOd;AACT,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../../src/components/TreeProvider.tsx"],"sourcesContent":["import * as React from 'react';\nimport type { SubtreeContextValue, TreeContextValue } from '../contexts';\nimport { SubtreeContext, TreeContext } from '../contexts';\nimport type { JSXElement } from '@fluentui/react-utilities';\n\n/**\n * @internal\n */\nconst rootSubtreeContextValue: SubtreeContextValue = {\n level: 1,\n contextType: 'subtree',\n};\nexport const TreeProvider = (props: React.ProviderProps<TreeContextValue | SubtreeContextValue>): JSXElement => {\n if (props.value.contextType === 'subtree') {\n return <SubtreeContext.Provider value={props.value}>{props.children}</SubtreeContext.Provider>;\n }\n return (\n <TreeContext.Provider value={props.value}>\n <SubtreeContext.Provider value={rootSubtreeContextValue}>{props.children}</SubtreeContext.Provider>\n </TreeContext.Provider>\n );\n};\n\nTreeProvider.displayName = 'TreeProvider';\n\nexport type TreeRootResetProps = {\n children?: React.ReactNode;\n};\nexport const TreeRootReset = (props: TreeRootResetProps): JSXElement => (\n <SubtreeContext.Provider value={undefined as unknown as SubtreeContextValue}>\n {props.children}\n </SubtreeContext.Provider>\n);\n"],"names":["React","SubtreeContext","TreeContext","rootSubtreeContextValue","level","contextType","TreeProvider","props","value","Provider","children","displayName","TreeRootReset","undefined"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAE/B,SAASC,cAAc,EAAEC,WAAW,QAAQ,uBAAc;AAG1D;;CAEC,GACD,MAAMC,0BAA+C;IACnDC,OAAO;IACPC,aAAa;AACf;AACA,OAAO,MAAMC,eAAe,CAACC;IAC3B,IAAIA,MAAMC,KAAK,CAACH,WAAW,KAAK,WAAW;QACzC,qBAAO,oBAACJ,eAAeQ,QAAQ;YAACD,OAAOD,MAAMC,KAAK;WAAGD,MAAMG,QAAQ;IACrE;IACA,qBACE,oBAACR,YAAYO,QAAQ;QAACD,OAAOD,MAAMC,KAAK;qBACtC,oBAACP,eAAeQ,QAAQ;QAACD,OAAOL;OAA0BI,MAAMG,QAAQ;AAG9E,EAAE;AAEFJ,aAAaK,WAAW,GAAG;AAK3B,OAAO,MAAMC,gBAAgB,CAACL,sBAC5B,oBAACN,eAAeQ,QAAQ;QAACD,OAAOK;OAC7BN,MAAMG,QAAQ,EAEjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../../src/contexts/index.ts"],"sourcesContent":["export type { TreeContextValue, TreeItemRequest } from './treeContext';\nexport { TreeContext, useTreeContext_unstable } from './treeContext';\nexport type { SubtreeContextValue } from './subtreeContext';\nexport { SubtreeContext, useSubtreeContext_unstable } from './subtreeContext';\nexport type { TreeItemContextValue } from './treeItemContext';\nexport { TreeItemProvider, useTreeItemContext_unstable } from './treeItemContext';\n"],"names":["TreeContext","useTreeContext_unstable","SubtreeContext","useSubtreeContext_unstable","TreeItemProvider","useTreeItemContext_unstable"],"mappings":"AACA,SAASA,WAAW,EAAEC,uBAAuB,QAAQ,mBAAgB;AAErE,SAASC,cAAc,EAAEC,0BAA0B,QAAQ,sBAAmB;AAE9E,SAASC,gBAAgB,EAAEC,2BAA2B,QAAQ,uBAAoB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../../src/contexts/subtreeContext.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\nexport type SubtreeContextValue = {\n contextType: 'subtree';\n level: number;\n};\n\n/**\n * @internal\n */\nconst defaultSubTreeContextValue: SubtreeContextValue = {\n level: 0,\n contextType: 'subtree',\n};\n\n/**\n * @internal\n */\nexport const SubtreeContext: React.Context<SubtreeContextValue> = React.createContext<SubtreeContextValue | undefined>(\n undefined,\n) as React.Context<SubtreeContextValue>;\n\nexport const useSubtreeContext_unstable = (): SubtreeContextValue => {\n return React.useContext(SubtreeContext) ?? defaultSubTreeContextValue;\n};\n"],"names":["React","defaultSubTreeContextValue","level","contextType","SubtreeContext","createContext","undefined","useSubtreeContext_unstable","useContext"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAO/B;;CAEC,GACD,MAAMC,6BAAkD;IACtDC,OAAO;IACPC,aAAa;AACf;AAEA;;CAEC,GACD,OAAO,MAAMC,iBAAqDJ,MAAMK,aAAa,CACnFC,WACsC;AAExC,OAAO,MAAMC,6BAA6B;QACjCP;IAAP,QAAOA,oBAAAA,MAAMQ,UAAU,CAACJ,6BAAjBJ,+BAAAA,oBAAoCC;AAC7C,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../../src/contexts/treeContext.ts"],"sourcesContent":["'use client';\n\nimport type { Context, ContextSelector } from '@fluentui/react-context-selector';\nimport { createContext, useContextSelector } from '@fluentui/react-context-selector';\nimport type { TreeItemType, TreeItemValue } from '../TreeItem';\nimport type { SelectionMode, DistributiveOmit } from '@fluentui/react-utilities';\nimport { ImmutableSet } from '../utils/ImmutableSet';\nimport { ImmutableMap } from '../utils/ImmutableMap';\nimport type { TreeCheckedChangeData, TreeNavigationData_unstable, TreeOpenChangeData } from '../Tree';\n\nexport type TreeContextValue = {\n contextType?: 'root';\n level: number;\n treeType: 'nested' | 'flat';\n selectionMode: 'none' | SelectionMode;\n appearance: 'subtle' | 'subtle-alpha' | 'transparent';\n size: 'small' | 'medium';\n openItems: ImmutableSet<TreeItemValue>;\n checkedItems: ImmutableMap<TreeItemValue, 'mixed' | boolean>;\n /**\n * requests root Tree component to respond to some tree item event,\n */\n requestTreeResponse(request: TreeItemRequest): void;\n // FIXME: this is only marked as optional to avoid breaking changes\n // it should always be provided internally\n forceUpdateRovingTabIndex?(): void;\n // FIXME: this is only marked as optional to avoid breaking changes\n // it should always be provided internally\n navigationMode?: 'tree' | 'treegrid';\n};\n\nexport type TreeItemRequest = { itemType: TreeItemType } & (\n | (DistributiveOmit<TreeOpenChangeData, 'openItems'> & { requestType: 'open' })\n | (TreeNavigationData_unstable & { requestType: 'navigate' })\n | (DistributiveOmit<TreeCheckedChangeData, 'selectionMode' | 'checkedItems'> & { requestType: 'selection' })\n);\n\n/**\n * @internal\n */\nconst defaultTreeContextValue: TreeContextValue = {\n level: 0,\n contextType: 'root',\n treeType: 'nested',\n selectionMode: 'none',\n openItems: ImmutableSet.empty,\n checkedItems: ImmutableMap.empty,\n requestTreeResponse: noop,\n forceUpdateRovingTabIndex: noop,\n appearance: 'subtle',\n size: 'medium',\n navigationMode: 'tree',\n};\n\nfunction noop() {\n /* noop */\n}\n\n/**\n * @internal\n */\nexport const TreeContext: Context<TreeContextValue> = createContext<TreeContextValue | undefined>(\n undefined,\n) as Context<TreeContextValue>;\n\nexport const useTreeContext_unstable = <T>(selector: ContextSelector<TreeContextValue, T>): T =>\n useContextSelector(TreeContext, (ctx = defaultTreeContextValue) => selector(ctx));\n"],"names":["createContext","useContextSelector","ImmutableSet","ImmutableMap","defaultTreeContextValue","level","contextType","treeType","selectionMode","openItems","empty","checkedItems","requestTreeResponse","noop","forceUpdateRovingTabIndex","appearance","size","navigationMode","TreeContext","undefined","useTreeContext_unstable","selector","ctx"],"mappings":"AAAA;AAGA,SAASA,aAAa,EAAEC,kBAAkB,QAAQ,mCAAmC;AAGrF,SAASC,YAAY,QAAQ,2BAAwB;AACrD,SAASC,YAAY,QAAQ,2BAAwB;AA8BrD;;CAEC,GACD,MAAMC,0BAA4C;IAChDC,OAAO;IACPC,aAAa;IACbC,UAAU;IACVC,eAAe;IACfC,WAAWP,aAAaQ,KAAK;IAC7BC,cAAcR,aAAaO,KAAK;IAChCE,qBAAqBC;IACrBC,2BAA2BD;IAC3BE,YAAY;IACZC,MAAM;IACNC,gBAAgB;AAClB;AAEA,SAASJ;AACP,QAAQ,GACV;AAEA;;CAEC,GACD,OAAO,MAAMK,cAAyClB,cACpDmB,WAC6B;AAE/B,OAAO,MAAMC,0BAA0B,CAAIC,WACzCpB,mBAAmBiB,aAAa,CAACI,MAAMlB,uBAAuB,GAAKiB,SAASC,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../../src/contexts/treeItemContext.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { Context, ContextSelector } from '@fluentui/react-context-selector';\nimport { createContext, useContextSelector } from '@fluentui/react-context-selector';\nimport type { TreeItemType, TreeItemValue } from '../TreeItem';\nimport { headlessTreeRootId } from '../utils/createHeadlessTree';\nimport type { TreeSelectionValue } from '../Tree';\n\nexport type TreeItemContextValue = {\n /**\n * @deprecated - this value is irrelevant for the tree item\n */\n isActionsVisible: boolean;\n /**\n * @deprecated - this value is irrelevant for the tree item\n */\n isAsideVisible: boolean;\n selectionRef: React.Ref<HTMLInputElement>;\n actionsRef: React.Ref<HTMLDivElement>;\n expandIconRef: React.Ref<HTMLDivElement>;\n layoutRef: React.Ref<HTMLDivElement>;\n // FIXME: this should be React.RefObject<HTMLDivElement>,\n // but as it would be a breaking change, we need to keep it as is for now\n subtreeRef: React.Ref<HTMLDivElement>;\n // FIXME: this is only marked as optional to avoid breaking changes\n // it should always be provided internally\n treeItemRef?: React.RefObject<HTMLDivElement | null>;\n itemType: TreeItemType;\n value: TreeItemValue;\n open: boolean;\n checked: TreeSelectionValue;\n};\n\nconst defaultContextValue: TreeItemContextValue = {\n value: headlessTreeRootId,\n selectionRef: React.createRef(),\n layoutRef: React.createRef(),\n treeItemRef: React.createRef(),\n subtreeRef: React.createRef(),\n actionsRef: React.createRef(),\n expandIconRef: React.createRef(),\n isActionsVisible: false,\n isAsideVisible: false,\n itemType: 'leaf',\n open: false,\n checked: false,\n};\n\nconst TreeItemContext: Context<TreeItemContextValue | undefined> = createContext<TreeItemContextValue | undefined>(\n undefined,\n);\n\nexport const { Provider: TreeItemProvider } = TreeItemContext;\nexport const useTreeItemContext_unstable = <T>(selector: ContextSelector<TreeItemContextValue, T>): T =>\n useContextSelector(TreeItemContext, (ctx = defaultContextValue) => selector(ctx));\n"],"names":["React","createContext","useContextSelector","headlessTreeRootId","defaultContextValue","value","selectionRef","createRef","layoutRef","treeItemRef","subtreeRef","actionsRef","expandIconRef","isActionsVisible","isAsideVisible","itemType","open","checked","TreeItemContext","undefined","Provider","TreeItemProvider","useTreeItemContext_unstable","selector","ctx"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAE/B,SAASC,aAAa,EAAEC,kBAAkB,QAAQ,mCAAmC;AAErF,SAASC,kBAAkB,QAAQ,iCAA8B;AA4BjE,MAAMC,sBAA4C;IAChDC,OAAOF;IACPG,cAAcN,MAAMO,SAAS;IAC7BC,WAAWR,MAAMO,SAAS;IAC1BE,aAAaT,MAAMO,SAAS;IAC5BG,YAAYV,MAAMO,SAAS;IAC3BI,YAAYX,MAAMO,SAAS;IAC3BK,eAAeZ,MAAMO,SAAS;IAC9BM,kBAAkB;IAClBC,gBAAgB;IAChBC,UAAU;IACVC,MAAM;IACNC,SAAS;AACX;AAEA,MAAMC,kBAA6DjB,cACjEkB;AAGF,OAAO,MAAM,EAAEC,UAAUC,gBAAgB,EAAE,GAAGH,gBAAgB;AAC9D,OAAO,MAAMI,8BAA8B,CAAIC,WAC7CrB,mBAAmBgB,iBAAiB,CAACM,MAAMpB,mBAAmB,GAAKmB,SAASC,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useControllableOpenItems.ts"],"sourcesContent":["'use client';\n\nimport { useControllableState } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport { ImmutableSet } from '../utils/ImmutableSet';\nimport type { TreeItemValue } from '../components/TreeItem/TreeItem.types';\nimport type { TreeOpenChangeData, TreeProps } from '../Tree';\n\n/**\n * @internal\n */\nexport function useControllableOpenItems(\n props: Pick<TreeProps, 'openItems' | 'defaultOpenItems'>,\n): [ImmutableSet<TreeItemValue>, React.Dispatch<React.SetStateAction<ImmutableSet<TreeItemValue>>>] {\n return useControllableState({\n state: React.useMemo(() => props.openItems && ImmutableSet.from(props.openItems), [props.openItems]),\n defaultState: props.defaultOpenItems && (() => ImmutableSet.from(props.defaultOpenItems)),\n initialState: ImmutableSet.empty,\n });\n}\n\n/**\n * @internal\n */\nexport function createNextOpenItems(\n data: Pick<TreeOpenChangeData, 'value' | 'open'>,\n previousOpenItems: ImmutableSet<TreeItemValue>,\n): ImmutableSet<TreeItemValue> {\n return data.open ? previousOpenItems.add(data.value) : previousOpenItems.delete(data.value);\n}\n"],"names":["useControllableState","React","ImmutableSet","useControllableOpenItems","props","state","useMemo","openItems","from","defaultState","defaultOpenItems","initialState","empty","createNextOpenItems","data","previousOpenItems","open","add","value","delete"],"mappings":"AAAA;AAEA,SAASA,oBAAoB,QAAQ,4BAA4B;AACjE,YAAYC,WAAW,QAAQ;AAC/B,SAASC,YAAY,QAAQ,2BAAwB;AAIrD;;CAEC,GACD,OAAO,SAASC,yBACdC,KAAwD;IAExD,OAAOJ,qBAAqB;QAC1BK,OAAOJ,MAAMK,OAAO,CAAC,IAAMF,MAAMG,SAAS,IAAIL,aAAaM,IAAI,CAACJ,MAAMG,SAAS,GAAG;YAACH,MAAMG,SAAS;SAAC;QACnGE,cAAcL,MAAMM,gBAAgB,IAAK,CAAA,IAAMR,aAAaM,IAAI,CAACJ,MAAMM,gBAAgB,CAAA;QACvFC,cAAcT,aAAaU,KAAK;IAClC;AACF;AAEA;;CAEC,GACD,OAAO,SAASC,oBACdC,IAAgD,EAChDC,iBAA8C;IAE9C,OAAOD,KAAKE,IAAI,GAAGD,kBAAkBE,GAAG,CAACH,KAAKI,KAAK,IAAIH,kBAAkBI,MAAM,CAACL,KAAKI,KAAK;AAC5F"}
|
|
@@ -7,7 +7,7 @@ import { dataTreeItemValueAttrName } from "../utils/getTreeItemValueFromElement.
|
|
|
7
7
|
import * as React from "react";
|
|
8
8
|
import { useHTMLElementWalkerRef } from "./useHTMLElementWalkerRef.js";
|
|
9
9
|
import { useFocusFinders } from "@fluentui/react-tabster";
|
|
10
|
-
import {
|
|
10
|
+
import { queryTreeItemActions } from "../utils/queryTreeItemActions.js";
|
|
11
11
|
export function useFlatTreeNavigation(navigationMode = 'tree') {
|
|
12
12
|
'use no memo'; // justified: compiler would optimize useFlatTreeNavigation — manual opt-out to preserve runtime behavior
|
|
13
13
|
const { walkerRef, rootRef: walkerRootRef } = useHTMLElementWalkerRef();
|
|
@@ -33,7 +33,7 @@ export function useFlatTreeNavigation(navigationMode = 'tree') {
|
|
|
33
33
|
return nextTypeAheadElement(walkerRef.current, data.event.key);
|
|
34
34
|
case treeDataTypes.ArrowLeft:
|
|
35
35
|
{
|
|
36
|
-
const actions =
|
|
36
|
+
const actions = queryTreeItemActions(data.target);
|
|
37
37
|
if (navigationMode === 'treegrid' && (actions === null || actions === void 0 ? void 0 : actions.contains(data.target.ownerDocument.activeElement))) {
|
|
38
38
|
return data.target;
|
|
39
39
|
}
|
|
@@ -49,7 +49,7 @@ No parent element found for the current element:`, data.target);
|
|
|
49
49
|
case treeDataTypes.ArrowRight:
|
|
50
50
|
{
|
|
51
51
|
if (navigationMode === 'treegrid') {
|
|
52
|
-
const actions =
|
|
52
|
+
const actions = queryTreeItemActions(data.target);
|
|
53
53
|
if (actions) {
|
|
54
54
|
var _findFirstFocusable;
|
|
55
55
|
(_findFirstFocusable = findFirstFocusable(actions)) === null || _findFirstFocusable === void 0 ? void 0 : _findFirstFocusable.focus();
|
|
@@ -113,4 +113,3 @@ function parentElement(parentValue, treeWalker) {
|
|
|
113
113
|
}
|
|
114
114
|
return treeWalker.root.querySelector(`[${dataTreeItemValueAttrName}="${parentValue}"]`);
|
|
115
115
|
}
|
|
116
|
-
const queryActions = (target)=>target.querySelector(`:scope > .${treeItemLayoutClassNames.root} > .${treeItemLayoutClassNames.actions}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useFlatTreeNavigation.ts"],"sourcesContent":["'use client';\n\nimport { useEventCallback, useMergedRefs } from '@fluentui/react-utilities';\nimport type { TreeNavigationData_unstable } from '../Tree';\nimport { nextTypeAheadElement } from '../utils/nextTypeAheadElement';\nimport { treeDataTypes } from '../utils/tokens';\nimport { useRovingTabIndex } from './useRovingTabIndexes';\nimport type { HTMLElementWalker } from '../utils/createHTMLElementWalker';\nimport type { TreeItemValue } from '../TreeItem';\nimport { dataTreeItemValueAttrName } from '../utils/getTreeItemValueFromElement';\nimport * as React from 'react';\nimport { useHTMLElementWalkerRef } from './useHTMLElementWalkerRef';\nimport type { TreeNavigationMode } from '../components/Tree/Tree.types';\nimport { useFocusFinders } from '@fluentui/react-tabster';\nimport { queryTreeItemActions } from '../utils/queryTreeItemActions';\n\nexport function useFlatTreeNavigation(navigationMode: TreeNavigationMode = 'tree'): {\n navigate: (data: TreeNavigationData_unstable) => void;\n rootRef: React.RefCallback<HTMLElement>;\n forceUpdateRovingTabIndex: () => void;\n} {\n 'use no memo'; // justified: compiler would optimize useFlatTreeNavigation — manual opt-out to preserve runtime behavior\n\n const { walkerRef, rootRef: walkerRootRef } = useHTMLElementWalkerRef();\n const { rove, forceUpdate: forceUpdateRovingTabIndex, initialize: initializeRovingTabIndex } = useRovingTabIndex();\n const { findFirstFocusable } = useFocusFinders();\n\n const rootRefCallback: React.RefCallback<HTMLElement> = React.useCallback(\n root => {\n if (walkerRef.current && root) {\n initializeRovingTabIndex(walkerRef.current);\n }\n },\n [initializeRovingTabIndex, walkerRef],\n );\n\n function getNextElement(data: TreeNavigationData_unstable) {\n if (!walkerRef.current) {\n return null;\n }\n switch (data.type) {\n case treeDataTypes.Click:\n return data.target;\n case treeDataTypes.TypeAhead:\n walkerRef.current.currentElement = data.target;\n return nextTypeAheadElement(walkerRef.current, data.event.key);\n case treeDataTypes.ArrowLeft: {\n const actions = queryTreeItemActions(data.target);\n if (navigationMode === 'treegrid' && actions?.contains(data.target.ownerDocument.activeElement)) {\n return data.target;\n }\n const nextElement = parentElement(data.parentValue, walkerRef.current);\n if (!nextElement && process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.warn(\n /* #__DE-INDENT__ */ `\n @fluentui/react-tree [useFlatTreeNavigation]:\n \\'ArrowLeft\\' navigation was not possible.\n No parent element found for the current element:\n `,\n data.target,\n );\n }\n return nextElement;\n }\n case treeDataTypes.ArrowRight: {\n if (navigationMode === 'treegrid') {\n const actions = queryTreeItemActions(data.target);\n if (actions) {\n findFirstFocusable(actions)?.focus();\n }\n return null;\n }\n walkerRef.current.currentElement = data.target;\n const nextElement = firstChild(data.target, walkerRef.current);\n if (!nextElement && process.env.NODE_ENV !== 'production') {\n const ariaLevel = Number(data.target.getAttribute('aria-level'));\n // eslint-disable-next-line no-console\n console.warn(\n /* #__DE-INDENT__ */ `\n @fluentui/react-tree [useFlatTreeNavigation]:\n \\'ArrowRight\\' navigation was not possible.\n No element with \"aria-posinset=1\" and \"aria-level=${ariaLevel + 1}\"\n was found after the current element!\n `,\n data.target,\n );\n }\n return nextElement;\n }\n case treeDataTypes.End:\n walkerRef.current.currentElement = walkerRef.current.root;\n return walkerRef.current.lastChild();\n case treeDataTypes.Home:\n walkerRef.current.currentElement = walkerRef.current.root;\n return walkerRef.current.firstChild();\n case treeDataTypes.ArrowDown:\n walkerRef.current.currentElement = data.target;\n return walkerRef.current.nextElement();\n case treeDataTypes.ArrowUp:\n walkerRef.current.currentElement = data.target;\n return walkerRef.current.previousElement();\n }\n }\n const navigate = useEventCallback((data: TreeNavigationData_unstable) => {\n const nextElement = getNextElement(data);\n if (nextElement) {\n rove(nextElement);\n }\n });\n return {\n navigate,\n rootRef: useMergedRefs<HTMLElement>(walkerRootRef, rootRefCallback),\n forceUpdateRovingTabIndex,\n } as const;\n}\n\nfunction firstChild(target: HTMLElement, treeWalker: HTMLElementWalker): HTMLElement | null {\n const nextElement = treeWalker.nextElement();\n if (!nextElement) {\n return null;\n }\n const nextElementAriaPosInSet = nextElement.getAttribute('aria-posinset');\n const nextElementAriaLevel = nextElement.getAttribute('aria-level');\n const targetAriaLevel = target.getAttribute('aria-level');\n if (nextElementAriaPosInSet === '1' && Number(nextElementAriaLevel) === Number(targetAriaLevel) + 1) {\n return nextElement;\n }\n return null;\n}\n\nfunction parentElement(parentValue: TreeItemValue | undefined, treeWalker: HTMLElementWalker) {\n if (parentValue === undefined) {\n return null;\n }\n return treeWalker.root.querySelector<HTMLElement>(`[${dataTreeItemValueAttrName}=\"${parentValue}\"]`);\n}\n"],"names":["useEventCallback","useMergedRefs","nextTypeAheadElement","treeDataTypes","useRovingTabIndex","dataTreeItemValueAttrName","React","useHTMLElementWalkerRef","useFocusFinders","queryTreeItemActions","useFlatTreeNavigation","navigationMode","walkerRef","rootRef","walkerRootRef","rove","forceUpdate","forceUpdateRovingTabIndex","initialize","initializeRovingTabIndex","findFirstFocusable","rootRefCallback","useCallback","root","current","getNextElement","data","type","Click","target","TypeAhead","currentElement","event","key","ArrowLeft","actions","contains","ownerDocument","activeElement","nextElement","parentElement","parentValue","process","env","NODE_ENV","console","warn","ArrowRight","focus","firstChild","ariaLevel","Number","getAttribute","End","lastChild","Home","ArrowDown","ArrowUp","previousElement","navigate","treeWalker","nextElementAriaPosInSet","nextElementAriaLevel","targetAriaLevel","undefined","querySelector"],"mappings":"AAAA;AAEA,SAASA,gBAAgB,EAAEC,aAAa,QAAQ,4BAA4B;AAE5E,SAASC,oBAAoB,QAAQ,mCAAgC;AACrE,SAASC,aAAa,QAAQ,qBAAkB;AAChD,SAASC,iBAAiB,QAAQ,2BAAwB;AAG1D,SAASC,yBAAyB,QAAQ,0CAAuC;AACjF,YAAYC,WAAW,QAAQ;AAC/B,SAASC,uBAAuB,QAAQ,+BAA4B;AAEpE,SAASC,eAAe,QAAQ,0BAA0B;AAC1D,SAASC,oBAAoB,QAAQ,mCAAgC;AAEr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;IACF;IACA,OAAO;QACLoB;QACA9C,SAASZ,cAA2Ba,eAAeO;QACnDJ;IACF;AACF;AAEA,SAASgC,WAAWpB,MAAmB,EAAE+B,UAA6B;IACpE,MAAMrB,cAAcqB,WAAWrB,WAAW;IAC1C,IAAI,CAACA,aAAa;QAChB,OAAO;IACT;IACA,MAAMsB,0BAA0BtB,YAAYa,YAAY,CAAC;IACzD,MAAMU,uBAAuBvB,YAAYa,YAAY,CAAC;IACtD,MAAMW,kBAAkBlC,OAAOuB,YAAY,CAAC;IAC5C,IAAIS,4BAA4B,OAAOV,OAAOW,0BAA0BX,OAAOY,mBAAmB,GAAG;QACnG,OAAOxB;IACT;IACA,OAAO;AACT;AAEA,SAASC,cAAcC,WAAsC,EAAEmB,UAA6B;IAC1F,IAAInB,gBAAgBuB,WAAW;QAC7B,OAAO;IACT;IACA,OAAOJ,WAAWrC,IAAI,CAAC0C,aAAa,CAAc,CAAC,CAAC,EAAE5D,0BAA0B,EAAE,EAAEoC,YAAY,EAAE,CAAC;AACrG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useHTMLElementWalkerRef.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useFluent_unstable } from '@fluentui/react-shared-contexts';\nimport type { HTMLElementWalker } from '../utils/createHTMLElementWalker';\nimport { createHTMLElementWalker } from '../utils/createHTMLElementWalker';\nimport { treeItemFilter } from '../utils/treeItemFilter';\n\nexport function useHTMLElementWalkerRef(): {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n walkerRef: React.MutableRefObject<HTMLElementWalker | undefined>;\n rootRef: React.Ref<HTMLElement>;\n} {\n const { targetDocument } = useFluent_unstable();\n\n const walkerRef = React.useRef<HTMLElementWalker>(undefined);\n\n const rootRef: React.Ref<HTMLElement> = React.useCallback(\n (root: HTMLElement) => {\n walkerRef.current =\n targetDocument && root ? createHTMLElementWalker(root, targetDocument, treeItemFilter) : undefined;\n },\n [targetDocument],\n );\n return { walkerRef, rootRef } as const;\n}\n"],"names":["React","useFluent_unstable","createHTMLElementWalker","treeItemFilter","useHTMLElementWalkerRef","targetDocument","walkerRef","useRef","undefined","rootRef","useCallback","root","current"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,kBAAkB,QAAQ,kCAAkC;AAErE,SAASC,uBAAuB,QAAQ,sCAAmC;AAC3E,SAASC,cAAc,QAAQ,6BAA0B;AAEzD,OAAO,SAASC;IAKd,MAAM,EAAEC,cAAc,EAAE,GAAGJ;IAE3B,MAAMK,YAAYN,MAAMO,MAAM,CAAoBC;IAElD,MAAMC,UAAkCT,MAAMU,WAAW,CACvD,CAACC;QACCL,UAAUM,OAAO,GACfP,kBAAkBM,OAAOT,wBAAwBS,MAAMN,gBAAgBF,kBAAkBK;IAC7F,GACA;QAACH;KAAe;IAElB,OAAO;QAAEC;QAAWG;IAAQ;AAC9B"}
|