interface.d.ts 4.7 KB

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