使用VUE重构项目
Some checks failed
build / build (api, amd64, linux) (push) Failing after -51s
build / build (api, arm64, linux) (push) Failing after -52s
build / build (api.exe, amd64, windows) (push) Failing after -51s

This commit is contained in:
2026-04-20 00:19:11 +08:00
parent c080bb8d4a
commit db7f1ba82f
12743 changed files with 1250466 additions and 359982 deletions

View File

@@ -0,0 +1,10 @@
import { SFCWithInstall } from "../../utils/vue/typescript.js";
import "../../utils/index.js";
import { Action, Callback, ElMessageBoxOptions, ElMessageBoxShortcutMethod, IElMessageBox, MessageBoxData, MessageBoxInputData, MessageBoxInputValidator, MessageBoxState, MessageBoxType } from "./src/message-box.type.js";
import { _default } from "./src/messageBox.js";
//#region ../../packages/components/message-box/index.d.ts
declare const _MessageBox: SFCWithInstall<typeof _default>;
declare const ElMessageBox: SFCWithInstall<IElMessageBox>;
//#endregion
export { Action, Callback, ElMessageBox, ElMessageBoxOptions, ElMessageBoxShortcutMethod, IElMessageBox, MessageBoxData, MessageBoxInputData, MessageBoxInputValidator, MessageBoxState, MessageBoxType, _MessageBox as default };

View File

@@ -0,0 +1,19 @@
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
const require_messageBox = require('./src/messageBox.js');
//#region ../../packages/components/message-box/index.ts
const _MessageBox = require_messageBox.default;
_MessageBox.install = (app) => {
_MessageBox._context = app._context;
app.config.globalProperties.$msgbox = _MessageBox;
app.config.globalProperties.$messageBox = _MessageBox;
app.config.globalProperties.$alert = _MessageBox.alert;
app.config.globalProperties.$confirm = _MessageBox.confirm;
app.config.globalProperties.$prompt = _MessageBox.prompt;
};
const ElMessageBox = _MessageBox;
//#endregion
exports.ElMessageBox = ElMessageBox;
exports.default = _MessageBox;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","names":["MessageBox"],"sources":["../../../../../packages/components/message-box/index.ts"],"sourcesContent":["import MessageBox from './src/messageBox'\n\nimport type { App } from 'vue'\nimport type { SFCWithInstall } from '@element-plus/utils'\n\nconst _MessageBox = MessageBox as SFCWithInstall<typeof MessageBox>\n\n_MessageBox.install = (app: App) => {\n _MessageBox._context = app._context\n app.config.globalProperties.$msgbox = _MessageBox\n app.config.globalProperties.$messageBox = _MessageBox\n app.config.globalProperties.$alert = _MessageBox.alert\n app.config.globalProperties.$confirm = _MessageBox.confirm\n app.config.globalProperties.$prompt = _MessageBox.prompt\n}\n\nexport default _MessageBox\nexport const ElMessageBox = _MessageBox\n\nexport * from './src/message-box.type'\n"],"mappings":";;;;AAKA,MAAM,cAAcA;AAEpB,YAAY,WAAW,QAAa;AAClC,aAAY,WAAW,IAAI;AAC3B,KAAI,OAAO,iBAAiB,UAAU;AACtC,KAAI,OAAO,iBAAiB,cAAc;AAC1C,KAAI,OAAO,iBAAiB,SAAS,YAAY;AACjD,KAAI,OAAO,iBAAiB,WAAW,YAAY;AACnD,KAAI,OAAO,iBAAiB,UAAU,YAAY;;AAIpD,MAAa,eAAe"}

View File

