/**
 * tdesign v0.32.0
 * (c) 2021 tdesign
 * @license MIT
 */

import { ChevronLeftIcon, ChevronRightIcon, RoundIcon } from 'tdesign-icons-vue';
import TButton from '../../button/button.js';
import mixins from '../../utils/mixins.js';
import getConfigReceiverMixins from '../../config-provider/config-receiver.js';
import { prefix } from '../../config.js';
import '@babel/runtime/helpers/defineProperty';
import 'vue';
import '../../utils/classnames.js';
import '../../loading/index.js';
import '../../loading/loading.js';
import '../../loading/icon/gradient.js';
import '../../utils/set-style.js';
import '../../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../../utils/easing.js';
import '../../utils/render-tnode.js';
import '@babel/runtime/helpers/typeof';
import '../../utils/transfer-dom.js';
import '../../loading/props.js';
import '../../utils/withInstall.js';
import 'lodash/capitalize';
import './style/index.js';
import '../../loading/type.js';
import '../../loading/plugin.js';
import '../../button/props.js';
import '../../utils/ripple.js';
import '../../config-provider/zh_CN_config.js';
import '../../config-provider/type.js';

var TDateHeader = mixins(getConfigReceiverMixins("datePicker")).extend({
  components: {
    TButton: TButton,
    TIconChevronLeft: ChevronLeftIcon,
    TIconChevronRight: ChevronRightIcon,
    TIconRound: RoundIcon
  },
  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(prefix, "-date-picker__header")
    }, [h("span", {
      "class": "".concat(prefix, "-date-picker__header-title")
    }, [type === "year" && h("span", [h("span", [startYear]), rangeSeparator, h("span", [startYear + 9])]), type !== "year" && h("t-button", {
      "class": "".concat(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(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(prefix, "-date-picker__header-controller")
    }, [h("t-button", {
      "class": "".concat(prefix, "-date-picker__header-controller__btn"),
      "attrs": {
        "variant": "text",
        "title": preLabel
      },
      "on": {
        "click": function click() {
          return onBtnClick(-1);
        }
      }
    }, [h("t-icon-chevron-left", {
      "slot": "icon"
    })]), h("t-button", {
      "class": ["".concat(prefix, "-date-picker__header-controller__btn"), "".concat(prefix, "-date-picker__header-controller__btn--now")],
      "attrs": {
        "variant": "text",
        "title": now
      },
      "on": {
        "click": function click() {
          return onBtnClick(0);
        }
      }
    }, [h("t-icon-round", {
      "slot": "icon"
    })]), h("t-button", {
      "class": "".concat(prefix, "-date-picker__header-controller__btn"),
      "attrs": {
        "variant": "text",
        "title": nextLabel
      },
      "on": {
        "click": function click() {
          return onBtnClick(1);
        }
      }
    }, [h("t-icon-chevron-right", {
      "slot": "icon"
    })])])]);
  }
});

export { TDateHeader as default };
//# sourceMappingURL=header.js.map
