@aplus-frontend/ui
Version:
165 lines (164 loc) • 4.69 kB
JavaScript
import { defineComponent as E, ref as d, computed as m, provide as t, createElementBlock as M, openBlock as c, normalizeClass as _, unref as r, createBlock as U, resolveDynamicComponent as O, mergeProps as j, createSlots as R, renderList as k, withCtx as z, renderSlot as A, normalizeProps as B, guardReactiveProps as D } from "vue";
import { Form as P } from "@aplus-frontend/antdv";
import "../../config-provider/index.mjs";
import "./components/MultipleFile.vue.mjs";
import "./components/Picture.vue.mjs";
import "./components/SingleFile.vue.mjs";
import { injectLocaleToOss as $ } from "./hooks/useOss.mjs";
import T from "./style/index.mjs";
import { injectLocaleToAccept as I } from "./utils/accept.mjs";
import { useLocale as L } from "../../config-provider/hooks/use-locale.mjs";
import { useNamespace as q } from "../../config-provider/hooks/use-namespace.mjs";
import V from "./components/Picture.vue2.mjs";
import G from "./components/MultipleFile.vue2.mjs";
import H from "./components/SingleFile.vue2.mjs";
import { useGlobalConfig as J } from "../../config-provider/hooks/use-global-config.mjs";
const K = ["id"], de = /* @__PURE__ */ E({
name: "AplusFileUpload",
__name: "apUpload",
props: {
dirName: {
type: String,
default: void 0
},
type: {
type: String,
default: "singleFile"
},
value: {
type: [String, Object, Array],
default: void 0
},
needName: {
type: [Boolean, Object],
default: void 0
},
accept: {
type: String,
default: void 0
},
maxSize: {
type: Number,
default: void 0
},
title: {
type: String,
default: ""
},
subTitle: {
type: [String, Object, null],
default: ""
},
maxCount: {
type: Number,
default: void 0
},
beforeUpload: {
type: Function,
default: void 0
},
customRequest: {
type: Function,
default: void 0
},
getOssAccess: {
type: Function,
default: void 0
},
onChange: {
type: Function,
default: void 0
},
maxSizeErrorMsg: {
type: String,
default: void 0
},
maxCountErrorMsg: {
type: String,
default: void 0
},
acceptErrorMsg: {
type: String,
default: void 0
},
onRemove: {
type: Function,
default: void 0
},
showUploadErrorMsg: {
type: Boolean,
default: !0
},
baseDirName: {
type: String,
default: "Frontend-Upload"
},
bucket: {
type: String,
default: void 0
},
showDownload: {
type: [Boolean, Object],
default: !0
},
showPreview: {
type: [Boolean, Object],
default: !0
}
},
emits: ["update:value"],
setup(f, { expose: g, emit: v }) {
const { t: n, lang: y } = L();
I(n), $(n, y);
const { b } = q("ap-upload"), C = T("ap-upload"), s = d(null), e = f, S = v, h = {
singleFile: H,
multipleFile: G,
picture: V
}, i = P.useInjectFormItemContext(), w = m({
get() {
return e.value;
},
set(o) {
S("update:value", o), i?.onFieldChange(), e.onChange?.(o);
}
}), a = J("apUpload");
t("value", w), t("dirName", e.dirName ?? a.value?.dirName), t(
"needName",
e.needName ?? a.value?.needName ?? !1
), t("accept", e.accept ?? a.value?.accept ?? ""), t("maxSize", e.maxSize), t("title", e.title), t("subTitle", e.subTitle), t("maxCount", e.maxCount), t("beforeUpload", e.beforeUpload), t("customRequest", e.customRequest), t("baseDirName", e.baseDirName ?? "Frontend-Upload"), t(
"getOssAccess",
e.getOssAccess ?? a.value?.getOssAccess
), t("maxSizeErrorMsg", e.maxSizeErrorMsg), t("maxCountErrorMsg", e.maxCountErrorMsg), t("acceptErrorMsg", e.acceptErrorMsg), t("onRemove", e.onRemove), t("showUploadErrorMsg", e.showUploadErrorMsg), t("bucket", e.bucket), t("showDownload", e.showDownload), t("showPreview", e.showPreview);
const x = m(() => l.value === 0), l = d(0);
t("uploadingCount", l);
function F() {
u(void 0);
}
function u(o) {
s?.value?.setValue?.(o);
}
return g({
done: x,
clear: F,
setValue: u
}), (o, Q) => (c(), M("div", {
id: r(i)?.id.value,
class: _([r(b)(), r(C)])
}, [
(c(), U(O(h[e.type]), j(o.$attrs, {
ref_key: "uploadRef",
ref: s
}), R({ _: 2 }, [
k(Object.keys(o.$slots), (p) => ({
name: p,
fn: z((N) => [
A(o.$slots, p, B(D(N || {})))
])
}))
]), 1040))
], 10, K));
}
});
export {
de as default
};