@fluentui/react-tabs 1.0.0-beta.96 → 9.0.0-beta.6

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 (223) hide show
  1. package/CHANGELOG.json +51 -1817
  2. package/CHANGELOG.md +17 -729
  3. package/README.md +0 -17
  4. package/Spec.md +433 -0
  5. package/dist/react-tabs.d.ts +171 -137
  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 +52 -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 +5 -0
  19. package/lib/components/Tab/index.js +6 -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 +18 -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 +82 -0
  26. package/lib/components/Tab/useTab.js.map +1 -0
  27. package/lib/components/Tab/useTabStyles.d.ts +6 -0
  28. package/lib/components/Tab/useTabStyles.js +205 -0
  29. package/lib/components/Tab/useTabStyles.js.map +1 -0
  30. package/lib/components/TabList/TabList.d.ts +6 -0
  31. package/lib/components/TabList/TabList.js +17 -0
  32. package/lib/components/TabList/TabList.js.map +1 -0
  33. package/lib/components/TabList/TabList.types.d.ts +99 -0
  34. package/lib/components/TabList/TabList.types.js +2 -0
  35. package/lib/components/TabList/TabList.types.js.map +1 -0
  36. package/lib/components/TabList/TabListContext.d.ts +3 -0
  37. package/lib/components/TabList/TabListContext.js +17 -0
  38. package/lib/components/TabList/TabListContext.js.map +1 -0
  39. package/lib/components/TabList/index.d.ts +5 -0
  40. package/lib/components/TabList/index.js +6 -0
  41. package/lib/components/TabList/index.js.map +1 -0
  42. package/lib/components/TabList/renderTabList.d.ts +5 -0
  43. package/lib/components/TabList/renderTabList.js +19 -0
  44. package/lib/components/TabList/renderTabList.js.map +1 -0
  45. package/lib/components/TabList/useTabList.d.ts +12 -0
  46. package/lib/components/TabList/useTabList.js +106 -0
  47. package/lib/components/TabList/useTabList.js.map +1 -0
  48. package/lib/components/TabList/useTabListContextValues.d.ts +2 -0
  49. package/lib/components/TabList/useTabListContextValues.js +24 -0
  50. package/lib/components/TabList/useTabListContextValues.js.map +1 -0
  51. package/lib/components/TabList/useTabListStyles.d.ts +9 -0
  52. package/lib/components/TabList/useTabListStyles.js +118 -0
  53. package/lib/components/TabList/useTabListStyles.js.map +1 -0
  54. package/lib/index.d.ts +2 -1
  55. package/lib/index.js +2 -1
  56. package/lib/index.js.map +1 -1
  57. package/lib/tab.constants.d.ts +15 -0
  58. package/lib/tab.constants.js +17 -0
  59. package/lib/tab.constants.js.map +1 -0
  60. package/lib/tsdoc-metadata.json +1 -1
  61. package/lib-commonjs/Tab.d.ts +1 -0
  62. package/lib-commonjs/Tab.js +10 -0
  63. package/lib-commonjs/Tab.js.map +1 -0
  64. package/lib-commonjs/TabList.d.ts +1 -0
  65. package/lib-commonjs/TabList.js +10 -0
  66. package/lib-commonjs/TabList.js.map +1 -0
  67. package/lib-commonjs/components/Tab/Tab.d.ts +6 -0
  68. package/lib-commonjs/components/Tab/Tab.js +26 -0
  69. package/lib-commonjs/components/Tab/Tab.js.map +1 -0
  70. package/lib-commonjs/components/Tab/Tab.types.d.ts +52 -0
  71. package/lib-commonjs/components/Tab/Tab.types.js +6 -0
  72. package/lib-commonjs/components/Tab/Tab.types.js.map +1 -0
  73. package/lib-commonjs/components/Tab/index.d.ts +5 -0
  74. package/lib-commonjs/components/Tab/index.js +18 -0
  75. package/lib-commonjs/components/Tab/index.js.map +1 -0
  76. package/lib-commonjs/components/Tab/renderTab.d.ts +5 -0
  77. package/lib-commonjs/components/Tab/renderTab.js +29 -0
  78. package/lib-commonjs/components/Tab/renderTab.js.map +1 -0
  79. package/lib-commonjs/components/Tab/useTab.d.ts +12 -0
  80. package/lib-commonjs/components/Tab/useTab.js +95 -0
  81. package/lib-commonjs/components/Tab/useTab.js.map +1 -0
  82. package/lib-commonjs/components/Tab/useTabStyles.d.ts +6 -0
  83. package/lib-commonjs/components/Tab/useTabStyles.js +218 -0
  84. package/lib-commonjs/components/Tab/useTabStyles.js.map +1 -0
  85. package/lib-commonjs/components/TabList/TabList.d.ts +6 -0
  86. package/lib-commonjs/components/TabList/TabList.js +29 -0
  87. package/lib-commonjs/components/TabList/TabList.js.map +1 -0
  88. package/lib-commonjs/components/TabList/TabList.types.d.ts +99 -0
  89. package/lib-commonjs/components/TabList/TabList.types.js +6 -0
  90. package/lib-commonjs/components/TabList/TabList.types.js.map +1 -0
  91. package/lib-commonjs/components/TabList/TabListContext.d.ts +3 -0
  92. package/lib-commonjs/components/TabList/TabListContext.js +25 -0
  93. package/lib-commonjs/components/TabList/TabListContext.js.map +1 -0
  94. package/lib-commonjs/components/TabList/index.d.ts +5 -0
  95. package/lib-commonjs/components/TabList/index.js +18 -0
  96. package/lib-commonjs/components/TabList/index.js.map +1 -0
  97. package/lib-commonjs/components/TabList/renderTabList.d.ts +5 -0
  98. package/lib-commonjs/components/TabList/renderTabList.js +31 -0
  99. package/lib-commonjs/components/TabList/renderTabList.js.map +1 -0
  100. package/lib-commonjs/components/TabList/useTabList.d.ts +12 -0
  101. package/lib-commonjs/components/TabList/useTabList.js +118 -0
  102. package/lib-commonjs/components/TabList/useTabList.js.map +1 -0
  103. package/lib-commonjs/components/TabList/useTabListContextValues.d.ts +2 -0
  104. package/lib-commonjs/components/TabList/useTabListContextValues.js +33 -0
  105. package/lib-commonjs/components/TabList/useTabListContextValues.js.map +1 -0
  106. package/lib-commonjs/components/TabList/useTabListStyles.d.ts +9 -0
  107. package/lib-commonjs/components/TabList/useTabListStyles.js +131 -0
  108. package/lib-commonjs/components/TabList/useTabListStyles.js.map +1 -0
  109. package/lib-commonjs/index.d.ts +2 -1
  110. package/lib-commonjs/index.js +10 -3
  111. package/lib-commonjs/index.js.map +1 -1
  112. package/lib-commonjs/tab.constants.d.ts +15 -0
  113. package/lib-commonjs/tab.constants.js +23 -0
  114. package/lib-commonjs/tab.constants.js.map +1 -0
  115. package/package.json +18 -13
  116. package/config/api-extractor.json +0 -3
  117. package/config/tests.js +0 -14
  118. package/etc/react-tabs.api.md +0 -104
  119. package/just.config.ts +0 -3
  120. package/lib/Tabs.d.ts +0 -1
  121. package/lib/Tabs.js +0 -2
  122. package/lib/Tabs.js.map +0 -1
  123. package/lib/common/isConformant.d.ts +0 -2
  124. package/lib/common/isConformant.js +0 -9
  125. package/lib/common/isConformant.js.map +0 -1
  126. package/lib/components/Tabs/TabItem.d.ts +0 -6
  127. package/lib/components/Tabs/TabItem.js +0 -18
  128. package/lib/components/Tabs/TabItem.js.map +0 -1
  129. package/lib/components/Tabs/TabItem.types.d.ts +0 -61
  130. package/lib/components/Tabs/TabItem.types.js +0 -2
  131. package/lib/components/Tabs/TabItem.types.js.map +0 -1
  132. package/lib/components/Tabs/Tabs.base.d.ts +0 -3
  133. package/lib/components/Tabs/Tabs.base.js +0 -179
  134. package/lib/components/Tabs/Tabs.base.js.map +0 -1
  135. package/lib/components/Tabs/Tabs.d.ts +0 -8
  136. package/lib/components/Tabs/Tabs.js +0 -12
  137. package/lib/components/Tabs/Tabs.js.map +0 -1
  138. package/lib/components/Tabs/Tabs.styles.d.ts +0 -2
  139. package/lib/components/Tabs/Tabs.styles.js +0 -264
  140. package/lib/components/Tabs/Tabs.styles.js.map +0 -1
  141. package/lib/components/Tabs/Tabs.types.d.ts +0 -113
  142. package/lib/components/Tabs/Tabs.types.js +0 -2
  143. package/lib/components/Tabs/Tabs.types.js.map +0 -1
  144. package/lib/components/Tabs/index.d.ts +0 -5
  145. package/lib/components/Tabs/index.js +0 -6
  146. package/lib/components/Tabs/index.js.map +0 -1
  147. package/lib/utilities/observeResize.d.ts +0 -21
  148. package/lib/utilities/observeResize.js +0 -46
  149. package/lib/utilities/observeResize.js.map +0 -1
  150. package/lib/utilities/useOverflow.d.ts +0 -45
  151. package/lib/utilities/useOverflow.js +0 -126
  152. package/lib/utilities/useOverflow.js.map +0 -1
  153. package/lib-amd/Tabs.d.ts +0 -1
  154. package/lib-amd/Tabs.js +0 -6
  155. package/lib-amd/Tabs.js.map +0 -1
  156. package/lib-amd/common/isConformant.d.ts +0 -2
  157. package/lib-amd/common/isConformant.js +0 -14
  158. package/lib-amd/common/isConformant.js.map +0 -1
  159. package/lib-amd/components/Tabs/TabItem.d.ts +0 -6
  160. package/lib-amd/components/Tabs/TabItem.js +0 -20
  161. package/lib-amd/components/Tabs/TabItem.js.map +0 -1
  162. package/lib-amd/components/Tabs/TabItem.types.d.ts +0 -61
  163. package/lib-amd/components/Tabs/TabItem.types.js +0 -5
  164. package/lib-amd/components/Tabs/TabItem.types.js.map +0 -1
  165. package/lib-amd/components/Tabs/Tabs.base.d.ts +0 -3
  166. package/lib-amd/components/Tabs/Tabs.base.js +0 -176
  167. package/lib-amd/components/Tabs/Tabs.base.js.map +0 -1
  168. package/lib-amd/components/Tabs/Tabs.d.ts +0 -8
  169. package/lib-amd/components/Tabs/Tabs.js +0 -14
  170. package/lib-amd/components/Tabs/Tabs.js.map +0 -1
  171. package/lib-amd/components/Tabs/Tabs.styles.d.ts +0 -2
  172. package/lib-amd/components/Tabs/Tabs.styles.js +0 -267
  173. package/lib-amd/components/Tabs/Tabs.styles.js.map +0 -1
  174. package/lib-amd/components/Tabs/Tabs.types.d.ts +0 -113
  175. package/lib-amd/components/Tabs/Tabs.types.js +0 -5
  176. package/lib-amd/components/Tabs/Tabs.types.js.map +0 -1
  177. package/lib-amd/components/Tabs/index.d.ts +0 -5
  178. package/lib-amd/components/Tabs/index.js +0 -11
  179. package/lib-amd/components/Tabs/index.js.map +0 -1
  180. package/lib-amd/index.d.ts +0 -1
  181. package/lib-amd/index.js +0 -6
  182. package/lib-amd/index.js.map +0 -1
  183. package/lib-amd/utilities/observeResize.d.ts +0 -21
  184. package/lib-amd/utilities/observeResize.js +0 -51
  185. package/lib-amd/utilities/observeResize.js.map +0 -1
  186. package/lib-amd/utilities/useOverflow.d.ts +0 -45
  187. package/lib-amd/utilities/useOverflow.js +0 -128
  188. package/lib-amd/utilities/useOverflow.js.map +0 -1
  189. package/lib-commonjs/Tabs.d.ts +0 -1
  190. package/lib-commonjs/Tabs.js +0 -5
  191. package/lib-commonjs/Tabs.js.map +0 -1
  192. package/lib-commonjs/common/isConformant.d.ts +0 -2
  193. package/lib-commonjs/common/isConformant.js +0 -13
  194. package/lib-commonjs/common/isConformant.js.map +0 -1
  195. package/lib-commonjs/components/Tabs/TabItem.d.ts +0 -6
  196. package/lib-commonjs/components/Tabs/TabItem.js +0 -21
  197. package/lib-commonjs/components/Tabs/TabItem.js.map +0 -1
  198. package/lib-commonjs/components/Tabs/TabItem.types.d.ts +0 -61
  199. package/lib-commonjs/components/Tabs/TabItem.types.js +0 -3
  200. package/lib-commonjs/components/Tabs/TabItem.types.js.map +0 -1
  201. package/lib-commonjs/components/Tabs/Tabs.base.d.ts +0 -3
  202. package/lib-commonjs/components/Tabs/Tabs.base.js +0 -182
  203. package/lib-commonjs/components/Tabs/Tabs.base.js.map +0 -1
  204. package/lib-commonjs/components/Tabs/Tabs.d.ts +0 -8
  205. package/lib-commonjs/components/Tabs/Tabs.js +0 -15
  206. package/lib-commonjs/components/Tabs/Tabs.js.map +0 -1
  207. package/lib-commonjs/components/Tabs/Tabs.styles.d.ts +0 -2
  208. package/lib-commonjs/components/Tabs/Tabs.styles.js +0 -268
  209. package/lib-commonjs/components/Tabs/Tabs.styles.js.map +0 -1
  210. package/lib-commonjs/components/Tabs/Tabs.types.d.ts +0 -113
  211. package/lib-commonjs/components/Tabs/Tabs.types.js +0 -3
  212. package/lib-commonjs/components/Tabs/Tabs.types.js.map +0 -1
  213. package/lib-commonjs/components/Tabs/index.d.ts +0 -5
  214. package/lib-commonjs/components/Tabs/index.js +0 -11
  215. package/lib-commonjs/components/Tabs/index.js.map +0 -1
  216. package/lib-commonjs/utilities/observeResize.d.ts +0 -21
  217. package/lib-commonjs/utilities/observeResize.js +0 -50
  218. package/lib-commonjs/utilities/observeResize.js.map +0 -1
  219. package/lib-commonjs/utilities/useOverflow.d.ts +0 -45
  220. package/lib-commonjs/utilities/useOverflow.js +0 -130
  221. package/lib-commonjs/utilities/useOverflow.js.map +0 -1
  222. package/src/components/Tabs/TabItem.types.ts +0 -69
  223. package/src/components/Tabs/Tabs.types.ts +0 -131
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=Tabs.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Tabs.types.js","sourceRoot":"../src/","sources":["components/Tabs/Tabs.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport { IStyle, ITheme } from '@fluentui/style-utilities';\nimport { IStyleFunctionOrObject } from '@fluentui/utilities';\nimport { TabItem } from './TabItem';\n\n/**\n * {@docCategory Tabs}\n */\nexport interface TabsImperativeHandle {\n /**\n * Sets focus to the first tab.\n */\n focus(): void;\n}\n\n/**\n * {@docCategory Tabs}\n */\nexport interface TabsProps extends React.HTMLAttributes<HTMLDivElement>, React.RefAttributes<HTMLDivElement> {\n /**\n * Optional callback to access the TabsImperativeHandle interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: React.RefObject<TabsImperativeHandle>;\n\n /**\n * Call to provide customized styling that will layer on top of the variant rules.\n */\n styles?: IStyleFunctionOrObject<TabsStyleProps, TabsStyles>;\n\n /**\n * Theme provided by High-Order Component.\n */\n theme?: ITheme;\n\n /**\n * Additional css class to apply to the Tabs\n * @defaultvalue undefined\n */\n className?: string;\n\n /**\n * Default selected TabItem key. Only provide this if the Tabs is an uncontrolled component;\n * otherwise, use the `selectedKey` property.\n */\n defaultSelectedKey?: string;\n\n /**\n * Key of the selected tab item. Updating this will override the selected tab state.\n * Only provide this if the Tabs is a controlled component where you are maintaining the\n * current state; otherwise, use `defaultSelectedKey`.\n */\n selectedKey?: string | null;\n\n /**\n * Callback for when the selected tab item is changed.\n */\n onTabClick?: (item?: TabItem, ev?: React.MouseEvent<HTMLElement>) => void;\n\n /**\n * Tab size (normal, large)\n */\n tabSize?: TabSizeType;\n\n /**\n * Tab format (links, tabs)\n */\n tabFormat?: TabFormatType;\n\n /**\n * Overflow behavior when there is not enough room to display all of the tabs\n * * none: Tabs will overflow the container and may not be visible\n * * menu: Display an overflow menu that contains the tabs that don't fit\n *\n * @default none\n */\n overflowBehavior?: 'none' | 'menu';\n\n /**\n * Whether to skip rendering the tabpanel with the content of the selected tab.\n * Use this prop if you plan to separately render the tab content\n * and don't want to leave an empty tabpanel in the page that may confuse Screen Readers.\n */\n headersOnly?: boolean;\n\n /**\n * Callback to customize how IDs are generated for each tab header.\n * Useful if you're rendering content outside and need to connect aria-labelledby.\n */\n getTabId?: (itemKey: string, index: number) => string;\n}\n\n/**\n * {@docCategory Tabs}\n */\nexport type TabsStyleProps = Required<Pick<TabsProps, 'theme'>> &\n Pick<TabsProps, 'className'> & {\n tabSize?: TabSizeType;\n tabFormat?: TabFormatType;\n };\n\n/**\n * {@docCategory Tabs}\n */\nexport interface TabsStyles {\n /**\n * Style for the root element.\n */\n root: IStyle;\n tab: IStyle;\n tabIsSelected: IStyle;\n tabContent: IStyle;\n text: IStyle;\n count: IStyle;\n icon: IStyle;\n tabInMenu: IStyle;\n overflowMenuButton: IStyle;\n itemContainer?: IStyle;\n}\n\n/**\n * {@docCategory Tabs}\n * Display mode for the tabs\n */\nexport type TabFormatType = 'links' | 'tabs';\n\n/**\n * {@docCategory Tabs}\n * Size of the tabs\n */\nexport type TabSizeType = 'normal' | 'large';\n"]}
@@ -1,5 +0,0 @@
1
- export * from './Tabs';
2
- export * from './Tabs.base';
3
- export { TabItem } from './TabItem';
4
- export * from './Tabs.types';
5
- export * from './TabItem.types';
@@ -1,6 +0,0 @@
1
- export * from './Tabs';
2
- export * from './Tabs.base';
3
- export { TabItem } from './TabItem';
4
- export * from './Tabs.types';
5
- export * from './TabItem.types';
6
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/Tabs/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC","sourcesContent":["export * from './Tabs';\nexport * from './Tabs.base';\nexport { TabItem } from './TabItem';\nexport * from './Tabs.types';\nexport * from './TabItem.types';\n"]}
@@ -1,21 +0,0 @@
1
- /**
2
- * Wrapper for ResizeObserver, with fallback for browsers that don't support ResizeObserver.
3
- *
4
- * Calls the onResize callback once layout is complete, and again whenever any of the target(s) change size.
5
- * Or if ResizeObserver isn't supported, calls the callback whenever the window changes size.
6
- *
7
- * @param target - Either a single element, or array of elements to watch for size changes.
8
- * @param onResize - Callback to be notified when layout is complete, and when the target(s) change size.
9
- * If this browser supports ResizeObserver, the callback will be passed the ResizeObserverEntry[] array.
10
- * Otherwise, the entries array will be undefined, and you'll need to find another way to get the element's size,
11
- * (e.g. clientWidth/clientHeight or getBoundingClientRect).
12
- *
13
- * @returns A function to clean up the observer/listener.
14
- */
15
- export declare const observeResize: (target: Element | Element[], onResize: (entries: readonly ResizeObserverEntry[] | undefined) => void) => (() => void);
16
- /** Temporary type definition for ResizeObserverEntry. Can be removed when official types are available. */
17
- declare type ResizeObserverEntry = {
18
- readonly contentRect: DOMRectReadOnly;
19
- readonly target: Element;
20
- };
21
- export {};
@@ -1,46 +0,0 @@
1
- import { getWindow } from '@fluentui/utilities';
2
- /**
3
- * Wrapper for ResizeObserver, with fallback for browsers that don't support ResizeObserver.
4
- *
5
- * Calls the onResize callback once layout is complete, and again whenever any of the target(s) change size.
6
- * Or if ResizeObserver isn't supported, calls the callback whenever the window changes size.
7
- *
8
- * @param target - Either a single element, or array of elements to watch for size changes.
9
- * @param onResize - Callback to be notified when layout is complete, and when the target(s) change size.
10
- * If this browser supports ResizeObserver, the callback will be passed the ResizeObserverEntry[] array.
11
- * Otherwise, the entries array will be undefined, and you'll need to find another way to get the element's size,
12
- * (e.g. clientWidth/clientHeight or getBoundingClientRect).
13
- *
14
- * @returns A function to clean up the observer/listener.
15
- */
16
- export var observeResize = function (target, onResize) {
17
- if (typeof ResizeObserver !== 'undefined') {
18
- var observer_1 = new ResizeObserver(onResize);
19
- if (Array.isArray(target)) {
20
- target.forEach(function (t) { return observer_1.observe(t); });
21
- }
22
- else {
23
- observer_1.observe(target);
24
- }
25
- return function () { return observer_1.disconnect(); };
26
- }
27
- else {
28
- // Fallback for browsers that don't support ResizeObserver
29
- var onResizeWrapper_1 = function () { return onResize(undefined); };
30
- var win_1 = getWindow(Array.isArray(target) ? target[0] : target);
31
- if (!win_1) {
32
- // Can't listen for resize if we can't get the window object
33
- return function () {
34
- // Nothing to clean up
35
- };
36
- }
37
- // Listen for the first animation frame, which will happen after layout is complete
38
- var animationFrameId_1 = win_1.requestAnimationFrame(onResizeWrapper_1);
39
- win_1.addEventListener('resize', onResizeWrapper_1, false);
40
- return function () {
41
- win_1.cancelAnimationFrame(animationFrameId_1);
42
- win_1.removeEventListener('resize', onResizeWrapper_1, false);
43
- };
44
- }
45
- };
46
- //# sourceMappingURL=observeResize.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"observeResize.js","sourceRoot":"../src/","sources":["utilities/observeResize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC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ers 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,45 +0,0 @@
1
- import { RefCallback } from '@fluentui/react-hooks';
2
- /**
3
- * Callback to notify the user that the items in the overflow have changed. This should ensure that the overflow menu
4
- * is visible, and contains all of the overflowing items.
5
- *
6
- * @param overflowIndex - The index of the first item in the overflow, or items.length if nothing is overflowing.
7
- * @param items - The list of all items in the container, and whether that particular item is in the overflow
8
- */
9
- export declare type OverflowItemsChangedCallback = (overflowIndex: number, items: {
10
- ele: HTMLElement;
11
- isOverflowing: boolean;
12
- }[]) => void;
13
- /** Parameters for {@see useOverflow} */
14
- export declare type OverflowParams = {
15
- /** Callback to notify the user that the items in the overflow have changed. */
16
- onOverflowItemsChanged: OverflowItemsChangedCallback;
17
- /** True if the element containing overflowMenuButtonRef is in right-to-left order */
18
- rtl: boolean;
19
- /** Optional: Index of item that should never go into the overflow menu. */
20
- pinnedIndex?: number;
21
- };
22
- /** Return value for {@see useOverflow} */
23
- export declare type OverflowRefs = {
24
- /** Set the overflow menu button's ref to this ref callback */
25
- menuButtonRef: RefCallback<HTMLElement>;
26
- };
27
- /**
28
- * Track whether any items don't fit within their container, and move them to the overflow menu.
29
- * Items are moved into the overflow menu from back to front, excluding pinned items.
30
- *
31
- * The overflow menu button must be the last sibling of all of the items that can be put into the overflow, and it
32
- * must be hooked up to the `setMenuButtonRef` setter function that's returned by `useOverflow`:
33
- * ```ts
34
- * const overflow = useOverflow(...);
35
- * ```
36
- * ```jsx
37
- * <Container>
38
- * <Item /> // Index 0
39
- * <Item /> // Index 1
40
- * ...
41
- * <Button ref={overflow.setMenuButtonRef} /> // Can be any React.Component or HTMLElement
42
- * </Container>
43
- * ```
44
- */
45
- export declare const useOverflow: ({ onOverflowItemsChanged, rtl, pinnedIndex }: OverflowParams) => OverflowRefs;
@@ -1,126 +0,0 @@
1
- import * as React from 'react';
2
- import { useRefEffect } from '@fluentui/react-hooks';
3
- import { getWindow } from '@fluentui/utilities';
4
- import { observeResize } from './observeResize';
5
- /**
6
- * Track whether any items don't fit within their container, and move them to the overflow menu.
7
- * Items are moved into the overflow menu from back to front, excluding pinned items.
8
- *
9
- * The overflow menu button must be the last sibling of all of the items that can be put into the overflow, and it
10
- * must be hooked up to the `setMenuButtonRef` setter function that's returned by `useOverflow`:
11
- * ```ts
12
- * const overflow = useOverflow(...);
13
- * ```
14
- * ```jsx
15
- * <Container>
16
- * <Item /> // Index 0
17
- * <Item /> // Index 1
18
- * ...
19
- * <Button ref={overflow.setMenuButtonRef} /> // Can be any React.Component or HTMLElement
20
- * </Container>
21
- * ```
22
- */
23
- export var useOverflow = function (_a) {
24
- var onOverflowItemsChanged = _a.onOverflowItemsChanged, rtl = _a.rtl, pinnedIndex = _a.pinnedIndex;
25
- var updateOverflowRef = React.useRef();
26
- var containerWidthRef = React.useRef();
27
- // Attach a resize observer to the container
28
- var containerRef = useRefEffect(function (container) {
29
- var cleanupObserver = observeResize(container, function (entries) {
30
- containerWidthRef.current = entries ? entries[0].contentRect.width : container.clientWidth;
31
- if (updateOverflowRef.current) {
32
- updateOverflowRef.current();
33
- }
34
- });
35
- return function () {
36
- cleanupObserver();
37
- containerWidthRef.current = undefined;
38
- };
39
- });
40
- var menuButtonRef = useRefEffect(function (menuButton) {
41
- containerRef(menuButton.parentElement);
42
- return function () { return containerRef(null); };
43
- });
44
- // eslint-disable-next-line no-restricted-properties
45
- React.useLayoutEffect(function () {
46
- var container = containerRef.current;
47
- var menuButton = menuButtonRef.current;
48
- if (!container || !menuButton) {
49
- return;
50
- }
51
- // items contains the container's children, excluding the overflow menu button itself
52
- var items = [];
53
- for (var i = 0; i < container.children.length; i++) {
54
- var item = container.children[i];
55
- if (item instanceof HTMLElement && item !== menuButton) {
56
- items.push(item);
57
- }
58
- }
59
- // Keep track of the minimum width of the container to fit each child index.
60
- // This cache is an integral part of the algorithm and not just a performance optimization: it allows us to
61
- // recalculate the overflowIndex on subsequent resizes even if some items are already inside the overflow.
62
- var minContainerWidth = [];
63
- var extraWidth = 0; // The accumulated width of items that don't move into the overflow
64
- updateOverflowRef.current = function () {
65
- var containerWidth = containerWidthRef.current;
66
- if (containerWidth === undefined) {
67
- return;
68
- }
69
- // Iterate the items in reverse order until we find one that fits within the bounds of the container
70
- for (var i = items.length - 1; i >= 0; i--) {
71
- // Calculate the min container width for this item if we haven't done so yet
72
- if (minContainerWidth[i] === undefined) {
73
- var itemOffsetEnd = rtl ? containerWidth - items[i].offsetLeft : items[i].offsetLeft + items[i].offsetWidth;
74
- // If the item after this one is pinned, reserve space for it
75
- if (i + 1 < items.length && i + 1 === pinnedIndex) {
76
- // Use distance between the end of the previous item and this one (rather than the
77
- // pinned item's offsetWidth), to account for any margin between the items.
78
- extraWidth = minContainerWidth[i + 1] - itemOffsetEnd;
79
- }
80
- // Reserve space for the menu button after the first item was added to the overflow
81
- if (i === items.length - 2) {
82
- extraWidth += menuButton.offsetWidth;
83
- }
84
- minContainerWidth[i] = itemOffsetEnd + extraWidth;
85
- }
86
- if (containerWidth > minContainerWidth[i]) {
87
- setOverflowIndex(i + 1);
88
- return;
89
- }
90
- }
91
- // If we got here, nothing fits outside the overflow
92
- setOverflowIndex(0);
93
- };
94
- var prevOverflowIndex = items.length;
95
- var setOverflowIndex = function (overflowIndex) {
96
- if (prevOverflowIndex !== overflowIndex) {
97
- prevOverflowIndex = overflowIndex;
98
- onOverflowItemsChanged(overflowIndex, items.map(function (ele, index) { return ({
99
- ele: ele,
100
- isOverflowing: index >= overflowIndex && index !== pinnedIndex,
101
- }); }));
102
- }
103
- };
104
- var cancelAnimationFrame = undefined;
105
- // If the container width is already known from a previous render, update the overflow with its width.
106
- // Do this in an animation frame to avoid forcing layout to happen early.
107
- if (containerWidthRef.current !== undefined) {
108
- var win_1 = getWindow(container);
109
- if (win_1) {
110
- var animationFrameId_1 = win_1.requestAnimationFrame(updateOverflowRef.current);
111
- cancelAnimationFrame = function () { return win_1.cancelAnimationFrame(animationFrameId_1); };
112
- }
113
- }
114
- return function () {
115
- if (cancelAnimationFrame) {
116
- cancelAnimationFrame();
117
- }
118
- // On cleanup, need to remove all items from the overflow
119
- // so they don't have stale properties on the next render
120
- setOverflowIndex(items.length);
121
- updateOverflowRef.current = undefined;
122
- };
123
- });
124
- return { menuButtonRef: menuButtonRef };
125
- };
126
- //# sourceMappingURL=useOverflow.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useOverflow.js","sourceRoot":"../src/","sources":["utilities/useOverflow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAe,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAgChD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,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,YAAY,CAAc,UAAA,SAAS;QACtD,IAAM,eAAe,GAAG,aAAa,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,aA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A6B,SAAS,CAAC;QAE/D,sGAAsG;QACtG,yEAAyE;QACzE,IAAI,iBAAiB,CAAC,OAAO,KAAK,SAAS,EAAE;YAC3C,IAAM,KAAG,GAAG,SAAS,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 // 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/lib-amd/Tabs.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './components/Tabs/index';
package/lib-amd/Tabs.js DELETED
@@ -1,6 +0,0 @@
1
- define(["require", "exports", "tslib", "./components/Tabs/index"], function (require, exports, tslib_1, index_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- tslib_1.__exportStar(index_1, exports);
5
- });
6
- //# sourceMappingURL=Tabs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Tabs.js","sourceRoot":"../src/","sources":["Tabs.ts"],"names":[],"mappings":";;;IAAA,uCAAwC","sourcesContent":["export * from './components/Tabs/index';\n"]}
@@ -1,2 +0,0 @@
1
- import { IsConformantOptions } from '@fluentui/react-conformance';
2
- export declare function isConformant(testInfo: Omit<IsConformantOptions, 'componentPath'>): void;
@@ -1,14 +0,0 @@
1
- define(["require", "exports", "@fluentui/react-conformance"], function (require, exports, react_conformance_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.isConformant = void 0;
5
- function isConformant(testInfo) {
6
- var defaultOptions = {
7
- disabledTests: ['has-docblock', 'kebab-aria-attributes'],
8
- componentPath: module.parent.filename.replace('.test', ''),
9
- };
10
- react_conformance_1.isConformant(defaultOptions, testInfo);
11
- }
12
- exports.isConformant = isConformant;
13
- });
14
- //# sourceMappingURL=isConformant.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isConformant.js","sourceRoot":"../src/","sources":["common/isConformant.ts"],"names":[],"mappings":";;;;IAEA,SAAgB,YAAY,CAAC,QAAoD;QAC/E,IAAM,cAAc,GAAG;YACrB,aAAa,EAAE,CAAC,cAAc,EAAE,uBAAuB,CAAC;YACxD,aAAa,EAAE,MAAO,CAAC,MAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;SAC7D,CAAC;QAEF,gCAAgB,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAPD,oCAOC","sourcesContent":["import { isConformant as baseIsConformant, IsConformantOptions } from '@fluentui/react-conformance';\n\nexport function isConformant(testInfo: Omit<IsConformantOptions, 'componentPath'>) {\n const defaultOptions = {\n disabledTests: ['has-docblock', 'kebab-aria-attributes'],\n componentPath: module!.parent!.filename.replace('.test', ''),\n };\n\n baseIsConformant(defaultOptions, testInfo);\n}\n"]}
@@ -1,6 +0,0 @@
1
- import * as React from 'react';
2
- import { TabItemProps } from './TabItem.types';
3
- export declare class TabItem extends React.Component<TabItemProps, {}> {
4
- constructor(props: TabItemProps);
5
- render(): JSX.Element;
6
- }
@@ -1,20 +0,0 @@
1
- define(["require", "exports", "tslib", "react", "@fluentui/utilities"], function (require, exports, tslib_1, React, utilities_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.TabItem = void 0;
5
- // const COMPONENT_NAME = 'TabItem';
6
- var TabItem = /** @class */ (function (_super) {
7
- tslib_1.__extends(TabItem, _super);
8
- function TabItem(props) {
9
- var _this = _super.call(this, props) || this;
10
- utilities_1.initializeComponentRef(_this);
11
- return _this;
12
- }
13
- TabItem.prototype.render = function () {
14
- return React.createElement("div", tslib_1.__assign({}, utilities_1.getNativeProps(this.props, utilities_1.divProperties)), this.props.children);
15
- };
16
- return TabItem;
17
- }(React.Component));
18
- exports.TabItem = TabItem;
19
- });
20
- //# sourceMappingURL=TabItem.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TabItem.js","sourceRoot":"../src/","sources":["components/Tabs/TabItem.tsx"],"names":[],"mappings":";;;;IAIA,oCAAoC;IAEpC;QAA6B,mCAAiC;QAC5D,iBAAY,KAAmB;YAA/B,YACE,kBAAM,KAAK,CAAC,SAGb;YADC,kCAAsB,CAAC,KAAI,CAAC,CAAC;;QAC/B,CAAC;QAEM,wBAAM,GAAb;YACE,OAAO,gDAAS,0BAAc,CAAC,IAAI,CAAC,KAAK,EAAE,yBAAa,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAO,CAAC;QACzF,CAAC;QACH,cAAC;IAAD,CAAC,AAVD,CAA6B,KAAK,CAAC,SAAS,GAU3C;IAVY,0BAAO","sourcesContent":["import * as React from 'react';\nimport { getNativeProps, divProperties, initializeComponentRef } from '@fluentui/utilities';\nimport { TabItemProps } from './TabItem.types';\n\n// const COMPONENT_NAME = 'TabItem';\n\nexport class TabItem extends React.Component<TabItemProps, {}> {\n constructor(props: TabItemProps) {\n super(props);\n\n initializeComponentRef(this);\n }\n\n public render(): JSX.Element {\n return <div {...getNativeProps(this.props, divProperties)}>{this.props.children}</div>;\n }\n}\n"]}
@@ -1,61 +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
- * {@docCategory Tabs}
7
- */
8
- export interface TabItemProps extends React.HTMLAttributes<HTMLDivElement> {
9
- /**
10
- * Gets the component ref.
11
- */
12
- componentRef?: IRefObject<{}>;
13
- /**
14
- * The text displayed of each tab.
15
- */
16
- headerText?: string;
17
- /**
18
- * Props for the header command button. This provides a way to pass in native props, such as data-* and aria-*,
19
- * for each tab element.
20
- */
21
- headerButtonProps?: IButtonProps | {
22
- [key: string]: string | number | boolean;
23
- };
24
- /**
25
- * An required key to uniquely identify a tab item.
26
- *
27
- * Note: The 'key' from react props cannot be used inside component.
28
- */
29
- itemKey?: string;
30
- /**
31
- * The aria label of each tab which will read by screen reader instead of headerText.
32
- *
33
- * Note that unless you have compelling requirements you should not override aria-label.
34
- */
35
- ariaLabel?: string;
36
- /**
37
- * Defines an optional item count displayed in parentheses just after the `headerText`.
38
- *
39
- * Examples: completed (4), Unread (99+)
40
- */
41
- itemCount?: number | string;
42
- /**
43
- * An optional icon to show next to the tab.
44
- */
45
- itemIcon?: string;
46
- /**
47
- * Optional custom renderer for the tab
48
- */
49
- onRenderTab?: IRenderFunction<TabItemProps>;
50
- /**
51
- * Optional keytip for this TabItem
52
- */
53
- keytipProps?: IKeytipProps;
54
- /**
55
- * Defines whether to always render the tab item (regardless of whether it is selected or not).
56
- * Useful if you're rendering content that is expensive to mount.
57
- *
58
- * @defaultvalue false
59
- */
60
- alwaysRender?: boolean;
61
- }
@@ -1,5 +0,0 @@
1
- define(["require", "exports"], function (require, exports) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- });
5
- //# sourceMappingURL=TabItem.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TabItem.types.js","sourceRoot":"../src/","sources":["components/Tabs/TabItem.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport { IKeytipProps } from '@fluentui/react';\nimport { IButtonProps } from '@fluentui/react/lib/Button';\nimport { IRefObject, IRenderFunction } from '@fluentui/utilities';\n\n/**\n * {@docCategory Tabs}\n */\nexport interface TabItemProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Gets the component ref.\n */\n componentRef?: IRefObject<{}>;\n\n /**\n * The text displayed of each tab.\n */\n headerText?: string;\n\n /**\n * Props for the header command button. This provides a way to pass in native props, such as data-* and aria-*,\n * for each tab element.\n */\n headerButtonProps?: IButtonProps | { [key: string]: string | number | boolean };\n\n /**\n * An required key to uniquely identify a tab item.\n *\n * Note: The 'key' from react props cannot be used inside component.\n */\n itemKey?: string;\n\n /**\n * The aria label of each tab which will read by screen reader instead of headerText.\n *\n * Note that unless you have compelling requirements you should not override aria-label.\n */\n ariaLabel?: string;\n\n /**\n * Defines an optional item count displayed in parentheses just after the `headerText`.\n *\n * Examples: completed (4), Unread (99+)\n */\n itemCount?: number | string;\n\n /**\n * An optional icon to show next to the tab.\n */\n itemIcon?: string;\n\n /**\n * Optional custom renderer for the tab\n */\n onRenderTab?: IRenderFunction<TabItemProps>;\n\n /**\n * Optional keytip for this TabItem\n */\n keytipProps?: IKeytipProps;\n\n /**\n * Defines whether to always render the tab item (regardless of whether it is selected or not).\n * Useful if you're rendering content that is expensive to mount.\n *\n * @defaultvalue false\n */\n alwaysRender?: boolean;\n}\n"]}
@@ -1,3 +0,0 @@
1
- import * as React from 'react';
2
- import { TabsProps } from './index';
3
- export declare const TabsBase: React.FunctionComponent<TabsProps>;