@arco-design/mobile-react 2.28.0 → 2.28.2

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.
package/dist/index.js CHANGED
@@ -132,7 +132,7 @@
132
132
  function isEmptyArray(obj) {
133
133
  return isArray(obj) && !(obj === null || obj === void 0 ? void 0 : obj.length);
134
134
  }
135
- var isDeepEqual = function isDeepEqual(obj, sub) {
135
+ function isDeepEqual(obj, sub) {
136
136
  if (typeof obj !== 'object' || typeof sub !== 'object' || obj === null || sub === null) {
137
137
  return obj === sub;
138
138
  }
@@ -150,7 +150,7 @@
150
150
  }
151
151
 
152
152
  return true;
153
- };
153
+ }
154
154
 
155
155
  function cls () {
156
156
  var args = [];
@@ -367,7 +367,7 @@
367
367
  * @param childrenEl 子节点
368
368
  */
369
369
 
370
- var isContains = function isContains(parentEl, childrenEl) {
370
+ function isContains(parentEl, childrenEl) {
371
371
  if (!parentEl || !childrenEl) return false;
372
372
 
373
373
  if (parentEl.contains) {
@@ -385,7 +385,7 @@
385
385
  }
386
386
 
387
387
  return false;
388
- };
388
+ }
389
389
  function execRAF(fn) {
390
390
  try {
391
391
  return requestAnimationFrame(fn);
@@ -3142,6 +3142,12 @@
3142
3142
  * @desc {en} Tips: Use in scenarios where asynchronous processing is not completed after unmount. It is not recommended to replace useState without brains
3143
3143
  * @param initialState 初始状态
3144
3144
  * @param initialState {en} Initial State
3145
+ * @example
3146
+ * ```
3147
+ * import { useMountedState } from '@arco-design/mobile-react/esm/_helpers/hooks';
3148
+ *
3149
+ * const [scrollValue, setScrollValue] = useMountedState(value);
3150
+ * ```
3145
3151
  */
3146
3152
 
3147
3153
  function useMountedState(initialState) {
@@ -3535,7 +3541,7 @@
3535
3541
  };
3536
3542
  }, [visible]);
3537
3543
  }
3538
- var useProgress = function useProgress(mountedTransition, percentage, duration, mountedBezier, step) {
3544
+ function useProgress(mountedTransition, percentage, duration, mountedBezier, step) {
3539
3545
  var _a = React.useState(0),
3540
3546
  currentPercentage = _a[0],
3541
3547
  setCurrentPercentage = _a[1];
@@ -3569,7 +3575,7 @@
3569
3575
  percentage === 100 ? setCurrentPercentage(100) : setCurrentPercentage(count * step);
3570
3576
  }, [count, percentage, step]);
3571
3577
  return [currentPercentage, transitionControl];
