@mui/material 6.4.4 → 6.4.6
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/Accordion/Accordion.d.ts +14 -12
- package/Alert/Alert.d.ts +3 -15
- package/Backdrop/Backdrop.d.ts +14 -12
- package/Button/Button.js +3 -3
- package/CHANGELOG.md +63 -0
- package/CardHeader/CardHeader.d.ts +4 -20
- package/Checkbox/Checkbox.d.ts +45 -9
- package/Checkbox/Checkbox.js +51 -21
- package/Dialog/Dialog.d.ts +4 -4
- package/Drawer/Drawer.d.ts +92 -1
- package/Drawer/Drawer.js +108 -36
- package/IconButton/IconButton.js +3 -3
- package/InputBase/inputBaseClasses.d.ts +15 -6
- package/Menu/Menu.d.ts +88 -1
- package/Menu/Menu.js +58 -19
- package/Modal/Modal.js +9 -10
- package/Popover/Popover.d.ts +60 -6
- package/Popover/Popover.js +78 -51
- package/Radio/Radio.d.ts +45 -1
- package/Radio/Radio.js +59 -16
- package/Select/SelectInput.js +8 -8
- package/Snackbar/Snackbar.d.ts +79 -2
- package/Snackbar/Snackbar.js +110 -32
- package/SpeedDial/SpeedDial.d.ts +8 -6
- package/SpeedDialAction/SpeedDialAction.d.ts +82 -1
- package/SpeedDialAction/SpeedDialAction.js +108 -30
- package/StepContent/StepContent.d.ts +2 -2
- package/SwipeableDrawer/SwipeableDrawer.d.ts +28 -2
- package/SwipeableDrawer/SwipeableDrawer.js +60 -13
- package/Switch/Switch.js +2 -0
- package/Tabs/Tabs.d.ts +129 -29
- package/Tabs/Tabs.js +120 -52
- package/Tabs/tabsClasses.d.ts +4 -0
- package/Tabs/tabsClasses.js +1 -1
- package/Tooltip/Tooltip.d.ts +20 -12
- package/index.js +1 -1
- package/internal/SwitchBase.d.ts +35 -1
- package/internal/SwitchBase.js +84 -30
- package/modern/Button/Button.js +3 -3
- package/modern/Checkbox/Checkbox.js +51 -21
- package/modern/Drawer/Drawer.js +108 -36
- package/modern/IconButton/IconButton.js +3 -3
- package/modern/Menu/Menu.js +58 -19
- package/modern/Modal/Modal.js +9 -10
- package/modern/Popover/Popover.js +78 -51
- package/modern/Radio/Radio.js +59 -16
- package/modern/Select/SelectInput.js +8 -8
- package/modern/Snackbar/Snackbar.js +110 -32
- package/modern/SpeedDialAction/SpeedDialAction.js +108 -30
- package/modern/SwipeableDrawer/SwipeableDrawer.js +60 -13
- package/modern/Switch/Switch.js +2 -0
- package/modern/Tabs/Tabs.js +120 -52
- package/modern/Tabs/tabsClasses.js +1 -1
- package/modern/index.js +1 -1
- package/modern/internal/SwitchBase.js +84 -30
- package/modern/styles/createThemeNoVars.js +7 -2
- package/modern/useAutocomplete/useAutocomplete.js +0 -1
- package/modern/version/index.js +2 -2
- package/node/Button/Button.js +3 -3
- package/node/Checkbox/Checkbox.js +51 -21
- package/node/Drawer/Drawer.js +108 -36
- package/node/IconButton/IconButton.js +3 -3
- package/node/Menu/Menu.js +58 -19
- package/node/Modal/Modal.js +9 -10
- package/node/Popover/Popover.js +78 -51
- package/node/Radio/Radio.js +59 -16
- package/node/Select/SelectInput.js +8 -8
- package/node/Snackbar/Snackbar.js +110 -32
- package/node/SpeedDialAction/SpeedDialAction.js +108 -30
- package/node/SwipeableDrawer/SwipeableDrawer.js +60 -13
- package/node/Switch/Switch.js +2 -0
- package/node/Tabs/Tabs.js +120 -52
- package/node/Tabs/tabsClasses.js +1 -1
- package/node/index.js +1 -1
- package/node/internal/SwitchBase.js +84 -30
- package/node/styles/createThemeNoVars.js +7 -2
- package/node/useAutocomplete/useAutocomplete.js +0 -1
- package/node/version/index.js +2 -2
- package/package.json +5 -5
- package/styles/createThemeNoVars.js +7 -2
- package/useAutocomplete/useAutocomplete.js +0 -1
- package/version/index.js +2 -2
package/Tabs/Tabs.js
CHANGED
|
@@ -19,6 +19,7 @@ import useEventCallback from "../utils/useEventCallback.js";
|
|
|
19
19
|
import tabsClasses, { getTabsUtilityClass } from "./tabsClasses.js";
|
|
20
20
|
import ownerDocument from "../utils/ownerDocument.js";
|
|
21
21
|
import ownerWindow from "../utils/ownerWindow.js";
|
|
22
|
+
import useSlot from "../utils/useSlot.js";
|
|
22
23
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
23
24
|
const nextItem = (list, item) => {
|
|
24
25
|
if (list === item) {
|
|
@@ -75,7 +76,7 @@ const useUtilityClasses = ownerState => {
|
|
|
75
76
|
const slots = {
|
|
76
77
|
root: ['root', vertical && 'vertical'],
|
|
77
78
|
scroller: ['scroller', fixed && 'fixed', hideScrollbar && 'hideScrollbar', scrollableX && 'scrollableX', scrollableY && 'scrollableY'],
|
|
78
|
-
|
|
79
|
+
list: ['list', 'flexContainer', vertical && 'flexContainerVertical', vertical && 'vertical', centered && 'centered'],
|
|
79
80
|
indicator: ['indicator'],
|
|
80
81
|
scrollButtons: ['scrollButtons', scrollButtonsHideMobile && 'scrollButtonsHideMobile'],
|
|
81
82
|
scrollableX: [scrollableX && 'scrollableX'],
|
|
@@ -176,14 +177,14 @@ const TabsScroller = styled('div', {
|
|
|
176
177
|
}
|
|
177
178
|
}]
|
|
178
179
|
});
|
|
179
|
-
const
|
|
180
|
+
const List = styled('div', {
|
|
180
181
|
name: 'MuiTabs',
|
|
181
|
-
slot: '
|
|
182
|
+
slot: 'List',
|
|
182
183
|
overridesResolver: (props, styles) => {
|
|
183
184
|
const {
|
|
184
185
|
ownerState
|
|
185
186
|
} = props;
|
|
186
|
-
return [styles.flexContainer, ownerState.vertical && styles.flexContainerVertical, ownerState.centered && styles.centered];
|
|
187
|
+
return [styles.list, styles.flexContainer, ownerState.vertical && styles.flexContainerVertical, ownerState.centered && styles.centered];
|
|
187
188
|
}
|
|
188
189
|
})({
|
|
189
190
|
display: 'flex',
|
|
@@ -271,13 +272,16 @@ const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(inProps, ref) {
|
|
|
271
272
|
indicatorColor = 'primary',
|
|
272
273
|
onChange,
|
|
273
274
|
orientation = 'horizontal',
|
|
274
|
-
ScrollButtonComponent
|
|
275
|
+
ScrollButtonComponent,
|
|
276
|
+
// TODO: remove in v7 (deprecated in v6)
|
|
275
277
|
scrollButtons = 'auto',
|
|
276
278
|
selectionFollowsFocus,
|
|
277
279
|
slots = {},
|
|
278
280
|
slotProps = {},
|
|
279
281
|
TabIndicatorProps = {},
|
|
282
|
+
// TODO: remove in v7 (deprecated in v6)
|
|
280
283
|
TabScrollButtonProps = {},
|
|
284
|
+
// TODO: remove in v7 (deprecated in v6)
|
|
281
285
|
textColor = 'primary',
|
|
282
286
|
value,
|
|
283
287
|
variant = 'standard',
|
|
@@ -337,6 +341,14 @@ const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(inProps, ref) {
|
|
|
337
341
|
const valueToIndex = new Map();
|
|
338
342
|
const tabsRef = React.useRef(null);
|
|
339
343
|
const tabListRef = React.useRef(null);
|
|
344
|
+
const externalForwardedProps = {
|
|
345
|
+
slots,
|
|
346
|
+
slotProps: {
|
|
347
|
+
indicator: TabIndicatorProps,
|
|
348
|
+
scrollButton: TabScrollButtonProps,
|
|
349
|
+
...slotProps
|
|
350
|
+
}
|
|
351
|
+
};
|
|
340
352
|
const getTabsMeta = () => {
|
|
341
353
|
const tabsNode = tabsRef.current;
|
|
342
354
|
let tabsMeta;
|
|
@@ -458,50 +470,62 @@ const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(inProps, ref) {
|
|
|
458
470
|
const handleEndScrollClick = () => {
|
|
459
471
|
moveTabsScroll(getScrollSize());
|
|
460
472
|
};
|
|
473
|
+
const [ScrollbarSlot, {
|
|
474
|
+
onChange: scrollbarOnChange,
|
|
475
|
+
...scrollbarSlotProps
|
|
476
|
+
}] = useSlot('scrollbar', {
|
|
477
|
+
className: clsx(classes.scrollableX, classes.hideScrollbar),
|
|
478
|
+
elementType: TabsScrollbarSize,
|
|
479
|
+
shouldForwardComponentProp: true,
|
|
480
|
+
externalForwardedProps,
|
|
481
|
+
ownerState
|
|
482
|
+
});
|
|
461
483
|
|
|
462
484
|
// TODO Remove <ScrollbarSize /> as browser support for hiding the scrollbar
|
|
463
485
|
// with CSS improves.
|
|
464
486
|
const handleScrollbarSizeChange = React.useCallback(scrollbarWidth => {
|
|
487
|
+
scrollbarOnChange?.(scrollbarWidth);
|
|
465
488
|
setScrollerStyle({
|
|
466
489
|
overflow: null,
|
|
467
490
|
scrollbarWidth
|
|
468
491
|
});
|
|
469
|
-
}, []);
|
|
492
|
+
}, [scrollbarOnChange]);
|
|
493
|
+
const [ScrollButtonsSlot, scrollButtonSlotProps] = useSlot('scrollButtons', {
|
|
494
|
+
className: clsx(classes.scrollButtons, TabScrollButtonProps.className),
|
|
495
|
+
elementType: TabScrollButton,
|
|
496
|
+
externalForwardedProps,
|
|
497
|
+
ownerState,
|
|
498
|
+
additionalProps: {
|
|
499
|
+
orientation,
|
|
500
|
+
slots: {
|
|
501
|
+
StartScrollButtonIcon: slots.startScrollButtonIcon || slots.StartScrollButtonIcon,
|
|
502
|
+
EndScrollButtonIcon: slots.endScrollButtonIcon || slots.EndScrollButtonIcon
|
|
503
|
+
},
|
|
504
|
+
slotProps: {
|
|
505
|
+
startScrollButtonIcon: startScrollButtonIconProps,
|
|
506
|
+
endScrollButtonIcon: endScrollButtonIconProps
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
});
|
|
470
510
|
const getConditionalElements = () => {
|
|
471
511
|
const conditionalElements = {};
|
|
472
|
-
conditionalElements.scrollbarSizeListener = scrollable ? /*#__PURE__*/_jsx(
|
|
473
|
-
|
|
474
|
-
|
|
512
|
+
conditionalElements.scrollbarSizeListener = scrollable ? /*#__PURE__*/_jsx(ScrollbarSlot, {
|
|
513
|
+
...scrollbarSlotProps,
|
|
514
|
+
onChange: handleScrollbarSizeChange
|
|
475
515
|
}) : null;
|
|
476
516
|
const scrollButtonsActive = displayStartScroll || displayEndScroll;
|
|
477
517
|
const showScrollButtons = scrollable && (scrollButtons === 'auto' && scrollButtonsActive || scrollButtons === true);
|
|
478
|
-
conditionalElements.scrollButtonStart = showScrollButtons ? /*#__PURE__*/_jsx(
|
|
479
|
-
slots: {
|
|
480
|
-
StartScrollButtonIcon: slots.StartScrollButtonIcon
|
|
481
|
-
},
|
|
482
|
-
slotProps: {
|
|
483
|
-
startScrollButtonIcon: startScrollButtonIconProps
|
|
484
|
-
},
|
|
485
|
-
orientation: orientation,
|
|
518
|
+
conditionalElements.scrollButtonStart = showScrollButtons ? /*#__PURE__*/_jsx(ScrollButtonsSlot, {
|
|
486
519
|
direction: isRtl ? 'right' : 'left',
|
|
487
520
|
onClick: handleStartScrollClick,
|
|
488
521
|
disabled: !displayStartScroll,
|
|
489
|
-
...
|
|
490
|
-
className: clsx(classes.scrollButtons, TabScrollButtonProps.className)
|
|
522
|
+
...scrollButtonSlotProps
|
|
491
523
|
}) : null;
|
|
492
|
-
conditionalElements.scrollButtonEnd = showScrollButtons ? /*#__PURE__*/_jsx(
|
|
493
|
-
slots: {
|
|
494
|
-
EndScrollButtonIcon: slots.EndScrollButtonIcon
|
|
495
|
-
},
|
|
496
|
-
slotProps: {
|
|
497
|
-
endScrollButtonIcon: endScrollButtonIconProps
|
|
498
|
-
},
|
|
499
|
-
orientation: orientation,
|
|
524
|
+
conditionalElements.scrollButtonEnd = showScrollButtons ? /*#__PURE__*/_jsx(ScrollButtonsSlot, {
|
|
500
525
|
direction: isRtl ? 'left' : 'right',
|
|
501
526
|
onClick: handleEndScrollClick,
|
|
502
527
|
disabled: !displayEndScroll,
|
|
503
|
-
...
|
|
504
|
-
className: clsx(classes.scrollButtons, TabScrollButtonProps.className)
|
|
528
|
+
...scrollButtonSlotProps
|
|
505
529
|
}) : null;
|
|
506
530
|
return conditionalElements;
|
|
507
531
|
};
|
|
@@ -629,15 +653,18 @@ const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(inProps, ref) {
|
|
|
629
653
|
updateIndicator: updateIndicatorState,
|
|
630
654
|
updateScrollButtons: updateScrollButtonState
|
|
631
655
|
}), [updateIndicatorState, updateScrollButtonState]);
|
|
632
|
-
const
|
|
633
|
-
...TabIndicatorProps,
|
|
656
|
+
const [IndicatorSlot, indicatorSlotProps] = useSlot('indicator', {
|
|
634
657
|
className: clsx(classes.indicator, TabIndicatorProps.className),
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
658
|
+
elementType: TabsIndicator,
|
|
659
|
+
externalForwardedProps,
|
|
660
|
+
ownerState,
|
|
661
|
+
additionalProps: {
|
|
662
|
+
style: indicatorStyle
|
|
639
663
|
}
|
|
640
664
|
});
|
|
665
|
+
const indicator = /*#__PURE__*/_jsx(IndicatorSlot, {
|
|
666
|
+
...indicatorSlotProps
|
|
667
|
+
});
|
|
641
668
|
let childIndex = 0;
|
|
642
669
|
const children = React.Children.map(childrenProp, child => {
|
|
643
670
|
if (! /*#__PURE__*/React.isValidElement(child)) {
|
|
@@ -704,29 +731,54 @@ const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(inProps, ref) {
|
|
|
704
731
|
}
|
|
705
732
|
};
|
|
706
733
|
const conditionalElements = getConditionalElements();
|
|
707
|
-
|
|
734
|
+
const [RootSlot, rootSlotProps] = useSlot('root', {
|
|
735
|
+
ref,
|
|
708
736
|
className: clsx(classes.root, className),
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
737
|
+
elementType: TabsRoot,
|
|
738
|
+
externalForwardedProps: {
|
|
739
|
+
...externalForwardedProps,
|
|
740
|
+
...other,
|
|
741
|
+
component
|
|
742
|
+
},
|
|
743
|
+
ownerState
|
|
744
|
+
});
|
|
745
|
+
const [ScrollerSlot, scrollerSlotProps] = useSlot('scroller', {
|
|
746
|
+
ref: tabsRef,
|
|
747
|
+
className: classes.scroller,
|
|
748
|
+
elementType: TabsScroller,
|
|
749
|
+
externalForwardedProps,
|
|
750
|
+
ownerState,
|
|
751
|
+
additionalProps: {
|
|
716
752
|
style: {
|
|
717
753
|
overflow: scrollerStyle.overflow,
|
|
718
754
|
[vertical ? `margin${isRtl ? 'Left' : 'Right'}` : 'marginBottom']: visibleScrollbar ? undefined : -scrollerStyle.scrollbarWidth
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
});
|
|
758
|
+
const [ListSlot, listSlotProps] = useSlot('list', {
|
|
759
|
+
ref: tabListRef,
|
|
760
|
+
className: clsx(classes.list, classes.flexContainer),
|
|
761
|
+
elementType: List,
|
|
762
|
+
externalForwardedProps,
|
|
763
|
+
ownerState,
|
|
764
|
+
getSlotProps: handlers => ({
|
|
765
|
+
...handlers,
|
|
766
|
+
onKeyDown: event => {
|
|
767
|
+
handleKeyDown(event);
|
|
768
|
+
handlers.onKeyDown?.(event);
|
|
769
|
+
}
|
|
770
|
+
})
|
|
771
|
+
});
|
|
772
|
+
return /*#__PURE__*/_jsxs(RootSlot, {
|
|
773
|
+
...rootSlotProps,
|
|
774
|
+
children: [conditionalElements.scrollButtonStart, conditionalElements.scrollbarSizeListener, /*#__PURE__*/_jsxs(ScrollerSlot, {
|
|
775
|
+
...scrollerSlotProps,
|
|
776
|
+
children: [/*#__PURE__*/_jsx(ListSlot, {
|
|
722
777
|
"aria-label": ariaLabel,
|
|
723
778
|
"aria-labelledby": ariaLabelledBy,
|
|
724
779
|
"aria-orientation": orientation === 'vertical' ? 'vertical' : null,
|
|
725
|
-
className: classes.flexContainer,
|
|
726
|
-
ownerState: ownerState,
|
|
727
|
-
onKeyDown: handleKeyDown,
|
|
728
|
-
ref: tabListRef,
|
|
729
780
|
role: "tablist",
|
|
781
|
+
...listSlotProps,
|
|
730
782
|
children: children
|
|
731
783
|
}), mounted && indicator]
|
|
732
784
|
}), conditionalElements.scrollButtonEnd]
|
|
@@ -802,6 +854,7 @@ process.env.NODE_ENV !== "production" ? Tabs.propTypes /* remove-proptypes */ =
|
|
|
802
854
|
orientation: PropTypes.oneOf(['horizontal', 'vertical']),
|
|
803
855
|
/**
|
|
804
856
|
* The component used to render the scroll buttons.
|
|
857
|
+
* @deprecated use the `slots.scrollButtons` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
805
858
|
* @default TabScrollButton
|
|
806
859
|
*/
|
|
807
860
|
ScrollButtonComponent: PropTypes.elementType,
|
|
@@ -823,12 +876,17 @@ process.env.NODE_ENV !== "production" ? Tabs.propTypes /* remove-proptypes */ =
|
|
|
823
876
|
*/
|
|
824
877
|
selectionFollowsFocus: PropTypes.bool,
|
|
825
878
|
/**
|
|
826
|
-
* The
|
|
827
|
-
* You can override the existing props or add new ones.
|
|
879
|
+
* The props used for each slot inside.
|
|
828
880
|
* @default {}
|
|
829
881
|
*/
|
|
830
882
|
slotProps: PropTypes.shape({
|
|
831
883
|
endScrollButtonIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
884
|
+
indicator: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
885
|
+
list: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
886
|
+
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
887
|
+
scrollbar: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
888
|
+
scrollButtons: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
889
|
+
scroller: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
832
890
|
startScrollButtonIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
833
891
|
}),
|
|
834
892
|
/**
|
|
@@ -836,7 +894,15 @@ process.env.NODE_ENV !== "production" ? Tabs.propTypes /* remove-proptypes */ =
|
|
|
836
894
|
* @default {}
|
|
837
895
|
*/
|
|
838
896
|
slots: PropTypes.shape({
|
|
897
|
+
endScrollButtonIcon: PropTypes.elementType,
|
|
839
898
|
EndScrollButtonIcon: PropTypes.elementType,
|
|
899
|
+
indicator: PropTypes.elementType,
|
|
900
|
+
list: PropTypes.elementType,
|
|
901
|
+
root: PropTypes.elementType,
|
|
902
|
+
scrollbar: PropTypes.elementType,
|
|
903
|
+
scrollButtons: PropTypes.elementType,
|
|
904
|
+
scroller: PropTypes.elementType,
|
|
905
|
+
startScrollButtonIcon: PropTypes.elementType,
|
|
840
906
|
StartScrollButtonIcon: PropTypes.elementType
|
|
841
907
|
}),
|
|
842
908
|
/**
|
|
@@ -845,11 +911,13 @@ process.env.NODE_ENV !== "production" ? Tabs.propTypes /* remove-proptypes */ =
|
|
|
845
911
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
846
912
|
/**
|
|
847
913
|
* Props applied to the tab indicator element.
|
|
914
|
+
* @deprecated use the `slotProps.indicator` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
848
915
|
* @default {}
|
|
849
916
|
*/
|
|
850
917
|
TabIndicatorProps: PropTypes.object,
|
|
851
918
|
/**
|
|
852
919
|
* Props applied to the [`TabScrollButton`](https://mui.com/material-ui/api/tab-scroll-button/) element.
|
|
920
|
+
* @deprecated use the `slotProps.scrollButtons` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
853
921
|
* @default {}
|
|
854
922
|
*/
|
|
855
923
|
TabScrollButtonProps: PropTypes.object,
|
package/Tabs/tabsClasses.d.ts
CHANGED
|
@@ -4,9 +4,13 @@ export interface TabsClasses {
|
|
|
4
4
|
/** Styles applied to the root element if `orientation="vertical"`. */
|
|
5
5
|
vertical: string;
|
|
6
6
|
/** Styles applied to the flex container element. */
|
|
7
|
+
/** @deprecated use `list` instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details. */
|
|
7
8
|
flexContainer: string;
|
|
8
9
|
/** Styles applied to the flex container element if `orientation="vertical"`. */
|
|
10
|
+
/** @deprecated use a combination of `list` and `vertical` instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details. */
|
|
9
11
|
flexContainerVertical: string;
|
|
12
|
+
/** Styles applied to the list element. */
|
|
13
|
+
list: string;
|
|
10
14
|
/** Styles applied to the flex container element if `centered={true}` & `!variant="scrollable"`. */
|
|
11
15
|
centered: string;
|
|
12
16
|
/** Styles applied to the tablist element. */
|
package/Tabs/tabsClasses.js
CHANGED
|
@@ -3,5 +3,5 @@ import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
|
3
3
|
export function getTabsUtilityClass(slot) {
|
|
4
4
|
return generateUtilityClass('MuiTabs', slot);
|
|
5
5
|
}
|
|
6
|
-
const tabsClasses = generateUtilityClasses('MuiTabs', ['root', 'vertical', 'flexContainer', 'flexContainerVertical', 'centered', 'scroller', 'fixed', 'scrollableX', 'scrollableY', 'hideScrollbar', 'scrollButtons', 'scrollButtonsHideMobile', 'indicator']);
|
|
6
|
+
const tabsClasses = generateUtilityClasses('MuiTabs', ['root', 'vertical', 'list', 'flexContainer', 'flexContainerVertical', 'centered', 'scroller', 'fixed', 'scrollableX', 'scrollableY', 'hideScrollbar', 'scrollButtons', 'scrollButtonsHideMobile', 'indicator']);
|
|
7
7
|
export default tabsClasses;
|
package/Tooltip/Tooltip.d.ts
CHANGED
|
@@ -41,26 +41,34 @@ export interface TooltipSlots {
|
|
|
41
41
|
export type TooltipSlotsAndSlotProps = CreateSlotsAndSlotProps<
|
|
42
42
|
TooltipSlots,
|
|
43
43
|
{
|
|
44
|
+
/**
|
|
45
|
+
* Props forwarded to the popper slot.
|
|
46
|
+
* By default, the avaible props are based on the [Popper](https://mui.com/material-ui/api/popper/#props) component.
|
|
47
|
+
*/
|
|
44
48
|
popper: SlotProps<
|
|
45
49
|
React.ElementType<PopperProps>,
|
|
46
50
|
TooltipPopperSlotPropsOverrides,
|
|
47
51
|
TooltipOwnerState
|
|
48
52
|
>;
|
|
53
|
+
/**
|
|
54
|
+
* Props forwarded to the transition slot.
|
|
55
|
+
* By default, the avaible props are based on the [Grow](https://mui.com/material-ui/api/grow/#props) component.
|
|
56
|
+
*/
|
|
49
57
|
transition: SlotProps<
|
|
50
|
-
React.ElementType
|
|
51
|
-
TooltipTransitionSlotPropsOverrides,
|
|
52
|
-
TooltipOwnerState
|
|
53
|
-
>;
|
|
54
|
-
tooltip: SlotProps<
|
|
55
|
-
React.ElementType<React.HTMLProps<HTMLDivElement>>,
|
|
56
|
-
TooltipTooltipSlotPropsOverrides,
|
|
57
|
-
TooltipOwnerState
|
|
58
|
-
>;
|
|
59
|
-
arrow: SlotProps<
|
|
60
|
-
React.ElementType<React.HTMLProps<HTMLSpanElement>>,
|
|
61
|
-
TooltipArrowSlotPropsOverrides,
|
|
58
|
+
React.ElementType,
|
|
59
|
+
TransitionProps & TooltipTransitionSlotPropsOverrides,
|
|
62
60
|
TooltipOwnerState
|
|
63
61
|
>;
|
|
62
|
+
/**
|
|
63
|
+
* Props forwarded to the tooltip slot.
|
|
64
|
+
* By default, the avaible props are based on the div element.
|
|
65
|
+
*/
|
|
66
|
+
tooltip: SlotProps<'div', TooltipTooltipSlotPropsOverrides, TooltipOwnerState>;
|
|
67
|
+
/**
|
|
68
|
+
* Props forwarded to the tooltip slot.
|
|
69
|
+
* By default, the avaible props are based on the span element.
|
|
70
|
+
*/
|
|
71
|
+
arrow: SlotProps<'span', TooltipArrowSlotPropsOverrides, TooltipOwnerState>;
|
|
64
72
|
}
|
|
65
73
|
>;
|
|
66
74
|
|
package/index.js
CHANGED
package/internal/SwitchBase.d.ts
CHANGED
|
@@ -2,9 +2,39 @@ import * as React from 'react';
|
|
|
2
2
|
import { InternalStandardProps as StandardProps } from '..';
|
|
3
3
|
import { ButtonBaseProps } from '../ButtonBase';
|
|
4
4
|
import { SwitchBaseClasses } from './switchBaseClasses';
|
|
5
|
+
import { CreateSlotsAndSlotProps, SlotProps } from '../utils/types';
|
|
6
|
+
|
|
7
|
+
interface SwitchBaseSlots {
|
|
8
|
+
/**
|
|
9
|
+
* The component that renders the root slot.
|
|
10
|
+
* @default ButtonBase
|
|
11
|
+
*/
|
|
12
|
+
root: React.ElementType;
|
|
13
|
+
/**
|
|
14
|
+
* The component that renders the input slot.
|
|
15
|
+
* @default 'input'
|
|
16
|
+
*/
|
|
17
|
+
input: React.ElementType;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type SwitchBaseSlotsAndSlotProps = CreateSlotsAndSlotProps<
|
|
21
|
+
SwitchBaseSlots,
|
|
22
|
+
{
|
|
23
|
+
/**
|
|
24
|
+
* Props forwarded to the root slot.
|
|
25
|
+
* By default, the avaible props are based on the [ButtonBase](https://mui.com/material-ui/api/button-base/#props) component.
|
|
26
|
+
*/
|
|
27
|
+
root: SlotProps<React.ElementType<ButtonBaseProps>, {}, SwitchBaseOwnerState>;
|
|
28
|
+
/**
|
|
29
|
+
* Props forwarded to the input slot.
|
|
30
|
+
*/
|
|
31
|
+
input: SlotProps<'input', {}, SwitchBaseOwnerState>;
|
|
32
|
+
}
|
|
33
|
+
>;
|
|
5
34
|
|
|
6
35
|
export interface SwitchBaseProps
|
|
7
|
-
extends StandardProps<ButtonBaseProps, 'children' | 'onChange' | 'type' | 'value'
|
|
36
|
+
extends StandardProps<ButtonBaseProps, 'children' | 'onChange' | 'type' | 'value'>,
|
|
37
|
+
SwitchBaseSlotsAndSlotProps {
|
|
8
38
|
autoFocus?: boolean;
|
|
9
39
|
/**
|
|
10
40
|
* If `true`, the component is checked.
|
|
@@ -48,10 +78,12 @@ export interface SwitchBaseProps
|
|
|
48
78
|
id?: string;
|
|
49
79
|
/**
|
|
50
80
|
* [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element.
|
|
81
|
+
* @deprecated Use `slotProps.input` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
51
82
|
*/
|
|
52
83
|
inputProps?: React.InputHTMLAttributes<HTMLInputElement>;
|
|
53
84
|
/**
|
|
54
85
|
* Pass a ref to the `input` element.
|
|
86
|
+
* @deprecated Use `slotProps.input.ref` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
55
87
|
*/
|
|
56
88
|
inputRef?: React.Ref<any>;
|
|
57
89
|
/**
|
|
@@ -80,6 +112,8 @@ export interface SwitchBaseProps
|
|
|
80
112
|
value?: unknown;
|
|
81
113
|
}
|
|
82
114
|
|
|
115
|
+
export interface SwitchBaseOwnerState extends Omit<SwitchBaseProps, 'slots' | 'slotProps'> {}
|
|
116
|
+
|
|
83
117
|
declare const SwitchBase: React.JSXElementConstructor<SwitchBaseProps>;
|
|
84
118
|
|
|
85
119
|
export default SwitchBase;
|
package/internal/SwitchBase.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
|
-
import clsx from 'clsx';
|
|
6
5
|
import refType from '@mui/utils/refType';
|
|
7
6
|
import composeClasses from '@mui/utils/composeClasses';
|
|
8
7
|
import capitalize from "../utils/capitalize.js";
|
|
@@ -12,6 +11,7 @@ import useControlled from "../utils/useControlled.js";
|
|
|
12
11
|
import useFormControl from "../FormControl/useFormControl.js";
|
|
13
12
|
import ButtonBase from "../ButtonBase/index.js";
|
|
14
13
|
import { getSwitchBaseUtilityClass } from "./switchBaseClasses.js";
|
|
14
|
+
import useSlot from "../utils/useSlot.js";
|
|
15
15
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
16
|
const useUtilityClasses = ownerState => {
|
|
17
17
|
const {
|
|
@@ -86,7 +86,6 @@ const SwitchBase = /*#__PURE__*/React.forwardRef(function SwitchBase(props, ref)
|
|
|
86
86
|
autoFocus,
|
|
87
87
|
checked: checkedProp,
|
|
88
88
|
checkedIcon,
|
|
89
|
-
className,
|
|
90
89
|
defaultChecked,
|
|
91
90
|
disabled: disabledProp,
|
|
92
91
|
disableFocusRipple = false,
|
|
@@ -104,6 +103,8 @@ const SwitchBase = /*#__PURE__*/React.forwardRef(function SwitchBase(props, ref)
|
|
|
104
103
|
tabIndex,
|
|
105
104
|
type,
|
|
106
105
|
value,
|
|
106
|
+
slots = {},
|
|
107
|
+
slotProps = {},
|
|
107
108
|
...other
|
|
108
109
|
} = props;
|
|
109
110
|
const [checked, setCheckedState] = useControlled({
|
|
@@ -156,38 +157,75 @@ const SwitchBase = /*#__PURE__*/React.forwardRef(function SwitchBase(props, ref)
|
|
|
156
157
|
edge
|
|
157
158
|
};
|
|
158
159
|
const classes = useUtilityClasses(ownerState);
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
160
|
+
const externalForwardedProps = {
|
|
161
|
+
slots,
|
|
162
|
+
slotProps: {
|
|
163
|
+
input: inputProps,
|
|
164
|
+
...slotProps
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
const [RootSlot, rootSlotProps] = useSlot('root', {
|
|
168
|
+
ref,
|
|
169
|
+
elementType: SwitchBaseRoot,
|
|
170
|
+
className: classes.root,
|
|
171
|
+
shouldForwardComponentProp: true,
|
|
172
|
+
externalForwardedProps: {
|
|
173
|
+
...externalForwardedProps,
|
|
174
|
+
component: 'span',
|
|
175
|
+
...other
|
|
176
|
+
},
|
|
177
|
+
getSlotProps: handlers => ({
|
|
178
|
+
...handlers,
|
|
179
|
+
onFocus: event => {
|
|
180
|
+
handlers.onFocus?.(event);
|
|
181
|
+
handleFocus(event);
|
|
182
|
+
},
|
|
183
|
+
onBlur: event => {
|
|
184
|
+
handlers.onBlur?.(event);
|
|
185
|
+
handleBlur(event);
|
|
186
|
+
}
|
|
187
|
+
}),
|
|
188
|
+
ownerState,
|
|
189
|
+
additionalProps: {
|
|
190
|
+
centerRipple: true,
|
|
191
|
+
focusRipple: !disableFocusRipple,
|
|
192
|
+
disabled,
|
|
193
|
+
role: undefined,
|
|
194
|
+
tabIndex: null
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
const [InputSlot, inputSlotProps] = useSlot('input', {
|
|
198
|
+
ref: inputRef,
|
|
199
|
+
elementType: SwitchBaseInput,
|
|
200
|
+
className: classes.input,
|
|
201
|
+
externalForwardedProps,
|
|
202
|
+
getSlotProps: handlers => ({
|
|
203
|
+
onChange: event => {
|
|
204
|
+
handlers.onChange?.(event);
|
|
205
|
+
handleInputChange(event);
|
|
206
|
+
}
|
|
207
|
+
}),
|
|
208
|
+
ownerState,
|
|
209
|
+
additionalProps: {
|
|
210
|
+
autoFocus,
|
|
174
211
|
checked: checkedProp,
|
|
175
|
-
defaultChecked
|
|
176
|
-
|
|
177
|
-
disabled: disabled,
|
|
212
|
+
defaultChecked,
|
|
213
|
+
disabled,
|
|
178
214
|
id: hasLabelFor ? id : undefined,
|
|
179
|
-
name
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
ownerState: ownerState,
|
|
185
|
-
tabIndex: tabIndex,
|
|
186
|
-
type: type,
|
|
215
|
+
name,
|
|
216
|
+
readOnly,
|
|
217
|
+
required,
|
|
218
|
+
tabIndex,
|
|
219
|
+
type,
|
|
187
220
|
...(type === 'checkbox' && value === undefined ? {} : {
|
|
188
221
|
value
|
|
189
|
-
})
|
|
190
|
-
|
|
222
|
+
})
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
return /*#__PURE__*/_jsxs(RootSlot, {
|
|
226
|
+
...rootSlotProps,
|
|
227
|
+
children: [/*#__PURE__*/_jsx(InputSlot, {
|
|
228
|
+
...inputSlotProps
|
|
191
229
|
}), checked ? checkedIcon : icon]
|
|
192
230
|
});
|
|
193
231
|
});
|
|
@@ -280,6 +318,22 @@ process.env.NODE_ENV !== "production" ? SwitchBase.propTypes = {
|
|
|
280
318
|
* If `true`, the `input` element is required.
|
|
281
319
|
*/
|
|
282
320
|
required: PropTypes.bool,
|
|
321
|
+
/**
|
|
322
|
+
* The props used for each slot inside.
|
|
323
|
+
* @default {}
|
|
324
|
+
*/
|
|
325
|
+
slotProps: PropTypes.shape({
|
|
326
|
+
input: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
327
|
+
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
328
|
+
}),
|
|
329
|
+
/**
|
|
330
|
+
* The components used for each slot inside.
|
|
331
|
+
* @default {}
|
|
332
|
+
*/
|
|
333
|
+
slots: PropTypes.shape({
|
|
334
|
+
input: PropTypes.elementType,
|
|
335
|
+
root: PropTypes.elementType
|
|
336
|
+
}),
|
|
283
337
|
/**
|
|
284
338
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
285
339
|
*/
|
package/modern/Button/Button.js
CHANGED
|
@@ -501,9 +501,9 @@ const Button = /*#__PURE__*/React.forwardRef(function Button(inProps, ref) {
|
|
|
501
501
|
variant = 'text',
|
|
502
502
|
...other
|
|
503
503
|
} = props;
|
|
504
|
-
const
|
|
504
|
+
const loadingId = useId(idProp);
|
|
505
505
|
const loadingIndicator = loadingIndicatorProp ?? /*#__PURE__*/_jsx(CircularProgress, {
|
|
506
|
-
"aria-labelledby":
|
|
506
|
+
"aria-labelledby": loadingId,
|
|
507
507
|
color: "inherit",
|
|
508
508
|
size: 16
|
|
509
509
|
});
|
|
@@ -563,7 +563,7 @@ const Button = /*#__PURE__*/React.forwardRef(function Button(inProps, ref) {
|
|
|
563
563
|
focusVisibleClassName: clsx(classes.focusVisible, focusVisibleClassName),
|
|
564
564
|
ref: ref,
|
|
565
565
|
type: type,
|
|
566
|
-
id:
|
|
566
|
+
id: loading ? loadingId : idProp,
|
|
567
567
|
...other,
|
|
568
568
|
classes: classes,
|
|
569
569
|
children: [startIcon, loadingPosition !== 'end' && loader, children, loadingPosition === 'end' && loader, endIcon]
|