text: "use strict";
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports.default = void 0;
  
  var _propTypes = _interopRequireDefault(require("prop-types"));
  
  var _react = _interopRequireDefault(require("react"));
  
  var _closeIcon = _interopRequireDefault(require("part:@sanity/base/close-icon"));
  
  var _classnames = _interopRequireDefault(require("classnames"));
  
  var _defaultStyle = _interopRequireDefault(require("part:@sanity/components/textinputs/default-style"));
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
  
  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 _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
  
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
  
  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; }
  
  var NOOP = () => {};
  
  class DefaultTextInput extends _react.default.PureComponent {
    constructor() {
      super(...arguments);
  
      _defineProperty(this, "setInput", element => {
        this._input = element;
      });
    }
  
    componentDidMount() {
      this._input.setCustomValidity(this.props.customValidity);
    }
  
    UNSAFE_componentWillReceiveProps(nextProps) {
      if (nextProps.customValidity !== this.props.customValidity) {
        this._input.setCustomValidity(nextProps.customValidity);
      }
    }
  
    select() {
      if (this._input) {
        this._input.select();
      }
    }
  
    focus() {
      if (this._input) {
        this._input.focus();
      }
    }
  
    render() {
      var _this$props = this.props,
          onClear = _this$props.onClear,
          hasError = _this$props.hasError,
          isClearable = _this$props.isClearable,
          isSelected = _this$props.isSelected,
          disabled = _this$props.disabled,
          markers = _this$props.markers,
          passedStyles = _this$props.styles,
          customValidity = _this$props.customValidity,
          focusPath = _this$props.focusPath,
          rest = _objectWithoutProperties(_this$props, ["onClear", "hasError", "isClearable", "isSelected", "disabled", "markers", "styles", "customValidity", "focusPath"]);
  
      var styles = _objectSpread(_objectSpread({}, _defaultStyle.default), passedStyles);
  
      return /*#__PURE__*/_react.default.createElement("div", {
        className: (0, _classnames.default)(styles.container, [isClearable && styles.isClearable, disabled && styles.isDisabled])
      }, /*#__PURE__*/_react.default.createElement("input", _extends({
        ref: this.setInput
      }, rest, {
        className: (0, _classnames.default)(styles.input),
        disabled: disabled
      })), isClearable && /*#__PURE__*/_react.default.createElement("button", {
        className: styles.clearButton,
        onClick: onClear
      }, /*#__PURE__*/_react.default.createElement(_closeIcon.default, {
        color: "inherit"
      })));
    }
  
  }
  
  exports.default = DefaultTextInput;
  
  _defineProperty(DefaultTextInput, "propTypes", {
    value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
    markers: _propTypes.default.array,
    focusPath: _propTypes.default.array,
    type: _propTypes.default.string,
    onClear: _propTypes.default.func,
    onFocus: _propTypes.default.func,
    onBlur: _propTypes.default.func,
    isClearable: _propTypes.default.bool,
    isSelected: _propTypes.default.bool,
    disabled: _propTypes.default.bool,
    autoComplete: _propTypes.default.string,
    hasError: _propTypes.default.bool,
    customValidity: _propTypes.default.string,
    styles: _propTypes.default.shape({
      container: _propTypes.default.string,
      input: _propTypes.default.string,
      isClearable: _propTypes.default.string,
      clearButton: _propTypes.default.string,
      inputOnDisabled: _propTypes.default.string,
      inputOnError: _propTypes.default.string,
      containerOnError: _propTypes.default.string
    })
  });
  
  _defineProperty(DefaultTextInput, "defaultProps", {
    value: '',
    type: 'text',
    hasError: false,
    isSelected: false,
    isClearable: false,
    disabled: false,
    autoComplete: 'off',
    onClear: NOOP,
    onFocus: NOOP,
    onBlur: NOOP,
    styles: {},
    customValidity: ''
  });