@element-plus/nightly 0.0.20220302 → 0.0.20220305

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (399) hide show
  1. package/README.md +1 -1
  2. package/attributes.json +1 -1
  3. package/dist/index.css +1 -1
  4. package/dist/index.full.js +1525 -1916
  5. package/dist/index.full.min.js +11 -11
  6. package/dist/index.full.min.js.map +1 -1
  7. package/dist/index.full.min.mjs +11 -11
  8. package/dist/index.full.min.mjs.map +1 -1
  9. package/dist/index.full.mjs +1516 -1917
  10. package/dist/locale/af.js +1 -1
  11. package/dist/locale/af.min.js +1 -1
  12. package/dist/locale/af.min.mjs +1 -1
  13. package/dist/locale/af.mjs +1 -1
  14. package/dist/locale/ar.js +1 -1
  15. package/dist/locale/ar.min.js +1 -1
  16. package/dist/locale/ar.min.mjs +1 -1
  17. package/dist/locale/ar.mjs +1 -1
  18. package/dist/locale/bg.js +1 -1
  19. package/dist/locale/bg.min.js +1 -1
  20. package/dist/locale/bg.min.mjs +1 -1
  21. package/dist/locale/bg.mjs +1 -1
  22. package/dist/locale/bn.js +1 -1
  23. package/dist/locale/bn.min.js +1 -1
  24. package/dist/locale/bn.min.mjs +1 -1
  25. package/dist/locale/bn.mjs +1 -1
  26. package/dist/locale/ca.js +1 -1
  27. package/dist/locale/ca.min.js +1 -1
  28. package/dist/locale/ca.min.mjs +1 -1
  29. package/dist/locale/ca.mjs +1 -1
  30. package/dist/locale/cs.js +1 -1
  31. package/dist/locale/cs.min.js +1 -1
  32. package/dist/locale/cs.min.mjs +1 -1
  33. package/dist/locale/cs.mjs +1 -1
  34. package/dist/locale/da.js +1 -1
  35. package/dist/locale/da.min.js +1 -1
  36. package/dist/locale/da.min.mjs +1 -1
  37. package/dist/locale/da.mjs +1 -1
  38. package/dist/locale/de.js +1 -1
  39. package/dist/locale/de.min.js +1 -1
  40. package/dist/locale/de.min.mjs +1 -1
  41. package/dist/locale/de.mjs +1 -1
  42. package/dist/locale/el.js +1 -1
  43. package/dist/locale/el.min.js +1 -1
  44. package/dist/locale/el.min.mjs +1 -1
  45. package/dist/locale/el.mjs +1 -1
  46. package/dist/locale/en.js +1 -1
  47. package/dist/locale/en.min.js +1 -1
  48. package/dist/locale/en.min.mjs +1 -1
  49. package/dist/locale/en.mjs +1 -1
  50. package/dist/locale/eo.js +1 -1
  51. package/dist/locale/eo.min.js +1 -1
  52. package/dist/locale/eo.min.mjs +1 -1
  53. package/dist/locale/eo.mjs +1 -1
  54. package/dist/locale/es.js +1 -1
  55. package/dist/locale/es.min.js +1 -1
  56. package/dist/locale/es.min.mjs +1 -1
  57. package/dist/locale/es.mjs +1 -1
  58. package/dist/locale/et.js +1 -1
  59. package/dist/locale/et.min.js +1 -1
  60. package/dist/locale/et.min.mjs +1 -1
  61. package/dist/locale/et.mjs +1 -1
  62. package/dist/locale/eu.js +1 -1
  63. package/dist/locale/eu.min.js +1 -1
  64. package/dist/locale/eu.min.mjs +1 -1
  65. package/dist/locale/eu.mjs +1 -1
  66. package/dist/locale/fa.js +1 -1
  67. package/dist/locale/fa.min.js +1 -1
  68. package/dist/locale/fa.min.mjs +1 -1
  69. package/dist/locale/fa.mjs +1 -1
  70. package/dist/locale/fi.js +1 -1
  71. package/dist/locale/fi.min.js +1 -1
  72. package/dist/locale/fi.min.mjs +1 -1
  73. package/dist/locale/fi.mjs +1 -1
  74. package/dist/locale/fr.js +1 -1
  75. package/dist/locale/fr.min.js +1 -1
  76. package/dist/locale/fr.min.mjs +1 -1
  77. package/dist/locale/fr.mjs +1 -1
  78. package/dist/locale/he.js +1 -1
  79. package/dist/locale/he.min.js +1 -1
  80. package/dist/locale/he.min.mjs +1 -1
  81. package/dist/locale/he.mjs +1 -1
  82. package/dist/locale/hr.js +1 -1
  83. package/dist/locale/hr.min.js +1 -1
  84. package/dist/locale/hr.min.mjs +1 -1
  85. package/dist/locale/hr.mjs +1 -1
  86. package/dist/locale/hu.js +1 -1
  87. package/dist/locale/hu.min.js +1 -1
  88. package/dist/locale/hu.min.mjs +1 -1
  89. package/dist/locale/hu.mjs +1 -1
  90. package/dist/locale/hy-am.js +1 -1
  91. package/dist/locale/hy-am.min.js +1 -1
  92. package/dist/locale/hy-am.min.mjs +1 -1
  93. package/dist/locale/hy-am.mjs +1 -1
  94. package/dist/locale/id.js +1 -1
  95. package/dist/locale/id.min.js +1 -1
  96. package/dist/locale/id.min.mjs +1 -1
  97. package/dist/locale/id.mjs +1 -1
  98. package/dist/locale/it.js +1 -1
  99. package/dist/locale/it.min.js +1 -1
  100. package/dist/locale/it.min.mjs +1 -1
  101. package/dist/locale/it.mjs +1 -1
  102. package/dist/locale/ja.js +1 -1
  103. package/dist/locale/ja.min.js +1 -1
  104. package/dist/locale/ja.min.mjs +1 -1
  105. package/dist/locale/ja.mjs +1 -1
  106. package/dist/locale/kk.js +1 -1
  107. package/dist/locale/kk.min.js +1 -1
  108. package/dist/locale/kk.min.mjs +1 -1
  109. package/dist/locale/kk.mjs +1 -1
  110. package/dist/locale/km.js +1 -1
  111. package/dist/locale/km.min.js +1 -1
  112. package/dist/locale/km.min.mjs +1 -1
  113. package/dist/locale/km.mjs +1 -1
  114. package/dist/locale/ko.js +1 -1
  115. package/dist/locale/ko.min.js +1 -1
  116. package/dist/locale/ko.min.mjs +1 -1
  117. package/dist/locale/ko.mjs +1 -1
  118. package/dist/locale/ku.js +1 -1
  119. package/dist/locale/ku.min.js +1 -1
  120. package/dist/locale/ku.min.mjs +1 -1
  121. package/dist/locale/ku.mjs +1 -1
  122. package/dist/locale/ky.js +1 -1
  123. package/dist/locale/ky.min.js +1 -1
  124. package/dist/locale/ky.min.mjs +1 -1
  125. package/dist/locale/ky.mjs +1 -1
  126. package/dist/locale/lt.js +1 -1
  127. package/dist/locale/lt.min.js +1 -1
  128. package/dist/locale/lt.min.mjs +1 -1
  129. package/dist/locale/lt.mjs +1 -1
  130. package/dist/locale/lv.js +1 -1
  131. package/dist/locale/lv.min.js +1 -1
  132. package/dist/locale/lv.min.mjs +1 -1
  133. package/dist/locale/lv.mjs +1 -1
  134. package/dist/locale/mg.js +1 -1
  135. package/dist/locale/mg.min.js +1 -1
  136. package/dist/locale/mg.min.mjs +1 -1
  137. package/dist/locale/mg.mjs +1 -1
  138. package/dist/locale/mn.js +1 -1
  139. package/dist/locale/mn.min.js +1 -1
  140. package/dist/locale/mn.min.mjs +1 -1
  141. package/dist/locale/mn.mjs +1 -1
  142. package/dist/locale/nb-no.js +1 -1
  143. package/dist/locale/nb-no.min.js +1 -1
  144. package/dist/locale/nb-no.min.mjs +1 -1
  145. package/dist/locale/nb-no.mjs +1 -1
  146. package/dist/locale/nl.js +1 -1
  147. package/dist/locale/nl.min.js +1 -1
  148. package/dist/locale/nl.min.mjs +1 -1
  149. package/dist/locale/nl.mjs +1 -1
  150. package/dist/locale/pa.js +1 -1
  151. package/dist/locale/pa.min.js +1 -1
  152. package/dist/locale/pa.min.mjs +1 -1
  153. package/dist/locale/pa.mjs +1 -1
  154. package/dist/locale/pl.js +1 -1
  155. package/dist/locale/pl.min.js +1 -1
  156. package/dist/locale/pl.min.mjs +1 -1
  157. package/dist/locale/pl.mjs +1 -1
  158. package/dist/locale/pt-br.js +1 -1
  159. package/dist/locale/pt-br.min.js +1 -1
  160. package/dist/locale/pt-br.min.mjs +1 -1
  161. package/dist/locale/pt-br.mjs +1 -1
  162. package/dist/locale/pt.js +1 -1
  163. package/dist/locale/pt.min.js +1 -1
  164. package/dist/locale/pt.min.mjs +1 -1
  165. package/dist/locale/pt.mjs +1 -1
  166. package/dist/locale/ro.js +1 -1
  167. package/dist/locale/ro.min.js +1 -1
  168. package/dist/locale/ro.min.mjs +1 -1
  169. package/dist/locale/ro.mjs +1 -1
  170. package/dist/locale/ru.js +1 -1
  171. package/dist/locale/ru.min.js +1 -1
  172. package/dist/locale/ru.min.mjs +1 -1
  173. package/dist/locale/ru.mjs +1 -1
  174. package/dist/locale/sk.js +1 -1
  175. package/dist/locale/sk.min.js +1 -1
  176. package/dist/locale/sk.min.mjs +1 -1
  177. package/dist/locale/sk.mjs +1 -1
  178. package/dist/locale/sl.js +1 -1
  179. package/dist/locale/sl.min.js +1 -1
  180. package/dist/locale/sl.min.mjs +1 -1
  181. package/dist/locale/sl.mjs +1 -1
  182. package/dist/locale/sr.js +1 -1
  183. package/dist/locale/sr.min.js +1 -1
  184. package/dist/locale/sr.min.mjs +1 -1
  185. package/dist/locale/sr.mjs +1 -1
  186. package/dist/locale/sv.js +1 -1
  187. package/dist/locale/sv.min.js +1 -1
  188. package/dist/locale/sv.min.mjs +1 -1
  189. package/dist/locale/sv.mjs +1 -1
  190. package/dist/locale/ta.js +1 -1
  191. package/dist/locale/ta.min.js +1 -1
  192. package/dist/locale/ta.min.mjs +1 -1
  193. package/dist/locale/ta.mjs +1 -1
  194. package/dist/locale/th.js +1 -1
  195. package/dist/locale/th.min.js +1 -1
  196. package/dist/locale/th.min.mjs +1 -1
  197. package/dist/locale/th.mjs +1 -1
  198. package/dist/locale/tk.js +1 -1
  199. package/dist/locale/tk.min.js +1 -1
  200. package/dist/locale/tk.min.mjs +1 -1
  201. package/dist/locale/tk.mjs +1 -1
  202. package/dist/locale/tr.js +1 -1
  203. package/dist/locale/tr.min.js +1 -1
  204. package/dist/locale/tr.min.mjs +1 -1
  205. package/dist/locale/tr.mjs +1 -1
  206. package/dist/locale/ug-cn.js +1 -1
  207. package/dist/locale/ug-cn.min.js +1 -1
  208. package/dist/locale/ug-cn.min.mjs +1 -1
  209. package/dist/locale/ug-cn.mjs +1 -1
  210. package/dist/locale/uk.js +1 -1
  211. package/dist/locale/uk.min.js +1 -1
  212. package/dist/locale/uk.min.mjs +1 -1
  213. package/dist/locale/uk.mjs +1 -1
  214. package/dist/locale/uz-uz.js +1 -1
  215. package/dist/locale/uz-uz.min.js +1 -1
  216. package/dist/locale/uz-uz.min.mjs +1 -1
  217. package/dist/locale/uz-uz.mjs +1 -1
  218. package/dist/locale/vi.js +1 -1
  219. package/dist/locale/vi.min.js +1 -1
  220. package/dist/locale/vi.min.mjs +1 -1
  221. package/dist/locale/vi.mjs +1 -1
  222. package/dist/locale/zh-cn.js +1 -1
  223. package/dist/locale/zh-cn.min.js +1 -1
  224. package/dist/locale/zh-cn.min.mjs +1 -1
  225. package/dist/locale/zh-cn.mjs +1 -1
  226. package/dist/locale/zh-tw.js +1 -1
  227. package/dist/locale/zh-tw.min.js +1 -1
  228. package/dist/locale/zh-tw.min.mjs +1 -1
  229. package/dist/locale/zh-tw.mjs +1 -1
  230. package/es/components/index.mjs +4 -0
  231. package/es/components/index.mjs.map +1 -1
  232. package/es/components/message-box/index.mjs +1 -0
  233. package/es/components/message-box/index.mjs.map +1 -1
  234. package/es/components/message-box/src/index.vue.d.ts +2 -2
  235. package/es/components/message-box/src/message-box.type.d.ts +4 -3
  236. package/es/components/message-box/src/messageBox.mjs +39 -56
  237. package/es/components/message-box/src/messageBox.mjs.map +1 -1
  238. package/es/components/select/index.d.ts +9 -0
  239. package/es/components/select/src/select.mjs +6 -2
  240. package/es/components/select/src/select.mjs.map +1 -1
  241. package/es/components/select/src/select.vue.d.ts +9 -0
  242. package/es/components/select-v2/index.d.ts +18 -0
  243. package/es/components/select-v2/src/defaults.d.ts +4 -0
  244. package/es/components/select-v2/src/defaults.mjs +4 -0
  245. package/es/components/select-v2/src/defaults.mjs.map +1 -1
  246. package/es/components/select-v2/src/select.mjs +3 -3
  247. package/es/components/select-v2/src/select.mjs.map +1 -1
  248. package/es/components/select-v2/src/select.vue.d.ts +9 -0
  249. package/es/components/upload/index.d.ts +807 -727
  250. package/es/components/upload/index.mjs +9 -7
  251. package/es/components/upload/index.mjs.map +1 -1
  252. package/es/components/upload/src/ajax.d.ts +8 -2
  253. package/es/components/upload/src/ajax.mjs +39 -34
  254. package/es/components/upload/src/ajax.mjs.map +1 -1
  255. package/es/components/upload/src/upload-content.d.ts +32 -0
  256. package/es/components/upload/src/upload-content.mjs +39 -0
  257. package/es/components/upload/src/upload-content.mjs.map +1 -0
  258. package/es/components/upload/src/upload-content.vue.d.ts +165 -0
  259. package/es/components/upload/src/upload-content2.mjs +172 -0
  260. package/es/components/upload/src/upload-content2.mjs.map +1 -0
  261. package/es/components/upload/src/upload-dragger.d.ts +11 -0
  262. package/es/components/upload/src/upload-dragger.mjs +11 -67
  263. package/es/components/upload/src/upload-dragger.mjs.map +1 -1
  264. package/es/components/upload/src/upload-dragger.vue.d.ts +15 -11
  265. package/es/components/upload/src/upload-dragger2.mjs +73 -0
  266. package/es/components/upload/src/upload-dragger2.mjs.map +1 -0
  267. package/es/components/upload/src/upload-list.d.ts +15 -0
  268. package/es/components/upload/src/upload-list.mjs +23 -207
  269. package/es/components/upload/src/upload-list.mjs.map +1 -1
  270. package/es/components/upload/src/upload-list.vue.d.ts +148 -44
  271. package/es/components/upload/src/upload-list2.mjs +173 -0
  272. package/es/components/upload/src/upload-list2.mjs.map +1 -0
  273. package/es/components/upload/src/upload.d.ts +97 -0
  274. package/es/components/upload/src/upload.mjs +103 -266
  275. package/es/components/upload/src/upload.mjs.map +1 -1
  276. package/es/components/upload/src/upload.vue.d.ts +830 -292
  277. package/es/components/upload/src/upload2.mjs +122 -0
  278. package/es/components/upload/src/upload2.mjs.map +1 -0
  279. package/es/components/upload/src/{useHandlers.d.ts → use-handlers.d.ts} +10 -13
  280. package/es/components/upload/src/use-handlers.mjs +142 -0
  281. package/es/components/upload/src/use-handlers.mjs.map +1 -0
  282. package/es/index.mjs +5 -0
  283. package/es/index.mjs.map +1 -1
  284. package/es/tokens/index.d.ts +1 -0
  285. package/es/tokens/index.mjs +1 -0
  286. package/es/tokens/index.mjs.map +1 -1
  287. package/es/tokens/upload.d.ts +5 -0
  288. package/es/tokens/upload.mjs +4 -0
  289. package/es/tokens/upload.mjs.map +1 -0
  290. package/es/utils/typescript.d.ts +1 -0
  291. package/es/utils/typescript.mjs.map +1 -1
  292. package/es/version.d.ts +1 -1
  293. package/es/version.mjs +1 -1
  294. package/es/version.mjs.map +1 -1
  295. package/lib/components/index.js +13 -0
  296. package/lib/components/index.js.map +1 -1
  297. package/lib/components/message-box/index.js +1 -0
  298. package/lib/components/message-box/index.js.map +1 -1
  299. package/lib/components/message-box/src/index.vue.d.ts +2 -2
  300. package/lib/components/message-box/src/message-box.type.d.ts +4 -3
  301. package/lib/components/message-box/src/messageBox.js +38 -55
  302. package/lib/components/message-box/src/messageBox.js.map +1 -1
  303. package/lib/components/select/index.d.ts +9 -0
  304. package/lib/components/select/src/select.js +6 -2
  305. package/lib/components/select/src/select.js.map +1 -1
  306. package/lib/components/select/src/select.vue.d.ts +9 -0
  307. package/lib/components/select-v2/index.d.ts +18 -0
  308. package/lib/components/select-v2/src/defaults.d.ts +4 -0
  309. package/lib/components/select-v2/src/defaults.js +4 -0
  310. package/lib/components/select-v2/src/defaults.js.map +1 -1
  311. package/lib/components/select-v2/src/select.js +3 -3
  312. package/lib/components/select-v2/src/select.js.map +1 -1
  313. package/lib/components/select-v2/src/select.vue.d.ts +9 -0
  314. package/lib/components/upload/index.d.ts +807 -727
  315. package/lib/components/upload/index.js +18 -7
  316. package/lib/components/upload/index.js.map +1 -1
  317. package/lib/components/upload/src/ajax.d.ts +8 -2
  318. package/lib/components/upload/src/ajax.js +40 -34
  319. package/lib/components/upload/src/ajax.js.map +1 -1
  320. package/lib/components/upload/src/upload-content.d.ts +32 -0
  321. package/lib/components/upload/src/upload-content.js +43 -0
  322. package/lib/components/upload/src/upload-content.js.map +1 -0
  323. package/lib/components/upload/src/upload-content.vue.d.ts +165 -0
  324. package/lib/components/upload/src/upload-content2.js +176 -0
  325. package/lib/components/upload/src/upload-content2.js.map +1 -0
  326. package/lib/components/upload/src/upload-dragger.d.ts +11 -0
  327. package/lib/components/upload/src/upload-dragger.js +12 -67
  328. package/lib/components/upload/src/upload-dragger.js.map +1 -1
  329. package/lib/components/upload/src/upload-dragger.vue.d.ts +15 -11
  330. package/lib/components/upload/src/upload-dragger2.js +77 -0
  331. package/lib/components/upload/src/upload-dragger2.js.map +1 -0
  332. package/lib/components/upload/src/upload-list.d.ts +15 -0
  333. package/lib/components/upload/src/upload-list.js +24 -207
  334. package/lib/components/upload/src/upload-list.js.map +1 -1
  335. package/lib/components/upload/src/upload-list.vue.d.ts +148 -44
  336. package/lib/components/upload/src/upload-list2.js +177 -0
  337. package/lib/components/upload/src/upload-list2.js.map +1 -0
  338. package/lib/components/upload/src/upload.d.ts +97 -0
  339. package/lib/components/upload/src/upload.js +104 -264
  340. package/lib/components/upload/src/upload.js.map +1 -1
  341. package/lib/components/upload/src/upload.vue.d.ts +830 -292
  342. package/lib/components/upload/src/upload2.js +126 -0
  343. package/lib/components/upload/src/upload2.js.map +1 -0
  344. package/lib/components/upload/src/{useHandlers.d.ts → use-handlers.d.ts} +10 -13
  345. package/lib/components/upload/src/use-handlers.js +146 -0
  346. package/lib/components/upload/src/use-handlers.js.map +1 -0
  347. package/lib/index.js +15 -0
  348. package/lib/index.js.map +1 -1
  349. package/lib/tokens/index.d.ts +1 -0
  350. package/lib/tokens/index.js +2 -0
  351. package/lib/tokens/index.js.map +1 -1
  352. package/lib/tokens/upload.d.ts +5 -0
  353. package/lib/tokens/upload.js +8 -0
  354. package/lib/tokens/upload.js.map +1 -0
  355. package/lib/utils/typescript.d.ts +1 -0
  356. package/lib/utils/typescript.js.map +1 -1
  357. package/lib/version.d.ts +1 -1
  358. package/lib/version.js +1 -1
  359. package/lib/version.js.map +1 -1
  360. package/package.json +2 -2
  361. package/tags.json +1 -1
  362. package/theme-chalk/el-cascader.css +1 -1
  363. package/theme-chalk/el-dialog.css +1 -1
  364. package/theme-chalk/el-input.css +1 -1
  365. package/theme-chalk/el-select-v2.css +1 -1
  366. package/theme-chalk/el-select.css +1 -1
  367. package/theme-chalk/el-table.css +1 -1
  368. package/theme-chalk/index.css +1 -1
  369. package/theme-chalk/src/cascader-panel.scss +1 -1
  370. package/theme-chalk/src/cascader.scss +1 -1
  371. package/theme-chalk/src/common/transition.scss +2 -2
  372. package/theme-chalk/src/common/var.scss +1 -0
  373. package/theme-chalk/src/date-picker/date-table.scss +4 -4
  374. package/theme-chalk/src/dialog.scss +1 -1
  375. package/theme-chalk/src/input.scss +12 -4
  376. package/theme-chalk/src/menu.scss +1 -1
  377. package/theme-chalk/src/option-item.scss +2 -2
  378. package/theme-chalk/src/page-header.scss +1 -1
  379. package/theme-chalk/src/pagination.scss +2 -2
  380. package/theme-chalk/src/select-v2.scss +8 -0
  381. package/theme-chalk/src/select.scss +0 -4
  382. package/theme-chalk/src/table.scss +2 -1
  383. package/web-types.json +1 -1
  384. package/es/components/upload/src/index.mjs +0 -220
  385. package/es/components/upload/src/index.mjs.map +0 -1
  386. package/es/components/upload/src/index.vue.d.ts +0 -282
  387. package/es/components/upload/src/upload.type.d.ts +0 -72
  388. package/es/components/upload/src/upload.type.mjs +0 -2
  389. package/es/components/upload/src/upload.type.mjs.map +0 -1
  390. package/es/components/upload/src/useHandlers.mjs +0 -143
  391. package/es/components/upload/src/useHandlers.mjs.map +0 -1
  392. package/lib/components/upload/src/index.js +0 -224
  393. package/lib/components/upload/src/index.js.map +0 -1
  394. package/lib/components/upload/src/index.vue.d.ts +0 -282
  395. package/lib/components/upload/src/upload.type.d.ts +0 -72
  396. package/lib/components/upload/src/upload.type.js +0 -3
  397. package/lib/components/upload/src/upload.type.js.map +0 -1
  398. package/lib/components/upload/src/useHandlers.js +0 -147
  399. package/lib/components/upload/src/useHandlers.js.map +0 -1
