@fluentui/react-overflow 0.0.0-nightly-20220511-0419.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +164 -0
- package/CHANGELOG.md +54 -0
- package/LICENSE +15 -0
- package/README.md +5 -0
- package/dist/index.d.ts +121 -0
- package/lib/components/Overflow.d.ts +14 -0
- package/lib/components/Overflow.js +73 -0
- package/lib/components/Overflow.js.map +1 -0
- package/lib/components/OverflowItem/OverflowItem.d.ts +7 -0
- package/lib/components/OverflowItem/OverflowItem.js +21 -0
- package/lib/components/OverflowItem/OverflowItem.js.map +1 -0
- package/lib/components/OverflowItem/OverflowItem.types.d.ts +22 -0
- package/lib/components/OverflowItem/OverflowItem.types.js +2 -0
- package/lib/components/OverflowItem/OverflowItem.types.js.map +1 -0
- package/lib/components/OverflowItem/index.d.ts +2 -0
- package/lib/components/OverflowItem/index.js +2 -0
- package/lib/components/OverflowItem/index.js.map +1 -0
- package/lib/constants.d.ts +3 -0
- package/lib/constants.js +4 -0
- package/lib/constants.js.map +1 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.js +10 -0
- package/lib/index.js.map +1 -0
- package/lib/overflowContext.d.ts +11 -0
- package/lib/overflowContext.js +10 -0
- package/lib/overflowContext.js.map +1 -0
- package/lib/tsdoc-metadata.json +11 -0
- package/lib/types.d.ts +16 -0
- package/lib/types.js +2 -0
- package/lib/types.js.map +1 -0
- package/lib/useIsOverflowGroupVisible.d.ts +6 -0
- package/lib/useIsOverflowGroupVisible.js +10 -0
- package/lib/useIsOverflowGroupVisible.js.map +1 -0
- package/lib/useIsOverflowItemVisible.d.ts +5 -0
- package/lib/useIsOverflowItemVisible.js +10 -0
- package/lib/useIsOverflowItemVisible.js.map +1 -0
- package/lib/useOverflowContainer.d.ts +10 -0
- package/lib/useOverflowContainer.js +69 -0
- package/lib/useOverflowContainer.js.map +1 -0
- package/lib/useOverflowCount.d.ts +4 -0
- package/lib/useOverflowCount.js +15 -0
- package/lib/useOverflowCount.js.map +1 -0
- package/lib/useOverflowItem.d.ts +9 -0
- package/lib/useOverflowItem.js +27 -0
- package/lib/useOverflowItem.js.map +1 -0
- package/lib/useOverflowMenu.d.ts +6 -0
- package/lib/useOverflowMenu.js +40 -0
- package/lib/useOverflowMenu.js.map +1 -0
- package/lib-commonjs/components/Overflow.d.ts +14 -0
- package/lib-commonjs/components/Overflow.js +85 -0
- package/lib-commonjs/components/Overflow.js.map +1 -0
- package/lib-commonjs/components/OverflowItem/OverflowItem.d.ts +7 -0
- package/lib-commonjs/components/OverflowItem/OverflowItem.js +31 -0
- package/lib-commonjs/components/OverflowItem/OverflowItem.js.map +1 -0
- package/lib-commonjs/components/OverflowItem/OverflowItem.types.d.ts +22 -0
- package/lib-commonjs/components/OverflowItem/OverflowItem.types.js +6 -0
- package/lib-commonjs/components/OverflowItem/OverflowItem.types.js.map +1 -0
- package/lib-commonjs/components/OverflowItem/index.d.ts +2 -0
- package/lib-commonjs/components/OverflowItem/index.js +16 -0
- package/lib-commonjs/components/OverflowItem/index.js.map +1 -0
- package/lib-commonjs/constants.d.ts +3 -0
- package/lib-commonjs/constants.js +10 -0
- package/lib-commonjs/constants.js.map +1 -0
- package/lib-commonjs/index.d.ts +12 -0
- package/lib-commonjs/index.js +106 -0
- package/lib-commonjs/index.js.map +1 -0
- package/lib-commonjs/overflowContext.d.ts +11 -0
- package/lib-commonjs/overflowContext.js +21 -0
- package/lib-commonjs/overflowContext.js.map +1 -0
- package/lib-commonjs/types.d.ts +16 -0
- package/lib-commonjs/types.js +6 -0
- package/lib-commonjs/types.js.map +1 -0
- package/lib-commonjs/useIsOverflowGroupVisible.d.ts +6 -0
- package/lib-commonjs/useIsOverflowGroupVisible.js +20 -0
- package/lib-commonjs/useIsOverflowGroupVisible.js.map +1 -0
- package/lib-commonjs/useIsOverflowItemVisible.d.ts +5 -0
- package/lib-commonjs/useIsOverflowItemVisible.js +20 -0
- package/lib-commonjs/useIsOverflowItemVisible.js.map +1 -0
- package/lib-commonjs/useOverflowContainer.d.ts +10 -0
- package/lib-commonjs/useOverflowContainer.js +85 -0
- package/lib-commonjs/useOverflowContainer.js.map +1 -0
- package/lib-commonjs/useOverflowCount.d.ts +4 -0
- package/lib-commonjs/useOverflowCount.js +25 -0
- package/lib-commonjs/useOverflowCount.js.map +1 -0
- package/lib-commonjs/useOverflowItem.d.ts +9 -0
- package/lib-commonjs/useOverflowItem.js +39 -0
- package/lib-commonjs/useOverflowItem.js.map +1 -0
- package/lib-commonjs/useOverflowMenu.d.ts +6 -0
- package/lib-commonjs/useOverflowMenu.js +54 -0
- package/lib-commonjs/useOverflowMenu.js.map +1 -0
- package/package.json +53 -0
package/lib/types.d.ts
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { OverflowContextValue } from './overflowContext';
|
3
|
+
export interface UseOverflowContainerReturn<TElement extends HTMLElement> {
|
4
|
+
/**
|
5
|
+
* Ref to apply to the container that will overflow
|
6
|
+
*/
|
7
|
+
containerRef: React.RefObject<TElement>;
|
8
|
+
/**
|
9
|
+
* Registers and overflow item
|
10
|
+
*/
|
11
|
+
registerItem: OverflowContextValue['registerItem'];
|
12
|
+
/**
|
13
|
+
* Imperative function to trigger overflow update
|
14
|
+
*/
|
15
|
+
updateOverflow: OverflowContextValue['updateOverflow'];
|
16
|
+
}
|
package/lib/types.js
ADDED
package/lib/types.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"../src/","sources":["types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport { OverflowContextValue } from './overflowContext';\n\nexport interface UseOverflowContainerReturn<TElement extends HTMLElement> {\n /**\n * Ref to apply to the container that will overflow\n */\n containerRef: React.RefObject<TElement>;\n /**\n * Registers and overflow item\n */\n registerItem: OverflowContextValue['registerItem'];\n /**\n * Imperative function to trigger overflow update\n */\n updateOverflow: OverflowContextValue['updateOverflow'];\n}\n"]}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { useOverflowContext } from './overflowContext';
|
2
|
+
/**
|
3
|
+
* @param id - unique identifier for a group of overflow items
|
4
|
+
* @returns visibility state of the group
|
5
|
+
*/
|
6
|
+
|
7
|
+
export function useIsOverflowGroupVisible(id) {
|
8
|
+
return useOverflowContext(ctx => ctx.groupVisibility[id]);
|
9
|
+
}
|
10
|
+
//# sourceMappingURL=useIsOverflowGroupVisible.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["useIsOverflowGroupVisible.ts"],"names":[],"mappings":"AACA,SAAS,kBAAT,QAAmC,mBAAnC;AAEA;;;AAGG;;AACH,OAAM,SAAU,yBAAV,CAAoC,EAApC,EAA8C;AAClD,SAAO,kBAAkB,CAAC,GAAG,IAAI,GAAG,CAAC,eAAJ,CAAoB,EAApB,CAAR,CAAzB;AACD","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"],"sourceRoot":"../src/"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { useOverflowContext } from './overflowContext';
|
2
|
+
/**
|
3
|
+
* @param id - unique identifier for the item used by the overflow manager
|
4
|
+
* @returns visibility state of an overflow item
|
5
|
+
*/
|
6
|
+
|
7
|
+
export function useIsOverflowItemVisible(id) {
|
8
|
+
return !!useOverflowContext(ctx => ctx.itemVisibility[id]);
|
9
|
+
}
|
10
|
+
//# sourceMappingURL=useIsOverflowItemVisible.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["useIsOverflowItemVisible.ts"],"names":[],"mappings":"AAAA,SAAS,kBAAT,QAAmC,mBAAnC;AAEA;;;AAGG;;AACH,OAAM,SAAU,wBAAV,CAAmC,EAAnC,EAA6C;AACjD,SAAO,CAAC,CAAC,kBAAkB,CAAC,GAAG,IAAI,GAAG,CAAC,cAAJ,CAAmB,EAAnB,CAAR,CAA3B;AACD","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"],"sourceRoot":"../src/"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import type { OnUpdateItemVisibility, OnUpdateOverflow, ObserveOptions } from '@fluentui/priority-overflow';
|
2
|
+
import { UseOverflowContainerReturn } from './types';
|
3
|
+
/**
|
4
|
+
*
|
5
|
+
* @param update - Callback when overflow state changes
|
6
|
+
* @param options - Options to configure the overflow container
|
7
|
+
* @returns - ref to attach to an intrinsic HTML element and imperative functions
|
8
|
+
*/
|
9
|
+
export declare const useOverflowContainer: <TElement extends HTMLElement>(update: OnUpdateOverflow, options: Omit<ObserveOptions, 'onUpdateOverflow'>) => UseOverflowContainerReturn<TElement>;
|
10
|
+
export declare const updateVisibilityAttribute: OnUpdateItemVisibility;
|
@@ -0,0 +1,69 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { createOverflowManager } from '@fluentui/priority-overflow';
|
3
|
+
import { useEventCallback, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
|
4
|
+
import { DATA_OVERFLOWING, DATA_OVERFLOW_ITEM } from './constants';
|
5
|
+
/**
|
6
|
+
*
|
7
|
+
* @param update - Callback when overflow state changes
|
8
|
+
* @param options - Options to configure the overflow container
|
9
|
+
* @returns - ref to attach to an intrinsic HTML element and imperative functions
|
10
|
+
*/
|
11
|
+
|
12
|
+
export const useOverflowContainer = (update, options) => {
|
13
|
+
const {
|
14
|
+
overflowAxis,
|
15
|
+
overflowDirection,
|
16
|
+
padding,
|
17
|
+
minimumVisible,
|
18
|
+
onUpdateItemVisibility
|
19
|
+
} = options; // DOM ref to the overflow container element
|
20
|
+
|
21
|
+
const containerRef = React.useRef(null);
|
22
|
+
const updateOverflowItems = useEventCallback(update);
|
23
|
+
const [overflowManager] = React.useState(() => createOverflowManager());
|
24
|
+
useIsomorphicLayoutEffect(() => {
|
25
|
+
if (!containerRef.current) {
|
26
|
+
return;
|
27
|
+
}
|
28
|
+
|
29
|
+
overflowManager.observe(containerRef.current, {
|
30
|
+
overflowDirection: overflowDirection !== null && overflowDirection !== void 0 ? overflowDirection : 'end',
|
31
|
+
overflowAxis: overflowAxis !== null && overflowAxis !== void 0 ? overflowAxis : 'horizontal',
|
32
|
+
padding: padding !== null && padding !== void 0 ? padding : 10,
|
33
|
+
minimumVisible: minimumVisible !== null && minimumVisible !== void 0 ? minimumVisible : 0,
|
34
|
+
onUpdateItemVisibility: onUpdateItemVisibility !== null && onUpdateItemVisibility !== void 0 ? onUpdateItemVisibility : () => undefined,
|
35
|
+
onUpdateOverflow: updateOverflowItems !== null && updateOverflowItems !== void 0 ? updateOverflowItems : () => undefined
|
36
|
+
});
|
37
|
+
return () => {
|
38
|
+
overflowManager.disconnect();
|
39
|
+
};
|
40
|
+
}, [updateOverflowItems, overflowManager, overflowDirection, overflowAxis, padding, minimumVisible, onUpdateItemVisibility]);
|
41
|
+
const registerItem = React.useCallback(item => {
|
42
|
+
overflowManager.addItem(item);
|
43
|
+
item.element.setAttribute(DATA_OVERFLOW_ITEM, '');
|
44
|
+
return () => {
|
45
|
+
item.element.removeAttribute(DATA_OVERFLOWING);
|
46
|
+
item.element.removeAttribute(DATA_OVERFLOW_ITEM);
|
47
|
+
overflowManager.removeItem(item.id);
|
48
|
+
};
|
49
|
+
}, [overflowManager]);
|
50
|
+
const updateOverflow = React.useCallback(() => {
|
51
|
+
overflowManager.update();
|
52
|
+
}, [overflowManager]);
|
53
|
+
return {
|
54
|
+
containerRef,
|
55
|
+
registerItem,
|
56
|
+
updateOverflow
|
57
|
+
};
|
58
|
+
};
|
59
|
+
export const updateVisibilityAttribute = ({
|
60
|
+
item,
|
61
|
+
visible
|
62
|
+
}) => {
|
63
|
+
if (visible) {
|
64
|
+
item.element.removeAttribute(DATA_OVERFLOWING);
|
65
|
+
} else {
|
66
|
+
item.element.setAttribute(DATA_OVERFLOWING, '');
|
67
|
+
}
|
68
|
+
};
|
69
|
+
//# sourceMappingURL=useOverflowContainer.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["useOverflowContainer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,qBAAT,QAAsC,6BAAtC;AASA,SAAS,gBAAT,EAA2B,yBAA3B,QAA4D,2BAA5D;AAEA,SAAS,gBAAT,EAA2B,kBAA3B,QAAqD,aAArD;AAEA;;;;;AAKG;;AACH,OAAO,MAAM,oBAAoB,GAAG,CAClC,MADkC,EAElC,OAFkC,KAGM;AACxC,QAAM;AAAE,IAAA,YAAF;AAAgB,IAAA,iBAAhB;AAAmC,IAAA,OAAnC;AAA4C,IAAA,cAA5C;AAA4D,IAAA;AAA5D,MAAuF,OAA7F,CADwC,CAExC;;AACA,QAAM,YAAY,GAAG,KAAK,CAAC,MAAN,CAAuB,IAAvB,CAArB;AACA,QAAM,mBAAmB,GAAG,gBAAgB,CAAC,MAAD,CAA5C;AACA,QAAM,CAAC,eAAD,IAAoB,KAAK,CAAC,QAAN,CAAgC,MAAM,qBAAqB,EAA3D,CAA1B;AAEA,EAAA,yBAAyB,CAAC,MAAK;AAC7B,QAAI,CAAC,YAAY,CAAC,OAAlB,EAA2B;AACzB;AACD;;AAED,IAAA,eAAe,CAAC,OAAhB,CAAwB,YAAY,CAAC,OAArC,EAA8C;AAC5C,MAAA,iBAAiB,EAAE,iBAAiB,KAAA,IAAjB,IAAA,iBAAiB,KAAA,KAAA,CAAjB,GAAA,iBAAA,GAAqB,KADI;AAE5C,MAAA,YAAY,EAAE,YAAY,KAAA,IAAZ,IAAA,YAAY,KAAA,KAAA,CAAZ,GAAA,YAAA,GAAgB,YAFc;AAG5C,MAAA,OAAO,EAAE,OAAO,KAAA,IAAP,IA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B,GAA2B,CAAC;AAAE,EAAA,IAAF;AAAQ,EAAA;AAAR,CAAD,KAAsB;AACrF,MAAI,OAAJ,EAAa;AACX,IAAA,IAAI,CAAC,OAAL,CAAa,eAAb,CAA6B,gBAA7B;AACD,GAFD,MAEO;AACL,IAAA,IAAI,CAAC,OAAL,CAAa,YAAb,CAA0B,gBAA1B,EAA4C,EAA5C;AACD;AACF,CANM","sourcesContent":["import * as React from 'react';\nimport { createOverflowManager } from '@fluentui/priority-overflow';\n\nimport type {\n OnUpdateItemVisibility,\n OnUpdateOverflow,\n OverflowItemEntry,\n OverflowManager,\n ObserveOptions,\n} from '@fluentui/priority-overflow';\nimport { useEventCallback, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport { UseOverflowContainerReturn } from './types';\nimport { DATA_OVERFLOWING, DATA_OVERFLOW_ITEM } from './constants';\n\n/**\n *\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<ObserveOptions, 'onUpdateOverflow'>,\n): UseOverflowContainerReturn<TElement> => {\n const { overflowAxis, overflowDirection, padding, minimumVisible, onUpdateItemVisibility } = options;\n // DOM ref to the overflow container element\n const containerRef = React.useRef<TElement>(null);\n const updateOverflowItems = useEventCallback(update);\n const [overflowManager] = React.useState<OverflowManager>(() => createOverflowManager());\n\n useIsomorphicLayoutEffect(() => {\n if (!containerRef.current) {\n return;\n }\n\n overflowManager.observe(containerRef.current, {\n overflowDirection: overflowDirection ?? 'end',\n overflowAxis: overflowAxis ?? 'horizontal',\n padding: padding ?? 10,\n minimumVisible: minimumVisible ?? 0,\n onUpdateItemVisibility: onUpdateItemVisibility ?? (() => undefined),\n onUpdateOverflow: updateOverflowItems ?? (() => undefined),\n });\n\n return () => {\n overflowManager.disconnect();\n };\n }, [\n updateOverflowItems,\n overflowManager,\n overflowDirection,\n overflowAxis,\n padding,\n minimumVisible,\n onUpdateItemVisibility,\n ]);\n\n const registerItem = React.useCallback(\n (item: OverflowItemEntry) => {\n overflowManager.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 overflowManager.removeItem(item.id);\n };\n },\n [overflowManager],\n );\n\n const updateOverflow = React.useCallback(() => {\n overflowManager.update();\n }, [overflowManager]);\n\n return {\n containerRef,\n registerItem,\n updateOverflow,\n };\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"],"sourceRoot":"../src/"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { useOverflowContext } from './overflowContext';
|
2
|
+
/**
|
3
|
+
* @returns Number of items that are overflowing
|
4
|
+
*/
|
5
|
+
|
6
|
+
export const useOverflowCount = () => useOverflowContext(v => {
|
7
|
+
return Object.entries(v.itemVisibility).reduce((acc, [id, visible]) => {
|
8
|
+
if (!visible) {
|
9
|
+
acc++;
|
10
|
+
}
|
11
|
+
|
12
|
+
return acc;
|
13
|
+
}, 0);
|
14
|
+
});
|
15
|
+
//# sourceMappingURL=useOverflowCount.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["useOverflowCount.ts"],"names":[],"mappings":"AAAA,SAAS,kBAAT,QAAmC,mBAAnC;AAEA;;AAEG;;AACH,OAAO,MAAM,gBAAgB,GAAG,MAC9B,kBAAkB,CAAC,CAAC,IAAG;AACrB,SAAO,MAAM,CAAC,OAAP,CAAe,CAAC,CAAC,cAAjB,EAAiC,MAAjC,CAAwC,CAAC,GAAD,EAAM,CAAC,EAAD,EAAK,OAAL,CAAN,KAAuB;AACpE,QAAI,CAAC,OAAL,EAAc;AACZ,MAAA,GAAG;AACJ;;AAED,WAAO,GAAP;AACD,GANM,EAMJ,CANI,CAAP;AAOD,CARiB,CADb","sourcesContent":["import { useOverflowContext } from './overflowContext';\n\n/**\n * @returns Number of items that are overflowing\n */\nexport const useOverflowCount = () =>\n useOverflowContext(v => {\n return Object.entries(v.itemVisibility).reduce((acc, [id, visible]) => {\n if (!visible) {\n acc++;\n }\n\n return acc;\n }, 0);\n });\n"],"sourceRoot":"../src/"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
/**
|
3
|
+
* Registers an overflow item
|
4
|
+
* @param id - unique identifier for the item used by the overflow manager
|
5
|
+
* @param priority - higher priority means the item overflows later
|
6
|
+
* @param groupId - assigns the item to a group, group visibility can be watched
|
7
|
+
* @returns ref to assign to an intrinsic HTML element
|
8
|
+
*/
|
9
|
+
export declare function useOverflowItem<TElement extends HTMLElement>(id: string, priority?: number, groupId?: string): React.RefObject<TElement>;
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
|
3
|
+
import { useOverflowContext } from './overflowContext';
|
4
|
+
/**
|
5
|
+
* Registers an overflow item
|
6
|
+
* @param id - unique identifier for the item used by the overflow manager
|
7
|
+
* @param priority - higher priority means the item overflows later
|
8
|
+
* @param groupId - assigns the item to a group, group visibility can be watched
|
9
|
+
* @returns ref to assign to an intrinsic HTML element
|
10
|
+
*/
|
11
|
+
|
12
|
+
export function useOverflowItem(id, priority, groupId) {
|
13
|
+
const ref = React.useRef(null);
|
14
|
+
const registerItem = useOverflowContext(v => v.registerItem);
|
15
|
+
useIsomorphicLayoutEffect(() => {
|
16
|
+
if (ref.current) {
|
17
|
+
return registerItem({
|
18
|
+
element: ref.current,
|
19
|
+
id,
|
20
|
+
priority: priority !== null && priority !== void 0 ? priority : 0,
|
21
|
+
groupId
|
22
|
+
});
|
23
|
+
}
|
24
|
+
}, [id, priority, registerItem, groupId]);
|
25
|
+
return ref;
|
26
|
+
}
|
27
|
+
//# sourceMappingURL=useOverflowItem.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["useOverflowItem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,yBAAT,QAA0C,2BAA1C;AACA,SAAS,kBAAT,QAAmC,mBAAnC;AAEA;;;;;;AAMG;;AACH,OAAM,SAAU,eAAV,CAAwD,EAAxD,EAAoE,QAApE,EAAuF,OAAvF,EAAuG;AAC3G,QAAM,GAAG,GAAG,KAAK,CAAC,MAAN,CAAuB,IAAvB,CAAZ;AACA,QAAM,YAAY,GAAG,kBAAkB,CAAC,CAAC,IAAI,CAAC,CAAC,YAAR,CAAvC;AAEA,EAAA,yBAAyB,CAAC,MAAK;AAC7B,QAAI,GAAG,CAAC,OAAR,EAAiB;AACf,aAAO,YAAY,CAAC;AAClB,QAAA,OAAO,EAAE,GAAG,CAAC,OADK;AAElB,QAAA,EAFkB;AAGlB,QAAA,QAAQ,EAAE,QAAQ,KAAA,IAAR,IAAA,QAAQ,KAAA,KAAA,CAAR,GAAA,QAAA,GAAY,CAHJ;AAIlB,QAAA;AAJkB,OAAD,CAAnB;AAMD;AACF,GATwB,EAStB,CAAC,EAAD,EAAK,QAAL,EAAe,YAAf,EAA6B,OAA7B,CATsB,CAAzB;AAWA,SAAO,GAAP;AACD","sourcesContent":["import * as React from 'react';\nimport { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport { useOverflowContext } from './overflowContext';\n\n/**\n * Registers an overflow item\n * @param id - unique identifier for the item used by the overflow manager\n * @param priority - higher priority means the item overflows later\n * @param groupId - assigns the item to a group, group visibility can be watched\n * @returns ref to assign to an intrinsic HTML element\n */\nexport function useOverflowItem<TElement extends HTMLElement>(id: string, priority?: number, groupId?: string) {\n const ref = React.useRef<TElement>(null);\n const registerItem = useOverflowContext(v => v.registerItem);\n\n useIsomorphicLayoutEffect(() => {\n if (ref.current) {\n return registerItem({\n element: ref.current,\n id,\n priority: priority ?? 0,\n groupId,\n });\n }\n }, [id, priority, registerItem, groupId]);\n\n return ref;\n}\n"],"sourceRoot":"../src/"}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { useId, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
|
3
|
+
import { useOverflowContext } from './overflowContext';
|
4
|
+
import { useOverflowCount } from './useOverflowCount';
|
5
|
+
import { DATA_OVERFLOW_MENU } from './constants';
|
6
|
+
export function useOverflowMenu(id) {
|
7
|
+
const elementId = useId('overflow-menu', id);
|
8
|
+
const overflowCount = useOverflowCount();
|
9
|
+
const registerItem = useOverflowContext(v => v.registerItem);
|
10
|
+
const updateOverflow = useOverflowContext(v => v.updateOverflow);
|
11
|
+
const ref = React.useRef(null);
|
12
|
+
const isOverflowing = overflowCount > 0;
|
13
|
+
useIsomorphicLayoutEffect(() => {
|
14
|
+
const element = ref.current;
|
15
|
+
|
16
|
+
if (element) {
|
17
|
+
const deregisterItem = registerItem({
|
18
|
+
element,
|
19
|
+
id: elementId,
|
20
|
+
priority: Infinity
|
21
|
+
});
|
22
|
+
element.setAttribute(DATA_OVERFLOW_MENU, '');
|
23
|
+
return () => {
|
24
|
+
deregisterItem();
|
25
|
+
element === null || element === void 0 ? void 0 : element.removeAttribute(DATA_OVERFLOW_MENU);
|
26
|
+
};
|
27
|
+
}
|
28
|
+
}, [registerItem, isOverflowing, elementId]);
|
29
|
+
useIsomorphicLayoutEffect(() => {
|
30
|
+
if (isOverflowing) {
|
31
|
+
updateOverflow();
|
32
|
+
}
|
33
|
+
}, [isOverflowing, updateOverflow, ref]);
|
34
|
+
return {
|
35
|
+
ref,
|
36
|
+
overflowCount,
|
37
|
+
isOverflowing
|
38
|
+
};
|
39
|
+
}
|
40
|
+
//# sourceMappingURL=useOverflowMenu.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["useOverflowMenu.ts"],"names":[],"mappings":"AAAA,OAAO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gB,cAAhB,EAAgC,GAAhC,CAJsB,CAAzB;AAMA,SAAO;AAAE,IAAA,GAAF;AAAO,IAAA,aAAP;AAAsB,IAAA;AAAtB,GAAP;AACD","sourcesContent":["import * as React from 'react';\nimport { useId, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport { useOverflowContext } from './overflowContext';\nimport { useOverflowCount } from './useOverflowCount';\nimport { DATA_OVERFLOW_MENU } from './constants';\n\nexport function useOverflowMenu<TElement extends HTMLElement>(id?: string) {\n const elementId = useId('overflow-menu', id);\n const overflowCount = useOverflowCount();\n const registerItem = useOverflowContext(v => v.registerItem);\n const updateOverflow = useOverflowContext(v => v.updateOverflow);\n const ref = React.useRef<TElement>(null);\n const isOverflowing = overflowCount > 0;\n\n useIsomorphicLayoutEffect(() => {\n const element = ref.current;\n if (element) {\n const deregisterItem = registerItem({\n element,\n id: elementId,\n priority: Infinity,\n });\n element.setAttribute(DATA_OVERFLOW_MENU, '');\n\n return () => {\n deregisterItem();\n element?.removeAttribute(DATA_OVERFLOW_MENU);\n };\n }\n }, [registerItem, isOverflowing, elementId]);\n\n useIsomorphicLayoutEffect(() => {\n if (isOverflowing) {\n updateOverflow();\n }\n }, [isOverflowing, updateOverflow, ref]);\n\n return { ref, overflowCount, isOverflowing };\n}\n"],"sourceRoot":"../src/"}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import type { ObserveOptions } from '@fluentui/priority-overflow';
|
3
|
+
/**
|
4
|
+
* Overflow Props
|
5
|
+
*/
|
6
|
+
export declare type OverflowProps = Partial<Pick<ObserveOptions, 'overflowAxis' | 'overflowDirection' | 'padding' | 'minimumVisible'>> & {
|
7
|
+
children: React.ReactElement;
|
8
|
+
};
|
9
|
+
/**
|
10
|
+
* Provides an OverflowContext for OverflowItem descendants.
|
11
|
+
*/
|
12
|
+
export declare const Overflow: React.ForwardRefExoticComponent<Partial<Pick<ObserveOptions, "padding" | "overflowDirection" | "overflowAxis" | "minimumVisible">> & {
|
13
|
+
children: React.ReactElement;
|
14
|
+
} & React.RefAttributes<unknown>>;
|
@@ -0,0 +1,85 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.Overflow = void 0;
|
7
|
+
|
8
|
+
const React = /*#__PURE__*/require("react");
|
9
|
+
|
10
|
+
const react_1 = /*#__PURE__*/require("@griffel/react");
|
11
|
+
|
12
|
+
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
13
|
+
|
14
|
+
const overflowContext_1 = /*#__PURE__*/require("../overflowContext");
|
15
|
+
|
16
|
+
const useOverflowContainer_1 = /*#__PURE__*/require("../useOverflowContainer");
|
17
|
+
|
18
|
+
const constants_1 = /*#__PURE__*/require("../constants");
|
19
|
+
|
20
|
+
const useStyles = /*#__PURE__*/react_1.__styles({
|
21
|
+
"overflowMenu": {
|
22
|
+
"Brvla84": "fyfkpbf"
|
23
|
+
},
|
24
|
+
"overflowingItems": {
|
25
|
+
"Hevnzl": "ftz08xh"
|
26
|
+
}
|
27
|
+
}, {
|
28
|
+
"d": [".fyfkpbf [data-overflow-menu]{-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;}", ".ftz08xh>[data-overflowing]{display:none;}"]
|
29
|
+
});
|
30
|
+
/**
|
31
|
+
* Provides an OverflowContext for OverflowItem descendants.
|
32
|
+
*/
|
33
|
+
|
34
|
+
|
35
|
+
exports.Overflow = /*#__PURE__*/React.forwardRef((props, ref) => {
|
36
|
+
const styles = useStyles();
|
37
|
+
const {
|
38
|
+
children,
|
39
|
+
minimumVisible,
|
40
|
+
overflowAxis = 'horizontal',
|
41
|
+
overflowDirection,
|
42
|
+
padding
|
43
|
+
} = props;
|
44
|
+
const [hasOverflow, setHasOverflow] = React.useState(false);
|
45
|
+
const [itemVisibility, setItemVisibility] = React.useState({});
|
46
|
+
const [groupVisibility, setGroupVisibility] = React.useState({}); // useOverflowContainer wraps this method in a useEventCallback.
|
47
|
+
// TODO: Do we need a useEventCallback here too?
|
48
|
+
|
49
|
+
const update = data => {
|
50
|
+
setHasOverflow(() => data.invisibleItems.length > 0);
|
51
|
+
setItemVisibility(() => {
|
52
|
+
const newState = {};
|
53
|
+
data.visibleItems.forEach(x => newState[x.id] = true);
|
54
|
+
data.invisibleItems.forEach(x => newState[x.id] = false);
|
55
|
+
return newState;
|
56
|
+
});
|
57
|
+
setGroupVisibility(data.groupVisibility);
|
58
|
+
};
|
59
|
+
|
60
|
+
const {
|
61
|
+
containerRef,
|
62
|
+
registerItem,
|
63
|
+
updateOverflow
|
64
|
+
} = useOverflowContainer_1.useOverflowContainer(update, {
|
65
|
+
overflowDirection,
|
66
|
+
overflowAxis,
|
67
|
+
padding,
|
68
|
+
minimumVisible,
|
69
|
+
onUpdateItemVisibility: useOverflowContainer_1.updateVisibilityAttribute
|
70
|
+
});
|
71
|
+
const clonedChild = react_utilities_1.applyTriggerPropsToChildren(children, {
|
72
|
+
ref: react_utilities_1.useMergedRefs(containerRef, ref),
|
73
|
+
className: react_1.mergeClasses(styles.overflowMenu, styles.overflowingItems, children.props.className)
|
74
|
+
});
|
75
|
+
return React.createElement(overflowContext_1.OverflowContext.Provider, {
|
76
|
+
value: {
|
77
|
+
itemVisibility,
|
78
|
+
groupVisibility,
|
79
|
+
hasOverflow,
|
80
|
+
registerItem,
|
81
|
+
updateOverflow
|
82
|
+
}
|
83
|
+
}, clonedChild);
|
84
|
+
});
|
85
|
+
//# sourceMappingURL=Overflow.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["components/Overflow.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,OAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AAEA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AAEA,MAAA,iBAAA,gBAAA,OAAA,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AkB,CAAC,IAAI,CAAC,eAAN,CAAlB;AACD,GATD;;AAWA,QAAM;AAAE,IAAA,YAAF;AAAgB,IAAA,YAAhB;AAA8B,IAAA;AAA9B,MAAiD,sBAAA,CAAA,oBAAA,CAAqB,MAArB,EAA6B;AAClF,IAAA,iBADkF;AAElF,IAAA,YAFkF;AAGlF,IAAA,OAHkF;AAIlF,IAAA,cAJkF;AAKlF,IAAA,sBAAsB,EAAE,sBAAA,CAAA;AAL0D,GAA7B,CAAvD;AAQA,QAAM,WAAW,GAAG,iBAAA,CAAA,2BAAA,CAA4B,QAA5B,EAAsC;AACxD,IAAA,GAAG,EAAE,iBAAA,CAAA,aAAA,CAAc,YAAd,EAA4B,GAA5B,CADmD;AAExD,IAAA,SAAS,EAAE,OAAA,CAAA,YAAA,CAAa,MAAM,CAAC,YAApB,EAAkC,MAAM,CAAC,gBAAzC,EAA2D,QAAQ,CAAC,KAAT,CAAe,SAA1E;AAF6C,GAAtC,CAApB;AAKA,SACE,KAAA,CAAA,aAAA,CAAC,iBAAA,CAAA,eAAA,CAAgB,QAAjB,EAAyB;AACvB,IAAA,KAAK,EAAE;AACL,MAAA,cADK;AAEL,MAAA,eAFK;AAGL,MAAA,WAHK;AAIL,MAAA,YAJK;AAKL,MAAA;AALK;AADgB,GAAzB,EASG,WATH,CADF;AAaD,CAhDuB,CAAX","sourcesContent":["import * as React from 'react';\nimport { makeStyles, 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 { DATA_OVERFLOWING, DATA_OVERFLOW_MENU } from '../constants';\n\nconst useStyles = 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\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 = useStyles();\n\n const { children, minimumVisible, overflowAxis = 'horizontal', overflowDirection, padding } = props;\n\n const [hasOverflow, setHasOverflow] = React.useState(false);\n const [itemVisibility, setItemVisibility] = React.useState<Record<string, boolean>>({});\n const [groupVisibility, setGroupVisibility] = React.useState<Record<string, OverflowGroupState>>({});\n\n // useOverflowContainer wraps this method in a useEventCallback.\n // TODO: Do we need a useEventCallback here too?\n const update: OnUpdateOverflow = data => {\n setHasOverflow(() => data.invisibleItems.length > 0);\n setItemVisibility(() => {\n const newState: Record<string, boolean> = {};\n data.visibleItems.forEach(x => (newState[x.id] = true));\n data.invisibleItems.forEach(x => (newState[x.id] = false));\n return newState;\n });\n setGroupVisibility(data.groupVisibility);\n };\n\n const { containerRef, registerItem, updateOverflow } = 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,\n groupVisibility,\n hasOverflow,\n registerItem,\n updateOverflow,\n }}\n >\n {clonedChild}\n </OverflowContext.Provider>\n );\n});\n"],"sourceRoot":"../src/"}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { OverflowItemProps } from './OverflowItem.types';
|
3
|
+
/**
|
4
|
+
* Attaches overflow item behavior to its child registered with the OverflowContext.
|
5
|
+
* It does not render an element of its own.
|
6
|
+
*/
|
7
|
+
export declare const OverflowItem: React.ForwardRefExoticComponent<OverflowItemProps & React.RefAttributes<unknown>>;
|
@@ -0,0 +1,31 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.OverflowItem = void 0;
|
7
|
+
|
8
|
+
const React = /*#__PURE__*/require("react");
|
9
|
+
|
10
|
+
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
11
|
+
|
12
|
+
const useOverflowItem_1 = /*#__PURE__*/require("../../useOverflowItem");
|
13
|
+
/**
|
14
|
+
* Attaches overflow item behavior to its child registered with the OverflowContext.
|
15
|
+
* It does not render an element of its own.
|
16
|
+
*/
|
17
|
+
|
18
|
+
|
19
|
+
exports.OverflowItem = /*#__PURE__*/React.forwardRef((props, ref) => {
|
20
|
+
const {
|
21
|
+
id,
|
22
|
+
groupId,
|
23
|
+
priority,
|
24
|
+
children
|
25
|
+
} = props;
|
26
|
+
const containerRef = useOverflowItem_1.useOverflowItem(id, priority, groupId);
|
27
|
+
return react_utilities_1.applyTriggerPropsToChildren(children, {
|
28
|
+
ref: react_utilities_1.useMergedRefs(containerRef, ref)
|
29
|
+
});
|
30
|
+
});
|
31
|
+
//# sourceMappingURL=OverflowItem.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["components/OverflowItem/OverflowItem.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,uBAAA,CAAA;AAGA;;;AAGG;;;AACU,OAAA,CAAA,YAAA,gBAAe,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAA2B,GAA3B,KAAkC;AAC7E,QAAM;AAAE,IAAA,EAAF;AAAM,IAAA,OAAN;AAAe,IAAA,QAAf;AAAyB,IAAA;AAAzB,MAAsC,KAA5C;AAEA,QAAM,YAAY,GAAG,iBAAA,CAAA,eAAA,CAAgB,EAAhB,EAAoB,QAApB,EAA8B,OAA9B,CAArB;AACA,SAAO,iBAAA,CAAA,2BAAA,CAA4B,QAA5B,EAAsC;AAC3C,IAAA,GAAG,EAAE,iBAAA,CAAA,aAAA,CAAc,YAAd,EAA4B,GAA5B;AADsC,GAAtC,CAAP;AAGD,CAP2B,CAAf","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"],"sourceRoot":"../src/"}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
/**
|
3
|
+
* OverflowItemProps
|
4
|
+
*/
|
5
|
+
export declare type OverflowItemProps = {
|
6
|
+
/**
|
7
|
+
* The unique identifier for the item used by the overflow manager.
|
8
|
+
*/
|
9
|
+
id: string;
|
10
|
+
/**
|
11
|
+
* Assigns the item to a group, group visibility can be watched.
|
12
|
+
*/
|
13
|
+
groupId?: string;
|
14
|
+
/**
|
15
|
+
* A higher priority means the item overflows later.
|
16
|
+
*/
|
17
|
+
priority?: number;
|
18
|
+
/**
|
19
|
+
* The single child that has overflow item behavior attached.
|
20
|
+
*/
|
21
|
+
children: React.ReactElement;
|
22
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":"../src/"}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.OverflowItem = void 0;
|
7
|
+
|
8
|
+
var OverflowItem_1 = /*#__PURE__*/require("./OverflowItem");
|
9
|
+
|
10
|
+
Object.defineProperty(exports, "OverflowItem", {
|
11
|
+
enumerable: true,
|
12
|
+
get: function () {
|
13
|
+
return OverflowItem_1.OverflowItem;
|
14
|
+
}
|
15
|
+
});
|
16
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["components/OverflowItem/index.ts"],"names":[],"mappings":";;;;;;;AACA,IAAA,cAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,cAAA,EAAA;AAAA,EAAA,UAAA,EAAA,IAAA;AAAA,EAAA,GAAA,EAAA,YAAA;AAAA,WAAA,cAAA,CAAA,YAAA;AAAY;AAAZ,CAAA","sourcesContent":["export type { OverflowItemProps } from './OverflowItem.types';\nexport { OverflowItem } from './OverflowItem';\n"],"sourceRoot":"../src/"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.DATA_OVERFLOW_MENU = exports.DATA_OVERFLOW_ITEM = exports.DATA_OVERFLOWING = void 0;
|
7
|
+
exports.DATA_OVERFLOWING = 'data-overflowing';
|
8
|
+
exports.DATA_OVERFLOW_ITEM = 'data-overflow-item';
|
9
|
+
exports.DATA_OVERFLOW_MENU = 'data-overflow-menu';
|
10
|
+
//# sourceMappingURL=constants.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["constants.ts"],"names":[],"mappings":";;;;;;AAAa,OAAA,CAAA,gBAAA,GAAmB,kBAAnB;AACA,OAAA,CAAA,kBAAA,GAAqB,oBAArB;AACA,OAAA,CAAA,kBAAA,GAAqB,oBAArB","sourcesContent":["export const DATA_OVERFLOWING = 'data-overflowing';\nexport const DATA_OVERFLOW_ITEM = 'data-overflow-item';\nexport const DATA_OVERFLOW_MENU = 'data-overflow-menu';\n"],"sourceRoot":"../src/"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
export { Overflow } from './components/Overflow';
|
2
|
+
export type { OverflowProps } from './components/Overflow';
|
3
|
+
export { DATA_OVERFLOWING, DATA_OVERFLOW_ITEM, DATA_OVERFLOW_MENU } from './constants';
|
4
|
+
export type { UseOverflowContainerReturn } from './types';
|
5
|
+
export { useIsOverflowGroupVisible } from './useIsOverflowGroupVisible';
|
6
|
+
export { useIsOverflowItemVisible } from './useIsOverflowItemVisible';
|
7
|
+
export { updateVisibilityAttribute, useOverflowContainer } from './useOverflowContainer';
|
8
|
+
export { useOverflowCount } from './useOverflowCount';
|
9
|
+
export { useOverflowItem } from './useOverflowItem';
|
10
|
+
export { useOverflowMenu } from './useOverflowMenu';
|
11
|
+
export type { OverflowItemProps } from './components/OverflowItem/OverflowItem.types';
|
12
|
+
export { OverflowItem } from './components/OverflowItem/OverflowItem';
|