@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.
Files changed (91) hide show
  1. package/CHANGELOG.json +164 -0
  2. package/CHANGELOG.md +54 -0
  3. package/LICENSE +15 -0
  4. package/README.md +5 -0
  5. package/dist/index.d.ts +121 -0
  6. package/lib/components/Overflow.d.ts +14 -0
  7. package/lib/components/Overflow.js +73 -0
  8. package/lib/components/Overflow.js.map +1 -0
  9. package/lib/components/OverflowItem/OverflowItem.d.ts +7 -0
  10. package/lib/components/OverflowItem/OverflowItem.js +21 -0
  11. package/lib/components/OverflowItem/OverflowItem.js.map +1 -0
  12. package/lib/components/OverflowItem/OverflowItem.types.d.ts +22 -0
  13. package/lib/components/OverflowItem/OverflowItem.types.js +2 -0
  14. package/lib/components/OverflowItem/OverflowItem.types.js.map +1 -0
  15. package/lib/components/OverflowItem/index.d.ts +2 -0
  16. package/lib/components/OverflowItem/index.js +2 -0
  17. package/lib/components/OverflowItem/index.js.map +1 -0
  18. package/lib/constants.d.ts +3 -0
  19. package/lib/constants.js +4 -0
  20. package/lib/constants.js.map +1 -0
  21. package/lib/index.d.ts +12 -0
  22. package/lib/index.js +10 -0
  23. package/lib/index.js.map +1 -0
  24. package/lib/overflowContext.d.ts +11 -0
  25. package/lib/overflowContext.js +10 -0
  26. package/lib/overflowContext.js.map +1 -0
  27. package/lib/tsdoc-metadata.json +11 -0
  28. package/lib/types.d.ts +16 -0
  29. package/lib/types.js +2 -0
  30. package/lib/types.js.map +1 -0
  31. package/lib/useIsOverflowGroupVisible.d.ts +6 -0
  32. package/lib/useIsOverflowGroupVisible.js +10 -0
  33. package/lib/useIsOverflowGroupVisible.js.map +1 -0
  34. package/lib/useIsOverflowItemVisible.d.ts +5 -0
  35. package/lib/useIsOverflowItemVisible.js +10 -0
  36. package/lib/useIsOverflowItemVisible.js.map +1 -0
  37. package/lib/useOverflowContainer.d.ts +10 -0
  38. package/lib/useOverflowContainer.js +69 -0
  39. package/lib/useOverflowContainer.js.map +1 -0
  40. package/lib/useOverflowCount.d.ts +4 -0
  41. package/lib/useOverflowCount.js +15 -0
  42. package/lib/useOverflowCount.js.map +1 -0
  43. package/lib/useOverflowItem.d.ts +9 -0
  44. package/lib/useOverflowItem.js +27 -0
  45. package/lib/useOverflowItem.js.map +1 -0
  46. package/lib/useOverflowMenu.d.ts +6 -0
  47. package/lib/useOverflowMenu.js +40 -0
  48. package/lib/useOverflowMenu.js.map +1 -0
  49. package/lib-commonjs/components/Overflow.d.ts +14 -0
  50. package/lib-commonjs/components/Overflow.js +85 -0
  51. package/lib-commonjs/components/Overflow.js.map +1 -0
  52. package/lib-commonjs/components/OverflowItem/OverflowItem.d.ts +7 -0
  53. package/lib-commonjs/components/OverflowItem/OverflowItem.js +31 -0
  54. package/lib-commonjs/components/OverflowItem/OverflowItem.js.map +1 -0
  55. package/lib-commonjs/components/OverflowItem/OverflowItem.types.d.ts +22 -0
  56. package/lib-commonjs/components/OverflowItem/OverflowItem.types.js +6 -0
  57. package/lib-commonjs/components/OverflowItem/OverflowItem.types.js.map +1 -0
  58. package/lib-commonjs/components/OverflowItem/index.d.ts +2 -0
  59. package/lib-commonjs/components/OverflowItem/index.js +16 -0
  60. package/lib-commonjs/components/OverflowItem/index.js.map +1 -0
  61. package/lib-commonjs/constants.d.ts +3 -0
  62. package/lib-commonjs/constants.js +10 -0
  63. package/lib-commonjs/constants.js.map +1 -0
  64. package/lib-commonjs/index.d.ts +12 -0
  65. package/lib-commonjs/index.js +106 -0
  66. package/lib-commonjs/index.js.map +1 -0
  67. package/lib-commonjs/overflowContext.d.ts +11 -0
  68. package/lib-commonjs/overflowContext.js +21 -0
  69. package/lib-commonjs/overflowContext.js.map +1 -0
  70. package/lib-commonjs/types.d.ts +16 -0
  71. package/lib-commonjs/types.js +6 -0
  72. package/lib-commonjs/types.js.map +1 -0
  73. package/lib-commonjs/useIsOverflowGroupVisible.d.ts +6 -0
  74. package/lib-commonjs/useIsOverflowGroupVisible.js +20 -0
  75. package/lib-commonjs/useIsOverflowGroupVisible.js.map +1 -0
  76. package/lib-commonjs/useIsOverflowItemVisible.d.ts +5 -0
  77. package/lib-commonjs/useIsOverflowItemVisible.js +20 -0
  78. package/lib-commonjs/useIsOverflowItemVisible.js.map +1 -0
  79. package/lib-commonjs/useOverflowContainer.d.ts +10 -0
  80. package/lib-commonjs/useOverflowContainer.js +85 -0
  81. package/lib-commonjs/useOverflowContainer.js.map +1 -0
  82. package/lib-commonjs/useOverflowCount.d.ts +4 -0
  83. package/lib-commonjs/useOverflowCount.js +25 -0
  84. package/lib-commonjs/useOverflowCount.js.map +1 -0
  85. package/lib-commonjs/useOverflowItem.d.ts +9 -0
  86. package/lib-commonjs/useOverflowItem.js +39 -0
  87. package/lib-commonjs/useOverflowItem.js.map +1 -0
  88. package/lib-commonjs/useOverflowMenu.d.ts +6 -0
  89. package/lib-commonjs/useOverflowMenu.js +54 -0
  90. package/lib-commonjs/useOverflowMenu.js.map +1 -0
  91. package/package.json +53 -0
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.OverflowItem = exports.useOverflowMenu = exports.useOverflowItem = exports.useOverflowCount = exports.useOverflowContainer = exports.updateVisibilityAttribute = exports.useIsOverflowItemVisible = exports.useIsOverflowGroupVisible = exports.DATA_OVERFLOW_MENU = exports.DATA_OVERFLOW_ITEM = exports.DATA_OVERFLOWING = exports.Overflow = void 0;
7
+
8
+ var Overflow_1 = /*#__PURE__*/require("./components/Overflow");
9
+
10
+ Object.defineProperty(exports, "Overflow", {
11
+ enumerable: true,
12
+ get: function () {
13
+ return Overflow_1.Overflow;
14
+ }
15
+ });
16
+
17
+ var constants_1 = /*#__PURE__*/require("./constants");
18
+
19
+ Object.defineProperty(exports, "DATA_OVERFLOWING", {
20
+ enumerable: true,
21
+ get: function () {
22
+ return constants_1.DATA_OVERFLOWING;
23
+ }
24
+ });
25
+ Object.defineProperty(exports, "DATA_OVERFLOW_ITEM", {
26
+ enumerable: true,
27
+ get: function () {
28
+ return constants_1.DATA_OVERFLOW_ITEM;
29
+ }
30
+ });
31
+ Object.defineProperty(exports, "DATA_OVERFLOW_MENU", {
32
+ enumerable: true,
33
+ get: function () {
34
+ return constants_1.DATA_OVERFLOW_MENU;
35
+ }
36
+ });
37
+
38
+ var useIsOverflowGroupVisible_1 = /*#__PURE__*/require("./useIsOverflowGroupVisible");
39
+
40
+ Object.defineProperty(exports, "useIsOverflowGroupVisible", {
41
+ enumerable: true,
42
+ get: function () {
43
+ return useIsOverflowGroupVisible_1.useIsOverflowGroupVisible;
44
+ }
45
+ });
46
+
47
+ var useIsOverflowItemVisible_1 = /*#__PURE__*/require("./useIsOverflowItemVisible");
48
+
49
+ Object.defineProperty(exports, "useIsOverflowItemVisible", {
50
+ enumerable: true,
51
+ get: function () {
52
+ return useIsOverflowItemVisible_1.useIsOverflowItemVisible;
53
+ }
54
+ });
55
+
56
+ var useOverflowContainer_1 = /*#__PURE__*/require("./useOverflowContainer");
57
+
58
+ Object.defineProperty(exports, "updateVisibilityAttribute", {
59
+ enumerable: true,
60
+ get: function () {
61
+ return useOverflowContainer_1.updateVisibilityAttribute;
62
+ }
63
+ });
64
+ Object.defineProperty(exports, "useOverflowContainer", {
65
+ enumerable: true,
66
+ get: function () {
67
+ return useOverflowContainer_1.useOverflowContainer;
68
+ }
69
+ });
70
+
71
+ var useOverflowCount_1 = /*#__PURE__*/require("./useOverflowCount");
72
+
73
+ Object.defineProperty(exports, "useOverflowCount", {
74
+ enumerable: true,
75
+ get: function () {
76
+ return useOverflowCount_1.useOverflowCount;
77
+ }
78
+ });
79
+
80
+ var useOverflowItem_1 = /*#__PURE__*/require("./useOverflowItem");
81
+
82
+ Object.defineProperty(exports, "useOverflowItem", {
83
+ enumerable: true,
84
+ get: function () {
85
+ return useOverflowItem_1.useOverflowItem;
86
+ }
87
+ });
88
+
89
+ var useOverflowMenu_1 = /*#__PURE__*/require("./useOverflowMenu");
90
+
91
+ Object.defineProperty(exports, "useOverflowMenu", {
92
+ enumerable: true,
93
+ get: function () {
94
+ return useOverflowMenu_1.useOverflowMenu;
95
+ }
96
+ });
97
+
98
+ var OverflowItem_1 = /*#__PURE__*/require("./components/OverflowItem/OverflowItem");
99
+
100
+ Object.defineProperty(exports, "OverflowItem", {
101
+ enumerable: true,
102
+ get: function () {
103
+ return OverflowItem_1.OverflowItem;
104
+ }
105
+ });
106
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":"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","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 { updateVisibilityAttribute, useOverflowContainer } from './useOverflowContainer';\nexport { useOverflowCount } from './useOverflowCount';\nexport { useOverflowItem } from './useOverflowItem';\nexport { useOverflowMenu } from './useOverflowMenu';\n\nexport type { OverflowItemProps } from './components/OverflowItem/OverflowItem.types';\nexport { OverflowItem } from './components/OverflowItem/OverflowItem';\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,11 @@
1
+ import type { OverflowGroupState, OverflowItemEntry } from '@fluentui/priority-overflow';
2
+ import { ContextSelector } from '@fluentui/react-context-selector';
3
+ export interface OverflowContextValue {
4
+ itemVisibility: Record<string, boolean>;
5
+ groupVisibility: Record<string, OverflowGroupState>;
6
+ hasOverflow: boolean;
7
+ registerItem: (item: OverflowItemEntry) => () => void;
8
+ updateOverflow: (padding?: number) => void;
9
+ }
10
+ export declare const OverflowContext: import("@fluentui/react-context-selector").Context<OverflowContextValue>;
11
+ export declare const useOverflowContext: <SelectedValue>(selector: ContextSelector<OverflowContextValue, SelectedValue>) => SelectedValue;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useOverflowContext = exports.OverflowContext = void 0;
7
+
8
+ const react_context_selector_1 = /*#__PURE__*/require("@fluentui/react-context-selector");
9
+
10
+ exports.OverflowContext = /*#__PURE__*/react_context_selector_1.createContext({
11
+ itemVisibility: {},
12
+ groupVisibility: {},
13
+ hasOverflow: false,
14
+ registerItem: () => () => null,
15
+ updateOverflow: () => null
16
+ });
17
+
18
+ const useOverflowContext = selector => react_context_selector_1.useContextSelector(exports.OverflowContext, selector);
19
+
20
+ exports.useOverflowContext = useOverflowContext;
21
+ //# sourceMappingURL=overflowContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["overflowContext.ts"],"names":[],"mappings":";;;;;;;AACA,MAAA,wBAAA,gBAAA,OAAA,CAAA,kCAAA,CAAA;;AAUa,OAAA,CAAA,eAAA,gBAAkB,wBAAA,CAAA,aAAA,CAAoC;AACjE,EAAA,cAAc,EAAE,EADiD;AAEjE,EAAA,eAAe,EAAE,EAFgD;AAGjE,EAAA,WAAW,EAAE,KAHoD;AAIjE,EAAA,YAAY,EAAE,MAAM,MAAM,IAJuC;AAKjE,EAAA,cAAc,EAAE,MAAM;AAL2C,CAApC,CAAlB;;AAQN,MAAM,kBAAkB,GAAmB,QAAhB,IAChC,wBAAA,CAAA,kBAAA,CAAmB,OAAA,CAAA,eAAnB,EAAoC,QAApC,CADK;;AAAM,OAAA,CAAA,kBAAA,GAAkB,kBAAlB","sourcesContent":["import type { OverflowGroupState, OverflowItemEntry } from '@fluentui/priority-overflow';\nimport { ContextSelector, createContext, useContextSelector } from '@fluentui/react-context-selector';\n\nexport interface OverflowContextValue {\n itemVisibility: Record<string, boolean>;\n groupVisibility: Record<string, OverflowGroupState>;\n hasOverflow: boolean;\n registerItem: (item: OverflowItemEntry) => () => void;\n updateOverflow: (padding?: number) => void;\n}\n\nexport const OverflowContext = createContext<OverflowContextValue>({\n itemVisibility: {},\n groupVisibility: {},\n hasOverflow: false,\n registerItem: () => () => null,\n updateOverflow: () => null,\n});\n\nexport const useOverflowContext = <SelectedValue>(selector: ContextSelector<OverflowContextValue, SelectedValue>) =>\n useContextSelector(OverflowContext, selector);\n"],"sourceRoot":"../src/"}
@@ -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
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":"../src/"}
@@ -0,0 +1,6 @@
1
+ import { OverflowGroupState } from '@fluentui/priority-overflow';
2
+ /**
3
+ * @param id - unique identifier for a group of overflow items
4
+ * @returns visibility state of the group
5
+ */
6
+ export declare function useIsOverflowGroupVisible(id: string): OverflowGroupState;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useIsOverflowGroupVisible = void 0;
7
+
8
+ const overflowContext_1 = /*#__PURE__*/require("./overflowContext");
9
+ /**
10
+ * @param id - unique identifier for a group of overflow items
11
+ * @returns visibility state of the group
12
+ */
13
+
14
+
15
+ function useIsOverflowGroupVisible(id) {
16
+ return overflowContext_1.useOverflowContext(ctx => ctx.groupVisibility[id]);
17
+ }
18
+
19
+ exports.useIsOverflowGroupVisible = useIsOverflowGroupVisible;
20
+ //# sourceMappingURL=useIsOverflowGroupVisible.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useIsOverflowGroupVisible.ts"],"names":[],"mappings":";;;;;;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,mBAAA,CAAA;AAEA;;;AAGG;;;AACH,SAAgB,yBAAhB,CAA0C,EAA1C,EAAoD;AAClD,SAAO,iBAAA,CAAA,kBAAA,CAAmB,GAAG,IAAI,GAAG,CAAC,eAAJ,CAAoB,EAApB,CAA1B,CAAP;AACD;;AAFD,OAAA,CAAA,yBAAA,GAAA,yBAAA","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,5 @@
1
+ /**
2
+ * @param id - unique identifier for the item used by the overflow manager
3
+ * @returns visibility state of an overflow item
4
+ */
5
+ export declare function useIsOverflowItemVisible(id: string): boolean;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useIsOverflowItemVisible = void 0;
7
+
8
+ const overflowContext_1 = /*#__PURE__*/require("./overflowContext");
9
+ /**
10
+ * @param id - unique identifier for the item used by the overflow manager
11
+ * @returns visibility state of an overflow item
12
+ */
13
+
14
+
15
+ function useIsOverflowItemVisible(id) {
16
+ return !!overflowContext_1.useOverflowContext(ctx => ctx.itemVisibility[id]);
17
+ }
18
+
19
+ exports.useIsOverflowItemVisible = useIsOverflowItemVisible;
20
+ //# sourceMappingURL=useIsOverflowItemVisible.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useIsOverflowItemVisible.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,iBAAA,gBAAA,OAAA,CAAA,mBAAA,CAAA;AAEA;;;AAGG;;;AACH,SAAgB,wBAAhB,CAAyC,EAAzC,EAAmD;AACjD,SAAO,CAAC,CAAC,iBAAA,CAAA,kBAAA,CAAmB,GAAG,IAAI,GAAG,CAAC,cAAJ,CAAmB,EAAnB,CAA1B,CAAT;AACD;;AAFD,OAAA,CAAA,wBAAA,GAAA,wBAAA","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,85 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.updateVisibilityAttribute = exports.useOverflowContainer = void 0;
7
+
8
+ const React = /*#__PURE__*/require("react");
9
+
10
+ const priority_overflow_1 = /*#__PURE__*/require("@fluentui/priority-overflow");
11
+
12
+ const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
13
+
14
+ const constants_1 = /*#__PURE__*/require("./constants");
15
+ /**
16
+ *
17
+ * @param update - Callback when overflow state changes
18
+ * @param options - Options to configure the overflow container
19
+ * @returns - ref to attach to an intrinsic HTML element and imperative functions
20
+ */
21
+
22
+
23
+ const useOverflowContainer = (update, options) => {
24
+ const {
25
+ overflowAxis,
26
+ overflowDirection,
27
+ padding,
28
+ minimumVisible,
29
+ onUpdateItemVisibility
30
+ } = options; // DOM ref to the overflow container element
31
+
32
+ const containerRef = React.useRef(null);
33
+ const updateOverflowItems = react_utilities_1.useEventCallback(update);
34
+ const [overflowManager] = React.useState(() => priority_overflow_1.createOverflowManager());
35
+ react_utilities_1.useIsomorphicLayoutEffect(() => {
36
+ if (!containerRef.current) {
37
+ return;
38
+ }
39
+
40
+ overflowManager.observe(containerRef.current, {
41
+ overflowDirection: overflowDirection !== null && overflowDirection !== void 0 ? overflowDirection : 'end',
42
+ overflowAxis: overflowAxis !== null && overflowAxis !== void 0 ? overflowAxis : 'horizontal',
43
+ padding: padding !== null && padding !== void 0 ? padding : 10,
44
+ minimumVisible: minimumVisible !== null && minimumVisible !== void 0 ? minimumVisible : 0,
45
+ onUpdateItemVisibility: onUpdateItemVisibility !== null && onUpdateItemVisibility !== void 0 ? onUpdateItemVisibility : () => undefined,
46
+ onUpdateOverflow: updateOverflowItems !== null && updateOverflowItems !== void 0 ? updateOverflowItems : () => undefined
47
+ });
48
+ return () => {
49
+ overflowManager.disconnect();
50
+ };
51
+ }, [updateOverflowItems, overflowManager, overflowDirection, overflowAxis, padding, minimumVisible, onUpdateItemVisibility]);
52
+ const registerItem = React.useCallback(item => {
53
+ overflowManager.addItem(item);
54
+ item.element.setAttribute(constants_1.DATA_OVERFLOW_ITEM, '');
55
+ return () => {
56
+ item.element.removeAttribute(constants_1.DATA_OVERFLOWING);
57
+ item.element.removeAttribute(constants_1.DATA_OVERFLOW_ITEM);
58
+ overflowManager.removeItem(item.id);
59
+ };
60
+ }, [overflowManager]);
61
+ const updateOverflow = React.useCallback(() => {
62
+ overflowManager.update();
63
+ }, [overflowManager]);
64
+ return {
65
+ containerRef,
66
+ registerItem,
67
+ updateOverflow
68
+ };
69
+ };
70
+
71
+ exports.useOverflowContainer = useOverflowContainer;
72
+
73
+ const updateVisibilityAttribute = ({
74
+ item,
75
+ visible
76
+ }) => {
77
+ if (visible) {
78
+ item.element.removeAttribute(constants_1.DATA_OVERFLOWING);
79
+ } else {
80
+ item.element.setAttribute(constants_1.DATA_OVERFLOWING, '');
81
+ }
82
+ };
83
+
84
+ exports.updateVisibilityAttribute = updateVisibilityAttribute;
85
+ //# sourceMappingURL=useOverflowContainer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useOverflowContainer.ts"],"names":[],"mappings":"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","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,4 @@
1
+ /**
2
+ * @returns Number of items that are overflowing
3
+ */
4
+ export declare const useOverflowCount: () => number;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useOverflowCount = void 0;
7
+
8
+ const overflowContext_1 = /*#__PURE__*/require("./overflowContext");
9
+ /**
10
+ * @returns Number of items that are overflowing
11
+ */
12
+
13
+
14
+ const useOverflowCount = () => overflowContext_1.useOverflowContext(v => {
15
+ return Object.entries(v.itemVisibility).reduce((acc, [id, visible]) => {
16
+ if (!visible) {
17
+ acc++;
18
+ }
19
+
20
+ return acc;
21
+ }, 0);
22
+ });
23
+
24
+ exports.useOverflowCount = useOverflowCount;
25
+ //# sourceMappingURL=useOverflowCount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useOverflowCount.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,iBAAA,gBAAA,OAAA,CAAA,mBAAA,CAAA;AAEA;;AAEG;;;AACI,MAAM,gBAAgB,GAAG,MAC9B,iBAAA,CAAA,kBAAA,CAAmB,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,CARD,CADK;;AAAM,OAAA,CAAA,gBAAA,GAAgB,gBAAhB","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,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useOverflowItem = void 0;
7
+
8
+ const React = /*#__PURE__*/require("react");
9
+
10
+ const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
11
+
12
+ const overflowContext_1 = /*#__PURE__*/require("./overflowContext");
13
+ /**
14
+ * Registers an overflow item
15
+ * @param id - unique identifier for the item used by the overflow manager
16
+ * @param priority - higher priority means the item overflows later
17
+ * @param groupId - assigns the item to a group, group visibility can be watched
18
+ * @returns ref to assign to an intrinsic HTML element
19
+ */
20
+
21
+
22
+ function useOverflowItem(id, priority, groupId) {
23
+ const ref = React.useRef(null);
24
+ const registerItem = overflowContext_1.useOverflowContext(v => v.registerItem);
25
+ react_utilities_1.useIsomorphicLayoutEffect(() => {
26
+ if (ref.current) {
27
+ return registerItem({
28
+ element: ref.current,
29
+ id,
30
+ priority: priority !== null && priority !== void 0 ? priority : 0,
31
+ groupId
32
+ });
33
+ }
34
+ }, [id, priority, registerItem, groupId]);
35
+ return ref;
36
+ }
37
+
38
+ exports.useOverflowItem = useOverflowItem;
39
+ //# sourceMappingURL=useOverflowItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useOverflowItem.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,mBAAA,CAAA;AAEA;;;;;;AAMG;;;AACH,SAAgB,eAAhB,CAA8D,EAA9D,EAA0E,QAA1E,EAA6F,OAA7F,EAA6G;AAC3G,QAAM,GAAG,GAAG,KAAK,CAAC,MAAN,CAAuB,IAAvB,CAAZ;AACA,QAAM,YAAY,GAAG,iBAAA,CAAA,kBAAA,CAAmB,CAAC,IAAI,CAAC,CAAC,YAA1B,CAArB;AAEA,EAAA,iBAAA,CAAA,yBAAA,CAA0B,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,GATD,EASG,CAAC,EAAD,EAAK,QAAL,EAAe,YAAf,EAA6B,OAA7B,CATH;AAWA,SAAO,GAAP;AACD;;AAhBD,OAAA,CAAA,eAAA,GAAA,eAAA","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,6 @@
1
+ import * as React from 'react';
2
+ export declare function useOverflowMenu<TElement extends HTMLElement>(id?: string): {
3
+ ref: React.RefObject<TElement>;
4
+ overflowCount: number;
5
+ isOverflowing: boolean;
6
+ };
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useOverflowMenu = void 0;
7
+
8
+ const React = /*#__PURE__*/require("react");
9
+
10
+ const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
11
+
12
+ const overflowContext_1 = /*#__PURE__*/require("./overflowContext");
13
+
14
+ const useOverflowCount_1 = /*#__PURE__*/require("./useOverflowCount");
15
+
16
+ const constants_1 = /*#__PURE__*/require("./constants");
17
+
18
+ function useOverflowMenu(id) {
19
+ const elementId = react_utilities_1.useId('overflow-menu', id);
20
+ const overflowCount = useOverflowCount_1.useOverflowCount();
21
+ const registerItem = overflowContext_1.useOverflowContext(v => v.registerItem);
22
+ const updateOverflow = overflowContext_1.useOverflowContext(v => v.updateOverflow);
23
+ const ref = React.useRef(null);
24
+ const isOverflowing = overflowCount > 0;
25
+ react_utilities_1.useIsomorphicLayoutEffect(() => {
26
+ const element = ref.current;
27
+
28
+ if (element) {
29
+ const deregisterItem = registerItem({
30
+ element,
31
+ id: elementId,
32
+ priority: Infinity
33
+ });
34
+ element.setAttribute(constants_1.DATA_OVERFLOW_MENU, '');
35
+ return () => {
36
+ deregisterItem();
37
+ element === null || element === void 0 ? void 0 : element.removeAttribute(constants_1.DATA_OVERFLOW_MENU);
38
+ };
39
+ }
40
+ }, [registerItem, isOverflowing, elementId]);
41
+ react_utilities_1.useIsomorphicLayoutEffect(() => {
42
+ if (isOverflowing) {
43
+ updateOverflow();
44
+ }
45
+ }, [isOverflowing, updateOverflow, ref]);
46
+ return {
47
+ ref,
48
+ overflowCount,
49
+ isOverflowing
50
+ };
51
+ }
52
+
53
+ exports.useOverflowMenu = useOverflowMenu;
54
+ //# sourceMappingURL=useOverflowMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useOverflowMenu.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,mBAAA,CAAA;;AACA,MAAA,kBAAA,gBAAA,OAAA,CAAA,oBAAA,CAAA;;AACA,MAAA,WAAA,gBAAA,OAAA,CAAA,aAAA,CAAA;;AAEA,SAAgB,eAAhB,CAA8D,EAA9D,EAAyE;AACvE,QAAM,SAAS,GAAG,iBAAA,CAAA,KAAA,CAAM,eAAN,EAAuB,EAAvB,CAAlB;AACA,QAAM,aAAa,GAAG,kBAAA,CAAA,gBAAA,EAAtB;AACA,QAAM,YAAY,GAAG,iBAAA,CAAA,kBAAA,CAAmB,CAAC,IAAI,CAAC,CAAC,YAA1B,CAArB;AACA,QAAM,cAAc,GAAG,iBAAA,CAAA,kBAAA,CAAmB,CAAC,IAAI,CAAC,CAAC,cAA1B,CAAvB;AACA,QAAM,GAAG,GAAG,KAAK,CAAC,MAAN,CAAuB,IAAvB,CAAZ;AACA,QAAM,aAAa,GAAG,aAAa,GAAG,CAAtC;AAEA,EAAA,iBAAA,CAAA,yBAAA,CAA0B,MAAK;AAC7B,UAAM,OAAO,GAAG,GAAG,CAAC,OAApB;;AACA,QAAI,OAAJ,EAAa;AACX,YAAM,cAAc,GAAG,YAAY,CAAC;AAClC,QAAA,OADkC;AAElC,QAAA,EAAE,EAAE,SAF8B;AAGlC,QAAA,QAAQ,EAAE;AAHwB,OAAD,CAAnC;AAKA,MAAA,OAAO,CAAC,YAAR,CAAqB,WAAA,CAAA,kBAArB,EAAyC,EAAzC;AAEA,aAAO,MAAK;AACV,QAAA,cAAc;AACd,QAAA,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,eAAT,CAAyB,WAAA,CAAA,kBAAzB,CAAA;AACD,OAHD;AAID;AACF,GAfD,EAeG,CAAC,YAAD,EAAe,aAAf,EAA8B,SAA9B,CAfH;AAiBA,EAAA,iBAAA,CAAA,yBAAA,CAA0B,MAAK;AAC7B,QAAI,aAAJ,EAAmB;AACjB,MAAA,cAAc;AACf;AACF,GAJD,EAIG,CAAC,aAAD,EAAgB,cAAhB,EAAgC,GAAhC,CAJH;AAMA,SAAO;AAAE,IAAA,GAAF;AAAO,IAAA,aAAP;AAAsB,IAAA;AAAtB,GAAP;AACD;;AAhCD,OAAA,CAAA,eAAA,GAAA,eAAA","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/"}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@fluentui/react-overflow",
3
+ "version": "0.0.0-nightly-20220511-0419.1",
4
+ "description": "React bindings for @fluentui/priority-overflow",
5
+ "main": "lib-commonjs/index.js",
6
+ "module": "lib/index.js",
7
+ "typings": "lib/index.d.ts",
8
+ "sideEffects": false,
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/microsoft/fluentui"
12
+ },
13
+ "license": "MIT",
14
+ "scripts": {
15
+ "build": "just-scripts build",
16
+ "bundle-size": "bundle-size measure",
17
+ "clean": "just-scripts clean",
18
+ "code-style": "just-scripts code-style",
19
+ "just": "just-scripts",
20
+ "lint": "just-scripts lint",
21
+ "start": "yarn storybook",
22
+ "test": "jest --passWithNoTests",
23
+ "docs": "api-extractor run --config=config/api-extractor.local.json --local",
24
+ "build:local": "tsc -p ./tsconfig.lib.json --module esnext --emitDeclarationOnly && node ../../../scripts/typescript/normalize-import --output ./dist/packages/react-components/react-overflow/src && yarn docs",
25
+ "storybook": "node ../../../scripts/storybook/runner",
26
+ "type-check": "tsc -b tsconfig.json"
27
+ },
28
+ "devDependencies": {
29
+ "@fluentui/eslint-plugin": "*",
30
+ "@fluentui/scripts": "^1.0.0"
31
+ },
32
+ "dependencies": {
33
+ "@fluentui/priority-overflow": "^0.0.0-nightly-20220511-0419.1",
34
+ "@fluentui/react-context-selector": "0.0.0-nightly-20220511-0419.1",
35
+ "@fluentui/react-theme": "0.0.0-nightly-20220511-0419.1",
36
+ "@fluentui/react-utilities": "0.0.0-nightly-20220511-0419.1",
37
+ "@griffel/react": "1.0.3",
38
+ "tslib": "^2.1.0"
39
+ },
40
+ "peerDependencies": {
41
+ "@types/react": ">=16.8.0 <18.0.0",
42
+ "@types/react-dom": ">=16.8.0 <18.0.0",
43
+ "react": ">=16.8.0 <18.0.0",
44
+ "react-dom": ">=16.8.0 <18.0.0"
45
+ },
46
+ "beachball": {
47
+ "disallowedChangeTypes": [
48
+ "major",
49
+ "minor",
50
+ "patch"
51
+ ]
52
+ }
53
+ }