UNPKG

wix-style-react

Version:
84 lines (65 loc) 5.29 kB
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } import React from 'react'; import classNames from 'classnames'; import Input from './Input'; import styles from './Input.scss'; var ThemedInput = function (_Input) { _inherits(ThemedInput, _Input); function ThemedInput() { _classCallCheck(this, ThemedInput); return _possibleConstructorReturn(this, (ThemedInput.__proto__ || Object.getPrototypeOf(ThemedInput)).apply(this, arguments)); } _createClass(ThemedInput, [{ key: 'render', value: function render() { var _classes; var _props = this.props, id = _props.id, size = _props.size, dataHook = _props.dataHook, title = _props.title, theme = _props.theme, rtl = _props.rtl, disabled = _props.disabled, error = _props.error, status = _props.status, forceHover = _props.forceHover, forceFocus = _props.forceFocus, roundInput = _props.roundInput, className = _props.className, noLeftBorderRadius = _props.noLeftBorderRadius, noRightBorderRadius = _props.noRightBorderRadius, value = _props.value, withSelection = _props.withSelection; var hasError = status === Input.StatusError; // Check for deprecated fields and use them if provided if (error) { hasError = true; } var classes = (_classes = {}, _defineProperty(_classes, styles.rtl, !!rtl), _defineProperty(_classes, styles.disabled, disabled), _defineProperty(_classes, styles.hasError, hasError), _defineProperty(_classes, styles.hasHover, forceHover), _defineProperty(_classes, styles.hasFocus, forceFocus || this.state.focus), _defineProperty(_classes, styles.roundInput, roundInput), _defineProperty(_classes, styles.hasValue, value && value.length || this.input && !!this.input.value), _defineProperty(_classes, styles.noRightBorderRadius, noRightBorderRadius === true), _defineProperty(_classes, styles.noLeftBorderRadius, noLeftBorderRadius === true), _defineProperty(_classes, noRightBorderRadius, typeof noRightBorderRadius === 'string'), _defineProperty(_classes, noLeftBorderRadius, typeof noLeftBorderRadius === 'string'), _classes); var placeholder = this.props.placeholder; return React.createElement( 'div', { className: classNames(classes, styles.root, styles['theme-' + theme], styles['size-' + size + (withSelection ? '-with-selection' : '')], className), 'data-hook': dataHook }, theme === 'amaterial' && React.createElement( 'label', { className: styles.materialTitle, htmlFor: id }, title ), _get(ThemedInput.prototype.__proto__ || Object.getPrototypeOf(ThemedInput.prototype), 'render', this).call(this, { placeholder: placeholder }), theme === 'material' && React.createElement('div', { className: styles.bar + ' ' + styles.barBlack }), theme === 'amaterial' && React.createElement('div', { className: styles.bar + ' ' + styles.barBlue }) ); } }]); return ThemedInput; }(Input); export default ThemedInput;