@@ -0,0 +1,187 @@
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
const require_runtime = require('../../../_virtual/_rolldown/runtime.js');
const require__plugin_vue_export_helper = require('../../../_virtual/_plugin-vue_export-helper.js');
const require_index_vue_vue_type_script_lang = require('./index.vue_vue_type_script_lang.js');
let vue = require("vue");
//#region ../../packages/components/message-box/src/index.vue
const _hoisted_1 = ["aria-label", "aria-describedby"];
const _hoisted_2 = ["aria-label"];
const _hoisted_3 = ["id"];
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
const _component_el_icon = (0, vue.resolveComponent)("el-icon");
const _component_el_input = (0, vue.resolveComponent)("el-input");
const _component_el_button = (0, vue.resolveComponent)("el-button");
const _component_el_focus_trap = (0, vue.resolveComponent)("el-focus-trap");
const _component_el_overlay = (0, vue.resolveComponent)("el-overlay");
return (0, vue.openBlock)(), (0, vue.createBlock)(vue.Transition, {
name: "fade-in-linear",
onAfterLeave: _cache[11] || (_cache[11] = ($event) => _ctx.$emit("vanish")),
persisted: ""
}, {
default: (0, vue.withCtx)(() => [(0, vue.withDirectives)((0, vue.createVNode)(_component_el_overlay, {
"z-index": _ctx.zIndex,
"overlay-class": [_ctx.ns.is("message-box"), _ctx.modalClass],
mask: _ctx.modal
}, {
default: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", {
role: "dialog",
"aria-label": _ctx.title,
"aria-modal": "true",
"aria-describedby": !_ctx.showInput ? _ctx.contentId : void 0,
class: (0, vue.normalizeClass)(`${_ctx.ns.namespace.value}-overlay-message-box`),
onClick: _cache[8] || (_cache[8] = (...args) => _ctx.overlayEvent.onClick && _ctx.overlayEvent.onClick(...args)),
onMousedown: _cache[9] || (_cache[9] = (...args) => _ctx.overlayEvent.onMousedown && _ctx.overlayEvent.onMousedown(...args)),
onMouseup: _cache[10] || (_cache[10] = (...args) => _ctx.overlayEvent.onMouseup && _ctx.overlayEvent.onMouseup(...args))
}, [(0, vue.createVNode)(_component_el_focus_trap, {
loop: "",
trapped: _ctx.visible,
"focus-trap-el": _ctx.rootRef,
"focus-start-el": _ctx.focusStartRef,
onReleaseRequested: _ctx.onCloseRequested
}, {
default: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", {
ref: "rootRef",
class: (0, vue.normalizeClass)([
_ctx.ns.b(),
_ctx.customClass,
_ctx.ns.is("draggable", _ctx.draggable),
_ctx.ns.is("dragging", _ctx.isDragging),
{ [_ctx.ns.m("center")]: _ctx.center }
]),
style: (0, vue.normalizeStyle)(_ctx.customStyle),
tabindex: "-1",
onClick: _cache[7] || (_cache[7] = (0, vue.withModifiers)(() => {}, ["stop"]))
}, [
_ctx.title !== null && _ctx.title !== void 0 ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
key: 0,
ref: "headerRef",
class: (0, vue.normalizeClass)([_ctx.ns.e("header"), { "show-close": _ctx.showClose }])
}, [(0, vue.createElementVNode)("div", { class: (0, vue.normalizeClass)(_ctx.ns.e("title")) }, [_ctx.iconComponent && _ctx.center ? ((0, vue.openBlock)(), (0, vue.createBlock)(_component_el_icon, {
key: 0,
class: (0, vue.normalizeClass)([_ctx.ns.e("status"), _ctx.typeClass])
}, {
default: (0, vue.withCtx)(() => [((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(_ctx.iconComponent)))]),
_: 1
}, 8, ["class"])) : (0, vue.createCommentVNode)("v-if", true), (0, vue.createElementVNode)("span", null, (0, vue.toDisplayString)(_ctx.title), 1)], 2), _ctx.showClose ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("button", {
key: 0,
type: "button",
class: (0, vue.normalizeClass)(_ctx.ns.e("headerbtn")),
"aria-label": _ctx.t("el.messagebox.close"),
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.handleAction(_ctx.distinguishCancelAndClose ? "close" : "cancel")),
onKeydown: _cache[1] || (_cache[1] = (0, vue.withKeys)((0, vue.withModifiers)(($event) => _ctx.handleAction(_ctx.distinguishCancelAndClose ? "close" : "cancel"), ["prevent"]), ["enter"]))
}, [(0, vue.createVNode)(_component_el_icon, { class: (0, vue.normalizeClass)(_ctx.ns.e("close")) }, {
default: (0, vue.withCtx)(() => [((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(_ctx.closeIcon || "close")))]),
_: 1
}, 8, ["class"])], 42, _hoisted_2)) : (0, vue.createCommentVNode)("v-if", true)], 2)) : (0, vue.createCommentVNode)("v-if", true),
(0, vue.createElementVNode)("div", {
id: _ctx.contentId,
class: (0, vue.normalizeClass)(_ctx.ns.e("content"))
}, [(0, vue.createElementVNode)("div", { class: (0, vue.normalizeClass)(_ctx.ns.e("container")) }, [_ctx.iconComponent && !_ctx.center && _ctx.hasMessage ? ((0, vue.openBlock)(), (0, vue.createBlock)(_component_el_icon, {
key: 0,
class: (0, vue.normalizeClass)([_ctx.ns.e("status"), _ctx.typeClass])
}, {
default: (0, vue.withCtx)(() => [((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(_ctx.iconComponent)))]),
_: 1
}, 8, ["class"])) : (0, vue.createCommentVNode)("v-if", true), _ctx.hasMessage ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
key: 1,
class: (0, vue.normalizeClass)(_ctx.ns.e("message"))
}, [(0, vue.renderSlot)(_ctx.$slots, "default", {}, () => [!_ctx.dangerouslyUseHTMLString ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(_ctx.showInput ? "label" : "p"), {
key: 0,
for: _ctx.showInput ? _ctx.inputId : void 0,
textContent: (0, vue.toDisplayString)(_ctx.message)
}, null, 8, ["for", "textContent"])) : ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(_ctx.showInput ? "label" : "p"), {
key: 1,
for: _ctx.showInput ? _ctx.inputId : void 0,
innerHTML: _ctx.message
}, null, 8, ["for", "innerHTML"]))])], 2)) : (0, vue.createCommentVNode)("v-if", true)], 2), (0, vue.withDirectives)((0, vue.createElementVNode)("div", { class: (0, vue.normalizeClass)(_ctx.ns.e("input")) }, [(0, vue.createVNode)(_component_el_input, {
id: _ctx.inputId,
ref: "inputRef",
modelValue: _ctx.inputValue,
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => _ctx.inputValue = $event),
type: _ctx.inputType,
placeholder: _ctx.inputPlaceholder,
"aria-invalid": _ctx.validateError,
class: (0, vue.normalizeClass)({ invalid: _ctx.validateError }),
onKeydown: (0, vue.withKeys)(_ctx.handleInputEnter, ["enter"])
}, null, 8, [
"id",
"modelValue",
"type",
"placeholder",
"aria-invalid",
"class",
"onKeydown"
]), (0, vue.createElementVNode)("div", {
class: (0, vue.normalizeClass)(_ctx.ns.e("errormsg")),
style: (0, vue.normalizeStyle)({ visibility: !!_ctx.editorErrorMessage ? "visible" : "hidden" })
}, (0, vue.toDisplayString)(_ctx.editorErrorMessage), 7)], 2), [[vue.vShow, _ctx.showInput]])], 10, _hoisted_3),
(0, vue.createElementVNode)("div", { class: (0, vue.normalizeClass)(_ctx.ns.e("btns")) }, [_ctx.showCancelButton ? ((0, vue.openBlock)(), (0, vue.createBlock)(_component_el_button, {
key: 0,
type: _ctx.cancelButtonType === "text" ? "" : _ctx.cancelButtonType,
text: _ctx.cancelButtonType === "text",
loading: _ctx.cancelButtonLoading,
"loading-icon": _ctx.cancelButtonLoadingIcon,
class: (0, vue.normalizeClass)([_ctx.cancelButtonClass]),
round: _ctx.roundButton,
size: _ctx.btnSize,
onClick: _cache[3] || (_cache[3] = ($event) => _ctx.handleAction("cancel")),
onKeydown: _cache[4] || (_cache[4] = (0, vue.withKeys)((0, vue.withModifiers)(($event) => _ctx.handleAction("cancel"), ["prevent"]), ["enter"]))
}, {
default: (0, vue.withCtx)(() => [(0, vue.createTextVNode)((0, vue.toDisplayString)(_ctx.cancelButtonText || _ctx.t("el.messagebox.cancel")), 1)]),
_: 1
}, 8, [
"type",
"text",
"loading",
"loading-icon",
"class",
"round",
"size"
])) : (0, vue.createCommentVNode)("v-if", true), (0, vue.withDirectives)((0, vue.createVNode)(_component_el_button, {
ref: "confirmRef",
type: _ctx.confirmButtonType === "text" ? "" : _ctx.confirmButtonType,
text: _ctx.confirmButtonType === "text",
loading: _ctx.confirmButtonLoading,
"loading-icon": _ctx.confirmButtonLoadingIcon,
class: (0, vue.normalizeClass)([_ctx.confirmButtonClasses]),
round: _ctx.roundButton,
disabled: _ctx.confirmButtonDisabled,
size: _ctx.btnSize,
onClick: _cache[5] || (_cache[5] = ($event) => _ctx.handleAction("confirm")),
onKeydown: _cache[6] || (_cache[6] = (0, vue.withKeys)((0, vue.withModifiers)(($event) => _ctx.handleAction("confirm"), ["prevent"]), ["enter"]))
}, {
default: (0, vue.withCtx)(() => [(0, vue.createTextVNode)((0, vue.toDisplayString)(_ctx.confirmButtonText || _ctx.t("el.messagebox.confirm")), 1)]),
_: 1
}, 8, [
"type",
"text",
"loading",
"loading-icon",
"class",
"round",
"disabled",
"size"
]), [[vue.vShow, _ctx.showConfirmButton]])], 2)
], 6)]),
_: 3
}, 8, [
"trapped",
"focus-trap-el",
"focus-start-el",
"onReleaseRequested"
])], 42, _hoisted_1)]),
_: 3
}, 8, [
"z-index",
"overlay-class",
"mask"
]), [[vue.vShow, _ctx.visible]])]),
_: 3
});
}
var src_default = /* @__PURE__ */ require__plugin_vue_export_helper.default(require_index_vue_vue_type_script_lang.default, [["render", _sfc_render]]);
//#endregion
exports.default = src_default;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,257 @@
const require_runtime = require('../../../_virtual/_rolldown/runtime.js');
const require_icon = require('../../../utils/vue/icon.js');
const require_validator = require('../../../utils/vue/validator.js');
const require_index = require('../../../directives/trap-focus/index.js');
const require_index$1 = require('../../../hooks/use-draggable/index.js');
const require_index$2 = require('../../../hooks/use-lockscreen/index.js');
const require_index$3 = require('../../../hooks/use-same-target/index.js');
const require_index$4 = require('../../../hooks/use-id/index.js');
const require_index$5 = require('../../icon/index.js');
const require_index$6 = require('../../focus-trap/index.js');
const require_index$7 = require('../../input/index.js');
const require_use_global_config = require('../../config-provider/src/hooks/use-global-config.js');
const require_index$8 = require('../../button/index.js');
const require_index$9 = require('../../overlay/index.js');
let _element_plus_icons_vue = require("@element-plus/icons-vue");
let vue = require("vue");
let _vue_shared = require("@vue/shared");
//#region ../../packages/components/message-box/src/index.vue?vue&type=script&lang.ts
var index_vue_vue_type_script_lang_default = (0, vue.defineComponent)({
name: "ElMessageBox",
directives: { TrapFocus: require_index.default },
components: {
ElButton: require_index$8.ElButton,
ElFocusTrap: require_index$6.default,
ElInput: require_index$7.ElInput,
ElOverlay: require_index$9.ElOverlay,
ElIcon: require_index$5.ElIcon,
...require_icon.TypeComponents
},
inheritAttrs: false,
props: {
buttonSize: {
type: String,
validator: require_validator.isValidComponentSize
},
modal: {
type: Boolean,
default: true
},
lockScroll: {
type: Boolean,
default: true
},
showClose: {
type: Boolean,
default: true
},
closeOnClickModal: {
type: Boolean,
default: true
},
closeOnPressEscape: {
type: Boolean,
default: true
},
closeOnHashChange: {
type: Boolean,
default: true
},
center: Boolean,
draggable: Boolean,
overflow: Boolean,
roundButton: Boolean,
container: {
type: String,
default: "body"
},
boxType: {
type: String,
default: ""
}
},
emits: ["vanish", "action"],
setup(props, { emit }) {
const { locale, zIndex, ns, size: btnSize } = require_use_global_config.useGlobalComponentSettings("message-box", (0, vue.computed)(() => props.buttonSize));
const { t } = locale;
const { nextZIndex } = zIndex;
const visible = (0, vue.ref)(false);
const state = (0, vue.reactive)({
autofocus: true,
beforeClose: null,
callback: null,
cancelButtonText: "",
cancelButtonClass: "",
confirmButtonText: "",
confirmButtonClass: "",
cancelButtonType: "",
confirmButtonType: "primary",
customClass: "",
customStyle: {},
dangerouslyUseHTMLString: false,
distinguishCancelAndClose: false,
icon: "",
closeIcon: "",
inputPattern: null,
inputPlaceholder: "",
inputType: "text",
inputValue: "",
inputValidator: void 0,
inputErrorMessage: "",
message: "",
modalFade: true,
modalClass: "",
showCancelButton: false,
showConfirmButton: true,
type: "",
title: void 0,
showInput: false,
action: "",
confirmButtonLoading: false,
cancelButtonLoading: false,
confirmButtonLoadingIcon: (0, vue.markRaw)(_element_plus_icons_vue.Loading),
cancelButtonLoadingIcon: (0, vue.markRaw)(_element_plus_icons_vue.Loading),
confirmButtonDisabled: false,
editorErrorMessage: "",
validateError: false,
zIndex: nextZIndex()
});
const typeClass = (0, vue.computed)(() => {
const type = state.type;
return { [ns.bm("icon", type)]: type && require_icon.TypeComponentsMap[type] };
});
const contentId = require_index$4.useId();
const inputId = require_index$4.useId();
const iconComponent = (0, vue.computed)(() => {
const type = state.type;
return state.icon || type && require_icon.TypeComponentsMap[type] || "";
});
const hasMessage = (0, vue.computed)(() => !!state.message);
const rootRef = (0, vue.ref)();
const headerRef = (0, vue.ref)();
const focusStartRef = (0, vue.ref)();
const inputRef = (0, vue.ref)();
const confirmRef = (0, vue.ref)();
const confirmButtonClasses = (0, vue.computed)(() => state.confirmButtonClass);
(0, vue.watch)(() => state.inputValue, async (val) => {
await (0, vue.nextTick)();
if (props.boxType === "prompt" && val) validate();
}, { immediate: true });
(0, vue.watch)(() => visible.value, (val) => {
if (val) {
if (props.boxType !== "prompt") if (state.autofocus) focusStartRef.value = confirmRef.value?.$el ?? rootRef.value;
else focusStartRef.value = rootRef.value;
state.zIndex = nextZIndex();
}
if (props.boxType !== "prompt") return;
if (val) (0, vue.nextTick)().then(() => {
if (inputRef.value && inputRef.value.$el) if (state.autofocus) focusStartRef.value = getInputElement() ?? rootRef.value;
else focusStartRef.value = rootRef.value;
});
else {
state.editorErrorMessage = "";
state.validateError = false;
}
});
const { isDragging } = require_index$1.useDraggable(rootRef, headerRef, (0, vue.computed)(() => props.draggable), (0, vue.computed)(() => props.overflow));
(0, vue.onMounted)(async () => {
await (0, vue.nextTick)();
if (props.closeOnHashChange) window.addEventListener("hashchange", doClose);
});
(0, vue.onBeforeUnmount)(() => {
if (props.closeOnHashChange) window.removeEventListener("hashchange", doClose);
});
function doClose() {
if (!visible.value) return;
visible.value = false;
(0, vue.nextTick)(() => {
if (state.action) emit("action", state.action);
});
}
const handleWrapperClick = () => {
if (props.closeOnClickModal) handleAction(state.distinguishCancelAndClose ? "close" : "cancel");
};
const overlayEvent = require_index$3.useSameTarget(handleWrapperClick);
const handleInputEnter = (e) => {
if (state.inputType !== "textarea" && !inputRef.value?.isComposing) {
e.preventDefault();
return handleAction("confirm");
}
};
const handleAction = (action) => {
if (props.boxType === "prompt" && action === "confirm" && !validate()) return;
state.action = action;
if (state.beforeClose) state.beforeClose?.(action, state, doClose);
else doClose();
};
const validate = () => {
if (props.boxType === "prompt") {
const inputPattern = state.inputPattern;
if (inputPattern && !inputPattern.test(state.inputValue || "")) {
state.editorErrorMessage = state.inputErrorMessage || t("el.messagebox.error");
state.validateError = true;
return false;
}
const inputValidator = state.inputValidator;
if ((0, _vue_shared.isFunction)(inputValidator)) {
const validateResult = inputValidator(state.inputValue);
if (validateResult === false) {
state.editorErrorMessage = state.inputErrorMessage || t("el.messagebox.error");
state.validateError = true;
return false;
}
if ((0, _vue_shared.isString)(validateResult)) {
state.editorErrorMessage = validateResult;
state.validateError = true;
return false;
}
}
}
state.editorErrorMessage = "";
state.validateError = false;
return true;
};
const getInputElement = () => {
const inputRefs = inputRef.value?.$refs;
return inputRefs?.input ?? inputRefs?.textarea;
};
const handleClose = () => {
handleAction("close");
};
const onCloseRequested = () => {
if (props.closeOnPressEscape) handleClose();
};
if (props.lockScroll) require_index$2.useLockscreen(visible, { ns });
return {
...(0, vue.toRefs)(state),
ns,
overlayEvent,
visible,
hasMessage,
typeClass,
contentId,
inputId,
btnSize,
iconComponent,
confirmButtonClasses,
rootRef,
focusStartRef,
headerRef,
inputRef,
isDragging,
confirmRef,
doClose,
handleClose,
onCloseRequested,
handleWrapperClick,
handleInputEnter,
handleAction,
t
};
}
});
//#endregion
exports.default = index_vue_vue_type_script_lang_default;
//# sourceMappingURL=index.vue_vue_type_script_lang.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,168 @@
import { ComponentSize } from "../../../constants/size.js";
import { CSSProperties as CSSProperties$1 } from "../../../utils/typescript.js";
import "../../../utils/index.js";
import { InputType } from "../../input/src/input.js";
import { buttonTypes } from "../../button/src/button.js";
import "../../button/index.js";
import { AppContext, Component, VNode } from "vue";
//#region ../../packages/components/message-box/src/message-box.type.d.ts
type MessageType = '' | 'primary' | 'success' | 'warning' | 'info' | 'error';
type MessageBoxButtonType = (typeof buttonTypes)[number];
type Action = 'confirm' | 'close' | 'cancel';
type MessageBoxType = '' | 'prompt' | 'alert' | 'confirm';
type MessageBoxData = MessageBoxInputData & Action;
interface MessageBoxInputData {
value: string;
action: Action;
}
type MessageBoxInputValidator = ((value: string) => boolean | string) | undefined;
declare interface MessageBoxState {
autofocus: boolean;
title: string | undefined;
message: string;
type: MessageType;
icon: string | Component;
closeIcon: string | Component;
customClass: string;
customStyle: CSSProperties$1;
showInput: boolean;
inputValue: string;
inputPlaceholder: string;
inputType: InputType;
inputPattern: RegExp | null;
inputValidator: MessageBoxInputValidator;
inputErrorMessage: string;
showConfirmButton: boolean;
showCancelButton: boolean;
action: Action;
dangerouslyUseHTMLString: boolean;
confirmButtonText: string;
cancelButtonText: string;
confirmButtonType: MessageBoxButtonType;
cancelButtonType: MessageBoxButtonType;
confirmButtonLoading: boolean;
cancelButtonLoading: boolean;
confirmButtonLoadingIcon: string | Component;
cancelButtonLoadingIcon: string | Component;
confirmButtonClass: string;
confirmButtonDisabled: boolean;
cancelButtonClass: string;
editorErrorMessage: string;
beforeClose: null | ((action: Action, instance: MessageBoxState, done: () => void) => void);
callback: null | Callback;
distinguishCancelAndClose: boolean;
modalFade: boolean;
modalClass: string;
validateError: boolean;
zIndex: number;
}
type Callback = ((value: string, action: Action) => any) | ((action: Action) => any);
/** Options used in MessageBox */
interface ElMessageBoxOptions {
/**
* auto focus when open message-box
*/
autofocus?: boolean;
/** Callback before MessageBox closes, and it will prevent MessageBox from closing */
beforeClose?: (action: Action, instance: MessageBoxState, done: () => void) => void;
/** Custom class name for MessageBox */
customClass?: string;
/** Custom inline style for MessageBox */
customStyle?: CSSProperties$1;
/** Whether a mask is displayed */
modal?: boolean;
/** modal class name for MessageBox */
modalClass?: string;
/** MessageBox closing callback if you don't prefer Promise */
callback?: Callback;
/** Text content of cancel button */
cancelButtonText?: string;
/** Text content of confirm button */
confirmButtonText?: string;
/** Type of cancel button */
cancelButtonType?: MessageBoxButtonType;
/** Type of confirm button */
confirmButtonType?: MessageBoxButtonType;
/** Loading Icon content of cancel button */
cancelButtonLoadingIcon?: string | Component;
/** Loading Icon content of confirm button */
confirmButtonLoadingIcon?: string | Component;
/** Custom class name of cancel button */
cancelButtonClass?: string;
/** Custom class name of confirm button */
confirmButtonClass?: string;
/** Whether to align the content in center */
center?: boolean;
/** Whether MessageBox can be drag */
draggable?: boolean;
/** Draggable MessageBox can overflow the viewport */
overflow?: boolean;
/** Content of the MessageBox */
message?: string | VNode | (() => VNode);
/** Title of the MessageBox */
title?: string | ElMessageBoxOptions;
/** Message type, used for icon display */
type?: MessageType;
/** Message box type */
boxType?: MessageBoxType;
/** Custom icon component */
icon?: string | Component;
/** Custom close icon component */
closeIcon?: string | Component;
/** Whether message is treated as HTML string */
dangerouslyUseHTMLString?: boolean;
/** Whether to distinguish canceling and closing */
distinguishCancelAndClose?: boolean;
/** Whether to lock body scroll when MessageBox prompts */
lockScroll?: boolean;
/** Whether to show a cancel button */
showCancelButton?: boolean;
/** Whether to show a confirm button */
showConfirmButton?: boolean;
/** Whether to show a close button */
showClose?: boolean;
/** Whether to use round button */
roundButton?: boolean;
/** Whether MessageBox can be closed by clicking the mask */
closeOnClickModal?: boolean;
/** Whether MessageBox can be closed by pressing the ESC */
closeOnPressEscape?: boolean;
/** Whether to close MessageBox when hash changes */
closeOnHashChange?: boolean;
/** Whether to show an input */
showInput?: boolean;
/** Placeholder of input */
inputPlaceholder?: string;
/** Initial value of input */
inputValue?: string;
/** Regexp for the input */
inputPattern?: RegExp;
/** type of input, see more in [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Form_%3Cinput%3E_types) */
inputType?: InputType;
/** Validation function for the input. Should returns a boolean or string. If a string is returned, it will be assigned to inputErrorMessage */
inputValidator?: MessageBoxInputValidator;
/** Error message when validation fails */
inputErrorMessage?: string;
/** Custom size of confirm and cancel buttons */
buttonSize?: ComponentSize;
/** Custom element to append the message box to */
appendTo?: HTMLElement | string;
}
type ElMessageBoxShortcutMethod = ((message: ElMessageBoxOptions['message'], options?: ElMessageBoxOptions, appContext?: AppContext | null) => Promise<MessageBoxData>) & ((message: ElMessageBoxOptions['message'], title: ElMessageBoxOptions['title'], options?: ElMessageBoxOptions, appContext?: AppContext | null) => Promise<MessageBoxData>);
interface IElMessageBox {
_context: AppContext | null;
/** Show a message box */
/** Show a message box */
(options: ElMessageBoxOptions, appContext?: AppContext | null): Promise<MessageBoxData>;
/** Show an alert message box */
alert: ElMessageBoxShortcutMethod;
/** Show a confirm message box */
confirm: ElMessageBoxShortcutMethod;
/** Show a prompt message box */
prompt: ElMessageBoxShortcutMethod;
/** Close current message box */
close(): void;
}
//#endregion
export { Action, Callback, ElMessageBoxOptions, ElMessageBoxShortcutMethod, IElMessageBox, MessageBoxData, MessageBoxInputData, MessageBoxInputValidator, MessageBoxState, MessageBoxType };

