@auth0/quantum-product 2.10.8 → 2.11.0

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 (31) hide show
  1. package/dropdown-menu/dropdown-menu-list-item/dropdown-menu-list-item.js +2 -1
  2. package/dropdown-menu/dropdown-menu.js +1 -1
  3. package/esm/dropdown-menu/dropdown-menu-list-item/dropdown-menu-list-item.js +2 -1
  4. package/esm/dropdown-menu/dropdown-menu.js +1 -1
  5. package/esm/tabs/tab/tab-override.js +18 -7
  6. package/esm/tabs/tab-list/tab-list-overrides.js +94 -0
  7. package/esm/tabs/tab-list/tab-list-utils.js +29 -0
  8. package/esm/tabs/tab-list/tab-list.js +111 -10
  9. package/esm/tabs/tab-list/use-tab-list-indicator/index.js +189 -0
  10. package/esm/tabs/tab-list/use-tab-list-keyboard/index.js +56 -0
  11. package/esm/tabs/tab-list/use-tab-list-overflow/index.js +149 -0
  12. package/esm/tabs/tabs-overrides.js +6 -7
  13. package/esm/tabs/tabs.js +12 -20
  14. package/package.json +6 -1
  15. package/tabs/tab/tab-override.d.ts +1 -1
  16. package/tabs/tab/tab-override.js +18 -7
  17. package/tabs/tab-list/tab-list-overrides.d.ts +12 -0
  18. package/tabs/tab-list/tab-list-overrides.js +97 -0
  19. package/tabs/tab-list/tab-list-utils.d.ts +32 -0
  20. package/tabs/tab-list/tab-list-utils.js +70 -0
  21. package/tabs/tab-list/tab-list.d.ts +9 -2
  22. package/tabs/tab-list/tab-list.js +111 -11
  23. package/tabs/tab-list/use-tab-list-indicator/index.d.ts +26 -0
  24. package/tabs/tab-list/use-tab-list-indicator/index.js +226 -0
  25. package/tabs/tab-list/use-tab-list-keyboard/index.d.ts +13 -0
  26. package/tabs/tab-list/use-tab-list-keyboard/index.js +93 -0
  27. package/tabs/tab-list/use-tab-list-overflow/index.d.ts +25 -0
  28. package/tabs/tab-list/use-tab-list-overflow/index.js +186 -0
  29. package/tabs/tabs-overrides.d.ts +1 -1
  30. package/tabs/tabs-overrides.js +6 -7
  31. package/tabs/tabs.js +12 -20
