@vuesax-alpha/nightly
Version:
A Component Library for Vue 3
1 lines • 6.42 kB
Source Map (JSON)
{"version":3,"file":"notification.mjs","sources":["../../../../../../packages/components/notification/src/notification.ts"],"sourcesContent":["import {\n buildProps,\n definePropType,\n iconPropType,\n isNumber,\n isStringNumber,\n} from '@vuesax-alpha/utils'\n\nimport { useColorProp } from '@vuesax-alpha/hooks'\nimport type { ExtractPropTypes, VNode } from 'vue'\nimport type Notification from './notification.vue'\n\nexport const notificationPosition = [\n 'top-right',\n 'top-center',\n 'top-left',\n 'bottom-right',\n 'bottom-center',\n 'bottom-left',\n] as const\n\nexport type NotificationPosition = (typeof notificationPosition)[number]\n\nexport const notificationProps = buildProps({\n border: useColorProp,\n color: useColorProp,\n /**\n * @description custom class name for Notification\n */\n customClass: {\n type: String,\n default: '',\n },\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 flat: { type: Boolean },\n /**\n * @description custom icon component.\n */\n icon: {\n type: iconPropType,\n },\n iconSize: {\n type: String,\n default: '1.2rem',\n },\n /**\n * @description notification dom id\n */\n id: {\n type: String,\n default: '',\n },\n dangerousHtmlString: {\n type: Boolean,\n default: false,\n },\n /**\n * @description description text\n */\n content: {\n type: definePropType<string | VNode>([String, Object]),\n default: '',\n },\n loading: Boolean,\n notPadding: Boolean,\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 called before the notification close, return false to cancel the notification, otherwise close the notification\n */\n onClickClose: {\n type: definePropType<() => boolean>(Function),\n default: () => true,\n },\n /**\n * @description callback function when closed\n */\n onClose: {\n type: definePropType<() => void>(Function),\n default: () => undefined,\n },\n /**\n * @description custom position\n */\n position: {\n type: definePropType<NotificationPosition>(String),\n values: notificationPosition,\n default: 'bottom-right',\n },\n progressAuto: { type: Boolean },\n shape: {\n type: String,\n values: ['square', ''] as const,\n default: '',\n },\n /**\n * @description whether to show a close button\n */\n showClose: {\n type: Boolean,\n default: true,\n },\n sticky: { type: Boolean },\n /**\n * @description title\n */\n title: {\n type: String,\n default: '',\n },\n /**\n * @description initial zIndex\n */\n zIndex: { type: Number },\n width: {\n type: definePropType<string | number>([String, Number]),\n validator: (prop) =>\n ['auto', 'full'].includes(prop) || isNumber(prop) || isStringNumber(prop),\n default: null,\n },\n} as const)\n\nexport type NotificationProps = ExtractPropTypes<typeof notificationProps>\n\nexport const notificationEmits = {\n destroy: () => true,\n}\n\nexport type NotificationEmits = typeof notificationEmits\n\nexport type NotificationInstance = InstanceType<typeof Notification>\n\nexport type NotificationOptions = Omit<NotificationProps, 'id'>\nexport type NotificationOptionsTyped = Omit<NotificationOptions, 'color'>\n\nexport interface NotificationHandle {\n close: () => void\n}\n\nexport type NotificationParamsTyped =\n | Partial<NotificationOptionsTyped>\n | string\n | VNode\n\nexport type NotificationParams = Partial<NotificationOptions> | string\n\nexport type NotifyFn = (options?: NotificationParams) => NotificationHandle\nexport type NotifyTypedFn = (\n options?: NotificationParamsTyped\n) => NotificationHandle\n\nexport interface Notify extends NotifyFn {\n primary: NotifyTypedFn\n success: NotifyTypedFn\n warn: NotifyTypedFn\n danger: NotifyTypedFn\n dark: NotifyTypedFn\n}\n"],"names":[],"mappings":";;;;;;;AAYO,MAAM,oBAAuB,GAAA;AAAA,EAClC,WAAA;AAAA,EACA,YAAA;AAAA,EACA,UAAA;AAAA,EACA,cAAA;AAAA,EACA,eAAA;AAAA,EACA,aAAA;AACF,EAAA;AAIO,MAAM,oBAAoB,UAAW,CAAA;AAAA,EAC1C,MAAQ,EAAA,YAAA;AAAA,EACR,KAAO,EAAA,YAAA;AAAA,EAIP,WAAa,EAAA;AAAA,IACX,IAAM,EAAA,MAAA;AAAA,IACN,OAAS,EAAA,EAAA;AAAA,GACX;AAAA,EAIA,QAAU,EAAA;AAAA,IACR,IAAM,EAA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