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

'use strict';

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

var tdesignIconsVue = require('tdesign-icons-vue');
var button_button = require('../../button/button.js');
var utils_mixins = require('../../utils/mixins.js');
var configProvider_configReceiver = require('../../config-provider/config-receiver.js');
var config = require('../../config.js');
require('../../_chunks/dep-99705d51.js');
require('@babel/runtime/helpers/defineProperty');
require('../../utils/classnames.js');
require('../../loading/index.js');
require('../../loading/loading.js');
require('vue');
require('../../loading/icon/gradient.js');
require('../../_common/js/loading/circle-adapter.js');
require('../../_common/js/utils/set-style.js');
require('../../_common/js/utils/helper.js');
require('@babel/runtime/helpers/objectWithoutProperties');
require('@babel/runtime/helpers/slicedToArray');
require('../../utils/dom.js');
require('raf');
require('lodash/isString');
require('../../utils/easing.js');
require('../../utils/render-tnode.js');
require('@babel/runtime/helpers/typeof');
require('../../utils/transfer-dom.js');
require('../../loading/props.js');
require('../../utils/withInstall.js');
require('lodash/capitalize');
require('../../loading/plugin.js');
require('../../button/props.js');
require('../../utils/ripple.js');
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');

var TDateHeader = utils_mixins["default"](configProvider_configReceiver["default"]("datePicker")).extend({
  components: {
    TButton: button_button["default"],
    RoundIcon: tdesignIconsVue.RoundIcon,
    ChevronLeftIcon: tdesignIconsVue.ChevronLeftIcon,
    ChevronRightIcon: tdesignIconsVue.ChevronRightIcon
  },
  props: {
    year: Number,
    month: Number,
    type: {
      type: String,
      "default": "date",
      validator: function validator(v) {
        return ["year", "month", "date"].indexOf(v) > -1;
      }
    },
    onBtnClick: Function,
    onTypeChange: Function
  },
  render: function render() {
    var h = arguments[0];
    var _this$$props = this.$props,
        type = _this$$props.type,
        year = _this$$props.year,
        month = _this$$props.month,
        onBtnClick = _this$$props.onBtnClick,
        onTypeChange = _this$$props.onTypeChange;
    var startYear = parseInt((this.year / 10).toString(), 10) * 10;
    var _this$global = this.global,
        rangeSeparator = _this$global.rangeSeparator,
        yearAriaLabel = _this$global.yearAriaLabel,
        now = _this$global.now,
        preMonth = _this$global.preMonth,
        preYear = _this$global.preYear,
        nextMonth = _this$global.nextMonth,
        nextYear = _this$global.nextYear,
        preDecade = _this$global.preDecade,
        nextDecade = _this$global.nextDecade;
    var preLabel;
    var nextLabel;

    if (type === "year") {
      preLabel = preDecade;
      nextLabel = nextDecade;
    } else if (type === "date") {
      preLabel = preMonth;
      nextLabel = nextMonth;
    } else {
      preLabel = preYear;
      nextLabel = nextYear;
    }

    return h("div", {
      "class": "".concat(config.prefix, "-date-picker__header")
    }, [h("span", {
      "class": "".concat(config.prefix, "-date-picker__header-title")
    }, [type === "year" && h("span", [h("span", [startYear]), rangeSeparator, h("span", [startYear + 9])]), type !== "year" && h("t-button", {
      "class": "".concat(config.prefix, "-date-picker__header-btn"),
      "attrs": {
        "variant": "text",
        "size": "small"
      },
      "on": {
        "click": function click() {
          return onTypeChange("year");
        }
      }
    }, ["".concat(year, " ").concat(yearAriaLabel)]), type === "date" && h("t-button", {
      "class": "".concat(config.prefix, "-date-picker__header-btn"),
      "attrs": {
        "variant": "text",
        "size": "small"
      },
      "on": {
        "click": function click() {
          return onTypeChange("month");
        }
      }
    }, [this.global.months[month]])]), h("span", {
      "class": "".concat(config.prefix, "-date-picker__header-controller")
    }, [h("t-button", {
      "class": "".concat(config.prefix, "-date-picker__header-controller__btn"),
      "attrs": {
        "variant": "text",
        "title": preLabel
      },
      "on": {
        "click": function click() {
          return onBtnClick(-1);
        }
      }
    }, [h("chevron-left-icon", {
      "slot": "icon"
    })]), h("t-button", {
      "class": ["".concat(config.prefix, "-date-picker__header-controller__btn"), "".concat(config.prefix, "-date-picker__header-controller__btn--now")],
      "attrs": {
        "variant": "text",
        "title": now
      },
      "on": {
        "click": function click() {
          return onBtnClick(0);
        }
      }
    }, [h("round-icon", {
      "slot": "icon"
    })]), h("t-button", {
      "class": "".concat(config.prefix, "-date-picker__header-controller__btn"),
      "attrs": {
        "variant": "text",
        "title": nextLabel
      },
      "on": {
        "click": function click() {
          return onBtnClick(1);
        }
      }
    }, [h("chevron-right-icon", {
      "slot": "icon"
    })])])]);
  }
});

exports["default"] = TDateHeader;
//# sourceMappingURL=header.js.map
