neue Homepage auf react basis

This commit is contained in:
2026-08-07 21:39:30 +02:00
parent 164bdd19ad
commit ee89442c04
52191 changed files with 1230242 additions and 58 deletions
@@ -0,0 +1,13 @@
import * as React from 'react';
interface RovingToggleButtonChildProps {
ref?: React.Ref<HTMLElement> | undefined;
tabIndex?: number | undefined;
}
interface RovingToggleButtonProps {
children: React.ReactElement<RovingToggleButtonChildProps>;
disabled?: boolean | undefined;
selected?: boolean | undefined;
value: unknown;
}
declare const _default: React.ForwardRefExoticComponent<RovingToggleButtonProps & React.RefAttributes<HTMLElement>>;
export default _default;
@@ -0,0 +1,13 @@
import * as React from 'react';
interface RovingToggleButtonChildProps {
ref?: React.Ref<HTMLElement> | undefined;
tabIndex?: number | undefined;
}
interface RovingToggleButtonProps {
children: React.ReactElement<RovingToggleButtonChildProps>;
disabled?: boolean | undefined;
selected?: boolean | undefined;
value: unknown;
}
declare const _default: React.ForwardRefExoticComponent<RovingToggleButtonProps & React.RefAttributes<HTMLElement>>;
export default _default;
+37
View File
@@ -0,0 +1,37 @@
"use strict";
'use client';
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
var _useRovingTabIndex = require("../utils/useRovingTabIndex");
function RovingToggleButton(props, ref) {
const {
children,
disabled = false,
selected = false,
value
} = props;
const rovingContext = (0, _useRovingTabIndex.useRovingTabIndexContext)();
const rovingItemProps = (0, _useRovingTabIndex.useRovingTabIndexItem)({
id: value,
ref,
disabled,
selected
});
// On the server, and on the first client render before registration effects run,
// the roving item map is still empty. In that window, fall back to `tabIndex={0}`
// for the selected toggle button so the rendered markup is immediately keyboard-accessible
// and hydration stays consistent until item registration takes over.
const shouldUseSelectedTabStopFallback = rovingContext.getItemMap().size === 0 && selected;
const tabIndex = shouldUseSelectedTabStopFallback ? 0 : rovingItemProps.tabIndex;
return /*#__PURE__*/React.cloneElement(React.Children.only(children), {
...rovingItemProps,
tabIndex: children.props.tabIndex ?? tabIndex
});
}
var _default = exports.default = /*#__PURE__*/React.forwardRef(RovingToggleButton);
+31
View File
@@ -0,0 +1,31 @@
'use client';
import * as React from 'react';
import { useRovingTabIndexContext, useRovingTabIndexItem } from "../utils/useRovingTabIndex.mjs";
function RovingToggleButton(props, ref) {
const {
children,
disabled = false,
selected = false,
value
} = props;
const rovingContext = useRovingTabIndexContext();
const rovingItemProps = useRovingTabIndexItem({
id: value,
ref,
disabled,
selected
});
// On the server, and on the first client render before registration effects run,
// the roving item map is still empty. In that window, fall back to `tabIndex={0}`
// for the selected toggle button so the rendered markup is immediately keyboard-accessible
// and hydration stays consistent until item registration takes over.
const shouldUseSelectedTabStopFallback = rovingContext.getItemMap().size === 0 && selected;
const tabIndex = shouldUseSelectedTabStopFallback ? 0 : rovingItemProps.tabIndex;
return /*#__PURE__*/React.cloneElement(React.Children.only(children), {
...rovingItemProps,
tabIndex: children.props.tabIndex ?? tabIndex
});
}
export default /*#__PURE__*/React.forwardRef(RovingToggleButton);
+95
View File
@@ -0,0 +1,95 @@
import { SxProps } from '@mui/system';
import { OverridableStringUnion } from '@mui/types';
import * as React from 'react';
import { Theme } from "../styles/index.mjs";
import { ExtendButtonBase, ExtendButtonBaseTypeMap } from "../ButtonBase/index.mjs";
import { OverrideProps } from "../OverridableComponent/index.mjs";
import { ToggleButtonClasses } from "./toggleButtonClasses.mjs";
export interface ToggleButtonPropsSizeOverrides {}
export interface ToggleButtonPropsColorOverrides {}
export interface ToggleButtonOwnProps {
/**
* The content of the component.
*/
children?: React.ReactNode;
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<ToggleButtonClasses> | undefined;
/**
* The color of the button when it is in an active state.
* It supports both default and custom theme colors, which can be added as shown in the
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
* @default 'standard'
*/
color?: OverridableStringUnion<'standard' | 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning', ToggleButtonPropsColorOverrides> | undefined;
/**
* If `true`, the component is disabled.
* @default false
*/
disabled?: boolean | undefined;
/**
* If `true`, the keyboard focus ripple is disabled.
* @default false
*/
disableFocusRipple?: boolean | undefined;
/**
* If `true`, the button will take up the full width of its container.
* @default false
*/
fullWidth?: boolean | undefined;
/**
* Callback fired when the state changes.
*
* @param {React.MouseEvent<HTMLElement>} event The event source of the callback.
* @param {any} value of the selected button.
*/
onChange?: ((event: React.MouseEvent<HTMLElement>, value: any) => void) | undefined;
/**
* Callback fired when the button is clicked.
*
* @param {React.MouseEvent<HTMLElement>} event The event source of the callback.
* @param {any} value of the selected button.
*/
onClick?: ((event: React.MouseEvent<HTMLElement>, value: any) => void) | undefined;
/**
* If `true`, the button is rendered in an active state.
*/
selected?: boolean | undefined;
/**
* The size of the component.
* The prop defaults to the value inherited from the parent ToggleButtonGroup component.
* @default 'medium'
*/
size?: OverridableStringUnion<'small' | 'medium' | 'large', ToggleButtonPropsSizeOverrides> | undefined;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme> | undefined;
/**
* The value to associate with the button when selected in a
* ToggleButtonGroup.
*/
value: NonNullable<unknown>;
}
export type ToggleButtonTypeMap<AdditionalProps = {}, RootComponent extends React.ElementType = 'button'> = ExtendButtonBaseTypeMap<{
props: AdditionalProps & ToggleButtonOwnProps;
defaultComponent: RootComponent;
}>;
/**
*
* Demos:
*
* - [Toggle Button](https://mui.com/material-ui/react-toggle-button/)
*
* API:
*
* - [ToggleButton API](https://mui.com/material-ui/api/toggle-button/)
* - inherits [ButtonBase API](https://mui.com/material-ui/api/button-base/)
*/
declare const ToggleButton: ExtendButtonBase<ToggleButtonTypeMap>;
export type ToggleButtonProps<RootComponent extends React.ElementType = ToggleButtonTypeMap['defaultComponent'], AdditionalProps = {}> = OverrideProps<ToggleButtonTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
component?: React.ElementType | undefined;
};
export default ToggleButton;
+95
View File
@@ -0,0 +1,95 @@
import { SxProps } from '@mui/system';
import { OverridableStringUnion } from '@mui/types';
import * as React from 'react';
import { Theme } from "../styles/index.js";
import { ExtendButtonBase, ExtendButtonBaseTypeMap } from "../ButtonBase/index.js";
import { OverrideProps } from "../OverridableComponent/index.js";
import { ToggleButtonClasses } from "./toggleButtonClasses.js";
export interface ToggleButtonPropsSizeOverrides {}
export interface ToggleButtonPropsColorOverrides {}
export interface ToggleButtonOwnProps {
/**
* The content of the component.
*/
children?: React.ReactNode;
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<ToggleButtonClasses> | undefined;
/**
* The color of the button when it is in an active state.
* It supports both default and custom theme colors, which can be added as shown in the
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
* @default 'standard'
*/
color?: OverridableStringUnion<'standard' | 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning', ToggleButtonPropsColorOverrides> | undefined;
/**
* If `true`, the component is disabled.
* @default false
*/
disabled?: boolean | undefined;
/**
* If `true`, the keyboard focus ripple is disabled.
* @default false
*/
disableFocusRipple?: boolean | undefined;
/**
* If `true`, the button will take up the full width of its container.
* @default false
*/
fullWidth?: boolean | undefined;
/**
* Callback fired when the state changes.
*
* @param {React.MouseEvent<HTMLElement>} event The event source of the callback.
* @param {any} value of the selected button.
*/
onChange?: ((event: React.MouseEvent<HTMLElement>, value: any) => void) | undefined;
/**
* Callback fired when the button is clicked.
*
* @param {React.MouseEvent<HTMLElement>} event The event source of the callback.
* @param {any} value of the selected button.
*/
onClick?: ((event: React.MouseEvent<HTMLElement>, value: any) => void) | undefined;
/**
* If `true`, the button is rendered in an active state.
*/
selected?: boolean | undefined;
/**
* The size of the component.
* The prop defaults to the value inherited from the parent ToggleButtonGroup component.
* @default 'medium'
*/
size?: OverridableStringUnion<'small' | 'medium' | 'large', ToggleButtonPropsSizeOverrides> | undefined;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme> | undefined;
/**
* The value to associate with the button when selected in a
* ToggleButtonGroup.
*/
value: NonNullable<unknown>;
}
export type ToggleButtonTypeMap<AdditionalProps = {}, RootComponent extends React.ElementType = 'button'> = ExtendButtonBaseTypeMap<{
props: AdditionalProps & ToggleButtonOwnProps;
defaultComponent: RootComponent;
}>;
/**
*
* Demos:
*
* - [Toggle Button](https://mui.com/material-ui/react-toggle-button/)
*
* API:
*
* - [ToggleButton API](https://mui.com/material-ui/api/toggle-button/)
* - inherits [ButtonBase API](https://mui.com/material-ui/api/button-base/)
*/
declare const ToggleButton: ExtendButtonBase<ToggleButtonTypeMap>;
export type ToggleButtonProps<RootComponent extends React.ElementType = ToggleButtonTypeMap['defaultComponent'], AdditionalProps = {}> = OverrideProps<ToggleButtonTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
component?: React.ElementType | undefined;
};
export default ToggleButton;
+287
View File
@@ -0,0 +1,287 @@
"use strict";
'use client';
// @inheritedComponent ButtonBase
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _clsx = _interopRequireDefault(require("clsx"));
var _resolveProps = _interopRequireDefault(require("@mui/utils/resolveProps"));
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
var _ButtonBase = _interopRequireDefault(require("../ButtonBase"));
var _capitalize = _interopRequireDefault(require("../utils/capitalize"));
var _zeroStyled = require("../zero-styled");
var _memoTheme = _interopRequireDefault(require("../utils/memoTheme"));
var _createSimplePaletteValueFilter = _interopRequireDefault(require("../utils/createSimplePaletteValueFilter"));
var _DefaultPropsProvider = require("../DefaultPropsProvider");
var _toggleButtonClasses = _interopRequireWildcard(require("./toggleButtonClasses"));
var _ToggleButtonGroupContext = _interopRequireDefault(require("../ToggleButtonGroup/ToggleButtonGroupContext"));
var _ToggleButtonGroupButtonContext = _interopRequireDefault(require("../ToggleButtonGroup/ToggleButtonGroupButtonContext"));
var _isValueSelected = _interopRequireDefault(require("../ToggleButtonGroup/isValueSelected"));
var _RovingToggleButton = _interopRequireDefault(require("./RovingToggleButton"));
var _jsxRuntime = require("react/jsx-runtime");
const useUtilityClasses = ownerState => {
const {
classes,
fullWidth,
selected,
disabled,
size,
color
} = ownerState;
const slots = {
root: ['root', selected && 'selected', disabled && 'disabled', fullWidth && 'fullWidth', `size${(0, _capitalize.default)(size)}`, color]
};
return (0, _composeClasses.default)(slots, _toggleButtonClasses.getToggleButtonUtilityClass, classes);
};
const ToggleButtonRoot = (0, _zeroStyled.styled)(_ButtonBase.default, {
name: 'MuiToggleButton',
slot: 'Root',
overridesResolver: (props, styles) => {
const {
ownerState
} = props;
return [styles.root, styles[`size${(0, _capitalize.default)(ownerState.size)}`]];
}
})((0, _memoTheme.default)(({
theme
}) => ({
...theme.typography.button,
borderRadius: (theme.vars || theme).shape.borderRadius,
padding: 11,
border: `1px solid ${(theme.vars || theme).palette.divider}`,
color: (theme.vars || theme).palette.action.active,
[`&.${_toggleButtonClasses.default.disabled}`]: {
color: (theme.vars || theme).palette.action.disabled,
border: `1px solid ${(theme.vars || theme).palette.action.disabledBackground}`
},
'&:hover': {
textDecoration: 'none',
// Reset on mouse devices
backgroundColor: theme.alpha((theme.vars || theme).palette.text.primary, (theme.vars || theme).palette.action.hoverOpacity),
'@media (hover: none)': {
backgroundColor: 'transparent'
}
},
variants: [{
props: {
color: 'standard'
},
style: {
[`&.${_toggleButtonClasses.default.selected}`]: {
color: (theme.vars || theme).palette.text.primary,
backgroundColor: theme.alpha((theme.vars || theme).palette.text.primary, (theme.vars || theme).palette.action.selectedOpacity),
'&:hover': {
backgroundColor: theme.alpha((theme.vars || theme).palette.text.primary, `${(theme.vars || theme).palette.action.selectedOpacity} + ${(theme.vars || theme).palette.action.hoverOpacity}`),
// Reset on touch devices, it doesn't add specificity
'@media (hover: none)': {
backgroundColor: theme.alpha((theme.vars || theme).palette.text.primary, (theme.vars || theme).palette.action.selectedOpacity)
}
}
}
}
}, ...Object.entries(theme.palette).filter((0, _createSimplePaletteValueFilter.default)()).map(([color]) => ({
props: {
color
},
style: {
[`&.${_toggleButtonClasses.default.selected}`]: {
color: (theme.vars || theme).palette[color].main,
backgroundColor: theme.alpha((theme.vars || theme).palette[color].main, (theme.vars || theme).palette.action.selectedOpacity),
'&:hover': {
backgroundColor: theme.alpha((theme.vars || theme).palette[color].main, `${(theme.vars || theme).palette.action.selectedOpacity} + ${(theme.vars || theme).palette.action.hoverOpacity}`),
// Reset on touch devices, it doesn't add specificity
'@media (hover: none)': {
backgroundColor: theme.alpha((theme.vars || theme).palette[color].main, (theme.vars || theme).palette.action.selectedOpacity)
}
}
}
}
})), {
props: {
fullWidth: true
},
style: {
width: '100%'
}
}, {
props: {
size: 'small'
},
style: {
padding: 7,
fontSize: theme.typography.pxToRem(13)
}
}, {
props: {
size: 'large'
},
style: {
padding: 15,
fontSize: theme.typography.pxToRem(15)
}
}]
})));
const ToggleButton = /*#__PURE__*/React.forwardRef(function ToggleButton(inProps, ref) {
// props priority: `inProps` > `contextProps` > `themeDefaultProps`
const {
value: contextValue,
isRovingTabIndex,
...contextProps
} = React.useContext(_ToggleButtonGroupContext.default);
const toggleButtonGroupButtonContextPositionClassName = React.useContext(_ToggleButtonGroupButtonContext.default);
const resolvedProps = (0, _resolveProps.default)({
...contextProps,
selected: (0, _isValueSelected.default)(inProps.value, contextValue)
}, inProps);
const props = (0, _DefaultPropsProvider.useDefaultProps)({
props: resolvedProps,
name: 'MuiToggleButton'
});
const {
children,
className,
color = 'standard',
disabled = false,
disableFocusRipple = false,
fullWidth = false,
onChange,
onClick,
selected,
size = 'medium',
value,
...other
} = props;
const ownerState = {
...props,
color,
disabled,
disableFocusRipple,
fullWidth,
size
};
const classes = useUtilityClasses(ownerState);
const handleChange = event => {
if (onClick) {
onClick(event, value);
if (event.defaultPrevented) {
return;
}
}
if (onChange) {
onChange(event, value);
}
};
const positionClassName = toggleButtonGroupButtonContextPositionClassName || '';
const button = /*#__PURE__*/(0, _jsxRuntime.jsx)(ToggleButtonRoot, {
className: (0, _clsx.default)(contextProps.className, classes.root, className, positionClassName),
internalNativeButton: true,
disabled: disabled,
focusRipple: !disableFocusRipple,
ref: isRovingTabIndex ? undefined : ref,
onClick: handleChange,
onChange: onChange,
value: value,
ownerState: ownerState,
"aria-pressed": selected,
...other,
children: children
});
if (isRovingTabIndex) {
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_RovingToggleButton.default, {
disabled: disabled,
selected: selected,
ref: ref,
value: value,
children: button
});
}
return button;
});
process.env.NODE_ENV !== "production" ? ToggleButton.propTypes /* remove-proptypes */ = {
// ┌────────────────────────────── Warning ──────────────────────────────┐
// │ These PropTypes are generated from the TypeScript type definitions. │
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
// └─────────────────────────────────────────────────────────────────────┘
/**
* The content of the component.
*/
children: _propTypes.default.node,
/**
* Override or extend the styles applied to the component.
*/
classes: _propTypes.default.object,
/**
* @ignore
*/
className: _propTypes.default.string,
/**
* The color of the button when it is in an active state.
* It supports both default and custom theme colors, which can be added as shown in the
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
* @default 'standard'
*/
color: _propTypes.default /* @typescript-to-proptypes-ignore */.oneOfType([_propTypes.default.oneOf(['standard', 'primary', 'secondary', 'error', 'info', 'success', 'warning']), _propTypes.default.string]),
/**
* If `true`, the component is disabled.
* @default false
*/
disabled: _propTypes.default.bool,
/**
* If `true`, the keyboard focus ripple is disabled.
* @default false
*/
disableFocusRipple: _propTypes.default.bool,
/**
* If `true`, the ripple effect is disabled.
*
* ⚠️ Without a ripple there is no styling for :focus-visible by default. Be sure
* to highlight the element by applying separate styles with the `.Mui-focusVisible` class.
* @default false
*/
disableRipple: _propTypes.default.bool,
/**
* If `true`, the button will take up the full width of its container.
* @default false
*/
fullWidth: _propTypes.default.bool,
/**
* Callback fired when the state changes.
*
* @param {React.MouseEvent<HTMLElement>} event The event source of the callback.
* @param {any} value of the selected button.
*/
onChange: _propTypes.default.func,
/**
* Callback fired when the button is clicked.
*
* @param {React.MouseEvent<HTMLElement>} event The event source of the callback.
* @param {any} value of the selected button.
*/
onClick: _propTypes.default.func,
/**
* If `true`, the button is rendered in an active state.
*/
selected: _propTypes.default.bool,
/**
* The size of the component.
* The prop defaults to the value inherited from the parent ToggleButtonGroup component.
* @default 'medium'
*/
size: _propTypes.default /* @typescript-to-proptypes-ignore */.oneOfType([_propTypes.default.oneOf(['small', 'medium', 'large']), _propTypes.default.string]),
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object]),
/**
* The value to associate with the button when selected in a
* ToggleButtonGroup.
*/
value: _propTypes.default /* @typescript-to-proptypes-ignore */.any.isRequired
} : void 0;
var _default = exports.default = ToggleButton;
+280
View File
@@ -0,0 +1,280 @@
'use client';
// @inheritedComponent ButtonBase
import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import resolveProps from '@mui/utils/resolveProps';
import composeClasses from '@mui/utils/composeClasses';
import ButtonBase from "../ButtonBase/index.mjs";
import capitalize from "../utils/capitalize.mjs";
import { styled } from "../zero-styled/index.mjs";
import memoTheme from "../utils/memoTheme.mjs";
import createSimplePaletteValueFilter from "../utils/createSimplePaletteValueFilter.mjs";
import { useDefaultProps } from "../DefaultPropsProvider/index.mjs";
import toggleButtonClasses, { getToggleButtonUtilityClass } from "./toggleButtonClasses.mjs";
import ToggleButtonGroupContext from "../ToggleButtonGroup/ToggleButtonGroupContext.mjs";
import ToggleButtonGroupButtonContext from "../ToggleButtonGroup/ToggleButtonGroupButtonContext.mjs";
import isValueSelected from "../ToggleButtonGroup/isValueSelected.mjs";
import RovingToggleButton from "./RovingToggleButton.mjs";
import { jsx as _jsx } from "react/jsx-runtime";
const useUtilityClasses = ownerState => {
const {
classes,
fullWidth,
selected,
disabled,
size,
color
} = ownerState;
const slots = {
root: ['root', selected && 'selected', disabled && 'disabled', fullWidth && 'fullWidth', `size${capitalize(size)}`, color]
};
return composeClasses(slots, getToggleButtonUtilityClass, classes);
};
const ToggleButtonRoot = styled(ButtonBase, {
name: 'MuiToggleButton',
slot: 'Root',
overridesResolver: (props, styles) => {
const {
ownerState
} = props;
return [styles.root, styles[`size${capitalize(ownerState.size)}`]];
}
})(memoTheme(({
theme
}) => ({
...theme.typography.button,
borderRadius: (theme.vars || theme).shape.borderRadius,
padding: 11,
border: `1px solid ${(theme.vars || theme).palette.divider}`,
color: (theme.vars || theme).palette.action.active,
[`&.${toggleButtonClasses.disabled}`]: {
color: (theme.vars || theme).palette.action.disabled,
border: `1px solid ${(theme.vars || theme).palette.action.disabledBackground}`
},
'&:hover': {
textDecoration: 'none',
// Reset on mouse devices
backgroundColor: theme.alpha((theme.vars || theme).palette.text.primary, (theme.vars || theme).palette.action.hoverOpacity),
'@media (hover: none)': {
backgroundColor: 'transparent'
}
},
variants: [{
props: {
color: 'standard'
},
style: {
[`&.${toggleButtonClasses.selected}`]: {
color: (theme.vars || theme).palette.text.primary,
backgroundColor: theme.alpha((theme.vars || theme).palette.text.primary, (theme.vars || theme).palette.action.selectedOpacity),
'&:hover': {
backgroundColor: theme.alpha((theme.vars || theme).palette.text.primary, `${(theme.vars || theme).palette.action.selectedOpacity} + ${(theme.vars || theme).palette.action.hoverOpacity}`),
// Reset on touch devices, it doesn't add specificity
'@media (hover: none)': {
backgroundColor: theme.alpha((theme.vars || theme).palette.text.primary, (theme.vars || theme).palette.action.selectedOpacity)
}
}
}
}
}, ...Object.entries(theme.palette).filter(createSimplePaletteValueFilter()).map(([color]) => ({
props: {
color
},
style: {
[`&.${toggleButtonClasses.selected}`]: {
color: (theme.vars || theme).palette[color].main,
backgroundColor: theme.alpha((theme.vars || theme).palette[color].main, (theme.vars || theme).palette.action.selectedOpacity),
'&:hover': {
backgroundColor: theme.alpha((theme.vars || theme).palette[color].main, `${(theme.vars || theme).palette.action.selectedOpacity} + ${(theme.vars || theme).palette.action.hoverOpacity}`),
// Reset on touch devices, it doesn't add specificity
'@media (hover: none)': {
backgroundColor: theme.alpha((theme.vars || theme).palette[color].main, (theme.vars || theme).palette.action.selectedOpacity)
}
}
}
}
})), {
props: {
fullWidth: true
},
style: {
width: '100%'
}
}, {
props: {
size: 'small'
},
style: {
padding: 7,
fontSize: theme.typography.pxToRem(13)
}
}, {
props: {
size: 'large'
},
style: {
padding: 15,
fontSize: theme.typography.pxToRem(15)
}
}]
})));
const ToggleButton = /*#__PURE__*/React.forwardRef(function ToggleButton(inProps, ref) {
// props priority: `inProps` > `contextProps` > `themeDefaultProps`
const {
value: contextValue,
isRovingTabIndex,
...contextProps
} = React.useContext(ToggleButtonGroupContext);
const toggleButtonGroupButtonContextPositionClassName = React.useContext(ToggleButtonGroupButtonContext);
const resolvedProps = resolveProps({
...contextProps,
selected: isValueSelected(inProps.value, contextValue)
}, inProps);
const props = useDefaultProps({
props: resolvedProps,
name: 'MuiToggleButton'
});
const {
children,
className,
color = 'standard',
disabled = false,
disableFocusRipple = false,
fullWidth = false,
onChange,
onClick,
selected,
size = 'medium',
value,
...other
} = props;
const ownerState = {
...props,
color,
disabled,
disableFocusRipple,
fullWidth,
size
};
const classes = useUtilityClasses(ownerState);
const handleChange = event => {
if (onClick) {
onClick(event, value);
if (event.defaultPrevented) {
return;
}
}
if (onChange) {
onChange(event, value);
}
};
const positionClassName = toggleButtonGroupButtonContextPositionClassName || '';
const button = /*#__PURE__*/_jsx(ToggleButtonRoot, {
className: clsx(contextProps.className, classes.root, className, positionClassName),
internalNativeButton: true,
disabled: disabled,
focusRipple: !disableFocusRipple,
ref: isRovingTabIndex ? undefined : ref,
onClick: handleChange,
onChange: onChange,
value: value,
ownerState: ownerState,
"aria-pressed": selected,
...other,
children: children
});
if (isRovingTabIndex) {
return /*#__PURE__*/_jsx(RovingToggleButton, {
disabled: disabled,
selected: selected,
ref: ref,
value: value,
children: button
});
}
return button;
});
process.env.NODE_ENV !== "production" ? ToggleButton.propTypes /* remove-proptypes */ = {
// ┌────────────────────────────── Warning ──────────────────────────────┐
// │ These PropTypes are generated from the TypeScript type definitions. │
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
// └─────────────────────────────────────────────────────────────────────┘
/**
* The content of the component.
*/
children: PropTypes.node,
/**
* Override or extend the styles applied to the component.
*/
classes: PropTypes.object,
/**
* @ignore
*/
className: PropTypes.string,
/**
* The color of the button when it is in an active state.
* It supports both default and custom theme colors, which can be added as shown in the
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
* @default 'standard'
*/
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['standard', 'primary', 'secondary', 'error', 'info', 'success', 'warning']), PropTypes.string]),
/**
* If `true`, the component is disabled.
* @default false
*/
disabled: PropTypes.bool,
/**
* If `true`, the keyboard focus ripple is disabled.
* @default false
*/
disableFocusRipple: PropTypes.bool,
/**
* If `true`, the ripple effect is disabled.
*
* ⚠️ Without a ripple there is no styling for :focus-visible by default. Be sure
* to highlight the element by applying separate styles with the `.Mui-focusVisible` class.
* @default false
*/
disableRipple: PropTypes.bool,
/**
* If `true`, the button will take up the full width of its container.
* @default false
*/
fullWidth: PropTypes.bool,
/**
* Callback fired when the state changes.
*
* @param {React.MouseEvent<HTMLElement>} event The event source of the callback.
* @param {any} value of the selected button.
*/
onChange: PropTypes.func,
/**
* Callback fired when the button is clicked.
*
* @param {React.MouseEvent<HTMLElement>} event The event source of the callback.
* @param {any} value of the selected button.
*/
onClick: PropTypes.func,
/**
* If `true`, the button is rendered in an active state.
*/
selected: PropTypes.bool,
/**
* The size of the component.
* The prop defaults to the value inherited from the parent ToggleButtonGroup component.
* @default 'medium'
*/
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['small', 'medium', 'large']), PropTypes.string]),
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
/**
* The value to associate with the button when selected in a
* ToggleButtonGroup.
*/
value: PropTypes /* @typescript-to-proptypes-ignore */.any.isRequired
} : void 0;
export default ToggleButton;
+4
View File
@@ -0,0 +1,4 @@
export { default } from "./ToggleButton.mjs";
export * from "./ToggleButton.mjs";
export { default as toggleButtonClasses } from "./toggleButtonClasses.mjs";
export * from "./toggleButtonClasses.mjs";
+4
View File
@@ -0,0 +1,4 @@
export { default } from "./ToggleButton.js";
export * from "./ToggleButton.js";
export { default as toggleButtonClasses } from "./toggleButtonClasses.js";
export * from "./toggleButtonClasses.js";
+35
View File
@@ -0,0 +1,35 @@
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _exportNames = {
toggleButtonClasses: true
};
Object.defineProperty(exports, "default", {
enumerable: true,
get: function () {
return _ToggleButton.default;
}
});
Object.defineProperty(exports, "toggleButtonClasses", {
enumerable: true,
get: function () {
return _toggleButtonClasses.default;
}
});
var _ToggleButton = _interopRequireDefault(require("./ToggleButton"));
var _toggleButtonClasses = _interopRequireWildcard(require("./toggleButtonClasses"));
Object.keys(_toggleButtonClasses).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _toggleButtonClasses[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _toggleButtonClasses[key];
}
});
});
+3
View File
@@ -0,0 +1,3 @@
export { default } from "./ToggleButton.mjs";
export { default as toggleButtonClasses } from "./toggleButtonClasses.mjs";
export * from "./toggleButtonClasses.mjs";
@@ -0,0 +1,26 @@
export interface ToggleButtonClasses {
/** Styles applied to the root element. */
root: string;
/** State class applied to the root element if `disabled={true}`. */
disabled: string;
/** State class applied to the root element if `selected={true}`. */
selected: string;
/** State class applied to the root element if `color="standard"`. */
standard: string;
/** State class applied to the root element if `color="primary"`. */
primary: string;
/** State class applied to the root element if `color="secondary"`. */
secondary: string;
/** Styles applied to the root element if `size="small"`. */
sizeSmall: string;
/** Styles applied to the root element if `size="medium"`. */
sizeMedium: string;
/** Styles applied to the root element if `size="large"`. */
sizeLarge: string;
/** Styles applied to the root element if `fullWidth={true}`. */
fullWidth: string;
}
export type ToggleButtonClassKey = keyof ToggleButtonClasses;
export declare function getToggleButtonUtilityClass(slot: string): string;
declare const toggleButtonClasses: ToggleButtonClasses;
export default toggleButtonClasses;
@@ -0,0 +1,26 @@
export interface ToggleButtonClasses {
/** Styles applied to the root element. */
root: string;
/** State class applied to the root element if `disabled={true}`. */
disabled: string;
/** State class applied to the root element if `selected={true}`. */
selected: string;
/** State class applied to the root element if `color="standard"`. */
standard: string;
/** State class applied to the root element if `color="primary"`. */
primary: string;
/** State class applied to the root element if `color="secondary"`. */
secondary: string;
/** Styles applied to the root element if `size="small"`. */
sizeSmall: string;
/** Styles applied to the root element if `size="medium"`. */
sizeMedium: string;
/** Styles applied to the root element if `size="large"`. */
sizeLarge: string;
/** Styles applied to the root element if `fullWidth={true}`. */
fullWidth: string;
}
export type ToggleButtonClassKey = keyof ToggleButtonClasses;
export declare function getToggleButtonUtilityClass(slot: string): string;
declare const toggleButtonClasses: ToggleButtonClasses;
export default toggleButtonClasses;
+15
View File
@@ -0,0 +1,15 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
exports.getToggleButtonUtilityClass = getToggleButtonUtilityClass;
var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateUtilityClass"));
function getToggleButtonUtilityClass(slot) {
return (0, _generateUtilityClass.default)('MuiToggleButton', slot);
}
const toggleButtonClasses = (0, _generateUtilityClasses.default)('MuiToggleButton', ['root', 'disabled', 'selected', 'standard', 'primary', 'secondary', 'sizeSmall', 'sizeMedium', 'sizeLarge', 'fullWidth']);
var _default = exports.default = toggleButtonClasses;
@@ -0,0 +1,7 @@
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
import generateUtilityClass from '@mui/utils/generateUtilityClass';
export function getToggleButtonUtilityClass(slot) {
return generateUtilityClass('MuiToggleButton', slot);
}
const toggleButtonClasses = generateUtilityClasses('MuiToggleButton', ['root', 'disabled', 'selected', 'standard', 'primary', 'secondary', 'sizeSmall', 'sizeMedium', 'sizeLarge', 'fullWidth']);
export default toggleButtonClasses;