Completely updated React, fixed #11, (hopefully)

This commit is contained in:
2018-03-04 19:11:49 -05:00
parent 6e0afd6e2a
commit 34e5f5139a
13674 changed files with 333464 additions and 473223 deletions

View File

@@ -1,112 +1,109 @@
// @flow weak
import React from 'react';
import type { Node } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import SwitchBase from '../internal/SwitchBase';
import RadioButtonCheckedIcon from '../internal/svg-icons/RadioButtonChecked';
import RadioButtonUncheckedIcon from '../internal/svg-icons/RadioButtonUnchecked';
import withStyles from '../styles/withStyles';
import createSwitch from '../internal/SwitchBase';
import RadioButtonCheckedIcon from '../svg-icons/RadioButtonChecked';
import RadioButtonUncheckedIcon from '../svg-icons/RadioButtonUnchecked';
export const styles = (theme: Object) => ({
export const styles = theme => ({
default: {
color: theme.palette.text.secondary,
},
checked: {
color: theme.palette.primary[500],
checked: {},
checkedPrimary: {
color: theme.palette.primary.main,
},
checkedSecondary: {
color: theme.palette.secondary.main,
},
disabled: {
color: theme.palette.action.disabled,
},
});
const Radio = withStyles(styles, { name: 'MuiRadio' })(
createSwitch({
inputType: 'radio',
defaultIcon: <RadioButtonUncheckedIcon />,
defaultCheckedIcon: <RadioButtonCheckedIcon />,
}),
);
function Radio(props) {
const { classes, color, ...other } = props;
const checkedClass = classNames(classes.checked, {
[classes.checkedPrimary]: color === 'primary',
[classes.checkedSecondary]: color === 'secondary',
});
Radio.displayName = 'Radio';
return (
<SwitchBase
type="radio"
icon={<RadioButtonUncheckedIcon />}
checkedIcon={<RadioButtonCheckedIcon />}
classes={{
default: classes.default,
checked: checkedClass,
disabled: classes.disabled,
}}
{...other}
/>
);
}
export default Radio;
type ProvidedProps = {
classes: Object,
};
export type Props = {
Radio.propTypes = {
/**
* If `true`, the component is checked.
*/
checked?: boolean | string,
/**
* The CSS class name of the root element when checked.
*/
checkedClassName?: string,
checked: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
/**
* The icon to display when the component is checked.
* If a string is provided, it will be used as a font ligature.
*/
checkedIcon?: Node,
checkedIcon: PropTypes.node,
/**
* Useful to extend the style applied to components.
*/
classes?: Object,
classes: PropTypes.object.isRequired,
/**
* @ignore
* The color of the component. It supports those theme colors that make sense for this component.
*/
className?: string,
/**
* @ignore
*/
defaultChecked?: boolean,
color: PropTypes.oneOf(['primary', 'secondary']),
/**
* If `true`, the switch will be disabled.
*/
disabled?: boolean,
/**
* The CSS class name of the root element when disabled.
*/
disabledClassName?: string,
disabled: PropTypes.bool,
/**
* If `true`, the ripple effect will be disabled.
*/
disableRipple?: boolean,
disableRipple: PropTypes.bool,
/**
* The icon to display when the component is unchecked.
* If a string is provided, it will be used as a font ligature.
*/
icon?: Node,
icon: PropTypes.node,
/**
* The id of the `input` element.
*/
id: PropTypes.string,
/**
* Properties applied to the `input` element.
*/
inputProps?: Object,
inputProps: PropTypes.object,
/**
* Use that property to pass a ref callback to the native input component.
*/
inputRef?: Function,
/*
* @ignore
*/
name?: string,
inputRef: PropTypes.func,
/**
* Callback fired when the state is changed.
*
* @param {object} event The event source of the callback
* @param {boolean} checked The `checked` value of the switch
*/
onChange?: Function,
onChange: PropTypes.func,
/**
* @ignore
* The input component property `type`.
*/
tabIndex?: number | string,
type: PropTypes.string,
/**
* The value of the component.
*/
value?: string,
value: PropTypes.string,
};
// This is here solely to trigger api doc generation
// eslint-disable-next-line no-unused-vars
export const RadioDocs = (props: ProvidedProps & Props) => <span />;
Radio.defaultProps = {
color: 'secondary',
};
export default withStyles(styles, { name: 'MuiRadio' })(Radio);