@fluentui/react-tabs 1.0.0-beta.17 → 1.0.0-beta.173

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 (244) hide show
  1. package/CHANGELOG.json +3135 -0
  2. package/CHANGELOG.md +1338 -1
  3. package/config/tests.js +0 -4
  4. package/dist/react-tabs.d.ts +68 -122
  5. package/etc/react-tabs.api.md +47 -64
  6. package/lib/{next/Tabs.d.ts → Tabs.d.ts} +0 -0
  7. package/lib/{next/Tabs.js → Tabs.js} +0 -0
  8. package/lib/Tabs.js.map +1 -0
  9. package/lib/common/isConformant.d.ts +4 -2
  10. package/lib/common/isConformant.js.map +1 -1
  11. package/{lib-commonjs/next → lib}/components/Tabs/TabItem.d.ts +1 -1
  12. package/lib/{next/components → components}/Tabs/TabItem.js +0 -0
  13. package/lib/components/Tabs/TabItem.js.map +1 -0
  14. package/{lib-commonjs/next → lib}/components/Tabs/TabItem.types.d.ts +3 -6
  15. package/lib/components/Tabs/TabItem.types.js +2 -0
  16. package/lib/components/Tabs/TabItem.types.js.map +1 -0
  17. package/{lib-amd/next → lib}/components/Tabs/Tabs.base.d.ts +1 -1
  18. package/lib/{next/components → components}/Tabs/Tabs.base.js +5 -5
  19. package/lib/components/Tabs/Tabs.base.js.map +1 -0
  20. package/{lib-commonjs/next → lib}/components/Tabs/Tabs.d.ts +1 -1
  21. package/lib/{next/components → components}/Tabs/Tabs.js +0 -0
  22. package/lib/components/Tabs/Tabs.js.map +1 -0
  23. package/lib/{next/components → components}/Tabs/Tabs.styles.d.ts +1 -1
  24. package/lib/{next/components → components}/Tabs/Tabs.styles.js +3 -8
  25. package/lib/components/Tabs/Tabs.styles.js.map +1 -0
  26. package/{lib-amd/next → lib}/components/Tabs/Tabs.types.d.ts +2 -16
  27. package/lib/components/Tabs/Tabs.types.js +2 -0
  28. package/lib/components/Tabs/Tabs.types.js.map +1 -0
  29. package/lib/{next/components → components}/Tabs/index.d.ts +0 -0
  30. package/lib/components/Tabs/index.js +6 -0
  31. package/lib/components/Tabs/index.js.map +1 -0
  32. package/lib/index.d.ts +1 -3
  33. package/lib/index.js +1 -3
  34. package/lib/index.js.map +1 -1
  35. package/lib/tsdoc-metadata.json +1 -1
  36. package/lib/utilities/observeResize.d.ts +1 -1
  37. package/lib/utilities/useOverflow.d.ts +1 -1
  38. package/lib/utilities/useOverflow.js +1 -0
  39. package/lib/utilities/useOverflow.js.map +1 -1
  40. package/lib-amd/{next/Tabs.d.ts → Tabs.d.ts} +0 -0
  41. package/lib-amd/{next/Tabs.js → Tabs.js} +0 -0
  42. package/lib-amd/Tabs.js.map +1 -0
  43. package/lib-amd/common/isConformant.d.ts +4 -2
  44. package/lib-amd/common/isConformant.js +1 -0
  45. package/lib-amd/common/isConformant.js.map +1 -1
  46. package/{lib/next → lib-amd}/components/Tabs/TabItem.d.ts +1 -1
  47. package/lib-amd/{next/components → components}/Tabs/TabItem.js +1 -0
  48. package/lib-amd/components/Tabs/TabItem.js.map +1 -0
  49. package/{lib/next → lib-amd}/components/Tabs/TabItem.types.d.ts +3 -6
  50. package/lib-amd/{next/components → components}/Tabs/TabItem.types.js +0 -0
  51. package/lib-amd/components/Tabs/TabItem.types.js.map +1 -0
  52. package/{lib/next → lib-amd}/components/Tabs/Tabs.base.d.ts +1 -1
  53. package/lib-amd/{next/components → components}/Tabs/Tabs.base.js +7 -6
  54. package/lib-amd/components/Tabs/Tabs.base.js.map +1 -0
  55. package/{lib/next → lib-amd}/components/Tabs/Tabs.d.ts +1 -1
  56. package/lib-amd/{next/components → components}/Tabs/Tabs.js +1 -0
  57. package/lib-amd/components/Tabs/Tabs.js.map +1 -0
  58. package/lib-amd/{next/components → components}/Tabs/Tabs.styles.d.ts +1 -1
  59. package/lib-amd/{next/components → components}/Tabs/Tabs.styles.js +4 -7
  60. package/lib-amd/components/Tabs/Tabs.styles.js.map +1 -0
  61. package/{lib/next → lib-amd}/components/Tabs/Tabs.types.d.ts +2 -16
  62. package/lib-amd/{next/components → components}/Tabs/Tabs.types.js +0 -0
  63. package/lib-amd/components/Tabs/Tabs.types.js.map +1 -0
  64. package/lib-amd/{next/components → components}/Tabs/index.d.ts +0 -0
  65. package/lib-amd/components/Tabs/index.js +11 -0
  66. package/lib-amd/components/Tabs/index.js.map +1 -0
  67. package/lib-amd/index.d.ts +1 -3
  68. package/lib-amd/index.js +2 -3
  69. package/lib-amd/index.js.map +1 -1
  70. package/lib-amd/utilities/observeResize.d.ts +1 -1
  71. package/lib-amd/utilities/observeResize.js +3 -1
  72. package/lib-amd/utilities/observeResize.js.map +1 -1
  73. package/lib-amd/utilities/useOverflow.d.ts +1 -1
  74. package/lib-amd/utilities/useOverflow.js +4 -1
  75. package/lib-amd/utilities/useOverflow.js.map +1 -1
  76. package/lib-commonjs/{next/Tabs.d.ts → Tabs.d.ts} +0 -0
  77. package/lib-commonjs/{next/Tabs.js → Tabs.js} +0 -0
  78. package/lib-commonjs/Tabs.js.map +1 -0
  79. package/lib-commonjs/common/isConformant.d.ts +4 -2
  80. package/lib-commonjs/common/isConformant.js +1 -0
  81. package/lib-commonjs/common/isConformant.js.map +1 -1
  82. package/{lib-amd/next → lib-commonjs}/components/Tabs/TabItem.d.ts +1 -1
  83. package/lib-commonjs/{next/components → components}/Tabs/TabItem.js +1 -0
  84. package/lib-commonjs/components/Tabs/TabItem.js.map +1 -0
  85. package/{lib-amd/next → lib-commonjs}/components/Tabs/TabItem.types.d.ts +3 -6
  86. package/lib-commonjs/{next/components → components}/Tabs/TabItem.types.js +0 -0
  87. package/lib-commonjs/components/Tabs/TabItem.types.js.map +1 -0
  88. package/lib-commonjs/{next/components → components}/Tabs/Tabs.base.d.ts +1 -1
  89. package/lib-commonjs/{next/components → components}/Tabs/Tabs.base.js +9 -8
  90. package/lib-commonjs/components/Tabs/Tabs.base.js.map +1 -0
  91. package/{lib-amd/next → lib-commonjs}/components/Tabs/Tabs.d.ts +1 -1
  92. package/lib-commonjs/{next/components → components}/Tabs/Tabs.js +1 -0
  93. package/lib-commonjs/components/Tabs/Tabs.js.map +1 -0
  94. package/lib-commonjs/{next/components → components}/Tabs/Tabs.styles.d.ts +1 -1
  95. package/lib-commonjs/{next/components → components}/Tabs/Tabs.styles.js +4 -7
  96. package/lib-commonjs/components/Tabs/Tabs.styles.js.map +1 -0
  97. package/lib-commonjs/{next/components → components}/Tabs/Tabs.types.d.ts +2 -16
  98. package/lib-commonjs/{next/components → components}/Tabs/Tabs.types.js +0 -0
  99. package/lib-commonjs/components/Tabs/Tabs.types.js.map +1 -0
  100. package/lib-commonjs/{next/components → components}/Tabs/index.d.ts +0 -0
  101. package/lib-commonjs/components/Tabs/index.js +11 -0
  102. package/lib-commonjs/components/Tabs/index.js.map +1 -0
  103. package/lib-commonjs/index.d.ts +1 -3
  104. package/lib-commonjs/index.js +1 -3
  105. package/lib-commonjs/index.js.map +1 -1
  106. package/lib-commonjs/utilities/observeResize.d.ts +1 -1
  107. package/lib-commonjs/utilities/observeResize.js +3 -1
  108. package/lib-commonjs/utilities/observeResize.js.map +1 -1
  109. package/lib-commonjs/utilities/useOverflow.d.ts +1 -1
  110. package/lib-commonjs/utilities/useOverflow.js +4 -1
  111. package/lib-commonjs/utilities/useOverflow.js.map +1 -1
  112. package/package.json +24 -26
  113. package/src/{next/components → components}/Tabs/TabItem.types.ts +3 -6
  114. package/src/{next/components → components}/Tabs/Tabs.types.ts +2 -16
  115. package/lib/Pivot.d.ts +0 -1
  116. package/lib/Pivot.js +0 -2
  117. package/lib/Pivot.js.map +0 -1
  118. package/lib/components/Pivot/Pivot.base.d.ts +0 -3
  119. package/lib/components/Pivot/Pivot.base.js +0 -183
  120. package/lib/components/Pivot/Pivot.base.js.map +0 -1
  121. package/lib/components/Pivot/Pivot.d.ts +0 -8
  122. package/lib/components/Pivot/Pivot.js +0 -12
  123. package/lib/components/Pivot/Pivot.js.map +0 -1
  124. package/lib/components/Pivot/Pivot.styles.d.ts +0 -2
  125. package/lib/components/Pivot/Pivot.styles.js +0 -269
  126. package/lib/components/Pivot/Pivot.styles.js.map +0 -1
  127. package/lib/components/Pivot/Pivot.types.d.ts +0 -141
  128. package/lib/components/Pivot/Pivot.types.js +0 -31
  129. package/lib/components/Pivot/Pivot.types.js.map +0 -1
  130. package/lib/components/Pivot/PivotItem.d.ts +0 -6
  131. package/lib/components/Pivot/PivotItem.js +0 -21
  132. package/lib/components/Pivot/PivotItem.js.map +0 -1
  133. package/lib/components/Pivot/PivotItem.types.d.ts +0 -66
  134. package/lib/components/Pivot/PivotItem.types.js +0 -1
  135. package/lib/components/Pivot/PivotItem.types.js.map +0 -1
  136. package/lib/components/Pivot/index.d.ts +0 -5
  137. package/lib/components/Pivot/index.js +0 -5
  138. package/lib/components/Pivot/index.js.map +0 -1
  139. package/lib/next/Tabs.js.map +0 -1
  140. package/lib/next/components/Tabs/TabItem.js.map +0 -1
  141. package/lib/next/components/Tabs/TabItem.types.js +0 -1
  142. package/lib/next/components/Tabs/TabItem.types.js.map +0 -1
  143. package/lib/next/components/Tabs/Tabs.base.js.map +0 -1
  144. package/lib/next/components/Tabs/Tabs.js.map +0 -1
  145. package/lib/next/components/Tabs/Tabs.styles.js.map +0 -1
  146. package/lib/next/components/Tabs/Tabs.types.js +0 -1
  147. package/lib/next/components/Tabs/Tabs.types.js.map +0 -1
  148. package/lib/next/components/Tabs/index.js +0 -4
  149. package/lib/next/components/Tabs/index.js.map +0 -1
  150. package/lib/next/index.d.ts +0 -2
  151. package/lib/next/index.js +0 -3
  152. package/lib/next/index.js.map +0 -1
  153. package/lib/next.d.ts +0 -1
  154. package/lib/next.js +0 -2
  155. package/lib/next.js.map +0 -1
  156. package/lib/version.d.ts +0 -1
  157. package/lib/version.js +0 -5
  158. package/lib/version.js.map +0 -1
  159. package/lib-amd/Pivot.d.ts +0 -1
  160. package/lib-amd/Pivot.js +0 -6
  161. package/lib-amd/Pivot.js.map +0 -1
  162. package/lib-amd/components/Pivot/Pivot.base.d.ts +0 -3
  163. package/lib-amd/components/Pivot/Pivot.base.js +0 -179
  164. package/lib-amd/components/Pivot/Pivot.base.js.map +0 -1
  165. package/lib-amd/components/Pivot/Pivot.d.ts +0 -8
  166. package/lib-amd/components/Pivot/Pivot.js +0 -13
  167. package/lib-amd/components/Pivot/Pivot.js.map +0 -1
  168. package/lib-amd/components/Pivot/Pivot.styles.d.ts +0 -2
  169. package/lib-amd/components/Pivot/Pivot.styles.js +0 -270
  170. package/lib-amd/components/Pivot/Pivot.styles.js.map +0 -1
  171. package/lib-amd/components/Pivot/Pivot.types.d.ts +0 -141
  172. package/lib-amd/components/Pivot/Pivot.types.js +0 -35
  173. package/lib-amd/components/Pivot/Pivot.types.js.map +0 -1
  174. package/lib-amd/components/Pivot/PivotItem.d.ts +0 -6
  175. package/lib-amd/components/Pivot/PivotItem.js +0 -22
  176. package/lib-amd/components/Pivot/PivotItem.js.map +0 -1
  177. package/lib-amd/components/Pivot/PivotItem.types.d.ts +0 -66
  178. package/lib-amd/components/Pivot/PivotItem.types.js +0 -5
  179. package/lib-amd/components/Pivot/PivotItem.types.js.map +0 -1
  180. package/lib-amd/components/Pivot/index.d.ts +0 -5
  181. package/lib-amd/components/Pivot/index.js +0 -9
  182. package/lib-amd/components/Pivot/index.js.map +0 -1
  183. package/lib-amd/next/Tabs.js.map +0 -1
  184. package/lib-amd/next/components/Tabs/TabItem.js.map +0 -1
  185. package/lib-amd/next/components/Tabs/TabItem.types.js.map +0 -1
  186. package/lib-amd/next/components/Tabs/Tabs.base.js.map +0 -1
  187. package/lib-amd/next/components/Tabs/Tabs.js.map +0 -1
  188. package/lib-amd/next/components/Tabs/Tabs.styles.js.map +0 -1
  189. package/lib-amd/next/components/Tabs/Tabs.types.js.map +0 -1
  190. package/lib-amd/next/components/Tabs/index.js +0 -8
  191. package/lib-amd/next/components/Tabs/index.js.map +0 -1
  192. package/lib-amd/next/index.d.ts +0 -2
  193. package/lib-amd/next/index.js +0 -7
  194. package/lib-amd/next/index.js.map +0 -1
  195. package/lib-amd/next.d.ts +0 -1
  196. package/lib-amd/next.js +0 -6
  197. package/lib-amd/next.js.map +0 -1
  198. package/lib-amd/version.d.ts +0 -1
  199. package/lib-amd/version.js +0 -6
  200. package/lib-amd/version.js.map +0 -1
  201. package/lib-commonjs/Pivot.d.ts +0 -1
  202. package/lib-commonjs/Pivot.js +0 -5
  203. package/lib-commonjs/Pivot.js.map +0 -1
  204. package/lib-commonjs/components/Pivot/Pivot.base.d.ts +0 -3
  205. package/lib-commonjs/components/Pivot/Pivot.base.js +0 -185
  206. package/lib-commonjs/components/Pivot/Pivot.base.js.map +0 -1
  207. package/lib-commonjs/components/Pivot/Pivot.d.ts +0 -8
  208. package/lib-commonjs/components/Pivot/Pivot.js +0 -14
  209. package/lib-commonjs/components/Pivot/Pivot.js.map +0 -1
  210. package/lib-commonjs/components/Pivot/Pivot.styles.d.ts +0 -2
  211. package/lib-commonjs/components/Pivot/Pivot.styles.js +0 -271
  212. package/lib-commonjs/components/Pivot/Pivot.styles.js.map +0 -1
  213. package/lib-commonjs/components/Pivot/Pivot.types.d.ts +0 -141
  214. package/lib-commonjs/components/Pivot/Pivot.types.js +0 -33
  215. package/lib-commonjs/components/Pivot/Pivot.types.js.map +0 -1
  216. package/lib-commonjs/components/Pivot/PivotItem.d.ts +0 -6
  217. package/lib-commonjs/components/Pivot/PivotItem.js +0 -23
  218. package/lib-commonjs/components/Pivot/PivotItem.js.map +0 -1
  219. package/lib-commonjs/components/Pivot/PivotItem.types.d.ts +0 -66
  220. package/lib-commonjs/components/Pivot/PivotItem.types.js +0 -3
  221. package/lib-commonjs/components/Pivot/PivotItem.types.js.map +0 -1
  222. package/lib-commonjs/components/Pivot/index.d.ts +0 -5
  223. package/lib-commonjs/components/Pivot/index.js +0 -9
  224. package/lib-commonjs/components/Pivot/index.js.map +0 -1
  225. package/lib-commonjs/next/Tabs.js.map +0 -1
  226. package/lib-commonjs/next/components/Tabs/TabItem.js.map +0 -1
  227. package/lib-commonjs/next/components/Tabs/TabItem.types.js.map +0 -1
  228. package/lib-commonjs/next/components/Tabs/Tabs.base.js.map +0 -1
  229. package/lib-commonjs/next/components/Tabs/Tabs.js.map +0 -1
  230. package/lib-commonjs/next/components/Tabs/Tabs.styles.js.map +0 -1
  231. package/lib-commonjs/next/components/Tabs/Tabs.types.js.map +0 -1
  232. package/lib-commonjs/next/components/Tabs/index.js +0 -8
  233. package/lib-commonjs/next/components/Tabs/index.js.map +0 -1
  234. package/lib-commonjs/next/index.d.ts +0 -2
  235. package/lib-commonjs/next/index.js +0 -6
  236. package/lib-commonjs/next/index.js.map +0 -1
  237. package/lib-commonjs/next.d.ts +0 -1
  238. package/lib-commonjs/next.js +0 -5
  239. package/lib-commonjs/next.js.map +0 -1
  240. package/lib-commonjs/version.d.ts +0 -1
  241. package/lib-commonjs/version.js +0 -7
  242. package/lib-commonjs/version.js.map +0 -1
  243. package/src/components/Pivot/Pivot.types.ts +0 -166
  244. package/src/components/Pivot/PivotItem.types.ts +0 -76
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":";;;AAAA,qBAAmB;AAEnB,kDAAwB;AACxB,yEAA+C","sourcesContent":["import './version';\n\nexport * from './Pivot';\nexport * from '@fluentui/react-theme-provider';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":";;;AAAA,iDAAuB","sourcesContent":["export * from './Tabs';\n"]}
@@ -12,7 +12,7 @@
12
12
  *
