@fluentui/react-overflow 0.0.0-nightly-20230501-0418.1 → 0.0.0-nightly-20230503-0419.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.json CHANGED
@@ -2,9 +2,9 @@
2
2
  "name": "@fluentui/react-overflow",
3
3
  "entries": [
4
4
  {
5
- "date": "Mon, 01 May 2023 04:24:00 GMT",
6
- "tag": "@fluentui/react-overflow_v0.0.0-nightly-20230501-0418.1",
7
- "version": "0.0.0-nightly-20230501-0418.1",
5
+ "date": "Wed, 03 May 2023 04:25:39 GMT",
6
+ "tag": "@fluentui/react-overflow_v0.0.0-nightly-20230503-0419.1",
7
+ "version": "0.0.0-nightly-20230503-0419.1",
8
8
  "comments": {
9
9
  "prerelease": [
10
10
  {
@@ -16,26 +16,26 @@
16
16
  {
17
17
  "author": "beachball",
18
18
  "package": "@fluentui/react-overflow",
19
- "comment": "Bump @fluentui/priority-overflow to v0.0.0-nightly-20230501-0418.1",
20
- "commit": "ec7f7770aa9dd65ad47721639ad0c5d238d9e037"
19
+ "comment": "Bump @fluentui/priority-overflow to v0.0.0-nightly-20230503-0419.1",
20
+ "commit": "a9a6cef152f4c3885a3697ddf9ded12bfce5a2be"
21
21
  },
22
22
  {
23
23
  "author": "beachball",
24
24
  "package": "@fluentui/react-overflow",
25
- "comment": "Bump @fluentui/react-context-selector to v0.0.0-nightly-20230501-0418.1",
26
- "commit": "ec7f7770aa9dd65ad47721639ad0c5d238d9e037"
25
+ "comment": "Bump @fluentui/react-context-selector to v0.0.0-nightly-20230503-0419.1",
26
+ "commit": "a9a6cef152f4c3885a3697ddf9ded12bfce5a2be"
27
27
  },
28
28
  {
29
29
  "author": "beachball",
30
30
  "package": "@fluentui/react-overflow",
31
- "comment": "Bump @fluentui/react-theme to v0.0.0-nightly-20230501-0418.1",
32
- "commit": "ec7f7770aa9dd65ad47721639ad0c5d238d9e037"
31
+ "comment": "Bump @fluentui/react-theme to v0.0.0-nightly-20230503-0419.1",
32
+ "commit": "a9a6cef152f4c3885a3697ddf9ded12bfce5a2be"
33
33
  },
34
34
  {
35
35
  "author": "beachball",
36
36
  "package": "@fluentui/react-overflow",
37
- "comment": "Bump @fluentui/react-utilities to v0.0.0-nightly-20230501-0418.1",
38
- "commit": "ec7f7770aa9dd65ad47721639ad0c5d238d9e037"
37
+ "comment": "Bump @fluentui/react-utilities to v0.0.0-nightly-20230503-0419.1",
38
+ "commit": "a9a6cef152f4c3885a3697ddf9ded12bfce5a2be"
39
39
  }
40
40
  ]
41
41
  }
package/CHANGELOG.md CHANGED
@@ -1,21 +1,21 @@
1
1
  # Change Log - @fluentui/react-overflow
2
2
 
3
- This log was last generated on Mon, 01 May 2023 04:24:00 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 03 May 2023 04:25:39 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## [0.0.0-nightly-20230501-0418.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-overflow_v0.0.0-nightly-20230501-0418.1)
7
+ ## [0.0.0-nightly-20230503-0419.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-overflow_v0.0.0-nightly-20230503-0419.1)
8
8
 
9
- Mon, 01 May 2023 04:24:00 GMT
10
- [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-overflow_v9.0.15..@fluentui/react-overflow_v0.0.0-nightly-20230501-0418.1)
9
+ Wed, 03 May 2023 04:25:39 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-overflow_v9.0.15..@fluentui/react-overflow_v0.0.0-nightly-20230503-0419.1)
11
11
 
12
12
  ### Changes
13
13
 
14
14
  - Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/not available) by fluentui-internal@service.microsoft.com)
