/**
 * tdesign v0.39.1-alpha.1
 * (c) 2022 tdesign
 * @license MIT
 */

import { RoundIcon, ChevronLeftIcon, ChevronRightIcon } 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 '../../_chunks/dep-1ec74b8b.js';
import '@babel/runtime/helpers/defineProperty';
import '../../utils/classnames.js';
import '../../loading/index.js';
import '../../loading/loading.js';
import 'vue';
import '../../loading/icon/gradient.js';
import '../../_common/js/loading/circle-adapter.js';
import '../../_common/js/utils/set-style.js';
import '../../_common/js/utils/helper.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '@babel/runtime/helpers/slicedToArray';
import '../../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../../utils/easing.js';
import '../../utils/render-tnode.js';
import '@babel/runtime/helpers/typeof';
import 'lodash/isObject';
import '../../utils/transfer-dom.js';
import '../../loading/props.js';
import '../../utils/withInstall.js';
import 'lodash/capitalize';
import './style/css.js';
import '../../loading/type.js';
import '../../loading/plugin.js';
import '../../button/props.js';
import '../../utils/ripple.js';
import 'lodash/mergeWith';
import '../../config-provider/context.js';
import 'lodash/merge';
import '../../_common/js/global-config/default-config.js';
import '../../_common/js/global-config/locale/zh_CN.js';
import '../../config-provider/type.js';

var TDateHeader = mixins(getConfigReceiverMixins("datePicker")).extend({
  components: {
    TButton: TButton,
    RoundIcon: RoundIcon,
    ChevronLeftIcon: ChevronLeftIcon,
    ChevronRightIcon: 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(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("chevron-left-icon", {
      "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("round-icon", {
      "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("chevron-right-icon", {
      "slot": "icon"
    })])])]);
  }
});

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