@fluentui/react-overflow 9.7.2 → 9.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/CHANGELOG.md +33 -4
  2. package/dist/index.d.ts +120 -17
  3. package/lib/components/Overflow/Overflow.js +14 -0
  4. package/lib/components/Overflow/Overflow.js.map +1 -0
  5. package/lib/components/Overflow/Overflow.types.js +3 -0
  6. package/lib/components/Overflow/Overflow.types.js.map +1 -0
  7. package/lib/components/Overflow/index.js +4 -0
  8. package/lib/components/Overflow/index.js.map +1 -0
  9. package/lib/components/Overflow/renderOverflow.js +19 -0
  10. package/lib/components/Overflow/renderOverflow.js.map +1 -0
  11. package/lib/components/Overflow/useOverflow.js +42 -0
  12. package/lib/components/Overflow/useOverflow.js.map +1 -0
  13. package/lib/components/Overflow/useOverflowStyles.styles.js +22 -0
  14. package/lib/components/Overflow/useOverflowStyles.styles.js.map +1 -0
  15. package/lib/components/Overflow/useOverflowStyles.styles.raw.js +23 -0
  16. package/lib/components/Overflow/useOverflowStyles.styles.raw.js.map +1 -0
  17. package/lib/components/OverflowReorderObserver/OverflowReorderObserver.js +43 -0
  18. package/lib/components/OverflowReorderObserver/OverflowReorderObserver.js.map +1 -0
  19. package/lib/components/OverflowReorderObserver/index.js +1 -0
  20. package/lib/components/OverflowReorderObserver/index.js.map +1 -0
  21. package/lib/index.js +4 -2
  22. package/lib/index.js.map +1 -1
  23. package/lib/overflowContext.js +23 -10
  24. package/lib/overflowContext.js.map +1 -1
  25. package/lib/types.js +1 -1
  26. package/lib/types.js.map +1 -1
  27. package/lib/useIsOverflowGroupVisible.js +2 -2
  28. package/lib/useIsOverflowGroupVisible.js.map +1 -1
  29. package/lib/useIsOverflowItemVisible.js +2 -2
  30. package/lib/useIsOverflowItemVisible.js.map +1 -1
  31. package/lib/useOverflowContainer.js +64 -55
  32. package/lib/useOverflowContainer.js.map +1 -1
  33. package/lib/useOverflowContextValues.js +35 -0
  34. package/lib/useOverflowContextValues.js.map +1 -0
  35. package/lib/useOverflowCount.js +3 -9
  36. package/lib/useOverflowCount.js.map +1 -1
  37. package/lib/useOverflowMenu.js +10 -12
  38. package/lib/useOverflowMenu.js.map +1 -1
  39. package/lib/useOverflowSnapshot.js +23 -0
  40. package/lib/useOverflowSnapshot.js.map +1 -0
  41. package/lib/useOverflowVisibility.js +6 -11
  42. package/lib/useOverflowVisibility.js.map +1 -1
  43. package/lib-commonjs/components/Overflow/Overflow.js +23 -0
  44. package/lib-commonjs/components/Overflow/Overflow.js.map +1 -0
  45. package/lib-commonjs/components/Overflow/Overflow.types.js +6 -0
  46. package/lib-commonjs/components/Overflow/Overflow.types.js.map +1 -0
  47. package/lib-commonjs/components/Overflow/index.js +28 -0
  48. package/lib-commonjs/components/Overflow/index.js.map +1 -0
  49. package/lib-commonjs/components/Overflow/renderOverflow.js +25 -0
  50. package/lib-commonjs/components/Overflow/renderOverflow.js.map +1 -0
  51. package/lib-commonjs/components/Overflow/useOverflow.js +47 -0
  52. package/lib-commonjs/components/Overflow/useOverflow.js.map +1 -0
  53. package/lib-commonjs/components/Overflow/useOverflowStyles.styles.js +41 -0
  54. package/lib-commonjs/components/Overflow/useOverflowStyles.styles.js.map +1 -0
  55. package/lib-commonjs/components/Overflow/useOverflowStyles.styles.raw.js +41 -0
  56. package/lib-commonjs/components/Overflow/useOverflowStyles.styles.raw.js.map +1 -0
  57. package/lib-commonjs/components/OverflowReorderObserver/OverflowReorderObserver.js +37 -0
  58. package/lib-commonjs/components/OverflowReorderObserver/OverflowReorderObserver.js.map +1 -0
  59. package/lib-commonjs/components/OverflowReorderObserver/index.js +11 -0
  60. package/lib-commonjs/components/OverflowReorderObserver/index.js.map +1 -0
  61. package/lib-commonjs/index.js +20 -0
  62. package/lib-commonjs/index.js.map +1 -1
  63. package/lib-commonjs/overflowContext.js +23 -8
  64. package/lib-commonjs/overflowContext.js.map +1 -1
  65. package/lib-commonjs/types.js +1 -1
  66. package/lib-commonjs/types.js.map +1 -1
  67. package/lib-commonjs/useIsOverflowGroupVisible.js +2 -2
  68. package/lib-commonjs/useIsOverflowGroupVisible.js.map +1 -1
  69. package/lib-commonjs/useIsOverflowItemVisible.js +2 -2
  70. package/lib-commonjs/useIsOverflowItemVisible.js.map +1 -1
  71. package/lib-commonjs/useOverflowContainer.js +62 -53
  72. package/lib-commonjs/useOverflowContainer.js.map +1 -1
  73. package/lib-commonjs/useOverflowContextValues.js +41 -0
  74. package/lib-commonjs/useOverflowContextValues.js.map +1 -0
  75. package/lib-commonjs/useOverflowCount.js +3 -9
  76. package/lib-commonjs/useOverflowCount.js.map +1 -1
  77. package/lib-commonjs/useOverflowMenu.js +10 -12
  78. package/lib-commonjs/useOverflowMenu.js.map +1 -1
  79. package/lib-commonjs/useOverflowSnapshot.js +30 -0
  80. package/lib-commonjs/useOverflowSnapshot.js.map +1 -0
  81. package/lib-commonjs/useOverflowVisibility.js +6 -12
  82. package/lib-commonjs/useOverflowVisibility.js.map +1 -1
  83. package/package.json +4 -4
  84. package/lib/components/Overflow.js +0 -60
  85. package/lib/components/Overflow.js.map +0 -1
  86. package/lib/components/useOverflowStyles.styles.js +0 -14
  87. package/lib/components/useOverflowStyles.styles.js.map +0 -1
  88. package/lib/components/useOverflowStyles.styles.raw.js +0 -15
  89. package/lib/components/useOverflowStyles.styles.raw.js.map +0 -1
  90. package/lib-commonjs/components/Overflow.js +0 -69
  91. package/lib-commonjs/components/Overflow.js.map +0 -1
  92. package/lib-commonjs/components/useOverflowStyles.styles.js +0 -25
  93. package/lib-commonjs/components/useOverflowStyles.styles.js.map +0 -1
  94. package/lib-commonjs/components/useOverflowStyles.styles.raw.js +0 -25
  95. package/lib-commonjs/components/useOverflowStyles.styles.raw.js.map +0 -1
