This commit is contained in:
2025-09-19 14:25:20 +08:00
parent 269893a435
commit fbf3f77229
24949 changed files with 2839404 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
export declare const ElNotification: import("element-plus/es/utils").SFCInstallWithContext<import("./src/notification").Notify>;
export default ElNotification;
export * from './src/notification';

View File

@@ -0,0 +1,8 @@
import notify from './src/notify.mjs';
export { notificationEmits, notificationProps, notificationTypes } from './src/notification.mjs';
import { withInstallFunction } from '../../utils/vue/install.mjs';
const ElNotification = withInstallFunction(notify, "$notify");
export { ElNotification, ElNotification as default };
//# sourceMappingURL=index.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":["../../../../../packages/components/notification/index.ts"],"sourcesContent":["import { withInstallFunction } from '@element-plus/utils'\nimport Notify from './src/notify'\n\nexport const ElNotification = withInstallFunction(Notify, '$notify')\nexport default ElNotification\n\nexport * from './src/notification'\n"],"names":["Notify"],"mappings":";;;;AAEY,MAAC,cAAc,GAAG,mBAAmB,CAACA,MAAM,EAAE,SAAS;;;;"}

View File

@@ -0,0 +1,92 @@
import type { AppContext, ExtractPropTypes, VNode, __ExtractPublicPropTypes } from 'vue';
import type Notification from './notification.vue';
export declare const notificationTypes: readonly ["primary", "success", "info", "warning", "error"];
export declare const notificationProps: {
readonly customClass: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly dangerouslyUseHTMLString: BooleanConstructor;
readonly duration: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, 4500, boolean>;
readonly icon: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => (string | import("vue").Component) & {}) | (() => string | import("vue").Component) | ((new (...args: any[]) => (string | import("vue").Component) & {}) | (() => string | import("vue").Component))[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly id: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly message: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => string | VNode<import("vue").RendererNode, import("vue").RendererElement, {
[key: string]: any;
}> | (() => VNode)) | (() => string | VNode<import("vue").RendererNode, import("vue").RendererElement, {
[key: string]: any;
}> | (() => VNode)) | ((new (...args: any[]) => string | VNode<import("vue").RendererNode, import("vue").RendererElement, {
[key: string]: any;
}> | (() => VNode)) | (() => string | VNode<import("vue").RendererNode, import("vue").RendererElement, {
[key: string]: any;
}> | (() => VNode)))[], unknown, unknown, "", boolean>;
readonly offset: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, 0, boolean>;
readonly onClick: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => () => void) | (() => () => void) | {
(): () => void;
new (): any;
readonly prototype: any;
} | ((new (...args: any[]) => () => void) | (() => () => void) | {
(): () => void;
new (): any;
readonly prototype: any;
})[], unknown, unknown, () => undefined, boolean>;
readonly onClose: {
readonly type: import("vue").PropType<() => void>;
readonly required: true;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly position: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "top-left" | "top-right" | "bottom-left" | "bottom-right", unknown, "top-right", boolean>;
readonly showClose: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, true, boolean>;
readonly title: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly type: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "" | "error" | "primary" | "success" | "warning" | "info", unknown, "", boolean>;
readonly zIndex: NumberConstructor;
readonly closeIcon: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => (string | import("vue").Component) & {}) | (() => string | import("vue").Component) | ((new (...args: any[]) => (string | import("vue").Component) & {}) | (() => string | import("vue").Component))[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
};
export type NotificationProps = ExtractPropTypes<typeof notificationProps>;
export type NotificationPropsPublic = __ExtractPublicPropTypes<typeof notificationProps>;
export declare const notificationEmits: {
destroy: () => boolean;
};
export type NotificationEmits = typeof notificationEmits;
export type NotificationInstance = InstanceType<typeof Notification> & unknown;
export type NotificationOptions = Omit<NotificationProps, 'id' | 'onClose'> & {
/**
* @description set the root element for the notification, default to `document.body`
*/
appendTo?: HTMLElement | string;
/**
* @description callback function when closed
*/
onClose?(vm: VNode): void;
};
export type NotificationOptionsTyped = Omit<NotificationOptions, 'type'>;
export interface NotificationHandle {
close: () => void;
}
export type NotificationParams = Partial<NotificationOptions> | string | VNode;
export type NotificationParamsTyped = Partial<NotificationOptionsTyped> | string | VNode;
export interface NotifyFn {
(options?: NotificationParams, appContext?: null | AppContext): NotificationHandle;
closeAll(): void;
updateOffsets(position?: NotificationOptions['position']): void;
_context: AppContext | null;
}
export type NotifyTypedFn = (options?: NotificationParamsTyped, appContext?: null | AppContext) => NotificationHandle;
export interface Notify extends NotifyFn {
primary: NotifyTypedFn;
success: NotifyTypedFn;
warning: NotifyTypedFn;
error: NotifyTypedFn;
info: NotifyTypedFn;
}
export interface NotificationQueueItem {
vm: VNode;
}
export type NotificationQueue = NotificationQueueItem[];

