"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var React = _interopRequireWildcard(require("react"));

var _styletronReact = require("styletron-react");

var _styles = require("../styles");

var _helpers = require("../helpers");

var _index = require("./index");

var _examplesList = _interopRequireDefault(require("./examples-list"));

var _examples$SIMPLE_EXAM;

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(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 Button = (0, _styles.styled)('button', function (_ref) {
  var $theme = _ref.$theme;
  return _objectSpread({}, $theme.typography.font300, {
    display: 'block',
    paddingTop: '10px',
    paddingRight: '12px',
    paddingBottom: '10px',
    paddingLeft: '12px',
    marginTop: '8px',
    width: '100%',
    borderRadius: $theme.sizing.scale100,
    borderWidth: 'none'
  });
});
var TextareaWithStyle = (0, _styletronReact.withStyle)(_index.StyledTextarea, function (props) {
  var $disabled = props.$disabled,
      $error = props.$error,
      $isFocused = props.$isFocused,
      _props$$theme = props.$theme,
      colors = _props$$theme.colors,
      sizing = _props$$theme.sizing;
  return {
    borderColor: $disabled ? colors.borderAlt : $error ? colors.borderError : $isFocused ? 'darkseagreen' : colors.border,
    boxShadow: "0 0 ".concat(sizing.scale100, " ").concat($disabled ? 'transparent' : $error ? colors.shadowError : $isFocused ? 'lightseagreen' : 'transparent')
  };
});
var TextareaWithProps = (0, _helpers.withProps)(_index.StyledTextarea, {
  'data-test': 'test'
});

var _default = (_examples$SIMPLE_EXAM = {}, _defineProperty(_examples$SIMPLE_EXAM, _examplesList.default.SIMPLE_EXAMPLE, function Story1() {
  return React.createElement(React.Fragment, null, React.createElement(_index.Textarea, {
    placeholder: "Controlled textarea"
  }), React.createElement("br", null), React.createElement(_index.StatefulTextarea, {
    placeholder: "Uncontrolled textarea",
    initialState: {
      value: 'initial value'
    }
  }));
}), _defineProperty(_examples$SIMPLE_EXAM, _examplesList.default.SIZE_EXAMPLE, function Story2() {
  return React.createElement(React.Fragment, null, React.createElement(_index.StatefulTextarea, {
    placeholder: "Default textarea"
  }), React.createElement("br", null), React.createElement(_index.StatefulTextarea, {
    size: _index.SIZE.compact,
    placeholder: "Compact textarea"
  }));
}), _defineProperty(_examples$SIMPLE_EXAM, _examplesList.default.STATE_EXAMPLE, function Story3() {
  return React.createElement(React.Fragment, null, React.createElement(_index.StatefulTextarea, {
    size: _index.SIZE.compact,
    placeholder: "Placeholder"
  }), React.createElement("br", null), React.createElement(_index.StatefulTextarea, {
    size: _index.SIZE.compact,
    placeholder: "Focused",
    autoFocus: true
  }), React.createElement("br", null), React.createElement(_index.StatefulTextarea, {
    initialState: {
      value: 'uber'
    },
    size: _index.SIZE.compact,
    placeholder: "Placeholder"
  }), React.createElement("br", null), React.createElement(_index.StatefulTextarea, {
    size: _index.SIZE.compact,
    error: true,
    placeholder: "Placeholder"
  }), React.createElement("br", null), React.createElement(_index.StatefulTextarea, {
    size: _index.SIZE.compact,
    disabled: true,
    placeholder: "Disabled textarea"
  }));
}), _defineProperty(_examples$SIMPLE_EXAM, _examplesList.default.OVERRIDES_EXAMPLE, function Story4() {
  return React.createElement(React.Fragment, null, React.createElement(_index.StatefulTextarea, {
    overrides: {
      Input: TextareaWithStyle
    },
    placeholder: "With style overrides on the textarea element"
  }), React.createElement("br", null), React.createElement(_index.StatefulTextarea, {
    label: "Input with extra props",
    overrides: {
      Input: TextareaWithProps
    },
    placeholder: "With a 'data-test' attrs passes to the input element"
  }));
}), _defineProperty(_examples$SIMPLE_EXAM, _examplesList.default.REF_EXAMPLE, function Story5() {
  var inputRef = React.createRef();
  return React.createElement(React.Fragment, null, React.createElement(_index.StatefulTextarea, {
    inputRef: inputRef,
    placeholder: "With textarea input ref"
  }), React.createElement(Button, {
    onClick: function onClick() {
      inputRef.current && inputRef.current.focus();
    }
  }, "Click here to focus input"));
}), _examples$SIMPLE_EXAM);

exports.default = _default;