@fluentui/react-tabs 1.0.0-beta.99 → 9.0.0-beta.10

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.
Files changed (229) hide show
  1. package/CHANGELOG.json +182 -1843
  2. package/CHANGELOG.md +54 -743
  3. package/README.md +0 -17
  4. package/Spec.md +433 -0
  5. package/dist/react-tabs.d.ts +173 -127
  6. package/lib/Tab.d.ts +1 -0
  7. package/lib/Tab.js +2 -0
  8. package/lib/Tab.js.map +1 -0
  9. package/lib/TabList.d.ts +1 -0
  10. package/lib/TabList.js +2 -0
  11. package/lib/TabList.js.map +1 -0
  12. package/lib/components/Tab/Tab.d.ts +6 -0
  13. package/lib/components/Tab/Tab.js +15 -0
  14. package/lib/components/Tab/Tab.js.map +1 -0
  15. package/lib/components/Tab/Tab.types.d.ts +61 -0
  16. package/lib/components/Tab/Tab.types.js +2 -0
  17. package/lib/components/Tab/Tab.types.js.map +1 -0
  18. package/lib/components/Tab/index.d.ts +6 -0
  19. package/lib/components/Tab/index.js +7 -0
  20. package/lib/components/Tab/index.js.map +1 -0
  21. package/lib/components/Tab/renderTab.d.ts +5 -0
  22. package/lib/components/Tab/renderTab.js +17 -0
  23. package/lib/components/Tab/renderTab.js.map +1 -0
  24. package/lib/components/Tab/useTab.d.ts +12 -0
  25. package/lib/components/Tab/useTab.js +78 -0
  26. package/lib/components/Tab/useTab.js.map +1 -0
  27. package/lib/components/Tab/useTabAnimatedIndicator.d.ts +5 -0
  28. package/lib/components/Tab/useTabAnimatedIndicator.js +134 -0
  29. package/lib/components/Tab/useTabAnimatedIndicator.js.map +1 -0
  30. package/lib/components/Tab/useTabStyles.d.ts +8 -0
  31. package/lib/components/Tab/useTabStyles.js +402 -0
  32. package/lib/components/Tab/useTabStyles.js.map +1 -0
  33. package/lib/components/TabList/TabList.d.ts +6 -0
  34. package/lib/components/TabList/TabList.js +17 -0
  35. package/lib/components/TabList/TabList.js.map +1 -0
  36. package/lib/components/TabList/TabList.types.d.ts +104 -0
  37. package/lib/components/TabList/TabList.types.js +2 -0
  38. package/lib/components/TabList/TabList.types.js.map +1 -0
  39. package/lib/components/TabList/TabListContext.d.ts +3 -0
  40. package/lib/components/TabList/TabListContext.js +23 -0
  41. package/lib/components/TabList/TabListContext.js.map +1 -0
  42. package/lib/components/TabList/index.d.ts +5 -0
  43. package/lib/components/TabList/index.js +6 -0
  44. package/lib/components/TabList/index.js.map +1 -0
  45. package/lib/components/TabList/renderTabList.d.ts +5 -0
  46. package/lib/components/TabList/renderTabList.js +18 -0
  47. package/lib/components/TabList/renderTabList.js.map +1 -0
  48. package/lib/components/TabList/useTabList.d.ts +12 -0
  49. package/lib/components/TabList/useTabList.js +81 -0
  50. package/lib/components/TabList/useTabList.js.map +1 -0
  51. package/lib/components/TabList/useTabListContextValues.d.ts +2 -0
  52. package/lib/components/TabList/useTabListContextValues.js +28 -0
  53. package/lib/components/TabList/useTabListContextValues.js.map +1 -0
  54. package/lib/components/TabList/useTabListStyles.d.ts +8 -0
  55. package/lib/components/TabList/useTabListStyles.js +45 -0
  56. package/lib/components/TabList/useTabListStyles.js.map +1 -0
  57. package/lib/index.d.ts +4 -1
  58. package/lib/index.js +2 -1
  59. package/lib/index.js.map +1 -1
  60. package/lib/tab.constants.d.ts +62 -0
  61. package/lib/tab.constants.js +68 -0
  62. package/lib/tab.constants.js.map +1 -0
  63. package/lib/tsdoc-metadata.json +1 -1
  64. package/lib-commonjs/Tab.d.ts +1 -0
  65. package/lib-commonjs/Tab.js +10 -0
  66. package/lib-commonjs/Tab.js.map +1 -0
  67. package/lib-commonjs/TabList.d.ts +1 -0
  68. package/lib-commonjs/TabList.js +10 -0
  69. package/lib-commonjs/TabList.js.map +1 -0
  70. package/lib-commonjs/components/Tab/Tab.d.ts +6 -0
  71. package/lib-commonjs/components/Tab/Tab.js +26 -0
  72. package/lib-commonjs/components/Tab/Tab.js.map +1 -0
  73. package/lib-commonjs/components/Tab/Tab.types.d.ts +61 -0
  74. package/lib-commonjs/components/Tab/Tab.types.js +6 -0
  75. package/lib-commonjs/components/Tab/Tab.types.js.map +1 -0
  76. package/lib-commonjs/components/Tab/index.d.ts +6 -0
  77. package/lib-commonjs/components/Tab/index.js +20 -0
  78. package/lib-commonjs/components/Tab/index.js.map +1 -0
  79. package/lib-commonjs/components/Tab/renderTab.d.ts +5 -0
  80. package/lib-commonjs/components/Tab/renderTab.js +28 -0
  81. package/lib-commonjs/components/Tab/renderTab.js.map +1 -0
  82. package/lib-commonjs/components/Tab/useTab.d.ts +12 -0
  83. package/lib-commonjs/components/Tab/useTab.js +91 -0
  84. package/lib-commonjs/components/Tab/useTab.js.map +1 -0
  85. package/lib-commonjs/components/Tab/useTabAnimatedIndicator.d.ts +5 -0
  86. package/lib-commonjs/components/Tab/useTabAnimatedIndicator.js +148 -0
  87. package/lib-commonjs/components/Tab/useTabAnimatedIndicator.js.map +1 -0
  88. package/lib-commonjs/components/Tab/useTabStyles.d.ts +8 -0
  89. package/lib-commonjs/components/Tab/useTabStyles.js +416 -0
  90. package/lib-commonjs/components/Tab/useTabStyles.js.map +1 -0
  91. package/lib-commonjs/components/TabList/TabList.d.ts +6 -0
  92. package/lib-commonjs/components/TabList/TabList.js +29 -0
  93. package/lib-commonjs/components/TabList/TabList.js.map +1 -0
  94. package/lib-commonjs/components/TabList/TabList.types.d.ts +104 -0
  95. package/lib-commonjs/components/TabList/TabList.types.js +6 -0
  96. package/lib-commonjs/components/TabList/TabList.types.js.map +1 -0
  97. package/lib-commonjs/components/TabList/TabListContext.d.ts +3 -0
  98. package/lib-commonjs/components/TabList/TabListContext.js +31 -0
  99. package/lib-commonjs/components/TabList/TabListContext.js.map +1 -0
  100. package/lib-commonjs/components/TabList/index.d.ts +5 -0
  101. package/lib-commonjs/components/TabList/index.js +18 -0
  102. package/lib-commonjs/components/TabList/index.js.map +1 -0
  103. package/lib-commonjs/components/TabList/renderTabList.d.ts +5 -0
  104. package/lib-commonjs/components/TabList/renderTabList.js +30 -0
  105. package/lib-commonjs/components/TabList/renderTabList.js.map +1 -0
  106. package/lib-commonjs/components/TabList/useTabList.d.ts +12 -0
  107. package/lib-commonjs/components/TabList/useTabList.js +93 -0
  108. package/lib-commonjs/components/TabList/useTabList.js.map +1 -0
  109. package/lib-commonjs/components/TabList/useTabListContextValues.d.ts +2 -0
  110. package/lib-commonjs/components/TabList/useTabListContextValues.js +37 -0
  111. package/lib-commonjs/components/TabList/useTabListContextValues.js.map +1 -0
  112. package/lib-commonjs/components/TabList/useTabListStyles.d.ts +8 -0
  113. package/lib-commonjs/components/TabList/useTabListStyles.js +55 -0
  114. package/lib-commonjs/components/TabList/useTabListStyles.js.map +1 -0
  115. package/lib-commonjs/index.d.ts +4 -1
  116. package/lib-commonjs/index.js +83 -3
  117. package/lib-commonjs/index.js.map +1 -1
  118. package/lib-commonjs/tab.constants.d.ts +62 -0
  119. package/lib-commonjs/tab.constants.js +75 -0
  120. package/lib-commonjs/tab.constants.js.map +1 -0
  121. package/package.json +25 -21
  122. package/config/api-extractor.json +0 -3
  123. package/config/tests.js +0 -14
  124. package/etc/react-tabs.api.md +0 -104
  125. package/just.config.ts +0 -3
  126. package/lib/Tabs.d.ts +0 -1
  127. package/lib/Tabs.js +0 -2
  128. package/lib/Tabs.js.map +0 -1
  129. package/lib/common/isConformant.d.ts +0 -4
  130. package/lib/common/isConformant.js +0 -9
  131. package/lib/common/isConformant.js.map +0 -1
  132. package/lib/components/Tabs/TabItem.d.ts +0 -6
  133. package/lib/components/Tabs/TabItem.js +0 -18
  134. package/lib/components/Tabs/TabItem.js.map +0 -1
  135. package/lib/components/Tabs/TabItem.types.d.ts +0 -61
  136. package/lib/components/Tabs/TabItem.types.js +0 -2
  137. package/lib/components/Tabs/TabItem.types.js.map +0 -1
  138. package/lib/components/Tabs/Tabs.base.d.ts +0 -3
  139. package/lib/components/Tabs/Tabs.base.js +0 -179
  140. package/lib/components/Tabs/Tabs.base.js.map +0 -1
  141. package/lib/components/Tabs/Tabs.d.ts +0 -8
  142. package/lib/components/Tabs/Tabs.js +0 -12
  143. package/lib/components/Tabs/Tabs.js.map +0 -1
  144. package/lib/components/Tabs/Tabs.styles.d.ts +0 -2
  145. package/lib/components/Tabs/Tabs.styles.js +0 -264
  146. package/lib/components/Tabs/Tabs.styles.js.map +0 -1
  147. package/lib/components/Tabs/Tabs.types.d.ts +0 -113
  148. package/lib/components/Tabs/Tabs.types.js +0 -2
  149. package/lib/components/Tabs/Tabs.types.js.map +0 -1
  150. package/lib/components/Tabs/index.d.ts +0 -5
  151. package/lib/components/Tabs/index.js +0 -6
  152. package/lib/components/Tabs/index.js.map +0 -1
  153. package/lib/utilities/observeResize.d.ts +0 -21
  154. package/lib/utilities/observeResize.js +0 -46
  155. package/lib/utilities/observeResize.js.map +0 -1
  156. package/lib/utilities/useOverflow.d.ts +0 -45
  157. package/lib/utilities/useOverflow.js +0 -126
  158. package/lib/utilities/useOverflow.js.map +0 -1
  159. package/lib-amd/Tabs.d.ts +0 -1
  160. package/lib-amd/Tabs.js +0 -6
  161. package/lib-amd/Tabs.js.map +0 -1
  162. package/lib-amd/common/isConformant.d.ts +0 -4
  163. package/lib-amd/common/isConformant.js +0 -14
  164. package/lib-amd/common/isConformant.js.map +0 -1
  165. package/lib-amd/components/Tabs/TabItem.d.ts +0 -6
  166. package/lib-amd/components/Tabs/TabItem.js +0 -20
  167. package/lib-amd/components/Tabs/TabItem.js.map +0 -1
  168. package/lib-amd/components/Tabs/TabItem.types.d.ts +0 -61
  169. package/lib-amd/components/Tabs/TabItem.types.js +0 -5
  170. package/lib-amd/components/Tabs/TabItem.types.js.map +0 -1
  171. package/lib-amd/components/Tabs/Tabs.base.d.ts +0 -3
  172. package/lib-amd/components/Tabs/Tabs.base.js +0 -176
  173. package/lib-amd/components/Tabs/Tabs.base.js.map +0 -1
  174. package/lib-amd/components/Tabs/Tabs.d.ts +0 -8
  175. package/lib-amd/components/Tabs/Tabs.js +0 -14
  176. package/lib-amd/components/Tabs/Tabs.js.map +0 -1
  177. package/lib-amd/components/Tabs/Tabs.styles.d.ts +0 -2
  178. package/lib-amd/components/Tabs/Tabs.styles.js +0 -267
  179. package/lib-amd/components/Tabs/Tabs.styles.js.map +0 -1
  180. package/lib-amd/components/Tabs/Tabs.types.d.ts +0 -113
  181. package/lib-amd/components/Tabs/Tabs.types.js +0 -5
  182. package/lib-amd/components/Tabs/Tabs.types.js.map +0 -1
  183. package/lib-amd/components/Tabs/index.d.ts +0 -5
  184. package/lib-amd/components/Tabs/index.js +0 -11
  185. package/lib-amd/components/Tabs/index.js.map +0 -1
  186. package/lib-amd/index.d.ts +0 -1
  187. package/lib-amd/index.js +0 -6
  188. package/lib-amd/index.js.map +0 -1
  189. package/lib-amd/utilities/observeResize.d.ts +0 -21
  190. package/lib-amd/utilities/observeResize.js +0 -51
  191. package/lib-amd/utilities/observeResize.js.map +0 -1
  192. package/lib-amd/utilities/useOverflow.d.ts +0 -45
  193. package/lib-amd/utilities/useOverflow.js +0 -128
  194. package/lib-amd/utilities/useOverflow.js.map +0 -1
  195. package/lib-commonjs/Tabs.d.ts +0 -1
  196. package/lib-commonjs/Tabs.js +0 -5
  197. package/lib-commonjs/Tabs.js.map +0 -1
  198. package/lib-commonjs/common/isConformant.d.ts +0 -4
  199. package/lib-commonjs/common/isConformant.js +0 -13
  200. package/lib-commonjs/common/isConformant.js.map +0 -1
  201. package/lib-commonjs/components/Tabs/TabItem.d.ts +0 -6
  202. package/lib-commonjs/components/Tabs/TabItem.js +0 -21
  203. package/lib-commonjs/components/Tabs/TabItem.js.map +0 -1
  204. package/lib-commonjs/components/Tabs/TabItem.types.d.ts +0 -61
  205. package/lib-commonjs/components/Tabs/TabItem.types.js +0 -3
  206. package/lib-commonjs/components/Tabs/TabItem.types.js.map +0 -1
  207. package/lib-commonjs/components/Tabs/Tabs.base.d.ts +0 -3
  208. package/lib-commonjs/components/Tabs/Tabs.base.js +0 -182
  209. package/lib-commonjs/components/Tabs/Tabs.base.js.map +0 -1
  210. package/lib-commonjs/components/Tabs/Tabs.d.ts +0 -8
  211. package/lib-commonjs/components/Tabs/Tabs.js +0 -15
  212. package/lib-commonjs/components/Tabs/Tabs.js.map +0 -1
  213. package/lib-commonjs/components/Tabs/Tabs.styles.d.ts +0 -2
  214. package/lib-commonjs/components/Tabs/Tabs.styles.js +0 -268
  215. package/lib-commonjs/components/Tabs/Tabs.styles.js.map +0 -1
  216. package/lib-commonjs/components/Tabs/Tabs.types.d.ts +0 -113
  217. package/lib-commonjs/components/Tabs/Tabs.types.js +0 -3
  218. package/lib-commonjs/components/Tabs/Tabs.types.js.map +0 -1
  219. package/lib-commonjs/components/Tabs/index.d.ts +0 -5
  220. package/lib-commonjs/components/Tabs/index.js +0 -11
  221. package/lib-commonjs/components/Tabs/index.js.map +0 -1
  222. package/lib-commonjs/utilities/observeResize.d.ts +0 -21
  223. package/lib-commonjs/utilities/observeResize.js +0 -50
  224. package/lib-commonjs/utilities/observeResize.js.map +0 -1
  225. package/lib-commonjs/utilities/useOverflow.d.ts +0 -45
  226. package/lib-commonjs/utilities/useOverflow.js +0 -130
  227. package/lib-commonjs/utilities/useOverflow.js.map +0 -1
  228. package/src/components/Tabs/TabItem.types.ts +0 -69
  229. package/src/components/Tabs/Tabs.types.ts +0 -131
