import * as moment from 'moment' import Calendar from '../vc-calendar' import VcDatePicker from '../vc-calendar/src/Picker' import Icon from '../icon' import { hasProp, getOptionProps, initDefaultProps } from '../_util/props-util' import BaseMixin from '../_util/BaseMixin' import { WeekPickerProps } from './interface' import interopDefault from '../_util/interopDefault' function formatValue (value, format) { return (value && value.format(format)) || '' } function noop () {} export default { // static defaultProps = { // format: 'YYYY-wo', // allowClear: true, // }; // private input: any; props: initDefaultProps(WeekPickerProps(), { format: 'gggg-wo', allowClear: true, }), name: 'AWeekPicker', mixins: [BaseMixin], model: { prop: 'value', event: 'change', }, data () { const value = this.value || this.defaultValue if (value && !interopDefault(moment).isMoment(value)) { throw new Error( 'The value/defaultValue of DatePicker or MonthPicker must be ' + 'a moment object', ) } return { sValue: value, } }, watch: { value (val) { this.setState({ sValue: val }) }, }, methods: { weekDateRender (current) { const selectedValue = this.sValue const { prefixCls } = this if (selectedValue && current.year() === selectedValue.year() && current.week() === selectedValue.week()) { return (