toastr-config.d.ts 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. import { InjectionToken } from '@angular/core';
  2. import { SafeHtml } from '@angular/platform-browser';
  3. import { Observable } from 'rxjs';
  4. import { ComponentType } from '../portal/portal';
  5. import { ToastRef } from './toast-injector';
  6. export declare type ProgressAnimationType = 'increasing' | 'decreasing';
  7. /**
  8. * Configuration for an individual toast.
  9. */
  10. export interface IndividualConfig {
  11. /**
  12. * disable both timeOut and extendedTimeOut
  13. * default: false
  14. */
  15. disableTimeOut: boolean;
  16. /**
  17. * toast time to live in milliseconds
  18. * default: 5000
  19. */
  20. timeOut: number;
  21. /**
  22. * toast show close button
  23. * default: false
  24. */
  25. closeButton: boolean;
  26. /**
  27. * time to close after a user hovers over toast
  28. * default: 1000
  29. */
  30. extendedTimeOut: number;
  31. /**
  32. * show toast progress bar
  33. * default: false
  34. */
  35. progressBar: boolean;
  36. /**
  37. * changes toast progress bar animation
  38. * default: decreasing
  39. */
  40. progressAnimation: ProgressAnimationType;
  41. /**
  42. * render html in toast message (possibly unsafe)
  43. * default: false
  44. */
  45. enableHtml: boolean;
  46. /**
  47. * css class on toast component
  48. * default: ngx-toastr
  49. */
  50. toastClass: string;
  51. /**
  52. * css class on toast container
  53. * default: toast-top-right
  54. */
  55. positionClass: string;
  56. /**
  57. * css class on toast title
  58. * default: toast-title
  59. */
  60. titleClass: string;
  61. /**
  62. * css class on toast message
  63. * default: toast-message
  64. */
  65. messageClass: string;
  66. /**
  67. * animation easing on toast
  68. * default: ease-in
  69. */
  70. easing: string;
  71. /**
  72. * animation ease time on toast
  73. * default: 300
  74. */
  75. easeTime: string | number;
  76. /**
  77. * clicking on toast dismisses it
  78. * default: true
  79. */
  80. tapToDismiss: boolean;
  81. /**
  82. * Angular toast component to be shown
  83. * default: Toast
  84. */
  85. toastComponent?: ComponentType<any>;
  86. /**
  87. * Helps show toast from a websocket or from event outside Angular
  88. * default: false
  89. */
  90. onActivateTick: boolean;
  91. }
  92. export interface ToastrIconClasses {
  93. error: string;
  94. info: string;
  95. success: string;
  96. warning: string;
  97. }
  98. /**
  99. * Global Toast configuration
  100. * Includes all IndividualConfig
  101. */
  102. export interface GlobalConfig extends IndividualConfig {
  103. /**
  104. * max toasts opened. Toasts will be queued
  105. * Zero is unlimited
  106. * default: 0
  107. */
  108. maxOpened: number;
  109. /**
  110. * dismiss current toast when max is reached
  111. * default: false
  112. */
  113. autoDismiss: boolean;
  114. iconClasses: Partial<ToastrIconClasses>;
  115. /**
  116. * New toast placement
  117. * default: true
  118. */
  119. newestOnTop: boolean;
  120. /**
  121. * block duplicate messages
  122. * default: false
  123. */
  124. preventDuplicates: boolean;
  125. /**
  126. * display the number of duplicate messages
  127. * default: false
  128. */
  129. countDuplicates: boolean;
  130. /**
  131. * Reset toast timeout when there's a duplicate (preventDuplicates needs to be set to true)
  132. * default: false
  133. */
  134. resetTimeoutOnDuplicate: boolean;
  135. }
  136. /**
  137. * Everything a toast needs to launch
  138. */
  139. export declare class ToastPackage {
  140. toastId: number;
  141. config: IndividualConfig;
  142. message: string | SafeHtml | null | undefined;
  143. title: string | undefined;
  144. toastType: string;
  145. toastRef: ToastRef<any>;
  146. private _onTap;
  147. private _onAction;
  148. constructor(toastId: number, config: IndividualConfig, message: string | SafeHtml | null | undefined, title: string | undefined, toastType: string, toastRef: ToastRef<any>);
  149. /** Fired on click */
  150. triggerTap(): void;
  151. onTap(): Observable<any>;
  152. /** available for use in custom toast */
  153. triggerAction(action?: any): void;
  154. onAction(): Observable<any>;
  155. }
  156. /** @deprecated use GlobalConfig */
  157. export interface GlobalToastrConfig extends GlobalConfig {
  158. }
  159. /** @deprecated use IndividualConfig */
  160. export interface IndividualToastrConfig extends IndividualConfig {
  161. }
  162. /** @deprecated use IndividualConfig */
  163. export interface ToastrConfig extends IndividualConfig {
  164. }
  165. export declare const DefaultNoComponentGlobalConfig: GlobalConfig;
  166. export interface ToastToken {
  167. default: GlobalConfig;
  168. config: Partial<GlobalConfig>;
  169. }
  170. export declare const TOAST_CONFIG: InjectionToken<ToastToken>;