View File

@@ -0,0 +1 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

View File

@@ -0,0 +1,6 @@
import { IElMessageBox } from "./message-box.type.js";
//#region ../../packages/components/message-box/src/messageBox.d.ts
declare const _default: IElMessageBox;
//#endregion
export { _default };

View File

@@ -0,0 +1,120 @@
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
const require_runtime = require('../../../_virtual/_rolldown/runtime.js');
const require_types = require('../../../utils/types.js');
const require_error = require('../../../utils/error.js');
const require_index = require('./index.js');
let vue = require("vue");
let _vue_shared = require("@vue/shared");
let _vueuse_core = require("@vueuse/core");
//#region ../../packages/components/message-box/src/messageBox.ts
const messageInstance = /* @__PURE__ */ new Map();
const getAppendToElement = (props) => {
let appendTo = document.body;
if (props.appendTo) {
if ((0, _vue_shared.isString)(props.appendTo)) appendTo = document.querySelector(props.appendTo);
if (require_types.isElement(props.appendTo)) appendTo = props.appendTo;
if (!require_types.isElement(appendTo)) {
require_error.debugWarn("ElMessageBox", "the appendTo option is not an HTMLElement. Falling back to document.body.");
appendTo = document.body;
}
}
return appendTo;
};
const initInstance = (props, container, appContext = null) => {
const vnode = (0, vue.createVNode)(require_index.default, props, (0, _vue_shared.isFunction)(props.message) || (0, vue.isVNode)(props.message) ? { default: (0, _vue_shared.isFunction)(props.message) ? props.message : () => props.message } : null);
vnode.appContext = appContext;
(0, vue.render)(vnode, container);
getAppendToElement(props).appendChild(container.firstElementChild);
return vnode.component;
};
const genContainer = () => {
return document.createElement("div");
};
const showMessage = (options, appContext) => {
const container = genContainer();
options.onVanish = () => {
(0, vue.render)(null, container);
messageInstance.delete(vm);
};
options.onAction = (action) => {
const currentMsg = messageInstance.get(vm);
let resolve;
if (options.showInput) resolve = {
value: vm.inputValue,
action
};
else resolve = action;
if (options.callback) options.callback(resolve, instance.proxy);
else if (action === "cancel" || action === "close") if (options.distinguishCancelAndClose && action !== "cancel") currentMsg.reject("close");
else currentMsg.reject("cancel");
else currentMsg.resolve(resolve);
};
const instance = initInstance(options, container, appContext);
const vm = instance.proxy;
for (const prop in options) if ((0, _vue_shared.hasOwn)(options, prop) && !(0, _vue_shared.hasOwn)(vm.$props, prop)) if (prop === "closeIcon" && (0, _vue_shared.isObject)(options[prop])) vm[prop] = (0, vue.markRaw)(options[prop]);
else vm[prop] = options[prop];
vm.visible = true;
return vm;
};
function MessageBox(options, appContext = null) {
if (!_vueuse_core.isClient) return Promise.reject();
let callback;
if ((0, _vue_shared.isString)(options) || (0, vue.isVNode)(options)) options = { message: options };
else callback = options.callback;
return new Promise((resolve, reject) => {
const vm = showMessage(options, appContext ?? MessageBox._context);
messageInstance.set(vm, {
options,
callback,
resolve,
reject
});
});
}
const MESSAGE_BOX_VARIANTS = [
"alert",
"confirm",
"prompt"
];
const MESSAGE_BOX_DEFAULT_OPTS = {
alert: {
closeOnPressEscape: false,
closeOnClickModal: false
},
confirm: { showCancelButton: true },
prompt: {
showCancelButton: true,
showInput: true
}
};
MESSAGE_BOX_VARIANTS.forEach((boxType) => {
MessageBox[boxType] = messageBoxFactory(boxType);
});
function messageBoxFactory(boxType) {
return (message, title, options, appContext) => {
let titleOrOpts = "";
if ((0, _vue_shared.isObject)(title)) {
options = title;
titleOrOpts = "";
} else if (require_types.isUndefined(title)) titleOrOpts = "";
else titleOrOpts = title;
return MessageBox(Object.assign({
title: titleOrOpts,
message,
type: "",
...MESSAGE_BOX_DEFAULT_OPTS[boxType]
}, options, { boxType }), appContext);
};
}
MessageBox.close = () => {
messageInstance.forEach((_, vm) => {
vm.doClose();
});
messageInstance.clear();
};
MessageBox._context = null;
//#endregion
exports.default = MessageBox;
//# sourceMappingURL=messageBox.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,6 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
require('../../base/style/css.js');
require('../../input/style/css.js');
require('../../button/style/css.js');
require('../../overlay/style/css.js');
require("element-plus/theme-chalk/el-message-box.css");

View File

@@ -0,0 +1,6 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
require('../../base/style/index.js');
require('../../input/style/index.js');
require('../../button/style/index.js');
require('../../overlay/style/index.js');
require("element-plus/theme-chalk/src/message-box.scss");