@fluentui/react-overflow 9.8.0 → 9.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -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
|
@@ -1,111 +1,120 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { createOverflowManager } from '@fluentui/priority-overflow';
|
|
4
|
-
import { canUseDOM, useEventCallback,
|
|
3
|
+
import { createOverflowManager, EMPTY_SNAPSHOT } from '@fluentui/priority-overflow';
|
|
4
|
+
import { canUseDOM, useEventCallback, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
|
|
5
5
|
import { DATA_OVERFLOWING, DATA_OVERFLOW_DIVIDER, DATA_OVERFLOW_ITEM, DATA_OVERFLOW_MENU } from './constants';
|
|
6
|
-
const noop = ()=>null;
|
|
7
6
|
/**
|
|
8
7
|
* @internal
|
|
9
8
|
* @param update - Callback when overflow state changes
|
|
10
9
|
* @param options - Options to configure the overflow container
|
|
11
10
|
* @returns - ref to attach to an intrinsic HTML element and imperative functions
|
|
12
11
|
*/ export const useOverflowContainer = (update, options)=>{
|
|
13
|
-
'use no memo';
|
|
14
12
|
const { overflowAxis = 'horizontal', overflowDirection = 'end', padding = 10, minimumVisible = 0, onUpdateItemVisibility = noop, hasHiddenItems = false } = options;
|
|
15
|
-
const
|
|
16
|
-
const
|
|
13
|
+
const onUpdateItemVisibilityCallback = useEventCallback(onUpdateItemVisibility);
|
|
14
|
+
const observeOptions = React.useMemo(()=>({
|
|
17
15
|
overflowAxis,
|
|
18
16
|
overflowDirection,
|
|
19
17
|
padding,
|
|
20
18
|
minimumVisible,
|
|
21
|
-
onUpdateItemVisibility,
|
|
22
|
-
onUpdateOverflow,
|
|
19
|
+
onUpdateItemVisibility: onUpdateItemVisibilityCallback,
|
|
20
|
+
onUpdateOverflow: update,
|
|
23
21
|
hasHiddenItems
|
|
24
22
|
}), [
|
|
25
23
|
minimumVisible,
|
|
26
|
-
|
|
24
|
+
onUpdateItemVisibilityCallback,
|
|
27
25
|
overflowAxis,
|
|
28
26
|
overflowDirection,
|
|
29
27
|
padding,
|
|
30
|
-
|
|
28
|
+
update,
|
|
31
29
|
hasHiddenItems
|
|
32
30
|
]);
|
|
33
|
-
const firstMount = useFirstMount();
|
|
34
|
-
// DOM ref to the overflow container element
|
|
35
31
|
const containerRef = React.useRef(null);
|
|
36
|
-
const
|
|
37
|
-
|
|
32
|
+
const managerRef = React.useRef(null);
|
|
33
|
+
if (managerRef.current === null) {
|
|
34
|
+
managerRef.current = canUseDOM() ? createOverflowManager(observeOptions) : null;
|
|
35
|
+
}
|
|
38
36
|
useIsomorphicLayoutEffect(()=>{
|
|
39
|
-
if (
|
|
40
|
-
|
|
37
|
+
if (managerRef.current && containerRef.current) {
|
|
38
|
+
// forceUpdate resolves overflow synchronously for a correct first paint; the manager guards it
|
|
39
|
+
// on the container being measured.
|
|
40
|
+
managerRef.current.observe(containerRef.current, {
|
|
41
|
+
forceUpdate: true
|
|
42
|
+
});
|
|
43
|
+
return ()=>{
|
|
44
|
+
var _managerRef_current;
|
|
45
|
+
return (_managerRef_current = managerRef.current) === null || _managerRef_current === void 0 ? void 0 : _managerRef_current.disconnect();
|
|
46
|
+
};
|
|
41
47
|
}
|
|
42
|
-
}, [
|
|
43
|
-
firstMount,
|
|
44
|
-
overflowManager,
|
|
45
|
-
overflowOptions
|
|
46
|
-
]);
|
|
48
|
+
}, []);
|
|
47
49
|
useIsomorphicLayoutEffect(()=>{
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
const newOverflowManager = createOverflowManager();
|
|
52
|
-
newOverflowManager.observe(containerRef.current, overflowOptions);
|
|
53
|
-
setOverflowManager(newOverflowManager);
|
|
54
|
-
// We don't want to re-create the overflow manager when the first mount flag changes from true to false
|
|
55
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
50
|
+
var _managerRef_current;
|
|
51
|
+
(_managerRef_current = managerRef.current) === null || _managerRef_current === void 0 ? void 0 : _managerRef_current.setOptions(observeOptions);
|
|
56
52
|
}, [
|
|
57
|
-
|
|
58
|
-
]);
|
|
59
|
-
/* Clean up overflow manager on unmount */ React.useEffect(()=>()=>{
|
|
60
|
-
overflowManager === null || overflowManager === void 0 ? void 0 : overflowManager.disconnect();
|
|
61
|
-
}, [
|
|
62
|
-
overflowManager
|
|
53
|
+
observeOptions
|
|
63
54
|
]);
|
|
64
55
|
const registerItem = React.useCallback((item)=>{
|
|
65
|
-
|
|
56
|
+
var _managerRef_current;
|
|
57
|
+
(_managerRef_current = managerRef.current) === null || _managerRef_current === void 0 ? void 0 : _managerRef_current.addItem(item);
|
|
66
58
|
item.element.setAttribute(DATA_OVERFLOW_ITEM, '');
|
|
67
59
|
return ()=>{
|
|
60
|
+
var _managerRef_current;
|
|
68
61
|
item.element.removeAttribute(DATA_OVERFLOWING);
|
|
69
62
|
item.element.removeAttribute(DATA_OVERFLOW_ITEM);
|
|
70
|
-
|
|
63
|
+
(_managerRef_current = managerRef.current) === null || _managerRef_current === void 0 ? void 0 : _managerRef_current.removeItem(item.id);
|
|
71
64
|
};
|
|
72
|
-
}, [
|
|
73
|
-
overflowManager
|
|
74
|
-
]);
|
|
65
|
+
}, []);
|
|
75
66
|
const registerDivider = React.useCallback((divider)=>{
|
|
67
|
+
var _managerRef_current;
|
|
76
68
|
const el = divider.element;
|
|
77
|
-
|
|
69
|
+
(_managerRef_current = managerRef.current) === null || _managerRef_current === void 0 ? void 0 : _managerRef_current.addDivider(divider);
|
|
78
70
|
el.setAttribute(DATA_OVERFLOW_DIVIDER, '');
|
|
79
71
|
return ()=>{
|
|
80
|
-
|
|
72
|
+
var _managerRef_current;
|
|
73
|
+
(_managerRef_current = managerRef.current) === null || _managerRef_current === void 0 ? void 0 : _managerRef_current.removeDivider(divider.groupId);
|
|
81
74
|
el.removeAttribute(DATA_OVERFLOW_DIVIDER);
|
|
82
75
|
};
|
|
83
|
-
}, [
|
|
84
|
-
overflowManager
|
|
85
|
-
]);
|
|
76
|
+
}, []);
|
|
86
77
|
const registerOverflowMenu = React.useCallback((el)=>{
|
|
87
|
-
|
|
78
|
+
var _managerRef_current;
|
|
79
|
+
(_managerRef_current = managerRef.current) === null || _managerRef_current === void 0 ? void 0 : _managerRef_current.addOverflowMenu(el);
|
|
88
80
|
el.setAttribute(DATA_OVERFLOW_MENU, '');
|
|
89
81
|
return ()=>{
|
|
90
|
-
|
|
82
|
+
var _managerRef_current;
|
|
83
|
+
(_managerRef_current = managerRef.current) === null || _managerRef_current === void 0 ? void 0 : _managerRef_current.removeOverflowMenu();
|
|
91
84
|
el.removeAttribute(DATA_OVERFLOW_MENU);
|
|
92
85
|
};
|
|
93
|
-
}, [
|
|
94
|
-
overflowManager
|
|
95
|
-
]);
|
|
86
|
+
}, []);
|
|
96
87
|
const updateOverflow = React.useCallback(()=>{
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
88
|
+
var _managerRef_current;
|
|
89
|
+
(_managerRef_current = managerRef.current) === null || _managerRef_current === void 0 ? void 0 : _managerRef_current.update();
|
|
90
|
+
}, []);
|
|
91
|
+
const getSnapshot = React.useCallback(()=>{
|
|
92
|
+
var _managerRef_current;
|
|
93
|
+
var _managerRef_current_getSnapshot;
|
|
94
|
+
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 : EMPTY_SNAPSHOT;
|
|
95
|
+
}, []);
|
|
96
|
+
const subscribe = React.useCallback((listener)=>{
|
|
97
|
+
var _managerRef_current;
|
|
98
|
+
var _managerRef_current_subscribe;
|
|
99
|
+
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;
|
|
100
|
+
}, []);
|
|
101
|
+
const forceUpdateOverflow = React.useCallback(()=>{
|
|
102
|
+
var _managerRef_current;
|
|
103
|
+
(_managerRef_current = managerRef.current) === null || _managerRef_current === void 0 ? void 0 : _managerRef_current.forceUpdate();
|
|
104
|
+
}, []);
|
|
101
105
|
return {
|
|
102
106
|
registerItem,
|
|
103
107
|
registerDivider,
|
|
104
108
|
registerOverflowMenu,
|
|
105
109
|
updateOverflow,
|
|
106
|
-
|
|
110
|
+
forceUpdateOverflow,
|
|
111
|
+
containerRef,
|
|
112
|
+
getSnapshot,
|
|
113
|
+
subscribe
|
|
107
114
|
};
|
|
108
115
|
};
|
|
116
|
+
const noop = ()=>{
|
|
117
|
+
/* noop */ };
|
|
109
118
|
export const updateVisibilityAttribute = ({ item, visible })=>{
|
|
110
119
|
if (visible) {
|
|
111
120
|
item.element.removeAttribute(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":"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"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Assembles the overflow context values provided to descendants, from the state returned by
|
|
5
|
+
* {@link useOverflow_unstable}.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/ export const useOverflowContextValues_unstable = (state)=>{
|
|
9
|
+
const { registerItem, registerDivider, registerOverflowMenu, updateOverflow, forceUpdateOverflow, containerRef, getSnapshot, subscribe } = state;
|
|
10
|
+
const overflow = React.useMemo(()=>({
|
|
11
|
+
groupVisibility: {},
|
|
12
|
+
itemVisibility: {},
|
|
13
|
+
hasOverflow: false,
|
|
14
|
+
registerItem,
|
|
15
|
+
registerDivider,
|
|
16
|
+
registerOverflowMenu,
|
|
17
|
+
updateOverflow,
|
|
18
|
+
forceUpdateOverflow,
|
|
19
|
+
containerRef,
|
|
20
|
+
getSnapshot,
|
|
21
|
+
subscribe
|
|
22
|
+
}), [
|
|
23
|
+
registerItem,
|
|
24
|
+
registerDivider,
|
|
25
|
+
registerOverflowMenu,
|
|
26
|
+
updateOverflow,
|
|
27
|
+
forceUpdateOverflow,
|
|
28
|
+
containerRef,
|
|
29
|
+
getSnapshot,
|
|
30
|
+
subscribe
|
|
31
|
+
]);
|
|
32
|
+
return {
|
|
33
|
+
overflow
|
|
34
|
+
};
|
|
35
|
+
};
|
|
@@ -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;AAEA,YAAYA,WAAW,QAAQ;AAI/B;;;;;CAKC,GACD,OAAO,MAAMC,oCAAoC,CAACC;IAChD,MAAM,EACJC,YAAY,EACZC,eAAe,EACfC,oBAAoB,EACpBC,cAAc,EACdC,mBAAmB,EACnBC,YAAY,EACZC,WAAW,EACXC,SAAS,EACV,GAAGR;IAEJ,MAAMS,WAAWX,MAAMY,OAAO,CAC5B,IAAO,CAAA;YACLC,iBAAiB,CAAC;YAClBC,gBAAgB,CAAC;YACjBC,aAAa;YACbZ;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;QACF,CAAA,GACA;QACEP;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;KACD;IAGH,OAAO;QAAEC;IAAS;AACpB,EAAE"}
|
package/lib/useOverflowCount.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { useOverflowSnapshot } from './useOverflowSnapshot';
|
|
3
3
|
/**
|
|
4
4
|
* @returns Number of items that are overflowing
|
|
5
|
-
*/ export const useOverflowCount = ()=>
|
|
6
|
-
|
|
7
|
-
if (!visible) {
|
|
8
|
-
acc++;
|
|
9
|
-
}
|
|
10
|
-
return acc;
|
|
11
|
-
}, 0);
|
|
12
|
-
});
|
|
5
|
+
*/ export const useOverflowCount = ()=>useOverflowSnapshot(selectInvisibleItemCount);
|
|
6
|
+
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;AAGA,SAASA,mBAAmB,QAAQ,wBAAwB;AAE5D;;CAEC,GACD,OAAO,MAAMC,mBAAmB,IAAcD,oBAAoBE,0BAA0B;AAE5F,MAAMA,2BAA2B,CAACC,WAAuCA,SAASC,kBAAkB"}
|
package/lib/useOverflowMenu.js
CHANGED
|
@@ -6,28 +6,26 @@ import { useOverflowCount } from './useOverflowCount';
|
|
|
6
6
|
export function useOverflowMenu(id) {
|
|
7
7
|
const elementId = useId('overflow-menu', id);
|
|
8
8
|
const overflowCount = useOverflowCount();
|
|
9
|
-
const registerOverflowMenu = useOverflowContext(
|
|
10
|
-
const updateOverflow = useOverflowContext((v)=>v.updateOverflow);
|
|
9
|
+
const { registerOverflowMenu, forceUpdateOverflow } = useOverflowContext();
|
|
11
10
|
const ref = React.useRef(null);
|
|
12
11
|
const isOverflowing = overflowCount > 0;
|
|
13
12
|
useIsomorphicLayoutEffect(()=>{
|
|
14
13
|
if (ref.current) {
|
|
15
|
-
|
|
14
|
+
const unregister = registerOverflowMenu(ref.current);
|
|
15
|
+
if (isOverflowing) {
|
|
16
|
+
forceUpdateOverflow();
|
|
17
|
+
}
|
|
18
|
+
return ()=>{
|
|
19
|
+
unregister();
|
|
20
|
+
forceUpdateOverflow();
|
|
21
|
+
};
|
|
16
22
|
}
|
|
17
23
|
}, [
|
|
18
24
|
registerOverflowMenu,
|
|
25
|
+
forceUpdateOverflow,
|
|
19
26
|
isOverflowing,
|
|
20
27
|
elementId
|
|
21
28
|
]);
|
|
22
|
-
useIsomorphicLayoutEffect(()=>{
|
|
23
|
-
if (isOverflowing) {
|
|
24
|
-
updateOverflow();
|
|
25
|
-
}
|
|
26
|
-
}, [
|
|
27
|
-
isOverflowing,
|
|
28
|
-
updateOverflow,
|
|
29
|
-
ref
|
|
30
|
-
]);
|
|
31
29
|
return {
|
|
32
30
|
ref,
|
|
33
31
|
overflowCount,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useOverflowMenu.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useId, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport { useOverflowContext } from './overflowContext';\nimport { useOverflowCount } from './useOverflowCount';\n\nexport function useOverflowMenu<TElement extends HTMLElement>(\n id?: string,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n): { ref: React.MutableRefObject<TElement | null>; overflowCount: number; isOverflowing: boolean } {\n const elementId = useId('overflow-menu', id);\n const overflowCount = useOverflowCount();\n const registerOverflowMenu
|
|
1
|
+
{"version":3,"sources":["../src/useOverflowMenu.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useId, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport { useOverflowContext } from './overflowContext';\nimport { useOverflowCount } from './useOverflowCount';\n\nexport function useOverflowMenu<TElement extends HTMLElement>(\n id?: string,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n): { ref: React.MutableRefObject<TElement | null>; overflowCount: number; isOverflowing: boolean } {\n const elementId = useId('overflow-menu', id);\n const overflowCount = useOverflowCount();\n const { registerOverflowMenu, forceUpdateOverflow } = useOverflowContext();\n const ref = React.useRef<TElement | null>(null);\n const isOverflowing = overflowCount > 0;\n\n useIsomorphicLayoutEffect(() => {\n if (ref.current) {\n const unregister = registerOverflowMenu(ref.current);\n if (isOverflowing) {\n forceUpdateOverflow();\n }\n return () => {\n unregister();\n forceUpdateOverflow();\n };\n }\n }, [registerOverflowMenu, forceUpdateOverflow, isOverflowing, elementId]);\n\n return { ref, overflowCount, isOverflowing };\n}\n"],"names":["React","useId","useIsomorphicLayoutEffect","useOverflowContext","useOverflowCount","useOverflowMenu","id","elementId","overflowCount","registerOverflowMenu","forceUpdateOverflow","ref","useRef","isOverflowing","current","unregister"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,KAAK,EAAEC,yBAAyB,QAAQ,4BAA4B;AAC7E,SAASC,kBAAkB,QAAQ,oBAAoB;AACvD,SAASC,gBAAgB,QAAQ,qBAAqB;AAEtD,OAAO,SAASC,gBACdC,EAAW;IAGX,MAAMC,YAAYN,MAAM,iBAAiBK;IACzC,MAAME,gBAAgBJ;IACtB,MAAM,EAAEK,oBAAoB,EAAEC,mBAAmB,EAAE,GAAGP;IACtD,MAAMQ,MAAMX,MAAMY,MAAM,CAAkB;IAC1C,MAAMC,gBAAgBL,gBAAgB;IAEtCN,0BAA0B;QACxB,IAAIS,IAAIG,OAAO,EAAE;YACf,MAAMC,aAAaN,qBAAqBE,IAAIG,OAAO;YACnD,IAAID,eAAe;gBACjBH;YACF;YACA,OAAO;gBACLK;gBACAL;YACF;QACF;IACF,GAAG;QAACD;QAAsBC;QAAqBG;QAAeN;KAAU;IAExE,OAAO;QAAEI;QAAKH;QAAeK;IAAc;AAC7C"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useEventCallback, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
|
|
4
|
+
import { useOverflowContext } from './overflowContext';
|
|
5
|
+
/**
|
|
6
|
+
* Subscribes to the overflow snapshot and returns a derived slice of it.
|
|
7
|
+
*
|
|
8
|
+
* @param selector - derives the slice of the snapshot the consumer depends on
|
|
9
|
+
*/ export function useOverflowSnapshot(selector) {
|
|
10
|
+
const { getSnapshot, subscribe } = useOverflowContext();
|
|
11
|
+
const select = useEventCallback(selector);
|
|
12
|
+
const [selected, setSelected] = React.useState(()=>selector(getSnapshot()));
|
|
13
|
+
useIsomorphicLayoutEffect(()=>{
|
|
14
|
+
const checkForUpdates = ()=>setSelected(select(getSnapshot()));
|
|
15
|
+
checkForUpdates();
|
|
16
|
+
return subscribe(checkForUpdates);
|
|
17
|
+
}, [
|
|
18
|
+
subscribe,
|
|
19
|
+
getSnapshot,
|
|
20
|
+
select
|
|
21
|
+
]);
|
|
22
|
+
return selected;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/useOverflowSnapshot.ts"],"sourcesContent":["'use client';\n\nimport type { OverflowSnapshot } from '@fluentui/priority-overflow';\nimport * as React from 'react';\nimport { useEventCallback, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport { useOverflowContext } from './overflowContext';\n\n/**\n * Subscribes to the overflow snapshot and returns a derived slice of it.\n *\n * @param selector - derives the slice of the snapshot the consumer depends on\n */\nexport function useOverflowSnapshot<Selected>(selector: (snapshot: OverflowSnapshot) => Selected): Selected {\n const { getSnapshot, subscribe } = useOverflowContext();\n const select = useEventCallback(selector);\n\n const [selected, setSelected] = React.useState(() => selector(getSnapshot()));\n\n useIsomorphicLayoutEffect(() => {\n const checkForUpdates = () => setSelected(select(getSnapshot()));\n checkForUpdates();\n return subscribe(checkForUpdates);\n }, [subscribe, getSnapshot, select]);\n\n return selected;\n}\n"],"names":["React","useEventCallback","useIsomorphicLayoutEffect","useOverflowContext","useOverflowSnapshot","selector","getSnapshot","subscribe","select","selected","setSelected","useState","checkForUpdates"],"mappings":"AAAA;AAGA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,gBAAgB,EAAEC,yBAAyB,QAAQ,4BAA4B;AACxF,SAASC,kBAAkB,QAAQ,oBAAoB;AAEvD;;;;CAIC,GACD,OAAO,SAASC,oBAA8BC,QAAkD;IAC9F,MAAM,EAAEC,WAAW,EAAEC,SAAS,EAAE,GAAGJ;IACnC,MAAMK,SAASP,iBAAiBI;IAEhC,MAAM,CAACI,UAAUC,YAAY,GAAGV,MAAMW,QAAQ,CAAC,IAAMN,SAASC;IAE9DJ,0BAA0B;QACxB,MAAMU,kBAAkB,IAAMF,YAAYF,OAAOF;QACjDM;QACA,OAAOL,UAAUK;IACnB,GAAG;QAACL;QAAWD;QAAaE;KAAO;IAEnC,OAAOC;AACT"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import
|
|
3
|
-
import { useOverflowContext } from './overflowContext';
|
|
2
|
+
import { useOverflowSnapshot } from './useOverflowSnapshot';
|
|
4
3
|
/**
|
|
5
4
|
* A hook that returns the visibility status of all items and groups.
|
|
6
5
|
*
|
|
@@ -10,13 +9,9 @@ import { useOverflowContext } from './overflowContext';
|
|
|
10
9
|
* visible - use with caution
|
|
11
10
|
* @returns visibility status of all items and groups
|
|
12
11
|
*/ export function useOverflowVisibility() {
|
|
13
|
-
|
|
14
|
-
const groupVisibility = useOverflowContext((ctx)=>ctx.groupVisibility);
|
|
15
|
-
return React.useMemo(()=>({
|
|
16
|
-
itemVisibility,
|
|
17
|
-
groupVisibility
|
|
18
|
-
}), [
|
|
19
|
-
itemVisibility,
|
|
20
|
-
groupVisibility
|
|
21
|
-
]);
|
|
12
|
+
return useOverflowSnapshot(selectVisibility);
|
|
22
13
|
}
|
|
14
|
+
const selectVisibility = (snapshot)=>({
|
|
15
|
+
itemVisibility: snapshot.itemVisibility,
|
|
16
|
+
groupVisibility: snapshot.groupVisibility
|
|
17
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useOverflowVisibility.ts"],"sourcesContent":["'use client';\n\nimport
|
|
1
|
+
{"version":3,"sources":["../src/useOverflowVisibility.ts"],"sourcesContent":["'use client';\n\nimport type { OverflowGroupState, OverflowSnapshot } from '@fluentui/priority-overflow';\nimport { useOverflowSnapshot } from './useOverflowSnapshot';\n\n/**\n * A hook that returns the visibility status of all items and groups.\n *\n * ⚠️ Heads up!\n *\n * This hook will cause the component it is in to re-render for every single time an item overflows or becomes\n * visible - use with caution\n * @returns visibility status of all items and groups\n */\nexport function useOverflowVisibility(): {\n itemVisibility: Record<string, boolean>;\n groupVisibility: Record<string, OverflowGroupState>;\n} {\n return useOverflowSnapshot(selectVisibility);\n}\n\nconst selectVisibility = (\n snapshot: OverflowSnapshot,\n): {\n itemVisibility: Record<string, boolean>;\n groupVisibility: Record<string, OverflowGroupState>;\n} => ({\n itemVisibility: snapshot.itemVisibility,\n groupVisibility: snapshot.groupVisibility,\n});\n"],"names":["useOverflowSnapshot","useOverflowVisibility","selectVisibility","snapshot","itemVisibility","groupVisibility"],"mappings":"AAAA;AAGA,SAASA,mBAAmB,QAAQ,wBAAwB;AAE5D;;;;;;;;CAQC,GACD,OAAO,SAASC;IAId,OAAOD,oBAAoBE;AAC7B;AAEA,MAAMA,mBAAmB,CACvBC,WAII,CAAA;QACJC,gBAAgBD,SAASC,cAAc;QACvCC,iBAAiBF,SAASE,eAAe;IAC3C,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Overflow", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function() {
|
|
9
|
+
return Overflow;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
13
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
14
|
+
const _useOverflow = require("./useOverflow");
|
|
15
|
+
const _useOverflowContextValues = require("../../useOverflowContextValues");
|
|
16
|
+
const _useOverflowStylesstyles = require("./useOverflowStyles.styles");
|
|
17
|
+
const _renderOverflow = require("./renderOverflow");
|
|
18
|
+
const Overflow = /*#__PURE__*/ _react.forwardRef((props, ref)=>{
|
|
19
|
+
const state = (0, _useOverflow.useOverflow_unstable)(props, ref);
|
|
20
|
+
const contextValues = (0, _useOverflowContextValues.useOverflowContextValues_unstable)(state);
|
|
21
|
+
(0, _useOverflowStylesstyles.useOverflowStyles_unstable)(state);
|
|
22
|
+
return (0, _renderOverflow.renderOverflow_unstable)(state, contextValues);
|
|
23
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Overflow/Overflow.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { OverflowProps } from './Overflow.types';\nimport { useOverflow_unstable } from './useOverflow';\nimport { useOverflowContextValues_unstable } from '../../useOverflowContextValues';\nimport { useOverflowStyles_unstable } from './useOverflowStyles.styles';\nimport { renderOverflow_unstable } from './renderOverflow';\n\n/**\n * Provides an OverflowContext for OverflowItem descendants.\n */\nexport const Overflow = React.forwardRef((props: OverflowProps, ref) => {\n const state = useOverflow_unstable(props, ref as React.Ref<HTMLElement>);\n const contextValues = useOverflowContextValues_unstable(state);\n\n useOverflowStyles_unstable(state);\n\n return renderOverflow_unstable(state, contextValues);\n});\n"],"names":["React","useOverflow_unstable","useOverflowContextValues_unstable","useOverflowStyles_unstable","renderOverflow_unstable","Overflow","forwardRef","props","ref","state","contextValues"],"mappings":"AAAA;;;;;;;;;;;;iEAEuB,QAAQ;6BAEM,gBAAgB;0CACH,iCAAiC;yCACxC,6BAA6B;gCAChC,mBAAmB;AAKpD,MAAMK,WAAAA,WAAAA,GAAWL,OAAMM,UAAU,CAAC,CAACC,OAAsBC;IAC9D,MAAMC,YAAQR,iCAAAA,EAAqBM,OAAOC;IAC1C,MAAME,oBAAgBR,2DAAAA,EAAkCO;QAExDN,mDAAAA,EAA2BM;IAE3B,WAAOL,uCAAAA,EAAwBK,OAAOC;AACxC,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Overflow/Overflow.types.ts"],"sourcesContent":["import type * as React from 'react';\nimport type { OverflowOptions, OverflowGroupState } from '@fluentui/priority-overflow';\nimport type { OverflowContextValue } from '../../overflowContext';\nimport type { UseOverflowContainerReturn } from '../../types';\n\nexport interface OverflowState {\n hasOverflow: boolean;\n itemVisibility: Record<string, boolean>;\n groupVisibility: Record<string, OverflowGroupState>;\n}\n\nexport interface OnOverflowChangeData extends OverflowState {}\n\nexport type OverflowProps = Partial<\n Pick<OverflowOptions, 'overflowAxis' | 'overflowDirection' | 'padding' | 'minimumVisible' | 'hasHiddenItems'>\n> & {\n children: React.ReactElement;\n\n // overflow is not caused by DOM event\n // eslint-disable-next-line @nx/workspace-consistent-callback-type\n onOverflowChange?: (ev: null, data: OverflowState) => void;\n};\n\n/**\n * State used in rendering Overflow. Carries the overflow container's registration api so\n * `useOverflowContextValues_unstable` can assemble the context values.\n */\nexport type OverflowComponentState = UseOverflowContainerReturn<HTMLElement> & {\n /**\n * Merged ref applied to the cloned child's root element.\n */\n ref: React.Ref<HTMLElement>;\n /**\n * Class name applied to the cloned child. Set by `useOverflowStyles_unstable`; left `undefined`\n * by headless consumers that apply no styling.\n */\n className?: string;\n /**\n * The single child that overflow behavior is attached to.\n */\n children: React.ReactElement;\n};\n\n/**\n * Context values provided to overflow descendants.\n */\nexport type OverflowContextValues = {\n overflow: OverflowContextValue;\n};\n"],"names":[],"mappings":"AA2CA;;CAEC,GACD,WAEE"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
Overflow: function() {
|
|
13
|
+
return _Overflow.Overflow;
|
|
14
|
+
},
|
|
15
|
+
renderOverflow_unstable: function() {
|
|
16
|
+
return _renderOverflow.renderOverflow_unstable;
|
|
17
|
+
},
|
|
18
|
+
useOverflowStyles_unstable: function() {
|
|
19
|
+
return _useOverflowStylesstyles.useOverflowStyles_unstable;
|
|
20
|
+
},
|
|
21
|
+
useOverflow_unstable: function() {
|
|
22
|
+
return _useOverflow.useOverflow_unstable;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const _Overflow = require("./Overflow");
|
|
26
|
+
const _useOverflow = require("./useOverflow");
|
|
27
|
+
const _renderOverflow = require("./renderOverflow");
|
|
28
|
+
const _useOverflowStylesstyles = require("./useOverflowStyles.styles");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Overflow/index.ts"],"sourcesContent":["export { Overflow } from './Overflow';\nexport { useOverflow_unstable } from './useOverflow';\nexport { renderOverflow_unstable } from './renderOverflow';\nexport { useOverflowStyles_unstable } from './useOverflowStyles.styles';\nexport type {\n OverflowProps,\n OnOverflowChangeData,\n OverflowState,\n OverflowComponentState,\n OverflowContextValues,\n} from './Overflow.types';\n"],"names":["Overflow","useOverflow_unstable","renderOverflow_unstable","useOverflowStyles_unstable"],"mappings":";;;;;;;;;;;;eAASA,kBAAQ;;;eAERE,uCAAuB;;;eACvBC,mDAA0B;;;eAF1BF,iCAAoB;;;0BADJ,aAAa;6BACD,gBAAgB;gCACb,mBAAmB;yCAChB,6BAA6B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "renderOverflow_unstable", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return renderOverflow_unstable;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
13
|
+
const _reactutilities = require("@fluentui/react-utilities");
|
|
14
|
+
const _overflowContext = require("../../overflowContext");
|
|
15
|
+
const renderOverflow_unstable = (state, contextValues)=>{
|
|
16
|
+
const child = (0, _reactutilities.getTriggerChild)(state.children);
|
|
17
|
+
var _state_className;
|
|
18
|
+
const clonedChild = (0, _reactutilities.applyTriggerPropsToChildren)(state.children, {
|
|
19
|
+
ref: state.ref,
|
|
20
|
+
className: (_state_className = state.className) !== null && _state_className !== void 0 ? _state_className : child === null || child === void 0 ? void 0 : child.props.className
|
|
21
|
+
});
|
|
22
|
+
return /*#__PURE__*/ _react.createElement(_overflowContext.OverflowContext.Provider, {
|
|
23
|
+
value: contextValues.overflow
|
|
24
|
+
}, clonedChild);
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Overflow/renderOverflow.tsx"],"sourcesContent":["import * as React from 'react';\nimport { applyTriggerPropsToChildren, getTriggerChild } from '@fluentui/react-utilities';\nimport { OverflowContext } from '../../overflowContext';\nimport type { OverflowComponentState, OverflowContextValues } from './Overflow.types';\n\n/**\n * Render the final JSX of Overflow.\n *\n * Griffel-free so it can be reused by headless consumers; all class merging happens in\n * `useOverflowStyles_unstable`.\n */\nexport const renderOverflow_unstable = (\n state: OverflowComponentState,\n contextValues: OverflowContextValues,\n): React.ReactElement => {\n const child = getTriggerChild<HTMLElement>(state.children);\n\n const clonedChild = applyTriggerPropsToChildren(state.children, {\n ref: state.ref,\n className: state.className ?? child?.props.className,\n });\n\n return <OverflowContext.Provider value={contextValues.overflow}>{clonedChild}</OverflowContext.Provider>;\n};\n"],"names":["React","applyTriggerPropsToChildren","getTriggerChild","OverflowContext","renderOverflow_unstable","state","contextValues","child","children","clonedChild","ref","className","props","Provider","value","overflow"],"mappings":";;;;+BAWaI;;;;;;;iEAXU,QAAQ;gCAC8B,4BAA4B;iCACzD,wBAAwB;AASjD,gCAAgC,CACrCC,OACAC;IAEA,MAAMC,YAAQL,+BAAAA,EAA6BG,MAAMG,QAAQ;QAI5CH;IAFb,MAAMI,kBAAcR,2CAAAA,EAA4BI,MAAMG,QAAQ,EAAE;QAC9DE,KAAKL,MAAMK,GAAG;QACdC,WAAWN,CAAAA,mBAAAA,MAAMM,SAAAA,AAAS,MAAA,QAAfN,qBAAAA,KAAAA,IAAAA,mBAAmBE,UAAAA,QAAAA,UAAAA,KAAAA,IAAAA,KAAAA,IAAAA,MAAOK,KAAK,CAACD,SAAS;IACtD;IAEA,OAAA,WAAA,GAAO,OAAA,aAAA,CAACR,gCAAAA,CAAgBU,QAAQ,EAAA;QAACC,OAAOR,cAAcS,QAAQ;OAAGN;AACnE,EAAE"}
|
|
@@ -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"}
|