epic-designer-cjh
Version:
基于vue3的设计器,可视化开发页面表单
1,280 lines (1,279 loc) • 36.5 kB
JavaScript
import { defineComponent as U, watch as Q, renderSlot as _, computed as S, openBlock as g, createElementBlock as T, normalizeClass as v, unref as e, createVNode as N, Transition as we, withCtx as L, withDirectives as Ce, createElementVNode as M, toDisplayString as V, vShow as Ee, normalizeStyle as q, createCommentVNode as C, createBlock as O, resolveDynamicComponent as Se, ref as Z, TransitionGroup as Ae, Fragment as Te, renderList as qe, withKeys as _e, withModifiers as H, inject as He, shallowRef as ae, useSlots as Ke, onBeforeUnmount as We, provide as Ve, toRef as Xe, createSlots as pe, mergeProps as fe, shallowReactive as Ge, onMounted as Ze, isVNode as Le, render as me } from "vue";
import { a5 as A, a6 as k, a8 as Je, a9 as K, aK as re, ag as W, aF as ue, bq as Qe, br as Pe, a7 as Ye, an as Fe, aE as Re, ai as Y, aB as x, af as j, aO as de, bs as ee, as as R, aD as te, bt as xe, bu as et, bv as tt, a4 as st, bw as ve, bx as nt, by as ot, aa as Oe, av as Be, aP as at, az as rt, bz as lt, ah as it, bA as ut, bB as dt } from "./index-97ce4605.js";
import { i as Ue } from "./isNil-8ef0e4b6.js";
import { u as ct, i as pt, T as ge, e as ft } from "./index-da336cb2.js";
import { c as ye } from "./cloneDeep-aa0cb853.js";
import { i as mt } from "./isEqual-eac09a18.js";
import { p as vt, u as gt } from "./use-global-config-0bac757e.js";
const yt = A({
a11y: {
type: Boolean,
default: !0
},
locale: {
type: k(Object)
},
size: Je,
button: {
type: k(Object)
},
experimentalFeatures: {
type: k(Object)
},
keyboardNavigation: {
type: Boolean,
default: !0
},
message: {
type: k(Object)
},
zIndex: Number,
namespace: {
type: String,
default: "el"
}
}), le = {};
U({
name: "ElConfigProvider",
props: yt,
setup(o, { slots: s }) {
Q(() => o.message, (n) => {
Object.assign(le, n ?? {});
}, { immediate: !0, deep: !0 });
const t = vt(o);
return () => _(s, "default", { config: t == null ? void 0 : t.value });
}
});
const ht = A({
value: {
type: [String, Number],
default: ""
},
max: {
type: Number,
default: 99
},
isDot: Boolean,
hidden: Boolean,
type: {
type: String,
values: ["primary", "success", "warning", "info", "danger"],
default: "danger"
}
}), bt = ["textContent"], kt = U({
name: "ElBadge"
}), $t = /* @__PURE__ */ U({
...kt,
props: ht,
setup(o, { expose: s }) {
const t = o, n = K("badge"), l = S(() => t.isDot ? "" : re(t.value) && re(t.max) ? t.max < t.value ? `${t.max}+` : `${t.value}` : `${t.value}`);
return s({
content: l
}), (d, p) => (g(), T("div", {
class: v(e(n).b())
}, [
_(d.$slots, "default"),
N(we, {
name: `${e(n).namespace.value}-zoom-in-center`,
persisted: ""
}, {
default: L(() => [
Ce(M("sup", {
class: v([
e(n).e("content"),
e(n).em("content", d.type),
e(n).is("fixed", !!d.$slots.default),
e(n).is("dot", d.isDot)
]),
textContent: V(e(l))
}, null, 10, bt), [
[Ee, !d.hidden && (e(l) || d.isDot)]
])
]),
_: 1
}, 8, ["name"])
], 2));
}
});
var wt = /* @__PURE__ */ W($t, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/badge/src/badge.vue"]]);
const Ct = ue(wt), Et = A({
type: {
type: String,
default: "line",
values: ["line", "circle", "dashboard"]
},
percentage: {
type: Number,
default: 0,
validator: (o) => o >= 0 && o <= 100
},
status: {
type: String,
default: "",
values: ["", "success", "exception", "warning"]
},
indeterminate: {
type: Boolean,
default: !1
},
duration: {
type: Number,
default: 3
},
strokeWidth: {
type: Number,
default: 6
},
strokeLinecap: {
type: k(String),
default: "round"
},
textInside: {
type: Boolean,
default: !1
},
width: {
type: Number,
default: 126
},
showText: {
type: Boolean,
default: !0
},
color: {
type: k([
String,
Array,
Function
]),
default: ""
},
striped: Boolean,
stripedFlow: Boolean,
format: {
type: k(Function),
default: (o) => `${o}%`
}
}), St = ["aria-valuenow"], Tt = { viewBox: "0 0 100 100" }, _t = ["d", "stroke", "stroke-linecap", "stroke-width"], Lt = ["d", "stroke", "opacity", "stroke-linecap", "stroke-width"], Pt = { key: 0 }, Ft = U({
name: "ElProgress"
}), Rt = /* @__PURE__ */ U({
...Ft,
props: Et,
setup(o) {
const s = o, t = {
success: "#13ce66",
exception: "#ff4949",
warning: "#e6a23c",
default: "#20a0ff"
}, n = K("progress"), l = S(() => ({
width: `${s.percentage}%`,
animationDuration: `${s.duration}s`,
backgroundColor: z(s.percentage)
})), d = S(() => (s.strokeWidth / s.width * 100).toFixed(1)), p = S(() => ["circle", "dashboard"].includes(s.type) ? Number.parseInt(`${50 - Number.parseFloat(d.value) / 2}`, 10) : 0), E = S(() => {
const r = p.value, F = s.type === "dashboard";
return `
M 50 50
m 0 ${F ? "" : "-"}${r}
a ${r} ${r} 0 1 1 0 ${F ? "-" : ""}${r * 2}
a ${r} ${r} 0 1 1 0 ${F ? "" : "-"}${r * 2}
`;
}), $ = S(() => 2 * Math.PI * p.value), f = S(() => s.type === "dashboard" ? 0.75 : 1), w = S(() => `${-1 * $.value * (1 - f.value) / 2}px`), y = S(() => ({
strokeDasharray: `${$.value * f.value}px, ${$.value}px`,
strokeDashoffset: w.value
})), i = S(() => ({
strokeDasharray: `${$.value * f.value * (s.percentage / 100)}px, ${$.value}px`,
strokeDashoffset: w.value,
transition: "stroke-dasharray 0.6s ease 0s, stroke 0.6s ease, opacity ease 0.6s"
})), c = S(() => {
let r;
return s.color ? r = z(s.percentage) : r = t[s.status] || t.default, r;
}), a = S(() => s.status === "warning" ? Qe : s.type === "line" ? s.status === "success" ? Pe : Ye : s.status === "success" ? Fe : Re), m = S(() => s.type === "line" ? 12 + s.strokeWidth * 0.4 : s.width * 0.111111 + 2), b = S(() => s.format(s.percentage));
function u(r) {
const F = 100 / r.length;
return r.map((P, h) => x(P) ? {
color: P,
percentage: (h + 1) * F
} : P).sort((P, h) => P.percentage - h.percentage);
}
const z = (r) => {
var F;
const { color: B } = s;
if (Y(B))
return B(r);
if (x(B))
return B;
{
const P = u(B);
for (const h of P)
if (h.percentage > r)
return h.color;
return (F = P[P.length - 1]) == null ? void 0 : F.color;
}
};
return (r, F) => (g(), T("div", {
class: v([
e(n).b(),
e(n).m(r.type),
e(n).is(r.status),
{
[e(n).m("without-text")]: !r.showText,
[e(n).m("text-inside")]: r.textInside
}
]),
role: "progressbar",
"aria-valuenow": r.percentage,
"aria-valuemin": "0",
"aria-valuemax": "100"
}, [
r.type === "line" ? (g(), T("div", {
key: 0,
class: v(e(n).b("bar"))
}, [
M("div", {
class: v(e(n).be("bar", "outer")),
style: q({ height: `${r.strokeWidth}px` })
}, [
M("div", {
class: v([
e(n).be("bar", "inner"),
{ [e(n).bem("bar", "inner", "indeterminate")]: r.indeterminate },
{ [e(n).bem("bar", "inner", "striped")]: r.striped },
{ [e(n).bem("bar", "inner", "striped-flow")]: r.stripedFlow }
]),
style: q(e(l))
}, [
(r.showText || r.$slots.default) && r.textInside ? (g(), T("div", {
key: 0,
class: v(e(n).be("bar", "innerText"))
}, [
_(r.$slots, "default", { percentage: r.percentage }, () => [
M("span", null, V(e(b)), 1)
])
], 2)) : C("v-if", !0)
], 6)
], 6)
], 2)) : (g(), T("div", {
key: 1,
class: v(e(n).b("circle")),
style: q({ height: `${r.width}px`, width: `${r.width}px` })
}, [
(g(), T("svg", Tt, [
M("path", {
class: v(e(n).be("circle", "track")),
d: e(E),
stroke: `var(${e(n).cssVarName("fill-color-light")}, #e5e9f2)`,
"stroke-linecap": r.strokeLinecap,
"stroke-width": e(d),
fill: "none",
style: q(e(y))
}, null, 14, _t),
M("path", {
class: v(e(n).be("circle", "path")),
d: e(E),
stroke: e(c),
fill: "none",
opacity: r.percentage ? 1 : 0,
"stroke-linecap": r.strokeLinecap,
"stroke-width": e(d),
style: q(e(i))
}, null, 14, Lt)
]))
], 6)),
(r.showText || r.$slots.default) && !r.textInside ? (g(), T("div", {
key: 2,
class: v(e(n).e("text")),
style: q({ fontSize: `${e(m)}px` })
}, [
_(r.$slots, "default", { percentage: r.percentage }, () => [
r.status ? (g(), O(e(j), { key: 1 }, {
default: L(() => [
(g(), O(Se(e(a))))
]),
_: 1
})) : (g(), T("span", Pt, V(e(b)), 1))
])
], 6)) : C("v-if", !0)
], 10, St));
}
});
var Ot = /* @__PURE__ */ W(Rt, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/progress/src/progress.vue"]]);
const Bt = ue(Ot), De = Symbol("uploadContextKey"), Ut = "ElUpload";
class Dt extends Error {
constructor(s, t, n, l) {
super(s), this.name = "UploadAjaxError", this.status = t, this.method = n, this.url = l;
}
}
function he(o, s, t) {
let n;
return t.response ? n = `${t.response.error || t.response}` : t.responseText ? n = `${t.responseText}` : n = `fail to ${s.method} ${o} ${t.status}`, new Dt(n, t.status, s.method, o);
}
function Nt(o) {
const s = o.responseText || o.response;
if (!s)
return s;
try {
return JSON.parse(s);
} catch {
return s;
}
}
const Mt = (o) => {
typeof XMLHttpRequest > "u" && de(Ut, "XMLHttpRequest is undefined");
const s = new XMLHttpRequest(), t = o.action;
s.upload && s.upload.addEventListener("progress", (d) => {
const p = d;
p.percent = d.total > 0 ? d.loaded / d.total * 100 : 0, o.onProgress(p);
});
const n = new FormData();
if (o.data)
for (const [d, p] of Object.entries(o.data))
Array.isArray(p) ? n.append(d, ...p) : n.append(d, p);
n.append(o.filename, o.file, o.file.name), s.addEventListener("error", () => {
o.onError(he(t, o, s));
}), s.addEventListener("load", () => {
if (s.status < 200 || s.status >= 300)
return o.onError(he(t, o, s));
o.onSuccess(Nt(s));
}), s.open(o.method, t, !0), o.withCredentials && "withCredentials" in s && (s.withCredentials = !0);
const l = o.headers || {};
if (l instanceof Headers)
l.forEach((d, p) => s.setRequestHeader(p, d));
else
for (const [d, p] of Object.entries(l))
Ue(p) || s.setRequestHeader(d, String(p));
return s.send(n), s;
}, Ne = ["text", "picture", "picture-card"];
let zt = 1;
const ie = () => Date.now() + zt++, Me = A({
action: {
type: String,
default: "#"
},
headers: {
type: k(Object)
},
method: {
type: String,
default: "post"
},
data: {
type: Object,
default: () => ee({})
},
multiple: {
type: Boolean,
default: !1
},
name: {
type: String,
default: "file"
},
drag: {
type: Boolean,
default: !1
},
withCredentials: Boolean,
showFileList: {
type: Boolean,
default: !0
},
accept: {
type: String,
default: ""
},
type: {
type: String,
default: "select"
},
fileList: {
type: k(Array),
default: () => ee([])
},
autoUpload: {
type: Boolean,
default: !0
},
listType: {
type: String,
values: Ne,
default: "text"
},
httpRequest: {
type: k(Function),
default: Mt
},
disabled: Boolean,
limit: Number
}), It = A({
...Me,
beforeUpload: {
type: k(Function),
default: R
},
beforeRemove: {
type: k(Function)
},
onRemove: {
type: k(Function),
default: R
},
onChange: {
type: k(Function),
default: R
},
onPreview: {
type: k(Function),
default: R
},
onSuccess: {
type: k(Function),
default: R
},
onProgress: {
type: k(Function),
default: R
},
onError: {
type: k(Function),
default: R
},
onExceed: {
type: k(Function),
default: R
}
}), jt = A({
files: {
type: k(Array),
default: () => ee([])
},
disabled: {
type: Boolean,
default: !1
},
handlePreview: {
type: k(Function),
default: R
},
listType: {
type: String,
values: Ne,
default: "text"
}
}), At = {
remove: (o) => !!o
}, qt = ["onKeydown"], Ht = ["src"], Kt = ["onClick"], Wt = ["title"], Vt = ["onClick"], Xt = ["onClick"], Gt = U({
name: "ElUploadList"
}), Zt = /* @__PURE__ */ U({
...Gt,
props: jt,
emits: At,
setup(o, { emit: s }) {
const { t } = ct(), n = K("upload"), l = K("icon"), d = K("list"), p = te(), E = Z(!1), $ = (f) => {
s("remove", f);
};
return (f, w) => (g(), O(Ae, {
tag: "ul",
class: v([
e(n).b("list"),
e(n).bm("list", f.listType),
e(n).is("disabled", e(p))
]),
name: e(d).b()
}, {
default: L(() => [
(g(!0), T(Te, null, qe(f.files, (y) => (g(), T("li", {
key: y.uid || y.name,
class: v([
e(n).be("list", "item"),
e(n).is(y.status),
{ focusing: E.value }
]),
tabindex: "0",
onKeydown: _e((i) => !e(p) && $(y), ["delete"]),
onFocus: w[0] || (w[0] = (i) => E.value = !0),
onBlur: w[1] || (w[1] = (i) => E.value = !1),
onClick: w[2] || (w[2] = (i) => E.value = !1)
}, [
_(f.$slots, "default", { file: y }, () => [
f.listType === "picture" || y.status !== "uploading" && f.listType === "picture-card" ? (g(), T("img", {
key: 0,
class: v(e(n).be("list", "item-thumbnail")),
src: y.url,
alt: ""
}, null, 10, Ht)) : C("v-if", !0),
y.status === "uploading" || f.listType !== "picture-card" ? (g(), T("div", {
key: 1,
class: v(e(n).be("list", "item-info"))
}, [
M("a", {
class: v(e(n).be("list", "item-name")),
onClick: H((i) => f.handlePreview(y), ["prevent"])
}, [
N(e(j), {
class: v(e(l).m("document"))
}, {
default: L(() => [
N(e(xe))
]),
_: 1
}, 8, ["class"]),
M("span", {
class: v(e(n).be("list", "item-file-name")),
title: y.name
}, V(y.name), 11, Wt)
], 10, Kt),
y.status === "uploading" ? (g(), O(e(Bt), {
key: 0,
type: f.listType === "picture-card" ? "circle" : "line",
"stroke-width": f.listType === "picture-card" ? 6 : 2,
percentage: Number(y.percentage),
style: q(f.listType === "picture-card" ? "" : "margin-top: 0.5rem")
}, null, 8, ["type", "stroke-width", "percentage", "style"])) : C("v-if", !0)
], 2)) : C("v-if", !0),
M("label", {
class: v(e(n).be("list", "item-status-label"))
}, [
f.listType === "text" ? (g(), O(e(j), {
key: 0,
class: v([e(l).m("upload-success"), e(l).m("circle-check")])
}, {
default: L(() => [
N(e(Pe))
]),
_: 1
}, 8, ["class"])) : ["picture-card", "picture"].includes(f.listType) ? (g(), O(e(j), {
key: 1,
class: v([e(l).m("upload-success"), e(l).m("check")])
}, {
default: L(() => [
N(e(Fe))
]),
_: 1
}, 8, ["class"])) : C("v-if", !0)
], 2),
e(p) ? C("v-if", !0) : (g(), O(e(j), {
key: 2,
class: v(e(l).m("close")),
onClick: (i) => $(y)
}, {
default: L(() => [
N(e(Re))
]),
_: 2
}, 1032, ["class", "onClick"])),
C(" Due to close btn only appears when li gets focused disappears after li gets blurred, thus keyboard navigation can never reach close btn"),
C(" This is a bug which needs to be fixed "),
C(" TODO: Fix the incorrect navigation interaction "),
e(p) ? C("v-if", !0) : (g(), T("i", {
key: 3,
class: v(e(l).m("close-tip"))
}, V(e(t)("el.upload.deleteTip")), 3)),
f.listType === "picture-card" ? (g(), T("span", {
key: 4,
class: v(e(n).be("list", "item-actions"))
}, [
M("span", {
class: v(e(n).be("list", "item-preview")),
onClick: (i) => f.handlePreview(y)
}, [
N(e(j), {
class: v(e(l).m("zoom-in"))
}, {
default: L(() => [
N(e(et))
]),
_: 1
}, 8, ["class"])
], 10, Vt),
e(p) ? C("v-if", !0) : (g(), T("span", {
key: 0,
class: v(e(n).be("list", "item-delete")),
onClick: (i) => $(y)
}, [
N(e(j), {
class: v(e(l).m("delete"))
}, {
default: L(() => [
N(e(tt))
]),
_: 1
}, 8, ["class"])
], 10, Xt))
], 2)) : C("v-if", !0)
])
], 42, qt))), 128)),
_(f.$slots, "append")
]),
_: 3
}, 8, ["class", "name"]));
}
});
var be = /* @__PURE__ */ W(Zt, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/upload/src/upload-list.vue"]]);
const Jt = A({
disabled: {
type: Boolean,
default: !1
}
}), Qt = {
file: (o) => st(o)
}, Yt = ["onDrop", "onDragover"], ze = "ElUploadDrag", xt = U({
name: ze
}), es = /* @__PURE__ */ U({
...xt,
props: Jt,
emits: Qt,
setup(o, { emit: s }) {
const t = He(De);
t || de(ze, "usage: <el-upload><el-upload-dragger /></el-upload>");
const n = K("upload"), l = Z(!1), d = te(), p = ($) => {
if (d.value)
return;
l.value = !1, $.stopPropagation();
const f = Array.from($.dataTransfer.files), w = t.accept.value;
if (!w) {
s("file", f);
return;
}
const y = f.filter((i) => {
const { type: c, name: a } = i, m = a.includes(".") ? `.${a.split(".").pop()}` : "", b = c.replace(/\/.*$/, "");
return w.split(",").map((u) => u.trim()).filter((u) => u).some((u) => u.startsWith(".") ? m === u : /\/\*$/.test(u) ? b === u.replace(/\/\*$/, "") : /^[^/]+\/[^/]+$/.test(u) ? c === u : !1);
});
s("file", y);
}, E = () => {
d.value || (l.value = !0);
};
return ($, f) => (g(), T("div", {
class: v([e(n).b("dragger"), e(n).is("dragover", l.value)]),
onDrop: H(p, ["prevent"]),
onDragover: H(E, ["prevent"]),
onDragleave: f[0] || (f[0] = H((w) => l.value = !1, ["prevent"]))
}, [
_($.$slots, "default")
], 42, Yt));
}
});
var ts = /* @__PURE__ */ W(es, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/upload/src/upload-dragger.vue"]]);
const ss = A({
...Me,
beforeUpload: {
type: k(Function),
default: R
},
onRemove: {
type: k(Function),
default: R
},
onStart: {
type: k(Function),
default: R
},
onSuccess: {
type: k(Function),
default: R
},
onProgress: {
type: k(Function),
default: R
},
onError: {
type: k(Function),
default: R
},
onExceed: {
type: k(Function),
default: R
}
}), ns = ["onKeydown"], os = ["name", "multiple", "accept"], as = U({
name: "ElUploadContent",
inheritAttrs: !1
}), rs = /* @__PURE__ */ U({
...as,
props: ss,
setup(o, { expose: s }) {
const t = o, n = K("upload"), l = te(), d = ae({}), p = ae(), E = (a) => {
if (a.length === 0)
return;
const { autoUpload: m, limit: b, fileList: u, multiple: z, onStart: r, onExceed: F } = t;
if (b && u.length + a.length > b) {
F(a, u);
return;
}
z || (a = a.slice(0, 1));
for (const B of a) {
const P = B;
P.uid = ie(), r(P), m && $(P);
}
}, $ = async (a) => {
if (p.value.value = "", !t.beforeUpload)
return f(a);
let m, b = {};
try {
const z = t.data, r = t.beforeUpload(a);
b = ve(t.data) ? ye(t.data) : t.data, m = await r, ve(t.data) && mt(z, b) && (b = ye(t.data));
} catch {
m = !1;
}
if (m === !1) {
t.onRemove(a);
return;
}
let u = a;
m instanceof Blob && (m instanceof File ? u = m : u = new File([m], a.name, {
type: a.type
})), f(Object.assign(u, {
uid: a.uid
}), b);
}, f = (a, m) => {
const {
headers: b,
data: u,
method: z,
withCredentials: r,
name: F,
action: B,
onProgress: P,
onSuccess: h,
onError: J,
httpRequest: ce
} = t, { uid: se } = a, ne = {
headers: b || {},
withCredentials: r,
file: a,
data: m ?? u,
method: z,
filename: F,
action: B,
onProgress: (G) => {
P(G, a);
},
onSuccess: (G) => {
h(G, a), delete d.value[se];
},
onError: (G) => {
J(G, a), delete d.value[se];
}
}, oe = ce(ne);
d.value[se] = oe, oe instanceof Promise && oe.then(ne.onSuccess, ne.onError);
}, w = (a) => {
const m = a.target.files;
m && E(Array.from(m));
}, y = () => {
l.value || (p.value.value = "", p.value.click());
}, i = () => {
y();
};
return s({
abort: (a) => {
nt(d.value).filter(a ? ([b]) => String(a.uid) === b : () => !0).forEach(([b, u]) => {
u instanceof XMLHttpRequest && u.abort(), delete d.value[b];
});
},
upload: $
}), (a, m) => (g(), T("div", {
class: v([e(n).b(), e(n).m(a.listType), e(n).is("drag", a.drag)]),
tabindex: "0",
onClick: y,
onKeydown: _e(H(i, ["self"]), ["enter", "space"])
}, [
a.drag ? (g(), O(ts, {
key: 0,
disabled: e(l),
onFile: E
}, {
default: L(() => [
_(a.$slots, "default")
]),
_: 3
}, 8, ["disabled"])) : _(a.$slots, "default", { key: 1 }),
M("input", {
ref_key: "inputRef",
ref: p,
class: v(e(n).e("input")),
name: a.name,
multiple: a.multiple,
accept: a.accept,
type: "file",
onChange: w,
onClick: m[0] || (m[0] = H(() => {
}, ["stop"]))
}, null, 42, os)
], 42, ns));
}
});
var ke = /* @__PURE__ */ W(rs, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/upload/src/upload-content.vue"]]);
const $e = "ElUpload", ls = (o) => {
var s;
(s = o.url) != null && s.startsWith("blob:") && URL.revokeObjectURL(o.url);
}, is = (o, s) => {
const t = ot(o, "fileList", void 0, { passive: !0 }), n = (i) => t.value.find((c) => c.uid === i.uid);
function l(i) {
var c;
(c = s.value) == null || c.abort(i);
}
function d(i = ["ready", "uploading", "success", "fail"]) {
t.value = t.value.filter((c) => !i.includes(c.status));
}
const p = (i, c) => {
const a = n(c);
a && (console.error(i), a.status = "fail", t.value.splice(t.value.indexOf(a), 1), o.onError(i, a, t.value), o.onChange(a, t.value));
}, E = (i, c) => {
const a = n(c);
a && (o.onProgress(i, a, t.value), a.status = "uploading", a.percentage = Math.round(i.percent));
}, $ = (i, c) => {
const a = n(c);
a && (a.status = "success", a.response = i, o.onSuccess(i, a, t.value), o.onChange(a, t.value));
}, f = (i) => {
Ue(i.uid) && (i.uid = ie());
const c = {
name: i.name,
percentage: 0,
status: "ready",
size: i.size,
raw: i,
uid: i.uid
};
if (o.listType === "picture-card" || o.listType === "picture")
try {
c.url = URL.createObjectURL(i);
} catch (a) {
Oe($e, a.message), o.onError(a, c, t.value);
}
t.value = [...t.value, c], o.onChange(c, t.value);
}, w = async (i) => {
const c = i instanceof File ? n(i) : i;
c || de($e, "file to be removed not found");
const a = (m) => {
l(m);
const b = t.value;
b.splice(b.indexOf(m), 1), o.onRemove(m, b), ls(m);
};
o.beforeRemove ? await o.beforeRemove(c, t.value) !== !1 && a(c) : a(c);
};
function y() {
t.value.filter(({ status: i }) => i === "ready").forEach(({ raw: i }) => {
var c;
return i && ((c = s.value) == null ? void 0 : c.upload(i));
});
}
return Q(() => o.listType, (i) => {
i !== "picture-card" && i !== "picture" || (t.value = t.value.map((c) => {
const { raw: a, url: m } = c;
if (!m && a)
try {
c.url = URL.createObjectURL(a);
} catch (b) {
o.onError(b, c, t.value);
}
return c;
}));
}), Q(t, (i) => {
for (const c of i)
c.uid || (c.uid = ie()), c.status || (c.status = "success");
}, { immediate: !0, deep: !0 }), {
uploadFiles: t,
abort: l,
clearFiles: d,
handleError: p,
handleProgress: E,
handleStart: f,
handleSuccess: $,
handleRemove: w,
submit: y
};
}, us = U({
name: "ElUpload"
}), ds = /* @__PURE__ */ U({
...us,
props: It,
setup(o, { expose: s }) {
const t = o, n = Ke(), l = te(), d = ae(), {
abort: p,
submit: E,
clearFiles: $,
uploadFiles: f,
handleStart: w,
handleError: y,
handleRemove: i,
handleSuccess: c,
handleProgress: a
} = is(t, d), m = S(() => t.listType === "picture-card"), b = S(() => ({
...t,
fileList: f.value,
onStart: w,
onProgress: a,
onSuccess: c,
onError: y,
onRemove: i
}));
return We(() => {
f.value.forEach(({ url: u }) => {
u != null && u.startsWith("blob:") && URL.revokeObjectURL(u);
});
}), Ve(De, {
accept: Xe(t, "accept")
}), s({
abort: p,
submit: E,
clearFiles: $,
handleStart: w,
handleRemove: i
}), (u, z) => (g(), T("div", null, [
e(m) && u.showFileList ? (g(), O(be, {
key: 0,
disabled: e(l),
"list-type": u.listType,
files: e(f),
"handle-preview": u.onPreview,
onRemove: e(i)
}, pe({
append: L(() => [
N(ke, fe({
ref_key: "uploadRef",
ref: d
}, e(b)), {
default: L(() => [
e(n).trigger ? _(u.$slots, "trigger", { key: 0 }) : C("v-if", !0),
!e(n).trigger && e(n).default ? _(u.$slots, "default", { key: 1 }) : C("v-if", !0)
]),
_: 3
}, 16)
]),
_: 2
}, [
u.$slots.file ? {
name: "default",
fn: L(({ file: r }) => [
_(u.$slots, "file", { file: r })
])
} : void 0
]), 1032, ["disabled", "list-type", "files", "handle-preview", "onRemove"])) : C("v-if", !0),
!e(m) || e(m) && !u.showFileList ? (g(), O(ke, fe({
key: 1,
ref_key: "uploadRef",
ref: d
}, e(b)), {
default: L(() => [
e(n).trigger ? _(u.$slots, "trigger", { key: 0 }) : C("v-if", !0),
!e(n).trigger && e(n).default ? _(u.$slots, "default", { key: 1 }) : C("v-if", !0)
]),
_: 3
}, 16)) : C("v-if", !0),
u.$slots.trigger ? _(u.$slots, "default", { key: 2 }) : C("v-if", !0),
_(u.$slots, "tip"),
!e(m) && u.showFileList ? (g(), O(be, {
key: 3,
disabled: e(l),
"list-type": u.listType,
files: e(f),
"handle-preview": u.onPreview,
onRemove: e(i)
}, pe({ _: 2 }, [
u.$slots.file ? {
name: "default",
fn: L(({ file: r }) => [
_(u.$slots, "file", { file: r })
])
} : void 0
]), 1032, ["disabled", "list-type", "files", "handle-preview", "onRemove"])) : C("v-if", !0)
]));
}
});
var cs = /* @__PURE__ */ W(ds, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/upload/src/upload.vue"]]);
const Bs = ue(cs), Ie = ["success", "info", "warning", "error"], D = ee({
customClass: "",
center: !1,
dangerouslyUseHTMLString: !1,
duration: 3e3,
icon: void 0,
id: "",
message: "",
onClose: void 0,
showClose: !1,
type: "info",
offset: 16,
zIndex: 0,
grouping: !1,
repeatNum: 1,
appendTo: Be ? document.body : void 0
}), ps = A({
customClass: {
type: String,
default: D.customClass
},
center: {
type: Boolean,
default: D.center
},
dangerouslyUseHTMLString: {
type: Boolean,
default: D.dangerouslyUseHTMLString
},
duration: {
type: Number,
default: D.duration
},
icon: {
type: pt,
default: D.icon
},
id: {
type: String,
default: D.id
},
message: {
type: k([
String,
Object,
Function
]),
default: D.message
},
onClose: {
type: k(Function),
required: !1
},
showClose: {
type: Boolean,
default: D.showClose
},
type: {
type: String,
values: Ie,
default: D.type
},
offset: {
type: Number,
default: D.offset
},
zIndex: {
type: Number,
default: D.zIndex
},
grouping: {
type: Boolean,
default: D.grouping
},
repeatNum: {
type: Number,
default: D.repeatNum
}
}), fs = {
destroy: () => !0
}, I = Ge([]), ms = (o) => {
const s = I.findIndex((l) => l.id === o), t = I[s];
let n;
return s > 0 && (n = I[s - 1]), { current: t, prev: n };
}, vs = (o) => {
const { prev: s } = ms(o);
return s ? s.vm.exposed.bottom.value : 0;
}, gs = (o, s) => I.findIndex((n) => n.id === o) > 0 ? 20 : s, ys = ["id"], hs = ["innerHTML"], bs = U({
name: "ElMessage"
}), ks = /* @__PURE__ */ U({
...bs,
props: ps,
emits: fs,
setup(o, { expose: s }) {
const t = o, { Close: n } = ft, { ns: l, zIndex: d } = gt("message"), { currentZIndex: p, nextZIndex: E } = d, $ = Z(), f = Z(!1), w = Z(0);
let y;
const i = S(() => t.type ? t.type === "error" ? "danger" : t.type : "info"), c = S(() => {
const h = t.type;
return { [l.bm("icon", h)]: h && ge[h] };
}), a = S(() => t.icon || ge[t.type] || ""), m = S(() => vs(t.id)), b = S(() => gs(t.id, t.offset) + m.value), u = S(() => w.value + b.value), z = S(() => ({
top: `${b.value}px`,
zIndex: p.value
}));
function r() {
t.duration !== 0 && ({ stop: y } = lt(() => {
B();
}, t.duration));
}
function F() {
y == null || y();
}
function B() {
f.value = !1;
}
function P({ code: h }) {
h === it.esc && B();
}
return Ze(() => {
r(), E(), f.value = !0;
}), Q(() => t.repeatNum, () => {
F(), r();
}), at(document, "keydown", P), rt($, () => {
w.value = $.value.getBoundingClientRect().height;
}), s({
visible: f,
bottom: u,
close: B
}), (h, J) => (g(), O(we, {
name: e(l).b("fade"),
onBeforeLeave: h.onClose,
onAfterLeave: J[0] || (J[0] = (ce) => h.$emit("destroy")),
persisted: ""
}, {
default: L(() => [
Ce(M("div", {
id: h.id,
ref_key: "messageRef",
ref: $,
class: v([
e(l).b(),
{ [e(l).m(h.type)]: h.type && !h.icon },
e(l).is("center", h.center),
e(l).is("closable", h.showClose),
h.customClass
]),
style: q(e(z)),
role: "alert",
onMouseenter: F,
onMouseleave: r
}, [
h.repeatNum > 1 ? (g(), O(e(Ct), {
key: 0,
value: h.repeatNum,
type: e(i),
class: v(e(l).e("badge"))
}, null, 8, ["value", "type", "class"])) : C("v-if", !0),
e(a) ? (g(), O(e(j), {
key: 1,
class: v([e(l).e("icon"), e(c)])
}, {
default: L(() => [
(g(), O(Se(e(a))))
]),
_: 1
}, 8, ["class"])) : C("v-if", !0),
_(h.$slots, "default", {}, () => [
h.dangerouslyUseHTMLString ? (g(), T(Te, { key: 1 }, [
C(" Caution here, message could've been compromised, never use user's input as message "),
M("p", {
class: v(e(l).e("content")),
innerHTML: h.message
}, null, 10, hs)
], 2112)) : (g(), T("p", {
key: 0,
class: v(e(l).e("content"))
}, V(h.message), 3))
]),
h.showClose ? (g(), O(e(j), {
key: 2,
class: v(e(l).e("closeBtn")),
onClick: H(B, ["stop"])
}, {
default: L(() => [
N(e(n))
]),
_: 1
}, 8, ["class", "onClick"])) : C("v-if", !0)
], 46, ys), [
[Ee, f.value]
])
]),
_: 3
}, 8, ["name", "onBeforeLeave"]));
}
});
var $s = /* @__PURE__ */ W(ks, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/message/src/message.vue"]]);
let ws = 1;
const je = (o) => {
const s = !o || x(o) || Le(o) || Y(o) ? { message: o } : o, t = {
...D,
...s
};
if (!t.appendTo)
t.appendTo = document.body;
else if (x(t.appendTo)) {
let n = document.querySelector(t.appendTo);
ut(n) || (Oe("ElMessage", "the appendTo option is not an HTMLElement. Falling back to document.body."), n = document.body), t.appendTo = n;
}
return t;
}, Cs = (o) => {
const s = I.indexOf(o);
if (s === -1)
return;
I.splice(s, 1);
const { handler: t } = o;
t.close();
}, Es = ({ appendTo: o, ...s }, t) => {
const n = `message_${ws++}`, l = s.onClose, d = document.createElement("div"), p = {
...s,
id: n,
onClose: () => {
l == null || l(), Cs(w);
},
onDestroy: () => {
me(null, d);
}
}, E = N($s, p, Y(p.message) || Le(p.message) ? {
default: Y(p.message) ? p.message : () => p.message
} : null);
E.appContext = t || X._context, me(E, d), o.appendChild(d.firstElementChild);
const $ = E.component, w = {
id: n,
vnode: E,
vm: $,
handler: {
close: () => {
$.exposed.visible.value = !1;
}
},
props: E.component.props
};
return w;
}, X = (o = {}, s) => {
if (!Be)
return { close: () => {
} };
if (re(le.max) && I.length >= le.max)
return { close: () => {
} };
const t = je(o);
if (t.grouping && I.length) {
const l = I.find(({ vnode: d }) => {
var p;
return ((p = d.props) == null ? void 0 : p.message) === t.message;
});
if (l)
return l.props.repeatNum += 1, l.props.type = t.type, l.handler;
}
const n = Es(t, s);
return I.push(n), n.handler;
};
Ie.forEach((o) => {
X[o] = (s = {}, t) => {
const n = je(s);
return X({ ...n, type: o }, t);
};
});
function Ss(o) {
for (const s of I)
(!o || o === s.props.type) && s.handler.close();
}
X.closeAll = Ss;
X._context = null;
const Us = dt(X, "$message");
export {
Ct as E,
Bt as a,
ht as b,
yt as c,
Ne as d,
It as e,
ss as f,
ie as g,
At as h,
jt as i,
Qt as j,
Jt as k,
De as l,
le as m,
Bs as n,
D as o,
Et as p,
fs as q,
ps as r,
Ie as s,
Us as t,
Me as u
};