element-plus
Version:
A Component Library for Vue 3
1 lines • 7.79 kB
Source Map (JSON)
{"version":3,"file":"notification.mjs","sources":["../../../../../../packages/components/notification/src/notification.ts"],"sourcesContent":["import { Close } from '@element-plus/icons-vue'\nimport { buildProps, definePropType, iconPropType } from '@element-plus/utils'\n\nimport type { AppContext, Component, ExtractPublicPropTypes, VNode } from 'vue'\nimport type Notification from './notification.vue'\n\nexport const notificationTypes = [\n 'primary',\n 'success',\n 'info',\n 'warning',\n 'error',\n] as const\n\nexport type NotificationType = (typeof notificationTypes)[number] | ''\n\nexport type NotificationPosition =\n | 'top-right'\n | 'top-left'\n | 'bottom-right'\n | 'bottom-left'\n\nexport interface NotificationProps {\n /**\n * @description custom class name for Notification\n */\n customClass?: string\n /**\n * @description whether `message` is treated as HTML string\n */\n dangerouslyUseHTMLString?: boolean\n /**\n * @description duration before close. It will not automatically close if set 0\n */\n duration?: number\n /**\n * @description custom icon component. It will be overridden by `type`\n */\n icon?: string | Component\n /**\n * @description notification dom id\n */\n id?: string\n /**\n * @description description text\n */\n message?: string | VNode | (() => VNode)\n /**\n * @description offset from the top edge of the screen. Every Notification instance of the same moment should have the same offset\n */\n offset?: number\n /**\n * @description callback function when notification clicked\n */\n onClick?: () => void\n /**\n * @description callback function when closed\n */\n onClose: () => void\n /**\n * @description custom position\n */\n position?: NotificationPosition\n /**\n * @description whether to show a close button\n */\n showClose?: boolean\n /**\n * @description title\n */\n title?: string\n /**\n * @description notification type\n */\n type?: NotificationType\n /**\n * @description initial zIndex\n */\n zIndex?: number\n /**\n * @description custom close icon, default is Close\n */\n closeIcon?: string | Component\n}\n\n/**\n * @deprecated Removed after 3.0.0, Use `NotificationProps` instead.\n */\nexport const notificationProps = buildProps({\n /**\n * @description custom class name for Notification\n */\n customClass: {\n type: String,\n default: '',\n },\n /**\n * @description whether `message` is treated as HTML string\n */\n dangerouslyUseHTMLString: Boolean,\n /**\n * @description duration before close. It will not automatically close if set 0\n */\n duration: {\n type: Number,\n default: 4500,\n },\n /**\n * @description custom icon component. It will be overridden by `type`\n */\n icon: {\n type: iconPropType,\n },\n /**\n * @description notification dom id\n */\n id: {\n type: String,\n default: '',\n },\n /**\n * @description description text\n */\n message: {\n type: definePropType<string | VNode | (() => VNode)>([\n String,\n Object,\n Function,\n ]),\n default: '',\n },\n /**\n * @description offset from the top edge of the screen. Every Notification instance of the same moment should have the same offset\n */\n offset: {\n type: Number,\n default: 0,\n },\n /**\n * @description callback function when notification clicked\n */\n onClick: {\n type: definePropType<() => void>(Function),\n default: () => undefined,\n },\n /**\n * @description callback function when closed\n */\n onClose: {\n type: definePropType<() => void>(Function),\n required: true,\n },\n /**\n * @description custom position\n */\n position: {\n type: String,\n values: ['top-right', 'top-left', 'bottom-right', 'bottom-left'],\n default: 'top-right',\n },\n /**\n * @description whether to show a close button\n */\n showClose: {\n type: Boolean,\n default: true,\n },\n /**\n * @description title\n */\n title: {\n type: String,\n default: '',\n },\n /**\n * @description notification type\n */\n type: {\n type: String,\n values: [...notificationTypes, ''],\n default: '',\n },\n /**\n * @description initial zIndex\n */\n zIndex: Number,\n /**\n * @description custom close icon, default is Close\n */\n closeIcon: {\n type: iconPropType,\n default: Close,\n },\n} as const)\n\n/**\n * @deprecated Removed after 3.0.0, Use `NotificationProps` instead.\n */\nexport type NotificationPropsPublic = ExtractPublicPropTypes<\n typeof notificationProps\n>\n\nexport const notificationEmits = {\n destroy: () => true,\n}\nexport type NotificationEmits = typeof notificationEmits\n\nexport type NotificationInstance = InstanceType<typeof Notification> & unknown\n\nexport type NotificationOptions = Omit<NotificationProps, 'id' | 'onClose'> & {\n /**\n * @description set the root element for the notification, default to `document.body`\n */\n appendTo?: HTMLElement | string\n /**\n * @description callback function when closed\n */\n onClose?(vm: VNode): void\n}\nexport type NotificationOptionsTyped = Omit<NotificationOptions, 'type'>\n\nexport interface NotificationHandle {\n close: () => void\n}\n\nexport type NotificationParams = Partial<NotificationOptions> | string | VNode\nexport type NotificationParamsTyped =\n | Partial<NotificationOptionsTyped>\n | string\n | VNode\n\nexport interface NotifyFn {\n (\n options?: NotificationParams,\n appContext?: null | AppContext\n ): NotificationHandle\n closeAll(): void\n updateOffsets(position?: NotificationOptions['position']): void\n _context: AppContext | null\n}\n\nexport type NotifyTypedFn = (\n options?: NotificationParamsTyped,\n appContext?: null | AppContext\n) => NotificationHandle\n\nexport interface Notify extends NotifyFn {\n primary: NotifyTypedFn\n success: NotifyTypedFn\n warning: NotifyTypedFn\n error: NotifyTypedFn\n info: NotifyTypedFn\n}\n\nexport interface NotificationQueueItem {\n vm: VNode\n}\n\nexport type NotificationQueue = NotificationQueueItem[]\n"],"names":[],"mappings":";;;;AAMO,MAAM,iBAAA,GAAoB;AAAA,EAC/B,SAAA;AAAA,EACA,SAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF;AA4EO,MAAM,oBAAoB,UAAA,CAAW;AAAA;AAAA;AAAA;AAAA,EAI1C,WAAA,EAAa;AAAA,IACX,IAAA,EAAM,MAAA;AAAA,IACN,OAAA,EAAS;AAAA,GACX;AAAA;AAAA;AAAA;AAAA,EAIA,wBAAA,EAA0B,OAAA;AAAA;AAAA;AAAA;AAAA,EAI1B,QAAA,EAAU;AAAA,IACR,IAAA,EAAM,MAAA;AAAA,IACN,OAAA,EAAS;AAAA,GACX;AAAA;AAAA;AAAA;AAAA,EAIA,IAAA,EAAM;AAAA,IACJ,IAAA,EAAM;AAAA,GACR;AAAA;AAAA;AAAA;AAAA,EAIA,EAAA,EAAI;AAAA,IACF,IAAA,EAAM,MAAA;AAAA,IACN,OAAA,EAAS;AAAA,GACX;AAAA;AAAA;AAAA;AAAA,EAIA,OAAA,EAAS;AAAA,IACP,MAAM,cAAA,CAA+C;AAAA,MACnD,MAAA;AAAA,MACA,MAAA;AAAA,MACA;AAAA,KACD,CAAA;AAAA,IACD,OAAA,EAAS;AAAA,GACX;AAAA;AAAA;AAAA;AAAA,EAIA,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM,MAAA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