113 lines
2.8 KiB
JavaScript
113 lines
2.8 KiB
JavaScript
'use strict';
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _simpleAssign = require('simple-assign');
|
|
|
|
var _simpleAssign2 = _interopRequireDefault(_simpleAssign);
|
|
|
|
var _react = require('react');
|
|
|
|
var _react2 = _interopRequireDefault(_react);
|
|
|
|
var _transitions = require('../styles/transitions');
|
|
|
|
var _transitions2 = _interopRequireDefault(_transitions);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function getStyles(props) {
|
|
var defaultStyles = {
|
|
position: 'absolute',
|
|
lineHeight: '22px',
|
|
top: 38,
|
|
transition: _transitions2.default.easeOut(),
|
|
zIndex: 1, // Needed to display label above Chrome's autocomplete field background
|
|
transform: 'scale(1) translate(0, 0)',
|
|
transformOrigin: 'left top',
|
|
pointerEvents: 'auto',
|
|
userSelect: 'none'
|
|
};
|
|
|
|
var shrinkStyles = props.shrink ? (0, _simpleAssign2.default)({
|
|
transform: 'scale(0.75) translate(0, -28px)',
|
|
pointerEvents: 'none'
|
|
}, props.shrinkStyle) : null;
|
|
|
|
return {
|
|
root: (0, _simpleAssign2.default)(defaultStyles, props.style, shrinkStyles)
|
|
};
|
|
}
|
|
|
|
var TextFieldLabel = function TextFieldLabel(props) {
|
|
var muiTheme = props.muiTheme,
|
|
className = props.className,
|
|
children = props.children,
|
|
htmlFor = props.htmlFor,
|
|
onTouchTap = props.onTouchTap;
|
|
var prepareStyles = muiTheme.prepareStyles;
|
|
|
|
var styles = getStyles(props);
|
|
|
|
return _react2.default.createElement(
|
|
'label',
|
|
{
|
|
className: className,
|
|
style: prepareStyles(styles.root),
|
|
htmlFor: htmlFor,
|
|
onTouchTap: onTouchTap
|
|
},
|
|
children
|
|
);
|
|
};
|
|
|
|
process.env.NODE_ENV !== "production" ? TextFieldLabel.propTypes = {
|
|
/**
|
|
* The label contents.
|
|
*/
|
|
children: _react.PropTypes.node,
|
|
/**
|
|
* The css class name of the root element.
|
|
*/
|
|
className: _react.PropTypes.string,
|
|
/**
|
|
* Disables the label if set to true.
|
|
*/
|
|
disabled: _react.PropTypes.bool,
|
|
/**
|
|
* The id of the target element that this label should refer to.
|
|
*/
|
|
htmlFor: _react.PropTypes.string,
|
|
/**
|
|
* @ignore
|
|
* The material-ui theme applied to this component.
|
|
*/
|
|
muiTheme: _react.PropTypes.object.isRequired,
|
|
/**
|
|
* Callback function for when the label is selected via a touch tap.
|
|
*
|
|
* @param {object} event TouchTap event targeting the text field label.
|
|
*/
|
|
onTouchTap: _react.PropTypes.func,
|
|
/**
|
|
* True if the floating label should shrink.
|
|
*/
|
|
shrink: _react.PropTypes.bool,
|
|
/**
|
|
* Override the inline-styles of the root element when shrunk.
|
|
*/
|
|
shrinkStyle: _react.PropTypes.object,
|
|
/**
|
|
* Override the inline-styles of the root element.
|
|
*/
|
|
style: _react.PropTypes.object
|
|
} : void 0;
|
|
|
|
TextFieldLabel.defaultProps = {
|
|
disabled: false,
|
|
shrink: false
|
|
};
|
|
|
|
exports.default = TextFieldLabel; |