@arco-design/mobile-react 2.29.3 → 2.29.4

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 (46) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.en-US.md +2 -2
  3. package/README.md +2 -2
  4. package/cjs/load-more/index.d.ts +6 -0
  5. package/cjs/load-more/index.js +9 -3
  6. package/cjs/picker/index.js +2 -9
  7. package/cjs/picker-view/components/cascader.d.ts +1 -0
  8. package/cjs/picker-view/components/cascader.js +8 -1
  9. package/cjs/picker-view/components/picker-cell.d.ts +1 -0
  10. package/cjs/picker-view/components/picker-cell.js +8 -1
  11. package/cjs/picker-view/index.js +15 -9
  12. package/cjs/search-bar/style/css/index.css +2 -0
  13. package/cjs/search-bar/style/index.less +93 -91
  14. package/cjs/tabs/index.js +4 -1
  15. package/dist/index.js +46 -23
  16. package/dist/index.min.js +2 -2
  17. package/dist/style.css +2 -0
  18. package/dist/style.min.css +1 -1
  19. package/esm/load-more/index.d.ts +6 -0
  20. package/esm/load-more/index.js +9 -3
  21. package/esm/picker/index.js +4 -10
  22. package/esm/picker-view/components/cascader.d.ts +1 -0
  23. package/esm/picker-view/components/cascader.js +8 -1
  24. package/esm/picker-view/components/picker-cell.d.ts +1 -0
  25. package/esm/picker-view/components/picker-cell.js +8 -1
  26. package/esm/picker-view/index.js +16 -10
  27. package/esm/search-bar/style/css/index.css +2 -0
  28. package/esm/search-bar/style/index.less +93 -91
  29. package/esm/tabs/index.js +4 -1
  30. package/package.json +3 -3
  31. package/tokens/app/arcodesign/default/css-variables.less +2 -0
  32. package/tokens/app/arcodesign/default/index.d.ts +2 -0
  33. package/tokens/app/arcodesign/default/index.js +2 -0
  34. package/tokens/app/arcodesign/default/index.json +24 -0
  35. package/tokens/app/arcodesign/default/index.less +2 -0
  36. package/umd/load-more/index.d.ts +6 -0
  37. package/umd/load-more/index.js +9 -3
  38. package/umd/picker/index.js +2 -9
  39. package/umd/picker-view/components/cascader.d.ts +1 -0
  40. package/umd/picker-view/components/cascader.js +8 -1
  41. package/umd/picker-view/components/picker-cell.d.ts +1 -0
  42. package/umd/picker-view/components/picker-cell.js +8 -1
  43. package/umd/picker-view/index.js +15 -9
  44. package/umd/search-bar/style/css/index.css +2 -0
  45. package/umd/search-bar/style/index.less +93 -91
  46. package/umd/tabs/index.js +4 -1
package/dist/index.js CHANGED
@@ -5247,6 +5247,7 @@
5247
5247
  var touchStartXRef = React.useRef(0);
5248
5248
  var touchStartYRef = React.useRef(0);
5249
5249
  var touchStartTimeRef = React.useRef(0);
5250
+ var touchMovedRef = React.useRef(false);
5250
5251
  var scrollingRef = React.useRef(null);
5251
5252
  var touchStoppedRef = React.useRef(false);
5252
5253
  var changeFromRef = React.useRef('');
@@ -5338,6 +5339,7 @@
5338
5339
  }
5339
5340
 
5340
5341
  touchStartedRef.current = true;
5342
+ touchMovedRef.current = false;
5341
5343
  setCellTrans(false);
5342
5344
  setPaneTrans(false);
5343
5345
  var evt = e.touches[0];
@@ -5365,6 +5367,7 @@
5365
5367
  return;
5366
5368
  }
5367
5369
 
5370
+ touchMovedRef.current = true;
5368
5371
  var evt = e.changedTouches[0];
5369
5372
  var touchMoveX = evt.clientX || 0;
5370
5373
  var touchMoveY = evt.clientY || 0; // bugfix: 兼容safari在右滑返回上一页时clientX为负值的情况,安卓有折叠屏,触点会有超出屏幕(clientX < 0)的情况,因此这里限定ios系统
@@ -5431,7 +5434,7 @@
5431
5434
  cellRef.current && cellRef.current.scrollToCenter();
5432
5435
  }
