@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.
- package/CHANGELOG.json +3135 -0
- package/CHANGELOG.md +1338 -1
- package/config/tests.js +0 -4
- package/dist/react-tabs.d.ts +68 -122
- package/etc/react-tabs.api.md +47 -64
- package/lib/{next/Tabs.d.ts → Tabs.d.ts} +0 -0
- package/lib/{next/Tabs.js → Tabs.js} +0 -0
- package/lib/Tabs.js.map +1 -0
- package/lib/common/isConformant.d.ts +4 -2
- package/lib/common/isConformant.js.map +1 -1
- package/{lib-commonjs/next → lib}/components/Tabs/TabItem.d.ts +1 -1
- package/lib/{next/components → components}/Tabs/TabItem.js +0 -0
- package/lib/components/Tabs/TabItem.js.map +1 -0
- package/{lib-commonjs/next → lib}/components/Tabs/TabItem.types.d.ts +3 -6
- package/lib/components/Tabs/TabItem.types.js +2 -0
- package/lib/components/Tabs/TabItem.types.js.map +1 -0
- package/{lib-amd/next → lib}/components/Tabs/Tabs.base.d.ts +1 -1
- package/lib/{next/components → components}/Tabs/Tabs.base.js +5 -5
- package/lib/components/Tabs/Tabs.base.js.map +1 -0
- package/{lib-commonjs/next → lib}/components/Tabs/Tabs.d.ts +1 -1
- package/lib/{next/components → components}/Tabs/Tabs.js +0 -0
- package/lib/components/Tabs/Tabs.js.map +1 -0
- package/lib/{next/components → components}/Tabs/Tabs.styles.d.ts +1 -1
- package/lib/{next/components → components}/Tabs/Tabs.styles.js +3 -8
- package/lib/components/Tabs/Tabs.styles.js.map +1 -0
- package/{lib-amd/next → lib}/components/Tabs/Tabs.types.d.ts +2 -16
- package/lib/components/Tabs/Tabs.types.js +2 -0
- package/lib/components/Tabs/Tabs.types.js.map +1 -0
- package/lib/{next/components → components}/Tabs/index.d.ts +0 -0
- package/lib/components/Tabs/index.js +6 -0
- package/lib/components/Tabs/index.js.map +1 -0
- package/lib/index.d.ts +1 -3
- package/lib/index.js +1 -3
- package/lib/index.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/utilities/observeResize.d.ts +1 -1
- package/lib/utilities/useOverflow.d.ts +1 -1
- package/lib/utilities/useOverflow.js +1 -0
- package/lib/utilities/useOverflow.js.map +1 -1
- package/lib-amd/{next/Tabs.d.ts → Tabs.d.ts} +0 -0
- package/lib-amd/{next/Tabs.js → Tabs.js} +0 -0
- package/lib-amd/Tabs.js.map +1 -0
- package/lib-amd/common/isConformant.d.ts +4 -2
- package/lib-amd/common/isConformant.js +1 -0
- package/lib-amd/common/isConformant.js.map +1 -1
- package/{lib/next → lib-amd}/components/Tabs/TabItem.d.ts +1 -1
- package/lib-amd/{next/components → components}/Tabs/TabItem.js +1 -0
- package/lib-amd/components/Tabs/TabItem.js.map +1 -0
- package/{lib/next → lib-amd}/components/Tabs/TabItem.types.d.ts +3 -6
- package/lib-amd/{next/components → components}/Tabs/TabItem.types.js +0 -0
- package/lib-amd/components/Tabs/TabItem.types.js.map +1 -0
- package/{lib/next → lib-amd}/components/Tabs/Tabs.base.d.ts +1 -1
- package/lib-amd/{next/components → components}/Tabs/Tabs.base.js +7 -6
- package/lib-amd/components/Tabs/Tabs.base.js.map +1 -0
- package/{lib/next → lib-amd}/components/Tabs/Tabs.d.ts +1 -1
- package/lib-amd/{next/components → components}/Tabs/Tabs.js +1 -0
- package/lib-amd/components/Tabs/Tabs.js.map +1 -0
- package/lib-amd/{next/components → components}/Tabs/Tabs.styles.d.ts +1 -1
- package/lib-amd/{next/components → components}/Tabs/Tabs.styles.js +4 -7
- package/lib-amd/components/Tabs/Tabs.styles.js.map +1 -0
- package/{lib/next → lib-amd}/components/Tabs/Tabs.types.d.ts +2 -16
- package/lib-amd/{next/components → components}/Tabs/Tabs.types.js +0 -0
- package/lib-amd/components/Tabs/Tabs.types.js.map +1 -0
- package/lib-amd/{next/components → components}/Tabs/index.d.ts +0 -0
- package/lib-amd/components/Tabs/index.js +11 -0
- package/lib-amd/components/Tabs/index.js.map +1 -0
- package/lib-amd/index.d.ts +1 -3
- package/lib-amd/index.js +2 -3
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/utilities/observeResize.d.ts +1 -1
- package/lib-amd/utilities/observeResize.js +3 -1
- package/lib-amd/utilities/observeResize.js.map +1 -1
- package/lib-amd/utilities/useOverflow.d.ts +1 -1
- package/lib-amd/utilities/useOverflow.js +4 -1
- package/lib-amd/utilities/useOverflow.js.map +1 -1
- package/lib-commonjs/{next/Tabs.d.ts → Tabs.d.ts} +0 -0
- package/lib-commonjs/{next/Tabs.js → Tabs.js} +0 -0
- package/lib-commonjs/Tabs.js.map +1 -0
- package/lib-commonjs/common/isConformant.d.ts +4 -2
- package/lib-commonjs/common/isConformant.js +1 -0
- package/lib-commonjs/common/isConformant.js.map +1 -1
- package/{lib-amd/next → lib-commonjs}/components/Tabs/TabItem.d.ts +1 -1
- package/lib-commonjs/{next/components → components}/Tabs/TabItem.js +1 -0
- package/lib-commonjs/components/Tabs/TabItem.js.map +1 -0
- package/{lib-amd/next → lib-commonjs}/components/Tabs/TabItem.types.d.ts +3 -6
- package/lib-commonjs/{next/components → components}/Tabs/TabItem.types.js +0 -0
- package/lib-commonjs/components/Tabs/TabItem.types.js.map +1 -0
- package/lib-commonjs/{next/components → components}/Tabs/Tabs.base.d.ts +1 -1
- package/lib-commonjs/{next/components → components}/Tabs/Tabs.base.js +9 -8
- package/lib-commonjs/components/Tabs/Tabs.base.js.map +1 -0
- package/{lib-amd/next → lib-commonjs}/components/Tabs/Tabs.d.ts +1 -1
- package/lib-commonjs/{next/components → components}/Tabs/Tabs.js +1 -0
- package/lib-commonjs/components/Tabs/Tabs.js.map +1 -0
- package/lib-commonjs/{next/components → components}/Tabs/Tabs.styles.d.ts +1 -1
- package/lib-commonjs/{next/components → components}/Tabs/Tabs.styles.js +4 -7
- package/lib-commonjs/components/Tabs/Tabs.styles.js.map +1 -0
- package/lib-commonjs/{next/components → components}/Tabs/Tabs.types.d.ts +2 -16
- package/lib-commonjs/{next/components → components}/Tabs/Tabs.types.js +0 -0
- package/lib-commonjs/components/Tabs/Tabs.types.js.map +1 -0
- package/lib-commonjs/{next/components → components}/Tabs/index.d.ts +0 -0
- package/lib-commonjs/components/Tabs/index.js +11 -0
- package/lib-commonjs/components/Tabs/index.js.map +1 -0
- package/lib-commonjs/index.d.ts +1 -3
- package/lib-commonjs/index.js +1 -3
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/utilities/observeResize.d.ts +1 -1
- package/lib-commonjs/utilities/observeResize.js +3 -1
- package/lib-commonjs/utilities/observeResize.js.map +1 -1
- package/lib-commonjs/utilities/useOverflow.d.ts +1 -1
- package/lib-commonjs/utilities/useOverflow.js +4 -1
- package/lib-commonjs/utilities/useOverflow.js.map +1 -1
- package/package.json +24 -26
- package/src/{next/components → components}/Tabs/TabItem.types.ts +3 -6
- package/src/{next/components → components}/Tabs/Tabs.types.ts +2 -16
- package/lib/Pivot.d.ts +0 -1
- package/lib/Pivot.js +0 -2
- package/lib/Pivot.js.map +0 -1
- package/lib/components/Pivot/Pivot.base.d.ts +0 -3
- package/lib/components/Pivot/Pivot.base.js +0 -183
- package/lib/components/Pivot/Pivot.base.js.map +0 -1
- package/lib/components/Pivot/Pivot.d.ts +0 -8
- package/lib/components/Pivot/Pivot.js +0 -12
- package/lib/components/Pivot/Pivot.js.map +0 -1
- package/lib/components/Pivot/Pivot.styles.d.ts +0 -2
- package/lib/components/Pivot/Pivot.styles.js +0 -269
- package/lib/components/Pivot/Pivot.styles.js.map +0 -1
- package/lib/components/Pivot/Pivot.types.d.ts +0 -141
- package/lib/components/Pivot/Pivot.types.js +0 -31
- package/lib/components/Pivot/Pivot.types.js.map +0 -1
- package/lib/components/Pivot/PivotItem.d.ts +0 -6
- package/lib/components/Pivot/PivotItem.js +0 -21
- package/lib/components/Pivot/PivotItem.js.map +0 -1
- package/lib/components/Pivot/PivotItem.types.d.ts +0 -66
- package/lib/components/Pivot/PivotItem.types.js +0 -1
- package/lib/components/Pivot/PivotItem.types.js.map +0 -1
- package/lib/components/Pivot/index.d.ts +0 -5
- package/lib/components/Pivot/index.js +0 -5
- package/lib/components/Pivot/index.js.map +0 -1
- package/lib/next/Tabs.js.map +0 -1
- package/lib/next/components/Tabs/TabItem.js.map +0 -1
- package/lib/next/components/Tabs/TabItem.types.js +0 -1
- package/lib/next/components/Tabs/TabItem.types.js.map +0 -1
- package/lib/next/components/Tabs/Tabs.base.js.map +0 -1
- package/lib/next/components/Tabs/Tabs.js.map +0 -1
- package/lib/next/components/Tabs/Tabs.styles.js.map +0 -1
- package/lib/next/components/Tabs/Tabs.types.js +0 -1
- package/lib/next/components/Tabs/Tabs.types.js.map +0 -1
- package/lib/next/components/Tabs/index.js +0 -4
- package/lib/next/components/Tabs/index.js.map +0 -1
- package/lib/next/index.d.ts +0 -2
- package/lib/next/index.js +0 -3
- package/lib/next/index.js.map +0 -1
- package/lib/next.d.ts +0 -1
- package/lib/next.js +0 -2
- package/lib/next.js.map +0 -1
- package/lib/version.d.ts +0 -1
- package/lib/version.js +0 -5
- package/lib/version.js.map +0 -1
- package/lib-amd/Pivot.d.ts +0 -1
- package/lib-amd/Pivot.js +0 -6
- package/lib-amd/Pivot.js.map +0 -1
- package/lib-amd/components/Pivot/Pivot.base.d.ts +0 -3
- package/lib-amd/components/Pivot/Pivot.base.js +0 -179
- package/lib-amd/components/Pivot/Pivot.base.js.map +0 -1
- package/lib-amd/components/Pivot/Pivot.d.ts +0 -8
- package/lib-amd/components/Pivot/Pivot.js +0 -13
- package/lib-amd/components/Pivot/Pivot.js.map +0 -1
- package/lib-amd/components/Pivot/Pivot.styles.d.ts +0 -2
- package/lib-amd/components/Pivot/Pivot.styles.js +0 -270
- package/lib-amd/components/Pivot/Pivot.styles.js.map +0 -1
- package/lib-amd/components/Pivot/Pivot.types.d.ts +0 -141
- package/lib-amd/components/Pivot/Pivot.types.js +0 -35
- package/lib-amd/components/Pivot/Pivot.types.js.map +0 -1
- package/lib-amd/components/Pivot/PivotItem.d.ts +0 -6
- package/lib-amd/components/Pivot/PivotItem.js +0 -22
- package/lib-amd/components/Pivot/PivotItem.js.map +0 -1
- package/lib-amd/components/Pivot/PivotItem.types.d.ts +0 -66
- package/lib-amd/components/Pivot/PivotItem.types.js +0 -5
- package/lib-amd/components/Pivot/PivotItem.types.js.map +0 -1
- package/lib-amd/components/Pivot/index.d.ts +0 -5
- package/lib-amd/components/Pivot/index.js +0 -9
- package/lib-amd/components/Pivot/index.js.map +0 -1
- package/lib-amd/next/Tabs.js.map +0 -1
- package/lib-amd/next/components/Tabs/TabItem.js.map +0 -1
- package/lib-amd/next/components/Tabs/TabItem.types.js.map +0 -1
- package/lib-amd/next/components/Tabs/Tabs.base.js.map +0 -1
- package/lib-amd/next/components/Tabs/Tabs.js.map +0 -1
- package/lib-amd/next/components/Tabs/Tabs.styles.js.map +0 -1
- package/lib-amd/next/components/Tabs/Tabs.types.js.map +0 -1
- package/lib-amd/next/components/Tabs/index.js +0 -8
- package/lib-amd/next/components/Tabs/index.js.map +0 -1
- package/lib-amd/next/index.d.ts +0 -2
- package/lib-amd/next/index.js +0 -7
- package/lib-amd/next/index.js.map +0 -1
- package/lib-amd/next.d.ts +0 -1
- package/lib-amd/next.js +0 -6
- package/lib-amd/next.js.map +0 -1
- package/lib-amd/version.d.ts +0 -1
- package/lib-amd/version.js +0 -6
- package/lib-amd/version.js.map +0 -1
- package/lib-commonjs/Pivot.d.ts +0 -1
- package/lib-commonjs/Pivot.js +0 -5
- package/lib-commonjs/Pivot.js.map +0 -1
- package/lib-commonjs/components/Pivot/Pivot.base.d.ts +0 -3
- package/lib-commonjs/components/Pivot/Pivot.base.js +0 -185
- package/lib-commonjs/components/Pivot/Pivot.base.js.map +0 -1
- package/lib-commonjs/components/Pivot/Pivot.d.ts +0 -8
- package/lib-commonjs/components/Pivot/Pivot.js +0 -14
- package/lib-commonjs/components/Pivot/Pivot.js.map +0 -1
- package/lib-commonjs/components/Pivot/Pivot.styles.d.ts +0 -2
- package/lib-commonjs/components/Pivot/Pivot.styles.js +0 -271
- package/lib-commonjs/components/Pivot/Pivot.styles.js.map +0 -1
- package/lib-commonjs/components/Pivot/Pivot.types.d.ts +0 -141
- package/lib-commonjs/components/Pivot/Pivot.types.js +0 -33
- package/lib-commonjs/components/Pivot/Pivot.types.js.map +0 -1
- package/lib-commonjs/components/Pivot/PivotItem.d.ts +0 -6
- package/lib-commonjs/components/Pivot/PivotItem.js +0 -23
- package/lib-commonjs/components/Pivot/PivotItem.js.map +0 -1
- package/lib-commonjs/components/Pivot/PivotItem.types.d.ts +0 -66
- package/lib-commonjs/components/Pivot/PivotItem.types.js +0 -3
- package/lib-commonjs/components/Pivot/PivotItem.types.js.map +0 -1
- package/lib-commonjs/components/Pivot/index.d.ts +0 -5
- package/lib-commonjs/components/Pivot/index.js +0 -9
- package/lib-commonjs/components/Pivot/index.js.map +0 -1
- package/lib-commonjs/next/Tabs.js.map +0 -1
- package/lib-commonjs/next/components/Tabs/TabItem.js.map +0 -1
- package/lib-commonjs/next/components/Tabs/TabItem.types.js.map +0 -1
- package/lib-commonjs/next/components/Tabs/Tabs.base.js.map +0 -1
- package/lib-commonjs/next/components/Tabs/Tabs.js.map +0 -1
- package/lib-commonjs/next/components/Tabs/Tabs.styles.js.map +0 -1
- package/lib-commonjs/next/components/Tabs/Tabs.types.js.map +0 -1
- package/lib-commonjs/next/components/Tabs/index.js +0 -8
- package/lib-commonjs/next/components/Tabs/index.js.map +0 -1
- package/lib-commonjs/next/index.d.ts +0 -2
- package/lib-commonjs/next/index.js +0 -6
- package/lib-commonjs/next/index.js.map +0 -1
- package/lib-commonjs/next.d.ts +0 -1
- package/lib-commonjs/next.js +0 -5
- package/lib-commonjs/next.js.map +0 -1
- package/lib-commonjs/version.d.ts +0 -1
- package/lib-commonjs/version.js +0 -7
- package/lib-commonjs/version.js.map +0 -1
- package/src/components/Pivot/Pivot.types.ts +0 -166
- package/src/components/Pivot/PivotItem.types.ts +0 -76
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tabs.types.js","sourceRoot":"../src/","sources":["components/Tabs/Tabs.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport { TabItem } from './TabItem';\nimport type { IStyle, ITheme } from '@fluentui/style-utilities';\nimport type { IStyleFunctionOrObject } from '@fluentui/utilities';\n\nexport interface TabsImperativeHandle {\n /**\n * Sets focus to the first tab.\n */\n focus(): void;\n}\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\nexport type TabsStyleProps = Required<Pick<TabsProps, 'theme'>> &\n Pick<TabsProps, 'className'> & {\n tabSize?: TabSizeType;\n tabFormat?: TabFormatType;\n };\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 * Display mode for the tabs\n */\nexport type TabFormatType = 'links' | 'tabs';\n\n/**\n * Size of the tabs\n */\nexport type TabSizeType = 'normal' | 'large';\n"]}
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
define(["require", "exports", "tslib", "./Tabs", "./Tabs.base", "./TabItem", "./Tabs.types", "./TabItem.types"], function (require, exports, tslib_1, Tabs_1, Tabs_base_1, TabItem_1, Tabs_types_1, TabItem_types_1) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.TabItem = void 0;
|
|
5
|
+
tslib_1.__exportStar(Tabs_1, exports);
|
|
6
|
+
tslib_1.__exportStar(Tabs_base_1, exports);
|
|
7
|
+
Object.defineProperty(exports, "TabItem", { enumerable: true, get: function () { return TabItem_1.TabItem; } });
|
|
8
|
+
tslib_1.__exportStar(Tabs_types_1, exports);
|
|
9
|
+
tslib_1.__exportStar(TabItem_types_1, exports);
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/Tabs/index.ts"],"names":[],"mappings":";;;;IAAA,sCAAuB;IACvB,2CAA4B;IACnB,kGAAA,OAAO,OAAA;IAChB,4CAA6B;IAC7B,+CAAgC","sourcesContent":["export * from './Tabs';\nexport * from './Tabs.base';\nexport { TabItem } from './TabItem';\nexport * from './Tabs.types';\nexport * from './TabItem.types';\n"]}
|
package/lib-amd/index.d.ts
CHANGED
package/lib-amd/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
define(["require", "exports", "tslib", "./
|
|
1
|
+
define(["require", "exports", "tslib", "./Tabs"], function (require, exports, tslib_1, Tabs_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
tslib_1.__exportStar(
|
|
5
|
-
tslib_1.__exportStar(react_theme_provider_1, exports);
|
|
4
|
+
tslib_1.__exportStar(Tabs_1, exports);
|
|
6
5
|
});
|
|
7
6
|
//# sourceMappingURL=index.js.map
|
package/lib-amd/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":";;;IAAA,sCAAuB","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,6 +1,7 @@
|
|
|
1
1
|
define(["require", "exports", "@fluentui/utilities"], function (require, exports, utilities_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.observeResize = void 0;
|
|
4
5
|
/**
|
|
5
6
|
* Wrapper for ResizeObserver, with fallback for browsers that don't support ResizeObserver.
|
|
6
7
|
*
|
|
@@ -15,7 +16,7 @@ define(["require", "exports", "@fluentui/utilities"], function (require, exports
|
|
|
15
16
|
*
|
|
16
17
|
* @returns A function to clean up the observer/listener.
|
|
17
18
|
*/
|
|
18
|
-
|
|
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,5 +46,6 @@ define(["require", "exports", "@fluentui/utilities"], function (require, exports
|
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
48
|
};
|
|
49
|
+
exports.observeResize = observeResize;
|
|
48
50
|
});
|
|
49
51
|
//# sourceMappingURL=observeResize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observeResize.js","sourceRoot":"../src/","sources":["utilities/observeResize.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"observeResize.js","sourceRoot":"../src/","sources":["utilities/observeResize.ts"],"names":[],"mappings":";;;;IAEA;;;;;;;;;;;;;OAaG;IACI,IAAM,aAAa,GAAG,UAC3B,MAA2B,EAC3B,QAAuE;QAEvE,IAAI,OAAO,cAAc,KAAK,WAAW,EAAE;YACzC,IAAM,UAAQ,GAAG,IAAI,cAAc,CAAC,QAAQ,CAAC,CAAC;YAE9C,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;gBACzB,MAAM,CAAC,OAAO,CAAC,UAAA,CAAC,IAAI,OAAA,UAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAnB,CAAmB,CAAC,CAAC;aAC1C;iBAAM;gBACL,UAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;aAC1B;YAED,OAAO,cAAM,OAAA,UAAQ,CAAC,UAAU,EAAE,EAArB,CAAqB,CAAC;SACpC;aAAM;YACL,0DAA0D;YAC1D,IAAM,iBAAe,GAAG,cAAM,OAAA,QAAQ,CAAC,SAAS,CAAC,EAAnB,CAAmB,CAAC;YAElD,IAAM,KAAG,GAAG,qBAAS,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;YAClE,IAAI,CAAC,KAAG,EAAE;gBACR,4DAA4D;gBAC5D,OAAO;oBACL,sBAAsB;gBACxB,CAAC,CAAC;aACH;YAED,mFAAmF;YACnF,IAAM,kBAAgB,GAAG,KAAG,CAAC,qBAAqB,CAAC,iBAAe,CAAC,CAAC;YACpE,KAAG,CAAC,gBAAgB,CAAC,QAAQ,EAAE,iBAAe,EAAE,KAAK,CAAC,CAAC;YAEvD,OAAO;gBACL,KAAG,CAAC,oBAAoB,CAAC,kBAAgB,CAAC,CAAC;gBAC3C,KAAG,CAAC,mBAAmB,CAAC,QAAQ,EAAE,iBAAe,EAAE,KAAK,CAAC,CAAC;YAC5D,CAAC,CAAC;SACH;IACH,CAAC,CAAC;IAnCW,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,6 +1,7 @@
|
|
|
1
1
|
define(["require", "exports", "react", "@fluentui/react-hooks", "@fluentui/utilities", "./observeResize"], function (require, exports, React, react_hooks_1, utilities_1, observeResize_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.useOverflow = void 0;
|
|
4
5
|
/**
|
|
5
6
|
* Track whether any items don't fit within their container, and move them to the overflow menu.
|
|
6
7
|
* Items are moved into the overflow menu from back to front, excluding pinned items.
|
|
@@ -19,7 +20,7 @@ define(["require", "exports", "react", "@fluentui/react-hooks", "@fluentui/utili
|
|
|
19
20
|
* </Container>
|
|
20
21
|
* ```
|
|
21
22
|
*/
|
|
22
|
-
|
|
23
|
+
var useOverflow = function (_a) {
|
|
23
24
|
var onOverflowItemsChanged = _a.onOverflowItemsChanged, rtl = _a.rtl, pinnedIndex = _a.pinnedIndex;
|
|
24
25
|
var updateOverflowRef = React.useRef();
|
|
25
26
|
var containerWidthRef = React.useRef();
|
|
@@ -40,6 +41,7 @@ define(["require", "exports", "react", "@fluentui/react-hooks", "@fluentui/utili
|
|
|
40
41
|
containerRef(menuButton.parentElement);
|
|
41
42
|
return function () { return containerRef(null); };
|
|
42
43
|
});
|
|
44
|
+
// eslint-disable-next-line no-restricted-properties
|
|
43
45
|
React.useLayoutEffect(function () {
|
|
44
46
|
var container = containerRef.current;
|
|
45
47
|
var menuButton = menuButtonRef.current;
|
|
@@ -121,5 +123,6 @@ define(["require", "exports", "react", "@fluentui/react-hooks", "@fluentui/utili
|
|
|
121
123
|
});
|
|
122
124
|
return { menuButtonRef: menuButtonRef };
|
|
123
125
|
};
|
|
126
|
+
exports.useOverflow = useOverflow;
|
|
124
127
|
});
|
|
125
128
|
//# sourceMappingURL=useOverflow.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOverflow.js","sourceRoot":"../src/","sources":["utilities/useOverflow.ts"],"names":[],"mappings":";;;IAmCA;;;;;;;;;;;;;;;;;OAiBG;IACU,QAAA,WAAW,GAAG,UAAC,EAA4D;YAA1D,kDAAsB,EAAE,YAAG,EAAE,4BAAW;QACpE,IAAM,iBAAiB,GAAG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AC;QAEH,OAAO,EAAE,aAAa,eAAA,EAAE,CAAC;IAC3B,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":";;;;IAoCA;;;;;;;;;;;;;;;;;OAiBG;IACI,IAAM,WAAW,GAAG,UAAC,EAA4D;YAA1D,sBAAsB,4BAAA,EAAE,GAAG,SAAA,EAAE,WAAW,iBAAA;QACpE,IAAM,iBAAiB,GAAG,KAAK,CAAC,MAAM,EAAc,CAAC;QACrD,IAAM,iBAAiB,GAAG,KAAK,CAAC,MAAM,EAAU,CAAC;QAEjD,4CAA4C;QAC5C,IAAM,YAAY,GAAG,0BAAY,CAAc,UAAA,SAAS;YACtD,IAAM,eAAe,GAAG,6BAAa,CAAC,SAAS,EAAE,UAAA,OAAO;gBACtD,iBAAiB,CAAC,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC;gBAC3F,IA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sB,CACpB,aAAa,EACb,KAAK,CAAC,GAAG,CAAC,UAAC,GAAG,EAAE,KAAK,IAAK,OAAA,CAAC;wBACzB,GAAG,KAAA;wBACH,aAAa,EAAE,KAAK,IAAI,aAAa,IAAI,KAAK,KAAK,WAAW;qBAC/D,CAAC,EAHwB,CAGxB,CAAC,CACJ,CAAC;iBACH;YACH,CAAC,CAAC;YAEF,IAAI,oBAAoB,GAA6B,SAAS,CAAC;YAE/D,sGAAsG;YACtG,yEAAyE;YACzE,IAAI,iBAAiB,CAAC,OAAO,KAAK,SAAS,EAAE;gBAC3C,IAAM,KAAG,GAAG,qBAAS,CAAC,SAAS,CAAC,CAAC;gBACjC,IAAI,KAAG,EAAE;oBACP,IAAM,kBAAgB,GAAG,KAAG,CAAC,qBAAqB,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;oBAC9E,oBAAoB,GAAG,cAAM,OAAA,KAAG,CAAC,oBAAoB,CAAC,kBAAgB,CAAC,EAA1C,CAA0C,CAAC;iBACzE;aACF;YAED,OAAO;gBACL,IAAI,oBAAoB,EAAE;oBACxB,oBAAoB,EAAE,CAAC;iBACxB;gBAED,yDAAyD;gBACzD,yDAAyD;gBACzD,gBAAgB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;gBAC/B,iBAAiB,CAAC,OAAO,GAAG,SAAS,CAAC;YACxC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,OAAO,EAAE,aAAa,eAAA,EAAE,CAAC;IAC3B,CAAC,CAAC;IA3HW,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"]}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tabs.js","sourceRoot":"../src/","sources":["Tabs.ts"],"names":[],"mappings":";;;AAAA,kEAAwC","sourcesContent":["export * from './components/Tabs/index';\n"]}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import { IsConformantOptions } from '@fluentui/react-conformance';
|
|
2
|
-
export declare function isConformant(testInfo: Omit<IsConformantOptions
|
|
1
|
+
import type { IsConformantOptions } from '@fluentui/react-conformance';
|
|
2
|
+
export declare function isConformant<TProps = {}>(testInfo: Omit<IsConformantOptions<TProps>, 'componentPath'> & {
|
|
3
|
+
componentPath?: string;
|
|
4
|
+
}): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isConformant.js","sourceRoot":"../src/","sources":["common/isConformant.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"isConformant.js","sourceRoot":"../src/","sources":["common/isConformant.ts"],"names":[],"mappings":";;;AAAA,iEAA+E;AAG/E,SAAgB,YAAY,CAC1B,QAAyF;IAEzF,IAAM,cAAc,GAAyC;QAC3D,aAAa,EAAE,CAAC,cAAc,EAAE,uBAAuB,CAAC;QACxD,aAAa,EAAE,MAAO,CAAC,MAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;KAC7D,CAAC;IAEF,gCAAgB,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;AAC7C,CAAC;AATD,oCASC","sourcesContent":["import { isConformant as baseIsConformant } from '@fluentui/react-conformance';\nimport type { IsConformantOptions } from '@fluentui/react-conformance';\n\nexport function isConformant<TProps = {}>(\n testInfo: Omit<IsConformantOptions<TProps>, 'componentPath'> & { componentPath?: string },\n) {\n const defaultOptions: Partial<IsConformantOptions<TProps>> = {\n disabledTests: ['has-docblock', 'kebab-aria-attributes'],\n componentPath: module!.parent!.filename.replace('.test', ''),\n };\n\n baseIsConformant(defaultOptions, testInfo);\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { TabItemProps } from './TabItem.types';
|
|
2
|
+
import type { TabItemProps } from './TabItem.types';
|
|
3
3
|
export declare class TabItem extends React.Component<TabItemProps, {}> {
|
|
4
4
|
constructor(props: TabItemProps);
|
|
5
5
|
render(): JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TabItem.js","sourceRoot":"../src/","sources":["components/Tabs/TabItem.tsx"],"names":[],"mappings":";;;;AAAA,6BAA+B;AAC/B,iDAA4F;AAG5F,oCAAoC;AAEpC;IAA6B,mCAAiC;IAC5D,iBAAY,KAAmB;QAA/B,YACE,kBAAM,KAAK,CAAC,SAGb;QADC,kCAAsB,CAAC,KAAI,CAAC,CAAC;;IAC/B,CAAC;IAEM,wBAAM,GAAb;QACE,OAAO,gDAAS,0BAAc,CAAC,IAAI,CAAC,KAAK,EAAE,yBAAa,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAO,CAAC;IACzF,CAAC;IACH,cAAC;AAAD,CAAC,AAVD,CAA6B,KAAK,CAAC,SAAS,GAU3C;AAVY,0BAAO","sourcesContent":["import * as React from 'react';\nimport { getNativeProps, divProperties, initializeComponentRef } from '@fluentui/utilities';\nimport type { 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,10 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { IKeytipProps } from '@fluentui/react
|
|
3
|
-
import { IButtonProps } from '@fluentui/react
|
|
4
|
-
import { IRefObject, IRenderFunction } from '@fluentui/utilities';
|
|
5
|
-
/**
|
|
6
|
-
* {@docCategory Tabs}
|
|
7
|
-
*/
|
|
2
|
+
import type { IKeytipProps } from '@fluentui/react';
|
|
3
|
+
import type { IButtonProps } from '@fluentui/react/lib/Button';
|
|
4
|
+
import type { IRefObject, IRenderFunction } from '@fluentui/utilities';
|
|
8
5
|
export interface TabItemProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
9
6
|
/**
|
|
10
7
|
* Gets the component ref.
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TabItem.types.js","sourceRoot":"../src/","sources":["components/Tabs/TabItem.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport type { IKeytipProps } from '@fluentui/react';\nimport type { IButtonProps } from '@fluentui/react/lib/Button';\nimport type { IRefObject, IRenderFunction } from '@fluentui/utilities';\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,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TabsBase = void 0;
|
|
3
4
|
var tslib_1 = require("tslib");
|
|
4
5
|
var React = require("react");
|
|
5
6
|
var react_hooks_1 = require("@fluentui/react-hooks");
|
|
6
7
|
var utilities_1 = require("@fluentui/utilities");
|
|
7
|
-
var
|
|
8
|
-
var Button_1 = require("@fluentui/react
|
|
8
|
+
var react_1 = require("@fluentui/react");
|
|
9
|
+
var Button_1 = require("@fluentui/react/lib-commonjs/Button");
|
|
9
10
|
var index_1 = require("./index");
|
|
10
|
-
var useOverflow_1 = require("
|
|
11
|
+
var useOverflow_1 = require("../../utilities/useOverflow");
|
|
11
12
|
var getClassNames = utilities_1.classNamesFunction();
|
|
12
13
|
var COMPONENT_NAME = 'Tabs';
|
|
13
14
|
var getTabId = function (props, baseId, itemKey, index) {
|
|
@@ -63,7 +64,7 @@ exports.TabsBase = React.forwardRef(function (props, ref) {
|
|
|
63
64
|
var itemCount = tab.itemCount, itemIcon = tab.itemIcon, headerText = tab.headerText;
|
|
64
65
|
return (React.createElement("span", { className: classNames.tabContent },
|
|
65
66
|
itemIcon !== undefined && (React.createElement("span", { className: classNames.icon },
|
|
66
|
-
React.createElement(
|
|
67
|
+
React.createElement(react_1.Icon, { iconName: itemIcon }))),
|
|
67
68
|
headerText !== undefined && React.createElement("span", { className: classNames.text },
|
|
68
69
|
" ",
|
|
69
70
|
tab.headerText),
|
|
@@ -91,13 +92,14 @@ exports.TabsBase = React.forwardRef(function (props, ref) {
|
|
|
91
92
|
// eslint-disable-next-line react/jsx-no-bind
|
|
92
93
|
onClick: function (ev) { return onTabClick(itemKey, ev); },
|
|
93
94
|
// eslint-disable-next-line react/jsx-no-bind
|
|
94
|
-
onKeyDown: function (ev) { return onKeyDown(itemKey, ev); }, "aria-label": tab.ariaLabel, role:
|
|
95
|
+
onKeyDown: function (ev) { return onKeyDown(itemKey, ev); }, "aria-label": tab.ariaLabel, role: tab.role || 'tab', "aria-selected": isSelected, name: tab.headerText, keytipProps: tab.keytipProps, "data-content": contentString }), tabContent));
|
|
95
96
|
};
|
|
96
97
|
var onTabClick = function (itemKey, ev) {
|
|
97
98
|
ev.preventDefault();
|
|
98
99
|
updateSelectedItem(itemKey, ev);
|
|
99
100
|
};
|
|
100
101
|
var onKeyDown = function (itemKey, ev) {
|
|
102
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
101
103
|
if (ev.which === utilities_1.KeyCodes.enter) {
|
|
102
104
|
ev.preventDefault();
|
|
103
105
|
updateSelectedItem(itemKey);
|
|
@@ -147,9 +149,8 @@ exports.TabsBase = React.forwardRef(function (props, ref) {
|
|
|
147
149
|
// The overflow menu starts empty and items[] is updated as the overflow items change
|
|
148
150
|
var overflowMenuProps = React.useMemo(function () { return ({
|
|
149
151
|
items: [],
|
|
150
|
-
doNotLayer: true,
|
|
151
152
|
alignTargetEdge: true,
|
|
152
|
-
directionalHint:
|
|
153
|
+
directionalHint: react_1.DirectionalHint.bottomRightEdge,
|
|
153
154
|
}); }, []);
|
|
154
155
|
var overflowMenuButtonRef = useOverflow_1.useOverflow({
|
|
155
156
|
onOverflowItemsChanged: function (overflowIndex, elements) {
|
|
@@ -168,7 +169,7 @@ exports.TabsBase = React.forwardRef(function (props, ref) {
|
|
|
168
169
|
pinnedIndex: renderedSelectedIndex,
|
|
169
170
|
}).menuButtonRef;
|
|
170
171
|
return (React.createElement("div", tslib_1.__assign({ role: "toolbar" }, divProps, { ref: ref }),
|
|
171
|
-
React.createElement(
|
|
172
|
+
React.createElement(react_1.FocusZone, { componentRef: focusZoneRef, direction: react_1.FocusZoneDirection.horizontal, className: classNames.root, role: "tablist" },
|
|
172
173
|
items,
|
|
173
174
|
overflowBehavior === 'menu' && (React.createElement(Button_1.CommandButton, { className: utilities_1.css(classNames.tab, classNames.overflowMenuButton), elementRef: overflowMenuButtonRef, componentRef: overflowMenuButtonComponentRef, menuProps: overflowMenuProps, menuIconProps: { iconName: 'More', style: { color: 'inherit' } } }))),
|
|
174
175
|
renderedSelectedKey &&
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tabs.base.js","sourceRoot":"../src/","sources":["components/Tabs/Tabs.base.tsx"],"names":[],"mappings":";;;;AAAA,6BAA+B;AAC/B,qDAAoE;AACpE,iDAAqH;AACrH,yCAAuF;AACvF,qDAA2D;AAC3D,iCAAkC;AAClC,2DAA0D;AAK1D,IAAM,aAAa,GAAG,8BAAkB,EAA8B,CAAC;AAEvE,IAAM,cAAc,GAAG,MAAM,CAAC;AAQ9B,IAAM,QAAQ,GAAG,UAAC,KAAgB,EAAE,MAAc,EAAE,OAAe,EAAE,KAAa;IAChF,IAAI,KAAK,CAAC,QAAQ,EAAE;QAClB,OAAO,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;KACvC;IACD,OAAO,MAAM,IAAG,SAAO,KAAO,CAAA,CAAC;AACjC,CAAC,CAAC;AAEF,gDAAgD;AAChD,oEAAoE;AACpE,IAAM,WAAW,GAAG,UAAC,KAAgB,EAAE,MAAc;IACnD,IAAM,MAAM,GAAsB;QAChC,IAAI,EAAE,EAAE;QACR,iBAAiB,EAAE,EAAE;QACrB,iBAAiB,EAAE,EAAE;KACtB,CAAC;IAEF,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ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UAAU,CAAC,IAAI,EAC1B,IAAI,EAAC,SAAS;YAEb,KAAK;YACL,gBAAgB,KAAK,MAAM,IAAI,CAC9B,oBAAC,sBAAa,IACZ,SAAS,EAAE,eAAG,CAAC,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,kBAAkB,CAAC,EAC7D,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,aAAa,CAAC,IAAI,CAAC,GAAG,CACpB,UAAA,GAAG;gBACD,OAAA,CAAC,GAAG,CAAC,YAAY,KAAK,IAAI,IAAI,mBAAmB,KAAK,GAAG,CAAC,OAAO,CAAC;oBAClE,aAAa,CAAC,GAAG,CAAC,OAAO,EAAE,mBAAmB,KAAK,GAAG,CAAC,OAAO,CAAC;YAD/D,CAC+D,CAClE,CACC,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AACF,gBAAQ,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 { DirectionalHint, FocusZone, FocusZoneDirection, Icon } from '@fluentui/react';\nimport { CommandButton } from '@fluentui/react/lib/Button';\nimport { TabItem } from './index';\nimport { useOverflow } from '../../utilities/useOverflow';\nimport type { IContextualMenuProps, IFocusZone } from '@fluentui/react';\nimport type { IButton } from '@fluentui/react/lib/Button';\nimport type { TabsImperativeHandle, TabItemProps, TabsProps, TabsStyleProps, TabsStyles } from './index';\n\nconst getClassNames = classNamesFunction<TabsStyleProps, TabsStyles>();\n\nconst COMPONENT_NAME = 'Tabs';\n\ntype TabItemCollection = {\n tabs: TabItemProps[];\n keyToIndexMapping: { [key: string]: number };\n keyToTabIdMapping: { [key: string]: string };\n};\n\nconst getTabId = (props: TabsProps, baseId: string, itemKey: string, index: number): string => {\n if (props.getTabId) {\n return props.getTabId(itemKey, index);\n }\n return baseId + `-Tab${index}`;\n};\n\n// Gets the set of Tabs as array of TabItemProps\n// The set of Tabs is determined by child components of type TabItem\nconst getTabItems = (props: TabsProps, baseId: string): TabItemCollection => {\n const result: TabItemCollection = {\n tabs: [],\n keyToIndexMapping: {},\n keyToTabIdMapping: {},\n };\n\n React.Children.forEach(React.Children.toArray(props.children), (child: React.ReactNode, index: number) => {\n if (isTabItem(child)) {\n const { itemKey = index.toString(), ...tabItemProps } = child.props;\n result.tabs.push({\n ...tabItemProps,\n itemKey: itemKey,\n });\n result.keyToIndexMapping[itemKey] = index;\n result.keyToTabIdMapping[itemKey] = getTabId(props, baseId, itemKey, index);\n } else if (child) {\n warn('The children of a Tabs component must be of type TabItem to be rendered.');\n }\n });\n return result;\n};\n\nconst isTabItem = (item: React.ReactNode): item is TabItem => {\n return ((item as React.ReactElement)?.type as React.ComponentType)?.name === TabItem.name;\n};\n\nexport const TabsBase: React.FunctionComponent<TabsProps> = React.forwardRef<HTMLDivElement, TabsProps>(\n (props, ref) => {\n const focusZoneRef = React.useRef<IFocusZone>(null);\n const overflowMenuButtonComponentRef = React.useRef<IButton>(null);\n const baseId: string = useId('Tabs');\n\n const [selectedKey, setSelectedKey] = useControllableValue(props.selectedKey, props.defaultSelectedKey);\n\n const { componentRef, theme, tabSize, tabFormat, overflowBehavior } = props;\n\n let classNames: { [key in keyof TabsStyles]: string };\n const divProps = getNativeProps<React.HTMLAttributes<HTMLDivElement>>(props, divProperties);\n\n let tabCollection = getTabItems(props, baseId);\n\n React.useImperativeHandle(componentRef as React.RefObject<TabsImperativeHandle>, () => ({\n focus: () => {\n focusZoneRef.current?.focus();\n },\n }));\n\n const renderTabContent = (tab?: TabItemProps): JSX.Element | null => {\n if (!tab) {\n return null;\n }\n\n const { itemCount, itemIcon, headerText } = tab;\n return (\n <span className={classNames.tabContent}>\n {itemIcon !== undefined && (\n <span className={classNames.icon}>\n <Icon iconName={itemIcon} />\n </span>\n )}\n {headerText !== undefined && <span className={classNames.text}> {tab.headerText}</span>}\n {itemCount !== undefined && <span className={classNames.count}> ({itemCount})</span>}\n </span>\n );\n };\n\n const renderTab = (\n renderTabCollection: TabItemCollection,\n tab: TabItemProps,\n renderTabSelectedKey: string | null | undefined,\n className: string,\n ): JSX.Element => {\n const { itemKey, headerButtonProps, onRenderTab } = tab;\n const tabId = renderTabCollection.keyToTabIdMapping[itemKey!];\n let tabContent: JSX.Element | null;\n const isSelected: boolean = renderTabSelectedKey === itemKey;\n\n if (onRenderTab) {\n tabContent = onRenderTab(tab, renderTabContent);\n } else {\n tabContent = renderTabContent(tab);\n }\n\n let contentString = tab.headerText || '';\n contentString += tab.itemCount ? ' (' + tab.itemCount + ')' : '';\n // Adding space supplementary for icon\n contentString += tab.itemIcon ? ' xx' : '';\n return (\n <CommandButton\n {...headerButtonProps}\n id={tabId}\n key={itemKey}\n className={css(className, isSelected && classNames.tabIsSelected)}\n // eslint-disable-next-line react/jsx-no-bind\n onClick={(ev: React.MouseEvent<HTMLElement>) => onTabClick(itemKey!, ev)}\n // eslint-disable-next-line react/jsx-no-bind\n onKeyDown={(ev: React.KeyboardEvent<HTMLElement>) => onKeyDown(itemKey!, ev)}\n aria-label={tab.ariaLabel}\n role={tab.role || 'tab'}\n aria-selected={isSelected}\n name={tab.headerText}\n keytipProps={tab.keytipProps}\n data-content={contentString}\n >\n {tabContent}\n </CommandButton>\n );\n };\n\n const onTabClick = (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 // eslint-disable-next-line deprecation/deprecation\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 tabCollection = getTabItems(props, baseId);\n if (props.onTabClick && tabCollection.keyToIndexMapping[itemKey] >= 0) {\n const selectedIndex = tabCollection.keyToIndexMapping[itemKey];\n const item = React.Children.toArray(props.children)[selectedIndex];\n if (isTabItem(item)) {\n props.onTabClick(item, ev);\n }\n }\n\n overflowMenuButtonComponentRef.current?.dismissMenu();\n };\n\n const renderTabItem = (itemKey: string | undefined, isActive: boolean): JSX.Element | null => {\n if (props.headersOnly || !itemKey) {\n return null;\n }\n\n const index = tabCollection.keyToIndexMapping[itemKey];\n const selectedTabId = tabCollection.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 && tabCollection.keyToIndexMapping[itemKey] !== undefined;\n };\n\n const getSelectedKey = () => {\n if (isKeyValid(selectedKey)) {\n return selectedKey;\n }\n if (tabCollection.tabs.length) {\n return tabCollection.tabs[0].itemKey;\n }\n return undefined;\n };\n\n classNames = getClassNames(props.styles!, {\n theme: theme!,\n tabSize,\n tabFormat,\n });\n\n const renderedSelectedKey = getSelectedKey();\n const renderedSelectedIndex = renderedSelectedKey ? tabCollection.keyToIndexMapping[renderedSelectedKey] : 0;\n\n const items = tabCollection.tabs.map(l => renderTab(tabCollection, l, renderedSelectedKey, classNames.tab));\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 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 = tabCollection.tabs.slice(overflowIndex).map((tab, index) => ({\n key: tab.itemKey || `${overflowIndex + index}`,\n onRender: () => renderTab(tabCollection, tab, renderedSelectedKey, classNames.tabInMenu),\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.tab, 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 tabCollection.tabs.map(\n tab =>\n (tab.alwaysRender === true || renderedSelectedKey === tab.itemKey) &&\n renderTabItem(tab.itemKey, renderedSelectedKey === tab.itemKey),\n )}\n </div>\n );\n },\n);\nTabsBase.displayName = COMPONENT_NAME;\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { TabsProps } from './Tabs.types';
|
|
2
|
+
import type { TabsProps } from './Tabs.types';
|
|
3
3
|
/**
|
|
4
4
|
* The Tabs control and related tabs pattern are used for navigating frequently accessed,
|
|
5
5
|
* distinct content categories. Tabs allow for navigation between two or more content
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tabs.js","sourceRoot":"../src/","sources":["components/Tabs/Tabs.tsx"],"names":[],"mappings":";;;AACA,iDAA6C;AAC7C,yCAAuC;AACvC,6CAA0C;AAG1C;;;;GAIG;AACU,QAAA,IAAI,GAAuC,kBAAM,CAC5D,oBAAQ,EACR,uBAAS,EACT,SAAS,EACT;IACE,KAAK,EAAE,MAAM;CACd,CACF,CAAC","sourcesContent":["import * as React from 'react';\nimport { styled } from '@fluentui/utilities';\nimport { TabsBase } from './Tabs.base';\nimport { getStyles } from './Tabs.styles';\nimport type { TabsProps, TabsStyleProps, TabsStyles } from './Tabs.types';\n\n/**\n * The Tabs control and related tabs pattern are used for navigating frequently accessed,\n * distinct content categories. Tabs 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 Tabs: React.FunctionComponent<TabsProps> = styled<TabsProps, TabsStyleProps, TabsStyles>(\n TabsBase,\n getStyles,\n undefined,\n {\n scope: 'Tabs',\n },\n);\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TabsStyleProps, TabsStyles } from './Tabs.types';
|
|
1
|
+
import type { TabsStyleProps, TabsStyles } from './Tabs.types';
|
|
2
2
|
export declare const getStyles: (props: TabsStyleProps) => TabsStyles;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getStyles = void 0;
|
|
3
4
|
var tslib_1 = require("tslib");
|
|
4
5
|
var style_utilities_1 = require("@fluentui/style-utilities");
|
|
5
6
|
var utilities_1 = require("@fluentui/utilities");
|
|
@@ -138,12 +139,7 @@ var getLinkStyles = function (props, classNames, isLinkInOverflowMenu) {
|
|
|
138
139
|
color: semanticColors.primaryButtonText,
|
|
139
140
|
}
|
|
140
141
|
},
|
|
141
|
-
_c[style_utilities_1.HighContrastSelector] = {
|
|
142
|
-
fontWeight: style_utilities_1.FontWeights.semibold,
|
|
143
|
-
color: 'HighlightText',
|
|
144
|
-
background: 'Highlight',
|
|
145
|
-
MsHighContrastAdjust: 'none',
|
|
146
|
-
},
|
|
142
|
+
_c[style_utilities_1.HighContrastSelector] = tslib_1.__assign({ fontWeight: style_utilities_1.FontWeights.semibold, color: 'HighlightText', background: 'Highlight' }, style_utilities_1.getHighContrastNoAdjustStyle()),
|
|
147
143
|
_c),
|
|
148
144
|
},
|
|
149
145
|
_b),
|
|
@@ -152,7 +148,7 @@ var getLinkStyles = function (props, classNames, isLinkInOverflowMenu) {
|
|
|
152
148
|
],
|
|
153
149
|
];
|
|
154
150
|
};
|
|
155
|
-
|
|
151
|
+
var getStyles = function (props) {
|
|
156
152
|
var _a, _b, _c, _d;
|
|
157
153
|
var className = props.className, tabSize = props.tabSize, tabFormat = props.tabFormat, theme = props.theme;
|
|
158
154
|
var semanticColors = theme.semanticColors, fonts = theme.fonts;
|
|
@@ -268,4 +264,5 @@ exports.getStyles = function (props) {
|
|
|
268
264
|
icon: classNames.icon,
|
|
269
265
|
};
|
|
270
266
|
};
|
|
267
|
+
exports.getStyles = getStyles;
|
|
271
268
|
//# sourceMappingURL=Tabs.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tabs.styles.js","sourceRoot":"../src/","sources":["components/Tabs/Tabs.styles.ts"],"names":[],"mappings":";;;;AAAA,6DAOmC;AACnC,iDAA8D;AAI9D,IAAM,gBAAgB,GAAG;IACvB,KAAK,EAAE,eAAe;IACtB,IAAI,EAAE,cAAc;IACpB,aAAa,EAAE,aAAa;IAC5B,GAAG,EAAE,aAAa;IAClB,UAAU,EAAE,oBAAoB;IAChC,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,gBAAgB;IAC7B,UAAU,EAAE,eAAe;IAC3B,IAAI,EAAE,cAAc;IACpB,SAAS,EAAE,mBAAmB;IAC9B,kBAAkB,EAAE,4BAA4B;CACjD,CAAC;AAEF,IAAM,aAAa,GAAG,UACpB,KAAqB,EACrB,UAAqC,EACrC,oBAAqC;;IAArC,qCAAA,EAAA,4BAAqC;IAE7B,IAAA,OAAO,GAAgB,KAAK,QAArB,EAAE,SAAS,GAAK,KAAK,UAAV,CAAW;IAC/B,IAAA,KAA4B,KAAK,CAAC,KAAK,EAArC,cAAc,oBAAA,EAAE,KAAK,WAAgB,CAAC;IAC9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AC;qBACd;oBACD,mBAAmB,EAAE;wBACnB,UAAU,EAAE,CAAC;qBACd;iBACF;aACF;SACF;QACD,IAAI,EAAE;YACJ,UAAU,CAAC,IAAI;YACf;gBACE,OAAO,EAAE,cAAc;gBACvB,aAAa,EAAE,KAAK;aACrB;SACF;QACD,KAAK,EAAE;YACL,UAAU,CAAC,KAAK;YAChB;gBACE,OAAO,EAAE,cAAc;gBACvB,aAAa,EAAE,KAAK;aACrB;SACF;QACD,IAAI,EAAE,UAAU,CAAC,IAAI;KACtB,CAAC;AACJ,CAAC,CAAC;AAnHW,QAAA,SAAS,aAmHpB","sourcesContent":["import {\n AnimationVariables,\n getGlobalClassNames,\n HighContrastSelector,\n normalize,\n FontWeights,\n getHighContrastNoAdjustStyle,\n} from '@fluentui/style-utilities';\nimport { IsFocusVisibleClassName } from '@fluentui/utilities';\nimport type { TabsStyleProps, TabsStyles } from './Tabs.types';\nimport type { IStyle } from '@fluentui/style-utilities';\n\nconst globalClassNames = {\n count: 'ms-Tabs-count',\n icon: 'ms-Tabs-icon',\n tabIsSelected: 'is-selected',\n tab: 'ms-Tabs-tab',\n tabContent: 'ms-Tabs-tabContent',\n root: 'ms-Tabs',\n rootIsLarge: 'ms-Tabs--large',\n rootIsTabs: 'ms-Tabs--tabs',\n text: 'ms-Tabs-text',\n tabInMenu: 'ms-Tabs-tabInMenu',\n overflowMenuButton: 'ms-Tabs-overflowMenuButton',\n};\n\nconst getLinkStyles = (\n props: TabsStyleProps,\n classNames: { [key: string]: string },\n isLinkInOverflowMenu: boolean = false,\n): IStyle[] => {\n const { tabSize, tabFormat } = props;\n const { semanticColors, fonts } = props.theme;\n const rootIsLarge = tabSize === 'large';\n const rootIsTabs = tabFormat === 'tabs';\n\n return [\n fonts.medium,\n {\n color: semanticColors.actionLink,\n padding: '0 8px',\n position: 'relative',\n backgroundColor: 'transparent',\n border: 0,\n borderRadius: 0,\n selectors: {\n ':hover': {\n backgroundColor: semanticColors.buttonBackgroundHovered,\n color: semanticColors.buttonTextHovered,\n cursor: 'pointer',\n },\n ':active': {\n backgroundColor: semanticColors.buttonBackgroundPressed,\n color: semanticColors.buttonTextHovered,\n },\n ':focus': {\n outline: 'none',\n },\n [`.${IsFocusVisibleClassName} &:focus`]: {\n outline: `1px solid ${semanticColors.focusBorder}`,\n },\n [`.${IsFocusVisibleClassName} &:focus:after`]: {\n content: 'attr(data-content)',\n position: 'relative',\n border: 0,\n },\n },\n },\n !isLinkInOverflowMenu && [\n {\n display: 'inline-block',\n lineHeight: 44,\n height: 44,\n marginRight: 8,\n textAlign: 'center',\n selectors: {\n ':before': {\n backgroundColor: 'transparent',\n bottom: 0,\n content: '\"\"',\n height: 2,\n left: 8,\n position: 'absolute',\n right: 8,\n transition: `left ${AnimationVariables.durationValue2} ${AnimationVariables.easeFunction2},\n right ${AnimationVariables.durationValue2} ${AnimationVariables.easeFunction2}`,\n },\n ':after': {\n color: 'transparent',\n content: 'attr(data-content)',\n display: 'block',\n fontWeight: FontWeights.bold,\n height: 1,\n overflow: 'hidden',\n visibility: 'hidden',\n },\n },\n },\n rootIsLarge && {\n fontSize: fonts.large.fontSize,\n },\n rootIsTabs && [\n {\n marginRight: 0,\n height: 44,\n lineHeight: 44,\n backgroundColor: semanticColors.buttonBackground,\n padding: '0 10px',\n verticalAlign: 'top',\n\n selectors: {\n ':focus': {\n outlineOffset: '-1px',\n },\n [`.${IsFocusVisibleClassName} &:focus::before`]: {\n height: 'auto',\n background: 'transparent',\n transition: 'none',\n },\n '&:hover, &:focus': {\n color: semanticColors.buttonTextCheckedHovered,\n },\n '&:active, &:hover': {\n color: semanticColors.primaryButtonText,\n backgroundColor: semanticColors.primaryButtonBackground,\n },\n [`&.${classNames.tabIsSelected}`]: {\n backgroundColor: semanticColors.primaryButtonBackground,\n color: semanticColors.primaryButtonText,\n fontWeight: FontWeights.regular,\n selectors: {\n ':before': {\n backgroundColor: 'transparent',\n transition: 'none',\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n content: '\"\"',\n height: 0,\n },\n ':hover': {\n backgroundColor: semanticColors.primaryButtonBackgroundHovered,\n color: semanticColors.primaryButtonText,\n },\n '&:active': {\n backgroundColor: semanticColors.primaryButtonBackgroundPressed,\n color: semanticColors.primaryButtonText,\n },\n [HighContrastSelector]: {\n fontWeight: FontWeights.semibold,\n color: 'HighlightText',\n background: 'Highlight',\n ...getHighContrastNoAdjustStyle(),\n },\n },\n },\n },\n },\n ],\n ],\n ];\n};\n\nexport const getStyles = (props: TabsStyleProps): TabsStyles => {\n const { className, tabSize, tabFormat, theme } = props;\n const { semanticColors, fonts } = theme;\n\n const classNames = getGlobalClassNames(globalClassNames, theme);\n\n const rootIsLarge = tabSize === 'large';\n const rootIsTabs = tabFormat === 'tabs';\n\n return {\n root: [\n classNames.root,\n fonts.medium,\n normalize,\n {\n position: 'relative',\n color: semanticColors.link,\n whiteSpace: 'nowrap',\n },\n rootIsLarge && classNames.rootIsLarge,\n rootIsTabs && classNames.rootIsTabs,\n className,\n ],\n itemContainer: {\n selectors: {\n '&[hidden]': {\n display: 'none',\n },\n },\n },\n tab: [\n classNames.tab,\n ...getLinkStyles(props, classNames),\n {\n [`&[data-is-overflowing='true']`]: {\n display: 'none',\n },\n },\n ],\n overflowMenuButton: [\n classNames.overflowMenuButton,\n {\n visibility: 'hidden',\n position: 'absolute',\n right: 0,\n [`.${classNames.tab}[data-is-overflowing='true'] ~ &`]: {\n visibility: 'visible',\n position: 'relative',\n },\n },\n ],\n tabInMenu: [\n classNames.tabInMenu,\n ...getLinkStyles(props, classNames, true),\n {\n textAlign: 'left',\n width: '100%',\n height: 36,\n lineHeight: 36,\n },\n ],\n tabIsSelected: [\n classNames.tab,\n classNames.tabIsSelected,\n {\n fontWeight: FontWeights.semibold,\n selectors: {\n ':before': {\n backgroundColor: semanticColors.inputBackgroundChecked,\n selectors: {\n [HighContrastSelector]: {\n backgroundColor: 'Highlight',\n },\n },\n },\n ':hover::before': {\n left: 0,\n right: 0,\n },\n [HighContrastSelector]: {\n color: 'Highlight',\n },\n },\n },\n ],\n tabContent: [\n classNames.tabContent,\n {\n flex: '0 1 100%',\n selectors: {\n '& > * ': {\n marginLeft: 4,\n },\n '& > *:first-child': {\n marginLeft: 0,\n },\n },\n },\n ],\n text: [\n classNames.text,\n {\n display: 'inline-block',\n verticalAlign: 'top',\n },\n ],\n count: [\n classNames.count,\n {\n display: 'inline-block',\n verticalAlign: 'top',\n },\n ],\n icon: classNames.icon,\n };\n};\n"]}
|
|
@@ -1,19 +1,13 @@
|
|
|
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';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*/
|
|
3
|
+
import type { IStyle, ITheme } from '@fluentui/style-utilities';
|
|
4
|
+
import type { IStyleFunctionOrObject } from '@fluentui/utilities';
|
|
8
5
|
export interface TabsImperativeHandle {
|
|
9
6
|
/**
|
|
10
7
|
* Sets focus to the first tab.
|
|
11
8
|
*/
|
|
12
9
|
focus(): void;
|
|
13
10
|
}
|
|
14
|
-
/**
|
|
15
|
-
* {@docCategory Tabs}
|
|
16
|
-
*/
|
|
17
11
|
export interface TabsProps extends React.HTMLAttributes<HTMLDivElement>, React.RefAttributes<HTMLDivElement> {
|
|
18
12
|
/**
|
|
19
13
|
* Optional callback to access the TabsImperativeHandle interface. Use this instead of ref for accessing
|
|
@@ -76,16 +70,10 @@ export interface TabsProps extends React.HTMLAttributes<HTMLDivElement>, React.R
|
|
|
76
70
|
*/
|
|
77
71
|
getTabId?: (itemKey: string, index: number) => string;
|
|
78
72
|
}
|
|
79
|
-
/**
|
|
80
|
-
* {@docCategory Tabs}
|
|
81
|
-
*/
|
|
82
73
|
export declare type TabsStyleProps = Required<Pick<TabsProps, 'theme'>> & Pick<TabsProps, 'className'> & {
|
|
83
74
|
tabSize?: TabSizeType;
|
|
84
75
|
tabFormat?: TabFormatType;
|
|
85
76
|
};
|
|
86
|
-
/**
|
|
87
|
-
* {@docCategory Tabs}
|
|
88
|
-
*/
|
|
89
77
|
export interface TabsStyles {
|
|
90
78
|
/**
|
|
91
79
|
* Style for the root element.
|
|
@@ -102,12 +90,10 @@ export interface TabsStyles {
|
|
|
102
90
|
itemContainer?: IStyle;
|
|
103
91
|
}
|
|
104
92
|
/**
|
|
105
|
-
* {@docCategory Tabs}
|
|
106
93
|
* Display mode for the tabs
|
|
107
94
|
*/
|
|
108
95
|
export declare type TabFormatType = 'links' | 'tabs';
|
|
109
96
|
/**
|
|
110
|
-
* {@docCategory Tabs}
|
|
111
97
|
* Size of the tabs
|
|
112
98
|
*/
|
|
113
99
|
export declare type TabSizeType = 'normal' | 'large';
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tabs.types.js","sourceRoot":"../src/","sources":["components/Tabs/Tabs.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport { TabItem } from './TabItem';\nimport type { IStyle, ITheme } from '@fluentui/style-utilities';\nimport type { IStyleFunctionOrObject } from '@fluentui/utilities';\n\nexport interface TabsImperativeHandle {\n /**\n * Sets focus to the first tab.\n */\n focus(): void;\n}\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\nexport type TabsStyleProps = Required<Pick<TabsProps, 'theme'>> &\n Pick<TabsProps, 'className'> & {\n tabSize?: TabSizeType;\n tabFormat?: TabFormatType;\n };\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 * Display mode for the tabs\n */\nexport type TabFormatType = 'links' | 'tabs';\n\n/**\n * Size of the tabs\n */\nexport type TabSizeType = 'normal' | 'large';\n"]}
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TabItem = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
tslib_1.__exportStar(require("./Tabs"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./Tabs.base"), exports);
|
|
7
|
+
var TabItem_1 = require("./TabItem");
|
|
8
|
+
Object.defineProperty(exports, "TabItem", { enumerable: true, get: function () { return TabItem_1.TabItem; } });
|
|
9
|
+
tslib_1.__exportStar(require("./Tabs.types"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./TabItem.types"), exports);
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/Tabs/index.ts"],"names":[],"mappings":";;;;AAAA,iDAAuB;AACvB,sDAA4B;AAC5B,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,uDAA6B;AAC7B,0DAAgC","sourcesContent":["export * from './Tabs';\nexport * from './Tabs.base';\nexport { TabItem } from './TabItem';\nexport * from './Tabs.types';\nexport * from './TabItem.types';\n"]}
|
package/lib-commonjs/index.d.ts
CHANGED
package/lib-commonjs/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var tslib_1 = require("tslib");
|
|
4
|
-
require("./
|
|
5
|
-
tslib_1.__exportStar(require("./Pivot"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("@fluentui/react-theme-provider"), exports);
|
|
4
|
+
tslib_1.__exportStar(require("./Tabs"), exports);
|
|
7
5
|
//# sourceMappingURL=index.js.map
|