2019-12-11 23:32:19 +08:00
|
|
|
import { PickerMode } from 'rc-picker/lib/interface';
|
2020-03-12 10:49:32 +08:00
|
|
|
import { PickerLocale } from './generatePicker';
|
2019-12-11 23:32:19 +08:00
|
|
|
|
2020-03-12 10:49:32 +08:00
|
|
|
export function getPlaceholder(picker: PickerMode | undefined, locale: PickerLocale): string {
|
2019-12-11 23:32:19 +08:00
|
|
|
if (picker === 'year' && locale.lang.yearPlaceholder) {
|
|
|
|
return locale.lang.yearPlaceholder;
|
|
|
|
}
|
2020-03-21 22:43:04 +08:00
|
|
|
if (picker === 'quarter' && locale.lang.quarterPlaceholder) {
|
|
|
|
return locale.lang.quarterPlaceholder;
|
|
|
|
}
|
2019-12-11 23:32:19 +08:00
|
|
|
if (picker === 'month' && locale.lang.monthPlaceholder) {
|
|
|
|
return locale.lang.monthPlaceholder;
|
|
|
|
}
|
|
|
|
if (picker === 'week' && locale.lang.weekPlaceholder) {
|
|
|
|
return locale.lang.weekPlaceholder;
|
|
|
|
}
|
|
|
|
if (picker === 'time' && locale.timePickerLocale.placeholder) {
|
|
|
|
return locale!.timePickerLocale.placeholder;
|
|
|
|
}
|
|
|
|
return locale.lang.placeholder;
|
|
|
|
}
|
|
|
|
|
2020-03-12 10:49:32 +08:00
|
|
|
export function getRangePlaceholder(picker: PickerMode | undefined, locale: PickerLocale) {
|
2019-12-11 23:32:19 +08:00
|
|
|
if (picker === 'year' && locale.lang.yearPlaceholder) {
|
|
|
|
return locale.lang.rangeYearPlaceholder;
|
|
|
|
}
|
|
|
|
if (picker === 'month' && locale.lang.monthPlaceholder) {
|
|
|
|
return locale.lang.rangeMonthPlaceholder;
|
|
|
|
}
|
|
|
|
if (picker === 'week' && locale.lang.weekPlaceholder) {
|
|
|
|
return locale.lang.rangeWeekPlaceholder;
|
|
|
|
}
|
|
|
|
if (picker === 'time' && locale.timePickerLocale.placeholder) {
|
|
|
|
return locale!.timePickerLocale.rangePlaceholder;
|
|
|
|
}
|
|
|
|
return locale.lang.rangePlaceholder;
|
|
|
|
}
|