@mui/material 9.0.0-alpha.4 → 9.0.0-beta.1
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.mts +1 -1
- package/Accordion/Accordion.d.ts +1 -1
- package/AccordionSummary/AccordionSummary.js +1 -0
- package/AccordionSummary/AccordionSummary.mjs +1 -0
- package/Backdrop/Backdrop.d.mts +1 -1
- package/Backdrop/Backdrop.d.ts +1 -1
- package/BottomNavigationAction/BottomNavigationAction.js +1 -0
- package/BottomNavigationAction/BottomNavigationAction.mjs +1 -0
- package/Breadcrumbs/BreadcrumbCollapsed.js +5 -1
- package/Breadcrumbs/BreadcrumbCollapsed.mjs +5 -1
- package/Button/Button.js +1 -0
- package/Button/Button.mjs +1 -0
- package/ButtonBase/ButtonBase.d.mts +5 -0
- package/ButtonBase/ButtonBase.d.ts +5 -0
- package/ButtonBase/ButtonBase.js +84 -85
- package/ButtonBase/ButtonBase.mjs +84 -85
- package/ButtonBase/useButtonBase.d.mts +91 -0
- package/ButtonBase/useButtonBase.d.ts +91 -0
- package/ButtonBase/useButtonBase.js +174 -0
- package/ButtonBase/useButtonBase.mjs +167 -0
- package/ButtonGroup/ButtonGroup.js +1 -9
- package/ButtonGroup/ButtonGroup.mjs +1 -9
- package/ButtonGroup/buttonGroupClasses.d.mts +0 -68
- package/ButtonGroup/buttonGroupClasses.d.ts +0 -68
- package/ButtonGroup/buttonGroupClasses.js +1 -1
- package/ButtonGroup/buttonGroupClasses.mjs +1 -1
- package/CHANGELOG.md +119 -4
- package/CardActionArea/CardActionArea.js +1 -0
- package/CardActionArea/CardActionArea.mjs +1 -0
- package/CardHeader/CardHeader.d.mts +13 -21
- package/CardHeader/CardHeader.d.ts +13 -21
- package/CardHeader/CardHeader.js +3 -21
- package/CardHeader/CardHeader.mjs +3 -21
- package/Checkbox/Checkbox.js +1 -7
- package/Checkbox/Checkbox.mjs +1 -7
- package/Chip/Chip.d.mts +7 -0
- package/Chip/Chip.d.ts +7 -0
- package/Chip/Chip.js +66 -55
- package/Chip/Chip.mjs +66 -55
- package/Chip/chipClasses.d.mts +0 -104
- package/Chip/chipClasses.d.ts +0 -104
- package/Chip/chipClasses.js +1 -1
- package/Chip/chipClasses.mjs +1 -1
- package/Dialog/Dialog.d.mts +8 -22
- package/Dialog/Dialog.d.ts +8 -22
- package/Dialog/Dialog.js +43 -72
- package/Dialog/Dialog.mjs +43 -72
- package/Dialog/dialogClasses.d.mts +0 -8
- package/Dialog/dialogClasses.d.ts +0 -8
- package/Dialog/dialogClasses.js +1 -1
- package/Dialog/dialogClasses.mjs +1 -1
- package/Divider/Divider.js +2 -10
- package/Divider/Divider.mjs +2 -10
- package/Divider/dividerClasses.d.mts +0 -4
- package/Divider/dividerClasses.d.ts +0 -4
- package/Divider/dividerClasses.js +1 -1
- package/Divider/dividerClasses.mjs +1 -1
- package/Drawer/Drawer.d.mts +1 -13
- package/Drawer/Drawer.d.ts +1 -13
- package/Drawer/Drawer.js +6 -40
- package/Drawer/Drawer.mjs +6 -40
- package/Drawer/drawerClasses.d.mts +0 -32
- package/Drawer/drawerClasses.d.ts +0 -32
- package/Drawer/drawerClasses.js +1 -1
- package/Drawer/drawerClasses.mjs +1 -1
- package/Fab/Fab.js +1 -0
- package/Fab/Fab.mjs +1 -0
- package/FilledInput/FilledInput.js +4 -33
- package/FilledInput/FilledInput.mjs +4 -33
- package/Grid/Grid.d.mts +8 -3
- package/Grid/Grid.d.ts +8 -3
- package/Grid/Grid.js +8 -3
- package/Grid/Grid.mjs +8 -3
- package/Grid/gridClasses.js +1 -1
- package/Grid/gridClasses.mjs +1 -1
- package/IconButton/IconButton.js +1 -0
- package/IconButton/IconButton.mjs +1 -0
- package/ImageListItemBar/ImageListItemBar.js +4 -17
- package/ImageListItemBar/ImageListItemBar.mjs +4 -17
- package/ImageListItemBar/imageListItemBarClasses.d.mts +0 -16
- package/ImageListItemBar/imageListItemBarClasses.d.ts +0 -16
- package/ImageListItemBar/imageListItemBarClasses.js +1 -1
- package/ImageListItemBar/imageListItemBarClasses.mjs +1 -1
- package/Input/Input.js +4 -33
- package/Input/Input.mjs +4 -33
- package/Input/inputClasses.d.mts +0 -16
- package/Input/inputClasses.d.ts +0 -16
- package/InputAdornment/inputAdornmentClasses.d.mts +2 -2
- package/InputAdornment/inputAdornmentClasses.d.ts +2 -2
- package/InputBase/InputBase.d.mts +0 -27
- package/InputBase/InputBase.d.ts +0 -27
- package/InputBase/InputBase.js +6 -35
- package/InputBase/InputBase.mjs +6 -35
- package/InputBase/inputBaseClasses.d.mts +0 -20
- package/InputBase/inputBaseClasses.d.ts +0 -20
- package/InputBase/inputBaseClasses.js +1 -1
- package/InputBase/inputBaseClasses.mjs +1 -1
- package/InputLabel/InputLabel.js +1 -1
- package/InputLabel/InputLabel.mjs +1 -1
- package/LinearProgress/LinearProgress.js +6 -18
- package/LinearProgress/LinearProgress.mjs +6 -18
- package/LinearProgress/linearProgressClasses.d.mts +0 -36
- package/LinearProgress/linearProgressClasses.d.ts +0 -36
- package/LinearProgress/linearProgressClasses.js +1 -1
- package/LinearProgress/linearProgressClasses.mjs +1 -1
- package/Link/Link.d.mts +1 -1
- package/Link/Link.d.ts +1 -1
- package/ListItem/ListItem.d.mts +2 -36
- package/ListItem/ListItem.d.ts +2 -36
- package/ListItem/ListItem.js +27 -152
- package/ListItem/ListItem.mjs +27 -152
- package/ListItem/listItemClasses.d.mts +2 -4
- package/ListItem/listItemClasses.d.ts +2 -4
- package/ListItem/listItemClasses.js +1 -1
- package/ListItem/listItemClasses.mjs +1 -1
- package/ListItemButton/ListItemButton.d.mts +1 -2
- package/ListItemButton/ListItemButton.d.ts +1 -2
- package/ListItemButton/ListItemButton.js +2 -2
- package/ListItemButton/ListItemButton.mjs +2 -2
- package/ListItemIcon/ListItemIcon.js +1 -1
- package/ListItemIcon/ListItemIcon.mjs +1 -1
- package/ListItemSecondaryAction/ListItemSecondaryAction.d.mts +10 -6
- package/ListItemSecondaryAction/ListItemSecondaryAction.d.ts +10 -6
- package/ListItemSecondaryAction/ListItemSecondaryAction.js +7 -2
- package/ListItemSecondaryAction/ListItemSecondaryAction.mjs +7 -2
- package/ListItemText/ListItemText.d.mts +12 -20
- package/ListItemText/ListItemText.d.ts +12 -20
- package/ListItemText/ListItemText.js +2 -20
- package/ListItemText/ListItemText.mjs +2 -20
- package/ListSubheader/ListSubheader.js +0 -3
- package/ListSubheader/ListSubheader.mjs +0 -3
- package/Menu/Menu.d.mts +1 -1
- package/Menu/Menu.d.ts +1 -1
- package/Menu/Menu.js +15 -32
- package/Menu/Menu.mjs +15 -32
- package/MenuItem/MenuItem.js +36 -26
- package/MenuItem/MenuItem.mjs +34 -26
- package/MenuList/MenuList.js +136 -101
- package/MenuList/MenuList.mjs +135 -100
- package/MenuList/MenuListContext.d.mts +11 -0
- package/MenuList/MenuListContext.d.ts +11 -0
- package/MenuList/MenuListContext.js +25 -0
- package/MenuList/MenuListContext.mjs +19 -0
- package/Modal/Modal.d.mts +1 -41
- package/Modal/Modal.d.ts +1 -41
- package/Modal/Modal.js +5 -58
- package/Modal/Modal.mjs +5 -58
- package/OutlinedInput/OutlinedInput.js +2 -14
- package/OutlinedInput/OutlinedInput.mjs +2 -14
- package/OutlinedInput/outlinedInputClasses.d.mts +0 -16
- package/OutlinedInput/outlinedInputClasses.d.ts +0 -16
- package/PaginationItem/PaginationItem.d.mts +5 -15
- package/PaginationItem/PaginationItem.d.ts +5 -15
- package/PaginationItem/PaginationItem.js +9 -24
- package/PaginationItem/PaginationItem.mjs +9 -24
- package/PaginationItem/paginationItemClasses.d.mts +0 -16
- package/PaginationItem/paginationItemClasses.d.ts +0 -16
- package/PaginationItem/paginationItemClasses.js +1 -1
- package/PaginationItem/paginationItemClasses.mjs +1 -1
- package/PigmentGrid/PigmentGrid.d.mts +1 -1
- package/PigmentGrid/PigmentGrid.d.ts +1 -1
- package/PigmentGrid/PigmentGrid.js +1 -1
- package/PigmentGrid/PigmentGrid.mjs +1 -1
- package/Popover/Popover.d.mts +1 -1
- package/Popover/Popover.d.ts +1 -1
- package/Popover/Popover.js +19 -7
- package/Popover/Popover.mjs +18 -6
- package/Radio/Radio.js +1 -13
- package/Radio/Radio.mjs +1 -13
- package/Rating/Rating.d.mts +0 -9
- package/Rating/Rating.d.ts +0 -9
- package/Rating/Rating.js +1 -17
- package/Rating/Rating.mjs +1 -17
- package/Select/SelectInput.js +2 -3
- package/Select/SelectInput.mjs +2 -3
- package/Select/selectClasses.d.mts +0 -12
- package/Select/selectClasses.d.ts +0 -12
- package/Select/selectClasses.js +1 -1
- package/Select/selectClasses.mjs +1 -1
- package/Slider/Slider.d.mts +0 -5
- package/Slider/Slider.d.ts +0 -5
- package/Slider/Slider.js +2 -8
- package/Slider/Slider.mjs +2 -8
- package/Slider/sliderClasses.d.mts +0 -28
- package/Slider/sliderClasses.d.ts +0 -28
- package/Slider/sliderClasses.js +1 -1
- package/Slider/sliderClasses.mjs +1 -1
- package/Snackbar/Snackbar.d.mts +1 -1
- package/Snackbar/Snackbar.d.ts +1 -1
- package/SpeedDial/SpeedDial.d.mts +1 -1
- package/SpeedDial/SpeedDial.d.ts +1 -1
- package/Stack/Stack.d.mts +2 -2
- package/Stack/Stack.d.ts +2 -2
- package/StepButton/StepButton.js +44 -14
- package/StepButton/StepButton.mjs +44 -14
- package/StepConnector/StepConnector.js +2 -8
- package/StepConnector/StepConnector.mjs +2 -8
- package/StepConnector/stepConnectorClasses.d.mts +0 -8
- package/StepConnector/stepConnectorClasses.d.ts +0 -8
- package/StepConnector/stepConnectorClasses.js +1 -1
- package/StepConnector/stepConnectorClasses.mjs +1 -1
- package/StepContent/StepContent.d.mts +2 -17
- package/StepContent/StepContent.d.ts +2 -17
- package/StepContent/StepContent.js +3 -22
- package/StepContent/StepContent.mjs +3 -22
- package/StepLabel/StepLabel.d.mts +0 -22
- package/StepLabel/StepLabel.d.ts +0 -22
- package/StepLabel/StepLabel.js +2 -31
- package/StepLabel/StepLabel.mjs +2 -31
- package/Stepper/Stepper.js +54 -22
- package/Stepper/Stepper.mjs +54 -22
- package/Stepper/StepperContext.d.mts +0 -5
- package/Stepper/StepperContext.d.ts +0 -5
- package/Stepper/StepperContext.js +1 -2
- package/Stepper/StepperContext.mjs +0 -1
- package/SvgIcon/createSvgIcon.d.mts +2 -0
- package/SvgIcon/createSvgIcon.d.ts +2 -0
- package/SvgIcon/createSvgIcon.js +31 -0
- package/SvgIcon/createSvgIcon.mjs +26 -0
- package/SvgIcon/index.d.mts +1 -0
- package/SvgIcon/index.d.ts +1 -0
- package/SvgIcon/index.js +8 -0
- package/SvgIcon/index.mjs +1 -0
- package/SwipeableDrawer/SwipeableDrawer.d.mts +0 -5
- package/SwipeableDrawer/SwipeableDrawer.d.ts +0 -5
- package/SwipeableDrawer/SwipeableDrawer.js +6 -37
- package/SwipeableDrawer/SwipeableDrawer.mjs +6 -37
- package/Switch/Switch.js +0 -11
- package/Switch/Switch.mjs +0 -11
- package/Tab/Tab.js +18 -4
- package/Tab/Tab.mjs +18 -4
- package/Tab/tabClasses.d.mts +0 -4
- package/Tab/tabClasses.d.ts +0 -4
- package/Tab/tabClasses.js +1 -1
- package/Tab/tabClasses.mjs +1 -1
- package/TabScrollButton/TabScrollButton.d.mts +1 -1
- package/TabScrollButton/TabScrollButton.d.ts +1 -1
- package/TabScrollButton/TabScrollButton.js +6 -2
- package/TabScrollButton/TabScrollButton.mjs +6 -2
- package/TablePagination/TablePagination.d.mts +0 -24
- package/TablePagination/TablePagination.d.ts +0 -24
- package/TablePagination/TablePagination.js +1 -29
- package/TablePagination/TablePagination.mjs +1 -29
- package/TablePaginationActions/TablePaginationActions.d.mts +0 -10
- package/TablePaginationActions/TablePaginationActions.d.ts +0 -10
- package/TablePaginationActions/TablePaginationActions.js +2 -14
- package/TablePaginationActions/TablePaginationActions.mjs +2 -14
- package/TableSortLabel/TableSortLabel.js +6 -8
- package/TableSortLabel/TableSortLabel.mjs +6 -8
- package/TableSortLabel/tableSortLabelClasses.d.mts +0 -8
- package/TableSortLabel/tableSortLabelClasses.d.ts +0 -8
- package/TableSortLabel/tableSortLabelClasses.js +1 -1
- package/TableSortLabel/tableSortLabelClasses.mjs +1 -1
- package/Tabs/Tabs.js +33 -24
- package/Tabs/Tabs.mjs +32 -23
- package/Tabs/tabsClasses.d.mts +0 -6
- package/Tabs/tabsClasses.d.ts +0 -6
- package/Tabs/tabsClasses.js +1 -1
- package/Tabs/tabsClasses.mjs +1 -1
- package/ToggleButton/ToggleButton.js +1 -0
- package/ToggleButton/ToggleButton.mjs +1 -0
- package/ToggleButtonGroup/ToggleButtonGroup.js +1 -4
- package/ToggleButtonGroup/ToggleButtonGroup.mjs +1 -4
- package/ToggleButtonGroup/toggleButtonGroupClasses.d.mts +0 -8
- package/ToggleButtonGroup/toggleButtonGroupClasses.d.ts +0 -8
- package/ToggleButtonGroup/toggleButtonGroupClasses.js +1 -1
- package/ToggleButtonGroup/toggleButtonGroupClasses.mjs +1 -1
- package/Tooltip/Tooltip.d.mts +1 -1
- package/Tooltip/Tooltip.d.ts +1 -1
- package/Typography/Typography.d.mts +3 -3
- package/Typography/Typography.d.ts +3 -3
- package/Typography/Typography.js +2 -24
- package/Typography/Typography.mjs +3 -25
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/internal/SwitchBase.d.mts +2 -12
- package/internal/SwitchBase.d.ts +2 -12
- package/internal/SwitchBase.js +6 -17
- package/internal/SwitchBase.mjs +6 -17
- package/locale/psAF.js +1 -1
- package/locale/psAF.mjs +1 -1
- package/package.json +7 -7
- package/styles/createThemeWithVars.js +10 -9
- package/styles/createThemeWithVars.mjs +10 -9
- package/styles/stringifyTheme.js +1 -1
- package/styles/stringifyTheme.mjs +1 -1
- package/useAutocomplete/useAutocomplete.js +8 -0
- package/useAutocomplete/useAutocomplete.mjs +8 -0
- package/utils/createSvgIcon.d.mts +4 -2
- package/utils/createSvgIcon.d.ts +4 -2
- package/utils/createSvgIcon.js +6 -24
- package/utils/createSvgIcon.mjs +2 -24
- package/utils/focusWithVisible.js +24 -0
- package/utils/focusWithVisible.mjs +19 -0
- package/utils/index.d.mts +0 -1
- package/utils/index.d.ts +0 -1
- package/utils/index.js +0 -7
- package/utils/index.mjs +0 -1
- package/utils/useFocusableWhenDisabled.d.mts +30 -0
- package/utils/useFocusableWhenDisabled.d.ts +30 -0
- package/utils/useFocusableWhenDisabled.js +47 -0
- package/utils/useFocusableWhenDisabled.mjs +41 -0
- package/utils/useRovingTabIndex.d.mts +1 -2
- package/utils/useRovingTabIndex.d.ts +1 -2
- package/utils/useRovingTabIndex.js +25 -4
- package/utils/useRovingTabIndex.mjs +1 -2
- package/version/index.js +2 -2
- package/version/index.mjs +2 -2
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface UseButtonBaseParameters {
|
|
3
|
+
/**
|
|
4
|
+
* Whether the root should be treated as a native `<button>` for render-time semantics.
|
|
5
|
+
*/
|
|
6
|
+
nativeButton: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The explicit `nativeButton` value provided by the caller, if any.
|
|
9
|
+
*/
|
|
10
|
+
nativeButtonProp?: boolean | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the default rendered element is expected to be a native button when
|
|
13
|
+
* `nativeButton` was not explicitly provided.
|
|
14
|
+
* @default nativeButton
|
|
15
|
+
*/
|
|
16
|
+
internalNativeButton?: boolean | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Whether to perform additional checks in dev mode on whether the resolved element
|
|
19
|
+
* matches the default native or non-native button expectation.
|
|
20
|
+
* Set to `true` to allow hook callers bypass this check, e.g. when the `component`
|
|
21
|
+
* prop is a string.
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
allowInferredHostMismatch?: boolean | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* The disabled state of the component.
|
|
27
|
+
*/
|
|
28
|
+
disabled: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The `type` attribute for the element.
|
|
31
|
+
*/
|
|
32
|
+
type?: string | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Whether the element has a `formAction` attribute. When true, the hook
|
|
35
|
+
* will not default `type` to `'button'` for native buttons so the browser
|
|
36
|
+
* can use its natural submit behaviour.
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
39
|
+
hasFormAction?: boolean | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* The `tabIndex` attribute for the element.
|
|
42
|
+
* @default 0
|
|
43
|
+
*/
|
|
44
|
+
tabIndex?: number | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* When `true`, a disabled root can remain focusable.
|
|
47
|
+
* When `undefined`, the feature is not enabled.
|
|
48
|
+
*/
|
|
49
|
+
focusableWhenDisabled?: boolean | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* When `true`, calls `event.stopPropagation()` on click before the disabled guard runs.
|
|
52
|
+
* @default false
|
|
53
|
+
*/
|
|
54
|
+
stopEventPropagation?: boolean | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* An additional function that will run before the user's `onKeyDown`, e.g.
|
|
57
|
+
* to trigger the ripple effect in `<ButtonBase>`.
|
|
58
|
+
*/
|
|
59
|
+
onBeforeKeyDown?: React.KeyboardEventHandler<HTMLElement> | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* An additional function that will run before the user's `onKeyUp`, e.g.
|
|
62
|
+
* to control the ripple effect in `<ButtonBase>`.
|
|
63
|
+
*/
|
|
64
|
+
onBeforeKeyUp?: React.KeyboardEventHandler<HTMLElement> | undefined;
|
|
65
|
+
}
|
|
66
|
+
export interface ButtonBaseButtonProps {
|
|
67
|
+
role?: string | undefined;
|
|
68
|
+
'aria-disabled'?: boolean | undefined;
|
|
69
|
+
type?: string | undefined;
|
|
70
|
+
disabled?: boolean | undefined;
|
|
71
|
+
tabIndex: number;
|
|
72
|
+
}
|
|
73
|
+
export interface ButtonBaseExternalProps extends React.HTMLAttributes<any> {
|
|
74
|
+
'aria-disabled'?: boolean | undefined;
|
|
75
|
+
disabled?: boolean | undefined;
|
|
76
|
+
type?: string | undefined;
|
|
77
|
+
}
|
|
78
|
+
export interface ButtonBaseEventHandlers {
|
|
79
|
+
onClick: React.MouseEventHandler<HTMLElement>;
|
|
80
|
+
onKeyDown: React.KeyboardEventHandler<HTMLElement>;
|
|
81
|
+
onKeyUp: React.KeyboardEventHandler<HTMLElement>;
|
|
82
|
+
}
|
|
83
|
+
export interface UseButtonBaseReturnValue {
|
|
84
|
+
/**
|
|
85
|
+
* @param externalProps additional props for the button
|
|
86
|
+
* @returns props that should be spread on the button
|
|
87
|
+
*/
|
|
88
|
+
getButtonProps: <ExternalProps extends ButtonBaseExternalProps = ButtonBaseExternalProps>(externalProps?: ExternalProps) => Omit<ExternalProps, keyof ButtonBaseEventHandlers> & ButtonBaseButtonProps & ButtonBaseEventHandlers;
|
|
89
|
+
rootRef: React.RefObject<HTMLElement | null>;
|
|
90
|
+
}
|
|
91
|
+
export default function useButtonBase(parameters: UseButtonBaseParameters): UseButtonBaseReturnValue;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface UseButtonBaseParameters {
|
|
3
|
+
/**
|
|
4
|
+
* Whether the root should be treated as a native `<button>` for render-time semantics.
|
|
5
|
+
*/
|
|
6
|
+
nativeButton: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The explicit `nativeButton` value provided by the caller, if any.
|
|
9
|
+
*/
|
|
10
|
+
nativeButtonProp?: boolean | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the default rendered element is expected to be a native button when
|
|
13
|
+
* `nativeButton` was not explicitly provided.
|
|
14
|
+
* @default nativeButton
|
|
15
|
+
*/
|
|
16
|
+
internalNativeButton?: boolean | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Whether to perform additional checks in dev mode on whether the resolved element
|
|
19
|
+
* matches the default native or non-native button expectation.
|
|
20
|
+
* Set to `true` to allow hook callers bypass this check, e.g. when the `component`
|
|
21
|
+
* prop is a string.
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
allowInferredHostMismatch?: boolean | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* The disabled state of the component.
|
|
27
|
+
*/
|
|
28
|
+
disabled: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The `type` attribute for the element.
|
|
31
|
+
*/
|
|
32
|
+
type?: string | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Whether the element has a `formAction` attribute. When true, the hook
|
|
35
|
+
* will not default `type` to `'button'` for native buttons so the browser
|
|
36
|
+
* can use its natural submit behaviour.
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
39
|
+
hasFormAction?: boolean | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* The `tabIndex` attribute for the element.
|
|
42
|
+
* @default 0
|
|
43
|
+
*/
|
|
44
|
+
tabIndex?: number | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* When `true`, a disabled root can remain focusable.
|
|
47
|
+
* When `undefined`, the feature is not enabled.
|
|
48
|
+
*/
|
|
49
|
+
focusableWhenDisabled?: boolean | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* When `true`, calls `event.stopPropagation()` on click before the disabled guard runs.
|
|
52
|
+
* @default false
|
|
53
|
+
*/
|
|
54
|
+
stopEventPropagation?: boolean | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* An additional function that will run before the user's `onKeyDown`, e.g.
|
|
57
|
+
* to trigger the ripple effect in `<ButtonBase>`.
|
|
58
|
+
*/
|
|
59
|
+
onBeforeKeyDown?: React.KeyboardEventHandler<HTMLElement> | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* An additional function that will run before the user's `onKeyUp`, e.g.
|
|
62
|
+
* to control the ripple effect in `<ButtonBase>`.
|
|
63
|
+
*/
|
|
64
|
+
onBeforeKeyUp?: React.KeyboardEventHandler<HTMLElement> | undefined;
|
|
65
|
+
}
|
|
66
|
+
export interface ButtonBaseButtonProps {
|
|
67
|
+
role?: string | undefined;
|
|
68
|
+
'aria-disabled'?: boolean | undefined;
|
|
69
|
+
type?: string | undefined;
|
|
70
|
+
disabled?: boolean | undefined;
|
|
71
|
+
tabIndex: number;
|
|
72
|
+
}
|
|
73
|
+
export interface ButtonBaseExternalProps extends React.HTMLAttributes<any> {
|
|
74
|
+
'aria-disabled'?: boolean | undefined;
|
|
75
|
+
disabled?: boolean | undefined;
|
|
76
|
+
type?: string | undefined;
|
|
77
|
+
}
|
|
78
|
+
export interface ButtonBaseEventHandlers {
|
|
79
|
+
onClick: React.MouseEventHandler<HTMLElement>;
|
|
80
|
+
onKeyDown: React.KeyboardEventHandler<HTMLElement>;
|
|
81
|
+
onKeyUp: React.KeyboardEventHandler<HTMLElement>;
|
|
82
|
+
}
|
|
83
|
+
export interface UseButtonBaseReturnValue {
|
|
84
|
+
/**
|
|
85
|
+
* @param externalProps additional props for the button
|
|
86
|
+
* @returns props that should be spread on the button
|
|
87
|
+
*/
|
|
88
|
+
getButtonProps: <ExternalProps extends ButtonBaseExternalProps = ButtonBaseExternalProps>(externalProps?: ExternalProps) => Omit<ExternalProps, keyof ButtonBaseEventHandlers> & ButtonBaseButtonProps & ButtonBaseEventHandlers;
|
|
89
|
+
rootRef: React.RefObject<HTMLElement | null>;
|
|
90
|
+
}
|
|
91
|
+
export default function useButtonBase(parameters: UseButtonBaseParameters): UseButtonBaseReturnValue;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.default = useButtonBase;
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _useFocusableWhenDisabled = _interopRequireDefault(require("../utils/useFocusableWhenDisabled"));
|
|
12
|
+
const EMPTY = {};
|
|
13
|
+
function useButtonBase(parameters) {
|
|
14
|
+
const {
|
|
15
|
+
nativeButton,
|
|
16
|
+
nativeButtonProp,
|
|
17
|
+
internalNativeButton = nativeButton,
|
|
18
|
+
allowInferredHostMismatch = false,
|
|
19
|
+
disabled,
|
|
20
|
+
type,
|
|
21
|
+
hasFormAction = false,
|
|
22
|
+
tabIndex = 0,
|
|
23
|
+
focusableWhenDisabled: focusableWhenDisabledParam,
|
|
24
|
+
stopEventPropagation = false,
|
|
25
|
+
onBeforeKeyDown,
|
|
26
|
+
onBeforeKeyUp
|
|
27
|
+
} = parameters;
|
|
28
|
+
const rootRef = React.useRef(null);
|
|
29
|
+
const focusableWhenDisabled = focusableWhenDisabledParam === true;
|
|
30
|
+
const focusableWhenDisabledProps = (0, _useFocusableWhenDisabled.default)({
|
|
31
|
+
focusableWhenDisabled,
|
|
32
|
+
disabled,
|
|
33
|
+
isNativeButton: nativeButton,
|
|
34
|
+
tabIndex
|
|
35
|
+
});
|
|
36
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
37
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
38
|
+
React.useEffect(() => {
|
|
39
|
+
const root = rootRef.current;
|
|
40
|
+
if (root == null) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const isButtonTag = root.tagName === 'BUTTON';
|
|
44
|
+
if (nativeButtonProp !== undefined) {
|
|
45
|
+
if (nativeButtonProp && !isButtonTag) {
|
|
46
|
+
const message = 'MUI: A component that acts as a button expected a native <button> because the ' + '`nativeButton` prop is true. Rendering a non-<button> removes native button ' + 'semantics, which can impact forms and accessibility. Render a real <button> ' + 'or set `nativeButton` to `false`.';
|
|
47
|
+
console.error(message);
|
|
48
|
+
}
|
|
49
|
+
if (!nativeButtonProp && isButtonTag) {
|
|
50
|
+
const message = 'MUI: A component that acts as a button expected a non-<button> because the `nativeButton` ' + 'prop is false. Rendering a <button> keeps native behavior while additionally applies ' + 'non-native attributes and handlers, which can add unintended extra attributes (such ' + 'as `role` or `aria-disabled`). Render a non-<button> such as <div>, or set ' + '`nativeButton` to `true`.';
|
|
51
|
+
console.error(message);
|
|
52
|
+
}
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (allowInferredHostMismatch) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// warn when expecting a native <button> element but a non-string `component` prop resolved to a non-button element
|
|
60
|
+
if (internalNativeButton && !isButtonTag) {
|
|
61
|
+
const message = 'MUI: A component rendering a native <button> resolved to a non-<button> element, ' + 'but `nativeButton={false}` was not specified and the resolved root is a non-<button>. ' + 'When rendering a custom component, set `nativeButton={false}` explicitly or render a <button> element.';
|
|
62
|
+
console.error(message);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// warn when expecting a non-button but a non-string `component` prop resolved to a native <button> element
|
|
66
|
+
if (!internalNativeButton && isButtonTag) {
|
|
67
|
+
const message = 'MUI: A component that acts as a non-native button resolved to a native <button> element, ' + 'but `nativeButton={true}` was not specified. ' + 'When rendering a custom component, set `nativeButton={true}` explicitly or render a non-<button> element.';
|
|
68
|
+
console.error(message);
|
|
69
|
+
}
|
|
70
|
+
}, [allowInferredHostMismatch, internalNativeButton, nativeButtonProp]);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// A helper for event handlers to determine whether to use browser-defined keyboard activation
|
|
74
|
+
// for native elements like <button> and <a href>, or synthesize Enter/Space clicks for non-native
|
|
75
|
+
// elements like `<div role="button">`.
|
|
76
|
+
// This is UNSAFE TO USE outside of event handers, e.g. in render.
|
|
77
|
+
const hasNativeKeyboardActivation = React.useCallback(() => {
|
|
78
|
+
const root = rootRef.current;
|
|
79
|
+
if (root == null) {
|
|
80
|
+
return nativeButton;
|
|
81
|
+
}
|
|
82
|
+
if (root.tagName === 'BUTTON') {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Although this hook is not intended for links, this check is for
|
|
87
|
+
// backward compatibility with `<ButtonBase href="#" />` since ButtonBase
|
|
88
|
+
// uses the returned event handlers.
|
|
89
|
+
return Boolean(root.tagName === 'A' && root.href);
|
|
90
|
+
}, [nativeButton]);
|
|
91
|
+
const buttonProps = React.useMemo(() => {
|
|
92
|
+
const resolvedButtonProps = focusableWhenDisabled ? {} : {
|
|
93
|
+
tabIndex: disabled ? -1 : tabIndex
|
|
94
|
+
};
|
|
95
|
+
if (nativeButton) {
|
|
96
|
+
resolvedButtonProps.type = type === undefined && !hasFormAction ? 'button' : type;
|
|
97
|
+
if (!focusableWhenDisabled) {
|
|
98
|
+
resolvedButtonProps.disabled = disabled;
|
|
99
|
+
}
|
|
100
|
+
} else {
|
|
101
|
+
resolvedButtonProps.role = 'button';
|
|
102
|
+
if (!focusableWhenDisabled && disabled) {
|
|
103
|
+
resolvedButtonProps['aria-disabled'] = disabled;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (focusableWhenDisabled) {
|
|
107
|
+
return {
|
|
108
|
+
...resolvedButtonProps,
|
|
109
|
+
...focusableWhenDisabledProps
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
return resolvedButtonProps;
|
|
113
|
+
}, [disabled, focusableWhenDisabled, focusableWhenDisabledProps, hasFormAction, nativeButton, tabIndex, type]);
|
|
114
|
+
const getButtonProps = React.useCallback((externalProps = EMPTY) => {
|
|
115
|
+
const {
|
|
116
|
+
onClick: externalOnClick,
|
|
117
|
+
onKeyDown: externalOnKeyDown,
|
|
118
|
+
onKeyUp: externalOnKeyUp,
|
|
119
|
+
...otherExternalProps
|
|
120
|
+
} = externalProps;
|
|
121
|
+
const handleClick = event => {
|
|
122
|
+
if (stopEventPropagation) {
|
|
123
|
+
event.stopPropagation();
|
|
124
|
+
}
|
|
125
|
+
if (disabled) {
|
|
126
|
+
event.preventDefault();
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
externalOnClick?.(event);
|
|
130
|
+
};
|
|
131
|
+
const handleKeyDown = event => {
|
|
132
|
+
if (focusableWhenDisabled) {
|
|
133
|
+
focusableWhenDisabledProps.onKeyDown(event);
|
|
134
|
+
}
|
|
135
|
+
if (disabled) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
onBeforeKeyDown?.(event);
|
|
139
|
+
externalOnKeyDown?.(event);
|
|
140
|
+
if (event.target !== event.currentTarget || hasNativeKeyboardActivation()) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (event.key === ' ') {
|
|
144
|
+
event.preventDefault();
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (event.key === 'Enter') {
|
|
148
|
+
event.preventDefault();
|
|
149
|
+
event.currentTarget.click();
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
const handleKeyUp = event => {
|
|
153
|
+
if (disabled) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
onBeforeKeyUp?.(event);
|
|
157
|
+
externalOnKeyUp?.(event);
|
|
158
|
+
if (event.target === event.currentTarget && !hasNativeKeyboardActivation() && event.key === ' ' && !event.defaultPrevented) {
|
|
159
|
+
event.currentTarget.click();
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
return {
|
|
163
|
+
...buttonProps,
|
|
164
|
+
...otherExternalProps,
|
|
165
|
+
onClick: handleClick,
|
|
166
|
+
onKeyDown: handleKeyDown,
|
|
167
|
+
onKeyUp: handleKeyUp
|
|
168
|
+
};
|
|
169
|
+
}, [buttonProps, disabled, focusableWhenDisabled, focusableWhenDisabledProps, hasNativeKeyboardActivation, onBeforeKeyDown, onBeforeKeyUp, stopEventPropagation]);
|
|
170
|
+
return {
|
|
171
|
+
getButtonProps,
|
|
172
|
+
rootRef
|
|
173
|
+
};
|
|
174
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import useFocusableWhenDisabled from "../utils/useFocusableWhenDisabled.mjs";
|
|
5
|
+
const EMPTY = {};
|
|
6
|
+
export default function useButtonBase(parameters) {
|
|
7
|
+
const {
|
|
8
|
+
nativeButton,
|
|
9
|
+
nativeButtonProp,
|
|
10
|
+
internalNativeButton = nativeButton,
|
|
11
|
+
allowInferredHostMismatch = false,
|
|
12
|
+
disabled,
|
|
13
|
+
type,
|
|
14
|
+
hasFormAction = false,
|
|
15
|
+
tabIndex = 0,
|
|
16
|
+
focusableWhenDisabled: focusableWhenDisabledParam,
|
|
17
|
+
stopEventPropagation = false,
|
|
18
|
+
onBeforeKeyDown,
|
|
19
|
+
onBeforeKeyUp
|
|
20
|
+
} = parameters;
|
|
21
|
+
const rootRef = React.useRef(null);
|
|
22
|
+
const focusableWhenDisabled = focusableWhenDisabledParam === true;
|
|
23
|
+
const focusableWhenDisabledProps = useFocusableWhenDisabled({
|
|
24
|
+
focusableWhenDisabled,
|
|
25
|
+
disabled,
|
|
26
|
+
isNativeButton: nativeButton,
|
|
27
|
+
tabIndex
|
|
28
|
+
});
|
|
29
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
30
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
31
|
+
React.useEffect(() => {
|
|
32
|
+
const root = rootRef.current;
|
|
33
|
+
if (root == null) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const isButtonTag = root.tagName === 'BUTTON';
|
|
37
|
+
if (nativeButtonProp !== undefined) {
|
|
38
|
+
if (nativeButtonProp && !isButtonTag) {
|
|
39
|
+
const message = 'MUI: A component that acts as a button expected a native <button> because the ' + '`nativeButton` prop is true. Rendering a non-<button> removes native button ' + 'semantics, which can impact forms and accessibility. Render a real <button> ' + 'or set `nativeButton` to `false`.';
|
|
40
|
+
console.error(message);
|
|
41
|
+
}
|
|
42
|
+
if (!nativeButtonProp && isButtonTag) {
|
|
43
|
+
const message = 'MUI: A component that acts as a button expected a non-<button> because the `nativeButton` ' + 'prop is false. Rendering a <button> keeps native behavior while additionally applies ' + 'non-native attributes and handlers, which can add unintended extra attributes (such ' + 'as `role` or `aria-disabled`). Render a non-<button> such as <div>, or set ' + '`nativeButton` to `true`.';
|
|
44
|
+
console.error(message);
|
|
45
|
+
}
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (allowInferredHostMismatch) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// warn when expecting a native <button> element but a non-string `component` prop resolved to a non-button element
|
|
53
|
+
if (internalNativeButton && !isButtonTag) {
|
|
54
|
+
const message = 'MUI: A component rendering a native <button> resolved to a non-<button> element, ' + 'but `nativeButton={false}` was not specified and the resolved root is a non-<button>. ' + 'When rendering a custom component, set `nativeButton={false}` explicitly or render a <button> element.';
|
|
55
|
+
console.error(message);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// warn when expecting a non-button but a non-string `component` prop resolved to a native <button> element
|
|
59
|
+
if (!internalNativeButton && isButtonTag) {
|
|
60
|
+
const message = 'MUI: A component that acts as a non-native button resolved to a native <button> element, ' + 'but `nativeButton={true}` was not specified. ' + 'When rendering a custom component, set `nativeButton={true}` explicitly or render a non-<button> element.';
|
|
61
|
+
console.error(message);
|
|
62
|
+
}
|
|
63
|
+
}, [allowInferredHostMismatch, internalNativeButton, nativeButtonProp]);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// A helper for event handlers to determine whether to use browser-defined keyboard activation
|
|
67
|
+
// for native elements like <button> and <a href>, or synthesize Enter/Space clicks for non-native
|
|
68
|
+
// elements like `<div role="button">`.
|
|
69
|
+
// This is UNSAFE TO USE outside of event handers, e.g. in render.
|
|
70
|
+
const hasNativeKeyboardActivation = React.useCallback(() => {
|
|
71
|
+
const root = rootRef.current;
|
|
72
|
+
if (root == null) {
|
|
73
|
+
return nativeButton;
|
|
74
|
+
}
|
|
75
|
+
if (root.tagName === 'BUTTON') {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Although this hook is not intended for links, this check is for
|
|
80
|
+
// backward compatibility with `<ButtonBase href="#" />` since ButtonBase
|
|
81
|
+
// uses the returned event handlers.
|
|
82
|
+
return Boolean(root.tagName === 'A' && root.href);
|
|
83
|
+
}, [nativeButton]);
|
|
84
|
+
const buttonProps = React.useMemo(() => {
|
|
85
|
+
const resolvedButtonProps = focusableWhenDisabled ? {} : {
|
|
86
|
+
tabIndex: disabled ? -1 : tabIndex
|
|
87
|
+
};
|
|
88
|
+
if (nativeButton) {
|
|
89
|
+
resolvedButtonProps.type = type === undefined && !hasFormAction ? 'button' : type;
|
|
90
|
+
if (!focusableWhenDisabled) {
|
|
91
|
+
resolvedButtonProps.disabled = disabled;
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
resolvedButtonProps.role = 'button';
|
|
95
|
+
if (!focusableWhenDisabled && disabled) {
|
|
96
|
+
resolvedButtonProps['aria-disabled'] = disabled;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (focusableWhenDisabled) {
|
|
100
|
+
return {
|
|
101
|
+
...resolvedButtonProps,
|
|
102
|
+
...focusableWhenDisabledProps
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
return resolvedButtonProps;
|
|
106
|
+
}, [disabled, focusableWhenDisabled, focusableWhenDisabledProps, hasFormAction, nativeButton, tabIndex, type]);
|
|
107
|
+
const getButtonProps = React.useCallback((externalProps = EMPTY) => {
|
|
108
|
+
const {
|
|
109
|
+
onClick: externalOnClick,
|
|
110
|
+
onKeyDown: externalOnKeyDown,
|
|
111
|
+
onKeyUp: externalOnKeyUp,
|
|
112
|
+
...otherExternalProps
|
|
113
|
+
} = externalProps;
|
|
114
|
+
const handleClick = event => {
|
|
115
|
+
if (stopEventPropagation) {
|
|
116
|
+
event.stopPropagation();
|
|
117
|
+
}
|
|
118
|
+
if (disabled) {
|
|
119
|
+
event.preventDefault();
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
externalOnClick?.(event);
|
|
123
|
+
};
|
|
124
|
+
const handleKeyDown = event => {
|
|
125
|
+
if (focusableWhenDisabled) {
|
|
126
|
+
focusableWhenDisabledProps.onKeyDown(event);
|
|
127
|
+
}
|
|
128
|
+
if (disabled) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
onBeforeKeyDown?.(event);
|
|
132
|
+
externalOnKeyDown?.(event);
|
|
133
|
+
if (event.target !== event.currentTarget || hasNativeKeyboardActivation()) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (event.key === ' ') {
|
|
137
|
+
event.preventDefault();
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (event.key === 'Enter') {
|
|
141
|
+
event.preventDefault();
|
|
142
|
+
event.currentTarget.click();
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
const handleKeyUp = event => {
|
|
146
|
+
if (disabled) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
onBeforeKeyUp?.(event);
|
|
150
|
+
externalOnKeyUp?.(event);
|
|
151
|
+
if (event.target === event.currentTarget && !hasNativeKeyboardActivation() && event.key === ' ' && !event.defaultPrevented) {
|
|
152
|
+
event.currentTarget.click();
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
return {
|
|
156
|
+
...buttonProps,
|
|
157
|
+
...otherExternalProps,
|
|
158
|
+
onClick: handleClick,
|
|
159
|
+
onKeyDown: handleKeyDown,
|
|
160
|
+
onKeyUp: handleKeyUp
|
|
161
|
+
};
|
|
162
|
+
}, [buttonProps, disabled, focusableWhenDisabled, focusableWhenDisabledProps, hasNativeKeyboardActivation, onBeforeKeyDown, onBeforeKeyUp, stopEventPropagation]);
|
|
163
|
+
return {
|
|
164
|
+
getButtonProps,
|
|
165
|
+
rootRef
|
|
166
|
+
};
|
|
167
|
+
}
|
|
@@ -27,14 +27,6 @@ const overridesResolver = (props, styles) => {
|
|
|
27
27
|
} = props;
|
|
28
28
|
return [{
|
|
29
29
|
[`& .${_buttonGroupClasses.default.grouped}`]: styles.grouped
|
|
30
|
-
}, {
|
|
31
|
-
[`& .${_buttonGroupClasses.default.grouped}`]: styles[`grouped${(0, _capitalize.default)(ownerState.orientation)}`]
|
|
32
|
-
}, {
|
|
33
|
-
[`& .${_buttonGroupClasses.default.grouped}`]: styles[`grouped${(0, _capitalize.default)(ownerState.variant)}`]
|
|
34
|
-
}, {
|
|
35
|
-
[`& .${_buttonGroupClasses.default.grouped}`]: styles[`grouped${(0, _capitalize.default)(ownerState.variant)}${(0, _capitalize.default)(ownerState.orientation)}`]
|
|
36
|
-
}, {
|
|
37
|
-
[`& .${_buttonGroupClasses.default.grouped}`]: styles[`grouped${(0, _capitalize.default)(ownerState.variant)}${(0, _capitalize.default)(ownerState.color)}`]
|
|
38
30
|
}, {
|
|
39
31
|
[`& .${_buttonGroupClasses.default.firstButton}`]: styles.firstButton
|
|
40
32
|
}, {
|
|
@@ -55,7 +47,7 @@ const useUtilityClasses = ownerState => {
|
|
|
55
47
|
} = ownerState;
|
|
56
48
|
const slots = {
|
|
57
49
|
root: ['root', variant, orientation, fullWidth && 'fullWidth', disableElevation && 'disableElevation', `color${(0, _capitalize.default)(color)}`],
|
|
58
|
-
grouped: ['grouped',
|
|
50
|
+
grouped: ['grouped', disabled && 'disabled'],
|
|
59
51
|
firstButton: ['firstButton'],
|
|
60
52
|
lastButton: ['lastButton'],
|
|
61
53
|
middleButton: ['middleButton']
|
|
@@ -20,14 +20,6 @@ const overridesResolver = (props, styles) => {
|
|
|
20
20
|
} = props;
|
|
21
21
|
return [{
|
|
22
22
|
[`& .${buttonGroupClasses.grouped}`]: styles.grouped
|
|
23
|
-
}, {
|
|
24
|
-
[`& .${buttonGroupClasses.grouped}`]: styles[`grouped${capitalize(ownerState.orientation)}`]
|
|
25
|
-
}, {
|
|
26
|
-
[`& .${buttonGroupClasses.grouped}`]: styles[`grouped${capitalize(ownerState.variant)}`]
|
|
27
|
-
}, {
|
|
28
|
-
[`& .${buttonGroupClasses.grouped}`]: styles[`grouped${capitalize(ownerState.variant)}${capitalize(ownerState.orientation)}`]
|
|
29
|
-
}, {
|
|
30
|
-
[`& .${buttonGroupClasses.grouped}`]: styles[`grouped${capitalize(ownerState.variant)}${capitalize(ownerState.color)}`]
|
|
31
23
|
}, {
|
|
32
24
|
[`& .${buttonGroupClasses.firstButton}`]: styles.firstButton
|
|
33
25
|
}, {
|
|
@@ -48,7 +40,7 @@ const useUtilityClasses = ownerState => {
|
|
|
48
40
|
} = ownerState;
|
|
49
41
|
const slots = {
|
|
50
42
|
root: ['root', variant, orientation, fullWidth && 'fullWidth', disableElevation && 'disableElevation', `color${capitalize(color)}`],
|
|
51
|
-
grouped: ['grouped',
|
|
43
|
+
grouped: ['grouped', disabled && 'disabled'],
|
|
52
44
|
firstButton: ['firstButton'],
|
|
53
45
|
lastButton: ['lastButton'],
|
|
54
46
|
middleButton: ['middleButton']
|
|
@@ -25,74 +25,6 @@ export interface ButtonGroupClasses {
|
|
|
25
25
|
colorPrimary: string;
|
|
26
26
|
/** Styles applied to the root element if `color="secondary"` */
|
|
27
27
|
colorSecondary: string;
|
|
28
|
-
/** Styles applied to the children if `orientation="horizontal"`.
|
|
29
|
-
* @deprecated Combine the [.MuiButtonGroup-horizontal](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-horizontal) and [.MuiButtonGroup-grouped](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-grouped) classes instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
30
|
-
*/
|
|
31
|
-
groupedHorizontal: string;
|
|
32
|
-
/** Styles applied to the children if `orientation="vertical"`.
|
|
33
|
-
* @deprecated Combine the [.MuiButtonGroup-vertical](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-vertical) and [.MuiButtonGroup-grouped](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-grouped) classes instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
34
|
-
*/
|
|
35
|
-
groupedVertical: string;
|
|
36
|
-
/** Styles applied to the children if `variant="text"`.
|
|
37
|
-
* @deprecated Combine the [.MuiButtonGroup-text](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-text) and [.MuiButtonGroup-grouped](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-grouped) classes instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
38
|
-
*/
|
|
39
|
-
groupedText: string;
|
|
40
|
-
/** Styles applied to the children if `variant="text"` and `orientation="horizontal"`.
|
|
41
|
-
* @deprecated Combine the [.MuiButtonGroup-text](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-text) , [.MuiButtonGroup-horizontal](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-horizontal) and [.MuiButtonGroup-grouped](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-grouped) classes instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
42
|
-
*/
|
|
43
|
-
groupedTextHorizontal: string;
|
|
44
|
-
/** Styles applied to the children if `variant="text"` and `orientation="vertical"`.
|
|
45
|
-
* @deprecated Combine the [.MuiButtonGroup-text](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-text) , [.MuiButtonGroup-vertical](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-vertical) and [.MuiButtonGroup-grouped](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-grouped) classes instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
46
|
-
*/
|
|
47
|
-
groupedTextVertical: string;
|
|
48
|
-
/** Styles applied to the children if `variant="text"` and `color="primary"`.
|
|
49
|
-
* @deprecated Combine the [.MuiButtonGroup-text](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-text) , [.MuiButtonGroup-colorPrimary](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-colorPrimary) and [.MuiButtonGroup-grouped](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-grouped) classes instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
50
|
-
*/
|
|
51
|
-
groupedTextPrimary: string;
|
|
52
|
-
/** Styles applied to the children if `variant="text"` and `color="secondary"`.
|
|
53
|
-
* @deprecated Combine the [.MuiButtonGroup-text](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-text) , [.MuiButtonGroup-colorSecondary](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-colorSecondary) and [.MuiButtonGroup-grouped](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-grouped) classes instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
54
|
-
*/
|
|
55
|
-
groupedTextSecondary: string;
|
|
56
|
-
/** Styles applied to the children if `variant="outlined"`.
|
|
57
|
-
* @deprecated Combine the [.MuiButtonGroup-outlined](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-outlined) and [.MuiButtonGroup-grouped](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-grouped) classes instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
58
|
-
*/
|
|
59
|
-
groupedOutlined: string;
|
|
60
|
-
/** Styles applied to the children if `variant="outlined"` and `orientation="horizontal"`.
|
|
61
|
-
* @deprecated Combine the [.MuiButtonGroup-outlined](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-outlined) , [.MuiButtonGroup-horizontal](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-horizontal) and [.MuiButtonGroup-grouped](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-grouped) classes instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
62
|
-
*/
|
|
63
|
-
groupedOutlinedHorizontal: string;
|
|
64
|
-
/** Styles applied to the children if `variant="outlined"` and `orientation="vertical"`.
|
|
65
|
-
* @deprecated Combine the [.MuiButtonGroup-outlined](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-outlined) , [.MuiButtonGroup-vertical](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-vertical) and [.MuiButtonGroup-grouped](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-grouped) classes instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
66
|
-
*/
|
|
67
|
-
groupedOutlinedVertical: string;
|
|
68
|
-
/** Styles applied to the children if `variant="outlined"` and `color="primary"`.
|
|
69
|
-
* @deprecated Combine the [.MuiButtonGroup-outlined](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-outlined) , [.MuiButtonGroup-colorPrimary](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-colorPrimary) and [.MuiButtonGroup-grouped](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-grouped) classes instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
70
|
-
*/
|
|
71
|
-
groupedOutlinedPrimary: string;
|
|
72
|
-
/** Styles applied to the children if `variant="outlined"` and `color="secondary"`.
|
|
73
|
-
* @deprecated Combine the [.MuiButtonGroup-outlined](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-outlined) , [.MuiButtonGroup-colorSecondary](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-colorSecondary) and [.MuiButtonGroup-grouped](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-grouped) classes instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
74
|
-
*/
|
|
75
|
-
groupedOutlinedSecondary: string;
|
|
76
|
-
/** Styles applied to the children if `variant="contained"`.
|
|
77
|
-
* @deprecated Combine the [.MuiButtonGroup-contained](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-contained) and [.MuiButtonGroup-grouped](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-grouped) classes instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
78
|
-
*/
|
|
79
|
-
groupedContained: string;
|
|
80
|
-
/** Styles applied to the children if `variant="contained"` and `orientation="horizontal"`.
|
|
81
|
-
* @deprecated Combine the [.MuiButtonGroup-contained](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-contained) , [.MuiButtonGroup-horizontal](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-horizontal) and [.MuiButtonGroup-grouped](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-grouped) classes instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
82
|
-
*/
|
|
83
|
-
groupedContainedHorizontal: string;
|
|
84
|
-
/** Styles applied to the children if `variant="contained"` and `orientation="vertical"`.
|
|
85
|
-
* @deprecated Combine the [.MuiButtonGroup-contained](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-contained) , [.MuiButtonGroup-vertical](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-vertical) and [.MuiButtonGroup-grouped](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-grouped) classes instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
86
|
-
*/
|
|
87
|
-
groupedContainedVertical: string;
|
|
88
|
-
/** Styles applied to the children if `variant="contained"` and `color="primary"`.
|
|
89
|
-
* @deprecated Combine the [.MuiButtonGroup-contained](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-contained) , [.MuiButtonGroup-colorPrimary](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-colorPrimary) and [.MuiButtonGroup-grouped](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-grouped) classes instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
90
|
-
*/
|
|
91
|
-
groupedContainedPrimary: string;
|
|
92
|
-
/** Styles applied to the children if `variant="contained"` and `color="secondary"`.
|
|
93
|
-
* @deprecated Combine the [.MuiButtonGroup-contained](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-contained) , [.MuiButtonGroup-colorSecondary](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-colorSecondary) and [.MuiButtonGroup-grouped](/material-ui/api/button-group/#button-group-classes-MuiButtonGroup-grouped) classes instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
94
|
-
*/
|
|
95
|
-
groupedContainedSecondary: string;
|
|
96
28
|
/** Styles applied to the last button in the button group. */
|
|
97
29
|
lastButton: string;
|
|
98
30
|
/** Styles applied to buttons in the middle of the button group. */
|