You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
12 KiB

{"ast":null,"code":"import '../../../utils/index.mjs';\nimport { ajaxUpload } from './ajax.mjs';\nimport { buildProps, definePropType } from '../../../utils/vue/props/runtime.mjs';\nimport { mutable } from '../../../utils/typescript.mjs';\nimport { NOOP } from '@vue/shared';\nconst uploadListTypes = [\"text\", \"picture\", \"picture-card\"];\nlet fileId = 1;\nconst genFileId = () => Date.now() + fileId++;\nconst uploadBaseProps = buildProps({\n action: {\n type: String,\n default: \"#\"\n },\n headers: {\n type: definePropType(Object)\n },\n method: {\n type: String,\n default: \"post\"\n },\n data: {\n type: definePropType([Object, Function, Promise]),\n default: () => mutable({})\n },\n multiple: Boolean,\n name: {\n type: String,\n default: \"file\"\n },\n drag: Boolean,\n withCredentials: Boolean,\n showFileList: {\n type: Boolean,\n default: true\n },\n accept: {\n type: String,\n default: \"\"\n },\n fileList: {\n type: definePropType(Array),\n default: () => mutable([])\n },\n autoUpload: {\n type: Boolean,\n default: true\n },\n listType: {\n type: String,\n values: uploadListTypes,\n default: \"text\"\n },\n httpRequest: {\n type: definePropType(Function),\n default: ajaxUpload\n },\n disabled: Boolean,\n limit: Number\n});\nconst uploadProps = buildProps({\n ...uploadBaseProps,\n beforeUpload: {\n type: definePropType(Function),\n default: NOOP\n },\n beforeRemove: {\n type: definePropType(Function)\n },\n onRemove: {\n type: definePropType(Function),\n default: NOOP\n },\n onChange: {\n type: definePropType(Function),\n default: NOOP\n },\n onPreview: {\n type: definePropType(Function),\n default: NOOP\n },\n onSuccess: {\n type: definePropType(Function),\n default: NOOP\n },\n onProgress: {\n type: definePropType(Function),\n default: NOOP\n },\n onError: {\n type: definePropType(Function),\n default: NOOP\n },\n onExceed: {\n type: definePropType(Function),\n default: NOOP\n },\n crossorigin: {\n type: definePropType(String)\n }\n});\nexport { genFileId, uploadBaseProps, uploadListTypes, uploadProps };","map":{"version":3,"names":["uploadListTypes","fileId","genFileId","Date","now","uploadBaseProps","buildProps","action","type","String","default","headers","definePropType","Object","method","data","Function","Promise","mutable","multiple","Boolean","name","drag","withCredentials","showFileList","accept","fileList","Array","autoUpload","listType","values","httpRequest","ajaxUpload","disabled","limit","Number","uploadProps","beforeUpload","NOOP","beforeRemove","onRemove","onChange","onPreview","onSuccess","onProgress","onError","onExceed","crossorigin"],"sources":["../../../../../../packages/components/upload/src/upload.ts"],"sourcesContent":["import { NOOP, buildProps, definePropType, mutable } from '@element-plus/utils'\nimport { ajaxUpload } from './ajax'\nimport type { Awaitable, Mutable } from '@element-plus/utils'\n\nimport type { UploadAjaxError } from './ajax'\nimport type { ExtractPropTypes } from 'vue'\nimport type Upload from './upload.vue'\n\nexport const uploadListTypes = ['text', 'picture', 'picture-card'] as const\n\nlet fileId = 1\nexport const genFileId = () => Date.now() + fileId++\n\nexport type UploadStatus = 'ready' | 'uploading' | 'success' | 'fail'\nexport interface UploadProgressEvent extends ProgressEvent {\n percent: number\n}\n\nexport interface UploadRequestOptions {\n action: string\n method: string\n data: Record<string, string | Blob | [string | Blob, string]>\n filename: string\n file: UploadRawFile\n headers: Headers | Record<string, string | number | null | undefined>\n onError: (evt: UploadAjaxError) => void\n onProgress: (evt: UploadProgressEvent) => void\n onSuccess: (response: any) => void\n withCredentials: boolean\n}\nexport interface UploadFile {\n name: string\n percentage?: number\n status: UploadStatus\n size?: number\n response?: unknown\n uid: number\n url?: string\n raw?: UploadRawFile\n}\nexport type UploadUserFile = Omit<UploadFile, 'status' | 'uid'> &\n Partial<Pick<UploadFile, 'status' | 'uid'>>\n\nexport type UploadFiles = UploadFile[]\nexport interface UploadRawFile extends File {\n uid: number\n}\nexport type UploadRequestHandler = (\n options: UploadRequestOptions\n) => XMLHttpRequest | Promise<unknown>\nexport interface UploadHooks {\n beforeUpload: (\n rawFile: UploadRawFile\n ) => Awaitable<void | undefined | null | boolean | File | Blob>\n beforeRemove: (\n uploadFile: UploadFile,\n uploadFiles: UploadFiles\n ) => Awaitable<boolean>\n onRemove: (uploadFile: UploadFile, uploadFiles: UploadFiles) => void\n onChange: (uploadFile: UploadFile, uploadFiles: UploadFiles) => void\n onPreview: (uploadFile: UploadFile) => void\n onSuccess: (\n response: any,\n uploadFile: UploadFile,\n uploadFiles: UploadFiles\n ) => void\n onProgress: (\n evt: UploadProgressEvent,\n uploadFile: UploadFile,\n uploadFiles: UploadFiles\n ) => void\n onError: (\n error: Error,\n uploadFile: UploadFile,\n uploadFiles: UploadFiles\n ) => void\n onExceed: (files: File[], uploadFiles: UploadUserFile[]) => void\n}\n\nexport type UploadData = Mutable<Record<string, any>>\n\nexport const uploadBaseProps = buildProps({\n /**\n * @description request URL\n */\n action: {\n type: String,\n default: '#',\n },\n /**\n * @description request headers\n */\n headers: {\n type: definePropType<Headers | Record<string, any>>(Object),\n },\n /**\n * @description set upload request method\n */\n method: {\n type: String,\n default: 'post',\n },\n /**\n * @description additions options of request\n */\n data: {\n type: definePropType<\n | Awaitable<UploadData>\n | ((rawFile: UploadRawFile) => Awaitable<UploadData>)\n >([Object, Function, Promise]),\n default: () => mutable({} as const),\n },\n /**\n * @description whether uploading multiple files is permitted\n */\n multiple: Boolean,\n /**\n * @description key name for uploaded file\n */\n name: {\n type: String,\n default: 'file',\n },\n /**\n * @description whether to activate drag and drop mode\n */\n drag: Boolean,\n /**\n * @description whether cookies are sent\n */\n withCredentials: Boolean,\n /**\n * @description whether to show the uploaded file list\n */\n showFileList: {\n type: Boolean,\n default: true,\n },\n /**\n * @description accepted [file types](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-accept), will not work when `thumbnail-mode === true`\n */\n accept: {\n type: String,\n default: '',\n },\n /**\n * @description default uploaded files\n */\n fileList: {\n type: definePropType<UploadUserFile[]>(Array),\n default: () => mutable([] as const),\n },\n /**\n * @description whether to auto upload file\n */\n autoUpload: {\n type: Boolean,\n default: true,\n },\n /**\n * @description type of file list\n */\n listType: {\n type: String,\n values: uploadListTypes,\n default: 'text',\n },\n /**\n * @description override default xhr behavior, allowing you to implement your own upload-file's request\n */\n httpRequest: {\n type: definePropType<UploadRequestHandler>(Function),\n default: ajaxUpload,\n },\n /**\n * @description whether to disable upload\n */\n disabled: Boolean,\n /**\n * @description maximum number of uploads allowed\n */\n limit: Number,\n} as const)\n\nexport const uploadProps = buildProps({\n ...uploadBaseProps,\n /**\n * @description hook function before uploading with the file to be uploaded as its parameter. If `false` is returned or a `Promise` is returned and then is rejected, uploading will be aborted\n */\n beforeUpload: {\n type: definePropType<UploadHooks['beforeUpload']>(Function),\n default: NOOP,\n },\n /**\n * @description hook function before removing a file with the file and file list as its parameters. If `false` is returned or a `Promise` is returned and then is rejected, removing will be aborted\n */\n beforeRemove: {\n type: definePropType<UploadHooks['beforeRemove']>(Function),\n },\n /**\n * @description hook function when files are removed\n */\n onRemove: {\n type: definePropType<UploadHooks['onRemove']>(Function),\n default: NOOP,\n },\n /**\n * @description hook function when select file or upload file success or upload file fail\n */\n onChange: {\n type: definePropType<UploadHooks['onChange']>(Function),\n default: NOOP,\n },\n /**\n * @description hook function when clicking the uploaded files\n */\n onPreview: {\n type: definePropType<UploadHooks['onPreview']>(Function),\n default: NOOP,\n },\n /**\n * @description hook function when uploaded successfully\n */\n onSuccess: {\n type: definePropType<UploadHooks['onSuccess']>(Function),\n default: NOOP,\n },\n /**\n * @description hook function when some progress occurs\n */\n onProgress: {\n type: definePropType<UploadHooks['onProgress']>(Function),\n default: NOOP,\n },\n /**\n * @description hook function when some errors occurs\n */\n onError: {\n type: definePropType<UploadHooks['onError']>(Function),\n default: NOOP,\n },\n /**\n * @description hook function when limit is exceeded\n */\n onExceed: {\n type: definePropType<UploadHooks['onExceed']>(Function),\n default: NOOP,\n },\n /**\n * @description set HTML attribute: crossorigin.\n */\n crossorigin: {\n type: definePropType<'anonymous' | 'use-credentials' | ''>(String),\n },\n} as const)\n\nexport type UploadProps = ExtractPropTypes<typeof uploadProps>\n\nexport type UploadInstance = InstanceType<typeof Upload>\n"],"mappings":";;;;;AAEY,M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