5433
5436
 
5434
- if (!touchStartedRef.current || posAdjustingRef.current || scrollingRef.current) {
5437
+ if (!touchStartedRef.current || posAdjustingRef.current || scrollingRef.current || !touchMovedRef.current) {
5435
5438
  return;
5436
5439
  }
5437
5440
 
@@ -5867,13 +5870,15 @@
5867
5870
  blockWhenLoading = _g === void 0 ? true : _g,
5868
5871
  onStatusChange = props.onStatusChange,
5869
5872
  onClick = props.onClick,
5870
- onEndReached = props.onEndReached;
5873
+ onEndReached = props.onEndReached,
5874
+ _h = props.getDataWhenNoScrollAtFirst,
5875
+ getDataWhenNoScrollAtFirst = _h === void 0 ? false : _h;
5871
5876
  var domRef = React.useRef(null);
5872
5877
  var requestAtFirst = trigger === 'scroll' ? getDataAtFirst : false;
5873
5878
 
5874
- var _h = React.useState(defaultStatus),
5875
- innerStatus = _h[0],
5876
- setInnerStatus = _h[1];
5879
+ var _j = React.useState(defaultStatus),
5880
+ innerStatus = _j[0],
5881
+ setInnerStatus = _j[1];
5877
5882
 
5878
5883
  var lastScrollEndRef = React.useRef(false);
5879
5884
  var nowStatus = status || innerStatus;
@@ -5912,10 +5917,14 @@
5912
5917
  }
5913
5918
  }, [nowStatus]);
