import * as moment from 'moment'; import Calendar from '../vc-calendar'; import VcDatePicker from '../vc-calendar/src/Picker'; import Icon from '../icon'; import { ConfigConsumerProps } from '../config-provider'; import { hasProp, getOptionProps, initDefaultProps, getComponentFromProp, isValidElement, getListeners, } from '../_util/props-util'; import BaseMixin from '../_util/BaseMixin'; import { WeekPickerProps } from './interface'; import interopDefault from '../_util/interopDefault'; import { cloneElement } from '../_util/vnode'; import InputIcon from './InputIcon'; function formatValue(value, format) { return (value && value.format(format)) || ''; } function noop() {} export default { // static defaultProps = { // format: 'YYYY-wo', // allowClear: true, // }; // private input: any; name: 'AWeekPicker', mixins: [BaseMixin], model: { prop: 'value', event: 'change', }, props: initDefaultProps(WeekPickerProps(), { format: 'gggg-wo', allowClear: true, }), inject: { configProvider: { default: () => ConfigConsumerProps }, }, data() { const value = this.value || this.defaultValue; if (value && !interopDefault(moment).isMoment(value)) { throw new Error( 'The value/defaultValue of WeekPicker or MonthPicker must be ' + 'a moment object', ); } return { _value: value, _open: this.open, }; }, watch: { value(val) { const state = { _value: val }; this.setState(state); this.prevState = { ...this.$data, ...state }; }, open(val) { const state = { _open: val }; this.setState(state); this.prevState = { ...this.$data, ...state }; }, _open(val, oldVal) { this.$nextTick(() => { if (!hasProp(this, 'open') && oldVal && !val) { this.focus(); } }); }, }, mounted() { this.prevState = { ...this.$data }; }, updated() { this.$nextTick(() => { if (!hasProp(this, 'open') && this.prevState._open && !this._open) { this.focus(); } }); }, methods: { weekDateRender(current) { const selectedValue = this.$data._value; const { _prefixCls: prefixCls, $scopedSlots } = this; const dateRender = this.dateRender || $scopedSlots.dateRender; const dateNode = dateRender ? dateRender(current) : current.date(); if ( selectedValue && current.year() === selectedValue.year() && current.week() === selectedValue.week() ) { return (