@@ -0,0 +1,47 @@
1
+ 'use client';
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "useOverflow_unstable", {
7
+ enumerable: true,
8
+ get: function() {
9
+ return useOverflow_unstable;
10
+ }
11
+ });
12
+ const _reactutilities = require("@fluentui/react-utilities");
13
+ const _useOverflowContainer = require("../../useOverflowContainer");
14
+ const useOverflow_unstable = (props, ref)=>{
15
+ const { children, minimumVisible, overflowAxis = 'horizontal', overflowDirection, padding, onOverflowChange, hasHiddenItems } = props;
16
+ const update = (0, _reactutilities.useEventCallback)(()=>{
17
+ // eslint-disable-next-line react-hooks/immutability
18
+ const snapshot = getSnapshot();
19
+ const state = {
20
+ hasOverflow: snapshot.invisibleItemCount > 0,
21
+ itemVisibility: snapshot.itemVisibility,
22
+ groupVisibility: snapshot.groupVisibility
23
+ };
24
+ onOverflowChange === null || onOverflowChange === void 0 ? void 0 : onOverflowChange(null, state);
25
+ });
26
+ const { containerRef, getSnapshot, subscribe, registerItem, updateOverflow, forceUpdateOverflow, registerOverflowMenu, registerDivider } = (0, _useOverflowContainer.useOverflowContainer)(update, {
27
+ overflowDirection,
28
+ overflowAxis,
29
+ padding,
30
+ minimumVisible,
31
+ hasHiddenItems,
32
+ onUpdateItemVisibility: _useOverflowContainer.updateVisibilityAttribute
33
+ });
34
+ const child = (0, _reactutilities.getTriggerChild)(children);
35
+ return {
36
+ containerRef,
37
+ getSnapshot,
38
+ subscribe,
39
+ registerItem,
40
+ updateOverflow,
41
+ forceUpdateOverflow,
42
+ registerOverflowMenu,
43
+ registerDivider,
44
+ ref: (0, _reactutilities.useMergedRefs)(containerRef, ref, (0, _reactutilities.getReactElementRef)(child)),
45
+ children
46
+ };
47
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/Overflow/useOverflow.ts"],"sourcesContent":["'use client';\n\nimport type * as React from 'react';\nimport type { OnUpdateOverflow } from '@fluentui/priority-overflow';\nimport { getTriggerChild, getReactElementRef, useMergedRefs, useEventCallback } from '@fluentui/react-utilities';\n\nimport { updateVisibilityAttribute, useOverflowContainer } from '../../useOverflowContainer';\nimport type { OverflowComponentState, OverflowProps, OverflowState } from './Overflow.types';\n\n/**\n * The state required to render Overflow.\n *\n * @param props - props from this instance of Overflow\n * @param ref - reference forwarded to the single child's root element\n */\nexport const useOverflow_unstable = (props: OverflowProps, ref: React.Ref<HTMLElement>): OverflowComponentState => {\n const {\n children,\n minimumVisible,\n overflowAxis = 'horizontal',\n overflowDirection,\n padding,\n onOverflowChange,\n hasHiddenItems,\n } = props;\n\n const update: OnUpdateOverflow = useEventCallback(() => {\n // eslint-disable-next-line react-hooks/immutability\n const snapshot = getSnapshot();\n const state: OverflowState = {\n hasOverflow: snapshot.invisibleItemCount > 0,\n itemVisibility: snapshot.itemVisibility,\n groupVisibility: snapshot.groupVisibility,\n };\n onOverflowChange?.(null, state);\n });\n\n const {\n containerRef,\n getSnapshot,\n subscribe,\n registerItem,\n updateOverflow,\n forceUpdateOverflow,\n registerOverflowMenu,\n registerDivider,\n } = useOverflowContainer(update, {\n overflowDirection,\n overflowAxis,\n padding,\n minimumVisible,\n hasHiddenItems,\n onUpdateItemVisibility: updateVisibilityAttribute,\n });\n\n const child = getTriggerChild<HTMLElement>(children);\n\n return {\n containerRef,\n getSnapshot,\n subscribe,\n registerItem,\n updateOverflow,\n forceUpdateOverflow,\n registerOverflowMenu,\n registerDivider,\n ref: useMergedRefs(containerRef, ref, getReactElementRef(child)),\n children,\n };\n};\n"],"names":["getTriggerChild","getReactElementRef","useMergedRefs","useEventCallback","updateVisibilityAttribute","useOverflowContainer","useOverflow_unstable","props","ref","children","minimumVisible","overflowAxis","overflowDirection","padding","onOverflowChange","hasHiddenItems","update","snapshot","getSnapshot","state","hasOverflow","invisibleItemCount","itemVisibility","groupVisibility","containerRef","subscribe","registerItem","updateOverflow","forceUpdateOverflow","registerOverflowMenu","registerDivider","onUpdateItemVisibility","child"],"mappings":"AAAA;;;;;+BAeaM;;;;;;gCAXwE,4BAA4B;sCAEjD,6BAA6B;AAStF,6BAA6B,CAACC,OAAsBC;IACzD,MAAM,EACJC,QAAQ,EACRC,cAAc,EACdC,eAAe,YAAY,EAC3BC,iBAAiB,EACjBC,OAAO,EACPC,gBAAgB,EAChBC,cAAc,EACf,GAAGR;IAEJ,MAAMS,aAA2Bb,gCAAAA,EAAiB;QAChD,oDAAoD;QACpD,MAAMc,WAAWC;QACjB,MAAMC,QAAuB;YAC3BC,aAAaH,SAASI,kBAAkB,GAAG;YAC3CC,gBAAgBL,SAASK,cAAc;YACvCC,iBAAiBN,SAASM,eAAe;QAC3C;QACAT,qBAAAA,QAAAA,qBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,iBAAmB,MAAMK;IAC3B;IAEA,MAAM,EACJK,YAAY,EACZN,WAAW,EACXO,SAAS,EACTC,YAAY,EACZC,cAAc,EACdC,mBAAmB,EACnBC,oBAAoB,EACpBC,eAAe,EAChB,OAAGzB,0CAAAA,EAAqBW,QAAQ;QAC/BJ;QACAD;QACAE;QACAH;QACAK;QACAgB,wBAAwB3B,+CAAAA;IAC1B;IAEA,MAAM4B,YAAQhC,+BAAAA,EAA6BS;IAE3C,OAAO;QACLe;QACAN;QACAO;QACAC;QACAC;QACAC;QACAC;QACAC;QACAtB,SAAKN,6BAAAA,EAAcsB,cAAchB,SAAKP,kCAAAA,EAAmB+B;QACzDvB;IACF;AACF,EAAE"}
@@ -0,0 +1,41 @@
1
+ 'use client';
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ function _export(target, all) {
7
+ for(var name in all)Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name]
10
+ });
11
+ }
12
+ _export(exports, {
13
+ useOverflowStyles: function() {
14
+ return useOverflowStyles;
15
+ },
16
+ useOverflowStyles_unstable: function() {
17
+ return useOverflowStyles_unstable;
18
+ }
19
+ });
20
+ const _react = require("@griffel/react");
21
+ const _reactutilities = require("@fluentui/react-utilities");
22
+ const useOverflowStyles = /*#__PURE__*/ (0, _react.__styles)({
23
+ overflowMenu: {
24
+ Brvla84: "fyfkpbf"
25
+ },
26
+ overflowingItems: {
27
+ zb22lx: "f10570jf"
28
+ }
29
+ }, {
30
+ d: [
31
+ ".fyfkpbf [data-overflow-menu]{flex-shrink:0;}",
32
+ ".f10570jf [data-overflowing]{display:none;}"
33
+ ]
34
+ });
35
+ const useOverflowStyles_unstable = (state)=>{
36
+ const styles = useOverflowStyles();
37
+ const child = (0, _reactutilities.getTriggerChild)(state.children);
38
+ // eslint-disable-next-line react-hooks/immutability
39
+ state.className = (0, _react.mergeClasses)('fui-Overflow', styles.overflowMenu, styles.overflowingItems, child === null || child === void 0 ? void 0 : child.props.className);
40
+ return state;
41
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useOverflowStyles.styles.js"],"sourcesContent":["'use client';\nimport { makeStyles, mergeClasses } from '@griffel/react';\nimport { getTriggerChild } from '@fluentui/react-utilities';\nimport { DATA_OVERFLOWING, DATA_OVERFLOW_MENU } from '../../constants';\nexport const useOverflowStyles = makeStyles({\n overflowMenu: {\n [`& [${DATA_OVERFLOW_MENU}]`]: {\n flexShrink: 0\n }\n },\n overflowingItems: {\n [`& [${DATA_OVERFLOWING}]`]: {\n display: 'none'\n }\n }\n});\nexport const useOverflowStyles_unstable = (state)=>{\n const styles = useOverflowStyles();\n const child = getTriggerChild(state.children);\n // eslint-disable-next-line react-hooks/immutability\n state.className = mergeClasses('fui-Overflow', styles.overflowMenu, styles.overflowingItems, child === null || child === void 0 ? void 0 : child.props.className);\n return state;\n};\n"],"names":["__styles","mergeClasses","getTriggerChild","DATA_OVERFLOWING","DATA_OVERFLOW_MENU","useOverflowStyles","overflowMenu","Brvla84","overflowingItems","zb22lx","d","useOverflowStyles_unstable","state","styles","child","children","className","props"],"mappings":"AAAA,YAAY;;;;;;;;;;;;IAICK,iBAAiB;;;IAYjBM,0BAA0B;;;;uBAfE,gBAAgB;gCACzB,2BAA2B;AAEpD,0BAAuB,WAAA,OAAGX,eAAA,EAAA;IAAAM,YAAA,EAAA;QAAAC,OAAA,EAAA;IAAA;IAAAC,gBAAA,EAAA;QAAAC,MAAA,EAAA;IAAA;AAAA,GAAA;IAAAC,CAAA,EAAA;QAAA;QAAA;KAAA;AAAA,CAWhC,CAAC;AACK,oCAAoCE,KAAK,IAAG;IAC/C,MAAMC,MAAM,GAAGR,iBAAiB,CAAC,CAAC;IAClC,MAAMS,KAAK,OAAGZ,+BAAe,EAACU,KAAK,CAACG,QAAQ,CAAC;IAC7C,oDAAA;IACAH,KAAK,CAACI,SAAS,OAAGf,mBAAY,EAAC,cAAc,EAAEY,MAAM,CAACP,YAAY,EAAEO,MAAM,CAACL,gBAAgB,EAAEM,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAGA,KAAK,CAACG,KAAK,CAACD,SAAS,CAAC;IACjK,OAAOJ,KAAK;AAChB,CAAC"}
@@ -0,0 +1,41 @@
1
+ 'use client';
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ function _export(target, all) {
7
+ for(var name in all)Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name]
10
+ });
11
+ }
12
+ _export(exports, {
13
+ useOverflowStyles: function() {
14
+ return useOverflowStyles;
15
+ },
16
+ useOverflowStyles_unstable: function() {
17
+ return useOverflowStyles_unstable;
18
+ }
19
+ });
20
+ const _react = require("@griffel/react");
21
+ const _reactutilities = require("@fluentui/react-utilities");
22
+ const _constants = require("../../constants");
23
+ const useOverflowStyles = (0, _react.makeStyles)({
24
+ overflowMenu: {
25
+ [`& [${_constants.DATA_OVERFLOW_MENU}]`]: {
26
+ flexShrink: 0
27
+ }
28
+ },
29
+ overflowingItems: {
30
+ [`& [${_constants.DATA_OVERFLOWING}]`]: {
31
+ display: 'none'
32
+ }
33
+ }
34
+ });
35
+ const useOverflowStyles_unstable = (state)=>{
36
+ const styles = useOverflowStyles();
37
+ const child = (0, _reactutilities.getTriggerChild)(state.children);
38
+ // eslint-disable-next-line react-hooks/immutability
39
+ state.className = (0, _react.mergeClasses)('fui-Overflow', styles.overflowMenu, styles.overflowingItems, child === null || child === void 0 ? void 0 : child.props.className);
40
+ return state;
41
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/Overflow/useOverflowStyles.styles.ts"],"sourcesContent":["'use client';\n\nimport { makeStyles, mergeClasses } from '@griffel/react';\nimport { getTriggerChild } from '@fluentui/react-utilities';\nimport { DATA_OVERFLOWING, DATA_OVERFLOW_MENU } from '../../constants';\nimport type { OverflowComponentState } from './Overflow.types';\n\nexport const useOverflowStyles = makeStyles({\n overflowMenu: {\n [`& [${DATA_OVERFLOW_MENU}]`]: {\n flexShrink: 0,\n },\n },\n\n overflowingItems: {\n [`& [${DATA_OVERFLOWING}]`]: {\n display: 'none',\n },\n },\n});\n\nexport const useOverflowStyles_unstable = (state: OverflowComponentState): OverflowComponentState => {\n const styles = useOverflowStyles();\n const child = getTriggerChild<HTMLElement>(state.children);\n\n // eslint-disable-next-line react-hooks/immutability\n state.className = mergeClasses('fui-Overflow', styles.overflowMenu, styles.overflowingItems, child?.props.className);\n\n return state;\n};\n"],"names":["makeStyles","mergeClasses","getTriggerChild","DATA_OVERFLOWING","DATA_OVERFLOW_MENU","useOverflowStyles","overflowMenu","flexShrink","overflowingItems","display","useOverflowStyles_unstable","state","styles","child","children","className","props"],"mappings":"AAAA;;;;;;;;;;;;IAOaK,iBAAAA;;;IAcAK,0BAAAA;;;;uBAnB4B,iBAAiB;gCAC1B,4BAA4B;2BACP,kBAAkB;AAGhE,8BAA0BV,iBAAAA,EAAW;IAC1CM,cAAc;QACZ,CAAC,CAAC,GAAG,EAAEF,6BAAAA,CAAmB,CAAC,CAAC,CAAC,EAAE;YAC7BG,YAAY;QACd;IACF;IAEAC,kBAAkB;QAChB,CAAC,CAAC,GAAG,EAAEL,2BAAAA,CAAiB,CAAC,CAAC,CAAC,EAAE;YAC3BM,SAAS;QACX;IACF;AACF,GAAG;AAEI,mCAAmC,CAACE;IACzC,MAAMC,SAASP;IACf,MAAMQ,YAAQX,+BAAAA,EAA6BS,MAAMG,QAAQ;IAEzD,oDAAoD;IACpDH,MAAMI,SAAS,OAAGd,mBAAAA,EAAa,gBAAgBW,OAAON,YAAY,EAAEM,OAAOJ,gBAAgB,EAAEK,UAAAA,QAAAA,UAAAA,KAAAA,IAAAA,KAAAA,IAAAA,MAAOG,KAAK,CAACD,SAAS;IAEnH,OAAOJ;AACT,EAAE"}
@@ -0,0 +1,37 @@
1
+ 'use client';
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "OverflowReorderObserver", {
7
+ enumerable: true,
8
+ get: function() {
9
+ return OverflowReorderObserver;
10
+ }
11
+ });
12
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
13
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
14
+ const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
15
+ const _overflowContext = require("../../overflowContext");
16
+ const OverflowReorderObserver = ()=>{
17
+ const containerRef = (0, _overflowContext.useOverflowContext)((v)=>v.containerRef);
18
+ const updateOverflow = (0, _overflowContext.useOverflowContext)((v)=>v.updateOverflow);
19
+ const { targetDocument } = (0, _reactsharedcontexts.useFluent_unstable)();
20
+ const targetWindow = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;
21
+ _react.useEffect(()=>{
22
+ const el = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current;
23
+ if (!el || !(targetWindow === null || targetWindow === void 0 ? void 0 : targetWindow.MutationObserver)) {
24
+ return;
25
+ }
26
+ const mutationObserver = new targetWindow.MutationObserver(()=>updateOverflow());
27
+ mutationObserver.observe(el, {
28
+ childList: true
29
+ });
30
+ return ()=>mutationObserver.disconnect();
31
+ }, [
32
+ containerRef,
33
+ updateOverflow,
34
+ targetWindow
35
+ ]);
36
+ return null;
37
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/OverflowReorderObserver/OverflowReorderObserver.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { useOverflowContext } from '../../overflowContext';\n\n/**\n * Renderless opt-in component that observes the `<Overflow>` container for\n * direct-child DOM mutations and triggers an overflow recompute. Drop it\n * inside `<Overflow>` when items can be reordered, added, or removed via\n * React state without a container resize — Fluent's overflow manager only\n * listens to `ResizeObserver` otherwise, so reorders leave visibility flags\n * stale.\n *\n * @example\n * ```tsx\n * <Overflow>\n * <div>\n * <OverflowReorderObserver />\n * {items.map(id => <OverflowItem key={id} id={id} priority={1}>{id}</OverflowItem>)}\n * </div>\n * </Overflow>\n * ```\n */\nexport const OverflowReorderObserver: React.FC = () => {\n const containerRef = useOverflowContext(v => v.containerRef);\n const updateOverflow = useOverflowContext(v => v.updateOverflow);\n const { targetDocument } = useFluent();\n const targetWindow = targetDocument?.defaultView;\n\n React.useEffect(() => {\n const el = containerRef?.current;\n if (!el || !targetWindow?.MutationObserver) {\n return;\n }\n\n const mutationObserver = new targetWindow.MutationObserver(() => updateOverflow());\n mutationObserver.observe(el, { childList: true });\n\n return () => mutationObserver.disconnect();\n }, [containerRef, updateOverflow, targetWindow]);\n\n return null;\n};\n"],"names":["React","useFluent_unstable","useFluent","useOverflowContext","OverflowReorderObserver","containerRef","v","updateOverflow","targetDocument","targetWindow","defaultView","useEffect","el","current","MutationObserver","mutationObserver","observe","childList","disconnect"],"mappings":"AAAA;;;;;+BAwBaI;;;;;;;iEAtBU,QAAQ;qCACiB,kCAAkC;iCAC/C,wBAAwB;AAoBpD,gCAA0C;IAC/C,MAAMC,mBAAeF,mCAAAA,EAAmBG,CAAAA,IAAKA,EAAED,YAAY;IAC3D,MAAME,qBAAiBJ,mCAAAA,EAAmBG,CAAAA,IAAKA,EAAEC,cAAc;IAC/D,MAAM,EAAEC,cAAc,EAAE,OAAGN,uCAAAA;IAC3B,MAAMO,eAAeD,mBAAAA,QAAAA,mBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,eAAgBE,WAAW;IAEhDV,OAAMW,SAAS,CAAC;QACd,MAAMC,KAAKP,iBAAAA,QAAAA,iBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,aAAcQ,OAAO;QAChC,IAAI,CAACD,MAAM,EAACH,iBAAAA,QAAAA,iBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,aAAcK,gBAAAA,AAAgB,GAAE;YAC1C;QACF;QAEA,MAAMC,mBAAmB,IAAIN,aAAaK,gBAAgB,CAAC,IAAMP;QACjEQ,iBAAiBC,OAAO,CAACJ,IAAI;YAAEK,WAAW;QAAK;QAE/C,OAAO,IAAMF,iBAAiBG,UAAU;IAC1C,GAAG;QAACb;QAAcE;QAAgBE;KAAa;IAE/C,OAAO;AACT,EAAE"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "OverflowReorderObserver", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _OverflowReorderObserver.OverflowReorderObserver;
9
+ }
10
+ });
11
+ const _OverflowReorderObserver = require("./OverflowReorderObserver");
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/OverflowReorderObserver/index.ts"],"sourcesContent":["export { OverflowReorderObserver } from './OverflowReorderObserver';\n"],"names":["OverflowReorderObserver"],"mappings":";;;;;;;eAASA,gDAAuB;;;yCAAQ,4BAA4B"}
@@ -30,6 +30,15 @@ _export(exports, {
30
30
  OverflowItem: function() {
31
31
  return _OverflowItem.OverflowItem;
32
32
  },
33
+ OverflowProvider: function() {
34
+ return _overflowContext.OverflowProvider;
35
+ },
36
+ OverflowReorderObserver: function() {
37
+ return _OverflowReorderObserver.OverflowReorderObserver;
38
+ },
39
+ renderOverflow_unstable: function() {
40
+ return _Overflow.renderOverflow_unstable;
41
+ },
33
42
  useIsOverflowGroupVisible: function() {
34
43
  return _useIsOverflowGroupVisible.useIsOverflowGroupVisible;
35
44
  },
@@ -42,6 +51,9 @@ _export(exports, {
42
51
  useOverflowContext: function() {
43
52
  return _overflowContext.useOverflowContext;
44
53
  },
54
+ useOverflowContextValues_unstable: function() {
55
+ return _useOverflowContextValues.useOverflowContextValues_unstable;
56
+ },
45
57
  useOverflowCount: function() {
46
58
  return _useOverflowCount.useOverflowCount;
47
59
  },
@@ -54,8 +66,14 @@ _export(exports, {
54
66
  useOverflowMenu: function() {
55
67
  return _useOverflowMenu.useOverflowMenu;
56
68
  },
69
+ useOverflowStyles_unstable: function() {
70
+ return _Overflow.useOverflowStyles_unstable;
71
+ },
57
72
  useOverflowVisibility: function() {
58
73
  return _useOverflowVisibility.useOverflowVisibility;
74
+ },
75
+ useOverflow_unstable: function() {
76
+ return _Overflow.useOverflow_unstable;
59
77
  }
60
78
  });
61
79
  const _Overflow = require("./components/Overflow");
@@ -63,6 +81,7 @@ const _constants = require("./constants");
63
81
  const _useIsOverflowGroupVisible = require("./useIsOverflowGroupVisible");
64
82
  const _useIsOverflowItemVisible = require("./useIsOverflowItemVisible");
65
83
  const _useOverflowContainer = require("./useOverflowContainer");
84
+ const _useOverflowContextValues = require("./useOverflowContextValues");
66
85
  const _useOverflowCount = require("./useOverflowCount");
67
86
  const _useOverflowItem = require("./useOverflowItem");
68
87
  const _useOverflowMenu = require("./useOverflowMenu");
@@ -71,3 +90,4 @@ const _useOverflowVisibility = require("./useOverflowVisibility");
71
90
  const _overflowContext = require("./overflowContext");
72
91
  const _OverflowItem = require("./components/OverflowItem/OverflowItem");
73
92
  const _OverflowDivider = require("./components/OverflowDivider/OverflowDivider");
93
+ const _OverflowReorderObserver = require("./components/OverflowReorderObserver");
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { Overflow } from './components/Overflow';\nexport type { OverflowProps, OnOverflowChangeData } from './components/Overflow';\nexport { DATA_OVERFLOWING, DATA_OVERFLOW_ITEM, DATA_OVERFLOW_MENU, DATA_OVERFLOW_DIVIDER } from './constants';\nexport type { UseOverflowContainerReturn } from './types';\nexport { useIsOverflowGroupVisible } from './useIsOverflowGroupVisible';\nexport { useIsOverflowItemVisible } from './useIsOverflowItemVisible';\nexport { useOverflowContainer } from './useOverflowContainer';\nexport { useOverflowCount } from './useOverflowCount';\nexport { useOverflowItem } from './useOverflowItem';\nexport { useOverflowMenu } from './useOverflowMenu';\nexport { useOverflowDivider } from './useOverflowDivider';\nexport { useOverflowVisibility } from './useOverflowVisibility';\n\nexport { useOverflowContext } from './overflowContext';\n\nexport type { OverflowItemProps } from './components/OverflowItem/OverflowItem.types';\nexport { OverflowItem } from './components/OverflowItem/OverflowItem';\nexport { OverflowDivider } from './components/OverflowDivider/OverflowDivider';\n"],"names":["Overflow","DATA_OVERFLOWING","DATA_OVERFLOW_ITEM","DATA_OVERFLOW_MENU","DATA_OVERFLOW_DIVIDER","useIsOverflowGroupVisible","useIsOverflowItemVisible","useOverflowContainer","useOverflowCount","useOverflowItem","useOverflowMenu","useOverflowDivider","useOverflowVisibility","useOverflowContext","OverflowItem","OverflowDivider"],"mappings":";;;;;;;;;;;IAESC,gBAAgB;;;;eAA0CG,gCAAqB;;;eAA7DF,6BAAkB;;;eAAEC,6BAAkB;;;eAFxDH,kBAAQ;;;eAiBRe,gCAAe;;gBADH;eAAZD;;;eAZAT,oDAAyB;;IACzBC,wBAAwB;;;;eACxBC,0CAAoB;;;eAOpBM,mCAAkB;;;eANlBL,kCAAgB;;;eAGhBG,sCAAkB;;;eAFlBF,gCAAe;;;eACfC,gCAAe;;;eAEfE,4CAAqB;;;0BAXL,wBAAwB;2BAE+C,cAAc;2CAEpE,8BAA8B;0CAC/B,6BAA6B;sCACjC,yBAAyB;kCAC7B,qBAAqB;iCACtB,oBAAoB;iCACpB,oBAAoB;oCACjB,uBAAuB;uCACpB,0BAA0B;iCAE7B,oBAAoB;8BAG1B,yCAAyC;iCACtC,+CAA+C"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {\n Overflow,\n useOverflow_unstable,\n renderOverflow_unstable,\n useOverflowStyles_unstable,\n} from './components/Overflow';\nexport type {\n OverflowProps,\n OnOverflowChangeData,\n OverflowState,\n OverflowComponentState,\n OverflowContextValues,\n} from './components/Overflow';\nexport { DATA_OVERFLOWING, DATA_OVERFLOW_ITEM, DATA_OVERFLOW_MENU, DATA_OVERFLOW_DIVIDER } from './constants';\nexport type { UseOverflowContainerReturn } from './types';\nexport { useIsOverflowGroupVisible } from './useIsOverflowGroupVisible';\nexport { useIsOverflowItemVisible } from './useIsOverflowItemVisible';\nexport { useOverflowContainer } from './useOverflowContainer';\nexport { useOverflowContextValues_unstable } from './useOverflowContextValues';\nexport { useOverflowCount } from './useOverflowCount';\nexport { useOverflowItem } from './useOverflowItem';\nexport { useOverflowMenu } from './useOverflowMenu';\nexport { useOverflowDivider } from './useOverflowDivider';\nexport { useOverflowVisibility } from './useOverflowVisibility';\n\nexport { useOverflowContext, OverflowProvider } from './overflowContext';\nexport type { OverflowContextValue } from './overflowContext';\n\nexport type { OverflowItemProps } from './components/OverflowItem/OverflowItem.types';\nexport type { OverflowDividerProps } from './components/OverflowDivider/OverflowDivider.types';\nexport { OverflowItem } from './components/OverflowItem/OverflowItem';\nexport { OverflowDivider } from './components/OverflowDivider/OverflowDivider';\nexport { OverflowReorderObserver } from './components/OverflowReorderObserver';\n\nexport type { OnUpdateItemVisibility, OnUpdateOverflow, OverflowEventPayload } from '@fluentui/priority-overflow';\n"],"names":["Overflow","useOverflow_unstable","renderOverflow_unstable","useOverflowStyles_unstable","DATA_OVERFLOWING","DATA_OVERFLOW_ITEM","DATA_OVERFLOW_MENU","DATA_OVERFLOW_DIVIDER","useIsOverflowGroupVisible","useIsOverflowItemVisible","useOverflowContainer","useOverflowContextValues_unstable","useOverflowCount","useOverflowItem","useOverflowMenu","useOverflowDivider","useOverflowVisibility","useOverflowContext","OverflowProvider","OverflowItem","OverflowDivider","OverflowReorderObserver"],"mappings":";;;;;;;;;;;IAaSI;0CAAgB;;yBAA+D;eAArBG;;;eAAxCF,6BAAkB;;;eAAEC,6BAAkB;;;eAZ/DN,kBAAQ;;IA8BDoB;+CAAe;;;eADfD,0BAAY;;oBALwB;eAAhBD;;IAOpBG,uBAAuB;;;;eA7B9BnB,iCAAuB;;;eAYhBM,oDAAyB;;;eACzBC,kDAAwB;;;eACxBC,0CAAoB;;;eAQpBO,mCAAkB;;;eAPlBN,2DAAiC;;oBACjB;eAAhBC;;sBAGkB;eAAlBG;;;eAFAF,gCAAe;;mBACA;eAAfC;;;eAjBPX,oCAA0B;;;eAmBnBa,4CAAqB;;;eArB5Bf,8BAAoB;;;0BAGf,wBAAwB;2BAQiE,cAAc;2CAEpE,8BAA8B;0CAC/B,6BAA6B;sCACjC,yBAAyB;0CACZ,6BAA6B;kCAC9C,qBAAqB;iCACtB,oBAAoB;iCACpB,oBAAoB;oCACjB,uBAAuB;uCACpB,0BAA0B;iCAEX,oBAAoB;8BAK5C,yCAAyC;iCACtC,+CAA+C;yCACvC,uCAAuC"}
@@ -13,19 +13,34 @@ _export(exports, {
13
13
  OverflowContext: function() {
14
14
  return OverflowContext;
15
15
  },
16
+ OverflowProvider: function() {
17
+ return OverflowProvider;
18
+ },
16
19
  useOverflowContext: function() {
17
20
  return useOverflowContext;
18
21
  }
19
22
  });
20
- const _reactcontextselector = require("@fluentui/react-context-selector");
21
- const OverflowContext = (0, _reactcontextselector.createContext)(undefined);
23
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
24
+ const _priorityoverflow = require("@fluentui/priority-overflow");
25
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
26
+ const OverflowContext = /*#__PURE__*/ _react.createContext(undefined);
27
+ const OverflowProvider = OverflowContext.Provider;
28
+ const noop = ()=>{
29
+ /* noop */ };
22
30
  const overflowContextDefaultValue = {
31
+ hasOverflow: false,
23
32
  itemVisibility: {},
24
33
  groupVisibility: {},
25
- hasOverflow: false,
26
- registerItem: ()=>()=>null,
27
- updateOverflow: ()=>null,
28
- registerOverflowMenu: ()=>()=>null,
29
- registerDivider: ()=>()=>null
34
+ registerItem: ()=>noop,
35
+ updateOverflow: noop,
36
+ forceUpdateOverflow: noop,
37
+ registerOverflowMenu: ()=>noop,
38
+ registerDivider: ()=>noop,
39
+ getSnapshot: ()=>_priorityoverflow.EMPTY_SNAPSHOT,
40
+ subscribe: ()=>noop
30
41
  };
31
- const useOverflowContext = (selector)=>(0, _reactcontextselector.useContextSelector)(OverflowContext, (ctx = overflowContextDefaultValue)=>selector(ctx));
42
+ function useOverflowContext(selector) {
43
+ var _React_useContext;
44
+ const context = (_React_useContext = _react.useContext(OverflowContext)) !== null && _React_useContext !== void 0 ? _React_useContext : overflowContextDefaultValue;
45
+ return selector ? selector(context) : context;
46
+ }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/overflowContext.ts"],"sourcesContent":["'use client';\n\nimport type { OverflowGroupState, OverflowItemEntry, OverflowDividerEntry } from '@fluentui/priority-overflow';\nimport type { ContextSelector, Context } from '@fluentui/react-context-selector';\nimport { createContext, useContextSelector } from '@fluentui/react-context-selector';\n\n/**\n * @internal\n */\nexport interface OverflowContextValue {\n itemVisibility: Record<string, boolean>;\n groupVisibility: Record<string, OverflowGroupState>;\n hasOverflow: boolean;\n registerItem: (item: OverflowItemEntry) => () => void;\n registerOverflowMenu: (el: HTMLElement) => () => void;\n registerDivider: (divider: OverflowDividerEntry) => () => void;\n updateOverflow: (padding?: number) => void;\n}\n\nexport const OverflowContext = createContext<OverflowContextValue | undefined>(\n undefined,\n) as Context<OverflowContextValue>;\n\nconst overflowContextDefaultValue: OverflowContextValue = {\n itemVisibility: {},\n groupVisibility: {},\n hasOverflow: false,\n registerItem: () => () => null,\n updateOverflow: () => null,\n registerOverflowMenu: () => () => null,\n registerDivider: () => () => null,\n};\n\n/**\n * @internal\n */\nexport const useOverflowContext = <SelectedValue>(\n selector: ContextSelector<OverflowContextValue, SelectedValue>,\n): SelectedValue => useContextSelector(OverflowContext, (ctx = overflowContextDefaultValue) => selector(ctx));\n"],"names":["createContext","useContextSelector","OverflowContext","undefined","overflowContextDefaultValue","itemVisibility","groupVisibility","hasOverflow","registerItem","updateOverflow","registerOverflowMenu","registerDivider","useOverflowContext","selector","ctx"],"mappings":"AAAA;;;;;;;;;;;;mBAmBaE;;;sBAiBAU;;;;sCAhCqC,mCAAmC;AAe9E,MAAMV,sBAAkBF,mCAAAA,EAC7BG,WACiC;AAEnC,MAAMC,8BAAoD;IACxDC,gBAAgB,CAAC;IACjBC,iBAAiB,CAAC;IAClBC,aAAa;IACbC,cAAc,IAAM,IAAM;IAC1BC,gBAAgB,IAAM;IACtBC,sBAAsB,IAAM,IAAM;IAClCC,iBAAiB,IAAM,IAAM;AAC/B;AAKO,MAAMC,qBAAqB,CAChCC,eACkBZ,wCAAAA,EAAmBC,iBAAiB,CAACY,MAAMV,2BAA2B,GAAKS,SAASC,MAAM"}
1
+ {"version":3,"sources":["../src/overflowContext.ts"],"sourcesContent":["'use client';\n\nimport type {\n OverflowItemEntry,\n OverflowDividerEntry,\n OverflowGroupState,\n OverflowSnapshot,\n} from '@fluentui/priority-overflow';\nimport { EMPTY_SNAPSHOT } from '@fluentui/priority-overflow';\nimport * as React from 'react';\n\n/**\n * @public\n */\nexport interface OverflowContextValue {\n /**\n * @deprecated This value is not guaranteed to be up to date and should not be used directly. Use getSnapshot or the provided hooks instead\n */\n itemVisibility: Record<string, boolean>;\n /**\n * @deprecated This value is not guaranteed to be up to date and should not be used directly. Use getSnapshot or the provided hooks instead\n */\n groupVisibility: Record<string, OverflowGroupState>;\n /**\n * @deprecated This value is not guaranteed to be up to date and should not be used directly. Use getSnapshot or the provided hooks instead\n */\n hasOverflow: boolean;\n registerItem: (item: OverflowItemEntry) => () => void;\n registerOverflowMenu: (el: HTMLElement) => () => void;\n registerDivider: (divider: OverflowDividerEntry) => () => void;\n updateOverflow: (padding?: number) => void;\n forceUpdateOverflow: () => void;\n containerRef?: React.RefObject<HTMLElement | null>;\n getSnapshot: () => OverflowSnapshot;\n subscribe: (listener: () => void) => () => void;\n}\n\nexport const OverflowContext = React.createContext<OverflowContextValue | undefined>(\n undefined,\n) as React.Context<OverflowContextValue>;\n\n/**\n * Provides an {@link OverflowContextValue} to descendant overflow hooks and components.\n * Used by headless consumers that build their own overflow root.\n * @public\n */\nexport const OverflowProvider = OverflowContext.Provider;\n\nconst noop = () => {\n /* noop */\n};\n\nconst overflowContextDefaultValue: OverflowContextValue = {\n hasOverflow: false,\n itemVisibility: {},\n groupVisibility: {},\n registerItem: () => noop,\n updateOverflow: noop,\n forceUpdateOverflow: noop,\n registerOverflowMenu: () => noop,\n registerDivider: () => noop,\n getSnapshot: () => EMPTY_SNAPSHOT,\n subscribe: () => noop,\n};\n\n/**\n * @internal\n */\nexport function useOverflowContext(): OverflowContextValue;\n/**\n * @internal\n */\nexport function useOverflowContext<SelectedValue>(\n selector: (context: OverflowContextValue) => SelectedValue,\n): SelectedValue;\nexport function useOverflowContext<SelectedValue>(\n selector?: (context: OverflowContextValue) => SelectedValue,\n): SelectedValue | OverflowContextValue {\n const context = React.useContext(OverflowContext) ?? overflowContextDefaultValue;\n return selector ? selector(context) : context;\n}\n"],"names":["EMPTY_SNAPSHOT","React","OverflowContext","createContext","undefined","OverflowProvider","Provider","noop","overflowContextDefaultValue","hasOverflow","itemVisibility","groupVisibility","registerItem","updateOverflow","forceUpdateOverflow","registerOverflowMenu","registerDivider","getSnapshot","subscribe","useOverflowContext","selector","context","useContext"],"mappings":"AAAA;;;;;;;;;;;;IAqCaE,eAAAA;;;oBASAG;;;IA6BGc,kBAAAA;;;;;kCAnEe,8BAA8B;iEACtC,QAAQ;AA4BxB,sCAAwBlB,OAAME,aAAa,CAChDC,WACuC;AAOlC,MAAMC,mBAAmBH,gBAAgBI,QAAQ,CAAC;AAEzD,MAAMC,OAAO;AACX,QAAQ,GACV;AAEA,MAAMC,8BAAoD;IACxDC,aAAa;IACbC,gBAAgB,CAAC;IACjBC,iBAAiB,CAAC;IAClBC,cAAc,IAAML;IACpBM,gBAAgBN;IAChBO,qBAAqBP;IACrBQ,sBAAsB,IAAMR;IAC5BS,iBAAiB,IAAMT;IACvBU,aAAa,IAAMjB,gCAAAA;IACnBkB,WAAW,IAAMX;AACnB;AAYO,4BACLa,QAA2D;QAE3CnB;IAAhB,MAAMoB,UAAUpB,CAAAA,oBAAAA,OAAMqB,UAAU,CAACpB,gBAAAA,MAAAA,QAAjBD,sBAAAA,KAAAA,IAAAA,oBAAqCO;IACrD,OAAOY,WAAWA,SAASC,WAAWA;AACxC"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @internal
2
+ * @public
3
3
  */ "use strict";
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type * as React from 'react';\nimport type { OverflowContextValue } from './overflowContext';\n\n/**\n * @internal\n */\nexport interface UseOverflowContainerReturn<TElement extends HTMLElement>\n extends Pick<OverflowContextValue, 'registerItem' | 'updateOverflow' | 'registerOverflowMenu' | 'registerDivider'> {\n /**\n * Ref to apply to the container that will overflow\n */\n containerRef: React.RefObject<TElement | null>;\n}\n"],"names":[],"mappings":"AAGA;;CAEC,GACD,WAMC"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type * as React from 'react';\nimport type { OverflowContextValue } from './overflowContext';\n\n/**\n * @public\n */\nexport interface UseOverflowContainerReturn<TElement extends HTMLElement>\n extends Pick<\n OverflowContextValue,\n | 'registerItem'\n | 'updateOverflow'\n | 'forceUpdateOverflow'\n | 'registerOverflowMenu'\n | 'registerDivider'\n | 'getSnapshot'\n | 'subscribe'\n > {\n /**\n * Ref to apply to the container that will overflow\n */\n containerRef: React.RefObject<TElement | null>;\n}\n"],"names":[],"mappings":"AAGA;;CAEC,GACD,WAeC"}
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "useIsOverflowGroupVisible", {
9
9
  return useIsOverflowGroupVisible;
10
10
  }
11
11
  });
