@fluentui/react-tree 9.74.7-experimental.cli-api.20261006-ccaa611d58.0 → 9.75.0-experimental.css-modules.20261031-810ab07afb.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 +77 -19
- package/README.md +12 -0
- package/lib/components/FlatTree/FlatTree.js.map +1 -1
- package/lib/components/FlatTree/FlatTree.module.css +7 -0
- 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.map +1 -1
- package/lib/components/FlatTree/useFlatTreeContextValues.js.map +1 -1
- package/lib/components/FlatTree/useFlatTreeStyles.styles.css.js +9 -0
- package/lib/components/FlatTree/useFlatTreeStyles.styles.css.js.map +1 -0
- package/lib/components/FlatTree/useFlatTreeStyles.styles.raw.css.js +9 -0
- package/lib/components/FlatTree/useFlatTreeStyles.styles.raw.css.js.map +1 -0
- 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.module.css +11 -0
- package/lib/components/Tree/Tree.types.js.map +1 -1
- package/lib/components/Tree/index.js.map +1 -1
- package/lib/components/Tree/renderTree.js +2 -2
- package/lib/components/Tree/renderTree.js.map +1 -1
- package/lib/components/Tree/useNestedControllableCheckedItems.js.map +1 -1
- package/lib/components/Tree/useTree.js.map +1 -1
- package/lib/components/Tree/useTreeContextValues.js.map +1 -1
- package/lib/components/Tree/useTreeStyles.styles.css.js +9 -0
- package/lib/components/Tree/useTreeStyles.styles.css.js.map +1 -0
- package/lib/components/Tree/useTreeStyles.styles.raw.css.js +9 -0
- package/lib/components/Tree/useTreeStyles.styles.raw.css.js.map +1 -0
- 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.module.css +65 -0
- 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.css.js +17 -0
- package/lib/components/TreeItem/useTreeItemStyles.styles.css.js.map +1 -0
- package/lib/components/TreeItem/useTreeItemStyles.styles.raw.css.js +17 -0
- package/lib/components/TreeItem/useTreeItemStyles.styles.raw.css.js.map +1 -0
- 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.module.css +137 -0
- package/lib/components/TreeItemLayout/TreeItemLayout.types.js.map +1 -1
- package/lib/components/TreeItemLayout/index.js.map +1 -1
- package/lib/components/TreeItemLayout/renderTreeItemLayout.js +2 -2
- package/lib/components/TreeItemLayout/renderTreeItemLayout.js.map +1 -1
- package/lib/components/TreeItemLayout/useTreeItemLayout.js.map +1 -1
- package/lib/components/TreeItemLayout/useTreeItemLayoutStyles.styles.css.js +51 -0
- package/lib/components/TreeItemLayout/useTreeItemLayoutStyles.styles.css.js.map +1 -0
- package/lib/components/TreeItemLayout/useTreeItemLayoutStyles.styles.raw.css.js +51 -0
- package/lib/components/TreeItemLayout/useTreeItemLayoutStyles.styles.raw.css.js.map +1 -0
- 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.module.css +149 -0
- 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.css.js +51 -0
- package/lib/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.styles.css.js.map +1 -0
- package/lib/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.styles.raw.css.js +51 -0
- package/lib/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.styles.raw.css.js.map +1 -0
- 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.map +1 -1
- package/lib/hooks/useHTMLElementWalkerRef.js.map +1 -1
- package/lib/hooks/useRootTree.js +1 -1
- package/lib/hooks/useRootTree.js.map +1 -1
- package/lib/hooks/useRovingTabIndexes.js.map +1 -1
- package/lib/hooks/useSubtree.js.map +1 -1
- package/lib/hooks/useTreeNavigation.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/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 +7 -7
- package/lib-commonjs/TreeItem.cjs +7 -7
- package/lib-commonjs/TreeItemLayout.cjs +6 -6
- package/lib-commonjs/TreeItemPersonaLayout.cjs +6 -6
- package/lib-commonjs/components/FlatTree/FlatTree.cjs.map +1 -1
- package/lib-commonjs/components/FlatTree/FlatTree.module.css +7 -0
- 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.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.css.cjs +28 -0
- package/lib-commonjs/components/FlatTree/useFlatTreeStyles.styles.css.cjs.map +1 -0
- 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/useFlatTreeStyles.styles.raw.css.cjs +28 -0
- package/lib-commonjs/components/FlatTree/useFlatTreeStyles.styles.raw.css.cjs.map +1 -0
- 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.module.css +11 -0
- package/lib-commonjs/components/Tree/Tree.types.cjs.map +1 -1
- package/lib-commonjs/components/Tree/index.cjs +7 -7
- package/lib-commonjs/components/Tree/index.cjs.map +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.map +1 -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.css.cjs +28 -0
- package/lib-commonjs/components/Tree/useTreeStyles.styles.css.cjs.map +1 -0
- 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/Tree/useTreeStyles.styles.raw.css.cjs +28 -0
- package/lib-commonjs/components/Tree/useTreeStyles.styles.raw.css.cjs.map +1 -0
- package/lib-commonjs/components/TreeItem/TreeItem.cjs.map +1 -1
- package/lib-commonjs/components/TreeItem/TreeItem.module.css +65 -0
- 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.css.cjs +36 -0
- package/lib-commonjs/components/TreeItem/useTreeItemStyles.styles.css.cjs.map +1 -0
- 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/TreeItem/useTreeItemStyles.styles.raw.css.cjs +36 -0
- package/lib-commonjs/components/TreeItem/useTreeItemStyles.styles.raw.css.cjs.map +1 -0
- 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.module.css +137 -0
- package/lib-commonjs/components/TreeItemLayout/TreeItemLayout.types.cjs.map +1 -1
- package/lib-commonjs/components/TreeItemLayout/index.cjs +6 -6
- package/lib-commonjs/components/TreeItemLayout/index.cjs.map +1 -1
- package/lib-commonjs/components/TreeItemLayout/renderTreeItemLayout.cjs.map +1 -1
- 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.css.cjs +70 -0
- package/lib-commonjs/components/TreeItemLayout/useTreeItemLayoutStyles.styles.css.cjs.map +1 -0
- 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/TreeItemLayout/useTreeItemLayoutStyles.styles.raw.css.cjs +70 -0
- package/lib-commonjs/components/TreeItemLayout/useTreeItemLayoutStyles.styles.raw.css.cjs.map +1 -0
- package/lib-commonjs/components/TreeItemPersonaLayout/TreeItemPersonaLayout.cjs.map +1 -1
- package/lib-commonjs/components/TreeItemPersonaLayout/TreeItemPersonaLayout.module.css +149 -0
- 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.css.cjs +70 -0
- package/lib-commonjs/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.styles.css.cjs.map +1 -0
- 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/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.styles.raw.css.cjs +70 -0
- package/lib-commonjs/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.styles.raw.css.cjs.map +1 -0
- 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.map +1 -1
- package/lib-commonjs/hooks/useHTMLElementWalkerRef.cjs.map +1 -1
- package/lib-commonjs/hooks/useRootTree.cjs +1 -1
- package/lib-commonjs/hooks/useRootTree.cjs.map +1 -1
- package/lib-commonjs/hooks/useRovingTabIndexes.cjs.map +1 -1
- package/lib-commonjs/hooks/useSubtree.cjs.map +1 -1
- package/lib-commonjs/hooks/useTreeNavigation.cjs.map +1 -1
- package/lib-commonjs/index.cjs +40 -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/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 +22 -22
- package/dist/metadata/api/api-root.json +0 -1
- package/dist/metadata/index.json +0 -1
|
@@ -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,EACxBC,mBAAmB,EACnBC,aAAa,EACbC,IAAI,EACJC,gBAAgB,EAChBC,eAAe,EACfC,oBAAoB,EACpBC,KAAK,QACA,4BAA4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AC;;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} 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,EACxBC,mBAAmB,EACnBC,aAAa,EACbC,IAAI,EACJC,gBAAgB,EAChBC,eAAe,EACfC,oBAAoB,EACpBC,KAAK,QACA,4BAA4B;AACnC,SAASC,2BAA2B,EAAEC,uBAAuB,QAAQ,0BAAiB;AAQtF,SAASC,QAAQ,QAAQ,2BAA2B;AAEpD,SAASC,KAAK,QAAQ,wBAAwB;AAC9C,SAASC,eAAe,QAAQ,wBAAqB;AACrD,SAASC,uBAAuB,EAAEC,2BAA2B,QAAQ,0BAA0B;AAC/F,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAElF;;;;;;;;CAQC,GACD,OAAO,MAAMC,6BAA6B,CACxCC,OACAC;IAEA,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAEC,UAAU,EAAE,GAAGJ;IAExC,MAAMK,YAAYf,4BAA4BgB,CAAAA,MAAOA,IAAID,SAAS;IAClE,MAAME,gBAAgBhB,wBAAwBe,CAAAA,MAAOA,IAAIC,aAAa;IACtE,MAAMC,iBAAiBjB,wBAAwBe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CH,MAAMjG,KAAKwD,MAAM,CACf3D,yBAAyB,OAAO;YAC9B,GAAGkB,KAAK;YACR,SAAS;YACT,4EAA4E;YAC5E,4FAA4F;YAC5FC,KAAKjB,cAAciB,KAAKI;QAC1B,IACA;YACEkC,aAAa;QACf;QAEFnC,YAAYnB,KAAKkD,QAAQ,CAAC/B,YAAY;YAAEmC,aAAa;QAAM;QAC3DrC,MAAMsC;QACNrC,WAAWlB,KAAKkD,QAAQ,CAAChC,WAAW;YAAEoC,aAAa;QAAM;QACzD4C,OAAO,CAACpE,mBAAmB9B,KAAKkD,QAAQ,CAACnC,MAAMmF,KAAK,EAAE;YAAE5C,aAAa;QAAM,KAAKzB;QAChFH;QACAmD;QACA7B;IACF;AACF,EAAE;AAEF,SAASS,kBAAyBzC,GAAsB;IACtD,IAAIqF,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,IAAI,OAAOvF,QAAQ,YAAYA,QAAQ,QAAQ,CAAE,CAAA,aAAaA,GAAE,GAAI;YAClE,MAAM,IAAIwF,MAAM,CAAC;8BACO,EAAE1F,2BAA2B2F,IAAI,CAAC;;MAE1D,CAAC;QACH;IACF;AACF"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { clsx } from "clsx";
|
|
3
|
+
import { useTreeContext_unstable } from "../../contexts/treeContext.js";
|
|
4
|
+
import { useTreeItemContext_unstable } from "../../contexts/treeItemContext.js";
|
|
5
|
+
import styles from "./TreeItemLayout.module.css";
|
|
6
|
+
export const treeItemLayoutClassNames = {
|
|
7
|
+
root: 'fui-TreeItemLayout',
|
|
8
|
+
iconBefore: 'fui-TreeItemLayout__iconBefore',
|
|
9
|
+
main: 'fui-TreeItemLayout__main',
|
|
10
|
+
iconAfter: 'fui-TreeItemLayout__iconAfter',
|
|
11
|
+
expandIcon: 'fui-TreeItemLayout__expandIcon',
|
|
12
|
+
aside: 'fui-TreeItemLayout__aside',
|
|
13
|
+
actions: 'fui-TreeItemLayout__actions',
|
|
14
|
+
selector: 'fui-TreeItemLayout__selector'
|
|
15
|
+
};
|
|
16
|
+
export const useTreeItemLayoutStyles_unstable = (state)=>{
|
|
17
|
+
const size = useTreeContext_unstable((ctx)=>ctx.size);
|
|
18
|
+
const appearance = useTreeContext_unstable((ctx)=>ctx.appearance);
|
|
19
|
+
const itemType = useTreeItemContext_unstable((ctx)=>ctx.itemType);
|
|
20
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
21
|
+
state.root.className = clsx(treeItemLayoutClassNames.root, styles.root, styles[itemType], styles[appearance], styles[size], state.root.className);
|
|
22
|
+
if (state.main) {
|
|
23
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
24
|
+
state.main.className = clsx(treeItemLayoutClassNames.main, styles.main, state.main.className);
|
|
25
|
+
}
|
|
26
|
+
if (state.expandIcon) {
|
|
27
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
28
|
+
state.expandIcon.className = clsx(treeItemLayoutClassNames.expandIcon, styles.expandIcon, state.expandIcon.className);
|
|
29
|
+
}
|
|
30
|
+
if (state.iconBefore) {
|
|
31
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
32
|
+
state.iconBefore.className = clsx(treeItemLayoutClassNames.iconBefore, styles.iconBefore, state.iconBefore.className);
|
|
33
|
+
}
|
|
34
|
+
if (state.iconAfter) {
|
|
35
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
36
|
+
state.iconAfter.className = clsx(treeItemLayoutClassNames.iconAfter, styles.iconAfter, state.iconAfter.className);
|
|
37
|
+
}
|
|
38
|
+
if (state.actions) {
|
|
39
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
40
|
+
state.actions.className = clsx(treeItemLayoutClassNames.actions, styles.actions, state.actions.className);
|
|
41
|
+
}
|
|
42
|
+
if (state.aside) {
|
|
43
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
44
|
+
state.aside.className = clsx(treeItemLayoutClassNames.aside, styles.aside, state.aside.className);
|
|
45
|
+
}
|
|
46
|
+
if (state.selector) {
|
|
47
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
48
|
+
state.selector.className = clsx(treeItemLayoutClassNames.selector, state.selector.className);
|
|
49
|
+
}
|
|
50
|
+
return state;
|
|
51
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/TreeItemLayout/useTreeItemLayoutStyles.styles.css.ts"],"sourcesContent":["'use client';\n\nimport { clsx } from 'clsx';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport type { TreeItemLayoutState, TreeItemLayoutSlots } from './TreeItemLayout.types';\nimport { useTreeContext_unstable } from '../../contexts/treeContext';\nimport { useTreeItemContext_unstable } from '../../contexts/treeItemContext';\nimport styles from './TreeItemLayout.module.css';\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\nexport const useTreeItemLayoutStyles_unstable = (state: TreeItemLayoutState): TreeItemLayoutState => {\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 // eslint-disable-next-line react-hooks/immutability\n state.root.className = clsx(\n treeItemLayoutClassNames.root,\n styles.root,\n styles[itemType],\n styles[appearance],\n styles[size],\n state.root.className,\n );\n if (state.main) {\n // eslint-disable-next-line react-hooks/immutability\n state.main.className = clsx(treeItemLayoutClassNames.main, styles.main, state.main.className);\n }\n if (state.expandIcon) {\n // eslint-disable-next-line react-hooks/immutability\n state.expandIcon.className = clsx(\n treeItemLayoutClassNames.expandIcon,\n styles.expandIcon,\n state.expandIcon.className,\n );\n }\n if (state.iconBefore) {\n // eslint-disable-next-line react-hooks/immutability\n state.iconBefore.className = clsx(\n treeItemLayoutClassNames.iconBefore,\n styles.iconBefore,\n state.iconBefore.className,\n );\n }\n if (state.iconAfter) {\n // eslint-disable-next-line react-hooks/immutability\n state.iconAfter.className = clsx(treeItemLayoutClassNames.iconAfter, styles.iconAfter, state.iconAfter.className);\n }\n if (state.actions) {\n // eslint-disable-next-line react-hooks/immutability\n state.actions.className = clsx(treeItemLayoutClassNames.actions, styles.actions, state.actions.className);\n }\n if (state.aside) {\n // eslint-disable-next-line react-hooks/immutability\n state.aside.className = clsx(treeItemLayoutClassNames.aside, styles.aside, state.aside.className);\n }\n if (state.selector) {\n // eslint-disable-next-line react-hooks/immutability\n state.selector.className = clsx(treeItemLayoutClassNames.selector, state.selector.className);\n }\n return state;\n};\n"],"names":["clsx","useTreeContext_unstable","useTreeItemContext_unstable","styles","treeItemLayoutClassNames","root","iconBefore","main","iconAfter","expandIcon","aside","actions","selector","useTreeItemLayoutStyles_unstable","state","size","ctx","appearance","itemType","className"],"mappings":"AAAA;AAEA,SAASA,IAAI,QAAQ,OAAO;AAG5B,SAASC,uBAAuB,QAAQ,gCAA6B;AACrE,SAASC,2BAA2B,QAAQ,oCAAiC;AAC7E,OAAOC,YAAY,8BAA8B;AAEjD,OAAO,MAAMC,2BAAgE;IAC3EC,MAAM;IACNC,YAAY;IACZC,MAAM;IACNC,WAAW;IACXC,YAAY;IACZC,OAAO;IACPC,SAAS;IACTC,UAAU;AACZ,EAAE;AAEF,OAAO,MAAMC,mCAAmC,CAACC;IAC/C,MAAMC,OAAOd,wBAAwBe,CAAAA,MAAOA,IAAID,IAAI;IACpD,MAAME,aAAahB,wBAAwBe,CAAAA,MAAOA,IAAIC,UAAU;IAChE,MAAMC,WAAWhB,4BAA4Bc,CAAAA,MAAOA,IAAIE,QAAQ;IAChE,oDAAoD;IACpDJ,MAAMT,IAAI,CAACc,SAAS,GAAGnB,KACrB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AAQ,CAACO,SAAS,GAAGnB,KAAKI,yBAAyBQ,QAAQ,EAAEE,MAAMF,QAAQ,CAACO,SAAS;IAC7F;IACA,OAAOL;AACT,EAAE"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { clsx } from "clsx";
|
|
3
|
+
import { useTreeContext_unstable } from "../../contexts/treeContext.js";
|
|
4
|
+
import { useTreeItemContext_unstable } from "../../contexts/treeItemContext.js";
|
|
5
|
+
import styles from "./TreeItemLayout.module.css";
|
|
6
|
+
export const treeItemLayoutClassNames = {
|
|
7
|
+
root: 'fui-TreeItemLayout',
|
|
8
|
+
iconBefore: 'fui-TreeItemLayout__iconBefore',
|
|
9
|
+
main: 'fui-TreeItemLayout__main',
|
|
10
|
+
iconAfter: 'fui-TreeItemLayout__iconAfter',
|
|
11
|
+
expandIcon: 'fui-TreeItemLayout__expandIcon',
|
|
12
|
+
aside: 'fui-TreeItemLayout__aside',
|
|
13
|
+
actions: 'fui-TreeItemLayout__actions',
|
|
14
|
+
selector: 'fui-TreeItemLayout__selector'
|
|
15
|
+
};
|
|
16
|
+
export const useTreeItemLayoutStyles_unstable = (state)=>{
|
|
17
|
+
const size = useTreeContext_unstable((ctx)=>ctx.size);
|
|
18
|
+
const appearance = useTreeContext_unstable((ctx)=>ctx.appearance);
|
|
19
|
+
const itemType = useTreeItemContext_unstable((ctx)=>ctx.itemType);
|
|
20
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
21
|
+
state.root.className = clsx(treeItemLayoutClassNames.root, styles.root, styles[itemType], styles[appearance], styles[size], state.root.className);
|
|
22
|
+
if (state.main) {
|
|
23
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
24
|
+
state.main.className = clsx(treeItemLayoutClassNames.main, styles.main, state.main.className);
|
|
25
|
+
}
|
|
26
|
+
if (state.expandIcon) {
|
|
27
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
28
|
+
state.expandIcon.className = clsx(treeItemLayoutClassNames.expandIcon, styles.expandIcon, state.expandIcon.className);
|
|
29
|
+
}
|
|
30
|
+
if (state.iconBefore) {
|
|
31
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
32
|
+
state.iconBefore.className = clsx(treeItemLayoutClassNames.iconBefore, styles.iconBefore, state.iconBefore.className);
|
|
33
|
+
}
|
|
34
|
+
if (state.iconAfter) {
|
|
35
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
36
|
+
state.iconAfter.className = clsx(treeItemLayoutClassNames.iconAfter, styles.iconAfter, state.iconAfter.className);
|
|
37
|
+
}
|
|
38
|
+
if (state.actions) {
|
|
39
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
40
|
+
state.actions.className = clsx(treeItemLayoutClassNames.actions, styles.actions, state.actions.className);
|
|
41
|
+
}
|
|
42
|
+
if (state.aside) {
|
|
43
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
44
|
+
state.aside.className = clsx(treeItemLayoutClassNames.aside, styles.aside, state.aside.className);
|
|
45
|
+
}
|
|
46
|
+
if (state.selector) {
|
|
47
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
48
|
+
state.selector.className = clsx(treeItemLayoutClassNames.selector, state.selector.className);
|
|
49
|
+
}
|
|
50
|
+
return state;
|
|
51
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/TreeItemLayout/useTreeItemLayoutStyles.styles.css.ts"],"sourcesContent":["'use client';\n\nimport { clsx } from 'clsx';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport type { TreeItemLayoutState, TreeItemLayoutSlots } from './TreeItemLayout.types';\nimport { useTreeContext_unstable } from '../../contexts/treeContext';\nimport { useTreeItemContext_unstable } from '../../contexts/treeItemContext';\nimport styles from './TreeItemLayout.module.css';\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\nexport const useTreeItemLayoutStyles_unstable = (state: TreeItemLayoutState): TreeItemLayoutState => {\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 // eslint-disable-next-line react-hooks/immutability\n state.root.className = clsx(\n treeItemLayoutClassNames.root,\n styles.root,\n styles[itemType],\n styles[appearance],\n styles[size],\n state.root.className,\n );\n if (state.main) {\n // eslint-disable-next-line react-hooks/immutability\n state.main.className = clsx(treeItemLayoutClassNames.main, styles.main, state.main.className);\n }\n if (state.expandIcon) {\n // eslint-disable-next-line react-hooks/immutability\n state.expandIcon.className = clsx(\n treeItemLayoutClassNames.expandIcon,\n styles.expandIcon,\n state.expandIcon.className,\n );\n }\n if (state.iconBefore) {\n // eslint-disable-next-line react-hooks/immutability\n state.iconBefore.className = clsx(\n treeItemLayoutClassNames.iconBefore,\n styles.iconBefore,\n state.iconBefore.className,\n );\n }\n if (state.iconAfter) {\n // eslint-disable-next-line react-hooks/immutability\n state.iconAfter.className = clsx(treeItemLayoutClassNames.iconAfter, styles.iconAfter, state.iconAfter.className);\n }\n if (state.actions) {\n // eslint-disable-next-line react-hooks/immutability\n state.actions.className = clsx(treeItemLayoutClassNames.actions, styles.actions, state.actions.className);\n }\n if (state.aside) {\n // eslint-disable-next-line react-hooks/immutability\n state.aside.className = clsx(treeItemLayoutClassNames.aside, styles.aside, state.aside.className);\n }\n if (state.selector) {\n // eslint-disable-next-line react-hooks/immutability\n state.selector.className = clsx(treeItemLayoutClassNames.selector, state.selector.className);\n }\n return state;\n};\n"],"names":["clsx","useTreeContext_unstable","useTreeItemContext_unstable","styles","treeItemLayoutClassNames","root","iconBefore","main","iconAfter","expandIcon","aside","actions","selector","useTreeItemLayoutStyles_unstable","state","size","ctx","appearance","itemType","className"],"mappings":"AAAA;AAEA,SAASA,IAAI,QAAQ,OAAO;AAG5B,SAASC,uBAAuB,QAAQ,gCAA6B;AACrE,SAASC,2BAA2B,QAAQ,oCAAiC;AAC7E,OAAOC,YAAY,8BAA8B;AAEjD,OAAO,MAAMC,2BAAgE;IAC3EC,MAAM;IACNC,YAAY;IACZC,MAAM;IACNC,WAAW;IACXC,YAAY;IACZC,OAAO;IACPC,SAAS;IACTC,UAAU;AACZ,EAAE;AAEF,OAAO,MAAMC,mCAAmC,CAACC;IAC/C,MAAMC,OAAOd,wBAAwBe,CAAAA,MAAOA,IAAID,IAAI;IACpD,MAAME,aAAahB,wBAAwBe,CAAAA,MAAOA,IAAIC,UAAU;IAChE,MAAMC,WAAWhB,4BAA4Bc,CAAAA,MAAOA,IAAIE,QAAQ;IAChE,oDAAoD;IACpDJ,MAAMT,IAAI,CAACc,SAAS,GAAGnB,KACrBI,yBAAyBC,IAAI,EAC7BF,OAAOE,IAAI,EACXF,MAAM,CAACe,SAAS,EAChBf,MAAM,CAACc,WAAW,EAClBd,MAAM,CAACY,KAAK,EACZD,MAAMT,IAAI,CAACc,SAAS;IAEtB,IAAIL,MAAMP,IAAI,EAAE;QACd,oDAAoD;QACpDO,MAAMP,IAAI,CAACY,SAAS,GAAGnB,KAAKI,yBAAyBG,IAAI,EAAEJ,OAAOI,IAAI,EAAEO,MAAMP,IAAI,CAACY,SAAS;IAC9F;IACA,IAAIL,MAAML,UAAU,EAAE;QACpB,oDAAoD;QACpDK,MAAML,UAAU,CAACU,SAAS,GAAGnB,KAC3BI,yBAAyBK,UAAU,EACnCN,OAAOM,UAAU,EACjBK,MAAML,UAAU,CAACU,SAAS;IAE9B;IACA,IAAIL,MAAMR,UAAU,EAAE;QACpB,oDAAoD;QACpDQ,MAAMR,UAAU,CAACa,SAAS,GAAGnB,KAC3BI,yBAAyBE,UAAU,EACnCH,OAAOG,UAAU,EACjBQ,MAAMR,UAAU,CAACa,SAAS;IAE9B;IACA,IAAIL,MAAMN,SAAS,EAAE;QACnB,oDAAoD;QACpDM,MAAMN,SAAS,CAACW,SAAS,GAAGnB,KAAKI,yBAAyBI,SAAS,EAAEL,OAAOK,SAAS,EAAEM,MAAMN,SAAS,CAACW,SAAS;IAClH;IACA,IAAIL,MAAMH,OAAO,EAAE;QACjB,oDAAoD;QACpDG,MAAMH,OAAO,CAACQ,SAAS,GAAGnB,KAAKI,yBAAyBO,OAAO,EAAER,OAAOQ,OAAO,EAAEG,MAAMH,OAAO,CAACQ,SAAS;IAC1G;IACA,IAAIL,MAAMJ,KAAK,EAAE;QACf,oDAAoD;QACpDI,MAAMJ,KAAK,CAACS,SAAS,GAAGnB,KAAKI,yBAAyBM,KAAK,EAAEP,OAAOO,KAAK,EAAEI,MAAMJ,KAAK,CAACS,SAAS;IAClG;IACA,IAAIL,MAAMF,QAAQ,EAAE;QAClB,oDAAoD;QACpDE,MAAMF,QAAQ,CAACO,SAAS,GAAGnB,KAAKI,yBAAyBQ,QAAQ,EAAEE,MAAMF,QAAQ,CAACO,SAAS;IAC7F;IACA,OAAOL;AACT,EAAE"}
|
|
@@ -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,iBAAi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DA,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
|
+
{"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,a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F,SAAS;IAGhB,oDAAoD;IACpD9E,KAAK8E,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"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
@layer fluentui {
|
|
2
|
+
.root {
|
|
3
|
+
display: grid;
|
|
4
|
+
grid-template-rows: 1fr auto;
|
|
5
|
+
grid-template-columns: auto auto 1fr auto;
|
|
6
|
+
grid-template-areas:
|
|
7
|
+
'expandIcon media main aside'
|
|
8
|
+
'expandIcon media description aside';
|
|
9
|
+
align-items: center;
|
|
10
|
+
font-family: var(--fontFamilyBase);
|
|
11
|
+
font-size: var(--fontSizeBase300);
|
|
12
|
+
font-weight: var(--fontWeightRegular);
|
|
13
|
+
line-height: var(--lineHeightBase300);
|
|
14
|
+
|
|
15
|
+
/* Preserve the original reset: hover takes precedence while active. */
|
|
16
|
+
&:active {
|
|
17
|
+
color: var(--colorNeutralForeground2Pressed);
|
|
18
|
+
background-color: var(--colorSubtleBackgroundPressed);
|
|
19
|
+
& :global(.fui-TreeItemPersonaLayout__expandIcon) {
|
|
20
|
+
color: var(--colorNeutralForeground3Pressed);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
&:hover {
|
|
24
|
+
color: var(--colorNeutralForeground2Hover);
|
|
25
|
+
background-color: var(--colorSubtleBackgroundHover);
|
|
26
|
+
& :global(.fui-TreeItemPersonaLayout__expandIcon) {
|
|
27
|
+
color: var(--colorNeutralForeground3Hover);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.leaf {
|
|
33
|
+
padding-inline-start: calc(var(--fluent-TreeItem--level, 1) * var(--spacingHorizontalXXL));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.branch {
|
|
37
|
+
padding-inline-start: calc((var(--fluent-TreeItem--level, 1) - 1) * var(--spacingHorizontalXXL));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.medium {
|
|
41
|
+
font-family: var(--fontFamilyBase);
|
|
42
|
+
font-size: var(--fontSizeBase300);
|
|
43
|
+
font-weight: var(--fontWeightRegular);
|
|
44
|
+
line-height: var(--lineHeightBase300);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.small {
|
|
48
|
+
min-height: var(--spacingHorizontalXXL);
|
|
49
|
+
font-family: var(--fontFamilyBase);
|
|
50
|
+
font-size: var(--fontSizeBase200);
|
|
51
|
+
font-weight: var(--fontWeightRegular);
|
|
52
|
+
line-height: var(--lineHeightBase200);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.subtle {
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.subtle-alpha {
|
|
59
|
+
&:hover {
|
|
60
|
+
background-color: var(--colorSubtleBackgroundLightAlphaHover);
|
|
61
|
+
}
|
|
62
|
+
&:active {
|
|
63
|
+
background-color: var(--colorSubtleBackgroundLightAlphaPressed);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.transparent {
|
|
68
|
+
background-color: var(--colorTransparentBackground);
|
|
69
|
+
&:hover {
|
|
70
|
+
background-color: var(--colorTransparentBackgroundHover);
|
|
71
|
+
}
|
|
72
|
+
&:active {
|
|
73
|
+
background-color: var(--colorTransparentBackgroundPressed);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.media {
|
|
78
|
+
display: flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
width: var(--spacingHorizontalXXXL);
|
|
81
|
+
height: var(--spacingHorizontalXXXL);
|
|
82
|
+
grid-area: media;
|
|
83
|
+
padding-top: 0;
|
|
84
|
+
padding-inline-end: var(--spacingHorizontalXS);
|
|
85
|
+
padding-bottom: 0;
|
|
86
|
+
padding-inline-start: var(--spacingHorizontalXXS);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.main {
|
|
90
|
+
grid-area: main;
|
|
91
|
+
padding-top: var(--spacingVerticalMNudge);
|
|
92
|
+
padding-inline-end: var(--spacingHorizontalXS);
|
|
93
|
+
padding-bottom: var(--spacingVerticalMNudge);
|
|
94
|
+
padding-inline-start: var(--spacingHorizontalS);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.description {
|
|
98
|
+
grid-area: description;
|
|
99
|
+
font-family: var(--fontFamilyBase);
|
|
100
|
+
font-size: var(--fontSizeBase200);
|
|
101
|
+
font-weight: var(--fontWeightRegular);
|
|
102
|
+
line-height: var(--lineHeightBase200);
|
|
103
|
+
padding-top: 0;
|
|
104
|
+
padding-inline-end: var(--spacingHorizontalXS);
|
|
105
|
+
padding-bottom: var(--spacingVerticalMNudge);
|
|
106
|
+
padding-inline-start: var(--spacingHorizontalS);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.actions {
|
|
110
|
+
display: flex;
|
|
111
|
+
margin-inline-start: auto;
|
|
112
|
+
position: relative;
|
|
113
|
+
z-index: 1;
|
|
114
|
+
grid-area: aside;
|
|
115
|
+
padding: 0 var(--spacingHorizontalS);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.aside {
|
|
119
|
+
display: flex;
|
|
120
|
+
margin-inline-start: auto;
|
|
121
|
+
align-items: center;
|
|
122
|
+
z-index: 0;
|
|
123
|
+
grid-area: aside;
|
|
124
|
+
padding: 0 var(--spacingHorizontalM);
|
|
125
|
+
gap: var(--spacingHorizontalXS);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.expandIcon {
|
|
129
|
+
display: flex;
|
|
130
|
+
align-items: center;
|
|
131
|
+
justify-content: center;
|
|
132
|
+
min-width: var(--spacingHorizontalXXL);
|
|
133
|
+
box-sizing: border-box;
|
|
134
|
+
color: var(--colorNeutralForeground3);
|
|
135
|
+
grid-area: expandIcon;
|
|
136
|
+
flex: 0 0 auto;
|
|
137
|
+
padding: var(--spacingVerticalXS) 0;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.selector {
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
:where(.withDescription) > .main {
|
|
144
|
+
padding-top: var(--spacingVerticalMNudge);
|
|
145
|
+
padding-inline-end: var(--spacingHorizontalXS);
|
|
146
|
+
padding-bottom: 0;
|
|
147
|
+
padding-inline-start: var(--spacingHorizontalS);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -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"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { clsx } from "clsx";
|
|
3
|
+
import { useTreeContext_unstable } from "../../contexts/treeContext.js";
|
|
4
|
+
import { useTreeItemContext_unstable } from "../../contexts/treeItemContext.js";
|
|
5
|
+
import styles from "./TreeItemPersonaLayout.module.css";
|
|
6
|
+
export const treeItemPersonaLayoutClassNames = {
|
|
7
|
+
root: 'fui-TreeItemPersonaLayout',
|
|
8
|
+
media: 'fui-TreeItemPersonaLayout__media',
|
|
9
|
+
description: 'fui-TreeItemPersonaLayout__description',
|
|
10
|
+
main: 'fui-TreeItemPersonaLayout__main',
|
|
11
|
+
expandIcon: 'fui-TreeItemPersonaLayout__expandIcon',
|
|
12
|
+
aside: 'fui-TreeItemPersonaLayout__aside',
|
|
13
|
+
actions: 'fui-TreeItemPersonaLayout__actions',
|
|
14
|
+
selector: 'fui-TreeItemPersonaLayout__selector'
|
|
15
|
+
};
|
|
16
|
+
export const useTreeItemPersonaLayoutStyles_unstable = (state)=>{
|
|
17
|
+
const size = useTreeContext_unstable((ctx)=>ctx.size);
|
|
18
|
+
const appearance = useTreeContext_unstable((ctx)=>ctx.appearance);
|
|
19
|
+
const itemType = useTreeItemContext_unstable((ctx)=>ctx.itemType);
|
|
20
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
21
|
+
state.root.className = clsx(treeItemPersonaLayoutClassNames.root, styles.root, styles[itemType], styles[appearance], styles[size], state.description && styles.withDescription, state.root.className);
|
|
22
|
+
if (state.media) {
|
|
23
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
24
|
+
state.media.className = clsx(treeItemPersonaLayoutClassNames.media, styles.media, state.media.className);
|
|
25
|
+
}
|
|
26
|
+
if (state.main) {
|
|
27
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
28
|
+
state.main.className = clsx(treeItemPersonaLayoutClassNames.main, styles.main, state.main.className);
|
|
29
|
+
}
|
|
30
|
+
if (state.description) {
|
|
31
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
32
|
+
state.description.className = clsx(treeItemPersonaLayoutClassNames.description, styles.description, state.description.className);
|
|
33
|
+
}
|
|
34
|
+
if (state.actions) {
|
|
35
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
36
|
+
state.actions.className = clsx(treeItemPersonaLayoutClassNames.actions, styles.actions, state.actions.className);
|
|
37
|
+
}
|
|
38
|
+
if (state.aside) {
|
|
39
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
40
|
+
state.aside.className = clsx(treeItemPersonaLayoutClassNames.aside, styles.aside, state.aside.className);
|
|
41
|
+
}
|
|
42
|
+
if (state.expandIcon) {
|
|
43
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
44
|
+
state.expandIcon.className = clsx(treeItemPersonaLayoutClassNames.expandIcon, styles.expandIcon, state.expandIcon.className);
|
|
45
|
+
}
|
|
46
|
+
if (state.selector) {
|
|
47
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
48
|
+
state.selector.className = clsx(treeItemPersonaLayoutClassNames.selector, state.selector.className);
|
|
49
|
+
}
|
|
50
|
+
return state;
|
|
51
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.styles.css.ts"],"sourcesContent":["'use client';\n\nimport { clsx } from 'clsx';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport type { TreeItemPersonaLayoutState, TreeItemPersonaLayoutSlots } from './TreeItemPersonaLayout.types';\nimport { useTreeContext_unstable } from '../../contexts/treeContext';\nimport { useTreeItemContext_unstable } from '../../contexts/treeItemContext';\nimport styles from './TreeItemPersonaLayout.module.css';\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\nexport const useTreeItemPersonaLayoutStyles_unstable = (\n state: TreeItemPersonaLayoutState,\n): TreeItemPersonaLayoutState => {\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 // eslint-disable-next-line react-hooks/immutability\n state.root.className = clsx(\n treeItemPersonaLayoutClassNames.root,\n styles.root,\n styles[itemType],\n styles[appearance],\n styles[size],\n state.description && styles.withDescription,\n state.root.className,\n );\n if (state.media) {\n // eslint-disable-next-line react-hooks/immutability\n state.media.className = clsx(treeItemPersonaLayoutClassNames.media, styles.media, state.media.className);\n }\n if (state.main) {\n // eslint-disable-next-line react-hooks/immutability\n state.main.className = clsx(treeItemPersonaLayoutClassNames.main, styles.main, state.main.className);\n }\n if (state.description) {\n // eslint-disable-next-line react-hooks/immutability\n state.description.className = clsx(\n treeItemPersonaLayoutClassNames.description,\n styles.description,\n state.description.className,\n );\n }\n if (state.actions) {\n // eslint-disable-next-line react-hooks/immutability\n state.actions.className = clsx(treeItemPersonaLayoutClassNames.actions, styles.actions, state.actions.className);\n }\n if (state.aside) {\n // eslint-disable-next-line react-hooks/immutability\n state.aside.className = clsx(treeItemPersonaLayoutClassNames.aside, styles.aside, state.aside.className);\n }\n if (state.expandIcon) {\n // eslint-disable-next-line react-hooks/immutability\n state.expandIcon.className = clsx(\n treeItemPersonaLayoutClassNames.expandIcon,\n styles.expandIcon,\n state.expandIcon.className,\n );\n }\n if (state.selector) {\n // eslint-disable-next-line react-hooks/immutability\n state.selector.className = clsx(treeItemPersonaLayoutClassNames.selector, state.selector.className);\n }\n return state;\n};\n"],"names":["clsx","useTreeContext_unstable","useTreeItemContext_unstable","styles","treeItemPersonaLayoutClassNames","root","media","description","main","expandIcon","aside","actions","selector","useTreeItemPersonaLayoutStyles_unstable","state","size","ctx","appearance","itemType","className","withDescription"],"mappings":"AAAA;AAEA,SAASA,IAAI,QAAQ,OAAO;AAG5B,SAASC,uBAAuB,QAAQ,gCAA6B;AACrE,SAASC,2BAA2B,QAAQ,oCAAiC;AAC7E,OAAOC,YAAY,qCAAqC;AAExD,OAAO,MAAMC,kCAA8E;IACzFC,MAAM;IACNC,OAAO;IACPC,aAAa;IACbC,MAAM;IACNC,YAAY;IACZC,OAAO;IACPC,SAAS;IACTC,UAAU;AACZ,EAAE;AAEF,OAAO,MAAMC,0CAA0C,CACrDC;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