Private
Public Access
1
0

feat: Fluent UI Outlook Lite + connections mockup

This commit is contained in:
2026-04-14 18:52:25 +00:00
parent 1199eff6c3
commit dfa4010406
34820 changed files with 1003813 additions and 205 deletions

View File

@@ -0,0 +1,17 @@
'use client';
import * as React from 'react';
import { useTreeItemLayout_unstable } from './useTreeItemLayout';
import { renderTreeItemLayout_unstable } from './renderTreeItemLayout';
import { useTreeItemLayoutStyles_unstable } from './useTreeItemLayoutStyles.styles';
import { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';
/**
* The `TreeItemLayout` component is used as a child of `TreeItem` to define the content and layout of a tree item.
* It provides a consistent visual structure for tree items in a `Tree` component.
* This component should only be used as a direct child of `TreeItem`.
*/ export const TreeItemLayout = /*#__PURE__*/ React.forwardRef((props, ref)=>{
const state = useTreeItemLayout_unstable(props, ref);
useTreeItemLayoutStyles_unstable(state);
useCustomStyleHook_unstable('useTreeItemLayoutStyles_unstable')(state);
return renderTreeItemLayout_unstable(state);
});
TreeItemLayout.displayName = 'TreeItemLayout';

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/components/TreeItemLayout/TreeItemLayout.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useTreeItemLayout_unstable } from './useTreeItemLayout';\nimport { renderTreeItemLayout_unstable } from './renderTreeItemLayout';\nimport { useTreeItemLayoutStyles_unstable } from './useTreeItemLayoutStyles.styles';\nimport type { TreeItemLayoutProps } from './TreeItemLayout.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';\n\n/**\n * The `TreeItemLayout` component is used as a child of `TreeItem` to define the content and layout of a tree item.\n * It provides a consistent visual structure for tree items in a `Tree` component.\n * This component should only be used as a direct child of `TreeItem`.\n */\nexport const TreeItemLayout: ForwardRefComponent<TreeItemLayoutProps> = React.forwardRef((props, ref) => {\n const state = useTreeItemLayout_unstable(props, ref);\n\n useTreeItemLayoutStyles_unstable(state);\n useCustomStyleHook_unstable('useTreeItemLayoutStyles_unstable')(state);\n\n return renderTreeItemLayout_unstable(state);\n});\n\nTreeItemLayout.displayName = 'TreeItemLayout';\n"],"names":["React","useTreeItemLayout_unstable","renderTreeItemLayout_unstable","useTreeItemLayoutStyles_unstable","useCustomStyleHook_unstable","TreeItemLayout","forwardRef","props","ref","state","displayName"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,0BAA0B,QAAQ,sBAAsB;AACjE,SAASC,6BAA6B,QAAQ,yBAAyB;AACvE,SAASC,gCAAgC,QAAQ,mCAAmC;AAGpF,SAASC,2BAA2B,QAAQ,kCAAkC;AAE9E;;;;CAIC,GACD,OAAO,MAAMC,+BAA2DL,MAAMM,UAAU,CAAC,CAACC,OAAOC;IAC/F,MAAMC,QAAQR,2BAA2BM,OAAOC;IAEhDL,iCAAiCM;IACjCL,4BAA4B,oCAAoCK;IAEhE,OAAOP,8BAA8BO;AACvC,GAAG;AAEHJ,eAAeK,WAAW,GAAG"}

View File

