notification.d.ts 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. import { IconPropType } from "../../../utils/vue/icon.js";
  2. import { EpPropFinalized, EpPropMergeType } from "../../../utils/vue/props/types.js";
  3. import _default from "./notification.vue.js";
  4. import * as _$vue from "vue";
  5. import { AppContext, ExtractPublicPropTypes, VNode } from "vue";
  6. //#region ../../packages/components/notification/src/notification.d.ts
  7. declare const notificationTypes: readonly ["primary", "success", "info", "warning", "error"];
  8. type NotificationType = (typeof notificationTypes)[number] | '';
  9. type NotificationPosition = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
  10. interface NotificationProps {
  11. /**
  12. * @description custom class name for Notification
  13. */
  14. customClass?: string;
  15. /**
  16. * @description whether `message` is treated as HTML string
  17. */
  18. dangerouslyUseHTMLString?: boolean;
  19. /**
  20. * @description duration before close. It will not automatically close if set 0
  21. */
  22. duration?: number;
  23. /**
  24. * @description custom icon component. It will be overridden by `type`
  25. */
  26. icon?: IconPropType;
  27. /**
  28. * @description notification dom id
  29. */
  30. id?: string;
  31. /**
  32. * @description description text
  33. */
  34. message?: string | VNode | (() => VNode);
  35. /**
  36. * @description offset from the top edge of the screen. Every Notification instance of the same moment should have the same offset
  37. */
  38. offset?: number;
  39. /**
  40. * @description callback function when notification clicked
  41. */
  42. onClick?: () => void;
  43. /**
  44. * @description callback function when closed
  45. */
  46. onClose: () => void;
  47. /**
  48. * @description custom position
  49. */
  50. position?: NotificationPosition;
  51. /**
  52. * @description whether to show a close button
  53. */
  54. showClose?: boolean;
  55. /**
  56. * @description title
  57. */
  58. title?: string;
  59. /**
  60. * @description notification type
  61. */
  62. type?: NotificationType;
  63. /**
  64. * @description initial zIndex
  65. */
  66. zIndex?: number;
  67. /**
  68. * @description custom close icon, default is Close
  69. */
  70. closeIcon?: IconPropType;
  71. }
  72. /**
  73. * @deprecated Removed after 3.0.0, Use `NotificationProps` instead.
  74. */
  75. declare const notificationProps: {
  76. readonly customClass: EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
  77. readonly dangerouslyUseHTMLString: BooleanConstructor;
  78. readonly duration: EpPropFinalized<NumberConstructor, unknown, unknown, 4500, boolean>;
  79. readonly icon: {
  80. readonly type: _$vue.PropType<EpPropMergeType<(new (...args: any[]) => (string | _$vue.Component) & {}) | (() => string | _$vue.Component) | (((new (...args: any[]) => (string | _$vue.Component) & {}) | (() => string | _$vue.Component)) | null)[], unknown, unknown>>;
  81. readonly required: false;
  82. readonly validator: ((val: unknown) => boolean) | undefined;
  83. __epPropKey: true;
  84. };
  85. readonly id: EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
  86. readonly message: EpPropFinalized<(new (...args: any[]) => string | VNode<_$vue.RendererNode, _$vue.RendererElement, {
  87. [key: string]: any;
  88. }> | (() => VNode)) | (() => string | VNode<_$vue.RendererNode, _$vue.RendererElement, {
  89. [key: string]: any;
  90. }> | (() => VNode)) | (((new (...args: any[]) => string | VNode<_$vue.RendererNode, _$vue.RendererElement, {
  91. [key: string]: any;
  92. }> | (() => VNode)) | (() => string | VNode<_$vue.RendererNode, _$vue.RendererElement, {
  93. [key: string]: any;
  94. }> | (() => VNode))) | null)[], unknown, unknown, "", boolean>;
  95. readonly offset: EpPropFinalized<NumberConstructor, unknown, unknown, 0, boolean>;
  96. readonly onClick: EpPropFinalized<(new (...args: any[]) => () => void) | (() => () => void) | {
  97. (): () => void;
  98. new (): any;
  99. readonly prototype: any;
  100. } | (((new (...args: any[]) => () => void) | (() => () => void) | {
  101. (): () => void;
  102. new (): any;
  103. readonly prototype: any;
  104. }) | null)[], unknown, unknown, () => undefined, boolean>;
  105. readonly onClose: {
  106. readonly type: _$vue.PropType<() => void>;
  107. readonly required: true;
  108. readonly validator: ((val: unknown) => boolean) | undefined;
  109. __epPropKey: true;
  110. };
  111. readonly position: EpPropFinalized<StringConstructor, "top-left" | "top-right" | "bottom-left" | "bottom-right", unknown, "top-right", boolean>;
  112. readonly showClose: EpPropFinalized<BooleanConstructor, unknown, unknown, true, boolean>;
  113. readonly title: EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
  114. readonly type: EpPropFinalized<StringConstructor, "" | "info" | "primary" | "success" | "warning" | "error", unknown, "", boolean>;
  115. readonly zIndex: NumberConstructor;
  116. readonly closeIcon: EpPropFinalized<(new (...args: any[]) => (string | _$vue.Component) & {}) | (() => string | _$vue.Component) | (((new (...args: any[]) => (string | _$vue.Component) & {}) | (() => string | _$vue.Component)) | null)[], unknown, unknown, _$vue.DefineComponent<{}, void, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<{}>, {}, {}, {}, {}, string, _$vue.ComponentProvideOptions, true, {}, any>, boolean>;
  117. };
  118. /**
  119. * @deprecated Removed after 3.0.0, Use `NotificationProps` instead.
  120. */
  121. type NotificationPropsPublic = ExtractPublicPropTypes<typeof notificationProps>;
  122. declare const notificationEmits: {
  123. destroy: () => boolean;
  124. };
  125. type NotificationEmits = typeof notificationEmits;
  126. type NotificationInstance = InstanceType<typeof _default> & unknown;
  127. type NotificationOptions = Omit<NotificationProps, 'id' | 'onClose'> & {
  128. /**
  129. * @description set the root element for the notification, default to `document.body`
  130. */
  131. appendTo?: HTMLElement | string;
  132. /**
  133. * @description callback function when closed
  134. */
  135. onClose?(vm: VNode): void;
  136. };
  137. type NotificationOptionsTyped = Omit<NotificationOptions, 'type'>;
  138. interface NotificationHandle {
  139. close: () => void;
  140. }
  141. type NotificationParams = Partial<NotificationOptions> | string | VNode;
  142. type NotificationParamsTyped = Partial<NotificationOptionsTyped> | string | VNode;
  143. interface NotifyFn {
  144. (options?: NotificationParams, appContext?: null | AppContext): NotificationHandle;
  145. closeAll(): void;
  146. updateOffsets(position?: NotificationOptions['position']): void;
  147. _context: AppContext | null;
  148. }
  149. type NotifyTypedFn = (options?: NotificationParamsTyped, appContext?: null | AppContext) => NotificationHandle;
  150. interface Notify extends NotifyFn {
  151. primary: NotifyTypedFn;
  152. success: NotifyTypedFn;
  153. warning: NotifyTypedFn;
  154. error: NotifyTypedFn;
  155. info: NotifyTypedFn;
  156. }
  157. interface NotificationQueueItem {
  158. vm: VNode;
  159. }
  160. type NotificationQueue = NotificationQueueItem[];
  161. //#endregion
  162. export { NotificationEmits, NotificationHandle, NotificationInstance, NotificationOptions, NotificationOptionsTyped, NotificationParams, NotificationParamsTyped, NotificationPosition, NotificationProps, NotificationPropsPublic, NotificationQueue, NotificationQueueItem, NotificationType, Notify, NotifyFn, NotifyTypedFn, notificationEmits, notificationProps, notificationTypes };