date-picker.d.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. import { ElementUIComponent, ElementUIComponentSize, ElementUIHorizontalAlignment } from './component'
  2. export type DatePickerType = 'year' | 'month' | 'date' | 'datetime' | 'week' | 'datetimerange' | 'daterange' | 'dates'
  3. export type FirstDayOfWeek = 1 | 2 | 3 | 4 | 5 | 6 | 7
  4. export interface DisabledDateChecker {
  5. /**
  6. * Determine if `date` will be disabled in the picker
  7. *
  8. * @param date The date to check
  9. * @returns if `date` will be disabled in the picker
  10. */
  11. (date: Date): boolean
  12. }
  13. // Picked date range
  14. export interface DateRange {
  15. minDate: Date,
  16. maxDate: Date
  17. }
  18. export interface PickEventHandler {
  19. /**
  20. * Callback function that triggers when picks a date range
  21. *
  22. * @param dateRange The selected date range
  23. */
  24. (dateRange: DateRange): void
  25. }
  26. export interface ShortcutClickEventHandler {
  27. /**
  28. * Callback function that triggers when clicking on a shortcut.
  29. * You can change the picker value by emitting the pick event.
  30. * Example: `vm.$emit('pick', new Date())`
  31. */
  32. (vm: ElDatePicker): void
  33. }
  34. /** Shortcut options */
  35. export interface Shortcut {
  36. /** Title of the shortcut */
  37. text: string,
  38. /** Callback function that triggers when picks a date range */
  39. onClick?: ShortcutClickEventHandler
  40. }
  41. /** Options of el-date-picker */
  42. export interface DatePickerOptions {
  43. /** An object array to set shortcut options */
  44. shortcuts?: Shortcut[]
  45. /** A function determining if a date is disabled. */
  46. disabledDate?: DisabledDateChecker
  47. /** First day of week */
  48. firstDayOfWeek?: FirstDayOfWeek
  49. /** A callback that triggers when the seleted date is changed. Only for daterange and datetimerange. */
  50. onPick?: PickEventHandler
  51. }
  52. /** DatePicker Component */
  53. export declare class ElDatePicker extends ElementUIComponent {
  54. /** The value of the date picker */
  55. value: Date | string | Date[] | string[]
  56. /** Whether DatePicker is read only */
  57. readonly: boolean
  58. /** Whether DatePicker is disabled */
  59. disabled: boolean
  60. /** Size of Input */
  61. size: ElementUIComponentSize
  62. /** Whether the input is editable */
  63. editable: boolean
  64. /** Whether to show clear button */
  65. clearable: boolean
  66. /** Placeholder */
  67. placeholder: string
  68. /** Placeholder for the start date in range mode */
  69. startPlaceholder: string
  70. /** Placeholder for the end date in range mode */
  71. endPlaceholder: string
  72. /** Type of the picker */
  73. type: DatePickerType
  74. /** Format of the picker */
  75. format: string
  76. /** Alignment */
  77. align: ElementUIHorizontalAlignment
  78. /** Custom class name for DatePicker's dropdown */
  79. popperClass: string
  80. /** Additional options, check the table below */
  81. pickerOptions: DatePickerOptions
  82. /** Range separator */
  83. rangeSeparator: string
  84. /** Default date of the calendar */
  85. defaultValue: Date | number | string
  86. /** Format of binding value. If not specified, the binding value will be a Date object */
  87. valueFormat: string
  88. /** name for the inner native input */
  89. name: string
  90. /**
  91. * Focus the Input component
  92. */
  93. focus (): void
  94. }