View File

@@ -0,0 +1,78 @@
import { Close } from '@element-plus/icons-vue';
import { buildProps, definePropType } from '../../../utils/vue/props/runtime.mjs';
import { iconPropType } from '../../../utils/vue/icon.mjs';
const notificationTypes = [
"primary",
"success",
"info",
"warning",
"error"
];
const notificationProps = buildProps({
customClass: {
type: String,
default: ""
},
dangerouslyUseHTMLString: Boolean,
duration: {
type: Number,
default: 4500
},
icon: {
type: iconPropType
},
id: {
type: String,
default: ""
},
message: {
type: definePropType([
String,
Object,
Function
]),
default: ""
},
offset: {
type: Number,
default: 0
},
onClick: {
type: definePropType(Function),
default: () => void 0
},
onClose: {
type: definePropType(Function),
required: true
},
position: {
type: String,
values: ["top-right", "top-left", "bottom-right", "bottom-left"],
default: "top-right"
},
showClose: {
type: Boolean,
default: true
},
title: {
type: String,
default: ""
},
type: {
type: String,
values: [...notificationTypes, ""],
default: ""
},
zIndex: Number,
closeIcon: {
type: iconPropType,
default: Close
}
});
const notificationEmits = {
destroy: () => true
};
export { notificationEmits, notificationProps, notificationTypes };
//# sourceMappingURL=notification.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,134 @@
declare function close(): void;
declare function __VLS_template(): {
default?(_: {}): any;
};
declare const __VLS_component: import("vue").DefineComponent<{
readonly customClass: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly dangerouslyUseHTMLString: BooleanConstructor;
readonly duration: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, 4500, boolean>;
readonly icon: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => (string | import("vue").Component) & {}) | (() => string | import("vue").Component) | ((new (...args: any[]) => (string | import("vue").Component) & {}) | (() => string | import("vue").Component))[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly id: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly message: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => string | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
[key: string]: any;
}> | (() => import("vue").VNode)) | (() => string | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
[key: string]: any;
}> | (() => import("vue").VNode)) | ((new (...args: any[]) => string | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
[key: string]: any;
}> | (() => import("vue").VNode)) | (() => string | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
[key: string]: any;
}> | (() => import("vue").VNode)))[], unknown, unknown, "", boolean>;
readonly offset: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, 0, boolean>;
readonly onClick: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => () => void) | (() => () => void) | {
(): () => void;
new (): any;
readonly prototype: any;
} | ((new (...args: any[]) => () => void) | (() => () => void) | {
(): () => void;
new (): any;
readonly prototype: any;
})[], unknown, unknown, () => undefined, boolean>;
readonly onClose: {
readonly type: import("vue").PropType<() => void>;
readonly required: true;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly position: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "top-left" | "top-right" | "bottom-left" | "bottom-right", unknown, "top-right", boolean>;
readonly showClose: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, true, boolean>;
readonly title: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly type: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "" | "error" | "primary" | "success" | "warning" | "info", unknown, "", boolean>;
readonly zIndex: NumberConstructor;
readonly closeIcon: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => (string | import("vue").Component) & {}) | (() => string | import("vue").Component) | ((new (...args: any[]) => (string | import("vue").Component) & {}) | (() => string | import("vue").Component))[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
}, {
visible: import("vue").Ref<boolean>;
/** @description close notification */
close: typeof close;
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
destroy: () => void;
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
readonly customClass: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly dangerouslyUseHTMLString: BooleanConstructor;
readonly duration: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, 4500, boolean>;
readonly icon: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => (string | import("vue").Component) & {}) | (() => string | import("vue").Component) | ((new (...args: any[]) => (string | import("vue").Component) & {}) | (() => string | import("vue").Component))[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly id: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly message: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => string | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
[key: string]: any;
}> | (() => import("vue").VNode)) | (() => string | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
[key: string]: any;
}> | (() => import("vue").VNode)) | ((new (...args: any[]) => string | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
[key: string]: any;
}> | (() => import("vue").VNode)) | (() => string | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
[key: string]: any;
}> | (() => import("vue").VNode)))[], unknown, unknown, "", boolean>;
readonly offset: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, 0, boolean>;
readonly onClick: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => () => void) | (() => () => void) | {
(): () => void;
new (): any;
readonly prototype: any;
} | ((new (...args: any[]) => () => void) | (() => () => void) | {
(): () => void;
new (): any;
readonly prototype: any;
})[], unknown, unknown, () => undefined, boolean>;
readonly onClose: {
readonly type: import("vue").PropType<() => void>;
readonly required: true;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly position: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "top-left" | "top-right" | "bottom-left" | "bottom-right", unknown, "top-right", boolean>;
readonly showClose: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, true, boolean>;
readonly title: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly type: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "" | "error" | "primary" | "success" | "warning" | "info", unknown, "", boolean>;
readonly zIndex: NumberConstructor;
readonly closeIcon: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => (string | import("vue").Component) & {}) | (() => string | import("vue").Component) | ((new (...args: any[]) => (string | import("vue").Component) & {}) | (() => string | import("vue").Component))[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
}>> & {
onDestroy?: (() => any) | undefined;
}, {
readonly title: string;
readonly position: import("element-plus/es/utils").EpPropMergeType<StringConstructor, "top-left" | "top-right" | "bottom-left" | "bottom-right", unknown>;
readonly offset: number;
readonly id: string;
readonly type: import("element-plus/es/utils").EpPropMergeType<StringConstructor, "" | "error" | "primary" | "success" | "warning" | "info", unknown>;
readonly message: import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => string | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
[key: string]: any;
}> | (() => import("vue").VNode)) | (() => string | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
[key: string]: any;
}> | (() => import("vue").VNode)) | ((new (...args: any[]) => string | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
[key: string]: any;
}> | (() => import("vue").VNode)) | (() => string | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
[key: string]: any;
}> | (() => import("vue").VNode)))[], unknown, unknown>;
readonly onClick: () => void;
readonly duration: number;
readonly showClose: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown>;
readonly customClass: string;
readonly dangerouslyUseHTMLString: boolean;
}>;
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
export default _default;
type __VLS_WithTemplateSlots<T, S> = T & {
new (): {
$slots: S;
};
};