@@ -0,0 +1,3 @@
/**
* State used in rendering TreeItemLayout
*/ export { };

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/components/TreeItemLayout/TreeItemLayout.types.ts"],"sourcesContent":["import type * as React from 'react';\nimport type {\n Slot,\n ComponentProps,\n ComponentState,\n ExtractSlotProps,\n EventData,\n EventHandler,\n} from '@fluentui/react-utilities';\nimport { ButtonContextValue } from '@fluentui/react-button';\nimport { Checkbox } from '@fluentui/react-checkbox';\nimport { Radio } from '@fluentui/react-radio';\n\nexport type TreeItemLayoutActionVisibilityChangeData = (\n | EventData<'mouseover' | 'mouseout', MouseEvent>\n | EventData<'focus' | 'blur', FocusEvent>\n | EventData<'blur', React.FocusEvent>\n) & { visible: boolean };\n\nexport type TreeItemLayoutActionSlotProps = ExtractSlotProps<\n Slot<'div'> & {\n /**\n * Forces visibility of the aside/action content\n */\n visible?: boolean;\n onVisibilityChange?: EventHandler<TreeItemLayoutActionVisibilityChangeData>;\n }\n>;\n\nexport type TreeItemLayoutSlots = {\n root: Slot<'div'>;\n /**\n * Content. Children of the root slot are automatically rendered here\n */\n main: NonNullable<Slot<'div'>>;\n /**\n * Icon slot that renders right before main content\n */\n iconBefore?: Slot<'div'>;\n /**\n * Icon slot that renders right after main content\n */\n iconAfter?: Slot<'div'>;\n /**\n * Expand icon slot,\n * by default renders a chevron icon to indicate opening and closing\n */\n expandIcon?: Slot<'div'>;\n /**\n * Aside content is normally used to render a badge or other non-actionable content\n */\n aside?: Slot<'div'>;\n /**\n * Actionable elements are normally buttons, menus, or other focusable elements.\n * Those elements are only visibly available if the given tree item is currently active.\n *\n * `actions` and `aside` slots are positioned on the exact same spot,\n * so they won't be visible at the same time.\n * `aside` slot is visible by default meanwhile `actions` slot are only visible when the tree item is active.\n *\n * `actions` slot supports a `visible` prop to force visibility of the actions.\n */\n actions?: Slot<TreeItemLayoutActionSlotProps>;\n selector?: Slot<typeof Checkbox> | Slot<typeof Radio>;\n};\n\n/**\n * TreeItemLayout Props\n */\nexport type TreeItemLayoutProps = ComponentProps<Partial<TreeItemLayoutSlots>>;\n\n/**\n * State used in rendering TreeItemLayout\n */\nexport type TreeItemLayoutState = ComponentState<TreeItemLayoutSlots> & {\n buttonContextValue: ButtonContextValue;\n};\n"],"names":[],"mappings":"AAuEA;;CAEC,GACD,WAEE"}

View File

@@ -0,0 +1,4 @@
export { TreeItemLayout } from './TreeItemLayout';
export { renderTreeItemLayout_unstable } from './renderTreeItemLayout';
export { useTreeItemLayout_unstable } from './useTreeItemLayout';
export { treeItemLayoutClassNames, useTreeItemLayoutStyles_unstable } from './useTreeItemLayoutStyles.styles';

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/components/TreeItemLayout/index.ts"],"sourcesContent":["export { TreeItemLayout } from './TreeItemLayout';\nexport type {\n TreeItemLayoutActionSlotProps,\n TreeItemLayoutActionVisibilityChangeData,\n TreeItemLayoutProps,\n TreeItemLayoutSlots,\n TreeItemLayoutState,\n} from './TreeItemLayout.types';\nexport { renderTreeItemLayout_unstable } from './renderTreeItemLayout';\nexport { useTreeItemLayout_unstable } from './useTreeItemLayout';\nexport { treeItemLayoutClassNames, useTreeItemLayoutStyles_unstable } from './useTreeItemLayoutStyles.styles';\n"],"names":["TreeItemLayout","renderTreeItemLayout_unstable","useTreeItemLayout_unstable","treeItemLayoutClassNames","useTreeItemLayoutStyles_unstable"],"mappings":"AAAA,SAASA,cAAc,QAAQ,mBAAmB;AAQlD,SAASC,6BAA6B,QAAQ,yBAAyB;AACvE,SAASC,0BAA0B,QAAQ,sBAAsB;AACjE,SAASC,wBAAwB,EAAEC,gCAAgC,QAAQ,mCAAmC"}

View File

