@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
@@ -1,5 +1,5 @@
1
1
  export declare const switchComponentName: "QuantumSwitch";
2
2
  export declare function getSwitchUtilityClass(slot: string): string;
3
- export declare const switchClasses: Record<"switch" | "formControlLabel", string>;
3
+ export declare const switchClasses: Record<"switch" | "formControlLabel" | "pressing", string>;
4
4
  export type SwitchClasses = typeof switchClasses;
5
5
  export type SwitchClassKey = keyof SwitchClasses;
@@ -7,4 +7,4 @@ exports.switchComponentName = 'QuantumSwitch';
7
7
  function getSwitchUtilityClass(slot) {
8
8
  return (0, classes_1.generateUtilityClass)(exports.switchComponentName, slot);
9
9
  }
10
- exports.switchClasses = (0, classes_1.generateUtilityClasses)(exports.switchComponentName, ['switch', 'formControlLabel']);
10
+ exports.switchClasses = (0, classes_1.generateUtilityClasses)(exports.switchComponentName, ['switch', 'formControlLabel', 'pressing']);
@@ -13,83 +13,161 @@ var __assign = (this && this.__assign) || function () {
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.createMuiSwitchOverrides = void 0;
15
15
  var Switch_1 = require("@mui/material/Switch");
16
- var SWITCH_DIMENSIONS = {
17
- heightPx: 24,
18
- widthPx: 44,
19
- thumbSizePx: 16,
16
+ var switch_classes_1 = require("./switch-classes");
17
+ var SWITCH_DIMENSIONS_BY_SIZE = {
18
+ medium: {
19
+ heightPx: 24,
20
+ widthPx: 40,
21
+ thumbSizePx: 22,
22
+ thumbActiveWidthPx: 28,
23
+ thumbEndPositionPx: 16,
24
+ },
25
+ small: {
26
+ heightPx: 20,
27
+ widthPx: 32,
28
+ thumbSizePx: 18,
29
+ thumbActiveWidthPx: 26,
30
+ thumbEndPositionPx: 12,
31
+ },
32
+ };
33
+ var getSwitchSizeStyles = function (size, pxToRem) {
34
+ var _a, _b, _c;
35
+ var dimensions = SWITCH_DIMENSIONS_BY_SIZE[size];
36
+ var thumbActiveExtensionPx = dimensions.thumbActiveWidthPx - dimensions.thumbSizePx;
37
+ return _a = {
38
+ width: pxToRem(dimensions.widthPx),
39
+ height: pxToRem(dimensions.heightPx),
40
+ '&:active': (_b = {},
41
+ _b["& .".concat(Switch_1.switchClasses.switchBase, ":not(.").concat(Switch_1.switchClasses.checked, "):not(.").concat(Switch_1.switchClasses.disabled, ") .").concat(Switch_1.switchClasses.thumb, "::before")] = {
42
+ insetInlineEnd: pxToRem(-thumbActiveExtensionPx),
43
+ },
44
+ _b["& .".concat(Switch_1.switchClasses.switchBase, ".").concat(Switch_1.switchClasses.checked, ":not(.").concat(Switch_1.switchClasses.disabled, ") .").concat(Switch_1.switchClasses.thumb, "::before")] = {
45
+ insetInlineStart: pxToRem(-thumbActiveExtensionPx),
46
+ },
47
+ _b)
48
+ },
49
+ _a["&.".concat(switch_classes_1.switchClasses.pressing)] = (_c = {},
50
+ _c["& .".concat(Switch_1.switchClasses.switchBase, ":not(.").concat(Switch_1.switchClasses.checked, "):not(.").concat(Switch_1.switchClasses.disabled, ") .").concat(Switch_1.switchClasses.thumb, "::before")] = {
51
+ insetInlineEnd: pxToRem(-thumbActiveExtensionPx),
52
+ },
53
+ _c["& .".concat(Switch_1.switchClasses.switchBase, ".").concat(Switch_1.switchClasses.checked, ":not(.").concat(Switch_1.switchClasses.disabled, ") .").concat(Switch_1.switchClasses.thumb, "::before")] = {
54
+ insetInlineStart: pxToRem(-thumbActiveExtensionPx),
55
+ },
56
+ _c),
57
+ _a["& .".concat(Switch_1.switchClasses.track)] = {
58
+ borderRadius: pxToRem(dimensions.heightPx * 2),
59
+ },
60
+ _a["& .".concat(Switch_1.switchClasses.switchBase)] = {
61
+ padding: pxToRem((dimensions.heightPx - dimensions.thumbSizePx) / 2),
62
+ },
63
+ _a["& .".concat(Switch_1.switchClasses.switchBase, ".").concat(Switch_1.switchClasses.checked)] = {
64
+ transform: "translateX(".concat(pxToRem(dimensions.thumbEndPositionPx), ")"),
65
+ },
66
+ _a["& .".concat(Switch_1.switchClasses.thumb)] = {
67
+ height: pxToRem(dimensions.thumbSizePx),
68
+ width: pxToRem(dimensions.thumbSizePx),
69
+ borderRadius: pxToRem(dimensions.thumbSizePx),
70
+ },
71
+ _a["& .".concat(Switch_1.switchClasses.thumb, "::before")] = {
72
+ borderRadius: pxToRem(dimensions.thumbSizePx),
73
+ },
74
+ _a;
20
75
  };
21
76
  var createMuiSwitchOverrides = function (_a) {
22
- var _b, _c, _d, _e, _f, _g, _h;
23
- var typography = _a.typography, tokens = _a.tokens, mixins = _a.mixins;
77
+ var _b, _c, _d, _e, _f, _g, _h, _j;
78
+ var typography = _a.typography, tokens = _a.tokens, transitions = _a.transitions, mixins = _a.mixins;
24
79
  return {
25
80
  defaultProps: {
26
81
  color: 'primary',
27
82
  size: 'medium',
28
83
  },
29
84
  styleOverrides: {
30
- root: {
31
- width: typography.pxToRem(SWITCH_DIMENSIONS.widthPx),
32
- height: typography.pxToRem(SWITCH_DIMENSIONS.heightPx),
33
- padding: 0,
34
- overflow: 'visible',
35
- '&:focus-within,&.Mui-focused': (_b = {},
36
- _b["& .".concat(Switch_1.switchClasses.track)] = __assign({ outlineOffset: 2 }, mixins.focusRing()),
37
- _b),
38
- },
39
- colorPrimary: (_c = {
85
+ root: __assign(__assign({ padding: 0, overflow: 'visible' }, getSwitchSizeStyles('medium', typography.pxToRem)), (_b = {}, _b["& .".concat(Switch_1.switchClasses.switchBase, ".").concat(Switch_1.switchClasses.disabled)] = {
86
+ cursor: 'not-allowed',
87
+ }, _b["& .".concat(Switch_1.switchClasses.switchBase, ".").concat(Switch_1.switchClasses.disabled, " + .").concat(Switch_1.switchClasses.track)] = {
88
+ cursor: 'not-allowed',
89
+ }, _b['&:focus-within,&.Mui-focused'] = (_c = {},
90
+ _c["& .".concat(Switch_1.switchClasses.track)] = __assign({ outlineOffset: 2 }, mixins.focusRing()),
91
+ _c), _b)),
92
+ colorPrimary: (_d = {
40
93
  color: tokens.color_bg_layer
41
94
  },
42
- _c["&.".concat(Switch_1.switchClasses.checked)] = (_d = {
95
+ _d["&.".concat(Switch_1.switchClasses.checked)] = (_e = {
43
96
  color: tokens.color_bg_layer
44
97
  },
45
- _d["& + .".concat(Switch_1.switchClasses.track)] = {
98
+ _e["& + .".concat(Switch_1.switchClasses.track)] = {
46
99
  backgroundColor: tokens.color_bg_switch_on,
47
100
  },
48
- _d["&.".concat(Switch_1.switchClasses.disabled)] = (_e = {
101
+ _e["&.".concat(Switch_1.switchClasses.disabled)] = (_f = {
49
102
  color: tokens.color_bg_layer
50
103
  },
51
- _e["& + .".concat(Switch_1.switchClasses.track)] = {
104
+ _f["& + .".concat(Switch_1.switchClasses.track)] = {
52
105
  backgroundColor: tokens.color_bg_switch_on_disabled,
53
106
  },
54
- _e),
55
- _d),
56
- _c["&.".concat(Switch_1.switchClasses.disabled)] = (_f = {
107
+ _f),
108
+ _e),
109
+ _d["&.".concat(Switch_1.switchClasses.disabled)] = (_g = {
57
110
  color: tokens.color_bg_layer
58
111
  },
59
- _f["& + .".concat(Switch_1.switchClasses.track)] = {
112
+ _g["& + .".concat(Switch_1.switchClasses.track)] = {
60
113
  opacity: 1,
61
114
  backgroundColor: tokens.color_bg_disabled,
62
115
  },
63
- _f),
64
- _c),
116
+ _g),
117
+ _d),
65
118
  track: {
66
119
  opacity: 1,
67
- backgroundColor: tokens.color_bg_layer_bold,
68
- borderRadius: typography.pxToRem(SWITCH_DIMENSIONS.heightPx * 2),
120
+ backgroundColor: tokens.color_bg_layer_alternate_bold,
121
+ boxShadow: "".concat(mixins.borderAsBoxShadow(tokens.color_border_default), ", 0 1px 2px rgba(0, 0, 0, 0.08) inset"),
122
+ transition: transitions.create(['background-color', 'box-shadow'], {
123
+ duration: transitions.duration.shorter,
124
+ easing: transitions.easing.easeOut,
125
+ }),
69
126
  },
70
- switchBase: (_g = {
127
+ switchBase: (_h = {
71
128
  borderRadius: '50%',
72
- padding: typography.pxToRem((SWITCH_DIMENSIONS.heightPx - SWITCH_DIMENSIONS.thumbSizePx) / 2),
73
129
  height: 'unset',
74
- width: 'unset'
130
+ width: 'unset',
131
+ transition: transitions.create(['transform'], {
132
+ duration: transitions.duration.shorter,
133
+ easing: 'cubic-bezier(0, 0, 0.2, 1)',
134
+ })
75
135
  },
76
- _g["&.".concat(Switch_1.switchClasses.checked)] = (_h = {
77
- transform: "translateX(".concat(typography.pxToRem(SWITCH_DIMENSIONS.thumbSizePx + 4), ")")
78
- },
79
- _h["& + .".concat(Switch_1.switchClasses.track)] = {
136
+ _h["&.".concat(Switch_1.switchClasses.checked)] = (_j = {},
137
+ _j["& + .".concat(Switch_1.switchClasses.track)] = {
80
138
  opacity: 1,
139
+ boxShadow: "".concat(mixins.borderAsBoxShadow(tokens.color_fg_state_success), ", 0 1px 2px rgba(0, 0, 0, 0.08) inset"),
81
140
  },
82
- _h),
83
- _g["&.".concat(Switch_1.switchClasses.disabled, ",&:hover,&:active")] = {
141
+ _j),
142
+ _h["&.".concat(Switch_1.switchClasses.disabled, ",&:hover,&:active")] = {
84
143
  backgroundColor: 'transparent',
85
144
  },
86
- _g),
145
+ _h),
87
146
  thumb: {
88
- height: typography.pxToRem(SWITCH_DIMENSIONS.thumbSizePx),
89
- width: typography.pxToRem(SWITCH_DIMENSIONS.thumbSizePx),
90
- borderRadius: typography.pxToRem(SWITCH_DIMENSIONS.thumbSizePx),
147
+ position: 'relative',
148
+ display: 'block',
149
+ overflow: 'visible',
150
+ backgroundColor: 'transparent',
151
+ boxShadow: 'none',
152
+ '&::before': {
153
+ content: '""',
154
+ position: 'absolute',
155
+ inset: 0,
156
+ backgroundColor: 'currentColor',
157
+ boxShadow: '0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px -1px rgba(0, 0, 0, 0.04), 0 2px 4px -2px rgba(0, 0, 0, 0.04), 0 3px 6px -3px rgba(0, 0, 0, 0.04), 0 4px 8px -4px rgba(0, 0, 0, 0.04)',
158
+ transition: transitions.create(['inset-inline-start', 'inset-inline-end'], {
159
+ duration: transitions.duration.shorter,
160
+ easing: 'cubic-bezier(0, 0, 0.2, 1)',
161
+ }),
162
+ },
91
163
  },
92
164
  },
165
+ variants: [
166
+ {
167
+ props: { size: 'small' },
168
+ style: getSwitchSizeStyles('small', typography.pxToRem),
169
+ },
170
+ ],
93
171
  };
94
172
  };
95
173
  exports.createMuiSwitchOverrides = createMuiSwitchOverrides;
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import { IFormControlLabelProps, IFormHelperTextProps } from '../form';
3
3
  import { SwitchProps } from '@mui/material/Switch';
4
4
  import { SwitchClasses } from './switch-classes';
5
- export interface ISwitchProps extends Omit<SwitchProps, 'size' | 'color' | 'classes'>, Pick<IFormControlLabelProps, 'labelPlacement'> {
5
+ export interface ISwitchProps extends Omit<SwitchProps, 'color' | 'classes'>, Pick<IFormControlLabelProps, 'labelPlacement'> {
6
6
  children?: React.ReactNode;
7
7
  /** [checked, unchecked] */
8
8
  labels?: [string, string];
package/switch/switch.js CHANGED
@@ -54,6 +54,22 @@ var __rest = (this && this.__rest) || function (s, e) {
54
54
  }
55
55
  return t;
56
56
  };
57
+ var __read = (this && this.__read) || function (o, n) {
58
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
59
+ if (!m) return o;
60
+ var i = m.call(o), r, ar = [], e;
61
+ try {
62
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
63
+ }
64
+ catch (error) { e = { error: error }; }
65
+ finally {
66
+ try {
67
+ if (r && !r.done && (m = i["return"])) m.call(i);
68
+ }
69
+ finally { if (e) throw e.error; }
70
+ }
71
+ return ar;
72
+ };
57
73
  var __importDefault = (this && this.__importDefault) || function (mod) {
58
74
  return (mod && mod.__esModule) ? mod : { "default": mod };
59
75
  };
@@ -66,18 +82,45 @@ var styled_1 = require("../styled");
66
82
  var clsx_1 = __importDefault(require("../utils/clsx"));
67
83
  var switch_classes_1 = require("./switch-classes");
68
84
  var classes_1 = require("../styles/classes");
69
- var SwitchHeight = 24;
85
+ var SWITCH_HEIGHT_BY_SIZE = {
86
+ medium: 24,
87
+ small: 20,
88
+ };
70
89
  var SwitchLineHeight = 18;
90
+ var StatusLabel = (0, styled_1.styled)('span', {
91
+ name: switch_classes_1.switchComponentName,
92
+ slot: 'StatusLabel',
93
+ })(function () { return ({
94
+ display: 'inline-block',
95
+ '@keyframes fadeInFromLeft': {
96
+ '0%': {
97
+ opacity: 0,
98
+ filter: 'blur(4px)',
99
+ transform: 'translateX(-12px)',
100
+ },
101
+ '100%': {
102
+ opacity: 1,
103
+ filter: 'blur(0)',
104
+ transform: 'translateX(0)',
105
+ },
106
+ },
107
+ animation: "fadeInFromLeft 200ms cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards",
108
+ '@media (prefers-reduced-motion: reduce)': {
109
+ animation: 'none',
110
+ },
111
+ }); });
71
112
  var StyledFormControlLabel = (0, styled_1.styled)(form_1.FormControlLabel, {
72
113
  name: switch_classes_1.switchComponentName,
73
114
  slot: 'FormControlLabel',
115
+ shouldForwardProp: function (prop) { return (0, styled_1.rootShouldForwardProp)(prop) && prop !== 'switchSize' && prop !== 'switchDisabled'; },
74
116
  })(function (_a) {
75
117
  var _b, _c;
76
- var theme = _a.theme, noWrap = _a.noWrap, labelPlacement = _a.labelPlacement;
77
- return __assign((_b = { paddingLeft: 0, paddingTop: 0, paddingBottom: 0, marginLeft: 0 }, _b["& .".concat(form_1.formControlLabelClasses.container)] = {
78
- lineHeight: theme.typography.pxToRem(SwitchHeight),
118
+ var theme = _a.theme, noWrap = _a.noWrap, labelPlacement = _a.labelPlacement, switchSize = _a.switchSize, switchDisabled = _a.switchDisabled;
119
+ return __assign((_b = { paddingLeft: 0, paddingTop: 0, paddingBottom: 0, marginLeft: 0, cursor: switchDisabled ? 'not-allowed' : undefined }, _b["& .".concat(form_1.formControlLabelClasses.container)] = {
120
+ lineHeight: theme.typography.pxToRem(SWITCH_HEIGHT_BY_SIZE[switchSize]),
79
121
  minWidth: noWrap ? 0 : undefined, // prevents overflow of parent flex container
80
122
  marginLeft: theme.spacing(2),
123
+ cursor: switchDisabled ? 'not-allowed' : undefined,
81
124
  '& > *:first-of-type': {
82
125
  marginLeft: 0,
83
126
  },
@@ -89,12 +132,63 @@ var StyledFormControlLabel = (0, styled_1.styled)(form_1.FormControlLabel, {
89
132
  _c)));
90
133
  });
91
134
  exports.Switch = React.forwardRef(function (props, ref) {
92
- var children = props.children, noWrap = props.noWrap, labelPlacement = props.labelPlacement, labels = props.labels, checked = props.checked, disabled = props.disabled, readOnly = props.readOnly, defaultChecked = props.defaultChecked, className = props.className, onValueChange = props.onValueChange, onChange = props.onChange, helperText = props.helperText, _a = props.HelperTextProps, HelperTextProps = _a === void 0 ? {} : _a, decoration = props.decoration, propClasses = props.classes, switchProps = __rest(props, ["children", "noWrap", "labelPlacement", "labels", "checked", "disabled", "readOnly", "defaultChecked", "className", "onValueChange", "onChange", "helperText", "HelperTextProps", "decoration", "classes"]);
135
+ var _a;
136
+ var children = props.children, noWrap = props.noWrap, labelPlacement = props.labelPlacement, labels = props.labels, checked = props.checked, disabled = props.disabled, readOnly = props.readOnly, _b = props.size, size = _b === void 0 ? 'medium' : _b, defaultChecked = props.defaultChecked, className = props.className, onMouseDown = props.onMouseDown, onMouseUp = props.onMouseUp, onKeyDown = props.onKeyDown, onKeyUp = props.onKeyUp, onValueChange = props.onValueChange, onChange = props.onChange, helperText = props.helperText, _c = props.HelperTextProps, HelperTextProps = _c === void 0 ? {} : _c, decoration = props.decoration, propClasses = props.classes, switchProps = __rest(props, ["children", "noWrap", "labelPlacement", "labels", "checked", "disabled", "readOnly", "size", "defaultChecked", "className", "onMouseDown", "onMouseUp", "onKeyDown", "onKeyUp", "onValueChange", "onChange", "helperText", "HelperTextProps", "decoration", "classes"]);
93
137
  var classes = (0, classes_1.useMergedClasses)(switch_classes_1.switchClasses, switch_classes_1.getSwitchUtilityClass, propClasses);
94
- var valueLabel = labels && labels.length === 2 ? labels[checked || defaultChecked ? 0 : 1] : '';
95
- var label = children || valueLabel;
138
+ var isDisabled = readOnly || disabled;
139
+ var _d = __read(React.useState(false), 2), isPressing = _d[0], setIsPressing = _d[1];
140
+ var handleMouseDown = React.useCallback(function () {
141
+ if (!isDisabled) {
142
+ setIsPressing(true);
143
+ }
144
+ }, [isDisabled]);
145
+ var handleMouseUp = React.useCallback(function () { return setIsPressing(false); }, []);
146
+ var handleSwitchMouseDown = React.useCallback(function (event) {
147
+ onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(event);
148
+ if (!isDisabled) {
149
+ handleMouseDown();
150
+ }
151
+ }, [handleMouseDown, isDisabled, onMouseDown]);
152
+ var handleSwitchMouseUp = React.useCallback(function (event) {
153
+ onMouseUp === null || onMouseUp === void 0 ? void 0 : onMouseUp(event);
154
+ handleMouseUp();
155
+ }, [handleMouseUp, onMouseUp]);
156
+ var handleSwitchKeyDown = React.useCallback(function (event) {
157
+ onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
158
+ if (event.key === ' ' && !isDisabled) {
159
+ setIsPressing(true);
160
+ }
161
+ }, [isDisabled, onKeyDown]);
162
+ var handleSwitchKeyUp = React.useCallback(function (event) {
163
+ onKeyUp === null || onKeyUp === void 0 ? void 0 : onKeyUp(event);
164
+ if (event.key === ' ') {
165
+ setIsPressing(false);
166
+ }
167
+ }, [onKeyUp]);
168
+ React.useEffect(function () {
169
+ if (isPressing) {
170
+ var release_1 = function () { return setIsPressing(false); };
171
+ window.addEventListener('mouseup', release_1);
172
+ return function () { return window.removeEventListener('mouseup', release_1); };
173
+ }
174
+ return undefined;
175
+ }, [isPressing]);
176
+ React.useEffect(function () {
177
+ if (isDisabled && isPressing) {
178
+ setIsPressing(false);
179
+ }
180
+ }, [isDisabled, isPressing]);
181
+ var _e = __read(React.useState((_a = checked !== null && checked !== void 0 ? checked : defaultChecked) !== null && _a !== void 0 ? _a : false), 2), uncontrolledChecked = _e[0], setUncontrolledChecked = _e[1];
182
+ var isChecked = checked !== null && checked !== void 0 ? checked : uncontrolledChecked;
183
+ var hasStatusLabels = labels && labels.length === 2;
184
+ var valueLabel = hasStatusLabels ? labels[isChecked ? 0 : 1] : '';
185
+ var animatedValueLabel = hasStatusLabels ? React.createElement(StatusLabel, { key: valueLabel }, valueLabel) : '';
186
+ var label = children || animatedValueLabel;
96
187
  var hasLabelOrHelperText = !!helperText || !!label;
97
188
  var handleChange = function (event) {
189
+ if (checked === undefined) {
190
+ setUncontrolledChecked(event.target.checked);
191
+ }
98
192
  if (onChange) {
99
193
  onChange(event, event.target.checked);
100
194
  }
@@ -102,9 +196,9 @@ exports.Switch = React.forwardRef(function (props, ref) {
102
196
  onValueChange(event.target.checked);
103
197
  }
104
198
  };
105
- var switchButton = (React.createElement(Switch_1.default, __assign({ checked: checked, disabled: readOnly || disabled, defaultChecked: defaultChecked, className: !hasLabelOrHelperText ? className : classes.switch, onChange: onChange || onValueChange ? handleChange : undefined }, switchProps, { ref: ref })));
199
+ var switchButton = (React.createElement(Switch_1.default, __assign({ checked: checked, disabled: isDisabled, defaultChecked: defaultChecked, size: size, className: (0, clsx_1.default)(!hasLabelOrHelperText ? className : classes.switch, isPressing && classes.pressing), onMouseDown: handleSwitchMouseDown, onMouseUp: handleSwitchMouseUp, onKeyDown: handleSwitchKeyDown, onKeyUp: handleSwitchKeyUp, onChange: onChange || onValueChange || hasStatusLabels ? handleChange : undefined }, switchProps, { ref: ref })));
106
200
  if (hasLabelOrHelperText) {
107
- return (React.createElement(StyledFormControlLabel, { className: (0, clsx_1.default)(classes.formControlLabel, className), height: SwitchLineHeight, label: label, labelPlacement: labelPlacement, helperText: helperText, HelperTextProps: HelperTextProps, decoration: decoration, noWrap: noWrap, disabled: readOnly || disabled, control: switchButton, ref: ref }));
201
+ return (React.createElement(StyledFormControlLabel, { className: (0, clsx_1.default)(classes.formControlLabel, className, isPressing && classes.pressing), height: SwitchLineHeight, switchSize: size, switchDisabled: isDisabled, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, label: label, labelPlacement: labelPlacement, helperText: helperText, HelperTextProps: HelperTextProps, decoration: decoration, noWrap: noWrap, disabled: isDisabled, control: switchButton, ref: ref }));
108
202
  }
109
203
  return switchButton;
110
204
  });
@@ -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
  };
package/tabs/tab/tab.d.ts CHANGED
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import { OverridableComponent, OverrideProps } from '../../overridable-component';
3
3
  import { TabTypeMap } from '@mui/material/Tab';
4
4
  type ITabTypeMap<ExtraPropsType = {}, DefaultElementType extends React.ElementType = TabTypeMap['defaultComponent']> = TabTypeMap<ExtraPropsType & {
5
- productReleaseStage?: 'beta' | 'earlyAccess' | 'generalAvailability';
5
+ productReleaseStage?: 'developerPreview' | 'beta' | 'earlyAccess' | 'generalAvailability';
6
6
  analyticsId?: string;
7
7
  }, DefaultElementType>;
8
8
  export type ITabProps<D extends React.ElementType = ITabTypeMap['defaultComponent'], P = {}> = OverrideProps<ITabTypeMap<P, D>, D>;
@@ -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 {};