@arco-design/mobile-react 2.20.0 → 2.21.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 (295) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.en-US.md +2 -2
  3. package/README.md +2 -2
  4. package/cjs/avatar/index.d.ts +1 -1
  5. package/cjs/avatar/index.js +1 -1
  6. package/cjs/badge/index.d.ts +1 -1
  7. package/cjs/badge/index.js +1 -1
  8. package/cjs/carousel/index.d.ts +1 -1
  9. package/cjs/carousel/index.js +1 -1
  10. package/cjs/cell/index.d.ts +1 -1
  11. package/cjs/cell/index.js +1 -1
  12. package/cjs/checkbox/index.d.ts +1 -1
  13. package/cjs/checkbox/index.js +1 -1
  14. package/cjs/collapse/index.d.ts +1 -1
  15. package/cjs/collapse/index.js +1 -1
  16. package/cjs/count-down/index.d.ts +1 -1
  17. package/cjs/count-down/index.js +1 -1
  18. package/cjs/date-picker/index.d.ts +1 -1
  19. package/cjs/date-picker/index.js +1 -1
  20. package/cjs/dropdown/dropdown.js +36 -20
  21. package/cjs/dropdown/style/css/index.css +3 -0
  22. package/cjs/dropdown/style/index.less +2 -0
  23. package/cjs/ellipsis/index.d.ts +1 -1
  24. package/cjs/ellipsis/index.js +1 -1
  25. package/cjs/image/index.d.ts +1 -1
  26. package/cjs/image/index.js +1 -1
  27. package/cjs/image-picker/index.d.ts +4 -175
  28. package/cjs/image-picker/index.js +41 -18
  29. package/cjs/image-picker/type.d.ts +174 -0
  30. package/cjs/image-picker/type.js +3 -0
  31. package/cjs/image-preview/index.d.ts +1 -1
  32. package/cjs/image-preview/index.js +1 -1
  33. package/cjs/index.d.ts +2 -0
  34. package/cjs/index.js +9 -1
  35. package/cjs/input/hooks.js +49 -8
  36. package/cjs/input/index.d.ts +1 -1
  37. package/cjs/input/index.js +1 -1
  38. package/cjs/input/props.d.ts +8 -2
  39. package/cjs/notice-bar/index.d.ts +1 -1
  40. package/cjs/notice-bar/index.js +1 -1
  41. package/cjs/picker/index.d.ts +1 -1
  42. package/cjs/picker/index.js +1 -1
  43. package/cjs/picker-view/index.d.ts +1 -1
  44. package/cjs/picker-view/index.js +1 -1
  45. package/cjs/popover/index.d.ts +1 -1
  46. package/cjs/popover/index.js +1 -1
  47. package/cjs/popup-swiper/index.js +3 -2
  48. package/cjs/radio/index.d.ts +1 -1
  49. package/cjs/radio/index.js +1 -1
  50. package/cjs/rate/index.d.ts +1 -1
  51. package/cjs/rate/index.js +1 -1
  52. package/cjs/search-bar/association.d.ts +3 -0
  53. package/cjs/search-bar/association.js +92 -0
  54. package/cjs/search-bar/cancel-button.d.ts +10 -0
  55. package/cjs/search-bar/cancel-button.js +41 -0
  56. package/cjs/search-bar/demo/style/css/mobile.css +5 -0
  57. package/cjs/search-bar/demo/style/mobile.less +9 -0
  58. package/cjs/search-bar/highlight.d.ts +12 -0
  59. package/cjs/search-bar/highlight.js +77 -0
  60. package/cjs/search-bar/index.d.ts +13 -0
  61. package/cjs/search-bar/index.js +239 -0
  62. package/cjs/search-bar/style/css/index.css +148 -0
  63. package/cjs/search-bar/style/css/index.d.ts +2 -0
  64. package/cjs/search-bar/style/css/index.js +5 -0
  65. package/cjs/search-bar/style/index.d.ts +2 -0
  66. package/cjs/search-bar/style/index.js +5 -0
  67. package/cjs/search-bar/style/index.less +111 -0
  68. package/cjs/search-bar/type.d.ts +163 -0
  69. package/cjs/search-bar/type.js +3 -0
  70. package/cjs/slider/index.d.ts +1 -1
  71. package/cjs/slider/index.js +1 -1
  72. package/cjs/steps/index.d.ts +1 -1
  73. package/cjs/steps/index.js +1 -1
  74. package/cjs/sticky/index.d.ts +1 -1
  75. package/cjs/style.d.ts +2 -0
  76. package/cjs/style.js +4 -0
  77. package/cjs/swipe-action/demo/style/css/mobile.css +5 -0
  78. package/cjs/swipe-action/demo/style/mobile.less +9 -0
  79. package/cjs/swipe-action/index.d.ts +12 -0
  80. package/cjs/swipe-action/index.js +339 -0
  81. package/cjs/swipe-action/item.d.ts +11 -0
  82. package/cjs/swipe-action/item.js +52 -0
  83. package/cjs/swipe-action/style/css/index.css +88 -0
  84. package/cjs/swipe-action/style/css/index.d.ts +2 -0
  85. package/cjs/swipe-action/style/css/index.js +5 -0
  86. package/cjs/swipe-action/style/index.d.ts +2 -0
  87. package/cjs/swipe-action/style/index.js +5 -0
  88. package/cjs/swipe-action/style/index.less +89 -0
  89. package/cjs/swipe-action/type.d.ts +123 -0
  90. package/cjs/swipe-action/type.js +3 -0
  91. package/cjs/switch/index.d.ts +1 -1
  92. package/cjs/switch/index.js +1 -1
  93. package/cjs/tabs/tab-pane.js +5 -1
  94. package/cjs/tag/index.d.ts +1 -1
  95. package/cjs/tag/index.js +1 -1
  96. package/cjs/textarea/index.d.ts +1 -1
  97. package/cjs/textarea/index.js +1 -1
  98. package/dist/index.js +7450 -6611
  99. package/dist/index.min.js +6 -6
  100. package/dist/style.css +203 -0
  101. package/dist/style.min.css +1 -1
  102. package/esm/avatar/index.d.ts +1 -1
  103. package/esm/avatar/index.js +1 -1
  104. package/esm/badge/index.d.ts +1 -1
  105. package/esm/badge/index.js +1 -1
  106. package/esm/carousel/index.d.ts +1 -1
  107. package/esm/carousel/index.js +1 -1
  108. package/esm/cell/index.d.ts +1 -1
  109. package/esm/cell/index.js +1 -1
  110. package/esm/checkbox/index.d.ts +1 -1
  111. package/esm/checkbox/index.js +1 -1
  112. package/esm/collapse/index.d.ts +1 -1
  113. package/esm/collapse/index.js +1 -1
  114. package/esm/count-down/index.d.ts +1 -1
  115. package/esm/count-down/index.js +1 -1
  116. package/esm/date-picker/index.d.ts +1 -1
  117. package/esm/date-picker/index.js +1 -1
  118. package/esm/dropdown/dropdown.js +36 -20
  119. package/esm/dropdown/style/css/index.css +3 -0
  120. package/esm/dropdown/style/index.less +2 -0
  121. package/esm/ellipsis/index.d.ts +1 -1
  122. package/esm/ellipsis/index.js +1 -1
  123. package/esm/image/index.d.ts +1 -1
  124. package/esm/image/index.js +1 -1
  125. package/esm/image-picker/index.d.ts +4 -175
  126. package/esm/image-picker/index.js +30 -17
  127. package/esm/image-picker/type.d.ts +174 -0
  128. package/esm/image-picker/type.js +1 -0
  129. package/esm/image-preview/index.d.ts +1 -1
  130. package/esm/image-preview/index.js +1 -1
  131. package/esm/index.d.ts +2 -0
  132. package/esm/index.js +2 -0
  133. package/esm/input/hooks.js +49 -8
  134. package/esm/input/index.d.ts +1 -1
  135. package/esm/input/index.js +1 -1
  136. package/esm/input/props.d.ts +8 -2
  137. package/esm/notice-bar/index.d.ts +1 -1
  138. package/esm/notice-bar/index.js +1 -1
  139. package/esm/picker/index.d.ts +1 -1
  140. package/esm/picker/index.js +1 -1
  141. package/esm/picker-view/index.d.ts +1 -1
  142. package/esm/picker-view/index.js +1 -1
  143. package/esm/popover/index.d.ts +1 -1
  144. package/esm/popover/index.js +1 -1
  145. package/esm/popup-swiper/index.js +3 -2
  146. package/esm/radio/index.d.ts +1 -1
  147. package/esm/radio/index.js +1 -1
  148. package/esm/rate/index.d.ts +1 -1
  149. package/esm/rate/index.js +1 -1
  150. package/esm/search-bar/association.d.ts +3 -0
  151. package/esm/search-bar/association.js +82 -0
  152. package/esm/search-bar/cancel-button.d.ts +10 -0
  153. package/esm/search-bar/cancel-button.js +30 -0
  154. package/esm/search-bar/demo/style/css/mobile.css +5 -0
  155. package/esm/search-bar/demo/style/mobile.less +9 -0
  156. package/esm/search-bar/highlight.d.ts +12 -0
  157. package/esm/search-bar/highlight.js +66 -0
  158. package/esm/search-bar/index.d.ts +13 -0
  159. package/esm/search-bar/index.js +213 -0
  160. package/esm/search-bar/style/css/index.css +148 -0
  161. package/esm/search-bar/style/css/index.d.ts +2 -0
  162. package/esm/search-bar/style/css/index.js +2 -0
  163. package/esm/search-bar/style/index.d.ts +2 -0
  164. package/esm/search-bar/style/index.js +2 -0
  165. package/esm/search-bar/style/index.less +111 -0
  166. package/esm/search-bar/type.d.ts +163 -0
  167. package/esm/search-bar/type.js +1 -0
  168. package/esm/slider/index.d.ts +1 -1
  169. package/esm/slider/index.js +1 -1
  170. package/esm/steps/index.d.ts +1 -1
  171. package/esm/steps/index.js +1 -1
  172. package/esm/sticky/index.d.ts +1 -1
  173. package/esm/style.d.ts +2 -0
  174. package/esm/style.js +2 -0
  175. package/esm/swipe-action/demo/style/css/mobile.css +5 -0
  176. package/esm/swipe-action/demo/style/mobile.less +9 -0
  177. package/esm/swipe-action/index.d.ts +12 -0
  178. package/esm/swipe-action/index.js +321 -0
  179. package/esm/swipe-action/item.d.ts +11 -0
  180. package/esm/swipe-action/item.js +42 -0
  181. package/esm/swipe-action/style/css/index.css +88 -0
  182. package/esm/swipe-action/style/css/index.d.ts +2 -0
  183. package/esm/swipe-action/style/css/index.js +2 -0
  184. package/esm/swipe-action/style/index.d.ts +2 -0
  185. package/esm/swipe-action/style/index.js +2 -0
  186. package/esm/swipe-action/style/index.less +89 -0
  187. package/esm/swipe-action/type.d.ts +123 -0
  188. package/esm/swipe-action/type.js +1 -0
  189. package/esm/switch/index.d.ts +1 -1
  190. package/esm/switch/index.js +1 -1
  191. package/esm/tabs/tab-pane.js +5 -1
  192. package/esm/tag/index.d.ts +1 -1
  193. package/esm/tag/index.js +1 -1
  194. package/esm/textarea/index.d.ts +1 -1
  195. package/esm/textarea/index.js +1 -1
  196. package/package.json +3 -3
  197. package/tokens/app/arcodesign/default/css-variables.less +34 -0
  198. package/tokens/app/arcodesign/default/index.d.ts +34 -0
  199. package/tokens/app/arcodesign/default/index.js +34 -0
  200. package/tokens/app/arcodesign/default/index.json +398 -0
  201. package/tokens/app/arcodesign/default/index.less +34 -0
  202. package/umd/avatar/index.d.ts +1 -1
  203. package/umd/avatar/index.js +1 -1
  204. package/umd/badge/index.d.ts +1 -1
  205. package/umd/badge/index.js +1 -1
  206. package/umd/carousel/index.d.ts +1 -1
  207. package/umd/carousel/index.js +1 -1
  208. package/umd/cell/index.d.ts +1 -1
  209. package/umd/cell/index.js +1 -1
  210. package/umd/checkbox/index.d.ts +1 -1
  211. package/umd/checkbox/index.js +1 -1
  212. package/umd/collapse/index.d.ts +1 -1
  213. package/umd/collapse/index.js +1 -1
  214. package/umd/count-down/index.d.ts +1 -1
  215. package/umd/count-down/index.js +1 -1
  216. package/umd/date-picker/index.d.ts +1 -1
  217. package/umd/date-picker/index.js +1 -1
  218. package/umd/dropdown/dropdown.js +36 -20
  219. package/umd/dropdown/style/css/index.css +3 -0
  220. package/umd/dropdown/style/index.less +2 -0
  221. package/umd/ellipsis/index.d.ts +1 -1
  222. package/umd/ellipsis/index.js +1 -1
  223. package/umd/image/index.d.ts +1 -1
  224. package/umd/image/index.js +1 -1
  225. package/umd/image-picker/index.d.ts +4 -175
  226. package/umd/image-picker/index.js +40 -22
  227. package/umd/image-picker/type.d.ts +174 -0
  228. package/umd/image-picker/type.js +17 -0
  229. package/umd/image-preview/index.d.ts +1 -1
  230. package/umd/image-preview/index.js +1 -1
  231. package/umd/index.d.ts +2 -0
  232. package/umd/index.js +9 -5
  233. package/umd/input/hooks.js +48 -7
  234. package/umd/input/index.d.ts +1 -1
  235. package/umd/input/index.js +1 -1
  236. package/umd/input/props.d.ts +8 -2
  237. package/umd/notice-bar/index.d.ts +1 -1
  238. package/umd/notice-bar/index.js +1 -1
  239. package/umd/picker/index.d.ts +1 -1
  240. package/umd/picker/index.js +1 -1
  241. package/umd/picker-view/index.d.ts +1 -1
  242. package/umd/picker-view/index.js +1 -1
  243. package/umd/popover/index.d.ts +1 -1
  244. package/umd/popover/index.js +1 -1
  245. package/umd/popup-swiper/index.js +3 -2
  246. package/umd/radio/index.d.ts +1 -1
  247. package/umd/radio/index.js +1 -1
  248. package/umd/rate/index.d.ts +1 -1
  249. package/umd/rate/index.js +1 -1
  250. package/umd/search-bar/association.d.ts +3 -0
  251. package/umd/search-bar/association.js +101 -0
  252. package/umd/search-bar/cancel-button.d.ts +10 -0
  253. package/umd/search-bar/cancel-button.js +52 -0
  254. package/umd/search-bar/demo/style/css/mobile.css +5 -0
  255. package/umd/search-bar/demo/style/mobile.less +9 -0
  256. package/umd/search-bar/highlight.d.ts +12 -0
  257. package/umd/search-bar/highlight.js +87 -0
  258. package/umd/search-bar/index.d.ts +13 -0
  259. package/umd/search-bar/index.js +235 -0
  260. package/umd/search-bar/style/css/index.css +148 -0
  261. package/umd/search-bar/style/css/index.d.ts +2 -0
  262. package/umd/search-bar/style/css/index.js +15 -0
  263. package/umd/search-bar/style/index.d.ts +2 -0
  264. package/umd/search-bar/style/index.js +15 -0
  265. package/umd/search-bar/style/index.less +111 -0
  266. package/umd/search-bar/type.d.ts +163 -0
  267. package/umd/search-bar/type.js +17 -0
  268. package/umd/slider/index.d.ts +1 -1
  269. package/umd/slider/index.js +1 -1
  270. package/umd/steps/index.d.ts +1 -1
  271. package/umd/steps/index.js +1 -1
  272. package/umd/sticky/index.d.ts +1 -1
  273. package/umd/style.d.ts +2 -0
  274. package/umd/style.js +4 -4
  275. package/umd/swipe-action/demo/style/css/mobile.css +5 -0
  276. package/umd/swipe-action/demo/style/mobile.less +9 -0
  277. package/umd/swipe-action/index.d.ts +12 -0
  278. package/umd/swipe-action/index.js +342 -0
  279. package/umd/swipe-action/item.d.ts +11 -0
  280. package/umd/swipe-action/item.js +62 -0
  281. package/umd/swipe-action/style/css/index.css +88 -0
  282. package/umd/swipe-action/style/css/index.d.ts +2 -0
  283. package/umd/swipe-action/style/css/index.js +15 -0
  284. package/umd/swipe-action/style/index.d.ts +2 -0
  285. package/umd/swipe-action/style/index.js +15 -0
  286. package/umd/swipe-action/style/index.less +89 -0
  287. package/umd/swipe-action/type.d.ts +123 -0
  288. package/umd/swipe-action/type.js +17 -0
  289. package/umd/switch/index.d.ts +1 -1
  290. package/umd/switch/index.js +1 -1
  291. package/umd/tabs/tab-pane.js +5 -1
  292. package/umd/tag/index.d.ts +1 -1
  293. package/umd/tag/index.js +1 -1
  294. package/umd/textarea/index.d.ts +1 -1
  295. package/umd/textarea/index.js +1 -1
