@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/CHANGELOG.md +25 -0
- package/README.en-US.md +2 -2
- package/README.md +2 -2
- package/cjs/_helpers/hooks.d.ts +7 -1
- package/cjs/_helpers/hooks.js +9 -5
- package/cjs/avatar/type.d.ts +1 -1
- package/cjs/form/form-item.js +109 -108
- package/cjs/nav-bar/index.d.ts +3 -3
- package/cjs/picker-view/components/picker-cell.js +20 -6
- package/cjs/tabs/index.js +8 -2
- package/dist/index.js +142 -113
- package/dist/index.min.js +3 -3
- package/esm/_helpers/hooks.d.ts +7 -1
- package/esm/_helpers/hooks.js +8 -2
- package/esm/avatar/type.d.ts +1 -1
- package/esm/form/form-item.js +109 -108
- package/esm/nav-bar/index.d.ts +3 -3
- package/esm/picker-view/components/picker-cell.js +20 -6
- package/esm/tabs/index.js +9 -3
- package/package.json +17 -3
- package/umd/_helpers/hooks.d.ts +7 -1
- package/umd/_helpers/hooks.js +9 -5
- package/umd/avatar/type.d.ts +1 -1
- package/umd/form/form-item.js +109 -108
- package/umd/nav-bar/index.d.ts +3 -3
- package/umd/picker-view/components/picker-cell.js +20 -6
- package/umd/tabs/index.js +8 -2
package/umd/form/form-item.js
CHANGED
@@ -40,15 +40,96 @@
|
|
40
40
|
_this._errors = [];
|
41
41
|
_this._touched = false;
|
42
42
|
|
43
|
+
_this.onValueChange = function (preStore, curStore) {
|
44
|
+
_this._touched = true;
|
45
|
+
var shouldUpdate = _this.props.shouldUpdate;
|
46
|
+
|
47
|
+
if (typeof shouldUpdate === 'function') {
|
48
|
+
shouldUpdate({
|
49
|
+
preStore: preStore,
|
50
|
+
curStore: curStore
|
51
|
+
}) && _this.forceUpdate();
|
52
|
+
return;
|
53
|
+
}
|
54
|
+
|
55
|
+
_this.forceUpdate();
|
56
|
+
};
|
57
|
+
|
58
|
+
_this.getFieldError = function () {
|
59
|
+
return _this._errors;
|
60
|
+
};
|
61
|
+
|
62
|
+
_this.isFieldTouched = function () {
|
63
|
+
return _this._touched;
|
64
|
+
};
|
65
|
+
|
66
|
+
_this.validateField = function () {
|
67
|
+
var validateMessages = _this.context.validateMessages;
|
68
|
+
var getFieldValue = _this.context.form.getFieldValue;
|
69
|
+
var _this$props = _this.props,
|
70
|
+
field = _this$props.field,
|
71
|
+
rules = _this$props.rules,
|
72
|
+
onValidateStatusChange = _this$props.onValidateStatusChange;
|
73
|
+
var value = getFieldValue(field);
|
74
|
+
|
75
|
+
if (rules != null && rules.length && field) {
|
76
|
+
var _Validator;
|
77
|
+
|
78
|
+
var fieldDom = _this.props.getFormItemRef();
|
79
|
+
|
80
|
+
var fieldValidator = new _mobileUtils.Validator((_Validator = {}, _Validator[field] = rules, _Validator), {
|
81
|
+
validateMessages: validateMessages
|
82
|
+
});
|
83
|
+
return new Promise(function (resolve) {
|
84
|
+
var _fieldValidator$valid;
|
85
|
+
|
86
|
+
fieldValidator.validate((_fieldValidator$valid = {}, _fieldValidator$valid[field] = value, _fieldValidator$valid), function (errorsMap) {
|
87
|
+
var _getErrorAndWarnings = (0, _utils.getErrorAndWarnings)((errorsMap == null ? void 0 : errorsMap[field]) || []),
|
88
|
+
errors = _getErrorAndWarnings.errors,
|
89
|
+
warnings = _getErrorAndWarnings.warnings;
|
90
|
+
|
91
|
+
_this._errors = errors;
|
92
|
+
onValidateStatusChange({
|
93
|
+
errors: _this._errors,
|
94
|
+
warnings: warnings
|
95
|
+
});
|
96
|
+
return resolve({
|
97
|
+
errors: _this._errors,
|
98
|
+
warnings: warnings,
|
99
|
+
value: value,
|
100
|
+
field: field,
|
101
|
+
dom: fieldDom
|
102
|
+
});
|
103
|
+
});
|
104
|
+
});
|
105
|
+
}
|
106
|
+
|
107
|
+
return Promise.resolve({
|
108
|
+
errors: [],
|
109
|
+
warnings: [],
|
110
|
+
value: value,
|
111
|
+
field: field,
|
112
|
+
dom: null
|
113
|
+
});
|
114
|
+
};
|
115
|
+
|
116
|
+
_this.setFieldData = function (value) {
|
117
|
+
var field = _this.props.field;
|
118
|
+
var setFieldValue = _this.context.form.setFieldValue;
|
119
|
+
setFieldValue(field, value);
|
120
|
+
|
121
|
+
_this.validateField();
|
122
|
+
};
|
123
|
+
|
43
124
|
_this.innerTriggerFunction = function (_, value) {
|
44
125
|
var _children$props;
|
45
126
|
|
46
127
|
_this.setFieldData(value);
|
47
128
|
|
48
|
-
var _this$
|
49
|
-
children = _this$
|
50
|
-
_this$
|
51
|
-
trigger = _this$
|
129
|
+
var _this$props2 = _this.props,
|
130
|
+
children = _this$props2.children,
|
131
|
+
_this$props2$trigger = _this$props2.trigger,
|
132
|
+
trigger = _this$props2$trigger === void 0 ? 'onChange' : _this$props2$trigger;
|
52
133
|
|
53
134
|
if (trigger && (_children$props = children.props) != null && _children$props[trigger]) {
|
54
135
|
var _children$props2;
|
@@ -66,10 +147,10 @@
|
|
66
147
|
|
67
148
|
_this.setFieldData(value);
|
68
149
|
|
69
|
-
var _this$
|
70
|
-
children = _this$
|
71
|
-
_this$
|
72
|
-
trigger = _this$
|
150
|
+
var _this$props3 = _this.props,
|
151
|
+
children = _this$props3.children,
|
152
|
+
_this$props3$trigger = _this$props3.trigger,
|
153
|
+
trigger = _this$props3$trigger === void 0 ? 'onChange' : _this$props3$trigger;
|
73
154
|
|
74
155
|
if (trigger && (_children$props3 = children.props) != null && _children$props3[trigger]) {
|
75
156
|
var _children$props4;
|
@@ -82,6 +163,24 @@
|
|
82
163
|
}
|
83
164
|
};
|
84
165
|
|
166
|
+
_this.innerClearFunction = function () {
|
167
|
+
var _children$props5;
|
168
|
+
|
169
|
+
var children = _this.props.children;
|
170
|
+
|
171
|
+
_this.setFieldData('');
|
172
|
+
|
173
|
+
if ((_children$props5 = children.props) != null && _children$props5.onClear) {
|
174
|
+
var _children$props6;
|
175
|
+
|
176
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
177
|
+
args[_key3] = arguments[_key3];
|
178
|
+
}
|
179
|
+
|
180
|
+
(_children$props6 = children.props) == null ? void 0 : _children$props6.onClear.apply(_children$props6, args);
|
181
|
+
}
|
182
|
+
};
|
183
|
+
|
85
184
|
_this.destroyField = function () {};
|
86
185
|
|
87
186
|
if (props != null && props.initialValue && props.field) {
|
@@ -109,108 +208,10 @@
|
|
109
208
|
this.destroyField();
|
110
209
|
};
|
111
210
|
|
112
|
-
_proto.onValueChange = function onValueChange(preStore, curStore) {
|
113
|
-
this._touched = true;
|
114
|
-
var shouldUpdate = this.props.shouldUpdate;
|
115
|
-
|
116
|
-
if (typeof shouldUpdate === 'function') {
|
117
|
-
shouldUpdate({
|
118
|
-
preStore: preStore,
|
119
|
-
curStore: curStore
|
120
|
-
}) && this.forceUpdate();
|
121
|
-
return;
|
122
|
-
}
|
123
|
-
|
124
|
-
this.forceUpdate();
|
125
|
-
};
|
126
|
-
|
127
|
-
_proto.getFieldError = function getFieldError() {
|
128
|
-
return this._errors;
|
129
|
-
};
|
130
|
-
|
131
|
-
_proto.isFieldTouched = function isFieldTouched() {
|
132
|
-
return this._touched;
|
133
|
-
};
|
134
|
-
|
135
|
-
_proto.validateField = function validateField() {
|
136
|
-
var _this2 = this;
|
137
|
-
|
138
|
-
var validateMessages = this.context.validateMessages;
|
139
|
-
var getFieldValue = this.context.form.getFieldValue;
|
140
|
-
var _this$props3 = this.props,
|
141
|
-
field = _this$props3.field,
|
142
|
-
rules = _this$props3.rules,
|
143
|
-
onValidateStatusChange = _this$props3.onValidateStatusChange;
|
144
|
-
var value = getFieldValue(field);
|
145
|
-
|
146
|
-
if (rules != null && rules.length && field) {
|
147
|
-
var _Validator;
|
148
|
-
|
149
|
-
var fieldDom = this.props.getFormItemRef();
|
150
|
-
var fieldValidator = new _mobileUtils.Validator((_Validator = {}, _Validator[field] = rules, _Validator), {
|
151
|
-
validateMessages: validateMessages
|
152
|
-
});
|
153
|
-
return new Promise(function (resolve) {
|
154
|
-
var _fieldValidator$valid;
|
155
|
-
|
156
|
-
fieldValidator.validate((_fieldValidator$valid = {}, _fieldValidator$valid[field] = value, _fieldValidator$valid), function (errorsMap) {
|
157
|
-
var _getErrorAndWarnings = (0, _utils.getErrorAndWarnings)((errorsMap == null ? void 0 : errorsMap[field]) || []),
|
158
|
-
errors = _getErrorAndWarnings.errors,
|
159
|
-
warnings = _getErrorAndWarnings.warnings;
|
160
|
-
|
161
|
-
_this2._errors = errors;
|
162
|
-
onValidateStatusChange({
|
163
|
-
errors: _this2._errors,
|
164
|
-
warnings: warnings
|
165
|
-
});
|
166
|
-
return resolve({
|
167
|
-
errors: _this2._errors,
|
168
|
-
warnings: warnings,
|
169
|
-
value: value,
|
170
|
-
field: field,
|
171
|
-
dom: fieldDom
|
172
|
-
});
|
173
|
-
});
|
174
|
-
});
|
175
|
-
}
|
176
|
-
|
177
|
-
return Promise.resolve({
|
178
|
-
errors: [],
|
179
|
-
warnings: [],
|
180
|
-
value: value,
|
181
|
-
field: field,
|
182
|
-
dom: null
|
183
|
-
});
|
184
|
-
};
|
185
|
-
|
186
|
-
_proto.setFieldData = function setFieldData(value) {
|
187
|
-
var field = this.props.field;
|
188
|
-
var setFieldValue = this.context.form.setFieldValue;
|
189
|
-
setFieldValue(field, value);
|
190
|
-
this.validateField();
|
191
|
-
};
|
192
|
-
|
193
|
-
_proto.innerClearFunction = function innerClearFunction() {
|
194
|
-
var _children$props5;
|
195
|
-
|
196
|
-
var children = this.props.children;
|
197
|
-
this.setFieldData('');
|
198
|
-
|
199
|
-
if ((_children$props5 = children.props) != null && _children$props5.onClear) {
|
200
|
-
var _children$props6;
|
201
|
-
|
202
|
-
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
203
|
-
args[_key3] = arguments[_key3];
|
204
|
-
}
|
205
|
-
|
206
|
-
(_children$props6 = children.props) == null ? void 0 : _children$props6.onClear.apply(_children$props6, args);
|
207
|
-
}
|
208
|
-
};
|
209
|
-
|
210
211
|
_proto.renderChildren = function renderChildren() {
|
211
212
|
var _props,
|
212
213
|
_children$type,
|
213
|
-
|
214
|
+
_this2 = this;
|
214
215
|
|
215
216
|
var _this$props4 = this.props,
|
216
217
|
children = _this$props4.children,
|
@@ -285,7 +286,7 @@
|
|
285
286
|
props.error = this._errors;
|
286
287
|
|
287
288
|
props[trigger] = function (newValue) {
|
288
|
-
|
289
|
+
_this2.setFieldData(newValue);
|
289
290
|
|
290
291
|
for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
291
292
|
args[_key4 - 1] = arguments[_key4];
|
package/umd/nav-bar/index.d.ts
CHANGED
@@ -32,13 +32,13 @@ export interface NavBarProps {
|
|
32
32
|
*/
|
33
33
|
rightContent?: React.ReactNode;
|
34
34
|
/**
|
35
|
-
*
|
35
|
+
* 自定义样式,最外层元素的背景文字颜色可在此定义
|
36
36
|
* @en Custom stylesheet, background and text colors can be defined here
|
37
37
|
*/
|
38
38
|
style?: React.CSSProperties;
|
39
39
|
/**
|
40
|
-
*
|
41
|
-
* @en
|
40
|
+
* 内层自定义类名
|
41
|
+
* @en Inner custom classname
|
42
42
|
*/
|
43
43
|
className?: string;
|
44
44
|
/**
|
@@ -75,6 +75,7 @@
|
|
75
75
|
var rowCount = Math.max(rows % 2 === 0 ? rows + 1 : rows, 3);
|
76
76
|
var isTouchMoveRef = (0, _react.useRef)(false);
|
77
77
|
var isTouchStopped = (0, _react.useRef)(false);
|
78
|
+
var unmountCallbackRef = (0, _react.useRef)();
|
78
79
|
var timeRef = (0, _react.useRef)(null);
|
79
80
|
var colStyle = (0, _react.useMemo)(function () {
|
80
81
|
return (0, _helpers.getStyleWithVendor)((0, _extends2.default)({
|
@@ -116,20 +117,24 @@
|
|
116
117
|
}
|
117
118
|
|
118
119
|
setTransitionDuration(transDuration ? transDuration + "ms" : '');
|
119
|
-
setTransformY(transY); //
|
120
|
-
// @en handle the case of continuous sliding:
|
121
|
-
// 如果上一次callback还未执行,先cancel掉上一次回调,只执行最近的一次回调
|
122
|
-
// @en If the last callback has not been executed, cancel the last callback first, and only execute the latest callback
|
120
|
+
setTransformY(transY); // 处理连续滑动的情况:如果上一次callback还未执行,先cancel掉上一次回调
|
121
|
+
// @en handle the case of continuous sliding: If the last callback has not been executed, cancel the last callback first
|
123
122
|
|
124
123
|
if (latestCallbackTimer.current) {
|
125
124
|
clearTimeout(latestCallbackTimer.current);
|
126
125
|
}
|
127
126
|
|
128
|
-
|
127
|
+
var setNormalStatus = function setNormalStatus() {
|
128
|
+
// 如果timer顺利执行,则在unmount时不再重复执行
|
129
|
+
// @en If the timer is successfully executed, it will not be repeated when unmounting
|
130
|
+
unmountCallbackRef.current = undefined;
|
129
131
|
movingStatusRef.current = 'normal';
|
130
132
|
setTransitionDuration('');
|
131
133
|
callback();
|
132
|
-
}
|
134
|
+
};
|
135
|
+
|
136
|
+
unmountCallbackRef.current = setNormalStatus;
|
137
|
+
latestCallbackTimer.current = window.setTimeout(setNormalStatus, transDuration);
|
133
138
|
}
|
134
139
|
|
135
140
|
function _scrollToIndex(itemIndex, transDuration, callback) {
|
@@ -327,6 +332,15 @@
|
|
327
332
|
_scrollToIndexWithChange(itemIndex, 200);
|
328
333
|
}
|
329
334
|
|
335
|
+
(0, _react.useEffect)(function () {
|
336
|
+
return function () {
|
337
|
+
// 卸载组件时,如果timer中还有未执行的onchange操作,则立刻执行该操作并移除timer
|
338
|
+
// @en When unloading the component, if there is an unexecuted onchange operation in the timer, execute it immediately and remove the timer
|
339
|
+
var timerId = latestCallbackTimer.current;
|
340
|
+
unmountCallbackRef.current == null ? void 0 : unmountCallbackRef.current();
|
341
|
+
timerId && clearTimeout(timerId);
|
342
|
+
};
|
343
|
+
}, []);
|
330
344
|
(0, _react.useEffect)(function () {
|
331
345
|
if (wrapRef.current) {
|
332
346
|
wrapRef.current.addEventListener('touchstart', _handleColumnTouchStart);
|
package/umd/tabs/index.js
CHANGED
@@ -427,9 +427,15 @@
|
|
427
427
|
}
|
428
428
|
|
429
429
|
function updateLayout() {
|
430
|
+
var _domRef$current, _domRef$current2;
|
431
|
+
|
432
|
+
var _getOffset = (0, _mobileUtils.getOffset)(domRef.current),
|
433
|
+
width = _getOffset.width,
|
434
|
+
height = _getOffset.height;
|
435
|
+
|
430
436
|
cellRef.current && cellRef.current.resetUnderlineStyle();
|
431
|
-
setWrapWidth(domRef.current ?
|
432
|
-
setWrapHeight(domRef.current ?
|
437
|
+
setWrapWidth(width || ((_domRef$current = domRef.current) == null ? void 0 : _domRef$current.offsetWidth) || 0);
|
438
|
+
setWrapHeight(height || ((_domRef$current2 = domRef.current) == null ? void 0 : _domRef$current2.offsetHeight) || 0);
|
433
439
|
paneRef.current && paneRef.current.setCurrentHeight();
|
434
440
|
}
|
435
441
|
|