@fluentui/react-drawer 9.10.4 → 9.10.5
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 +14 -2
- package/lib/components/DrawerBody/useDrawerBody.js +27 -22
- package/lib/components/DrawerBody/useDrawerBody.js.map +1 -1
- package/lib-commonjs/components/DrawerBody/useDrawerBody.js +27 -22
- package/lib-commonjs/components/DrawerBody/useDrawerBody.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
# Change Log - @fluentui/react-drawer
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Tue, 21 Oct 2025 14:13:11 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [9.10.5](https://github.com/microsoft/fluentui/tree/@fluentui/react-drawer_v9.10.5)
|
|
8
|
+
|
|
9
|
+
Tue, 21 Oct 2025 14:13:11 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-drawer_v9.10.4..@fluentui/react-drawer_v9.10.5)
|
|
11
|
+
|
|
12
|
+
### Patches
|
|
13
|
+
|
|
14
|
+
- fix: update drawer scroll state when content changes ([PR #35210](https://github.com/microsoft/fluentui/pull/35210) by marcosvmmoura@gmail.com)
|
|
15
|
+
- Bump @fluentui/react-dialog to v9.15.5 ([PR #35307](https://github.com/microsoft/fluentui/pull/35307) by beachball)
|
|
16
|
+
- Bump @fluentui/react-jsx-runtime to v9.3.0 ([PR #35307](https://github.com/microsoft/fluentui/pull/35307) by beachball)
|
|
17
|
+
- Bump @fluentui/react-portal to v9.8.5 ([PR #35307](https://github.com/microsoft/fluentui/pull/35307) by beachball)
|
|
18
|
+
|
|
7
19
|
## [9.10.4](https://github.com/microsoft/fluentui/tree/@fluentui/react-drawer_v9.10.4)
|
|
8
20
|
|
|
9
|
-
Wed, 08 Oct 2025 12:
|
|
21
|
+
Wed, 08 Oct 2025 12:04:53 GMT
|
|
10
22
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-drawer_v9.10.3..@fluentui/react-drawer_v9.10.4)
|
|
11
23
|
|
|
12
24
|
### Patches
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { mergeCallbacks, slot, useAnimationFrame, useMergedRefs, useIsomorphicLayoutEffect, getIntrinsicElementProps } from '@fluentui/react-utilities';
|
|
4
4
|
import { useDrawerContext_unstable } from '../../contexts/drawerContext';
|
|
5
|
+
import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
|
|
5
6
|
/**
|
|
6
7
|
* @internal
|
|
7
8
|
*
|
|
@@ -29,9 +30,13 @@ import { useDrawerContext_unstable } from '../../contexts/drawerContext';
|
|
|
29
30
|
* @param props - props from this instance of DrawerBody
|
|
30
31
|
* @param ref - reference to root HTMLElement of DrawerBody
|
|
31
32
|
*/ export const useDrawerBody_unstable = (props, ref)=>{
|
|
33
|
+
const { targetDocument } = useFluent();
|
|
34
|
+
const win = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;
|
|
32
35
|
const { setScrollState } = useDrawerContext_unstable();
|
|
33
36
|
const scrollRef = React.useRef(null);
|
|
34
|
-
const
|
|
37
|
+
const mergedRef = useMergedRefs(ref, scrollRef);
|
|
38
|
+
const [setScrollAnimationFrame, cancelScrollAnimationFrame] = useAnimationFrame();
|
|
39
|
+
const [setResizeAnimationFrame, cancelResizeAnimationFrame] = useAnimationFrame();
|
|
35
40
|
const updateScrollState = React.useCallback(()=>{
|
|
36
41
|
if (!scrollRef.current) {
|
|
37
42
|
return;
|
|
@@ -41,41 +46,41 @@ import { useDrawerContext_unstable } from '../../contexts/drawerContext';
|
|
|
41
46
|
setScrollState
|
|
42
47
|
]);
|
|
43
48
|
const onScroll = React.useCallback(()=>{
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
cancelScrollAnimationFrame();
|
|
50
|
+
setScrollAnimationFrame(updateScrollState);
|
|
46
51
|
}, [
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
cancelScrollAnimationFrame,
|
|
53
|
+
setScrollAnimationFrame,
|
|
49
54
|
updateScrollState
|
|
50
55
|
]);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
setAnimationFrame(()=>updateScrollState());
|
|
54
|
-
/* update scroll state when children changes */ return ()=>cancelAnimationFrame();
|
|
55
|
-
}, [
|
|
56
|
+
// Update scroll state on children change
|
|
57
|
+
useIsomorphicLayoutEffect(updateScrollState, [
|
|
56
58
|
props.children,
|
|
57
|
-
|
|
58
|
-
updateScrollState,
|
|
59
|
-
setAnimationFrame
|
|
59
|
+
updateScrollState
|
|
60
60
|
]);
|
|
61
|
+
// Update scroll state on mount and when resize occurs
|
|
61
62
|
useIsomorphicLayoutEffect(()=>{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
if (!scrollRef.current || !(win === null || win === void 0 ? void 0 : win.ResizeObserver)) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const observer = new win.ResizeObserver(()=>setResizeAnimationFrame(updateScrollState));
|
|
67
|
+
observer.observe(scrollRef.current);
|
|
68
|
+
return ()=>{
|
|
69
|
+
observer.disconnect();
|
|
70
|
+
cancelResizeAnimationFrame();
|
|
71
|
+
};
|
|
65
72
|
}, [
|
|
66
|
-
|
|
73
|
+
setResizeAnimationFrame,
|
|
74
|
+
cancelResizeAnimationFrame,
|
|
67
75
|
updateScrollState,
|
|
68
|
-
|
|
76
|
+
win
|
|
69
77
|
]);
|
|
70
78
|
return {
|
|
71
79
|
components: {
|
|
72
80
|
root: 'div'
|
|
73
81
|
},
|
|
74
82
|
root: slot.always(getIntrinsicElementProps('div', {
|
|
75
|
-
|
|
76
|
-
// `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLDivElement`
|
|
77
|
-
// but since it would be a breaking change to fix it, we are casting ref to it's proper type
|
|
78
|
-
ref: useMergedRefs(ref, scrollRef),
|
|
83
|
+
ref: mergedRef,
|
|
79
84
|
...props,
|
|
80
85
|
onScroll: mergeCallbacks(props.onScroll, onScroll)
|
|
81
86
|
}), {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/DrawerBody/useDrawerBody.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport {\n mergeCallbacks,\n slot,\n useAnimationFrame,\n useMergedRefs,\n useIsomorphicLayoutEffect,\n getIntrinsicElementProps,\n} from '@fluentui/react-utilities';\n\nimport { useDrawerContext_unstable } from '../../contexts/drawerContext';\nimport { DrawerScrollState } from '../../shared/DrawerBase.types';\n\nimport type { DrawerBodyProps, DrawerBodyState } from './DrawerBody.types';\n\n/**\n * @internal\n *\n * Get the current scroll state of the DrawerBody.\n *\n * @param element - HTMLElement to check scroll state of\n */\nconst getScrollState = ({ scrollTop, scrollHeight, clientHeight }: HTMLElement): DrawerScrollState => {\n if (scrollHeight <= clientHeight) {\n return 'none';\n }\n\n if (scrollTop === 0) {\n return 'top';\n }\n\n if (scrollTop + clientHeight === scrollHeight) {\n return 'bottom';\n }\n\n return 'middle';\n};\n\n/**\n * Create the state required to render DrawerBody.\n *\n * The returned state can be modified with hooks such as useDrawerBodyStyles_unstable,\n * before being passed to renderDrawerBody_unstable.\n *\n * @param props - props from this instance of DrawerBody\n * @param ref - reference to root HTMLElement of DrawerBody\n */\nexport const useDrawerBody_unstable = (props: DrawerBodyProps, ref: React.Ref<HTMLElement>): DrawerBodyState => {\n const { setScrollState } = useDrawerContext_unstable();\n\n const scrollRef = React.useRef<HTMLDivElement | null>(null);\n const [
|
|
1
|
+
{"version":3,"sources":["../src/components/DrawerBody/useDrawerBody.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport {\n mergeCallbacks,\n slot,\n useAnimationFrame,\n useMergedRefs,\n useIsomorphicLayoutEffect,\n getIntrinsicElementProps,\n} from '@fluentui/react-utilities';\n\nimport { useDrawerContext_unstable } from '../../contexts/drawerContext';\nimport { DrawerScrollState } from '../../shared/DrawerBase.types';\n\nimport type { DrawerBodyProps, DrawerBodyState } from './DrawerBody.types';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\n\n/**\n * @internal\n *\n * Get the current scroll state of the DrawerBody.\n *\n * @param element - HTMLElement to check scroll state of\n */\nconst getScrollState = ({ scrollTop, scrollHeight, clientHeight }: HTMLElement): DrawerScrollState => {\n if (scrollHeight <= clientHeight) {\n return 'none';\n }\n\n if (scrollTop === 0) {\n return 'top';\n }\n\n if (scrollTop + clientHeight === scrollHeight) {\n return 'bottom';\n }\n\n return 'middle';\n};\n\n/**\n * Create the state required to render DrawerBody.\n *\n * The returned state can be modified with hooks such as useDrawerBodyStyles_unstable,\n * before being passed to renderDrawerBody_unstable.\n *\n * @param props - props from this instance of DrawerBody\n * @param ref - reference to root HTMLElement of DrawerBody\n */\nexport const useDrawerBody_unstable = (props: DrawerBodyProps, ref: React.Ref<HTMLElement>): DrawerBodyState => {\n const { targetDocument } = useFluent();\n const win = targetDocument?.defaultView;\n\n const { setScrollState } = useDrawerContext_unstable();\n\n const scrollRef = React.useRef<HTMLDivElement | null>(null);\n const mergedRef = useMergedRefs(ref, scrollRef);\n\n const [setScrollAnimationFrame, cancelScrollAnimationFrame] = useAnimationFrame();\n const [setResizeAnimationFrame, cancelResizeAnimationFrame] = useAnimationFrame();\n\n const updateScrollState = React.useCallback(() => {\n if (!scrollRef.current) {\n return;\n }\n\n setScrollState(getScrollState(scrollRef.current));\n }, [setScrollState]);\n\n const onScroll = React.useCallback(() => {\n cancelScrollAnimationFrame();\n setScrollAnimationFrame(updateScrollState);\n }, [cancelScrollAnimationFrame, setScrollAnimationFrame, updateScrollState]);\n\n // Update scroll state on children change\n useIsomorphicLayoutEffect(updateScrollState, [props.children, updateScrollState]);\n\n // Update scroll state on mount and when resize occurs\n useIsomorphicLayoutEffect(() => {\n if (!scrollRef.current || !win?.ResizeObserver) {\n return;\n }\n\n const observer = new win.ResizeObserver(() => setResizeAnimationFrame(updateScrollState));\n\n observer.observe(scrollRef.current);\n\n return () => {\n observer.disconnect();\n cancelResizeAnimationFrame();\n };\n }, [setResizeAnimationFrame, cancelResizeAnimationFrame, updateScrollState, win]);\n\n return {\n components: {\n root: 'div',\n },\n\n root: slot.always(\n getIntrinsicElementProps<DrawerBodyProps>('div', {\n ref: mergedRef,\n ...props,\n onScroll: mergeCallbacks(props.onScroll, onScroll),\n }),\n { elementType: 'div' },\n ),\n };\n};\n"],"names":["React","mergeCallbacks","slot","useAnimationFrame","useMergedRefs","useIsomorphicLayoutEffect","getIntrinsicElementProps","useDrawerContext_unstable","useFluent_unstable","useFluent","getScrollState","scrollTop","scrollHeight","clientHeight","useDrawerBody_unstable","props","ref","targetDocument","win","defaultView","setScrollState","scrollRef","useRef","mergedRef","setScrollAnimationFrame","cancelScrollAnimationFrame","setResizeAnimationFrame","cancelResizeAnimationFrame","updateScrollState","useCallback","current","onScroll","children","ResizeObserver","observer","observe","disconnect","components","root","always","elementType"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SACEC,cAAc,EACdC,IAAI,EACJC,iBAAiB,EACjBC,aAAa,EACbC,yBAAyB,EACzBC,wBAAwB,QACnB,4BAA4B;AAEnC,SAASC,yBAAyB,QAAQ,+BAA+B;AAIzE,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAElF;;;;;;CAMC,GACD,MAAMC,iBAAiB,CAAC,EAAEC,SAAS,EAAEC,YAAY,EAAEC,YAAY,EAAe;IAC5E,IAAID,gBAAgBC,cAAc;QAChC,OAAO;IACT;IAEA,IAAIF,cAAc,GAAG;QACnB,OAAO;IACT;IAEA,IAAIA,YAAYE,iBAAiBD,cAAc;QAC7C,OAAO;IACT;IAEA,OAAO;AACT;AAEA;;;;;;;;CAQC,GACD,OAAO,MAAME,yBAAyB,CAACC,OAAwBC;IAC7D,MAAM,EAAEC,cAAc,EAAE,GAAGR;IAC3B,MAAMS,MAAMD,2BAAAA,qCAAAA,eAAgBE,WAAW;IAEvC,MAAM,EAAEC,cAAc,EAAE,GAAGb;IAE3B,MAAMc,YAAYrB,MAAMsB,MAAM,CAAwB;IACtD,MAAMC,YAAYnB,cAAcY,KAAKK;IAErC,MAAM,CAACG,yBAAyBC,2BAA2B,GAAGtB;IAC9D,MAAM,CAACuB,yBAAyBC,2BAA2B,GAAGxB;IAE9D,MAAMyB,oBAAoB5B,MAAM6B,WAAW,CAAC;QAC1C,IAAI,CAACR,UAAUS,OAAO,EAAE;YACtB;QACF;QAEAV,eAAeV,eAAeW,UAAUS,OAAO;IACjD,GAAG;QAACV;KAAe;IAEnB,MAAMW,WAAW/B,MAAM6B,WAAW,CAAC;QACjCJ;QACAD,wBAAwBI;IAC1B,GAAG;QAACH;QAA4BD;QAAyBI;KAAkB;IAE3E,yCAAyC;IACzCvB,0BAA0BuB,mBAAmB;QAACb,MAAMiB,QAAQ;QAAEJ;KAAkB;IAEhF,sDAAsD;IACtDvB,0BAA0B;QACxB,IAAI,CAACgB,UAAUS,OAAO,IAAI,EAACZ,gBAAAA,0BAAAA,IAAKe,cAAc,GAAE;YAC9C;QACF;QAEA,MAAMC,WAAW,IAAIhB,IAAIe,cAAc,CAAC,IAAMP,wBAAwBE;QAEtEM,SAASC,OAAO,CAACd,UAAUS,OAAO;QAElC,OAAO;YACLI,SAASE,UAAU;YACnBT;QACF;IACF,GAAG;QAACD;QAAyBC;QAA4BC;QAAmBV;KAAI;IAEhF,OAAO;QACLmB,YAAY;YACVC,MAAM;QACR;QAEAA,MAAMpC,KAAKqC,MAAM,CACfjC,yBAA0C,OAAO;YAC/CU,KAAKO;YACL,GAAGR,KAAK;YACRgB,UAAU9B,eAAec,MAAMgB,QAAQ,EAAEA;QAC3C,IACA;YAAES,aAAa;QAAM;IAEzB;AACF,EAAE"}
|
|
@@ -13,6 +13,7 @@ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildc
|
|
|
13
13
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
14
14
|
const _reactutilities = require("@fluentui/react-utilities");
|
|
15
15
|
const _drawerContext = require("../../contexts/drawerContext");
|
|
16
|
+
const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
|
|
16
17
|
/**
|
|
17
18
|
* @internal
|
|
18
19
|
*
|
|
@@ -32,9 +33,13 @@ const _drawerContext = require("../../contexts/drawerContext");
|
|
|
32
33
|
return 'middle';
|
|
33
34
|
};
|
|
34
35
|
const useDrawerBody_unstable = (props, ref)=>{
|
|
36
|
+
const { targetDocument } = (0, _reactsharedcontexts.useFluent_unstable)();
|
|
37
|
+
const win = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;
|
|
35
38
|
const { setScrollState } = (0, _drawerContext.useDrawerContext_unstable)();
|
|
36
39
|
const scrollRef = _react.useRef(null);
|
|
37
|
-
const
|
|
40
|
+
const mergedRef = (0, _reactutilities.useMergedRefs)(ref, scrollRef);
|
|
41
|
+
const [setScrollAnimationFrame, cancelScrollAnimationFrame] = (0, _reactutilities.useAnimationFrame)();
|
|
42
|
+
const [setResizeAnimationFrame, cancelResizeAnimationFrame] = (0, _reactutilities.useAnimationFrame)();
|
|
38
43
|
const updateScrollState = _react.useCallback(()=>{
|
|
39
44
|
if (!scrollRef.current) {
|
|
40
45
|
return;
|
|
@@ -44,41 +49,41 @@ const useDrawerBody_unstable = (props, ref)=>{
|
|
|
44
49
|
setScrollState
|
|
45
50
|
]);
|
|
46
51
|
const onScroll = _react.useCallback(()=>{
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
cancelScrollAnimationFrame();
|
|
53
|
+
setScrollAnimationFrame(updateScrollState);
|
|
49
54
|
}, [
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
cancelScrollAnimationFrame,
|
|
56
|
+
setScrollAnimationFrame,
|
|
52
57
|
updateScrollState
|
|
53
58
|
]);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
setAnimationFrame(()=>updateScrollState());
|
|
57
|
-
/* update scroll state when children changes */ return ()=>cancelAnimationFrame();
|
|
58
|
-
}, [
|
|
59
|
+
// Update scroll state on children change
|
|
60
|
+
(0, _reactutilities.useIsomorphicLayoutEffect)(updateScrollState, [
|
|
59
61
|
props.children,
|
|
60
|
-
|
|
61
|
-
updateScrollState,
|
|
62
|
-
setAnimationFrame
|
|
62
|
+
updateScrollState
|
|
63
63
|
]);
|
|
64
|
+
// Update scroll state on mount and when resize occurs
|
|
64
65
|
(0, _reactutilities.useIsomorphicLayoutEffect)(()=>{
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
if (!scrollRef.current || !(win === null || win === void 0 ? void 0 : win.ResizeObserver)) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const observer = new win.ResizeObserver(()=>setResizeAnimationFrame(updateScrollState));
|
|
70
|
+
observer.observe(scrollRef.current);
|
|
71
|
+
return ()=>{
|
|
72
|
+
observer.disconnect();
|
|
73
|
+
cancelResizeAnimationFrame();
|
|
74
|
+
};
|
|
68
75
|
}, [
|
|
69
|
-
|
|
76
|
+
setResizeAnimationFrame,
|
|
77
|
+
cancelResizeAnimationFrame,
|
|
70
78
|
updateScrollState,
|
|
71
|
-
|
|
79
|
+
win
|
|
72
80
|
]);
|
|
73
81
|
return {
|
|
74
82
|
components: {
|
|
75
83
|
root: 'div'
|
|
76
84
|
},
|
|
77
85
|
root: _reactutilities.slot.always((0, _reactutilities.getIntrinsicElementProps)('div', {
|
|
78
|
-
|
|
79
|
-
// `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLDivElement`
|
|
80
|
-
// but since it would be a breaking change to fix it, we are casting ref to it's proper type
|
|
81
|
-
ref: (0, _reactutilities.useMergedRefs)(ref, scrollRef),
|
|
86
|
+
ref: mergedRef,
|
|
82
87
|
...props,
|
|
83
88
|
onScroll: (0, _reactutilities.mergeCallbacks)(props.onScroll, onScroll)
|
|
84
89
|
}), {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/DrawerBody/useDrawerBody.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport {\n mergeCallbacks,\n slot,\n useAnimationFrame,\n useMergedRefs,\n useIsomorphicLayoutEffect,\n getIntrinsicElementProps,\n} from '@fluentui/react-utilities';\n\nimport { useDrawerContext_unstable } from '../../contexts/drawerContext';\nimport { DrawerScrollState } from '../../shared/DrawerBase.types';\n\nimport type { DrawerBodyProps, DrawerBodyState } from './DrawerBody.types';\n\n/**\n * @internal\n *\n * Get the current scroll state of the DrawerBody.\n *\n * @param element - HTMLElement to check scroll state of\n */\nconst getScrollState = ({ scrollTop, scrollHeight, clientHeight }: HTMLElement): DrawerScrollState => {\n if (scrollHeight <= clientHeight) {\n return 'none';\n }\n\n if (scrollTop === 0) {\n return 'top';\n }\n\n if (scrollTop + clientHeight === scrollHeight) {\n return 'bottom';\n }\n\n return 'middle';\n};\n\n/**\n * Create the state required to render DrawerBody.\n *\n * The returned state can be modified with hooks such as useDrawerBodyStyles_unstable,\n * before being passed to renderDrawerBody_unstable.\n *\n * @param props - props from this instance of DrawerBody\n * @param ref - reference to root HTMLElement of DrawerBody\n */\nexport const useDrawerBody_unstable = (props: DrawerBodyProps, ref: React.Ref<HTMLElement>): DrawerBodyState => {\n const { setScrollState } = useDrawerContext_unstable();\n\n const scrollRef = React.useRef<HTMLDivElement | null>(null);\n const [
|
|
1
|
+
{"version":3,"sources":["../src/components/DrawerBody/useDrawerBody.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport {\n mergeCallbacks,\n slot,\n useAnimationFrame,\n useMergedRefs,\n useIsomorphicLayoutEffect,\n getIntrinsicElementProps,\n} from '@fluentui/react-utilities';\n\nimport { useDrawerContext_unstable } from '../../contexts/drawerContext';\nimport { DrawerScrollState } from '../../shared/DrawerBase.types';\n\nimport type { DrawerBodyProps, DrawerBodyState } from './DrawerBody.types';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\n\n/**\n * @internal\n *\n * Get the current scroll state of the DrawerBody.\n *\n * @param element - HTMLElement to check scroll state of\n */\nconst getScrollState = ({ scrollTop, scrollHeight, clientHeight }: HTMLElement): DrawerScrollState => {\n if (scrollHeight <= clientHeight) {\n return 'none';\n }\n\n if (scrollTop === 0) {\n return 'top';\n }\n\n if (scrollTop + clientHeight === scrollHeight) {\n return 'bottom';\n }\n\n return 'middle';\n};\n\n/**\n * Create the state required to render DrawerBody.\n *\n * The returned state can be modified with hooks such as useDrawerBodyStyles_unstable,\n * before being passed to renderDrawerBody_unstable.\n *\n * @param props - props from this instance of DrawerBody\n * @param ref - reference to root HTMLElement of DrawerBody\n */\nexport const useDrawerBody_unstable = (props: DrawerBodyProps, ref: React.Ref<HTMLElement>): DrawerBodyState => {\n const { targetDocument } = useFluent();\n const win = targetDocument?.defaultView;\n\n const { setScrollState } = useDrawerContext_unstable();\n\n const scrollRef = React.useRef<HTMLDivElement | null>(null);\n const mergedRef = useMergedRefs(ref, scrollRef);\n\n const [setScrollAnimationFrame, cancelScrollAnimationFrame] = useAnimationFrame();\n const [setResizeAnimationFrame, cancelResizeAnimationFrame] = useAnimationFrame();\n\n const updateScrollState = React.useCallback(() => {\n if (!scrollRef.current) {\n return;\n }\n\n setScrollState(getScrollState(scrollRef.current));\n }, [setScrollState]);\n\n const onScroll = React.useCallback(() => {\n cancelScrollAnimationFrame();\n setScrollAnimationFrame(updateScrollState);\n }, [cancelScrollAnimationFrame, setScrollAnimationFrame, updateScrollState]);\n\n // Update scroll state on children change\n useIsomorphicLayoutEffect(updateScrollState, [props.children, updateScrollState]);\n\n // Update scroll state on mount and when resize occurs\n useIsomorphicLayoutEffect(() => {\n if (!scrollRef.current || !win?.ResizeObserver) {\n return;\n }\n\n const observer = new win.ResizeObserver(() => setResizeAnimationFrame(updateScrollState));\n\n observer.observe(scrollRef.current);\n\n return () => {\n observer.disconnect();\n cancelResizeAnimationFrame();\n };\n }, [setResizeAnimationFrame, cancelResizeAnimationFrame, updateScrollState, win]);\n\n return {\n components: {\n root: 'div',\n },\n\n root: slot.always(\n getIntrinsicElementProps<DrawerBodyProps>('div', {\n ref: mergedRef,\n ...props,\n onScroll: mergeCallbacks(props.onScroll, onScroll),\n }),\n { elementType: 'div' },\n ),\n };\n};\n"],"names":["React","mergeCallbacks","slot","useAnimationFrame","useMergedRefs","useIsomorphicLayoutEffect","getIntrinsicElementProps","useDrawerContext_unstable","useFluent_unstable","useFluent","getScrollState","scrollTop","scrollHeight","clientHeight","useDrawerBody_unstable","props","ref","targetDocument","win","defaultView","setScrollState","scrollRef","useRef","mergedRef","setScrollAnimationFrame","cancelScrollAnimationFrame","setResizeAnimationFrame","cancelResizeAnimationFrame","updateScrollState","useCallback","current","onScroll","children","ResizeObserver","observer","observe","disconnect","components","root","always","elementType"],"mappings":"AAAA;;;;;;;;eAkDac;;;;iEAhDU,QAAQ;gCAQxB,4BAA4B;+BAEO,+BAA+B;qCAIzB,kCAAkC;AAElF;;;;;;CAMC,GACD,MAAMJ,iBAAiB,CAAC,EAAEC,SAAS,EAAEC,YAAY,EAAEC,YAAY,EAAe;IAC5E,IAAID,gBAAgBC,cAAc;QAChC,OAAO;IACT;IAEA,IAAIF,cAAc,GAAG;QACnB,OAAO;IACT;IAEA,IAAIA,YAAYE,iBAAiBD,cAAc;QAC7C,OAAO;IACT;IAEA,OAAO;AACT;AAWO,+BAA+B,CAACG,OAAwBC;IAC7D,MAAM,EAAEC,cAAc,EAAE,OAAGR,uCAAAA;IAC3B,MAAMS,MAAMD,mBAAAA,QAAAA,mBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,eAAgBE,WAAW;IAEvC,MAAM,EAAEC,cAAc,EAAE,OAAGb,wCAAAA;IAE3B,MAAMc,YAAYrB,OAAMsB,MAAM,CAAwB;IACtD,MAAMC,gBAAYnB,6BAAAA,EAAcY,KAAKK;IAErC,MAAM,CAACG,yBAAyBC,2BAA2B,OAAGtB,iCAAAA;IAC9D,MAAM,CAACuB,yBAAyBC,2BAA2B,OAAGxB,iCAAAA;IAE9D,MAAMyB,oBAAoB5B,OAAM6B,WAAW,CAAC;QAC1C,IAAI,CAACR,UAAUS,OAAO,EAAE;YACtB;QACF;QAEAV,eAAeV,eAAeW,UAAUS,OAAO;IACjD,GAAG;QAACV;KAAe;IAEnB,MAAMW,WAAW/B,OAAM6B,WAAW,CAAC;QACjCJ;QACAD,wBAAwBI;IAC1B,GAAG;QAACH;QAA4BD;QAAyBI;KAAkB;IAE3E,yCAAyC;QACzCvB,yCAAAA,EAA0BuB,mBAAmB;QAACb,MAAMiB,QAAQ;QAAEJ;KAAkB;IAEhF,sDAAsD;QACtDvB,yCAAAA,EAA0B;QACxB,IAAI,CAACgB,UAAUS,OAAO,IAAI,EAACZ,QAAAA,QAAAA,QAAAA,KAAAA,IAAAA,KAAAA,IAAAA,IAAKe,cAAAA,AAAc,GAAE;YAC9C;QACF;QAEA,MAAMC,WAAW,IAAIhB,IAAIe,cAAc,CAAC,IAAMP,wBAAwBE;QAEtEM,SAASC,OAAO,CAACd,UAAUS,OAAO;QAElC,OAAO;YACLI,SAASE,UAAU;YACnBT;QACF;IACF,GAAG;QAACD;QAAyBC;QAA4BC;QAAmBV;KAAI;IAEhF,OAAO;QACLmB,YAAY;YACVC,MAAM;QACR;QAEAA,MAAMpC,oBAAAA,CAAKqC,MAAM,KACfjC,wCAAAA,EAA0C,OAAO;YAC/CU,KAAKO;YACL,GAAGR,KAAK;YACRgB,cAAU9B,8BAAAA,EAAec,MAAMgB,QAAQ,EAAEA;QAC3C,IACA;YAAES,aAAa;QAAM;IAEzB;AACF,EAAE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui/react-drawer",
|
|
3
|
-
"version": "9.10.
|
|
3
|
+
"version": "9.10.5",
|
|
4
4
|
"description": "Drawer components for Fluent UI React",
|
|
5
5
|
"main": "lib-commonjs/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"@fluentui/scripts-cypress": "*"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@fluentui/react-dialog": "^9.15.
|
|
24
|
-
"@fluentui/react-jsx-runtime": "^9.
|
|
23
|
+
"@fluentui/react-dialog": "^9.15.5",
|
|
24
|
+
"@fluentui/react-jsx-runtime": "^9.3.0",
|
|
25
25
|
"@fluentui/react-motion": "^9.11.1",
|
|
26
|
-
"@fluentui/react-portal": "^9.8.
|
|
26
|
+
"@fluentui/react-portal": "^9.8.5",
|
|
27
27
|
"@fluentui/react-shared-contexts": "^9.25.2",
|
|
28
28
|
"@fluentui/react-tabster": "^9.26.7",
|
|
29
29
|
"@fluentui/react-theme": "^9.2.0",
|