vxe-pc-ui 4.20.34 → 4.20.35

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 (367) hide show
  1. package/dist/all.esm.js +45718 -45038
  2. package/dist/all.esm.min.js +3 -3
  3. package/dist/style.css +307 -1
  4. package/dist/style.mini.css +1 -1
  5. package/es/alert/src/alert.js +117 -114
  6. package/es/anchor/src/anchor-link.js +110 -107
  7. package/es/anchor/src/anchor.js +212 -209
  8. package/es/avatar/src/avatar.js +132 -129
  9. package/es/backtop/src/backtop.js +267 -264
  10. package/es/badge/src/badge.js +102 -99
  11. package/es/breadcrumb/src/breadcrumb-item.js +104 -101
  12. package/es/breadcrumb/src/breadcrumb.js +70 -67
  13. package/es/button/src/button-group.js +88 -85
  14. package/es/calendar/src/calendar.js +1371 -1368
  15. package/es/card/src/card.js +235 -232
  16. package/es/carousel/src/carousel-item.js +78 -75
  17. package/es/carousel/src/carousel.js +392 -389
  18. package/es/cascader/src/cascader.js +1667 -1664
  19. package/es/checkbox/src/button.js +198 -195
  20. package/es/checkbox/src/checkbox.js +181 -178
  21. package/es/checkbox/src/group.js +210 -207
  22. package/es/collapse/src/collapse-pane.js +98 -95
  23. package/es/collapse/src/collapse.js +340 -337
  24. package/es/color-picker/src/color-picker.js +1116 -1113
  25. package/es/components.d.ts +1 -0
  26. package/es/components.js +3 -0
  27. package/es/context-menu/src/context-menu.js +601 -598
  28. package/es/countdown/src/countdown.js +224 -221
  29. package/es/date-panel/src/date-panel.js +1905 -1902
  30. package/es/date-picker/src/date-picker.js +1537 -1534
  31. package/es/date-range-picker/src/date-range-picker.js +1412 -1409
  32. package/es/divider/src/divider.js +80 -77
  33. package/es/drawer/src/drawer.js +778 -775
  34. package/es/empty/src/empty.js +100 -97
  35. package/es/form/src/form-group.js +74 -71
  36. package/es/form/src/form-item.js +76 -73
  37. package/es/form/src/form.js +789 -786
  38. package/es/icon/src/icon.js +59 -56
  39. package/es/icon/style.css +1 -1
  40. package/es/icon/style.mini.css +1 -1
  41. package/es/icon-picker/src/icon-picker.js +719 -716
  42. package/es/image/src/group.js +130 -127
  43. package/es/image/src/image.js +243 -240
  44. package/es/image/src/preview.js +627 -624
  45. package/es/index.esm.js +2 -0
  46. package/es/index.js +2 -0
  47. package/es/input/src/input.js +2700 -2697
  48. package/es/layout-aside/src/layout-aside.js +138 -135
  49. package/es/layout-body/src/layout-body.js +145 -142
  50. package/es/layout-container/src/layout-container.js +71 -68
  51. package/es/layout-footer/src/layout-footer.js +60 -57
  52. package/es/layout-header/src/layout-header.js +58 -55
  53. package/es/link/src/link.js +131 -128
  54. package/es/list/src/list.js +2174 -2171
  55. package/es/loading/src/loading.js +141 -138
  56. package/es/mention/src/mention.js +49 -46
  57. package/es/menu/src/menu.js +799 -796
  58. package/es/modal/src/modal.js +1519 -1527
  59. package/es/notice-bar/src/notice-bar.js +168 -165
  60. package/es/number-input/src/number-input.js +1094 -1091
  61. package/es/pager/src/pager.js +767 -764
  62. package/es/password-input/src/password-input.js +431 -428
  63. package/es/print/src/page-break.js +63 -60
  64. package/es/print/src/print.js +303 -300
  65. package/es/pulldown/src/pulldown.js +403 -400
  66. package/es/radio/src/button.js +214 -211
  67. package/es/radio/src/group.js +195 -192
  68. package/es/radio/src/radio.js +194 -191
  69. package/es/rate/src/rate.js +164 -161
  70. package/es/result/src/result.js +116 -113
  71. package/es/row/src/col.js +133 -130
  72. package/es/row/src/row.js +111 -108
  73. package/es/scrollbar/src/scrollbar.js +518 -515
  74. package/es/segmented/src/segmented.js +240 -237
  75. package/es/select/src/optgroup.js +44 -41
  76. package/es/select/src/option.js +39 -36
  77. package/es/select/src/select.js +1914 -1896
  78. package/es/slider/src/slider.js +419 -416
  79. package/es/space/src/space.js +190 -187
  80. package/es/splitter/src/splitter-panel.js +146 -143
  81. package/es/splitter/src/splitter.js +917 -914
  82. package/es/step-item/index.d.ts +76 -0
  83. package/es/step-item/index.js +17 -0
  84. package/es/steps/index.d.ts +288 -34
  85. package/es/steps/src/step-info.d.ts +6 -0
  86. package/es/steps/src/step-info.js +20 -0
  87. package/es/steps/src/step-item.d.ts +14 -0
  88. package/es/steps/src/step-item.js +39 -0
  89. package/es/steps/src/steps.d.ts +68 -8
  90. package/es/steps/src/steps.js +299 -47
  91. package/es/steps/src/util.d.ts +7 -0
  92. package/es/steps/src/util.js +44 -0
  93. package/es/steps/style.css +297 -0
  94. package/es/steps/style.mini.css +1 -0
  95. package/es/style.css +307 -1
  96. package/es/style.mini.css +1 -1
  97. package/es/switch/src/switch.js +228 -225
  98. package/es/table-select/src/table-select.js +865 -862
  99. package/es/table-transfer/src/table-transfer.js +61 -58
  100. package/es/tabs/src/tab-pane.js +102 -99
  101. package/es/tabs/src/tabs.js +936 -933
  102. package/es/tag/src/tag.js +163 -160
  103. package/es/text/src/text.js +232 -229
  104. package/es/text-ellipsis/src/text-ellipsis.js +252 -249
  105. package/es/textarea/src/textarea.js +434 -431
  106. package/es/timeline/src/timeline.js +74 -36
  107. package/es/timeline/src/util.js +7 -4
  108. package/es/tip/src/tip.js +117 -114
  109. package/es/tooltip/src/tooltip.js +552 -549
  110. package/es/tour/src/tour.js +49 -46
  111. package/es/transfer/src/transfer.js +95 -92
  112. package/es/tree/src/tree.js +3379 -3376
  113. package/es/tree-select/src/tree-select.js +969 -966
  114. package/es/ui/index.js +8 -2
  115. package/es/ui/src/log.js +1 -1
  116. package/es/upload/src/upload.js +1791 -1788
  117. package/es/vxe-icon/style.css +1 -1
  118. package/es/vxe-icon/style.mini.css +1 -1
  119. package/es/vxe-steps/style.css +297 -0
  120. package/es/vxe-steps/style.mini.css +1 -0
  121. package/es/watermark/src/watermark.js +158 -155
  122. package/lib/alert/src/alert.js +117 -114
  123. package/lib/anchor/src/anchor-link.js +110 -107
  124. package/lib/anchor/src/anchor.js +212 -209
  125. package/lib/avatar/src/avatar.js +132 -129
  126. package/lib/backtop/src/backtop.js +267 -264
  127. package/lib/badge/src/badge.js +102 -99
  128. package/lib/breadcrumb/src/breadcrumb-item.js +104 -101
  129. package/lib/breadcrumb/src/breadcrumb.js +70 -67
  130. package/lib/button/src/button-group.js +88 -85
  131. package/lib/calendar/src/calendar.js +1371 -1368
  132. package/lib/card/src/card.js +235 -232
  133. package/lib/carousel/src/carousel-item.js +78 -75
  134. package/lib/carousel/src/carousel.js +392 -389
  135. package/lib/cascader/src/cascader.js +1665 -1662
  136. package/lib/checkbox/src/button.js +198 -195
  137. package/lib/checkbox/src/checkbox.js +181 -178
  138. package/lib/checkbox/src/group.js +210 -207
  139. package/lib/collapse/src/collapse-pane.js +98 -95
  140. package/lib/collapse/src/collapse.js +340 -337
  141. package/lib/color-picker/src/color-picker.js +1116 -1113
  142. package/lib/components.js +3 -0
  143. package/lib/context-menu/src/context-menu.js +601 -598
  144. package/lib/countdown/src/countdown.js +224 -221
  145. package/lib/date-panel/src/date-panel.js +1905 -1902
  146. package/lib/date-picker/src/date-picker.js +1537 -1534
  147. package/lib/date-range-picker/src/date-range-picker.js +1412 -1409
  148. package/lib/divider/src/divider.js +80 -77
  149. package/lib/drawer/src/drawer.js +778 -775
  150. package/lib/empty/src/empty.js +100 -97
  151. package/lib/form/src/form-group.js +74 -71
  152. package/lib/form/src/form-item.js +76 -73
  153. package/lib/form/src/form.js +789 -786
  154. package/lib/icon/src/icon.js +59 -56
  155. package/lib/icon/style/style.css +1 -1
  156. package/lib/icon/style/style.mini.css +1 -1
  157. package/lib/icon-picker/src/icon-picker.js +719 -716
  158. package/lib/image/src/group.js +130 -127
  159. package/lib/image/src/image.js +243 -240
  160. package/lib/image/src/preview.js +627 -624
  161. package/lib/index.common.js +2 -0
  162. package/lib/index.js +2 -0
  163. package/lib/index.umd.js +47411 -46732
  164. package/lib/index.umd.min.js +3 -3
  165. package/lib/input/src/input.js +2700 -2697
  166. package/lib/layout-aside/src/layout-aside.js +138 -135
  167. package/lib/layout-body/src/layout-body.js +145 -142
  168. package/lib/layout-container/src/layout-container.js +71 -68
  169. package/lib/layout-footer/src/layout-footer.js +60 -57
  170. package/lib/layout-header/src/layout-header.js +58 -55
  171. package/lib/link/src/link.js +131 -128
  172. package/lib/list/src/list.js +2173 -2170
  173. package/lib/loading/src/loading.js +141 -138
  174. package/lib/mention/src/mention.js +49 -46
  175. package/lib/menu/src/menu.js +799 -796
  176. package/lib/modal/src/modal.js +1519 -1527
  177. package/lib/notice-bar/src/notice-bar.js +168 -165
  178. package/lib/number-input/src/number-input.js +1094 -1091
  179. package/lib/pager/src/pager.js +767 -764
  180. package/lib/password-input/src/password-input.js +431 -428
  181. package/lib/print/src/page-break.js +63 -60
  182. package/lib/print/src/print.js +303 -300
  183. package/lib/pulldown/src/pulldown.js +403 -400
  184. package/lib/radio/src/button.js +214 -211
  185. package/lib/radio/src/group.js +195 -192
  186. package/lib/radio/src/radio.js +194 -191
  187. package/lib/rate/src/rate.js +164 -161
  188. package/lib/result/src/result.js +116 -113
  189. package/lib/row/src/col.js +133 -130
  190. package/lib/row/src/row.js +111 -108
  191. package/lib/scrollbar/src/scrollbar.js +518 -515
  192. package/lib/segmented/src/segmented.js +240 -237
  193. package/lib/select/src/optgroup.js +44 -41
  194. package/lib/select/src/option.js +39 -36
  195. package/lib/select/src/select.js +1915 -1897
  196. package/lib/slider/src/slider.js +419 -416
  197. package/lib/space/src/space.js +190 -187
  198. package/lib/splitter/src/splitter-panel.js +146 -143
  199. package/lib/splitter/src/splitter.js +917 -914
  200. package/lib/step-item/index.js +47 -0
  201. package/lib/steps/src/step-info.js +49 -0
  202. package/lib/steps/src/step-item.js +59 -0
  203. package/lib/steps/src/steps.js +298 -46
  204. package/lib/steps/src/util.js +74 -0
  205. package/lib/steps/style/style.css +297 -0
  206. package/lib/steps/style/style.mini.css +1 -0
  207. package/lib/style.css +307 -1
  208. package/lib/style.mini.css +1 -1
  209. package/lib/switch/src/switch.js +228 -225
  210. package/lib/table-select/src/table-select.js +865 -862
  211. package/lib/table-transfer/src/table-transfer.js +61 -58
  212. package/lib/tabs/src/tab-pane.js +102 -99
  213. package/lib/tabs/src/tabs.js +936 -933
  214. package/lib/tag/src/tag.js +163 -160
  215. package/lib/text/src/text.js +232 -229
  216. package/lib/text-ellipsis/src/text-ellipsis.js +252 -249
  217. package/lib/textarea/src/textarea.js +434 -431
  218. package/lib/timeline/src/timeline.js +74 -36
  219. package/lib/timeline/src/util.js +7 -4
  220. package/lib/tip/src/tip.js +117 -114
  221. package/lib/tooltip/src/tooltip.js +552 -549
  222. package/lib/tour/src/tour.js +49 -46
  223. package/lib/transfer/src/transfer.js +95 -92
  224. package/lib/tree/src/tree.js +3379 -3376
  225. package/lib/tree-select/src/tree-select.js +969 -966
  226. package/lib/ui/index.js +8 -2
  227. package/lib/ui/src/log.js +1 -1
  228. package/lib/upload/src/upload.js +1788 -1785
  229. package/lib/vxe-icon/style/style.css +1 -1
  230. package/lib/vxe-icon/style/style.mini.css +1 -1
  231. package/lib/vxe-steps/style/style.css +297 -0
  232. package/lib/vxe-steps/style/style.mini.css +1 -0
  233. package/lib/watermark/src/watermark.js +158 -155
  234. package/package.json +1 -1
  235. package/packages/alert/src/alert.ts +2 -2
  236. package/packages/anchor/src/anchor-link.ts +2 -2
  237. package/packages/anchor/src/anchor.ts +2 -2
  238. package/packages/avatar/src/avatar.ts +2 -2
  239. package/packages/backtop/src/backtop.ts +2 -2
  240. package/packages/badge/src/badge.ts +2 -2
  241. package/packages/breadcrumb/src/breadcrumb-item.ts +2 -2
  242. package/packages/breadcrumb/src/breadcrumb.ts +2 -2
  243. package/packages/button/src/button-group.ts +2 -2
  244. package/packages/calendar/src/calendar.ts +2 -2
  245. package/packages/card/src/card.ts +2 -2
  246. package/packages/carousel/src/carousel-item.ts +2 -2
  247. package/packages/carousel/src/carousel.ts +2 -2
  248. package/packages/cascader/src/cascader.ts +2 -2
  249. package/packages/checkbox/src/button.ts +3 -15
  250. package/packages/checkbox/src/checkbox.ts +2 -2
  251. package/packages/checkbox/src/group.ts +2 -2
  252. package/packages/collapse/src/collapse-pane.ts +2 -2
  253. package/packages/collapse/src/collapse.ts +2 -2
  254. package/packages/color-picker/src/color-picker.ts +2 -2
  255. package/packages/components.ts +3 -0
  256. package/packages/context-menu/src/context-menu.ts +3 -16
  257. package/packages/countdown/src/countdown.ts +2 -2
  258. package/packages/date-panel/src/date-panel.ts +2 -2
  259. package/packages/date-picker/src/date-picker.ts +2 -2
  260. package/packages/date-range-picker/src/date-range-picker.ts +2 -2
  261. package/packages/divider/src/divider.ts +2 -2
  262. package/packages/drawer/src/drawer.ts +2 -2
  263. package/packages/empty/src/empty.ts +2 -2
  264. package/packages/form/src/form-group.ts +2 -2
  265. package/packages/form/src/form-item.ts +2 -2
  266. package/packages/form/src/form.ts +2 -2
  267. package/packages/icon/src/icon.ts +2 -2
  268. package/packages/icon-picker/src/icon-picker.ts +2 -2
  269. package/packages/image/src/group.ts +2 -2
  270. package/packages/image/src/image.ts +2 -2
  271. package/packages/image/src/preview.ts +3 -16
  272. package/packages/index.ts +2 -2
  273. package/packages/input/src/input.ts +2 -2
  274. package/packages/layout-aside/src/layout-aside.ts +2 -2
  275. package/packages/layout-body/src/layout-body.ts +2 -2
  276. package/packages/layout-container/src/layout-container.ts +3 -14
  277. package/packages/layout-footer/src/layout-footer.ts +2 -2
  278. package/packages/layout-header/src/layout-header.ts +2 -2
  279. package/packages/link/src/link.ts +2 -2
  280. package/packages/list/src/list.ts +2 -2
  281. package/packages/loading/src/loading.ts +2 -2
  282. package/packages/mention/src/mention.ts +2 -2
  283. package/packages/menu/src/menu.ts +2 -2
  284. package/packages/modal/src/modal.ts +5 -20
  285. package/packages/notice-bar/src/notice-bar.ts +2 -2
  286. package/packages/number-input/src/number-input.ts +3 -17
  287. package/packages/pager/src/pager.ts +2 -2
  288. package/packages/password-input/src/password-input.ts +2 -2
  289. package/packages/print/src/page-break.ts +2 -2
  290. package/packages/print/src/print.ts +2 -2
  291. package/packages/pulldown/src/pulldown.ts +2 -2
  292. package/packages/radio/src/button.ts +3 -16
  293. package/packages/radio/src/group.ts +3 -17
  294. package/packages/radio/src/radio.ts +2 -2
  295. package/packages/rate/src/rate.ts +2 -2
  296. package/packages/result/src/result.ts +2 -2
  297. package/packages/row/src/col.ts +2 -2
  298. package/packages/row/src/row.ts +2 -2
  299. package/packages/scrollbar/src/scrollbar.ts +3 -4
  300. package/packages/segmented/src/segmented.ts +2 -2
  301. package/packages/select/src/optgroup.ts +2 -2
  302. package/packages/select/src/option.ts +2 -2
  303. package/packages/select/src/select.ts +33 -19
  304. package/packages/slider/src/slider.ts +2 -2
  305. package/packages/space/src/space.ts +2 -2
  306. package/packages/splitter/src/splitter-panel.ts +2 -2
  307. package/packages/splitter/src/splitter.ts +2 -2
  308. package/packages/step-item/index.ts +16 -0
  309. package/packages/steps/src/step-info.ts +18 -0
  310. package/packages/steps/src/step-item.ts +41 -0
  311. package/packages/steps/src/steps.ts +273 -13
  312. package/packages/steps/src/util.ts +44 -0
  313. package/packages/switch/src/switch.ts +2 -2
  314. package/packages/table-select/src/table-select.ts +2 -2
  315. package/packages/table-transfer/src/table-transfer.ts +3 -15
  316. package/packages/tabs/src/tab-pane.ts +2 -2
  317. package/packages/tabs/src/tabs.ts +2 -2
  318. package/packages/tag/src/tag.ts +2 -2
  319. package/packages/text/src/text.ts +2 -2
  320. package/packages/text-ellipsis/src/text-ellipsis.ts +2 -2
  321. package/packages/textarea/src/textarea.ts +2 -2
  322. package/packages/timeline/src/timeline-info.ts +17 -17
  323. package/packages/timeline/src/timeline.ts +93 -49
  324. package/packages/timeline/src/util.ts +44 -41
  325. package/packages/tip/src/tip.ts +2 -2
  326. package/packages/tooltip/src/tooltip.ts +2 -2
  327. package/packages/tour/src/tour.ts +2 -2
  328. package/packages/transfer/src/transfer.ts +2 -2
  329. package/packages/tree/src/tree.ts +2 -2
  330. package/packages/tree-select/src/tree-select.ts +2 -2
  331. package/packages/ui/index.ts +8 -1
  332. package/packages/upload/src/upload.ts +2 -2
  333. package/packages/watermark/src/watermark.ts +2 -2
  334. package/styles/all.scss +1 -0
  335. package/styles/components/step-item.scss +0 -0
  336. package/styles/components/steps.scss +354 -0
  337. package/styles/theme/base.scss +9 -0
  338. package/types/all.d.ts +3 -0
  339. package/types/components/gantt.d.ts +1 -3
  340. package/types/components/select.d.ts +1 -13
  341. package/types/components/step-item.d.ts +72 -0
  342. package/types/components/steps.d.ts +67 -8
  343. package/types/components/table.d.ts +7 -66
  344. package/types/handles/form-design.d.ts +1 -4
  345. package/types/ui/global-config.d.ts +2 -0
  346. package/types/ui/global-icon.d.ts +7 -0
  347. /package/dist/{iconfont.1793330162657.ttf → iconfont.1793359478136.ttf} +0 -0
  348. /package/dist/{iconfont.1793330162657.woff → iconfont.1793359478136.woff} +0 -0
  349. /package/dist/{iconfont.1793330162657.woff2 → iconfont.1793359478136.woff2} +0 -0
  350. /package/es/icon/{iconfont.1793330162657.ttf → iconfont.1793359478136.ttf} +0 -0
  351. /package/es/icon/{iconfont.1793330162657.woff → iconfont.1793359478136.woff} +0 -0
  352. /package/es/icon/{iconfont.1793330162657.woff2 → iconfont.1793359478136.woff2} +0 -0
  353. /package/es/{iconfont.1793330162657.ttf → iconfont.1793359478136.ttf} +0 -0
  354. /package/es/{iconfont.1793330162657.woff → iconfont.1793359478136.woff} +0 -0
  355. /package/es/{iconfont.1793330162657.woff2 → iconfont.1793359478136.woff2} +0 -0
  356. /package/es/vxe-icon/{iconfont.1793330162657.ttf → iconfont.1793359478136.ttf} +0 -0
  357. /package/es/vxe-icon/{iconfont.1793330162657.woff → iconfont.1793359478136.woff} +0 -0
  358. /package/es/vxe-icon/{iconfont.1793330162657.woff2 → iconfont.1793359478136.woff2} +0 -0
  359. /package/lib/icon/style/{iconfont.1793330162657.ttf → iconfont.1793359478136.ttf} +0 -0
  360. /package/lib/icon/style/{iconfont.1793330162657.woff → iconfont.1793359478136.woff} +0 -0
  361. /package/lib/icon/style/{iconfont.1793330162657.woff2 → iconfont.1793359478136.woff2} +0 -0
  362. /package/lib/{iconfont.1793330162657.ttf → iconfont.1793359478136.ttf} +0 -0
  363. /package/lib/{iconfont.1793330162657.woff → iconfont.1793359478136.woff} +0 -0
  364. /package/lib/{iconfont.1793330162657.woff2 → iconfont.1793359478136.woff2} +0 -0
  365. /package/lib/vxe-icon/style/{iconfont.1793330162657.ttf → iconfont.1793359478136.ttf} +0 -0
  366. /package/lib/vxe-icon/style/{iconfont.1793330162657.woff → iconfont.1793359478136.woff} +0 -0
  367. /package/lib/vxe-icon/style/{iconfont.1793330162657.woff2 → iconfont.1793359478136.woff2} +0 -0
