@douyinfe/semi-foundation 2.36.0-beta.0 → 2.36.0

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 (415) hide show
  1. package/calendar/foundation.ts +2 -1
  2. package/lib/cjs/anchor/constants.js +0 -2
  3. package/lib/cjs/anchor/foundation.js +10 -73
  4. package/lib/cjs/anchor/linkFoundation.js +4 -16
  5. package/lib/cjs/autoComplete/constants.js +0 -3
  6. package/lib/cjs/autoComplete/foundation.d.ts +1 -1
  7. package/lib/cjs/autoComplete/foundation.js +25 -139
  8. package/lib/cjs/autoComplete/optionFoundation.js +4 -14
  9. package/lib/cjs/avatar/constants.js +0 -2
  10. package/lib/cjs/avatar/foundation.js +0 -17
  11. package/lib/cjs/backtop/constants.js +0 -2
  12. package/lib/cjs/backtop/foundation.d.ts +2 -2
  13. package/lib/cjs/backtop/foundation.js +0 -21
  14. package/lib/cjs/badge/constants.js +0 -2
  15. package/lib/cjs/banner/constants.js +0 -2
  16. package/lib/cjs/banner/foundation.js +0 -7
  17. package/lib/cjs/base/constants.js +2 -4
  18. package/lib/cjs/base/foundation.d.ts +1 -1
  19. package/lib/cjs/base/foundation.js +12 -46
  20. package/lib/cjs/base/index.js +0 -3
  21. package/lib/cjs/breadcrumb/constants.js +0 -2
  22. package/lib/cjs/breadcrumb/foundation.js +1 -12
  23. package/lib/cjs/breadcrumb/itemFoundation.js +0 -7
  24. package/lib/cjs/button/constants.js +0 -2
  25. package/lib/cjs/calendar/constants.js +0 -2
  26. package/lib/cjs/calendar/eventUtil.d.ts +1 -1
  27. package/lib/cjs/calendar/eventUtil.js +2 -74
  28. package/lib/cjs/calendar/foundation.d.ts +2 -2
  29. package/lib/cjs/calendar/foundation.js +28 -123
  30. package/lib/cjs/card/constants.js +0 -2
  31. package/lib/cjs/carousel/constants.js +0 -2
  32. package/lib/cjs/carousel/foundation.js +2 -52
  33. package/lib/cjs/cascader/constants.js +0 -3
  34. package/lib/cjs/cascader/foundation.d.ts +4 -4
  35. package/lib/cjs/cascader/foundation.js +28 -242
  36. package/lib/cjs/cascader/util.js +6 -24
  37. package/lib/cjs/checkbox/checkboxFoundation.js +2 -38
  38. package/lib/cjs/checkbox/checkboxGroupFoundation.js +2 -23
  39. package/lib/cjs/checkbox/constants.js +0 -2
  40. package/lib/cjs/collapse/constants.js +0 -2
  41. package/lib/cjs/collapse/foundation.d.ts +1 -1
  42. package/lib/cjs/collapse/foundation.js +2 -13
  43. package/lib/cjs/collapsible/constants.js +0 -2
  44. package/lib/cjs/collapsible/foundation.js +0 -9
  45. package/lib/cjs/datePicker/_utils/formatter.js +4 -10
  46. package/lib/cjs/datePicker/_utils/getDayOfWeek.d.ts +1 -1
  47. package/lib/cjs/datePicker/_utils/getDayOfWeek.js +0 -4
  48. package/lib/cjs/datePicker/_utils/getDefaultFormatToken.js +0 -5
  49. package/lib/cjs/datePicker/_utils/getDefaultPickerDate.d.ts +1 -1
  50. package/lib/cjs/datePicker/_utils/getDefaultPickerDate.js +0 -15
  51. package/lib/cjs/datePicker/_utils/getFullDateOffset.js +0 -7
  52. package/lib/cjs/datePicker/_utils/getInsetInputFormatToken.js +0 -5
  53. package/lib/cjs/datePicker/_utils/getInsetInputValueFromInsetInputStr.js +0 -6
  54. package/lib/cjs/datePicker/_utils/getMonthTable.d.ts +1 -1
  55. package/lib/cjs/datePicker/_utils/getMonthTable.js +3 -14
  56. package/lib/cjs/datePicker/_utils/getMonthsInYear.js +0 -2
  57. package/lib/cjs/datePicker/_utils/getYears.js +0 -4
  58. package/lib/cjs/datePicker/_utils/index.js +0 -13
  59. package/lib/cjs/datePicker/_utils/isAfter.js +0 -4
  60. package/lib/cjs/datePicker/_utils/isBefore.js +0 -4
  61. package/lib/cjs/datePicker/_utils/isBetween.js +0 -4
  62. package/lib/cjs/datePicker/_utils/isDate.js +0 -1
  63. package/lib/cjs/datePicker/_utils/isSameDay.js +0 -4
  64. package/lib/cjs/datePicker/_utils/isTimestamp.js +0 -4
  65. package/lib/cjs/datePicker/_utils/isUnixTimestamp.js +0 -4
  66. package/lib/cjs/datePicker/_utils/isValidDate.js +0 -1
  67. package/lib/cjs/datePicker/_utils/isValidTimeZone.js +0 -1
  68. package/lib/cjs/datePicker/_utils/isWithinInterval.js +0 -4
  69. package/lib/cjs/datePicker/_utils/parser.js +0 -10
  70. package/lib/cjs/datePicker/constants.js +0 -3
  71. package/lib/cjs/datePicker/foundation.d.ts +24 -24
  72. package/lib/cjs/datePicker/foundation.js +22 -333
  73. package/lib/cjs/datePicker/inputFoundation.d.ts +3 -3
  74. package/lib/cjs/datePicker/inputFoundation.js +5 -86
  75. package/lib/cjs/datePicker/monthFoundation.d.ts +1 -1
  76. package/lib/cjs/datePicker/monthFoundation.js +3 -28
  77. package/lib/cjs/datePicker/monthsGridFoundation.d.ts +3 -3
  78. package/lib/cjs/datePicker/monthsGridFoundation.js +43 -238
  79. package/lib/cjs/datePicker/yearAndMonthFoundation.d.ts +1 -1
  80. package/lib/cjs/datePicker/yearAndMonthFoundation.js +12 -38
  81. package/lib/cjs/descriptions/constants.js +0 -2
  82. package/lib/cjs/divider/constants.js +0 -2
  83. package/lib/cjs/dropdown/constants.js +0 -3
  84. package/lib/cjs/dropdown/foundation.js +4 -23
  85. package/lib/cjs/dropdown/menuFoundation.js +8 -27
  86. package/lib/cjs/empty/constants.js +0 -2
  87. package/lib/cjs/form/constants.js +0 -2
  88. package/lib/cjs/form/foundation.js +75 -206
  89. package/lib/cjs/form/interface.d.ts +5 -5
  90. package/lib/cjs/form/utils.js +47 -77
  91. package/lib/cjs/grid/constants.js +0 -2
  92. package/lib/cjs/highlight/constants.js +0 -2
  93. package/lib/cjs/icons/constants.js +0 -2
  94. package/lib/cjs/image/constants.js +0 -2
  95. package/lib/cjs/image/imageFoundation.js +4 -18
  96. package/lib/cjs/image/previewFooterFoundation.js +0 -13
  97. package/lib/cjs/image/previewFoundation.js +0 -11
  98. package/lib/cjs/image/previewImageFoundation.js +6 -80
  99. package/lib/cjs/image/previewInnerFoundation.js +12 -77
  100. package/lib/cjs/image/utils.js +0 -14
  101. package/lib/cjs/input/constants.js +0 -2
  102. package/lib/cjs/input/foundation.js +17 -101
  103. package/lib/cjs/input/textareaFoundation.js +20 -85
  104. package/lib/cjs/input/util/calculateNodeHeight.js +6 -18
  105. package/lib/cjs/input/util/getSizingData.js +7 -11
  106. package/lib/cjs/inputNumber/constants.js +0 -2
  107. package/lib/cjs/inputNumber/foundation.js +29 -192
  108. package/lib/cjs/layout/constants.js +0 -2
  109. package/lib/cjs/list/constants.js +0 -2
  110. package/lib/cjs/modal/constants.js +0 -2
  111. package/lib/cjs/modal/modalContentFoundation.js +0 -20
  112. package/lib/cjs/modal/modalFoundation.d.ts +2 -2
  113. package/lib/cjs/modal/modalFoundation.js +2 -22
  114. package/lib/cjs/navigation/NavItem.js +0 -10
  115. package/lib/cjs/navigation/constants.js +0 -3
  116. package/lib/cjs/navigation/foundation.js +3 -67
  117. package/lib/cjs/navigation/itemFoundation.js +3 -21
  118. package/lib/cjs/navigation/subNavFoundation.js +4 -40
  119. package/lib/cjs/notification/constants.js +0 -3
  120. package/lib/cjs/notification/notificationFoundation.d.ts +3 -3
  121. package/lib/cjs/notification/notificationFoundation.js +0 -16
  122. package/lib/cjs/notification/notificationListFoundation.js +7 -17
  123. package/lib/cjs/overflowList/constants.js +0 -2
  124. package/lib/cjs/overflowList/foundation.js +11 -41
  125. package/lib/cjs/pagination/constants.js +0 -2
  126. package/lib/cjs/pagination/foundation.d.ts +3 -3
  127. package/lib/cjs/pagination/foundation.js +21 -90
  128. package/lib/cjs/popconfirm/constants.js +0 -2
  129. package/lib/cjs/popconfirm/popconfirmFoundation.js +1 -21
  130. package/lib/cjs/popover/constants.js +0 -3
  131. package/lib/cjs/progress/constants.js +0 -2
  132. package/lib/cjs/progress/generates.d.ts +2 -2
  133. package/lib/cjs/progress/generates.js +19 -60
  134. package/lib/cjs/radio/constants.js +0 -2
  135. package/lib/cjs/radio/radioFoundation.js +0 -14
  136. package/lib/cjs/radio/radioGroupFoundation.js +4 -23
  137. package/lib/cjs/radio/radioInnerFoundation.js +2 -19
  138. package/lib/cjs/rating/constants.js +0 -2
  139. package/lib/cjs/rating/foundation.js +11 -61
  140. package/lib/cjs/scrollList/constants.js +0 -2
  141. package/lib/cjs/scrollList/foundation.js +0 -4
  142. package/lib/cjs/scrollList/itemFoundation.js +8 -61
  143. package/lib/cjs/scrollList/scrollTo.js +2 -5
  144. package/lib/cjs/select/constants.js +0 -3
  145. package/lib/cjs/select/foundation.d.ts +2 -2
  146. package/lib/cjs/select/foundation.js +122 -425
  147. package/lib/cjs/select/optionFoundation.js +4 -14
  148. package/lib/cjs/sideSheet/constants.js +0 -2
  149. package/lib/cjs/sideSheet/sideSheetFoundation.js +0 -18
  150. package/lib/cjs/skeleton/constants.js +0 -2
  151. package/lib/cjs/slider/constants.js +0 -2
  152. package/lib/cjs/slider/foundation.d.ts +1 -1
  153. package/lib/cjs/slider/foundation.js +25 -204
  154. package/lib/cjs/space/constants.js +0 -2
  155. package/lib/cjs/spin/constants.js +0 -2
  156. package/lib/cjs/spin/foundation.js +3 -13
  157. package/lib/cjs/steps/constants.js +0 -2
  158. package/lib/cjs/switch/constants.js +0 -2
  159. package/lib/cjs/switch/foundation.js +2 -18
  160. package/lib/cjs/table/bodyFoundation.js +2 -34
  161. package/lib/cjs/table/cellFoundation.js +0 -5
  162. package/lib/cjs/table/constants.js +7 -8
  163. package/lib/cjs/table/foundation.d.ts +17 -14
  164. package/lib/cjs/table/foundation.js +71 -302
  165. package/lib/cjs/table/tableRowFoundation.js +0 -11
  166. package/lib/cjs/table/tableSelectionCellFoundation.js +0 -6
  167. package/lib/cjs/table/utils.d.ts +2 -2
  168. package/lib/cjs/table/utils.js +5 -118
  169. package/lib/cjs/tabs/constants.js +0 -2
  170. package/lib/cjs/tabs/foundation.js +2 -40
  171. package/lib/cjs/tag/constants.js +1 -2
  172. package/lib/cjs/tagInput/constants.js +0 -2
  173. package/lib/cjs/tagInput/foundation.d.ts +4 -4
  174. package/lib/cjs/tagInput/foundation.js +4 -94
  175. package/lib/cjs/tagInput/utils/getSplitedArray.js +0 -11
  176. package/lib/cjs/timePicker/ComboxFoundation.js +4 -39
  177. package/lib/cjs/timePicker/constants.js +0 -3
  178. package/lib/cjs/timePicker/foundation.d.ts +1 -1
  179. package/lib/cjs/timePicker/foundation.js +3 -97
  180. package/lib/cjs/timePicker/inputFoundation.js +6 -25
  181. package/lib/cjs/timePicker/utils/index.js +6 -45
  182. package/lib/cjs/timePicker/utils/localeDate.js +0 -10
  183. package/lib/cjs/timeline/constants.js +0 -2
  184. package/lib/cjs/toast/constants.js +0 -3
  185. package/lib/cjs/toast/toastFoundation.d.ts +3 -3
  186. package/lib/cjs/toast/toastFoundation.js +0 -14
  187. package/lib/cjs/toast/toastListFoundation.js +4 -22
  188. package/lib/cjs/tooltip/constants.js +0 -2
  189. package/lib/cjs/tooltip/foundation.d.ts +1 -1
  190. package/lib/cjs/tooltip/foundation.js +63 -291
  191. package/lib/cjs/transfer/constants.js +0 -2
  192. package/lib/cjs/transfer/foundation.d.ts +1 -1
  193. package/lib/cjs/transfer/foundation.js +4 -68
  194. package/lib/cjs/transfer/transferUtils.js +5 -27
  195. package/lib/cjs/tree/constants.js +0 -2
  196. package/lib/cjs/tree/foundation.d.ts +3 -3
  197. package/lib/cjs/tree/foundation.js +34 -150
  198. package/lib/cjs/tree/treeUtil.js +54 -173
  199. package/lib/cjs/treeSelect/constants.js +0 -2
  200. package/lib/cjs/treeSelect/foundation.d.ts +7 -7
  201. package/lib/cjs/treeSelect/foundation.js +18 -192
  202. package/lib/cjs/typography/constants.js +0 -2
  203. package/lib/cjs/typography/formatNumeral.d.ts +3 -3
  204. package/lib/cjs/typography/formatNumeral.js +16 -32
  205. package/lib/cjs/upload/constants.js +0 -2
  206. package/lib/cjs/upload/foundation.d.ts +5 -5
  207. package/lib/cjs/upload/foundation.js +36 -245
  208. package/lib/cjs/upload/utils.js +10 -29
  209. package/lib/cjs/utils/Event.js +2 -21
  210. package/lib/cjs/utils/FocusHandle.d.ts +1 -1
  211. package/lib/cjs/utils/FocusHandle.js +6 -35
  212. package/lib/cjs/utils/Logger.js +0 -21
  213. package/lib/cjs/utils/Store.js +0 -10
  214. package/lib/cjs/utils/a11y.js +18 -43
  215. package/lib/cjs/utils/array.d.ts +1 -1
  216. package/lib/cjs/utils/array.js +0 -7
  217. package/lib/cjs/utils/arrayMove.js +0 -1
  218. package/lib/cjs/utils/classnames.js +0 -12
  219. package/lib/cjs/utils/date-fns-extra.js +0 -35
  220. package/lib/cjs/utils/dom.d.ts +1 -1
  221. package/lib/cjs/utils/dom.js +0 -13
  222. package/lib/cjs/utils/function.js +0 -1
  223. package/lib/cjs/utils/getDataAttr.js +0 -2
  224. package/lib/cjs/utils/getHighlight.js +5 -26
  225. package/lib/cjs/utils/getMotionObjFromProps.js +0 -12
  226. package/lib/cjs/utils/index.js +0 -4
  227. package/lib/cjs/utils/isBothNaN.js +0 -2
  228. package/lib/cjs/utils/isElement.js +0 -1
  229. package/lib/cjs/utils/isEnterPress.js +0 -5
  230. package/lib/cjs/utils/isEscPress.js +0 -5
  231. package/lib/cjs/utils/isNullOrUndefined.js +0 -1
  232. package/lib/cjs/utils/isNumber.js +0 -1
  233. package/lib/cjs/utils/isObject.js +0 -1
  234. package/lib/cjs/utils/isPromise.js +0 -3
  235. package/lib/cjs/utils/isString.js +0 -1
  236. package/lib/cjs/utils/keyCode.js +0 -105
  237. package/lib/cjs/utils/log.js +0 -5
  238. package/lib/cjs/utils/number.js +0 -2
  239. package/lib/cjs/utils/object.d.ts +4 -4
  240. package/lib/cjs/utils/object.js +12 -34
  241. package/lib/cjs/utils/set.js +0 -8
  242. package/lib/cjs/utils/shallowEqualObjects.js +0 -7
  243. package/lib/cjs/utils/touchPolyfill.js +0 -7
  244. package/lib/cjs/utils/type.d.ts +3 -3
  245. package/lib/cjs/utils/uuid.js +2 -9
  246. package/lib/cjs/utils/warning.js +0 -1
  247. package/lib/es/anchor/foundation.js +10 -66
  248. package/lib/es/anchor/linkFoundation.js +4 -12
  249. package/lib/es/autoComplete/foundation.d.ts +1 -1
  250. package/lib/es/autoComplete/foundation.js +24 -132
  251. package/lib/es/autoComplete/optionFoundation.js +4 -10
  252. package/lib/es/avatar/foundation.js +0 -12
  253. package/lib/es/backtop/foundation.d.ts +2 -2
  254. package/lib/es/backtop/foundation.js +0 -16
  255. package/lib/es/banner/foundation.js +0 -3
  256. package/lib/es/base/constants.js +2 -2
  257. package/lib/es/base/foundation.d.ts +1 -1
  258. package/lib/es/base/foundation.js +11 -44
  259. package/lib/es/breadcrumb/foundation.js +0 -7
  260. package/lib/es/breadcrumb/itemFoundation.js +0 -3
  261. package/lib/es/calendar/eventUtil.d.ts +1 -1
  262. package/lib/es/calendar/eventUtil.js +2 -36
  263. package/lib/es/calendar/foundation.d.ts +2 -2
  264. package/lib/es/calendar/foundation.js +28 -117
  265. package/lib/es/carousel/foundation.js +2 -47
  266. package/lib/es/cascader/constants.js +0 -1
  267. package/lib/es/cascader/foundation.d.ts +4 -4
  268. package/lib/es/cascader/foundation.js +30 -226
  269. package/lib/es/cascader/util.js +6 -15
  270. package/lib/es/checkbox/checkboxFoundation.js +2 -34
  271. package/lib/es/checkbox/checkboxGroupFoundation.js +2 -20
  272. package/lib/es/collapse/foundation.d.ts +1 -1
  273. package/lib/es/collapse/foundation.js +2 -9
  274. package/lib/es/collapsible/foundation.js +0 -7
  275. package/lib/es/datePicker/_utils/formatter.js +4 -8
  276. package/lib/es/datePicker/_utils/getDayOfWeek.d.ts +1 -1
  277. package/lib/es/datePicker/_utils/getDayOfWeek.js +0 -3
  278. package/lib/es/datePicker/_utils/getDefaultFormatToken.js +0 -2
  279. package/lib/es/datePicker/_utils/getDefaultPickerDate.d.ts +1 -1
  280. package/lib/es/datePicker/_utils/getDefaultPickerDate.js +0 -10
  281. package/lib/es/datePicker/_utils/getFullDateOffset.js +0 -3
  282. package/lib/es/datePicker/_utils/getInsetInputFormatToken.js +0 -4
  283. package/lib/es/datePicker/_utils/getInsetInputValueFromInsetInputStr.js +0 -5
  284. package/lib/es/datePicker/_utils/getMonthTable.d.ts +1 -1
  285. package/lib/es/datePicker/_utils/getMonthTable.js +4 -14
  286. package/lib/es/datePicker/_utils/getMonthsInYear.js +0 -1
  287. package/lib/es/datePicker/_utils/getYears.js +0 -3
  288. package/lib/es/datePicker/_utils/isBetween.js +0 -1
  289. package/lib/es/datePicker/_utils/parser.js +0 -8
  290. package/lib/es/datePicker/foundation.d.ts +24 -24
  291. package/lib/es/datePicker/foundation.js +22 -318
  292. package/lib/es/datePicker/inputFoundation.d.ts +3 -3
  293. package/lib/es/datePicker/inputFoundation.js +5 -74
  294. package/lib/es/datePicker/monthFoundation.d.ts +1 -1
  295. package/lib/es/datePicker/monthFoundation.js +4 -22
  296. package/lib/es/datePicker/monthsGridFoundation.d.ts +3 -3
  297. package/lib/es/datePicker/monthsGridFoundation.js +42 -222
  298. package/lib/es/datePicker/yearAndMonthFoundation.d.ts +1 -1
  299. package/lib/es/datePicker/yearAndMonthFoundation.js +12 -36
  300. package/lib/es/dropdown/foundation.js +4 -18
  301. package/lib/es/dropdown/menuFoundation.js +8 -22
  302. package/lib/es/form/foundation.js +74 -195
  303. package/lib/es/form/interface.d.ts +5 -5
  304. package/lib/es/form/utils.js +47 -70
  305. package/lib/es/image/imageFoundation.js +4 -13
  306. package/lib/es/image/previewFooterFoundation.js +0 -9
  307. package/lib/es/image/previewFoundation.js +0 -7
  308. package/lib/es/image/previewImageFoundation.js +6 -72
  309. package/lib/es/image/previewInnerFoundation.js +12 -70
  310. package/lib/es/image/utils.js +0 -6
  311. package/lib/es/input/foundation.js +17 -93
  312. package/lib/es/input/textareaFoundation.js +20 -75
  313. package/lib/es/input/util/calculateNodeHeight.js +6 -18
  314. package/lib/es/input/util/getSizingData.js +7 -11
  315. package/lib/es/inputNumber/foundation.js +28 -183
  316. package/lib/es/modal/modalContentFoundation.js +0 -15
  317. package/lib/es/modal/modalFoundation.d.ts +2 -2
  318. package/lib/es/modal/modalFoundation.js +2 -17
  319. package/lib/es/navigation/NavItem.js +0 -6
  320. package/lib/es/navigation/constants.js +1 -1
  321. package/lib/es/navigation/foundation.js +2 -60
  322. package/lib/es/navigation/itemFoundation.js +3 -18
  323. package/lib/es/navigation/subNavFoundation.js +4 -36
  324. package/lib/es/notification/constants.js +1 -1
  325. package/lib/es/notification/notificationFoundation.d.ts +3 -3
  326. package/lib/es/notification/notificationFoundation.js +0 -11
  327. package/lib/es/notification/notificationListFoundation.js +6 -13
  328. package/lib/es/overflowList/foundation.js +11 -37
  329. package/lib/es/pagination/foundation.d.ts +3 -3
  330. package/lib/es/pagination/foundation.js +20 -87
  331. package/lib/es/popconfirm/popconfirmFoundation.js +1 -16
  332. package/lib/es/progress/generates.d.ts +2 -2
  333. package/lib/es/progress/generates.js +19 -59
  334. package/lib/es/radio/radioFoundation.js +0 -9
  335. package/lib/es/radio/radioGroupFoundation.js +4 -19
  336. package/lib/es/radio/radioInnerFoundation.js +2 -15
  337. package/lib/es/rating/foundation.js +10 -54
  338. package/lib/es/scrollList/itemFoundation.js +8 -60
  339. package/lib/es/scrollList/scrollTo.js +2 -4
  340. package/lib/es/select/foundation.d.ts +2 -2
  341. package/lib/es/select/foundation.js +122 -411
  342. package/lib/es/select/optionFoundation.js +4 -10
  343. package/lib/es/sideSheet/sideSheetFoundation.js +0 -12
  344. package/lib/es/slider/foundation.d.ts +1 -1
  345. package/lib/es/slider/foundation.js +24 -197
  346. package/lib/es/spin/foundation.js +3 -11
  347. package/lib/es/switch/foundation.js +2 -13
  348. package/lib/es/table/bodyFoundation.js +2 -25
  349. package/lib/es/table/cellFoundation.js +0 -1
  350. package/lib/es/table/constants.js +6 -6
  351. package/lib/es/table/foundation.d.ts +17 -14
  352. package/lib/es/table/foundation.js +71 -309
  353. package/lib/es/table/tableRowFoundation.js +2 -9
  354. package/lib/es/table/tableSelectionCellFoundation.js +0 -2
  355. package/lib/es/table/utils.d.ts +2 -2
  356. package/lib/es/table/utils.js +5 -81
  357. package/lib/es/tabs/foundation.js +2 -35
  358. package/lib/es/tagInput/foundation.d.ts +4 -4
  359. package/lib/es/tagInput/foundation.js +4 -84
  360. package/lib/es/tagInput/utils/getSplitedArray.js +0 -7
  361. package/lib/es/timePicker/ComboxFoundation.js +4 -30
  362. package/lib/es/timePicker/foundation.d.ts +1 -1
  363. package/lib/es/timePicker/foundation.js +4 -90
  364. package/lib/es/timePicker/inputFoundation.js +6 -22
  365. package/lib/es/timePicker/utils/index.js +6 -25
  366. package/lib/es/timePicker/utils/localeDate.js +0 -8
  367. package/lib/es/toast/constants.js +1 -1
  368. package/lib/es/toast/toastFoundation.d.ts +3 -3
  369. package/lib/es/toast/toastFoundation.js +0 -9
  370. package/lib/es/toast/toastListFoundation.js +4 -18
  371. package/lib/es/tooltip/foundation.d.ts +1 -1
  372. package/lib/es/tooltip/foundation.js +63 -288
  373. package/lib/es/transfer/foundation.d.ts +1 -1
  374. package/lib/es/transfer/foundation.js +6 -62
  375. package/lib/es/transfer/transferUtils.js +5 -21
  376. package/lib/es/tree/foundation.d.ts +3 -3
  377. package/lib/es/tree/foundation.js +34 -143
  378. package/lib/es/tree/treeUtil.js +54 -139
  379. package/lib/es/treeSelect/foundation.d.ts +7 -7
  380. package/lib/es/treeSelect/foundation.js +20 -179
  381. package/lib/es/typography/formatNumeral.d.ts +3 -3
  382. package/lib/es/typography/formatNumeral.js +16 -29
  383. package/lib/es/upload/foundation.d.ts +5 -5
  384. package/lib/es/upload/foundation.js +36 -238
  385. package/lib/es/upload/utils.js +10 -24
  386. package/lib/es/utils/Event.js +2 -17
  387. package/lib/es/utils/FocusHandle.d.ts +1 -1
  388. package/lib/es/utils/FocusHandle.js +6 -32
  389. package/lib/es/utils/Logger.js +0 -20
  390. package/lib/es/utils/Store.js +0 -9
  391. package/lib/es/utils/a11y.js +18 -31
  392. package/lib/es/utils/array.d.ts +1 -1
  393. package/lib/es/utils/array.js +0 -5
  394. package/lib/es/utils/classnames.js +0 -10
  395. package/lib/es/utils/date-fns-extra.js +0 -27
  396. package/lib/es/utils/dom.d.ts +1 -1
  397. package/lib/es/utils/dom.js +0 -9
  398. package/lib/es/utils/getDataAttr.js +0 -1
  399. package/lib/es/utils/getHighlight.js +5 -26
  400. package/lib/es/utils/getMotionObjFromProps.js +0 -8
  401. package/lib/es/utils/isBothNaN.js +0 -1
  402. package/lib/es/utils/isEnterPress.js +0 -2
  403. package/lib/es/utils/isEscPress.js +0 -2
  404. package/lib/es/utils/keyCode.js +0 -104
  405. package/lib/es/utils/log.js +0 -3
  406. package/lib/es/utils/object.d.ts +4 -4
  407. package/lib/es/utils/object.js +12 -28
  408. package/lib/es/utils/set.js +0 -5
  409. package/lib/es/utils/shallowEqualObjects.js +0 -6
  410. package/lib/es/utils/touchPolyfill.js +0 -5
  411. package/lib/es/utils/type.d.ts +3 -3
  412. package/lib/es/utils/uuid.js +2 -8
  413. package/package.json +2 -2
  414. package/table/foundation.ts +7 -10
  415. package/upload/foundation.ts +8 -8
