@auth0/quantum-product 2.10.8 → 2.12.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 (44) 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/label/label.js +6 -0
  6. package/esm/switch/switch-classes.js +1 -1
  7. package/esm/switch/switch-overrides.js +119 -41
  8. package/esm/switch/switch.js +104 -10
  9. package/esm/tabs/tab/tab-override.js +18 -7
  10. package/esm/tabs/tab-list/tab-list-overrides.js +94 -0
  11. package/esm/tabs/tab-list/tab-list-utils.js +29 -0
  12. package/esm/tabs/tab-list/tab-list.js +111 -10
  13. package/esm/tabs/tab-list/use-tab-list-indicator/index.js +189 -0
  14. package/esm/tabs/tab-list/use-tab-list-keyboard/index.js +56 -0
  15. package/esm/tabs/tab-list/use-tab-list-overflow/index.js +149 -0
  16. package/esm/tabs/tabs-overrides.js +6 -7
  17. package/esm/tabs/tabs.js +12 -20
  18. package/label/label.d.ts +2 -2
  19. package/label/label.js +6 -0
  20. package/package.json +6 -1
  21. package/page/page-header/page-header.d.ts +1 -1
  22. package/switch/switch-classes.d.ts +1 -1
  23. package/switch/switch-classes.js +1 -1
  24. package/switch/switch-overrides.js +119 -41
  25. package/switch/switch.d.ts +1 -1
  26. package/switch/switch.js +103 -9
  27. package/tabs/tab/tab-override.d.ts +1 -1
  28. package/tabs/tab/tab-override.js +18 -7
  29. package/tabs/tab/tab.d.ts +1 -1
  30. package/tabs/tab-list/tab-list-overrides.d.ts +12 -0
  31. package/tabs/tab-list/tab-list-overrides.js +97 -0
  32. package/tabs/tab-list/tab-list-utils.d.ts +32 -0
  33. package/tabs/tab-list/tab-list-utils.js +70 -0
  34. package/tabs/tab-list/tab-list.d.ts +9 -2
  35. package/tabs/tab-list/tab-list.js +111 -11
  36. package/tabs/tab-list/use-tab-list-indicator/index.d.ts +26 -0
  37. package/tabs/tab-list/use-tab-list-indicator/index.js +226 -0
  38. package/tabs/tab-list/use-tab-list-keyboard/index.d.ts +13 -0
  39. package/tabs/tab-list/use-tab-list-keyboard/index.js +93 -0
  40. package/tabs/tab-list/use-tab-list-overflow/index.d.ts +25 -0
  41. package/tabs/tab-list/use-tab-list-overflow/index.js +186 -0
  42. package/tabs/tabs-overrides.d.ts +1 -1
  43. package/tabs/tabs-overrides.js +6 -7
  44. package/tabs/tabs.js +12 -20
@@ -9,16 +9,117 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
12
23
  import * as React from 'react';
13
24
  import MuiTabs from '@mui/material/Tabs';
