feat: update date-picker
parent
a3a53613c5
commit
98733252c1
|
@ -1 +1 @@
|
||||||
Subproject commit e5569f28132b299accd77cbbbb7354f6308d25e5
|
Subproject commit 2bead0607865ddfbb49f958507d55249b9b0f3c4
|
|
@ -97,3 +97,11 @@ renderItem(item, index) => renderItem({item, index}) 该用单参数
|
||||||
## TreeSelect
|
## TreeSelect
|
||||||
|
|
||||||
treeData 中 scopedSlots => slots , v-model => v-model:value
|
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})
|
||||||
|
|
|
@ -58,7 +58,7 @@ export default {
|
||||||
|
|
||||||
const options = [];
|
const options = [];
|
||||||
for (let index = start; index < end; index++) {
|
for (let index = start; index < end; index++) {
|
||||||
options.push(<Option key={`${index}`}>{index + suffix}</Option>);
|
options.push(<Option key={`${index}`}>{(() => index + suffix)()}</Option>);
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Select
|
<Select
|
||||||
|
@ -67,7 +67,7 @@ export default {
|
||||||
class={`${prefixCls}-year-select`}
|
class={`${prefixCls}-year-select`}
|
||||||
onChange={this.onYearChange}
|
onChange={this.onYearChange}
|
||||||
value={String(year)}
|
value={String(year)}
|
||||||
getPopupContainer={() => this.calenderHeaderNode}
|
getPopupContainer={() => this.calendarHeaderNode}
|
||||||
>
|
>
|
||||||
{options}
|
{options}
|
||||||
</Select>
|
</Select>
|
||||||
|
@ -90,7 +90,7 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (let index = start; index < end; index++) {
|
for (let index = start; index < end; index++) {
|
||||||
options.push(<Option key={`${index}`}>{months[index]}</Option>);
|
options.push(<Option key={`${index}`}>{(() => months[index])()}</Option>);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -143,24 +143,24 @@ const Calendar = {
|
||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
monthCellRender2(value) {
|
monthCellRender2({ current: value }) {
|
||||||
const { _sPrefixCls, $slots } = this;
|
const { _sPrefixCls, $slots } = this;
|
||||||
const monthCellRender = this.monthCellRender || $slots.monthCellRender || noop;
|
const monthCellRender = this.monthCellRender || $slots.monthCellRender || noop;
|
||||||
return (
|
return (
|
||||||
<div class={`${_sPrefixCls}-month`}>
|
<div class={`${_sPrefixCls}-month`}>
|
||||||
<div class={`${_sPrefixCls}-value`}>{value.localeData().monthsShort(value)}</div>
|
<div class={`${_sPrefixCls}-value`}>{value.localeData().monthsShort(value)}</div>
|
||||||
<div class={`${_sPrefixCls}-content`}>{monthCellRender(value)}</div>
|
<div class={`${_sPrefixCls}-content`}>{monthCellRender({ current: value })}</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
dateCellRender2(value) {
|
dateCellRender2({ current: value }) {
|
||||||
const { _sPrefixCls, $slots } = this;
|
const { _sPrefixCls, $slots } = this;
|
||||||
const dateCellRender = this.dateCellRender || $slots.dateCellRender || noop;
|
const dateCellRender = this.dateCellRender || $slots.dateCellRender || noop;
|
||||||
return (
|
return (
|
||||||
<div class={`${_sPrefixCls}-date`}>
|
<div class={`${_sPrefixCls}-date`}>
|
||||||
<div class={`${_sPrefixCls}-value`}>{zerofixed(value.date())}</div>
|
<div class={`${_sPrefixCls}-value`}>{zerofixed(value.date())}</div>
|
||||||
<div class={`${_sPrefixCls}-content`}>{dateCellRender(value)}</div>
|
<div class={`${_sPrefixCls}-content`}>{dateCellRender({ current: value })}</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -414,7 +414,7 @@ export default {
|
||||||
onMouseenter={this.onMouseEnter}
|
onMouseenter={this.onMouseEnter}
|
||||||
onMouseleave={this.onMouseLeave}
|
onMouseleave={this.onMouseLeave}
|
||||||
>
|
>
|
||||||
<VcDatePicker {...vcDatePickerProps} vSlots={$slots} children={input}></VcDatePicker>
|
<VcDatePicker {...vcDatePickerProps} vSlots={{ default: input, ...$slots }}></VcDatePicker>
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -74,11 +74,11 @@ export default {
|
||||||
saveInput(node) {
|
saveInput(node) {
|
||||||
this.input = node;
|
this.input = node;
|
||||||
},
|
},
|
||||||
weekDateRender(current) {
|
weekDateRender({ current }) {
|
||||||
const selectedValue = this.$data._value;
|
const selectedValue = this.$data._value;
|
||||||
const { _prefixCls: prefixCls, $slots } = this;
|
const { _prefixCls: prefixCls, $slots } = this;
|
||||||
const dateRender = this.dateRender || $slots.dateRender;
|
const dateRender = this.dateRender || $slots.dateRender;
|
||||||
const dateNode = dateRender ? dateRender(current) : current.date();
|
const dateNode = dateRender ? dateRender({ current }) : current.date();
|
||||||
if (
|
if (
|
||||||
selectedValue &&
|
selectedValue &&
|
||||||
current.year() === selectedValue.year() &&
|
current.year() === selectedValue.year() &&
|
||||||
|
@ -208,7 +208,7 @@ export default {
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<span class={classNames(className, pickerClass)} style={style} id={id}>
|
<span class={classNames(className, pickerClass)} style={style} id={id}>
|
||||||
<VcDatePicker {...vcDatePickerProps} vSlots={$slots} children={input}></VcDatePicker>
|
<VcDatePicker {...vcDatePickerProps} vSlots={{ default: input, ...$slots }}></VcDatePicker>
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -106,11 +106,11 @@ export default function createPicker(TheCalendar, props) {
|
||||||
this.$emit('openChange', open);
|
this.$emit('openChange', open);
|
||||||
},
|
},
|
||||||
focus() {
|
focus() {
|
||||||
this.input.focus();
|
this.input?.focus();
|
||||||
},
|
},
|
||||||
|
|
||||||
blur() {
|
blur() {
|
||||||
this.input.blur();
|
this.input?.blur();
|
||||||
},
|
},
|
||||||
renderFooter(...args) {
|
renderFooter(...args) {
|
||||||
const { $slots, _prefixCls: prefixCls } = this;
|
const { $slots, _prefixCls: prefixCls } = this;
|
||||||
|
@ -235,7 +235,6 @@ export default function createPicker(TheCalendar, props) {
|
||||||
open,
|
open,
|
||||||
onOpenChange: this.handleOpenChange,
|
onOpenChange: this.handleOpenChange,
|
||||||
style: props.popupStyle,
|
style: props.popupStyle,
|
||||||
children: input,
|
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
|
@ -248,7 +247,10 @@ export default function createPicker(TheCalendar, props) {
|
||||||
onMouseenter={this.onMouseEnter}
|
onMouseenter={this.onMouseEnter}
|
||||||
onMouseleave={this.onMouseLeave}
|
onMouseleave={this.onMouseLeave}
|
||||||
>
|
>
|
||||||
<VcDatePicker {...vcDatePickerProps} vSlots={omit($slots, ['default'])}></VcDatePicker>
|
<VcDatePicker
|
||||||
|
{...vcDatePickerProps}
|
||||||
|
vSlots={{ default: input, ...$slots }}
|
||||||
|
></VcDatePicker>
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -20,7 +20,7 @@ export const PickerProps = () => ({
|
||||||
open: PropTypes.bool,
|
open: PropTypes.bool,
|
||||||
disabledDate: PropTypes.func,
|
disabledDate: PropTypes.func,
|
||||||
showToday: PropTypes.bool,
|
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,
|
pickerClass: PropTypes.string,
|
||||||
pickerInputClass: PropTypes.string,
|
pickerInputClass: PropTypes.string,
|
||||||
timePicker: PropTypes.any,
|
timePicker: PropTypes.any,
|
||||||
|
|
|
@ -34,7 +34,6 @@ const Picker = {
|
||||||
format: PropTypes.oneOfType([PropTypes.string, PropTypes.array, PropTypes.func]),
|
format: PropTypes.oneOfType([PropTypes.string, PropTypes.array, PropTypes.func]),
|
||||||
// onChange: PropTypes.func,
|
// onChange: PropTypes.func,
|
||||||
// onOpenChange: PropTypes.func,
|
// onOpenChange: PropTypes.func,
|
||||||
children: PropTypes.func,
|
|
||||||
getCalendarContainer: PropTypes.func,
|
getCalendarContainer: PropTypes.func,
|
||||||
calendar: PropTypes.any,
|
calendar: PropTypes.any,
|
||||||
open: PropTypes.bool,
|
open: PropTypes.bool,
|
||||||
|
@ -46,7 +45,7 @@ const Picker = {
|
||||||
align: PropTypes.object.def(() => ({})),
|
align: PropTypes.object.def(() => ({})),
|
||||||
dropdownClassName: PropTypes.string,
|
dropdownClassName: PropTypes.string,
|
||||||
dateRender: PropTypes.func,
|
dateRender: PropTypes.func,
|
||||||
children: PropTypes.func.isRequired,
|
children: PropTypes.func,
|
||||||
},
|
},
|
||||||
mixins: [BaseMixin],
|
mixins: [BaseMixin],
|
||||||
|
|
||||||
|
@ -214,7 +213,7 @@ const Picker = {
|
||||||
value: sValue,
|
value: sValue,
|
||||||
open: sOpen,
|
open: sOpen,
|
||||||
};
|
};
|
||||||
const children = this.children(childrenState, props);
|
const children = this.$slots.default(childrenState);
|
||||||
if (this.sOpen || !this.calendarElement) {
|
if (this.sOpen || !this.calendarElement) {
|
||||||
this.calendarElement = this.getCalendarElement();
|
this.calendarElement = this.getCalendarElement();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import PropTypes from '../../../_util/vue-types';
|
import PropTypes from '../../../_util/vue-types';
|
||||||
import BaseMixin from '../../../_util/BaseMixin';
|
import BaseMixin from '../../../_util/BaseMixin';
|
||||||
import { getOptionProps, getListeners } from '../../../_util/props-util';
|
import { getOptionProps } from '../../../_util/props-util';
|
||||||
import MonthPanel from '../month/MonthPanel';
|
import MonthPanel from '../month/MonthPanel';
|
||||||
import YearPanel from '../year/YearPanel';
|
import YearPanel from '../year/YearPanel';
|
||||||
import DecadePanel from '../decade/DecadePanel';
|
import DecadePanel from '../decade/DecadePanel';
|
||||||
|
@ -52,7 +52,7 @@ const CalendarHeader = {
|
||||||
methods: {
|
methods: {
|
||||||
onMonthSelect(value) {
|
onMonthSelect(value) {
|
||||||
this.__emit('panelChange', value, 'date');
|
this.__emit('panelChange', value, 'date');
|
||||||
if (getListeners(this).monthSelect) {
|
if (this.$attrs.onMonthSelect) {
|
||||||
this.__emit('monthSelect', value);
|
this.__emit('monthSelect', value);
|
||||||
} else {
|
} else {
|
||||||
this.__emit('valueChange', value);
|
this.__emit('valueChange', value);
|
||||||
|
|
|
@ -211,9 +211,9 @@ const DateTBody = {
|
||||||
|
|
||||||
let dateHtml;
|
let dateHtml;
|
||||||
if (dateRender) {
|
if (dateRender) {
|
||||||
dateHtml = dateRender(current, value);
|
dateHtml = dateRender({ current, today: value });
|
||||||
} else {
|
} else {
|
||||||
const content = contentRender ? contentRender(current, value) : current.date();
|
const content = contentRender ? contentRender({ current, today: value }) : current.date();
|
||||||
dateHtml = (
|
dateHtml = (
|
||||||
<div
|
<div
|
||||||
key={getIdFromDate(current)}
|
key={getIdFromDate(current)}
|
||||||
|
|
|
@ -39,7 +39,7 @@ const CalendarHeader = {
|
||||||
|
|
||||||
const options = [];
|
const options = [];
|
||||||
for (let index = start; index < end; index++) {
|
for (let index = start; index < end; index++) {
|
||||||
options.push(<Select.Option key={`${index}`}>{index}</Select.Option>);
|
options.push(<Select.Option key={`${index}`}>{(() => index)()}</Select.Option>);
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Select
|
<Select
|
||||||
|
@ -63,7 +63,7 @@ const CalendarHeader = {
|
||||||
|
|
||||||
for (let index = 0; index < 12; index++) {
|
for (let index = 0; index < 12; index++) {
|
||||||
t.month(index);
|
t.month(index);
|
||||||
options.push(<Select.Option key={`${index}`}>{getMonthName(t)}</Select.Option>);
|
options.push(<Select.Option key={`${index}`}>{(() => getMonthName(t))()}</Select.Option>);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -91,13 +91,13 @@ const MonthTable = {
|
||||||
if (cellRender) {
|
if (cellRender) {
|
||||||
const currentValue = value.clone();
|
const currentValue = value.clone();
|
||||||
currentValue.month(monthData.value);
|
currentValue.month(monthData.value);
|
||||||
cellEl = cellRender(currentValue, locale);
|
cellEl = cellRender({ current: currentValue, locale });
|
||||||
} else {
|
} else {
|
||||||
let content;
|
let content;
|
||||||
if (contentRender) {
|
if (contentRender) {
|
||||||
const currentValue = value.clone();
|
const currentValue = value.clone();
|
||||||
currentValue.month(monthData.value);
|
currentValue.month(monthData.value);
|
||||||
content = contentRender(currentValue, locale);
|
content = contentRender({ current: currentValue, locale });
|
||||||
} else {
|
} else {
|
||||||
content = monthData.content;
|
content = monthData.content;
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,7 +163,6 @@ export default {
|
||||||
dropdownStyle,
|
dropdownStyle,
|
||||||
dropdownMatchSelectWidth,
|
dropdownMatchSelectWidth,
|
||||||
} = props;
|
} = props;
|
||||||
//const { mouseenter, mouseleave, popupFocus, dropdownVisibleChange } = getListeners(this);
|
|
||||||
const dropdownPrefixCls = this.getDropdownPrefixCls();
|
const dropdownPrefixCls = this.getDropdownPrefixCls();
|
||||||
const popupClassName = {
|
const popupClassName = {
|
||||||
[dropdownClassName]: !!dropdownClassName,
|
[dropdownClassName]: !!dropdownClassName,
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import demo from '../antdv-demo/docs/date-picker/demo/basic';
|
import demo from '../antdv-demo/docs/date-picker/demo/index';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
|
Loading…
Reference in New Issue