View File

@@ -0,0 +1,145 @@
import { defineComponent, ref, computed, onMounted, openBlock, createBlock, Transition, unref, withCtx, withDirectives, createElementVNode, normalizeClass, normalizeStyle, resolveDynamicComponent, createCommentVNode, toDisplayString, renderSlot, createElementBlock, Fragment, vShow, withModifiers } from 'vue';
import { useEventListener, useTimeoutFn } from '@vueuse/core';
import { ElIcon } from '../../icon/index.mjs';
import { notificationProps, notificationEmits } from './notification.mjs';
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
import { useGlobalComponentSettings } from '../../config-provider/src/hooks/use-global-config.mjs';
import { TypeComponentsMap } from '../../../utils/vue/icon.mjs';
import { EVENT_CODE } from '../../../constants/aria.mjs';
const __default__ = defineComponent({
name: "ElNotification"
});
const _sfc_main = /* @__PURE__ */ defineComponent({
...__default__,
props: notificationProps,
emits: notificationEmits,
setup(__props, { expose }) {
const props = __props;
const { ns, zIndex } = useGlobalComponentSettings("notification");
const { nextZIndex, currentZIndex } = zIndex;
const visible = ref(false);
let timer = void 0;
const typeClass = computed(() => {
const type = props.type;
return type && TypeComponentsMap[props.type] ? ns.m(type) : "";
});
const iconComponent = computed(() => {
if (!props.type)
return props.icon;
return TypeComponentsMap[props.type] || props.icon;
});
const horizontalClass = computed(() => props.position.endsWith("right") ? "right" : "left");
const verticalProperty = computed(() => props.position.startsWith("top") ? "top" : "bottom");
const positionStyle = computed(() => {
var _a;
return {
[verticalProperty.value]: `${props.offset}px`,
zIndex: (_a = props.zIndex) != null ? _a : currentZIndex.value
};
});
function startTimer() {
if (props.duration > 0) {
({ stop: timer } = useTimeoutFn(() => {
if (visible.value)
close();
}, props.duration));
}
}
function clearTimer() {
timer == null ? void 0 : timer();
}
function close() {
visible.value = false;
}
function onKeydown({ code }) {
if (code === EVENT_CODE.delete || code === EVENT_CODE.backspace) {
clearTimer();
} else if (code === EVENT_CODE.esc) {
if (visible.value) {
close();
}
} else {
startTimer();
}
}
onMounted(() => {
startTimer();
nextZIndex();
visible.value = true;
});
useEventListener(document, "keydown", onKeydown);
expose({
visible,
close
});
return (_ctx, _cache) => {
return openBlock(), createBlock(Transition, {
name: unref(ns).b("fade"),
onBeforeLeave: _ctx.onClose,
onAfterLeave: ($event) => _ctx.$emit("destroy"),
persisted: ""
}, {
default: withCtx(() => [
withDirectives(createElementVNode("div", {
id: _ctx.id,
class: normalizeClass([unref(ns).b(), _ctx.customClass, unref(horizontalClass)]),
style: normalizeStyle(unref(positionStyle)),
role: "alert",
onMouseenter: clearTimer,
onMouseleave: startTimer,
onClick: _ctx.onClick
}, [
unref(iconComponent) ? (openBlock(), createBlock(unref(ElIcon), {
key: 0,
class: normalizeClass([unref(ns).e("icon"), unref(typeClass)])
}, {
default: withCtx(() => [
(openBlock(), createBlock(resolveDynamicComponent(unref(iconComponent))))
]),
_: 1
}, 8, ["class"])) : createCommentVNode("v-if", true),
createElementVNode("div", {
class: normalizeClass(unref(ns).e("group"))
}, [
createElementVNode("h2", {
class: normalizeClass(unref(ns).e("title")),
textContent: toDisplayString(_ctx.title)
}, null, 10, ["textContent"]),
withDirectives(createElementVNode("div", {
class: normalizeClass(unref(ns).e("content")),
style: normalizeStyle(!!_ctx.title ? void 0 : { margin: 0 })
}, [
renderSlot(_ctx.$slots, "default", {}, () => [
!_ctx.dangerouslyUseHTMLString ? (openBlock(), createElementBlock("p", { key: 0 }, toDisplayString(_ctx.message), 1)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
createCommentVNode(" Caution here, message could've been compromised, never use user's input as message "),
createElementVNode("p", { innerHTML: _ctx.message }, null, 8, ["innerHTML"])
], 2112))
])
], 6), [
[vShow, _ctx.message]
]),
_ctx.showClose ? (openBlock(), createBlock(unref(ElIcon), {
key: 0,
class: normalizeClass(unref(ns).e("closeBtn")),
onClick: withModifiers(close, ["stop"])
}, {
default: withCtx(() => [
(openBlock(), createBlock(resolveDynamicComponent(_ctx.closeIcon)))
]),
_: 1
}, 8, ["class", "onClick"])) : createCommentVNode("v-if", true)
], 2)
], 46, ["id", "onClick"]), [
[vShow, visible.value]
])
]),
_: 3
}, 8, ["name", "onBeforeLeave", "onAfterLeave"]);
};
}
});
var NotificationConstructor = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "notification.vue"]]);
export { NotificationConstructor as default };
//# sourceMappingURL=notification2.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,15 @@
import type { VNode } from 'vue';
import type { NotificationOptions, Notify } from './notification';
/**
* This function gets called when user click `x` button or press `esc` or the time reached its limitation.
* Emitted by transition@before-leave event so that we can fetch the current notification.offsetHeight, if this was called
* by @after-leave the DOM element will be removed from the page thus we can no longer fetch the offsetHeight.
* @param {String} id notification id to be closed
* @param {Position} position the positioning strategy
* @param {Function} userOnClose the callback called when close passed by user
*/
export declare function close(id: string, position: NotificationOptions['position'], userOnClose?: (vm: VNode) => void): void;
export declare function closeAll(): void;
export declare function updateOffsets(position?: NotificationOptions['position']): void;
declare const _default: Notify;
export default _default;