@@ -4,26 +4,18 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _foundation = _interopRequireDefault(require("../base/foundation"));
9
-
10
8
  var _isPromise = _interopRequireDefault(require("../utils/isPromise"));
11
-
12
9
  var _uuid = require("../utils/uuid");
13
-
14
10
  var _constants = require("./constants");
15
-
16
11
  var _utils = require("./utils");
17
-
18
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
13
  var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
21
14
  function adopt(value) {
22
15
  return value instanceof P ? value : new P(function (resolve) {
23
16
  resolve(value);
24
17
  });
25
18
  }
26
-
27
19
  return new (P || (P = Promise))(function (resolve, reject) {
28
20
  function fulfilled(value) {
29
21
  try {
@@ -32,7 +24,6 @@ var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P
32
24
  reject(e);
33
25
  }
34
26
  }
35
-
36
27
  function rejected(value) {
37
28
  try {
38
29
  step(generator["throw"](value));
@@ -40,15 +31,12 @@ var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P
40
31
  reject(e);
41
32
  }
42
33
  }
43
-
44
34
  function step(result) {
45
35
  result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
46
36
  }
47
-
48
37
  step((generator = generator.apply(thisArg, _arguments || [])).next());
49
38
  });
50
39
  };
51
-
52
40
  const {
53
41
  FILE_STATUS_UPLOADING,
54
42
  FILE_STATUS_SUCCESS,
@@ -59,16 +47,13 @@ const {
59
47
  DRAG_AREA_LEGAL,
60
48
  TRIGGER_AUTO
61
49
  } = _constants.strings;
62
-
63
50
  class UploadFoundation extends _foundation.default {
64
51
  constructor(adapter) {
65
52
  super(Object.assign({}, adapter));
66
53
  }
67
-
68
54
  destroy() {
69
55
  this.releaseMemory();
70
56
  }
71
-
72
57
  getError(_ref) {
73
58
  let {
74
59
  action,
@@ -84,25 +69,20 @@ class UploadFoundation extends _foundation.default {
84
69
  err.url = action;
85
70
  return err;
86
71
  }
87
-
88
72
  getBody(xhr) {
89
73
  if (!xhr) {
90
74
  return;
91
75
  }
92
-
93
76
  const text = xhr.responseText || xhr.response;
94
-
95
77
  if (!text) {
96
78
  return text;
97
79
  }
98
-
99
80
  try {
100
81
  return JSON.parse(text);
101
82
  } catch (error) {
102
83
  return text;
103
84
  }
104
85
  }
105
-
106
86
  checkFileSize(file) {
107
87
  const {
108
88
  size
@@ -112,11 +92,9 @@ class UploadFoundation extends _foundation.default {
112
92
  minSize
113
93
  } = this.getProps();
114
94
  let isIllegal = false;
115
-
116
95
  if (size > maxSize * _utils.byteKB || size < minSize * _utils.byteKB) {
117
96
  isIllegal = true;
118
97
  }
119
-
120
98
  return isIllegal;
121
99
  }
122
100
  /**
@@ -148,8 +126,6 @@ class UploadFoundation extends _foundation.default {
148
126
  * 8. TODO: check
149
127
  * 9. afterUpload
150
128
  */
151
-
152
-
153
129
  handleChange(currentFileList) {
154
130
  const invalidFiles = [];
155
131
  const {
@@ -161,83 +137,62 @@ class UploadFoundation extends _foundation.default {
161
137
  fileList
162
138
  } = this.getStates();
163
139
  let files = Array.from(currentFileList); // When the selected file
164
-
165
140
  if (typeof accept !== 'undefined') {
166
141
  files = files.filter(item => {
167
142
  const isValid = this.checkFileFormat(accept, item);
168
-
169
143
  if (!isValid) {
170
144
  invalidFiles.push(item);
171
145
  }
172
-
173
146
  return isValid;
174
147
  });
175
-
176
148
  if (invalidFiles.length !== 0) {
177
149
  this._adapter.notifyAcceptInvalid(invalidFiles);
178
150
  }
179
-
180
151
  if (files.length === 0) {
181
152
  return;
182
153
  }
183
154
  }
184
-
185
155
  files = files.map(file => {
186
156
  if (transformFile) {
187
157
  file = transformFile(file);
188
158
  }
189
-
190
159
  if (!file.uid) {
191
160
  file.uid = (0, _uuid.getUuidv4)();
192
161
  }
193
-
194
162
  if (this.checkFileSize(file)) {
195
163
  file._sizeInvalid = true;
196
164
  file.status = FILE_STATUS_VALID_FAIL;
197
-
198
165
  this._adapter.notifySizeError(file, fileList);
199
166
  }
200
-
201
167
  return file;
202
168
  });
203
169
  const total = fileList.length + files.length;
204
-
205
170
  if (typeof limit !== 'undefined') {
206
171
  // Determine whether the limit is exceeded
207
172
  if (total > limit) {
208
173
  this._adapter.notifyExceed(files);
209
-
210
174
  if (limit === 1) {
211
175
  // Replace the current file with the last file
212
176
  files = files.slice(-1);
213
-
214
177
  this._adapter.notifyFileSelect(files);
215
-
216
178
  this._adapter.resetInput();
217
-
218
179
  this.replaceFileList(files);
219
180
  return;
220
- } // If the limit is exceeded, the calculation can add a few more files and continue uploading the remaining files
221
-
222
-
181
+ }
182
+ // If the limit is exceeded, the calculation can add a few more files and continue uploading the remaining files
223
183
  const restNum = limit - fileList.length;
224
184
  files = files.slice(0, restNum);
225
185
  }
226
186
  }
227
-
228
187
  this._adapter.notifyFileSelect(files);
229
-
230
188
  this._adapter.resetInput();
231
-
232
189
  this.addFilesToList(files);
233
- } // Triggered when replacing a single file
234
-
235
-
190
+ }
191
+ // Triggered when replacing a single file
236
192
  handleReplaceChange(currentFileList) {
237
193
  if (currentFileList.length === 0) {
238
194
  return;
239
195
  }
240
-
241
196
  const {
242
197
  transformFile,
243
198
  uploadTrigger,
@@ -248,60 +203,46 @@ class UploadFoundation extends _foundation.default {
248
203
  fileList
249
204
  } = this.getStates();
250
205
  let newFile = Array.from(currentFileList).pop();
251
-
252
206
  if (typeof accept !== 'undefined') {
253
207
  if (!this.checkFileFormat(accept, newFile)) {
254
208
  this._adapter.notifyAcceptInvalid([newFile]);
255
-
256
209
  return;
257
210
  }
258
211
  }
259
-
260
212
  if (transformFile) {
261
213
  newFile = transformFile(newFile);
262
214
  }
263
-
264
215
  if (!newFile.uid) {
265
216
  newFile.uid = (0, _uuid.getUuidv4)();
266
217
  }
267
-
268
218
  if (this.checkFileSize(newFile)) {
269
219
  newFile._sizeInvalid = true;
270
220
  newFile.status = FILE_STATUS_VALID_FAIL;
271
-
272
221
  this._adapter.notifySizeError(newFile, fileList);
273
222
  }
274
-
275
223
  this._adapter.notifyFileSelect([newFile]);
276
-
277
224
  const newFileItem = this.buildFileItem(newFile, uploadTrigger);
278
225
  const newFileList = [...fileList];
279
226
  newFileList.splice(replaceIdx, 1, newFileItem);
280
-
281
227
  this._adapter.notifyChange({
282
228
  currentFile: newFileItem,
283
229
  fileList: newFileList
284
230
  });
285
-
286
231
  this._adapter.updateFileList(newFileList, () => {
287
232
  this._adapter.resetReplaceInput();
288
-
289
233
  this.upload(newFileItem);
290
234
  });
291
235
  }
292
-
293
236
  buildFileItem(fileInstance, uploadTrigger) {
294
237
  const {
295
238
  _sizeInvalid,
296
239
  status
297
240
  } = fileInstance;
298
-
299
241
  try {
300
242
  // can't use ... to get rest property on File Object
301
243
  delete fileInstance._sizeInvalid;
302
244
  delete fileInstance.status;
303
245
  } catch (error) {}
304
-
305
246
  const _file = {
306
247
  status: status ? status : uploadTrigger === TRIGGER_AUTO ? FILE_STATUS_UPLOADING : FILE_STATUS_WAIT_UPLOAD,
307
248
  name: fileInstance.name,
@@ -311,37 +252,30 @@ class UploadFoundation extends _foundation.default {
311
252
  fileInstance,
312
253
  url: this._createURL(fileInstance)
313
254
  };
314
-
315
255
  if (_sizeInvalid) {
316
256
  _file._sizeInvalid = true;
317
- } // If it is an image, preview; if it is a pdf, you can jump to
318
-
319
-
257
+ }
258
+ // If it is an image, preview; if it is a pdf, you can jump to
320
259
  if (this.isImage(fileInstance)) {
321
260
  _file.preview = true;
322
261
  }
323
-
324
262
  return _file;
325
263
  }
326
-
327
264
  replaceFileList(files) {
328
265
  const {
329
266
  uploadTrigger
330
267
  } = this.getProps();
331
268
  const currentFiles = files.map(item => this.buildFileItem(item, uploadTrigger));
332
-
333
269
  this._adapter.notifyChange({
334
270
  fileList: currentFiles,
335
271
  currentFile: currentFiles[0]
336
272
  });
337
-
338
273
  this._adapter.updateFileList(currentFiles, () => {
339
274
  if (uploadTrigger === TRIGGER_AUTO) {
340
275
  this.startUpload(currentFiles);
341
276
  }
342
277
  });
343
278
  }
344
-
345
279
  addFilesToList(files) {
346
280
  const fileList = this.getState('fileList').slice();
347
281
  const {
@@ -350,28 +284,24 @@ class UploadFoundation extends _foundation.default {
350
284
  const currentFiles = files.map(item => this.buildFileItem(item, uploadTrigger));
351
285
  currentFiles.forEach(file => {
352
286
  const index = fileList.findIndex(item => item.uid === file.uid);
353
-
354
287
  if (index !== -1) {
355
288
  fileList[index] = file;
356
289
  } else {
357
290
  fileList.push(file);
358
-
359
291
  this._adapter.notifyChange({
360
292
  fileList,
361
293
  currentFile: file
362
294
  });
363
295
  }
364
296
  });
365
-
366
297
  this._adapter.updateFileList(fileList, () => {
367
298
  if (uploadTrigger === TRIGGER_AUTO) {
368
299
  this.startUpload(currentFiles);
369
300
  }
370
301
  });
371
- } // 插入多个文件到指定位置
302
+ }
303
+ // 插入多个文件到指定位置
372
304
  // Insert files to the specified location
373
-
374
-
375
305
  insertFileToList(files, index) {
376
306
  const {
377
307
  limit,
@@ -382,51 +312,40 @@ class UploadFoundation extends _foundation.default {
382
312
  const {
383
313
  fileList
384
314
  } = this.getStates();
385
- const unAcceptFileList = []; // 当次选中的文件
315
+ const unAcceptFileList = [];
316
+ // 当次选中的文件
386
317
  // current selected file
387
-
388
318
  let currentFileList = Array.from(files);
389
-
390
319
  if (typeof accept !== 'undefined') {
391
320
  currentFileList = currentFileList.filter(item => {
392
321
  const isValid = this.checkFileFormat(accept, item);
393
-
394
322
  if (!isValid) {
395
323
  unAcceptFileList.push(item);
396
324
  }
397
-
398
325
  return isValid;
399
326
  });
400
-
401
327
  if (unAcceptFileList.length !== 0) {
402
328
  this._adapter.notifyAcceptInvalid(unAcceptFileList);
403
329
  }
404
-
405
330
  if (currentFileList.length === 0) {
406
331
  return;
407
332
  }
408
333
  }
409
-
410
334
  currentFileList = currentFileList.map(file => {
411
335
  if (!file.uid) {
412
336
  file.uid = (0, _uuid.getUuidv4)();
413
337
  }
414
-
415
338
  if (this.checkFileSize(file)) {
416
339
  file._sizeInvalid = true;
417
340
  file.status = FILE_STATUS_VALID_FAIL;
418
-
419
341
  this._adapter.notifySizeError(file, fileList);
420
342
  }
421
-
422
343
  if (transformFile) {
423
344
  file = transformFile(file);
424
345
  }
425
-
426
346
  return file;
427
347
  });
428
348
  const total = fileList.length + currentFileList.length;
429
-
430
349
  if (typeof limit !== 'undefined') {
431
350
  // 判断是否超出限制
432
351
  // Determine whether the limit is exceeded
@@ -435,40 +354,30 @@ class UploadFoundation extends _foundation.default {
435
354
  // 使用最后面的文件对当前文件进行替换
436
355
  // Use the last file to replace the current file
437
356
  currentFileList = currentFileList.slice(-1);
438
-
439
357
  this._adapter.notifyFileSelect(currentFileList);
440
-
441
358
  this._adapter.resetInput();
442
-
443
359
  this.replaceFileList(currentFileList);
444
360
  return;
445
- } // 如果超出了限制,则计算还能添加几个文件,将剩余的文件继续上传
361
+ }
362
+ // 如果超出了限制,则计算还能添加几个文件,将剩余的文件继续上传
446
363
  // If the limit is exceeded, several files can be added to the calculation, and the remaining files will continue to be uploaded
447
-
448
-
449
364
  const restNum = limit - fileList.length;
450
365
  currentFileList = currentFileList.slice(0, restNum);
451
-
452
366
  this._adapter.notifyExceed(currentFileList);
453
367
  }
454
368
  }
455
-
456
369
  const fileItemList = currentFileList.map(file => this.buildFileItem(file, uploadTrigger));
457
370
  const newFileList = fileList.slice();
458
-
459
371
  if (typeof index !== 'undefined') {
460
372
  newFileList.splice(index, 0, ...fileItemList);
461
373
  } else {
462
374
  newFileList.push(...fileItemList);
463
375
  }
464
-
465
376
  this._adapter.notifyFileSelect(currentFileList);
466
-
467
377
  this._adapter.notifyChange({
468
378
  fileList: newFileList,
469
379
  currentFile: null
470
380
  });
471
-
472
381
  this._adapter.updateFileList(newFileList, () => {
473
382
  if (uploadTrigger === TRIGGER_AUTO) {
474
383
  this.startUpload(fileItemList);
@@ -476,14 +385,11 @@ class UploadFoundation extends _foundation.default {
476
385
  });
477
386
  }
478
387
  /* istanbul ignore next */
479
-
480
-
481
388
  manualUpload() {
482
389
  // find the list of files that have not been uploaded
483
390
  const waitToUploadFileList = this.getState('fileList').filter(item => item.status === FILE_STATUS_WAIT_UPLOAD);
484
391
  this.startUpload(waitToUploadFileList);
485
392
  }
486
-
487
393
  startUpload(fileList) {
488
394
  fileList.forEach(file => {
489
395
  if (!file._sizeInvalid) {
@@ -491,27 +397,22 @@ class UploadFoundation extends _foundation.default {
491
397
  }
492
398
  });
493
399
  }
494
-
495
400
  upload(file) {
496
401
  const {
497
402
  beforeUpload
498
403
  } = this.getProps();
499
-
500
404
  if (typeof beforeUpload === 'undefined') {
501
405
  this.post(file);
502
406
  return;
503
407
  }
504
-
505
408
  if (typeof beforeUpload === 'function') {
506
409
  const {
507
410
  fileList
508
411
  } = this.getStates();
509
-
510
412
  const buResult = this._adapter.notifyBeforeUpload({
511
413
  file,
512
414
  fileList
513
415
  });
514
-
515
416
  switch (true) {
516
417
  // sync validate - boolean
517
418
  case buResult === true:
@@ -519,7 +420,6 @@ class UploadFoundation extends _foundation.default {
519
420
  this.post(file);
520
421
  break;
521
422
  }
522
-
523
423
  case buResult === false:
524
424
  {
525
425
  const newResult = {
@@ -530,7 +430,6 @@ class UploadFoundation extends _foundation.default {
530
430
  break;
531
431
  }
532
432
  // async validate
533
-
534
433
  case buResult && (0, _isPromise.default)(buResult):
535
434
  {
536
435
  Promise.resolve(buResult).then(resolveData => {
@@ -538,11 +437,9 @@ class UploadFoundation extends _foundation.default {
538
437
  shouldUpload: true
539
438
  };
540
439
  const typeOfResolveData = Object.prototype.toString.call(resolveData).slice(8, -1);
541
-
542
440
  if (typeOfResolveData === 'Object') {
543
441
  newResult = Object.assign(Object.assign({}, newResult), resolveData);
544
442
  }
545
-
546
443
  this.handleBeforeUploadResultInObject(newResult, file);
547
444
  }, rejectVal => {
548
445
  let newResult = {
@@ -550,29 +447,24 @@ class UploadFoundation extends _foundation.default {
550
447
  status: _constants.strings.FILE_STATUS_VALID_FAIL
551
448
  };
552
449
  const typeOfRejectData = Object.prototype.toString.call(rejectVal).slice(8, -1);
553
-
554
450
  if (typeOfRejectData === 'Object') {
555
451
  newResult = Object.assign(Object.assign({}, newResult), rejectVal);
556
452
  }
557
-
558
453
  this.handleBeforeUploadResultInObject(newResult, file);
559
454
  });
560
455
  break;
561
456
  }
562
457
  // sync validate - object
563
-
564
458
  case typeof buResult === 'object':
565
459
  // inject to fileList
566
460
  this.handleBeforeUploadResultInObject(buResult, file);
567
461
  break;
568
-
569
462
  default:
570
463
  break;
571
464
  }
572
465
  }
573
- } // handle beforeUpload result when it's an object
574
-
575
-
466
+ }
467
+ // handle beforeUpload result when it's an object
576
468
  handleBeforeUploadResultInObject(buResult, file) {
577
469
  const {
578
470
  shouldUpload,
@@ -582,75 +474,59 @@ class UploadFoundation extends _foundation.default {
582
474
  fileInstance
583
475
  } = buResult;
584
476
  let newFileList = this.getState('fileList').slice();
585
-
586
477
  if (autoRemove) {
587
478
  newFileList = newFileList.filter(item => item.uid !== file.uid);
588
479
  } else {
589
480
  const index = this._getFileIndex(file, newFileList);
590
-
591
481
  if (index < 0) {
592
482
  return;
593
483
  }
594
-
595
484
  status ? newFileList[index].status = status : null;
596
485
  validateMessage ? newFileList[index].validateMessage = validateMessage : null;
597
-
598
486
  if (fileInstance) {
599
487
  fileInstance.uid = file.uid; // reuse recent file uid
600
-
601
488
  newFileList[index].fileInstance = fileInstance;
602
489
  newFileList[index].size = (0, _utils.getFileSize)(fileInstance.size);
603
490
  newFileList[index].name = fileInstance.name;
604
491
  }
605
-
606
492
  newFileList[index].shouldUpload = shouldUpload;
607
493
  }
608
-
609
494
  this._adapter.updateFileList(newFileList);
610
-
611
495
  this._adapter.notifyChange({
612
496
  fileList: newFileList,
613
497
  currentFile: file
614
498
  });
615
-
616
499
  if (shouldUpload) {
617
500
  this.post(file);
618
501
  }
619
502
  }
620
-
621
503
  post(file) {
622
504
  const {
623
505
  fileInstance
624
506
  } = file;
625
507
  const option = this.getProps();
626
-
627
508
  if (typeof XMLHttpRequest === 'undefined') {
628
509
  return;
629
510
  }
630
-
631
511
  const xhr = new XMLHttpRequest();
632
512
  const formData = new FormData();
633
513
  const {
634
514
  action
635
- } = option; // add data
636
-
515
+ } = option;
516
+ // add data
637
517
  let {
638
518
  data
639
519
  } = option;
640
-
641
520
  if (data) {
642
521
  if (typeof data === 'function') {
643
522
  data = data(fileInstance);
644
523
  }
645
-
646
524
  Object.keys(data).forEach(key => {
647
525
  formData.append(key, data[key]);
648
526
  });
649
- } // add file
650
-
651
-
527
+ }
528
+ // add file
652
529
  const fileName = option.name || option.fileName || fileInstance.name;
653
-
654
530
  if (option.customRequest) {
655
531
  return option.customRequest({
656
532
  fileName,
@@ -676,50 +552,40 @@ class UploadFoundation extends _foundation.default {
676
552
  action: option.action
677
553
  });
678
554
  }
679
-
680
555
  formData.append(fileName, fileInstance);
681
556
  xhr.open('post', action, true);
682
-
683
557
  if (option.withCredentials && 'withCredentials' in xhr) {
684
558
  xhr.withCredentials = true;
685
559
  }
686
-
687
560
  if (xhr.upload) {
688
561
  xhr.upload.onprogress = e => this.handleProgress({
689
562
  e,
690
563
  fileInstance
691
564
  });
692
- } // Callback function after upload is completed
693
-
694
-
565
+ }
566
+ // Callback function after upload is completed
695
567
  xhr.onload = e => this.handleOnLoad({
696
568
  e,
697
569
  xhr,
698
570
  fileInstance
699
571
  });
700
-
701
572
  xhr.onerror = e => this.handleError({
702
573
  e,
703
574
  xhr,
704
575
  fileInstance
705
- }); // add headers
706
-
707
-
576
+ });
577
+ // add headers
708
578
  let headers = option.headers || {};
709
-
710
579
  if (typeof headers === 'function') {
711
580
  headers = headers(fileInstance);
712
581
  }
713
-
714
582
  for (const item in headers) {
715
583
  if (Object.prototype.hasOwnProperty.call(headers, item) && headers[item] !== null) {
716
584
  xhr.setRequestHeader(item, headers[item]);
717
585
  }
718
586
  }
719
-
720
587
  xhr.send(formData);
721
588
  }
722
-
723
589
  handleProgress(_ref2) {
724
590
  let {
725
591
  e,
@@ -730,30 +596,22 @@ class UploadFoundation extends _foundation.default {
730
596
  } = this.getStates();
731
597
  const newFileList = fileList.slice();
732
598
  let percent = 0;
733
-
734
599
  if (e.total > 0) {
735
600
  percent = Number((e.loaded / e.total * 100 * _constants.numbers.PROGRESS_COEFFICIENT).toFixed(0)) || 0;
736
601
  }
737
-
738
602
  const index = this._getFileIndex(fileInstance, newFileList);
739
-
740
603
  if (index < 0) {
741
604
  return;
742
605
  }
743
-
744
606
  newFileList[index].percent = percent;
745
607
  newFileList[index].status = FILE_STATUS_UPLOADING;
746
-
747
608
  this._adapter.notifyProgress(percent, fileInstance, newFileList);
748
-
749
609
  this._adapter.updateFileList(newFileList);
750
-
751
610
  this._adapter.notifyChange({
752
611
  fileList: newFileList,
753
612
  currentFile: newFileList[index]
754
613
  });
755
614
  }
756
-
757
615
  handleOnLoad(_ref3) {
758
616
  let {
759
617
  e,
@@ -763,13 +621,10 @@ class UploadFoundation extends _foundation.default {
763
621
  const {
764
622
  fileList
765
623
  } = this.getStates();
766
-
767
624
  const index = this._getFileIndex(fileInstance, fileList);
768
-
769
625
  if (index < 0) {
770
626
  return;
771
627
  }
772
-
773
628
  if (xhr.status < 200 || xhr.status >= 300) {
774
629
  this.handleError({
775
630
  e,
@@ -785,7 +640,6 @@ class UploadFoundation extends _foundation.default {
785
640
  });
786
641
  }
787
642
  }
788
-
789
643
  handleSuccess(_ref4) {
790
644
  let {
791
645
  e,
@@ -798,32 +652,25 @@ class UploadFoundation extends _foundation.default {
798
652
  fileList
799
653
  } = this.getStates();
800
654
  let body = null;
801
-
802
655
  const index = this._getFileIndex(fileInstance, fileList);
803
-
804
656
  if (index < 0) {
805
657
  return;
806
658
  }
807
-
808
659
  if (isCustomRequest) {
809
660
  // use when pass customRequest
810
661
  body = response;
811
662
  } else {
812
663
  body = this.getBody(xhr);
813
664
  }
814
-
815
665
  const newFileList = fileList.slice();
816
666
  const {
817
667
  afterUpload
818
668
  } = this.getProps();
819
669
  newFileList[index].status = FILE_STATUS_SUCCESS;
820
670
  newFileList[index].percent = 100;
821
-
822
671
  this._adapter.notifyProgress(100, fileInstance, newFileList);
823
-
824
672
  newFileList[index].response = body;
825
673
  e ? newFileList[index].event = e : null;
826
-
827
674
  if (afterUpload && typeof afterUpload === 'function') {
828
675
  const {
829
676
  autoRemove,
@@ -840,30 +687,23 @@ class UploadFoundation extends _foundation.default {
840
687
  name ? newFileList[index].name = name : null;
841
688
  autoRemove ? newFileList.splice(index, 1) : null;
842
689
  }
843
-
844
690
  this._adapter.notifySuccess(body, fileInstance, newFileList);
845
-
846
691
  this._adapter.notifyChange({
847
692
  fileList: newFileList,
848
693
  currentFile: newFileList[index]
849
694
  });
850
-
851
695
  this._adapter.updateFileList(newFileList);
852
696
  }
853
-
854
697
  _getFileIndex(file, fileList) {
855
698
  return fileList.findIndex(item => item.uid === file.uid);
856
699
  }
857
-
858
700
  handleRemove(file) {
859
701
  const {
860
702
  disabled
861
703
  } = this.getProps();
862
-
863
704
  if (disabled) {
864
705
  return;
865
706
  }
866
-
867
707
  const {
868
708
  fileList
869
709
  } = this.getStates();
@@ -872,28 +712,20 @@ class UploadFoundation extends _foundation.default {
872
712
  if (res === false) {
873
713
  return;
874
714
  }
875
-
876
715
  const newFileList = fileList.slice();
877
-
878
716
  const index = this._getFileIndex(file, fileList);
879
-
880
717
  if (index < 0) {
881
718
  return;
882
719
  }
883
-
884
720
  newFileList.splice(index, 1);
885
-
886
721
  this._adapter.notifyRemove(file.fileInstance, newFileList, file);
887
-
888
722
  this._adapter.updateFileList(newFileList);
889
-
890
723
  this._adapter.notifyChange({
891
724
  fileList: newFileList,
892
725
  currentFile: file
893
726
  });
894
727
  });
895
728
  }
896
-
897
729
  handleError(_ref5) {
898
730
  let {
899
731
  e,
@@ -903,13 +735,10 @@ class UploadFoundation extends _foundation.default {
903
735
  const {
904
736
  fileList
905
737
  } = this.getStates();
906
-
907
738
  const index = this._getFileIndex(fileInstance, fileList);
908
-
909
739
  if (index < 0) {
910
740
  return;
911
741
  }
912
-
913
742
  const {
914
743
  action
915
744
  } = this.getProps();
@@ -922,17 +751,13 @@ class UploadFoundation extends _foundation.default {
922
751
  newFileList[index].status = FILE_STATUS_UPLOAD_FAIL;
923
752
  newFileList[index].response = error;
924
753
  newFileList[index].event = e;
925
-
926
754
  this._adapter.notifyError(error, fileInstance, newFileList, xhr);
927
-
928
755
  this._adapter.updateFileList(newFileList);
929
-
930
756
  this._adapter.notifyChange({
931
757
  currentFile: newFileList[index],
932
758
  fileList: newFileList
933
759
  });
934
760
  }
935
-
936
761
  handleClear() {
937
762
  const {
938
763
  disabled
@@ -940,27 +765,22 @@ class UploadFoundation extends _foundation.default {
940
765
  const {
941
766
  fileList
942
767
  } = this.getStates();
943
-
944
768
  if (disabled) {
945
769
  return;
946
770
  }
947
-
948
771
  Promise.resolve(this._adapter.notifyBeforeClear(fileList)).then(res => {
949
772
  if (res === false) {
950
773
  return;
951
774
  }
952
-
953
775
  this._adapter.updateFileList([]);
954
-
955
776
  this._adapter.notifyClear();
956
-
957
777
  this._adapter.notifyChange({
958
778
  fileList: []
959
779
  });
960
- }).catch(error => {// if user pass reject promise, no need to do anything
780
+ }).catch(error => {
781
+ // if user pass reject promise, no need to do anything
961
782
  });
962
783
  }
963
-
964
784
  _createURL(fileInstance) {
965
785
  // https://stackoverflow.com/questions/31742072/filereader-vs-window-url-createobjecturl
966
786
  const url = URL.createObjectURL(fileInstance);
@@ -969,14 +789,11 @@ class UploadFoundation extends _foundation.default {
969
789
  } = this.getStates();
970
790
  const newUrls = localUrls.slice();
971
791
  newUrls.push(url);
972
-
973
792
  this._adapter.updateLocalUrls(newUrls);
974
-
975
793
  return url;
976
- } // 释放预览文件所占用的内存
794
+ }
795
+ // 释放预览文件所占用的内存
977
796
  // Release memory used by preview files
978
-
979
-
980
797
  releaseMemory() {
981
798
  const {
982
799
  localUrls
@@ -985,7 +802,6 @@ class UploadFoundation extends _foundation.default {
985
802
  this._releaseBlob(url);
986
803
  });
987
804
  }
988
-
989
805
  _releaseBlob(url) {
990
806
  try {
991
807
  URL.revokeObjectURL(url);
@@ -993,17 +809,13 @@ class UploadFoundation extends _foundation.default {
993
809
  console.log(error);
994
810
  }
995
811
  }
996
-
997
812
  isImage(file) {
998
813
  return /(webp|svg|png|gif|jpg|jpeg|bmp|dpg)$/i.test(file.type);
999
814
  }
1000
815
  /* istanbul ignore next */
1001
-
1002
-
1003
816
  isMultiple() {
1004
817
  return Boolean(this.getProp('multiple'));
1005
818
  }
1006
-
1007
819
  handleDragEnter(e) {
1008
820
  e.preventDefault();
1009
821
  e.stopPropagation();
@@ -1011,25 +823,20 @@ class UploadFoundation extends _foundation.default {
1011
823
  const {
1012
824
  disabled
1013
825
  } = this.getProps();
1014
-
1015
826
  if (!disabled) {
1016
827
  this._adapter.updateDragAreaStatus(DRAG_AREA_LEGAL);
1017
828
  }
1018
829
  }
1019
-
1020
830
  handleDirectoryDrop(e) {
1021
831
  return __awaiter(this, void 0, void 0, function* () {
1022
832
  const fileList = this.getState('fileList').slice();
1023
833
  const items = [].slice.call(e.dataTransfer.items);
1024
834
  const files = yield (0, _utils.mapFileTree)(items);
1025
835
  this.handleChange(files);
1026
-
1027
836
  this._adapter.updateDragAreaStatus(DRAG_AREA_DEFAULT);
1028
-
1029
837
  this._adapter.notifyDrop(e, files, fileList);
1030
838
  });
1031
839
  }
1032
-
1033
840
  handleDrop(e) {
1034
841
  // Block file opening in browser
1035
842
  e.preventDefault();
@@ -1039,44 +846,37 @@ class UploadFoundation extends _foundation.default {
1039
846
  directory
1040
847
  } = this.getProps();
1041
848
  const fileList = this.getState('fileList').slice();
1042
-
1043
849
  if (!disabled) {
1044
850
  if (directory) {
1045
851
  this.handleDirectoryDrop(e);
1046
852
  return;
1047
853
  }
1048
-
1049
854
  const files = Array.from(e.dataTransfer.files);
1050
855
  this.handleChange(files);
1051
-
1052
856
  this._adapter.updateDragAreaStatus(DRAG_AREA_DEFAULT);
1053
-
1054
857
  this._adapter.notifyDrop(e, files, fileList);
1055
858
  }
1056
859
  }
1057
-
1058
860
  handleDragOver(e) {
1059
861
  e.preventDefault();
1060
862
  e.stopPropagation();
1061
863
  }
1062
-
1063
864
  handleDragLeave(e) {
1064
865
  e.preventDefault();
1065
- e.stopPropagation(); // 防止拖拽进入子元素时触发的dragLeave也被处理
866
+ e.stopPropagation();
867
+ // 防止拖拽进入子元素时触发的dragLeave也被处理
1066
868
  // Prevent dragLeave triggered when dragging into a child element is also handled
1067
869
  // https://stackoverflow.com/questions/7110353/html5-dragleave-fired-when-hovering-a-child-element
1068
-
1069
870
  if (this._dragEnterTarget === e.target) {
1070
871
  this._adapter.updateDragAreaStatus(DRAG_AREA_DEFAULT);
1071
872
  }
1072
- } // 拖拽上传时,需要对文件的格式进行校验
873
+ }
874
+ // 拖拽上传时,需要对文件的格式进行校验
1073
875
  // When dragging and uploading, you need to verify the file format
1074
-
1075
-
1076
876
  checkFileFormat(accept, file) {
1077
877
  const acceptTypes = accept.split(',').map(type => type.trim()).filter(type => type);
1078
- const mimeType = file.type || ''; // Get the large class to which MIMEtype belongs, eg: image/jpeg = > image, application/= > application
1079
-
878
+ const mimeType = file.type || '';
879
+ // Get the large class to which MIMEtype belongs, eg: image/jpeg = > image, application/= > application
1080
880
  const baseMimeType = mimeType.replace(/\/.*$/, '');
1081
881
  return acceptTypes.some(type => {
1082
882
  // When accepted as a suffix filename such as [.jpeg]
@@ -1084,40 +884,31 @@ class UploadFoundation extends _foundation.default {
1084
884
  const fileName = file.name || '';
1085
885
  const acceptExtension = type.split('.').pop().toLowerCase();
1086
886
  return (0, _utils.endsWith)(fileName.toLowerCase(), acceptExtension);
1087
- } // When accepted as a general class such as [image/*] or [video/*]
1088
-
1089
-
887
+ }
888
+ // When accepted as a general class such as [image/*] or [video/*]
1090
889
  if (/\/\*$/.test(type)) {
1091
890
  const acceptBaseMimeType = type.replace(/\/.*$/, '');
1092
891
  return baseMimeType === acceptBaseMimeType;
1093
- } // When accepted as a full MIME types string
1094
-
1095
-
892
+ }
893
+ // When accepted as a full MIME types string
1096
894
  if (/^[^\/]+\/[^\/]+$/.test(type)) {
1097
895
  return mimeType === type;
1098
896
  }
1099
-
1100
897
  return false;
1101
898
  });
1102
899
  }
1103
-
1104
900
  retry(fileItem) {
1105
901
  const {
1106
902
  onRetry
1107
903
  } = this.getProps();
1108
-
1109
904
  if (onRetry && typeof onRetry === 'function') {
1110
905
  onRetry(fileItem);
1111
906
  }
1112
-
1113
907
  this.post(fileItem);
1114
908
  }
1115
-
1116
909
  handlePreviewClick(fileItem) {
1117
910
  this._adapter.notifyPreviewClick(fileItem);
1118
911
  }
1119
-
1120
912
  }
1121
-
1122
913
  var _default = UploadFoundation;
1123
914
  exports.default = _default;