/**
 * tdesign v0.41.7
 * (c) 2022 tdesign
 * @license MIT
 */

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var config = require('../../config.js');
var datePicker_basic_cell = require('./cell.js');
var utils_mixins = require('../../utils/mixins.js');
var configProvider_configReceiver = require('../../config-provider/config-receiver.js');
require('vue');
require('lodash/mergeWith');
require('../../config-provider/context.js');
require('lodash/merge');
require('../../_common/js/global-config/default-config.js');
require('../../_common/js/global-config/locale/zh_CN.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);

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) { _defineProperty__default["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 name = "".concat(config.prefix, "-date-picker-table");
var DAY_NAMES = ["\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D", "\u65E5"];
var TDateTable = utils_mixins["default"](configProvider_configReceiver["default"]("datePicker")).extend({
  name: name,
  components: {
    TDatePickerCell: datePicker_basic_cell["default"]
  },
  props: {
    type: {
      type: String,
      "default": "day"
    },
    data: Array,
    firstDayOfWeek: Number,
    dayNames: {
      type: Array,
      "default": function _default() {
        return DAY_NAMES;
      }
    },
    onCellClick: {
      type: Function
    },
    onCellMouseEnter: {
      type: Function
    }
  },
  render: function render() {
    var h = arguments[0];
    var type = this.type,
        data = this.data,
        onCellClick = this.onCellClick,
        onCellMouseEnter = this.onCellMouseEnter,
        firstDayOfWeek = this.firstDayOfWeek;
    var weekdays = this.global.weekdays;
    var weekArr = [];
    var wi = firstDayOfWeek - 1;
    var len = weekdays.length;

    while (weekArr.length < len) {
      weekArr.push(weekdays[wi]);
      wi = (wi + len + 1) % len;
    }

    var panelClass = "".concat(config.prefix, "-date-picker--").concat(type);
    return h("div", {
      "class": panelClass
    }, [h("table", [type === "date" && h("thead", [h("tr", [weekArr.map(function (value, i) {
      return h("th", {
        "key": i
      }, [value]);
    })])]), h("tbody", [data.map(function (row, i) {
      return h("tr", {
        "key": i
      }, [row.map(function (col, j) {
        return h("t-date-picker-cell", {
          "props": _objectSpread({}, _objectSpread(_objectSpread({}, col), {}, {
            onClick: onCellClick,
            onMouseEnter: onCellMouseEnter
          })),
          "key": j
        });
      })]);
    })])])]);
  }
});

exports["default"] = TDateTable;
//# sourceMappingURL=table.js.map