13
13
  * @returns A function to clean up the observer/listener.
14
14
  */
15
- export declare const observeResize: (target: Element | Element[], onResize: (entries: readonly ResizeObserverEntry[] | undefined) => void) => () => void;
15
+ export declare const observeResize: (target: Element | Element[], onResize: (entries: readonly ResizeObserverEntry[] | undefined) => void) => (() => void);
16
16
  /** Temporary type definition for ResizeObserverEntry. Can be removed when official types are available. */
17
17
  declare type ResizeObserverEntry = {
18
18
  readonly contentRect: DOMRectReadOnly;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.observeResize = void 0;
3
4
  var utilities_1 = require("@fluentui/utilities");
4
5
  /**
5
6
  * Wrapper for ResizeObserver, with fallback for browsers that don't support ResizeObserver.
@@ -15,7 +16,7 @@ var utilities_1 = require("@fluentui/utilities");
15
16
  *
16
17
  * @returns A function to clean up the observer/listener.
17
18
  */
18
- exports.observeResize = function (target, onResize) {
19
+ var observeResize = function (target, onResize) {
19
20
  if (typeof ResizeObserver !== 'undefined') {
20
21
  var observer_1 = new ResizeObserver(onResize);
21
22
  if (Array.isArray(target)) {
@@ -45,4 +46,5 @@ exports.observeResize = function (target, onResize) {
45
46
  };
46
47
  }
47
48
  };
49
+ exports.observeResize = observeResize;
48
50
  //# sourceMappingURL=observeResize.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"observeResize.js","sourceRoot":"../src/","sources":["utilities/observeResize.ts"],"names":[],"mappings":";;AAAA,iDAAgD;AAEhD;;;;;;;;;;;;;GAaG;AACU,QAAA,aAAa,GAAG,UAC3B,MAA2B,EAC3B,QAAuE;IAEvE,IAAI,OAAO,cAAc,KAAK,WAAW,EAAE;QACzC,IAAM,UAAQ,GAAG,IAAI,cAAc,CAAC,QAAQ,CAAC,CAAC;QAE9C,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACzB,MAAM,CAAC,OAAO,CAAC,UAAA,CAAC,IAAI,OAAA,UAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAnB,CAAmB,CAAC,CAAC;SAC1C;aAAM;YACL,UAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;SAC1B;QAED,OAAO,cAAM,OAAA,UAAQ,CAAC,UAAU,EAAE,EAArB,CAAqB,CAAC;KACpC;SAAM;QACL,0DAA0D;QAC1D,IAAM,iBAAe,GAAG,cAAM,OAAA,QAAQ,CAAC,SAAS,CAAC,EAAnB,CAAmB,CAAC;QAElD,IAAM,KAAG,GAAG,qBAAS,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAClE,IAAI,CAAC,KAAG,EAAE;YACR,4DAA4D;YAC5D,OAAO;gBACL,sBAAsB;YACxB,CAAC,CAAC;SACH;QAED,mFAAmF;QACnF,IAAM,kBAAgB,GAAG,KAAG,CAAC,qBAAqB,CAAC,iBAAe,CAAC,CAAC;QACpE,KAAG,CAAC,gBAAgB,CAAC,QAAQ,EAAE,iBAAe,EAAE,KAAK,CAAC,CAAC;QAEvD,OAAO;YACL,KAAG,CAAC,oBAAoB,CAAC,kBAAgB,CAAC,CAAC;YAC3C,KAAG,CAAC,mBAAmB,CAAC,QAAQ,EAAE,iBAAe,EAAE,KAAK,CAAC,CAAC;QAC5D,CAAC,CAAC;KACH;AACH,CAAC,CAAC","sourcesContent":["import { getWindow } from '@fluentui/utilities';\n\n/**\n * Wrapper for ResizeObserver, with fallback for browsers that don't support ResizeObserver.\n *\n * Calls the onResize callback once layout is complete, and again whenever any of the target(s) change size.\n * Or if ResizeObserver isn't supported, calls the callback whenever the window changes size.\n *\n * @param target - Either a single element, or array of elements to watch for size changes.\n * @param onResize - Callback to be notified when layout is complete, and when the target(s) change size.\n * If this browser supports ResizeObserver, the callback will be passed the ResizeObserverEntry[] array.\n * Otherwise, the entries array will be undefined, and you'll need to find another way to get the element's size,\n * (e.g. clientWidth/clientHeight or getBoundingClientRect).\n *\n * @returns A function to clean up the observer/listener.\n */\nexport const observeResize = (\n target: Element | Element[],\n onResize: (entries: readonly ResizeObserverEntry[] | undefined) => void,\n): (() => void) => {\n if (typeof ResizeObserver !== 'undefined') {\n const observer = new ResizeObserver(onResize);\n\n if (Array.isArray(target)) {\n target.forEach(t => observer.observe(t));\n } else {\n observer.observe(target);\n }\n\n return () => observer.disconnect();\n } else {\n // Fallback for browsers that don't support ResizeObserver\n const onResizeWrapper = () => onResize(undefined);\n\n const win = getWindow(Array.isArray(target) ? target[0] : target);\n if (!win) {\n // Can't listen for resize if we can't get the window object\n return () => {\n // Nothing to clean up\n };\n }\n\n // Listen for the first animation frame, which will happen after layout is complete\n const animationFrameId = win.requestAnimationFrame(onResizeWrapper);\n win.addEventListener('resize', onResizeWrapper, false);\n\n return () => {\n win.cancelAnimationFrame(animationFrameId);\n win.removeEventListener('resize', onResizeWrapper, false);\n };\n }\n};\n\n/** Temporary type definition for ResizeObserver. Can be removed when official types are available. */\ntype ResizeObserver = {\n new (callback: (entries: readonly ResizeObserverEntry[], observer: ResizeObserver) => void): ResizeObserver;\n observe(target: Element, options?: { box: 'content-box' | 'border-box' }): void;\n unobserve(target: Element): void;\n disconnect(): void;\n};\n\n/** Temporary type definition for ResizeObserverEntry. Can be removed when official types are available. */\ntype ResizeObserverEntry = {\n readonly contentRect: DOMRectReadOnly;\n readonly target: Element;\n};\n\n/** Temporary definition for ResizeObserver. Can be removed when official types are available. */\ndeclare const ResizeObserver: ResizeObserver | undefined;\n"]}
1
+ {"version":3,"file":"observeResize.js","sourceRoot":"../src/","sources":["utilities/observeResize.ts"],"names":[],"mappings":";;;AAAA,iDAAgD;AAEhD;;;;;;;;;;;;;GAaG;AACI,IAAM,aAAa,GAAG,UAC3B,MAA2B,EAC3B,QAAuE;IAEvE,IAAI,OAAO,cAAc,KAAK,WAAW,EAAE;QACzC,IAAM,UAAQ,GAAG,IAAI,cAAc,CAAC,QAAQ,CAAC,CAAC;QAE9C,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACzB,MAAM,CAAC,OAAO,CAAC,UAAA,CAAC,IAAI,OAAA,UAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAnB,CAAmB,CAAC,CAAC;SAC1C;aAAM;YACL,UAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;SAC1B;QAED,OAAO,cAAM,OAAA,UAAQ,CAAC,UAAU,EAAE,EAArB,CAAqB,CAAC;KACpC;SAAM;QACL,0DAA0D;QAC1D,IAAM,iBAAe,GAAG,cAAM,OAAA,QAAQ,CAAC,SAAS,CAAC,EAAnB,CAAmB,CAAC;QAElD,IAAM,KAAG,GAAG,qBAAS,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAClE,IAAI,CAAC,KAAG,EAAE;YACR,4DAA4D;YAC5D,OAAO;gBACL,sBAAsB;YACxB,CAAC,CAAC;SACH;QAED,mFAAmF;QACnF,IAAM,kBAAgB,GAAG,KAAG,CAAC,qBAAqB,CAAC,iBAAe,CAAC,CAAC;QACpE,KAAG,CAAC,gBAAgB,CAAC,QAAQ,EAAE,iBAAe,EAAE,KAAK,CAAC,CAAC;QAEvD,OAAO;YACL,KAAG,CAAC,oBAAoB,CAAC,kBAAgB,CAAC,CAAC;YAC3C,KAAG,CAAC,mBAAmB,CAAC,QAAQ,EAAE,iBAAe,EAAE,KAAK,CAAC,CAAC;QAC5D,CAAC,CAAC;KACH;AACH,CAAC,CAAC;AAnCW,QAAA,aAAa,iBAmCxB","sourcesContent":["import { getWindow } from '@fluentui/utilities';\n\n/**\n * Wrapper for ResizeObserver, with fallback for browsers that don't support ResizeObserver.\n *\n * Calls the onResize callback once layout is complete, and again whenever any of the target(s) change size.\n * Or if ResizeObserver isn't supported, calls the callback whenever the window changes size.\n *\n * @param target - Either a single element, or array of elements to watch for size changes.\n * @param onResize - Callback to be notified when layout is complete, and when the target(s) change size.\n * If this browser supports ResizeObserver, the callback will be passed the ResizeObserverEntry[] array.\n * Otherwise, the entries array will be undefined, and you'll need to find another way to get the element's size,\n * (e.g. clientWidth/clientHeight or getBoundingClientRect).\n *\n * @returns A function to clean up the observer/listener.\n */\nexport const observeResize = (\n target: Element | Element[],\n onResize: (entries: readonly ResizeObserverEntry[] | undefined) => void,\n): (() => void) => {\n if (typeof ResizeObserver !== 'undefined') {\n const observer = new ResizeObserver(onResize);\n\n if (Array.isArray(target)) {\n target.forEach(t => observer.observe(t));\n } else {\n observer.observe(target);\n }\n\n return () => observer.disconnect();\n } else {\n // Fallback for browsers that don't support ResizeObserver\n const onResizeWrapper = () => onResize(undefined);\n\n const win = getWindow(Array.isArray(target) ? target[0] : target);\n if (!win) {\n // Can't listen for resize if we can't get the window object\n return () => {\n // Nothing to clean up\n };\n }\n\n // Listen for the first animation frame, which will happen after layout is complete\n const animationFrameId = win.requestAnimationFrame(onResizeWrapper);\n win.addEventListener('resize', onResizeWrapper, false);\n\n return () => {\n win.cancelAnimationFrame(animationFrameId);\n win.removeEventListener('resize', onResizeWrapper, false);\n };\n }\n};\n\n/** Temporary type definition for ResizeObserver. Can be removed when official types are available. */\ntype ResizeObserver = {\n new (callback: (entries: readonly ResizeObserverEntry[], observer: ResizeObserver) => void): ResizeObserver;\n observe(target: Element, options?: { box: 'content-box' | 'border-box' }): void;\n unobserve(target: Element): void;\n disconnect(): void;\n};\n\n/** Temporary type definition for ResizeObserverEntry. Can be removed when official types are available. */\ntype ResizeObserverEntry = {\n readonly contentRect: DOMRectReadOnly;\n readonly target: Element;\n};\n\n/** Temporary definition for ResizeObserver. Can be removed when official types are available. */\ndeclare const ResizeObserver: ResizeObserver | undefined;\n"]}
@@ -1,4 +1,4 @@
1
- import { RefCallback } from '@fluentui/react-hooks';
1
+ import type { RefCallback } from '@fluentui/react-hooks';
2
2
  /**
3
3
  * Callback to notify the user that the items in the overflow have changed. This should ensure that the overflow menu
4
4
  * is visible, and contains all of the overflowing items.
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useOverflow = void 0;
3
4
  var React = require("react");
4
5
  var react_hooks_1 = require("@fluentui/react-hooks");
5
6
  var utilities_1 = require("@fluentui/utilities");
@@ -22,7 +23,7 @@ var observeResize_1 = require("./observeResize");
22
23
  * </Container>
23
24
  * ```
24
25
  */
25
- exports.useOverflow = function (_a) {
26
+ var useOverflow = function (_a) {
26
27
  var onOverflowItemsChanged = _a.onOverflowItemsChanged, rtl = _a.rtl, pinnedIndex = _a.pinnedIndex;
27
28
  var updateOverflowRef = React.useRef();
28
29
  var containerWidthRef = React.useRef();
@@ -43,6 +44,7 @@ exports.useOverflow = function (_a) {
43
44
  containerRef(menuButton.parentElement);
44
45
  return function () { return containerRef(null); };
45
46
  });
47
+ // eslint-disable-next-line no-restricted-properties
46
48
  React.useLayoutEffect(function () {
47
49
  var container = containerRef.current;
48
50
  var menuButton = menuButtonRef.current;
@@ -124,4 +126,5 @@ exports.useOverflow = function (_a) {
124
126
  });
125
127
  return { menuButtonRef: menuButtonRef };
126
128
  };
129
+ exports.useOverflow = useOverflow;
127
130
  //# sourceMappingURL=useOverflow.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useOverflow.js","sourceRoot":"../src/","sources":["utilities/useOverflow.ts"],"names":[],"mappings":";;AAAA,6BAA+B;AAC/B,qDAAkE;AAClE,iDAAgD;AAChD,iDAAgD;AAgChD;;;;;;;;;;;;;;;;;GAiBG;AACU,QAAA,WAAW,GAAG,UAAC,EAA4D;QAA1D,kDAAsB,EAAE,YAAG,EAAE,4BAAW;IACpE,IAAM,iBAAiB,GAAG,KAAK,CAAC,MAAM,EAAc,CAAC;IACrD,IAAM,iBAAiB,GAAG,KAAK,CAAC,MAAM,EAAU,CAAC;IAEjD,4CAA4C;IAC5C,IAAM,YAAY,GAAG,0BAAY,CAAc,UAAA,SAAS;QACtD,IAAM,eAAe,GAAG,6BAAa,CAAC,SAAS,EAAE,UAAA,OAAO;YACtD,iBAAiB,CAAC,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC;YAC3F,IAAI,iBAAiB,CAAC,OAAO,EAAE;gBAC7B,iBAAiB,CAAC,OAAO,EAAE,CAAC;aAC7B;QACH,CAAC,CAAC,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,IAAI,aAAa,IAAI,KAAK,KAAK,WAAW;iBAC/D,CAAC,EAHwB,CAGxB,CAAC,CACJ,CAAC;aACH;QACH,CAAC,CAAC;QAEF,IAAI,oBAAoB,GAA6B,SAAS,CAAC;QAE/D,sGAAsG;QACtG,yEAAyE;QACzE,IAAI,iBAAiB,CAAC,OAAO,KAAK,SAAS,EAAE;YAC3C,IAAM,KAAG,GAAG,qBAAS,CAAC,SAAS,CAAC,CAAC;YACjC,IAAI,KAAG,EAAE;gBACP,IAAM,kBAAgB,GAAG,KAAG,CAAC,qBAAqB,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;gBAC9E,oBAAoB,GAAG,cAAM,OAAA,KAAG,CAAC,oBAAoB,CAAC,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","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 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
+ {"version":3,"file":"useOverflow.js","sourceRoot":"../src/","sources":["utilities/useOverflow.ts"],"names":[],"mappings":";;;AAAA,6BAA+B;AAC/B,qDAAqD;AACrD,iDAAgD;AAChD,iDAAgD;AAiChD;;;;;;;;;;;;;;;;;GAiBG;AACI,IAAM,WAAW,GAAG,UAAC,EAA4D;QAA1D,sBAAsB,4BAAA,EAAE,GAAG,SAAA,EAAE,WAAW,iBAAA;IACpE,IAAM,iBAAiB,GAAG,KAAK,CAAC,MAAM,EAAc,CAAC;IACrD,IAAM,iBAAiB,GAAG,KAAK,CAAC,MAAM,EAAU,CAAC;IAEjD,4CAA4C;IAC5C,IAAM,YAAY,GAAG,0BAAY,CAAc,UAAA,SAAS;QACtD,IAAM,eAAe,GAAG,6BAAa,CAAC,SAAS,EAAE,UAAA,OAAO;YACtD,iBAAiB,CAAC,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC;YAC3F,IAAI,iBAAiB,CAAC,OAAO,EAAE;gBAC7B,iBAAiB,CAAC,OAAO,EAAE,CAAC;aAC7B;QACH,CAAC,CAAC,CAAC;QAEH,OAAO;YACL,eAAe,EAAE,CAAC;YAClB,iBAAiB,CAAC,OAAO,GAAG,SAAS,CAAC;QACxC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,IAAM,aAAa,GAAG,0BAAY,CAAc,UAAA,UAAU;QACxD,YAAY,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;QACvC,OAAO,cAAM,OAAA,YAAY,CAAC,IAAI,CAAC,EAAlB,CAAkB,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,oDAAoD;IACpD,KAAK,CAAC,eAAe,C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C,qBAAqB,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;gBAC9E,oBAAoB,GAAG,cAAM,OAAA,KAAG,CAAC,oBAAoB,CAAC,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 } from '@fluentui/react-hooks';\nimport { getWindow } from '@fluentui/utilities';\nimport { observeResize } from './observeResize';\nimport type { RefCallback } from '@fluentui/react-hooks';\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"]}
package/package.json CHANGED
@@ -1,13 +1,11 @@
1
1
  {
2
2
  "name": "@fluentui/react-tabs",
3
- "version": "1.0.0-beta.17",
3
+ "version": "1.0.0-beta.173",
4
4
  "description": "Fluent UI React Tabs component",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
7
7
  "typings": "lib/index.d.ts",
8
- "sideEffects": [
9
- "lib/version.js"
10
- ],
8
+ "sideEffects": false,
11
9
  "repository": {
12
10
  "type": "git",
13
11
  "url": "https://github.com/microsoft/fluentui"
@@ -15,7 +13,6 @@
15
13
  "license": "MIT",
16
14
  "scripts": {
17
15
  "build": "just-scripts build",
18
- "bundle": "just-scripts bundle",
19
16
  "clean": "just-scripts clean",
20
17
  "code-style": "just-scripts code-style",
21
18
  "just": "just-scripts",
@@ -23,39 +20,40 @@
23
20
  "start": "just-scripts dev:storybook",
24
21
  "start-test": "just-scripts jest-watch",
25
22
  "test": "just-scripts test",
26
- "update-api": "just-scripts update-api",
27
23
  "update-snapshots": "just-scripts jest -u"
28
24
  },
29
25
  "devDependencies": {
30
- "@fluentui/common-styles": "^1.0.0-beta.7",
31
- "@fluentui/eslint-plugin": "^1.0.0-beta.0",
32
- "@fluentui/react-conformance": "^1.0.0",
26
+ "@fluentui/eslint-plugin": "*",
27
+ "@fluentui/react-conformance": "*",
28
+ "@fluentui/scripts": "^1.0.0",
33
29
  "@types/enzyme": "3.10.3",
34
30
  "@types/enzyme-adapter-react-16": "1.0.3",
35
- "@types/jest": "~24.9.0",
36
- "@types/react": "16.8.25",
37
- "@types/react-dom": "16.8.4",
31
+ "@types/react": "16.9.42",
32
+ "@types/react-dom": "16.9.10",
38
33
  "@types/react-test-renderer": "^16.0.0",
39
- "@types/webpack-env": "1.15.1",
40
- "@fluentui/scripts": "^1.0.0",
41
34
  "enzyme": "~3.10.0",
42
35
  "react": "16.8.6",
43
- "react-app-polyfill": "~1.0.1",
44
36
  "react-dom": "16.8.6"
45
37
  },
46
38
  "dependencies": {
47
- "@fluentui/react-internal": "^8.0.0-beta.18",
48
- "@fluentui/react-theme-provider": "^1.0.0-beta.10",
49
- "@fluentui/react-hooks": "^8.0.0-beta.6",
50
- "@fluentui/set-version": "^8.0.0-beta.0",
51
- "@fluentui/style-utilities": "^8.0.0-beta.7",
52
- "@fluentui/utilities": "^8.0.0-beta.6",
53
- "tslib": "^1.10.0"
39
+ "@fluentui/react": "^8.37.2",
40
+ "@fluentui/react-hooks": "^8.3.4",
41
+ "@fluentui/style-utilities": "^8.3.4",
42
+ "@fluentui/utilities": "^8.3.4",
43
+ "tslib": "^2.1.0"
54
44
  },
55
45
  "peerDependencies": {
56
- "@types/react": ">=16.8.0 <17.0.0",
57
- "@types/react-dom": ">=16.8.0 <17.0.0",
58
- "react": ">=16.8.0 <17.0.0",
59
- "react-dom": ">=16.8.0 <17.0.0"
46
+ "@types/react": ">=16.8.0 <18.0.0",
47
+ "@types/react-dom": ">=16.8.0 <18.0.0",
48
+ "react": ">=16.8.0 <18.0.0",
49
+ "react-dom": ">=16.8.0 <18.0.0"
50
+ },
51
+ "beachball": {
52
+ "tag": "beta",
53
+ "disallowedChangeTypes": [
54
+ "major",
55
+ "minor",
56
+ "patch"
57
+ ]
60
58
  }
61
59
  }
@@ -1,11 +1,8 @@
1
1
  import * as React from 'react';
2
- import { IKeytipProps } from '@fluentui/react-internal';
3
- import { IButtonProps } from '@fluentui/react-internal/lib/compat/Button';
4
- import { IRefObject, IRenderFunction } from '@fluentui/utilities';
2
+ import type { IKeytipProps } from '@fluentui/react';
3
+ import type { IButtonProps } from '@fluentui/react/lib/Button';
4
+ import type { IRefObject, IRenderFunction } from '@fluentui/utilities';
5
5
 
6
- /**
7
- * {@docCategory Tabs}
8
- */
9
6
  export interface TabItemProps extends React.HTMLAttributes<HTMLDivElement> {
10
7
  /**
11
8
  * Gets the component ref.
@@ -1,11 +1,8 @@
1
1
  import * as React from 'react';
2
- import { IStyle, ITheme } from '@fluentui/style-utilities';
3
- import { IStyleFunctionOrObject } from '@fluentui/utilities';
4
2
  import { TabItem } from './TabItem';
3
+ import type { IStyle, ITheme } from '@fluentui/style-utilities';
4
+ import type { IStyleFunctionOrObject } from '@fluentui/utilities';
5
5
 
6
- /**
7
- * {@docCategory Tabs}
8
- */
9
6
  export interface TabsImperativeHandle {
10
7
  /**
11
8
  * Sets focus to the first tab.
@@ -13,9 +10,6 @@ export interface TabsImperativeHandle {
13
10
  focus(): void;
14
11
  }
15
12
 
16
- /**
17
- * {@docCategory Tabs}
18
- */
19
13
  export interface TabsProps extends React.HTMLAttributes<HTMLDivElement>, React.RefAttributes<HTMLDivElement> {
20
14
  /**
21
15
  * Optional callback to access the TabsImperativeHandle interface. Use this instead of ref for accessing
@@ -90,18 +84,12 @@ export interface TabsProps extends React.HTMLAttributes<HTMLDivElement>, React.R
90
84
  getTabId?: (itemKey: string, index: number) => string;
91
85
  }
92
86
 
93
- /**
94
- * {@docCategory Tabs}
95
- */
96
87
  export type TabsStyleProps = Required<Pick<TabsProps, 'theme'>> &
97
88
  Pick<TabsProps, 'className'> & {
98
89
  tabSize?: TabSizeType;
99
90
  tabFormat?: TabFormatType;
100
91
  };
101
92
 
102
- /**
103
- * {@docCategory Tabs}
104
- */
105
93
  export interface TabsStyles {
106
94
  /**
107
95
  * Style for the root element.
@@ -119,13 +107,11 @@ export interface TabsStyles {
119
107
  }
120
108
 
121
109
  /**
122
- * {@docCategory Tabs}
123
110
  * Display mode for the tabs
124
111
  */
125
112
  export type TabFormatType = 'links' | 'tabs';
126
113
 
127
114
  /**
128
- * {@docCategory Tabs}
129
115
  * Size of the tabs
130
116
  */
131
117
  export type TabSizeType = 'normal' | 'large';
package/lib/Pivot.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './components/Pivot/index';
package/lib/Pivot.js DELETED
@@ -1,2 +0,0 @@
1
- export * from './components/Pivot/index';
2
- //# sourceMappingURL=Pivot.js.map
package/lib/Pivot.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"Pivot.js","sourceRoot":"../src/","sources":["Pivot.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC","sourcesContent":["export * from './components/Pivot/index';\n"]}
@@ -1,3 +0,0 @@
1
- import * as React from 'react';
2
- import { IPivotProps } from './index';
3
- export declare const PivotBase: React.FunctionComponent<IPivotProps>;
@@ -1,183 +0,0 @@
1
- import { __assign, __rest } from "tslib";
2
- import * as React from 'react';
3
- import { useControllableValue, useId } from '@fluentui/react-hooks';
4
- import { classNamesFunction, css, divProperties, getNativeProps, getRTL, KeyCodes, warn } from '@fluentui/utilities';
5
- import { DirectionalHint, FocusZone, FocusZoneDirection, Icon, } from '@fluentui/react-internal';
6
- import { CommandButton } from '@fluentui/react-internal/lib/compat/Button';
7
- import { PivotItem } from './index';
8
- import { useOverflow } from '../../utilities/useOverflow';
9
- var getClassNames = classNamesFunction();
10
- var COMPONENT_NAME = 'Pivot';
11
- var getTabId = function (props, pivotId, itemKey, index) {
12
- if (props.getTabId) {
13
- return props.getTabId(itemKey, index);
14
- }
15
- return pivotId + ("-Tab" + index);
16
- };
17
- // Gets the set of PivotLinks as array of IPivotItemProps
18
- // The set of Links is determined by child components of type PivotItem
19
- var getLinkItems = function (props, pivotId) {
20
- var result = {
21
- links: [],
22
- keyToIndexMapping: {},
23
- keyToTabIdMapping: {},
24
- };
25
- React.Children.forEach(React.Children.toArray(props.children), function (child, index) {
26
- if (isPivotItem(child)) {
27
- // eslint-disable-next-line deprecation/deprecation
28
- var _a = child.props, linkText = _a.linkText, pivotItemProps = __rest(_a, ["linkText"]);
29
- var itemKey = child.props.itemKey || index.toString();
30
- result.links.push(__assign(__assign({ headerText: linkText }, pivotItemProps), { itemKey: itemKey }));
31
- result.keyToIndexMapping[itemKey] = index;
32
- result.keyToTabIdMapping[itemKey] = getTabId(props, pivotId, itemKey, index);
33
- }
34
- else if (child) {
35
- warn('The children of a Pivot component must be of type PivotItem to be rendered.');
36
- }
37
- });
38
- return result;
39
- };
40
- var isPivotItem = function (item) {
41
- var _a, _b;
42
- return ((_b = (_a = item) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.name) === PivotItem.name;
43
- };
44
- export var PivotBase = React.forwardRef(function (props, ref) {
45
- var focusZoneRef = React.useRef(null);
46
- var overflowMenuButtonComponentRef = React.useRef(null);
47
- var pivotId = useId('Pivot');
48
- var _a = useControllableValue(props.selectedKey, props.defaultSelectedKey), selectedKey = _a[0], setSelectedKey = _a[1];
49
- var componentRef = props.componentRef, theme = props.theme, linkSize = props.linkSize, linkFormat = props.linkFormat, overflowBehavior = props.overflowBehavior;
50
- var classNames;
51
- var divProps = getNativeProps(props, divProperties);
52
- var linkCollection = getLinkItems(props, pivotId);
53
- React.useImperativeHandle(componentRef, function () { return ({
54
- focus: function () {
55
- var _a;
56
- (_a = focusZoneRef.current) === null || _a === void 0 ? void 0 : _a.focus();
57
- },
58
- }); });
59
- var renderLinkContent = function (link) {
60
- if (!link) {
61
- return null;
62
- }
63
- var itemCount = link.itemCount, itemIcon = link.itemIcon, headerText = link.headerText;
64
- return (React.createElement("span", { className: classNames.linkContent },
65
- itemIcon !== undefined && (React.createElement("span", { className: classNames.icon },
66
- React.createElement(Icon, { iconName: itemIcon }))),
67
- headerText !== undefined && React.createElement("span", { className: classNames.text },
68
- " ",
69
- link.headerText),
70
- itemCount !== undefined && React.createElement("span", { className: classNames.count },
71
- " (",
72
- itemCount,
73
- ")")));
74
- };
75
- var renderPivotLink = function (renderLinkCollection, link, renderPivotLinkSelectedKey, className) {
76
- var itemKey = link.itemKey, headerButtonProps = link.headerButtonProps, onRenderItemLink = link.onRenderItemLink;
77
- var tabId = renderLinkCollection.keyToTabIdMapping[itemKey];
78
- var linkContent;
79
- var isSelected = renderPivotLinkSelectedKey === itemKey;
80
- if (onRenderItemLink) {
81
- linkContent = onRenderItemLink(link, renderLinkContent);
82
- }
83
- else {
84
- linkContent = renderLinkContent(link);
85
- }
86
- var contentString = link.headerText || '';
87
- contentString += link.itemCount ? ' (' + link.itemCount + ')' : '';
88
- // Adding space supplementary for icon
89
- contentString += link.itemIcon ? ' xx' : '';
90
- return (React.createElement(CommandButton, __assign({}, headerButtonProps, { id: tabId, key: itemKey, className: css(className, isSelected && classNames.linkIsSelected),
91
- // eslint-disable-next-line react/jsx-no-bind
92
- onClick: function (ev) { return onLinkClick(itemKey, ev); },
93
- // eslint-disable-next-line react/jsx-no-bind
94
- onKeyDown: function (ev) { return onKeyDown(itemKey, ev); }, "aria-label": link.ariaLabel, role: "tab", "aria-selected": isSelected, name: link.headerText, keytipProps: link.keytipProps, "data-content": contentString }), linkContent));
95
- };
96
- var onLinkClick = function (itemKey, ev) {
97
- ev.preventDefault();
98
- updateSelectedItem(itemKey, ev);
99
- };
100
- var onKeyDown = function (itemKey, ev) {
101
- if (ev.which === KeyCodes.enter) {
102
- ev.preventDefault();
103
- updateSelectedItem(itemKey);
104
- }
105
- };
106
- var updateSelectedItem = function (itemKey, ev) {
107
- var _a;
108
- setSelectedKey(itemKey);
109
- linkCollection = getLinkItems(props, pivotId);
110
- if (props.onLinkClick && linkCollection.keyToIndexMapping[itemKey] >= 0) {
111
- var selectedIndex = linkCollection.keyToIndexMapping[itemKey];
112
- var item = React.Children.toArray(props.children)[selectedIndex];
113
- if (isPivotItem(item)) {
114
- props.onLinkClick(item, ev);
115
- }
116
- }
117
- (_a = overflowMenuButtonComponentRef.current) === null || _a === void 0 ? void 0 : _a.dismissMenu();
118
- };
119
- var renderPivotItem = function (itemKey, isActive) {
120
- if (props.headersOnly || !itemKey) {
121
- return null;
122
- }
123
- var index = linkCollection.keyToIndexMapping[itemKey];
124
- var selectedTabId = linkCollection.keyToTabIdMapping[itemKey];
125
- return (React.createElement("div", { role: "tabpanel", hidden: !isActive, key: itemKey, "aria-hidden": !isActive, "aria-labelledby": selectedTabId, className: classNames.itemContainer }, React.Children.toArray(props.children)[index]));
126
- };
127
- var isKeyValid = function (itemKey) {
128
- return itemKey !== undefined && itemKey !== null && linkCollection.keyToIndexMapping[itemKey] !== undefined;
129
- };
130
- var getSelectedKey = function () {
131
- if (isKeyValid(selectedKey)) {
132
- return selectedKey;
133
- }
134
- if (linkCollection.links.length) {
135
- return linkCollection.links[0].itemKey;
136
- }
137
- return undefined;
138
- };
139
- classNames = getClassNames(props.styles, {
140
- theme: theme,
141
- linkSize: linkSize,
142
- linkFormat: linkFormat,
143
- });
144
- var renderedSelectedKey = getSelectedKey();
145
- var renderedSelectedIndex = renderedSelectedKey ? linkCollection.keyToIndexMapping[renderedSelectedKey] : 0;
146
- var items = linkCollection.links.map(function (l) {
147
- return renderPivotLink(linkCollection, l, renderedSelectedKey, classNames.link);
148
- });
149
- // The overflow menu starts empty and items[] is updated as the overflow items change
150
- var overflowMenuProps = React.useMemo(function () { return ({
151
- items: [],
152
- doNotLayer: true,
153
- alignTargetEdge: true,
154
- directionalHint: DirectionalHint.bottomRightEdge,
155
- }); }, []);
156
- var overflowMenuButtonRef = useOverflow({
157
- onOverflowItemsChanged: function (overflowIndex, elements) {
158
- // Set data-is-overflowing on each item
159
- elements.forEach(function (_a) {
160
- var ele = _a.ele, isOverflowing = _a.isOverflowing;
161
- return (ele.dataset.isOverflowing = "" + isOverflowing);
162
- });
163
- // Update the menu items
164
- overflowMenuProps.items = linkCollection.links.slice(overflowIndex).map(function (link, index) { return ({
165
- key: link.itemKey || "" + (overflowIndex + index),
166
- onRender: function () { return renderPivotLink(linkCollection, link, renderedSelectedKey, classNames.linkInMenu); },
167
- }); });
168
- },
169
- rtl: getRTL(theme),
170
- pinnedIndex: renderedSelectedIndex,
171
- }).menuButtonRef;
172
- return (React.createElement("div", __assign({ role: "toolbar" }, divProps, { ref: ref }),
173
- React.createElement(FocusZone, { componentRef: focusZoneRef, direction: FocusZoneDirection.horizontal, className: classNames.root, role: "tablist" },
174
- items,
175
- overflowBehavior === 'menu' && (React.createElement(CommandButton, { className: css(classNames.link, classNames.overflowMenuButton), elementRef: overflowMenuButtonRef, componentRef: overflowMenuButtonComponentRef, menuProps: overflowMenuProps, menuIconProps: { iconName: 'More', style: { color: 'inherit' } } }))),
176
- renderedSelectedKey &&
177
- linkCollection.links.map(function (link) {
178
- return (link.alwaysRender === true || renderedSelectedKey === link.itemKey) &&
179
- renderPivotItem(link.itemKey, renderedSelectedKey === link.itemKey);
180
- })));
181
- });
182
- PivotBase.displayName = COMPONENT_NAME;
183
- //# sourceMappingURL=Pivot.base.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Pivot.base.js","sourceRoot":"../src/","sources":["components/Pivot/Pivot.base.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,GAAG,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AACrH,OAAO,EACL,eAAe,EACf,SAAS,EACT,kBAAkB,EAClB,IAAI,GAGL,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAW,MAAM,4CAA4C,CAAC;AACpF,OAAO,EAAwE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC1G,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,IAAM,aAAa,GAAG,kBAAkB,EAAkC,CAAC;AAE3E,IAAM,cAAc,GAAG,OAAO,CAAC;AAQ/B,IAAM,QAAQ,GAAG,UAAC,KAAkB,EAAE,OAAe,EAAE,OAAe,EAAE,KAAa;IACnF,IAAI,KAAK,CAAC,QAAQ,EAAE;QAClB,OAAO,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;KACvC;IACD,OAAO,OAAO,IAAG,SAAO,KAAO,CAAA,CAAC;AAClC,CAAC,CAAC;AAEF,yDAAyD;AACzD,uEAAuE;AACvE,IAAM,YAAY,GAAG,UAAC,KAAkB,EAAE,OAAe;IACvD,IAAM,MAAM,GAAwB;QAClC,KAAK,EAAE,EAAE;QACT,iBAAiB,EAAE,EAAE;QACrB,iBAAiB,EAAE,EAAE;KACtB,CAAC;IAEF,KAAK,CAAC,QAAQ,CAAC,OAAO,CA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Ae;KACjD,CAAC,EALI,CAKJ,EACF,EAAE,CACH,CAAC;IAEM,IAAA;;;;;;;;;;;;;;;oBAAoC,CAazC;IAEH,OAAO,CACL,sCAAK,IAAI,EAAC,SAAS,IAAK,QAAQ,IAAE,GAAG,EAAE,GAAG;QACxC,oBAAC,SAAS,IACR,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,kBAAkB,CAAC,UAAU,EACxC,SAAS,EAAE,UAAU,CAAC,IAAI,EAC1B,IAAI,EAAC,SAAS;YAEb,KAAK;YACL,gBAAgB,KAAK,MAAM,IAAI,CAC9B,oBAAC,aAAa,IACZ,SAAS,EAAE,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,kBAAkB,CAAC,EAC9D,UAAU,EAAE,qBAAqB,EACjC,YAAY,EAAE,8BAA8B,EAC5C,SAAS,EAAE,iBAAiB,EAC5B,aAAa,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,GAChE,CACH,CACS;QACX,mBAAmB;YAClB,cAAc,CAAC,KAAK,CAAC,GAAG,CACtB,UAAA,IAAI;gBACF,OAAA,CAAC,IAAI,CAAC,YAAY,KAAK,IAAI,IAAI,mBAAmB,KAAK,IAAI,CAAC,OAAO,CAAC;oBACpE,eAAe,CAAC,IAAI,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,CAAC,OAAO,CAAC;YADnE,CACmE,CACtE,CACC,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AACF,SAAS,CAAC,WAAW,GAAG,cAAc,CAAC","sourcesContent":["import * as React from 'react';\nimport { useControllableValue, useId } from '@fluentui/react-hooks';\nimport { classNamesFunction, css, divProperties, getNativeProps, getRTL, KeyCodes, warn } from '@fluentui/utilities';\nimport {\n DirectionalHint,\n FocusZone,\n FocusZoneDirection,\n Icon,\n IContextualMenuProps,\n IFocusZone,\n} from '@fluentui/react-internal';\nimport { CommandButton, IButton } from '@fluentui/react-internal/lib/compat/Button';\nimport { IPivot, IPivotItemProps, IPivotProps, IPivotStyleProps, IPivotStyles, PivotItem } from './index';\nimport { useOverflow } from '../../utilities/useOverflow';\n\nconst getClassNames = classNamesFunction<IPivotStyleProps, IPivotStyles>();\n\nconst COMPONENT_NAME = 'Pivot';\n\ntype PivotLinkCollection = {\n links: IPivotItemProps[];\n keyToIndexMapping: { [key: string]: number };\n keyToTabIdMapping: { [key: string]: string };\n};\n\nconst getTabId = (props: IPivotProps, pivotId: string, itemKey: string, index: number): string => {\n if (props.getTabId) {\n return props.getTabId(itemKey, index);\n }\n return pivotId + `-Tab${index}`;\n};\n\n// Gets the set of PivotLinks as array of IPivotItemProps\n// The set of Links is determined by child components of type PivotItem\nconst getLinkItems = (props: IPivotProps, pivotId: string): PivotLinkCollection => {\n const result: PivotLinkCollection = {\n links: [],\n keyToIndexMapping: {},\n keyToTabIdMapping: {},\n };\n\n React.Children.forEach(React.Children.toArray(props.children), (child: React.ReactNode, index: number) => {\n if (isPivotItem(child)) {\n // eslint-disable-next-line deprecation/deprecation\n const { linkText, ...pivotItemProps } = child.props;\n const itemKey = child.props.itemKey || index.toString();\n result.links.push({\n headerText: linkText,\n ...pivotItemProps,\n itemKey: itemKey,\n });\n result.keyToIndexMapping[itemKey] = index;\n result.keyToTabIdMapping[itemKey] = getTabId(props, pivotId, itemKey, index);\n } else if (child) {\n warn('The children of a Pivot component must be of type PivotItem to be rendered.');\n }\n });\n return result;\n};\n\nconst isPivotItem = (item: React.ReactNode): item is PivotItem => {\n return ((item as React.ReactElement)?.type as React.ComponentType)?.name === PivotItem.name;\n};\n\nexport const PivotBase: React.FunctionComponent<IPivotProps> = React.forwardRef<HTMLDivElement, IPivotProps>(\n (props, ref) => {\n const focusZoneRef = React.useRef<IFocusZone>(null);\n const overflowMenuButtonComponentRef = React.useRef<IButton>(null);\n const pivotId: string = useId('Pivot');\n\n const [selectedKey, setSelectedKey] = useControllableValue(props.selectedKey, props.defaultSelectedKey);\n\n const { componentRef, theme, linkSize, linkFormat, overflowBehavior } = props;\n\n let classNames: { [key in keyof IPivotStyles]: string };\n const divProps = getNativeProps<React.HTMLAttributes<HTMLDivElement>>(props, divProperties);\n\n let linkCollection = getLinkItems(props, pivotId);\n\n React.useImperativeHandle(componentRef as React.RefObject<IPivot>, () => ({\n focus: () => {\n focusZoneRef.current?.focus();\n },\n }));\n\n const renderLinkContent = (link?: IPivotItemProps): JSX.Element | null => {\n if (!link) {\n return null;\n }\n\n const { itemCount, itemIcon, headerText } = link;\n return (\n <span className={classNames.linkContent}>\n {itemIcon !== undefined && (\n <span className={classNames.icon}>\n <Icon iconName={itemIcon} />\n </span>\n )}\n {headerText !== undefined && <span className={classNames.text}> {link.headerText}</span>}\n {itemCount !== undefined && <span className={classNames.count}> ({itemCount})</span>}\n </span>\n );\n };\n\n const renderPivotLink = (\n renderLinkCollection: PivotLinkCollection,\n link: IPivotItemProps,\n renderPivotLinkSelectedKey: string | null | undefined,\n className: string,\n ): JSX.Element => {\n const { itemKey, headerButtonProps, onRenderItemLink } = link;\n const tabId = renderLinkCollection.keyToTabIdMapping[itemKey!];\n let linkContent: JSX.Element | null;\n const isSelected: boolean = renderPivotLinkSelectedKey === itemKey;\n\n if (onRenderItemLink) {\n linkContent = onRenderItemLink(link, renderLinkContent);\n } else {\n linkContent = renderLinkContent(link);\n }\n\n let contentString = link.headerText || '';\n contentString += link.itemCount ? ' (' + link.itemCount + ')' : '';\n // Adding space supplementary for icon\n contentString += link.itemIcon ? ' xx' : '';\n return (\n <CommandButton\n {...headerButtonProps}\n id={tabId}\n key={itemKey}\n className={css(className, isSelected && classNames.linkIsSelected)}\n // eslint-disable-next-line react/jsx-no-bind\n onClick={(ev: React.MouseEvent<HTMLElement>) => onLinkClick(itemKey!, ev)}\n // eslint-disable-next-line react/jsx-no-bind\n onKeyDown={(ev: React.KeyboardEvent<HTMLElement>) => onKeyDown(itemKey!, ev)}\n aria-label={link.ariaLabel}\n role=\"tab\"\n aria-selected={isSelected}\n name={link.headerText}\n keytipProps={link.keytipProps}\n data-content={contentString}\n >\n {linkContent}\n </CommandButton>\n );\n };\n\n const onLinkClick = (itemKey: string, ev: React.MouseEvent<HTMLElement>): void => {\n ev.preventDefault();\n updateSelectedItem(itemKey, ev);\n };\n\n const onKeyDown = (itemKey: string, ev: React.KeyboardEvent<HTMLElement>): void => {\n if (ev.which === KeyCodes.enter) {\n ev.preventDefault();\n updateSelectedItem(itemKey);\n }\n };\n\n const updateSelectedItem = (itemKey: string, ev?: React.MouseEvent<HTMLElement>): void => {\n setSelectedKey(itemKey);\n linkCollection = getLinkItems(props, pivotId);\n if (props.onLinkClick && linkCollection.keyToIndexMapping[itemKey] >= 0) {\n const selectedIndex = linkCollection.keyToIndexMapping[itemKey];\n const item = React.Children.toArray(props.children)[selectedIndex];\n if (isPivotItem(item)) {\n props.onLinkClick(item, ev);\n }\n }\n\n overflowMenuButtonComponentRef.current?.dismissMenu();\n };\n\n const renderPivotItem = (itemKey: string | undefined, isActive: boolean): JSX.Element | null => {\n if (props.headersOnly || !itemKey) {\n return null;\n }\n\n const index = linkCollection.keyToIndexMapping[itemKey];\n const selectedTabId = linkCollection.keyToTabIdMapping[itemKey];\n return (\n <div\n role=\"tabpanel\"\n hidden={!isActive}\n key={itemKey}\n aria-hidden={!isActive}\n aria-labelledby={selectedTabId}\n className={classNames.itemContainer}\n >\n {React.Children.toArray(props.children)[index]}\n </div>\n );\n };\n\n const isKeyValid = (itemKey: string | null | undefined): boolean => {\n return itemKey !== undefined && itemKey !== null && linkCollection.keyToIndexMapping[itemKey] !== undefined;\n };\n\n const getSelectedKey = () => {\n if (isKeyValid(selectedKey)) {\n return selectedKey;\n }\n if (linkCollection.links.length) {\n return linkCollection.links[0].itemKey;\n }\n return undefined;\n };\n\n classNames = getClassNames(props.styles!, {\n theme: theme!,\n linkSize,\n linkFormat,\n });\n\n const renderedSelectedKey = getSelectedKey();\n const renderedSelectedIndex = renderedSelectedKey ? linkCollection.keyToIndexMapping[renderedSelectedKey] : 0;\n\n const items = linkCollection.links.map(l =>\n renderPivotLink(linkCollection, l, renderedSelectedKey, classNames.link),\n );\n\n // The overflow menu starts empty and items[] is updated as the overflow items change\n const overflowMenuProps: IContextualMenuProps = React.useMemo(\n () => ({\n items: [],\n doNotLayer: true,\n alignTargetEdge: true,\n directionalHint: DirectionalHint.bottomRightEdge,\n }),\n [],\n );\n\n const { menuButtonRef: overflowMenuButtonRef } = useOverflow({\n onOverflowItemsChanged: (overflowIndex, elements) => {\n // Set data-is-overflowing on each item\n elements.forEach(({ ele, isOverflowing }) => (ele.dataset.isOverflowing = `${isOverflowing}`));\n\n // Update the menu items\n overflowMenuProps.items = linkCollection.links.slice(overflowIndex).map((link, index) => ({\n key: link.itemKey || `${overflowIndex + index}`,\n onRender: () => renderPivotLink(linkCollection, link, renderedSelectedKey, classNames.linkInMenu),\n }));\n },\n rtl: getRTL(theme),\n pinnedIndex: renderedSelectedIndex,\n });\n\n return (\n <div role=\"toolbar\" {...divProps} ref={ref}>\n <FocusZone\n componentRef={focusZoneRef}\n direction={FocusZoneDirection.horizontal}\n className={classNames.root}\n role=\"tablist\"\n >\n {items}\n {overflowBehavior === 'menu' && (\n <CommandButton\n className={css(classNames.link, classNames.overflowMenuButton)}\n elementRef={overflowMenuButtonRef}\n componentRef={overflowMenuButtonComponentRef}\n menuProps={overflowMenuProps}\n menuIconProps={{ iconName: 'More', style: { color: 'inherit' } }}\n />\n )}\n </FocusZone>\n {renderedSelectedKey &&\n linkCollection.links.map(\n link =>\n (link.alwaysRender === true || renderedSelectedKey === link.itemKey) &&\n renderPivotItem(link.itemKey, renderedSelectedKey === link.itemKey),\n )}\n </div>\n );\n },\n);\nPivotBase.displayName = COMPONENT_NAME;\n"]}
@@ -1,8 +0,0 @@
1
- import * as React from 'react';
2
- import { IPivotProps } from './Pivot.types';
3
- /**
4
- * The Pivot control and related tabs pattern are used for navigating frequently accessed,
5
- * distinct content categories. Pivots allow for navigation between two or more content
6
- * views and relies on text headers to articulate the different sections of content.
7
- */
8
- export declare const Pivot: React.FunctionComponent<IPivotProps>;
@@ -1,12 +0,0 @@
1
- import { styled } from '@fluentui/utilities';
2
- import { PivotBase } from './Pivot.base';
3
- import { getStyles } from './Pivot.styles';
4
- /**
5
- * The Pivot control and related tabs pattern are used for navigating frequently accessed,
6
- * distinct content categories. Pivots allow for navigation between two or more content
7
- * views and relies on text headers to articulate the different sections of content.
8
- */
9
- export var Pivot = styled(PivotBase, getStyles, undefined, {
10
- scope: 'Pivot',
11
- });
12
- //# sourceMappingURL=Pivot.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Pivot.js","sourceRoot":"../src/","sources":["components/Pivot/Pivot.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;;;GAIG;AACH,MAAM,CAAC,IAAM,KAAK,GAAyC,MAAM,CAC/D,SAAS,EACT,SAAS,EACT,SAAS,EACT;IACE,KAAK,EAAE,OAAO;CACf,CACF,CAAC","sourcesContent":["import * as React from 'react';\nimport { styled } from '@fluentui/utilities';\nimport { IPivotProps, IPivotStyleProps, IPivotStyles } from './Pivot.types';\nimport { PivotBase } from './Pivot.base';\nimport { getStyles } from './Pivot.styles';\n\n/**\n * The Pivot control and related tabs pattern are used for navigating frequently accessed,\n * distinct content categories. Pivots allow for navigation between two or more content\n * views and relies on text headers to articulate the different sections of content.\n */\nexport const Pivot: React.FunctionComponent<IPivotProps> = styled<IPivotProps, IPivotStyleProps, IPivotStyles>(\n PivotBase,\n getStyles,\n undefined,\n {\n scope: 'Pivot',\n },\n);\n"]}
@@ -1,2 +0,0 @@
1
- import { IPivotStyleProps, IPivotStyles } from './Pivot.types';
2
- export declare const getStyles: (props: IPivotStyleProps) => IPivotStyles;