notification.d.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import Vue, { VNode } from 'vue'
  2. import { MessageType } from './message'
  3. export type NotificationPosition = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'
  4. /** Notification Component */
  5. export declare class ElNotificationComponent extends Vue {
  6. /** Close the Notification instance */
  7. close (): void
  8. }
  9. export interface ElNotificationOptions {
  10. /** Title */
  11. title: string
  12. /** Description text */
  13. message: string | VNode
  14. /** Notification type */
  15. type?: MessageType
  16. /** Custom icon's class. It will be overridden by type */
  17. iconClass?: string
  18. /** Custom class name for Notification */
  19. customClass?: string
  20. /** Duration before close. It will not automatically close if set 0 */
  21. duration?: number
  22. /** Whether to show a close button */
  23. showClose?: boolean
  24. /** Whether message is treated as HTML string */
  25. dangerouslyUseHTMLString?: boolean
  26. /** Callback function when closed */
  27. onClose?: () => void
  28. /** Callback function when notification clicked */
  29. onClick?: () => void
  30. /** Offset from the top edge of the screen. Every Notification instance of the same moment should have the same offset */
  31. offset?: number
  32. /** custom position */
  33. position?: NotificationPosition
  34. }
  35. export interface ElNotification {
  36. /** Show a notification */
  37. (options: ElNotificationOptions): ElNotificationComponent
  38. /** Show a success notification */
  39. success (message: string | VNode): ElNotificationComponent
  40. /** Show a success notification */
  41. success (options: ElNotificationOptions): ElNotificationComponent
  42. /** Show a warning notification */
  43. warning (message: string | VNode): ElNotificationComponent
  44. /** Show a warning notification */
  45. warning (options: ElNotificationOptions): ElNotificationComponent
  46. /** Show an info notification */
  47. info (message: string | VNode): ElNotificationComponent
  48. /** Show an info notification */
  49. info (options: ElNotificationOptions): ElNotificationComponent
  50. /** Show an error notification */
  51. error (message: string | VNode): ElNotificationComponent
  52. /** Show an error notification */
  53. error (options: ElNotificationOptions): ElNotificationComponent
  54. }
  55. declare module 'vue/types/vue' {
  56. interface Vue {
  57. /** Displays a global notification message at the upper right corner of the page */
  58. $notify: ElNotification
  59. }
  60. }