| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779 |
- import { G as He, H as qe, I as We, l as Ge, _ as O, J as Ve, i as ve, M as w, N as Q, e as V, O as B, Q as J, h as se, d as S, u as he, S as Ke, T as Je, U as Ye, V as Ze, W as Qe, X as ke, Y as et, Z as tt, $ as nt, A as be, a0 as ot, n as rt, D as $e, a1 as it, a2 as Re, t as De, a3 as Pe, a4 as at, g as lt, m as st, a5 as ct, r as dt, y as ut, j as ue, a6 as pt, a7 as ft, c as k, a8 as mt } from "./index2.js";
- import { defineComponent as Y, ref as ne, onMounted as ce, onBeforeUnmount as Oe, createVNode as m, shallowRef as te, watch as Te, computed as oe, Transition as gt, withDirectives as _e, vShow as Ue, watchEffect as vt, triggerRef as ht, TransitionGroup as wt, toRef as yt } from "vue";
- import { b as bt } from "./FormItem.js";
- import { P as $t } from "./index10.js";
- import { u as It } from "./useMergedState.js";
- import "./index5.js";
- import { u as Ct } from "./FormItemContext.js";
- function St(e, t, n, o) {
- for (var i = -1, a = e == null ? 0 : e.length; ++i < a; ) {
- var r = e[i];
- t(o, r, n(r), e);
- }
- return o;
- }
- function xt(e) {
- return function(t, n, o) {
- for (var i = -1, a = Object(t), r = o(t), s = r.length; s--; ) {
- var y = r[++i];
- if (n(a[y], y, a) === !1)
- break;
- }
- return t;
- };
- }
- var Ft = xt();
- function Rt(e, t) {
- return e && Ft(e, t, He);
- }
- function Dt(e, t) {
- return function(n, o) {
- if (n == null)
- return n;
- if (!qe(n))
- return e(n, o);
- for (var i = n.length, a = -1, r = Object(n); ++a < i && o(r[a], a, r) !== !1; )
- ;
- return n;
- };
- }
- var Pt = Dt(Rt);
- function Ot(e, t, n, o) {
- return Pt(e, function(i, a, r) {
- t(o, i, n(i), r);
- }), o;
- }
- function Tt(e, t) {
- return function(n, o) {
- var i = We(n) ? St : Ot, a = t ? t() : {};
- return i(n, e, bt(o), a);
- };
- }
- var _t = Tt(function(e, t, n) {
- e[n ? 0 : 1].push(t);
- }, function() {
- return [[], []];
- });
- function Ut(e, t) {
- const n = `cannot ${e.method} ${e.action} ${t.status}'`, o = new Error(n);
- return o.status = t.status, o.method = e.method, o.url = e.action, o;
- }
- function Ie(e) {
- const t = e.responseText || e.response;
- if (!t)
- return t;
- try {
- return JSON.parse(t);
- } catch (n) {
- return t;
- }
- }
- function At(e) {
- const t = new XMLHttpRequest();
- e.onProgress && t.upload && (t.upload.onprogress = function(a) {
- a.total > 0 && (a.percent = a.loaded / a.total * 100), e.onProgress(a);
- });
- const n = new FormData();
- e.data && Object.keys(e.data).forEach((i) => {
- const a = e.data[i];
- if (Array.isArray(a)) {
- a.forEach((r) => {
- n.append(`${i}[]`, r);
- });
- return;
- }
- n.append(i, a);
- }), e.file instanceof Blob ? n.append(e.filename, e.file, e.file.name) : n.append(e.filename, e.file), t.onerror = function(a) {
- e.onError(a);
- }, t.onload = function() {
- return t.status < 200 || t.status >= 300 ? e.onError(Ut(e, t), Ie(t)) : e.onSuccess(Ie(t), t);
- }, t.open(e.method, e.action, !0), e.withCredentials && "withCredentials" in t && (t.withCredentials = !0);
- const o = e.headers || {};
- return o["X-Requested-With"] !== null && t.setRequestHeader("X-Requested-With", "XMLHttpRequest"), Object.keys(o).forEach((i) => {
- o[i] !== null && t.setRequestHeader(i, o[i]);
- }), t.send(n), {
- abort() {
- t.abort();
- }
- };
- }
- const Lt = +/* @__PURE__ */ new Date();
- let Et = 0;
- function pe() {
- return `vc-upload-${Lt}-${++Et}`;
- }
- const fe = (e, t) => {
- if (e && t) {
- const n = Array.isArray(t) ? t : t.split(","), o = e.name || "", i = e.type || "", a = i.replace(/\/.*$/, "");
- return n.some((r) => {
- const s = r.trim();
- if (/^\*(\/\*)?$/.test(r))
- return !0;
- if (s.charAt(0) === ".") {
- const y = o.toLowerCase(), F = s.toLowerCase();
- let g = [F];
- return (F === ".jpg" || F === ".jpeg") && (g = [".jpg", ".jpeg"]), g.some((T) => y.endsWith(T));
- }
- return /\/\*$/.test(s) ? a === s.replace(/\/.*$/, "") : i === s ? !0 : /^\w+$/.test(s) ? (Ge(!1, `Upload takes an invalidate 'accept' type '${s}'.Skip for check.`), !0) : !1;
- });
- }
- return !0;
- };
- function jt(e, t) {
- const n = e.createReader();
- let o = [];
- function i() {
- n.readEntries((a) => {
- const r = Array.prototype.slice.apply(a);
- o = o.concat(r), !r.length ? t(o) : i();
- });
- }
- i();
- }
- const Mt = (e, t, n) => {
- const o = (i, a) => {
- i.path = a || "", i.isFile ? i.file((r) => {
- n(r) && (i.fullPath && !r.webkitRelativePath && (Object.defineProperties(r, {
- webkitRelativePath: {
- writable: !0
- }
- }), r.webkitRelativePath = i.fullPath.replace(/^\//, ""), Object.defineProperties(r, {
- webkitRelativePath: {
- writable: !1
- }
- })), t([r]));
- }) : i.isDirectory && jt(i, (r) => {
- r.forEach((s) => {
- o(s, `${a}${i.name}/`);
- });
- });
- };
- e.forEach((i) => {
- o(i.webkitGetAsEntry());
- });
- }, Ae = () => ({
- capture: [Boolean, String],
- multipart: {
- type: Boolean,
- default: void 0
- },
- name: String,
- disabled: {
- type: Boolean,
- default: void 0
- },
- componentTag: String,
- action: [String, Function],
- method: String,
- directory: {
- type: Boolean,
- default: void 0
- },
- data: [Object, Function],
- headers: Object,
- accept: String,
- multiple: {
- type: Boolean,
- default: void 0
- },
- onBatchStart: Function,
- onReject: Function,
- onStart: Function,
- onError: Function,
- onSuccess: Function,
- onProgress: Function,
- beforeUpload: Function,
- customRequest: Function,
- withCredentials: {
- type: Boolean,
- default: void 0
- },
- openFileDialogOnClick: {
- type: Boolean,
- default: void 0
- },
- prefixCls: String,
- id: String,
- onMouseenter: Function,
- onMouseleave: Function,
- onClick: Function
- });
- var Bt = function(e, t, n, o) {
- function i(a) {
- return a instanceof n ? a : new n(function(r) {
- r(a);
- });
- }
- return new (n || (n = Promise))(function(a, r) {
- function s(g) {
- try {
- F(o.next(g));
- } catch (T) {
- r(T);
- }
- }
- function y(g) {
- try {
- F(o.throw(g));
- } catch (T) {
- r(T);
- }
- }
- function F(g) {
- g.done ? a(g.value) : i(g.value).then(s, y);
- }
- F((o = o.apply(e, t || [])).next());
- });
- }, zt = function(e, t) {
- var n = {};
- for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && t.indexOf(o) < 0 && (n[o] = e[o]);
- if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var i = 0, o = Object.getOwnPropertySymbols(e); i < o.length; i++)
- t.indexOf(o[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, o[i]) && (n[o[i]] = e[o[i]]);
- return n;
- };
- const Nt = Y({
- compatConfig: {
- MODE: 3
- },
- name: "AjaxUploader",
- inheritAttrs: !1,
- props: Ae(),
- setup(e, t) {
- let {
- slots: n,
- attrs: o,
- expose: i
- } = t;
- const a = ne(pe()), r = {}, s = ne();
- let y = !1;
- const F = (d, v) => Bt(this, void 0, void 0, function* () {
- const {
- beforeUpload: $
- } = e;
- let I = d;
- if ($) {
- try {
- I = yield $(d, v);
- } catch (p) {
- I = !1;
- }
- if (I === !1)
- return {
- origin: d,
- parsedFile: null,
- action: null,
- data: null
- };
- }
- const {
- action: D
- } = e;
- let U;
- typeof D == "function" ? U = yield D(d) : U = D;
- const {
- data: j
- } = e;
- let A;
- typeof j == "function" ? A = yield j(d) : A = j;
- const M = (
- // string type is from legacy `transformFile`.
- // Not sure if this will work since no related test case works with it
- (typeof I == "object" || typeof I == "string") && I ? I : d
- );
- let c;
- M instanceof File ? c = M : c = new File([M], d.name, {
- type: d.type
- });
- const u = c;
- return u.uid = d.uid, {
- origin: d,
- data: A,
- parsedFile: u,
- action: U
- };
- }), g = (d) => {
- let {
- data: v,
- origin: $,
- action: I,
- parsedFile: D
- } = d;
- if (!y)
- return;
- const {
- onStart: U,
- customRequest: j,
- name: A,
- headers: M,
- withCredentials: c,
- method: u
- } = e, {
- uid: p
- } = $, f = j || At, h = {
- action: I,
- filename: A,
- data: v,
- file: D,
- headers: M,
- withCredentials: c,
- method: u || "post",
- onProgress: (C) => {
- const {
- onProgress: P
- } = e;
- P == null || P(C, D);
- },
- onSuccess: (C, P) => {
- const {
- onSuccess: x
- } = e;
- x == null || x(C, D, P), delete r[p];
- },
- onError: (C, P) => {
- const {
- onError: x
- } = e;
- x == null || x(C, P, D), delete r[p];
- }
- };
- U($), r[p] = f(h);
- }, T = () => {
- a.value = pe();
- }, R = (d) => {
- if (d) {
- const v = d.uid ? d.uid : d;
- r[v] && r[v].abort && r[v].abort(), delete r[v];
- } else
- Object.keys(r).forEach((v) => {
- r[v] && r[v].abort && r[v].abort(), delete r[v];
- });
- };
- ce(() => {
- y = !0;
- }), Oe(() => {
- y = !1, R();
- });
- const _ = (d) => {
- const v = [...d], $ = v.map((I) => (I.uid = pe(), F(I, v)));
- Promise.all($).then((I) => {
- const {
- onBatchStart: D
- } = e;
- D == null || D(I.map((U) => {
- let {
- origin: j,
- parsedFile: A
- } = U;
- return {
- file: j,
- parsedFile: A
- };
- })), I.filter((U) => U.parsedFile !== null).forEach((U) => {
- g(U);
- });
- });
- }, z = (d) => {
- const {
- accept: v,
- directory: $
- } = e, {
- files: I
- } = d.target, D = [...I].filter((U) => !$ || fe(U, v));
- _(D), T();
- }, l = (d) => {
- const v = s.value;
- if (!v)
- return;
- const {
- onClick: $
- } = e;
- v.click(), $ && $(d);
- }, b = (d) => {
- d.key === "Enter" && l(d);
- }, L = (d) => {
- const {
- multiple: v
- } = e;
- if (d.preventDefault(), d.type !== "dragover")
- if (e.directory)
- Mt(Array.prototype.slice.call(d.dataTransfer.items), _, ($) => fe($, e.accept));
- else {
- const $ = _t(Array.prototype.slice.call(d.dataTransfer.files), (U) => fe(U, e.accept));
- let I = $[0];
- const D = $[1];
- v === !1 && (I = I.slice(0, 1)), _(I), D.length && e.onReject && e.onReject(D);
- }
- };
- return i({
- abort: R
- }), () => {
- var d;
- const {
- componentTag: v,
- prefixCls: $,
- disabled: I,
- id: D,
- multiple: U,
- accept: j,
- capture: A,
- directory: M,
- openFileDialogOnClick: c,
- onMouseenter: u,
- onMouseleave: p
- } = e, f = zt(e, ["componentTag", "prefixCls", "disabled", "id", "multiple", "accept", "capture", "directory", "openFileDialogOnClick", "onMouseenter", "onMouseleave"]), h = {
- [$]: !0,
- [`${$}-disabled`]: I,
- [o.class]: !!o.class
- }, C = M ? {
- directory: "directory",
- webkitdirectory: "webkitdirectory"
- } : {};
- return m(v, O(O({}, I ? {} : {
- onClick: c ? l : () => {
- },
- onKeydown: c ? b : () => {
- },
- onMouseenter: u,
- onMouseleave: p,
- onDrop: L,
- onDragover: L,
- tabindex: "0"
- }), {}, {
- class: h,
- role: "button",
- style: o.style
- }), {
- default: () => [m("input", O(O(O({}, Ve(f, {
- aria: !0,
- data: !0
- })), {}, {
- id: D,
- type: "file",
- ref: s,
- onClick: (x) => x.stopPropagation(),
- onCancel: (x) => x.stopPropagation(),
- key: a.value,
- style: {
- display: "none"
- },
- accept: j
- }, C), {}, {
- multiple: U,
- onChange: z
- }, A != null ? {
- capture: A
- } : {}), null), (d = n.default) === null || d === void 0 ? void 0 : d.call(n)]
- });
- };
- }
- });
- function me() {
- }
- const Ce = Y({
- compatConfig: {
- MODE: 3
- },
- name: "Upload",
- inheritAttrs: !1,
- props: ve(Ae(), {
- componentTag: "span",
- prefixCls: "rc-upload",
- data: {},
- headers: {},
- name: "file",
- multipart: !1,
- onStart: me,
- onError: me,
- onSuccess: me,
- multiple: !1,
- beforeUpload: null,
- customRequest: null,
- withCredentials: !1,
- openFileDialogOnClick: !0
- }),
- setup(e, t) {
- let {
- slots: n,
- attrs: o,
- expose: i
- } = t;
- const a = ne();
- return i({
- abort: (s) => {
- var y;
- (y = a.value) === null || y === void 0 || y.abort(s);
- }
- }), () => m(Nt, O(O(O({}, e), o), {}, {
- ref: a
- }), n);
- }
- });
- function Le() {
- return {
- capture: Q([Boolean, String]),
- type: J(),
- name: String,
- defaultFileList: se(),
- fileList: se(),
- action: Q([String, Function]),
- directory: B(),
- data: Q([Object, Function]),
- method: J(),
- headers: V(),
- showUploadList: Q([Boolean, Object]),
- multiple: B(),
- accept: String,
- beforeUpload: w(),
- onChange: w(),
- "onUpdate:fileList": w(),
- onDrop: w(),
- listType: J(),
- onPreview: w(),
- onDownload: w(),
- onReject: w(),
- onRemove: w(),
- /** @deprecated Please use `onRemove` directly */
- remove: w(),
- supportServerRender: B(),
- disabled: B(),
- prefixCls: String,
- customRequest: w(),
- withCredentials: B(),
- openFileDialogOnClick: B(),
- locale: V(),
- id: String,
- previewFile: w(),
- /** @deprecated Please use `beforeUpload` directly */
- transformFile: w(),
- iconRender: w(),
- isImageUrl: w(),
- progress: V(),
- itemRender: w(),
- /** Config max count of `fileList`. Will replace current one when `maxCount` is 1 */
- maxCount: Number,
- height: Q([Number, String]),
- removeIcon: w(),
- downloadIcon: w(),
- previewIcon: w()
- };
- }
- function Xt() {
- return {
- listType: J(),
- onPreview: w(),
- onDownload: w(),
- onRemove: w(),
- items: se(),
- progress: V(),
- prefixCls: J(),
- showRemoveIcon: B(),
- showDownloadIcon: B(),
- showPreviewIcon: B(),
- removeIcon: w(),
- downloadIcon: w(),
- previewIcon: w(),
- locale: V(void 0),
- previewFile: w(),
- iconRender: w(),
- isImageUrl: w(),
- appendAction: w(),
- appendActionVisible: B(),
- itemRender: w()
- };
- }
- function re(e) {
- return S(S({}, e), {
- lastModified: e.lastModified,
- lastModifiedDate: e.lastModifiedDate,
- name: e.name,
- size: e.size,
- type: e.type,
- uid: e.uid,
- percent: 0,
- originFileObj: e
- });
- }
- function ie(e, t) {
- const n = [...t], o = n.findIndex((i) => {
- let {
- uid: a
- } = i;
- return a === e.uid;
- });
- return o === -1 ? n.push(e) : n[o] = e, n;
- }
- function ge(e, t) {
- const n = e.uid !== void 0 ? "uid" : "name";
- return t.filter((o) => o[n] === e[n])[0];
- }
- function Ht(e, t) {
- const n = e.uid !== void 0 ? "uid" : "name", o = t.filter((i) => i[n] !== e[n]);
- return o.length === t.length ? null : o;
- }
- const qt = function() {
- const t = (arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "").split("/"), o = t[t.length - 1].split(/#|\?/)[0];
- return (/\.[^./\\]*$/.exec(o) || [""])[0];
- }, Ee = (e) => e.indexOf("image/") === 0, Wt = (e) => {
- if (e.type && !e.thumbUrl)
- return Ee(e.type);
- const t = e.thumbUrl || e.url || "", n = qt(t);
- return /^data:image\//.test(t) || /(webp|svg|png|gif|jpg|jpeg|jfif|bmp|dpg|ico)$/i.test(n) ? !0 : !(/^data:/.test(t) || n);
- }, G = 200;
- function Gt(e) {
- return new Promise((t) => {
- if (!e.type || !Ee(e.type)) {
- t("");
- return;
- }
- const n = document.createElement("canvas");
- n.width = G, n.height = G, n.style.cssText = `position: fixed; left: 0; top: 0; width: ${G}px; height: ${G}px; z-index: 9999; display: none;`, document.body.appendChild(n);
- const o = n.getContext("2d"), i = new Image();
- if (i.onload = () => {
- const {
- width: a,
- height: r
- } = i;
- let s = G, y = G, F = 0, g = 0;
- a > r ? (y = r * (G / a), g = -(y - s) / 2) : (s = a * (G / r), F = -(s - y) / 2), o.drawImage(i, F, g, s, y);
- const T = n.toDataURL();
- document.body.removeChild(n), t(T);
- }, i.crossOrigin = "anonymous", e.type.startsWith("image/svg+xml")) {
- const a = new FileReader();
- a.addEventListener("load", () => {
- a.result && (i.src = a.result);
- }), a.readAsDataURL(e);
- } else
- i.src = window.URL.createObjectURL(e);
- });
- }
- const Vt = () => ({
- prefixCls: String,
- locale: V(void 0),
- file: V(),
- items: se(),
- listType: J(),
- isImgUrl: w(),
- showRemoveIcon: B(),
- showDownloadIcon: B(),
- showPreviewIcon: B(),
- removeIcon: w(),
- downloadIcon: w(),
- previewIcon: w(),
- iconRender: w(),
- actionIconRender: w(),
- itemRender: w(),
- onPreview: w(),
- onClose: w(),
- onDownload: w(),
- progress: V()
- }), Kt = Y({
- compatConfig: {
- MODE: 3
- },
- name: "ListItem",
- inheritAttrs: !1,
- props: Vt(),
- setup(e, t) {
- let {
- slots: n,
- attrs: o
- } = t;
- var i;
- const a = te(!1), r = te();
- ce(() => {
- r.value = setTimeout(() => {
- a.value = !0;
- }, 300);
- }), Oe(() => {
- clearTimeout(r.value);
- });
- const s = te((i = e.file) === null || i === void 0 ? void 0 : i.status);
- Te(() => {
- var g;
- return (g = e.file) === null || g === void 0 ? void 0 : g.status;
- }, (g) => {
- g !== "removed" && (s.value = g);
- });
- const {
- rootPrefixCls: y
- } = he("upload", e), F = oe(() => Ke(`${y.value}-fade`));
- return () => {
- var g, T;
- const {
- prefixCls: R,
- locale: _,
- listType: z,
- file: l,
- items: b,
- progress: L,
- iconRender: d = n.iconRender,
- actionIconRender: v = n.actionIconRender,
- itemRender: $ = n.itemRender,
- isImgUrl: I,
- showPreviewIcon: D,
- showRemoveIcon: U,
- showDownloadIcon: j,
- previewIcon: A = n.previewIcon,
- removeIcon: M = n.removeIcon,
- downloadIcon: c = n.downloadIcon,
- onPreview: u,
- onDownload: p,
- onClose: f
- } = e, {
- class: h,
- style: C
- } = o, P = d({
- file: l
- });
- let x = m("div", {
- class: `${R}-text-icon`
- }, [P]);
- if (z === "picture" || z === "picture-card")
- if (s.value === "uploading" || !l.thumbUrl && !l.url) {
- const N = {
- [`${R}-list-item-thumbnail`]: !0,
- [`${R}-list-item-file`]: s.value !== "uploading"
- };
- x = m("div", {
- class: N
- }, [P]);
- } else {
- const N = I != null && I(l) ? m("img", {
- src: l.thumbUrl || l.url,
- alt: l.name,
- class: `${R}-list-item-image`,
- crossorigin: l.crossOrigin
- }, null) : P, Ne = {
- [`${R}-list-item-thumbnail`]: !0,
- [`${R}-list-item-file`]: I && !I(l)
- };
- x = m("a", {
- class: Ne,
- onClick: (Xe) => u(l, Xe),
- href: l.url || l.thumbUrl,
- target: "_blank",
- rel: "noopener noreferrer"
- }, [N]);
- }
- const E = {
- [`${R}-list-item`]: !0,
- [`${R}-list-item-${s.value}`]: !0
- }, q = typeof l.linkProps == "string" ? JSON.parse(l.linkProps) : l.linkProps, K = U ? v({
- customIcon: M ? M({
- file: l
- }) : m(Je, null, null),
- callback: () => f(l),
- prefixCls: R,
- title: _.removeFile
- }) : null, X = j && s.value === "done" ? v({
- customIcon: c ? c({
- file: l
- }) : m(Ye, null, null),
- callback: () => p(l),
- prefixCls: R,
- title: _.downloadFile
- }) : null, H = z !== "picture-card" && m("span", {
- key: "download-delete",
- class: [`${R}-list-item-actions`, {
- picture: z === "picture"
- }]
- }, [X, K]), W = `${R}-list-item-name`, Z = l.url ? [m("a", O(O({
- key: "view",
- target: "_blank",
- rel: "noopener noreferrer",
- class: W,
- title: l.name
- }, q), {}, {
- href: l.url,
- onClick: (N) => u(l, N)
- }), [l.name]), H] : [m("span", {
- key: "view",
- class: W,
- onClick: (N) => u(l, N),
- title: l.name
- }, [l.name]), H], de = {
- pointerEvents: "none",
- opacity: 0.5
- }, je = D ? m("a", {
- href: l.url || l.thumbUrl,
- target: "_blank",
- rel: "noopener noreferrer",
- style: l.url || l.thumbUrl ? void 0 : de,
- onClick: (N) => u(l, N),
- title: _.previewFile
- }, [A ? A({
- file: l
- }) : m(Ze, null, null)]) : null, Me = z === "picture-card" && s.value !== "uploading" && m("span", {
- class: `${R}-list-item-actions`
- }, [je, s.value === "done" && X, K]), we = m("div", {
- class: E
- }, [x, Z, Me, a.value && m(gt, F.value, {
- default: () => [_e(m("div", {
- class: `${R}-list-item-progress`
- }, ["percent" in l ? m($t, O(O({}, L), {}, {
- type: "line",
- percent: l.percent
- }), null) : null]), [[Ue, s.value === "uploading"]])]
- })]), Be = {
- [`${R}-list-item-container`]: !0,
- [`${h}`]: !!h
- }, ze = l.response && typeof l.response == "string" ? l.response : ((g = l.error) === null || g === void 0 ? void 0 : g.statusText) || ((T = l.error) === null || T === void 0 ? void 0 : T.message) || _.uploadError, ye = s.value === "error" ? m(Qe, {
- title: ze,
- getPopupContainer: (N) => N.parentNode
- }, {
- default: () => [we]
- }) : we;
- return m("div", {
- class: Be,
- style: C
- }, [$ ? $({
- originNode: ye,
- file: l,
- fileList: b,
- actions: {
- download: p.bind(null, l),
- preview: u.bind(null, l),
- remove: f.bind(null, l)
- }
- }) : ye]);
- };
- }
- }), Jt = (e, t) => {
- let {
- slots: n
- } = t;
- var o;
- return it((o = n.default) === null || o === void 0 ? void 0 : o.call(n))[0];
- }, Yt = Y({
- compatConfig: {
- MODE: 3
- },
- name: "AUploadList",
- props: ve(Xt(), {
- listType: "text",
- progress: {
- strokeWidth: 2,
- showInfo: !1
- },
- showRemoveIcon: !0,
- showDownloadIcon: !1,
- showPreviewIcon: !0,
- previewFile: Gt,
- isImageUrl: Wt,
- items: [],
- appendActionVisible: !0
- }),
- setup(e, t) {
- let {
- slots: n,
- expose: o
- } = t;
- const i = te(!1);
- ce(() => {
- i.value == !0;
- });
- const a = te([]);
- Te(() => e.items, function() {
- let l = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
- a.value = l.slice();
- }, {
- immediate: !0,
- deep: !0
- }), vt(() => {
- if (e.listType !== "picture" && e.listType !== "picture-card")
- return;
- let l = !1;
- (e.items || []).forEach((b, L) => {
- typeof document == "undefined" || typeof window == "undefined" || !window.FileReader || !window.File || !(b.originFileObj instanceof File || b.originFileObj instanceof Blob) || b.thumbUrl !== void 0 || (b.thumbUrl = "", e.previewFile && e.previewFile(b.originFileObj).then((d) => {
- const v = d || "";
- v !== b.thumbUrl && (a.value[L].thumbUrl = v, l = !0);
- }));
- }), l && ht(a);
- });
- const r = (l, b) => {
- if (e.onPreview)
- return b == null || b.preventDefault(), e.onPreview(l);
- }, s = (l) => {
- typeof e.onDownload == "function" ? e.onDownload(l) : l.url && window.open(l.url);
- }, y = (l) => {
- var b;
- (b = e.onRemove) === null || b === void 0 || b.call(e, l);
- }, F = (l) => {
- let {
- file: b
- } = l;
- const L = e.iconRender || n.iconRender;
- if (L)
- return L({
- file: b,
- listType: e.listType
- });
- const d = b.status === "uploading", v = e.isImageUrl && e.isImageUrl(b) ? m(tt, null, null) : m(nt, null, null);
- let $ = d ? m(be, null, null) : m(ot, null, null);
- return e.listType === "picture" ? $ = d ? m(be, null, null) : v : e.listType === "picture-card" && ($ = d ? e.locale.uploading : v), $;
- }, g = (l) => {
- const {
- customIcon: b,
- callback: L,
- prefixCls: d,
- title: v
- } = l, $ = {
- type: "text",
- size: "small",
- title: v,
- onClick: () => {
- L();
- },
- class: `${d}-list-item-action`
- };
- return rt(b) ? m($e, $, {
- icon: () => b
- }) : m($e, $, {
- default: () => [m("span", null, [b])]
- });
- };
- o({
- handlePreview: r,
- handleDownload: s
- });
- const {
- prefixCls: T,
- rootPrefixCls: R
- } = he("upload", e), _ = oe(() => ({
- [`${T.value}-list`]: !0,
- [`${T.value}-list-${e.listType}`]: !0
- })), z = oe(() => {
- const l = S({}, ke(`${R.value}-motion-collapse`));
- delete l.onAfterAppear, delete l.onAfterEnter, delete l.onAfterLeave;
- const b = S(S({}, et(`${T.value}-${e.listType === "picture-card" ? "animate-inline" : "animate"}`)), {
- class: _.value,
- appear: i.value
- });
- return e.listType !== "picture-card" ? S(S({}, l), b) : b;
- });
- return () => {
- const {
- listType: l,
- locale: b,
- isImageUrl: L,
- showPreviewIcon: d,
- showRemoveIcon: v,
- showDownloadIcon: $,
- removeIcon: I,
- previewIcon: D,
- downloadIcon: U,
- progress: j,
- appendAction: A,
- itemRender: M,
- appendActionVisible: c
- } = e, u = A == null ? void 0 : A(), p = a.value;
- return m(wt, O(O({}, z.value), {}, {
- tag: "div"
- }), {
- default: () => [p.map((f) => {
- const {
- uid: h
- } = f;
- return m(Kt, {
- key: h,
- locale: b,
- prefixCls: T.value,
- file: f,
- items: p,
- progress: j,
- listType: l,
- isImgUrl: L,
- showPreviewIcon: d,
- showRemoveIcon: v,
- showDownloadIcon: $,
- onPreview: r,
- onDownload: s,
- onClose: y,
- removeIcon: I,
- previewIcon: D,
- downloadIcon: U,
- itemRender: M
- }, S(S({}, n), {
- iconRender: F,
- actionIconRender: g
- }));
- }), A ? _e(m(Jt, {
- key: "__ant_upload_appendAction"
- }, {
- default: () => u
- }), [[Ue, !!c]]) : null]
- });
- };
- }
- }), Zt = (e) => {
- const {
- componentCls: t,
- iconCls: n
- } = e;
- return {
- [`${t}-wrapper`]: {
- [`${t}-drag`]: {
- position: "relative",
- width: "100%",
- height: "100%",
- textAlign: "center",
- background: e.colorFillAlter,
- border: `${e.lineWidth}px dashed ${e.colorBorder}`,
- borderRadius: e.borderRadiusLG,
- cursor: "pointer",
- transition: `border-color ${e.motionDurationSlow}`,
- [t]: {
- padding: `${e.padding}px 0`
- },
- [`${t}-btn`]: {
- display: "table",
- width: "100%",
- height: "100%",
- outline: "none"
- },
- [`${t}-drag-container`]: {
- display: "table-cell",
- verticalAlign: "middle"
- },
- [`&:not(${t}-disabled):hover`]: {
- borderColor: e.colorPrimaryHover
- },
- [`p${t}-drag-icon`]: {
- marginBottom: e.margin,
- [n]: {
- color: e.colorPrimary,
- fontSize: e.uploadThumbnailSize
- }
- },
- [`p${t}-text`]: {
- margin: `0 0 ${e.marginXXS}px`,
- color: e.colorTextHeading,
- fontSize: e.fontSizeLG
- },
- [`p${t}-hint`]: {
- color: e.colorTextDescription,
- fontSize: e.fontSize
- },
- // ===================== Disabled =====================
- [`&${t}-disabled`]: {
- cursor: "not-allowed",
- [`p${t}-drag-icon ${n},
- p${t}-text,
- p${t}-hint
- `]: {
- color: e.colorTextDisabled
- }
- }
- }
- }
- };
- }, Qt = (e) => {
- const {
- componentCls: t,
- antCls: n,
- iconCls: o,
- fontSize: i,
- lineHeight: a
- } = e, r = `${t}-list-item`, s = `${r}-actions`, y = `${r}-action`, F = Math.round(i * a);
- return {
- [`${t}-wrapper`]: {
- [`${t}-list`]: S(S({}, Re()), {
- lineHeight: e.lineHeight,
- [r]: {
- position: "relative",
- height: e.lineHeight * i,
- marginTop: e.marginXS,
- fontSize: i,
- display: "flex",
- alignItems: "center",
- transition: `background-color ${e.motionDurationSlow}`,
- "&:hover": {
- backgroundColor: e.controlItemBgHover
- },
- [`${r}-name`]: S(S({}, De), {
- padding: `0 ${e.paddingXS}px`,
- lineHeight: a,
- flex: "auto",
- transition: `all ${e.motionDurationSlow}`
- }),
- [s]: {
- [y]: {
- opacity: 0
- },
- [`${y}${n}-btn-sm`]: {
- height: F,
- border: 0,
- lineHeight: 1,
- // FIXME: should not override small button
- "> span": {
- transform: "scale(1)"
- }
- },
- [`
- ${y}:focus,
- &.picture ${y}
- `]: {
- opacity: 1
- },
- [o]: {
- color: e.colorTextDescription,
- transition: `all ${e.motionDurationSlow}`
- },
- [`&:hover ${o}`]: {
- color: e.colorText
- }
- },
- [`${t}-icon ${o}`]: {
- color: e.colorTextDescription,
- fontSize: i
- },
- [`${r}-progress`]: {
- position: "absolute",
- bottom: -e.uploadProgressOffset,
- width: "100%",
- paddingInlineStart: i + e.paddingXS,
- fontSize: i,
- lineHeight: 0,
- pointerEvents: "none",
- "> div": {
- margin: 0
- }
- }
- },
- [`${r}:hover ${y}`]: {
- opacity: 1,
- color: e.colorText
- },
- [`${r}-error`]: {
- color: e.colorError,
- [`${r}-name, ${t}-icon ${o}`]: {
- color: e.colorError
- },
- [s]: {
- [`${o}, ${o}:hover`]: {
- color: e.colorError
- },
- [y]: {
- opacity: 1
- }
- }
- },
- [`${t}-list-item-container`]: {
- transition: `opacity ${e.motionDurationSlow}, height ${e.motionDurationSlow}`,
- // For smooth removing animation
- "&::before": {
- display: "table",
- width: 0,
- height: 0,
- content: '""'
- }
- }
- })
- }
- };
- }, Se = new Pe("uploadAnimateInlineIn", {
- from: {
- width: 0,
- height: 0,
- margin: 0,
- padding: 0,
- opacity: 0
- }
- }), xe = new Pe("uploadAnimateInlineOut", {
- to: {
- width: 0,
- height: 0,
- margin: 0,
- padding: 0,
- opacity: 0
- }
- }), kt = (e) => {
- const {
- componentCls: t
- } = e, n = `${t}-animate-inline`;
- return [{
- [`${t}-wrapper`]: {
- [`${n}-appear, ${n}-enter, ${n}-leave`]: {
- animationDuration: e.motionDurationSlow,
- animationTimingFunction: e.motionEaseInOutCirc,
- animationFillMode: "forwards"
- },
- [`${n}-appear, ${n}-enter`]: {
- animationName: Se
- },
- [`${n}-leave`]: {
- animationName: xe
- }
- }
- }, Se, xe];
- }, en = (e) => {
- const {
- componentCls: t,
- iconCls: n,
- uploadThumbnailSize: o,
- uploadProgressOffset: i
- } = e, a = `${t}-list`, r = `${a}-item`;
- return {
- [`${t}-wrapper`]: {
- // ${listCls} 增加优先级
- [`${a}${a}-picture, ${a}${a}-picture-card`]: {
- [r]: {
- position: "relative",
- height: o + e.lineWidth * 2 + e.paddingXS * 2,
- padding: e.paddingXS,
- border: `${e.lineWidth}px ${e.lineType} ${e.colorBorder}`,
- borderRadius: e.borderRadiusLG,
- "&:hover": {
- background: "transparent"
- },
- [`${r}-thumbnail`]: S(S({}, De), {
- width: o,
- height: o,
- lineHeight: `${o + e.paddingSM}px`,
- textAlign: "center",
- flex: "none",
- [n]: {
- fontSize: e.fontSizeHeading2,
- color: e.colorPrimary
- },
- img: {
- display: "block",
- width: "100%",
- height: "100%",
- overflow: "hidden"
- }
- }),
- [`${r}-progress`]: {
- bottom: i,
- width: `calc(100% - ${e.paddingSM * 2}px)`,
- marginTop: 0,
- paddingInlineStart: o + e.paddingXS
- }
- },
- [`${r}-error`]: {
- borderColor: e.colorError,
- // Adjust the color of the error icon : https://github.com/ant-design/ant-design/pull/24160
- [`${r}-thumbnail ${n}`]: {
- "svg path[fill='#e6f7ff']": {
- fill: e.colorErrorBg
- },
- "svg path[fill='#1890ff']": {
- fill: e.colorError
- }
- }
- },
- [`${r}-uploading`]: {
- borderStyle: "dashed",
- [`${r}-name`]: {
- marginBottom: i
- }
- }
- }
- }
- };
- }, tn = (e) => {
- const {
- componentCls: t,
- iconCls: n,
- fontSizeLG: o,
- colorTextLightSolid: i
- } = e, a = `${t}-list`, r = `${a}-item`, s = e.uploadPicCardSize;
- return {
- [`${t}-wrapper${t}-picture-card-wrapper`]: S(S({}, Re()), {
- display: "inline-block",
- width: "100%",
- [`${t}${t}-select`]: {
- width: s,
- height: s,
- marginInlineEnd: e.marginXS,
- marginBottom: e.marginXS,
- textAlign: "center",
- verticalAlign: "top",
- backgroundColor: e.colorFillAlter,
- border: `${e.lineWidth}px dashed ${e.colorBorder}`,
- borderRadius: e.borderRadiusLG,
- cursor: "pointer",
- transition: `border-color ${e.motionDurationSlow}`,
- [`> ${t}`]: {
- display: "flex",
- alignItems: "center",
- justifyContent: "center",
- height: "100%",
- textAlign: "center"
- },
- [`&:not(${t}-disabled):hover`]: {
- borderColor: e.colorPrimary
- }
- },
- // list
- [`${a}${a}-picture-card`]: {
- [`${a}-item-container`]: {
- display: "inline-block",
- width: s,
- height: s,
- marginBlock: `0 ${e.marginXS}px`,
- marginInline: `0 ${e.marginXS}px`,
- verticalAlign: "top"
- },
- "&::after": {
- display: "none"
- },
- [r]: {
- height: "100%",
- margin: 0,
- "&::before": {
- position: "absolute",
- zIndex: 1,
- width: `calc(100% - ${e.paddingXS * 2}px)`,
- height: `calc(100% - ${e.paddingXS * 2}px)`,
- backgroundColor: e.colorBgMask,
- opacity: 0,
- transition: `all ${e.motionDurationSlow}`,
- content: '" "'
- }
- },
- [`${r}:hover`]: {
- [`&::before, ${r}-actions`]: {
- opacity: 1
- }
- },
- [`${r}-actions`]: {
- position: "absolute",
- insetInlineStart: 0,
- zIndex: 10,
- width: "100%",
- whiteSpace: "nowrap",
- textAlign: "center",
- opacity: 0,
- transition: `all ${e.motionDurationSlow}`,
- [`${n}-eye, ${n}-download, ${n}-delete`]: {
- zIndex: 10,
- width: o,
- margin: `0 ${e.marginXXS}px`,
- fontSize: o,
- cursor: "pointer",
- transition: `all ${e.motionDurationSlow}`
- }
- },
- [`${r}-actions, ${r}-actions:hover`]: {
- [`${n}-eye, ${n}-download, ${n}-delete`]: {
- color: new at(i).setAlpha(0.65).toRgbString(),
- "&:hover": {
- color: i
- }
- }
- },
- [`${r}-thumbnail, ${r}-thumbnail img`]: {
- position: "static",
- display: "block",
- width: "100%",
- height: "100%",
- objectFit: "contain"
- },
- [`${r}-name`]: {
- display: "none",
- textAlign: "center"
- },
- [`${r}-file + ${r}-name`]: {
- position: "absolute",
- bottom: e.margin,
- display: "block",
- width: `calc(100% - ${e.paddingXS * 2}px)`
- },
- [`${r}-uploading`]: {
- [`&${r}`]: {
- backgroundColor: e.colorFillAlter
- },
- [`&::before, ${n}-eye, ${n}-download, ${n}-delete`]: {
- display: "none"
- }
- },
- [`${r}-progress`]: {
- bottom: e.marginXL,
- width: `calc(100% - ${e.paddingXS * 2}px)`,
- paddingInlineStart: 0
- }
- }
- })
- };
- }, nn = (e) => {
- const {
- componentCls: t
- } = e;
- return {
- [`${t}-rtl`]: {
- direction: "rtl"
- }
- };
- }, on = (e) => {
- const {
- componentCls: t,
- colorTextDisabled: n
- } = e;
- return {
- [`${t}-wrapper`]: S(S({}, dt(e)), {
- [t]: {
- outline: 0,
- "input[type='file']": {
- cursor: "pointer"
- }
- },
- [`${t}-select`]: {
- display: "inline-block"
- },
- [`${t}-disabled`]: {
- color: n,
- cursor: "not-allowed"
- }
- })
- };
- }, rn = lt("Upload", (e) => {
- const {
- fontSizeHeading3: t,
- fontSize: n,
- lineHeight: o,
- lineWidth: i,
- controlHeightLG: a
- } = e, r = Math.round(n * o), s = st(e, {
- uploadThumbnailSize: t * 2,
- uploadProgressOffset: r / 2 + i,
- uploadPicCardSize: a * 2.55
- });
- return [on(s), Zt(s), en(s), tn(s), Qt(s), kt(s), nn(s), ct(s)];
- });
- var an = function(e, t, n, o) {
- function i(a) {
- return a instanceof n ? a : new n(function(r) {
- r(a);
- });
- }
- return new (n || (n = Promise))(function(a, r) {
- function s(g) {
- try {
- F(o.next(g));
- } catch (T) {
- r(T);
- }
- }
- function y(g) {
- try {
- F(o.throw(g));
- } catch (T) {
- r(T);
- }
- }
- function F(g) {
- g.done ? a(g.value) : i(g.value).then(s, y);
- }
- F((o = o.apply(e, t || [])).next());
- });
- }, ln = function(e, t) {
- var n = {};
- for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && t.indexOf(o) < 0 && (n[o] = e[o]);
- if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var i = 0, o = Object.getOwnPropertySymbols(e); i < o.length; i++)
- t.indexOf(o[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, o[i]) && (n[o[i]] = e[o[i]]);
- return n;
- };
- const ee = `__LIST_IGNORE_${Date.now()}__`, ae = Y({
- compatConfig: {
- MODE: 3
- },
- name: "AUpload",
- inheritAttrs: !1,
- props: ve(Le(), {
- type: "select",
- multiple: !1,
- action: "",
- data: {},
- accept: "",
- showUploadList: !0,
- listType: "text",
- supportServerRender: !0
- }),
- setup(e, t) {
- let {
- slots: n,
- attrs: o,
- expose: i
- } = t;
- const a = Ct(), {
- prefixCls: r,
- direction: s,
- disabled: y
- } = he("upload", e), [F, g] = rn(r), T = ut(), R = oe(() => {
- var c;
- return (c = y.value) !== null && c !== void 0 ? c : T.value;
- }), [_, z] = It(e.defaultFileList || [], {
- value: yt(e, "fileList"),
- postState: (c) => {
- const u = Date.now();
- return (c != null ? c : []).map((p, f) => (!p.uid && !Object.isFrozen(p) && (p.uid = `__AUTO__${u}_${f}__`), p));
- }
- }), l = ne("drop"), b = ne(null);
- ce(() => {
- ue(e.fileList !== void 0 || o.value === void 0, "Upload", "`value` is not a valid prop, do you mean `fileList`?"), ue(e.transformFile === void 0, "Upload", "`transformFile` is deprecated. Please use `beforeUpload` directly."), ue(e.remove === void 0, "Upload", "`remove` props is deprecated. Please use `remove` event.");
- });
- const L = (c, u, p) => {
- var f, h;
- let C = [...u];
- e.maxCount === 1 ? C = C.slice(-1) : e.maxCount && (C = C.slice(0, e.maxCount)), z(C);
- const P = {
- file: c,
- fileList: C
- };
- p && (P.event = p), (f = e["onUpdate:fileList"]) === null || f === void 0 || f.call(e, P.fileList), (h = e.onChange) === null || h === void 0 || h.call(e, P), a.onFieldChange();
- }, d = (c, u) => an(this, void 0, void 0, function* () {
- const {
- beforeUpload: p,
- transformFile: f
- } = e;
- let h = c;
- if (p) {
- const C = yield p(c, u);
- if (C === !1)
- return !1;
- if (delete c[ee], C === ee)
- return Object.defineProperty(c, ee, {
- value: !0,
- configurable: !0
- }), !1;
- typeof C == "object" && C && (h = C);
- }
- return f && (h = yield f(h)), h;
- }), v = (c) => {
- const u = c.filter((h) => !h.file[ee]);
- if (!u.length)
- return;
- const p = u.map((h) => re(h.file));
- let f = [..._.value];
- p.forEach((h) => {
- f = ie(h, f);
- }), p.forEach((h, C) => {
- let P = h;
- if (u[C].parsedFile)
- h.status = "uploading";
- else {
- const {
- originFileObj: x
- } = h;
- let E;
- try {
- E = new File([x], x.name, {
- type: x.type
- });
- } catch (q) {
- E = new Blob([x], {
- type: x.type
- }), E.name = x.name, E.lastModifiedDate = /* @__PURE__ */ new Date(), E.lastModified = (/* @__PURE__ */ new Date()).getTime();
- }
- E.uid = h.uid, P = E;
- }
- L(P, f);
- });
- }, $ = (c, u, p) => {
- try {
- typeof c == "string" && (c = JSON.parse(c));
- } catch (C) {
- }
- if (!ge(u, _.value))
- return;
- const f = re(u);
- f.status = "done", f.percent = 100, f.response = c, f.xhr = p;
- const h = ie(f, _.value);
- L(f, h);
- }, I = (c, u) => {
- if (!ge(u, _.value))
- return;
- const p = re(u);
- p.status = "uploading", p.percent = c.percent;
- const f = ie(p, _.value);
- L(p, f, c);
- }, D = (c, u, p) => {
- if (!ge(p, _.value))
- return;
- const f = re(p);
- f.error = c, f.response = u, f.status = "error";
- const h = ie(f, _.value);
- L(f, h);
- }, U = (c) => {
- let u;
- const p = e.onRemove || e.remove;
- Promise.resolve(typeof p == "function" ? p(c) : p).then((f) => {
- var h, C;
- if (f === !1)
- return;
- const P = Ht(c, _.value);
- P && (u = S(S({}, c), {
- status: "removed"
- }), (h = _.value) === null || h === void 0 || h.forEach((x) => {
- const E = u.uid !== void 0 ? "uid" : "name";
- x[E] === u[E] && !Object.isFrozen(x) && (x.status = "removed");
- }), (C = b.value) === null || C === void 0 || C.abort(u), L(u, P));
- });
- }, j = (c) => {
- var u;
- l.value = c.type, c.type === "drop" && ((u = e.onDrop) === null || u === void 0 || u.call(e, c));
- };
- i({
- onBatchStart: v,
- onSuccess: $,
- onProgress: I,
- onError: D,
- fileList: _,
- upload: b
- });
- const [A] = pt("Upload", ft.Upload, oe(() => e.locale)), M = (c, u) => {
- const {
- removeIcon: p,
- previewIcon: f,
- downloadIcon: h,
- previewFile: C,
- onPreview: P,
- onDownload: x,
- isImageUrl: E,
- progress: q,
- itemRender: K,
- iconRender: X,
- showUploadList: H
- } = e, {
- showDownloadIcon: W,
- showPreviewIcon: Z,
- showRemoveIcon: de
- } = typeof H == "boolean" ? {} : H;
- return H ? m(Yt, {
- prefixCls: r.value,
- listType: e.listType,
- items: _.value,
- previewFile: C,
- onPreview: P,
- onDownload: x,
- onRemove: U,
- showRemoveIcon: !R.value && de,
- showPreviewIcon: Z,
- showDownloadIcon: W,
- removeIcon: p,
- previewIcon: f,
- downloadIcon: h,
- iconRender: X,
- locale: A.value,
- isImageUrl: E,
- progress: q,
- itemRender: K,
- appendActionVisible: u,
- appendAction: c
- }, S({}, n)) : c == null ? void 0 : c();
- };
- return () => {
- var c, u, p;
- const {
- listType: f,
- type: h
- } = e, {
- class: C,
- style: P
- } = o, x = ln(o, ["class", "style"]), E = S(S(S({
- onBatchStart: v,
- onError: D,
- onProgress: I,
- onSuccess: $
- }, x), e), {
- id: (c = e.id) !== null && c !== void 0 ? c : a.id.value,
- prefixCls: r.value,
- beforeUpload: d,
- onChange: void 0,
- disabled: R.value
- });
- delete E.remove, (!n.default || R.value) && delete E.id;
- const q = {
- [`${r.value}-rtl`]: s.value === "rtl"
- };
- if (h === "drag") {
- const W = k(r.value, {
- [`${r.value}-drag`]: !0,
- [`${r.value}-drag-uploading`]: _.value.some((Z) => Z.status === "uploading"),
- [`${r.value}-drag-hover`]: l.value === "dragover",
- [`${r.value}-disabled`]: R.value,
- [`${r.value}-rtl`]: s.value === "rtl"
- }, o.class, g.value);
- return F(m("span", O(O({}, o), {}, {
- class: k(`${r.value}-wrapper`, q, C, g.value)
- }), [m("div", {
- class: W,
- onDrop: j,
- onDragover: j,
- onDragleave: j,
- style: o.style
- }, [m(Ce, O(O({}, E), {}, {
- ref: b,
- class: `${r.value}-btn`
- }), O({
- default: () => [m("div", {
- class: `${r.value}-drag-container`
- }, [(u = n.default) === null || u === void 0 ? void 0 : u.call(n)])]
- }, n))]), M()]));
- }
- const K = k(r.value, {
- [`${r.value}-select`]: !0,
- [`${r.value}-select-${f}`]: !0,
- [`${r.value}-disabled`]: R.value,
- [`${r.value}-rtl`]: s.value === "rtl"
- }), X = mt((p = n.default) === null || p === void 0 ? void 0 : p.call(n)), H = (W) => m("div", {
- class: K,
- style: W
- }, [m(Ce, O(O({}, E), {}, {
- ref: b
- }), n)]);
- return F(f === "picture-card" ? m("span", O(O({}, o), {}, {
- class: k(`${r.value}-wrapper`, `${r.value}-picture-card-wrapper`, q, o.class, g.value)
- }), [M(H, !!(X && X.length))]) : m("span", O(O({}, o), {}, {
- class: k(`${r.value}-wrapper`, q, o.class, g.value)
- }), [H(X && X.length ? void 0 : {
- display: "none"
- }), M()]));
- };
- }
- });
- var Fe = function(e, t) {
- var n = {};
- for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && t.indexOf(o) < 0 && (n[o] = e[o]);
- if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var i = 0, o = Object.getOwnPropertySymbols(e); i < o.length; i++)
- t.indexOf(o[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, o[i]) && (n[o[i]] = e[o[i]]);
- return n;
- };
- const le = Y({
- compatConfig: {
- MODE: 3
- },
- name: "AUploadDragger",
- inheritAttrs: !1,
- props: Le(),
- setup(e, t) {
- let {
- slots: n,
- attrs: o
- } = t;
- return () => {
- const {
- height: i
- } = e, a = Fe(e, ["height"]), {
- style: r
- } = o, s = Fe(o, ["style"]), y = S(S(S({}, a), s), {
- type: "drag",
- style: S(S({}, r), {
- height: typeof i == "number" ? `${i}px` : i
- })
- });
- return m(ae, y, n);
- };
- }
- }), gn = le, vn = S(ae, {
- Dragger: le,
- LIST_IGNORE: ee,
- install(e) {
- return e.component(ae.name, ae), e.component(le.name, le), e;
- }
- });
- export {
- gn as U,
- vn as _
- };
|