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,22 +1,21 @@
// @flow
// @inheritedComponent FormLabel
import React from 'react';
import type { Node } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
import { FormLabel } from '../Form';
export const styles = (theme: Object) => ({
export const styles = theme => ({
root: {
transformOrigin: `top ${theme.direction === 'ltr' ? 'left' : 'right'}`,
transformOrigin: 'top left',
},
formControl: {
position: 'absolute',
left: 0,
top: 0,
// slight alteration to spec spacing to match visual spec result
transform: `translate(0, ${theme.spacing.unit * 3 - 1}px) scale(1)`,
transform: `translate(0, ${theme.spacing.unit * 3}px) scale(1)`,
},
labelDense: {
// Compensation for the `Input.inputDense` style.
@@ -24,7 +23,7 @@ export const styles = (theme: Object) => ({
},
shrink: {
transform: 'translate(0, 1.5px) scale(0.75)',
transformOrigin: `top ${theme.direction === 'ltr' ? 'left' : 'right'}`,
transformOrigin: 'top left',
},
animated: {
transition: theme.transitions.create('transform', {
@@ -33,74 +32,20 @@ export const styles = (theme: Object) => ({
}),
},
disabled: {
color: theme.palette.input.disabled,
color: theme.palette.text.disabled,
},
});
type ProvidedProps = {
classes: Object,
disabled: boolean,
disableAnimation: boolean,
};
export type Props = {
/**
* The contents of the `InputLabel`.
*/
children?: Node,
/**
* Useful to extend the style applied to components.
*/
classes?: Object,
/**
* @ignore
*/
className?: string,
/**
* If `true`, the transition animation is disabled.
*/
disableAnimation?: boolean,
/**
* If `true`, apply disabled class.
*/
disabled?: boolean,
/**
* If `true`, the label will be displayed in an error state.
*/
error?: boolean,
/**
* `classes` property applied to the `FormControl` element.
*/
FormControlClasses?: Object,
/**
* If `true`, the input of this label is focused.
*/
focused?: boolean,
/**
* If `dense`, will adjust vertical spacing. This is normally obtained via context from
* FormControl.
*/
margin?: 'dense',
/**
* if `true`, the label will indicate that the input is required.
*/
required?: boolean,
/**
* If `true`, the label is shrunk.
*/
shrink?: boolean,
};
function InputLabel(props: ProvidedProps & Props, context: { muiFormControl: Object }) {
function InputLabel(props, context) {
const {
disabled,
disableAnimation,
children,
classes,
className: classNameProp,
disableAnimation,
disabled,
FormControlClasses,
shrink: shrinkProp,
margin: marginProp,
shrink: shrinkProp,
...other
} = props;
@@ -135,6 +80,54 @@ function InputLabel(props: ProvidedProps & Props, context: { muiFormControl: Obj
);
}
InputLabel.propTypes = {
/**
* The contents of the `InputLabel`.
*/
children: PropTypes.node,
/**
* Useful to extend the style applied to components.
*/
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
className: PropTypes.string,
/**
* If `true`, the transition animation is disabled.
*/
disableAnimation: PropTypes.bool,
/**
* If `true`, apply disabled class.
*/
disabled: PropTypes.bool,
/**
* If `true`, the label will be displayed in an error state.
*/
error: PropTypes.bool,
/**
* If `true`, the input of this label is focused.
*/
focused: PropTypes.bool,
/**
* `classes` property applied to the `FormControl` element.
*/
FormControlClasses: PropTypes.object,
/**
* If `dense`, will adjust vertical spacing. This is normally obtained via context from
* FormControl.
*/
margin: PropTypes.oneOf(['dense']),
/**
* if `true`, the label will indicate that the input is required.
*/
required: PropTypes.bool,
/**
* If `true`, the label is shrunk.
*/
shrink: PropTypes.bool,
};
InputLabel.defaultProps = {
disabled: false,
disableAnimation: false,