"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

var _typeof = require("@babel/runtime/helpers/typeof");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.timeInput = exports.textarea = exports.numericInput = exports.inputPrefixSuffix = exports.inputConnected = exports.input = exports.durationInput = exports.default = void 0;

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));

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

var _utils = require("../../../.storybook/utils");

var _Input = _interopRequireDefault(require("./Input"));

var _button = _interopRequireDefault(require("../button"));

var _checkbox = _interopRequireDefault(require("../checkbox"));

var _icon = _interopRequireDefault(require("../icon"));

var _typography = require("../typography");

var _counter = _interopRequireDefault(require("../counter"));

var _loadingSpinner = _interopRequireDefault(require("../loadingSpinner"));

var _uiIcons = require("@teamleader/ui-icons");

var _NumericInput = _interopRequireDefault(require("./NumericInput"));

var _TimeInput = _interopRequireDefault(require("./TimeInput"));

var _DurationInput = _interopRequireDefault(require("./DurationInput"));

var _Textarea = _interopRequireDefault(require("./Textarea"));

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

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

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); 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 = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

var placeholder = 'I am the placeholder';
var prefix = [
/*#__PURE__*/

/* eslint-disable-next-line react/jsx-key */
_react.default.createElement(_icon.default, {
  color: "neutral",
  tint: "darkest"
}, /*#__PURE__*/_react.default.createElement(_uiIcons.IconCalendarSmallOutline, null)),
/*#__PURE__*/

/* eslint-disable-next-line react/jsx-key */
_react.default.createElement(_typography.TextBody, {
  color: "neutral"
}, "\u20AC")];
/* eslint-disable-next-line react/jsx-key */

var suffix = [/*#__PURE__*/_react.default.createElement(_typography.TextSmall, {
  key: "suffix1",
  color: "neutral"
}, "incl. BTW"), /*#__PURE__*/_react.default.createElement(_counter.default, {
  key: "suffix2",
  count: 99,
  maxCount: 100,
  size: "medium"
}), /*#__PURE__*/_react.default.createElement(_loadingSpinner.default, {
  key: "suffix3"
})];

var connectedLeft = /*#__PURE__*/_react.default.createElement(_button.default, {
  size: "medium",
  label: "\u20AC"
});

var connectedRight = /*#__PURE__*/_react.default.createElement(_button.default, {
  size: "medium"
}, /*#__PURE__*/_react.default.createElement(_checkbox.default, {
  size: "small"
}, "Discount"));

var stepperOptions = ['none', 'connected', 'suffix'];
var sizes = ['small', 'medium', 'large'];
var types = ['text', 'button', 'checkbox', 'color', 'date', 'datetime-local', 'email', 'file', 'hidden', 'image', 'month', 'number', 'password', 'radio', 'range', 'reset', 'search', 'submit', 'tel', 'time', 'url', 'week'];
var inputArgTypes = {
  size: {
    control: 'select',
    options: ['tiny'].concat(sizes)
  }
};
var _default = {
  component: _Input.default,
  title: (0, _utils.addStoryInGroup)(_utils.LOW_LEVEL_BLOCKS, 'Form elements/Input'),
  argTypes: {
    value: {
      control: {
        type: 'text'
      }
    }
  }
};
exports.default = _default;

var input = function input(args) {
  var _useState = (0, _react.useState)(''),
      _useState2 = (0, _slicedToArray2.default)(_useState, 2),
      value = _useState2[0],
      setValue = _useState2[1];

  var handleChange = function handleChange(event, value) {
    setValue(value);
  };

  return /*#__PURE__*/_react.default.createElement(_Input.default, (0, _extends2.default)({
    value: value,
    onChange: handleChange
  }, args));
};

exports.input = input;
input.storyName = 'Input';
input.args = {
  bold: false,
  disabled: false,
  error: '',
  helpText: '',
  success: '',
  warning: '',
  inverse: false,
  placeholder: placeholder,
  readOnly: false,
  size: 'medium',
  type: 'text',
  textAlignRight: false,
  width: ''
};
input.argTypes = _objectSpread(_objectSpread({}, inputArgTypes), {}, {
  type: {
    control: 'select',
    options: types
  }
});

var inputConnected = function inputConnected(args) {
  var _useState3 = (0, _react.useState)(''),
      _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
      value = _useState4[0],
      setValue = _useState4[1];

  var handleChange = function handleChange(event, value) {
    setValue(value);
  };

  return /*#__PURE__*/_react.default.createElement(_Input.default, (0, _extends2.default)({
    value: value,
    onChange: handleChange
  }, args));
};

