feat: calendar update locale
parent
9077e181fd
commit
738d2f442a
|
@ -1,5 +1,5 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
dev: {
|
dev: {
|
||||||
componentName: 'table', // dev components
|
componentName: 'calendar', // dev components
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,15 +1,9 @@
|
||||||
import PropTypes from '../_util/vue-types';
|
import PropTypes from '../_util/vue-types';
|
||||||
import BaseMixin from '../_util/BaseMixin';
|
import BaseMixin from '../_util/BaseMixin';
|
||||||
import {
|
import { getOptionProps, hasProp, initDefaultProps, getListeners } from '../_util/props-util';
|
||||||
getOptionProps,
|
|
||||||
hasProp,
|
|
||||||
initDefaultProps,
|
|
||||||
getListeners,
|
|
||||||
getComponentFromProp,
|
|
||||||
} from '../_util/props-util';
|
|
||||||
import * as moment from 'moment';
|
import * as moment from 'moment';
|
||||||
import FullCalendar from '../vc-calendar/src/FullCalendar';
|
import FullCalendar from '../vc-calendar/src/FullCalendar';
|
||||||
import Header, { HeaderRender } from './Header';
|
import Header from './Header';
|
||||||
import LocaleReceiver from '../locale-provider/LocaleReceiver';
|
import LocaleReceiver from '../locale-provider/LocaleReceiver';
|
||||||
import interopDefault from '../_util/interopDefault';
|
import interopDefault from '../_util/interopDefault';
|
||||||
import { ConfigConsumerProps } from '../config-provider';
|
import { ConfigConsumerProps } from '../config-provider';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// based on rc-calendar 9.10.10
|
// based on rc-calendar 9.15.8
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import ref from 'vue-ref';
|
import ref from 'vue-ref';
|
||||||
import Calendar from './src/';
|
import Calendar from './src/';
|
||||||
|
|
|
@ -14,6 +14,13 @@ import enUs from './locale/en_US';
|
||||||
import { getTimeConfig, getTodayTime, syncTime } from './util';
|
import { getTimeConfig, getTodayTime, syncTime } from './util';
|
||||||
import { goStartMonth, goEndMonth, goTime } from './util/toTime';
|
import { goStartMonth, goEndMonth, goTime } from './util/toTime';
|
||||||
|
|
||||||
|
const getMomentObjectIfValid = date => {
|
||||||
|
if (moment.isMoment(date) && date.isValid()) {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
const Calendar = {
|
const Calendar = {
|
||||||
props: {
|
props: {
|
||||||
locale: PropTypes.object.def(enUs),
|
locale: PropTypes.object.def(enUs),
|
||||||
|
@ -46,6 +53,7 @@ const Calendar = {
|
||||||
renderSidebar: PropTypes.func.def(() => null),
|
renderSidebar: PropTypes.func.def(() => null),
|
||||||
clearIcon: PropTypes.any,
|
clearIcon: PropTypes.any,
|
||||||
focusablePanel: PropTypes.bool.def(true),
|
focusablePanel: PropTypes.bool.def(true),
|
||||||
|
inputMode: PropTypes.string,
|
||||||
},
|
},
|
||||||
|
|
||||||
mixins: [BaseMixin, CommonMixin, CalendarMixin],
|
mixins: [BaseMixin, CommonMixin, CalendarMixin],
|
||||||
|
@ -54,7 +62,10 @@ const Calendar = {
|
||||||
const props = this.$props;
|
const props = this.$props;
|
||||||
return {
|
return {
|
||||||
sMode: this.mode || 'date',
|
sMode: this.mode || 'date',
|
||||||
sValue: props.value || props.defaultValue || moment(),
|
sValue:
|
||||||
|
getMomentObjectIfValid(props.value) ||
|
||||||
|
getMomentObjectIfValid(props.defaultValue) ||
|
||||||
|
moment(),
|
||||||
sSelectedValue: props.selectedValue || props.defaultSelectedValue,
|
sSelectedValue: props.selectedValue || props.defaultSelectedValue,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -63,9 +74,11 @@ const Calendar = {
|
||||||
this.setState({ sMode: val });
|
this.setState({ sMode: val });
|
||||||
},
|
},
|
||||||
value(val) {
|
value(val) {
|
||||||
const sValue = val || this.defaultValue || getNowByCurrentStateValue(this.sValue);
|
|
||||||
this.setState({
|
this.setState({
|
||||||
sValue,
|
sValue:
|
||||||
|
getMomentObjectIfValid(val) ||
|
||||||
|
getMomentObjectIfValid(this.defaultValue) ||
|
||||||
|
getNowByCurrentStateValue(this.sValue),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
selectedValue(val) {
|
selectedValue(val) {
|
||||||
|
@ -190,6 +203,25 @@ const Calendar = {
|
||||||
source: 'todayButton',
|
source: 'todayButton',
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onBlur(event) {
|
||||||
|
setTimeout(() => {
|
||||||
|
const dateInput = DateInput.getInstance();
|
||||||
|
const rootInstance = this.rootInstance;
|
||||||
|
|
||||||
|
if (
|
||||||
|
!rootInstance ||
|
||||||
|
rootInstance.contains(document.activeElement) ||
|
||||||
|
(dateInput && dateInput.contains(document.activeElement))
|
||||||
|
) {
|
||||||
|
// focused element is still part of Calendar
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$emit('blur', event);
|
||||||
|
}, 0);
|
||||||
|
},
|
||||||
|
|
||||||
getRootDOMNode() {
|
getRootDOMNode() {
|
||||||
return this.$el;
|
return this.$el;
|
||||||
},
|
},
|
||||||
|
@ -217,6 +249,9 @@ const Calendar = {
|
||||||
sSelectedValue,
|
sSelectedValue,
|
||||||
sMode,
|
sMode,
|
||||||
renderFooter,
|
renderFooter,
|
||||||
|
inputMode,
|
||||||
|
monthCellRender,
|
||||||
|
monthCellContentRender,
|
||||||
$props: props,
|
$props: props,
|
||||||
} = this;
|
} = this;
|
||||||
const clearIcon = getComponentFromProp(this, 'clearIcon');
|
const clearIcon = getComponentFromProp(this, 'clearIcon');
|
||||||
|
@ -267,6 +302,7 @@ const Calendar = {
|
||||||
onChange={this.onDateInputChange}
|
onChange={this.onDateInputChange}
|
||||||
clearIcon={clearIcon}
|
clearIcon={clearIcon}
|
||||||
onSelect={this.onDateInputSelect}
|
onSelect={this.onDateInputSelect}
|
||||||
|
inputMode={inputMode}
|
||||||
/>
|
/>
|
||||||
) : null;
|
) : null;
|
||||||
const children = [];
|
const children = [];
|
||||||
|
@ -286,6 +322,8 @@ const Calendar = {
|
||||||
renderFooter={renderFooter}
|
renderFooter={renderFooter}
|
||||||
showTimePicker={showTimePicker}
|
showTimePicker={showTimePicker}
|
||||||
prefixCls={prefixCls}
|
prefixCls={prefixCls}
|
||||||
|
monthCellRender={monthCellRender}
|
||||||
|
monthCellContentRender={monthCellContentRender}
|
||||||
/>
|
/>
|
||||||
{timePicker && showTimePicker ? (
|
{timePicker && showTimePicker ? (
|
||||||
<div class={`${prefixCls}-time-picker`}>
|
<div class={`${prefixCls}-time-picker`}>
|
||||||
|
|
|
@ -14,7 +14,6 @@ const MonthCalendar = {
|
||||||
visible: PropTypes.bool.def(true),
|
visible: PropTypes.bool.def(true),
|
||||||
prefixCls: PropTypes.string.def('rc-calendar'),
|
prefixCls: PropTypes.string.def('rc-calendar'),
|
||||||
monthCellRender: PropTypes.func,
|
monthCellRender: PropTypes.func,
|
||||||
dateCellRender: PropTypes.func,
|
|
||||||
value: PropTypes.object,
|
value: PropTypes.object,
|
||||||
defaultValue: PropTypes.object,
|
defaultValue: PropTypes.object,
|
||||||
selectedValue: PropTypes.object,
|
selectedValue: PropTypes.object,
|
||||||
|
|
|
@ -38,6 +38,7 @@ const Picker = {
|
||||||
defaultValue: PropTypes.oneOfType([MomentType, PropTypes.arrayOf(MomentType)]),
|
defaultValue: PropTypes.oneOfType([MomentType, PropTypes.arrayOf(MomentType)]),
|
||||||
align: PropTypes.object.def({}),
|
align: PropTypes.object.def({}),
|
||||||
dropdownClassName: PropTypes.string,
|
dropdownClassName: PropTypes.string,
|
||||||
|
dateRender: PropTypes.func,
|
||||||
},
|
},
|
||||||
mixins: [BaseMixin],
|
mixins: [BaseMixin],
|
||||||
|
|
||||||
|
@ -123,6 +124,10 @@ const Picker = {
|
||||||
this.closeCalendar(this.focus);
|
this.closeCalendar(this.focus);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onCalendarBlur() {
|
||||||
|
this.setOpen(false);
|
||||||
|
},
|
||||||
|
|
||||||
onVisibleChange(open) {
|
onVisibleChange(open) {
|
||||||
this.setOpen(open);
|
this.setOpen(open);
|
||||||
},
|
},
|
||||||
|
@ -144,6 +149,7 @@ const Picker = {
|
||||||
ok: createChainedFunction(calendarEvents.ok, this.onCalendarOk),
|
ok: createChainedFunction(calendarEvents.ok, this.onCalendarOk),
|
||||||
select: createChainedFunction(calendarEvents.select, this.onCalendarSelect),
|
select: createChainedFunction(calendarEvents.select, this.onCalendarSelect),
|
||||||
clear: createChainedFunction(calendarEvents.clear, this.onCalendarClear),
|
clear: createChainedFunction(calendarEvents.clear, this.onCalendarClear),
|
||||||
|
blur: createChainedFunction(calendarEvents.blur, this.onCalendarBlur),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -38,9 +38,15 @@ function isArraysEqual(a, b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getValueFromSelectedValue(selectedValue) {
|
function getValueFromSelectedValue(selectedValue) {
|
||||||
const [start, end] = selectedValue;
|
let [start, end] = selectedValue;
|
||||||
const newEnd = end && end.isSame(start, 'month') ? end.clone().add(1, 'month') : end;
|
if (end && (start === undefined || start === null)) {
|
||||||
return [start, newEnd];
|
start = end.clone().subtract(1, 'month');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (start && (end === undefined || end === null)) {
|
||||||
|
end = start.clone().add(1, 'month');
|
||||||
|
}
|
||||||
|
return [start, end];
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalizeAnchor(props, init) {
|
function normalizeAnchor(props, init) {
|
||||||
|
@ -73,7 +79,7 @@ function onInputSelect(direction, value, cause) {
|
||||||
const index = direction === 'left' ? 0 : 1;
|
const index = direction === 'left' ? 0 : 1;
|
||||||
selectedValue[index] = value;
|
selectedValue[index] = value;
|
||||||
if (selectedValue[0] && this.compare(selectedValue[0], selectedValue[1]) > 0) {
|
if (selectedValue[0] && this.compare(selectedValue[0], selectedValue[1]) > 0) {
|
||||||
selectedValue[1 - index] = this.showTimePicker ? selectedValue[index] : undefined;
|
selectedValue[1 - index] = this.sShowTimePicker ? selectedValue[index] : undefined;
|
||||||
}
|
}
|
||||||
this.__emit('inputSelect', selectedValue);
|
this.__emit('inputSelect', selectedValue);
|
||||||
this.fireSelectValueChange(selectedValue, null, cause || { source: 'dateInput' });
|
this.fireSelectValueChange(selectedValue, null, cause || { source: 'dateInput' });
|
||||||
|
@ -89,7 +95,7 @@ const RangeCalendar = {
|
||||||
defaultValue: PropTypes.any,
|
defaultValue: PropTypes.any,
|
||||||
value: PropTypes.any,
|
value: PropTypes.any,
|
||||||
hoverValue: PropTypes.any,
|
hoverValue: PropTypes.any,
|
||||||
mode: PropTypes.arrayOf(PropTypes.oneOf(['date', 'month', 'year', 'decade'])),
|
mode: PropTypes.arrayOf(PropTypes.oneOf(['time', 'date', 'month', 'year', 'decade'])),
|
||||||
showDateInput: PropTypes.bool.def(true),
|
showDateInput: PropTypes.bool.def(true),
|
||||||
timePicker: PropTypes.any,
|
timePicker: PropTypes.any,
|
||||||
showOk: PropTypes.bool,
|
showOk: PropTypes.bool,
|
||||||
|
@ -104,7 +110,7 @@ const RangeCalendar = {
|
||||||
// onValueChange: PropTypes.func,
|
// onValueChange: PropTypes.func,
|
||||||
// onHoverChange: PropTypes.func,
|
// onHoverChange: PropTypes.func,
|
||||||
// onPanelChange: PropTypes.func,
|
// onPanelChange: PropTypes.func,
|
||||||
format: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
format: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
|
||||||
// onClear: PropTypes.func,
|
// onClear: PropTypes.func,
|
||||||
type: PropTypes.any.def('both'),
|
type: PropTypes.any.def('both'),
|
||||||
disabledDate: PropTypes.func,
|
disabledDate: PropTypes.func,
|
||||||
|
@ -127,8 +133,9 @@ const RangeCalendar = {
|
||||||
firstSelectedValue: null,
|
firstSelectedValue: null,
|
||||||
sHoverValue: props.hoverValue || [],
|
sHoverValue: props.hoverValue || [],
|
||||||
sValue: value,
|
sValue: value,
|
||||||
showTimePicker: false,
|
sShowTimePicker: false,
|
||||||
sMode: props.mode || ['date', 'date'],
|
sMode: props.mode || ['date', 'date'],
|
||||||
|
sPanelTriggerSource: '', // Trigger by which picker panel: 'start' & 'end'
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
@ -359,12 +366,12 @@ const RangeCalendar = {
|
||||||
|
|
||||||
onOpenTimePicker() {
|
onOpenTimePicker() {
|
||||||
this.setState({
|
this.setState({
|
||||||
showTimePicker: true,
|
sShowTimePicker: true,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onCloseTimePicker() {
|
onCloseTimePicker() {
|
||||||
this.setState({
|
this.setState({
|
||||||
showTimePicker: false,
|
sShowTimePicker: false,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -412,11 +419,13 @@ const RangeCalendar = {
|
||||||
const newMode = [mode, sMode[1]];
|
const newMode = [mode, sMode[1]];
|
||||||
const newValue = [value || sValue[0], sValue[1]];
|
const newValue = [value || sValue[0], sValue[1]];
|
||||||
this.__emit('panelChange', newValue, newMode);
|
this.__emit('panelChange', newValue, newMode);
|
||||||
|
const newState = {
|
||||||
|
sPanelTriggerSource: 'start',
|
||||||
|
};
|
||||||
if (!hasProp(this, 'mode')) {
|
if (!hasProp(this, 'mode')) {
|
||||||
this.setState({
|
newState.sMode = newMode;
|
||||||
sMode: newMode,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
this.setState(newState);
|
||||||
},
|
},
|
||||||
|
|
||||||
onEndPanelChange(value, mode) {
|
onEndPanelChange(value, mode) {
|
||||||
|
@ -424,37 +433,74 @@ const RangeCalendar = {
|
||||||
const newMode = [sMode[0], mode];
|
const newMode = [sMode[0], mode];
|
||||||
const newValue = [sValue[0], value || sValue[1]];
|
const newValue = [sValue[0], value || sValue[1]];
|
||||||
this.__emit('panelChange', newValue, newMode);
|
this.__emit('panelChange', newValue, newMode);
|
||||||
|
const newState = {
|
||||||
|
sPanelTriggerSource: 'start',
|
||||||
|
};
|
||||||
if (!hasProp(this, 'mode')) {
|
if (!hasProp(this, 'mode')) {
|
||||||
this.setState({
|
newState.sMode = newMode;
|
||||||
sMode: newMode,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
this.setState(newState);
|
||||||
},
|
},
|
||||||
|
|
||||||
getStartValue() {
|
getStartValue() {
|
||||||
let value = this.sValue[0];
|
const {
|
||||||
const selectedValue = this.sSelectedValue;
|
sSelectedValue: selectedValue,
|
||||||
|
sShowTimePicker: showTimePicker,
|
||||||
|
sValue: value,
|
||||||
|
sMode: mode,
|
||||||
|
sPanelTriggerSource: panelTriggerSource,
|
||||||
|
} = this.$data;
|
||||||
|
let startValue = value[0];
|
||||||
// keep selectedTime when select date
|
// keep selectedTime when select date
|
||||||
if (selectedValue[0] && this.timePicker) {
|
if (selectedValue[0] && this.props.timePicker) {
|
||||||
value = value.clone();
|
startValue = startValue.clone();
|
||||||
syncTime(selectedValue[0], value);
|
syncTime(selectedValue[0], startValue);
|
||||||
}
|
}
|
||||||
if (this.showTimePicker && selectedValue[0]) {
|
if (showTimePicker && selectedValue[0]) {
|
||||||
return selectedValue[0];
|
startValue = selectedValue[0];
|
||||||
}
|
}
|
||||||
return value;
|
|
||||||
|
// Adjust month if date not align
|
||||||
|
if (
|
||||||
|
panelTriggerSource === 'end' &&
|
||||||
|
mode[0] === 'date' &&
|
||||||
|
mode[1] === 'date' &&
|
||||||
|
startValue.isSame(value[1], 'month')
|
||||||
|
) {
|
||||||
|
startValue = startValue.clone().subtract(1, 'month');
|
||||||
|
}
|
||||||
|
|
||||||
|
return startValue;
|
||||||
},
|
},
|
||||||
|
|
||||||
getEndValue() {
|
getEndValue() {
|
||||||
const { sValue, sSelectedValue, showTimePicker } = this;
|
const {
|
||||||
const endValue = sValue[1] ? sValue[1].clone() : sValue[0].clone().add(1, 'month');
|
sSelectedValue: selectedValue,
|
||||||
|
sShowTimePicker: showTimePicker,
|
||||||
|
sValue: value,
|
||||||
|
sMode: mode,
|
||||||
|
sPanelTriggerSource: panelTriggerSource,
|
||||||
|
} = this.$data;
|
||||||
|
let endValue = value[1] ? value[1].clone() : value[0].clone().add(1, 'month');
|
||||||
// keep selectedTime when select date
|
// keep selectedTime when select date
|
||||||
if (sSelectedValue[1] && this.timePicker) {
|
if (selectedValue[1] && this.props.timePicker) {
|
||||||
syncTime(sSelectedValue[1], endValue);
|
syncTime(selectedValue[1], endValue);
|
||||||
}
|
}
|
||||||
if (showTimePicker) {
|
if (showTimePicker) {
|
||||||
return sSelectedValue[1] ? sSelectedValue[1] : this.getStartValue();
|
endValue = selectedValue[1] ? selectedValue[1] : this.getStartValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Adjust month if date not align
|
||||||
|
if (
|
||||||
|
!showTimePicker &&
|
||||||
|
panelTriggerSource !== 'end' &&
|
||||||
|
mode[0] === 'date' &&
|
||||||
|
mode[1] === 'date' &&
|
||||||
|
endValue.isSame(value[0], 'month')
|
||||||
|
) {
|
||||||
|
endValue = endValue.clone().add(1, 'month');
|
||||||
|
}
|
||||||
|
|
||||||
return endValue;
|
return endValue;
|
||||||
},
|
},
|
||||||
// get disabled hours for second picker
|
// get disabled hours for second picker
|
||||||
|
@ -596,12 +642,12 @@ const RangeCalendar = {
|
||||||
|
|
||||||
disabledStartMonth(month) {
|
disabledStartMonth(month) {
|
||||||
const { sValue } = this;
|
const { sValue } = this;
|
||||||
return month.isSameOrAfter(sValue[1], 'month');
|
return month.isAfter(sValue[1], 'month');
|
||||||
},
|
},
|
||||||
|
|
||||||
disabledEndMonth(month) {
|
disabledEndMonth(month) {
|
||||||
const { sValue } = this;
|
const { sValue } = this;
|
||||||
return month.isSameOrBefore(sValue[0], 'month');
|
return month.isBefore(sValue[0], 'month');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -619,12 +665,12 @@ const RangeCalendar = {
|
||||||
seperator,
|
seperator,
|
||||||
} = props;
|
} = props;
|
||||||
const clearIcon = getComponentFromProp(this, 'clearIcon');
|
const clearIcon = getComponentFromProp(this, 'clearIcon');
|
||||||
const { sHoverValue, sSelectedValue, sMode, showTimePicker, sValue } = this;
|
const { sHoverValue, sSelectedValue, sMode, sShowTimePicker, sValue } = this;
|
||||||
const className = {
|
const className = {
|
||||||
[prefixCls]: 1,
|
[prefixCls]: 1,
|
||||||
[`${prefixCls}-hidden`]: !props.visible,
|
[`${prefixCls}-hidden`]: !props.visible,
|
||||||
[`${prefixCls}-range`]: 1,
|
[`${prefixCls}-range`]: 1,
|
||||||
[`${prefixCls}-show-time-picker`]: showTimePicker,
|
[`${prefixCls}-show-time-picker`]: sShowTimePicker,
|
||||||
[`${prefixCls}-week-number`]: props.showWeekNumber,
|
[`${prefixCls}-week-number`]: props.showWeekNumber,
|
||||||
};
|
};
|
||||||
const baseProps = {
|
const baseProps = {
|
||||||
|
@ -686,7 +732,7 @@ const RangeCalendar = {
|
||||||
placeholder: placeholder1,
|
placeholder: placeholder1,
|
||||||
showDateInput: this.showDateInput,
|
showDateInput: this.showDateInput,
|
||||||
timePicker: timePicker,
|
timePicker: timePicker,
|
||||||
showTimePicker: showTimePicker,
|
showTimePicker: sShowTimePicker || mode[0] === 'time',
|
||||||
enablePrev: true,
|
enablePrev: true,
|
||||||
enableNext: !isClosestMonths || this.isMonthYearPanelShow(sMode[1]),
|
enableNext: !isClosestMonths || this.isMonthYearPanelShow(sMode[1]),
|
||||||
clearIcon,
|
clearIcon,
|
||||||
|
@ -709,7 +755,7 @@ const RangeCalendar = {
|
||||||
mode: sMode[1],
|
mode: sMode[1],
|
||||||
showDateInput: this.showDateInput,
|
showDateInput: this.showDateInput,
|
||||||
timePicker: timePicker,
|
timePicker: timePicker,
|
||||||
showTimePicker: showTimePicker,
|
showTimePicker: sShowTimePicker || mode[1] === 'time',
|
||||||
disabledTime: this.disabledEndTime,
|
disabledTime: this.disabledEndTime,
|
||||||
disabledMonth: this.disabledEndMonth,
|
disabledMonth: this.disabledEndMonth,
|
||||||
enablePrev: !isClosestMonths || this.isMonthYearPanelShow(sMode[0]),
|
enablePrev: !isClosestMonths || this.isMonthYearPanelShow(sMode[0]),
|
||||||
|
@ -742,7 +788,7 @@ const RangeCalendar = {
|
||||||
if (props.timePicker) {
|
if (props.timePicker) {
|
||||||
const timePickerButtonProps = mergeProps(baseProps, {
|
const timePickerButtonProps = mergeProps(baseProps, {
|
||||||
props: {
|
props: {
|
||||||
showTimePicker: showTimePicker,
|
showTimePicker: sShowTimePicker || (mode[0] === 'time' && mode[1] === 'time'),
|
||||||
timePickerDisabled: !this.hasSelectedValue() || sHoverValue.length,
|
timePickerDisabled: !this.hasSelectedValue() || sHoverValue.length,
|
||||||
},
|
},
|
||||||
on: {
|
on: {
|
||||||
|
|
|
@ -8,7 +8,6 @@ import KeyCode from '../../../_util/KeyCode';
|
||||||
let cachedSelectionStart;
|
let cachedSelectionStart;
|
||||||
let cachedSelectionEnd;
|
let cachedSelectionEnd;
|
||||||
let dateInputInstance;
|
let dateInputInstance;
|
||||||
import { isIE, isIE9 } from '../../../_util/env';
|
|
||||||
|
|
||||||
const DateInput = {
|
const DateInput = {
|
||||||
mixins: [BaseMixin],
|
mixins: [BaseMixin],
|
||||||
|
@ -26,6 +25,7 @@ const DateInput = {
|
||||||
// onSelect: PropTypes.func,
|
// onSelect: PropTypes.func,
|
||||||
selectedValue: PropTypes.object,
|
selectedValue: PropTypes.object,
|
||||||
clearIcon: PropTypes.any,
|
clearIcon: PropTypes.any,
|
||||||
|
inputMode: PropTypes.string,
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
|
@ -141,13 +141,15 @@ const DateInput = {
|
||||||
str: formatDate(prevProps.value, prevProps.format),
|
str: formatDate(prevProps.value, prevProps.format),
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
onKeyDown({ keyCode }) {
|
onKeyDown(event) {
|
||||||
|
const { keyCode } = event;
|
||||||
const { value, disabledDate } = this.$props;
|
const { value, disabledDate } = this.$props;
|
||||||
if (keyCode === KeyCode.ENTER) {
|
if (keyCode === KeyCode.ENTER) {
|
||||||
const validateDate = !disabledDate || !disabledDate(value);
|
const validateDate = !disabledDate || !disabledDate(value);
|
||||||
if (validateDate) {
|
if (validateDate) {
|
||||||
this.__emit('select', value.clone());
|
this.__emit('select', value.clone());
|
||||||
}
|
}
|
||||||
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getRootDOMNode() {
|
getRootDOMNode() {
|
||||||
|
@ -164,7 +166,7 @@ const DateInput = {
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { invalid, str, locale, prefixCls, placeholder, disabled, showClear } = this;
|
const { invalid, str, locale, prefixCls, placeholder, disabled, showClear, inputMode } = this;
|
||||||
const clearIcon = getComponentFromProp(this, 'clearIcon');
|
const clearIcon = getComponentFromProp(this, 'clearIcon');
|
||||||
const invalidClass = invalid ? `${prefixCls}-input-invalid` : '';
|
const invalidClass = invalid ? `${prefixCls}-input-invalid` : '';
|
||||||
return (
|
return (
|
||||||
|
@ -190,6 +192,7 @@ const DateInput = {
|
||||||
onKeydown={this.onKeyDown}
|
onKeydown={this.onKeyDown}
|
||||||
onFocus={this.onFocus}
|
onFocus={this.onFocus}
|
||||||
onBlur={this.onBlur}
|
onBlur={this.onBlur}
|
||||||
|
inputMode={inputMode}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{showClear ? (
|
{showClear ? (
|
||||||
|
|
|
@ -139,11 +139,21 @@ const DateTBody = {
|
||||||
cls += ` ${selectedStartDateClass}`;
|
cls += ` ${selectedStartDateClass}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (startValue && endValue) {
|
if (startValue || endValue) {
|
||||||
if (isSameDay(current, endValue)) {
|
if (isSameDay(current, endValue)) {
|
||||||
selected = true;
|
selected = true;
|
||||||
isActiveWeek = true;
|
isActiveWeek = true;
|
||||||
cls += ` ${selectedEndDateClass}`;
|
cls += ` ${selectedEndDateClass}`;
|
||||||
|
} else if (
|
||||||
|
(startValue === null || startValue === undefined) &&
|
||||||
|
current.isBefore(endValue, 'day')
|
||||||
|
) {
|
||||||
|
cls += ` ${inRangeClass}`;
|
||||||
|
} else if (
|
||||||
|
(endValue === null || endValue === undefined) &&
|
||||||
|
current.isAfter(startValue, 'day')
|
||||||
|
) {
|
||||||
|
cls += ` ${inRangeClass}`;
|
||||||
} else if (current.isAfter(startValue, 'day') && current.isBefore(endValue, 'day')) {
|
} else if (current.isAfter(startValue, 'day') && current.isBefore(endValue, 'day')) {
|
||||||
cls += ` ${inRangeClass}`;
|
cls += ` ${inRangeClass}`;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
export default {
|
||||||
|
today: 'Danas',
|
||||||
|
now: 'Sad',
|
||||||
|
backToToday: 'Natrag na danas',
|
||||||
|
ok: 'Ok',
|
||||||
|
clear: 'Očisti',
|
||||||
|
month: 'Mjesec',
|
||||||
|
year: 'Godina',
|
||||||
|
timeSelect: 'odaberite vrijeme',
|
||||||
|
dateSelect: 'odaberite datum',
|
||||||
|
weekSelect: 'Odaberite tjedan',
|
||||||
|
monthSelect: 'Odaberite mjesec',
|
||||||
|
yearSelect: 'Odaberite godinu',
|
||||||
|
decadeSelect: 'Odaberite desetljeće',
|
||||||
|
yearFormat: 'YYYY',
|
||||||
|
dateFormat: 'D.M.YYYY',
|
||||||
|
dayFormat: 'D',
|
||||||
|
dateTimeFormat: 'D.M.YYYY HH:mm:ss',
|
||||||
|
monthBeforeYear: true,
|
||||||
|
previousMonth: 'Prošli mjesec (PageUp)',
|
||||||
|
nextMonth: 'Sljedeći mjesec (PageDown)',
|
||||||
|
previousYear: 'Prošla godina (Control + left)',
|
||||||
|
nextYear: 'Sljedeća godina (Control + right)',
|
||||||
|
previousDecade: 'Prošlo desetljeće',
|
||||||
|
nextDecade: 'Sljedeće desetljeće',
|
||||||
|
previousCentury: 'Prošlo stoljeće',
|
||||||
|
nextCentury: 'Sljedeće stoljeće',
|
||||||
|
};
|
|
@ -13,14 +13,14 @@ export default {
|
||||||
yearSelect: 'Pilih satu tahun',
|
yearSelect: 'Pilih satu tahun',
|
||||||
decadeSelect: 'Pilih satu dekade',
|
decadeSelect: 'Pilih satu dekade',
|
||||||
yearFormat: 'YYYY',
|
yearFormat: 'YYYY',
|
||||||
dateFormat: 'M/D/YYYY',
|
dateFormat: 'D/M/YYYY',
|
||||||
dayFormat: 'D',
|
dayFormat: 'D',
|
||||||
dateTimeFormat: 'M/D/YYYY HH:mm:ss',
|
dateTimeFormat: 'D/M/YYYY HH:mm:ss',
|
||||||
monthBeforeYear: true,
|
monthBeforeYear: true,
|
||||||
previousMonth: 'Bulan sebelumnya (PageUp)',
|
previousMonth: 'Bulan sebelumnya (PageUp)',
|
||||||
nextMonth: 'Bulan depan (PageDown)',
|
nextMonth: 'Bulan selanjutnya (PageDown)',
|
||||||
previousYear: 'Tahun lalu (Control + kiri)',
|
previousYear: 'Tahun lalu (Control + kiri)',
|
||||||
nextYear: 'Tahun depan (Kontrol + kanan)',
|
nextYear: 'Tahun selanjutnya (Kontrol + kanan)',
|
||||||
previousDecade: 'Dekade terakhir',
|
previousDecade: 'Dekade terakhir',
|
||||||
nextDecade: 'Dekade berikutnya',
|
nextDecade: 'Dekade berikutnya',
|
||||||
previousCentury: 'Abad terakhir',
|
previousCentury: 'Abad terakhir',
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
export default {
|
||||||
|
today: 'Šodien',
|
||||||
|
now: 'Tagad',
|
||||||
|
backToToday: 'Atpakaļ pie šodienas',
|
||||||
|
ok: 'Ok',
|
||||||
|
clear: 'Skaidrs',
|
||||||
|
month: 'Mēnesis',
|
||||||
|
year: 'Gads',
|
||||||
|
timeSelect: 'Izvēlieties laiku',
|
||||||
|
dateSelect: 'Izvēlieties datumu',
|
||||||
|
monthSelect: 'Izvēlieties mēnesi',
|
||||||
|
yearSelect: 'Izvēlieties gadu',
|
||||||
|
decadeSelect: 'Izvēlieties desmit gadus',
|
||||||
|
yearFormat: 'YYYY',
|
||||||
|
dateFormat: 'D.M.YYYY',
|
||||||
|
dayFormat: 'D',
|
||||||
|
dateTimeFormat: 'D.M.YYYY HH:mm:ss',
|
||||||
|
monthBeforeYear: true,
|
||||||
|
previousMonth: 'Iepriekšējais mēnesis (PageUp)',
|
||||||
|
nextMonth: 'Nākammēnes (PageDown)',
|
||||||
|
previousYear: 'Pagājušais gads (Control + left)',
|
||||||
|
nextYear: 'Nākamgad (Control + right)',
|
||||||
|
previousDecade: 'Pēdējā desmitgadē',
|
||||||
|
nextDecade: 'Nākamā desmitgade',
|
||||||
|
previousCentury: 'Pagājušajā gadsimtā',
|
||||||
|
nextCentury: 'Nākamajā gadsimtā',
|
||||||
|
};
|
|
@ -0,0 +1,27 @@
|
||||||
|
export default {
|
||||||
|
today: 'Денес',
|
||||||
|
now: 'Сега',
|
||||||
|
backToToday: 'Назад до денес',
|
||||||
|
ok: 'ОК',
|
||||||
|
clear: 'Избриши',
|
||||||
|
month: 'Месец',
|
||||||
|
year: 'Година',
|
||||||
|
timeSelect: 'Избери време',
|
||||||
|
dateSelect: 'Избери датум',
|
||||||
|
monthSelect: 'Избери месец',
|
||||||
|
yearSelect: 'Избери година',
|
||||||
|
decadeSelect: 'Избери деценија',
|
||||||
|
yearFormat: 'YYYY',
|
||||||
|
dateFormat: 'D.M.YYYY',
|
||||||
|
dayFormat: 'D',
|
||||||
|
dateTimeFormat: 'D.M.YYYY HH:mm:ss',
|
||||||
|
monthBeforeYear: true,
|
||||||
|
previousMonth: 'Претходен месец (PageUp)',
|
||||||
|
nextMonth: 'Нареден месец (PageDown)',
|
||||||
|
previousYear: 'Претходна година (Control + left)',
|
||||||
|
nextYear: 'Наредна година (Control + right)',
|
||||||
|
previousDecade: 'Претходна деценија',
|
||||||
|
nextDecade: 'Наредна деценија',
|
||||||
|
previousCentury: 'Претходен век',
|
||||||
|
nextCentury: 'Нареден век',
|
||||||
|
};
|
|
@ -0,0 +1,27 @@
|
||||||
|
export default {
|
||||||
|
today: 'Hari ini',
|
||||||
|
now: 'Sekarang',
|
||||||
|
backToToday: 'Kembali ke hari ini',
|
||||||
|
ok: 'Ok',
|
||||||
|
timeSelect: 'Pilih masa',
|
||||||
|
dateSelect: 'Pilih tarikh',
|
||||||
|
weekSelect: 'Pilih minggu',
|
||||||
|
clear: 'Padam',
|
||||||
|
month: 'Bulan',
|
||||||
|
year: 'Tahun',
|
||||||
|
previousMonth: 'Bulan lepas',
|
||||||
|
nextMonth: 'Bulan depan',
|
||||||
|
monthSelect: 'Pilih bulan',
|
||||||
|
yearSelect: 'Pilih tahun',
|
||||||
|
decadeSelect: 'Pilih dekad',
|
||||||
|
yearFormat: 'YYYY',
|
||||||
|
dayFormat: 'D',
|
||||||
|
dateFormat: 'M/D/YYYY',
|
||||||
|
dateTimeFormat: 'M/D/YYYY HH:mm:ss',
|
||||||
|
previousYear: 'Tahun lepas (Ctrl+left)',
|
||||||
|
nextYear: 'Tahun depan (Ctrl+right)',
|
||||||
|
previousDecade: 'Dekad lepas',
|
||||||
|
nextDecade: 'Dekad depan',
|
||||||
|
previousCentury: 'Abad lepas',
|
||||||
|
nextCentury: 'Abad depan',
|
||||||
|
};
|
|
@ -0,0 +1,28 @@
|
||||||
|
export default {
|
||||||
|
today: 'Azi',
|
||||||
|
now: 'Acum',
|
||||||
|
backToToday: 'Înapoi la azi',
|
||||||
|
ok: 'Ok',
|
||||||
|
clear: 'Șterge',
|
||||||
|
month: 'Lună',
|
||||||
|
year: 'An',
|
||||||
|
timeSelect: 'selectează timpul',
|
||||||
|
dateSelect: 'selectează data',
|
||||||
|
weekSelect: 'Alege o săptămână',
|
||||||
|
monthSelect: 'Alege o lună',
|
||||||
|
yearSelect: 'Alege un an',
|
||||||
|
decadeSelect: 'Alege un deceniu',
|
||||||
|
yearFormat: 'YYYY',
|
||||||
|
dateFormat: 'D/M/YYYY',
|
||||||
|
dayFormat: 'D',
|
||||||
|
dateTimeFormat: 'D/M/YYYY HH:mm:ss',
|
||||||
|
monthBeforeYear: true,
|
||||||
|
previousMonth: 'Luna anterioară (PageUp)',
|
||||||
|
nextMonth: 'Luna următoare (PageDown)',
|
||||||
|
previousYear: 'Anul anterior (Control + stânga)',
|
||||||
|
nextYear: 'Anul următor (Control + dreapta)',
|
||||||
|
previousDecade: 'Deceniul anterior',
|
||||||
|
nextDecade: 'Deceniul următor',
|
||||||
|
previousCentury: 'Secolul anterior',
|
||||||
|
nextCentury: 'Secolul următor',
|
||||||
|
};
|
|
@ -8,6 +8,7 @@ export default {
|
||||||
year: 'Rok',
|
year: 'Rok',
|
||||||
timeSelect: 'Vybrať čas',
|
timeSelect: 'Vybrať čas',
|
||||||
dateSelect: 'Vybrať dátum',
|
dateSelect: 'Vybrať dátum',
|
||||||
|
weekSelect: 'Vybrať týždeň',
|
||||||
monthSelect: 'Vybrať mesiac',
|
monthSelect: 'Vybrať mesiac',
|
||||||
yearSelect: 'Vybrať rok',
|
yearSelect: 'Vybrať rok',
|
||||||
decadeSelect: 'Vybrať dekádu',
|
decadeSelect: 'Vybrať dekádu',
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
export default {
|
||||||
|
today: 'இன்று',
|
||||||
|
now: 'இப்போது',
|
||||||
|
backToToday: 'இன்றுக்கு திரும்பு',
|
||||||
|
ok: 'சரி',
|
||||||
|
clear: 'அழி',
|
||||||
|
month: 'மாதம்',
|
||||||
|
year: 'வருடம்',
|
||||||
|
timeSelect: 'நேரத்தைத் தேர்ந்தெடு',
|
||||||
|
dateSelect: 'தேதியைத் தேர்ந்தெடு',
|
||||||
|
weekSelect: 'வாரத்தைத் தேர்வுசெய்க',
|
||||||
|
monthSelect: 'மாதத்தைத் தேர்வுசெய்க',
|
||||||
|
yearSelect: 'வருடத்தைத் தேர்வுசெய்க',
|
||||||
|
decadeSelect: 'தசாப்தத்தைத் தேர்வுசெய்க',
|
||||||
|
yearFormat: 'YYYY',
|
||||||
|
dateFormat: 'M/D/YYYY',
|
||||||
|
dayFormat: 'D',
|
||||||
|
dateTimeFormat: 'M/D/YYYY HH:mm:ss',
|
||||||
|
monthBeforeYear: true,
|
||||||
|
previousMonth: 'முந்தைய மாதம் (PageUp)',
|
||||||
|
nextMonth: 'அடுத்த மாதம் (PageDown)',
|
||||||
|
previousYear: 'முந்தைய வருடம் (Control + left)',
|
||||||
|
nextYear: 'அடுத்த வருடம் (Control + right)',
|
||||||
|
previousDecade: 'முந்தைய தசாப்தம்',
|
||||||
|
nextDecade: 'அடுத்த தசாப்தம்',
|
||||||
|
previousCentury: 'முந்தைய நூற்றாண்டு',
|
||||||
|
nextCentury: 'அடுத்த நூற்றாண்டு',
|
||||||
|
};
|
|
@ -72,7 +72,13 @@ const CalendarMixin = {
|
||||||
[newProps.class]: !!newProps.class,
|
[newProps.class]: !!newProps.class,
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<div ref="rootInstance" class={className} tabIndex="0" onKeydown={this.onKeyDown || noop}>
|
<div
|
||||||
|
ref="rootInstance"
|
||||||
|
class={className}
|
||||||
|
tabIndex="0"
|
||||||
|
onKeydown={this.onKeyDown || noop}
|
||||||
|
onBlur={this.onBlur || noop}
|
||||||
|
>
|
||||||
{newProps.children}
|
{newProps.children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,22 +1,4 @@
|
||||||
export default {
|
export default {
|
||||||
// getDefaultProps () {
|
|
||||||
// return {
|
|
||||||
// locale: enUs,
|
|
||||||
// visible: true,
|
|
||||||
// prefixCls: 'rc-calendar',
|
|
||||||
|
|
||||||
// renderFooter () {
|
|
||||||
// return null
|
|
||||||
// },
|
|
||||||
// renderSidebar () {
|
|
||||||
// return null
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
|
|
||||||
// shouldComponentUpdate (nextProps) {
|
|
||||||
// return this.props.visible || nextProps.visible
|
|
||||||
// },
|
|
||||||
methods: {
|
methods: {
|
||||||
getFormat() {
|
getFormat() {
|
||||||
let { format } = this;
|
let { format } = this;
|
||||||
|
|
|
@ -30,8 +30,9 @@ const CalendarPart = {
|
||||||
timePickerDisabledTime: PropTypes.object,
|
timePickerDisabledTime: PropTypes.object,
|
||||||
enableNext: PropTypes.any,
|
enableNext: PropTypes.any,
|
||||||
enablePrev: PropTypes.any,
|
enablePrev: PropTypes.any,
|
||||||
dateRender: PropTypes.func,
|
|
||||||
clearIcon: PropTypes.any,
|
clearIcon: PropTypes.any,
|
||||||
|
dateRender: PropTypes.func,
|
||||||
|
inputMode: PropTypes.string,
|
||||||
},
|
},
|
||||||
render() {
|
render() {
|
||||||
const { $props: props } = this;
|
const { $props: props } = this;
|
||||||
|
@ -56,6 +57,8 @@ const CalendarPart = {
|
||||||
showDateInput,
|
showDateInput,
|
||||||
dateRender,
|
dateRender,
|
||||||
showWeekNumber,
|
showWeekNumber,
|
||||||
|
showClear,
|
||||||
|
inputMode,
|
||||||
} = props;
|
} = props;
|
||||||
const clearIcon = getComponentFromProp(this, 'clearIcon');
|
const clearIcon = getComponentFromProp(this, 'clearIcon');
|
||||||
const {
|
const {
|
||||||
|
@ -107,12 +110,13 @@ const CalendarPart = {
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
disabledTime={disabledTime}
|
disabledTime={disabledTime}
|
||||||
value={value}
|
value={value}
|
||||||
showClear={false}
|
showClear={showClear || false}
|
||||||
selectedValue={selectedValue[index]}
|
selectedValue={selectedValue[index]}
|
||||||
onChange={inputSelect}
|
onChange={inputSelect}
|
||||||
onChange={inputChange}
|
onChange={inputChange}
|
||||||
onSelect={inputSelect}
|
onSelect={inputSelect}
|
||||||
clearIcon={clearIcon}
|
clearIcon={clearIcon}
|
||||||
|
inputMode={inputMode}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
const headerProps = {
|
const headerProps = {
|
||||||
|
|
|
@ -38,6 +38,7 @@ export function syncTime(from, to) {
|
||||||
to.hour(from.hour());
|
to.hour(from.hour());
|
||||||
to.minute(from.minute());
|
to.minute(from.minute());
|
||||||
to.second(from.second());
|
to.second(from.second());
|
||||||
|
to.millisecond(from.millisecond());
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getTimeConfig(value, disabledTime) {
|
export function getTimeConfig(value, disabledTime) {
|
||||||
|
|
Loading…
Reference in New Issue