@@ -0,0 +1,149 @@
1
+ var __read = (this && this.__read) || function (o, n) {
2
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
3
+ if (!m) return o;
4
+ var i = m.call(o), r, ar = [], e;
5
+ try {
6
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
7
+ }
8
+ catch (error) { e = { error: error }; }
9
+ finally {
10
+ try {
11
+ if (r && !r.done && (m = i["return"])) m.call(i);
12
+ }
13
+ finally { if (e) throw e.error; }
14
+ }
15
+ return ar;
16
+ };
17
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
18
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
19
+ if (ar || !(i in from)) {
20
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
21
+ ar[i] = from[i];
22
+ }
23
+ }
24
+ return to.concat(ar || Array.prototype.slice.call(from));
25
+ };
26
+ import * as React from 'react';
27
+ import { useTabsContext } from '../../tabs-context';
28
+ import { areValueArraysEqual, createOverflowState, getChildOrderValue, getResolvedChildValue, isTabChild, } from '../tab-list-utils';
29
+ export var useTabListOverflow = function (_a) {
30
+ var children = _a.children, maxVisibleTabs = _a.maxVisibleTabs, moreLabel = _a.moreLabel, getOverflowCountLabel = _a.getOverflowCountLabel;
31
+ var _b = useTabsContext(), onChange = _b.onChange, value = _b.value;
32
+ var allChildren = React.useMemo(function () { return React.Children.toArray(children); }, [children]);
33
+ var resolvedChildren = React.useMemo(function () {
34
+ return allChildren.map(function (child, index) {
35
+ if (!isTabChild(child) || child.props.value !== undefined) {
36
+ return child;
37
+ }
38
+ return React.cloneElement(child, { value: getResolvedChildValue(child, index) });
39
+ });
40
+ }, [allChildren]);
41
+ var defaultTabOrder = React.useMemo(function () { return resolvedChildren.map(function (child, index) { return getChildOrderValue(child, index); }); }, [resolvedChildren]);
42
+ var childByOrderValue = React.useMemo(function () {
43
+ return new Map(defaultTabOrder.map(function (orderValue, index) { return [orderValue, resolvedChildren[index]]; }));
44
+ }, [defaultTabOrder, resolvedChildren]);
45
+ var baseVisibleTabCount = React.useMemo(function () {
46
+ var normalizedMaxVisibleTabs = Number.isFinite(maxVisibleTabs) && maxVisibleTabs > 0 ? maxVisibleTabs : resolvedChildren.length;
47
+ return Math.min(resolvedChildren.length, normalizedMaxVisibleTabs);
48
+ }, [resolvedChildren.length, maxVisibleTabs]);
49
+ var _c = __read(React.useState(function () {
50
+ return createOverflowState({
51
+ baseVisibleTabCount: baseVisibleTabCount,
52
+ moreLabel: moreLabel,
53
+ defaultTabOrder: defaultTabOrder,
54
+ });
55
+ }), 2), overflowState = _c[0], setOverflowState = _c[1];
56
+ var shouldResetOverflowState = overflowState.baselineVisibleTabCount !== baseVisibleTabCount ||
57
+ overflowState.baselineMoreLabel !== moreLabel ||
58
+ !areValueArraysEqual(overflowState.baselineTabOrder, defaultTabOrder);
59
+ var hasValidOrderedTabValues = overflowState.orderedTabValues !== undefined &&
60
+ overflowState.orderedTabValues.length === defaultTabOrder.length &&
61
+ overflowState.orderedTabValues.every(function (orderValue) { return childByOrderValue.has(orderValue); });
62
+ var overflowCompensation = shouldResetOverflowState ? 0 : overflowState.overflowCompensation;
63
+ var orderedTabValues = shouldResetOverflowState || !hasValidOrderedTabValues ? undefined : overflowState.orderedTabValues;
64
+ var minimumVisibleTabCount = baseVisibleTabCount > 0 ? 1 : 0;
65
+ var visibleTabCount = Math.max(minimumVisibleTabCount, baseVisibleTabCount - overflowCompensation);
66
+ var orderedChildren = React.useMemo(function () {
67
+ if (!orderedTabValues || orderedTabValues.length !== resolvedChildren.length) {
68
+ return resolvedChildren;
69
+ }
70
+ var mappedChildren = orderedTabValues.map(function (orderValue) { return childByOrderValue.get(orderValue); });
71
+ if (mappedChildren.some(function (child) { return child === undefined; })) {
72
+ return resolvedChildren;
73
+ }
74
+ return mappedChildren;
75
+ }, [childByOrderValue, orderedTabValues, resolvedChildren]);
76
+ var resetOverflowState = React.useCallback(function () {
77
+ setOverflowState(createOverflowState({
78
+ baseVisibleTabCount: baseVisibleTabCount,
79
+ moreLabel: moreLabel,
80
+ defaultTabOrder: defaultTabOrder,
81
+ }));
82
+ }, [baseVisibleTabCount, defaultTabOrder, moreLabel]);
83
+ var handleChange = React.useCallback(function (_evt, newValue) {
84
+ if (orderedTabValues !== undefined) {
85
+ resetOverflowState();
86
+ }
87
+ if (onChange) {
88
+ onChange(newValue);
89
+ }
90
+ }, [onChange, orderedTabValues, resetOverflowState]);
91
+ var _d = React.useMemo(function () {
92
+ var shouldOverflow = orderedChildren.length > visibleTabCount;
93
+ if (!shouldOverflow) {
94
+ return {
95
+ visibleChildren: orderedChildren,
96
+ overflowChildren: [],
97
+ };
98
+ }
99
+ var visible = orderedChildren.slice(0, visibleTabCount);
100
+ var selectedChild = orderedChildren.find(function (child) { return isTabChild(child) && child.props.value === value; });
101
+ if (selectedChild && !visible.includes(selectedChild) && visibleTabCount > 0) {
102
+ visible = __spreadArray(__spreadArray([], __read(visible.slice(0, Math.max(visibleTabCount - 1, 0))), false), [selectedChild], false);
103
+ }
104
+ var visibleSet = new Set(visible);
105
+ var overflow = orderedChildren.filter(function (child) { return !visibleSet.has(child); });
106
+ return {
107
+ visibleChildren: visible,
108
+ overflowChildren: overflow,
109
+ };
110
+ }, [orderedChildren, value, visibleTabCount]), visibleChildren = _d.visibleChildren, overflowChildren = _d.overflowChildren;
111
+ var hasOverflow = overflowChildren.length > 0;
112
+ var overflowCountLabel = React.useMemo(function () { return getOverflowCountLabel(overflowChildren.length); }, [getOverflowCountLabel, overflowChildren.length]);
113
+ var isSelectedValueVisible = React.useMemo(function () { return visibleChildren.some(function (child) { return isTabChild(child) && child.props.value === value; }); }, [value, visibleChildren]);
114
+ var isSelectedValueInOverflow = React.useMemo(function () { return overflowChildren.some(function (child) { return isTabChild(child) && child.props.value === value; }); }, [overflowChildren, value]);
115
+ var promoteTabValue = React.useCallback(function (tabValue) {
116
+ var _a;
117
+ var nextOrderedChildren = __spreadArray([], __read(orderedChildren), false);
118
+ var lastVisibleIndex = baseVisibleTabCount - 1;
119
+ var selectedIndex = nextOrderedChildren.findIndex(function (orderedChild) { return isTabChild(orderedChild) && orderedChild.props.value === tabValue; });
120
+ if (selectedIndex !== -1 && lastVisibleIndex >= 0 && selectedIndex !== lastVisibleIndex) {
121
+ _a = __read([
122
+ nextOrderedChildren[selectedIndex],
123
+ nextOrderedChildren[lastVisibleIndex],
124
+ ], 2), nextOrderedChildren[lastVisibleIndex] = _a[0], nextOrderedChildren[selectedIndex] = _a[1];
125
+ }
126
+ setOverflowState(createOverflowState({
127
+ baseVisibleTabCount: baseVisibleTabCount,
128
+ moreLabel: moreLabel,
129
+ defaultTabOrder: defaultTabOrder,
130
+ orderedTabValues: nextOrderedChildren.map(function (orderedChild, index) { return getChildOrderValue(orderedChild, index); }),
131
+ }));
132
+ }, [baseVisibleTabCount, defaultTabOrder, moreLabel, orderedChildren]);
133
+ return {
134
+ value: value,
135
+ onChange: onChange,
136
+ baseVisibleTabCount: baseVisibleTabCount,
137
+ minimumVisibleTabCount: minimumVisibleTabCount,
138
+ defaultTabOrder: defaultTabOrder,
139
+ visibleChildren: visibleChildren,
140
+ overflowChildren: overflowChildren,
141
+ hasOverflow: hasOverflow,
142
+ overflowCountLabel: overflowCountLabel,
143
+ isSelectedValueVisible: isSelectedValueVisible,
144
+ isSelectedValueInOverflow: isSelectedValueInOverflow,
145
+ handleChange: handleChange,
146
+ setOverflowState: setOverflowState,
147
+ promoteTabValue: promoteTabValue,
148
+ };
149
+ };
@@ -1,19 +1,18 @@
1
1
  export var createMuiTabsOverrides = function (_a) {
2
- var tokens = _a.tokens;
2
+ var spacing = _a.spacing;
3
3
  return {
4
4
  defaultProps: {
5
5
  indicatorColor: 'primary',
6
6
  textColor: 'primary',
7
7
  },
8
8
  styleOverrides: {
9
- indicator: {
10
- backgroundColor: tokens.color_border_selected,
9
+ root: {
10
+ minHeight: 'unset',
11
11
  },
12
12
  flexContainer: {
13
- display: 'block',
14
- },
15
- scroller: {
16
- borderBottom: "1px solid ".concat(tokens.color_border_default),
13
+ display: 'flex',
14
+ gap: spacing(0.5),
15
+ paddingBottom: spacing(1),
17
16
  },
18
17
  },
19
18
  };
package/esm/tabs/tabs.js CHANGED
@@ -1,23 +1,17 @@
1
1
  import * as React from 'react';
2
2
  import { TabsContext } from './tabs-context';
3
3
  export var Tabs = function (_a) {
4
- var baseId = _a.baseId, fullWidth = _a.fullWidth, onChange = _a.onChange, selectedValue = _a.value, isLazy = _a.isLazy, children = _a.children;
5
- var getTabPanelId = function (value) { return "".concat(baseId, "-tabpanel-").concat(value); };
6
- var getTabId = function (value) { return "".concat(baseId, "-tab-").concat(value); };
7
- var getTabProps = function (value) {
8
- return {
9
- id: getTabId(value),
10
- 'aria-controls': getTabPanelId(value),
11
- };
12
- };
13
- var getTabPanelProps = function (value) {
14
- return {
15
- role: 'tabpanel',
16
- hidden: selectedValue !== value,
17
- id: getTabPanelId(value),
18
- 'aria-labelledby': getTabId(value),
19
- };
20
- };
4
+ var baseId = _a.baseId, fullWidth = _a.fullWidth, onChange = _a.onChange, selectedValue = _a.value, _b = _a.isLazy, isLazy = _b === void 0 ? true : _b, children = _a.children;
5
+ var getTabProps = React.useCallback(function (value) { return ({
6
+ id: "".concat(baseId, "-tab-").concat(value),
7
+ 'aria-controls': "".concat(baseId, "-tabpanel-").concat(value),
8
+ }); }, [baseId]);
9
+ var getTabPanelProps = React.useCallback(function (value) { return ({
10
+ role: 'tabpanel',
11
+ hidden: selectedValue !== value,
12
+ id: "".concat(baseId, "-tabpanel-").concat(value),
13
+ 'aria-labelledby': "".concat(baseId, "-tab-").concat(value),
14
+ }); }, [baseId, selectedValue]);
21
15
  var ctxValue = React.useMemo(function () { return ({
22
16
  onChange: onChange,
23
17
  getTabProps: getTabProps,
@@ -25,8 +19,6 @@ export var Tabs = function (_a) {
25
19
  value: selectedValue,
26
20
  isLazy: isLazy,
27
21
  fullWidth: fullWidth,
28
- }); },
29
- // eslint-disable-next-line react-hooks/exhaustive-deps
30
- [selectedValue, baseId, onChange, isLazy, fullWidth]);
22
+ }); }, [selectedValue, onChange, isLazy, fullWidth, getTabProps, getTabPanelProps]);
31
23
  return React.createElement(TabsContext.Provider, { value: ctxValue }, children);
