"use strict";

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

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

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

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

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

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

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

var _luxon = require("luxon");

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 languages = ['da-DK', 'de-DE', 'en-GB', 'en-US', 'es-ES', 'fi-FI', 'fr-BE', 'fr-FR', 'it-IT', 'nb-NO', 'nl-BE', 'nl-NL', 'pl-PL', 'pt-PT', 'sv-SE', 'tr-TR'];
var sizes = ['small', 'medium', 'large'];
var optionalSizes = {
  small: 'small',
  medium: 'medium',
  large: 'large',
  none: null
};

var customFormatDate = function customFormatDate(date, locale) {
  return _luxon.DateTime.fromJSDate(date).setLocale(locale).toLocaleString(_luxon.DateTime.DATETIME_HUGE);
};

var inputPlaceholderToday = function inputPlaceholderToday() {
  var locale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'nl-BE';
  return _luxon.DateTime.fromJSDate(new Date()).setLocale(locale).toLocaleString(_luxon.DateTime.DATE_SHORT);
};

var preSelectedDate = _luxon.DateTime.local().plus({
  days: 3
}).toJSDate();

var _default = {
  component: _index.DatePicker,
  title: (0, _utils.addStoryInGroup)(_utils.LOW_LEVEL_BLOCKS, 'Form elements/DatePicker')
};
exports.default = _default;

var singleDate = function singleDate(args) {
  var handleOnChange = function handleOnChange(selectedDate) {
    console.log('Selected date', selectedDate);
  };

  return /*#__PURE__*/_react.default.createElement(_index.DatePicker, (0, _extends2.default)({
    onChange: handleOnChange,
    selectedDate: preSelectedDate
  }, args));
};

exports.singleDate = singleDate;
singleDate.storyName = 'Single date';
singleDate.args = {
  bordered: true,
  className: '',
  modifiers: {
    today: true,
    outside: true
  },
  selectedDate: new Date(),
  size: 'medium',
  withMonthPicker: true,
  showWeekNumbers: true
};
singleDate.parameters = {
  design: [{
    name: 'Figma',
    type: 'figma',
    url: 'https://www.figma.com/file/LHH25GN90ljQaBEUNMsdJn/Desktop-components?node-id=980%3A0'
  }, {
    name: 'Vendor docs',
    type: 'iframe',
    url: 'http://react-day-picker.js.org/api/DayPicker'
  }]
};

var inputSingleDate = function inputSingleDate(args) {
  var handleOnChange = function handleOnChange(selectedDate) {
    console.log('Selected date', selectedDate);
  };

  return /*#__PURE__*/_react.default.createElement(_index.DatePickerInput, (0, _extends2.default)({}, args, {
    dayPickerProps: _objectSpread({}, args.dayPickerProps),
    inputProps: _objectSpread(_objectSpread({}, args.inputProps), {}, {
      placeholder: inputPlaceholderToday(args.locale)
    }),
    footer: /*#__PURE__*/_react.default.createElement(_index.Toggle, {
      label: "Lorem ipsum dolor sit amet, suspendisse faucibus nunc et pellentesque",
      size: "small"
    }),
    formatDate: customFormatDate,
    onChange: handleOnChange,
    selectedDate: preSelectedDate
  }));
};

exports.inputSingleDate = inputSingleDate;
inputSingleDate.storyName = 'Input single date';
inputSingleDate.args = {
  dayPickerProps: {
    numberOfMonths: 1,
    showOutsideDays: true,
    showWeekNumbers: true,
    withMonthPicker: false
  },
  inputProps: {
    bold: false,
    disable: false,
    error: '',
    helpText: 'Pick a date',
    inverse: false,
    warning: '',
    readonly: false,
    width: ''
  },
  locale: 'nl-BE',
  size: 'medium',
  inputSize: undefined,
  datePickerSize: undefined
};
inputSingleDate.argTypes = {
  locale: {
    control: 'select',
    options: languages
  },
  size: {
    control: 'select',
    options: sizes
  },
  inputSize: {
    control: 'select',
    options: optionalSizes
  },
  datePickerSize: {
    control: 'select',
    options: optionalSizes
  }
};
inputSingleDate.parameters = {
  design: [{
    name: 'Figma',
    type: 'figma',
    url: 'https://www.figma.com/file/LHH25GN90ljQaBEUNMsdJn/Desktop-components?node-id=980%3A0'
  }, {
    name: 'Vendor docs',
    type: 'iframe',
    url: 'http://react-day-picker.js.org/api/DayPickerInput'
  }]
};