SinglePicker.d.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import * as React from 'react';
  2. import type { BaseInfo, PanelMode, PickerRef, SharedPickerProps, SharedTimeProps, ValueDate } from '../interface';
  3. export interface BasePickerProps<DateType extends object = any> extends SharedPickerProps<DateType> {
  4. id?: string;
  5. /** Not support `time` or `datetime` picker */
  6. multiple?: boolean;
  7. removeIcon?: React.ReactNode;
  8. /** Only work when `multiple` is in used */
  9. maxTagCount?: number | 'responsive';
  10. value?: DateType | DateType[] | null;
  11. defaultValue?: DateType | DateType[];
  12. onChange?: (date: DateType | DateType[], dateString: string | string[]) => void;
  13. onCalendarChange?: (date: DateType | DateType[], dateString: string | string[], info: BaseInfo) => void;
  14. /** */
  15. onOk?: (value?: DateType | DateType[]) => void;
  16. placeholder?: string;
  17. /**
  18. * Config the popup panel date.
  19. * Every time active the input to open popup will reset with `defaultPickerValue`.
  20. *
  21. * Note: `defaultPickerValue` priority is higher than `value` for the first open.
  22. */
  23. defaultPickerValue?: DateType | null;
  24. /**
  25. * Config each start & end field popup panel date.
  26. * When config `pickerValue`, you must also provide `onPickerValueChange` to handle changes.
  27. */
  28. pickerValue?: DateType | null;
  29. /**
  30. * Each popup panel `pickerValue` change will trigger the callback.
  31. * @param date The changed picker value
  32. * @param info.source `panel` from the panel click. `reset` from popup open or field typing.
  33. */
  34. onPickerValueChange?: (date: DateType, info: {
  35. source: 'reset' | 'panel';
  36. mode: PanelMode;
  37. }) => void;
  38. presets?: ValueDate<DateType>[];
  39. disabled?: boolean;
  40. mode?: PanelMode;
  41. onPanelChange?: (values: DateType, modes: PanelMode) => void;
  42. }
  43. export interface PickerProps<DateType extends object = any> extends BasePickerProps<DateType>, Omit<SharedTimeProps<DateType>, 'format' | 'defaultValue'> {
  44. }
  45. /** Internal usage. For cross function get same aligned props */
  46. export type ReplacedPickerProps<DateType extends object = any> = {
  47. onChange?: (date: DateType | DateType[], dateString: string | string[]) => void;
  48. onCalendarChange?: (date: DateType | DateType[], dateString: string | string[], info: BaseInfo) => void;
  49. };
  50. declare const RefPicker: <DateType extends object = any>(props: PickerProps<DateType> & React.RefAttributes<PickerRef>) => React.ReactElement;
  51. export default RefPicker;