UNPKG

wix-style-react

Version:
110 lines (92 loc) 5.97 kB
import _extends from "@babel/runtime/helpers/extends"; import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; import _createClass from "@babel/runtime/helpers/createClass"; import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized"; import _get from "@babel/runtime/helpers/get"; import _inherits from "@babel/runtime/helpers/inherits"; import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } import React from 'react'; import Input from './Input'; import { st, classes } from './Input.st.css'; import DATA_ATTR from './DataAttr'; import { filterObject } from '../utils/filterObject'; import { FontUpgradeContext } from '../FontUpgrade/context'; var ThemedInput = /*#__PURE__*/function (_Input) { _inherits(ThemedInput, _Input); var _super = _createSuper(ThemedInput); function ThemedInput() { var _this; _classCallCheck(this, ThemedInput); for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = _super.call.apply(_super, [this].concat(args)); _defineProperty(_assertThisInitialized(_this), "_getDataAttr", function () { var _filterObject; var _this$props = _this.props, size = _this$props.size, status = _this$props.status, prefix = _this$props.prefix, disabled = _this$props.disabled, forceHover = _this$props.forceHover, forceFocus = _this$props.forceFocus, noLeftBorderRadius = _this$props.noLeftBorderRadius, noRightBorderRadius = _this$props.noRightBorderRadius; return filterObject((_filterObject = {}, _defineProperty(_filterObject, DATA_ATTR.SIZE, size), _defineProperty(_filterObject, DATA_ATTR.STATUS, status), _defineProperty(_filterObject, DATA_ATTR.PREFIX, !!prefix), _defineProperty(_filterObject, DATA_ATTR.DISABLED, !!disabled), _defineProperty(_filterObject, DATA_ATTR.HOVER, !!forceHover), _defineProperty(_filterObject, DATA_ATTR.FOCUS, !!(forceFocus || _this.state.focus)), _defineProperty(_filterObject, DATA_ATTR.LEFTBORDERRADIUS, !!noLeftBorderRadius), _defineProperty(_filterObject, DATA_ATTR.RIGHTBORDERRADIUS, !!noRightBorderRadius), _filterObject), function (key, value) { return !!value; }); }); return _this; } _createClass(ThemedInput, [{ key: "render", value: function render() { var _this2 = this; var _this$props2 = this.props, size = _this$props2.size, dataHook = _this$props2.dataHook, rtl = _this$props2.rtl, status = _this$props2.status, disabled = _this$props2.disabled, forceHover = _this$props2.forceHover, forceFocus = _this$props2.forceFocus, border = _this$props2.border, roundInput = _this$props2.roundInput, className = _this$props2.className, noLeftBorderRadius = _this$props2.noLeftBorderRadius, noRightBorderRadius = _this$props2.noRightBorderRadius, readOnly = _this$props2.readOnly; var placeholder = this.props.placeholder; return /*#__PURE__*/React.createElement(FontUpgradeContext.Consumer, null, function (_ref) { var isMadefor = _ref.active; return /*#__PURE__*/React.createElement("div", _extends({ className: st(classes.root, { isMadefor: isMadefor, size: size, hasFocus: forceFocus || _this2.state.focus, status: status, forceHover: forceHover, readOnly: readOnly, disabled: disabled, border: roundInput ? 'round' : border, noRightBorderRadius: noRightBorderRadius, noLeftBorderRadius: noLeftBorderRadius }, className), dir: rtl ? 'rtl' : null, "data-hook": dataHook }, _this2._getDataAttr()), _get(_getPrototypeOf(ThemedInput.prototype), "render", _this2).call(_this2, { placeholder: placeholder })); }); } }]); return ThemedInput; }(Input); ThemedInput.propTypes = _objectSpread({}, Input.propTypes); export default ThemedInput;