14
- import { useTabsContext } from '../tabs-context';
15
- export var TabList = function (props) {
16
- var _a = useTabsContext(), onChange = _a.onChange, value = _a.value;
17
- var handleChange = function (_evt, newValue) {
18
- // onChange could be optional in react-router applications
19
- if (onChange) {
20
- onChange(newValue);
21
- }
22
- };
23
- return (React.createElement(MuiTabs, __assign({}, props, { onChange: onChange ? handleChange : undefined, value: value }), props.children));
25
+ import { Label } from '../../label';
26
+ import { Button } from '../../button';
27
+ import { DropdownMenu } from '../../dropdown-menu/dropdown-menu';
28
+ import { DropdownMenuList } from '../../dropdown-menu/dropdown-menu-list';
29
+ import { DropdownMenuListItem } from '../../dropdown-menu/dropdown-menu-list-item';
30
+ import { useDropdownMenuState } from '../../dropdown-menu/dropdown-menu-state';
31
+ import { useId } from '../../utils/use-id';
32
+ import { ChevronDown } from '@auth0/quantum-icons';
33
+ import useForkRef from '@mui/utils/useForkRef';
34
+ import { OverflowButtonWrapper, OverflowLabel, OverflowLabelContainer, SelectionIndicator, TabListContainer, } from './tab-list-overrides';
35
+ import { isTabChild } from './tab-list-utils';
36
+ import { useTabListIndicator } from './use-tab-list-indicator/index';
37
+ import { useTabListKeyboard } from './use-tab-list-keyboard/index';
38
+ import { useTabListOverflow } from './use-tab-list-overflow/index';
39
+ var defaultGetOverflowCountLabel = function (overflowCount) {
40
+ return "".concat(overflowCount, " more tab").concat(overflowCount === 1 ? '' : 's');
24
41
  };
42
+ export var TabList = React.forwardRef(function (_a, ref) {
43
+ var _b;
44
+ var _c = _a.maxVisibleTabs, maxVisibleTabs = _c === void 0 ? Infinity : _c, _d = _a.moreLabel, moreLabel = _d === void 0 ? 'More' : _d, _e = _a.getOverflowCountLabel, getOverflowCountLabel = _e === void 0 ? defaultGetOverflowCountLabel : _e, props = __rest(_a, ["maxVisibleTabs", "moreLabel", "getOverflowCountLabel"]);
45
+ var overflowMenuId = useId();
46
+ var _f = useDropdownMenuState({ baseId: "tab-overflow-menu-".concat(overflowMenuId) }), triggerProps = _f.triggerProps, menuProps = _f.menuProps;
47
+ var containerRef = React.useRef(null);
48
+ var handleRef = useForkRef(ref, containerRef);
49
+ var overflowRef = React.useRef(null);
50
+ var overflowButtonRef = React.useRef(null);
51
+ var _g = useTabListOverflow({
52
+ children: props.children,
53
+ maxVisibleTabs: maxVisibleTabs,
54
+ moreLabel: moreLabel,
55
+ getOverflowCountLabel: getOverflowCountLabel,
56
+ }), value = _g.value, onChange = _g.onChange, baseVisibleTabCount = _g.baseVisibleTabCount, minimumVisibleTabCount = _g.minimumVisibleTabCount, defaultTabOrder = _g.defaultTabOrder, visibleChildren = _g.visibleChildren, overflowChildren = _g.overflowChildren, hasOverflow = _g.hasOverflow, overflowCountLabel = _g.overflowCountLabel, isSelectedValueVisible = _g.isSelectedValueVisible, isSelectedValueInOverflow = _g.isSelectedValueInOverflow, handleChange = _g.handleChange, setOverflowState = _g.setOverflowState, promoteTabValue = _g.promoteTabValue;
57
+ var _h = useTabListKeyboard({
58
+ containerRef: containerRef,
59
+ overflowButtonRef: overflowButtonRef,
60
+ hasOverflow: hasOverflow,
61
+ menuId: menuProps.id,
62
+ menuOpen: menuProps.open,
63
+ }), handleTabsKeyDown = _h.handleTabsKeyDown, handleOverflowKeyDown = _h.handleOverflowKeyDown;
64
+ var indicatorState = useTabListIndicator({
65
+ containerRef: containerRef,
66
+ overflowRef: overflowRef,
67
+ overflowButtonRef: overflowButtonRef,
68
+ baseVisibleTabCount: baseVisibleTabCount,
69
+ minimumVisibleTabCount: minimumVisibleTabCount,
70
+ moreLabel: moreLabel,
71
+ defaultTabOrder: defaultTabOrder,
72
+ hasOverflow: hasOverflow,
73
+ visibleChildren: visibleChildren,
74
+ overflowChildrenLength: overflowChildren.length,
75
+ isSelectedValueInOverflow: isSelectedValueInOverflow,
76
+ value: value,
77
+ setOverflowState: setOverflowState,
78
+ }).indicatorState;
79
+ return (React.createElement(TabListContainer, { ref: handleRef },
80
+ React.createElement(SelectionIndicator, { className: (_b = props.classes) === null || _b === void 0 ? void 0 : _b.indicator, ownerState: {
81
+ leftOffset: indicatorState.leftOffset,
82
+ indicatorWidth: indicatorState.indicatorWidth,
83
+ isVisible: indicatorState.isVisible,
84
+ } }),
85
+ React.createElement(MuiTabs, __assign({}, props, { TabIndicatorProps: { style: { display: 'none' } }, onChange: onChange ? handleChange : undefined, onKeyDown: handleTabsKeyDown, value: isSelectedValueVisible ? value : false }), visibleChildren),
86
+ hasOverflow && (React.createElement(OverflowButtonWrapper, { ref: overflowRef },
87
+ React.createElement(Button, __assign({}, triggerProps, { ref: overflowButtonRef, "aria-controls": menuProps.open ? triggerProps['aria-controls'] : undefined, "aria-label": overflowCountLabel, "data-selected": isSelectedValueInOverflow ? 'true' : undefined, onKeyDown: handleOverflowKeyDown, label: React.createElement(OverflowLabelContainer, null,
88
+ React.createElement(OverflowLabel, null,
89
+ moreLabel,
90
+ React.createElement(Label, { color: "default" }, overflowChildren.length)),
91
+ React.createElement(ChevronDown, { size: 16, color: "currentColor" })), size: "small", variant: "link", sx: function (theme) { return ({
92
+ padding: theme.spacing(0.65, 1),
93
+ transition: 'none',
94
+ '&:hover': { background: 'transparent' },
95
+ '&:hover *': {
96
+ color: theme.tokens.color_fg_bold,
97
+ },
98
+ '&:focus': { outline: 'none' },
99
+ '&:focus-visible': {
100
+ boxShadow: "0 0 0 2px ".concat(theme.tokens.color_border_focus, " inset"),
101
+ transition: 'none',
102
+ },
103
+ }); } })),
104
+ React.createElement(DropdownMenu, __assign({}, menuProps),
105
+ React.createElement(DropdownMenuList, null, overflowChildren.map(function (child) {
106
+ if (!isTabChild(child))
107
+ return null;
108
+ var _a = child.props, label = _a.label, tabValue = _a.value, disabled = _a.disabled, tabOnClick = _a.onClick, _icon = _a.icon, _iconPosition = _a.iconPosition, _labelIcon = _a.labelIcon, _productReleaseStage = _a.productReleaseStage, _sx = _a.sx, _textColor = _a.textColor, _wrapped = _a.wrapped, overflowItemProps = __rest(_a, ["label", "value", "disabled", "onClick", "icon", "iconPosition", "labelIcon", "productReleaseStage", "sx", "textColor", "wrapped"]);
109
+ var isSelected = tabValue === value;
110
+ return (React.createElement(DropdownMenuListItem, __assign({ key: String(tabValue), title: label, selected: isSelected, disabled: disabled }, overflowItemProps, { onClick: function (event) {
111
+ if (disabled)
112
+ return;
113
+ if (tabOnClick) {
114
+ tabOnClick(event);
115
+ }
116
+ promoteTabValue(tabValue);
117
+ if (onChange) {
118
+ onChange(tabValue);
119
+ }
120
+ if (menuProps.onClose) {
121
+ menuProps.onClose({}, 'itemSelect');
122
+ }
123
+ } })));
124
+ })))))));
125
+ });
@@ -0,0 +1,189 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __read = (this && this.__read) || function (o, n) {
13
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
14
+ if (!m) return o;
15
+ var i = m.call(o), r, ar = [], e;
16
+ try {
17
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
18
+ }
19
+ catch (error) { e = { error: error }; }
20
+ finally {
21
+ try {
22
+ if (r && !r.done && (m = i["return"])) m.call(i);
23
+ }
24
+ finally { if (e) throw e.error; }
25
+ }
26
+ return ar;
27
+ };
28
+ import * as React from 'react';
29
+ import { createOverflowState } from '../tab-list-utils';
30
+ var RESIZE_SETTLE_DELAY = 120;
31
+ var HIDDEN_INDICATOR_STATE = { leftOffset: 0, indicatorWidth: 0, isVisible: false };
32
+ var getHiddenIndicatorState = function (currentValue) {
33
+ if (currentValue.isVisible === HIDDEN_INDICATOR_STATE.isVisible &&
34
+ currentValue.leftOffset === HIDDEN_INDICATOR_STATE.leftOffset &&
35
+ currentValue.indicatorWidth === HIDDEN_INDICATOR_STATE.indicatorWidth) {
36
+ return currentValue;
37
+ }
38
+ return HIDDEN_INDICATOR_STATE;
39
+ };
40
+ export var useTabListIndicator = function (_a) {
41
+ var containerRef = _a.containerRef, overflowRef = _a.overflowRef, overflowButtonRef = _a.overflowButtonRef, baseVisibleTabCount = _a.baseVisibleTabCount, minimumVisibleTabCount = _a.minimumVisibleTabCount, moreLabel = _a.moreLabel, defaultTabOrder = _a.defaultTabOrder, hasOverflow = _a.hasOverflow, visibleChildren = _a.visibleChildren, overflowChildrenLength = _a.overflowChildrenLength, isSelectedValueInOverflow = _a.isSelectedValueInOverflow, value = _a.value, setOverflowState = _a.setOverflowState;
42
+ var _b = __read(React.useState(0), 2), measurementVersion = _b[0], setMeasurementVersion = _b[1];
43
+ var _c = __read(React.useState(HIDDEN_INDICATOR_STATE), 2), indicatorState = _c[0], setIndicatorState = _c[1];
44
+ var resizeResetTimeoutRef = React.useRef();
45
+ var previousContainerWidthRef = React.useRef(null);
46
+ var clearResizeResetTimeout = React.useCallback(function () {
47
+ if (resizeResetTimeoutRef.current === undefined) {
48
+ return;
49
+ }
50
+ window.clearTimeout(resizeResetTimeoutRef.current);
51
+ resizeResetTimeoutRef.current = undefined;
52
+ }, []);
53
+ React.useLayoutEffect(function () {
54
+ if (!hasOverflow || !containerRef.current || !overflowRef.current) {
55
+ return;
56
+ }
57
+ var visibleTabs = containerRef.current.querySelectorAll('[role="tab"]');
58
+ var firstVisibleTab = visibleTabs[0];
59
+ var lastVisibleTab = visibleTabs[visibleTabs.length - 1];
60
+ if (!firstVisibleTab || !lastVisibleTab) {
61
+ return;
62
+ }
63
+ var containerRect = containerRef.current.getBoundingClientRect();
64
+ var firstVisibleTabRect = firstVisibleTab.getBoundingClientRect();
65
+ var lastVisibleTabRect = lastVisibleTab.getBoundingClientRect();
66
+ var overflowRect = overflowRef.current.getBoundingClientRect();
67
+ if (containerRect.width === 0 ||
68
+ firstVisibleTabRect.width === 0 ||
69
+ lastVisibleTabRect.width === 0 ||
70
+ overflowRect.width === 0) {
71
+ return;
72
+ }
73
+ var isClippedAtStart = firstVisibleTabRect.left < containerRect.left;
74
+ var overlapsOverflowTrigger = lastVisibleTabRect.right >= overflowRect.left;
75
+ if (isClippedAtStart || overlapsOverflowTrigger) {
76
+ setOverflowState(function (currentValue) {
77
+ var nextOverflowCompensation = Math.min(currentValue.overflowCompensation + 1, baseVisibleTabCount - minimumVisibleTabCount);
78
+ if (nextOverflowCompensation === currentValue.overflowCompensation) {
79
+ return currentValue;
80
+ }
81
+ return __assign(__assign({}, currentValue), { overflowCompensation: nextOverflowCompensation, baselineVisibleTabCount: baseVisibleTabCount, baselineMoreLabel: moreLabel, baselineTabOrder: defaultTabOrder });
82
+ });
83
+ }
84
+ }, [
85
+ baseVisibleTabCount,
86
+ containerRef,
87
+ defaultTabOrder,
88
+ measurementVersion,
89
+ minimumVisibleTabCount,
90
+ moreLabel,
91
+ hasOverflow,
92
+ overflowChildrenLength,
93
+ overflowRef,
94
+ setOverflowState,
95
+ visibleChildren,
96
+ ]);
97
+ React.useLayoutEffect(function () {
98
+ if (!containerRef.current) {
99
+ setIndicatorState(getHiddenIndicatorState);
100
+ return;
101
+ }
102
+ var selectedVisibleTab = containerRef.current.querySelector('[role="tab"][aria-selected="true"]');
103
+ var indicatorTarget = selectedVisibleTab || (isSelectedValueInOverflow ? overflowButtonRef.current : null);
104
+ if (!indicatorTarget) {
105
+ setIndicatorState(getHiddenIndicatorState);
106
+ return;
107
+ }
108
+ var containerRect = containerRef.current.getBoundingClientRect();
109
+ var targetRect = indicatorTarget.getBoundingClientRect();
110
+ if (containerRect.width === 0 || targetRect.width === 0) {
111
+ setIndicatorState(getHiddenIndicatorState);
112
+ return;
113
+ }
114
+ var nextIndicatorState = {
115
+ leftOffset: targetRect.left - containerRect.left,
116
+ indicatorWidth: targetRect.width,
117
+ isVisible: true,
118
+ };
119
+ setIndicatorState(function (currentValue) {
120
+ if (currentValue.isVisible === nextIndicatorState.isVisible &&
121
+ currentValue.leftOffset === nextIndicatorState.leftOffset &&
122
+ currentValue.indicatorWidth === nextIndicatorState.indicatorWidth) {
123
+ return currentValue;
124
+ }
125
+ return nextIndicatorState;
126
+ });
127
+ }, [
128
+ containerRef,
129
+ isSelectedValueInOverflow,
130
+ measurementVersion,
131
+ overflowButtonRef,
132
+ overflowChildrenLength,
133
+ value,
134
+ visibleChildren,
135
+ ]);
136
+ React.useLayoutEffect(function () {
137
+ if (!containerRef.current || typeof ResizeObserver === 'undefined') {
138
+ return;
139
+ }
140
+ previousContainerWidthRef.current = containerRef.current.getBoundingClientRect().width;
141
+ var observer = new ResizeObserver(function () {
142
+ var _a, _b;
143
+ var nextContainerWidth = (_b = (_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width) !== null && _b !== void 0 ? _b : 0;
144
+ var previousContainerWidth = previousContainerWidthRef.current;
145
+ var isExpanding = previousContainerWidth !== null && nextContainerWidth > previousContainerWidth;
146
+ previousContainerWidthRef.current = nextContainerWidth;
147
+ if (isExpanding) {
148
+ clearResizeResetTimeout();
149
+ resizeResetTimeoutRef.current = window.setTimeout(function () {
150
+ setOverflowState(function (currentValue) {
151
+ if (currentValue.overflowCompensation === 0) {
152
+ return currentValue;
153
+ }
154
+ return createOverflowState({
155
+ baseVisibleTabCount: baseVisibleTabCount,
156
+ moreLabel: moreLabel,
157
+ defaultTabOrder: defaultTabOrder,
158
+ overflowCompensation: 0,
159
+ orderedTabValues: currentValue.orderedTabValues,
160
+ });
161
+ });
162
+ setMeasurementVersion(function (currentValue) { return currentValue + 1; });
163
+ resizeResetTimeoutRef.current = undefined;
164
+ }, RESIZE_SETTLE_DELAY);
165
+ }
166
+ else {
167
+ clearResizeResetTimeout();
168
+ }
169
+ setMeasurementVersion(function (currentValue) { return currentValue + 1; });
170
+ });
171
+ observer.observe(containerRef.current);
172
+ if (overflowRef.current) {
173
+ observer.observe(overflowRef.current);
174
+ }
175
+ return function () {
176
+ clearResizeResetTimeout();
177
+ observer.disconnect();
178
+ };
179
+ }, [
180
+ baseVisibleTabCount,
181
+ clearResizeResetTimeout,
182
+ containerRef,
183
+ defaultTabOrder,
184
+ moreLabel,
185
+ overflowRef,
186
+ setOverflowState,
187
+ ]);
188
+ return { indicatorState: indicatorState };
189
+ };
@@ -0,0 +1,56 @@
1
+ import * as React from 'react';
2
+ export var useTabListKeyboard = function (_a) {
3
+ var containerRef = _a.containerRef, overflowButtonRef = _a.overflowButtonRef, hasOverflow = _a.hasOverflow, menuId = _a.menuId, menuOpen = _a.menuOpen;
4
+ var shouldFocusOverflowMenuRef = React.useRef(false);
5
+ var focusLastVisibleTab = React.useCallback(function () {
6
+ var _a;
7
+ var visibleTabs = (_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll('[role="tab"]');
8
+ var lastVisibleTab = visibleTabs === null || visibleTabs === void 0 ? void 0 : visibleTabs[visibleTabs.length - 1];
9
+ lastVisibleTab === null || lastVisibleTab === void 0 ? void 0 : lastVisibleTab.focus();
10
+ }, [containerRef]);
11
+ var handleTabsKeyDown = React.useCallback(function (event) {
12
+ var _a;
13
+ if (!hasOverflow || !overflowButtonRef.current || event.key !== 'ArrowRight') {
14
+ return;
15
+ }
16
+ var visibleTabs = (_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll('[role="tab"]');
17
+ var lastVisibleTab = visibleTabs === null || visibleTabs === void 0 ? void 0 : visibleTabs[visibleTabs.length - 1];
18
+ if (lastVisibleTab && event.target === lastVisibleTab) {
19
+ event.preventDefault();
20
+ overflowButtonRef.current.focus();
21
+ }
22
+ }, [containerRef, hasOverflow, overflowButtonRef]);
23
+ var handleOverflowKeyDown = React.useCallback(function (event) {
24
+ if ((event.key === 'Enter' || event.key === ' ' || event.key === 'Spacebar') && !menuOpen) {
25
+ shouldFocusOverflowMenuRef.current = true;
26
+ }
27
+ if (event.key !== 'ArrowLeft') {
28
+ return;
29
+ }
30
+ event.preventDefault();
31
+ focusLastVisibleTab();
32
+ }, [focusLastVisibleTab, menuOpen]);
33
+ React.useEffect(function () {
34
+ if (!menuOpen || !shouldFocusOverflowMenuRef.current) {
35
+ return;
36
+ }
37
+ var focusOverflowMenuItem = function () {
38
+ var overflowMenu = document.getElementById(menuId !== null && menuId !== void 0 ? menuId : '');
39
+ if (!overflowMenu) {
40
+ return;
41
+ }
42
+ var nextFocusedItem = overflowMenu.querySelector('[role="menuitem"][aria-selected="true"]:not([aria-disabled="true"])') || overflowMenu.querySelector('[role="menuitem"]:not([aria-disabled="true"])');
43
+ if (!nextFocusedItem) {
44
+ return;
45
+ }
46
+ nextFocusedItem.focus();
47
+ shouldFocusOverflowMenuRef.current = false;
48
+ };
49
+ var frameId = window.requestAnimationFrame(focusOverflowMenuItem);
50
+ return function () { return window.cancelAnimationFrame(frameId); };
51
+ }, [menuId, menuOpen]);
52
+ return {
53
+ handleTabsKeyDown: handleTabsKeyDown,
54
+ handleOverflowKeyDown: handleOverflowKeyDown,
55
+ };
56
+ };
@@ -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/label/label.d.ts CHANGED
@@ -7,9 +7,9 @@ export interface ILabelComponentProps {
7
7
  /**
8
8
  * Availability of the feature. Displays as a label after the title.
9
9
  */
10
- productReleaseStage?: 'beta' | 'earlyAccess' | 'generalAvailability' | 'deprecated';
10
+ productReleaseStage?: 'developerPreview' | 'beta' | 'earlyAccess' | 'generalAvailability' | 'deprecated';
11
11
  /**
12
- * If true will abbreviate the "Early Access" label to "Early"
12
+ * If true will abbreviate the "Early Access" label to "Early" and the "Developer Preview" label to "Preview"
13
13
  * @default true
14
14
  */
15
15
  productReleaseStageAbbr?: boolean;
package/label/label.js CHANGED
@@ -71,6 +71,12 @@ var getReleaseStageLabelProps = function (productReleaseStage, productReleaseSta
71
71
  labelProps.children = productReleaseStageLabel !== null && productReleaseStageLabel !== void 0 ? productReleaseStageLabel : 'New';
72
72
  labelProps.color = 'primary';
73
73
  break;
74
+ case 'developerPreview':
75
+ labelProps.color = 'primary';
76
+ productReleaseStageAbbr
77
+ ? (labelProps.children = productReleaseStageLabel !== null && productReleaseStageLabel !== void 0 ? productReleaseStageLabel : 'Preview')
78
+ : (labelProps.children = productReleaseStageLabel !== null && productReleaseStageLabel !== void 0 ? productReleaseStageLabel : 'Developer Preview');
79
+ break;
74
80
  case 'beta':
75
81
  labelProps.children = productReleaseStageLabel !== null && productReleaseStageLabel !== void 0 ? productReleaseStageLabel : 'Beta';
76
82
  labelProps.color = 'primary';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auth0/quantum-product",
3
- "version": "2.10.8",
3
+ "version": "2.12.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
  }
@@ -22,6 +22,6 @@ export interface IPageHeaderProps extends Omit<IRowLayoutProps, 'title'>, Pick<I
22
22
  fullWidth?: boolean;
23
23
  compact?: boolean;
24
24
  startActions?: React.ReactNode;
25
- productReleaseStage?: 'beta' | 'generalAvailability' | 'earlyAccess' | 'deprecated';
25
+ productReleaseStage?: 'developerPreview' | 'beta' | 'generalAvailability' | 'earlyAccess' | 'deprecated';
26
26
  }
27
27
  export declare const PageHeader: React.ForwardRefExoticComponent<IPageHeaderProps & React.RefAttributes<HTMLDivElement>>;