5914
5919
  React.useEffect(function () {
5915
- if (requestAtFirst && !disabled) {
5916
- if (statusRef.current === 'prepare') {
5920
+ if (requestAtFirst) {
5921
+ if (statusRef.current === 'prepare' && !disabled) {
5917
5922
  triggerGetData('requestAtFirst');
5918
5923
  }
5924
+ } else {
5925
+ if (trigger === 'scroll' && nowStatus === 'prepare' && checkNeedTrigger(0, threshold) && !disabled && getDataWhenNoScrollAtFirst) {
5926
+ triggerGetData('pageEnd');
5927
+ }
5919
5928
  }
5920
5929
  }, [trigger, disabled]);
5921
5930
  var handleContainerScroll = React.useCallback(function () {
@@ -11215,6 +11224,12 @@
11215
11224
  _scrollToIndexWithChange(nowIndex, 0);
11216
11225
  }
11217
11226
 
11227
+ function getCurrentCellValue() {
11228
+ var _a;
11229
+
11230
+ return currentValue || ((_a = data[currentIndex]) === null || _a === void 0 ? void 0 : _a.value);
11231
+ }
11232
+
11218
11233
  function _clearTimer() {
11219
11234
  timeRef.current && clearTimeout(timeRef.current);
11220
11235
  timeRef.current = null;
@@ -11281,7 +11296,8 @@
11281
11296
  React.useImperativeHandle(ref, function () {
11282
11297
  return {
11283
11298
  movingStatus: movingStatusRef.current,
11284
- scrollToCurrentIndex: scrollToCurrentIndex
11299
+ scrollToCurrentIndex: scrollToCurrentIndex,
11300
+ getCurrentCellValue: getCurrentCellValue
11285
11301
  };
11286
11302
  });
11287
11303
  return !hideEmptyCols || data && data.length ? /*#__PURE__*/React__default["default"].createElement("div", {
@@ -11331,7 +11347,8 @@
11331
11347
  React.useImperativeHandle(ref, function () {
11332
11348
  return {
11333
11349
  getCellMovingStatus: getCellMovingStatus,
11334
- scrollToCurrentIndex: scrollToCurrentIndex
11350
+ scrollToCurrentIndex: scrollToCurrentIndex,
11351
+ getAllCellsValue: getAllCellsValue
11335
11352
  };
11336
11353
  });
11337
11354
 
@@ -11347,6 +11364,12 @@
11347
11364
  });
11348
11365
  }
11349
11366
 
11367
+ function getAllCellsValue() {
11368
+ return pickerCellsRef.current.map(function (cell) {
11369
+ return cell.getCurrentCellValue();
11370
+ });
11371
+ }
11372
+
11350
11373
  function _onValueChange(value, index, newData) {
11351
11374
  var children = arrayTreeFilter(data, function (item, level) {
11352
11375
  return level <= index && item.value === value[level];
@@ -11452,7 +11475,6 @@
11452
11475
  var wrapperRef = React.useRef(null);
11453
11476
  var domRef = React.useRef(null);
11454
11477
  var barRef = React.useRef(null);
11455
- var scrollValueRef = useLatestRef(scrollValue);
11456
11478
  var pickerCellsRef = React.useRef([]);
11457
11479
  var cascaderRef = React.useRef(null); // itemStyle height 同时对 selection-bar 生效,这里不单独抛出 selection-bar 的高度设置属性
11458
11480
  // @en The height of itemStyle applies to the selection-bar as well, without separately exposing the height setting property for the selection-bar.
@@ -11494,17 +11516,24 @@
11494
11516
  }, [data]);
11495
11517
 
11496
11518
  var getAllColumnValues = function getAllColumnValues() {
11497
- return scrollValueRef.current || [];
11519
+ var _a;
11520
+
11521
+ var curValues = cascade ? ((_a = cascaderRef.current) === null || _a === void 0 ? void 0 : _a.getAllCellsValue()) || [] : pickerCellsRef.current.map(function (cell) {
11522
+ return cell.getCurrentCellValue();
11523
+ }); // 移除级联带来的空列值,理论上非首尾列不会有空值
11524
+ // @en Remove empty values from cascader
11525
+
11526
+ return curValues.filter(function (v) {
11527
+ return v;
11528
+ });
11498
11529
  };
11499
11530
 
11500
11531
  function getColumnValue(index) {
11501
- var _a;
11502
-
11503
11532
  if (index === void 0) {
11504
11533
  index = 0;
11505
11534
  }
11506
11535
 
11507
- return (_a = scrollValueRef.current) === null || _a === void 0 ? void 0 : _a[index];
11536
+ return getAllColumnValues()[index];
11508
11537
  }
11509
11538
 
11510
11539
  function getCellMovingStatus() {
@@ -11688,10 +11717,7 @@
11688
11717
  gestureOutOfControl = _l === void 0 ? true : _l,
11689
11718
  otherProps = __rest$1(props, ["className", "itemStyle", "cascade", "cols", "rows", "data", "okText", "dismissText", "disabled", "clickable", "hideEmptyCols", "title", "visible", "value", "needBottomOffset", "onDismiss", "onOk", "onChange", "maskClosable", "onHide", "onPickerChange", "touchToStop", "gestureOutOfControl"]);
11690
11719
 
11691
- var _m = React.useState(value),
11692
- scrollValue = _m[0],
11693
- setScrollValue = _m[1];
11694
-
11720
+ var scrollValueRef = useLatestRef(value);
11695
11721
  var domRef = React.useRef(null);
11696
11722
  var pickerViewRef = React.useRef(null);
11697
11723
  React.useImperativeHandle(ref, function () {
@@ -11742,7 +11768,7 @@
11742
11768
  nextTick(function () {
11743
11769
  var _a;
11744
11770
 
11745
- var val = ((_a = pickerViewRef.current) === null || _a === void 0 ? void 0 : _a.getAllColumnValues()) || scrollValue || [];
11771
+ var val = ((_a = pickerViewRef.current) === null || _a === void 0 ? void 0 : _a.getAllColumnValues()) || scrollValueRef.current || [];
11746
11772
 
11747
11773
  if (onOk) {
11748
11774
  onOk(val);
@@ -11758,9 +11784,6 @@
11758
11784
  });
11759
11785
  };
11760
11786
 
11761
- React.useEffect(function () {
11762
- setScrollValue(value);
11763
- }, [value, setScrollValue]);
11764
11787
  useListenResize(updateLayoutByVisible, [visible]); // 每次visible从false变为true时需要重新设置scrollValue的值为当前value的值(初始值)
11765
11788
 
11766
11789
  function updateLayoutByVisible() {
@@ -17333,7 +17356,7 @@
17333
17356
  var index$h = componentWrapper(ImagePicker, 'ImagePicker');
17334
17357
 
17335
17358
  /*!
17336
- * @arco-design/transformable v1.0.2
17359
+ * @arco-design/transformable v1.0.1
17337
17360
  * (c) 2022 ludan.kibbon
17338
17361
  */
17339
17362
  function _defineProperty(obj, key, value) {