diff --git a/antdv-demo b/antdv-demo index aae9db4ae..e5569f281 160000 --- a/antdv-demo +++ b/antdv-demo @@ -1 +1 @@ -Subproject commit aae9db4ae607a00f4c8482c159bfaf71fe982595 +Subproject commit e5569f28132b299accd77cbbbb7354f6308d25e5 diff --git a/components/calendar/Header.jsx b/components/calendar/Header.jsx index e69643bdb..d89db1133 100644 --- a/components/calendar/Header.jsx +++ b/components/calendar/Header.jsx @@ -1,3 +1,4 @@ +import { inject } from 'vue'; import Select from '../select'; import { Group, Button } from '../radio'; import PropTypes from '../_util/vue-types'; @@ -24,22 +25,26 @@ export const HeaderProps = { yearSelectOffset: PropTypes.number, yearSelectTotal: PropTypes.number, type: PropTypes.string, - // onValueChange: PropTypes.(value: moment.Moment) => void, - // onTypeChange: PropTypes.(type: string) => void, value: PropTypes.any, validRange: PropTypes.array, headerRender: PropTypes.func, + onValueChange: PropTypes.func, + onTypeChange: PropTypes.func, }; export default { + name: 'CalendarHeader', + inheritAttrs: false, props: initDefaultProps(HeaderProps, { yearSelectOffset: 10, yearSelectTotal: 20, }), - inject: { - configProvider: { default: () => ConfigConsumerProps }, + setup() { + return { + configProvider: inject('configProvider', ConfigConsumerProps), + }; }, - // private calenderHeaderNode: HTMLDivElement; + // private calendarHeaderNode: HTMLDivElement; methods: { getYearSelectElement(prefixCls, year) { const { yearSelectOffset, yearSelectTotal, locale = {}, fullscreen, validRange } = this; @@ -62,7 +67,7 @@ export default { class={`${prefixCls}-year-select`} onChange={this.onYearChange} value={String(year)} - getPopupContainer={() => this.getCalenderHeaderNode()} + getPopupContainer={() => this.calenderHeaderNode} > {options} @@ -95,7 +100,7 @@ export default { class={`${prefixCls}-month-select`} value={String(month)} onChange={this.onMonthChange} - getPopupContainer={() => this.getCalenderHeaderNode()} + getPopupContainer={() => this.calendarHeaderNode} > {options} @@ -128,16 +133,12 @@ export default { }, onInternalTypeChange(e) { - this.onTypeChange(e.target.value); + this.triggerTypeChange(e.target.value); }, - onTypeChange(val) { + triggerTypeChange(val) { this.$emit('typeChange', val); }, - - getCalenderHeaderNode() { - return this.$refs.calenderHeaderNode; - }, getMonthYearSelections(getPrefixCls) { const { prefixCls: customizePrefixCls, type, value } = this.$props; @@ -163,16 +164,19 @@ export default { ); }, - onValueChange() { + triggerValueChange() { this.$emit('valueChange', ...arguments); }, + saveCalendarHeaderNode(node) { + this.calendarHeaderNode = node; + }, headerRenderCustom(headerRender) { const { type, value } = this.$props; return headerRender({ value, type: type || 'month', - onChange: this.onValueChange, - onTypeChange: this.onTypeChange, + onChange: this.triggerValueChange, + onTypeChange: this.triggerTypeChange, }); }, }, @@ -186,7 +190,7 @@ export default { return headerRender ? ( this.headerRenderCustom(headerRender) ) : ( -