Added logging, changed some directory structure

This commit is contained in:
2018-01-13 21:33:40 -05:00
parent f079a5f067
commit 8e72ffb917
73656 changed files with 35284 additions and 53718 deletions

View File

@@ -0,0 +1,31 @@
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 type RadioClassKey =
| SwitchBaseClassKey
;
declare const Radio: React.ComponentType<RadioProps>;
export default Radio;

View File

@@ -0,0 +1,34 @@
// weak
import React from 'react';
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]
},
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)
}));
Radio.displayName = 'Radio';
export default Radio;
// This is here solely to trigger api doc generation
// eslint-disable-next-line no-unused-vars
export const RadioDocs = props => React.createElement('span', null);

View File

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

View File

@@ -0,0 +1,73 @@
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; }
// @inheritedComponent FormGroup
import React from 'react';
import FormGroup from '../Form/FormGroup';
import { find } from '../utils/helpers';
class RadioGroup extends React.Component {
constructor(...args) {
var _temp;
return _temp = super(...args), this.radios = [], this.focus = () => {
if (!this.radios || !this.radios.length) {
return;
}
const focusRadios = this.radios.filter(n => !n.disabled);
if (!focusRadios.length) {
return;
}
const selectedRadio = find(focusRadios, n => n.checked);
if (selectedRadio) {
selectedRadio.focus();
return;
}
focusRadios[0].focus();
}, this.handleRadioChange = (event, checked) => {
if (checked && this.props.onChange) {
this.props.onChange(event, event.target.value);
}
}, _temp;
}
render() {
const _props = this.props,
{ children, name, value, onChange } = _props,
other = _objectWithoutProperties(_props, ['children', 'name', 'value', 'onChange']);
this.radios = [];
return React.createElement(
FormGroup,
_extends({ 'data-mui-test': 'RadioGroup', role: 'radiogroup' }, other),
React.Children.map(children, (child, index) => {
if (!React.isValidElement(child)) {
return null;
}
return React.cloneElement(child, {
key: index,
name,
inputRef: node => {
if (node) {
this.radios.push(node);
}
},
checked: value === child.props.value,
onChange: this.handleRadioChange
});
})
);
}
}
export default RadioGroup;

View File

@@ -0,0 +1,4 @@
export { default } from './Radio';
export * from './Radio';
export { default as RadioGroup } from './RadioGroup';
export * from './RadioGroup';

View File

@@ -0,0 +1,2 @@
export { default } from './Radio';
export { default as RadioGroup } from './RadioGroup';