@@ -0,0 +1,26 @@
import { jsx as _jsx, jsxs as _jsxs } from "@fluentui/react-jsx-runtime/jsx-runtime";
import { assertSlots } from '@fluentui/react-utilities';
import { ButtonContextProvider } from '@fluentui/react-button';
/**
* Render the final JSX of TreeItemLayout
*/ export const renderTreeItemLayout_unstable = (state)=>{
assertSlots(state);
return /*#__PURE__*/ _jsxs(state.root, {
children: [
state.expandIcon && /*#__PURE__*/ _jsx(state.expandIcon, {}),
state.selector && /*#__PURE__*/ _jsx(state.selector, {}),
state.iconBefore && /*#__PURE__*/ _jsx(state.iconBefore, {}),
/*#__PURE__*/ _jsx(state.main, {
children: state.root.children
}),
state.iconAfter && /*#__PURE__*/ _jsx(state.iconAfter, {}),
/*#__PURE__*/ _jsxs(ButtonContextProvider, {
value: state.buttonContextValue,
children: [
state.actions && /*#__PURE__*/ _jsx(state.actions, {}),
state.aside && /*#__PURE__*/ _jsx(state.aside, {})
]
})
]
});
};

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/components/TreeItemLayout/renderTreeItemLayout.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport type { TreeItemLayoutState, TreeItemLayoutSlots } from './TreeItemLayout.types';\nimport { ButtonContextProvider } from '@fluentui/react-button';\n\n/**\n * Render the final JSX of TreeItemLayout\n */\nexport const renderTreeItemLayout_unstable = (state: TreeItemLayoutState): JSXElement => {\n assertSlots<TreeItemLayoutSlots>(state);\n\n return (\n <state.root>\n {state.expandIcon && <state.expandIcon />}\n {state.selector && <state.selector />}\n {state.iconBefore && <state.iconBefore />}\n <state.main>{state.root.children}</state.main>\n {state.iconAfter && <state.iconAfter />}\n <ButtonContextProvider value={state.buttonContextValue}>\n {state.actions && <state.actions />}\n {state.aside && <state.aside />}\n </ButtonContextProvider>\n </state.root>\n );\n};\n"],"names":["assertSlots","ButtonContextProvider","renderTreeItemLayout_unstable","state","root","expandIcon","selector","iconBefore","main","children","iconAfter","value","buttonContextValue","actions","aside"],"mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AACjD,SAASA,WAAW,QAAQ,4BAA4B;AAGxD,SAASC,qBAAqB,QAAQ,yBAAyB;AAE/D;;CAEC,GACD,OAAO,MAAMC,gCAAgC,CAACC;IAC5CH,YAAiCG;IAEjC,qBACE,MAACA,MAAMC,IAAI;;YACRD,MAAME,UAAU,kBAAI,KAACF,MAAME,UAAU;YACrCF,MAAMG,QAAQ,kBAAI,KAACH,MAAMG,QAAQ;YACjCH,MAAMI,UAAU,kBAAI,KAACJ,MAAMI,UAAU;0BACtC,KAACJ,MAAMK,IAAI;0BAAEL,MAAMC,IAAI,CAACK,QAAQ;;YAC/BN,MAAMO,SAAS,kBAAI,KAACP,MAAMO,SAAS;0BACpC,MAACT;gBAAsBU,OAAOR,MAAMS,kBAAkB;;oBACnDT,MAAMU,OAAO,kBAAI,KAACV,MAAMU,OAAO;oBAC/BV,MAAMW,KAAK,kBAAI,KAACX,MAAMW,KAAK;;;;;AAIpC,EAAE"}

View File

