File size: 4,746 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
import type {
PickerRef,
PickerProps as RcPickerProps,
RangePickerProps as RcRangePickerProps,
} from 'rc-picker';
import type { Locale as RcPickerLocale } from 'rc-picker/lib/interface';
import type { InputStatus } from '../../_util/statusUtils';
import type { AnyObject } from '../../_util/type';
import type { SizeType } from '../../config-provider/SizeContext';
import type { Variant } from '../../config-provider';
import type { TimePickerLocale } from '../../time-picker';
const _DataPickerPlacements = ['bottomLeft', 'bottomRight', 'topLeft', 'topRight'] as const;
type DataPickerPlacement = (typeof _DataPickerPlacements)[number];
type SemanticName = 'root';
type PopupSemantic = 'root';
export type PickerLocale = {
lang: RcPickerLocale & AdditionalPickerLocaleLangProps;
timePickerLocale: TimePickerLocale;
} & AdditionalPickerLocaleProps;
/** @deprecated **Useless**. */
export type AdditionalPickerLocaleProps = {
/**
* @deprecated **Invalid**, Please use `lang.fieldDateFormat` instead.
* @see [Migration Guide](https://github.com/ant-design/ant-design/discussions/53011)
*/
dateFormat?: string;
/**
* @deprecated **Invalid**, Please use `lang.fieldDateTimeFormat` instead,
* @see [Migration Guide](https://github.com/ant-design/ant-design/discussions/53011)
*/
dateTimeFormat?: string;
/**
* @deprecated **Invalid**, Please use `lang.fieldWeekFormat` instead,
* @see [Migration Guide](https://github.com/ant-design/ant-design/discussions/53011)
*/
weekFormat?: string;
/**
* @deprecated **Invalid**, Please use `lang.fieldWeekFormat` instead,
* @see [Migration Guide](https://github.com/ant-design/ant-design/discussions/53011)
*/
monthFormat?: string;
};
export type AdditionalPickerLocaleLangProps = {
placeholder: string;
yearPlaceholder?: string;
quarterPlaceholder?: string;
monthPlaceholder?: string;
weekPlaceholder?: string;
rangeYearPlaceholder?: [string, string];
rangeQuarterPlaceholder?: [string, string];
rangeMonthPlaceholder?: [string, string];
rangeWeekPlaceholder?: [string, string];
rangePlaceholder?: [string, string];
};
export type PickerClassNames = Partial<Record<SemanticName, string>> & {
popup?: Partial<Record<PopupSemantic, string>>;
};
export type PickerStyles = Partial<Record<SemanticName, React.CSSProperties>> & {
popup?: Partial<Record<PopupSemantic, React.CSSProperties>>;
};
export type RequiredSemanticPicker = readonly [
classNames: Required<Record<SemanticName, string>> & {
popup: Required<Record<PopupSemantic, string>>;
},
styles: Required<Record<SemanticName, React.CSSProperties>> & {
popup: Required<Record<PopupSemantic, React.CSSProperties>>;
},
];
type InjectDefaultProps<Props> = Omit<
Props,
'locale' | 'generateConfig' | 'hideHeader' | 'classNames' | 'styles'
> & {
locale?: PickerLocale;
size?: SizeType;
placement?: DataPickerPlacement;
/** @deprecated Use `variant` instead */
bordered?: boolean;
status?: InputStatus;
/**
* @since 5.13.0
* @default "outlined"
*/
variant?: Variant;
/**
* @deprecated `dropdownClassName` is deprecated which will be removed in next major
* version.Please use `classNames.popup.root` instead.
*/
dropdownClassName?: string;
/**
* @deprecated please use `classNames.popup.root` instead
*/
popupClassName?: string;
rootClassName?: string;
/**
* @deprecated please use `styles.popup.root` instead
*/
popupStyle?: React.CSSProperties;
styles?: PickerStyles;
classNames?: PickerClassNames;
};
/** Base Single Picker props */
export type PickerProps<DateType extends AnyObject = any> = InjectDefaultProps<
RcPickerProps<DateType>
>;
/** Base Range Picker props */
export type RangePickerProps<DateType extends AnyObject = any> = InjectDefaultProps<
RcRangePickerProps<DateType>
>;
export type GenericTimePickerProps<DateType extends AnyObject = any> = Omit<
PickerProps<DateType>,
'picker' | 'showTime'
> & {
/** @deprecated Please use `onCalendarChange` instead */
onSelect?: (value: DateType) => void;
};
/**
* Single Picker has the `multiple` prop,
* which will make the `value` be `DateType[]` type.
* Here to be a generic which accept the `ValueType` for developer usage.
*/
export type PickerPropsWithMultiple<
DateType extends AnyObject = any,
InnerPickerProps extends PickerProps<DateType> = PickerProps<DateType>,
ValueType = DateType,
> = Omit<InnerPickerProps, 'defaultValue' | 'value' | 'onChange' | 'onOk'> &
React.RefAttributes<PickerRef> & {
defaultValue?: ValueType | null;
value?: ValueType | null;
onChange?: (date: ValueType, dateString: string | string[]) => void;
onOk?: (date: ValueType) => void;
};
|