yanzhen-design-vue
Version:
78 lines (77 loc) • 2.35 kB
JavaScript
import { propsSeparate, buildProps, definePropType, buildEmits } from "@yanzhen-libs/utils-vue";
import { apiProviderBaseProps } from "@yanzhen-lowcode/core";
import "../../../constants/index.mjs";
import "../../../hooks/index.mjs";
import { uploadProps as uploadProps$1 } from "ant-design-vue/es/upload/interface";
import "../../text-preview/index.mjs";
import { uploadStyleType, uploadListType, uploadType } from "./constants/listType.mjs";
import { defaultPreviewConfig } from "./hooks/use-preview-config.mjs";
import { useNamespace } from "../../../hooks/use-namespace/index.mjs";
import { textPreviewProps } from "../../text-preview/src/text-preview.mjs";
import { UPDATE_MODEL_EVENT, UPDATE_VALUE_EVENT } from "../../../constants/event.mjs";
const ns = useNamespace("upload");
const uploadOptions = {
ns,
class: ns.b(),
name: ns.defineVNodeName()
};
const uploadName = uploadOptions.name;
const uploadPreviewName = ns.defineVNodeName("preview");
const AntUpload = propsSeparate(uploadProps$1());
const uploadProps = buildProps({
...apiProviderBaseProps,
...AntUpload.props,
...textPreviewProps,
// 这里的 value 单选是图片url, 多选时是 [url1,url2]
modelValue: definePropType([String, Array]),
value: definePropType([String, Array]),
fileList: definePropType([String, Array]),
// 模式:编辑 edit 预览 view
mode: {
type: String,
default: "edit"
},
styleType: {
type: definePropType(String),
default: uploadStyleType[0]
},
listType: {
type: definePropType(String),
default: uploadListType[0]
},
accept: definePropType([String, Array]),
uploadType: {
type: definePropType(String),
values: uploadType,
default: uploadType[0]
},
uploadDesc: String,
max: Number,
maxMsg: String,
maxSize: [String, Number],
maxSizeMsg: String,
defaultMaxSize: {
type: Number,
default: 20
},
// 预览配置
previewConfig: {
type: definePropType(Object),
default: () => defaultPreviewConfig()
}
});
const uploadEmits = buildEmits({
...AntUpload.emits,
[UPDATE_MODEL_EVENT]: AntUpload.emits["update:fileList"],
[UPDATE_VALUE_EVENT]: AntUpload.emits["update:fileList"],
uploaded: (_value) => true,
close: (e) => true
});
export {
AntUpload,
uploadEmits,
uploadName,
uploadOptions,
uploadPreviewName,
uploadProps
};