🌈 An enterprise-class UI components based on Ant Design and Vue. 🐜
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

102 lines
2.5 KiB

import type { PickerMode } from '../vc-picker/interface';
import type { SelectCommonPlacement } from '../_util/transition';
import type { PickerLocale } from './generatePicker';
import type { DirectionType } from '../config-provider';
export function getPlaceholder(
locale: PickerLocale,
picker: PickerMode,
customizePlaceholder?: string,
): string {
if (customizePlaceholder !== undefined) {
return customizePlaceholder;
}
if (picker === 'year' && locale.lang.yearPlaceholder) {
return locale.lang.yearPlaceholder;
}
if (picker === 'quarter' && locale.lang.quarterPlaceholder) {
return locale.lang.quarterPlaceholder;
}
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;
}
export function getRangePlaceholder(
locale: PickerLocale,
picker: PickerMode,
customizePlaceholder?: [string, string],
) {
if (customizePlaceholder !== undefined) {
return customizePlaceholder;
}
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;
}
export function transPlacement2DropdownAlign(
direction: DirectionType,
placement?: SelectCommonPlacement,
) {
const overflow = {
adjustX: 1,
adjustY: 1,
};
switch (placement) {
case 'bottomLeft': {
return {
points: ['tl', 'bl'],
offset: [0, 4],
overflow,
};
}
case 'bottomRight': {
return {
points: ['tr', 'br'],
offset: [0, 4],
overflow,
};
}
case 'topLeft': {
return {
points: ['bl', 'tl'],
offset: [0, -4],
overflow,
};
}
case 'topRight': {
return {
points: ['br', 'tr'],
offset: [0, -4],
overflow,
};
}
default: {
return {
points: direction === 'rtl' ? ['tr', 'br'] : ['tl', 'bl'],
offset: [0, 4],
overflow,
};
}
}
}