Files
goTorrent/goTorrentWebUI/node_modules/material-ui/Input/InputLabel.js

163 lines
4.9 KiB
JavaScript

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.styles = undefined;
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _classnames = require('classnames');
var _classnames2 = _interopRequireDefault(_classnames);
var _withStyles = require('../styles/withStyles');
var _withStyles2 = _interopRequireDefault(_withStyles);
var _Form = require('../Form');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var styles = exports.styles = function styles(theme) {
return {
root: {
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 + 'px) scale(1)'
},
labelDense: {
// Compensation for the `Input.inputDense` style.
transform: 'translate(0, ' + (theme.spacing.unit * 2.5 + 1) + 'px) scale(1)'
},
shrink: {
transform: 'translate(0, 1.5px) scale(0.75)',
transformOrigin: 'top left'
},
animated: {
transition: theme.transitions.create('transform', {
duration: theme.transitions.duration.shorter,
easing: theme.transitions.easing.easeOut
})
},
disabled: {
color: theme.palette.text.disabled
}
};
}; // @inheritedComponent FormLabel
function InputLabel(props, context) {
var _classNames;
var children = props.children,
classes = props.classes,
classNameProp = props.className,
disableAnimation = props.disableAnimation,
disabled = props.disabled,
FormControlClasses = props.FormControlClasses,
marginProp = props.margin,
shrinkProp = props.shrink,
other = (0, _objectWithoutProperties3.default)(props, ['children', 'classes', 'className', 'disableAnimation', 'disabled', 'FormControlClasses', 'margin', 'shrink']);
var muiFormControl = context.muiFormControl;
var shrink = shrinkProp;
if (typeof shrink === 'undefined' && muiFormControl) {
shrink = muiFormControl.dirty || muiFormControl.focused || muiFormControl.adornedStart;
}
var margin = marginProp;
if (typeof margin === 'undefined' && muiFormControl) {
margin = muiFormControl.margin;
}
var className = (0, _classnames2.default)(classes.root, (_classNames = {}, (0, _defineProperty3.default)(_classNames, classes.formControl, muiFormControl), (0, _defineProperty3.default)(_classNames, classes.animated, !disableAnimation), (0, _defineProperty3.default)(_classNames, classes.shrink, shrink), (0, _defineProperty3.default)(_classNames, classes.disabled, disabled), (0, _defineProperty3.default)(_classNames, classes.labelDense, margin === 'dense'), _classNames), classNameProp);
return _react2.default.createElement(
_Form.FormLabel,
(0, _extends3.default)({ 'data-shrink': shrink, className: className, classes: FormControlClasses }, other),
children
);
}
InputLabel.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* The contents of the `InputLabel`.
*/
children: _propTypes2.default.node,
/**
* Useful to extend the style applied to components.
*/
classes: _propTypes2.default.object.isRequired,
/**
* @ignore
*/
className: _propTypes2.default.string,
/**
* If `true`, the transition animation is disabled.
*/
disableAnimation: _propTypes2.default.bool,
/**
* If `true`, apply disabled class.
*/
disabled: _propTypes2.default.bool,
/**
* If `true`, the label will be displayed in an error state.
*/
error: _propTypes2.default.bool,
/**
* If `true`, the input of this label is focused.
*/
focused: _propTypes2.default.bool,
/**
* `classes` property applied to the `FormControl` element.
*/
FormControlClasses: _propTypes2.default.object,
/**
* If `dense`, will adjust vertical spacing. This is normally obtained via context from
* FormControl.
*/
margin: _propTypes2.default.oneOf(['dense']),
/**
* if `true`, the label will indicate that the input is required.
*/
required: _propTypes2.default.bool,
/**
* If `true`, the label is shrunk.
*/
shrink: _propTypes2.default.bool
} : {};
InputLabel.defaultProps = {
disabled: false,
disableAnimation: false
};
InputLabel.contextTypes = {
muiFormControl: _propTypes2.default.object
};
exports.default = (0, _withStyles2.default)(styles, { name: 'MuiInputLabel' })(InputLabel);