32
24
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auth0/quantum-product",
3
- "version": "2.10.8",
3
+ "version": "2.11.0",
4
4
  "sideEffects": false,
5
5
  "license": "Apache-2.0",
6
6
  "publishConfig": {
@@ -38,5 +38,10 @@
38
38
  "verify": "yarn tsc --noEmit",
39
39
  "test": "jest"
40
40
  },
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "git+https://github.com/auth0/quantum-product.git",
44
+ "directory": "packages/quantum-product"
45
+ },
41
46
  "module": "./esm/index.js"
42
47
  }
@@ -1,3 +1,3 @@
1
- import { TabProps, TabClassKey } from '@mui/material/Tab';
1
+ import { TabClassKey, TabProps } from '@mui/material/Tab';
2
2
  import type { ComponentOverrideCreator } from '../../theme/create-component-overrides';
3
3
  export declare const createMuiTabOverrides: ComponentOverrideCreator<TabProps, TabClassKey>;
@@ -18,10 +18,18 @@ var createMuiTabOverrides = function (_a) {
18
18
  ],
19
19
  styleOverrides: {
20
20
  root: (_b = {
21
- paddingLeft: spacing(0.5),
22
- paddingRight: spacing(0.5),
23
- margin: spacing(0, 1.5),
24
- minWidth: 'unset'
21
+ position: 'relative',
22
+ zIndex: 1,
23
+ padding: spacing(0.75),
24
+ marginRight: 0,
25
+ height: spacing(4),
26
+ minHeight: spacing(4),
27
+ minWidth: 'unset',
28
+ transition: 'background-color 0.25s cubic-bezier(0, 0, 0.2, 1)',
29
+ '@media (prefers-reduced-motion: reduce)': {
30
+ transition: 'none',
31
+ },
32
+ borderRadius: spacing(0.5)
25
33
  },
26
34
  _b[breakpoints.up('sm')] = {
27
35
  minWidth: 'unset',
@@ -31,17 +39,20 @@ var createMuiTabOverrides = function (_a) {
31
39
  },
32
40
  _b),
33
41
  textColorPrimary: (_c = {},
42
+ _c["&.".concat(Tab_1.tabClasses.disabled)] = {
43
+ color: tokens.color_fg_disabled,
44
+ },
34
45
  _c["&.".concat(Tab_1.tabClasses.selected)] = {
35
- color: tokens.color_fg_selected,
46
+ color: tokens.color_fg_bold,
36
47
  },
37
48
  _c['&:hover'] = {
38
- color: tokens.color_fg_selected,
49
+ color: tokens.color_fg_bold,
39
50
  },
40
51
  _c['&:focus-visible'] = {
41
52
  boxShadow: "0 0 0 2px ".concat(tokens.color_border_focus, " inset"),
42
53
  },
43
54
  _c.color = tokens.color_fg_link_subtle,
44
- _c.fontWeight = typography.fontWeightRegular,
55
+ _c.fontWeight = typography.fontWeightSemibold,
45
56
  _c),
46
57
  },
47
58
  };