View File

@@ -0,0 +1,117 @@
import { isVNode, createVNode, render } from 'vue';
import NotificationConstructor from './notification2.mjs';
import { notificationTypes } from './notification.mjs';
import { isClient } from '@vueuse/core';
import { isString, isFunction } from '@vue/shared';
import { isElement, isUndefined } from '../../../utils/types.mjs';
const notifications = {
"top-left": [],
"top-right": [],
"bottom-left": [],
"bottom-right": []
};
const GAP_SIZE = 16;
let seed = 1;
const notify = function(options = {}, context) {
if (!isClient)
return { close: () => void 0 };
if (isString(options) || isVNode(options)) {
options = { message: options };
}
const position = options.position || "top-right";
let verticalOffset = options.offset || 0;
notifications[position].forEach(({ vm: vm2 }) => {
var _a;
verticalOffset += (((_a = vm2.el) == null ? void 0 : _a.offsetHeight) || 0) + GAP_SIZE;
});
verticalOffset += GAP_SIZE;
const id = `notification_${seed++}`;
const userOnClose = options.onClose;
const props = {
...options,
offset: verticalOffset,
id,
onClose: () => {
close(id, position, userOnClose);
}
};
let appendTo = document.body;
if (isElement(options.appendTo)) {
appendTo = options.appendTo;
} else if (isString(options.appendTo)) {
appendTo = document.querySelector(options.appendTo);
}
if (!isElement(appendTo)) {
appendTo = document.body;
}
const container = document.createElement("div");
const vm = createVNode(NotificationConstructor, props, isFunction(props.message) ? props.message : isVNode(props.message) ? () => props.message : null);
vm.appContext = isUndefined(context) ? notify._context : context;
vm.props.onDestroy = () => {
render(null, container);
};
render(vm, container);
notifications[position].push({ vm });
appendTo.appendChild(container.firstElementChild);
return {
close: () => {
vm.component.exposed.visible.value = false;
}
};
};
notificationTypes.forEach((type) => {
notify[type] = (options = {}, appContext) => {
if (isString(options) || isVNode(options)) {
options = {
message: options
};
}
return notify({ ...options, type }, appContext);
};
});
function close(id, position, userOnClose) {
const orientedNotifications = notifications[position];
const idx = orientedNotifications.findIndex(({ vm: vm2 }) => {
var _a;
return ((_a = vm2.component) == null ? void 0 : _a.props.id) === id;
});
if (idx === -1)
return;
const { vm } = orientedNotifications[idx];
if (!vm)
return;
userOnClose == null ? void 0 : userOnClose(vm);
const removedHeight = vm.el.offsetHeight;
const verticalPos = position.split("-")[0];
orientedNotifications.splice(idx, 1);
const len = orientedNotifications.length;
if (len < 1)
return;
for (let i = idx; i < len; i++) {
const { el, component } = orientedNotifications[i].vm;
const pos = Number.parseInt(el.style[verticalPos], 10) - removedHeight - GAP_SIZE;
component.props.offset = pos;
}
}
function closeAll() {
for (const orientedNotifications of Object.values(notifications)) {
orientedNotifications.forEach(({ vm }) => {
vm.component.exposed.visible.value = false;
});
}
}
function updateOffsets(position = "top-right") {
var _a, _b, _c, _d;
let verticalOffset = ((_c = (_b = (_a = notifications[position][0]) == null ? void 0 : _a.vm.component) == null ? void 0 : _b.props) == null ? void 0 : _c.offset) || 0;
for (const { vm } of notifications[position]) {
vm.component.props.offset = verticalOffset;
verticalOffset += (((_d = vm.el) == null ? void 0 : _d.offsetHeight) || 0) + GAP_SIZE;
}
}
notify.closeAll = closeAll;
notify.updateOffsets = updateOffsets;
notify._context = null;
export { close, closeAll, notify as default, updateOffsets };
//# sourceMappingURL=notify.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
import 'element-plus/es/components/base/style/css';
import 'element-plus/theme-chalk/el-notification.css';

View File

@@ -0,0 +1,3 @@
import '../../base/style/css.mjs';
import 'element-plus/theme-chalk/el-notification.css';
//# sourceMappingURL=css.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"css.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}

View File

@@ -0,0 +1,2 @@
import 'element-plus/es/components/base/style';
import 'element-plus/theme-chalk/src/notification.scss';

View File

@@ -0,0 +1,3 @@
import '../../base/style/index.mjs';
import 'element-plus/theme-chalk/src/notification.scss';
//# sourceMappingURL=index.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}