@mui/material 9.0.0-alpha.2 → 9.0.0-alpha.3
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/Autocomplete/Autocomplete.d.mts +16 -0
- package/Autocomplete/Autocomplete.d.ts +16 -0
- package/Autocomplete/Autocomplete.js +48 -25
- package/Autocomplete/Autocomplete.mjs +48 -25
- package/Box/Box.d.mts +1 -0
- package/Box/Box.d.ts +1 -0
- package/Button/Button.d.mts +1 -0
- package/Button/Button.d.ts +1 -0
- package/CHANGELOG.md +37 -0
- package/CardHeader/CardHeader.js +5 -1
- package/CardHeader/CardHeader.mjs +5 -1
- package/Divider/Divider.d.mts +1 -0
- package/Divider/Divider.d.ts +1 -0
- package/List/List.d.mts +1 -0
- package/List/List.d.ts +1 -0
- package/ListItemButton/ListItemButton.d.mts +1 -0
- package/ListItemButton/ListItemButton.d.ts +1 -0
- package/ListItemIcon/ListItemIcon.d.mts +1 -0
- package/ListItemIcon/ListItemIcon.d.ts +1 -0
- package/ListItemText/ListItemText.d.mts +1 -0
- package/ListItemText/ListItemText.d.ts +1 -0
- package/ListItemText/ListItemText.js +5 -1
- package/ListItemText/ListItemText.mjs +5 -1
- package/ListSubheader/ListSubheader.d.mts +1 -0
- package/ListSubheader/ListSubheader.d.ts +1 -0
- package/MenuList/MenuList.js +76 -106
- package/MenuList/MenuList.mjs +76 -106
- package/Paper/Paper.d.mts +1 -0
- package/Paper/Paper.d.ts +1 -0
- package/Step/Step.js +7 -5
- package/Step/Step.mjs +7 -5
- package/StepButton/StepButton.js +16 -6
- package/StepButton/StepButton.mjs +16 -6
- package/StepConnector/StepConnector.js +2 -2
- package/StepConnector/StepConnector.mjs +2 -2
- package/StepContent/StepContent.js +2 -2
- package/StepContent/StepContent.mjs +2 -2
- package/StepLabel/StepLabel.js +2 -2
- package/StepLabel/StepLabel.mjs +2 -2
- package/Stepper/Stepper.js +44 -7
- package/Stepper/Stepper.mjs +44 -7
- package/Stepper/StepperContext.d.mts +7 -0
- package/Stepper/StepperContext.d.ts +7 -0
- package/Stepper/StepperContext.js +2 -1
- package/Stepper/StepperContext.mjs +1 -0
- package/Stepper/index.d.mts +0 -1
- package/Stepper/index.d.ts +0 -1
- package/Tab/Tab.js +0 -1
- package/Tab/Tab.mjs +0 -1
- package/Tabs/Tabs.js +46 -97
- package/Tabs/Tabs.mjs +46 -97
- package/Typography/Typography.d.mts +1 -0
- package/Typography/Typography.d.ts +1 -0
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/package.json +236 -222
- package/themeCssVarsAugmentation/index.js +5 -0
- package/themeCssVarsAugmentation/index.mjs +5 -0
- package/useAutocomplete/useAutocomplete.js +24 -0
- package/useAutocomplete/useAutocomplete.mjs +24 -0
- package/utils/index.d.mts +2 -0
- package/utils/index.d.ts +2 -0
- package/utils/index.js +14 -0
- package/utils/index.mjs +2 -0
- package/utils/useRovingTabIndex.d.mts +2 -0
- package/utils/useRovingTabIndex.d.ts +2 -0
- package/utils/useRovingTabIndex.js +9 -0
- package/utils/useRovingTabIndex.mjs +2 -0
- package/version/index.js +2 -2
- package/version/index.mjs +2 -2
package/Tabs/Tabs.mjs
CHANGED
|
@@ -17,53 +17,11 @@ import ScrollbarSize from "./ScrollbarSize.mjs";
|
|
|
17
17
|
import TabScrollButton from "../TabScrollButton/index.mjs";
|
|
18
18
|
import useEventCallback from "../utils/useEventCallback.mjs";
|
|
19
19
|
import tabsClasses, { getTabsUtilityClass } from "./tabsClasses.mjs";
|
|
20
|
-
import ownerDocument from "../utils/ownerDocument.mjs";
|
|
21
20
|
import ownerWindow from "../utils/ownerWindow.mjs";
|
|
22
|
-
import getActiveElement from "../utils/getActiveElement.mjs";
|
|
23
21
|
import isLayoutSupported from "../utils/isLayoutSupported.mjs";
|
|
24
22
|
import useSlot from "../utils/useSlot.mjs";
|
|
23
|
+
import { ownerDocument, useForkRef, getActiveElement, useRovingTabIndex } from "../utils/index.mjs";
|
|
25
24
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
26
|
-
const nextItem = (list, item) => {
|
|
27
|
-
if (list === item) {
|
|
28
|
-
return list.firstChild;
|
|
29
|
-
}
|
|
30
|
-
if (item && item.nextElementSibling) {
|
|
31
|
-
return item.nextElementSibling;
|
|
32
|
-
}
|
|
33
|
-
return list.firstChild;
|
|
34
|
-
};
|
|
35
|
-
const previousItem = (list, item) => {
|
|
36
|
-
if (list === item) {
|
|
37
|
-
return list.lastChild;
|
|
38
|
-
}
|
|
39
|
-
if (item && item.previousElementSibling) {
|
|
40
|
-
return item.previousElementSibling;
|
|
41
|
-
}
|
|
42
|
-
return list.lastChild;
|
|
43
|
-
};
|
|
44
|
-
const moveFocus = (list, currentFocus, traversalFunction) => {
|
|
45
|
-
let wrappedOnce = false;
|
|
46
|
-
let nextFocus = traversalFunction(list, currentFocus);
|
|
47
|
-
while (nextFocus) {
|
|
48
|
-
// Prevent infinite loop.
|
|
49
|
-
if (nextFocus === list.firstChild) {
|
|
50
|
-
if (wrappedOnce) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
wrappedOnce = true;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Same logic as useAutocomplete.js
|
|
57
|
-
const nextFocusDisabled = nextFocus.disabled || nextFocus.getAttribute('aria-disabled') === 'true';
|
|
58
|
-
if (!nextFocus.hasAttribute('tabindex') || nextFocusDisabled) {
|
|
59
|
-
// Move to the next element.
|
|
60
|
-
nextFocus = traversalFunction(list, nextFocus);
|
|
61
|
-
} else {
|
|
62
|
-
nextFocus.focus();
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
25
|
const useUtilityClasses = ownerState => {
|
|
68
26
|
const {
|
|
69
27
|
vertical,
|
|
@@ -666,20 +624,37 @@ const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(inProps, ref) {
|
|
|
666
624
|
const indicator = /*#__PURE__*/_jsx(IndicatorSlot, {
|
|
667
625
|
...indicatorSlotProps
|
|
668
626
|
});
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
if (! /*#__PURE__*/React.isValidElement(child)) {
|
|
672
|
-
return null;
|
|
673
|
-
}
|
|
627
|
+
const validChildren = React.Children.toArray(childrenProp).filter(React.isValidElement).map((child, index) => {
|
|
628
|
+
const childValue = child.props.value === undefined ? index : child.props.value;
|
|
674
629
|
if (process.env.NODE_ENV !== 'production') {
|
|
675
630
|
if (isFragment(child)) {
|
|
676
631
|
console.error(["MUI: The Tabs component doesn't accept a Fragment as a child.", 'Consider providing an array instead.'].join('\n'));
|
|
677
632
|
}
|
|
678
633
|
}
|
|
679
|
-
|
|
680
|
-
|
|
634
|
+
valueToIndex.set(childValue, index);
|
|
635
|
+
return {
|
|
636
|
+
child,
|
|
637
|
+
index,
|
|
638
|
+
childValue
|
|
639
|
+
};
|
|
640
|
+
});
|
|
641
|
+
const focusableIndex = valueToIndex.get(value);
|
|
642
|
+
const {
|
|
643
|
+
getContainerProps,
|
|
644
|
+
getItemProps
|
|
645
|
+
} = useRovingTabIndex({
|
|
646
|
+
focusableIndex,
|
|
647
|
+
orientation,
|
|
648
|
+
isRtl
|
|
649
|
+
});
|
|
650
|
+
const rovingTabIndexContainerProps = getContainerProps();
|
|
651
|
+
const children = validChildren.map(({
|
|
652
|
+
child,
|
|
653
|
+
index,
|
|
654
|
+
childValue
|
|
655
|
+
}) => {
|
|
681
656
|
const selected = childValue === value;
|
|
682
|
-
|
|
657
|
+
const rovingTabIndexItemProps = getItemProps(index, child.ref);
|
|
683
658
|
return /*#__PURE__*/React.cloneElement(child, {
|
|
684
659
|
fullWidth: variant === 'fullWidth',
|
|
685
660
|
indicator: selected && !mounted && indicator,
|
|
@@ -688,53 +663,10 @@ const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(inProps, ref) {
|
|
|
688
663
|
onChange,
|
|
689
664
|
textColor,
|
|
690
665
|
value: childValue,
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
} : {})
|
|
666
|
+
ref: rovingTabIndexItemProps.ref,
|
|
667
|
+
tabIndex: child.props.tabIndex ?? rovingTabIndexItemProps.tabIndex
|
|
694
668
|
});
|
|
695
669
|
});
|
|
696
|
-
const handleKeyDown = event => {
|
|
697
|
-
// Check if a modifier key (Alt, Shift, Ctrl, Meta) is pressed
|
|
698
|
-
if (event.altKey || event.shiftKey || event.ctrlKey || event.metaKey) {
|
|
699
|
-
return;
|
|
700
|
-
}
|
|
701
|
-
const list = tabListRef.current;
|
|
702
|
-
const currentFocus = getActiveElement(ownerDocument(list));
|
|
703
|
-
// Keyboard navigation assumes that [role="tab"] are siblings
|
|
704
|
-
// though we might warn in the future about nested, interactive elements
|
|
705
|
-
// as a a11y violation
|
|
706
|
-
const role = currentFocus?.getAttribute('role');
|
|
707
|
-
if (role !== 'tab') {
|
|
708
|
-
return;
|
|
709
|
-
}
|
|
710
|
-
let previousItemKey = orientation === 'horizontal' ? 'ArrowLeft' : 'ArrowUp';
|
|
711
|
-
let nextItemKey = orientation === 'horizontal' ? 'ArrowRight' : 'ArrowDown';
|
|
712
|
-
if (orientation === 'horizontal' && isRtl) {
|
|
713
|
-
// swap previousItemKey with nextItemKey
|
|
714
|
-
previousItemKey = 'ArrowRight';
|
|
715
|
-
nextItemKey = 'ArrowLeft';
|
|
716
|
-
}
|
|
717
|
-
switch (event.key) {
|
|
718
|
-
case previousItemKey:
|
|
719
|
-
event.preventDefault();
|
|
720
|
-
moveFocus(list, currentFocus, previousItem);
|
|
721
|
-
break;
|
|
722
|
-
case nextItemKey:
|
|
723
|
-
event.preventDefault();
|
|
724
|
-
moveFocus(list, currentFocus, nextItem);
|
|
725
|
-
break;
|
|
726
|
-
case 'Home':
|
|
727
|
-
event.preventDefault();
|
|
728
|
-
moveFocus(list, null, nextItem);
|
|
729
|
-
break;
|
|
730
|
-
case 'End':
|
|
731
|
-
event.preventDefault();
|
|
732
|
-
moveFocus(list, null, previousItem);
|
|
733
|
-
break;
|
|
734
|
-
default:
|
|
735
|
-
break;
|
|
736
|
-
}
|
|
737
|
-
};
|
|
738
670
|
const conditionalElements = getConditionalElements();
|
|
739
671
|
const [RootSlot, rootSlotProps] = useSlot('root', {
|
|
740
672
|
ref,
|
|
@@ -760,8 +692,21 @@ const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(inProps, ref) {
|
|
|
760
692
|
}
|
|
761
693
|
}
|
|
762
694
|
});
|
|
695
|
+
const mergedRef = useForkRef(rovingTabIndexContainerProps.ref, tabListRef);
|
|
696
|
+
const handleKeyDown = event => {
|
|
697
|
+
const list = tabListRef.current;
|
|
698
|
+
const currentFocus = getActiveElement(ownerDocument(list));
|
|
699
|
+
// Keyboard navigation assumes that [role="tab"] are siblings
|
|
700
|
+
// though we might warn in the future about nested, interactive elements
|
|
701
|
+
// as a a11y violation
|
|
702
|
+
const role = currentFocus?.getAttribute('role');
|
|
703
|
+
if (role !== 'tab') {
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
706
|
+
rovingTabIndexContainerProps.onKeyDown(event);
|
|
707
|
+
};
|
|
763
708
|
const [ListSlot, listSlotProps] = useSlot('list', {
|
|
764
|
-
ref:
|
|
709
|
+
ref: mergedRef,
|
|
765
710
|
className: clsx(classes.list, classes.flexContainer),
|
|
766
711
|
elementType: List,
|
|
767
712
|
externalForwardedProps,
|
|
@@ -771,6 +716,10 @@ const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(inProps, ref) {
|
|
|
771
716
|
onKeyDown: event => {
|
|
772
717
|
handleKeyDown(event);
|
|
773
718
|
handlers.onKeyDown?.(event);
|
|
719
|
+
},
|
|
720
|
+
onFocus: event => {
|
|
721
|
+
rovingTabIndexContainerProps.onFocus(event);
|
|
722
|
+
handlers.onFocus?.(event);
|
|
774
723
|
}
|
|
775
724
|
})
|
|
776
725
|
});
|
|
@@ -86,6 +86,7 @@ export interface TypographyTypeMap<AdditionalProps = {}, RootComponent extends R
|
|
|
86
86
|
* Demos:
|
|
87
87
|
*
|
|
88
88
|
* - [Breadcrumbs](https://next.mui.com/material-ui/react-breadcrumbs/)
|
|
89
|
+
* - [Menubar](https://next.mui.com/material-ui/react-menubar/)
|
|
89
90
|
* - [Typography](https://next.mui.com/material-ui/react-typography/)
|
|
90
91
|
*
|
|
91
92
|
* API:
|
|
@@ -86,6 +86,7 @@ export interface TypographyTypeMap<AdditionalProps = {}, RootComponent extends R
|
|
|
86
86
|
* Demos:
|
|
87
87
|
*
|
|
88
88
|
* - [Breadcrumbs](https://next.mui.com/material-ui/react-breadcrumbs/)
|
|
89
|
+
* - [Menubar](https://next.mui.com/material-ui/react-menubar/)
|
|
89
90
|
* - [Typography](https://next.mui.com/material-ui/react-typography/)
|
|
90
91
|
*
|
|
91
92
|
* API:
|
package/index.js
CHANGED
package/index.mjs
CHANGED