@@ -1,130 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useOverflow = void 0;
4
- var React = require("react");
5
- var react_hooks_1 = require("@fluentui/react-hooks");
6
- var utilities_1 = require("@fluentui/utilities");
7
- var observeResize_1 = require("./observeResize");
8
- /**
9
- * Track whether any items don't fit within their container, and move them to the overflow menu.
10
- * Items are moved into the overflow menu from back to front, excluding pinned items.
11
- *
12
- * The overflow menu button must be the last sibling of all of the items that can be put into the overflow, and it
13
- * must be hooked up to the `setMenuButtonRef` setter function that's returned by `useOverflow`:
14
- * ```ts
15
- * const overflow = useOverflow(...);
16
- * ```
17
- * ```jsx
18
- * <Container>
19
- * <Item /> // Index 0
20
- * <Item /> // Index 1
21
- * ...
22
- * <Button ref={overflow.setMenuButtonRef} /> // Can be any React.Component or HTMLElement
23
- * </Container>
24
- * ```
25
- */
26
- var useOverflow = function (_a) {
27
- var onOverflowItemsChanged = _a.onOverflowItemsChanged, rtl = _a.rtl, pinnedIndex = _a.pinnedIndex;
28
- var updateOverflowRef = React.useRef();
29
- var containerWidthRef = React.useRef();
30
- // Attach a resize observer to the container
31
- var containerRef = react_hooks_1.useRefEffect(function (container) {
32
- var cleanupObserver = observeResize_1.observeResize(container, function (entries) {
33
- containerWidthRef.current = entries ? entries[0].contentRect.width : container.clientWidth;
34
- if (updateOverflowRef.current) {
35
- updateOverflowRef.current();
36
- }
37
- });
38
- return function () {
39
- cleanupObserver();
40
- containerWidthRef.current = undefined;
41
- };
42
- });
43
- var menuButtonRef = react_hooks_1.useRefEffect(function (menuButton) {
44
- containerRef(menuButton.parentElement);
45
- return function () { return containerRef(null); };
46
- });
47
- // eslint-disable-next-line no-restricted-properties
48
- React.useLayoutEffect(function () {
49
- var container = containerRef.current;
50
- var menuButton = menuButtonRef.current;
51
- if (!container || !menuButton) {
52
- return;
53
- }
54
- // items contains the container's children, excluding the overflow menu button itself
55
- var items = [];
56
- for (var i = 0; i < container.children.length; i++) {
57
- var item = container.children[i];
58
- if (item instanceof HTMLElement && item !== menuButton) {
59
- items.push(item);
60
- }
61
- }
62
- // Keep track of the minimum width of the container to fit each child index.
63
- // This cache is an integral part of the algorithm and not just a performance optimization: it allows us to
64
- // recalculate the overflowIndex on subsequent resizes even if some items are already inside the overflow.
65
- var minContainerWidth = [];
66
- var extraWidth = 0; // The accumulated width of items that don't move into the overflow
67
- updateOverflowRef.current = function () {
68
- var containerWidth = containerWidthRef.current;
69
- if (containerWidth === undefined) {
70
- return;
71
- }
72
- // Iterate the items in reverse order until we find one that fits within the bounds of the container
73
- for (var i = items.length - 1; i >= 0; i--) {
74
- // Calculate the min container width for this item if we haven't done so yet
75
- if (minContainerWidth[i] === undefined) {
76
- var itemOffsetEnd = rtl ? containerWidth - items[i].offsetLeft : items[i].offsetLeft + items[i].offsetWidth;
77
- // If the item after this one is pinned, reserve space for it
78
- if (i + 1 < items.length && i + 1 === pinnedIndex) {
79
- // Use distance between the end of the previous item and this one (rather than the
80
- // pinned item's offsetWidth), to account for any margin between the items.
81
- extraWidth = minContainerWidth[i + 1] - itemOffsetEnd;
82
- }
83
- // Reserve space for the menu button after the first item was added to the overflow
84
- if (i === items.length - 2) {
85
- extraWidth += menuButton.offsetWidth;
86
- }
87
- minContainerWidth[i] = itemOffsetEnd + extraWidth;
88
- }
89
- if (containerWidth > minContainerWidth[i]) {
90
- setOverflowIndex(i + 1);
91
- return;
92
- }
93
- }
94
- // If we got here, nothing fits outside the overflow
95
- setOverflowIndex(0);
96
- };
97
- var prevOverflowIndex = items.length;
98
- var setOverflowIndex = function (overflowIndex) {
99
- if (prevOverflowIndex !== overflowIndex) {
100
- prevOverflowIndex = overflowIndex;
101
- onOverflowItemsChanged(overflowIndex, items.map(function (ele, index) { return ({
102
- ele: ele,
103
- isOverflowing: index >= overflowIndex && index !== pinnedIndex,
104
- }); }));
105
- }
106
- };
107
- var cancelAnimationFrame = undefined;
108
- // If the container width is already known from a previous render, update the overflow with its width.
109
- // Do this in an animation frame to avoid forcing layout to happen early.
110
- if (containerWidthRef.current !== undefined) {
111
- var win_1 = utilities_1.getWindow(container);
112
- if (win_1) {
113
- var animationFrameId_1 = win_1.requestAnimationFrame(updateOverflowRef.current);
114
- cancelAnimationFrame = function () { return win_1.cancelAnimationFrame(animationFrameId_1); };
115
- }
116
- }
117
- return function () {
118
- if (cancelAnimationFrame) {
119
- cancelAnimationFrame();
120
- }
121
- // On cleanup, need to remove all items from the overflow
122
- // so they don't have stale properties on the next render
123
- setOverflowIndex(items.length);
124
- updateOverflowRef.current = undefined;
125
- };
126
- });
127
- return { menuButtonRef: menuButtonRef };
128
- };
129
- exports.useOverflow = useOverflow;
130
- //# sourceMappingURL=useOverflow.js.map
@@ -1 +0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,kBAAgB,CAAC,EAA1C,CAA0C,CAAC;aACzE;SACF;QAED,OAAO;YACL,IAAI,oBAAoB,EAAE;gBACxB,oBAAoB,EAAE,CAAC;aACxB;YAED,yDAAyD;YACzD,yDAAyD;YACzD,gBAAgB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAC/B,iBAAiB,CAAC,OAAO,GAAG,SAAS,CAAC;QACxC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,aAAa,eAAA,EAAE,CAAC;AAC3B,CAAC,CAAC;AA3HW,QAAA,WAAW,eA2HtB","sourcesContent":["import * as React from 'react';\nimport { useRefEffect, RefCallback } from '@fluentui/react-hooks';\nimport { getWindow } from '@fluentui/utilities';\nimport { observeResize } from './observeResize';\n\n/**\n * Callback to notify the user that the items in the overflow have changed. This should ensure that the overflow menu\n * is visible, and contains all of the overflowing items.\n *\n * @param overflowIndex - The index of the first item in the overflow, or items.length if nothing is overflowing.\n * @param items - The list of all items in the container, and whether that particular item is in the overflow\n */\nexport type OverflowItemsChangedCallback = (\n overflowIndex: number,\n items: { ele: HTMLElement; isOverflowing: boolean }[],\n) => void;\n\n/** Parameters for {@see useOverflow} */\nexport type OverflowParams = {\n /** Callback to notify the user that the items in the overflow have changed. */\n onOverflowItemsChanged: OverflowItemsChangedCallback;\n\n /** True if the element containing overflowMenuButtonRef is in right-to-left order */\n rtl: boolean;\n\n /** Optional: Index of item that should never go into the overflow menu. */\n pinnedIndex?: number;\n};\n\n/** Return value for {@see useOverflow} */\nexport type OverflowRefs = {\n /** Set the overflow menu button's ref to this ref callback */\n menuButtonRef: RefCallback<HTMLElement>;\n};\n\n/**\n * Track whether any items don't fit within their container, and move them to the overflow menu.\n * Items are moved into the overflow menu from back to front, excluding pinned items.\n *\n * The overflow menu button must be the last sibling of all of the items that can be put into the overflow, and it\n * must be hooked up to the `setMenuButtonRef` setter function that's returned by `useOverflow`:\n * ```ts\n * const overflow = useOverflow(...);\n * ```\n * ```jsx\n * <Container>\n * <Item /> // Index 0\n * <Item /> // Index 1\n * ...\n * <Button ref={overflow.setMenuButtonRef} /> // Can be any React.Component or HTMLElement\n * </Container>\n * ```\n */\nexport const useOverflow = ({ onOverflowItemsChanged, rtl, pinnedIndex }: OverflowParams): OverflowRefs => {\n const updateOverflowRef = React.useRef<() => void>();\n const containerWidthRef = React.useRef<number>();\n\n // Attach a resize observer to the container\n const containerRef = useRefEffect<HTMLElement>(container => {\n const cleanupObserver = observeResize(container, entries => {\n containerWidthRef.current = entries ? entries[0].contentRect.width : container.clientWidth;\n if (updateOverflowRef.current) {\n updateOverflowRef.current();\n }\n });\n\n return () => {\n cleanupObserver();\n containerWidthRef.current = undefined;\n };\n });\n\n const menuButtonRef = useRefEffect<HTMLElement>(menuButton => {\n containerRef(menuButton.parentElement);\n return () => containerRef(null);\n });\n\n // eslint-disable-next-line no-restricted-properties\n React.useLayoutEffect(() => {\n const container = containerRef.current;\n const menuButton = menuButtonRef.current;\n if (!container || !menuButton) {\n return;\n }\n\n // items contains the container's children, excluding the overflow menu button itself\n const items: HTMLElement[] = [];\n for (let i = 0; i < container.children.length; i++) {\n const item = container.children[i];\n if (item instanceof HTMLElement && item !== menuButton) {\n items.push(item);\n }\n }\n\n // Keep track of the minimum width of the container to fit each child index.\n // This cache is an integral part of the algorithm and not just a performance optimization: it allows us to\n // recalculate the overflowIndex on subsequent resizes even if some items are already inside the overflow.\n const minContainerWidth: number[] = [];\n let extraWidth = 0; // The accumulated width of items that don't move into the overflow\n\n updateOverflowRef.current = () => {\n const containerWidth = containerWidthRef.current;\n if (containerWidth === undefined) {\n return;\n }\n\n // Iterate the items in reverse order until we find one that fits within the bounds of the container\n for (let i = items.length - 1; i >= 0; i--) {\n // Calculate the min container width for this item if we haven't done so yet\n if (minContainerWidth[i] === undefined) {\n const itemOffsetEnd = rtl ? containerWidth - items[i].offsetLeft : items[i].offsetLeft + items[i].offsetWidth;\n\n // If the item after this one is pinned, reserve space for it\n if (i + 1 < items.length && i + 1 === pinnedIndex) {\n // Use distance between the end of the previous item and this one (rather than the\n // pinned item's offsetWidth), to account for any margin between the items.\n extraWidth = minContainerWidth[i + 1] - itemOffsetEnd;\n }\n\n // Reserve space for the menu button after the first item was added to the overflow\n if (i === items.length - 2) {\n extraWidth += menuButton.offsetWidth;\n }\n\n minContainerWidth[i] = itemOffsetEnd + extraWidth;\n }\n\n if (containerWidth > minContainerWidth[i]) {\n setOverflowIndex(i + 1);\n return;\n }\n }\n\n // If we got here, nothing fits outside the overflow\n setOverflowIndex(0);\n };\n\n let prevOverflowIndex = items.length;\n const setOverflowIndex = (overflowIndex: number) => {\n if (prevOverflowIndex !== overflowIndex) {\n prevOverflowIndex = overflowIndex;\n onOverflowItemsChanged(\n overflowIndex,\n items.map((ele, index) => ({\n ele,\n isOverflowing: index >= overflowIndex && index !== pinnedIndex,\n })),\n );\n }\n };\n\n let cancelAnimationFrame: (() => void) | undefined = undefined;\n\n // If the container width is already known from a previous render, update the overflow with its width.\n // Do this in an animation frame to avoid forcing layout to happen early.\n if (containerWidthRef.current !== undefined) {\n const win = getWindow(container);\n if (win) {\n const animationFrameId = win.requestAnimationFrame(updateOverflowRef.current);\n cancelAnimationFrame = () => win.cancelAnimationFrame(animationFrameId);\n }\n }\n\n return () => {\n if (cancelAnimationFrame) {\n cancelAnimationFrame();\n }\n\n // On cleanup, need to remove all items from the overflow\n // so they don't have stale properties on the next render\n setOverflowIndex(items.length);\n updateOverflowRef.current = undefined;\n };\n });\n\n return { menuButtonRef };\n};\n"]}
@@ -1,69 +0,0 @@
1
- import * as React from 'react';
2
- import { IKeytipProps } from '@fluentui/react';
3
- import { IButtonProps } from '@fluentui/react/lib/Button';
4
- import { IRefObject, IRenderFunction } from '@fluentui/utilities';
5
-
6
- /**
7
- * {@docCategory Tabs}
8
- */
9
- export interface TabItemProps extends React.HTMLAttributes<HTMLDivElement> {
10
- /**
11
- * Gets the component ref.
12
- */
13
- componentRef?: IRefObject<{}>;
14
-
15
- /**
16
- * The text displayed of each tab.
17
- */
18
- headerText?: string;
19
-
20
- /**
21
- * Props for the header command button. This provides a way to pass in native props, such as data-* and aria-*,
22
- * for each tab element.
23
- */
24
- headerButtonProps?: IButtonProps | { [key: string]: string | number | boolean };
25
-
26
- /**
27
- * An required key to uniquely identify a tab item.
28
- *
29
- * Note: The 'key' from react props cannot be used inside component.
30
- */
31
- itemKey?: string;
32
-
33
- /**
34
- * The aria label of each tab which will read by screen reader instead of headerText.
35
- *
36
- * Note that unless you have compelling requirements you should not override aria-label.
37
- */
38
- ariaLabel?: string;
39
-
40
- /**
41
- * Defines an optional item count displayed in parentheses just after the `headerText`.
42
- *
43
- * Examples: completed (4), Unread (99+)
44
- */
45
- itemCount?: number | string;
46
-
47
- /**
48
- * An optional icon to show next to the tab.
49
- */
50
- itemIcon?: string;
51
-
52
- /**
53
- * Optional custom renderer for the tab
54
- */
55
- onRenderTab?: IRenderFunction<TabItemProps>;
56
-
57
- /**
58
- * Optional keytip for this TabItem
59
- */
60
- keytipProps?: IKeytipProps;
61
-
62
- /**
63
- * Defines whether to always render the tab item (regardless of whether it is selected or not).
64
- * Useful if you're rendering content that is expensive to mount.
65
- *
66
- * @defaultvalue false
67
- */
68
- alwaysRender?: boolean;
69
- }
@@ -1,131 +0,0 @@
1
- import * as React from 'react';
2
- import { IStyle, ITheme } from '@fluentui/style-utilities';
3
- import { IStyleFunctionOrObject } from '@fluentui/utilities';
4
- import { TabItem } from './TabItem';
5
-
6
- /**
7
- * {@docCategory Tabs}
8
- */
9
- export interface TabsImperativeHandle {
10
- /**
11
- * Sets focus to the first tab.
12
- */
13
- focus(): void;
14
- }
15
-
16
- /**
17
- * {@docCategory Tabs}
18
- */
19
- export interface TabsProps extends React.HTMLAttributes<HTMLDivElement>, React.RefAttributes<HTMLDivElement> {
20
- /**
21
- * Optional callback to access the TabsImperativeHandle interface. Use this instead of ref for accessing
22
- * the public methods and properties of the component.
23
- */
24
- componentRef?: React.RefObject<TabsImperativeHandle>;
25
-
26
- /**
27
- * Call to provide customized styling that will layer on top of the variant rules.
28
- */
29
- styles?: IStyleFunctionOrObject<TabsStyleProps, TabsStyles>;
30
-
31
- /**
32
- * Theme provided by High-Order Component.
33
- */
34
- theme?: ITheme;
35
-
36
- /**
37
- * Additional css class to apply to the Tabs
38
- * @defaultvalue undefined
39
- */
40
- className?: string;
41
-
42
- /**
43
- * Default selected TabItem key. Only provide this if the Tabs is an uncontrolled component;
44
- * otherwise, use the `selectedKey` property.
45
- */
46
- defaultSelectedKey?: string;
47
-
48
- /**
49
- * Key of the selected tab item. Updating this will override the selected tab state.
50
- * Only provide this if the Tabs is a controlled component where you are maintaining the
51
- * current state; otherwise, use `defaultSelectedKey`.
52
- */
53
- selectedKey?: string | null;
54
-
55
- /**
56
- * Callback for when the selected tab item is changed.
57
- */
58
- onTabClick?: (item?: TabItem, ev?: React.MouseEvent<HTMLElement>) => void;
59
-
60
- /**
61
- * Tab size (normal, large)
62
- */
63
- tabSize?: TabSizeType;
64
-
65
- /**
66
- * Tab format (links, tabs)
67
- */
68
- tabFormat?: TabFormatType;
69
-
70
- /**
71
- * Overflow behavior when there is not enough room to display all of the tabs
72
- * * none: Tabs will overflow the container and may not be visible
73
- * * menu: Display an overflow menu that contains the tabs that don't fit
74
- *
75
- * @default none
76
- */
77
- overflowBehavior?: 'none' | 'menu';
78
-
79
- /**
80
- * Whether to skip rendering the tabpanel with the content of the selected tab.
81
- * Use this prop if you plan to separately render the tab content
82
- * and don't want to leave an empty tabpanel in the page that may confuse Screen Readers.
83
- */
84
- headersOnly?: boolean;
85
-
86
- /**
87
- * Callback to customize how IDs are generated for each tab header.
88
- * Useful if you're rendering content outside and need to connect aria-labelledby.
89
- */
90
- getTabId?: (itemKey: string, index: number) => string;
91
- }
92
-
93
- /**
94
- * {@docCategory Tabs}
95
- */
96
- export type TabsStyleProps = Required<Pick<TabsProps, 'theme'>> &
97
- Pick<TabsProps, 'className'> & {
98
- tabSize?: TabSizeType;
99
- tabFormat?: TabFormatType;
100
- };
101
-
102
- /**
103
- * {@docCategory Tabs}
104
- */
105
- export interface TabsStyles {
106
- /**
107
- * Style for the root element.
108
- */
109
- root: IStyle;
110
- tab: IStyle;
111
- tabIsSelected: IStyle;
112
- tabContent: IStyle;
113
- text: IStyle;
114
- count: IStyle;
115
- icon: IStyle;
116
- tabInMenu: IStyle;
117
- overflowMenuButton: IStyle;
118
- itemContainer?: IStyle;
119
- }
120
-
121
- /**
122
- * {@docCategory Tabs}
123
- * Display mode for the tabs
124
- */
125
- export type TabFormatType = 'links' | 'tabs';
126
-
127
- /**
128
- * {@docCategory Tabs}
129
- * Size of the tabs
130
- */
131
- export type TabSizeType = 'normal' | 'large';