feat: remove localeCode
parent
889ae305df
commit
8e45eebea4
|
@ -1 +1 @@
|
||||||
Subproject commit e705545e455dd81aef96dc293c84f303cff67b21
|
Subproject commit b35f6ab6b59169fa7c0413263f75c185bd62b97c
|
|
@ -170,12 +170,9 @@ const Calendar = defineComponent({
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
renderCalendar(locale: any, localeCode: string) {
|
renderCalendar(locale: any) {
|
||||||
const props: any = { ...getOptionProps(this), ...this.$attrs };
|
const props: any = { ...getOptionProps(this), ...this.$attrs };
|
||||||
const { sValue: value, sMode: mode, $slots } = this;
|
const { sValue: value, sMode: mode, $slots } = this;
|
||||||
if (value && localeCode) {
|
|
||||||
value.locale(localeCode);
|
|
||||||
}
|
|
||||||
const {
|
const {
|
||||||
prefixCls: customizePrefixCls,
|
prefixCls: customizePrefixCls,
|
||||||
fullscreen,
|
fullscreen,
|
||||||
|
|
|
@ -59,22 +59,6 @@ function isEmptyArray(arr: any) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fixLocale(value: RangePickerValue | undefined, localeCode: string | undefined) {
|
|
||||||
if (!localeCode) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!value || value.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const [start, end] = value;
|
|
||||||
if (start) {
|
|
||||||
start.locale(localeCode);
|
|
||||||
}
|
|
||||||
if (end) {
|
|
||||||
end.locale(localeCode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface RangePickerState {
|
export interface RangePickerState {
|
||||||
sValue?: RangePickerValue;
|
sValue?: RangePickerValue;
|
||||||
sShowDate?: RangePickerValue;
|
sShowDate?: RangePickerValue;
|
||||||
|
@ -301,7 +285,6 @@ export default defineComponent({
|
||||||
showToday,
|
showToday,
|
||||||
ranges,
|
ranges,
|
||||||
locale,
|
locale,
|
||||||
localeCode,
|
|
||||||
format,
|
format,
|
||||||
separator,
|
separator,
|
||||||
inputReadOnly,
|
inputReadOnly,
|
||||||
|
@ -319,8 +302,6 @@ export default defineComponent({
|
||||||
this.sTagPrefixCls = tagPrefixCls;
|
this.sTagPrefixCls = tagPrefixCls;
|
||||||
|
|
||||||
const dateRender = props.dateRender || $slots.dateRender;
|
const dateRender = props.dateRender || $slots.dateRender;
|
||||||
fixLocale(value, localeCode);
|
|
||||||
fixLocale(showDate, localeCode);
|
|
||||||
|
|
||||||
const calendarClassName = classNames({
|
const calendarClassName = classNames({
|
||||||
[`${prefixCls}-time`]: showTime,
|
[`${prefixCls}-time`]: showTime,
|
||||||
|
|
|
@ -148,7 +148,6 @@ export default defineComponent({
|
||||||
format,
|
format,
|
||||||
allowClear,
|
allowClear,
|
||||||
locale,
|
locale,
|
||||||
localeCode,
|
|
||||||
disabledDate,
|
disabledDate,
|
||||||
defaultPickerValue,
|
defaultPickerValue,
|
||||||
$data,
|
$data,
|
||||||
|
@ -161,10 +160,6 @@ export default defineComponent({
|
||||||
const { _value: pickerValue, _open: open } = $data;
|
const { _value: pickerValue, _open: open } = $data;
|
||||||
const { class: className, style, id, onFocus = noop, onBlur = noop } = props as any;
|
const { class: className, style, id, onFocus = noop, onBlur = noop } = props as any;
|
||||||
|
|
||||||
if (pickerValue && localeCode) {
|
|
||||||
pickerValue.locale(localeCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
const placeholder = hasProp(this, 'placeholder') ? this.placeholder : locale.lang.placeholder;
|
const placeholder = hasProp(this, 'placeholder') ? this.placeholder : locale.lang.placeholder;
|
||||||
const weekDateRender = this.dateRender || $slots.dateRender || this.weekDateRender;
|
const weekDateRender = this.dateRender || $slots.dateRender || this.weekDateRender;
|
||||||
const calendar = (
|
const calendar = (
|
||||||
|
|
|
@ -143,7 +143,7 @@ export default function createPicker<P>(
|
||||||
suffixIcon = Array.isArray(suffixIcon) ? suffixIcon[0] : suffixIcon;
|
suffixIcon = Array.isArray(suffixIcon) ? suffixIcon[0] : suffixIcon;
|
||||||
const props: any = omit({ ...getOptionProps(this), ...this.$attrs }, ['onChange']);
|
const props: any = omit({ ...getOptionProps(this), ...this.$attrs }, ['onChange']);
|
||||||
|
|
||||||
const { prefixCls: customizePrefixCls, locale, localeCode, inputReadOnly } = props;
|
const { prefixCls: customizePrefixCls, locale, inputReadOnly } = props;
|
||||||
const getPrefixCls = this.configProvider.getPrefixCls;
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
||||||
const prefixCls = getPrefixCls('calendar', customizePrefixCls);
|
const prefixCls = getPrefixCls('calendar', customizePrefixCls);
|
||||||
this.sPrefixCls = prefixCls;
|
this.sPrefixCls = prefixCls;
|
||||||
|
@ -159,10 +159,6 @@ export default function createPicker<P>(
|
||||||
[`${prefixCls}-month`]: (MonthCalendar as any) === TheCalendar,
|
[`${prefixCls}-month`]: (MonthCalendar as any) === TheCalendar,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (value && localeCode) {
|
|
||||||
value.locale(localeCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
const pickerProps: any = {};
|
const pickerProps: any = {};
|
||||||
const calendarProps: any = {};
|
const calendarProps: any = {};
|
||||||
const pickerStyle: CSSProperties = {};
|
const pickerStyle: CSSProperties = {};
|
||||||
|
|
|
@ -157,7 +157,7 @@ export default function wrapPicker<P>(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
renderPicker(locale: any, localeCode: string) {
|
renderPicker(locale: any) {
|
||||||
const props: any = { ...getOptionProps(this), ...this.$attrs };
|
const props: any = { ...getOptionProps(this), ...this.$attrs };
|
||||||
this.transformValue(props);
|
this.transformValue(props);
|
||||||
const {
|
const {
|
||||||
|
@ -214,7 +214,6 @@ export default function wrapPicker<P>(
|
||||||
pickerClass,
|
pickerClass,
|
||||||
pickerInputClass,
|
pickerInputClass,
|
||||||
locale,
|
locale,
|
||||||
localeCode,
|
|
||||||
timePicker,
|
timePicker,
|
||||||
onOpenChange: this.handleOpenChange,
|
onOpenChange: this.handleOpenChange,
|
||||||
onFocus: this.handleFocus,
|
onFocus: this.handleFocus,
|
||||||
|
|
|
@ -45,27 +45,23 @@ const MonthCalendar = defineComponent({
|
||||||
let value = stateValue;
|
let value = stateValue;
|
||||||
switch (keyCode) {
|
switch (keyCode) {
|
||||||
case KeyCode.DOWN:
|
case KeyCode.DOWN:
|
||||||
value = stateValue.clone();
|
value = stateValue.clone().add(3, 'months');
|
||||||
value.add(3, 'months');
|
|
||||||
break;
|
break;
|
||||||
case KeyCode.UP:
|
case KeyCode.UP:
|
||||||
value = stateValue.clone();
|
value = stateValue.clone().add(-3, 'months');
|
||||||
value.add(-3, 'months');
|
|
||||||
break;
|
break;
|
||||||
case KeyCode.LEFT:
|
case KeyCode.LEFT:
|
||||||
value = stateValue.clone();
|
|
||||||
if (ctrlKey) {
|
if (ctrlKey) {
|
||||||
value.add(-1, 'years');
|
value = stateValue.clone().add(-1, 'years');
|
||||||
} else {
|
} else {
|
||||||
value.add(-1, 'months');
|
value = stateValue.clone().add(-1, 'months');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KeyCode.RIGHT:
|
case KeyCode.RIGHT:
|
||||||
value = stateValue.clone();
|
|
||||||
if (ctrlKey) {
|
if (ctrlKey) {
|
||||||
value.add(1, 'years');
|
value = stateValue.clone().add(1, 'years');
|
||||||
} else {
|
} else {
|
||||||
value.add(1, 'months');
|
value = stateValue.clone().add(1, 'months');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KeyCode.ENTER:
|
case KeyCode.ENTER:
|
||||||
|
|
|
@ -6,14 +6,12 @@ import YearPanel from '../year/YearPanel';
|
||||||
import DecadePanel from '../decade/DecadePanel';
|
import DecadePanel from '../decade/DecadePanel';
|
||||||
function noop() {}
|
function noop() {}
|
||||||
function goMonth(direction) {
|
function goMonth(direction) {
|
||||||
const next = this.value.clone();
|
const next = this.value.clone().add(direction, 'months');
|
||||||
next.add(direction, 'months');
|
|
||||||
this.__emit('valueChange', next);
|
this.__emit('valueChange', next);
|
||||||
}
|
}
|
||||||
|
|
||||||
function goYear(direction) {
|
function goYear(direction) {
|
||||||
const next = this.value.clone();
|
const next = this.value.clone().add(direction, 'years');
|
||||||
next.add(direction, 'years');
|
|
||||||
this.__emit('valueChange', next);
|
this.__emit('valueChange', next);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,15 +78,13 @@ const DateTBody = {
|
||||||
const day = month1.day();
|
const day = month1.day();
|
||||||
const lastMonthDiffDay = (day + 7 - value.localeData().firstDayOfWeek()) % 7;
|
const lastMonthDiffDay = (day + 7 - value.localeData().firstDayOfWeek()) % 7;
|
||||||
// calculate last month
|
// calculate last month
|
||||||
const lastMonth1 = month1.clone();
|
const lastMonth1 = month1.clone().add(0 - lastMonthDiffDay, 'days');
|
||||||
lastMonth1.add(0 - lastMonthDiffDay, 'days');
|
|
||||||
let passed = 0;
|
let passed = 0;
|
||||||
for (iIndex = 0; iIndex < DateConstants.DATE_ROW_COUNT; iIndex++) {
|
for (iIndex = 0; iIndex < DateConstants.DATE_ROW_COUNT; iIndex++) {
|
||||||
for (jIndex = 0; jIndex < DateConstants.DATE_COL_COUNT; jIndex++) {
|
for (jIndex = 0; jIndex < DateConstants.DATE_COL_COUNT; jIndex++) {
|
||||||
current = lastMonth1;
|
current = lastMonth1;
|
||||||
if (passed) {
|
if (passed) {
|
||||||
current = current.clone();
|
current = current.clone().add(passed, 'days');
|
||||||
current.add(passed, 'days');
|
|
||||||
}
|
}
|
||||||
dateTable.push(current);
|
dateTable.push(current);
|
||||||
passed++;
|
passed++;
|
||||||
|
|
|
@ -4,8 +4,7 @@ const ROW = 4;
|
||||||
const COL = 3;
|
const COL = 3;
|
||||||
function noop() {}
|
function noop() {}
|
||||||
function goYear(direction) {
|
function goYear(direction) {
|
||||||
const next = this.sValue.clone();
|
const next = this.sValue.clone().add(direction, 'years');
|
||||||
next.add(direction, 'years');
|
|
||||||
this.setState({
|
this.setState({
|
||||||
sValue: next,
|
sValue: next,
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,8 +13,9 @@ const defaultDisabledTime = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getTodayTime(value) {
|
export function getTodayTime(value) {
|
||||||
const today = moment();
|
const today = moment()
|
||||||
today.locale(value.locale()).utcOffset(value.utcOffset());
|
.locale(value.locale())
|
||||||
|
.utcOffset(value.utcOffset());
|
||||||
return today;
|
return today;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,7 @@ const ROW = 4;
|
||||||
const COL = 3;
|
const COL = 3;
|
||||||
function noop() {}
|
function noop() {}
|
||||||
function goYear(direction) {
|
function goYear(direction) {
|
||||||
const value = this.sValue.clone();
|
const value = this.sValue.clone().add(direction, 'year');
|
||||||
value.add(direction, 'year');
|
|
||||||
this.setState({
|
this.setState({
|
||||||
sValue: value,
|
sValue: value,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue