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

@@ -2,29 +2,9 @@ import * as React from 'react';
import { StandardProps } from '..';
import { SwitchBaseProps, SwitchBaseClassKey } from '../internal/SwitchBase';
export interface RadioProps extends StandardProps<
SwitchBaseProps,
RadioClassKey
> {
checked?: boolean | string;
checkedClassName?: string;
checkedIcon?: React.ReactNode;
defaultChecked?: boolean;
disabled?: boolean;
disabledClassName?: string;
disableRipple?: boolean;
icon?: React.ReactNode;
inputProps?: Object;
inputRef?: React.Ref<any>;
name?: string;
onChange?: (event: React.ChangeEvent<{}>, checked: boolean) => void;
tabIndex?: number;
value?: string;
}
export interface RadioProps extends StandardProps<SwitchBaseProps, RadioClassKey> {}
export type RadioClassKey =
| SwitchBaseClassKey
;
export type RadioClassKey = SwitchBaseClassKey;
declare const Radio: React.ComponentType<RadioProps>;

View File

@@ -1,34 +1,113 @@
// weak
import _extends from 'babel-runtime/helpers/extends';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import React 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 => ({
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: React.createElement(RadioButtonUncheckedIcon, null),
defaultCheckedIcon: React.createElement(RadioButtonCheckedIcon, null)
}));
var _ref = React.createElement(RadioButtonUncheckedIcon, null);
Radio.displayName = 'Radio';
var _ref2 = React.createElement(RadioButtonCheckedIcon, null);
export default Radio;
function Radio(props) {
const { classes, color } = props,
other = _objectWithoutProperties(props, ['classes', 'color']);
const checkedClass = classNames(classes.checked, {
[classes.checkedPrimary]: color === 'primary',
[classes.checkedSecondary]: color === 'secondary'
});
// This is here solely to trigger api doc generation
// eslint-disable-next-line no-unused-vars
export const RadioDocs = props => React.createElement('span', null);
return React.createElement(SwitchBase, _extends({
type: 'radio',
icon: _ref,
checkedIcon: _ref2,
classes: {
default: classes.default,
checked: checkedClass,
disabled: classes.disabled
}
}, other));
}
Radio.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* If `true`, the component is checked.
*/
checked: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
/**
* The icon to display when the component is checked.
*/
checkedIcon: PropTypes.node,
/**
* Useful to extend the style applied to components.
*/
classes: PropTypes.object.isRequired,
/**
* The color of the component. It supports those theme colors that make sense for this component.
*/
color: PropTypes.oneOf(['primary', 'secondary']),
/**
* If `true`, the switch will be disabled.
*/
disabled: PropTypes.bool,
/**
* If `true`, the ripple effect will be disabled.
*/
disableRipple: PropTypes.bool,
/**
* The icon to display when the component is unchecked.
*/
icon: PropTypes.node,
/**
* The id of the `input` element.
*/
id: PropTypes.string,
/**
* Properties applied to the `input` element.
*/
inputProps: PropTypes.object,
/**
* Use that property to pass a ref callback to the native input component.
*/
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: PropTypes.func,
/**
* The input component property `type`.
*/
type: PropTypes.string,
/**
* The value of the component.
*/
value: PropTypes.string
} : {};
Radio.defaultProps = {
color: 'secondary'
};
export default withStyles(styles, { name: 'MuiRadio' })(Radio);

View File

@@ -2,19 +2,14 @@ import * as React from 'react';
import { StandardProps } from '..';
import { FormGroupProps, FormGroupClassKey } from '../Form/FormGroup';
export interface RadioGroupProps extends StandardProps<
FormGroupProps,
RadioGroupClassKey,
'onChange'
> {
export interface RadioGroupProps
extends StandardProps<FormGroupProps, RadioGroupClassKey, 'onChange'> {
name?: string;
onChange?: (event: React.ChangeEvent<{}>, value: string) => void;
value?: string;
}
export type RadioGroupClassKey =
| FormGroupClassKey
;
export type RadioGroupClassKey = FormGroupClassKey;
declare const RadioGroup: React.ComponentType<RadioGroupProps>;

View File

@@ -1,11 +1,9 @@
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
import _extends from 'babel-runtime/helpers/extends';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
// @inheritedComponent FormGroup
import React from 'react';
import PropTypes from 'prop-types';
import FormGroup from '../Form/FormGroup';
import { find } from '../utils/helpers';
@@ -48,7 +46,7 @@ class RadioGroup extends React.Component {
return React.createElement(
FormGroup,
_extends({ 'data-mui-test': 'RadioGroup', role: 'radiogroup' }, other),
_extends({ role: 'radiogroup' }, other),
React.Children.map(children, (child, index) => {
if (!React.isValidElement(child)) {
return null;
@@ -70,4 +68,34 @@ class RadioGroup extends React.Component {
}
}
RadioGroup.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* The content of the component.
*/
children: PropTypes.node,
/**
* The name used to reference the value of the control.
*/
name: PropTypes.string,
/**
* @ignore
*/
onBlur: PropTypes.func,
/**
* Callback fired when a radio button is selected.
*
* @param {object} event The event source of the callback
* @param {string} value The `value` of the selected radio button
*/
onChange: PropTypes.func,
/**
* @ignore
*/
onKeyDown: PropTypes.func,
/**
* Value of the selected radio button.
*/
value: PropTypes.string
} : {};
export default RadioGroup;