@@ -0,0 +1,12 @@
1
+ import { IStyledOwnerStateProps } from '../../styled';
2
+ export declare const tabListComponentName = "QuantumTabList";
3
+ export declare const TabListContainer: import("styled-components").StyledComponent<"div", import("../..").ITheme, import("@mui/system").MUIStyledCommonProps<import("../..").ITheme>, never>;
4
+ export declare const OverflowButtonWrapper: import("styled-components").StyledComponent<"div", import("../..").ITheme, import("@mui/system").MUIStyledCommonProps<import("../..").ITheme>, never>;
5
+ export declare const OverflowLabelContainer: import("styled-components").StyledComponent<"span", import("../..").ITheme, import("@mui/system").MUIStyledCommonProps<import("../..").ITheme>, never>;
6
+ export declare const OverflowLabel: import("styled-components").StyledComponent<"span", import("../..").ITheme, import("@mui/system").MUIStyledCommonProps<import("../..").ITheme>, never>;
7
+ export interface ISelectionIndicatorOwnerState {
8
+ leftOffset: number;
9
+ indicatorWidth: number;
10
+ isVisible: boolean;
11
+ }
12
+ export declare const SelectionIndicator: import("styled-components").StyledComponent<"span", import("../..").ITheme, import("@mui/system").MUIStyledCommonProps<import("../..").ITheme> & IStyledOwnerStateProps<ISelectionIndicatorOwnerState>, never>;
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SelectionIndicator = exports.OverflowLabel = exports.OverflowLabelContainer = exports.OverflowButtonWrapper = exports.TabListContainer = exports.tabListComponentName = void 0;
4
+ var styled_1 = require("../../styled");
5
+ exports.tabListComponentName = 'QuantumTabList';
6
+ exports.TabListContainer = (0, styled_1.styled)('div', {
7
+ name: exports.tabListComponentName,
8
+ slot: 'Root',
9
+ })(function (_a) {
10
+ var theme = _a.theme;
11
+ return ({
12
+ display: 'flex',
13
+ alignItems: 'center',
14
+ position: 'relative',
15
+ isolation: 'isolate',
16
+ borderBottom: "1px solid ".concat(theme.tokens.color_border_default),
17
+ overflow: 'hidden',
18
+ });
19
+ });
20
+ exports.OverflowButtonWrapper = (0, styled_1.styled)('div', {
21
+ name: exports.tabListComponentName,
22
+ slot: 'OverflowButtonWrapper',
23
+ })(function (_a) {
24
+ var theme = _a.theme;
25
+ return ({
26
+ display: 'flex',
27
+ alignItems: 'center',
28
+ marginLeft: theme.spacing(0.5),
29
+ flexShrink: 0,
30
+ height: theme.spacing(3.5),
31
+ marginBottom: theme.spacing(1),
32
+ });
33
+ });
34
+ exports.OverflowLabelContainer = (0, styled_1.styled)('span', {
35
+ name: exports.tabListComponentName,
36
+ slot: 'OverflowLabelContainer',
37
+ })(function (_a) {
38
+ var theme = _a.theme;
39
+ return ({
40
+ position: 'relative',
41
+ display: 'inline-flex',
42
+ alignItems: 'center',
43
+ gap: theme.spacing(0.5),
44
+ });
45
+ });
46
+ exports.OverflowLabel = (0, styled_1.styled)('span', {
47
+ name: exports.tabListComponentName,
48
+ slot: 'OverflowLabel',
49
+ })(function (_a) {
50
+ var theme = _a.theme;
51
+ return ({
52
+ display: 'flex',
53
+ alignItems: 'center',
54
+ justifyContent: 'space-between',
55
+ gap: theme.spacing(1),
56
+ fontSize: theme.typography.pxToRem(14),
57
+ fontWeight: theme.typography.fontWeightSemibold,
58
+ color: theme.tokens.color_fg_default,
59
+ });
60
+ });
61
+ var TIMING_FUNCTION = 'cubic-bezier(0.19, 1, 0.22, 1)';
62
+ exports.SelectionIndicator = (0, styled_1.styled)('span', {
63
+ name: exports.tabListComponentName,
64
+ slot: 'SelectionIndicator',
65
+ shouldForwardProp: function (prop) { return !['ownerState'].includes(String(prop)); },
66
+ })(function (_a) {
67
+ var theme = _a.theme, _b = _a.ownerState, leftOffset = _b.leftOffset, indicatorWidth = _b.indicatorWidth, isVisible = _b.isVisible;
68
+ return ({
69
+ position: 'absolute',
70
+ top: 0,
71
+ bottom: theme.spacing(1),
72
+ left: 0,
73
+ width: indicatorWidth,
74
+ borderRadius: theme.spacing(0.5),
75
+ backgroundColor: theme.tokens.color_bg_layer_alternate_bold,
76
+ pointerEvents: 'none',
77
+ zIndex: 0,
78
+ opacity: isVisible ? 1 : 0,
79
+ transform: "translate3d(".concat(leftOffset, "px, 0, 0)"),
80
+ willChange: 'transform, width, opacity',
81
+ transition: "transform ".concat(theme.transitions.duration.short, "ms ").concat(TIMING_FUNCTION, ", width ").concat(theme.transitions.duration.short, "ms ").concat(TIMING_FUNCTION, ", opacity ").concat(theme.transitions.duration.short, "ms ").concat(TIMING_FUNCTION),
82
+ '@media (prefers-reduced-motion: reduce)': {
83
+ transition: 'none',
84
+ },
85
+ '&::before': {
86
+ content: '""',
87
+ position: 'absolute',
88
+ display: 'block',
89
+ bottom: theme.spacing(-1),
90
+ left: '50%',
91
+ transform: 'translateX(-50%)',
92
+ height: theme.spacing(0.25),
93
+ width: "calc(100% - ".concat(theme.spacing(2), ")"),
94
+ backgroundColor: theme.tokens.color_bg_brand_primary,
95
+ },
96
+ });
97
+ });
@@ -0,0 +1,32 @@
1
+ import * as React from 'react';
2
+ export type TabChildProps = {
3
+ component?: React.ElementType;
4
+ disabled?: boolean;
5
+ href?: string;
6
+ label?: React.ReactNode;
7
+ onClick?: (event: React.MouseEvent) => void;
8
+ value?: unknown;
9
+ analyticsId?: string;
10
+ [key: string]: unknown;
11
+ };
12
+ export type TabChild = React.ReactElement<TabChildProps>;
13
+ export interface IOverflowState {
14
+ overflowCompensation: number;
15
+ orderedTabValues?: unknown[];
16
+ baselineVisibleTabCount: number;
17
+ baselineMoreLabel: string;
18
+ baselineTabOrder: unknown[];
19
+ }
20
+ export declare const isTabChild: (child: React.ReactNode) => child is TabChild;
21
+ export declare const getResolvedChildValue: (child: TabChild, index: number) => unknown;
22
+ export declare const getChildOrderValue: (child: React.ReactNode, index: number) => unknown;
23
+ export declare const areValueArraysEqual: (left: unknown[], right: unknown[]) => boolean;
24
+ interface ICreateOverflowStateProps {
25
+ baseVisibleTabCount: number;
26
+ moreLabel: string;
27
+ defaultTabOrder: unknown[];
28
+ overflowCompensation?: number;
29
+ orderedTabValues?: unknown[];
30
+ }
31
+ export declare const createOverflowState: ({ baseVisibleTabCount, moreLabel, defaultTabOrder, overflowCompensation, orderedTabValues, }: ICreateOverflowStateProps) => IOverflowState;
32
+ export {};
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.createOverflowState = exports.areValueArraysEqual = exports.getChildOrderValue = exports.getResolvedChildValue = exports.isTabChild = void 0;
37
+ var React = __importStar(require("react"));
38
+ var isTabChild = function (child) { return React.isValidElement(child); };
39
+ exports.isTabChild = isTabChild;
40
+ var getResolvedChildValue = function (child, index) { var _a; return (_a = child.props.value) !== null && _a !== void 0 ? _a : index; };
41
+ exports.getResolvedChildValue = getResolvedChildValue;
42
+ var getChildOrderValue = function (child, index) {
43
+ var _a, _b;
44
+ if ((0, exports.isTabChild)(child)) {
45
+ return (_b = (_a = child.props.value) !== null && _a !== void 0 ? _a : child.key) !== null && _b !== void 0 ? _b : index;
46
+ }
47
+ return index;
48
+ };
49
+ exports.getChildOrderValue = getChildOrderValue;
50
+ // Tab selection uses identity equality for object values elsewhere in the tabs stack,
51
+ // so overflow ordering should follow the same semantics.
52
+ var areTabValuesEqual = function (left, right) { return left === right; };
53
+ var areValueArraysEqual = function (left, right) {
54
+ if (left.length !== right.length) {
55
+ return false;
56
+ }
57
+ return left.every(function (value, index) { return areTabValuesEqual(value, right[index]); });
58
+ };
59
+ exports.areValueArraysEqual = areValueArraysEqual;
60
+ var createOverflowState = function (_a) {
61
+ var baseVisibleTabCount = _a.baseVisibleTabCount, moreLabel = _a.moreLabel, defaultTabOrder = _a.defaultTabOrder, _b = _a.overflowCompensation, overflowCompensation = _b === void 0 ? 0 : _b, orderedTabValues = _a.orderedTabValues;
62
+ return ({
63
+ overflowCompensation: overflowCompensation,
64
+ orderedTabValues: orderedTabValues,
65
+ baselineVisibleTabCount: baseVisibleTabCount,
66
+ baselineMoreLabel: moreLabel,
67
+ baselineTabOrder: defaultTabOrder,
68
+ });
69
+ };
70
+ exports.createOverflowState = createOverflowState;
@@ -1,4 +1,11 @@
1
1
  import * as React from 'react';
2
2
  import { TabsProps } from '@mui/material/Tabs';
3
- export type ITabListProps = Omit<TabsProps, 'onChange' | 'value'>;
4
- export declare const TabList: React.FC<ITabListProps>;
3
+ export interface ITabListProps extends Omit<TabsProps, 'onChange' | 'value'> {
4
+ /** Maximum number of tabs to show before collapsing into an overflow menu. @default Infinity */
5
+ maxVisibleTabs?: number;
6
+ /** Label for the overflow menu trigger button. @default "More" */
7
+ moreLabel?: string;
8
+ /** Accessible label generator for the overflow menu trigger button count. */
9
+ getOverflowCountLabel?: (overflowCount: number) => string;
10
+ }
11
+ export declare const TabList: React.ForwardRefExoticComponent<Omit<ITabListProps, "ref"> & React.RefAttributes<HTMLDivElement>>;