@@ -0,0 +1,241 @@
'use client';
import * as React from 'react';
import { getIntrinsicElementProps, isResolvedShorthand, useMergedRefs, slot, useEventCallback, elementContains, useControllableState } from '@fluentui/react-utilities';
import { useTreeItemContext_unstable, useTreeContext_unstable } from '../../contexts';
import { Checkbox } from '@fluentui/react-checkbox';
import { Radio } from '@fluentui/react-radio';
import { TreeItemChevron } from '../TreeItemChevron';
import { useArrowNavigationGroup, useIsNavigatingWithKeyboard } from '@fluentui/react-tabster';
import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
/**
* Create the state required to render TreeItemLayout.
*
* The returned state can be modified with hooks such as useTreeItemLayoutStyles_unstable,
* before being passed to renderTreeItemLayout_unstable.
*
* @param props - props from this instance of TreeItemLayout
* @param ref - reference to root HTMLElement of TreeItemLayout
*/ export const useTreeItemLayout_unstable = (props, ref)=>{
'use no memo';
const { main, iconAfter, iconBefore } = props;
const layoutRef = useTreeItemContext_unstable((ctx)=>ctx.layoutRef);
const selectionMode = useTreeContext_unstable((ctx)=>ctx.selectionMode);
const navigationMode = useTreeContext_unstable((ctx)=>{
var _ctx_navigationMode;
return (_ctx_navigationMode = ctx.navigationMode) !== null && _ctx_navigationMode !== void 0 ? _ctx_navigationMode : 'tree';
});
const [isActionsVisibleFromProps, onActionVisibilityChange] = isResolvedShorthand(props.actions) ? [
props.actions.visible,
props.actions.onVisibilityChange
] : [
undefined,
undefined
];
const [isActionsVisible, setIsActionsVisible] = useControllableState({
state: isActionsVisibleFromProps,
initialState: false
});
const selectionRef = useTreeItemContext_unstable((ctx)=>ctx.selectionRef);
const expandIconRef = useTreeItemContext_unstable((ctx)=>ctx.expandIconRef);
const actionsRef = useTreeItemContext_unstable((ctx)=>ctx.actionsRef);
const actionsRefInternal = React.useRef(null);
const treeItemRef = useTreeItemContext_unstable((ctx)=>ctx.treeItemRef);
const subtreeRef = useTreeItemContext_unstable((ctx)=>ctx.subtreeRef);
const checked = useTreeItemContext_unstable((ctx)=>ctx.checked);
const isBranch = useTreeItemContext_unstable((ctx)=>ctx.itemType === 'branch');
// FIXME: Asserting is required here, as converting this to RefObject on context type would be a breaking change
assertIsRefObject(treeItemRef);
// FIXME: Asserting is required here, as converting this to RefObject on context type would be a breaking change
assertIsRefObject(subtreeRef);
const setActionsVisibleIfNotFromSubtree = React.useCallback((event)=>{
const isTargetFromSubtree = Boolean(subtreeRef.current && elementContains(subtreeRef.current, event.target));
if (!isTargetFromSubtree) {
onActionVisibilityChange === null || onActionVisibilityChange === void 0 ? void 0 : onActionVisibilityChange(event, {
visible: true,
event,
type: event.type
});
if (event.defaultPrevented) {
return;
}
setIsActionsVisible(true);
}
}, [
subtreeRef,
setIsActionsVisible,
onActionVisibilityChange
]);
const { targetDocument } = useFluent();
const isNavigatingWithKeyboard = useIsNavigatingWithKeyboard();
const setActionsInvisibleIfNotFromSubtree = React.useCallback((event)=>{
const isRelatedTargetFromActions = ()=>Boolean(actionsRefInternal.current && elementContains(actionsRefInternal.current, event.relatedTarget));
const isRelatedTargetFromTreeItem = ()=>Boolean(treeItemRef.current && elementContains(treeItemRef.current, event.relatedTarget));
const isTargetFromActions = ()=>{
var _actionsRefInternal_current;
return Boolean((_actionsRefInternal_current = actionsRefInternal.current) === null || _actionsRefInternal_current === void 0 ? void 0 : _actionsRefInternal_current.contains(event.target));
};
if (isRelatedTargetFromActions()) {
onActionVisibilityChange === null || onActionVisibilityChange === void 0 ? void 0 : onActionVisibilityChange(event, {
visible: true,
event,
type: event.type
});
if (event.defaultPrevented) {
return;
}
setIsActionsVisible(true);
return;
}
if (isTargetFromActions() && isRelatedTargetFromTreeItem()) {
return;
}
// when a mouseout event happens during keyboard interaction
// we should not hide the actions if the activeElement is the treeitem or an action
// as the focus on the treeitem takes precedence over the mouseout event
if (event.type === 'mouseout' && isNavigatingWithKeyboard() && ((targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.activeElement) === treeItemRef.current || elementContains(actionsRefInternal.current, targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.activeElement))) {
return;
}
onActionVisibilityChange === null || onActionVisibilityChange === void 0 ? void 0 : onActionVisibilityChange(event, {
visible: false,
event,
type: event.type
});
if (event.defaultPrevented) {
return;
}
setIsActionsVisible(false);
}, [
setIsActionsVisible,
onActionVisibilityChange,
treeItemRef,
isNavigatingWithKeyboard,
targetDocument
]);
const expandIcon = slot.optional(props.expandIcon, {
renderByDefault: isBranch,
defaultProps: {
children: /*#__PURE__*/ React.createElement(TreeItemChevron, null),
'aria-hidden': true
},
elementType: 'div'
});
const expandIconRefs = useMergedRefs(expandIcon === null || expandIcon === void 0 ? void 0 : expandIcon.ref, expandIconRef);
if (expandIcon) {
expandIcon.ref = expandIconRefs;
}
const arrowNavigationProps = useArrowNavigationGroup({
circular: navigationMode === 'tree',
axis: 'horizontal'
});
const actions = isActionsVisible ? slot.optional(props.actions, {
defaultProps: {
...arrowNavigationProps,
role: 'toolbar'
},
elementType: 'div'
}) : undefined;
actions === null || actions === void 0 ? true : delete actions.visible;
actions === null || actions === void 0 ? true : delete actions.onVisibilityChange;
const actionsRefs = useMergedRefs(actions === null || actions === void 0 ? void 0 : actions.ref, actionsRef, actionsRefInternal);
const handleActionsBlur = useEventCallback((event)=>{
if (isResolvedShorthand(props.actions)) {
var _props_actions_onBlur, _props_actions;
(_props_actions_onBlur = (_props_actions = props.actions).onBlur) === null || _props_actions_onBlur === void 0 ? void 0 : _props_actions_onBlur.call(_props_actions, event);
}
const isRelatedTargetFromActions = Boolean(elementContains(event.currentTarget, event.relatedTarget));
onActionVisibilityChange === null || onActionVisibilityChange === void 0 ? void 0 : onActionVisibilityChange(event, {
visible: isRelatedTargetFromActions,
event,
type: event.type
});
setIsActionsVisible(isRelatedTargetFromActions);
});
if (actions) {
actions.ref = actionsRefs;
actions.onBlur = handleActionsBlur;
}
const hasActions = Boolean(props.actions);
React.useEffect(()=>{
if (treeItemRef.current && hasActions) {
const treeItemElement = treeItemRef.current;
const handleMouseOver = setActionsVisibleIfNotFromSubtree;
const handleMouseOut = setActionsInvisibleIfNotFromSubtree;
const handleFocus = setActionsVisibleIfNotFromSubtree;
const handleBlur = setActionsInvisibleIfNotFromSubtree;
treeItemElement.addEventListener('mouseover', handleMouseOver);
treeItemElement.addEventListener('mouseout', handleMouseOut);
treeItemElement.addEventListener('focus', handleFocus);
treeItemElement.addEventListener('blur', handleBlur);
return ()=>{
treeItemElement.removeEventListener('mouseover', handleMouseOver);
treeItemElement.removeEventListener('mouseout', handleMouseOut);
treeItemElement.removeEventListener('focus', handleFocus);
treeItemElement.removeEventListener('blur', handleBlur);
};
}
}, [
hasActions,
treeItemRef,
setActionsVisibleIfNotFromSubtree,
setActionsInvisibleIfNotFromSubtree
]);
return {
components: {
root: 'div',
expandIcon: 'div',
iconBefore: 'div',
main: 'div',
iconAfter: 'div',
actions: 'div',
aside: 'div',
// Casting here to a union between checkbox and radio
selector: selectionMode === 'multiselect' ? Checkbox : Radio
},
buttonContextValue: {
size: 'small'
},
root: slot.always(getIntrinsicElementProps('div', {
...props,
// FIXME:
// `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLDivElement`
// but since it would be a breaking change to fix it, we are casting ref to it's proper type
ref: useMergedRefs(ref, layoutRef)
}), {
elementType: 'div'
}),
iconBefore: slot.optional(iconBefore, {
elementType: 'div'
}),
main: slot.always(main, {
elementType: 'div'
}),
iconAfter: slot.optional(iconAfter, {
elementType: 'div'
}),
aside: !isActionsVisible ? slot.optional(props.aside, {
elementType: 'div'
}) : undefined,
actions,
expandIcon,
selector: slot.optional(props.selector, {
renderByDefault: selectionMode !== 'none',
defaultProps: {
checked,
tabIndex: -1,
'aria-hidden': true,
ref: selectionRef
},
elementType: selectionMode === 'multiselect' ? Checkbox : Radio
})
};
};
function assertIsRefObject(ref) {
if (process.env.NODE_ENV !== 'production') {
if (typeof ref !== 'object' || ref === null || !('current' in ref)) {
throw new Error(`
@fluentui/react-tree [${useTreeItemLayout_unstable.name}]:
Internal Error: contextual ref is not a RefObject! Please report this bug immediately, as contextual refs should be RefObjects.
`);
}
}
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,146 @@
'use client';
import { __resetStyles, __styles, mergeClasses } from '@griffel/react';
import { tokens, typographyStyles } from '@fluentui/react-theme';
import { useTreeContext_unstable } from '../../contexts/treeContext';
import { treeItemLevelToken } from '../../utils/tokens';
import { useTreeItemContext_unstable } from '../../contexts/treeItemContext';
export const treeItemLayoutClassNames = {
root: 'fui-TreeItemLayout',
iconBefore: 'fui-TreeItemLayout__iconBefore',
main: 'fui-TreeItemLayout__main',
iconAfter: 'fui-TreeItemLayout__iconAfter',
expandIcon: 'fui-TreeItemLayout__expandIcon',
aside: 'fui-TreeItemLayout__aside',
actions: 'fui-TreeItemLayout__actions',
selector: 'fui-TreeItemLayout__selector'
};
const useRootBaseStyles = /*#__PURE__*/__resetStyles("ryb8khq", null, [".ryb8khq{display:flex;align-items:center;min-height:32px;box-sizing:border-box;grid-area:layout;}", ".ryb8khq:hover{color:var(--colorNeutralForeground2Hover);background-color:var(--colorSubtleBackgroundHover);}", ".ryb8khq:hover .fui-TreeItemLayout__expandIcon{color:var(--colorNeutralForeground3Hover);}", ".ryb8khq:active{color:var(--colorNeutralForeground2Pressed);background-color:var(--colorSubtleBackgroundPressed);}", ".ryb8khq:active .fui-TreeItemLayout__expandIcon{color:var(--colorNeutralForeground3Pressed);}"]);
/**
* Styles for the root slot
*/
const useRootStyles = /*#__PURE__*/__styles({
leaf: {
uwmqm3: ["f1k1erfc", "faevyjx"]
},
branch: {
uwmqm3: ["fo100m9", "f6yw3pu"]
},
medium: {
Bahqtrf: "fk6fouc",
Be2twd7: "fkhj508",
Bhrd7zp: "figsok6",
Bg96gwp: "f1i3iumi"
},
small: {
sshi5w: "f1pha7fy",
Bahqtrf: "fk6fouc",
Be2twd7: "fy9rknc",
Bhrd7zp: "figsok6",
Bg96gwp: "fwrc4pm"
},
subtle: {},
"subtle-alpha": {
Jwef8y: "f146ro5n",
ecr2s2: "fkam630"
},
transparent: {
De3pzq: "f1c21dwh",
Jwef8y: "fjxutwb",
ecr2s2: "fophhak"
}
}, {
d: [".f1k1erfc{padding-left:calc(var(--fluent-TreeItem--level, 1) * var(--spacingHorizontalXXL));}", ".faevyjx{padding-right:calc(var(--fluent-TreeItem--level, 1) * var(--spacingHorizontalXXL));}", ".fo100m9{padding-left:calc((var(--fluent-TreeItem--level, 1) - 1) * var(--spacingHorizontalXXL));}", ".f6yw3pu{padding-right:calc((var(--fluent-TreeItem--level, 1) - 1) * var(--spacingHorizontalXXL));}", ".fk6fouc{font-family:var(--fontFamilyBase);}", ".fkhj508{font-size:var(--fontSizeBase300);}", ".figsok6{font-weight:var(--fontWeightRegular);}", ".f1i3iumi{line-height:var(--lineHeightBase300);}", ".f1pha7fy{min-height:24px;}", ".fy9rknc{font-size:var(--fontSizeBase200);}", ".fwrc4pm{line-height:var(--lineHeightBase200);}", ".f1c21dwh{background-color:var(--colorTransparentBackground);}"],
h: [".f146ro5n:hover{background-color:var(--colorSubtleBackgroundLightAlphaHover);}", ".fjxutwb:hover{background-color:var(--colorTransparentBackgroundHover);}"],
a: [".fkam630:active{background-color:var(--colorSubtleBackgroundLightAlphaPressed);}", ".fophhak:active{background-color:var(--colorTransparentBackgroundPressed);}"]
});
/**
* Styles for the action icon slot
*/
const useActionsBaseStyles = /*#__PURE__*/__resetStyles("rzvs2in", "r17h8a29", [".rzvs2in{display:flex;margin-left:auto;position:relative;z-index:1;grid-area:aside;padding:0 var(--spacingHorizontalS);}", ".r17h8a29{display:flex;margin-right:auto;position:relative;z-index:1;grid-area:aside;padding:0 var(--spacingHorizontalS);}"]);
/**
* Styles for the action icon slot
*/
const useAsideBaseStyles = /*#__PURE__*/__resetStyles("r1825u21", "rezy0yk", [".r1825u21{display:flex;margin-left:auto;align-items:center;z-index:0;grid-area:aside;padding:0 var(--spacingHorizontalM);gap:var(--spacingHorizontalXS);}", ".rezy0yk{display:flex;margin-right:auto;align-items:center;z-index:0;grid-area:aside;padding:0 var(--spacingHorizontalM);gap:var(--spacingHorizontalXS);}"]);
/**
* Styles for the expand icon slot
*/
const useExpandIconBaseStyles = /*#__PURE__*/__resetStyles("rh4pu5o", null, [".rh4pu5o{display:flex;align-items:center;justify-content:center;min-width:24px;box-sizing:border-box;color:var(--colorNeutralForeground3);flex:0 0 auto;padding:var(--spacingVerticalXS) 0;}"]);
/**
* Styles for the content slot
*/
const useMainBaseStyles = /*#__PURE__*/__resetStyles("rklbe47", null, [".rklbe47{padding:0 var(--spacingHorizontalXXS);}"]);
/**
* Styles for the before/after icon slot
*/
const useIconBaseStyles = /*#__PURE__*/__resetStyles("rphzgg1", null, [".rphzgg1{display:flex;align-items:center;color:var(--colorNeutralForeground2);line-height:var(--lineHeightBase500);font-size:var(--fontSizeBase500);}"]);
const useIconBeforeStyles = /*#__PURE__*/__styles({
medium: {
z189sj: ["f7x41pl", "fruq291"]
},
small: {
z189sj: ["ffczdla", "fgiv446"]
}
}, {
d: [".f7x41pl{padding-right:var(--spacingHorizontalXS);}", ".fruq291{padding-left:var(--spacingHorizontalXS);}", ".ffczdla{padding-right:var(--spacingHorizontalXXS);}", ".fgiv446{padding-left:var(--spacingHorizontalXXS);}"]
});
const useIconAfterStyles = /*#__PURE__*/__styles({
medium: {
uwmqm3: ["fruq291", "f7x41pl"]
},
small: {
uwmqm3: ["fgiv446", "ffczdla"]
}
}, {
d: [".fruq291{padding-left:var(--spacingHorizontalXS);}", ".f7x41pl{padding-right:var(--spacingHorizontalXS);}", ".fgiv446{padding-left:var(--spacingHorizontalXXS);}", ".ffczdla{padding-right:var(--spacingHorizontalXXS);}"]
});
/**
* Apply styling to the TreeItemLayout slots based on the state
*/
export const useTreeItemLayoutStyles_unstable = state => {
'use no memo';
const {
main,
iconAfter,
iconBefore,
expandIcon,
root,
aside,
actions,
selector
} = state;
const rootStyles = useRootStyles();
const rootBaseStyles = useRootBaseStyles();
const actionsBaseStyles = useActionsBaseStyles();
const asideBaseStyles = useAsideBaseStyles();
const mainBaseStyles = useMainBaseStyles();
const expandIconBaseStyles = useExpandIconBaseStyles();
const iconBaseStyles = useIconBaseStyles();
const iconBeforeStyles = useIconBeforeStyles();
const iconAfterStyles = useIconAfterStyles();
const size = useTreeContext_unstable(ctx => ctx.size);
const appearance = useTreeContext_unstable(ctx => ctx.appearance);
const itemType = useTreeItemContext_unstable(ctx => ctx.itemType);
root.className = mergeClasses(treeItemLayoutClassNames.root, rootBaseStyles, rootStyles[appearance], rootStyles[size], rootStyles[itemType], root.className);
main.className = mergeClasses(treeItemLayoutClassNames.main, mainBaseStyles, main.className);
if (expandIcon) {
expandIcon.className = mergeClasses(treeItemLayoutClassNames.expandIcon, expandIconBaseStyles, expandIcon.className);
}
if (iconBefore) {
iconBefore.className = mergeClasses(treeItemLayoutClassNames.iconBefore, iconBaseStyles, iconBeforeStyles[size], iconBefore.className);
}
if (iconAfter) {
iconAfter.className = mergeClasses(treeItemLayoutClassNames.iconAfter, iconBaseStyles, iconAfterStyles[size], iconAfter.className);
}
if (actions) {
actions.className = mergeClasses(treeItemLayoutClassNames.actions, actionsBaseStyles, actions.className);
}
if (aside) {
aside.className = mergeClasses(treeItemLayoutClassNames.aside, asideBaseStyles, aside.className);
}
if (selector) {
selector.className = mergeClasses(treeItemLayoutClassNames.selector, selector.className);
}
return state;
};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,177 @@
'use client';
import { makeResetStyles, makeStyles, mergeClasses } from '@griffel/react';
import { tokens, typographyStyles } from '@fluentui/react-theme';
import { useTreeContext_unstable } from '../../contexts/treeContext';
import { treeItemLevelToken } from '../../utils/tokens';
import { useTreeItemContext_unstable } from '../../contexts/treeItemContext';
export const treeItemLayoutClassNames = {
root: 'fui-TreeItemLayout',
iconBefore: 'fui-TreeItemLayout__iconBefore',
main: 'fui-TreeItemLayout__main',
iconAfter: 'fui-TreeItemLayout__iconAfter',
expandIcon: 'fui-TreeItemLayout__expandIcon',
aside: 'fui-TreeItemLayout__aside',
actions: 'fui-TreeItemLayout__actions',
selector: 'fui-TreeItemLayout__selector'
};
const useRootBaseStyles = makeResetStyles({
display: 'flex',
alignItems: 'center',
minHeight: '32px',
boxSizing: 'border-box',
gridArea: 'layout',
':hover': {
color: tokens.colorNeutralForeground2Hover,
backgroundColor: tokens.colorSubtleBackgroundHover,
// TODO: stop using treeItemLayoutClassNames.expandIcon for styling
[`& .${treeItemLayoutClassNames.expandIcon}`]: {
color: tokens.colorNeutralForeground3Hover
}
},
':active': {
color: tokens.colorNeutralForeground2Pressed,
backgroundColor: tokens.colorSubtleBackgroundPressed,
// TODO: stop using treeItemLayoutClassNames.expandIcon for styling
[`& .${treeItemLayoutClassNames.expandIcon}`]: {
color: tokens.colorNeutralForeground3Pressed
}
}
});
/**
* Styles for the root slot
*/ const useRootStyles = makeStyles({
leaf: {
paddingLeft: `calc(var(${treeItemLevelToken}, 1) * ${tokens.spacingHorizontalXXL})`
},
branch: {
paddingLeft: `calc((var(${treeItemLevelToken}, 1) - 1) * ${tokens.spacingHorizontalXXL})`
},
medium: {
...typographyStyles.body1
},
small: {
minHeight: '24px',
...typographyStyles.caption1
},
// Appearance variations
subtle: {},
'subtle-alpha': {
':hover': {
backgroundColor: tokens.colorSubtleBackgroundLightAlphaHover
},
':active': {
backgroundColor: tokens.colorSubtleBackgroundLightAlphaPressed
}
},
transparent: {
backgroundColor: tokens.colorTransparentBackground,
':hover': {
backgroundColor: tokens.colorTransparentBackgroundHover
},
':active': {
backgroundColor: tokens.colorTransparentBackgroundPressed
}
}
});
/**
* Styles for the action icon slot
*/ const useActionsBaseStyles = makeResetStyles({
display: 'flex',
marginLeft: 'auto',
position: 'relative',
zIndex: 1,
gridArea: 'aside',
padding: `0 ${tokens.spacingHorizontalS}`
});
/**
* Styles for the action icon slot
*/ const useAsideBaseStyles = makeResetStyles({
display: 'flex',
marginLeft: 'auto',
alignItems: 'center',
zIndex: 0,
gridArea: 'aside',
padding: `0 ${tokens.spacingHorizontalM}`,
gap: tokens.spacingHorizontalXS
});
/**
* Styles for the expand icon slot
*/ const useExpandIconBaseStyles = makeResetStyles({
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
minWidth: '24px',
boxSizing: 'border-box',
color: tokens.colorNeutralForeground3,
flex: `0 0 auto`,
padding: `${tokens.spacingVerticalXS} 0`
});
/**
* Styles for the content slot
*/ const useMainBaseStyles = makeResetStyles({
padding: `0 ${tokens.spacingHorizontalXXS}`
});
/**
* Styles for the before/after icon slot
*/ const useIconBaseStyles = makeResetStyles({
display: 'flex',
alignItems: 'center',
color: tokens.colorNeutralForeground2,
lineHeight: tokens.lineHeightBase500,
fontSize: tokens.fontSizeBase500
});
const useIconBeforeStyles = makeStyles({
medium: {
paddingRight: tokens.spacingHorizontalXS
},
small: {
paddingRight: tokens.spacingHorizontalXXS
}
});
const useIconAfterStyles = makeStyles({
medium: {
paddingLeft: tokens.spacingHorizontalXS
},
small: {
paddingLeft: tokens.spacingHorizontalXXS
}
});
/**
* Apply styling to the TreeItemLayout slots based on the state
*/ export const useTreeItemLayoutStyles_unstable = (state)=>{
'use no memo';
const { main, iconAfter, iconBefore, expandIcon, root, aside, actions, selector } = state;
const rootStyles = useRootStyles();
const rootBaseStyles = useRootBaseStyles();
const actionsBaseStyles = useActionsBaseStyles();
const asideBaseStyles = useAsideBaseStyles();
const mainBaseStyles = useMainBaseStyles();
const expandIconBaseStyles = useExpandIconBaseStyles();
const iconBaseStyles = useIconBaseStyles();
const iconBeforeStyles = useIconBeforeStyles();
const iconAfterStyles = useIconAfterStyles();
const size = useTreeContext_unstable((ctx)=>ctx.size);
const appearance = useTreeContext_unstable((ctx)=>ctx.appearance);
const itemType = useTreeItemContext_unstable((ctx)=>ctx.itemType);
root.className = mergeClasses(treeItemLayoutClassNames.root, rootBaseStyles, rootStyles[appearance], rootStyles[size], rootStyles[itemType], root.className);
main.className = mergeClasses(treeItemLayoutClassNames.main, mainBaseStyles, main.className);
if (expandIcon) {
expandIcon.className = mergeClasses(treeItemLayoutClassNames.expandIcon, expandIconBaseStyles, expandIcon.className);
}
if (iconBefore) {
iconBefore.className = mergeClasses(treeItemLayoutClassNames.iconBefore, iconBaseStyles, iconBeforeStyles[size], iconBefore.className);
}
if (iconAfter) {
iconAfter.className = mergeClasses(treeItemLayoutClassNames.iconAfter, iconBaseStyles, iconAfterStyles[size], iconAfter.className);
}
if (actions) {
actions.className = mergeClasses(treeItemLayoutClassNames.actions, actionsBaseStyles, actions.className);
}
if (aside) {
aside.className = mergeClasses(treeItemLayoutClassNames.aside, asideBaseStyles, aside.className);
}
if (selector) {
selector.className = mergeClasses(treeItemLayoutClassNames.selector, selector.className);
}
return state;
};

File diff suppressed because one or more lines are too long