@@ -29,1727 +29,1796 @@ function createInternalData() {
29
29
  // prevDragPos: ''
30
30
  };
31
31
  }
32
- var upload_default = defineVxeComponent({
33
- name: "VxeUpload",
34
- props: {
35
- modelValue: [Array, String, Object],
36
- showList: {
37
- type: Boolean,
38
- default: () => getConfig().upload.showList
39
- },
40
- moreConfig: Object,
41
- readonly: {
42
- type: Boolean,
43
- default: null
44
- },
45
- disabled: {
46
- type: Boolean,
47
- default: null
48
- },
49
- autoSubmit: {
50
- type: Boolean,
51
- default: () => getConfig().upload.autoSubmit
52
- },
53
- mode: {
54
- type: String,
55
- default: () => getConfig().upload.mode
56
- },
57
- imageTypes: {
58
- type: Array,
59
- default: () => XEUtils.clone(getConfig().upload.imageTypes, true)
60
- },
61
- imageConfig: {
62
- type: Object,
63
- default: () => XEUtils.clone(getConfig().upload.imageConfig, true)
64
- },
65
- /**
66
- * 已废弃,被 image-config 替换
67
- * @deprecated
68
- */
69
- imageStyle: {
70
- type: Object,
71
- default: () => XEUtils.clone(getConfig().upload.imageStyle, true)
72
- },
73
- fileTypes: {
74
- type: Array,
75
- default: () => XEUtils.clone(getConfig().upload.fileTypes, true)
76
- },
77
- dragSort: Boolean,
78
- dragToUpload: {
79
- type: Boolean,
80
- default: () => XEUtils.clone(getConfig().upload.dragToUpload, true)
81
- },
82
- dragPlaceholder: {
83
- type: String,
84
- default: () => getConfig().upload.dragPlaceholder
85
- },
86
- pasteToUpload: {
87
- type: Boolean,
88
- default: () => XEUtils.clone(getConfig().upload.pasteToUpload, true)
89
- },
90
- keyField: String,
91
- singleMode: Boolean,
92
- urlMode: Boolean,
93
- urlArgs: {
94
- type: Boolean,
95
- default: () => getConfig().upload.urlArgs
96
- },
97
- multiple: Boolean,
98
- limitSize: {
99
- type: [String, Number],
100
- default: () => getConfig().upload.limitSize
101
- },
102
- showLimitSize: {
103
- type: Boolean,
104
- default: () => getConfig().upload.showLimitSize
105
- },
106
- limitSizeText: {
107
- type: [String, Number, Function],
108
- default: () => getConfig().upload.limitSizeText
109
- },
110
- limitCount: {
111
- type: [String, Number],
112
- default: () => getConfig().upload.limitCount
113
- },
114
- showLimitCount: {
115
- type: Boolean,
116
- default: () => getConfig().upload.showLimitCount
117
- },
118
- limitCountText: {
119
- type: [String, Number, Function],
120
- default: () => getConfig().upload.limitCountText
121
- },
122
- nameField: {
123
- type: String,
124
- default: () => getConfig().upload.nameField
125
- },
126
- typeField: {
127
- type: String,
128
- default: () => getConfig().upload.typeField
129
- },
130
- urlField: {
131
- type: String,
132
- default: () => getConfig().upload.urlField
133
- },
134
- sizeField: {
135
- type: String,
136
- default: () => getConfig().upload.sizeField
137
- },
138
- showErrorStatus: {
139
- type: Boolean,
140
- default: () => getConfig().upload.showErrorStatus
141
- },
142
- showProgress: {
143
- type: Boolean,
144
- default: () => getConfig().upload.showProgress
145
- },
146
- progressText: {
147
- type: [String, Number, Function],
148
- default: () => getConfig().upload.progressText
149
- },
150
- previewImageConfig: Object,
151
- showSubmitButton: Boolean,
152
- autoHiddenButton: {
153
- type: Boolean,
154
- default: () => getConfig().upload.autoHiddenButton
155
- },
156
- showUploadButton: {
157
- type: Boolean,
158
- default: () => getConfig().upload.showUploadButton
159
- },
160
- buttonText: {
161
- type: [String, Number, Function],
162
- default: () => getConfig().upload.buttonText
163
- },
164
- buttonIcon: {
165
- type: String,
166
- default: () => getConfig().upload.buttonIcon
167
- },
168
- showButtonText: {
169
- type: Boolean,
170
- default: () => getConfig().upload.showButtonText
171
- },
172
- showButtonIcon: {
173
- type: Boolean,
174
- default: () => getConfig().upload.showButtonIcon
175
- },
176
- showRemoveButton: {
177
- type: Boolean,
178
- default: () => getConfig().upload.showRemoveButton
179
- },
180
- showDownloadButton: {
181
- type: Boolean,
182
- default: () => getConfig().upload.showDownloadButton
183
- },
184
- showPreview: {
185
- type: Boolean,
186
- default: () => getConfig().upload.showPreview
187
- },
188
- showTip: {
189
- type: Boolean,
190
- default: () => null
191
- },
192
- maxSimultaneousUploads: {
193
- type: Number,
194
- default: () => getConfig().upload.maxSimultaneousUploads
32
+ var upload_default = (
33
+ /* define-vxe-component start */
34
+ defineVxeComponent({
35
+ name: "VxeUpload",
36
+ props: {
37
+ modelValue: [Array, String, Object],
38
+ showList: {
39
+ type: Boolean,
40
+ default: () => getConfig().upload.showList
41
+ },
42
+ moreConfig: Object,
43
+ readonly: {
44
+ type: Boolean,
45
+ default: null
46
+ },
47
+ disabled: {
48
+ type: Boolean,
49
+ default: null
50
+ },
51
+ autoSubmit: {
52
+ type: Boolean,
53
+ default: () => getConfig().upload.autoSubmit
54
+ },
55
+ mode: {
56
+ type: String,
57
+ default: () => getConfig().upload.mode
58
+ },
59
+ imageTypes: {
60
+ type: Array,
61
+ default: () => XEUtils.clone(getConfig().upload.imageTypes, true)
62
+ },
63
+ imageConfig: {
64
+ type: Object,
65
+ default: () => XEUtils.clone(getConfig().upload.imageConfig, true)
66
+ },
67
+ /**
68
+ * 已废弃,被 image-config 替换
69
+ * @deprecated
70
+ */
71
+ imageStyle: {
72
+ type: Object,
73
+ default: () => XEUtils.clone(getConfig().upload.imageStyle, true)
74
+ },
75
+ fileTypes: {
76
+ type: Array,
77
+ default: () => XEUtils.clone(getConfig().upload.fileTypes, true)
78
+ },
79
+ dragSort: Boolean,
80
+ dragToUpload: {
81
+ type: Boolean,
82
+ default: () => XEUtils.clone(getConfig().upload.dragToUpload, true)
83
+ },
84
+ dragPlaceholder: {
85
+ type: String,
86
+ default: () => getConfig().upload.dragPlaceholder
87
+ },
88
+ pasteToUpload: {
89
+ type: Boolean,
90
+ default: () => XEUtils.clone(getConfig().upload.pasteToUpload, true)
91
+ },
92
+ keyField: String,
93
+ singleMode: Boolean,
94
+ urlMode: Boolean,
95
+ urlArgs: {
96
+ type: Boolean,
97
+ default: () => getConfig().upload.urlArgs
98
+ },
99
+ multiple: Boolean,
100
+ limitSize: {
101
+ type: [String, Number],
102
+ default: () => getConfig().upload.limitSize
103
+ },
104
+ showLimitSize: {
105
+ type: Boolean,
106
+ default: () => getConfig().upload.showLimitSize
107
+ },
108
+ limitSizeText: {
109
+ type: [String, Number, Function],
110
+ default: () => getConfig().upload.limitSizeText
111
+ },
112
+ limitCount: {
113
+ type: [String, Number],
114
+ default: () => getConfig().upload.limitCount
115
+ },
116
+ showLimitCount: {
117
+ type: Boolean,
118
+ default: () => getConfig().upload.showLimitCount
119
+ },
120
+ limitCountText: {
121
+ type: [String, Number, Function],
122
+ default: () => getConfig().upload.limitCountText
123
+ },
124
+ nameField: {
125
+ type: String,
126
+ default: () => getConfig().upload.nameField
127
+ },
128
+ typeField: {
129
+ type: String,
130
+ default: () => getConfig().upload.typeField
131
+ },
132
+ urlField: {
133
+ type: String,
134
+ default: () => getConfig().upload.urlField
135
+ },
136
+ sizeField: {
137
+ type: String,
138
+ default: () => getConfig().upload.sizeField
139
+ },
140
+ showErrorStatus: {
141
+ type: Boolean,
142
+ default: () => getConfig().upload.showErrorStatus
143
+ },
144
+ showProgress: {
145
+ type: Boolean,
146
+ default: () => getConfig().upload.showProgress
147
+ },
148
+ progressText: {
149
+ type: [String, Number, Function],
150
+ default: () => getConfig().upload.progressText
151
+ },
152
+ previewImageConfig: Object,
153
+ showSubmitButton: Boolean,
154
+ autoHiddenButton: {
155
+ type: Boolean,
156
+ default: () => getConfig().upload.autoHiddenButton
157
+ },
158
+ showUploadButton: {
159
+ type: Boolean,
160
+ default: () => getConfig().upload.showUploadButton
161
+ },
162
+ buttonText: {
163
+ type: [String, Number, Function],
164
+ default: () => getConfig().upload.buttonText
165
+ },
166
+ buttonIcon: {
167
+ type: String,
168
+ default: () => getConfig().upload.buttonIcon
169
+ },
170
+ showButtonText: {
171
+ type: Boolean,
172
+ default: () => getConfig().upload.showButtonText
173
+ },
174
+ showButtonIcon: {
175
+ type: Boolean,
176
+ default: () => getConfig().upload.showButtonIcon
177
+ },
178
+ showRemoveButton: {
179
+ type: Boolean,
180
+ default: () => getConfig().upload.showRemoveButton
181
+ },
182
+ showDownloadButton: {
183
+ type: Boolean,
184
+ default: () => getConfig().upload.showDownloadButton
185
+ },
186
+ showPreview: {
187
+ type: Boolean,
188
+ default: () => getConfig().upload.showPreview
189
+ },
190
+ showTip: {
191
+ type: Boolean,
192
+ default: () => null
193
+ },
194
+ maxSimultaneousUploads: {
195
+ type: Number,
196
+ default: () => getConfig().upload.maxSimultaneousUploads
197
+ },
198
+ tipText: [String, Number, Function],
199
+ hintText: String,
200
+ previewMethod: Function,
201
+ beforeSelectMethod: Function,
202
+ uploadMethod: Function,
203
+ beforeRemoveMethod: Function,
204
+ removeMethod: Function,
205
+ beforeDownloadMethod: Function,
206
+ downloadMethod: Function,
207
+ getUrlMethod: Function,
208
+ getThumbnailUrlMethod: Function,
209
+ size: {
210
+ type: String,
211
+ default: () => getConfig().upload.size || getConfig().size
212
+ }
195
213
  },
196
- tipText: [String, Number, Function],
197
- hintText: String,
198
- previewMethod: Function,
199
- beforeSelectMethod: Function,
200
- uploadMethod: Function,
201
- beforeRemoveMethod: Function,
202
- removeMethod: Function,
203
- beforeDownloadMethod: Function,
204
- downloadMethod: Function,
205
- getUrlMethod: Function,
206
- getThumbnailUrlMethod: Function,
207
- size: {
208
- type: String,
209
- default: () => getConfig().upload.size || getConfig().size
210
- }
211
- },
212
- emits: ["update:modelValue", "change", "add", "remove", "remove-fail", "download", "download-fail", "upload-start", "upload-success", "upload-error", "upload-end", "upload-queue-start", "upload-queue-end", "sort-dragend", "more-visible"],
213
- setup(props, context) {
214
- const { emit, slots } = context;
215
- const $xeForm = inject("$xeForm", null);
216
- const formItemInfo = inject("xeFormItemInfo", null);
217
- const $xeTable = inject("$xeTable", null);
218
- const xID = XEUtils.uniqueId();
219
- const { computeSize } = useFns.useSize(props);
220
- const refElem = ref();
221
- const refPopupElem = ref();
222
- const refDragLineElem = ref();
223
- const refModalDragLineElem = ref();
224
- const reactData = reactive(createReactData());
225
- const internalData = createInternalData();
226
- const refMaps = {
227
- refElem
228
- };
229
- const computeFormReadonly = computed(() => {
230
- const { readonly } = props;
231
- if (readonly === null) {
232
- if ($xeForm) {
233
- return $xeForm.props.readonly;
214
+ emits: ["update:modelValue", "change", "add", "remove", "remove-fail", "download", "download-fail", "upload-start", "upload-success", "upload-error", "upload-end", "upload-queue-start", "upload-queue-end", "sort-dragend", "more-visible"],
215
+ setup(props, context) {
216
+ const { emit, slots } = context;
217
+ const $xeForm = inject("$xeForm", null);
218
+ const formItemInfo = inject("xeFormItemInfo", null);
219
+ const $xeTable = inject("$xeTable", null);
220
+ const xID = XEUtils.uniqueId();
221
+ const { computeSize } = useFns.useSize(props);
222
+ const refElem = ref();
223
+ const refPopupElem = ref();
224
+ const refDragLineElem = ref();
225
+ const refModalDragLineElem = ref();
226
+ const reactData = reactive(createReactData());
227
+ const internalData = createInternalData();
228
+ const refMaps = {
229
+ refElem
230
+ };
231
+ const computeFormReadonly = computed(() => {
232
+ const { readonly } = props;
233
+ if (readonly === null) {
234
+ if ($xeForm) {
235
+ return $xeForm.props.readonly;
236
+ }
237
+ return false;
234
238
  }
235
- return false;
236
- }
237
- return readonly;
238
- });
239
- const computeIsDisabled = computed(() => {
240
- const { disabled } = props;
241
- if (disabled === null) {
242
- if ($xeForm) {
243
- return $xeForm.props.disabled;
239
+ return readonly;
240
+ });
241
+ const computeIsDisabled = computed(() => {
242
+ const { disabled } = props;
243
+ if (disabled === null) {
244
+ if ($xeForm) {
245
+ return $xeForm.props.disabled;
246
+ }
247
+ return false;
244
248
  }
245
- return false;
246
- }
247
- return disabled;
248
- });
249
- const computeKeyField = computed(() => {
250
- return props.keyField || "_X_KEY";
251
- });
252
- const computeIsImage = computed(() => {
253
- return props.mode === "image";
254
- });
255
- const computeNameProp = computed(() => {
256
- return props.nameField || "name";
257
- });
258
- const computeTypeProp = computed(() => {
259
- return props.typeField || "type";
260
- });
261
- const computeUrlProp = computed(() => {
262
- return props.urlField || "url";
263
- });
264
- const computeSizeProp = computed(() => {
265
- return props.sizeField || "size";
266
- });
267
- const computeLimitMaxSize = computed(() => {
268
- return XEUtils.toNumber(props.limitSize) * 1024 * 1024;
269
- });
270
- const computeLimitMaxCount = computed(() => {
271
- return props.multiple ? XEUtils.toNumber(props.limitCount) : 1;
272
- });
273
- const computePreviewImageOpts = computed(() => {
274
- const { showDownloadButton } = props;
275
- return Object.assign(
276
- {
277
- showDownloadButton
278
- },
279
- getConfig().upload.previewImageConfig,
280
- props.previewImageConfig
281
- );
282
- });
283
- const computeOverCount = computed(() => {
284
- const { multiple } = props;
285
- const { fileList } = reactData;
286
- const limitMaxCount = computeLimitMaxCount.value;
287
- if (multiple) {
288
- if (limitMaxCount) {
289
- return fileList.length >= limitMaxCount;
249
+ return disabled;
250
+ });
251
+ const computeKeyField = computed(() => {
252
+ return props.keyField || "_X_KEY";
253
+ });
254
+ const computeIsImage = computed(() => {
255
+ return props.mode === "image";
256
+ });
257
+ const computeNameProp = computed(() => {
258
+ return props.nameField || "name";
259
+ });
260
+ const computeTypeProp = computed(() => {
261
+ return props.typeField || "type";
262
+ });
263
+ const computeUrlProp = computed(() => {
264
+ return props.urlField || "url";
265
+ });
266
+ const computeSizeProp = computed(() => {
267
+ return props.sizeField || "size";
268
+ });
269
+ const computeLimitMaxSize = computed(() => {
270
+ return XEUtils.toNumber(props.limitSize) * 1024 * 1024;
271
+ });
272
+ const computeLimitMaxCount = computed(() => {
273
+ return props.multiple ? XEUtils.toNumber(props.limitCount) : 1;
274
+ });
275
+ const computePreviewImageOpts = computed(() => {
276
+ const { showDownloadButton } = props;
277
+ return Object.assign(
278
+ {
279
+ showDownloadButton
280
+ },
281
+ getConfig().upload.previewImageConfig,
282
+ props.previewImageConfig
283
+ );
284
+ });
285
+ const computeOverCount = computed(() => {
286
+ const { multiple } = props;
287
+ const { fileList } = reactData;
288
+ const limitMaxCount = computeLimitMaxCount.value;
289
+ if (multiple) {
290
+ if (limitMaxCount) {
291
+ return fileList.length >= limitMaxCount;
292
+ }
293
+ return true;
290
294
  }
291
- return true;
292
- }
293
- return fileList.length >= 1;
294
- });
295
- const computeLimitSizeUnit = computed(() => {
296
- const limitSize = XEUtils.toNumber(props.limitSize);
297
- if (limitSize) {
298
- if (limitSize > 1048576) {
299
- return `${limitSize / 1048576}T`;
295
+ return fileList.length >= 1;
296
+ });
297
+ const computeLimitSizeUnit = computed(() => {
298
+ const limitSize = XEUtils.toNumber(props.limitSize);
299
+ if (limitSize) {
300
+ if (limitSize > 1048576) {
301
+ return `${limitSize / 1048576}T`;
302
+ }
303
+ if (limitSize > 1024) {
304
+ return `${limitSize / 1024}G`;
305
+ }
306
+ return `${limitSize}M`;
300
307
  }
301
- if (limitSize > 1024) {
302
- return `${limitSize / 1024}G`;
308
+ return "";
309
+ });
310
+ const computedShowTipText = computed(() => {
311
+ const { showTip, tipText } = props;
312
+ if (XEUtils.isBoolean(showTip)) {
313
+ return showTip;
303
314
  }
304
- return `${limitSize}M`;
305
- }
306
- return "";
307
- });
308
- const computedShowTipText = computed(() => {
309
- const { showTip, tipText } = props;
310
- if (XEUtils.isBoolean(showTip)) {
311
- return showTip;
312
- }
313
- const defShowTip = getConfig().upload.showTip;
314
- if (XEUtils.isBoolean(defShowTip)) {
315
- return defShowTip;
316
- }
317
- if (tipText) {
318
- return true;
319
- }
320
- return false;
321
- });
322
- const computedDefTipText = computed(() => {
323
- const { limitSize, fileTypes, multiple, limitCount } = props;
324
- const tipText = props.tipText || props.hintText;
325
- const isImage = computeIsImage.value;
326
- const limitSizeUnit = computeLimitSizeUnit.value;
327
- if (XEUtils.isString(tipText)) {
328
- return tipText;
329
- }
330
- if (XEUtils.isFunction(tipText)) {
331
- return `${tipText({})}`;
332
- }
333
- const defTips = [];
334
- if (isImage) {
335
- if (multiple && limitCount) {
336
- defTips.push(getI18n("vxe.upload.imgCountHint", [limitCount]));
315
+ const defShowTip = getConfig().upload.showTip;
316
+ if (XEUtils.isBoolean(defShowTip)) {
317
+ return defShowTip;
337
318
  }
338
- if (limitSize && limitSizeUnit) {
339
- defTips.push(getI18n("vxe.upload.imgSizeHint", [limitSizeUnit]));
319
+ if (tipText) {
320
+ return true;
340
321
  }
341
- } else {
342
- if (fileTypes && fileTypes.length) {
343
- defTips.push(getI18n("vxe.upload.fileTypeHint", [fileTypes.join("/")]));
322
+ return false;
323
+ });
324
+ const computedDefTipText = computed(() => {
325
+ const { limitSize, fileTypes, multiple, limitCount } = props;
326
+ const tipText = props.tipText || props.hintText;
327
+ const isImage = computeIsImage.value;
328
+ const limitSizeUnit = computeLimitSizeUnit.value;
329
+ if (XEUtils.isString(tipText)) {
330
+ return tipText;
344
331
  }
345
- if (limitSize && limitSizeUnit) {
346
- defTips.push(getI18n("vxe.upload.fileSizeHint", [limitSizeUnit]));
332
+ if (XEUtils.isFunction(tipText)) {
333
+ return `${tipText({})}`;
347
334
  }
348
- if (multiple && limitCount) {
349
- defTips.push(getI18n("vxe.upload.fileCountHint", [limitCount]));
335
+ const defTips = [];
336
+ if (isImage) {
337
+ if (multiple && limitCount) {
338
+ defTips.push(getI18n("vxe.upload.imgCountHint", [limitCount]));
339
+ }
340
+ if (limitSize && limitSizeUnit) {
341
+ defTips.push(getI18n("vxe.upload.imgSizeHint", [limitSizeUnit]));
342
+ }
343
+ } else {
344
+ if (fileTypes && fileTypes.length) {
345
+ defTips.push(getI18n("vxe.upload.fileTypeHint", [fileTypes.join("/")]));
346
+ }
347
+ if (limitSize && limitSizeUnit) {
348
+ defTips.push(getI18n("vxe.upload.fileSizeHint", [limitSizeUnit]));
349
+ }
350
+ if (multiple && limitCount) {
351
+ defTips.push(getI18n("vxe.upload.fileCountHint", [limitCount]));
352
+ }
350
353
  }
351
- }
352
- return defTips.join(getI18n("vxe.base.comma"));
353
- });
354
- const computeImageOpts = computed(() => {
355
- return Object.assign({}, props.imageConfig || props.imageStyle);
356
- });
357
- const computeImgStyle = computed(() => {
358
- const imageOpts = computeImageOpts.value;
359
- const { width, height } = imageOpts;
360
- const stys = {};
361
- if (width) {
362
- stys.width = toCssUnit(width);
363
- }
364
- if (height) {
365
- stys.height = toCssUnit(height);
366
- }
367
- return stys;
368
- });
369
- const computeMoreOpts = computed(() => {
370
- return Object.assign({ showMoreButton: true }, props.moreConfig);
371
- });
372
- const computeMaps = {
373
- computeUrlProp
374
- };
375
- const $xeUpload = {
376
- xID,
377
- props,
378
- context,
379
- reactData,
380
- internalData,
381
- getRefMaps: () => refMaps,
382
- getComputeMaps: () => computeMaps
383
- };
384
- const getUniqueKey = () => {
385
- return XEUtils.uniqueId();
386
- };
387
- const getFieldKey = (item) => {
388
- const keyField = computeKeyField.value;
389
- return item[keyField];
390
- };
391
- const updateFileList = () => {
392
- const { modelValue, multiple } = props;
393
- const formReadonly = computeFormReadonly.value;
394
- const keyField = computeKeyField.value;
395
- const nameProp = computeNameProp.value;
396
- const typeProp = computeTypeProp.value;
397
- const urlProp = computeUrlProp.value;
398
- const sizeProp = computeSizeProp.value;
399
- const fileList = modelValue ? (modelValue ? XEUtils.isArray(modelValue) ? modelValue : [modelValue] : []).map((item) => {
400
- if (!item || XEUtils.isString(item)) {
401
- const url = `${item || ""}`;
402
- const urlObj = XEUtils.parseUrl(item);
403
- const name2 = (urlObj ? urlObj.searchQuery[nameProp] : "") || parseFileName(url);
404
- return {
405
- [nameProp]: name2,
406
- [typeProp]: (urlObj ? urlObj.searchQuery[typeProp] : "") || parseFileType(name2),
407
- [urlProp]: url,
408
- [sizeProp]: XEUtils.toNumber(urlObj ? urlObj.searchQuery[sizeProp] : 0) || 0,
409
- [keyField]: getUniqueKey()
410
- };
354
+ return defTips.join(getI18n("vxe.base.comma"));
355
+ });
356
+ const computeImageOpts = computed(() => {
357
+ return Object.assign({}, props.imageConfig || props.imageStyle);
358
+ });
359
+ const computeImgStyle = computed(() => {
360
+ const imageOpts = computeImageOpts.value;
361
+ const { width, height } = imageOpts;
362
+ const stys = {};
363
+ if (width) {
364
+ stys.width = toCssUnit(width);
411
365
  }
412
- const name = item[nameProp] || "";
413
- item[nameProp] = name;
414
- item[typeProp] = item[typeProp] || parseFileType(name);
415
- item[urlProp] = item[urlProp] || "";
416
- item[sizeProp] = item[sizeProp] || 0;
417
- item[keyField] = item[keyField] || getUniqueKey();
418
- return item;
419
- }) : [];
420
- reactData.fileList = formReadonly || multiple ? fileList : fileList.slice(0, 1);
421
- };
422
- const parseFileName = (url) => {
423
- return decodeURIComponent(`${url || ""}`).split("/").pop() || "";
424
- };
425
- const parseFileType = (name) => {
426
- const index = name.lastIndexOf(".");
427
- if (index > 0) {
428
- return name.substring(index + 1).toLowerCase();
429
- }
430
- return "";
431
- };
432
- const dispatchEvent = (type, params, evnt) => {
433
- emit(type, createEvent(evnt, { $upload: $xeUpload }, params));
434
- };
435
- const emitModel = (value) => {
436
- emit("update:modelValue", value);
437
- };
438
- const handleModel = (vals) => {
439
- const { singleMode, urlMode, urlArgs } = props;
440
- const urlProp = computeUrlProp.value;
441
- const nameProp = computeNameProp.value;
442
- let restList = vals ? vals.slice(0) : [];
443
- if (urlMode) {
444
- restList = restList.map((item) => {
445
- const url = item[urlProp];
446
- if (url && urlArgs) {
447
- const urlObj = XEUtils.parseUrl(url);
448
- if (!urlObj.searchQuery[nameProp]) {
449
- if (url.indexOf("blob:") === -1) {
450
- return `${url}${url.indexOf("?") === -1 ? "?" : "&"}${nameProp}=${encodeURIComponent(item[nameProp] || "")}`;
366
+ if (height) {
367
+ stys.height = toCssUnit(height);
368
+ }
369
+ return stys;
370
+ });
371
+ const computeMoreOpts = computed(() => {
372
+ return Object.assign({ showMoreButton: true }, props.moreConfig);
373
+ });
374
+ const computeMaps = {
375
+ computeUrlProp
376
+ };
377
+ const $xeUpload = {
378
+ xID,
379
+ props,
380
+ context,
381
+ reactData,
382
+ internalData,
383
+ getRefMaps: () => refMaps,
384
+ getComputeMaps: () => computeMaps
385
+ };
386
+ const getUniqueKey = () => {
387
+ return XEUtils.uniqueId();
388
+ };
389
+ const getFieldKey = (item) => {
390
+ const keyField = computeKeyField.value;
391
+ return item[keyField];
392
+ };
393
+ const updateFileList = () => {
394
+ const { modelValue, multiple } = props;
395
+ const formReadonly = computeFormReadonly.value;
396
+ const keyField = computeKeyField.value;
397
+ const nameProp = computeNameProp.value;
398
+ const typeProp = computeTypeProp.value;
399
+ const urlProp = computeUrlProp.value;
400
+ const sizeProp = computeSizeProp.value;
401
+ const fileList = modelValue ? (modelValue ? XEUtils.isArray(modelValue) ? modelValue : [modelValue] : []).map((item) => {
402
+ if (!item || XEUtils.isString(item)) {
403
+ const url = `${item || ""}`;
404
+ const urlObj = XEUtils.parseUrl(item);
405
+ const name2 = (urlObj ? urlObj.searchQuery[nameProp] : "") || parseFileName(url);
406
+ return {
407
+ [nameProp]: name2,
408
+ [typeProp]: (urlObj ? urlObj.searchQuery[typeProp] : "") || parseFileType(name2),
409
+ [urlProp]: url,
410
+ [sizeProp]: XEUtils.toNumber(urlObj ? urlObj.searchQuery[sizeProp] : 0) || 0,
411
+ [keyField]: getUniqueKey()
412
+ };
413
+ }
414
+ const name = item[nameProp] || "";
415
+ item[nameProp] = name;
416
+ item[typeProp] = item[typeProp] || parseFileType(name);
417
+ item[urlProp] = item[urlProp] || "";
418
+ item[sizeProp] = item[sizeProp] || 0;
419
+ item[keyField] = item[keyField] || getUniqueKey();
420
+ return item;
421
+ }) : [];
422
+ reactData.fileList = formReadonly || multiple ? fileList : fileList.slice(0, 1);
423
+ };
424
+ const parseFileName = (url) => {
425
+ return decodeURIComponent(`${url || ""}`).split("/").pop() || "";
426
+ };
427
+ const parseFileType = (name) => {
428
+ const index = name.lastIndexOf(".");
429
+ if (index > 0) {
430
+ return name.substring(index + 1).toLowerCase();
431
+ }
432
+ return "";
433
+ };
434
+ const dispatchEvent = (type, params, evnt) => {
435
+ emit(type, createEvent(evnt, { $upload: $xeUpload }, params));
436
+ };
437
+ const emitModel = (value) => {
438
+ emit("update:modelValue", value);
439
+ };
440
+ const handleModel = (vals) => {
441
+ const { singleMode, urlMode, urlArgs } = props;
442
+ const urlProp = computeUrlProp.value;
443
+ const nameProp = computeNameProp.value;
444
+ let restList = vals ? vals.slice(0) : [];
445
+ if (urlMode) {
446
+ restList = restList.map((item) => {
447
+ const url = item[urlProp];
448
+ if (url && urlArgs) {
449
+ const urlObj = XEUtils.parseUrl(url);
450
+ if (!urlObj.searchQuery[nameProp]) {
451
+ if (url.indexOf("blob:") === -1) {
452
+ return `${url}${url.indexOf("?") === -1 ? "?" : "&"}${nameProp}=${encodeURIComponent(item[nameProp] || "")}`;
453
+ }
451
454
  }
452
455
  }
453
- }
454
- return url;
455
- });
456
- }
457
- const value = singleMode ? restList[0] || null : restList;
458
- emitModel(value);
459
- return value;
460
- };
461
- const handleChangeEvent = (evnt, vals) => {
462
- const value = handleModel(vals);
463
- dispatchEvent("change", { value }, evnt);
464
- return value;
465
- };
466
- const getThumbnailFileUrl = (item) => {
467
- const getThumbnailUrlFn = props.getThumbnailUrlMethod || getConfig().upload.getThumbnailUrlMethod;
468
- if (getThumbnailUrlFn) {
469
- return getThumbnailUrlFn({
470
- $upload: $xeUpload,
471
- option: item
472
- });
473
- }
474
- return getFileUrl(item);
475
- };
476
- const getFileUrl = (item) => {
477
- const getUrlFn = props.getUrlMethod || getConfig().upload.getUrlMethod;
478
- const urlProp = computeUrlProp.value;
479
- return getUrlFn ? getUrlFn({
480
- $upload: $xeUpload,
481
- option: item
482
- }) : item[urlProp];
483
- };
484
- const handleDefaultFilePreview = (item) => {
485
- const { imageTypes, showDownloadButton } = props;
486
- const typeProp = computeTypeProp.value;
487
- const previewImageOpts = computePreviewImageOpts.value;
488
- const beforeDownloadFn = props.beforeDownloadMethod || getConfig().upload.beforeDownloadMethod;
489
- const { imagePreviewTypes } = internalData;
490
- if (imagePreviewTypes.concat(imageTypes || []).some((type) => `${type}`.toLowerCase() === `${item[typeProp]}`.toLowerCase())) {
491
- if (VxeUI.previewImage) {
492
- VxeUI.previewImage({
493
- ...previewImageOpts,
494
- urlList: [getFileUrl(item)],
495
- showDownloadButton,
496
- beforeDownloadMethod: beforeDownloadFn ? () => {
497
- return beforeDownloadFn({
498
- $upload: $xeUpload,
499
- option: item
500
- });
501
- } : void 0
456
+ return url;
502
457
  });
503
458
  }
504
- }
505
- };
506
- const handlePreviewFileEvent = (evnt, item) => {
507
- const previewFn = props.previewMethod || getConfig().upload.previewMethod;
508
- if (props.showPreview) {
509
- if (previewFn) {
510
- previewFn({
459
+ const value = singleMode ? restList[0] || null : restList;
460
+ emitModel(value);
461
+ return value;
462
+ };
463
+ const handleChangeEvent = (evnt, vals) => {
464
+ const value = handleModel(vals);
465
+ dispatchEvent("change", { value }, evnt);
466
+ return value;
467
+ };
468
+ const getThumbnailFileUrl = (item) => {
469
+ const getThumbnailUrlFn = props.getThumbnailUrlMethod || getConfig().upload.getThumbnailUrlMethod;
470
+ if (getThumbnailUrlFn) {
471
+ return getThumbnailUrlFn({
511
472
  $upload: $xeUpload,
512
473
  option: item
513
474
  });
514
- } else {
515
- handleDefaultFilePreview(item);
516
475
  }
517
- }
518
- };
519
- const handlePreviewImageEvent = (evnt, item, index) => {
520
- const { showDownloadButton } = props;
521
- const { fileList } = reactData;
522
- const previewImageOpts = computePreviewImageOpts.value;
523
- const previewFn = props.previewMethod || getConfig().upload.previewMethod;
524
- const beforeDownloadFn = props.beforeDownloadMethod || getConfig().upload.beforeDownloadMethod;
525
- if (props.showPreview) {
526
- if (previewFn) {
527
- previewFn({
528
- $upload: $xeUpload,
529
- option: item
530
- });
531
- } else if (VxeUI.previewImage) {
532
- VxeUI.previewImage({
533
- ...previewImageOpts,
534
- urlList: fileList.map((item2) => getFileUrl(item2)),
535
- activeIndex: index,
536
- showDownloadButton,
537
- beforeDownloadMethod: beforeDownloadFn ? ({ index: index2 }) => {
538
- return beforeDownloadFn({
539
- $upload: $xeUpload,
540
- option: fileList[index2]
541
- });
542
- } : void 0
543
- });
476
+ return getFileUrl(item);
477
+ };
478
+ const getFileUrl = (item) => {
479
+ const getUrlFn = props.getUrlMethod || getConfig().upload.getUrlMethod;
480
+ const urlProp = computeUrlProp.value;
481
+ return getUrlFn ? getUrlFn({
482
+ $upload: $xeUpload,
483
+ option: item
484
+ }) : item[urlProp];
485
+ };
486
+ const handleDefaultFilePreview = (item) => {
487
+ const { imageTypes, showDownloadButton } = props;
488
+ const typeProp = computeTypeProp.value;
489
+ const previewImageOpts = computePreviewImageOpts.value;
490
+ const beforeDownloadFn = props.beforeDownloadMethod || getConfig().upload.beforeDownloadMethod;
491
+ const { imagePreviewTypes } = internalData;
492
+ if (imagePreviewTypes.concat(imageTypes || []).some((type) => `${type}`.toLowerCase() === `${item[typeProp]}`.toLowerCase())) {
493
+ if (VxeUI.previewImage) {
494
+ VxeUI.previewImage({
495
+ ...previewImageOpts,
496
+ urlList: [getFileUrl(item)],
497
+ showDownloadButton,
498
+ beforeDownloadMethod: beforeDownloadFn ? () => {
499
+ return beforeDownloadFn({
500
+ $upload: $xeUpload,
501
+ option: item
502
+ });
503
+ } : void 0
504
+ });
505
+ }
544
506
  }
545
- }
546
- };
547
- const handleUploadResult = (item, file) => {
548
- const { showErrorStatus } = props;
549
- const fileKey = getFieldKey(item);
550
- const uploadFn = props.uploadMethod || getConfig().upload.uploadMethod;
551
- if (uploadFn) {
552
- dispatchEvent("upload-start", { option: item }, null);
553
- return Promise.resolve(
554
- uploadFn({
555
- $upload: $xeUpload,
556
- file,
557
- option: item,
558
- updateProgress(percentNum) {
559
- const { fileCacheMaps } = reactData;
560
- const cacheItem = fileCacheMaps[getFieldKey(item)];
561
- if (cacheItem) {
562
- cacheItem.percent = Math.max(0, Math.min(99, XEUtils.toNumber(percentNum)));
563
- }
564
- }
565
- })
566
- ).then((res) => {
567
- const { fileCacheMaps } = reactData;
568
- const cacheItem = fileCacheMaps[fileKey];
569
- if (cacheItem) {
570
- cacheItem.percent = 100;
571
- cacheItem.status = "success";
572
- cacheItem.response = res;
507
+ };
508
+ const handlePreviewFileEvent = (evnt, item) => {
509
+ const previewFn = props.previewMethod || getConfig().upload.previewMethod;
510
+ if (props.showPreview) {
511
+ if (previewFn) {
512
+ previewFn({
513
+ $upload: $xeUpload,
514
+ option: item
515
+ });
516
+ } else {
517
+ handleDefaultFilePreview(item);
573
518
  }
574
- Object.assign(item, res);
575
- handleModel(reactData.fileList);
576
- dispatchEvent("upload-success", { option: item, data: res }, null);
577
- }).catch((res) => {
578
- const { fileCacheMaps } = reactData;
579
- const cacheItem = fileCacheMaps[fileKey];
580
- if (cacheItem) {
581
- cacheItem.status = "error";
582
- cacheItem.response = res;
519
+ }
520
+ };
521
+ const handlePreviewImageEvent = (evnt, item, index) => {
522
+ const { showDownloadButton } = props;
523
+ const { fileList } = reactData;
524
+ const previewImageOpts = computePreviewImageOpts.value;
525
+ const previewFn = props.previewMethod || getConfig().upload.previewMethod;
526
+ const beforeDownloadFn = props.beforeDownloadMethod || getConfig().upload.beforeDownloadMethod;
527
+ if (props.showPreview) {
528
+ if (previewFn) {
529
+ previewFn({
530
+ $upload: $xeUpload,
531
+ option: item
532
+ });
533
+ } else if (VxeUI.previewImage) {
534
+ VxeUI.previewImage({
535
+ ...previewImageOpts,
536
+ urlList: fileList.map((item2) => getFileUrl(item2)),
537
+ activeIndex: index,
538
+ showDownloadButton,
539
+ beforeDownloadMethod: beforeDownloadFn ? ({ index: index2 }) => {
540
+ return beforeDownloadFn({
541
+ $upload: $xeUpload,
542
+ option: fileList[index2]
543
+ });
544
+ } : void 0
545
+ });
583
546
  }
584
- if (showErrorStatus) {
547
+ }
548
+ };
549
+ const handleUploadResult = (item, file) => {
550
+ const { showErrorStatus } = props;
551
+ const fileKey = getFieldKey(item);
552
+ const uploadFn = props.uploadMethod || getConfig().upload.uploadMethod;
553
+ if (uploadFn) {
554
+ dispatchEvent("upload-start", { option: item }, null);
555
+ return Promise.resolve(
556
+ uploadFn({
557
+ $upload: $xeUpload,
558
+ file,
559
+ option: item,
560
+ updateProgress(percentNum) {
561
+ const { fileCacheMaps } = reactData;
562
+ const cacheItem = fileCacheMaps[getFieldKey(item)];
563
+ if (cacheItem) {
564
+ cacheItem.percent = Math.max(0, Math.min(99, XEUtils.toNumber(percentNum)));
565
+ }
566
+ }
567
+ })
568
+ ).then((res) => {
569
+ const { fileCacheMaps } = reactData;
570
+ const cacheItem = fileCacheMaps[fileKey];
571
+ if (cacheItem) {
572
+ cacheItem.percent = 100;
573
+ cacheItem.status = "success";
574
+ cacheItem.response = res;
575
+ }
585
576
  Object.assign(item, res);
586
- } else {
587
- reactData.fileList = reactData.fileList.filter((obj) => getFieldKey(obj) !== fileKey);
588
- delete fileCacheMaps[fileKey];
589
- }
590
- handleModel(reactData.fileList);
591
- dispatchEvent("upload-error", { option: item, data: res }, null);
592
- }).finally(() => {
577
+ handleModel(reactData.fileList);
578
+ dispatchEvent("upload-success", { option: item, data: res }, null);
579
+ }).catch((res) => {
580
+ const { fileCacheMaps } = reactData;
581
+ const cacheItem = fileCacheMaps[fileKey];
582
+ if (cacheItem) {
583
+ cacheItem.status = "error";
584
+ cacheItem.response = res;
585
+ }
586
+ if (showErrorStatus) {
587
+ Object.assign(item, res);
588
+ } else {
589
+ reactData.fileList = reactData.fileList.filter((obj) => getFieldKey(obj) !== fileKey);
590
+ delete fileCacheMaps[fileKey];
591
+ }
592
+ handleModel(reactData.fileList);
593
+ dispatchEvent("upload-error", { option: item, data: res }, null);
594
+ }).finally(() => {
595
+ const { fileCacheMaps } = reactData;
596
+ const cacheItem = fileCacheMaps[fileKey];
597
+ if (cacheItem) {
598
+ cacheItem.loading = false;
599
+ }
600
+ const result = {
601
+ option: item,
602
+ status: cacheItem ? cacheItem.status : null,
603
+ response: cacheItem ? cacheItem.response : null
604
+ };
605
+ dispatchEvent("upload-end", { option: item, result }, null);
606
+ });
607
+ } else {
593
608
  const { fileCacheMaps } = reactData;
594
609
  const cacheItem = fileCacheMaps[fileKey];
595
610
  if (cacheItem) {
596
611
  cacheItem.loading = false;
597
612
  }
598
- const result = {
599
- option: item,
600
- status: cacheItem ? cacheItem.status : null,
601
- response: cacheItem ? cacheItem.response : null
602
- };
603
- dispatchEvent("upload-end", { option: item, result }, null);
604
- });
605
- } else {
613
+ }
614
+ return Promise.resolve();
615
+ };
616
+ const handleReUploadEvent = (evnt, item) => {
617
+ const { uploadMethod, urlMode } = props;
606
618
  const { fileCacheMaps } = reactData;
619
+ const fileKey = getFieldKey(item);
607
620
  const cacheItem = fileCacheMaps[fileKey];
608
- if (cacheItem) {
609
- cacheItem.loading = false;
610
- }
611
- }
612
- return Promise.resolve();
613
- };
614
- const handleReUploadEvent = (evnt, item) => {
615
- const { uploadMethod, urlMode } = props;
616
- const { fileCacheMaps } = reactData;
617
- const fileKey = getFieldKey(item);
618
- const cacheItem = fileCacheMaps[fileKey];
619
- const uploadFn = uploadMethod || getConfig().upload.uploadMethod;
620
- if (uploadFn && cacheItem) {
621
- const file = cacheItem.file;
622
- cacheItem.loading = true;
623
- cacheItem.status = "pending";
624
- cacheItem.percent = 0;
625
- handleUploadResult(item, file).then(() => {
626
- if (urlMode) {
627
- handleChangeEvent(evnt, reactData.fileList);
628
- }
629
- });
630
- }
631
- };
632
- const handleUploadFile = (files, evnt) => {
633
- const { multiple, showLimitSize, limitSizeText, showLimitCount, limitCountText, autoSubmit } = props;
634
- const { fileList } = reactData;
635
- const beforeSelectFn = props.beforeSelectMethod || getConfig().upload.beforeSelectMethod;
636
- const uploadFn = props.uploadMethod || getConfig().upload.uploadMethod;
637
- const keyField = computeKeyField.value;
638
- const nameProp = computeNameProp.value;
639
- const typeProp = computeTypeProp.value;
640
- const urlProp = computeUrlProp.value;
641
- const sizeProp = computeSizeProp.value;
642
- const limitMaxSize = computeLimitMaxSize.value;
643
- const limitMaxCount = computeLimitMaxCount.value;
644
- const limitSizeUnit = computeLimitSizeUnit.value;
645
- let selectFiles = files;
646
- if (multiple && limitMaxCount) {
647
- if (showLimitCount && fileList.length >= limitMaxCount) {
648
- if (VxeUI.modal) {
649
- VxeUI.modal.notification({
650
- title: getI18n("vxe.modal.errTitle"),
651
- status: "error",
652
- content: limitCountText ? `${XEUtils.isFunction(limitCountText) ? limitCountText({ maxCount: limitMaxCount }) : limitCountText}` : getI18n("vxe.upload.overCountErr", [limitMaxCount])
653
- });
654
- }
655
- return;
656
- }
657
- const overNum = selectFiles.length - (limitMaxCount - fileList.length);
658
- if (showLimitCount && overNum > 0) {
659
- const overExtraList = selectFiles.slice(limitMaxCount - fileList.length);
660
- if (limitCountText) {
661
- VxeUI.modal.notification({
662
- title: getI18n("vxe.modal.errTitle"),
663
- status: "error",
664
- content: `${XEUtils.isFunction(limitCountText) ? limitCountText({ maxCount: limitMaxCount }) : limitCountText}`
665
- });
666
- } else if (VxeUI.modal) {
667
- VxeUI.modal.notification({
668
- title: getI18n("vxe.modal.errTitle"),
669
- status: "error",
670
- width: null,
671
- slots: {
672
- default() {
673
- return h(
674
- "div",
675
- {
676
- class: "vxe-upload--file-message-over-error"
677
- },
678
- [
679
- h("div", {}, getI18n("vxe.upload.overCountExtraErr", [limitMaxCount, overNum])),
680
- h(
681
- "div",
682
- {
683
- class: "vxe-upload--file-message-over-extra"
684
- },
685
- overExtraList.map((file, index) => {
686
- return h(
687
- "div",
688
- {
689
- key: index,
690
- class: "vxe-upload--file-message-over-extra-item"
691
- },
692
- file.name
693
- );
694
- })
695
- )
696
- ]
697
- );
698
- }
699
- }
700
- });
701
- }
621
+ const uploadFn = uploadMethod || getConfig().upload.uploadMethod;
622
+ if (uploadFn && cacheItem) {
623
+ const file = cacheItem.file;
624
+ cacheItem.loading = true;
625
+ cacheItem.status = "pending";
626
+ cacheItem.percent = 0;
627
+ handleUploadResult(item, file).then(() => {
628
+ if (urlMode) {
629
+ handleChangeEvent(evnt, reactData.fileList);
630
+ }
631
+ });
702
632
  }
703
- selectFiles = selectFiles.slice(0, limitMaxCount - fileList.length);
704
- }
705
- if (showLimitSize && limitMaxSize) {
706
- for (let i = 0; i < files.length; i++) {
707
- const file = files[0];
708
- if (file.size > limitMaxSize) {
633
+ };
634
+ const handleUploadFile = (files, evnt) => {
635
+ const { multiple, showLimitSize, limitSizeText, showLimitCount, limitCountText, autoSubmit } = props;
636
+ const { fileList } = reactData;
637
+ const beforeSelectFn = props.beforeSelectMethod || getConfig().upload.beforeSelectMethod;
638
+ const uploadFn = props.uploadMethod || getConfig().upload.uploadMethod;
639
+ const keyField = computeKeyField.value;
640
+ const nameProp = computeNameProp.value;
641
+ const typeProp = computeTypeProp.value;
642
+ const urlProp = computeUrlProp.value;
643
+ const sizeProp = computeSizeProp.value;
644
+ const limitMaxSize = computeLimitMaxSize.value;
645
+ const limitMaxCount = computeLimitMaxCount.value;
646
+ const limitSizeUnit = computeLimitSizeUnit.value;
647
+ let selectFiles = files;
648
+ if (multiple && limitMaxCount) {
649
+ if (showLimitCount && fileList.length >= limitMaxCount) {
709
650
  if (VxeUI.modal) {
710
651
  VxeUI.modal.notification({
711
652
  title: getI18n("vxe.modal.errTitle"),
712
653
  status: "error",
713
- content: limitSizeText ? `${XEUtils.isFunction(limitSizeText) ? limitSizeText({ maxSize: limitMaxSize }) : limitSizeText}` : getI18n("vxe.upload.overSizeErr", [limitSizeUnit])
654
+ content: limitCountText ? `${XEUtils.isFunction(limitCountText) ? limitCountText({ maxCount: limitMaxCount }) : limitCountText}` : getI18n("vxe.upload.overCountErr", [limitMaxCount])
714
655
  });
715
656
  }
716
657
  return;
717
658
  }
659
+ const overNum = selectFiles.length - (limitMaxCount - fileList.length);
660
+ if (showLimitCount && overNum > 0) {
661
+ const overExtraList = selectFiles.slice(limitMaxCount - fileList.length);
662
+ if (limitCountText) {
663
+ VxeUI.modal.notification({
664
+ title: getI18n("vxe.modal.errTitle"),
665
+ status: "error",
666
+ content: `${XEUtils.isFunction(limitCountText) ? limitCountText({ maxCount: limitMaxCount }) : limitCountText}`
667
+ });
668
+ } else if (VxeUI.modal) {
669
+ VxeUI.modal.notification({
670
+ title: getI18n("vxe.modal.errTitle"),
671
+ status: "error",
672
+ width: null,
673
+ slots: {
674
+ default() {
675
+ return h(
676
+ "div",
677
+ {
678
+ class: "vxe-upload--file-message-over-error"
679
+ },
680
+ [
681
+ h("div", {}, getI18n("vxe.upload.overCountExtraErr", [limitMaxCount, overNum])),
682
+ h(
683
+ "div",
684
+ {
685
+ class: "vxe-upload--file-message-over-extra"
686
+ },
687
+ overExtraList.map((file, index) => {
688
+ return h(
689
+ "div",
690
+ {
691
+ key: index,
692
+ class: "vxe-upload--file-message-over-extra-item"
693
+ },
694
+ file.name
695
+ );
696
+ })
697
+ )
698
+ ]
699
+ );
700
+ }
701
+ }
702
+ });
703
+ }
704
+ }
705
+ selectFiles = selectFiles.slice(0, limitMaxCount - fileList.length);
718
706
  }
719
- }
720
- dispatchEvent("upload-queue-start", { files: selectFiles }, evnt);
721
- const cacheMaps = Object.assign({}, reactData.fileCacheMaps);
722
- const uploadFileList = multiple ? fileList : [];
723
- const newFileList = [];
724
- const uploadPromiseRests = [];
725
- selectFiles.forEach((file) => {
726
- const { name } = file;
727
- const fileKey = getUniqueKey();
728
- const fileObj = {
729
- [nameProp]: name,
730
- [typeProp]: parseFileType(name),
731
- [sizeProp]: file.size,
732
- [urlProp]: URL.createObjectURL(file),
733
- [keyField]: fileKey
734
- };
735
- if (uploadFn) {
736
- cacheMaps[fileKey] = {
737
- file,
738
- loading: !!autoSubmit,
739
- status: "pending",
740
- percent: 0,
741
- response: null
742
- };
743
- }
744
- const item = reactive(fileObj);
745
- if (!beforeSelectFn || beforeSelectFn({ $upload: $xeUpload, file })) {
746
- if (uploadFn && autoSubmit) {
747
- uploadPromiseRests.push(handleUploadResult(item, file));
707
+ if (showLimitSize && limitMaxSize) {
708
+ for (let i = 0; i < files.length; i++) {
709
+ const file = files[0];
710
+ if (file.size > limitMaxSize) {
711
+ if (VxeUI.modal) {
712
+ VxeUI.modal.notification({
713
+ title: getI18n("vxe.modal.errTitle"),
714
+ status: "error",
715
+ content: limitSizeText ? `${XEUtils.isFunction(limitSizeText) ? limitSizeText({ maxSize: limitMaxSize }) : limitSizeText}` : getI18n("vxe.upload.overSizeErr", [limitSizeUnit])
716
+ });
717
+ }
718
+ return;
719
+ }
748
720
  }
749
- newFileList.push(item);
750
- uploadFileList.push(item);
751
721
  }
752
- });
753
- reactData.fileList = uploadFileList;
754
- reactData.fileCacheMaps = cacheMaps;
755
- uploadFileList.forEach((item) => {
756
- dispatchEvent("add", { option: item }, evnt);
757
- });
758
- Promise.all(uploadPromiseRests).then(() => {
759
- const { fileCacheMaps } = reactData;
760
- const restFileList = reactData.fileList;
761
- const uploadResults = newFileList.map((option) => {
762
- const fileKey = getFieldKey(option);
763
- const cacheItem = fileCacheMaps[fileKey];
764
- return {
765
- option,
766
- status: cacheItem ? cacheItem.status : null,
767
- response: cacheItem ? cacheItem.response : null
722
+ dispatchEvent("upload-queue-start", { files: selectFiles }, evnt);
723
+ const cacheMaps = Object.assign({}, reactData.fileCacheMaps);
724
+ const uploadFileList = multiple ? fileList : [];
725
+ const newFileList = [];
726
+ const uploadPromiseRests = [];
727
+ selectFiles.forEach((file) => {
728
+ const { name } = file;
729
+ const fileKey = getUniqueKey();
730
+ const fileObj = {
731
+ [nameProp]: name,
732
+ [typeProp]: parseFileType(name),
733
+ [sizeProp]: file.size,
734
+ [urlProp]: URL.createObjectURL(file),
735
+ [keyField]: fileKey
768
736
  };
737
+ if (uploadFn) {
738
+ cacheMaps[fileKey] = {
739
+ file,
740
+ loading: !!autoSubmit,
741
+ status: "pending",
742
+ percent: 0,
743
+ response: null
744
+ };
745
+ }
746
+ const item = reactive(fileObj);
747
+ if (!beforeSelectFn || beforeSelectFn({ $upload: $xeUpload, file })) {
748
+ if (uploadFn && autoSubmit) {
749
+ uploadPromiseRests.push(handleUploadResult(item, file));
750
+ }
751
+ newFileList.push(item);
752
+ uploadFileList.push(item);
753
+ }
769
754
  });
770
- const value = handleChangeEvent(evnt, restFileList);
771
- dispatchEvent("upload-queue-end", { value, options: restFileList, results: uploadResults, files: selectFiles }, evnt);
772
- if ($xeForm && formItemInfo) {
773
- $xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, value);
755
+ reactData.fileList = uploadFileList;
756
+ reactData.fileCacheMaps = cacheMaps;
757
+ uploadFileList.forEach((item) => {
758
+ dispatchEvent("add", { option: item }, evnt);
759
+ });
760
+ Promise.all(uploadPromiseRests).then(() => {
761
+ const { fileCacheMaps } = reactData;
762
+ const restFileList = reactData.fileList;
763
+ const uploadResults = newFileList.map((option) => {
764
+ const fileKey = getFieldKey(option);
765
+ const cacheItem = fileCacheMaps[fileKey];
766
+ return {
767
+ option,
768
+ status: cacheItem ? cacheItem.status : null,
769
+ response: cacheItem ? cacheItem.response : null
770
+ };
771
+ });
772
+ const value = handleChangeEvent(evnt, restFileList);
773
+ dispatchEvent("upload-queue-end", { value, options: restFileList, results: uploadResults, files: selectFiles }, evnt);
774
+ if ($xeForm && formItemInfo) {
775
+ $xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, value);
776
+ }
777
+ });
778
+ };
779
+ const handleChoose = (evnt) => {
780
+ const { multiple, imageTypes, fileTypes } = props;
781
+ const isDisabled = computeIsDisabled.value;
782
+ const isImage = computeIsImage.value;
783
+ if (isDisabled) {
784
+ return Promise.resolve({
785
+ status: false,
786
+ files: [],
787
+ file: null
788
+ });
774
789
  }
775
- });
776
- };
777
- const handleChoose = (evnt) => {
778
- const { multiple, imageTypes, fileTypes } = props;
779
- const isDisabled = computeIsDisabled.value;
780
- const isImage = computeIsImage.value;
781
- if (isDisabled) {
782
- return Promise.resolve({
783
- status: false,
784
- files: [],
785
- file: null
790
+ return readLocalFile({
791
+ multiple,
792
+ types: isImage ? imageTypes : fileTypes
793
+ }).then((params) => {
794
+ handleUploadFile(params.files, evnt);
795
+ return params;
786
796
  });
787
- }
788
- return readLocalFile({
789
- multiple,
790
- types: isImage ? imageTypes : fileTypes
791
- }).then((params) => {
792
- handleUploadFile(params.files, evnt);
793
- return params;
794
- });
795
- };
796
- const clickEvent = (evnt) => {
797
- handleChoose(evnt).catch(() => {
798
- });
799
- };
800
- const handleRemoveEvent = (evnt, item, index) => {
801
- const { fileList } = reactData;
802
- fileList.splice(index, 1);
803
- handleChangeEvent(evnt, fileList);
804
- if ($xeForm && formItemInfo) {
805
- $xeForm.triggerItemEvent(evnt || { type: "remove" }, formItemInfo.itemConfig.field, fileList);
806
- }
807
- if (evnt) {
808
- dispatchEvent("remove", { option: item }, evnt);
809
- }
810
- };
811
- const removeFileEvent = (evnt, item, index) => {
812
- const beforeRemoveFn = props.beforeRemoveMethod || getConfig().upload.beforeRemoveMethod;
813
- const removeFn = props.removeMethod || getConfig().upload.removeMethod;
814
- return Promise.resolve(
815
- beforeRemoveFn ? beforeRemoveFn({
816
- $upload: $xeUpload,
817
- option: item
818
- }) : true
819
- ).then((status) => {
820
- if (status) {
821
- if (removeFn) {
822
- Promise.resolve(
823
- removeFn({
824
- $upload: $xeUpload,
825
- option: item
826
- })
827
- ).then(() => {
797
+ };
798
+ const clickEvent = (evnt) => {
799
+ handleChoose(evnt).catch(() => {
800
+ });
801
+ };
802
+ const handleRemoveEvent = (evnt, item, index) => {
803
+ const { fileList } = reactData;
804
+ fileList.splice(index, 1);
805
+ handleChangeEvent(evnt, fileList);
806
+ if ($xeForm && formItemInfo) {
807
+ $xeForm.triggerItemEvent(evnt || { type: "remove" }, formItemInfo.itemConfig.field, fileList);
808
+ }
809
+ if (evnt) {
810
+ dispatchEvent("remove", { option: item }, evnt);
811
+ }
812
+ };
813
+ const removeFileEvent = (evnt, item, index) => {
814
+ const beforeRemoveFn = props.beforeRemoveMethod || getConfig().upload.beforeRemoveMethod;
815
+ const removeFn = props.removeMethod || getConfig().upload.removeMethod;
816
+ return Promise.resolve(
817
+ beforeRemoveFn ? beforeRemoveFn({
818
+ $upload: $xeUpload,
819
+ option: item
820
+ }) : true
821
+ ).then((status) => {
822
+ if (status) {
823
+ if (removeFn) {
824
+ Promise.resolve(
825
+ removeFn({
826
+ $upload: $xeUpload,
827
+ option: item
828
+ })
829
+ ).then(() => {
830
+ handleRemoveEvent(evnt, item, index);
831
+ }).catch((e) => e);
832
+ } else {
828
833
  handleRemoveEvent(evnt, item, index);
829
- }).catch((e) => e);
834
+ }
830
835
  } else {
831
- handleRemoveEvent(evnt, item, index);
836
+ if (evnt) {
837
+ dispatchEvent("remove-fail", { option: item }, evnt);
838
+ }
832
839
  }
840
+ return status;
841
+ });
842
+ };
843
+ const handleDownloadEvent = (evnt, item) => {
844
+ dispatchEvent("download", { option: item }, evnt);
845
+ };
846
+ const downloadFileEvent = (evnt, item) => {
847
+ const beforeDownloadFn = props.beforeDownloadMethod || getConfig().upload.beforeDownloadMethod;
848
+ const downloadFn = props.downloadMethod || getConfig().upload.downloadMethod;
849
+ Promise.resolve(
850
+ beforeDownloadFn ? beforeDownloadFn({
851
+ $upload: $xeUpload,
852
+ option: item
853
+ }) : true
854
+ ).then((status) => {
855
+ if (status) {
856
+ if (downloadFn) {
857
+ Promise.resolve(
858
+ downloadFn({
859
+ $upload: $xeUpload,
860
+ option: item
861
+ })
862
+ ).then(() => {
863
+ handleDownloadEvent(evnt, item);
864
+ }).catch((e) => e);
865
+ } else {
866
+ handleDownloadEvent(evnt, item);
867
+ }
868
+ } else {
869
+ dispatchEvent("download-fail", { option: item }, evnt);
870
+ }
871
+ });
872
+ };
873
+ const handleUploadDragleaveEvent = (evnt) => {
874
+ const targetElem = evnt.currentTarget;
875
+ const { clientX, clientY } = evnt;
876
+ if (targetElem) {
877
+ const { x: targetX, y: targetY, height: targetHeight, width: targetWidth } = targetElem.getBoundingClientRect();
878
+ if (clientX < targetX || clientX > targetX + targetWidth || clientY < targetY || clientY > targetY + targetHeight) {
879
+ reactData.isDragUploadStatus = false;
880
+ }
881
+ }
882
+ };
883
+ const handleUploadDragoverEvent = (evnt) => {
884
+ const dataTransfer = evnt.dataTransfer;
885
+ if (dataTransfer) {
886
+ const { items } = dataTransfer;
887
+ if (items && items.length) {
888
+ evnt.preventDefault();
889
+ reactData.isDragUploadStatus = true;
890
+ }
891
+ }
892
+ };
893
+ const uploadTransferFileEvent = (evnt, files) => {
894
+ const { imageTypes, fileTypes } = props;
895
+ const { imagePreviewTypes } = internalData;
896
+ const isImage = computeIsImage.value;
897
+ if (isImage) {
898
+ const pasteImgTypes = imagePreviewTypes.concat(imageTypes && imageTypes.length ? imageTypes : []);
899
+ files = files.filter((file) => {
900
+ const fileType = `${file.type.split("/")[1] || ""}`.toLowerCase();
901
+ if (pasteImgTypes.some((type) => `${type}`.toLowerCase() === fileType)) {
902
+ return true;
903
+ }
904
+ return false;
905
+ });
833
906
  } else {
907
+ if (fileTypes && fileTypes.length) {
908
+ const errTypes = [];
909
+ files.forEach((file) => {
910
+ const fileType = parseFileType(file.name);
911
+ if (!fileTypes.some((type) => `${type}`.toLowerCase() === fileType)) {
912
+ errTypes.push(fileType);
913
+ }
914
+ });
915
+ if (errTypes.length) {
916
+ if (VxeUI.modal) {
917
+ VxeUI.modal.message({
918
+ content: getI18n("vxe.error.notType", [errTypes.join(", ")]),
919
+ status: "error"
920
+ });
921
+ }
922
+ return;
923
+ }
924
+ }
925
+ }
926
+ if (!files.length) {
927
+ if (VxeUI.modal) {
928
+ VxeUI.modal.notification({
929
+ title: getI18n("vxe.modal.errTitle"),
930
+ status: "error",
931
+ content: getI18n("vxe.upload.uploadTypeErr")
932
+ });
933
+ }
934
+ return;
935
+ }
936
+ handleUploadFile(files, evnt);
937
+ };
938
+ const handleUploadDropEvent = (evnt) => {
939
+ const dataTransfer = evnt.dataTransfer;
940
+ if (dataTransfer) {
941
+ const { items } = dataTransfer;
942
+ if (items && items.length) {
943
+ evnt.preventDefault();
944
+ const files = handleTransferFiles(items);
945
+ if (files.length) {
946
+ uploadTransferFileEvent(evnt, files);
947
+ }
948
+ }
949
+ }
950
+ reactData.isDragUploadStatus = false;
951
+ };
952
+ const handleTransferFiles = (items) => {
953
+ const files = [];
954
+ XEUtils.arrayEach(items, (item) => {
955
+ const file = item.getAsFile();
956
+ if (file) {
957
+ files.push(file);
958
+ }
959
+ });
960
+ return files;
961
+ };
962
+ const handleMoreEvent = (evntParams) => {
963
+ const formReadonly = computeFormReadonly.value;
964
+ const isImage = computeIsImage.value;
965
+ const evnt = evntParams.$event;
966
+ if (VxeUI.modal) {
967
+ VxeUI.modal.open({
968
+ id: internalData.moreId,
969
+ title: formReadonly ? getI18n("vxe.upload.morePopup.readTitle") : getI18n(`vxe.upload.morePopup.${isImage ? "imageTitle" : "fileTitle"}`),
970
+ width: 660,
971
+ height: 500,
972
+ escClosable: true,
973
+ showMaximize: true,
974
+ resize: true,
975
+ maskClosable: true,
976
+ slots: {
977
+ default() {
978
+ const { showErrorStatus, dragToUpload, dragSort, dragPlaceholder } = props;
979
+ const { isActivated, isDragMove, isDragUploadStatus, dragIndex } = reactData;
980
+ const { fileList } = reactData;
981
+ const isDisabled = computeIsDisabled.value;
982
+ const moreContSlot = slots.moreContent || slots["more-content"];
983
+ const ons = {};
984
+ if (dragToUpload && dragIndex === -1) {
985
+ ons.onDragover = handleUploadDragoverEvent;
986
+ ons.onDragleave = handleUploadDragleaveEvent;
987
+ ons.onDrop = handleUploadDropEvent;
988
+ }
989
+ return h(
990
+ "div",
991
+ {
992
+ ref: refPopupElem,
993
+ class: [
994
+ "vxe-upload--more-popup",
995
+ {
996
+ "is--readonly": formReadonly,
997
+ "is--disabled": isDisabled,
998
+ "is--active": isActivated,
999
+ "show--error": showErrorStatus,
1000
+ "is--drag": isDragUploadStatus
1001
+ }
1002
+ ],
1003
+ ...ons
1004
+ },
1005
+ moreContSlot ? getSlotVNs(moreContSlot({ options: fileList })) : [
1006
+ isImage ? dragSort ? h(
1007
+ TransitionGroup,
1008
+ {
1009
+ name: `vxe-upload--drag-list${isDragMove ? "" : "-disabled"}`,
1010
+ tag: "div",
1011
+ class: "vxe-upload--image-more-list"
1012
+ },
1013
+ {
1014
+ default: () => renderImageItemList(fileList, true).concat(renderImageAction(true))
1015
+ }
1016
+ ) : h(
1017
+ "div",
1018
+ {
1019
+ class: "vxe-upload--image-more-list"
1020
+ },
1021
+ renderImageItemList(fileList, true).concat(renderImageAction(true))
1022
+ ) : h(
1023
+ "div",
1024
+ {
1025
+ class: "vxe-upload--file-more-list"
1026
+ },
1027
+ [
1028
+ renderFileAction(true),
1029
+ dragSort ? h(
1030
+ TransitionGroup,
1031
+ {
1032
+ name: `vxe-upload--drag-list${isDragMove ? "" : "-disabled"}`,
1033
+ tag: "div",
1034
+ class: "vxe-upload--file-list"
1035
+ },
1036
+ {
1037
+ default: () => renderFileItemList(fileList, false)
1038
+ }
1039
+ ) : h(
1040
+ "div",
1041
+ {
1042
+ class: "vxe-upload--file-list"
1043
+ },
1044
+ renderFileItemList(fileList, true)
1045
+ )
1046
+ ]
1047
+ ),
1048
+ dragSort ? h("div", {
1049
+ ref: refModalDragLineElem,
1050
+ class: "vxe-upload--drag-line"
1051
+ }) : renderEmptyElement($xeUpload),
1052
+ isDragUploadStatus ? h(
1053
+ "div",
1054
+ {
1055
+ class: "vxe-upload--drag-placeholder"
1056
+ },
1057
+ dragPlaceholder || getI18n("vxe.upload.dragPlaceholder")
1058
+ ) : renderEmptyElement($xeUpload)
1059
+ ]
1060
+ );
1061
+ }
1062
+ },
1063
+ onShow() {
1064
+ reactData.showMorePopup = true;
1065
+ },
1066
+ onHide({ $event }) {
1067
+ reactData.showMorePopup = false;
1068
+ if ($event) {
1069
+ dispatchEvent("more-visible", { visible: false }, $event);
1070
+ }
1071
+ }
1072
+ });
834
1073
  if (evnt) {
835
- dispatchEvent("remove-fail", { option: item }, evnt);
1074
+ dispatchEvent("more-visible", { visible: true }, evnt);
836
1075
  }
837
1076
  }
838
- return status;
839
- });
840
- };
841
- const handleDownloadEvent = (evnt, item) => {
842
- dispatchEvent("download", { option: item }, evnt);
843
- };
844
- const downloadFileEvent = (evnt, item) => {
845
- const beforeDownloadFn = props.beforeDownloadMethod || getConfig().upload.beforeDownloadMethod;
846
- const downloadFn = props.downloadMethod || getConfig().upload.downloadMethod;
847
- Promise.resolve(
848
- beforeDownloadFn ? beforeDownloadFn({
849
- $upload: $xeUpload,
850
- option: item
851
- }) : true
852
- ).then((status) => {
853
- if (status) {
854
- if (downloadFn) {
855
- Promise.resolve(
856
- downloadFn({
857
- $upload: $xeUpload,
858
- option: item
859
- })
860
- ).then(() => {
861
- handleDownloadEvent(evnt, item);
862
- }).catch((e) => e);
863
- } else {
864
- handleDownloadEvent(evnt, item);
865
- }
866
- } else {
867
- dispatchEvent("download-fail", { option: item }, evnt);
1077
+ };
1078
+ const showDropTip = (evnt, dragEl, dragPos) => {
1079
+ const { showMorePopup } = reactData;
1080
+ const el = refElem.value;
1081
+ const popupEl = refPopupElem.value;
1082
+ const wrapperEl = showMorePopup ? popupEl : el;
1083
+ if (!wrapperEl) {
1084
+ return;
1085
+ }
1086
+ const wrapperRect = wrapperEl.getBoundingClientRect();
1087
+ const ddLineEl = refDragLineElem.value;
1088
+ const mdLineEl = refModalDragLineElem.value;
1089
+ const currDLineEl = showMorePopup ? mdLineEl : ddLineEl;
1090
+ if (currDLineEl) {
1091
+ const dragRect = dragEl.getBoundingClientRect();
1092
+ currDLineEl.style.display = "block";
1093
+ currDLineEl.style.top = `${Math.max(1, dragRect.y - wrapperRect.y)}px`;
1094
+ currDLineEl.style.left = `${Math.max(1, dragRect.x - wrapperRect.x)}px`;
1095
+ currDLineEl.style.height = `${dragRect.height}px`;
1096
+ currDLineEl.style.width = `${dragRect.width - 1}px`;
1097
+ currDLineEl.setAttribute("drag-pos", dragPos);
1098
+ }
1099
+ };
1100
+ const hideDropTip = () => {
1101
+ const ddLineEl = refDragLineElem.value;
1102
+ const mdLineEl = refModalDragLineElem.value;
1103
+ if (ddLineEl) {
1104
+ ddLineEl.style.display = "";
1105
+ }
1106
+ if (mdLineEl) {
1107
+ mdLineEl.style.display = "";
1108
+ }
1109
+ };
1110
+ const handleDragSortDragstartEvent = (evnt) => {
1111
+ evnt.stopPropagation();
1112
+ if (evnt.dataTransfer) {
1113
+ evnt.dataTransfer.setDragImage(getTpImg(), 0, 0);
1114
+ }
1115
+ const dragEl = evnt.currentTarget;
1116
+ const parentEl = dragEl.parentElement;
1117
+ const dragIndex = XEUtils.findIndexOf(Array.from(parentEl.children), (item) => dragEl === item);
1118
+ reactData.isDragMove = true;
1119
+ reactData.dragIndex = dragIndex;
1120
+ setTimeout(() => {
1121
+ reactData.isDragMove = false;
1122
+ }, 500);
1123
+ };
1124
+ const handleDragSortDragoverEvent = (evnt) => {
1125
+ evnt.stopPropagation();
1126
+ evnt.preventDefault();
1127
+ const { dragIndex } = reactData;
1128
+ if (dragIndex === -1) {
1129
+ return;
1130
+ }
1131
+ const isImage = computeIsImage.value;
1132
+ const dragEl = evnt.currentTarget;
1133
+ const parentEl = dragEl.parentElement;
1134
+ const currIndex = XEUtils.findIndexOf(Array.from(parentEl.children), (item) => dragEl === item);
1135
+ let dragPos = "";
1136
+ if (isImage) {
1137
+ const offsetX = evnt.clientX - dragEl.getBoundingClientRect().x;
1138
+ dragPos = offsetX < dragEl.clientWidth / 2 ? "left" : "right";
1139
+ } else {
1140
+ const offsetY = evnt.clientY - dragEl.getBoundingClientRect().y;
1141
+ dragPos = offsetY < dragEl.clientHeight / 2 ? "top" : "bottom";
1142
+ }
1143
+ if (dragIndex === currIndex) {
1144
+ showDropTip(evnt, dragEl, dragPos);
1145
+ return;
1146
+ }
1147
+ showDropTip(evnt, dragEl, dragPos);
1148
+ internalData.prevDragIndex = currIndex;
1149
+ internalData.prevDragPos = dragPos;
1150
+ };
1151
+ const handleDragSortDragendEvent = (evnt) => {
1152
+ const { fileList, dragIndex } = reactData;
1153
+ const { prevDragIndex, prevDragPos } = internalData;
1154
+ const oldIndex = dragIndex;
1155
+ const targetIndex = prevDragIndex;
1156
+ const dragOffsetIndex = prevDragPos === "bottom" || prevDragPos === "right" ? 1 : 0;
1157
+ const oldItem = fileList[oldIndex];
1158
+ const newItem = fileList[targetIndex];
1159
+ if (oldItem && newItem) {
1160
+ fileList.splice(oldIndex, 1);
1161
+ const ptfIndex = XEUtils.findIndexOf(fileList, (item) => newItem === item);
1162
+ const nIndex = ptfIndex + dragOffsetIndex;
1163
+ fileList.splice(nIndex, 0, oldItem);
1164
+ dispatchEvent(
1165
+ "sort-dragend",
1166
+ {
1167
+ oldItem,
1168
+ newItem,
1169
+ dragPos: prevDragPos,
1170
+ offsetIndex: dragOffsetIndex,
1171
+ _index: {
1172
+ newIndex: nIndex,
1173
+ oldIndex
1174
+ }
1175
+ },
1176
+ evnt
1177
+ );
1178
+ }
1179
+ hideDropTip();
1180
+ reactData.dragIndex = -1;
1181
+ };
1182
+ const handleItemMousedownEvent = (evnt) => {
1183
+ if ($xeTable) {
1184
+ evnt.stopPropagation();
868
1185
  }
869
- });
870
- };
871
- const handleUploadDragleaveEvent = (evnt) => {
872
- const targetElem = evnt.currentTarget;
873
- const { clientX, clientY } = evnt;
874
- if (targetElem) {
875
- const { x: targetX, y: targetY, height: targetHeight, width: targetWidth } = targetElem.getBoundingClientRect();
876
- if (clientX < targetX || clientX > targetX + targetWidth || clientY < targetY || clientY > targetY + targetHeight) {
877
- reactData.isDragUploadStatus = false;
1186
+ reactData.isActivated = true;
1187
+ };
1188
+ const handleGlobalPasteEvent = (evnt) => {
1189
+ const { pasteToUpload } = props;
1190
+ const { isActivated } = reactData;
1191
+ if (!isActivated || !pasteToUpload) {
1192
+ return;
878
1193
  }
879
- }
880
- };
881
- const handleUploadDragoverEvent = (evnt) => {
882
- const dataTransfer = evnt.dataTransfer;
883
- if (dataTransfer) {
884
- const { items } = dataTransfer;
885
- if (items && items.length) {
1194
+ const clipboardData = evnt.clipboardData || evnt.originalEvent.clipboardData;
1195
+ if (!clipboardData) {
1196
+ return;
1197
+ }
1198
+ const { items } = clipboardData;
1199
+ if (!items) {
1200
+ return;
1201
+ }
1202
+ const files = handleTransferFiles(items);
1203
+ if (files.length) {
886
1204
  evnt.preventDefault();
887
- reactData.isDragUploadStatus = true;
1205
+ uploadTransferFileEvent(evnt, files);
888
1206
  }
889
- }
890
- };
891
- const uploadTransferFileEvent = (evnt, files) => {
892
- const { imageTypes, fileTypes } = props;
893
- const { imagePreviewTypes } = internalData;
894
- const isImage = computeIsImage.value;
895
- if (isImage) {
896
- const pasteImgTypes = imagePreviewTypes.concat(imageTypes && imageTypes.length ? imageTypes : []);
897
- files = files.filter((file) => {
898
- const fileType = `${file.type.split("/")[1] || ""}`.toLowerCase();
899
- if (pasteImgTypes.some((type) => `${type}`.toLowerCase() === fileType)) {
900
- return true;
1207
+ };
1208
+ const handleGlobalClickEvent = (evnt) => {
1209
+ const el = refElem.value;
1210
+ const popupEl = refPopupElem.value;
1211
+ let isActivated = getEventTargetNode(evnt, el).flag;
1212
+ if (!isActivated && popupEl) {
1213
+ const parentEl = popupEl.parentElement || popupEl;
1214
+ const modalEl = parentEl ? parentEl.parentElement : parentEl;
1215
+ isActivated = getEventTargetNode(evnt, modalEl).flag;
1216
+ }
1217
+ reactData.isActivated = isActivated;
1218
+ };
1219
+ const handleGlobalBlurEvent = () => {
1220
+ reactData.isActivated = false;
1221
+ };
1222
+ const handleClearFile = (evnt) => {
1223
+ const { fileList } = reactData;
1224
+ const urlProp = computeUrlProp.value;
1225
+ const rest = [];
1226
+ XEUtils.lastEach(fileList, (item, index) => {
1227
+ rest.push(
1228
+ removeFileEvent(evnt, item, index).then((status) => {
1229
+ return { url: item[urlProp], status };
1230
+ })
1231
+ );
1232
+ });
1233
+ return Promise.all(rest);
1234
+ };
1235
+ const handleRemoveFile = (evnt, urlOrItem) => {
1236
+ const { fileList } = reactData;
1237
+ const urlProp = computeUrlProp.value;
1238
+ const urls = XEUtils.isArray(urlOrItem) ? urlOrItem : [urlOrItem];
1239
+ const rest = [];
1240
+ urls.forEach((obj) => {
1241
+ if (obj) {
1242
+ const url = XEUtils.isString(obj) ? obj : obj[urlProp];
1243
+ const index = XEUtils.findIndexOf(fileList, (fileItem) => fileItem[urlProp] === url);
1244
+ if (index > -1) {
1245
+ rest.push(
1246
+ removeFileEvent(evnt, fileList[index], index).then((status) => {
1247
+ return { url, status };
1248
+ })
1249
+ );
1250
+ }
901
1251
  }
902
- return false;
903
1252
  });
904
- } else {
905
- if (fileTypes && fileTypes.length) {
906
- const errTypes = [];
907
- files.forEach((file) => {
908
- const fileType = parseFileType(file.name);
909
- if (!fileTypes.some((type) => `${type}`.toLowerCase() === fileType)) {
910
- errTypes.push(fileType);
1253
+ return Promise.all(rest);
1254
+ };
1255
+ const uploadMethods = {
1256
+ dispatchEvent,
1257
+ choose() {
1258
+ return handleChoose(null);
1259
+ },
1260
+ clear() {
1261
+ return handleClearFile(null);
1262
+ },
1263
+ clearByEvent(evnt) {
1264
+ return handleClearFile(evnt);
1265
+ },
1266
+ getPendingFiles() {
1267
+ const { fileList, fileCacheMaps } = reactData;
1268
+ const pendingFiles = [];
1269
+ fileList.forEach((item) => {
1270
+ const fileKey = getFieldKey(item);
1271
+ const cacheItem = fileCacheMaps[fileKey];
1272
+ if (cacheItem && cacheItem.status === "pending") {
1273
+ pendingFiles.push(cacheItem.file);
911
1274
  }
912
1275
  });
913
- if (errTypes.length) {
914
- if (VxeUI.modal) {
915
- VxeUI.modal.message({
916
- content: getI18n("vxe.error.notType", [errTypes.join(", ")]),
917
- status: "error"
918
- });
1276
+ return pendingFiles;
1277
+ },
1278
+ submit(isFull) {
1279
+ const { maxSimultaneousUploads } = props;
1280
+ const msNum = XEUtils.toNumber(maxSimultaneousUploads || 1) || 1;
1281
+ const { fileList, fileCacheMaps } = reactData;
1282
+ const allPendingList = fileList.filter((item) => {
1283
+ const fileKey = getFieldKey(item);
1284
+ const cacheItem = fileCacheMaps[fileKey];
1285
+ return cacheItem && (cacheItem.status === "pending" || isFull && cacheItem.status === "error");
1286
+ });
1287
+ const handleSubmit = (item) => {
1288
+ const fileKey = getFieldKey(item);
1289
+ const cacheItem = fileCacheMaps[fileKey];
1290
+ if (cacheItem) {
1291
+ const file = cacheItem.file;
1292
+ if (file && (cacheItem.status === "pending" || isFull && cacheItem.status === "error")) {
1293
+ cacheItem.loading = true;
1294
+ cacheItem.percent = 0;
1295
+ return handleUploadResult(item, file).then(handleNextSubmit);
1296
+ }
919
1297
  }
920
- return;
921
- }
922
- }
923
- }
924
- if (!files.length) {
925
- if (VxeUI.modal) {
926
- VxeUI.modal.notification({
927
- title: getI18n("vxe.modal.errTitle"),
928
- status: "error",
929
- content: getI18n("vxe.upload.uploadTypeErr")
1298
+ return handleNextSubmit();
1299
+ };
1300
+ const handleNextSubmit = () => {
1301
+ if (allPendingList.length) {
1302
+ const item = allPendingList[0];
1303
+ allPendingList.splice(0, 1);
1304
+ return handleSubmit(item).then(handleNextSubmit);
1305
+ }
1306
+ return Promise.resolve();
1307
+ };
1308
+ return Promise.all(allPendingList.splice(0, msNum).map(handleSubmit)).then(() => {
930
1309
  });
931
- }
932
- return;
933
- }
934
- handleUploadFile(files, evnt);
935
- };
936
- const handleUploadDropEvent = (evnt) => {
937
- const dataTransfer = evnt.dataTransfer;
938
- if (dataTransfer) {
939
- const { items } = dataTransfer;
940
- if (items && items.length) {
941
- evnt.preventDefault();
942
- const files = handleTransferFiles(items);
943
- if (files.length) {
944
- uploadTransferFileEvent(evnt, files);
1310
+ },
1311
+ getMoreVisible() {
1312
+ return reactData.showMorePopup;
1313
+ },
1314
+ openMore() {
1315
+ handleMoreEvent({ $event: new Event("click") });
1316
+ return nextTick();
1317
+ },
1318
+ openMoreByEvent(evnt) {
1319
+ handleMoreEvent({ $event: evnt });
1320
+ return nextTick();
1321
+ },
1322
+ closeMore() {
1323
+ if (VxeUI.modal) {
1324
+ VxeUI.modal.close(internalData.moreId);
945
1325
  }
1326
+ return nextTick();
1327
+ },
1328
+ remove(urlOrItem) {
1329
+ return handleRemoveFile(null, urlOrItem);
1330
+ },
1331
+ removeByEvent(evnt, urlOrItem) {
1332
+ return handleRemoveFile(evnt, urlOrItem);
946
1333
  }
947
- }
948
- reactData.isDragUploadStatus = false;
949
- };
950
- const handleTransferFiles = (items) => {
951
- const files = [];
952
- XEUtils.arrayEach(items, (item) => {
953
- const file = item.getAsFile();
954
- if (file) {
955
- files.push(file);
1334
+ };
1335
+ const uploadPrivateMethods = {
1336
+ removeFileEvent
1337
+ };
1338
+ Object.assign($xeUpload, uploadMethods, uploadPrivateMethods);
1339
+ const renderFileItemList = (currList, isMoreView) => {
1340
+ const { showRemoveButton, showDownloadButton, showProgress, progressText, showPreview, showErrorStatus, dragSort, autoSubmit, showSubmitButton } = props;
1341
+ const { fileList, fileCacheMaps } = reactData;
1342
+ const isDisabled = computeIsDisabled.value;
1343
+ const formReadonly = computeFormReadonly.value;
1344
+ const nameProp = computeNameProp.value;
1345
+ const typeProp = computeTypeProp.value;
1346
+ const optionSlot = slots.option;
1347
+ const actionSlot = slots.action;
1348
+ const cornerSlot = slots.corner;
1349
+ const nameSlot = slots.name;
1350
+ const ons = {};
1351
+ if (dragSort && currList.length > 1) {
1352
+ ons.onDragstart = handleDragSortDragstartEvent;
1353
+ ons.onDragover = handleDragSortDragoverEvent;
1354
+ ons.onDragend = handleDragSortDragendEvent;
956
1355
  }
957
- });
958
- return files;
959
- };
960
- const handleMoreEvent = (evntParams) => {
961
- const formReadonly = computeFormReadonly.value;
962
- const isImage = computeIsImage.value;
963
- const evnt = evntParams.$event;
964
- if (VxeUI.modal) {
965
- VxeUI.modal.open({
966
- id: internalData.moreId,
967
- title: formReadonly ? getI18n("vxe.upload.morePopup.readTitle") : getI18n(`vxe.upload.morePopup.${isImage ? "imageTitle" : "fileTitle"}`),
968
- width: 660,
969
- height: 500,
970
- escClosable: true,
971
- showMaximize: true,
972
- resize: true,
973
- maskClosable: true,
974
- slots: {
975
- default() {
976
- const { showErrorStatus, dragToUpload, dragSort, dragPlaceholder } = props;
977
- const { isActivated, isDragMove, isDragUploadStatus, dragIndex } = reactData;
978
- const { fileList } = reactData;
979
- const isDisabled = computeIsDisabled.value;
980
- const moreContSlot = slots.moreContent || slots["more-content"];
981
- const ons = {};
982
- if (dragToUpload && dragIndex === -1) {
983
- ons.onDragover = handleUploadDragoverEvent;
984
- ons.onDragleave = handleUploadDragleaveEvent;
985
- ons.onDrop = handleUploadDropEvent;
986
- }
987
- return h(
1356
+ return currList.map((item, index) => {
1357
+ const fileKey = getFieldKey(item);
1358
+ const cacheItem = fileCacheMaps[fileKey];
1359
+ let isLoading = false;
1360
+ let isError = false;
1361
+ let isPending = false;
1362
+ const fileName = `${item[nameProp] || ""}`;
1363
+ if (cacheItem) {
1364
+ isLoading = cacheItem.loading;
1365
+ isError = cacheItem.status === "error";
1366
+ isPending = cacheItem.status === "pending";
1367
+ }
1368
+ return h(
1369
+ "div",
1370
+ {
1371
+ key: dragSort ? fileKey : index,
1372
+ class: [
1373
+ "vxe-upload--file-item",
1374
+ {
1375
+ "is--preview": showPreview,
1376
+ "is--loading": isLoading,
1377
+ "is--pending": isPending,
1378
+ "is--error": isError
1379
+ }
1380
+ ],
1381
+ fileid: fileKey,
1382
+ draggable: dragSort ? true : null,
1383
+ ...ons
1384
+ },
1385
+ optionSlot ? getSlotVNs(optionSlot({ option: item, isMoreView, options: fileList })) : [
1386
+ h(
988
1387
  "div",
989
1388
  {
990
- ref: refPopupElem,
991
- class: [
992
- "vxe-upload--more-popup",
993
- {
994
- "is--readonly": formReadonly,
995
- "is--disabled": isDisabled,
996
- "is--active": isActivated,
997
- "show--error": showErrorStatus,
998
- "is--drag": isDragUploadStatus
1389
+ class: "vxe-upload--file-item-icon"
1390
+ },
1391
+ [
1392
+ h("i", {
1393
+ class: getIcon()[`UPLOAD_FILE_TYPE_${`${item[typeProp]}`.toLocaleUpperCase()}`] || getIcon().UPLOAD_FILE_TYPE_DEFAULT
1394
+ })
1395
+ ]
1396
+ ),
1397
+ h(
1398
+ "div",
1399
+ {
1400
+ class: "vxe-upload--file-item-name",
1401
+ title: fileName,
1402
+ onClick(evnt) {
1403
+ if (!isLoading && !isError) {
1404
+ handlePreviewFileEvent(evnt, item);
999
1405
  }
1000
- ],
1001
- ...ons
1406
+ }
1002
1407
  },
1003
- moreContSlot ? getSlotVNs(moreContSlot({ options: fileList })) : [
1004
- isImage ? dragSort ? h(
1005
- TransitionGroup,
1006
- {
1007
- name: `vxe-upload--drag-list${isDragMove ? "" : "-disabled"}`,
1008
- tag: "div",
1009
- class: "vxe-upload--image-more-list"
1010
- },
1011
- {
1012
- default: () => renderImageItemList(fileList, true).concat(renderImageAction(true))
1408
+ nameSlot ? getSlotVNs(nameSlot({ option: item, isMoreView, options: fileList })) : fileName
1409
+ ),
1410
+ isLoading ? h(
1411
+ "div",
1412
+ {
1413
+ class: "vxe-upload--file-item-loading-icon"
1414
+ },
1415
+ [
1416
+ h("i", {
1417
+ class: getIcon().UPLOAD_LOADING
1418
+ })
1419
+ ]
1420
+ ) : renderEmptyElement($xeUpload),
1421
+ showProgress && isLoading && cacheItem ? h(
1422
+ "div",
1423
+ {
1424
+ class: "vxe-upload--file-item-loading-text"
1425
+ },
1426
+ progressText ? XEUtils.toFormatString(`${XEUtils.isFunction(progressText) ? progressText({}) : progressText}`, { percent: cacheItem.percent }) : getI18n("vxe.upload.uploadProgress", [cacheItem.percent])
1427
+ ) : renderEmptyElement($xeUpload),
1428
+ !isLoading && (isError && showErrorStatus || isPending && showSubmitButton && !autoSubmit) ? h(
1429
+ "div",
1430
+ {
1431
+ class: "vxe-upload--file-item-rebtn"
1432
+ },
1433
+ [
1434
+ h(VxeButtonComponent, {
1435
+ icon: isError ? getIcon().UPLOAD_IMAGE_RE_UPLOAD : getIcon().UPLOAD_IMAGE_UPLOAD,
1436
+ mode: "text",
1437
+ status: "primary",
1438
+ content: isError ? getI18n("vxe.upload.reUpload") : getI18n("vxe.upload.manualUpload"),
1439
+ onClick(evnt) {
1440
+ handleReUploadEvent(evnt, item);
1013
1441
  }
1014
- ) : h(
1442
+ })
1443
+ ]
1444
+ ) : renderEmptyElement($xeUpload),
1445
+ h(
1446
+ "div",
1447
+ {
1448
+ class: "vxe-upload--file-item-btn-wrapper"
1449
+ },
1450
+ actionSlot ? getSlotVNs(actionSlot({ option: item, isMoreView, options: fileList, readonly: formReadonly })) : [
1451
+ cornerSlot ? h(
1015
1452
  "div",
1016
1453
  {
1017
- class: "vxe-upload--image-more-list"
1454
+ class: "vxe-upload--file-item-action"
1018
1455
  },
1019
- renderImageItemList(fileList, true).concat(renderImageAction(true))
1020
- ) : h(
1456
+ getSlotVNs(cornerSlot({ option: item, isMoreView, options: fileList, readonly: formReadonly }))
1457
+ ) : renderEmptyElement($xeUpload),
1458
+ showDownloadButton && !(isLoading || isPending) ? h(
1021
1459
  "div",
1022
1460
  {
1023
- class: "vxe-upload--file-more-list"
1461
+ class: "vxe-upload--file-item-download-btn",
1462
+ onClick(evnt) {
1463
+ downloadFileEvent(evnt, item);
1464
+ }
1024
1465
  },
1025
1466
  [
1026
- renderFileAction(true),
1027
- dragSort ? h(
1028
- TransitionGroup,
1029
- {
1030
- name: `vxe-upload--drag-list${isDragMove ? "" : "-disabled"}`,
1031
- tag: "div",
1032
- class: "vxe-upload--file-list"
1033
- },
1034
- {
1035
- default: () => renderFileItemList(fileList, false)
1036
- }
1037
- ) : h(
1038
- "div",
1039
- {
1040
- class: "vxe-upload--file-list"
1041
- },
1042
- renderFileItemList(fileList, true)
1043
- )
1467
+ h("i", {
1468
+ class: getIcon().UPLOAD_FILE_DOWNLOAD
1469
+ })
1044
1470
  ]
1045
- ),
1046
- dragSort ? h("div", {
1047
- ref: refModalDragLineElem,
1048
- class: "vxe-upload--drag-line"
1049
- }) : renderEmptyElement($xeUpload),
1050
- isDragUploadStatus ? h(
1471
+ ) : renderEmptyElement($xeUpload),
1472
+ showRemoveButton && !formReadonly && !isDisabled && !isLoading ? h(
1051
1473
  "div",
1052
1474
  {
1053
- class: "vxe-upload--drag-placeholder"
1475
+ class: "vxe-upload--file-item-remove-btn",
1476
+ onClick(evnt) {
1477
+ removeFileEvent(evnt, item, index);
1478
+ }
1054
1479
  },
1055
- dragPlaceholder || getI18n("vxe.upload.dragPlaceholder")
1480
+ [
1481
+ h("i", {
1482
+ class: getIcon().UPLOAD_FILE_REMOVE
1483
+ })
1484
+ ]
1056
1485
  ) : renderEmptyElement($xeUpload)
1057
1486
  ]
1058
- );
1059
- }
1060
- },
1061
- onShow() {
1062
- reactData.showMorePopup = true;
1063
- },
1064
- onHide({ $event }) {
1065
- reactData.showMorePopup = false;
1066
- if ($event) {
1067
- dispatchEvent("more-visible", { visible: false }, $event);
1068
- }
1069
- }
1070
- });
1071
- if (evnt) {
1072
- dispatchEvent("more-visible", { visible: true }, evnt);
1073
- }
1074
- }
1075
- };
1076
- const showDropTip = (evnt, dragEl, dragPos) => {
1077
- const { showMorePopup } = reactData;
1078
- const el = refElem.value;
1079
- const popupEl = refPopupElem.value;
1080
- const wrapperEl = showMorePopup ? popupEl : el;
1081
- if (!wrapperEl) {
1082
- return;
1083
- }
1084
- const wrapperRect = wrapperEl.getBoundingClientRect();
1085
- const ddLineEl = refDragLineElem.value;
1086
- const mdLineEl = refModalDragLineElem.value;
1087
- const currDLineEl = showMorePopup ? mdLineEl : ddLineEl;
1088
- if (currDLineEl) {
1089
- const dragRect = dragEl.getBoundingClientRect();
1090
- currDLineEl.style.display = "block";
1091
- currDLineEl.style.top = `${Math.max(1, dragRect.y - wrapperRect.y)}px`;
1092
- currDLineEl.style.left = `${Math.max(1, dragRect.x - wrapperRect.x)}px`;
1093
- currDLineEl.style.height = `${dragRect.height}px`;
1094
- currDLineEl.style.width = `${dragRect.width - 1}px`;
1095
- currDLineEl.setAttribute("drag-pos", dragPos);
1096
- }
1097
- };
1098
- const hideDropTip = () => {
1099
- const ddLineEl = refDragLineElem.value;
1100
- const mdLineEl = refModalDragLineElem.value;
1101
- if (ddLineEl) {
1102
- ddLineEl.style.display = "";
1103
- }
1104
- if (mdLineEl) {
1105
- mdLineEl.style.display = "";
1106
- }
1107
- };
1108
- const handleDragSortDragstartEvent = (evnt) => {
1109
- evnt.stopPropagation();
1110
- if (evnt.dataTransfer) {
1111
- evnt.dataTransfer.setDragImage(getTpImg(), 0, 0);
1112
- }
1113
- const dragEl = evnt.currentTarget;
1114
- const parentEl = dragEl.parentElement;
1115
- const dragIndex = XEUtils.findIndexOf(Array.from(parentEl.children), (item) => dragEl === item);
1116
- reactData.isDragMove = true;
1117
- reactData.dragIndex = dragIndex;
1118
- setTimeout(() => {
1119
- reactData.isDragMove = false;
1120
- }, 500);
1121
- };
1122
- const handleDragSortDragoverEvent = (evnt) => {
1123
- evnt.stopPropagation();
1124
- evnt.preventDefault();
1125
- const { dragIndex } = reactData;
1126
- if (dragIndex === -1) {
1127
- return;
1128
- }
1129
- const isImage = computeIsImage.value;
1130
- const dragEl = evnt.currentTarget;
1131
- const parentEl = dragEl.parentElement;
1132
- const currIndex = XEUtils.findIndexOf(Array.from(parentEl.children), (item) => dragEl === item);
1133
- let dragPos = "";
1134
- if (isImage) {
1135
- const offsetX = evnt.clientX - dragEl.getBoundingClientRect().x;
1136
- dragPos = offsetX < dragEl.clientWidth / 2 ? "left" : "right";
1137
- } else {
1138
- const offsetY = evnt.clientY - dragEl.getBoundingClientRect().y;
1139
- dragPos = offsetY < dragEl.clientHeight / 2 ? "top" : "bottom";
1140
- }
1141
- if (dragIndex === currIndex) {
1142
- showDropTip(evnt, dragEl, dragPos);
1143
- return;
1144
- }
1145
- showDropTip(evnt, dragEl, dragPos);
1146
- internalData.prevDragIndex = currIndex;
1147
- internalData.prevDragPos = dragPos;
1148
- };
1149
- const handleDragSortDragendEvent = (evnt) => {
1150
- const { fileList, dragIndex } = reactData;
1151
- const { prevDragIndex, prevDragPos } = internalData;
1152
- const oldIndex = dragIndex;
1153
- const targetIndex = prevDragIndex;
1154
- const dragOffsetIndex = prevDragPos === "bottom" || prevDragPos === "right" ? 1 : 0;
1155
- const oldItem = fileList[oldIndex];
1156
- const newItem = fileList[targetIndex];
1157
- if (oldItem && newItem) {
1158
- fileList.splice(oldIndex, 1);
1159
- const ptfIndex = XEUtils.findIndexOf(fileList, (item) => newItem === item);
1160
- const nIndex = ptfIndex + dragOffsetIndex;
1161
- fileList.splice(nIndex, 0, oldItem);
1162
- dispatchEvent(
1163
- "sort-dragend",
1164
- {
1165
- oldItem,
1166
- newItem,
1167
- dragPos: prevDragPos,
1168
- offsetIndex: dragOffsetIndex,
1169
- _index: {
1170
- newIndex: nIndex,
1171
- oldIndex
1172
- }
1173
- },
1174
- evnt
1175
- );
1176
- }
1177
- hideDropTip();
1178
- reactData.dragIndex = -1;
1179
- };
1180
- const handleItemMousedownEvent = (evnt) => {
1181
- if ($xeTable) {
1182
- evnt.stopPropagation();
1183
- }
1184
- reactData.isActivated = true;
1185
- };
1186
- const handleGlobalPasteEvent = (evnt) => {
1187
- const { pasteToUpload } = props;
1188
- const { isActivated } = reactData;
1189
- if (!isActivated || !pasteToUpload) {
1190
- return;
1191
- }
1192
- const clipboardData = evnt.clipboardData || evnt.originalEvent.clipboardData;
1193
- if (!clipboardData) {
1194
- return;
1195
- }
1196
- const { items } = clipboardData;
1197
- if (!items) {
1198
- return;
1199
- }
1200
- const files = handleTransferFiles(items);
1201
- if (files.length) {
1202
- evnt.preventDefault();
1203
- uploadTransferFileEvent(evnt, files);
1204
- }
1205
- };
1206
- const handleGlobalClickEvent = (evnt) => {
1207
- const el = refElem.value;
1208
- const popupEl = refPopupElem.value;
1209
- let isActivated = getEventTargetNode(evnt, el).flag;
1210
- if (!isActivated && popupEl) {
1211
- const parentEl = popupEl.parentElement || popupEl;
1212
- const modalEl = parentEl ? parentEl.parentElement : parentEl;
1213
- isActivated = getEventTargetNode(evnt, modalEl).flag;
1214
- }
1215
- reactData.isActivated = isActivated;
1216
- };
1217
- const handleGlobalBlurEvent = () => {
1218
- reactData.isActivated = false;
1219
- };
1220
- const handleClearFile = (evnt) => {
1221
- const { fileList } = reactData;
1222
- const urlProp = computeUrlProp.value;
1223
- const rest = [];
1224
- XEUtils.lastEach(fileList, (item, index) => {
1225
- rest.push(
1226
- removeFileEvent(evnt, item, index).then((status) => {
1227
- return { url: item[urlProp], status };
1228
- })
1229
- );
1230
- });
1231
- return Promise.all(rest);
1232
- };
1233
- const handleRemoveFile = (evnt, urlOrItem) => {
1234
- const { fileList } = reactData;
1235
- const urlProp = computeUrlProp.value;
1236
- const urls = XEUtils.isArray(urlOrItem) ? urlOrItem : [urlOrItem];
1237
- const rest = [];
1238
- urls.forEach((obj) => {
1239
- if (obj) {
1240
- const url = XEUtils.isString(obj) ? obj : obj[urlProp];
1241
- const index = XEUtils.findIndexOf(fileList, (fileItem) => fileItem[urlProp] === url);
1242
- if (index > -1) {
1243
- rest.push(
1244
- removeFileEvent(evnt, fileList[index], index).then((status) => {
1245
- return { url, status };
1246
- })
1247
- );
1248
- }
1249
- }
1250
- });
1251
- return Promise.all(rest);
1252
- };
1253
- const uploadMethods = {
1254
- dispatchEvent,
1255
- choose() {
1256
- return handleChoose(null);
1257
- },
1258
- clear() {
1259
- return handleClearFile(null);
1260
- },
1261
- clearByEvent(evnt) {
1262
- return handleClearFile(evnt);
1263
- },
1264
- getPendingFiles() {
1265
- const { fileList, fileCacheMaps } = reactData;
1266
- const pendingFiles = [];
1267
- fileList.forEach((item) => {
1268
- const fileKey = getFieldKey(item);
1269
- const cacheItem = fileCacheMaps[fileKey];
1270
- if (cacheItem && cacheItem.status === "pending") {
1271
- pendingFiles.push(cacheItem.file);
1272
- }
1273
- });
1274
- return pendingFiles;
1275
- },
1276
- submit(isFull) {
1277
- const { maxSimultaneousUploads } = props;
1278
- const msNum = XEUtils.toNumber(maxSimultaneousUploads || 1) || 1;
1279
- const { fileList, fileCacheMaps } = reactData;
1280
- const allPendingList = fileList.filter((item) => {
1281
- const fileKey = getFieldKey(item);
1282
- const cacheItem = fileCacheMaps[fileKey];
1283
- return cacheItem && (cacheItem.status === "pending" || isFull && cacheItem.status === "error");
1284
- });
1285
- const handleSubmit = (item) => {
1286
- const fileKey = getFieldKey(item);
1287
- const cacheItem = fileCacheMaps[fileKey];
1288
- if (cacheItem) {
1289
- const file = cacheItem.file;
1290
- if (file && (cacheItem.status === "pending" || isFull && cacheItem.status === "error")) {
1291
- cacheItem.loading = true;
1292
- cacheItem.percent = 0;
1293
- return handleUploadResult(item, file).then(handleNextSubmit);
1294
- }
1295
- }
1296
- return handleNextSubmit();
1297
- };
1298
- const handleNextSubmit = () => {
1299
- if (allPendingList.length) {
1300
- const item = allPendingList[0];
1301
- allPendingList.splice(0, 1);
1302
- return handleSubmit(item).then(handleNextSubmit);
1303
- }
1304
- return Promise.resolve();
1305
- };
1306
- return Promise.all(allPendingList.splice(0, msNum).map(handleSubmit)).then(() => {
1487
+ )
1488
+ ]
1489
+ );
1307
1490
  });
1308
- },
1309
- getMoreVisible() {
1310
- return reactData.showMorePopup;
1311
- },
1312
- openMore() {
1313
- handleMoreEvent({ $event: new Event("click") });
1314
- return nextTick();
1315
- },
1316
- openMoreByEvent(evnt) {
1317
- handleMoreEvent({ $event: evnt });
1318
- return nextTick();
1319
- },
1320
- closeMore() {
1321
- if (VxeUI.modal) {
1322
- VxeUI.modal.close(internalData.moreId);
1323
- }
1324
- return nextTick();
1325
- },
1326
- remove(urlOrItem) {
1327
- return handleRemoveFile(null, urlOrItem);
1328
- },
1329
- removeByEvent(evnt, urlOrItem) {
1330
- return handleRemoveFile(evnt, urlOrItem);
1331
- }
1332
- };
1333
- const uploadPrivateMethods = {
1334
- removeFileEvent
1335
- };
1336
- Object.assign($xeUpload, uploadMethods, uploadPrivateMethods);
1337
- const renderFileItemList = (currList, isMoreView) => {
1338
- const { showRemoveButton, showDownloadButton, showProgress, progressText, showPreview, showErrorStatus, dragSort, autoSubmit, showSubmitButton } = props;
1339
- const { fileList, fileCacheMaps } = reactData;
1340
- const isDisabled = computeIsDisabled.value;
1341
- const formReadonly = computeFormReadonly.value;
1342
- const nameProp = computeNameProp.value;
1343
- const typeProp = computeTypeProp.value;
1344
- const optionSlot = slots.option;
1345
- const actionSlot = slots.action;
1346
- const cornerSlot = slots.corner;
1347
- const nameSlot = slots.name;
1348
- const ons = {};
1349
- if (dragSort && currList.length > 1) {
1350
- ons.onDragstart = handleDragSortDragstartEvent;
1351
- ons.onDragover = handleDragSortDragoverEvent;
1352
- ons.onDragend = handleDragSortDragendEvent;
1353
- }
1354
- return currList.map((item, index) => {
1355
- const fileKey = getFieldKey(item);
1356
- const cacheItem = fileCacheMaps[fileKey];
1357
- let isLoading = false;
1358
- let isError = false;
1359
- let isPending = false;
1360
- const fileName = `${item[nameProp] || ""}`;
1361
- if (cacheItem) {
1362
- isLoading = cacheItem.loading;
1363
- isError = cacheItem.status === "error";
1364
- isPending = cacheItem.status === "pending";
1491
+ };
1492
+ const renderFileAction = (isMoreView) => {
1493
+ const { showUploadButton, buttonText, buttonIcon, showButtonText, showButtonIcon, autoHiddenButton } = props;
1494
+ const { fileList } = reactData;
1495
+ const isDisabled = computeIsDisabled.value;
1496
+ const formReadonly = computeFormReadonly.value;
1497
+ const showTipText = computedShowTipText.value;
1498
+ const defTipText = computedDefTipText.value;
1499
+ const overCount = computeOverCount.value;
1500
+ const defaultSlot = slots.default;
1501
+ const tipSlot = slots.tip || slots.hint;
1502
+ if (formReadonly || !showUploadButton) {
1503
+ return renderEmptyElement($xeUpload);
1365
1504
  }
1366
1505
  return h(
1367
1506
  "div",
1368
1507
  {
1369
- key: dragSort ? fileKey : index,
1370
- class: [
1371
- "vxe-upload--file-item",
1372
- {
1373
- "is--preview": showPreview,
1374
- "is--loading": isLoading,
1375
- "is--pending": isPending,
1376
- "is--error": isError
1377
- }
1378
- ],
1379
- fileid: fileKey,
1380
- draggable: dragSort ? true : null,
1381
- ...ons
1508
+ class: "vxe-upload--file-action"
1382
1509
  },
1383
- optionSlot ? getSlotVNs(optionSlot({ option: item, isMoreView, options: fileList })) : [
1384
- h(
1510
+ [
1511
+ autoHiddenButton && overCount ? renderEmptyElement($xeUpload) : h(
1385
1512
  "div",
1386
1513
  {
1387
- class: "vxe-upload--file-item-icon"
1514
+ class: "vxe-upload--file-action-btn",
1515
+ onClick: clickEvent
1388
1516
  },
1389
- [
1390
- h("i", {
1391
- class: getIcon()[`UPLOAD_FILE_TYPE_${`${item[typeProp]}`.toLocaleUpperCase()}`] || getIcon().UPLOAD_FILE_TYPE_DEFAULT
1517
+ defaultSlot ? getSlotVNs(defaultSlot({ isMoreView, options: fileList, $upload: $xeUpload })) : [
1518
+ h(VxeButtonComponent, {
1519
+ class: "vxe-upload--file-action-button",
1520
+ content: isMoreView || showButtonText ? buttonText ? `${XEUtils.isFunction(buttonText) ? buttonText({}) : buttonText}` : getI18n("vxe.upload.fileBtnText") : "",
1521
+ icon: showButtonIcon ? buttonIcon || getIcon().UPLOAD_FILE_ADD : "",
1522
+ disabled: isDisabled
1392
1523
  })
1393
1524
  ]
1394
1525
  ),
1395
- h(
1396
- "div",
1397
- {
1398
- class: "vxe-upload--file-item-name",
1399
- title: fileName,
1400
- onClick(evnt) {
1401
- if (!isLoading && !isError) {
1402
- handlePreviewFileEvent(evnt, item);
1403
- }
1404
- }
1405
- },
1406
- nameSlot ? getSlotVNs(nameSlot({ option: item, isMoreView, options: fileList })) : fileName
1407
- ),
1408
- isLoading ? h(
1409
- "div",
1410
- {
1411
- class: "vxe-upload--file-item-loading-icon"
1412
- },
1413
- [
1414
- h("i", {
1415
- class: getIcon().UPLOAD_LOADING
1416
- })
1417
- ]
1418
- ) : renderEmptyElement($xeUpload),
1419
- showProgress && isLoading && cacheItem ? h(
1526
+ showTipText && (defTipText || tipSlot) ? h(
1420
1527
  "div",
1421
1528
  {
1422
- class: "vxe-upload--file-item-loading-text"
1529
+ class: "vxe-upload--file-action-tip"
1423
1530
  },
1424
- progressText ? XEUtils.toFormatString(`${XEUtils.isFunction(progressText) ? progressText({}) : progressText}`, { percent: cacheItem.percent }) : getI18n("vxe.upload.uploadProgress", [cacheItem.percent])
1425
- ) : renderEmptyElement($xeUpload),
1426
- !isLoading && (isError && showErrorStatus || isPending && showSubmitButton && !autoSubmit) ? h(
1427
- "div",
1428
- {
1429
- class: "vxe-upload--file-item-rebtn"
1430
- },
1431
- [
1432
- h(VxeButtonComponent, {
1433
- icon: isError ? getIcon().UPLOAD_IMAGE_RE_UPLOAD : getIcon().UPLOAD_IMAGE_UPLOAD,
1434
- mode: "text",
1435
- status: "primary",
1436
- content: isError ? getI18n("vxe.upload.reUpload") : getI18n("vxe.upload.manualUpload"),
1437
- onClick(evnt) {
1438
- handleReUploadEvent(evnt, item);
1439
- }
1440
- })
1441
- ]
1442
- ) : renderEmptyElement($xeUpload),
1531
+ tipSlot ? getSlotVNs(tipSlot({ isMoreView, options: fileList, $upload: $xeUpload })) : `${defTipText}`
1532
+ ) : renderEmptyElement($xeUpload)
1533
+ ]
1534
+ );
1535
+ };
1536
+ const rendeFileMode = () => {
1537
+ const { showList, moreConfig, dragSort } = props;
1538
+ const { fileList, isDragMove } = reactData;
1539
+ const moreOpts = computeMoreOpts.value;
1540
+ const { maxCount, showMoreButton, layout, moreButtonText } = moreOpts;
1541
+ const isHorizontal = layout === "horizontal";
1542
+ const moreBtnSlot = slots.moreButton || slots["more-button"];
1543
+ let currList = fileList;
1544
+ let overMaxNum = 0;
1545
+ let isMoreMax = false;
1546
+ let isMiniMore = false;
1547
+ if (XEUtils.isNumber(maxCount) && fileList.length > maxCount) {
1548
+ isMoreMax = true;
1549
+ isMiniMore = maxCount === 0;
1550
+ overMaxNum = fileList.length - maxCount;
1551
+ currList = fileList.slice(0, maxCount);
1552
+ }
1553
+ return h(
1554
+ "div",
1555
+ {
1556
+ key: "all",
1557
+ class: "vxe-upload--file-wrapper"
1558
+ },
1559
+ showList ? [
1560
+ showMoreButton && moreConfig && isHorizontal ? renderEmptyElement($xeUpload) : renderFileAction(true),
1443
1561
  h(
1444
1562
  "div",
1445
1563
  {
1446
- class: "vxe-upload--file-item-btn-wrapper"
1564
+ class: [
1565
+ "vxe-upload--file-list-wrapper",
1566
+ {
1567
+ "is--horizontal": isHorizontal
1568
+ }
1569
+ ]
1447
1570
  },
1448
- actionSlot ? getSlotVNs(actionSlot({ option: item, isMoreView, options: fileList, readonly: formReadonly })) : [
1449
- cornerSlot ? h(
1450
- "div",
1571
+ [
1572
+ currList.length ? dragSort ? h(
1573
+ TransitionGroup,
1451
1574
  {
1452
- class: "vxe-upload--file-item-action"
1575
+ name: `vxe-upload--drag-list${isDragMove ? "" : "-disabled"}`,
1576
+ tag: "div",
1577
+ class: "vxe-upload--file-list"
1453
1578
  },
1454
- getSlotVNs(cornerSlot({ option: item, isMoreView, options: fileList, readonly: formReadonly }))
1455
- ) : renderEmptyElement($xeUpload),
1456
- showDownloadButton && !(isLoading || isPending) ? h(
1457
- "div",
1458
1579
  {
1459
- class: "vxe-upload--file-item-download-btn",
1460
- onClick(evnt) {
1461
- downloadFileEvent(evnt, item);
1462
- }
1463
- },
1464
- [
1465
- h("i", {
1466
- class: getIcon().UPLOAD_FILE_DOWNLOAD
1467
- })
1468
- ]
1580
+ default: () => renderFileItemList(currList, false)
1581
+ }
1582
+ ) : h(
1583
+ "div",
1584
+ {
1585
+ class: "vxe-upload--file-list"
1586
+ },
1587
+ renderFileItemList(currList, false)
1469
1588
  ) : renderEmptyElement($xeUpload),
1470
- showRemoveButton && !formReadonly && !isDisabled && !isLoading ? h(
1589
+ showMoreButton && overMaxNum ? h(
1471
1590
  "div",
1472
1591
  {
1473
- class: "vxe-upload--file-item-remove-btn",
1474
- onClick(evnt) {
1475
- removeFileEvent(evnt, item, index);
1476
- }
1592
+ class: "vxe-upload--file-over-more"
1477
1593
  },
1478
- [
1479
- h("i", {
1480
- class: getIcon().UPLOAD_FILE_REMOVE
1594
+ moreBtnSlot ? getSlotVNs(moreBtnSlot({ options: fileList })) : [
1595
+ h(VxeButtonComponent, {
1596
+ mode: "text",
1597
+ content: moreButtonText ? XEUtils.isFunction(moreButtonText) ? moreButtonText({ $upload: $xeUpload, options: fileList }) : XEUtils.toFormatString(moreButtonText, [fileList.length]) : getI18n(isMoreMax && isMiniMore ? "vxe.upload.moreFileBtnText" : "vxe.upload.moreBtnText", [fileList.length]),
1598
+ status: "primary",
1599
+ onClick: handleMoreEvent
1481
1600
  })
1482
1601
  ]
1483
- ) : renderEmptyElement($xeUpload)
1602
+ ) : renderEmptyElement($xeUpload),
1603
+ showMoreButton && moreConfig && isHorizontal ? renderFileAction(false) : renderEmptyElement($xeUpload)
1484
1604
  ]
1485
1605
  )
1486
- ]
1606
+ ] : [renderFileAction(false)]
1487
1607
  );
1488
- });
1489
- };
1490
- const renderFileAction = (isMoreView) => {
1491
- const { showUploadButton, buttonText, buttonIcon, showButtonText, showButtonIcon, autoHiddenButton } = props;
1492
- const { fileList } = reactData;
1493
- const isDisabled = computeIsDisabled.value;
1494
- const formReadonly = computeFormReadonly.value;
1495
- const showTipText = computedShowTipText.value;
1496
- const defTipText = computedDefTipText.value;
1497
- const overCount = computeOverCount.value;
1498
- const defaultSlot = slots.default;
1499
- const tipSlot = slots.tip || slots.hint;
1500
- if (formReadonly || !showUploadButton) {
1501
- return renderEmptyElement($xeUpload);
1502
- }
1503
- return h(
1504
- "div",
1505
- {
1506
- class: "vxe-upload--file-action"
1507
- },
1508
- [
1509
- autoHiddenButton && overCount ? renderEmptyElement($xeUpload) : h(
1510
- "div",
1511
- {
1512
- class: "vxe-upload--file-action-btn",
1513
- onClick: clickEvent
1514
- },
1515
- defaultSlot ? getSlotVNs(defaultSlot({ isMoreView, options: fileList, $upload: $xeUpload })) : [
1516
- h(VxeButtonComponent, {
1517
- class: "vxe-upload--file-action-button",
1518
- content: isMoreView || showButtonText ? buttonText ? `${XEUtils.isFunction(buttonText) ? buttonText({}) : buttonText}` : getI18n("vxe.upload.fileBtnText") : "",
1519
- icon: showButtonIcon ? buttonIcon || getIcon().UPLOAD_FILE_ADD : "",
1520
- disabled: isDisabled
1521
- })
1522
- ]
1523
- ),
1524
- showTipText && (defTipText || tipSlot) ? h(
1525
- "div",
1526
- {
1527
- class: "vxe-upload--file-action-tip"
1528
- },
1529
- tipSlot ? getSlotVNs(tipSlot({ isMoreView, options: fileList, $upload: $xeUpload })) : `${defTipText}`
1530
- ) : renderEmptyElement($xeUpload)
1531
- ]
1532
- );
1533
- };
1534
- const rendeFileMode = () => {
1535
- const { showList, moreConfig, dragSort } = props;
1536
- const { fileList, isDragMove } = reactData;
1537
- const moreOpts = computeMoreOpts.value;
1538
- const { maxCount, showMoreButton, layout, moreButtonText } = moreOpts;
1539
- const isHorizontal = layout === "horizontal";
1540
- const moreBtnSlot = slots.moreButton || slots["more-button"];
1541
- let currList = fileList;
1542
- let overMaxNum = 0;
1543
- let isMoreMax = false;
1544
- let isMiniMore = false;
1545
- if (XEUtils.isNumber(maxCount) && fileList.length > maxCount) {
1546
- isMoreMax = true;
1547
- isMiniMore = maxCount === 0;
1548
- overMaxNum = fileList.length - maxCount;
1549
- currList = fileList.slice(0, maxCount);
1550
- }
1551
- return h(
1552
- "div",
1553
- {
1554
- key: "all",
1555
- class: "vxe-upload--file-wrapper"
1556
- },
1557
- showList ? [
1558
- showMoreButton && moreConfig && isHorizontal ? renderEmptyElement($xeUpload) : renderFileAction(true),
1559
- h(
1608
+ };
1609
+ const renderImageItemList = (currList, isMoreView) => {
1610
+ const { showRemoveButton, showProgress, progressText, showPreview, showErrorStatus, dragSort, autoSubmit, showSubmitButton } = props;
1611
+ const { fileList, fileCacheMaps } = reactData;
1612
+ const isDisabled = computeIsDisabled.value;
1613
+ const formReadonly = computeFormReadonly.value;
1614
+ const imageOpts = computeImageOpts.value;
1615
+ const imgStyle = computeImgStyle.value;
1616
+ const optionSlot = slots.option;
1617
+ const actionSlot = slots.action;
1618
+ const cornerSlot = slots.corner;
1619
+ const ons = {
1620
+ onMousedown: handleItemMousedownEvent
1621
+ };
1622
+ if (dragSort && currList.length > 1) {
1623
+ ons.onDragstart = handleDragSortDragstartEvent;
1624
+ ons.onDragover = handleDragSortDragoverEvent;
1625
+ ons.onDragend = handleDragSortDragendEvent;
1626
+ }
1627
+ return currList.map((item, index) => {
1628
+ const fileKey = getFieldKey(item);
1629
+ const cacheItem = fileCacheMaps[fileKey];
1630
+ let isLoading = false;
1631
+ let isError = false;
1632
+ let isPending = false;
1633
+ if (cacheItem) {
1634
+ isLoading = cacheItem.loading;
1635
+ isError = cacheItem.status === "error";
1636
+ isPending = cacheItem.status === "pending";
1637
+ }
1638
+ return h(
1560
1639
  "div",
1561
1640
  {
1641
+ key: dragSort ? fileKey : index,
1562
1642
  class: [
1563
- "vxe-upload--file-list-wrapper",
1643
+ "vxe-upload--image-item",
1564
1644
  {
1565
- "is--horizontal": isHorizontal
1645
+ "is--preview": showPreview,
1646
+ "is--circle": imageOpts.circle,
1647
+ "is--loading": isLoading,
1648
+ "is--pending": isPending,
1649
+ "is--error": isError
1566
1650
  }
1567
- ]
1651
+ ],
1652
+ fileid: fileKey,
1653
+ draggable: dragSort ? true : null,
1654
+ ...ons
1568
1655
  },
1569
- [
1570
- currList.length ? dragSort ? h(
1571
- TransitionGroup,
1572
- {
1573
- name: `vxe-upload--drag-list${isDragMove ? "" : "-disabled"}`,
1574
- tag: "div",
1575
- class: "vxe-upload--file-list"
1576
- },
1577
- {
1578
- default: () => renderFileItemList(currList, false)
1579
- }
1580
- ) : h(
1581
- "div",
1582
- {
1583
- class: "vxe-upload--file-list"
1584
- },
1585
- renderFileItemList(currList, false)
1586
- ) : renderEmptyElement($xeUpload),
1587
- showMoreButton && overMaxNum ? h(
1656
+ optionSlot ? getSlotVNs(optionSlot({ option: item, isMoreView, options: fileList })) : [
1657
+ h(
1588
1658
  "div",
1589
1659
  {
1590
- class: "vxe-upload--file-over-more"
1660
+ class: "vxe-upload--image-item-box",
1661
+ style: isMoreView ? null : imgStyle,
1662
+ onClick(evnt) {
1663
+ if (!isLoading && !isError) {
1664
+ handlePreviewImageEvent(evnt, item, index);
1665
+ }
1666
+ }
1591
1667
  },
1592
- moreBtnSlot ? getSlotVNs(moreBtnSlot({ options: fileList })) : [
1593
- h(VxeButtonComponent, {
1594
- mode: "text",
1595
- content: moreButtonText ? XEUtils.isFunction(moreButtonText) ? moreButtonText({ $upload: $xeUpload, options: fileList }) : XEUtils.toFormatString(moreButtonText, [fileList.length]) : getI18n(isMoreMax && isMiniMore ? "vxe.upload.moreFileBtnText" : "vxe.upload.moreBtnText", [fileList.length]),
1596
- status: "primary",
1597
- onClick: handleMoreEvent
1598
- })
1668
+ [
1669
+ isLoading && cacheItem ? h(
1670
+ "div",
1671
+ {
1672
+ class: "vxe-upload--image-item-loading"
1673
+ },
1674
+ [
1675
+ h(
1676
+ "div",
1677
+ {
1678
+ class: "vxe-upload--image-item-loading-icon"
1679
+ },
1680
+ [
1681
+ h("i", {
1682
+ class: getIcon().UPLOAD_LOADING
1683
+ })
1684
+ ]
1685
+ ),
1686
+ showProgress ? h(
1687
+ "div",
1688
+ {
1689
+ class: "vxe-upload--image-item-loading-text"
1690
+ },
1691
+ progressText ? XEUtils.toFormatString(`${XEUtils.isFunction(progressText) ? progressText({}) : progressText}`, { percent: cacheItem.percent }) : getI18n("vxe.upload.uploadProgress", [cacheItem.percent])
1692
+ ) : renderEmptyElement($xeUpload)
1693
+ ]
1694
+ ) : renderEmptyElement($xeUpload),
1695
+ h(
1696
+ "div",
1697
+ {
1698
+ class: "vxe-upload--image-item-img-wrapper",
1699
+ title: getI18n("vxe.upload.viewItemTitle")
1700
+ },
1701
+ [
1702
+ h("img", {
1703
+ class: "vxe-upload--image-item-img",
1704
+ src: getThumbnailFileUrl(item)
1705
+ })
1706
+ ]
1707
+ ),
1708
+ !isLoading && (isError && showErrorStatus || isPending && showSubmitButton && !autoSubmit) ? h(
1709
+ "div",
1710
+ {
1711
+ class: "vxe-upload--image-item-rebtn"
1712
+ },
1713
+ [
1714
+ h(VxeButtonComponent, {
1715
+ icon: isError ? getIcon().UPLOAD_IMAGE_RE_UPLOAD : getIcon().UPLOAD_IMAGE_UPLOAD,
1716
+ mode: "text",
1717
+ status: "primary",
1718
+ content: isError ? getI18n("vxe.upload.reUpload") : getI18n("vxe.upload.manualUpload"),
1719
+ onClick(evnt) {
1720
+ handleReUploadEvent(evnt, item);
1721
+ }
1722
+ })
1723
+ ]
1724
+ ) : renderEmptyElement($xeUpload),
1725
+ h(
1726
+ "div",
1727
+ {
1728
+ class: "vxe-upload--image-item-btn-wrapper",
1729
+ onClick(evnt) {
1730
+ evnt.stopPropagation();
1731
+ }
1732
+ },
1733
+ actionSlot ? getSlotVNs(actionSlot({ option: item, isMoreView, options: fileList, readonly: formReadonly })) : [
1734
+ cornerSlot ? h(
1735
+ "div",
1736
+ {
1737
+ class: "vxe-upload--file-item-action"
1738
+ },
1739
+ getSlotVNs(cornerSlot({ option: item, isMoreView, options: fileList, readonly: formReadonly }))
1740
+ ) : renderEmptyElement($xeUpload),
1741
+ showRemoveButton && !formReadonly && !isDisabled && !isLoading ? h(
1742
+ "div",
1743
+ {
1744
+ class: "vxe-upload--image-item-remove-btn",
1745
+ onClick(evnt) {
1746
+ evnt.stopPropagation();
1747
+ removeFileEvent(evnt, item, index);
1748
+ }
1749
+ },
1750
+ [
1751
+ h("i", {
1752
+ class: getIcon().UPLOAD_IMAGE_REMOVE
1753
+ })
1754
+ ]
1755
+ ) : renderEmptyElement($xeUpload)
1756
+ ]
1757
+ )
1599
1758
  ]
1600
- ) : renderEmptyElement($xeUpload),
1601
- showMoreButton && moreConfig && isHorizontal ? renderFileAction(false) : renderEmptyElement($xeUpload)
1759
+ )
1602
1760
  ]
1603
- )
1604
- ] : [renderFileAction(false)]
1605
- );
1606
- };
1607
- const renderImageItemList = (currList, isMoreView) => {
1608
- const { showRemoveButton, showProgress, progressText, showPreview, showErrorStatus, dragSort, autoSubmit, showSubmitButton } = props;
1609
- const { fileList, fileCacheMaps } = reactData;
1610
- const isDisabled = computeIsDisabled.value;
1611
- const formReadonly = computeFormReadonly.value;
1612
- const imageOpts = computeImageOpts.value;
1613
- const imgStyle = computeImgStyle.value;
1614
- const optionSlot = slots.option;
1615
- const actionSlot = slots.action;
1616
- const cornerSlot = slots.corner;
1617
- const ons = {
1618
- onMousedown: handleItemMousedownEvent
1761
+ );
1762
+ });
1619
1763
  };
1620
- if (dragSort && currList.length > 1) {
1621
- ons.onDragstart = handleDragSortDragstartEvent;
1622
- ons.onDragover = handleDragSortDragoverEvent;
1623
- ons.onDragend = handleDragSortDragendEvent;
1624
- }
1625
- return currList.map((item, index) => {
1626
- const fileKey = getFieldKey(item);
1627
- const cacheItem = fileCacheMaps[fileKey];
1628
- let isLoading = false;
1629
- let isError = false;
1630
- let isPending = false;
1631
- if (cacheItem) {
1632
- isLoading = cacheItem.loading;
1633
- isError = cacheItem.status === "error";
1634
- isPending = cacheItem.status === "pending";
1764
+ const renderImageAction = (isMoreView) => {
1765
+ const { showUploadButton, buttonText, buttonIcon, showButtonText, showButtonIcon, autoHiddenButton } = props;
1766
+ const { fileList } = reactData;
1767
+ const formReadonly = computeFormReadonly.value;
1768
+ const showTipText = computedShowTipText.value;
1769
+ const defTipText = computedDefTipText.value;
1770
+ const overCount = computeOverCount.value;
1771
+ const imgStyle = computeImgStyle.value;
1772
+ const defaultSlot = slots.default;
1773
+ const tipSlot = slots.tip || slots.hint;
1774
+ if (formReadonly || !showUploadButton || autoHiddenButton && overCount) {
1775
+ return renderEmptyElement($xeUpload);
1635
1776
  }
1636
1777
  return h(
1637
1778
  "div",
1638
1779
  {
1639
- key: dragSort ? fileKey : index,
1640
- class: [
1641
- "vxe-upload--image-item",
1642
- {
1643
- "is--preview": showPreview,
1644
- "is--circle": imageOpts.circle,
1645
- "is--loading": isLoading,
1646
- "is--pending": isPending,
1647
- "is--error": isError
1648
- }
1649
- ],
1650
- fileid: fileKey,
1651
- draggable: dragSort ? true : null,
1652
- ...ons
1780
+ key: "action",
1781
+ class: "vxe-upload--image-action"
1653
1782
  },
1654
- optionSlot ? getSlotVNs(optionSlot({ option: item, isMoreView, options: fileList })) : [
1783
+ [
1655
1784
  h(
1656
1785
  "div",
1657
1786
  {
1658
- class: "vxe-upload--image-item-box",
1659
- style: isMoreView ? null : imgStyle,
1660
- onClick(evnt) {
1661
- if (!isLoading && !isError) {
1662
- handlePreviewImageEvent(evnt, item, index);
1663
- }
1664
- }
1787
+ class: "vxe-upload--image-action-btn",
1788
+ onClick: clickEvent
1665
1789
  },
1666
- [
1667
- isLoading && cacheItem ? h(
1790
+ defaultSlot ? defaultSlot({ isMoreView, options: fileList, $upload: $xeUpload }) : [
1791
+ h(
1668
1792
  "div",
1669
1793
  {
1670
- class: "vxe-upload--image-item-loading"
1794
+ class: "vxe-upload--image-action-box",
1795
+ style: isMoreView ? null : imgStyle
1671
1796
  },
1672
1797
  [
1673
- h(
1798
+ showButtonIcon ? h(
1674
1799
  "div",
1675
1800
  {
1676
- class: "vxe-upload--image-item-loading-icon"
1801
+ class: "vxe-upload--image-action-icon"
1677
1802
  },
1678
1803
  [
1679
1804
  h("i", {
1680
- class: getIcon().UPLOAD_LOADING
1805
+ class: buttonIcon || getIcon().UPLOAD_IMAGE_ADD
1681
1806
  })
1682
1807
  ]
1683
- ),
1684
- showProgress ? h(
1685
- "div",
1686
- {
1687
- class: "vxe-upload--image-item-loading-text"
1688
- },
1689
- progressText ? XEUtils.toFormatString(`${XEUtils.isFunction(progressText) ? progressText({}) : progressText}`, { percent: cacheItem.percent }) : getI18n("vxe.upload.uploadProgress", [cacheItem.percent])
1690
- ) : renderEmptyElement($xeUpload)
1691
- ]
1692
- ) : renderEmptyElement($xeUpload),
1693
- h(
1694
- "div",
1695
- {
1696
- class: "vxe-upload--image-item-img-wrapper",
1697
- title: getI18n("vxe.upload.viewItemTitle")
1698
- },
1699
- [
1700
- h("img", {
1701
- class: "vxe-upload--image-item-img",
1702
- src: getThumbnailFileUrl(item)
1703
- })
1704
- ]
1705
- ),
1706
- !isLoading && (isError && showErrorStatus || isPending && showSubmitButton && !autoSubmit) ? h(
1707
- "div",
1708
- {
1709
- class: "vxe-upload--image-item-rebtn"
1710
- },
1711
- [
1712
- h(VxeButtonComponent, {
1713
- icon: isError ? getIcon().UPLOAD_IMAGE_RE_UPLOAD : getIcon().UPLOAD_IMAGE_UPLOAD,
1714
- mode: "text",
1715
- status: "primary",
1716
- content: isError ? getI18n("vxe.upload.reUpload") : getI18n("vxe.upload.manualUpload"),
1717
- onClick(evnt) {
1718
- handleReUploadEvent(evnt, item);
1719
- }
1720
- })
1721
- ]
1722
- ) : renderEmptyElement($xeUpload),
1723
- h(
1724
- "div",
1725
- {
1726
- class: "vxe-upload--image-item-btn-wrapper",
1727
- onClick(evnt) {
1728
- evnt.stopPropagation();
1729
- }
1730
- },
1731
- actionSlot ? getSlotVNs(actionSlot({ option: item, isMoreView, options: fileList, readonly: formReadonly })) : [
1732
- cornerSlot ? h(
1808
+ ) : renderEmptyElement($xeUpload),
1809
+ isMoreView || showButtonText ? h(
1733
1810
  "div",
1734
1811
  {
1735
- class: "vxe-upload--file-item-action"
1812
+ class: "vxe-upload--image-action-content"
1736
1813
  },
1737
- getSlotVNs(cornerSlot({ option: item, isMoreView, options: fileList, readonly: formReadonly }))
1814
+ buttonText ? `${XEUtils.isFunction(buttonText) ? buttonText({}) : buttonText}` : getI18n("vxe.upload.imgBtnText")
1738
1815
  ) : renderEmptyElement($xeUpload),
1739
- showRemoveButton && !formReadonly && !isDisabled && !isLoading ? h(
1816
+ showTipText && (defTipText || tipSlot) ? h(
1740
1817
  "div",
1741
1818
  {
1742
- class: "vxe-upload--image-item-remove-btn",
1743
- onClick(evnt) {
1744
- evnt.stopPropagation();
1745
- removeFileEvent(evnt, item, index);
1746
- }
1819
+ class: "vxe-upload--image-action-hint"
1747
1820
  },
1748
- [
1749
- h("i", {
1750
- class: getIcon().UPLOAD_IMAGE_REMOVE
1751
- })
1752
- ]
1821
+ tipSlot ? getSlotVNs(tipSlot({ isMoreView, options: fileList, $upload: $xeUpload })) : `${defTipText}`
1753
1822
  ) : renderEmptyElement($xeUpload)
1754
1823
  ]
1755
1824
  )
@@ -1757,110 +1826,66 @@ var upload_default = defineVxeComponent({
1757
1826
  )
1758
1827
  ]
1759
1828
  );
1760
- });
1761
- };
1762
- const renderImageAction = (isMoreView) => {
1763
- const { showUploadButton, buttonText, buttonIcon, showButtonText, showButtonIcon, autoHiddenButton } = props;
1764
- const { fileList } = reactData;
1765
- const formReadonly = computeFormReadonly.value;
1766
- const showTipText = computedShowTipText.value;
1767
- const defTipText = computedDefTipText.value;
1768
- const overCount = computeOverCount.value;
1769
- const imgStyle = computeImgStyle.value;
1770
- const defaultSlot = slots.default;
1771
- const tipSlot = slots.tip || slots.hint;
1772
- if (formReadonly || !showUploadButton || autoHiddenButton && overCount) {
1773
- return renderEmptyElement($xeUpload);
1774
- }
1775
- return h(
1776
- "div",
1777
- {
1778
- key: "action",
1779
- class: "vxe-upload--image-action"
1780
- },
1781
- [
1782
- h(
1783
- "div",
1784
- {
1785
- class: "vxe-upload--image-action-btn",
1786
- onClick: clickEvent
1787
- },
1788
- defaultSlot ? defaultSlot({ isMoreView, options: fileList, $upload: $xeUpload }) : [
1789
- h(
1790
- "div",
1791
- {
1792
- class: "vxe-upload--image-action-box",
1793
- style: isMoreView ? null : imgStyle
1794
- },
1795
- [
1796
- showButtonIcon ? h(
1829
+ };
1830
+ const renderImageMode = () => {
1831
+ const { showList, dragSort } = props;
1832
+ const { fileList, isDragMove } = reactData;
1833
+ const moreOpts = computeMoreOpts.value;
1834
+ const moreBtnSlot = slots.moreButton || slots["more-button"];
1835
+ const { maxCount, showMoreButton, moreButtonText } = moreOpts;
1836
+ let currList = fileList;
1837
+ let overMaxNum = 0;
1838
+ let isMoreMax = false;
1839
+ let isMiniMore = false;
1840
+ if (XEUtils.isNumber(maxCount) && fileList.length > maxCount) {
1841
+ isMoreMax = true;
1842
+ isMiniMore = maxCount === 0;
1843
+ overMaxNum = fileList.length - maxCount;
1844
+ currList = fileList.slice(0, maxCount);
1845
+ }
1846
+ return h(
1847
+ "div",
1848
+ {
1849
+ key: "image",
1850
+ class: "vxe-upload--image-wrapper"
1851
+ },
1852
+ showList ? [
1853
+ dragSort ? h(
1854
+ TransitionGroup,
1855
+ {
1856
+ name: `vxe-upload--drag-list${isDragMove ? "" : "-disabled"}`,
1857
+ tag: "div",
1858
+ class: "vxe-upload--image-list"
1859
+ },
1860
+ {
1861
+ default: () => renderImageItemList(currList, false).concat([
1862
+ showMoreButton && overMaxNum ? h(
1797
1863
  "div",
1798
1864
  {
1799
- class: "vxe-upload--image-action-icon"
1865
+ key: "om",
1866
+ class: "vxe-upload--image-over-more"
1800
1867
  },
1801
- [
1802
- h("i", {
1803
- class: buttonIcon || getIcon().UPLOAD_IMAGE_ADD
1868
+ moreBtnSlot ? getSlotVNs(moreBtnSlot({ options: fileList })) : [
1869
+ h(VxeButtonComponent, {
1870
+ mode: "text",
1871
+ content: moreButtonText ? XEUtils.isFunction(moreButtonText) ? moreButtonText({ $upload: $xeUpload, options: fileList }) : XEUtils.toFormatString(moreButtonText, [fileList.length]) : getI18n(isMoreMax && isMiniMore ? "vxe.upload.moreImgBtnText" : "vxe.upload.moreBtnText", [fileList.length]),
1872
+ status: "primary",
1873
+ onClick: handleMoreEvent
1804
1874
  })
1805
1875
  ]
1806
1876
  ) : renderEmptyElement($xeUpload),
1807
- isMoreView || showButtonText ? h(
1808
- "div",
1809
- {
1810
- class: "vxe-upload--image-action-content"
1811
- },
1812
- buttonText ? `${XEUtils.isFunction(buttonText) ? buttonText({}) : buttonText}` : getI18n("vxe.upload.imgBtnText")
1813
- ) : renderEmptyElement($xeUpload),
1814
- showTipText && (defTipText || tipSlot) ? h(
1815
- "div",
1816
- {
1817
- class: "vxe-upload--image-action-hint"
1818
- },
1819
- tipSlot ? getSlotVNs(tipSlot({ isMoreView, options: fileList, $upload: $xeUpload })) : `${defTipText}`
1820
- ) : renderEmptyElement($xeUpload)
1821
- ]
1822
- )
1823
- ]
1824
- )
1825
- ]
1826
- );
1827
- };
1828
- const renderImageMode = () => {
1829
- const { showList, dragSort } = props;
1830
- const { fileList, isDragMove } = reactData;
1831
- const moreOpts = computeMoreOpts.value;
1832
- const moreBtnSlot = slots.moreButton || slots["more-button"];
1833
- const { maxCount, showMoreButton, moreButtonText } = moreOpts;
1834
- let currList = fileList;
1835
- let overMaxNum = 0;
1836
- let isMoreMax = false;
1837
- let isMiniMore = false;
1838
- if (XEUtils.isNumber(maxCount) && fileList.length > maxCount) {
1839
- isMoreMax = true;
1840
- isMiniMore = maxCount === 0;
1841
- overMaxNum = fileList.length - maxCount;
1842
- currList = fileList.slice(0, maxCount);
1843
- }
1844
- return h(
1845
- "div",
1846
- {
1847
- key: "image",
1848
- class: "vxe-upload--image-wrapper"
1849
- },
1850
- showList ? [
1851
- dragSort ? h(
1852
- TransitionGroup,
1853
- {
1854
- name: `vxe-upload--drag-list${isDragMove ? "" : "-disabled"}`,
1855
- tag: "div",
1856
- class: "vxe-upload--image-list"
1857
- },
1858
- {
1859
- default: () => renderImageItemList(currList, false).concat([
1877
+ renderImageAction(false)
1878
+ ])
1879
+ }
1880
+ ) : h(
1881
+ "div",
1882
+ {
1883
+ class: "vxe-upload--image-list"
1884
+ },
1885
+ renderImageItemList(currList, false).concat([
1860
1886
  showMoreButton && overMaxNum ? h(
1861
1887
  "div",
1862
1888
  {
1863
- key: "om",
1864
1889
  class: "vxe-upload--image-over-more"
1865
1890
  },
1866
1891
  moreBtnSlot ? getSlotVNs(moreBtnSlot({ options: fileList })) : [
@@ -1874,136 +1899,114 @@ var upload_default = defineVxeComponent({
1874
1899
  ) : renderEmptyElement($xeUpload),
1875
1900
  renderImageAction(false)
1876
1901
  ])
1877
- }
1878
- ) : h(
1879
- "div",
1880
- {
1881
- class: "vxe-upload--image-list"
1882
- },
1883
- renderImageItemList(currList, false).concat([
1884
- showMoreButton && overMaxNum ? h(
1885
- "div",
1886
- {
1887
- class: "vxe-upload--image-over-more"
1888
- },
1889
- moreBtnSlot ? getSlotVNs(moreBtnSlot({ options: fileList })) : [
1890
- h(VxeButtonComponent, {
1891
- mode: "text",
1892
- content: moreButtonText ? XEUtils.isFunction(moreButtonText) ? moreButtonText({ $upload: $xeUpload, options: fileList }) : XEUtils.toFormatString(moreButtonText, [fileList.length]) : getI18n(isMoreMax && isMiniMore ? "vxe.upload.moreImgBtnText" : "vxe.upload.moreBtnText", [fileList.length]),
1893
- status: "primary",
1894
- onClick: handleMoreEvent
1895
- })
1896
- ]
1897
- ) : renderEmptyElement($xeUpload),
1898
- renderImageAction(false)
1899
- ])
1900
- )
1901
- ] : [
1902
- h(
1903
- "div",
1904
- {
1905
- class: "vxe-upload--image-list"
1906
- },
1907
- [renderImageAction(false)]
1908
- )
1909
- ]
1910
- );
1911
- };
1912
- const renderVN = () => {
1913
- const { showErrorStatus, dragToUpload, pasteToUpload, dragSort, dragPlaceholder } = props;
1914
- const { isDragUploadStatus, showMorePopup, isActivated, dragIndex } = reactData;
1915
- const vSize = computeSize.value;
1916
- const isDisabled = computeIsDisabled.value;
1917
- const formReadonly = computeFormReadonly.value;
1918
- const isImage = computeIsImage.value;
1919
- const ons = {
1920
- onMousedown: handleItemMousedownEvent
1902
+ )
1903
+ ] : [
1904
+ h(
1905
+ "div",
1906
+ {
1907
+ class: "vxe-upload--image-list"
1908
+ },
1909
+ [renderImageAction(false)]
1910
+ )
1911
+ ]
1912
+ );
1921
1913
  };
1922
- if (dragToUpload && dragIndex === -1) {
1923
- ons.onDragover = handleUploadDragoverEvent;
1924
- ons.onDragleave = handleUploadDragleaveEvent;
1925
- ons.onDrop = handleUploadDropEvent;
1926
- }
1927
- return h(
1928
- "div",
1929
- {
1930
- ref: refElem,
1931
- class: [
1932
- "vxe-upload",
1933
- {
1934
- [`size--${vSize}`]: vSize,
1935
- "is--active": isActivated,
1936
- "is--readonly": formReadonly,
1937
- "is--disabled": isDisabled,
1938
- "is--paste": pasteToUpload,
1939
- "show--error": showErrorStatus,
1940
- "is--drag": isDragUploadStatus
1941
- }
1942
- ],
1943
- ...ons
1944
- },
1945
- [
1946
- isImage ? renderImageMode() : rendeFileMode(),
1947
- dragSort ? h("div", {
1948
- ref: refDragLineElem,
1949
- class: "vxe-upload--drag-line"
1950
- }) : renderEmptyElement($xeUpload),
1951
- isDragUploadStatus && !showMorePopup ? h(
1952
- "div",
1953
- {
1954
- class: "vxe-upload--drag-placeholder"
1955
- },
1956
- dragPlaceholder || getI18n("vxe.upload.dragPlaceholder")
1957
- ) : renderEmptyElement($xeUpload)
1958
- ]
1914
+ const renderVN = () => {
1915
+ const { showErrorStatus, dragToUpload, pasteToUpload, dragSort, dragPlaceholder } = props;
1916
+ const { isDragUploadStatus, showMorePopup, isActivated, dragIndex } = reactData;
1917
+ const vSize = computeSize.value;
1918
+ const isDisabled = computeIsDisabled.value;
1919
+ const formReadonly = computeFormReadonly.value;
1920
+ const isImage = computeIsImage.value;
1921
+ const ons = {
1922
+ onMousedown: handleItemMousedownEvent
1923
+ };
1924
+ if (dragToUpload && dragIndex === -1) {
1925
+ ons.onDragover = handleUploadDragoverEvent;
1926
+ ons.onDragleave = handleUploadDragleaveEvent;
1927
+ ons.onDrop = handleUploadDropEvent;
1928
+ }
1929
+ return h(
1930
+ "div",
1931
+ {
1932
+ ref: refElem,
1933
+ class: [
1934
+ "vxe-upload",
1935
+ {
1936
+ [`size--${vSize}`]: vSize,
1937
+ "is--active": isActivated,
1938
+ "is--readonly": formReadonly,
1939
+ "is--disabled": isDisabled,
1940
+ "is--paste": pasteToUpload,
1941
+ "show--error": showErrorStatus,
1942
+ "is--drag": isDragUploadStatus
1943
+ }
1944
+ ],
1945
+ ...ons
1946
+ },
1947
+ [
1948
+ isImage ? renderImageMode() : rendeFileMode(),
1949
+ dragSort ? h("div", {
1950
+ ref: refDragLineElem,
1951
+ class: "vxe-upload--drag-line"
1952
+ }) : renderEmptyElement($xeUpload),
1953
+ isDragUploadStatus && !showMorePopup ? h(
1954
+ "div",
1955
+ {
1956
+ class: "vxe-upload--drag-placeholder"
1957
+ },
1958
+ dragPlaceholder || getI18n("vxe.upload.dragPlaceholder")
1959
+ ) : renderEmptyElement($xeUpload)
1960
+ ]
1961
+ );
1962
+ };
1963
+ const listFlag = ref(0);
1964
+ watch(
1965
+ () => props.modelValue ? props.modelValue.length : 0,
1966
+ () => {
1967
+ listFlag.value++;
1968
+ }
1959
1969
  );
1960
- };
1961
- const listFlag = ref(0);
1962
- watch(
1963
- () => props.modelValue ? props.modelValue.length : 0,
1964
- () => {
1965
- listFlag.value++;
1966
- }
1967
- );
1968
- watch(
1969
- () => props.modelValue,
1970
- () => {
1971
- listFlag.value++;
1972
- }
1973
- );
1974
- watch(listFlag, () => {
1970
+ watch(
1971
+ () => props.modelValue,
1972
+ () => {
1973
+ listFlag.value++;
1974
+ }
1975
+ );
1976
+ watch(listFlag, () => {
1977
+ updateFileList();
1978
+ });
1979
+ onMounted(() => {
1980
+ if (props.multiple && props.singleMode) {
1981
+ errLog("vxe.error.errConflicts", ["multiple", "single-mode"]);
1982
+ }
1983
+ if (props.imageStyle) {
1984
+ warnLog("vxe.error.delProp", ["image-style", "image-config"]);
1985
+ }
1986
+ if (props.dragSort) {
1987
+ initTpImg();
1988
+ }
1989
+ globalEvents.on($xeUpload, "paste", handleGlobalPasteEvent);
1990
+ globalEvents.on($xeUpload, "click", handleGlobalClickEvent);
1991
+ globalEvents.on($xeUpload, "blur", handleGlobalBlurEvent);
1992
+ });
1993
+ onBeforeUnmount(() => {
1994
+ reactData.isDragUploadStatus = false;
1995
+ globalEvents.off($xeUpload, "paste");
1996
+ globalEvents.off($xeUpload, "click");
1997
+ globalEvents.off($xeUpload, "blur");
1998
+ XEUtils.assign(reactData, createReactData());
1999
+ XEUtils.assign(internalData, createInternalData());
2000
+ });
1975
2001
  updateFileList();
1976
- });
1977
- onMounted(() => {
1978
- if (props.multiple && props.singleMode) {
1979
- errLog("vxe.error.errConflicts", ["multiple", "single-mode"]);
1980
- }
1981
- if (props.imageStyle) {
1982
- warnLog("vxe.error.delProp", ["image-style", "image-config"]);
1983
- }
1984
- if (props.dragSort) {
1985
- initTpImg();
1986
- }
1987
- globalEvents.on($xeUpload, "paste", handleGlobalPasteEvent);
1988
- globalEvents.on($xeUpload, "click", handleGlobalClickEvent);
1989
- globalEvents.on($xeUpload, "blur", handleGlobalBlurEvent);
1990
- });
1991
- onBeforeUnmount(() => {
1992
- reactData.isDragUploadStatus = false;
1993
- globalEvents.off($xeUpload, "paste");
1994
- globalEvents.off($xeUpload, "click");
1995
- globalEvents.off($xeUpload, "blur");
1996
- XEUtils.assign(reactData, createReactData());
1997
- XEUtils.assign(internalData, createInternalData());
1998
- });
1999
- updateFileList();
2000
- $xeUpload.renderVN = renderVN;
2001
- return $xeUpload;
2002
- },
2003
- render() {
2004
- return this.renderVN();
2005
- }
2006
- });
2002
+ $xeUpload.renderVN = renderVN;
2003
+ return $xeUpload;
2004
+ },
2005
+ render() {
2006
+ return this.renderVN();
2007
+ }
2008
+ })
2009
+ );
2007
2010
  export {
2008
2011
  upload_default as default
2009
2012
  };