"use strict";

function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.VmFilterItem = exports.VMSelect = exports.VMRangePicker = exports.VMRadioTime = exports.VMMonthPicker = exports.VMDatePicker = exports.Radio = void 0;
var _tslib = require("tslib");
var _react = _interopRequireWildcard(require("react"));
var _antd = require("antd");
var _zh_CN = _interopRequireDefault(require("antd/es/date-picker/locale/zh_CN"));
require("moment/locale/zh-cn");
var _useSettings5 = _interopRequireDefault(require("../vm-hooks/useSettings"));
var _vmRadio = _interopRequireWildcard(require("../vm-radio"));
require("./style");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
var RangePicker = _antd.DatePicker.RangePicker,
  MonthPicker = _antd.DatePicker.MonthPicker;
/**
 * 二次封装的日期选择器
 * @param props
 * @returns
 */
var VMRangePicker = exports.VMRangePicker = function VMRangePicker(props) {
  var _useSettings = (0, _useSettings5["default"])(),
    theme = _useSettings.theme;
  return /*#__PURE__*/_react["default"].createElement(RangePicker, Object.assign({
    className: "vm-range-picker ".concat(theme),
    dropdownClassName: "vm-range-picker-dropdown ".concat(theme),
    allowClear: false
  }, props, {
    locale: _zh_CN["default"]
  }));
};
var VMDatePicker = exports.VMDatePicker = function VMDatePicker(props) {
  var _useSettings2 = (0, _useSettings5["default"])(),
    theme = _useSettings2.theme;
  return /*#__PURE__*/_react["default"].createElement(_antd.DatePicker, Object.assign({
    className: "vm-range-picker ".concat(theme),
    dropdownClassName: "vm-range-picker-dropdown ".concat(theme),
    allowClear: false
  }, props, {
    locale: _zh_CN["default"]
  }));
};
var VMMonthPicker = exports.VMMonthPicker = function VMMonthPicker(props) {
  var _useSettings3 = (0, _useSettings5["default"])(),
    theme = _useSettings3.theme;
  return /*#__PURE__*/_react["default"].createElement(MonthPicker, Object.assign({
    className: "vm-range-picker ".concat(theme),
    dropdownClassName: "vm-range-picker-dropdown ".concat(theme),
    allowClear: false
  }, props, {
    locale: _zh_CN["default"]
  }));
};
var VMSelect = exports.VMSelect = function VMSelect(props) {
  var _useSettings4 = (0, _useSettings5["default"])(),
    theme = _useSettings4.theme;
  return /*#__PURE__*/_react["default"].createElement(_antd.Select, Object.assign({
    className: "vm-select ".concat(theme),
    dropdownClassName: "vm-select-dropdown ".concat(theme)
  }, props), props.children);
};
var Radio = exports.Radio = function Radio(props) {
  var _props$itemProps = props.itemProps,
    itemProps = _props$itemProps === void 0 ? {} : _props$itemProps,
    defaultValue = props.defaultValue,
    style = props.style,
    height = props.height;
  var _itemProps$options = itemProps.options,
    options = _itemProps$options === void 0 ? [] : _itemProps$options,
    ext = (0, _tslib.__rest)(itemProps, ["options"]);
  var _onChange = props.onChange || itemProps.onChange;
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "vm-radio",
    style: style
  }, /*#__PURE__*/_react["default"].createElement(_vmRadio.VmRadioGroup, Object.assign({
    defaultValue: defaultValue
  }, ext, {
    onChange: function onChange(e) {
      _onChange && _onChange(e);
    }
  }), options.map(function (v, index) {
    return /*#__PURE__*/_react["default"].createElement(_vmRadio["default"], {
      key: index,
      value: v.value,
      style: {
        width: v.width,
        height: height
      }
    }, v.title || v.label || v.name);
  })));
};
var VMRadioTime = exports.VMRadioTime = function VMRadioTime(props) {
  var _props$itemProps2 = props.itemProps,
    itemProps = _props$itemProps2 === void 0 ? {} : _props$itemProps2,
    defaultValue = props.defaultValue,
    timeStyle = props.timeStyle;
  var onRadioChange = itemProps.onRadioChange,
    onTimeChange = itemProps.onTimeChange,
    defaultTimeValue = itemProps.defaultTimeValue;
  var _useState = (0, _react.useState)(defaultValue || 'date'),
    _useState2 = _slicedToArray(_useState, 2),
    picker = _useState2[0],
    setPicker = _useState2[1];
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "vm-radioTime"
  }, /*#__PURE__*/_react["default"].createElement(Radio, Object.assign({}, props, {
    onChange: function onChange(e) {
      var _a;
      setPicker((_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.value);
      onRadioChange && onRadioChange(e);
    }
  })), /*#__PURE__*/_react["default"].createElement(VMRangePicker, {
    picker: picker,
    defaultValue: defaultTimeValue,
    style: timeStyle,
    onChange: function onChange(e) {
      onTimeChange && onTimeChange(e);
    }
  }));
};
var VmFilterItem = exports.VmFilterItem = function VmFilterItem(props) {
  var _props$items = props.items,
    items = _props$items === void 0 ? [] : _props$items,
    _props$style = props.style,
    style = _props$style === void 0 ? {} : _props$style;
  var Filter = {
    radio: Radio,
    radioTime: VMRadioTime,
    datePicker: VMDatePicker,
    rangePicker: VMRangePicker,
    select: VMSelect,
    input: _antd.Input
  };
  return /*#__PURE__*/_react["default"].createElement("div", null, items.map(function (item, i) {
    // @ts-ignore
    var P = Filter[item.type];
    return /*#__PURE__*/_react["default"].createElement("div", {
      key: i,
      className: "vm-filter",
      style: Object.assign({}, style)
    }, item.label && /*#__PURE__*/_react["default"].createElement("span", {
      className: "vm-filter-label"
    }, item.label), P ? /*#__PURE__*/_react["default"].createElement(P, Object.assign({}, item)) : null);
  }));
};
//# sourceMappingURL=index.js.map
