@fluentui/react-overflow 9.0.17 → 9.0.19
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +64 -1
- package/CHANGELOG.md +23 -2
- package/lib/components/Overflow.js +42 -59
- package/lib/components/Overflow.js.map +1 -1
- package/lib/components/OverflowItem/OverflowItem.js +6 -13
- package/lib/components/OverflowItem/OverflowItem.js.map +1 -1
- package/lib/components/OverflowItem/OverflowItem.types.js +0 -1
- package/lib/components/OverflowItem/OverflowItem.types.js.map +1 -1
- package/lib/components/OverflowItem/index.js +0 -1
- package/lib/components/OverflowItem/index.js.map +1 -1
- package/lib/components/useOverflowStyles.styles.js.map +1 -1
- package/lib/constants.js +0 -1
- package/lib/constants.js.map +1 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/lib/overflowContext.js +8 -10
- package/lib/overflowContext.js.map +1 -1
- package/lib/types.js +0 -1
- package/lib/types.js.map +1 -1
- package/lib/useIsOverflowGroupVisible.js +2 -4
- package/lib/useIsOverflowGroupVisible.js.map +1 -1
- package/lib/useIsOverflowItemVisible.js +2 -4
- package/lib/useIsOverflowItemVisible.js.map +1 -1
- package/lib/useOverflowContainer.js +69 -66
- package/lib/useOverflowContainer.js.map +1 -1
- package/lib/useOverflowCount.js +8 -10
- package/lib/useOverflowCount.js.map +1 -1
- package/lib/useOverflowItem.js +17 -14
- package/lib/useOverflowItem.js.map +1 -1
- package/lib/useOverflowMenu.js +29 -22
- package/lib/useOverflowMenu.js.map +1 -1
- package/lib-commonjs/components/Overflow.js +1 -3
- package/lib-commonjs/components/Overflow.js.map +1 -1
- package/lib-commonjs/components/OverflowItem/OverflowItem.js +1 -3
- package/lib-commonjs/components/OverflowItem/OverflowItem.js.map +1 -1
- package/lib-commonjs/components/OverflowItem/OverflowItem.types.js +0 -3
- package/lib-commonjs/components/OverflowItem/OverflowItem.types.js.map +1 -1
- package/lib-commonjs/components/OverflowItem/index.js +0 -3
- package/lib-commonjs/components/OverflowItem/index.js.map +1 -1
- package/lib-commonjs/components/useOverflowStyles.styles.js +0 -2
- package/lib-commonjs/components/useOverflowStyles.styles.js.map +1 -1
- package/lib-commonjs/constants.js +1 -3
- package/lib-commonjs/constants.js.map +1 -1
- package/lib-commonjs/index.js +0 -3
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/overflowContext.js +2 -4
- package/lib-commonjs/overflowContext.js.map +1 -1
- package/lib-commonjs/types.js +0 -3
- package/lib-commonjs/types.js.map +1 -1
- package/lib-commonjs/useIsOverflowGroupVisible.js +1 -3
- package/lib-commonjs/useIsOverflowGroupVisible.js.map +1 -1
- package/lib-commonjs/useIsOverflowItemVisible.js +1 -3
- package/lib-commonjs/useIsOverflowItemVisible.js.map +1 -1
- package/lib-commonjs/useOverflowContainer.js +1 -3
- package/lib-commonjs/useOverflowContainer.js.map +1 -1
- package/lib-commonjs/useOverflowCount.js +1 -3
- package/lib-commonjs/useOverflowCount.js.map +1 -1
- package/lib-commonjs/useOverflowItem.js +1 -3
- package/lib-commonjs/useOverflowItem.js.map +1 -1
- package/lib-commonjs/useOverflowMenu.js +1 -3
- package/lib-commonjs/useOverflowMenu.js.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.json
CHANGED
@@ -2,7 +2,70 @@
|
|
2
2
|
"name": "@fluentui/react-overflow",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
5
|
+
"date": "Wed, 31 May 2023 06:42:59 GMT",
|
6
|
+
"tag": "@fluentui/react-overflow_v9.0.19",
|
7
|
+
"version": "9.0.19",
|
8
|
+
"comments": {
|
9
|
+
"patch": [
|
10
|
+
{
|
11
|
+
"author": "seanmonahan@microsoft.com",
|
12
|
+
"package": "@fluentui/react-overflow",
|
13
|
+
"commit": "d640b972d7ac86bfb76ae6c6329f12cdd33b3b7c",
|
14
|
+
"comment": "chore: Update Griffel to v1.5.7."
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"author": "beachball",
|
18
|
+
"package": "@fluentui/react-overflow",
|
19
|
+
"comment": "Bump @fluentui/react-context-selector to v9.1.22",
|
20
|
+
"commit": "17ca96c6b7f684f36a5c63e40e78b4986a86c713"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"author": "beachball",
|
24
|
+
"package": "@fluentui/react-overflow",
|
25
|
+
"comment": "Bump @fluentui/react-utilities to v9.9.2",
|
26
|
+
"commit": "17ca96c6b7f684f36a5c63e40e78b4986a86c713"
|
27
|
+
}
|
28
|
+
]
|
29
|
+
}
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"date": "Thu, 25 May 2023 10:00:48 GMT",
|
33
|
+
"tag": "@fluentui/react-overflow_v9.0.18",
|
34
|
+
"version": "9.0.18",
|
35
|
+
"comments": {
|
36
|
+
"patch": [
|
37
|
+
{
|
38
|
+
"author": "beachball",
|
39
|
+
"package": "@fluentui/react-overflow",
|
40
|
+
"comment": "Bump @fluentui/react-context-selector to v9.1.21",
|
41
|
+
"commit": "8f7c1b7591b3e665ae39e1b22ab0f0b28fb795c4"
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"author": "beachball",
|
45
|
+
"package": "@fluentui/react-overflow",
|
46
|
+
"comment": "Bump @fluentui/react-utilities to v9.9.1",
|
47
|
+
"commit": "8f7c1b7591b3e665ae39e1b22ab0f0b28fb795c4"
|
48
|
+
}
|
49
|
+
]
|
50
|
+
}
|
51
|
+
},
|
52
|
+
{
|
53
|
+
"date": "Wed, 24 May 2023 20:45:29 GMT",
|
54
|
+
"tag": "@fluentui/react-overflow_v9.0.17",
|
55
|
+
"version": "9.0.17",
|
56
|
+
"comments": {
|
57
|
+
"none": [
|
58
|
+
{
|
59
|
+
"author": "olfedias@microsoft.com",
|
60
|
+
"package": "@fluentui/react-overflow",
|
61
|
+
"commit": "69e0617a93cb44ef42f3bd19284b7dc5fe27fed3",
|
62
|
+
"comment": "chore: update test-ssr script"
|
63
|
+
}
|
64
|
+
]
|
65
|
+
}
|
66
|
+
},
|
67
|
+
{
|
68
|
+
"date": "Thu, 18 May 2023 00:39:10 GMT",
|
6
69
|
"tag": "@fluentui/react-overflow_v9.0.17",
|
7
70
|
"version": "9.0.17",
|
8
71
|
"comments": {
|
package/CHANGELOG.md
CHANGED
@@ -1,12 +1,33 @@
|
|
1
1
|
# Change Log - @fluentui/react-overflow
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Wed, 31 May 2023 06:42:59 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
+
## [9.0.19](https://github.com/microsoft/fluentui/tree/@fluentui/react-overflow_v9.0.19)
|
8
|
+
|
9
|
+
Wed, 31 May 2023 06:42:59 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-overflow_v9.0.18..@fluentui/react-overflow_v9.0.19)
|
11
|
+
|
12
|
+
### Patches
|
13
|
+
|
14
|
+
- chore: Update Griffel to v1.5.7. ([PR #27925](https://github.com/microsoft/fluentui/pull/27925) by seanmonahan@microsoft.com)
|
15
|
+
- Bump @fluentui/react-context-selector to v9.1.22 ([PR #28054](https://github.com/microsoft/fluentui/pull/28054) by beachball)
|
16
|
+
- Bump @fluentui/react-utilities to v9.9.2 ([PR #28054](https://github.com/microsoft/fluentui/pull/28054) by beachball)
|
17
|
+
|
18
|
+
## [9.0.18](https://github.com/microsoft/fluentui/tree/@fluentui/react-overflow_v9.0.18)
|
19
|
+
|
20
|
+
Thu, 25 May 2023 10:00:48 GMT
|
21
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-overflow_v9.0.17..@fluentui/react-overflow_v9.0.18)
|
22
|
+
|
23
|
+
### Patches
|
24
|
+
|
25
|
+
- Bump @fluentui/react-context-selector to v9.1.21 ([PR #27988](https://github.com/microsoft/fluentui/pull/27988) by beachball)
|
26
|
+
- Bump @fluentui/react-utilities to v9.9.1 ([PR #27988](https://github.com/microsoft/fluentui/pull/27988) by beachball)
|
27
|
+
|
7
28
|
## [9.0.17](https://github.com/microsoft/fluentui/tree/@fluentui/react-overflow_v9.0.17)
|
8
29
|
|
9
|
-
Thu, 18 May 2023 00:
|
30
|
+
Thu, 18 May 2023 00:39:10 GMT
|
10
31
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-overflow_v9.0.16..@fluentui/react-overflow_v9.0.17)
|
11
32
|
|
12
33
|
### Patches
|
@@ -6,64 +6,47 @@ import { updateVisibilityAttribute, useOverflowContainer } from '../useOverflowC
|
|
6
6
|
import { useOverflowStyles } from './useOverflowStyles.styles';
|
7
7
|
/**
|
8
8
|
* Provides an OverflowContext for OverflowItem descendants.
|
9
|
-
*/
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
overflowDirection,
|
17
|
-
padding
|
18
|
-
} = props;
|
19
|
-
const [overflowState, setOverflowState] = React.useState({
|
20
|
-
hasOverflow: false,
|
21
|
-
itemVisibility: {},
|
22
|
-
groupVisibility: {}
|
23
|
-
});
|
24
|
-
// useOverflowContainer wraps this method in a useEventCallback.
|
25
|
-
const update = data => {
|
26
|
-
const {
|
27
|
-
visibleItems,
|
28
|
-
invisibleItems,
|
29
|
-
groupVisibility
|
30
|
-
} = data;
|
31
|
-
const itemVisibility = {};
|
32
|
-
visibleItems.forEach(x => itemVisibility[x.id] = true);
|
33
|
-
invisibleItems.forEach(x => itemVisibility[x.id] = false);
|
34
|
-
setOverflowState(() => {
|
35
|
-
return {
|
36
|
-
hasOverflow: data.invisibleItems.length > 0,
|
37
|
-
itemVisibility,
|
38
|
-
groupVisibility
|
39
|
-
};
|
9
|
+
*/ export const Overflow = /*#__PURE__*/ React.forwardRef((props, ref)=>{
|
10
|
+
const styles = useOverflowStyles();
|
11
|
+
const { children , minimumVisible , overflowAxis ='horizontal' , overflowDirection , padding } = props;
|
12
|
+
const [overflowState, setOverflowState] = React.useState({
|
13
|
+
hasOverflow: false,
|
14
|
+
itemVisibility: {},
|
15
|
+
groupVisibility: {}
|
40
16
|
});
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
17
|
+
// useOverflowContainer wraps this method in a useEventCallback.
|
18
|
+
const update = (data)=>{
|
19
|
+
const { visibleItems , invisibleItems , groupVisibility } = data;
|
20
|
+
const itemVisibility = {};
|
21
|
+
visibleItems.forEach((x)=>itemVisibility[x.id] = true);
|
22
|
+
invisibleItems.forEach((x)=>itemVisibility[x.id] = false);
|
23
|
+
setOverflowState(()=>{
|
24
|
+
return {
|
25
|
+
hasOverflow: data.invisibleItems.length > 0,
|
26
|
+
itemVisibility,
|
27
|
+
groupVisibility
|
28
|
+
};
|
29
|
+
});
|
30
|
+
};
|
31
|
+
const { containerRef , registerItem , updateOverflow , registerOverflowMenu } = useOverflowContainer(update, {
|
32
|
+
overflowDirection,
|
33
|
+
overflowAxis,
|
34
|
+
padding,
|
35
|
+
minimumVisible,
|
36
|
+
onUpdateItemVisibility: updateVisibilityAttribute
|
37
|
+
});
|
38
|
+
const clonedChild = applyTriggerPropsToChildren(children, {
|
39
|
+
ref: useMergedRefs(containerRef, ref),
|
40
|
+
className: mergeClasses(styles.overflowMenu, styles.overflowingItems, children.props.className)
|
41
|
+
});
|
42
|
+
return /*#__PURE__*/ React.createElement(OverflowContext.Provider, {
|
43
|
+
value: {
|
44
|
+
itemVisibility: overflowState.itemVisibility,
|
45
|
+
groupVisibility: overflowState.groupVisibility,
|
46
|
+
hasOverflow: overflowState.hasOverflow,
|
47
|
+
registerItem,
|
48
|
+
updateOverflow,
|
49
|
+
registerOverflowMenu
|
50
|
+
}
|
51
|
+
}, clonedChild);
|
68
52
|
});
|
69
|
-
//# sourceMappingURL=Overflow.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["Overflow.tsx"],"sourcesContent":["import * as React from 'react';\nimport { mergeClasses } from '@griffel/react';\nimport type { OnUpdateOverflow, OverflowGroupState, ObserveOptions } from '@fluentui/priority-overflow';\nimport { applyTriggerPropsToChildren, useMergedRefs } from '@fluentui/react-utilities';\n\nimport { OverflowContext } from '../overflowContext';\nimport { updateVisibilityAttribute, useOverflowContainer } from '../useOverflowContainer';\nimport { useOverflowStyles } from './useOverflowStyles.styles';\n\ninterface OverflowState {\n hasOverflow: boolean;\n itemVisibility: Record<string, boolean>;\n groupVisibility: Record<string, OverflowGroupState>;\n}\n\n/**\n * Overflow Props\n */\nexport type OverflowProps = Partial<\n Pick<ObserveOptions, 'overflowAxis' | 'overflowDirection' | 'padding' | 'minimumVisible'>\n> & {\n children: React.ReactElement;\n};\n\n/**\n * Provides an OverflowContext for OverflowItem descendants.\n */\nexport const Overflow = React.forwardRef((props: OverflowProps, ref) => {\n const styles = useOverflowStyles();\n\n const { children, minimumVisible, overflowAxis = 'horizontal', overflowDirection, padding } = props;\n\n const [overflowState, setOverflowState] = React.useState<OverflowState>({\n hasOverflow: false,\n itemVisibility: {},\n groupVisibility: {},\n });\n\n // useOverflowContainer wraps this method in a useEventCallback.\n const update: OnUpdateOverflow = data => {\n const { visibleItems, invisibleItems, groupVisibility } = data;\n\n const itemVisibility: Record<string, boolean> = {};\n visibleItems.forEach(x => (itemVisibility[x.id] = true));\n invisibleItems.forEach(x => (itemVisibility[x.id] = false));\n\n setOverflowState(() => {\n return {\n hasOverflow: data.invisibleItems.length > 0,\n itemVisibility,\n groupVisibility,\n };\n });\n };\n\n const { containerRef, registerItem, updateOverflow, registerOverflowMenu } = useOverflowContainer(update, {\n overflowDirection,\n overflowAxis,\n padding,\n minimumVisible,\n onUpdateItemVisibility: updateVisibilityAttribute,\n });\n\n const clonedChild = applyTriggerPropsToChildren(children, {\n ref: useMergedRefs(containerRef, ref),\n className: mergeClasses(styles.overflowMenu, styles.overflowingItems, children.props.className),\n });\n\n return (\n <OverflowContext.Provider\n value={{\n itemVisibility: overflowState.itemVisibility,\n groupVisibility: overflowState.groupVisibility,\n hasOverflow: overflowState.hasOverflow,\n registerItem,\n updateOverflow,\n registerOverflowMenu,\n }}\n >\n {clonedChild}\n </OverflowContext.Provider>\n );\n});\n"],"names":["React","mergeClasses","applyTriggerPropsToChildren","useMergedRefs","OverflowContext","updateVisibilityAttribute","useOverflowContainer","useOverflowStyles","Overflow","forwardRef","props","ref","styles","children","minimumVisible","overflowAxis","overflowDirection","padding","overflowState","setOverflowState","useState","hasOverflow","itemVisibility","groupVisibility","update","data","visibleItems","invisibleItems","forEach","x","id","length","containerRef","registerItem","updateOverflow","registerOverflowMenu","onUpdateItemVisibility","clonedChild","className","overflowMenu","overflowingItems","Provider","value"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,SAASC,2BAA2B,EAAEC,aAAa,QAAQ,4BAA4B;AAEvF,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,yBAAyB,EAAEC,oBAAoB,QAAQ,0BAA0B;AAC1F,SAASC,iBAAiB,QAAQ,6BAA6B;AAiB/D;;CAEC,GACD,OAAO,MAAMC,yBAAWR,MAAMS,UAAU,CAAC,CAACC,OAAsBC,MAAQ;IACtE,MAAMC,SAASL;IAEf,MAAM,EAAEM,SAAQ,EAAEC,eAAc,EAAEC,cAAe,aAAY,EAAEC,kBAAiB,EAAEC,QAAO,EAAE,GAAGP;IAE9F,MAAM,CAACQ,eAAeC,iBAAiB,GAAGnB,MAAMoB,QAAQ,CAAgB;QACtEC,aAAa,KAAK;QAClBC,gBAAgB,CAAC;QACjBC,iBAAiB,CAAC;IACpB;IAEA,gEAAgE;IAChE,MAAMC,SAA2BC,CAAAA,OAAQ;QACvC,MAAM,EAAEC,aAAY,EAAEC,eAAc,EAAEJ,gBAAe,EAAE,GAAGE;QAE1D,MAAMH,iBAA0C,CAAC;QACjDI,aAAaE,OAAO,CAACC,CAAAA,IAAMP,cAAc,CAACO,EAAEC,EAAE,CAAC,GAAG,IAAI;QACtDH,eAAeC,OAAO,CAACC,CAAAA,IAAMP,cAAc,CAACO,EAAEC,EAAE,CAAC,GAAG,KAAK;QAEzDX,iBAAiB,IAAM;YACrB,OAAO;gBACLE,aAAaI,KAAKE,cAAc,CAACI,MAAM,GAAG;gBAC1CT;gBACAC;YACF;QACF;IACF;IAEA,MAAM,EAAES,aAAY,EAAEC,aAAY,EAAEC,eAAc,EAAEC,qBAAoB,EAAE,GAAG7B,qBAAqBkB,QAAQ;QACxGR;QACAD;QACAE;QACAH;QACAsB,wBAAwB/B;IAC1B;IAEA,MAAMgC,cAAcnC,4BAA4BW,UAAU;QACxDF,KAAKR,cAAc6B,cAAcrB;QACjC2B,WAAWrC,aAAaW,OAAO2B,YAAY,EAAE3B,OAAO4B,gBAAgB,EAAE3B,SAASH,KAAK,CAAC4B,SAAS;IAChG;IAEA,qBACE,oBAAClC,gBAAgBqC,QAAQ;QACvBC,OAAO;YACLpB,gBAAgBJ,cAAcI,cAAc;YAC5CC,iBAAiBL,cAAcK,eAAe;YAC9CF,aAAaH,cAAcG,WAAW;YACtCY;YACAC;YACAC;QACF;OAECE;AAGP,GAAG"}
|
@@ -4,17 +4,10 @@ import { useOverflowItem } from '../../useOverflowItem';
|
|
4
4
|
/**
|
5
5
|
* Attaches overflow item behavior to its child registered with the OverflowContext.
|
6
6
|
* It does not render an element of its own.
|
7
|
-
*/
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
children
|
14
|
-
} = props;
|
15
|
-
const containerRef = useOverflowItem(id, priority, groupId);
|
16
|
-
return applyTriggerPropsToChildren(children, {
|
17
|
-
ref: useMergedRefs(containerRef, ref)
|
18
|
-
});
|
7
|
+
*/ export const OverflowItem = /*#__PURE__*/ React.forwardRef((props, ref)=>{
|
8
|
+
const { id , groupId , priority , children } = props;
|
9
|
+
const containerRef = useOverflowItem(id, priority, groupId);
|
10
|
+
return applyTriggerPropsToChildren(children, {
|
11
|
+
ref: useMergedRefs(containerRef, ref)
|
12
|
+
});
|
19
13
|
});
|
20
|
-
//# sourceMappingURL=OverflowItem.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["OverflowItem.tsx"],"sourcesContent":["import * as React from 'react';\nimport { applyTriggerPropsToChildren, useMergedRefs } from '@fluentui/react-utilities';\nimport { useOverflowItem } from '../../useOverflowItem';\nimport { OverflowItemProps } from './OverflowItem.types';\n\n/**\n * Attaches overflow item behavior to its child registered with the OverflowContext.\n * It does not render an element of its own.\n */\nexport const OverflowItem = React.forwardRef((props: OverflowItemProps, ref) => {\n const { id, groupId, priority, children } = props;\n\n const containerRef = useOverflowItem(id, priority, groupId);\n return applyTriggerPropsToChildren(children, {\n ref: useMergedRefs(containerRef, ref),\n });\n});\n"],"names":["React","applyTriggerPropsToChildren","useMergedRefs","useOverflowItem","OverflowItem","forwardRef","props","ref","id","groupId","priority","children","containerRef"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,2BAA2B,EAAEC,aAAa,QAAQ,4BAA4B;AACvF,SAASC,eAAe,QAAQ,wBAAwB;AAGxD;;;CAGC,GACD,OAAO,MAAMC,6BAAeJ,MAAMK,UAAU,CAAC,CAACC,OAA0BC,MAAQ;IAC9E,MAAM,EAAEC,GAAE,EAAEC,QAAO,EAAEC,SAAQ,EAAEC,SAAQ,EAAE,GAAGL;IAE5C,MAAMM,eAAeT,gBAAgBK,IAAIE,UAAUD;IACnD,OAAOR,4BAA4BU,UAAU;QAC3CJ,KAAKL,cAAcU,cAAcL;IACnC;AACF,GAAG"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["OverflowItem.types.ts"],"sourcesContent":["import * as React from 'react';\n\n/**\n * OverflowItemProps\n */\nexport type OverflowItemProps = {\n /**\n * The unique identifier for the item used by the overflow manager.\n */\n id: string;\n /**\n * Assigns the item to a group, group visibility can be watched.\n */\n groupId?: string;\n /**\n * A higher priority means the item overflows later.\n */\n priority?: number;\n /**\n * The single child that has overflow item behavior attached.\n */\n children: React.ReactElement;\n};\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export type { OverflowItemProps } from './OverflowItem.types';\nexport { OverflowItem } from './OverflowItem';\n"],"names":["OverflowItem"],"mappings":"AACA,SAASA,YAAY,QAAQ,iBAAiB"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["__styles","DATA_OVERFLOWING","DATA_OVERFLOW_MENU","useOverflowStyles","overflowMenu","Brvla84","overflowingItems","zb22lx","d"],"sources":["
|
1
|
+
{"version":3,"names":["__styles","DATA_OVERFLOWING","DATA_OVERFLOW_MENU","useOverflowStyles","overflowMenu","Brvla84","overflowingItems","zb22lx","d"],"sources":["useOverflowStyles.styles.js"],"sourcesContent":["import { makeStyles } from '@griffel/react';\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});\n"],"mappings":"AAAA,SAAAA,QAAA,QAA2B,gBAAgB;AAC3C,SAASC,gBAAgB,EAAEC,kBAAkB,QAAQ,cAAc;AACnE,OAAO,MAAMC,iBAAiB,gBAAGH,QAAA;EAAAI,YAAA;IAAAC,OAAA;EAAA;EAAAC,gBAAA;IAAAC,MAAA;EAAA;AAAA;EAAAC,CAAA;AAAA,CAWhC,CAAC"}
|
package/lib/constants.js
CHANGED
package/lib/constants.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["constants.ts"],"sourcesContent":["export const DATA_OVERFLOWING = 'data-overflowing';\nexport const DATA_OVERFLOW_ITEM = 'data-overflow-item';\nexport const DATA_OVERFLOW_MENU = 'data-overflow-menu';\n"],"names":["DATA_OVERFLOWING","DATA_OVERFLOW_ITEM","DATA_OVERFLOW_MENU"],"mappings":"AAAA,OAAO,MAAMA,mBAAmB,mBAAmB;AACnD,OAAO,MAAMC,qBAAqB,qBAAqB;AACvD,OAAO,MAAMC,qBAAqB,qBAAqB"}
|
package/lib/index.js
CHANGED
@@ -8,4 +8,3 @@ export { useOverflowItem } from './useOverflowItem';
|
|
8
8
|
export { useOverflowMenu } from './useOverflowMenu';
|
9
9
|
export { useOverflowContext } from './overflowContext';
|
10
10
|
export { OverflowItem } from './components/OverflowItem/OverflowItem';
|
11
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export { Overflow } from './components/Overflow';\nexport type { OverflowProps } from './components/Overflow';\nexport { DATA_OVERFLOWING, DATA_OVERFLOW_ITEM, DATA_OVERFLOW_MENU } 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';\n\nexport { useOverflowContext } from './overflowContext';\n\nexport type { OverflowItemProps } from './components/OverflowItem/OverflowItem.types';\nexport { OverflowItem } from './components/OverflowItem/OverflowItem';\n"],"names":["Overflow","DATA_OVERFLOWING","DATA_OVERFLOW_ITEM","DATA_OVERFLOW_MENU","useIsOverflowGroupVisible","useIsOverflowItemVisible","useOverflowContainer","useOverflowCount","useOverflowItem","useOverflowMenu","useOverflowContext","OverflowItem"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,wBAAwB;AAEjD,SAASC,gBAAgB,EAAEC,kBAAkB,EAAEC,kBAAkB,QAAQ,cAAc;AAEvF,SAASC,yBAAyB,QAAQ,8BAA8B;AACxE,SAASC,wBAAwB,QAAQ,6BAA6B;AACtE,SAASC,oBAAoB,QAAQ,yBAAyB;AAC9D,SAASC,gBAAgB,QAAQ,qBAAqB;AACtD,SAASC,eAAe,QAAQ,oBAAoB;AACpD,SAASC,eAAe,QAAQ,oBAAoB;AAEpD,SAASC,kBAAkB,QAAQ,oBAAoB;AAGvD,SAASC,YAAY,QAAQ,yCAAyC"}
|
package/lib/overflowContext.js
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
import { createContext, useContextSelector } from '@fluentui/react-context-selector';
|
2
|
-
export const OverflowContext =
|
2
|
+
export const OverflowContext = createContext(undefined);
|
3
3
|
const overflowContextDefaultValue = {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
itemVisibility: {},
|
5
|
+
groupVisibility: {},
|
6
|
+
hasOverflow: false,
|
7
|
+
registerItem: ()=>()=>null,
|
8
|
+
updateOverflow: ()=>null,
|
9
|
+
registerOverflowMenu: ()=>()=>null
|
10
10
|
};
|
11
11
|
/**
|
12
12
|
* @internal
|
13
|
-
*/
|
14
|
-
export const useOverflowContext = selector => useContextSelector(OverflowContext, (ctx = overflowContextDefaultValue) => selector(ctx));
|
15
|
-
//# sourceMappingURL=overflowContext.js.map
|
13
|
+
*/ export const useOverflowContext = (selector)=>useContextSelector(OverflowContext, (ctx = overflowContextDefaultValue)=>selector(ctx));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["overflowContext.ts"],"sourcesContent":["import type { OverflowGroupState, OverflowItemEntry } from '@fluentui/priority-overflow';\nimport { ContextSelector, createContext, useContextSelector, Context } 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 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};\n\n/**\n * @internal\n */\nexport const useOverflowContext = <SelectedValue>(selector: ContextSelector<OverflowContextValue, SelectedValue>) =>\n useContextSelector(OverflowContext, (ctx = overflowContextDefaultValue) => selector(ctx));\n"],"names":["createContext","useContextSelector","OverflowContext","undefined","overflowContextDefaultValue","itemVisibility","groupVisibility","hasOverflow","registerItem","updateOverflow","registerOverflowMenu","useOverflowContext","selector","ctx"],"mappings":"AACA,SAA0BA,aAAa,EAAEC,kBAAkB,QAAiB,mCAAmC;AAc/G,OAAO,MAAMC,kBAAkBF,cAC7BG,WACiC;AAEnC,MAAMC,8BAAoD;IACxDC,gBAAgB,CAAC;IACjBC,iBAAiB,CAAC;IAClBC,aAAa,KAAK;IAClBC,cAAc,IAAM,IAAM,IAAI;IAC9BC,gBAAgB,IAAM,IAAI;IAC1BC,sBAAsB,IAAM,IAAM,IAAI;AACxC;AAEA;;CAEC,GACD,OAAO,MAAMC,qBAAqB,CAAgBC,WAChDX,mBAAmBC,iBAAiB,CAACW,MAAMT,2BAA2B,GAAKQ,SAASC,MAAM"}
|
package/lib/types.js
CHANGED
package/lib/types.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["types.ts"],"sourcesContent":["import * as React from 'react';\nimport { OverflowContextValue } from './overflowContext';\n\n/**\n * @internal\n */\nexport interface UseOverflowContainerReturn<TElement extends HTMLElement>\n extends Pick<OverflowContextValue, 'registerItem' | 'updateOverflow' | 'registerOverflowMenu'> {\n /**\n * Ref to apply to the container that will overflow\n */\n containerRef: React.RefObject<TElement>;\n}\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
|
@@ -2,8 +2,6 @@ import { useOverflowContext } from './overflowContext';
|
|
2
2
|
/**
|
3
3
|
* @param id - unique identifier for a group of overflow items
|
4
4
|
* @returns visibility state of the group
|
5
|
-
*/
|
6
|
-
|
7
|
-
return useOverflowContext(ctx => ctx.groupVisibility[id]);
|
5
|
+
*/ export function useIsOverflowGroupVisible(id) {
|
6
|
+
return useOverflowContext((ctx)=>ctx.groupVisibility[id]);
|
8
7
|
}
|
9
|
-
//# sourceMappingURL=useIsOverflowGroupVisible.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["useIsOverflowGroupVisible.ts"],"sourcesContent":["import { 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":"AACA,SAASA,kBAAkB,QAAQ,oBAAoB;AAEvD;;;CAGC,GACD,OAAO,SAASC,0BAA0BC,EAAU,EAAsB;IACxE,OAAOF,mBAAmBG,CAAAA,MAAOA,IAAIC,eAAe,CAACF,GAAG;AAC1D,CAAC"}
|
@@ -2,8 +2,6 @@ import { useOverflowContext } from './overflowContext';
|
|
2
2
|
/**
|
3
3
|
* @param id - unique identifier for the item used by the overflow manager
|
4
4
|
* @returns visibility state of an overflow item
|
5
|
-
*/
|
6
|
-
|
7
|
-
return !!useOverflowContext(ctx => ctx.itemVisibility[id]);
|
5
|
+
*/ export function useIsOverflowItemVisible(id) {
|
6
|
+
return !!useOverflowContext((ctx)=>ctx.itemVisibility[id]);
|
8
7
|
}
|
9
|
-
//# sourceMappingURL=useIsOverflowItemVisible.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["useIsOverflowItemVisible.ts"],"sourcesContent":["import { 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,SAASA,kBAAkB,QAAQ,oBAAoB;AAEvD;;;CAGC,GACD,OAAO,SAASC,yBAAyBC,EAAU,EAAW;IAC5D,OAAO,CAAC,CAACF,mBAAmBG,CAAAA,MAAOA,IAAIC,cAAc,CAACF,GAAG;AAC3D,CAAC"}
|
@@ -7,72 +7,75 @@ import { DATA_OVERFLOWING, DATA_OVERFLOW_ITEM, DATA_OVERFLOW_MENU } from './cons
|
|
7
7
|
* @param update - Callback when overflow state changes
|
8
8
|
* @param options - Options to configure the overflow container
|
9
9
|
* @returns - ref to attach to an intrinsic HTML element and imperative functions
|
10
|
-
*/
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
10
|
+
*/ export const useOverflowContainer = (update, options)=>{
|
11
|
+
const { overflowAxis , overflowDirection , padding , minimumVisible , onUpdateItemVisibility } = options;
|
12
|
+
// DOM ref to the overflow container element
|
13
|
+
const containerRef = React.useRef(null);
|
14
|
+
const updateOverflowItems = useEventCallback(update);
|
15
|
+
const [overflowManager] = React.useState(()=>canUseDOM() ? createOverflowManager() : null);
|
16
|
+
useIsomorphicLayoutEffect(()=>{
|
17
|
+
if (!containerRef.current) {
|
18
|
+
return;
|
19
|
+
}
|
20
|
+
if (overflowManager) {
|
21
|
+
overflowManager.observe(containerRef.current, {
|
22
|
+
overflowDirection: overflowDirection !== null && overflowDirection !== void 0 ? overflowDirection : 'end',
|
23
|
+
overflowAxis: overflowAxis !== null && overflowAxis !== void 0 ? overflowAxis : 'horizontal',
|
24
|
+
padding: padding !== null && padding !== void 0 ? padding : 10,
|
25
|
+
minimumVisible: minimumVisible !== null && minimumVisible !== void 0 ? minimumVisible : 0,
|
26
|
+
onUpdateItemVisibility: onUpdateItemVisibility !== null && onUpdateItemVisibility !== void 0 ? onUpdateItemVisibility : ()=>undefined,
|
27
|
+
onUpdateOverflow: updateOverflowItems !== null && updateOverflowItems !== void 0 ? updateOverflowItems : ()=>undefined
|
28
|
+
});
|
29
|
+
return ()=>{
|
30
|
+
overflowManager.disconnect();
|
31
|
+
};
|
32
|
+
}
|
33
|
+
}, [
|
34
|
+
updateOverflowItems,
|
35
|
+
overflowManager,
|
36
|
+
overflowDirection,
|
37
|
+
overflowAxis,
|
38
|
+
padding,
|
39
|
+
minimumVisible,
|
40
|
+
onUpdateItemVisibility
|
41
|
+
]);
|
42
|
+
const registerItem = React.useCallback((item)=>{
|
43
|
+
overflowManager === null || overflowManager === void 0 ? void 0 : overflowManager.addItem(item);
|
44
|
+
item.element.setAttribute(DATA_OVERFLOW_ITEM, '');
|
45
|
+
return ()=>{
|
46
|
+
item.element.removeAttribute(DATA_OVERFLOWING);
|
47
|
+
item.element.removeAttribute(DATA_OVERFLOW_ITEM);
|
48
|
+
overflowManager === null || overflowManager === void 0 ? void 0 : overflowManager.removeItem(item.id);
|
49
|
+
};
|
50
|
+
}, [
|
51
|
+
overflowManager
|
52
|
+
]);
|
53
|
+
const updateOverflow = React.useCallback(()=>{
|
54
|
+
overflowManager === null || overflowManager === void 0 ? void 0 : overflowManager.update();
|
55
|
+
}, [
|
56
|
+
overflowManager
|
57
|
+
]);
|
58
|
+
const registerOverflowMenu = React.useCallback((el)=>{
|
59
|
+
overflowManager === null || overflowManager === void 0 ? void 0 : overflowManager.addOverflowMenu(el);
|
60
|
+
el.setAttribute(DATA_OVERFLOW_MENU, '');
|
61
|
+
return ()=>{
|
62
|
+
overflowManager === null || overflowManager === void 0 ? void 0 : overflowManager.removeOverflowMenu();
|
63
|
+
el.removeAttribute(DATA_OVERFLOW_MENU);
|
64
|
+
};
|
65
|
+
}, [
|
66
|
+
overflowManager
|
67
|
+
]);
|
68
|
+
return {
|
69
|
+
containerRef,
|
70
|
+
registerItem,
|
71
|
+
updateOverflow,
|
72
|
+
registerOverflowMenu
|
48
73
|
};
|
49
|
-
}, [overflowManager]);
|
50
|
-
const updateOverflow = React.useCallback(() => {
|
51
|
-
overflowManager === null || overflowManager === void 0 ? void 0 : overflowManager.update();
|
52
|
-
}, [overflowManager]);
|
53
|
-
const registerOverflowMenu = React.useCallback(el => {
|
54
|
-
overflowManager === null || overflowManager === void 0 ? void 0 : overflowManager.addOverflowMenu(el);
|
55
|
-
el.setAttribute(DATA_OVERFLOW_MENU, '');
|
56
|
-
return () => {
|
57
|
-
overflowManager === null || overflowManager === void 0 ? void 0 : overflowManager.removeOverflowMenu();
|
58
|
-
el.removeAttribute(DATA_OVERFLOW_MENU);
|
59
|
-
};
|
60
|
-
}, [overflowManager]);
|
61
|
-
return {
|
62
|
-
containerRef,
|
63
|
-
registerItem,
|
64
|
-
updateOverflow,
|
65
|
-
registerOverflowMenu
|
66
|
-
};
|
67
74
|
};
|
68
|
-
export const updateVisibilityAttribute = ({
|
69
|
-
|
70
|
-
|
71
|
-
}
|
72
|
-
|
73
|
-
|
74
|
-
} else {
|
75
|
-
item.element.setAttribute(DATA_OVERFLOWING, '');
|
76
|
-
}
|
75
|
+
export const updateVisibilityAttribute = ({ item , visible })=>{
|
76
|
+
if (visible) {
|
77
|
+
item.element.removeAttribute(DATA_OVERFLOWING);
|
78
|
+
} else {
|
79
|
+
item.element.setAttribute(DATA_OVERFLOWING, '');
|
80
|
+
}
|
77
81
|
};
|
78
|
-
//# sourceMappingURL=useOverflowContainer.js.map
|