@@ -1,143 +0,0 @@
1
- import { ref, watch } from 'vue';
2
- import { NOOP } from '@vue/shared';
3
- import { cloneDeep } from 'lodash-unified';
4
-
5
- function getFile(rawFile, uploadFiles) {
6
- return uploadFiles.find((file) => file.uid === rawFile.uid);
7
- }
8
- function genUid(seed) {
9
- return Date.now() + seed;
10
- }
11
- var useHandlers = (props) => {
12
- const uploadFiles = ref([]);
13
- const uploadRef = ref(null);
14
- let tempIndex = 1;
15
- function abort(file) {
16
- uploadRef.value.abort(file);
17
- }
18
- function clearFiles(status = ["ready", "uploading", "success", "fail"]) {
19
- uploadFiles.value = uploadFiles.value.filter((row) => {
20
- return !status.includes(row.status);
21
- });
22
- }
23
- function handleError(err, rawFile) {
24
- const file = getFile(rawFile, uploadFiles.value);
25
- file.status = "fail";
26
- uploadFiles.value.splice(uploadFiles.value.indexOf(file), 1);
27
- props.onError(err, file, uploadFiles.value);
28
- props.onChange(file, uploadFiles.value);
29
- }
30
- function handleProgress(ev, rawFile) {
31
- const file = getFile(rawFile, uploadFiles.value);
32
- props.onProgress(ev, file, uploadFiles.value);
33
- file.status = "uploading";
34
- file.percentage = ev.percent || 0;
35
- }
36
- function handleSuccess(res, rawFile) {
37
- const file = getFile(rawFile, uploadFiles.value);
38
- if (file) {
39
- file.status = "success";
40
- file.response = res;
41
- props.onSuccess(res, file, uploadFiles.value);
42
- props.onChange(file, uploadFiles.value);
43
- }
44
- }
45
- function handleStart(rawFile) {
46
- const uid = genUid(tempIndex++);
47
- rawFile.uid = uid;
48
- const file = {
49
- name: rawFile.name,
50
- percentage: 0,
51
- status: "ready",
52
- size: rawFile.size,
53
- raw: rawFile,
54
- uid
55
- };
56
- if (props.listType === "picture-card" || props.listType === "picture") {
57
- try {
58
- file.url = URL.createObjectURL(rawFile);
59
- } catch (err) {
60
- console.error("[Element Error][Upload]", err);
61
- props.onError(err, file, uploadFiles.value);
62
- }
63
- }
64
- uploadFiles.value.push(file);
65
- props.onChange(file, uploadFiles.value);
66
- }
67
- function handleRemove(file, raw) {
68
- if (raw) {
69
- file = getFile(raw, uploadFiles.value);
70
- }
71
- const revokeObjectURL = () => {
72
- if (file.url && file.url.indexOf("blob:") === 0) {
73
- URL.revokeObjectURL(file.url);
74
- }
75
- };
76
- const doRemove = () => {
77
- abort(file);
78
- const fileList = uploadFiles.value;
79
- fileList.splice(fileList.indexOf(file), 1);
80
- props.onRemove(file, fileList);
81
- revokeObjectURL();
82
- };
83
- if (!props.beforeRemove) {
84
- doRemove();
85
- } else if (typeof props.beforeRemove === "function") {
86
- const before = props.beforeRemove(file, uploadFiles.value);
87
- if (before instanceof Promise) {
88
- before.then(() => {
89
- doRemove();
90
- }).catch(NOOP);
91
- } else if (before !== false) {
92
- doRemove();
93
- }
94
- }
95
- }
96
- function submit() {
97
- uploadFiles.value.filter((file) => file.status === "ready").forEach((file) => {
98
- uploadRef.value.upload(file.raw);
99
- });
100
- }
101
- watch(() => props.listType, (val) => {
102
- if (val === "picture-card" || val === "picture") {
103
- uploadFiles.value = uploadFiles.value.map((file) => {
104
- if (!file.url && file.raw) {
105
- try {
106
- file.url = URL.createObjectURL(file.raw);
107
- } catch (err) {
108
- props.onError(err, file, uploadFiles.value);
109
- }
110
- }
111
- return file;
112
- });
113
- }
114
- });
115
- watch(() => props.fileList, (fileList) => {
116
- uploadFiles.value = fileList.map((file) => {
117
- const cloneFile = cloneDeep(file);
118
- return {
119
- ...cloneFile,
120
- uid: file.uid || genUid(tempIndex++),
121
- status: file.status || "success"
122
- };
123
- });
124
- }, {
125
- immediate: true,
126
- deep: true
127
- });
128
- return {
129
- abort,
130
- clearFiles,
131
- handleError,
132
- handleProgress,
133
- handleStart,
134
- handleSuccess,
135
- handleRemove,
136
- submit,
137
- uploadFiles,
138
- uploadRef
139
- };
140
- };
141
-
142
- export { useHandlers as default };
143
- //# sourceMappingURL=useHandlers.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useHandlers.mjs","sources":["../../../../../../packages/components/upload/src/useHandlers.ts"],"sourcesContent":["import { ref, watch } from 'vue'\nimport { NOOP } from '@vue/shared'\nimport { cloneDeep } from 'lodash-unified'\n\n// Inline types\nimport type {\n ListType,\n UploadFile,\n UploadStatus,\n ElFile,\n ElUploadProgressEvent,\n IUseHandlersProps,\n} from './upload.type'\ntype UploadRef = {\n abort: (file: UploadFile) => void\n upload: (file: ElFile) => void\n}\n// helpers\nfunction getFile(rawFile: ElFile, uploadFiles: UploadFile[]) {\n return uploadFiles.find((file) => file.uid === rawFile.uid)\n}\n\nfunction genUid(seed: number) {\n return Date.now() + seed\n}\n\nexport default (props: IUseHandlersProps) => {\n const uploadFiles = ref<UploadFile[]>([])\n const uploadRef = ref<UploadRef>(null)\n\n let tempIndex = 1\n\n function abort(file: UploadFile) {\n uploadRef.value.abort(file)\n }\n\n function clearFiles(\n status: UploadStatus[] = ['ready', 'uploading', 'success', 'fail']\n ) {\n uploadFiles.value = uploadFiles.value.filter((row) => {\n return !status.includes(row.status)\n })\n }\n\n function handleError(err: Error, rawFile: ElFile) {\n const file = getFile(rawFile, uploadFiles.value)\n file.status = 'fail'\n uploadFiles.value.splice(uploadFiles.value.indexOf(file), 1)\n props.onError(err, file, uploadFiles.value)\n props.onChange(file, uploadFiles.value)\n }\n\n function handleProgress(ev: ElUploadProgressEvent, rawFile: ElFile) {\n const file = getFile(rawFile, uploadFiles.value)\n props.onProgress(ev, file, uploadFiles.value)\n file.status = 'uploading'\n file.percentage = ev.percent || 0\n }\n\n function handleSuccess(res: any, rawFile: ElFile) {\n const file = getFile(rawFile, uploadFiles.value)\n if (file) {\n file.status = 'success'\n file.response = res\n props.onSuccess(res, file, uploadFiles.value)\n props.onChange(file, uploadFiles.value)\n }\n }\n\n function handleStart(rawFile: ElFile) {\n const uid = genUid(tempIndex++)\n rawFile.uid = uid\n const file: UploadFile = {\n name: rawFile.name,\n percentage: 0,\n status: 'ready',\n size: rawFile.size,\n raw: rawFile,\n uid,\n }\n if (props.listType === 'picture-card' || props.listType === 'picture') {\n try {\n file.url = URL.createObjectURL(rawFile)\n } catch (err) {\n console.error('[Element Error][Upload]', err)\n props.onError(err, file, uploadFiles.value)\n }\n }\n uploadFiles.value.push(file)\n props.onChange(file, uploadFiles.value)\n }\n\n function handleRemove(file: UploadFile, raw: ElFile) {\n if (raw) {\n file = getFile(raw, uploadFiles.value)\n }\n const revokeObjectURL = () => {\n if (file.url && file.url.indexOf('blob:') === 0) {\n URL.revokeObjectURL(file.url)\n }\n }\n const doRemove = () => {\n abort(file)\n const fileList = uploadFiles.value\n fileList.splice(fileList.indexOf(file), 1)\n props.onRemove(file, fileList)\n revokeObjectURL()\n }\n if (!props.beforeRemove) {\n doRemove()\n } else if (typeof props.beforeRemove === 'function') {\n const before = props.beforeRemove(file, uploadFiles.value)\n if (before instanceof Promise) {\n before\n .then(() => {\n doRemove()\n })\n .catch(NOOP)\n } else if (before !== false) {\n doRemove()\n }\n }\n }\n\n function submit() {\n uploadFiles.value\n .filter((file) => file.status === 'ready')\n .forEach((file) => {\n uploadRef.value.upload(file.raw)\n })\n }\n\n watch(\n () => props.listType,\n (val: ListType) => {\n if (val === 'picture-card' || val === 'picture') {\n uploadFiles.value = uploadFiles.value.map((file) => {\n if (!file.url && file.raw) {\n try {\n file.url = URL.createObjectURL(file.raw)\n } catch (err) {\n props.onError(err, file, uploadFiles.value)\n }\n }\n return file\n })\n }\n }\n )\n\n watch(\n () => props.fileList,\n (fileList: UploadFile[]) => {\n uploadFiles.value = fileList.map((file) => {\n const cloneFile = cloneDeep(file)\n return {\n ...cloneFile,\n uid: file.uid || genUid(tempIndex++),\n status: file.status || 'success',\n }\n })\n },\n {\n immediate: true,\n deep: true,\n }\n )\n\n return {\n abort,\n clearFiles,\n handleError,\n handleProgress,\n handleStart,\n handleSuccess,\n handleRemove,\n submit,\n uploadFiles,\n uploadRef,\n }\n}\n"],"names":[],"mappings":";;;;AAGA,SAAS,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE;AACvC,EAAE,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAC9D,CAAC;AACD,SAAS,MAAM,CAAC,IAAI,EAAE;AACtB,EAAE,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAC3B,CAAC;AACD,kBAAe,CAAC,KAAK,KAAK;AAC1B,EAAE,MAAM,WAAW,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC;AAC9B,EAAE,MAAM,SAAS,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;AAC9B,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AK;AACL,GAAG,CAAC,CAAC;AACL,EAAE,KAAK,CAAC,MAAM,KAAK,CAAC,QAAQ,EAAE,CAAC,QAAQ,KAAK;AAC5C,IAAI,WAAW,CAAC,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK;AAC/C,MAAM,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;AACxC,MAAM,OAAO;AACb,QAAQ,GAAG,SAAS;AACpB,QAAQ,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;AAC5C,QAAQ,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,SAAS;AACxC,OAAO,CAAC;AACR,KAAK,CAAC,CAAC;AACP,GAAG,EAAE;AACL,IAAI,SAAS,EAAE,IAAI;AACnB,IAAI,IAAI,EAAE,IAAI;AACd,GAAG,CAAC,CAAC;AACL,EAAE,OAAO;AACT,IAAI,KAAK;AACT,IAAI,UAAU;AACd,IAAI,WAAW;AACf,IAAI,cAAc;AAClB,IAAI,WAAW;AACf,IAAI,aAAa;AACjB,IAAI,YAAY;AAChB,IAAI,MAAM;AACV,IAAI,WAAW;AACf,IAAI,SAAS;AACb,GAAG,CAAC;AACJ,CAAC;;;;"}
@@ -1,224 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var vue = require('vue');
6
- var shared = require('@vue/shared');
7
- require('../../../tokens/index.js');
8
- var ajax = require('./ajax.js');
9
- var uploadList = require('./upload-list.js');
10
- var upload = require('./upload.js');
11
- var useHandlers = require('./useHandlers.js');
12
- var form = require('../../../tokens/form.js');
13
-
14
- const _sfc_main = vue.defineComponent({
15
- name: "ElUpload",
16
- components: {
17
- Upload: upload["default"],
18
- UploadList: uploadList["default"]
19
- },
20
- props: {
21
- action: {
22
- type: String,
23
- required: true
24
- },
25
- headers: {
26
- type: Object,
27
- default: () => ({})
28
- },
29
- method: {
30
- type: String,
31
- default: "post"
32
- },
33
- data: {
34
- type: Object,
35
- default: () => ({})
36
- },
37
- multiple: {
38
- type: Boolean,
39
- default: false
40
- },
41
- name: {
42
- type: String,
43
- default: "file"
44
- },
45
- drag: {
46
- type: Boolean,
47
- default: false
48
- },
49
- withCredentials: Boolean,
50
- showFileList: {
51
- type: Boolean,
52
- default: true
53
- },
54
- accept: {
55
- type: String,
56
- default: ""
57
- },
58
- type: {
59
- type: String,
60
- default: "select"
61
- },
62
- beforeUpload: {
63
- type: Function,
64
- default: shared.NOOP
65
- },
66
- beforeRemove: {
67
- type: Function,
68
- default: shared.NOOP
69
- },
70
- onRemove: {
71
- type: Function,
72
- default: shared.NOOP
73
- },
74
- onChange: {
75
- type: Function,
76
- default: shared.NOOP
77
- },
78
- onPreview: {
79
- type: Function,
80
- default: shared.NOOP
81
- },
82
- onSuccess: {
83
- type: Function,
84
- default: shared.NOOP
85
- },
86
- onProgress: {
87
- type: Function,
88
- default: shared.NOOP
89
- },
90
- onError: {
91
- type: Function,
92
- default: shared.NOOP
93
- },
94
- fileList: {
95
- type: Array,
96
- default: () => {
97
- return [];
98
- }
99
- },
100
- autoUpload: {
101
- type: Boolean,
102
- default: true
103
- },
104
- listType: {
105
- type: String,
106
- default: "text"
107
- },
108
- httpRequest: {
109
- type: Function,
110
- default: ajax["default"]
111
- },
112
- disabled: Boolean,
113
- limit: {
114
- type: Number,
115
- default: null
116
- },
117
- onExceed: {
118
- type: Function,
119
- default: () => shared.NOOP
120
- }
121
- },
122
- setup(props) {
123
- const elForm = vue.inject(form.elFormKey, {});
124
- const uploadDisabled = vue.computed(() => {
125
- return props.disabled || elForm.disabled;
126
- });
127
- const {
128
- abort,
129
- clearFiles,
130
- handleError,
131
- handleProgress,
132
- handleStart,
133
- handleSuccess,
134
- handleRemove,
135
- submit,
136
- uploadRef,
137
- uploadFiles
138
- } = useHandlers["default"](props);
139
- vue.provide("uploader", vue.getCurrentInstance());
140
- vue.onBeforeUnmount(() => {
141
- uploadFiles.value.forEach((file) => {
142
- if (file.url && file.url.indexOf("blob:") === 0) {
143
- URL.revokeObjectURL(file.url);
144
- }
145
- });
146
- });
147
- return {
148
- abort,
149
- dragOver: vue.ref(false),
150
- draging: vue.ref(false),
151
- handleError,
152
- handleProgress,
153
- handleRemove,
154
- handleStart,
155
- handleSuccess,
156
- uploadDisabled,
157
- uploadFiles,
158
- uploadRef,
159
- submit,
160
- clearFiles
161
- };
162
- },
163
- render() {
164
- var _a, _b;
165
- let uploadList$1;
166
- if (this.showFileList) {
167
- uploadList$1 = vue.h(uploadList["default"], {
168
- disabled: this.uploadDisabled,
169
- listType: this.listType,
170
- files: this.uploadFiles,
171
- onRemove: this.handleRemove,
172
- handlePreview: this.onPreview
173
- }, this.$slots.file ? {
174
- default: (props) => {
175
- return this.$slots.file({
176
- file: props.file
177
- });
178
- }
179
- } : null);
180
- } else {
181
- uploadList$1 = null;
182
- }
183
- const uploadData = {
184
- type: this.type,
185
- drag: this.drag,
186
- action: this.action,
187
- multiple: this.multiple,
188
- "before-upload": this.beforeUpload,
189
- "with-credentials": this.withCredentials,
190
- headers: this.headers,
191
- method: this.method,
192
- name: this.name,
193
- data: this.data,
194
- accept: this.accept,
195
- fileList: this.uploadFiles,
196
- autoUpload: this.autoUpload,
197
- listType: this.listType,
198
- disabled: this.uploadDisabled,
199
- limit: this.limit,
200
- "on-exceed": this.onExceed,
201
- "on-start": this.handleStart,
202
- "on-progress": this.handleProgress,
203
- "on-success": this.handleSuccess,
204
- "on-error": this.handleError,
205
- "on-preview": this.onPreview,
206
- "on-remove": this.handleRemove,
207
- "http-request": this.httpRequest,
208
- ref: "uploadRef"
209
- };
210
- const trigger = this.$slots.trigger || this.$slots.default;
211
- const uploadComponent = vue.h(upload["default"], uploadData, {
212
- default: () => trigger == null ? void 0 : trigger()
213
- });
214
- return vue.h("div", [
215
- this.listType === "picture-card" ? uploadList$1 : null,
216
- this.$slots.trigger ? [uploadComponent, this.$slots.default()] : uploadComponent,
217
- (_b = (_a = this.$slots).tip) == null ? void 0 : _b.call(_a),
218
- this.listType !== "picture-card" ? uploadList$1 : null
219
- ]);
220
- }
221
- });
222
-
223
- exports["default"] = _sfc_main;
224
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../../packages/components/upload/src/index.vue"],"sourcesContent":["<script lang=\"ts\">\nimport {\n computed,\n defineComponent,\n h,\n getCurrentInstance,\n inject,\n ref,\n provide,\n onBeforeUnmount,\n} from 'vue'\nimport { NOOP } from '@vue/shared'\nimport { elFormKey } from '@element-plus/tokens'\n\nimport ajax from './ajax'\nimport UploadList from './upload-list.vue'\nimport Upload from './upload.vue'\nimport useHandlers from './useHandlers'\n\nimport type { PropType } from 'vue'\nimport type { ElFormContext } from '@element-plus/tokens'\nimport type { Nullable } from '@element-plus/utils'\nimport type {\n ListType,\n UploadFile,\n FileHandler,\n FileResultHandler,\n} from './upload.type'\n\ntype PFileHandler<T> = PropType<FileHandler<T>>\ntype PFileResultHandler<T = any> = PropType<FileResultHandler<T>>\n\nexport default defineComponent({\n name: 'ElUpload',\n components: {\n Upload,\n UploadList,\n },\n props: {\n action: {\n type: String,\n required: true,\n },\n headers: {\n type: Object as PropType<Headers>,\n default: () => ({}),\n },\n method: {\n type: String,\n default: 'post',\n },\n data: {\n type: Object,\n default: () => ({}),\n },\n multiple: {\n type: Boolean,\n default: false,\n },\n name: {\n type: String,\n default: 'file',\n },\n drag: {\n type: Boolean,\n default: false,\n },\n withCredentials: Boolean,\n showFileList: {\n type: Boolean,\n default: true,\n },\n accept: {\n type: String,\n default: '',\n },\n type: {\n type: String,\n default: 'select',\n },\n beforeUpload: {\n type: Function as PFileHandler<void>,\n default: NOOP,\n },\n beforeRemove: {\n type: Function as PFileHandler<boolean>,\n default: NOOP,\n },\n onRemove: {\n type: Function as PFileHandler<void>,\n default: NOOP,\n },\n onChange: {\n type: Function as PFileHandler<void>,\n default: NOOP,\n },\n onPreview: {\n type: Function as PropType<() => void>,\n default: NOOP,\n },\n onSuccess: {\n type: Function as PFileResultHandler,\n default: NOOP,\n },\n onProgress: {\n type: Function as PFileResultHandler<ProgressEvent>,\n default: NOOP,\n },\n onError: {\n type: Function as PFileResultHandler<Error>,\n default: NOOP,\n },\n fileList: {\n type: Array as PropType<UploadFile[]>,\n default: () => {\n return [] as UploadFile[]\n },\n },\n autoUpload: {\n type: Boolean,\n default: true,\n },\n listType: {\n type: String as PropType<ListType>,\n default: 'text' as ListType, // text,picture,picture-card\n },\n httpRequest: {\n type: Function,\n default: ajax,\n },\n disabled: Boolean,\n limit: {\n type: Number as PropType<Nullable<number>>,\n default: null,\n },\n onExceed: {\n type: Function,\n default: () => NOOP,\n },\n },\n setup(props) {\n const elForm = inject(elFormKey, {} as ElFormContext)\n\n const uploadDisabled = computed(() => {\n return props.disabled || elForm.disabled\n })\n\n const {\n abort,\n clearFiles,\n handleError,\n handleProgress,\n handleStart,\n handleSuccess,\n handleRemove,\n submit,\n uploadRef,\n uploadFiles,\n } = useHandlers(props)\n\n provide('uploader', getCurrentInstance())\n\n onBeforeUnmount(() => {\n uploadFiles.value.forEach((file) => {\n if (file.url && file.url.indexOf('blob:') === 0) {\n URL.revokeObjectURL(file.url)\n }\n })\n })\n\n return {\n abort,\n dragOver: ref(false),\n draging: ref(false),\n handleError,\n handleProgress,\n handleRemove,\n handleStart,\n handleSuccess,\n uploadDisabled,\n uploadFiles,\n uploadRef,\n submit,\n clearFiles,\n }\n },\n render() {\n let uploadList\n if (this.showFileList) {\n uploadList = h(\n UploadList,\n {\n disabled: this.uploadDisabled,\n listType: this.listType,\n files: this.uploadFiles,\n onRemove: this.handleRemove,\n handlePreview: this.onPreview,\n },\n this.$slots.file\n ? {\n default: (props: { file: UploadFile }) => {\n return this.$slots.file({\n file: props.file,\n })\n },\n }\n : null\n )\n } else {\n uploadList = null\n }\n\n const uploadData = {\n type: this.type,\n drag: this.drag,\n action: this.action,\n multiple: this.multiple,\n 'before-upload': this.beforeUpload,\n 'with-credentials': this.withCredentials,\n headers: this.headers,\n method: this.method,\n name: this.name,\n data: this.data,\n accept: this.accept,\n fileList: this.uploadFiles,\n autoUpload: this.autoUpload,\n listType: this.listType,\n disabled: this.uploadDisabled,\n limit: this.limit,\n 'on-exceed': this.onExceed,\n 'on-start': this.handleStart,\n 'on-progress': this.handleProgress,\n 'on-success': this.handleSuccess,\n 'on-error': this.handleError,\n 'on-preview': this.onPreview,\n 'on-remove': this.handleRemove,\n 'http-request': this.httpRequest,\n ref: 'uploadRef',\n }\n const trigger = this.$slots.trigger || this.$slots.default\n const uploadComponent = h(Upload, uploadData, {\n default: () => trigger?.(),\n })\n return h('div', [\n this.listType === 'picture-card' ? uploadList : null,\n this.$slots.trigger\n ? [uploadComponent, this.$slots.default()]\n : uploadComponent,\n this.$slots.tip?.(),\n this.listType !== 'picture-card' ? uploadList : null,\n ])\n },\n})\n</script>\n"],"names":["defineComponent","Upload","UploadList","NOOP","ajax","inject","elFormKey","computed","useHandlers","getCurrentInstance","ref","uploadList","h"],"mappings":";;;;;;;;;;;;;MAgCK,YAAaA,oBAAa;AAAA,EAC7B,MAAM;AAAA,EACN,YAAY;AAAA,YACVC;AAAA,gBACAC;AAAA;AAAA,EAEF,OAAO;AAAA,IACL,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA;AAAA,IAEZ,SAAS;AAAA,MACP,MAAM;AAAA,MACN,SAAS;AAAO;AAAA,IAElB,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,SAAS;AAAA;AAAA,IAEX,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,SAAS;AAAO;AAAA,IAElB,UAAU;AAAA,MACR,MAAM;AAAA,MACN,SAAS;AAAA;AAAA,IAEX,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,SAAS;AAAA;AAAA,IAEX,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,SAAS;AAAA;AAAA,IAEX,iBAAiB;AAAA,IACjB,cAAc;AAAA,MACZ,MAAM;AAAA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A,MACA;AAAA,MACA;AAAA,QACEC,uBAAY;AAEhB,gBAAQ,YAAYC;AAEpB,wBAAgB,MAAM;AACpB,kBAAY,MAAM,QAAQ,CAAC,SAAS;AAClC,YAAI,KAAK,OAAO,KAAK,IAAI,QAAQ,aAAa,GAAG;AAC/C,cAAI,gBAAgB,KAAK;AAAA;AAAA;AAAA;AAK/B,WAAO;AAAA,MACL;AAAA,MACA,UAAUC,QAAI;AAAA,MACd,SAASA,QAAI;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA;AAAA,EAGJ,SAAS;AACP,QAAI;AACJ,QAAIC;AACF;AAEE;AACiB,QACf,UAAU,KAAK;AAAA,QACf;AAAY,QACZ;AAAe,QACf,eAAe;AAAK,qBAEV,OACR;AAAA,4BAC4C;AACxC,iBAAO;AAAiB;AACV;AAAA;AAAA;AAIlB;AAGN;AAAa;AAGf;AAAmB;AACN,MACX,MAAM,KAAK;AAAA,MACX;AAAa,MACb;AAAe,MACf;AAAsB,MACtB;AAAyB,MACzB;AAAc,MACd,aAAa;AAAA,MACb,MAAM;AAAK,MACX,MAAM,KAAK;AAAA,MACX;AAAa,MACb;AAAe,MACf;AAAiB,MACjB,UAAU;AAAK,MACf,UAAU,KAAK;AAAA,MACf;AAAY,MACZ;AAAkB,MAClB,iBAAiB;AAAA,MACjB;AAAoB,MACpB,mBAAmB;AAAA,MACnB,YAAY;AAAK,MACjB;AAAmB,MACnB,kBAAkB;AAAA,MAClB;AAAqB,MACrB;AAAK;AAEP;AACA,UAAM;AAAwC;AAC7B;AAEjB;AAAgB,WACTC;AAA2C,MAChD,KAAK,0CACsB,OAAO;AAC9B,MACJ,KAAK,OAAO;AAAA,MACZ;AAAgD;AAAA;AAAA;;;;;"}
@@ -1,282 +0,0 @@
1
- /// <reference types="node" />
2
- import ajax from './ajax';
3
- import type { PropType } from 'vue';
4
- import type { Nullable } from 'element-plus/es/utils';
5
- import type { ListType, UploadFile, FileHandler, FileResultHandler } from './upload.type';
6
- declare type PFileHandler<T> = PropType<FileHandler<T>>;
7
- declare type PFileResultHandler<T = any> = PropType<FileResultHandler<T>>;
8
- declare const _default: import("vue").DefineComponent<{
9
- action: {
10
- type: StringConstructor;
11
- required: true;
12
- };
13
- headers: {
14
- type: PropType<Headers>;
15
- default: () => {};
16
- };
17
- method: {
18
- type: StringConstructor;
19
- default: string;
20
- };
21
- data: {
22
- type: ObjectConstructor;
23
- default: () => {};
24
- };
25
- multiple: {
26
- type: BooleanConstructor;
27
- default: boolean;
28
- };
29
- name: {
30
- type: StringConstructor;
31
- default: string;
32
- };
33
- drag: {
34
- type: BooleanConstructor;
35
- default: boolean;
36
- };
37
- withCredentials: BooleanConstructor;
38
- showFileList: {
39
- type: BooleanConstructor;
40
- default: boolean;
41
- };
42
- accept: {
43
- type: StringConstructor;
44
- default: string;
45
- };
46
- type: {
47
- type: StringConstructor;
48
- default: string;
49
- };
50
- beforeUpload: {
51
- type: PFileHandler<void>;
52
- default: () => void;
53
- };
54
- beforeRemove: {
55
- type: PFileHandler<boolean>;
56
- default: () => void;
57
- };
58
- onRemove: {
59
- type: PFileHandler<void>;
60
- default: () => void;
61
- };
62
- onChange: {
63
- type: PFileHandler<void>;
64
- default: () => void;
65
- };
66
- onPreview: {
67
- type: PropType<() => void>;
68
- default: () => void;
69
- };
70
- onSuccess: {
71
- type: PFileResultHandler<any>;
72
- default: () => void;
73
- };
74
- onProgress: {
75
- type: PFileResultHandler<ProgressEvent<EventTarget>>;
76
- default: () => void;
77
- };
78
- onError: {
79
- type: PFileResultHandler<Error>;
80
- default: () => void;
81
- };
82
- fileList: {
83
- type: PropType<UploadFile[]>;
84
- default: () => UploadFile[];
85
- };
86
- autoUpload: {
87
- type: BooleanConstructor;
88
- default: boolean;
89
- };
90
- listType: {
91
- type: PropType<ListType>;
92
- default: ListType;
93
- };
94
- httpRequest: {
95
- type: FunctionConstructor;
96
- default: typeof ajax;
97
- };
98
- disabled: BooleanConstructor;
99
- limit: {
100
- type: PropType<Nullable<number>>;
101
- default: null;
102
- };
103
- onExceed: {
104
- type: FunctionConstructor;
105
- default: () => () => void;
106
- };
107
- }, {
108
- abort: (file: UploadFile) => void;
109
- dragOver: import("vue").Ref<boolean>;
110
- draging: import("vue").Ref<boolean>;
111
- handleError: (err: Error, rawFile: import("./upload.type").ElFile) => void;
112
- handleProgress: (ev: import("./upload.type").ElUploadProgressEvent, rawFile: import("./upload.type").ElFile) => void;
113
- handleRemove: (file: UploadFile, raw: import("./upload.type").ElFile) => void;
114
- handleStart: (rawFile: import("./upload.type").ElFile) => void;
115
- handleSuccess: (res: any, rawFile: import("./upload.type").ElFile) => void;
116
- uploadDisabled: import("vue").ComputedRef<boolean | undefined>;
117
- uploadFiles: import("vue").Ref<{
118
- name: string;
119
- percentage?: number | undefined;
120
- status: import("./upload.type").UploadStatus;
121
- size: number;
122
- response?: unknown;
123
- uid: number;
124
- url?: string | undefined;
125
- raw: {
126
- uid: number;
127
- readonly lastModified: number;
128
- readonly name: string;
129
- readonly webkitRelativePath: string;
130
- readonly size: number;
131
- readonly type: string;
132
- arrayBuffer: {
133
- (): Promise<ArrayBuffer>;
134
- (): Promise<ArrayBuffer>;
135
- };
136
- slice: {
137
- (start?: number | undefined, end?: number | undefined, contentType?: string | undefined): Blob;
138
- (start?: number | undefined, end?: number | undefined, contentType?: string | undefined): Blob;
139
- };
140
- stream: {
141
- (): ReadableStream<any>;
142
- (): NodeJS.ReadableStream;
143
- };
144
- text: {
145
- (): Promise<string>;
146
- (): Promise<string>;
147
- };
148
- };
149
- }[]>;
150
- uploadRef: import("vue").Ref<{
151
- abort: (file: UploadFile) => void;
152
- upload: (file: import("./upload.type").ElFile) => void;
153
- }>;
154
- submit: () => void;
155
- clearFiles: (status?: import("./upload.type").UploadStatus[]) => void;
156
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
157
- action: {
158
- type: StringConstructor;
159
- required: true;
160
- };
161
- headers: {
162
- type: PropType<Headers>;
163
- default: () => {};
164
- };
165
- method: {
166
- type: StringConstructor;
167
- default: string;
168
- };
169
- data: {
170
- type: ObjectConstructor;
171
- default: () => {};
172
- };
173
- multiple: {
174
- type: BooleanConstructor;
175
- default: boolean;
176
- };
177
- name: {
178
- type: StringConstructor;
179
- default: string;
180
- };
181
- drag: {
182
- type: BooleanConstructor;
183
- default: boolean;
184
- };
185
- withCredentials: BooleanConstructor;
186
- showFileList: {
187
- type: BooleanConstructor;
188
- default: boolean;
189
- };
190
- accept: {
191
- type: StringConstructor;
192
- default: string;
193
- };
194
- type: {
195
- type: StringConstructor;
196
- default: string;
197
- };
198
- beforeUpload: {
199
- type: PFileHandler<void>;
200
- default: () => void;
201
- };
202
- beforeRemove: {
203
- type: PFileHandler<boolean>;
204
- default: () => void;
205
- };
206
- onRemove: {
207
- type: PFileHandler<void>;
208
- default: () => void;
209
- };
210
- onChange: {
211
- type: PFileHandler<void>;
212
- default: () => void;
213
- };
214
- onPreview: {
215
- type: PropType<() => void>;
216
- default: () => void;
217
- };
218
- onSuccess: {
219
- type: PFileResultHandler<any>;
220
- default: () => void;
221
- };
222
- onProgress: {
223
- type: PFileResultHandler<ProgressEvent<EventTarget>>;
224
- default: () => void;
225
- };
226
- onError: {
227
- type: PFileResultHandler<Error>;
228
- default: () => void;
229
- };
230
- fileList: {
231
- type: PropType<UploadFile[]>;
232
- default: () => UploadFile[];
233
- };
234
- autoUpload: {
235
- type: BooleanConstructor;
236
- default: boolean;
237
- };
238
- listType: {
239
- type: PropType<ListType>;
240
- default: ListType;
241
- };
242
- httpRequest: {
243
- type: FunctionConstructor;
244
- default: typeof ajax;
245
- };
246
- disabled: BooleanConstructor;
247
- limit: {
248
- type: PropType<Nullable<number>>;
249
- default: null;
250
- };
251
- onExceed: {
252
- type: FunctionConstructor;
253
- default: () => () => void;
254
- };
255
- }>>, {
256
- type: string;
257
- disabled: boolean;
258
- name: string;
259
- data: Record<string, any>;
260
- onChange: FileHandler<void>;
261
- drag: boolean;
262
- multiple: boolean;
263
- onError: FileResultHandler<Error>;
264
- onProgress: FileResultHandler<ProgressEvent<EventTarget>>;
265
- headers: Headers;
266
- method: string;
267
- withCredentials: boolean;
268
- accept: string;
269
- onSuccess: FileResultHandler<any>;
270
- beforeUpload: FileHandler<void>;
271
- onPreview: () => void;
272
- onRemove: FileHandler<void>;
273
- fileList: UploadFile[];
274
- autoUpload: boolean;
275
- listType: ListType;
276
- httpRequest: Function;
277
- limit: Nullable<number>;
278
- onExceed: Function;
279
- showFileList: boolean;
280
- beforeRemove: FileHandler<boolean>;
281
- }>;
282
- export default _default;