@fluentui/react-overflow 9.8.0 → 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.
- package/CHANGELOG.md +20 -2
- package/dist/index.d.ts +99 -17
- package/lib/components/Overflow/Overflow.js +14 -0
- package/lib/components/Overflow/Overflow.js.map +1 -0
- package/lib/components/Overflow/Overflow.types.js +3 -0
- package/lib/components/Overflow/Overflow.types.js.map +1 -0
- package/lib/components/Overflow/index.js +4 -0
- package/lib/components/Overflow/index.js.map +1 -0
- package/lib/components/Overflow/renderOverflow.js +19 -0
- package/lib/components/Overflow/renderOverflow.js.map +1 -0
- package/lib/components/Overflow/useOverflow.js +42 -0
- package/lib/components/Overflow/useOverflow.js.map +1 -0
- package/lib/components/Overflow/useOverflowStyles.styles.js +22 -0
- package/lib/components/Overflow/useOverflowStyles.styles.js.map +1 -0
- package/lib/components/Overflow/useOverflowStyles.styles.raw.js +23 -0
- package/lib/components/Overflow/useOverflowStyles.styles.raw.js.map +1 -0
- package/lib/index.js +3 -2
- package/lib/index.js.map +1 -1
- package/lib/overflowContext.js +23 -10
- package/lib/overflowContext.js.map +1 -1
- package/lib/types.js +1 -1
- package/lib/types.js.map +1 -1
- package/lib/useIsOverflowGroupVisible.js +2 -2
- package/lib/useIsOverflowGroupVisible.js.map +1 -1
- package/lib/useIsOverflowItemVisible.js +2 -2
- package/lib/useIsOverflowItemVisible.js.map +1 -1
- package/lib/useOverflowContainer.js +64 -55
- package/lib/useOverflowContainer.js.map +1 -1
- package/lib/useOverflowContextValues.js +35 -0
- package/lib/useOverflowContextValues.js.map +1 -0
- package/lib/useOverflowCount.js +3 -9
- package/lib/useOverflowCount.js.map +1 -1
- package/lib/useOverflowMenu.js +10 -12
- package/lib/useOverflowMenu.js.map +1 -1
- package/lib/useOverflowSnapshot.js +23 -0
- package/lib/useOverflowSnapshot.js.map +1 -0
- package/lib/useOverflowVisibility.js +6 -11
- package/lib/useOverflowVisibility.js.map +1 -1
- package/lib-commonjs/components/Overflow/Overflow.js +23 -0
- package/lib-commonjs/components/Overflow/Overflow.js.map +1 -0
- package/lib-commonjs/components/Overflow/Overflow.types.js +6 -0
- package/lib-commonjs/components/Overflow/Overflow.types.js.map +1 -0
- package/lib-commonjs/components/Overflow/index.js +28 -0
- package/lib-commonjs/components/Overflow/index.js.map +1 -0
- package/lib-commonjs/components/Overflow/renderOverflow.js +25 -0
- package/lib-commonjs/components/Overflow/renderOverflow.js.map +1 -0
- package/lib-commonjs/components/Overflow/useOverflow.js +47 -0
- package/lib-commonjs/components/Overflow/useOverflow.js.map +1 -0
- package/lib-commonjs/components/Overflow/useOverflowStyles.styles.js +41 -0
- package/lib-commonjs/components/Overflow/useOverflowStyles.styles.js.map +1 -0
- package/lib-commonjs/components/Overflow/useOverflowStyles.styles.raw.js +41 -0
- package/lib-commonjs/components/Overflow/useOverflowStyles.styles.raw.js.map +1 -0
- package/lib-commonjs/index.js +16 -0
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/overflowContext.js +23 -8
- package/lib-commonjs/overflowContext.js.map +1 -1
- package/lib-commonjs/types.js +1 -1
- package/lib-commonjs/types.js.map +1 -1
- package/lib-commonjs/useIsOverflowGroupVisible.js +2 -2
- package/lib-commonjs/useIsOverflowGroupVisible.js.map +1 -1
- package/lib-commonjs/useIsOverflowItemVisible.js +2 -2
- package/lib-commonjs/useIsOverflowItemVisible.js.map +1 -1
- package/lib-commonjs/useOverflowContainer.js +62 -53
- package/lib-commonjs/useOverflowContainer.js.map +1 -1
- package/lib-commonjs/useOverflowContextValues.js +41 -0
- package/lib-commonjs/useOverflowContextValues.js.map +1 -0
- package/lib-commonjs/useOverflowCount.js +3 -9
- package/lib-commonjs/useOverflowCount.js.map +1 -1
- package/lib-commonjs/useOverflowMenu.js +10 -12
- package/lib-commonjs/useOverflowMenu.js.map +1 -1
- package/lib-commonjs/useOverflowSnapshot.js +30 -0
- package/lib-commonjs/useOverflowSnapshot.js.map +1 -0
- package/lib-commonjs/useOverflowVisibility.js +6 -12
- package/lib-commonjs/useOverflowVisibility.js.map +1 -1
- package/package.json +3 -4
- package/lib/components/Overflow.js +0 -61
- package/lib/components/Overflow.js.map +0 -1
- package/lib/components/useOverflowStyles.styles.js +0 -14
- package/lib/components/useOverflowStyles.styles.js.map +0 -1
- package/lib/components/useOverflowStyles.styles.raw.js +0 -15
- package/lib/components/useOverflowStyles.styles.raw.js.map +0 -1
- package/lib-commonjs/components/Overflow.js +0 -70
- package/lib-commonjs/components/Overflow.js.map +0 -1
- package/lib-commonjs/components/useOverflowStyles.styles.js +0 -25
- package/lib-commonjs/components/useOverflowStyles.styles.js.map +0 -1
- package/lib-commonjs/components/useOverflowStyles.styles.raw.js +0 -25
- package/lib-commonjs/components/useOverflowStyles.styles.raw.js.map +0 -1
|
@@ -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"}
|
package/lib-commonjs/index.js
CHANGED
|
@@ -30,9 +30,15 @@ _export(exports, {
|
|
|
30
30
|
OverflowItem: function() {
|
|
31
31
|
return _OverflowItem.OverflowItem;
|
|
32
32
|
},
|
|
33
|
+
OverflowProvider: function() {
|
|
34
|
+
return _overflowContext.OverflowProvider;
|
|
35
|
+
},
|
|
33
36
|
OverflowReorderObserver: function() {
|
|
34
37
|
return _OverflowReorderObserver.OverflowReorderObserver;
|
|
35
38
|
},
|
|
39
|
+
renderOverflow_unstable: function() {
|
|
40
|
+
return _Overflow.renderOverflow_unstable;
|
|
41
|
+
},
|
|
36
42
|
useIsOverflowGroupVisible: function() {
|
|
37
43
|
return _useIsOverflowGroupVisible.useIsOverflowGroupVisible;
|
|
38
44
|
},
|
|
@@ -45,6 +51,9 @@ _export(exports, {
|
|
|
45
51
|
useOverflowContext: function() {
|
|
46
52
|
return _overflowContext.useOverflowContext;
|
|
47
53
|
},
|
|
54
|
+
useOverflowContextValues_unstable: function() {
|
|
55
|
+
return _useOverflowContextValues.useOverflowContextValues_unstable;
|
|
56
|
+
},
|
|
48
57
|
useOverflowCount: function() {
|
|
49
58
|
return _useOverflowCount.useOverflowCount;
|
|
50
59
|
},
|
|
@@ -57,8 +66,14 @@ _export(exports, {
|
|
|
57
66
|
useOverflowMenu: function() {
|
|
58
67
|
return _useOverflowMenu.useOverflowMenu;
|
|
59
68
|
},
|
|
69
|
+
useOverflowStyles_unstable: function() {
|
|
70
|
+
return _Overflow.useOverflowStyles_unstable;
|
|
71
|
+
},
|
|
60
72
|
useOverflowVisibility: function() {
|
|
61
73
|
return _useOverflowVisibility.useOverflowVisibility;
|
|
74
|
+
},
|
|
75
|
+
useOverflow_unstable: function() {
|
|
76
|
+
return _Overflow.useOverflow_unstable;
|
|
62
77
|
}
|
|
63
78
|
});
|
|
64
79
|
const _Overflow = require("./components/Overflow");
|
|
@@ -66,6 +81,7 @@ const _constants = require("./constants");
|
|
|
66
81
|
const _useIsOverflowGroupVisible = require("./useIsOverflowGroupVisible");
|
|
67
82
|
const _useIsOverflowItemVisible = require("./useIsOverflowItemVisible");
|
|
68
83
|
const _useOverflowContainer = require("./useOverflowContainer");
|
|
84
|
+
const _useOverflowContextValues = require("./useOverflowContextValues");
|
|
69
85
|
const _useOverflowCount = require("./useOverflowCount");
|
|
70
86
|
const _useOverflowItem = require("./useOverflowItem");
|
|
71
87
|
const _useOverflowMenu = require("./useOverflowMenu");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {
|
|
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
|
|
21
|
-
const
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
registerOverflowMenu: ()=>
|
|
29
|
-
registerDivider: ()=>
|
|
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
|
-
|
|
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
|
|
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"}
|
package/lib-commonjs/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type * as React from 'react';\nimport type { OverflowContextValue } from './overflowContext';\n\n/**\n * @
|
|
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
|
|
12
|
+
const _useOverflowSnapshot = require("./useOverflowSnapshot");
|
|
13
13
|
function useIsOverflowGroupVisible(id) {
|
|
14
|
-
return (0,
|
|
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 {
|
|
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
|
|
12
|
+
const _useOverflowSnapshot = require("./useOverflowSnapshot");
|
|
13
13
|
function useIsOverflowItemVisible(id) {
|
|
14
|
-
return
|
|
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 {
|
|
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
|
|
30
|
-
const
|
|
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
|
-
|
|
38
|
+
onUpdateItemVisibilityCallback,
|
|
41
39
|
overflowAxis,
|
|
42
40
|
overflowDirection,
|
|
43
41
|
padding,
|
|
44
|
-
|
|
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
|
|
51
|
-
|
|
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 (
|
|
54
|
-
|
|
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
|
-
|
|
63
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
-
|
|
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);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useOverflowContainer.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createOverflowManager } from '@fluentui/priority-overflow';\n\n/**\n * @internal\n */\nimport type {\n OnUpdateItemVisibility,\n OnUpdateOverflow,\n OverflowItemEntry,\n OverflowDividerEntry,\n OverflowManager,\n
|
|
1
|
+
{"version":3,"sources":["../src/useOverflowContainer.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createOverflowManager, EMPTY_SNAPSHOT } from '@fluentui/priority-overflow';\n\n/**\n * @internal\n */\nimport type {\n OnUpdateItemVisibility,\n OnUpdateOverflow,\n OverflowItemEntry,\n OverflowDividerEntry,\n OverflowManager,\n OverflowOptions,\n} from '@fluentui/priority-overflow';\nimport { canUseDOM, useEventCallback, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport type { UseOverflowContainerReturn } from './types';\nimport { DATA_OVERFLOWING, DATA_OVERFLOW_DIVIDER, DATA_OVERFLOW_ITEM, DATA_OVERFLOW_MENU } from './constants';\n\n/**\n * @internal\n * @param update - Callback when overflow state changes\n * @param options - Options to configure the overflow container\n * @returns - ref to attach to an intrinsic HTML element and imperative functions\n */\nexport const useOverflowContainer = <TElement extends HTMLElement>(\n update: OnUpdateOverflow,\n options: Omit<OverflowOptions, 'onUpdateOverflow'>,\n): UseOverflowContainerReturn<TElement> => {\n const {\n overflowAxis = 'horizontal',\n overflowDirection = 'end',\n padding = 10,\n minimumVisible = 0,\n onUpdateItemVisibility = noop,\n hasHiddenItems = false,\n } = options;\n\n const onUpdateItemVisibilityCallback = useEventCallback(onUpdateItemVisibility);\n\n const observeOptions: Required<OverflowOptions> = React.useMemo(\n () => ({\n overflowAxis,\n overflowDirection,\n padding,\n minimumVisible,\n onUpdateItemVisibility: onUpdateItemVisibilityCallback,\n onUpdateOverflow: update,\n hasHiddenItems,\n }),\n [minimumVisible, onUpdateItemVisibilityCallback, overflowAxis, overflowDirection, padding, update, hasHiddenItems],\n );\n\n const containerRef = React.useRef<TElement>(null);\n\n const managerRef = React.useRef<OverflowManager | null>(null);\n\n if (managerRef.current === null) {\n managerRef.current = canUseDOM() ? createOverflowManager(observeOptions) : null;\n }\n\n useIsomorphicLayoutEffect(() => {\n if (managerRef.current && containerRef.current) {\n // forceUpdate resolves overflow synchronously for a correct first paint; the manager guards it\n // on the container being measured.\n managerRef.current.observe(containerRef.current, { forceUpdate: true });\n return () => managerRef.current?.disconnect();\n }\n }, []);\n\n useIsomorphicLayoutEffect(() => {\n managerRef.current?.setOptions(observeOptions);\n }, [observeOptions]);\n\n const registerItem = React.useCallback((item: OverflowItemEntry) => {\n managerRef.current?.addItem(item);\n item.element.setAttribute(DATA_OVERFLOW_ITEM, '');\n\n return () => {\n item.element.removeAttribute(DATA_OVERFLOWING);\n item.element.removeAttribute(DATA_OVERFLOW_ITEM);\n managerRef.current?.removeItem(item.id);\n };\n }, []);\n\n const registerDivider = React.useCallback((divider: OverflowDividerEntry) => {\n const el = divider.element;\n managerRef.current?.addDivider(divider);\n el.setAttribute(DATA_OVERFLOW_DIVIDER, '');\n\n return () => {\n managerRef.current?.removeDivider(divider.groupId);\n el.removeAttribute(DATA_OVERFLOW_DIVIDER);\n };\n }, []);\n\n const registerOverflowMenu = React.useCallback((el: HTMLElement) => {\n managerRef.current?.addOverflowMenu(el);\n el.setAttribute(DATA_OVERFLOW_MENU, '');\n\n return () => {\n managerRef.current?.removeOverflowMenu();\n el.removeAttribute(DATA_OVERFLOW_MENU);\n };\n }, []);\n\n const updateOverflow = React.useCallback(() => {\n managerRef.current?.update();\n }, []);\n\n const getSnapshot = React.useCallback<OverflowManager['getSnapshot']>(\n () => managerRef.current?.getSnapshot() ?? EMPTY_SNAPSHOT,\n [],\n );\n\n const subscribe = React.useCallback<OverflowManager['subscribe']>(\n listener => managerRef.current?.subscribe(listener) ?? noop,\n [],\n );\n\n const forceUpdateOverflow = React.useCallback(() => {\n managerRef.current?.forceUpdate();\n }, []);\n\n return {\n registerItem,\n registerDivider,\n registerOverflowMenu,\n updateOverflow,\n forceUpdateOverflow,\n containerRef,\n getSnapshot,\n subscribe,\n };\n};\n\nconst noop = () => {\n /* noop */\n};\n\nexport const updateVisibilityAttribute: OnUpdateItemVisibility = ({ item, visible }) => {\n if (visible) {\n item.element.removeAttribute(DATA_OVERFLOWING);\n } else {\n item.element.setAttribute(DATA_OVERFLOWING, '');\n }\n};\n"],"names":["React","createOverflowManager","EMPTY_SNAPSHOT","canUseDOM","useEventCallback","useIsomorphicLayoutEffect","DATA_OVERFLOWING","DATA_OVERFLOW_DIVIDER","DATA_OVERFLOW_ITEM","DATA_OVERFLOW_MENU","useOverflowContainer","update","options","overflowAxis","overflowDirection","padding","minimumVisible","onUpdateItemVisibility","noop","hasHiddenItems","onUpdateItemVisibilityCallback","observeOptions","useMemo","onUpdateOverflow","containerRef","useRef","managerRef","current","observe","forceUpdate","disconnect","setOptions","registerItem","useCallback","item","addItem","element","setAttribute","removeAttribute","removeItem","id","registerDivider","divider","el","addDivider","removeDivider","groupId","registerOverflowMenu","addOverflowMenu","removeOverflowMenu","updateOverflow","getSnapshot","subscribe","listener","forceUpdateOverflow","updateVisibilityAttribute","visible"],"mappings":"AAAA;;;;;;;;;;;;6BA6IauD;;;IAnHA7C,oBAAAA;;;;;iEAxBU,QAAQ;kCACuB,8BAA8B;gCAab,4BAA4B;2BAEH,cAAc;AAQvG,6BA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
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "useOverflowContextValues_unstable", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function() {
|
|
9
|
+
return useOverflowContextValues_unstable;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
13
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
14
|
+
const useOverflowContextValues_unstable = (state)=>{
|
|
15
|
+
const { registerItem, registerDivider, registerOverflowMenu, updateOverflow, forceUpdateOverflow, containerRef, getSnapshot, subscribe } = state;
|
|
16
|
+
const overflow = _react.useMemo(()=>({
|
|
17
|
+
groupVisibility: {},
|
|
18
|
+
itemVisibility: {},
|
|
19
|
+
hasOverflow: false,
|
|
20
|
+
registerItem,
|
|
21
|
+
registerDivider,
|
|
22
|
+
registerOverflowMenu,
|
|
23
|
+
updateOverflow,
|
|
24
|
+
forceUpdateOverflow,
|
|
25
|
+
containerRef,
|
|
26
|
+
getSnapshot,
|
|
27
|
+
subscribe
|
|
28
|
+
}), [
|
|
29
|
+
registerItem,
|
|
30
|
+
registerDivider,
|
|
31
|
+
registerOverflowMenu,
|
|
32
|
+
updateOverflow,
|
|
33
|
+
forceUpdateOverflow,
|
|
34
|
+
containerRef,
|
|
35
|
+
getSnapshot,
|
|
36
|
+
subscribe
|
|
37
|
+
]);
|
|
38
|
+
return {
|
|
39
|
+
overflow
|
|
40
|
+
};
|
|
41
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/useOverflowContextValues.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { OverflowContextValue } from './overflowContext';\nimport type { OverflowComponentState, OverflowContextValues } from './components/Overflow/Overflow.types';\n\n/**\n * Assembles the overflow context values provided to descendants, from the state returned by\n * {@link useOverflow_unstable}.\n *\n * @internal\n */\nexport const useOverflowContextValues_unstable = (state: OverflowComponentState): OverflowContextValues => {\n const {\n registerItem,\n registerDivider,\n registerOverflowMenu,\n updateOverflow,\n forceUpdateOverflow,\n containerRef,\n getSnapshot,\n subscribe,\n } = state;\n\n const overflow = React.useMemo<OverflowContextValue>(\n () => ({\n groupVisibility: {},\n itemVisibility: {},\n hasOverflow: false,\n registerItem,\n registerDivider,\n registerOverflowMenu,\n updateOverflow,\n forceUpdateOverflow,\n containerRef,\n getSnapshot,\n subscribe,\n }),\n [\n registerItem,\n registerDivider,\n registerOverflowMenu,\n updateOverflow,\n forceUpdateOverflow,\n containerRef,\n getSnapshot,\n subscribe,\n ],\n );\n\n return { overflow };\n};\n"],"names":["React","useOverflowContextValues_unstable","state","registerItem","registerDivider","registerOverflowMenu","updateOverflow","forceUpdateOverflow","containerRef","getSnapshot","subscribe","overflow","useMemo","groupVisibility","itemVisibility","hasOverflow"],"mappings":"AAAA;;;;;+BAYaC;;;;;;;iEAVU,QAAQ;AAUxB,0CAA0C,CAACC;IAChD,MAAM,EACJC,YAAY,EACZC,eAAe,EACfC,oBAAoB,EACpBC,cAAc,EACdC,mBAAmB,EACnBC,YAAY,EACZC,WAAW,EACXC,SAAS,EACV,GAAGR;IAEJ,MAAMS,WAAWX,OAAMY,OAAO,CAC5B,IAAO,CAAA;YACLC,iBAAiB,CAAC;YAClBC,gBAAgB,CAAC;YACjBC,aAAa;YACbZ;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;SACF,CAAA,EACA;QACEP;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;KACD;IAGH,OAAO;QAAEC;IAAS;AACpB,EAAE"}
|
|
@@ -9,12 +9,6 @@ Object.defineProperty(exports, "useOverflowCount", {
|
|
|
9
9
|
return useOverflowCount;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
const
|
|
13
|
-
const useOverflowCount = ()=>(0,
|
|
14
|
-
|
|
15
|
-
if (!visible) {
|
|
16
|
-
acc++;
|
|
17
|
-
}
|
|
18
|
-
return acc;
|
|
19
|
-
}, 0);
|
|
20
|
-
});
|
|
12
|
+
const _useOverflowSnapshot = require("./useOverflowSnapshot");
|
|
13
|
+
const useOverflowCount = ()=>(0, _useOverflowSnapshot.useOverflowSnapshot)(selectInvisibleItemCount);
|
|
14
|
+
const selectInvisibleItemCount = (snapshot)=>snapshot.invisibleItemCount;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useOverflowCount.ts"],"sourcesContent":["'use client';\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../src/useOverflowCount.ts"],"sourcesContent":["'use client';\n\nimport type { OverflowSnapshot } from '@fluentui/priority-overflow';\nimport { useOverflowSnapshot } from './useOverflowSnapshot';\n\n/**\n * @returns Number of items that are overflowing\n */\nexport const useOverflowCount = (): number => useOverflowSnapshot(selectInvisibleItemCount);\n\nconst selectInvisibleItemCount = (snapshot: OverflowSnapshot): number => snapshot.invisibleItemCount;\n"],"names":["useOverflowSnapshot","useOverflowCount","selectInvisibleItemCount","snapshot","invisibleItemCount"],"mappings":"AAAA;;;;;;;;;;;qCAGoC,wBAAwB;AAKrD,MAAMC,mBAAmB,QAAcD,wCAAAA,EAAoBE,0BAA0B;AAE5F,MAAMA,2BAA2B,CAACC,WAAuCA,SAASC,kBAAkB"}
|
|
@@ -17,28 +17,26 @@ const _useOverflowCount = require("./useOverflowCount");
|
|
|
17
17
|
function useOverflowMenu(id) {
|
|
18
18
|
const elementId = (0, _reactutilities.useId)('overflow-menu', id);
|
|
19
19
|
const overflowCount = (0, _useOverflowCount.useOverflowCount)();
|
|
20
|
-
const registerOverflowMenu = (0, _overflowContext.useOverflowContext)(
|
|
21
|
-
const updateOverflow = (0, _overflowContext.useOverflowContext)((v)=>v.updateOverflow);
|
|
20
|
+
const { registerOverflowMenu, forceUpdateOverflow } = (0, _overflowContext.useOverflowContext)();
|
|
22
21
|
const ref = _react.useRef(null);
|
|
23
22
|
const isOverflowing = overflowCount > 0;
|
|
24
23
|
(0, _reactutilities.useIsomorphicLayoutEffect)(()=>{
|
|
25
24
|
if (ref.current) {
|
|
26
|
-
|
|
25
|
+
const unregister = registerOverflowMenu(ref.current);
|
|
26
|
+
if (isOverflowing) {
|
|
27
|
+
forceUpdateOverflow();
|
|
28
|
+
}
|
|
29
|
+
return ()=>{
|
|
30
|
+
unregister();
|
|
31
|
+
forceUpdateOverflow();
|
|
32
|
+
};
|
|
27
33
|
}
|
|
28
34
|
}, [
|
|
29
35
|
registerOverflowMenu,
|
|
36
|
+
forceUpdateOverflow,
|
|
30
37
|
isOverflowing,
|
|
31
38
|
elementId
|
|
32
39
|
]);
|
|
33
|
-
(0, _reactutilities.useIsomorphicLayoutEffect)(()=>{
|
|
34
|
-
if (isOverflowing) {
|
|
35
|
-
updateOverflow();
|
|
36
|
-
}
|
|
37
|
-
}, [
|
|
38
|
-
isOverflowing,
|
|
39
|
-
updateOverflow,
|
|
40
|
-
ref
|
|
41
|
-
]);
|
|
42
40
|
return {
|
|
43
41
|
ref,
|
|
44
42
|
overflowCount,
|