diff --git a/antdv-demo b/antdv-demo index e5569f281..2bead0607 160000 --- a/antdv-demo +++ b/antdv-demo @@ -1 +1 @@ -Subproject commit e5569f28132b299accd77cbbbb7354f6308d25e5 +Subproject commit 2bead0607865ddfbb49f958507d55249b9b0f3c4 diff --git a/breakChange-2.x.md b/breakChange-2.x.md index 76f2c1293..fa4b9fe4c 100644 --- a/breakChange-2.x.md +++ b/breakChange-2.x.md @@ -97,3 +97,11 @@ renderItem(item, index) => renderItem({item, index}) 该用单参数 ## TreeSelect treeData 中 scopedSlots => slots , v-model => v-model:value + +## datePicker + +dateRender + +(current: moment.Moment, today: moment.Moment) => ({current: moment.Moment, today: moment.Moment}) + +monthCellContentRender (date, locale) => ({date, locale}) diff --git a/components/calendar/Header.jsx b/components/calendar/Header.jsx index d89db1133..3d04b510f 100644 --- a/components/calendar/Header.jsx +++ b/components/calendar/Header.jsx @@ -58,7 +58,7 @@ export default { const options = []; for (let index = start; index < end; index++) { - options.push(); + options.push(); } return ( @@ -90,7 +90,7 @@ export default { } } for (let index = start; index < end; index++) { - options.push(); + options.push(); } return ( diff --git a/components/calendar/index.jsx b/components/calendar/index.jsx index 316aacc0d..e67570f3a 100644 --- a/components/calendar/index.jsx +++ b/components/calendar/index.jsx @@ -143,24 +143,24 @@ const Calendar = { }; return result; }, - monthCellRender2(value) { + monthCellRender2({ current: value }) { const { _sPrefixCls, $slots } = this; const monthCellRender = this.monthCellRender || $slots.monthCellRender || noop; return (
{value.localeData().monthsShort(value)}
-
{monthCellRender(value)}
+
{monthCellRender({ current: value })}
); }, - dateCellRender2(value) { + dateCellRender2({ current: value }) { const { _sPrefixCls, $slots } = this; const dateCellRender = this.dateCellRender || $slots.dateCellRender || noop; return (
{zerofixed(value.date())}
-
{dateCellRender(value)}
+
{dateCellRender({ current: value })}
); }, diff --git a/components/date-picker/RangePicker.jsx b/components/date-picker/RangePicker.jsx index 96d9fa74c..395fac141 100644 --- a/components/date-picker/RangePicker.jsx +++ b/components/date-picker/RangePicker.jsx @@ -414,7 +414,7 @@ export default { onMouseenter={this.onMouseEnter} onMouseleave={this.onMouseLeave} > - + ); }, diff --git a/components/date-picker/WeekPicker.jsx b/components/date-picker/WeekPicker.jsx index 039856caf..04f768614 100644 --- a/components/date-picker/WeekPicker.jsx +++ b/components/date-picker/WeekPicker.jsx @@ -74,11 +74,11 @@ export default { saveInput(node) { this.input = node; }, - weekDateRender(current) { + weekDateRender({ current }) { const selectedValue = this.$data._value; const { _prefixCls: prefixCls, $slots } = this; const dateRender = this.dateRender || $slots.dateRender; - const dateNode = dateRender ? dateRender(current) : current.date(); + const dateNode = dateRender ? dateRender({ current }) : current.date(); if ( selectedValue && current.year() === selectedValue.year() && @@ -208,7 +208,7 @@ export default { }; return ( - + ); }, diff --git a/components/date-picker/createPicker.js b/components/date-picker/createPicker.js index bab5b65a7..9aea18f82 100644 --- a/components/date-picker/createPicker.js +++ b/components/date-picker/createPicker.js @@ -106,11 +106,11 @@ export default function createPicker(TheCalendar, props) { this.$emit('openChange', open); }, focus() { - this.input.focus(); + this.input?.focus(); }, blur() { - this.input.blur(); + this.input?.blur(); }, renderFooter(...args) { const { $slots, _prefixCls: prefixCls } = this; @@ -235,7 +235,6 @@ export default function createPicker(TheCalendar, props) { open, onOpenChange: this.handleOpenChange, style: props.popupStyle, - children: input, }; return ( - + ); }, diff --git a/components/date-picker/interface.js b/components/date-picker/interface.js index fdaa4fe10..a15fbd557 100644 --- a/components/date-picker/interface.js +++ b/components/date-picker/interface.js @@ -20,7 +20,7 @@ export const PickerProps = () => ({ open: PropTypes.bool, disabledDate: PropTypes.func, showToday: PropTypes.bool, - dateRender: PropTypes.any, // (current: moment.Moment, today: moment.Moment) => React.ReactNode, + dateRender: PropTypes.any, // ({current: moment.Moment, today: moment.Moment}) => vNode, pickerClass: PropTypes.string, pickerInputClass: PropTypes.string, timePicker: PropTypes.any, diff --git a/components/vc-calendar/src/Picker.jsx b/components/vc-calendar/src/Picker.jsx index 69be36689..fb8308e4a 100644 --- a/components/vc-calendar/src/Picker.jsx +++ b/components/vc-calendar/src/Picker.jsx @@ -34,7 +34,6 @@ const Picker = { format: PropTypes.oneOfType([PropTypes.string, PropTypes.array, PropTypes.func]), // onChange: PropTypes.func, // onOpenChange: PropTypes.func, - children: PropTypes.func, getCalendarContainer: PropTypes.func, calendar: PropTypes.any, open: PropTypes.bool, @@ -46,7 +45,7 @@ const Picker = { align: PropTypes.object.def(() => ({})), dropdownClassName: PropTypes.string, dateRender: PropTypes.func, - children: PropTypes.func.isRequired, + children: PropTypes.func, }, mixins: [BaseMixin], @@ -214,7 +213,7 @@ const Picker = { value: sValue, open: sOpen, }; - const children = this.children(childrenState, props); + const children = this.$slots.default(childrenState); if (this.sOpen || !this.calendarElement) { this.calendarElement = this.getCalendarElement(); } diff --git a/components/vc-calendar/src/calendar/CalendarHeader.jsx b/components/vc-calendar/src/calendar/CalendarHeader.jsx index 5642817f4..4c0652f49 100644 --- a/components/vc-calendar/src/calendar/CalendarHeader.jsx +++ b/components/vc-calendar/src/calendar/CalendarHeader.jsx @@ -1,6 +1,6 @@ import PropTypes from '../../../_util/vue-types'; import BaseMixin from '../../../_util/BaseMixin'; -import { getOptionProps, getListeners } from '../../../_util/props-util'; +import { getOptionProps } from '../../../_util/props-util'; import MonthPanel from '../month/MonthPanel'; import YearPanel from '../year/YearPanel'; import DecadePanel from '../decade/DecadePanel'; @@ -52,7 +52,7 @@ const CalendarHeader = { methods: { onMonthSelect(value) { this.__emit('panelChange', value, 'date'); - if (getListeners(this).monthSelect) { + if (this.$attrs.onMonthSelect) { this.__emit('monthSelect', value); } else { this.__emit('valueChange', value); diff --git a/components/vc-calendar/src/date/DateTBody.jsx b/components/vc-calendar/src/date/DateTBody.jsx index 9cd8d1efc..be5358a5f 100644 --- a/components/vc-calendar/src/date/DateTBody.jsx +++ b/components/vc-calendar/src/date/DateTBody.jsx @@ -211,9 +211,9 @@ const DateTBody = { let dateHtml; if (dateRender) { - dateHtml = dateRender(current, value); + dateHtml = dateRender({ current, today: value }); } else { - const content = contentRender ? contentRender(current, value) : current.date(); + const content = contentRender ? contentRender({ current, today: value }) : current.date(); dateHtml = (
{index}); + options.push({(() => index)()}); } return (