exports.inputConnected = inputConnected;
inputConnected.storyName = 'Input with connected';
inputConnected.args = _objectSpread(_objectSpread({}, input.args), {}, {
  connectedLeft: connectedLeft,
  connectedRight: connectedRight
});
inputConnected.argTypes = _objectSpread(_objectSpread({}, inputArgTypes), {}, {
  type: {
    control: 'select',
    options: types
  }
});

var inputPrefixSuffix = function inputPrefixSuffix(args) {
  var _useState5 = (0, _react.useState)(''),
      _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
      value = _useState6[0],
      setValue = _useState6[1];

  var handleChange = function handleChange(event, value) {
    setValue(value);
  };

  return /*#__PURE__*/_react.default.createElement(_Input.default, (0, _extends2.default)({
    value: value,
    onChange: handleChange
  }, args));
};

exports.inputPrefixSuffix = inputPrefixSuffix;
inputPrefixSuffix.storyName = 'Input with prefix and suffix';
inputPrefixSuffix.args = _objectSpread(_objectSpread({}, input.args), {}, {
  prefix: prefix,
  suffix: suffix
});
inputPrefixSuffix.argTypes = _objectSpread(_objectSpread({}, inputArgTypes), {}, {
  type: {
    control: 'select',
    options: types
  }
});

var numericInput = function numericInput(args) {
  var _useState7 = (0, _react.useState)(6),
      _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
      value = _useState8[0],
      setValue = _useState8[1];

  var handleChange = function handleChange(event, value) {
    setValue(value);
  };

  return /*#__PURE__*/_react.default.createElement(_NumericInput.default, (0, _extends2.default)({
    value: value,
    onChange: handleChange
  }, args));
};

exports.numericInput = numericInput;
numericInput.storyName = 'NumericInput';
numericInput.args = {
  bold: false,
  disabled: false,
  error: '',
  helpText: '',
  success: '',
  warning: '',
  inverse: false,
  max: 10,
  min: 0,
  placeholder: placeholder,
  readOnly: false,
  size: 'medium',
  stepper: 'suffix',
  step: 1,
  textAlignRight: false,
  width: ''
};
numericInput.argTypes = _objectSpread(_objectSpread({}, inputArgTypes), {}, {
  stepper: {
    control: 'select',
    options: stepperOptions
  }
});

var timeInput = function timeInput(args) {
  var _useState9 = (0, _react.useState)(''),
      _useState10 = (0, _slicedToArray2.default)(_useState9, 2),
      value = _useState10[0],
      setValue = _useState10[1];

  var handleChange = function handleChange(event) {
    setValue(event.currentTarget.value);
  };

  return /*#__PURE__*/_react.default.createElement(_TimeInput.default, (0, _extends2.default)({
    value: value,
    onChange: handleChange
  }, args));
};

exports.timeInput = timeInput;
timeInput.storyName = 'TimeInput';
timeInput.args = {
  bold: false,
  disabled: false,
  error: '',
  helpText: '',
  success: '',
  warning: '',
  inverse: false,
  placeholder: placeholder,
  readOnly: false,
  size: 'medium',
  textAlighRight: false,
  width: '90px'
};
timeInput.argTypes = inputArgTypes;

var durationInput = function durationInput(args) {
  var _useState11 = (0, _react.useState)(),
      _useState12 = (0, _slicedToArray2.default)(_useState11, 2),
      value = _useState12[0],
      setValue = _useState12[1];

  var handleChange = function handleChange(value) {
    setValue(value);
  };

  return /*#__PURE__*/_react.default.createElement(_DurationInput.default, (0, _extends2.default)({
    value: value,
    onChange: handleChange
  }, args));
};

exports.durationInput = durationInput;
durationInput.storyName = 'DurationInput';

var textarea = function textarea(args) {
  var _useState13 = (0, _react.useState)(''),
      _useState14 = (0, _slicedToArray2.default)(_useState13, 2),
      value = _useState14[0],
      setValue = _useState14[1];

  var handleChange = function handleChange(event) {
    setValue(event.currentTarget.value);
  };

  return /*#__PURE__*/_react.default.createElement(_Textarea.default, (0, _extends2.default)({
    value: value,
    onChange: handleChange
  }, args));
};

exports.textarea = textarea;
textarea.storyName = 'Textarea';
textarea.args = {
  bold: false,
  disabled: false,
  error: '',
  helpText: '',
  success: '',
  warning: '',
  inverse: false,
  placeholder: placeholder,
  readOnly: false,
  size: 'medium',
  textAlignRight: false
};
textarea.argTypes = inputArgTypes;