3572
- };
3578
+ }
3573
3579
  function useSingleAndDoubleClick(onClick, onDoubleClick, delay) {
3574
3580
  if (delay === void 0) {
3575
3581
  delay = 200;
@@ -5468,9 +5474,15 @@
5468
5474
  }
5469
5475
 
5470
5476
  function updateLayout() {
5477
+ var _a, _b;
5478
+
5479
+ var _c = getOffset(domRef.current),
5480
+ width = _c.width,
5481
+ height = _c.height;
5482
+
5471
5483
  cellRef.current && cellRef.current.resetUnderlineStyle();
5472
- setWrapWidth(domRef.current ? domRef.current.offsetWidth : 0);
5473
- setWrapHeight(domRef.current ? domRef.current.offsetHeight : 0);
5484
+ setWrapWidth(width || ((_a = domRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0);
5485
+ setWrapHeight(height || ((_b = domRef.current) === null || _b === void 0 ? void 0 : _b.offsetHeight) || 0);
5474
5486
  paneRef.current && paneRef.current.setCurrentHeight();
5475
5487
  }
5476
5488
 
@@ -10964,6 +10976,7 @@
10964
10976
  var rowCount = Math.max(rows % 2 === 0 ? rows + 1 : rows, 3);
10965
10977
  var isTouchMoveRef = React.useRef(false);
10966
10978
  var isTouchStopped = React.useRef(false);
10979
+ var unmountCallbackRef = React.useRef();
10967
10980
  var timeRef = React.useRef(null);
10968
10981
  var colStyle = React.useMemo(function () {
10969
10982
  return getStyleWithVendor(__assign$2(__assign$2({
@@ -11005,20 +11018,24 @@
11005
11018
  }
11006
11019
 
11007
11020
  setTransitionDuration(transDuration ? transDuration + "ms" : '');
11008
- setTransformY(transY); // 处理连续滑动的情况:
11009
- // @en handle the case of continuous sliding:
11010
- // 如果上一次callback还未执行,先cancel掉上一次回调,只执行最近的一次回调
11011
- // @en If the last callback has not been executed, cancel the last callback first, and only execute the latest callback
11021
+ setTransformY(transY); // 处理连续滑动的情况:如果上一次callback还未执行,先cancel掉上一次回调
11022
+ // @en handle the case of continuous sliding: If the last callback has not been executed, cancel the last callback first
11012
11023
 
11013
11024
  if (latestCallbackTimer.current) {
11014
11025
  clearTimeout(latestCallbackTimer.current);
11015
11026
  }
11016
11027
 
11017
- latestCallbackTimer.current = window.setTimeout(function () {
11028
+ var setNormalStatus = function setNormalStatus() {
11029
+ // 如果timer顺利执行,则在unmount时不再重复执行
11030
+ // @en If the timer is successfully executed, it will not be repeated when unmounting
11031
+ unmountCallbackRef.current = undefined;
11018
11032
  movingStatusRef.current = 'normal';
11019
11033
  setTransitionDuration('');
11020
11034
  callback();
11021
- }, transDuration);
11035
+ };
11036
+
11037
+ unmountCallbackRef.current = setNormalStatus;
11038
+ latestCallbackTimer.current = window.setTimeout(setNormalStatus, transDuration);
11022
11039
  }
11023
11040
 
11024
11041
  function _scrollToIndex(itemIndex, transDuration, callback) {
@@ -11216,6 +11233,17 @@
11216
11233
  _scrollToIndexWithChange(itemIndex, 200);
11217
11234
  }
11218
11235
 
11236
+ React.useEffect(function () {
11237
+ return function () {
11238
+ var _a; // 卸载组件时,如果timer中还有未执行的onchange操作,则立刻执行该操作并移除timer
11239
+ // @en When unloading the component, if there is an unexecuted onchange operation in the timer, execute it immediately and remove the timer
11240
+
11241
+
11242
+ var timerId = latestCallbackTimer.current;
11243
+ (_a = unmountCallbackRef.current) === null || _a === void 0 ? void 0 : _a.call(unmountCallbackRef);
11244
+ timerId && clearTimeout(timerId);
11245
+ };
11246
+ }, []);
11219
11247
  React.useEffect(function () {
11220
11248
  if (wrapRef.current) {
11221
11249
  wrapRef.current.addEventListener('touchstart', _handleColumnTouchStart);
@@ -14891,6 +14919,87 @@
14891
14919
  _this._errors = [];
14892
14920
  _this._touched = false;
14893
14921
 
14922
+ _this.onValueChange = function (preStore, curStore) {
14923
+ _this._touched = true;
14924
+ var shouldUpdate = _this.props.shouldUpdate;
14925
+
14926
+ if (typeof shouldUpdate === 'function') {
14927
+ shouldUpdate({
14928
+ preStore: preStore,
14929
+ curStore: curStore
14930
+ }) && _this.forceUpdate();
14931
+ return;
14932
+ }
14933
+
14934
+ _this.forceUpdate();
14935
+ };
14936
+
14937
+ _this.getFieldError = function () {
14938
+ return _this._errors;
14939
+ };
14940
+
14941
+ _this.isFieldTouched = function () {
14942
+ return _this._touched;
14943
+ };
14944
+
14945
+ _this.validateField = function () {
14946
+ var _a;
14947
+
14948
+ var validateMessages = _this.context.validateMessages;
14949
+ var getFieldValue = _this.context.form.getFieldValue;
14950
+ var _b = _this.props,
14951
+ field = _b.field,
14952
+ rules = _b.rules,
14953
+ onValidateStatusChange = _b.onValidateStatusChange;
14954
+ var value = getFieldValue(field);
14955
+
14956
+ if ((rules === null || rules === void 0 ? void 0 : rules.length) && field) {
14957
+ var fieldDom_1 = _this.props.getFormItemRef();
14958
+
14959
+ var fieldValidator_1 = new Validator((_a = {}, _a[field] = rules, _a), {
14960
+ validateMessages: validateMessages
14961
+ });
14962
+ return new Promise(function (resolve) {
14963
+ var _a;
14964
+
14965
+ fieldValidator_1.validate((_a = {}, _a[field] = value, _a), function (errorsMap) {
14966
+ var _a = getErrorAndWarnings((errorsMap === null || errorsMap === void 0 ? void 0 : errorsMap[field]) || []),
14967
+ errors = _a.errors,
14968
+ warnings = _a.warnings;
14969
+
14970
+ _this._errors = errors;
14971
+ onValidateStatusChange({
14972
+ errors: _this._errors,
14973
+ warnings: warnings
14974
+ });
14975
+ return resolve({
14976
+ errors: _this._errors,
14977
+ warnings: warnings,
14978
+ value: value,
14979
+ field: field,
14980
+ dom: fieldDom_1
14981
+ });
14982
+ });
14983
+ });
14984
+ }
14985
+
14986
+ return Promise.resolve({
14987
+ errors: [],
14988
+ warnings: [],
14989
+ value: value,
14990
+ field: field,
14991
+ dom: null
14992
+ });
14993
+ };
14994
+
14995
+ _this.setFieldData = function (value) {
14996
+ var field = _this.props.field;
14997
+ var setFieldValue = _this.context.form.setFieldValue;
14998
+ setFieldValue(field, value);
14999
+
15000
+ _this.validateField();
15001
+ };
15002
+
14894
15003
  _this.innerTriggerFunction = function (_, value) {
14895
15004
  var _a, _b;
14896
15005
 
@@ -14933,6 +15042,24 @@
14933
15042
  }
14934
15043
  };
14935
15044
 
15045
+ _this.innerClearFunction = function () {
15046
+ var _a, _b;
15047
+
15048
+ var args = [];
15049
+
15050
+ for (var _i = 0; _i < arguments.length; _i++) {
15051
+ args[_i] = arguments[_i];
15052
+ }
15053
+
15054
+ var children = _this.props.children;
15055
+
15056
+ _this.setFieldData('');
15057
+
15058
+ if ((_a = children.props) === null || _a === void 0 ? void 0 : _a.onClear) {
15059
+ (_b = children.props) === null || _b === void 0 ? void 0 : _b.onClear.apply(_b, args);
15060
+ }
15061
+ };
15062
+
14936
15063
  _this.destroyField = function () {};
14937
15064
 
14938
15065
  if ((props === null || props === void 0 ? void 0 : props.initialValue) && props.field) {
@@ -14952,104 +15079,6 @@
14952
15079
  this.destroyField();
14953
15080
  };
14954
15081
 
14955
- FormItemInner.prototype.onValueChange = function (preStore, curStore) {
14956
- this._touched = true;
14957
- var shouldUpdate = this.props.shouldUpdate;
14958
-
14959
- if (typeof shouldUpdate === 'function') {
14960
- shouldUpdate({
14961
- preStore: preStore,
14962
- curStore: curStore
14963
- }) && this.forceUpdate();
14964
- return;
14965
- }
14966
-
14967
- this.forceUpdate();
14968
- };
14969
-
14970
- FormItemInner.prototype.getFieldError = function () {
14971
- return this._errors;
14972
- };
14973
-
14974
- FormItemInner.prototype.isFieldTouched = function () {
14975
- return this._touched;
14976
- };
14977
-
14978
- FormItemInner.prototype.validateField = function () {
14979
- var _a;
14980
-
14981
- var _this = this;
14982
-
14983
- var validateMessages = this.context.validateMessages;
14984
- var getFieldValue = this.context.form.getFieldValue;
14985
- var _b = this.props,
14986
- field = _b.field,
14987
- rules = _b.rules,
14988
- onValidateStatusChange = _b.onValidateStatusChange;
14989
- var value = getFieldValue(field);
14990
-
14991
- if ((rules === null || rules === void 0 ? void 0 : rules.length) && field) {
14992
- var fieldDom_1 = this.props.getFormItemRef();
14993
- var fieldValidator_1 = new Validator((_a = {}, _a[field] = rules, _a), {
14994
- validateMessages: validateMessages
14995
- });
14996
- return new Promise(function (resolve) {
14997
- var _a;
14998
-
14999
- fieldValidator_1.validate((_a = {}, _a[field] = value, _a), function (errorsMap) {
15000
- var _a = getErrorAndWarnings((errorsMap === null || errorsMap === void 0 ? void 0 : errorsMap[field]) || []),
15001
- errors = _a.errors,
15002
- warnings = _a.warnings;
15003
-
15004
- _this._errors = errors;
15005
- onValidateStatusChange({
15006
- errors: _this._errors,
15007
- warnings: warnings
15008
- });
15009
- return resolve({
15010
- errors: _this._errors,
15011
- warnings: warnings,
15012
- value: value,
15013
- field: field,
15014
- dom: fieldDom_1
15015
- });
15016
- });
15017
- });
15018
- }
15019
-
15020
- return Promise.resolve({
15021
- errors: [],
15022
- warnings: [],
15023
- value: value,
15024
- field: field,
15025
- dom: null
15026
- });
15027
- };
15028
-
15029
- FormItemInner.prototype.setFieldData = function (value) {
15030
- var field = this.props.field;
15031
- var setFieldValue = this.context.form.setFieldValue;
15032
- setFieldValue(field, value);
15033
- this.validateField();
15034
- };
15035
-
15036
- FormItemInner.prototype.innerClearFunction = function () {
15037
- var _a, _b;
15038
-
15039
- var args = [];
15040
-
15041
- for (var _i = 0; _i < arguments.length; _i++) {
15042
- args[_i] = arguments[_i];
15043
- }
15044
-
15045
- var children = this.props.children;
15046
- this.setFieldData('');
15047
-
15048
- if ((_a = children.props) === null || _a === void 0 ? void 0 : _a.onClear) {
15049
- (_b = children.props) === null || _b === void 0 ? void 0 : _b.onClear.apply(_b, args);
15050
- }
15051
- };
15052
-
15053
15082
  FormItemInner.prototype.renderChildren = function () {
15054
15083
  var _a;
15055
15084
 
@@ -17287,7 +17316,7 @@
17287
17316
  var index$g = componentWrapper(ImagePicker, 'ImagePicker');
17288
17317
 
17289
17318
  /*!
17290
- * @arco-design/transformable v1.0.1
17319
+ * @arco-design/transformable v1.0.2
17291
17320
  * (c) 2022 ludan.kibbon
17292
17321
  */
17293
17322
  function _defineProperty(obj, key, value) {