12
- const _overflowContext = require("./overflowContext");
12
+ const _useOverflowSnapshot = require("./useOverflowSnapshot");
13
13
  function useIsOverflowGroupVisible(id) {
14
- return (0, _overflowContext.useOverflowContext)((ctx)=>ctx.groupVisibility[id]);
14
+ return (0, _useOverflowSnapshot.useOverflowSnapshot)((snapshot)=>snapshot.groupVisibility[id]);
15
15
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/useIsOverflowGroupVisible.ts"],"sourcesContent":["'use client';\n\nimport type { OverflowGroupState } from '@fluentui/priority-overflow';\nimport { useOverflowContext } from './overflowContext';\n\n/**\n * @param id - unique identifier for a group of overflow items\n * @returns visibility state of the group\n */\nexport function useIsOverflowGroupVisible(id: string): OverflowGroupState {\n return useOverflowContext(ctx => ctx.groupVisibility[id]);\n}\n"],"names":["useOverflowContext","useIsOverflowGroupVisible","id","ctx","groupVisibility"],"mappings":"AAAA;;;;;;;;;;;iCAGmC,oBAAoB;AAMhD,SAASC,0BAA0BC,EAAU;IAClD,WAAOF,mCAAAA,EAAmBG,CAAAA,MAAOA,IAAIC,eAAe,CAACF,GAAG;AAC1D"}
1
+ {"version":3,"sources":["../src/useIsOverflowGroupVisible.ts"],"sourcesContent":["'use client';\n\nimport type { OverflowGroupState } from '@fluentui/priority-overflow';\nimport { useOverflowSnapshot } from './useOverflowSnapshot';\n\n/**\n * @param id - unique identifier for a group of overflow items\n * @returns visibility state of the group\n */\nexport function useIsOverflowGroupVisible(id: string): OverflowGroupState {\n return useOverflowSnapshot(snapshot => snapshot.groupVisibility[id]);\n}\n"],"names":["useOverflowSnapshot","useIsOverflowGroupVisible","id","snapshot","groupVisibility"],"mappings":"AAAA;;;;;;;;;;;qCAGoC,wBAAwB;AAMrD,SAASC,0BAA0BC,EAAU;IAClD,WAAOF,wCAAAA,EAAoBG,CAAAA,WAAYA,SAASC,eAAe,CAACF,GAAG;AACrE"}
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "useIsOverflowItemVisible", {
9
9
  return useIsOverflowItemVisible;
10
10
  }
11
11
  });
