<template>
<uni-shadow-root class="vant-calendar-components-header-index"><view class="van-calendar__header">
  <block v-if="showTitle">
    <view class="van-calendar__header-title"><slot name="title"></slot></view>
    <view class="van-calendar__header-title">{{ title }}</view>
  </block>

  <view v-if="showSubtitle" class="van-calendar__header-subtitle">
    {{ subtitle }}
  </view>

  <view class="van-calendar__weekdays">
    <view v-for="(item,index) in (weekdays)" :key="item.index" class="van-calendar__weekday">
      {{ item }}
    </view>
  </view>
</view></uni-shadow-root>
</template>

<script>

global['__wxRoute'] = 'vant/calendar/components/header/index'
import { VantComponent } from '../../../common/component';
VantComponent({
  props: {
    title: {
      type: String,
      value: '日期选择',
    },
    subtitle: String,
    showTitle: Boolean,
    showSubtitle: Boolean,
    firstDayOfWeek: {
      type: Number,
      observer: 'initWeekDay',
    },
  },
  data: {
    weekdays: [],
  },
  created() {
    this.initWeekDay();
  },
  methods: {
    initWeekDay() {
      const defaultWeeks = ['日', '一', '二', '三', '四', '五', '六'];
      const firstDayOfWeek = this.data.firstDayOfWeek || 0;
      this.setData({
        weekdays: [
          ...defaultWeeks.slice(firstDayOfWeek, 7),
          ...defaultWeeks.slice(0, firstDayOfWeek),
        ],
      });
    },
  },
});
export default global['__wxComponents']['vant/calendar/components/header/index']
</script>
<style platform="mp-weixin">
@import '../../../common/index.css';

.van-calendar__header {
  -webkit-flex-shrink: 0;
  flex-shrink: 0;
  box-shadow: 0 4rpx 20rpx rgba(125,126,128,.16);
  box-shadow: var(--calendar-header-box-shadow,0 4rpx 20rpx rgba(125,126,128,.16));
}

.van-calendar__header-subtitle,
.van-calendar__header-title {
  text-align: center;
  height: 88rpx;
  height: var(--calendar-header-title-height,88rpx);
  font-weight: 500;
  font-weight: var(--font-weight-bold,500);
  line-height: 88rpx;
  line-height: var(--calendar-header-title-height,88rpx);
}

.van-calendar__header-title+.van-calendar__header-title,
.van-calendar__header-title:empty {
  display: none;
}

.van-calendar__header-title:empty+.van-calendar__header-title {
  display: block!important;
}

.van-calendar__weekdays {
  display: -webkit-flex;
  display: flex;
}

.van-calendar__weekday {
  -webkit-flex: 1;
  flex: 1;
  text-align: center;
  font-size: 24rpx;
  font-size: var(--calendar-weekdays-font-size,24rpx);
  line-height: 60rpx;
  line-height: var(--calendar-weekdays-height,60rpx);
}
</style>