@@ -98,7 +98,7 @@
98
98
  // @en down=0 is to expand upwards, 1 is to expand downwards
99
99
 
100
100
 
101
- var _useState3 = (0, _react.useState)(direction === 'down'),
101
+ var _useState3 = (0, _react.useState)(null),
102
102
  down = _useState3[0],
103
103
  setDown = _useState3[1];
104
104
 
@@ -137,12 +137,15 @@
137
137
 
138
138
  (0, _helpers.usePopupScroll)(showDropdown, domRef.current, getScrollContainer);
139
139
  (0, _helpers.usePreventBodyScroll)(showDropdown, preventBodyScroll, initialBodyOverflow);
140
- (0, _react.useEffect)(function () {
140
+ var updateDown = (0, _react.useCallback)(function (wrapperHeight) {
141
141
  var _dropdownContainer$cu2;
142
142
 
143
143
  // 为0的时候不改变
144
144
  // @en Does not change when it is 0
145
- if (optionsWrapperHeight === 0) return;
145
+ if (wrapperHeight === 0) {
146
+ return;
147
+ }
148
+
146
149
  var tempEl = getAnchorElement ? getAnchorElement() : (_dropdownContainer$cu2 = dropdownContainer.current) == null ? void 0 : _dropdownContainer$cu2.parentElement;
147
150
 
148
151
  var _ref = (tempEl == null ? void 0 : tempEl.getBoundingClientRect()) || {
@@ -157,7 +160,7 @@
157
160
  var tempMaskHeight = windowHeight - tempTop; // 没有指定方向,且空间足够时,或向上展开的空间不够,向下展开
158
161
  // @en If there is no specified direction and there is enough space, or there is not enough space to expand upward, expand downward
159
162
 
160
- var tempDown = direction !== 'up' && optionsWrapperHeight < tempMaskHeight || optionsWrapperHeight > tempTop;
163
+ var tempDown = direction !== 'up' && wrapperHeight < tempMaskHeight || wrapperHeight > tempTop;
161
164
 
162
165
  if (tempDown) {
163
166
  maskHeight.current = tempMaskHeight;
@@ -174,7 +177,7 @@
174
177
  }
175
178
 
176
179
  setDown(tempDown);
177
- }, [dropdownContainer, optionsWrapperHeight, props.top, props.bottom, Boolean(getAnchorElement), direction, windowHeight]);
180
+ }, [props.top, props.bottom, Boolean(getAnchorElement), direction, windowHeight]);
178
181
  /**
179
182
  * 取消选择
180
183
  * @en Cancel selection
@@ -215,19 +218,27 @@
215
218
  };
216
219
  }, [showDropdown, clickOtherToClose, handleCancel]);
217
220
  (0, _react.useEffect)(function () {
218
- (0, _mobileUtils.nextTick)(function () {
219
- if (height !== void 0) {
220
- // 受控模式下,完全交由外层控制
221
- // @en In controlled mode, it is completely controlled by the outer layer
222
- setOptionsWrapperHeight(height);
221
+ var wrapperHeight = 0;
222
+
223
+ if (height !== void 0) {
224
+ // 受控模式下,完全交由外层控制
225
+ // @en In controlled mode, it is completely controlled by the outer layer
226
+ wrapperHeight = height;
227
+ } else {
228
+ if (!optionsContainer.current) return;
229
+
230
+ if (!showDropdown) {
231
+ wrapperHeight = 0;
223
232
  } else {
224
- if (!optionsContainer.current) return;
225
- if (!showDropdown) setOptionsWrapperHeight(0);else {
226
- setOptionsWrapperHeight(optionsContainer.current.getBoundingClientRect().height);
227
- }
233
+ wrapperHeight = optionsContainer.current.getBoundingClientRect().height;
228
234
  }
235
+ }
236
+
237
+ updateDown(wrapperHeight);
238
+ (0, _mobileUtils.nextTick)(function () {
239
+ setOptionsWrapperHeight(wrapperHeight);
229
240
  });
230
- }, [showDropdown, options.length, height]);
241
+ }, [showDropdown, options.length, height, updateDown]);
231
242
  (0, _react.useImperativeHandle)(ref, function () {
232
243
  return {
233
244
  dom: domRef.current
@@ -236,13 +247,17 @@
236
247
 
237
248
  function getOptionsStyle() {
238
249
  var trans = down ? 'translateY(-100%)' : 'translateY(100%)';
239
- return (0, _helpers.getStyleWithVendor)({
240
- // height: `${optionsWrapperHeight}px`,
241
- transform: optionsWrapperHeight ? '' : trans,
242
- transition: "transform " + dropdownAnimationTimeout + "ms " + dropdownAnimationFunction,
250
+ var transStyle = down === null ? {
251
+ opacity: 0
252
+ } : {
253
+ opacity: 1,
254
+ transform: optionsWrapperHeight ? 'translateY(0)' : trans,
255
+ transition: "all " + dropdownAnimationTimeout + "ms " + dropdownAnimationFunction
256
+ };
257
+ return (0, _helpers.getStyleWithVendor)((0, _extends2.default)({}, transStyle, {
243
258
  overflow: optionsWrapperHeight > maxHeight || height ? 'auto' : 'hidden',
244
259
  maxHeight: maxHeight + "px"
245
- });
260
+ }));
246
261
  }
247
262
 
248
263
  function renderInnerOptions() {
@@ -276,6 +291,7 @@
276
291
  },
277
292
  onExited: function onExited(el) {
278
293
  el.style.visibility = 'hidden';
294
+ setDown(null);
279
295
  },
280
296
  mountOnEnter: mountOnEnter,
281
297
  unmountOnExit: unmountOnExit
@@ -47,6 +47,9 @@
47
47
  }
48
48
  .arco-dropdown-options-item-icon {
49
49
  position: absolute;
50
+ top: 50%;
51
+ -webkit-transform: translateY(-50%);
52
+ transform: translateY(-50%);
50
53
  right: 0.32rem ;
51
54
  color: transparent;
52
55
  }
@@ -55,6 +55,8 @@
55
55
 
56
56
  &-icon {
57
57
  position: absolute;
58
+ top: 50%;
59
+ transform: translateY(-50%);
58
60
  .use-var(right, dropdown-options-item-icon-right);
59
61
  color: transparent;
60
62
  }
@@ -4,7 +4,7 @@ export * from './type';
4
4
  /**
5
5
  * 文本缩略组件,支持多行缩略、富文本、自定义缩略符、尾字符过滤等。
6
6
  * @en Text ellipsis component supports multi-line abbreviations, rich text, custom abbreviations, tail character filtering, etc.
7
- * @type 数据展示
7
+ * @type 信息展示
8
8
  * @type_en Data Display
9
9
  * @name 文本缩略
10
10
  * @name_en Ellipsis
@@ -35,7 +35,7 @@
35
35
  /**
36
36
  * 文本缩略组件,支持多行缩略、富文本、自定义缩略符、尾字符过滤等。
37
37
  * @en Text ellipsis component supports multi-line abbreviations, rich text, custom abbreviations, tail character filtering, etc.
38
- * @type 数据展示
38
+ * @type 信息展示
39
39
  * @type_en Data Display
40
40
  * @name 文本缩略
41
41
  * @name_en Ellipsis
@@ -177,7 +177,7 @@ export interface ImageRef {
177
177
  /**
178
178
  * 增强版的 img 标签,提供多种图片填充模式,支持图片加载中提示、加载失败提示。
179
179
  * @en Enhanced img tag, provides a variety of image filling modes, and supports image loading prompts and loading failure prompts.
180
- * @type 数据展示
180
+ * @type 信息展示
181
181
  * @type_en Data Display
182
182
  * @name 图片
183
183
  * @name_en Image
@@ -28,7 +28,7 @@
28
28
  /**
29
29
  * 增强版的 img 标签,提供多种图片填充模式,支持图片加载中提示、加载失败提示。
30
30
  * @en Enhanced img tag, provides a variety of image filling modes, and supports image loading prompts and loading failure prompts.
31
- * @type 数据展示
31
+ * @type 信息展示
32
32
  * @type_en Data Display
33
33
  * @name 图片
34
34
  * @name_en Image
@@ -1,181 +1,10 @@
1
- import React, { InputHTMLAttributes } from 'react';
2
- import { ImageProps } from '../image';
3
- export interface ImagePickItem {
4
- /**
5
- * 图片地址
6
- * @en Image Url
7
- */
8
- url: string;
9
- /**
10
- * 图片文件
11
- * @en Image File
12
- */
13
- file?: File;
14
- /**
15
- * 图片状态
16
- * @en Image Status
17
- * @default 以图片自身加载状态而定
18
- * @default_en According to inner status of the image
19
- */
20
- status?: 'loaded' | 'loading' | 'error';
21
- }
22
- export interface AdapterFile {
23
- url?: string;
24
- size: number;
25
- name: string;
26
- }
27
- export interface SelectCallback {
28
- files: AdapterFile[];
29
- }
30
- export interface ImagePickerProps {
31
- /**
32
- * 自定义类名
33
- * @en Custom className
34
- */
35
- className?: string;
36
- /**
37
- * 自定义样式
38
- * @en Custom stylesheet
39
- */
40
- style?: React.CSSProperties;
41
- /**
42
- * 已选择图片列表
43
- * @en selected images list
44
- */
45
- images: ImagePickItem[];
46
- /**
47
- * 可以选择的文件类型
48
- * @en Available File Types
49
- * @default 'image/*'
50
- */
51
- accept?: string;
52
- /**
53
- * 是否支持多选
54
- * @en Whether To Support Multiple Selection
55
- */
56
- multiple?: boolean;
57
- /**
58
- * 图片选取模式 Image selection mode [capture MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture)
59
- * @en Whether To Support Multiple Selection [capture MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture)
60
- */
61
- capture?: InputHTMLAttributes<unknown>['capture'];
62
- /**
63
- * 一行展示图片张数
64
- * @en The Number Of Pictures Displayed In A Row
65
- * @default 3
66
- */
67
- columns?: number;
68
- /**
69
- * 格子间的间距
70
- * @en spacing between grids
71
- * @default 8
72
- */
73
- gutter?: number;
74
- /**
75
- * 最多选择图片张数,超出数量自动隐藏上传按钮,0表示不做限制
76
- * @en max Pictures Can Choose
77
- */
78
- limit?: number;
79
- /**
80
- * 文件大小限制,单位为K
81
- * @en File size limit, in K
82
- */
83
- maxSize?: number;
84
- /**
85
- * 是否隐藏删除Icon
86
- * @en Whether to hide delete Icon
87
- * @default false
88
- */
89
- hideDelete?: boolean;
90
- /**
91
- * 是否隐藏选择Icon
92
- * @en Whether to hide Select Icon
93
- * @default false
94
- */
95
- hideSelect?: boolean;
96
- /**
97
- * 是否总是展示选择Icon,默认情况下当图片数量超出limit值时会自动隐藏选择Icon
98
- * @en Whether to always show Select Icon
99
- * @default false
100
- */
101
- alwaysShowSelect?: boolean;
102
- /**
103
- * 禁用选择和删除图片
104
- * @en Disable Select & Delete Image
105
- */
106
- disabled?: boolean;
107
- /**
108
- * 自定义删除图标
109
- * @en Defined Delete Icon
110
- */
111
- deleteIcon?: React.ReactNode;
112
- /**
113
- * 自定义选择图标
114
- * @en Defined Select Icon
115
- */
116
- selectIcon?: React.ReactNode;
117
- /**
118
- * 透传给图片的属性
119
- * @en Attributes passed through to the image
120
- */
121
- imageProps?: Partial<ImageProps>;
122
- /**
123
- * 自定义上传失败展示
124
- * @en Defined upload failed display
125
- */
126
- renderError?: (index?: number) => React.ReactNode | React.ReactNode;
127
- /**
128
- * 自定义上传中展示
129
- * @en Defined uploading display
130
- */
131
- renderLoading?: (index?: number) => React.ReactNode | React.ReactNode;
132
- /**
133
- * 上传方法
134
- * @en upload function
135
- */
136
- upload?: (file: ImagePickItem) => Promise<ImagePickItem | null>;
137
- /**
138
- * 已选图片列表发生变化
139
- * @en The list of selected images changes
140
- */
141
- onChange?: (fileList: ImagePickItem[]) => void;
142
- /**
143
- * 图片超过限制大小
144
- * @en Image exceeds size limit
145
- */
146
- onMaxSizeExceed?: (file: File) => void;
147
- /**
148
- * 选择张数超过限制
149
- * @en The number of pictures exceeds the limit
150
- */
151
- onLimitExceed?: (files: File[]) => void;
152
- /**
153
- * 图片点击
154
- * @en click event
155
- */
156
- onClick?: (e: React.MouseEvent<HTMLElement, MouseEvent>, image: ImagePickItem, index: number) => void;
157
- /**
158
- * 图片长按事件
159
- * @en long press event
160
- */
161
- onLongPress?: (e: React.TouchEvent<HTMLElement>, image: ImagePickItem, index: number) => void;
162
- /**
163
- * 图片选择适配器
164
- * @en Select Adaptor
165
- */
166
- selectAdapter?: () => Promise<SelectCallback>;
167
- }
168
- export interface ImagePickerRef {
169
- /**
170
- * 最外层 DOM 元素
171
- * @en The outer DOM element of the component
172
- */
173
- dom: HTMLDivElement | null;
174
- }
1
+ import React from 'react';
2
+ import { ImagePickerProps, ImagePickerRef } from './type';
3
+ export * from './type';
175
4
  /**
176
5
  * 图片选择器组件
177
6
  * @en ImagePicker Component
178
- * @type 数据输入
7
+ * @type 数据录入
179
8
  * @type_en Data Entry
180
9
  * @name 图片选择器
181
10
  * @name_en ImagePicker
@@ -1,27 +1,34 @@
1
1
  (function (global, factory) {
2
2
  if (typeof define === "function" && define.amd) {
3
- define(["exports", "@babel/runtime/helpers/extends", "react", "@arco-design/mobile-utils", "../context-provider", "../icon", "../image", "../grid", "./add-icon"], factory);
3
+ define(["exports", "@babel/runtime/helpers/extends", "react", "es6-promise", "@arco-design/mobile-utils", "../context-provider", "../icon", "../image", "../grid", "./add-icon", "./type"], factory);
4
4
  } else if (typeof exports !== "undefined") {
5
- factory(exports, require("@babel/runtime/helpers/extends"), require("react"), require("@arco-design/mobile-utils"), require("../context-provider"), require("../icon"), require("../image"), require("../grid"), require("./add-icon"));
5
+ factory(exports, require("@babel/runtime/helpers/extends"), require("react"), require("es6-promise"), require("@arco-design/mobile-utils"), require("../context-provider"), require("../icon"), require("../image"), require("../grid"), require("./add-icon"), require("./type"));
6
6
  } else {
7
7
  var mod = {
8
8
  exports: {}
9
9
  };
10
- factory(mod.exports, global._extends, global.react, global.mobileUtils, global.contextProvider, global.icon, global.image, global.grid, global.addIcon);
10
+ factory(mod.exports, global._extends, global.react, global.es6Promise, global.mobileUtils, global.contextProvider, global.icon, global.image, global.grid, global.addIcon, global.type);
11
11
  global.index = mod.exports;
12
12
  }
13
- })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _extends2, _react, _mobileUtils, _contextProvider, _icon, _image, _grid, _addIcon) {
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _extends2, _react, _es6Promise, _mobileUtils, _contextProvider, _icon, _image, _grid, _addIcon, _type) {
14
14
  "use strict";
15
15
 
16
16
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
17
17
 
18
18
  _exports.__esModule = true;
19
+ var _exportNames = {};
19
20
  _exports.default = void 0;
20
21
  _extends2 = _interopRequireDefault(_extends2);
21
22
  _react = _interopRequireWildcard(_react);
22
23
  _image = _interopRequireDefault(_image);
23
24
  _grid = _interopRequireDefault(_grid);
24
25
  _addIcon = _interopRequireDefault(_addIcon);
26
+ Object.keys(_type).forEach(function (key) {
27
+ if (key === "default" || key === "__esModule") return;
28
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
29
+ if (key in _exports && _exports[key] === _type[key]) return;
30
+ _exports[key] = _type[key];
31
+ });
25
32
 
26
33
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
27
34
 
@@ -30,7 +37,7 @@
30
37
  /**
31
38
  * 图片选择器组件
32
39
  * @en ImagePicker Component
33
- * @type 数据输入
40
+ * @type 数据录入
34
41
  * @type_en Data Entry
35
42
  * @name 图片选择器
36
43
  * @name_en ImagePicker
@@ -77,6 +84,7 @@
77
84
  selectAdapter = props.selectAdapter;
78
85
  var domRef = (0, _react.useRef)(null);
79
86
  var fileRef = (0, _react.useRef)(null);
87
+ var cacheRef = (0, _react.useRef)([]);
80
88
  (0, _react.useImperativeHandle)(ref, function () {
81
89
  return {
82
90
  dom: domRef.current
@@ -84,7 +92,7 @@
84
92
  });
85
93
 
86
94
  var parseFile = function parseFile(file) {
87
- return new Promise(function (resolve, reject) {
95
+ return new _es6Promise.Promise(function (resolve, reject) {
88
96
  if (file.url) {
89
97
  resolve(file.url);
90
98
  } else {
@@ -112,7 +120,7 @@
112
120
  };
113
121
 
114
122
  var handleChange = function handleChange(event, fromAdapter) {
115
- var files = [].concat(event.target.files || []).filter(function (file) {
123
+ var files = Array.prototype.filter.call(event.target.files || [], function (file) {
116
124
  // 过滤maxSize
117
125
  if (maxSize && file.size > maxSize * 1024) {
118
126
  onMaxSizeExceed && onMaxSizeExceed(file);
@@ -133,7 +141,7 @@
133
141
  } // 解析文件生成预览
134
142
 
135
143
 
136
- Promise.all(files.map(function (file) {
144
+ _es6Promise.Promise.all(files.map(function (file) {
137
145
  return parseFile(file);
138
146
  })).then(function (parseFiles) {
139
147
  var res = parseFiles.map(function (url, index) {
@@ -143,20 +151,30 @@
143
151
  file: files[index]
144
152
  };
145
153
  });
146
- var cacheRes = [].concat(images, res);
147
- onChange(cacheRes); // 执行upload
154
+ cacheRef.current = [].concat(images, res);
155
+ onChange([].concat(cacheRef.current)); // 执行upload
148
156
 
149
157
  if (typeof upload === 'function') {
150
- var propsImageLength = images.length;
151
- files.forEach(function (_file, index) {
152
- upload(cacheRes[propsImageLength + index]).then(function (data) {
153
- cacheRes[propsImageLength + index] = (0, _extends2.default)({}, cacheRes[propsImageLength + index], data, {
158
+ files.forEach(function (_file) {
159
+ upload(cacheRef.current.find(function (_ref) {
160
+ var file = _ref.file;
161
+ return file === _file;
162
+ })).then(function (data) {
163
+ var index = cacheRef.current.findIndex(function (_ref2) {
164
+ var file = _ref2.file;
165
+ return file === _file;
166
+ });
167
+ cacheRef.current[index] = (0, _extends2.default)({}, cacheRef.current[index], data, {
154
168
  status: undefined
155
169
  });
156
170
  }).catch(function () {
157
- cacheRes[propsImageLength + index].status = 'error';
171
+ var index = cacheRef.current.findIndex(function (_ref3) {
172
+ var file = _ref3.file;
173
+ return file === _file;
174
+ });
175
+ cacheRef.current[index].status = 'error';
158
176
  }).finally(function () {
159
- onChange([].concat(cacheRes));
177
+ onChange([].concat(cacheRef.current));
160
178
  });
161
179
  });
162
180
  }
@@ -191,8 +209,8 @@
191
209
  var handleSelect = function handleSelect() {
192
210
  var _fileRef$current;
193
211
 
194
- selectAdapter ? selectAdapter().then(function (_ref) {
195
- var files = _ref.files;
212
+ selectAdapter ? selectAdapter().then(function (_ref4) {
213
+ var files = _ref4.files;
196
214
  return handleChange({
197
215
  target: {
198
216
  files: files
@@ -287,12 +305,12 @@
287
305
  return data;
288
306
  };
289
307
 
290
- return /*#__PURE__*/_react.default.createElement(_contextProvider.ContextLayout, null, function (_ref2) {
308
+ return /*#__PURE__*/_react.default.createElement(_contextProvider.ContextLayout, null, function (_ref5) {
291
309
  var _cls2;
292
310
 
293
- var prefixCls = _ref2.prefixCls,
294
- _ref2$locale = _ref2.locale,
295
- locale = _ref2$locale === void 0 ? _mobileUtils.defaultLocale : _ref2$locale;
311
+ var prefixCls = _ref5.prefixCls,
312
+ _ref5$locale = _ref5.locale,
313
+ locale = _ref5$locale === void 0 ? _mobileUtils.defaultLocale : _ref5$locale;
296
314
  return /*#__PURE__*/_react.default.createElement("div", {
297
315
  className: (0, _mobileUtils.cls)(prefixCls + "-image-picker", className, (_cls2 = {}, _cls2[prefixCls + "-image-picker-disabled"] = disabled, _cls2)),
298
316
  style: style,
@@ -0,0 +1,174 @@
1
+ import { InputHTMLAttributes } from 'react';
2
+ import { ImageProps } from '../image';
3
+ export interface ImagePickItem {
4
+ /**
5
+ * 图片地址
6
+ * @en Image Url
7
+ */
8
+ url: string;
9
+ /**
10
+ * 图片文件
11
+ * @en Image File
12
+ */
13
+ file?: File;
14
+ /**
15
+ * 图片状态
16
+ * @en Image Status
17
+ * @default 以图片自身加载状态而定
18
+ * @default_en According to inner status of the image
19
+ */
20
+ status?: 'loaded' | 'loading' | 'error';
21
+ }
22
+ export interface AdapterFile {
23
+ url?: string;
24
+ size: number;
25
+ name: string;
26
+ }
27
+ export interface SelectCallback {
28
+ files: AdapterFile[];
29
+ }
30
+ export interface ImagePickerProps {
31
+ /**
32
+ * 自定义类名
33
+ * @en Custom className
34
+ */
35
+ className?: string;
36
+ /**
37
+ * 自定义样式
38
+ * @en Custom stylesheet
39
+ */
40
+ style?: React.CSSProperties;
41
+ /**
42
+ * 已选择图片列表
43
+ * @en selected images list
44
+ */
45
+ images: ImagePickItem[];
46
+ /**
47
+ * 可以选择的文件类型
48
+ * @en Available File Types
49
+ * @default 'image/*'
50
+ */
51
+ accept?: string;
52
+ /**
53
+ * 是否支持多选
54
+ * @en Whether To Support Multiple Selection
55
+ */
56
+ multiple?: boolean;
57
+ /**
58
+ * 图片选取模式 Image selection mode [capture MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture)
59
+ * @en Whether To Support Multiple Selection [capture MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture)
60
+ */
61
+ capture?: InputHTMLAttributes<unknown>['capture'];
62
+ /**
63
+ * 一行展示图片张数
64
+ * @en The Number Of Pictures Displayed In A Row
65
+ * @default 3
66
+ */
67
+ columns?: number;
68
+ /**
69
+ * 格子间的间距
70
+ * @en spacing between grids
71
+ * @default 8
72
+ */
73
+ gutter?: number;
74
+ /**
75
+ * 最多选择图片张数,超出数量自动隐藏上传按钮,0表示不做限制
76
+ * @en max Pictures Can Choose
77
+ */
78
+ limit?: number;
79
+ /**
80
+ * 文件大小限制,单位为K
81
+ * @en File size limit, in K
82
+ */
83
+ maxSize?: number;
84
+ /**
85
+ * 是否隐藏删除Icon
86
+ * @en Whether to hide delete Icon
87
+ * @default false
88
+ */
89
+ hideDelete?: boolean;
90
+ /**
91
+ * 是否隐藏选择Icon
92
+ * @en Whether to hide Select Icon
93
+ * @default false
94
+ */
95
+ hideSelect?: boolean;
96
+ /**
97
+ * 是否总是展示选择Icon,默认情况下当图片数量超出limit值时会自动隐藏选择Icon
98
+ * @en Whether to always show Select Icon
99
+ * @default false
100
+ */
101
+ alwaysShowSelect?: boolean;
102
+ /**
103
+ * 禁用选择和删除图片
104
+ * @en Disable Select & Delete Image
105
+ */
106
+ disabled?: boolean;
107
+ /**
108
+ * 自定义删除图标
109
+ * @en Defined Delete Icon
110
+ */
111
+ deleteIcon?: React.ReactNode;
112
+ /**
113
+ * 自定义选择图标
114
+ * @en Defined Select Icon
115
+ */
116
+ selectIcon?: React.ReactNode;
117
+ /**
118
+ * 透传给图片的属性
119
+ * @en Attributes passed through to the image
120
+ */
121
+ imageProps?: Partial<ImageProps>;
122
+ /**
123
+ * 自定义上传失败展示
124
+ * @en Defined upload failed display
125
+ */
126
+ renderError?: (index?: number) => React.ReactNode | React.ReactNode;
127
+ /**
128
+ * 自定义上传中展示
129
+ * @en Defined uploading display
130
+ */
131
+ renderLoading?: (index?: number) => React.ReactNode | React.ReactNode;
132
+ /**
133
+ * 上传方法
134
+ * @en upload function
135
+ */
136
+ upload?: (file: ImagePickItem) => Promise<ImagePickItem | null>;
137
+ /**
138
+ * 已选图片列表发生变化
139
+ * @en The list of selected images changes
140
+ */
141
+ onChange?: (fileList: ImagePickItem[]) => void;
142
+ /**
143
+ * 图片超过限制大小
144
+ * @en Image exceeds size limit
145
+ */
146
+ onMaxSizeExceed?: (file: File) => void;
147
+ /**
148
+ * 选择张数超过限制
149
+ * @en The number of pictures exceeds the limit
150
+ */
151
+ onLimitExceed?: (files: File[]) => void;
152
+ /**
153
+ * 图片点击
154
+ * @en click event
155
+ */
156
+ onClick?: (e: React.MouseEvent<HTMLElement, MouseEvent>, image: ImagePickItem, index: number) => void;
157
+ /**
158
+ * 图片长按事件
159
+ * @en long press event
160
+ */
161
+ onLongPress?: (e: React.TouchEvent<HTMLElement>, image: ImagePickItem, index: number) => void;
162
+ /**
163
+ * 图片选择适配器
164
+ * @en Select Adaptor
165
+ */
166
+ selectAdapter?: () => Promise<SelectCallback>;
167
+ }
168
+ export interface ImagePickerRef {
169
+ /**
170
+ * 最外层 DOM 元素
171
+ * @en The outer DOM element of the component
172
+ */
173
+ dom: HTMLDivElement | null;
174
+ }