12
- const _overflowContext = require("./overflowContext");
12
+ const _useOverflowSnapshot = require("./useOverflowSnapshot");
13
13
  function useIsOverflowItemVisible(id) {
14
- return !!(0, _overflowContext.useOverflowContext)((ctx)=>ctx.itemVisibility[id]);
14
+ return (0, _useOverflowSnapshot.useOverflowSnapshot)((snapshot)=>!!snapshot.itemVisibility[id]);
15
15
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/useIsOverflowItemVisible.ts"],"sourcesContent":["'use client';\n\nimport { useOverflowContext } from './overflowContext';\n\n/**\n * @param id - unique identifier for the item used by the overflow manager\n * @returns visibility state of an overflow item\n */\nexport function useIsOverflowItemVisible(id: string): boolean {\n return !!useOverflowContext(ctx => ctx.itemVisibility[id]);\n}\n"],"names":["useOverflowContext","useIsOverflowItemVisible","id","ctx","itemVisibility"],"mappings":"AAAA;;;;;;;;;;;iCAEmC,oBAAoB;AAMhD,SAASC,yBAAyBC,EAAU;IACjD,OAAO,CAAC,KAACF,mCAAAA,EAAmBG,CAAAA,MAAOA,IAAIC,cAAc,CAACF,GAAG;AAC3D"}
1
+ {"version":3,"sources":["../src/useIsOverflowItemVisible.ts"],"sourcesContent":["'use client';\n\nimport { useOverflowSnapshot } from './useOverflowSnapshot';\n\n/**\n * @param id - unique identifier for the item used by the overflow manager\n * @returns visibility state of an overflow item\n */\nexport function useIsOverflowItemVisible(id: string): boolean {\n return useOverflowSnapshot(snapshot => !!snapshot.itemVisibility[id]);\n}\n"],"names":["useOverflowSnapshot","useIsOverflowItemVisible","id","snapshot","itemVisibility"],"mappings":"AAAA;;;;;;;;;;;qCAEoC,wBAAwB;AAMrD,SAASC,yBAAyBC,EAAU;IACjD,WAAOF,wCAAAA,EAAoBG,CAAAA,WAAY,CAAC,CAACA,SAASC,cAAc,CAACF,GAAG;AACtE"}
@@ -22,104 +22,113 @@ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
22
22
  const _priorityoverflow = require("@fluentui/priority-overflow");
23
23
  const _reactutilities = require("@fluentui/react-utilities");
24
24
  const _constants = require("./constants");
25
- const noop = ()=>null;
26
25
  const useOverflowContainer = (update, options)=>{
27
- 'use no memo';
28
26
  const { overflowAxis = 'horizontal', overflowDirection = 'end', padding = 10, minimumVisible = 0, onUpdateItemVisibility = noop, hasHiddenItems = false } = options;
29
- const onUpdateOverflow = (0, _reactutilities.useEventCallback)(update);
30
- const overflowOptions = _react.useMemo(()=>({
27
+ const onUpdateItemVisibilityCallback = (0, _reactutilities.useEventCallback)(onUpdateItemVisibility);
28
+ const observeOptions = _react.useMemo(()=>({
31
29
  overflowAxis,
32
30
  overflowDirection,
33
31
  padding,
34
32
  minimumVisible,
35
- onUpdateItemVisibility,
36
- onUpdateOverflow,
33
+ onUpdateItemVisibility: onUpdateItemVisibilityCallback,
34
+ onUpdateOverflow: update,
37
35
  hasHiddenItems
38
36
  }), [
39
37
  minimumVisible,
40
- onUpdateItemVisibility,
38
+ onUpdateItemVisibilityCallback,
41
39
  overflowAxis,
42
40
  overflowDirection,
43
41
  padding,
44
- onUpdateOverflow,
42
+ update,
45
43
  hasHiddenItems
46
44
  ]);
47
- const firstMount = (0, _reactutilities.useFirstMount)();
48
- // DOM ref to the overflow container element
49
45
  const containerRef = _react.useRef(null);
50
- const [overflowManager, setOverflowManager] = _react.useState(()=>(0, _reactutilities.canUseDOM)() ? (0, _priorityoverflow.createOverflowManager)() : null);
51
- // On first mount there is no need to create an overflow manager and re-render
46
+ const managerRef = _react.useRef(null);
47
+ if (managerRef.current === null) {
48
+ managerRef.current = (0, _reactutilities.canUseDOM)() ? (0, _priorityoverflow.createOverflowManager)(observeOptions) : null;
49
+ }
52
50
  (0, _reactutilities.useIsomorphicLayoutEffect)(()=>{
53
- if (firstMount && containerRef.current) {
54
- overflowManager === null || overflowManager === void 0 ? void 0 : overflowManager.observe(containerRef.current, overflowOptions);
51
+ if (managerRef.current && containerRef.current) {
52
+ // forceUpdate resolves overflow synchronously for a correct first paint; the manager guards it
53
+ // on the container being measured.
54
+ managerRef.current.observe(containerRef.current, {
55
+ forceUpdate: true
56
+ });
57
+ return ()=>{
58
+ var _managerRef_current;
59
+ return (_managerRef_current = managerRef.current) === null || _managerRef_current === void 0 ? void 0 : _managerRef_current.disconnect();
60
+ };
55
61
  }
56
- }, [
57
- firstMount,
58
- overflowManager,
59
- overflowOptions
60
- ]);
62
+ }, []);
61
63
  (0, _reactutilities.useIsomorphicLayoutEffect)(()=>{
62
- if (!containerRef.current || !(0, _reactutilities.canUseDOM)() || firstMount) {
63
- return;
64
- }
65
- const newOverflowManager = (0, _priorityoverflow.createOverflowManager)();
66
- newOverflowManager.observe(containerRef.current, overflowOptions);
67
- setOverflowManager(newOverflowManager);
68
- // We don't want to re-create the overflow manager when the first mount flag changes from true to false
69
- // eslint-disable-next-line react-hooks/exhaustive-deps
64
+ var _managerRef_current;
65
+ (_managerRef_current = managerRef.current) === null || _managerRef_current === void 0 ? void 0 : _managerRef_current.setOptions(observeOptions);
70
66
  }, [
71
- overflowOptions
72
- ]);
73
- /* Clean up overflow manager on unmount */ _react.useEffect(()=>()=>{
74
- overflowManager === null || overflowManager === void 0 ? void 0 : overflowManager.disconnect();
75
- }, [
76
- overflowManager
67
+ observeOptions
77
68
  ]);
78
69
  const registerItem = _react.useCallback((item)=>{
79
- overflowManager === null || overflowManager === void 0 ? void 0 : overflowManager.addItem(item);
70
+ var _managerRef_current;
71
+ (_managerRef_current = managerRef.current) === null || _managerRef_current === void 0 ? void 0 : _managerRef_current.addItem(item);
80
72
  item.element.setAttribute(_constants.DATA_OVERFLOW_ITEM, '');
81
73
  return ()=>{
74
+ var _managerRef_current;
82
75
  item.element.removeAttribute(_constants.DATA_OVERFLOWING);
83
76
  item.element.removeAttribute(_constants.DATA_OVERFLOW_ITEM);
84
- overflowManager === null || overflowManager === void 0 ? void 0 : overflowManager.removeItem(item.id);
77
+ (_managerRef_current = managerRef.current) === null || _managerRef_current === void 0 ? void 0 : _managerRef_current.removeItem(item.id);
85
78
  };
86
- }, [
87
- overflowManager
88
- ]);
79
+ }, []);
89
80
  const registerDivider = _react.useCallback((divider)=>{
81
+ var _managerRef_current;
90
82
  const el = divider.element;
91
- overflowManager === null || overflowManager === void 0 ? void 0 : overflowManager.addDivider(divider);
83
+ (_managerRef_current = managerRef.current) === null || _managerRef_current === void 0 ? void 0 : _managerRef_current.addDivider(divider);
92
84
  el.setAttribute(_constants.DATA_OVERFLOW_DIVIDER, '');
93
85
  return ()=>{
94
- divider.groupId && (overflowManager === null || overflowManager === void 0 ? void 0 : overflowManager.removeDivider(divider.groupId));
86
+ var _managerRef_current;
87
+ (_managerRef_current = managerRef.current) === null || _managerRef_current === void 0 ? void 0 : _managerRef_current.removeDivider(divider.groupId);
95
88
  el.removeAttribute(_constants.DATA_OVERFLOW_DIVIDER);
96
89
  };
97
- }, [
98
- overflowManager
99
- ]);
90
+ }, []);
100
91
  const registerOverflowMenu = _react.useCallback((el)=>{
101
- overflowManager === null || overflowManager === void 0 ? void 0 : overflowManager.addOverflowMenu(el);
92
+ var _managerRef_current;
93
+ (_managerRef_current = managerRef.current) === null || _managerRef_current === void 0 ? void 0 : _managerRef_current.addOverflowMenu(el);
102
94
  el.setAttribute(_constants.DATA_OVERFLOW_MENU, '');
103
95
  return ()=>{
104
- overflowManager === null || overflowManager === void 0 ? void 0 : overflowManager.removeOverflowMenu();
96
+ var _managerRef_current;
97
+ (_managerRef_current = managerRef.current) === null || _managerRef_current === void 0 ? void 0 : _managerRef_current.removeOverflowMenu();
105
98
  el.removeAttribute(_constants.DATA_OVERFLOW_MENU);
106
99
  };
107
- }, [
108
- overflowManager
109
- ]);
100
+ }, []);
110
101
  const updateOverflow = _react.useCallback(()=>{
111
- overflowManager === null || overflowManager === void 0 ? void 0 : overflowManager.update();
112
- }, [
113
- overflowManager
114
- ]);
102
+ var _managerRef_current;
103
+ (_managerRef_current = managerRef.current) === null || _managerRef_current === void 0 ? void 0 : _managerRef_current.update();
104
+ }, []);
105
+ const getSnapshot = _react.useCallback(()=>{
106
+ var _managerRef_current;
107
+ var _managerRef_current_getSnapshot;
108
+ return (_managerRef_current_getSnapshot = (_managerRef_current = managerRef.current) === null || _managerRef_current === void 0 ? void 0 : _managerRef_current.getSnapshot()) !== null && _managerRef_current_getSnapshot !== void 0 ? _managerRef_current_getSnapshot : _priorityoverflow.EMPTY_SNAPSHOT;
109
+ }, []);
110
+ const subscribe = _react.useCallback((listener)=>{
111
+ var _managerRef_current;
112
+ var _managerRef_current_subscribe;
113
+ return (_managerRef_current_subscribe = (_managerRef_current = managerRef.current) === null || _managerRef_current === void 0 ? void 0 : _managerRef_current.subscribe(listener)) !== null && _managerRef_current_subscribe !== void 0 ? _managerRef_current_subscribe : noop;
114
+ }, []);
115
+ const forceUpdateOverflow = _react.useCallback(()=>{
116
+ var _managerRef_current;
117
+ (_managerRef_current = managerRef.current) === null || _managerRef_current === void 0 ? void 0 : _managerRef_current.forceUpdate();
118
+ }, []);
115
119
  return {
116
120
  registerItem,
117
121
  registerDivider,
118
122
  registerOverflowMenu,
119
123
  updateOverflow,
120
- containerRef
124
+ forceUpdateOverflow,
125
+ containerRef,
126
+ getSnapshot,
127
+ subscribe
121
128
  };
122
129
  };
130
+ const noop = ()=>{
131
+ /* noop */ };
123
132
  const updateVisibilityAttribute = ({ item, visible })=>{
124
133
  if (visible) {
125
134
  item.element.removeAttribute(_constants.DATA_OVERFLOWING);