15
- - Bump @fluentui/priority-overflow to v0.0.0-nightly-20230501-0418.1 ([commit](https://github.com/microsoft/fluentui/commit/ec7f7770aa9dd65ad47721639ad0c5d238d9e037) by beachball)
16
- - Bump @fluentui/react-context-selector to v0.0.0-nightly-20230501-0418.1 ([commit](https://github.com/microsoft/fluentui/commit/ec7f7770aa9dd65ad47721639ad0c5d238d9e037) by beachball)
17
- - Bump @fluentui/react-theme to v0.0.0-nightly-20230501-0418.1 ([commit](https://github.com/microsoft/fluentui/commit/ec7f7770aa9dd65ad47721639ad0c5d238d9e037) by beachball)
18
- - Bump @fluentui/react-utilities to v0.0.0-nightly-20230501-0418.1 ([commit](https://github.com/microsoft/fluentui/commit/ec7f7770aa9dd65ad47721639ad0c5d238d9e037) by beachball)
15
+ - Bump @fluentui/priority-overflow to v0.0.0-nightly-20230503-0419.1 ([commit](https://github.com/microsoft/fluentui/commit/a9a6cef152f4c3885a3697ddf9ded12bfce5a2be) by beachball)
16
+ - Bump @fluentui/react-context-selector to v0.0.0-nightly-20230503-0419.1 ([commit](https://github.com/microsoft/fluentui/commit/a9a6cef152f4c3885a3697ddf9ded12bfce5a2be) by beachball)
17
+ - Bump @fluentui/react-theme to v0.0.0-nightly-20230503-0419.1 ([commit](https://github.com/microsoft/fluentui/commit/a9a6cef152f4c3885a3697ddf9ded12bfce5a2be) by beachball)
18
+ - Bump @fluentui/react-utilities to v0.0.0-nightly-20230503-0419.1 ([commit](https://github.com/microsoft/fluentui/commit/a9a6cef152f4c3885a3697ddf9ded12bfce5a2be) by beachball)
19
19
 
20
20
  ## [9.0.15](https://github.com/microsoft/fluentui/tree/@fluentui/react-overflow_v9.0.15)
21
21
 
@@ -0,0 +1,124 @@
1
+ import { ContextSelector } from '@fluentui/react-context-selector';
2
+ import type { ObserveOptions } from '@fluentui/priority-overflow';
3
+ import type { OnUpdateOverflow } from '@fluentui/priority-overflow';
4
+ import { OverflowGroupState } from '@fluentui/priority-overflow';
5
+ import type { OverflowItemEntry } from '@fluentui/priority-overflow';
6
+ import * as React_2 from 'react';
7
+
8
+ export declare const DATA_OVERFLOW_ITEM = "data-overflow-item";
9
+
10
+ export declare const DATA_OVERFLOW_MENU = "data-overflow-menu";
11
+
12
+ export declare const DATA_OVERFLOWING = "data-overflowing";
13
+
14
+ /**
15
+ * Provides an OverflowContext for OverflowItem descendants.
16
+ */
17
+ export declare const Overflow: React_2.ForwardRefExoticComponent<Partial<Pick<ObserveOptions, "padding" | "overflowDirection" | "overflowAxis" | "minimumVisible">> & {
18
+ children: React_2.ReactElement;
19
+ } & React_2.RefAttributes<unknown>>;
20
+
21
+ /**
22
+ * @internal
23
+ */
24
+ declare interface OverflowContextValue {
25
+ itemVisibility: Record<string, boolean>;
26
+ groupVisibility: Record<string, OverflowGroupState>;
27
+ hasOverflow: boolean;
28
+ registerItem: (item: OverflowItemEntry) => () => void;
29
+ registerOverflowMenu: (el: HTMLElement) => () => void;
30
+ updateOverflow: (padding?: number) => void;
31
+ }
32
+
33
+ /**
34
+ * Attaches overflow item behavior to its child registered with the OverflowContext.
35
+ * It does not render an element of its own.
36
+ */
37
+ export declare const OverflowItem: React_2.ForwardRefExoticComponent<OverflowItemProps & React_2.RefAttributes<unknown>>;
38
+
39
+ /**
40
+ * OverflowItemProps
41
+ */
42
+ export declare type OverflowItemProps = {
43
+ /**
44
+ * The unique identifier for the item used by the overflow manager.
45
+ */
46
+ id: string;
47
+ /**
48
+ * Assigns the item to a group, group visibility can be watched.
49
+ */
50
+ groupId?: string;
51
+ /**
52
+ * A higher priority means the item overflows later.
53
+ */
54
+ priority?: number;
55
+ /**
56
+ * The single child that has overflow item behavior attached.
57
+ */
58
+ children: React_2.ReactElement;
59
+ };
60
+
61
+ /**
62
+ * Overflow Props
63
+ */
64
+ export declare type OverflowProps = Partial<Pick<ObserveOptions, 'overflowAxis' | 'overflowDirection' | 'padding' | 'minimumVisible'>> & {
65
+ children: React_2.ReactElement;
66
+ };
67
+
68
+ /**
69
+ * @param id - unique identifier for a group of overflow items
70
+ * @returns visibility state of the group
71
+ */
72
+ export declare function useIsOverflowGroupVisible(id: string): OverflowGroupState;
73
+
74
+ /**
75
+ * @param id - unique identifier for the item used by the overflow manager
76
+ * @returns visibility state of an overflow item
77
+ */
78
+ export declare function useIsOverflowItemVisible(id: string): boolean;
79
+
80
+ /**
81
+ * @internal
82
+ * @param update - Callback when overflow state changes
83
+ * @param options - Options to configure the overflow container
84
+ * @returns - ref to attach to an intrinsic HTML element and imperative functions
85
+ */
86
+ export declare const useOverflowContainer: <TElement extends HTMLElement>(update: OnUpdateOverflow, options: Omit<ObserveOptions, 'onUpdateOverflow'>) => UseOverflowContainerReturn<TElement>;
87
+
88
+ /**
89
+ * @internal
90
+ */
91
+ export declare interface UseOverflowContainerReturn<TElement extends HTMLElement> extends Pick<OverflowContextValue, 'registerItem' | 'updateOverflow' | 'registerOverflowMenu'> {
92
+ /**
93
+ * Ref to apply to the container that will overflow
94
+ */
95
+ containerRef: React_2.RefObject<TElement>;
96
+ }
97
+
98
+ /**
99
+ * @internal
100
+ */
101
+ export declare const useOverflowContext: <SelectedValue>(selector: ContextSelector<OverflowContextValue, SelectedValue>) => SelectedValue;
102
+
103
+ /**
104
+ * @returns Number of items that are overflowing
105
+ */
106
+ export declare const useOverflowCount: () => number;
107
+
108
+ /**
109
+ * @internal
110
+ * Registers an overflow item
111
+ * @param id - unique identifier for the item used by the overflow manager
112
+ * @param priority - higher priority means the item overflows later
113
+ * @param groupId - assigns the item to a group, group visibility can be watched
114
+ * @returns ref to assign to an intrinsic HTML element
115
+ */
116
+ export declare function useOverflowItem<TElement extends HTMLElement>(id: string, priority?: number, groupId?: string): React_2.RefObject<TElement>;
117
+
118
+ export declare function useOverflowMenu<TElement extends HTMLElement>(id?: string): {
119
+ ref: React_2.RefObject<TElement>;
120
+ overflowCount: number;
121
+ isOverflowing: boolean;
122
+ };
123
+
124
+ export { }
@@ -0,0 +1,61 @@
1
+ import * as React from 'react';
2
+ import { mergeClasses } from '@griffel/react';
3
+ import { applyTriggerPropsToChildren, useMergedRefs } from '@fluentui/react-utilities';
4
+ import { OverflowContext } from '../overflowContext';
5
+ import { updateVisibilityAttribute, useOverflowContainer } from '../useOverflowContainer';
6
+ import { useOverflowStyles } from './useOverflowStyles.styles';
7
+ /**
8
+ * Provides an OverflowContext for OverflowItem descendants.
9
+ */
10
+ export const Overflow = /*#__PURE__*/React.forwardRef((props, ref) => {
11
+ const styles = useOverflowStyles();
12
+ const {
13
+ children,
14
+ minimumVisible,
15
+ overflowAxis = 'horizontal',
16
+ overflowDirection,
17
+ padding
18
+ } = props;
19
+ const [hasOverflow, setHasOverflow] = React.useState(false);
20
+ const [itemVisibility, setItemVisibility] = React.useState({});
21
+ const [groupVisibility, setGroupVisibility] = React.useState({});
22
+ // useOverflowContainer wraps this method in a useEventCallback.
23
+ // TODO: Do we need a useEventCallback here too?
24
+ const update = data => {
25
+ setHasOverflow(() => data.invisibleItems.length > 0);
26
+ setItemVisibility(() => {
27
+ const newState = {};
28
+ data.visibleItems.forEach(x => newState[x.id] = true);
29
+ data.invisibleItems.forEach(x => newState[x.id] = false);
30
+ return newState;
31
+ });
32
+ setGroupVisibility(data.groupVisibility);
33
+ };
34
+ const {
35
+ containerRef,
36
+ registerItem,
37
+ updateOverflow,
38
+ registerOverflowMenu
39
+ } = useOverflowContainer(update, {
40
+ overflowDirection,
41
+ overflowAxis,
42
+ padding,
43
+ minimumVisible,
44
+ onUpdateItemVisibility: updateVisibilityAttribute
45
+ });
46
+ const clonedChild = applyTriggerPropsToChildren(children, {
47
+ ref: useMergedRefs(containerRef, ref),
48
+ className: mergeClasses(styles.overflowMenu, styles.overflowingItems, children.props.className)
49
+ });
50
+ return /*#__PURE__*/React.createElement(OverflowContext.Provider, {
51
+ value: {
52
+ itemVisibility,
53
+ groupVisibility,
54
+ hasOverflow,
55
+ registerItem,
56
+ updateOverflow,
57
+ registerOverflowMenu
58
+ }
59
+ }, clonedChild);
60
+ });
61
+ //# sourceMappingURL=Overflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","mergeClasses","applyTriggerPropsToChildren","useMergedRefs","OverflowContext","updateVisibilityAttribute","useOverflowContainer","useOverflowStyles","Overflow","forwardRef","props","ref","styles","children","minimumVisible","overflowAxis","overflowDirection","padding","hasOverflow","setHasOverflow","useState","itemVisibility","setItemVisibility","groupVisibility","setGroupVisibility","update","data","invisibleItems","length","newState","visibleItems","forEach","x","id","containerRef","registerItem","updateOverflow","registerOverflowMenu","onUpdateItemVisibility","clonedChild","className","overflowMenu","overflowingItems","createElement","Provider","value"],"sources":["../../src/components/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\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 [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, 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,\n groupVisibility,\n hasOverflow,\n registerItem,\n updateOverflow,\n registerOverflowMenu,\n }}\n >\n {clonedChild}\n </OverflowContext.Provider>\n );\n});\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,YAAY,QAAQ;AAE7B,SAASC,2BAA2B,EAAEC,aAAa,QAAQ;AAE3D,SAASC,eAAe,QAAQ;AAChC,SAASC,yBAAyB,EAAEC,oBAAoB,QAAQ;AAChE,SAASC,iBAAiB,QAAQ;AAWlC;;;AAGA,OAAO,MAAMC,QAAA,gBAAWR,KAAA,CAAMS,UAAU,CAAC,CAACC,KAAA,EAAsBC,GAAA,KAAQ;EACtE,MAAMC,MAAA,GAASL,iBAAA;EAEf,MAAM;IAAEM,QAAA;IAAUC,cAAA;IAAgBC,YAAA,GAAe;IAAcC,iBAAA;IAAmBC;EAAO,CAAE,GAAGP,KAAA;EAE9F,MAAM,CAACQ,WAAA,EAAaC,cAAA,CAAe,GAAGnB,KAAA,CAAMoB,QAAQ,CAAC,KAAK;EAC1D,MAAM,CAACC,cAAA,EAAgBC,iBAAA,CAAkB,GAAGtB,KAAA,CAAMoB,QAAQ,CAA0B,CAAC;EACrF,MAAM,CAACG,eAAA,EAAiBC,kBAAA,CAAmB,GAAGxB,KAAA,CAAMoB,QAAQ,CAAqC,CAAC;EAElG;EACA;EACA,MAAMK,MAAA,GAA2BC,IAAA,IAAQ;IACvCP,cAAA,CAAe,MAAMO,IAAA,CAAKC,cAAc,CAACC,MAAM,GAAG;IAClDN,iBAAA,CAAkB,MAAM;MACtB,MAAMO,QAAA,GAAoC,CAAC;MAC3CH,IAAA,CAAKI,YAAY,CAACC,OAAO,CAACC,CAAA,IAAMH,QAAQ,CAACG,CAAA,CAAEC,EAAE,CAAC,GAAG,IAAI;MACrDP,IAAA,CAAKC,cAAc,CAACI,OAAO,CAACC,CAAA,IAAMH,QAAQ,CAACG,CAAA,CAAEC,EAAE,CAAC,GAAG,KAAK;MACxD,OAAOJ,QAAA;IACT;IACAL,kBAAA,CAAmBE,IAAA,CAAKH,eAAe;EACzC;EAEA,MAAM;IAAEW,YAAA;IAAcC,YAAA;IAAcC,cAAA;IAAgBC;EAAoB,CAAE,GAAG/B,oBAAA,CAAqBmB,MAAA,EAAQ;IACxGT,iBAAA;IACAD,YAAA;IACAE,OAAA;IACAH,cAAA;IACAwB,sBAAA,EAAwBjC;EAC1B;EAEA,MAAMkC,WAAA,GAAcrC,2BAAA,CAA4BW,QAAA,EAAU;IACxDF,GAAA,EAAKR,aAAA,CAAc+B,YAAA,EAAcvB,GAAA;IACjC6B,SAAA,EAAWvC,YAAA,CAAaW,MAAA,CAAO6B,YAAY,EAAE7B,MAAA,CAAO8B,gBAAgB,EAAE7B,QAAA,CAASH,KAAK,CAAC8B,SAAS;EAChG;EAEA,oBACExC,KAAA,CAAA2C,aAAA,CAACvC,eAAA,CAAgBwC,QAAQ;IACvBC,KAAA,EAAO;MACLxB,cAAA;MACAE,eAAA;MACAL,WAAA;MACAiB,YAAA;MACAC,cAAA;MACAC;IACF;KAECE,WAAA;AAGP"}
@@ -0,0 +1,20 @@
1
+ import * as React from 'react';
2
+ import { applyTriggerPropsToChildren, useMergedRefs } from '@fluentui/react-utilities';
3
+ import { useOverflowItem } from '../../useOverflowItem';
4
+ /**
5
+ * Attaches overflow item behavior to its child registered with the OverflowContext.
6
+ * It does not render an element of its own.
7
+ */
8
+ export const OverflowItem = /*#__PURE__*/React.forwardRef((props, ref) => {
9
+ const {
10
+ id,
11
+ groupId,
12
+ priority,
13
+ children
14
+ } = props;
15
+ const containerRef = useOverflowItem(id, priority, groupId);
16
+ return applyTriggerPropsToChildren(children, {
17
+ ref: useMergedRefs(containerRef, ref)
18
+ });
19
+ });
20
+ //# sourceMappingURL=OverflowItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","applyTriggerPropsToChildren","useMergedRefs","useOverflowItem","OverflowItem","forwardRef","props","ref","id","groupId","priority","children","containerRef"],"sources":["../../../src/components/OverflowItem/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"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,2BAA2B,EAAEC,aAAa,QAAQ;AAC3D,SAASC,eAAe,QAAQ;AAGhC;;;;AAIA,OAAO,MAAMC,YAAA,gBAAeJ,KAAA,CAAMK,UAAU,CAAC,CAACC,KAAA,EAA0BC,GAAA,KAAQ;EAC9E,MAAM;IAAEC,EAAA;IAAIC,OAAA;IAASC,QAAA;IAAUC;EAAQ,CAAE,GAAGL,KAAA;EAE5C,MAAMM,YAAA,GAAeT,eAAA,CAAgBK,EAAA,EAAIE,QAAA,EAAUD,OAAA;EACnD,OAAOR,2BAAA,CAA4BU,QAAA,EAAU;IAC3CJ,GAAA,EAAKL,aAAA,CAAcU,YAAA,EAAcL,GAAA;EACnC;AACF"}
@@ -0,0 +1,2 @@
1
+ import * as React from 'react';
2
+ //# sourceMappingURL=OverflowItem.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React"],"sources":["../../../src/components/OverflowItem/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"],"mappings":"AAAA,YAAYA,KAAA,MAAW"}
@@ -0,0 +1,2 @@
1
+ export { OverflowItem } from './OverflowItem';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["OverflowItem"],"sources":["../../../src/components/OverflowItem/index.ts"],"sourcesContent":["export type { OverflowItemProps } from './OverflowItem.types';\nexport { OverflowItem } from './OverflowItem';\n"],"mappings":"AACA,SAASA,YAAY,QAAQ"}
@@ -0,0 +1,13 @@
1
+ import { __styles } from '@griffel/react';
2
+ import { DATA_OVERFLOWING, DATA_OVERFLOW_MENU } from '../constants';
3
+ export const useOverflowStyles = /*#__PURE__*/__styles({
4
+ overflowMenu: {
5
+ Brvla84: "fyfkpbf"
6
+ },
7
+ overflowingItems: {
8
+ zb22lx: "f10570jf"
9
+ }
10
+ }, {
11
+ d: [".fyfkpbf [data-overflow-menu]{-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;}", ".f10570jf [data-overflowing]{display:none;}"]
12
+ });
13
+ //# sourceMappingURL=useOverflowStyles.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__styles","DATA_OVERFLOWING","DATA_OVERFLOW_MENU","useOverflowStyles","overflowMenu","Brvla84","overflowingItems","zb22lx","d"],"sources":["../../src/components/useOverflowStyles.styles.ts"],"sourcesContent":["import { makeStyles } from '@griffel/react';\nimport { DATA_OVERFLOWING, DATA_OVERFLOW_MENU } from '../constants';\n\nexport const useOverflowStyles = makeStyles({\n overflowMenu: {\n [`& [${DATA_OVERFLOW_MENU}]`]: {\n flexShrink: 0,\n },\n },\n\n overflowingItems: {\n [`& [${DATA_OVERFLOWING}]`]: {\n display: 'none',\n },\n },\n});\n"],"mappings":"AAAA,SAAAA,QAAA,QAA2B;AAC3B,SAASC,gBAAgB,EAAEC,kBAAkB,QAAQ;AAErD,OAAO,MAAMC,iBAAA,gBAAoBH,QAAA;EAAAI,YAAA;IAAAC,OAAA;EAAA;EAAAC,gBAAA;IAAAC,MAAA;EAAA;AAAA;EAAAC,CAAA;AAAA,EAYjC"}
@@ -0,0 +1,4 @@
1
+ export const DATA_OVERFLOWING = 'data-overflowing';
2
+ export const DATA_OVERFLOW_ITEM = 'data-overflow-item';
3
+ export const DATA_OVERFLOW_MENU = 'data-overflow-menu';
4
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["DATA_OVERFLOWING","DATA_OVERFLOW_ITEM","DATA_OVERFLOW_MENU"],"sources":["../src/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"],"mappings":"AAAA,OAAO,MAAMA,gBAAA,GAAmB;AAChC,OAAO,MAAMC,kBAAA,GAAqB;AAClC,OAAO,MAAMC,kBAAA,GAAqB"}
package/lib/index.js ADDED
@@ -0,0 +1,11 @@
1
+ export { Overflow } from './components/Overflow';
2
+ export { DATA_OVERFLOWING, DATA_OVERFLOW_ITEM, DATA_OVERFLOW_MENU } from './constants';
3
+ export { useIsOverflowGroupVisible } from './useIsOverflowGroupVisible';
4
+ export { useIsOverflowItemVisible } from './useIsOverflowItemVisible';
5
+ export { useOverflowContainer } from './useOverflowContainer';
6
+ export { useOverflowCount } from './useOverflowCount';
7
+ export { useOverflowItem } from './useOverflowItem';
8
+ export { useOverflowMenu } from './useOverflowMenu';
9
+ export { useOverflowContext } from './overflowContext';
10
+ export { OverflowItem } from './components/OverflowItem/OverflowItem';
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Overflow","DATA_OVERFLOWING","DATA_OVERFLOW_ITEM","DATA_OVERFLOW_MENU","useIsOverflowGroupVisible","useIsOverflowItemVisible","useOverflowContainer","useOverflowCount","useOverflowItem","useOverflowMenu","useOverflowContext","OverflowItem"],"sources":["../src/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"],"mappings":"AAAA,SAASA,QAAQ,QAAQ;AAEzB,SAASC,gBAAgB,EAAEC,kBAAkB,EAAEC,kBAAkB,QAAQ;AAEzE,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,wBAAwB,QAAQ;AACzC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,eAAe,QAAQ;AAChC,SAASC,eAAe,QAAQ;AAEhC,SAASC,kBAAkB,QAAQ;AAGnC,SAASC,YAAY,QAAQ"}
@@ -0,0 +1,15 @@
1
+ import { createContext, useContextSelector } from '@fluentui/react-context-selector';
2
+ export const OverflowContext = /*#__PURE__*/createContext(undefined);
3
+ const overflowContextDefaultValue = {
4
+ itemVisibility: {},
5
+ groupVisibility: {},
6
+ hasOverflow: false,
7
+ registerItem: () => () => null,
8
+ updateOverflow: () => null,
9
+ registerOverflowMenu: () => () => null
10
+ };
11
+ /**
12
+ * @internal
13
+ */
14
+ export const useOverflowContext = selector => useContextSelector(OverflowContext, (ctx = overflowContextDefaultValue) => selector(ctx));
15
+ //# sourceMappingURL=overflowContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createContext","useContextSelector","OverflowContext","undefined","overflowContextDefaultValue","itemVisibility","groupVisibility","hasOverflow","registerItem","updateOverflow","registerOverflowMenu","useOverflowContext","selector","ctx"],"sources":["../src/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"],"mappings":"AACA,SAA0BA,aAAa,EAAEC,kBAAkB,QAAiB;AAc5E,OAAO,MAAMC,eAAA,gBAAkBF,aAAA,CAC7BG,SAAA;AAGF,MAAMC,2BAAA,GAAoD;EACxDC,cAAA,EAAgB,CAAC;EACjBC,eAAA,EAAiB,CAAC;EAClBC,WAAA,EAAa,KAAK;EAClBC,YAAA,EAAcA,CAAA,KAAM,MAAM,IAAI;EAC9BC,cAAA,EAAgBA,CAAA,KAAM,IAAI;EAC1BC,oBAAA,EAAsBA,CAAA,KAAM,MAAM;AACpC;AAEA;;;AAGA,OAAO,MAAMC,kBAAA,GAAqCC,QAAA,IAChDX,kBAAA,CAAmBC,eAAA,EAAiB,CAACW,GAAA,GAAMT,2BAA2B,KAAKQ,QAAA,CAASC,GAAA"}
package/lib/types.js ADDED
@@ -0,0 +1,2 @@
1
+ import * as React from 'react';
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React"],"sources":["../src/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"],"mappings":"AAAA,YAAYA,KAAA,MAAW"}
@@ -0,0 +1,9 @@
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
+ export function useIsOverflowGroupVisible(id) {
7
+ return useOverflowContext(ctx => ctx.groupVisibility[id]);
8
+ }
9
+ //# sourceMappingURL=useIsOverflowGroupVisible.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useOverflowContext","useIsOverflowGroupVisible","id","ctx","groupVisibility"],"sources":["../src/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"],"mappings":"AACA,SAASA,kBAAkB,QAAQ;AAEnC;;;;AAIA,OAAO,SAASC,0BAA0BC,EAAU,EAAsB;EACxE,OAAOF,kBAAA,CAAmBG,GAAA,IAAOA,GAAA,CAAIC,eAAe,CAACF,EAAA,CAAG;AAC1D"}
@@ -0,0 +1,9 @@
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
+ export function useIsOverflowItemVisible(id) {
7
+ return !!useOverflowContext(ctx => ctx.itemVisibility[id]);
8
+ }
9
+ //# sourceMappingURL=useIsOverflowItemVisible.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useOverflowContext","useIsOverflowItemVisible","id","ctx","itemVisibility"],"sources":["../src/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"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ;AAEnC;;;;AAIA,OAAO,SAASC,yBAAyBC,EAAU,EAAW;EAC5D,OAAO,CAAC,CAACF,kBAAA,CAAmBG,GAAA,IAAOA,GAAA,CAAIC,cAAc,CAACF,EAAA,CAAG;AAC3D"}
@@ -0,0 +1,78 @@
1
+ import * as React from 'react';
2
+ import { createOverflowManager } from '@fluentui/priority-overflow';
3
+ import { canUseDOM, useEventCallback, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
4
+ import { DATA_OVERFLOWING, DATA_OVERFLOW_ITEM, DATA_OVERFLOW_MENU } from './constants';
5
+ /**
6
+ * @internal
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
+ export const useOverflowContainer = (update, options) => {
12
+ const {
13
+ overflowAxis,
14
+ overflowDirection,
15
+ padding,
16
+ minimumVisible,
17
+ onUpdateItemVisibility
18
+ } = options;
19
+ // DOM ref to the overflow container element
20
+ const containerRef = React.useRef(null);
21
+ const updateOverflowItems = useEventCallback(update);
22
+ const [overflowManager] = React.useState(() => canUseDOM() ? createOverflowManager() : null);
23
+ useIsomorphicLayoutEffect(() => {
24
+ if (!containerRef.current) {
25
+ return;
26
+ }
27
+ if (overflowManager) {
28
+ overflowManager.observe(containerRef.current, {
29
+ overflowDirection: overflowDirection !== null && overflowDirection !== void 0 ? overflowDirection : 'end',
30
+ overflowAxis: overflowAxis !== null && overflowAxis !== void 0 ? overflowAxis : 'horizontal',
31
+ padding: padding !== null && padding !== void 0 ? padding : 10,
32
+ minimumVisible: minimumVisible !== null && minimumVisible !== void 0 ? minimumVisible : 0,
33
+ onUpdateItemVisibility: onUpdateItemVisibility !== null && onUpdateItemVisibility !== void 0 ? onUpdateItemVisibility : () => undefined,
34
+ onUpdateOverflow: updateOverflowItems !== null && updateOverflowItems !== void 0 ? updateOverflowItems : () => undefined
35
+ });
36
+ return () => {
37
+ overflowManager.disconnect();
38
+ };
39
+ }
40
+ }, [updateOverflowItems, overflowManager, overflowDirection, overflowAxis, padding, minimumVisible, onUpdateItemVisibility]);
41
+ const registerItem = React.useCallback(item => {
42
+ overflowManager === null || overflowManager === void 0 ? void 0 : 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 === null || overflowManager === void 0 ? void 0 : overflowManager.removeItem(item.id);
48
+ };
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
+ };
68
+ export const updateVisibilityAttribute = ({
69
+ item,
70
+ visible
71
+ }) => {
72
+ if (visible) {
73
+ item.element.removeAttribute(DATA_OVERFLOWING);
74
+ } else {
75
+ item.element.setAttribute(DATA_OVERFLOWING, '');
76
+ }
77
+ };
78
+ //# sourceMappingURL=useOverflowContainer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","createOverflowManager","canUseDOM","useEventCallback","useIsomorphicLayoutEffect","DATA_OVERFLOWING","DATA_OVERFLOW_ITEM","DATA_OVERFLOW_MENU","useOverflowContainer","update","options","overflowAxis","overflowDirection","padding","minimumVisible","onUpdateItemVisibility","containerRef","useRef","updateOverflowItems","overflowManager","useState","current","observe","undefined","onUpdateOverflow","disconnect","registerItem","useCallback","item","addItem","element","setAttribute","removeAttribute","removeItem","id","updateOverflow","registerOverflowMenu","el","addOverflowMenu","removeOverflowMenu","updateVisibilityAttribute","visible"],"sources":["../src/useOverflowContainer.ts"],"sourcesContent":["import * as React from 'react';\nimport { createOverflowManager } from '@fluentui/priority-overflow';\n\n/**\n * @internal\n */\nimport type {\n OnUpdateItemVisibility,\n OnUpdateOverflow,\n OverflowItemEntry,\n OverflowManager,\n ObserveOptions,\n} from '@fluentui/priority-overflow';\nimport { canUseDOM, useEventCallback, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport { UseOverflowContainerReturn } from './types';\nimport { DATA_OVERFLOWING, 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<ObserveOptions, 'onUpdateOverflow'>,\n): UseOverflowContainerReturn<TElement> => {\n const { overflowAxis, overflowDirection, padding, minimumVisible, onUpdateItemVisibility } = options;\n\n // DOM ref to the overflow container element\n const containerRef = React.useRef<TElement>(null);\n const updateOverflowItems = useEventCallback(update);\n\n const [overflowManager] = React.useState<OverflowManager | null>(() =>\n canUseDOM() ? createOverflowManager() : null,\n );\n\n useIsomorphicLayoutEffect(() => {\n if (!containerRef.current) {\n return;\n }\n\n if (overflowManager) {\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 }, [\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 const registerOverflowMenu = React.useCallback(\n (el: HTMLElement) => {\n overflowManager?.addOverflowMenu(el);\n el.setAttribute(DATA_OVERFLOW_MENU, '');\n\n return () => {\n overflowManager?.removeOverflowMenu();\n el.removeAttribute(DATA_OVERFLOW_MENU);\n };\n },\n [overflowManager],\n );\n\n return {\n containerRef,\n registerItem,\n updateOverflow,\n registerOverflowMenu,\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"],"mappings":"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"}
@@ -0,0 +1,13 @@
1
+ import { useOverflowContext } from './overflowContext';
2
+ /**
3
+ * @returns Number of items that are overflowing
4
+ */
5
+ export const useOverflowCount = () => useOverflowContext(v => {
6
+ return Object.entries(v.itemVisibility).reduce((acc, [id, visible]) => {
7
+ if (!visible) {
8
+ acc++;
9
+ }
10
+ return acc;
11
+ }, 0);
12
+ });
13
+ //# sourceMappingURL=useOverflowCount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useOverflowContext","useOverflowCount","v","Object","entries","itemVisibility","reduce","acc","id","visible"],"sources":["../src/useOverflowCount.ts"],"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"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ;AAEnC;;;AAGA,OAAO,MAAMC,gBAAA,GAAmBA,CAAA,KAC9BD,kBAAA,CAAmBE,CAAA,IAAK;EACtB,OAAOC,MAAA,CAAOC,OAAO,CAACF,CAAA,CAAEG,cAAc,EAAEC,MAAM,CAAC,CAACC,GAAA,EAAK,CAACC,EAAA,EAAIC,OAAA,CAAQ,KAAK;IACrE,IAAI,CAACA,OAAA,EAAS;MACZF,GAAA;IACF;IAEA,OAAOA,GAAA;EACT,GAAG;AACL"}
@@ -0,0 +1,27 @@
1
+ import * as React from 'react';
2
+ import { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
3
+ import { useOverflowContext } from './overflowContext';
4
+ /**
5
+ * @internal
6
+ * Registers an overflow item
7
+ * @param id - unique identifier for the item used by the overflow manager
8
+ * @param priority - higher priority means the item overflows later
9
+ * @param groupId - assigns the item to a group, group visibility can be watched
10
+ * @returns ref to assign to an intrinsic HTML element
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,"names":["React","useIsomorphicLayoutEffect","useOverflowContext","useOverflowItem","id","priority","groupId","ref","useRef","registerItem","v","current","element"],"sources":["../src/useOverflowItem.ts"],"sourcesContent":["import * as React from 'react';\nimport { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport { useOverflowContext } from './overflowContext';\n\n/**\n * @internal\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"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,QAAQ;AAEnC;;;;;;;;AAQA,OAAO,SAASC,gBAA8CC,EAAU,EAAEC,QAAiB,EAAEC,OAAgB,EAAE;EAC7G,MAAMC,GAAA,GAAMP,KAAA,CAAMQ,MAAM,CAAW,IAAI;EACvC,MAAMC,YAAA,GAAeP,kBAAA,CAAmBQ,CAAA,IAAKA,CAAA,CAAED,YAAY;EAE3DR,yBAAA,CAA0B,MAAM;IAC9B,IAAIM,GAAA,CAAII,OAAO,EAAE;MACf,OAAOF,YAAA,CAAa;QAClBG,OAAA,EAASL,GAAA,CAAII,OAAO;QACpBP,EAAA;QACAC,QAAA,EAAUA,QAAA,aAAAA,QAAA,cAAAA,QAAA,GAAY,CAAC;QACvBC;MACF;IACF;EACF,GAAG,CAACF,EAAA,EAAIC,QAAA,EAAUI,YAAA,EAAcH,OAAA,CAAQ;EAExC,OAAOC,GAAA;AACT"}
@@ -0,0 +1,28 @@
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
+ export function useOverflowMenu(id) {
6
+ const elementId = useId('overflow-menu', id);
7
+ const overflowCount = useOverflowCount();
8
+ const registerOverflowMenu = useOverflowContext(v => v.registerOverflowMenu);
9
+ const updateOverflow = useOverflowContext(v => v.updateOverflow);
10
+ const ref = React.useRef(null);
11
+ const isOverflowing = overflowCount > 0;
12
+ useIsomorphicLayoutEffect(() => {
13
+ if (ref.current) {
14
+ return registerOverflowMenu(ref.current);
15
+ }
16
+ }, [registerOverflowMenu, isOverflowing, elementId]);
17
+ useIsomorphicLayoutEffect(() => {
18
+ if (isOverflowing) {
19
+ updateOverflow();
20
+ }
21
+ }, [isOverflowing, updateOverflow, ref]);
22
+ return {
23
+ ref,
24
+ overflowCount,
25
+ isOverflowing
26
+ };
27
+ }
28
+ //# sourceMappingURL=useOverflowMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useId","useIsomorphicLayoutEffect","useOverflowContext","useOverflowCount","useOverflowMenu","id","elementId","overflowCount","registerOverflowMenu","v","updateOverflow","ref","useRef","isOverflowing","current"],"sources":["../src/useOverflowMenu.ts"],"sourcesContent":["import * 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>(id?: string) {\n const elementId = useId('overflow-menu', id);\n const overflowCount = useOverflowCount();\n const registerOverflowMenu = useOverflowContext(v => v.registerOverflowMenu);\n const updateOverflow = useOverflowContext(v => v.updateOverflow);\n const ref = React.useRef<TElement>(null);\n const isOverflowing = overflowCount > 0;\n\n useIsomorphicLayoutEffect(() => {\n if (ref.current) {\n return registerOverflowMenu(ref.current);\n }\n }, [registerOverflowMenu, isOverflowing, elementId]);\n\n useIsomorphicLayoutEffect(() => {\n if (isOverflowing) {\n updateOverflow();\n }\n }, [isOverflowing, updateOverflow, ref]);\n\n return { ref, overflowCount, isOverflowing };\n}\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,KAAK,EAAEC,yBAAyB,QAAQ;AACjD,SAASC,kBAAkB,QAAQ;AACnC,SAASC,gBAAgB,QAAQ;AAEjC,OAAO,SAASC,gBAA8CC,EAAW,EAAE;EACzE,MAAMC,SAAA,GAAYN,KAAA,CAAM,iBAAiBK,EAAA;EACzC,MAAME,aAAA,GAAgBJ,gBAAA;EACtB,MAAMK,oBAAA,GAAuBN,kBAAA,CAAmBO,CAAA,IAAKA,CAAA,CAAED,oBAAoB;EAC3E,MAAME,cAAA,GAAiBR,kBAAA,CAAmBO,CAAA,IAAKA,CAAA,CAAEC,cAAc;EAC/D,MAAMC,GAAA,GAAMZ,KAAA,CAAMa,MAAM,CAAW,IAAI;EACvC,MAAMC,aAAA,GAAgBN,aAAA,GAAgB;EAEtCN,yBAAA,CAA0B,MAAM;IAC9B,IAAIU,GAAA,CAAIG,OAAO,EAAE;MACf,OAAON,oBAAA,CAAqBG,GAAA,CAAIG,OAAO;IACzC;EACF,GAAG,CAACN,oBAAA,EAAsBK,aAAA,EAAeP,SAAA,CAAU;EAEnDL,yBAAA,CAA0B,MAAM;IAC9B,IAAIY,aAAA,EAAe;MACjBH,cAAA;IACF;EACF,GAAG,CAACG,aAAA,EAAeH,cAAA,EAAgBC,GAAA,CAAI;EAEvC,OAAO;IAAEA,GAAA;IAAKJ,aAAA;IAAeM;EAAc;AAC7C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-overflow",
3
- "version": "0.0.0-nightly-20230501-0418.1",
3
+ "version": "0.0.0-nightly-20230503-0419.1",
4
4
  "description": "React bindings for @fluentui/priority-overflow",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -33,10 +33,10 @@
33
33
  "@fluentui/scripts-tasks": "*"
34
34
  },
35
35
  "dependencies": {
36
- "@fluentui/priority-overflow": "0.0.0-nightly-20230501-0418.1",
37
- "@fluentui/react-context-selector": "0.0.0-nightly-20230501-0418.1",
38
- "@fluentui/react-theme": "0.0.0-nightly-20230501-0418.1",
39
- "@fluentui/react-utilities": "0.0.0-nightly-20230501-0418.1",
36
+ "@fluentui/priority-overflow": "0.0.0-nightly-20230503-0419.1",
37
+ "@fluentui/react-context-selector": "0.0.0-nightly-20230503-0419.1",
38
+ "@fluentui/react-theme": "0.0.0-nightly-20230503-0419.1",
39
+ "@fluentui/react-utilities": "0.0.0-nightly-20230503-0419.1",
40
40
  "@griffel/react": "^1.5.2",
41
41
  "@swc/helpers": "^0.4.14"
42
42
  },