@fluentui/react-tree 9.6.0 → 9.7.1
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 +121 -97
- package/dist/index.d.ts +15 -6
- package/lib/components/TreeItemLayout/TreeItemLayout.types.js.map +1 -1
- package/lib/components/TreeItemLayout/useTreeItemLayout.js +34 -13
- package/lib/components/TreeItemLayout/useTreeItemLayout.js.map +1 -1
- package/lib-commonjs/components/TreeItemLayout/useTreeItemLayout.js +34 -13
- package/lib-commonjs/components/TreeItemLayout/useTreeItemLayout.js.map +1 -1
- package/package.json +11 -14
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ import { ContextSelector } from '@fluentui/react-context-selector';
|
|
|
15
15
|
import type { DistributiveOmit } from '@fluentui/react-utilities';
|
|
16
16
|
import type { End } from '@fluentui/keyboard-keys';
|
|
17
17
|
import type { Enter } from '@fluentui/keyboard-keys';
|
|
18
|
+
import type { EventData } from '@fluentui/react-utilities';
|
|
19
|
+
import type { EventHandler } from '@fluentui/react-utilities';
|
|
18
20
|
import type { ExtractSlotProps } from '@fluentui/react-utilities';
|
|
19
21
|
import { ForwardRefComponent } from '@fluentui/react-utilities';
|
|
20
22
|
import type { Home } from '@fluentui/keyboard-keys';
|
|
@@ -497,6 +499,18 @@ declare type TreeItemCSSProperties = React_2.CSSProperties & {
|
|
|
497
499
|
*/
|
|
498
500
|
export declare const TreeItemLayout: ForwardRefComponent<TreeItemLayoutProps>;
|
|
499
501
|
|
|
502
|
+
declare type TreeItemLayoutActionSlotProps = ExtractSlotProps<Slot<'div'> & {
|
|
503
|
+
/**
|
|
504
|
+
* Forces visibility of the aside/action content
|
|
505
|
+
*/
|
|
506
|
+
visible?: boolean;
|
|
507
|
+
onVisibilityChange?: EventHandler<TreeItemLayoutActionVisibilityChangeData>;
|
|
508
|
+
}>;
|
|
509
|
+
|
|
510
|
+
declare type TreeItemLayoutActionVisibilityChangeData = (EventData<'mouseover' | 'mouseout', MouseEvent> | EventData<'focus' | 'blur', FocusEvent> | EventData<'blur', React_2.FocusEvent>) & {
|
|
511
|
+
visible: boolean;
|
|
512
|
+
};
|
|
513
|
+
|
|
500
514
|
export declare const treeItemLayoutClassNames: SlotClassNames<TreeItemLayoutSlots>;
|
|
501
515
|
|
|
502
516
|
/**
|
|
@@ -538,12 +552,7 @@ export declare type TreeItemLayoutSlots = {
|
|
|
538
552
|
*
|
|
539
553
|
* `actions` slot supports a `visible` prop to force visibility of the actions.
|
|
540
554
|
*/
|
|
541
|
-
actions?: Slot<
|
|
542
|
-
/**
|
|
543
|
-
* Forces visibility of the aside/action content
|
|
544
|
-
*/
|
|
545
|
-
visible?: boolean;
|
|
546
|
-
}>>;
|
|
555
|
+
actions?: Slot<TreeItemLayoutActionSlotProps>;
|
|
547
556
|
selector?: Slot<typeof Checkbox> | Slot<typeof Radio>;
|
|
548
557
|
};
|
|
549
558
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["TreeItemLayout.types.ts"],"sourcesContent":["import type
|
|
1
|
+
{"version":3,"sources":["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 * It is aria-hidden by default and is only meant to be used as visual aid.\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":"AAAA,WA6EE"}
|
|
@@ -17,15 +17,12 @@ import { useArrowNavigationGroup } from '@fluentui/react-tabster';
|
|
|
17
17
|
const { main, iconAfter, iconBefore } = props;
|
|
18
18
|
const layoutRef = useTreeItemContext_unstable((ctx)=>ctx.layoutRef);
|
|
19
19
|
const selectionMode = useTreeContext_unstable((ctx)=>ctx.selectionMode);
|
|
20
|
-
const [isActionsVisibleFromProps,
|
|
20
|
+
const [isActionsVisibleFromProps, onActionVisibilityChange] = isResolvedShorthand(props.actions) ? [
|
|
21
21
|
props.actions.visible,
|
|
22
|
-
|
|
23
|
-
...props.actions,
|
|
24
|
-
visible: undefined
|
|
25
|
-
}
|
|
22
|
+
props.actions.onVisibilityChange
|
|
26
23
|
] : [
|
|
27
24
|
undefined,
|
|
28
|
-
|
|
25
|
+
undefined
|
|
29
26
|
];
|
|
30
27
|
const [isActionsVisible, setIsActionsVisible] = useControllableState({
|
|
31
28
|
state: isActionsVisibleFromProps,
|
|
@@ -46,26 +43,43 @@ import { useArrowNavigationGroup } from '@fluentui/react-tabster';
|
|
|
46
43
|
const setActionsVisibleIfNotFromSubtree = React.useCallback((event)=>{
|
|
47
44
|
const isTargetFromSubtree = Boolean(subtreeRef.current && elementContains(subtreeRef.current, event.target));
|
|
48
45
|
if (!isTargetFromSubtree) {
|
|
46
|
+
onActionVisibilityChange === null || onActionVisibilityChange === void 0 ? void 0 : onActionVisibilityChange(event, {
|
|
47
|
+
visible: true,
|
|
48
|
+
event,
|
|
49
|
+
type: event.type
|
|
50
|
+
});
|
|
49
51
|
setIsActionsVisible(true);
|
|
50
52
|
}
|
|
51
53
|
}, [
|
|
52
54
|
subtreeRef,
|
|
53
|
-
setIsActionsVisible
|
|
55
|
+
setIsActionsVisible,
|
|
56
|
+
onActionVisibilityChange
|
|
54
57
|
]);
|
|
55
58
|
const setActionsInvisibleIfNotFromSubtree = React.useCallback((event)=>{
|
|
56
59
|
const isRelatedTargetFromActions = Boolean(actionsRefInternal.current && elementContains(actionsRefInternal.current, event.relatedTarget));
|
|
57
60
|
if (isRelatedTargetFromActions) {
|
|
61
|
+
onActionVisibilityChange === null || onActionVisibilityChange === void 0 ? void 0 : onActionVisibilityChange(event, {
|
|
62
|
+
visible: true,
|
|
63
|
+
event,
|
|
64
|
+
type: event.type
|
|
65
|
+
});
|
|
58
66
|
setIsActionsVisible(true);
|
|
59
67
|
return;
|
|
60
68
|
}
|
|
61
69
|
const isTargetFromSubtree = Boolean(subtreeRef.current && elementContains(subtreeRef.current, event.target));
|
|
62
70
|
if (!isTargetFromSubtree) {
|
|
71
|
+
onActionVisibilityChange === null || onActionVisibilityChange === void 0 ? void 0 : onActionVisibilityChange(event, {
|
|
72
|
+
visible: false,
|
|
73
|
+
event,
|
|
74
|
+
type: event.type
|
|
75
|
+
});
|
|
63
76
|
setIsActionsVisible(false);
|
|
64
77
|
return;
|
|
65
78
|
}
|
|
66
79
|
}, [
|
|
67
80
|
subtreeRef,
|
|
68
|
-
setIsActionsVisible
|
|
81
|
+
setIsActionsVisible,
|
|
82
|
+
onActionVisibilityChange
|
|
69
83
|
]);
|
|
70
84
|
const expandIcon = slot.optional(props.expandIcon, {
|
|
71
85
|
renderByDefault: isBranch,
|
|
@@ -83,27 +97,34 @@ import { useArrowNavigationGroup } from '@fluentui/react-tabster';
|
|
|
83
97
|
circular: true,
|
|
84
98
|
axis: 'horizontal'
|
|
85
99
|
});
|
|
86
|
-
const actions = isActionsVisible ? slot.optional(
|
|
100
|
+
const actions = isActionsVisible ? slot.optional(props.actions, {
|
|
87
101
|
defaultProps: {
|
|
88
102
|
...arrowNavigationProps,
|
|
89
103
|
role: 'toolbar'
|
|
90
104
|
},
|
|
91
105
|
elementType: 'div'
|
|
92
106
|
}) : undefined;
|
|
107
|
+
actions === null || actions === void 0 ? true : delete actions.visible;
|
|
108
|
+
actions === null || actions === void 0 ? true : delete actions.onVisibilityChange;
|
|
93
109
|
const actionsRefs = useMergedRefs(actions === null || actions === void 0 ? void 0 : actions.ref, actionsRef, actionsRefInternal);
|
|
94
110
|
const handleActionsBlur = useEventCallback((event)=>{
|
|
95
|
-
if (isResolvedShorthand(
|
|
96
|
-
var
|
|
97
|
-
(
|
|
111
|
+
if (isResolvedShorthand(props.actions)) {
|
|
112
|
+
var _props_actions_onBlur, _props_actions;
|
|
113
|
+
(_props_actions_onBlur = (_props_actions = props.actions).onBlur) === null || _props_actions_onBlur === void 0 ? void 0 : _props_actions_onBlur.call(_props_actions, event);
|
|
98
114
|
}
|
|
99
115
|
const isRelatedTargetFromActions = Boolean(elementContains(event.currentTarget, event.relatedTarget));
|
|
116
|
+
onActionVisibilityChange === null || onActionVisibilityChange === void 0 ? void 0 : onActionVisibilityChange(event, {
|
|
117
|
+
visible: isRelatedTargetFromActions,
|
|
118
|
+
event,
|
|
119
|
+
type: event.type
|
|
120
|
+
});
|
|
100
121
|
setIsActionsVisible(isRelatedTargetFromActions);
|
|
101
122
|
});
|
|
102
123
|
if (actions) {
|
|
103
124
|
actions.ref = actionsRefs;
|
|
104
125
|
actions.onBlur = handleActionsBlur;
|
|
105
126
|
}
|
|
106
|
-
const hasActions = Boolean(
|
|
127
|
+
const hasActions = Boolean(props.actions);
|
|
107
128
|
React.useEffect(()=>{
|
|
108
129
|
if (treeItemRef.current && hasActions && isActionsVisibleFromProps === undefined) {
|
|
109
130
|
const treeItemElement = treeItemRef.current;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useTreeItemLayout.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n getIntrinsicElementProps,\n isResolvedShorthand,\n useMergedRefs,\n slot,\n useEventCallback,\n elementContains,\n useControllableState,\n} from '@fluentui/react-utilities';\nimport { useTreeItemContext_unstable, useTreeContext_unstable } from '../../contexts';\nimport type { TreeItemLayoutProps, TreeItemLayoutSlots, TreeItemLayoutState } from './TreeItemLayout.types';\nimport { Checkbox, CheckboxProps } from '@fluentui/react-checkbox';\nimport { Radio, RadioProps } from '@fluentui/react-radio';\nimport { TreeItemChevron } from '../TreeItemChevron';\nimport { useArrowNavigationGroup } from '@fluentui/react-tabster';\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\n const [isActionsVisibleFromProps, actionsShorthand]: [boolean | undefined, TreeItemLayoutSlots['actions']] =\n isResolvedShorthand(props.actions)\n ? // .visible prop should not be propagated to the DOM\n [props.actions.visible, { ...props.actions, visible: undefined }]\n : [undefined, props.actions];\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 // FIXME: Asserting is required here, as converting this to RefObject on context type would be a breaking change\n assertIsRefObject(treeItemRef);\n // FIXME: Asserting is required here, as converting this to RefObject on context type would be a breaking change\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 setIsActionsVisible(true);\n }\n },\n [subtreeRef, setIsActionsVisible],\n );\n\n const setActionsInvisibleIfNotFromSubtree = React.useCallback(\n (event: FocusEvent | MouseEvent) => {\n const isRelatedTargetFromActions = Boolean(\n actionsRefInternal.current && elementContains(actionsRefInternal.current, event.relatedTarget as Node),\n );\n if (isRelatedTargetFromActions) {\n setIsActionsVisible(true);\n return;\n }\n const isTargetFromSubtree = Boolean(\n subtreeRef.current && elementContains(subtreeRef.current, event.target as Node),\n );\n if (!isTargetFromSubtree) {\n setIsActionsVisible(false);\n return;\n }\n },\n [subtreeRef, setIsActionsVisible],\n );\n\n const expandIcon = slot.optional(props.expandIcon, {\n renderByDefault: isBranch,\n defaultProps: {\n children: <TreeItemChevron />,\n 'aria-hidden': true,\n },\n elementType: 'div',\n });\n const expandIconRefs = useMergedRefs(expandIcon?.ref, expandIconRef);\n if (expandIcon) {\n expandIcon.ref = expandIconRefs;\n }\n const arrowNavigationProps = useArrowNavigationGroup({ circular: true, axis: 'horizontal' });\n const actions = isActionsVisible\n ? slot.optional(actionsShorthand, {\n defaultProps: { ...arrowNavigationProps, role: 'toolbar' },\n elementType: 'div',\n })\n : undefined;\n const actionsRefs = useMergedRefs(actions?.ref, actionsRef, actionsRefInternal);\n const handleActionsBlur = useEventCallback((event: React.FocusEvent<HTMLDivElement>) => {\n if (isResolvedShorthand(actionsShorthand)) {\n actionsShorthand.onBlur?.(event);\n }\n const isRelatedTargetFromActions = Boolean(elementContains(event.currentTarget, event.relatedTarget as Node));\n setIsActionsVisible(isRelatedTargetFromActions);\n });\n if (actions) {\n actions.ref = actionsRefs;\n actions.onBlur = handleActionsBlur;\n }\n\n const hasActions = Boolean(actionsShorthand);\n\n React.useEffect(() => {\n if (treeItemRef.current && hasActions && isActionsVisibleFromProps === undefined) {\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 }, [\n hasActions,\n treeItemRef,\n isActionsVisibleFromProps,\n setActionsVisibleIfNotFromSubtree,\n setActionsInvisibleIfNotFromSubtree,\n ]);\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, { defaultProps: { 'aria-hidden': true }, elementType: 'div' }),\n main: slot.always(main, { elementType: 'div' }),\n iconAfter: slot.optional(iconAfter, { defaultProps: { 'aria-hidden': true }, elementType: 'div' }),\n aside: !isActionsVisible\n ? slot.optional(props.aside, { defaultProps: { 'aria-hidden': true }, elementType: 'div' })\n : undefined,\n actions,\n expandIcon,\n selector: slot.optional(props.selector, {\n renderByDefault: selectionMode !== 'none',\n defaultProps: {\n checked,\n tabIndex: -1,\n 'aria-hidden': true,\n ref: selectionRef,\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<\n CheckboxProps | RadioProps\n >,\n }),\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","useTreeItemContext_unstable","useTreeContext_unstable","Checkbox","Radio","TreeItemChevron","useArrowNavigationGroup","useTreeItemLayout_unstable","props","ref","main","iconAfter","iconBefore","layoutRef","ctx","selectionMode","isActionsVisibleFromProps","actionsShorthand","actions","visible","undefined","isActionsVisible","setIsActionsVisible","state","initialState","selectionRef","expandIconRef","actionsRef","actionsRefInternal","useRef","treeItemRef","subtreeRef","checked","isBranch","itemType","assertIsRefObject","setActionsVisibleIfNotFromSubtree","useCallback","event","isTargetFromSubtree","Boolean","current","target","setActionsInvisibleIfNotFromSubtree","isRelatedTargetFromActions","relatedTarget","expandIcon","optional","renderByDefault","defaultProps","children","elementType","expandIconRefs","arrowNavigationProps","circular","axis","role","actionsRefs","handleActionsBlur","onBlur","currentTarget","hasActions","useEffect","treeItemElement","handleMouseOver","handleMouseOut","handleFocus","handleBlur","addEventListener","removeEventListener","components","root","aside","selector","buttonContextValue","size","always","tabIndex","process","env","NODE_ENV","Error","name"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SACEC,wBAAwB,EACxBC,mBAAmB,EACnBC,aAAa,EACbC,IAAI,EACJC,gBAAgB,EAChBC,eAAe,EACfC,oBAAoB,QACf,4BAA4B;AACnC,SAASC,2BAA2B,EAAEC,uBAAuB,QAAQ,iBAAiB;AAEtF,SAASC,QAAQ,QAAuB,2BAA2B;AACnE,SAASC,KAAK,QAAoB,wBAAwB;AAC1D,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,uBAAuB,QAAQ,0BAA0B;AAElE;;;;;;;;CAQC,GACD,OAAO,MAAMC,6BAA6B,CACxCC,OACAC;IAEA,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAEC,UAAU,EAAE,GAAGJ;IAExC,MAAMK,YAAYZ,4BAA4Ba,CAAAA,MAAOA,IAAID,SAAS;IAClE,MAAME,gBAAgBb,wBAAwBY,CAAAA,MAAOA,IAAIC,aAAa;IAEtE,MA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vC,MAAMgE,KAAK,EAAE;YAAEvB,cAAc;gBAAE,eAAe;YAAK;YAAGE,aAAa;QAAM,KACvF/B;QACJF;QACA4B;QACA2B,UAAU5E,KAAKkD,QAAQ,CAACvC,MAAMiE,QAAQ,EAAE;YACtCzB,iBAAiBjC,kBAAkB;YACnCkC,cAAc;gBACZjB;gBACA6C,UAAU,CAAC;gBACX,eAAe;gBACfpE,KAAKgB;YAIP;YACA0B,aAAcpC,kBAAkB,gBAAgBZ,WAAWC;QAG7D;IACF;AACF,EAAE;AAEF,SAAS+B,kBAAyB1B,GAAsB;IACtD,IAAIqE,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,IAAI,OAAOvE,QAAQ,YAAYA,QAAQ,QAAQ,CAAE,CAAA,aAAaA,GAAE,GAAI;YAClE,MAAM,IAAIwE,MAAM,CAAC;8BACO,EAAE1E,2BAA2B2E,IAAI,CAAC;;MAE1D,CAAC;QACH;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["useTreeItemLayout.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n getIntrinsicElementProps,\n isResolvedShorthand,\n useMergedRefs,\n slot,\n useEventCallback,\n elementContains,\n useControllableState,\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 { Checkbox, CheckboxProps } from '@fluentui/react-checkbox';\nimport { Radio, RadioProps } from '@fluentui/react-radio';\nimport { TreeItemChevron } from '../TreeItemChevron';\nimport { useArrowNavigationGroup } from '@fluentui/react-tabster';\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\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 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 // FIXME: Asserting is required here, as converting this to RefObject on context type would be a breaking change\n assertIsRefObject(treeItemRef);\n // FIXME: Asserting is required here, as converting this to RefObject on context type would be a breaking change\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 setIsActionsVisible(true);\n }\n },\n [subtreeRef, setIsActionsVisible, onActionVisibilityChange],\n );\n\n const setActionsInvisibleIfNotFromSubtree = React.useCallback(\n (event: FocusEvent | MouseEvent) => {\n const isRelatedTargetFromActions = Boolean(\n actionsRefInternal.current && elementContains(actionsRefInternal.current, event.relatedTarget as Node),\n );\n if (isRelatedTargetFromActions) {\n onActionVisibilityChange?.(event, {\n visible: true,\n event,\n type: event.type,\n } as Extract<TreeItemLayoutActionVisibilityChangeData, { event: typeof event }>);\n setIsActionsVisible(true);\n return;\n }\n const isTargetFromSubtree = Boolean(\n subtreeRef.current && elementContains(subtreeRef.current, event.target as Node),\n );\n if (!isTargetFromSubtree) {\n onActionVisibilityChange?.(event, {\n visible: false,\n event,\n type: event.type,\n } as Extract<TreeItemLayoutActionVisibilityChangeData, { event: typeof event }>);\n setIsActionsVisible(false);\n return;\n }\n },\n [subtreeRef, setIsActionsVisible, onActionVisibilityChange],\n );\n\n const expandIcon = slot.optional(props.expandIcon, {\n renderByDefault: isBranch,\n defaultProps: {\n children: <TreeItemChevron />,\n 'aria-hidden': true,\n },\n elementType: 'div',\n });\n const expandIconRefs = useMergedRefs(expandIcon?.ref, expandIconRef);\n if (expandIcon) {\n expandIcon.ref = expandIconRefs;\n }\n const arrowNavigationProps = useArrowNavigationGroup({ circular: true, axis: 'horizontal' });\n const actions = isActionsVisible\n ? slot.optional(props.actions, {\n defaultProps: { ...arrowNavigationProps, role: 'toolbar' },\n elementType: 'div',\n })\n : undefined;\n delete actions?.visible;\n delete actions?.onVisibilityChange;\n const actionsRefs = useMergedRefs(actions?.ref, actionsRef, actionsRefInternal);\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 if (actions) {\n actions.ref = actionsRefs;\n actions.onBlur = handleActionsBlur;\n }\n\n const hasActions = Boolean(props.actions);\n\n React.useEffect(() => {\n if (treeItemRef.current && hasActions && isActionsVisibleFromProps === undefined) {\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 }, [\n hasActions,\n treeItemRef,\n isActionsVisibleFromProps,\n setActionsVisibleIfNotFromSubtree,\n setActionsInvisibleIfNotFromSubtree,\n ]);\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, { defaultProps: { 'aria-hidden': true }, elementType: 'div' }),\n main: slot.always(main, { elementType: 'div' }),\n iconAfter: slot.optional(iconAfter, { defaultProps: { 'aria-hidden': true }, elementType: 'div' }),\n aside: !isActionsVisible\n ? slot.optional(props.aside, { defaultProps: { 'aria-hidden': true }, elementType: 'div' })\n : undefined,\n actions,\n expandIcon,\n selector: slot.optional(props.selector, {\n renderByDefault: selectionMode !== 'none',\n defaultProps: {\n checked,\n tabIndex: -1,\n 'aria-hidden': true,\n ref: selectionRef,\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<\n CheckboxProps | RadioProps\n >,\n }),\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","useTreeItemContext_unstable","useTreeContext_unstable","Checkbox","Radio","TreeItemChevron","useArrowNavigationGroup","useTreeItemLayout_unstable","props","ref","main","iconAfter","iconBefore","layoutRef","ctx","selectionMode","isActionsVisibleFromProps","onActionVisibilityChange","actions","visible","onVisibilityChange","undefined","isActionsVisible","setIsActionsVisible","state","initialState","selectionRef","expandIconRef","actionsRef","actionsRefInternal","useRef","treeItemRef","subtreeRef","checked","isBranch","itemType","assertIsRefObject","setActionsVisibleIfNotFromSubtree","useCallback","event","isTargetFromSubtree","Boolean","current","target","type","setActionsInvisibleIfNotFromSubtree","isRelatedTargetFromActions","relatedTarget","expandIcon","optional","renderByDefault","defaultProps","children","elementType","expandIconRefs","arrowNavigationProps","circular","axis","role","actionsRefs","handleActionsBlur","onBlur","currentTarget","hasActions","useEffect","treeItemElement","handleMouseOver","handleMouseOut","handleFocus","handleBlur","addEventListener","removeEventListener","components","root","aside","selector","buttonContextValue","size","always","tabIndex","process","env","NODE_ENV","Error","name"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SACEC,wBAAwB,EACxBC,mBAAmB,EACnBC,aAAa,EACbC,IAAI,EACJC,gBAAgB,EAChBC,eAAe,EACfC,oBAAoB,QACf,4BAA4B;AACnC,SAASC,2BAA2B,EAAEC,uBAAuB,QAAQ,iBAAiB;AAOtF,SAASC,QAAQ,QAAuB,2BAA2B;AACnE,SAASC,KAAK,QAAoB,wBAAwB;AAC1D,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,uBAAuB,QAAQ,0BAA0B;AAElE;;;;;;;;CAQC,GACD,OAAO,MAAMC,6BAA6B,CACxCC,OACAC;IAEA,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAEC,UAAU,EAAE,GAAGJ;IAExC,MAAMK,YAAYZ,4BAA4Ba,CAAAA,MAAOA,IAAID,SAAS;IAClE,MAAME,gBAAgBb,wBAAwBY,CAAAA,MAAOA,IAAIC,aAAa;IAEtE,MAAM,CAACC,2BAA2BC,yBAAyB,GAGvDtB,oBAAoBa,MAAMU,OAAO,IAEjC;QAACV,MAAMU,OAAO,CAACC,OAAO;QAAEX,MAAMU,OAAO,CAACE,kBAAkB;KAAC,GACzD;QAACC;QAAWA;KAAU;IAE1B,MAAM,CAACC,kBAAkBC,oBAAoB,GAAGvB,qBAAqB;QACnEwB,OAAOR;QACPS,cAAc;IAChB;IACA,MAAMC,eAAezB,4BAA4Ba,CAAAA,MAAOA,IAAIY,YAAY;IACxE,MAAMC,gBAAgB1B,4BAA4Ba,CAAAA,MAAOA,IAAIa,aAAa;IAC1E,MAAMC,aAAa3B,4BAA4Ba,CAAAA,MAAOA,IAAIc,UAAU;IACpE,MAAMC,qBAAqBpC,MAAMqC,MAAM,CAAiB;IACxD,MAAMC,cAAc9B,4BAA4Ba,CAAAA,MAAOA,IA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E;YAAEvB,cAAc;gBAAE,eAAe;YAAK;YAAGE,aAAa;QAAM,KACvFhC;QACJH;QACA8B;QACA2B,UAAU9E,KAAKoD,QAAQ,CAACzC,MAAMmE,QAAQ,EAAE;YACtCzB,iBAAiBnC,kBAAkB;YACnCoC,cAAc;gBACZlB;gBACA8C,UAAU,CAAC;gBACX,eAAe;gBACftE,KAAKiB;YAIP;YACA2B,aAActC,kBAAkB,gBAAgBZ,WAAWC;QAG7D;IACF;AACF,EAAE;AAEF,SAASgC,kBAAyB3B,GAAsB;IACtD,IAAIuE,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,IAAI,OAAOzE,QAAQ,YAAYA,QAAQ,QAAQ,CAAE,CAAA,aAAaA,GAAE,GAAI;YAClE,MAAM,IAAI0E,MAAM,CAAC;8BACO,EAAE5E,2BAA2B6E,IAAI,CAAC;;MAE1D,CAAC;QACH;IACF;AACF"}
|
|
@@ -20,15 +20,12 @@ const useTreeItemLayout_unstable = (props, ref)=>{
|
|
|
20
20
|
const { main, iconAfter, iconBefore } = props;
|
|
21
21
|
const layoutRef = (0, _contexts.useTreeItemContext_unstable)((ctx)=>ctx.layoutRef);
|
|
22
22
|
const selectionMode = (0, _contexts.useTreeContext_unstable)((ctx)=>ctx.selectionMode);
|
|
23
|
-
const [isActionsVisibleFromProps,
|
|
23
|
+
const [isActionsVisibleFromProps, onActionVisibilityChange] = (0, _reactutilities.isResolvedShorthand)(props.actions) ? [
|
|
24
24
|
props.actions.visible,
|
|
25
|
-
|
|
26
|
-
...props.actions,
|
|
27
|
-
visible: undefined
|
|
28
|
-
}
|
|
25
|
+
props.actions.onVisibilityChange
|
|
29
26
|
] : [
|
|
30
27
|
undefined,
|
|
31
|
-
|
|
28
|
+
undefined
|
|
32
29
|
];
|
|
33
30
|
const [isActionsVisible, setIsActionsVisible] = (0, _reactutilities.useControllableState)({
|
|
34
31
|
state: isActionsVisibleFromProps,
|
|
@@ -49,26 +46,43 @@ const useTreeItemLayout_unstable = (props, ref)=>{
|
|
|
49
46
|
const setActionsVisibleIfNotFromSubtree = _react.useCallback((event)=>{
|
|
50
47
|
const isTargetFromSubtree = Boolean(subtreeRef.current && (0, _reactutilities.elementContains)(subtreeRef.current, event.target));
|
|
51
48
|
if (!isTargetFromSubtree) {
|
|
49
|
+
onActionVisibilityChange === null || onActionVisibilityChange === void 0 ? void 0 : onActionVisibilityChange(event, {
|
|
50
|
+
visible: true,
|
|
51
|
+
event,
|
|
52
|
+
type: event.type
|
|
53
|
+
});
|
|
52
54
|
setIsActionsVisible(true);
|
|
53
55
|
}
|
|
54
56
|
}, [
|
|
55
57
|
subtreeRef,
|
|
56
|
-
setIsActionsVisible
|
|
58
|
+
setIsActionsVisible,
|
|
59
|
+
onActionVisibilityChange
|
|
57
60
|
]);
|
|
58
61
|
const setActionsInvisibleIfNotFromSubtree = _react.useCallback((event)=>{
|
|
59
62
|
const isRelatedTargetFromActions = Boolean(actionsRefInternal.current && (0, _reactutilities.elementContains)(actionsRefInternal.current, event.relatedTarget));
|
|
60
63
|
if (isRelatedTargetFromActions) {
|
|
64
|
+
onActionVisibilityChange === null || onActionVisibilityChange === void 0 ? void 0 : onActionVisibilityChange(event, {
|
|
65
|
+
visible: true,
|
|
66
|
+
event,
|
|
67
|
+
type: event.type
|
|
68
|
+
});
|
|
61
69
|
setIsActionsVisible(true);
|
|
62
70
|
return;
|
|
63
71
|
}
|
|
64
72
|
const isTargetFromSubtree = Boolean(subtreeRef.current && (0, _reactutilities.elementContains)(subtreeRef.current, event.target));
|
|
65
73
|
if (!isTargetFromSubtree) {
|
|
74
|
+
onActionVisibilityChange === null || onActionVisibilityChange === void 0 ? void 0 : onActionVisibilityChange(event, {
|
|
75
|
+
visible: false,
|
|
76
|
+
event,
|
|
77
|
+
type: event.type
|
|
78
|
+
});
|
|
66
79
|
setIsActionsVisible(false);
|
|
67
80
|
return;
|
|
68
81
|
}
|
|
69
82
|
}, [
|
|
70
83
|
subtreeRef,
|
|
71
|
-
setIsActionsVisible
|
|
84
|
+
setIsActionsVisible,
|
|
85
|
+
onActionVisibilityChange
|
|
72
86
|
]);
|
|
73
87
|
const expandIcon = _reactutilities.slot.optional(props.expandIcon, {
|
|
74
88
|
renderByDefault: isBranch,
|
|
@@ -86,27 +100,34 @@ const useTreeItemLayout_unstable = (props, ref)=>{
|
|
|
86
100
|
circular: true,
|
|
87
101
|
axis: 'horizontal'
|
|
88
102
|
});
|
|
89
|
-
const actions = isActionsVisible ? _reactutilities.slot.optional(
|
|
103
|
+
const actions = isActionsVisible ? _reactutilities.slot.optional(props.actions, {
|
|
90
104
|
defaultProps: {
|
|
91
105
|
...arrowNavigationProps,
|
|
92
106
|
role: 'toolbar'
|
|
93
107
|
},
|
|
94
108
|
elementType: 'div'
|
|
95
109
|
}) : undefined;
|
|
110
|
+
actions === null || actions === void 0 ? true : delete actions.visible;
|
|
111
|
+
actions === null || actions === void 0 ? true : delete actions.onVisibilityChange;
|
|
96
112
|
const actionsRefs = (0, _reactutilities.useMergedRefs)(actions === null || actions === void 0 ? void 0 : actions.ref, actionsRef, actionsRefInternal);
|
|
97
113
|
const handleActionsBlur = (0, _reactutilities.useEventCallback)((event)=>{
|
|
98
|
-
if ((0, _reactutilities.isResolvedShorthand)(
|
|
99
|
-
var
|
|
100
|
-
(
|
|
114
|
+
if ((0, _reactutilities.isResolvedShorthand)(props.actions)) {
|
|
115
|
+
var _props_actions_onBlur, _props_actions;
|
|
116
|
+
(_props_actions_onBlur = (_props_actions = props.actions).onBlur) === null || _props_actions_onBlur === void 0 ? void 0 : _props_actions_onBlur.call(_props_actions, event);
|
|
101
117
|
}
|
|
102
118
|
const isRelatedTargetFromActions = Boolean((0, _reactutilities.elementContains)(event.currentTarget, event.relatedTarget));
|
|
119
|
+
onActionVisibilityChange === null || onActionVisibilityChange === void 0 ? void 0 : onActionVisibilityChange(event, {
|
|
120
|
+
visible: isRelatedTargetFromActions,
|
|
121
|
+
event,
|
|
122
|
+
type: event.type
|
|
123
|
+
});
|
|
103
124
|
setIsActionsVisible(isRelatedTargetFromActions);
|
|
104
125
|
});
|
|
105
126
|
if (actions) {
|
|
106
127
|
actions.ref = actionsRefs;
|
|
107
128
|
actions.onBlur = handleActionsBlur;
|
|
108
129
|
}
|
|
109
|
-
const hasActions = Boolean(
|
|
130
|
+
const hasActions = Boolean(props.actions);
|
|
110
131
|
_react.useEffect(()=>{
|
|
111
132
|
if (treeItemRef.current && hasActions && isActionsVisibleFromProps === undefined) {
|
|
112
133
|
const treeItemElement = treeItemRef.current;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useTreeItemLayout.js"],"sourcesContent":["import * as React from 'react';\nimport { getIntrinsicElementProps, isResolvedShorthand, useMergedRefs, slot, useEventCallback, elementContains, useControllableState } from '@fluentui/react-utilities';\nimport { useTreeItemContext_unstable, useTreeContext_unstable } from '../../contexts';\nimport { Checkbox } from '@fluentui/react-checkbox';\nimport { Radio } from '@fluentui/react-radio';\nimport { TreeItemChevron } from '../TreeItemChevron';\nimport { useArrowNavigationGroup } from '@fluentui/react-tabster';\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 */ export const useTreeItemLayout_unstable = (props, ref)=>{\n const { main, iconAfter, iconBefore } = props;\n const layoutRef = useTreeItemContext_unstable((ctx)=>ctx.layoutRef);\n const selectionMode = useTreeContext_unstable((ctx)=>ctx.selectionMode);\n const [isActionsVisibleFromProps, actionsShorthand] = isResolvedShorthand(props.actions) ? [\n props.actions.visible,\n {\n ...props.actions,\n visible: undefined\n }\n ] : [\n undefined,\n props.actions\n ];\n const [isActionsVisible, setIsActionsVisible] = useControllableState({\n state: isActionsVisibleFromProps,\n initialState: false\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(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 // FIXME: Asserting is required here, as converting this to RefObject on context type would be a breaking change\n assertIsRefObject(treeItemRef);\n // FIXME: Asserting is required here, as converting this to RefObject on context type would be a breaking change\n assertIsRefObject(subtreeRef);\n const setActionsVisibleIfNotFromSubtree = React.useCallback((event)=>{\n const isTargetFromSubtree = Boolean(subtreeRef.current && elementContains(subtreeRef.current, event.target));\n if (!isTargetFromSubtree) {\n setIsActionsVisible(true);\n }\n }, [\n subtreeRef,\n setIsActionsVisible\n ]);\n const setActionsInvisibleIfNotFromSubtree = React.useCallback((event)=>{\n const isRelatedTargetFromActions = Boolean(actionsRefInternal.current && elementContains(actionsRefInternal.current, event.relatedTarget));\n if (isRelatedTargetFromActions) {\n setIsActionsVisible(true);\n return;\n }\n const isTargetFromSubtree = Boolean(subtreeRef.current && elementContains(subtreeRef.current, event.target));\n if (!isTargetFromSubtree) {\n setIsActionsVisible(false);\n return;\n }\n }, [\n subtreeRef,\n setIsActionsVisible\n ]);\n const expandIcon = slot.optional(props.expandIcon, {\n renderByDefault: isBranch,\n defaultProps: {\n children: /*#__PURE__*/ React.createElement(TreeItemChevron, null),\n 'aria-hidden': true\n },\n elementType: 'div'\n });\n const expandIconRefs = useMergedRefs(expandIcon === null || expandIcon === void 0 ? void 0 : expandIcon.ref, expandIconRef);\n if (expandIcon) {\n expandIcon.ref = expandIconRefs;\n }\n const arrowNavigationProps = useArrowNavigationGroup({\n circular: true,\n axis: 'horizontal'\n });\n const actions = isActionsVisible ? slot.optional(actionsShorthand, {\n defaultProps: {\n ...arrowNavigationProps,\n role: 'toolbar'\n },\n elementType: 'div'\n }) : undefined;\n const actionsRefs = useMergedRefs(actions === null || actions === void 0 ? void 0 : actions.ref, actionsRef, actionsRefInternal);\n const handleActionsBlur = useEventCallback((event)=>{\n if (isResolvedShorthand(actionsShorthand)) {\n var _actionsShorthand_onBlur;\n (_actionsShorthand_onBlur = actionsShorthand.onBlur) === null || _actionsShorthand_onBlur === void 0 ? void 0 : _actionsShorthand_onBlur.call(actionsShorthand, event);\n }\n const isRelatedTargetFromActions = Boolean(elementContains(event.currentTarget, event.relatedTarget));\n setIsActionsVisible(isRelatedTargetFromActions);\n });\n if (actions) {\n actions.ref = actionsRefs;\n actions.onBlur = handleActionsBlur;\n }\n const hasActions = Boolean(actionsShorthand);\n React.useEffect(()=>{\n if (treeItemRef.current && hasActions && isActionsVisibleFromProps === undefined) {\n const treeItemElement = treeItemRef.current;\n const handleMouseOver = setActionsVisibleIfNotFromSubtree;\n const handleMouseOut = setActionsInvisibleIfNotFromSubtree;\n const handleFocus = setActionsVisibleIfNotFromSubtree;\n const handleBlur = setActionsInvisibleIfNotFromSubtree;\n treeItemElement.addEventListener('mouseover', handleMouseOver);\n treeItemElement.addEventListener('mouseout', handleMouseOut);\n treeItemElement.addEventListener('focus', handleFocus);\n treeItemElement.addEventListener('blur', handleBlur);\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 }, [\n hasActions,\n treeItemRef,\n isActionsVisibleFromProps,\n setActionsVisibleIfNotFromSubtree,\n 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\n },\n buttonContextValue: {\n size: 'small'\n },\n root: slot.always(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)\n }), {\n elementType: 'div'\n }),\n iconBefore: slot.optional(iconBefore, {\n defaultProps: {\n 'aria-hidden': true\n },\n elementType: 'div'\n }),\n main: slot.always(main, {\n elementType: 'div'\n }),\n iconAfter: slot.optional(iconAfter, {\n defaultProps: {\n 'aria-hidden': true\n },\n elementType: 'div'\n }),\n aside: !isActionsVisible ? slot.optional(props.aside, {\n defaultProps: {\n 'aria-hidden': true\n },\n elementType: 'div'\n }) : undefined,\n actions,\n expandIcon,\n selector: slot.optional(props.selector, {\n renderByDefault: selectionMode !== 'none',\n defaultProps: {\n checked,\n tabIndex: -1,\n 'aria-hidden': true,\n ref: selectionRef\n },\n elementType: selectionMode === 'multiselect' ? Checkbox : Radio\n })\n };\n};\nfunction assertIsRefObject(ref) {\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":["useTreeItemLayout_unstable","props","ref","main","iconAfter","iconBefore","layoutRef","useTreeItemContext_unstable","ctx","selectionMode","useTreeContext_unstable","isActionsVisibleFromProps","actionsShorthand","isResolvedShorthand","actions","visible","undefined","isActionsVisible","setIsActionsVisible","useControllableState","state","initialState","selectionRef","expandIconRef","actionsRef","actionsRefInternal","React","useRef","treeItemRef","subtreeRef","checked","isBranch","itemType","assertIsRefObject","setActionsVisibleIfNotFromSubtree","useCallback","event","isTargetFromSubtree","Boolean","current","elementContains","target","setActionsInvisibleIfNotFromSubtree","isRelatedTargetFromActions","relatedTarget","expandIcon","slot","optional","renderByDefault","defaultProps","children","createElement","TreeItemChevron","elementType","expandIconRefs","useMergedRefs","arrowNavigationProps","useArrowNavigationGroup","circular","axis","role","actionsRefs","handleActionsBlur","useEventCallback","_actionsShorthand_onBlur","onBlur","call","currentTarget","hasActions","useEffect","treeItemElement","handleMouseOver","handleMouseOut","handleFocus","handleBlur","addEventListener","removeEventListener","components","root","aside","selector","Checkbox","Radio","buttonContextValue","size","always","getIntrinsicElementProps","tabIndex","process","env","NODE_ENV","Error","name"],"mappings":";;;;+BAeiBA;;;eAAAA;;;;iEAfM;gCACqH;0BACvE;+BAC5C;4BACH;iCACU;8BACQ;AAS7B,MAAMA,6BAA6B,CAACC,OAAOC;IAClD,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAEC,UAAU,EAAE,GAAGJ;IACxC,MAAMK,YAAYC,IAAAA,qCAA2B,EAAC,CAACC,MAAMA,IAAIF,SAAS;IAClE,MAAMG,gBAAgBC,IAAAA,iCAAuB,EAAC,CAACF,MAAMA,IAAIC,aAAa;IACtE,MAAM,CAACE,2BAA2BC,iBAAiB,GAAGC,IAAAA,mCAAmB,EAACZ,MAAMa,OAAO,IAAI;QACvFb,MAAMa,OAAO,CAACC,OAAO;QACrB;YACI,GAAGd,MAAMa,OAAO;YAChBC,SAASC;QACb;KACH,GAAG;QACAA;QACAf,MAAMa,OAAO;KAChB;IACD,MAAM,CAACG,kBAAkBC,oBAAoB,GAAGC,IAAAA,oCAAoB,EAAC;QACjEC,OAAOT;QACPU,cAAc;IAClB;IACA,MAAMC,eAAef,IAAAA,qCAA2B,EAAC,CAACC,MAAMA,IAAIc,YAAY;IACxE,MAAMC,gBAAgBhB,IAAAA,qCAA2B,EAAC,CAACC,MAAMA,IAAIe,aAAa;IAC1E,MAAMC,aAAajB,IAAAA,qCAA2B,EAAC,CAACC,MAAMA,IAAIgB,UAAU;IACpE,MAAMC,qBAAqBC,OAAMC,MAAM,CAAC;IACxC,MAAMC,cAAcrB,IAAAA,qCAA2B,EAAC,CAACC,MAAMA,IAAIoB,WAAW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UAAU,CAAC;gBACX,eAAe;gBACfrF,KAAKoB;YACT;YACA+B,aAAa5C,kBAAkB,gBAAgBwE,uBAAQ,GAAGC,iBAAK;QACnE;IACJ;AACJ;AACA,SAASjD,kBAAkB/B,GAAG;IAC1B,IAAIsF,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACvC,IAAI,OAAOxF,QAAQ,YAAYA,QAAQ,QAAQ,CAAE,CAAA,aAAaA,GAAE,GAAI;YAChE,MAAM,IAAIyF,MAAM,CAAC;8BACC,EAAE3F,2BAA2B4F,IAAI,CAAC;;MAE1D,CAAC;QACC;IACJ;AACJ"}
|
|
1
|
+
{"version":3,"sources":["useTreeItemLayout.js"],"sourcesContent":["import * as React from 'react';\nimport { getIntrinsicElementProps, isResolvedShorthand, useMergedRefs, slot, useEventCallback, elementContains, useControllableState } from '@fluentui/react-utilities';\nimport { useTreeItemContext_unstable, useTreeContext_unstable } from '../../contexts';\nimport { Checkbox } from '@fluentui/react-checkbox';\nimport { Radio } from '@fluentui/react-radio';\nimport { TreeItemChevron } from '../TreeItemChevron';\nimport { useArrowNavigationGroup } from '@fluentui/react-tabster';\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 */ export const useTreeItemLayout_unstable = (props, ref)=>{\n const { main, iconAfter, iconBefore } = props;\n const layoutRef = useTreeItemContext_unstable((ctx)=>ctx.layoutRef);\n const selectionMode = useTreeContext_unstable((ctx)=>ctx.selectionMode);\n const [isActionsVisibleFromProps, onActionVisibilityChange] = isResolvedShorthand(props.actions) ? [\n props.actions.visible,\n props.actions.onVisibilityChange\n ] : [\n undefined,\n undefined\n ];\n const [isActionsVisible, setIsActionsVisible] = useControllableState({\n state: isActionsVisibleFromProps,\n initialState: false\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(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 // FIXME: Asserting is required here, as converting this to RefObject on context type would be a breaking change\n assertIsRefObject(treeItemRef);\n // FIXME: Asserting is required here, as converting this to RefObject on context type would be a breaking change\n assertIsRefObject(subtreeRef);\n const setActionsVisibleIfNotFromSubtree = React.useCallback((event)=>{\n const isTargetFromSubtree = Boolean(subtreeRef.current && elementContains(subtreeRef.current, event.target));\n if (!isTargetFromSubtree) {\n onActionVisibilityChange === null || onActionVisibilityChange === void 0 ? void 0 : onActionVisibilityChange(event, {\n visible: true,\n event,\n type: event.type\n });\n setIsActionsVisible(true);\n }\n }, [\n subtreeRef,\n setIsActionsVisible,\n onActionVisibilityChange\n ]);\n const setActionsInvisibleIfNotFromSubtree = React.useCallback((event)=>{\n const isRelatedTargetFromActions = Boolean(actionsRefInternal.current && elementContains(actionsRefInternal.current, event.relatedTarget));\n if (isRelatedTargetFromActions) {\n onActionVisibilityChange === null || onActionVisibilityChange === void 0 ? void 0 : onActionVisibilityChange(event, {\n visible: true,\n event,\n type: event.type\n });\n setIsActionsVisible(true);\n return;\n }\n const isTargetFromSubtree = Boolean(subtreeRef.current && elementContains(subtreeRef.current, event.target));\n if (!isTargetFromSubtree) {\n onActionVisibilityChange === null || onActionVisibilityChange === void 0 ? void 0 : onActionVisibilityChange(event, {\n visible: false,\n event,\n type: event.type\n });\n setIsActionsVisible(false);\n return;\n }\n }, [\n subtreeRef,\n setIsActionsVisible,\n onActionVisibilityChange\n ]);\n const expandIcon = slot.optional(props.expandIcon, {\n renderByDefault: isBranch,\n defaultProps: {\n children: /*#__PURE__*/ React.createElement(TreeItemChevron, null),\n 'aria-hidden': true\n },\n elementType: 'div'\n });\n const expandIconRefs = useMergedRefs(expandIcon === null || expandIcon === void 0 ? void 0 : expandIcon.ref, expandIconRef);\n if (expandIcon) {\n expandIcon.ref = expandIconRefs;\n }\n const arrowNavigationProps = useArrowNavigationGroup({\n circular: true,\n axis: 'horizontal'\n });\n const actions = isActionsVisible ? slot.optional(props.actions, {\n defaultProps: {\n ...arrowNavigationProps,\n role: 'toolbar'\n },\n elementType: 'div'\n }) : undefined;\n actions === null || actions === void 0 ? true : delete actions.visible;\n actions === null || actions === void 0 ? true : delete actions.onVisibilityChange;\n const actionsRefs = useMergedRefs(actions === null || actions === void 0 ? void 0 : actions.ref, actionsRef, actionsRefInternal);\n const handleActionsBlur = useEventCallback((event)=>{\n if (isResolvedShorthand(props.actions)) {\n var _props_actions_onBlur, _props_actions;\n (_props_actions_onBlur = (_props_actions = props.actions).onBlur) === null || _props_actions_onBlur === void 0 ? void 0 : _props_actions_onBlur.call(_props_actions, event);\n }\n const isRelatedTargetFromActions = Boolean(elementContains(event.currentTarget, event.relatedTarget));\n onActionVisibilityChange === null || onActionVisibilityChange === void 0 ? void 0 : onActionVisibilityChange(event, {\n visible: isRelatedTargetFromActions,\n event,\n type: event.type\n });\n setIsActionsVisible(isRelatedTargetFromActions);\n });\n if (actions) {\n actions.ref = actionsRefs;\n actions.onBlur = handleActionsBlur;\n }\n const hasActions = Boolean(props.actions);\n React.useEffect(()=>{\n if (treeItemRef.current && hasActions && isActionsVisibleFromProps === undefined) {\n const treeItemElement = treeItemRef.current;\n const handleMouseOver = setActionsVisibleIfNotFromSubtree;\n const handleMouseOut = setActionsInvisibleIfNotFromSubtree;\n const handleFocus = setActionsVisibleIfNotFromSubtree;\n const handleBlur = setActionsInvisibleIfNotFromSubtree;\n treeItemElement.addEventListener('mouseover', handleMouseOver);\n treeItemElement.addEventListener('mouseout', handleMouseOut);\n treeItemElement.addEventListener('focus', handleFocus);\n treeItemElement.addEventListener('blur', handleBlur);\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 }, [\n hasActions,\n treeItemRef,\n isActionsVisibleFromProps,\n setActionsVisibleIfNotFromSubtree,\n 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\n },\n buttonContextValue: {\n size: 'small'\n },\n root: slot.always(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)\n }), {\n elementType: 'div'\n }),\n iconBefore: slot.optional(iconBefore, {\n defaultProps: {\n 'aria-hidden': true\n },\n elementType: 'div'\n }),\n main: slot.always(main, {\n elementType: 'div'\n }),\n iconAfter: slot.optional(iconAfter, {\n defaultProps: {\n 'aria-hidden': true\n },\n elementType: 'div'\n }),\n aside: !isActionsVisible ? slot.optional(props.aside, {\n defaultProps: {\n 'aria-hidden': true\n },\n elementType: 'div'\n }) : undefined,\n actions,\n expandIcon,\n selector: slot.optional(props.selector, {\n renderByDefault: selectionMode !== 'none',\n defaultProps: {\n checked,\n tabIndex: -1,\n 'aria-hidden': true,\n ref: selectionRef\n },\n elementType: selectionMode === 'multiselect' ? Checkbox : Radio\n })\n };\n};\nfunction assertIsRefObject(ref) {\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":["useTreeItemLayout_unstable","props","ref","main","iconAfter","iconBefore","layoutRef","useTreeItemContext_unstable","ctx","selectionMode","useTreeContext_unstable","isActionsVisibleFromProps","onActionVisibilityChange","isResolvedShorthand","actions","visible","onVisibilityChange","undefined","isActionsVisible","setIsActionsVisible","useControllableState","state","initialState","selectionRef","expandIconRef","actionsRef","actionsRefInternal","React","useRef","treeItemRef","subtreeRef","checked","isBranch","itemType","assertIsRefObject","setActionsVisibleIfNotFromSubtree","useCallback","event","isTargetFromSubtree","Boolean","current","elementContains","target","type","setActionsInvisibleIfNotFromSubtree","isRelatedTargetFromActions","relatedTarget","expandIcon","slot","optional","renderByDefault","defaultProps","children","createElement","TreeItemChevron","elementType","expandIconRefs","useMergedRefs","arrowNavigationProps","useArrowNavigationGroup","circular","axis","role","actionsRefs","handleActionsBlur","useEventCallback","_props_actions_onBlur","_props_actions","onBlur","call","currentTarget","hasActions","useEffect","treeItemElement","handleMouseOver","handleMouseOut","handleFocus","handleBlur","addEventListener","removeEventListener","components","root","aside","selector","Checkbox","Radio","buttonContextValue","size","always","getIntrinsicElementProps","tabIndex","process","env","NODE_ENV","Error","name"],"mappings":";;;;+BAeiBA;;;eAAAA;;;;iEAfM;gCACqH;0BACvE;+BAC5C;4BACH;iCACU;8BACQ;AAS7B,MAAMA,6BAA6B,CAACC,OAAOC;IAClD,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAEC,UAAU,EAAE,GAAGJ;IACxC,MAAMK,YAAYC,IAAAA,qCAA2B,EAAC,CAACC,MAAMA,IAAIF,SAAS;IAClE,MAAMG,gBAAgBC,IAAAA,iCAAuB,EAAC,CAACF,MAAMA,IAAIC,aAAa;IACtE,MAAM,CAACE,2BAA2BC,yBAAyB,GAAGC,IAAAA,mCAAmB,EAACZ,MAAMa,OAAO,IAAI;QAC/Fb,MAAMa,OAAO,CAACC,OAAO;QACrBd,MAAM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;gBACfxF,KAAKqB;YACT;YACAgC,aAAa9C,kBAAkB,gBAAgB2E,uBAAQ,GAAGC,iBAAK;QACnE;IACJ;AACJ;AACA,SAASnD,kBAAkBhC,GAAG;IAC1B,IAAIyF,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACvC,IAAI,OAAO3F,QAAQ,YAAYA,QAAQ,QAAQ,CAAE,CAAA,aAAaA,GAAE,GAAI;YAChE,MAAM,IAAI4F,MAAM,CAAC;8BACC,EAAE9F,2BAA2B+F,IAAI,CAAC;;MAE1D,CAAC;QACC;IACJ;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui/react-tree",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.7.1",
|
|
4
4
|
"description": "Tree component for Fluent UI React",
|
|
5
5
|
"main": "lib-commonjs/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -17,17 +17,14 @@
|
|
|
17
17
|
"generate-api": "just-scripts generate-api",
|
|
18
18
|
"lint": "just-scripts lint",
|
|
19
19
|
"start": "yarn storybook",
|
|
20
|
-
"storybook": "
|
|
20
|
+
"storybook": "yarn --cwd ../stories storybook",
|
|
21
21
|
"test": "jest --passWithNoTests",
|
|
22
|
-
"
|
|
23
|
-
"type-check": "tsc -b tsconfig.json",
|
|
22
|
+
"type-check": "just-scripts type-check",
|
|
24
23
|
"e2e": "cypress run --component",
|
|
25
24
|
"e2e:local": "cypress open --component"
|
|
26
25
|
},
|
|
27
26
|
"devDependencies": {
|
|
28
|
-
"@
|
|
29
|
-
"@dnd-kit/sortable": "^7.0.2",
|
|
30
|
-
"@dnd-kit/utilities": "^3.2.1",
|
|
27
|
+
"@fluentui/react-provider": "*",
|
|
31
28
|
"@fluentui/eslint-plugin": "*",
|
|
32
29
|
"@fluentui/react-conformance": "*",
|
|
33
30
|
"@fluentui/react-conformance-griffel": "*",
|
|
@@ -37,15 +34,15 @@
|
|
|
37
34
|
},
|
|
38
35
|
"dependencies": {
|
|
39
36
|
"@fluentui/keyboard-keys": "^9.0.7",
|
|
40
|
-
"@fluentui/react-aria": "^9.12.
|
|
41
|
-
"@fluentui/react-avatar": "^9.6.
|
|
42
|
-
"@fluentui/react-button": "^9.3.
|
|
43
|
-
"@fluentui/react-checkbox": "^9.2.
|
|
44
|
-
"@fluentui/react-context-selector": "^9.1.
|
|
37
|
+
"@fluentui/react-aria": "^9.12.1",
|
|
38
|
+
"@fluentui/react-avatar": "^9.6.30",
|
|
39
|
+
"@fluentui/react-button": "^9.3.84",
|
|
40
|
+
"@fluentui/react-checkbox": "^9.2.29",
|
|
41
|
+
"@fluentui/react-context-selector": "^9.1.62",
|
|
45
42
|
"@fluentui/react-icons": "^2.0.239",
|
|
46
|
-
"@fluentui/react-radio": "^9.2.
|
|
43
|
+
"@fluentui/react-radio": "^9.2.24",
|
|
47
44
|
"@fluentui/react-shared-contexts": "^9.19.0",
|
|
48
|
-
"@fluentui/react-tabster": "^9.
|
|
45
|
+
"@fluentui/react-tabster": "^9.22.0",
|
|
49
46
|
"@fluentui/react-theme": "^9.1.19",
|
|
50
47
|
"@fluentui/react-utilities": "^9.18.10",
|
|
51
48
|
"@fluentui/react-jsx-runtime": "^9.0.39",
|