@arco-design/mobile-react 2.36.1 → 2.36.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.
Files changed (76) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.en-US.md +2 -2
  3. package/README.md +2 -2
  4. package/cjs/carousel/index.js +8 -7
  5. package/cjs/form/form-item.d.ts +33 -2
  6. package/cjs/form/form-item.js +142 -121
  7. package/cjs/form/index.js +3 -1
  8. package/cjs/form/linked-container.d.ts +1 -1
  9. package/cjs/form/linked-container.js +4 -0
  10. package/cjs/form/style/css/index.css +4 -1
  11. package/cjs/form/style/index.less +6 -1
  12. package/cjs/form/type.d.ts +24 -1
  13. package/cjs/form/type.js +10 -2
  14. package/cjs/form/useForm.d.ts +2 -17
  15. package/cjs/form/useForm.js +98 -17
  16. package/cjs/form/utils.d.ts +2 -0
  17. package/cjs/form/utils.js +42 -2
  18. package/cjs/input/index.js +1 -1
  19. package/cjs/radio/group.js +1 -1
  20. package/cjs/radio/type.d.ts +2 -2
  21. package/dist/index.js +2993 -362
  22. package/dist/index.min.js +4 -4
  23. package/dist/style.css +4 -1
  24. package/dist/style.min.css +1 -1
  25. package/esm/carousel/index.js +8 -7
  26. package/esm/form/form-item.d.ts +33 -2
  27. package/esm/form/form-item.js +143 -122
  28. package/esm/form/index.js +3 -1
  29. package/esm/form/linked-container.d.ts +1 -1
  30. package/esm/form/linked-container.js +4 -0
  31. package/esm/form/style/css/index.css +4 -1
  32. package/esm/form/style/index.less +6 -1
  33. package/esm/form/type.d.ts +24 -1
  34. package/esm/form/type.js +8 -1
  35. package/esm/form/useForm.d.ts +2 -17
  36. package/esm/form/useForm.js +97 -17
  37. package/esm/form/utils.d.ts +2 -0
  38. package/esm/form/utils.js +31 -1
  39. package/esm/input/index.js +1 -1
  40. package/esm/radio/group.js +1 -1
  41. package/esm/radio/type.d.ts +2 -2
  42. package/esnext/carousel/index.js +7 -5
  43. package/esnext/form/form-item.d.ts +33 -2
  44. package/esnext/form/form-item.js +85 -71
  45. package/esnext/form/index.js +2 -1
  46. package/esnext/form/linked-container.d.ts +1 -1
  47. package/esnext/form/linked-container.js +3 -0
  48. package/esnext/form/style/css/index.css +4 -1
  49. package/esnext/form/style/index.less +6 -1
  50. package/esnext/form/type.d.ts +24 -1
  51. package/esnext/form/type.js +7 -0
  52. package/esnext/form/useForm.d.ts +2 -17
  53. package/esnext/form/useForm.js +72 -13
  54. package/esnext/form/utils.d.ts +2 -0
  55. package/esnext/form/utils.js +26 -0
  56. package/esnext/input/index.js +1 -1
  57. package/esnext/radio/group.js +3 -1
  58. package/esnext/radio/type.d.ts +2 -2
  59. package/package.json +3 -3
  60. package/umd/carousel/index.js +8 -7
  61. package/umd/form/form-item.d.ts +33 -2
  62. package/umd/form/form-item.js +142 -121
  63. package/umd/form/index.js +3 -1
  64. package/umd/form/linked-container.d.ts +1 -1
  65. package/umd/form/linked-container.js +4 -0
  66. package/umd/form/style/css/index.css +4 -1
  67. package/umd/form/style/index.less +6 -1
  68. package/umd/form/type.d.ts +24 -1
  69. package/umd/form/type.js +9 -1
  70. package/umd/form/useForm.d.ts +2 -17
  71. package/umd/form/useForm.js +98 -21
  72. package/umd/form/utils.d.ts +2 -0
  73. package/umd/form/utils.js +40 -5
  74. package/umd/input/index.js +1 -1
  75. package/umd/radio/group.js +1 -1
  76. package/umd/radio/type.d.ts +2 -2
package/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.36.2](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.36.1...@arco-design/mobile-react@2.36.2) (2025-06-06)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * `Carousel` swipping problem after setting "bounceWhenNoLoop" ([#326](https://github.com/arco-design/arco-design-mobile/issues/326)) ([8e5a788](https://github.com/arco-design/arco-design-mobile/commit/8e5a78858ba5398936ed5d6923753adfae46e1e7))
12
+ * `Form` add change & reset callback ([#325](https://github.com/arco-design/arco-design-mobile/issues/325)) ([16c2ffd](https://github.com/arco-design/arco-design-mobile/commit/16c2ffd9190cb38b1b8df9ca4087b1b0a90e67ff))
13
+
14
+
15
+
16
+
17
+
6
18
  ## [2.36.1](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.36.0...@arco-design/mobile-react@2.36.1) (2025-05-15)
7
19
 
8
20
 
package/README.en-US.md CHANGED
@@ -59,8 +59,8 @@ React & ReactDOM: **<a href="https://reactjs.org/docs/cdn-links.html" target="_b
59
59
  React Transition Group: **<a href="https://reactcommunity.org/react-transition-group/" target="_blank">Click here</a>**
60
60
 
61
61
  ```
62
- <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.36.0/dist/style.min.css">
63
- <script src="https://unpkg.com/@arco-design/mobile-react@2.36.0/dist/index.min.js"></script>
62
+ <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.36.1/dist/style.min.css">
63
+ <script src="https://unpkg.com/@arco-design/mobile-react@2.36.1/dist/index.min.js"></script>
64
64
  ```
65
65
 
66
66
  ## Full import
package/README.md CHANGED
@@ -59,8 +59,8 @@ React & ReactDOM: **<a href="https://reactjs.org/docs/cdn-links.html" target="
59
59
  React Transition Group: **<a href="https://reactcommunity.org/react-transition-group/" target="_blank">戳这里获取</a>**
60
60
 
61
61
  ```
62
- <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.36.0/dist/style.min.css">
63
- <script src="https://unpkg.com/@arco-design/mobile-react@2.36.0/dist/index.min.js"></script>
62
+ <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.36.1/dist/style.min.css">
63
+ <script src="https://unpkg.com/@arco-design/mobile-react@2.36.1/dist/index.min.js"></script>
64
64
  ```
65
65
 
66
66
  ## 引入全部
@@ -699,12 +699,6 @@ var Carousel = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
699
699
 
700
700
  stopPropagation && e.stopPropagation();
701
701
 
702
- if (bouncingRef.current) {
703
- bouncingRef.current = false;
704
- jumpTo(index, false);
705
- return;
706
- }
707
-
708
702
  if (!touchStartedRef.current) {
709
703
  return;
710
704
  }
@@ -716,7 +710,14 @@ var Carousel = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
716
710
  return;
717
711
  }
718
712
 
719
- touchMovedRef.current = false;
713
+ touchMovedRef.current = false; // bugfix: 回弹判断逻辑需在touchMovedRef标识重置逻辑之后,否则会在触发回弹后导致标识无法重置引起滑动判断问题
714
+ // @en bugfix: The logic for the bounce judgment needs to be after the touchMovedRef reset logic, otherwise it will cause the problem of slide judgment after the bounce is triggered.
715
+
716
+ if (bouncingRef.current) {
717
+ bouncingRef.current = false;
718
+ jumpTo(index, false);
719
+ return;
720
+ }
720
721
 
721
722
  if (posAdjustingRef.current || touchStoppedRef.current) {
722
723
  return;
@@ -1,4 +1,35 @@
1
- import React from 'react';
2
- import { FormItemProps, FormItemRef } from './type';
1
+ import React, { PureComponent, ReactNode } from 'react';
2
+ import { Promise } from 'es6-promise';
3
+ import { FormItemContext } from './form-item-context';
4
+ import { IFieldError, FieldValue, IFormItemInnerProps, FormItemProps, ValidateStatus, FormItemRef, ValueChangeType, IFormItemContext } from './type';
5
+ interface IFormItemInnerState {
6
+ validateStatus: ValidateStatus;
7
+ errors?: ReactNode[];
8
+ _touched: boolean;
9
+ }
10
+ declare class FormItemInner extends PureComponent<IFormItemInnerProps, IFormItemInnerState> {
11
+ context: React.ContextType<typeof FormItemContext>;
12
+ destroyField: () => void;
13
+ private _errors;
14
+ private _touched;
15
+ constructor(props: IFormItemInnerProps, context: IFormItemContext);
16
+ componentDidMount(): void;
17
+ componentWillUnmount(): void;
18
+ onValueChange: (curValue: FieldValue, preValue: any, info?: {
19
+ changeType: ValueChangeType;
20
+ } | undefined) => void;
21
+ getInitialValue: () => any;
22
+ getFieldError: () => React.ReactNode[];
23
+ isFieldTouched: () => boolean;
24
+ getAllRuleValidateTriggers: () => string[];
25
+ validateField: (validateTrigger?: string | undefined) => Promise<IFieldError>;
26
+ setFieldData: (value: FieldValue) => void;
27
+ innerTriggerFunctionWithValueFirst: (value: any, ...args: any[]) => void;
28
+ innerOnInputFunction: (_: any, value: any, ...args: any[]) => void;
29
+ innerClearFunction: (...args: any[]) => void;
30
+ renderChildren(): React.FunctionComponentElement<any>;
31
+ render(): React.FunctionComponentElement<any>;
32
+ }
33
+ export { FormItemInner };
3
34
  declare const _default: React.ForwardRefExoticComponent<FormItemProps & React.RefAttributes<FormItemRef>>;
4
35
  export default _default;
@@ -3,7 +3,7 @@
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
5
  exports.__esModule = true;
6
- exports.default = void 0;
6
+ exports.default = exports.FormItemInner = void 0;
7
7
 
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
 
@@ -46,7 +46,7 @@ var FormItemInner = /*#__PURE__*/function (_PureComponent) {
46
46
  _this._errors = [];
47
47
  _this._touched = false;
48
48
 
49
- _this.onValueChange = function (curValue, preValue) {
49
+ _this.onValueChange = function (curValue, preValue, info) {
50
50
  _this._touched = true;
51
51
  var shouldUpdate = _this.props.shouldUpdate;
52
52
 
@@ -58,9 +58,34 @@ var FormItemInner = /*#__PURE__*/function (_PureComponent) {
58
58
  return;
59
59
  }
60
60
 
61
+ if ((info == null ? void 0 : info.changeType) === _type.ValueChangeType.Reset) {
62
+ _this.props.onValidateStatusChange({
63
+ errors: [],
64
+ warnings: [],
65
+ errorTypes: []
66
+ });
67
+
68
+ _this._errors = [];
69
+ }
70
+
61
71
  _this.forceUpdate();
62
72
  };
63
73
 
74
+ _this.getInitialValue = function () {
75
+ var _children$type, _getInitialValue;
76
+
77
+ var _this$props = _this.props,
78
+ children = _this$props.children,
79
+ displayType = _this$props.displayType;
80
+
81
+ var _this$context$form$ge = _this.context.form.getInternalHooks(),
82
+ getInitialValue = _this$context$form$ge.getInitialValue;
83
+
84
+ var childrenType = displayType || ((_children$type = children.type) == null ? void 0 : _children$type.displayName); // get user-defined initialValue or if not defined
85
+
86
+ return (_getInitialValue = getInitialValue(_this.props.field)) != null ? _getInitialValue : (0, _utils.getDefaultValueForInterComponent)(childrenType);
87
+ };
88
+
64
89
  _this.getFieldError = function () {
65
90
  return _this._errors;
66
91
  };
@@ -69,21 +94,37 @@ var FormItemInner = /*#__PURE__*/function (_PureComponent) {
69
94
  return _this._touched;
70
95
  };
71
96
 
72
- _this.validateField = function () {
97
+ _this.getAllRuleValidateTriggers = function () {
98
+ var _this$props$rules;
99
+
100
+ return ((_this$props$rules = _this.props.rules) == null ? void 0 : _this$props$rules.map(function (rule) {
101
+ return rule.validateTrigger;
102
+ }).flat().filter(function (v) {
103
+ return !!v;
104
+ })) || [];
105
+ };
106
+
107
+ _this.validateField = function (validateTrigger) {
73
108
  var validateMessages = _this.context.validateMessages;
74
109
  var getFieldValue = _this.context.form.getFieldValue;
75
- var _this$props = _this.props,
76
- field = _this$props.field,
77
- rules = _this$props.rules,
78
- onValidateStatusChange = _this$props.onValidateStatusChange;
79
- var value = getFieldValue(field);
80
-
81
- if (rules != null && rules.length && field) {
110
+ var _this$props2 = _this.props,
111
+ field = _this$props2.field,
112
+ rules = _this$props2.rules,
113
+ onValidateStatusChange = _this$props2.onValidateStatusChange;
114
+ var value = getFieldValue(field); // rules: if validateTrigger is not defined, all rules will be validated
115
+ // if validateTrigger is defined, only rules with validateTrigger or without rule.validateTrigger will be validated
116
+
117
+ var curRules = validateTrigger ? rules == null ? void 0 : rules.filter(function (rule) {
118
+ var triggerList = [].concat(rule.validateTrigger || validateTrigger);
119
+ return triggerList.includes(validateTrigger);
120
+ }) : rules;
121
+
122
+ if (curRules != null && curRules.length && field) {
82
123
  var _Validator;
83
124
 
84
125
  var fieldDom = _this.props.getFormItemRef();
85
126
 
86
- var fieldValidator = new _mobileUtils.Validator((_Validator = {}, _Validator[field] = rules, _Validator), {
127
+ var fieldValidator = new _mobileUtils.Validator((_Validator = {}, _Validator[field] = curRules, _Validator), {
87
128
  validateMessages: validateMessages
88
129
  });
89
130
  return new _es6Promise.Promise(function (resolve) {
@@ -122,82 +163,79 @@ var FormItemInner = /*#__PURE__*/function (_PureComponent) {
122
163
  };
123
164
 
124
165
  _this.setFieldData = function (value) {
125
- var field = _this.props.field;
126
- var setFieldValue = _this.context.form.setFieldValue;
127
- setFieldValue(field, value);
166
+ var _this$props3 = _this.props,
167
+ field = _this$props3.field,
168
+ _this$props3$trigger = _this$props3.trigger,
169
+ trigger = _this$props3$trigger === void 0 ? 'onChange' : _this$props3$trigger;
170
+
171
+ var _this$context$form$ge2 = _this.context.form.getInternalHooks(),
172
+ innerSetFieldValue = _this$context$form$ge2.innerSetFieldValue;
128
173
 
129
- _this.validateField();
174
+ innerSetFieldValue(field, value);
175
+
176
+ _this.validateField(trigger);
130
177
  };
131
178
 
132
- _this.innerTriggerFunction = function (_, value) {
179
+ _this.innerTriggerFunctionWithValueFirst = function (value) {
133
180
  var _children$props;
134
181
 
135
182
  _this.setFieldData(value);
136
183
 
137
- var _this$props2 = _this.props,
138
- children = _this$props2.children,
139
- _this$props2$trigger = _this$props2.trigger,
140
- trigger = _this$props2$trigger === void 0 ? 'onChange' : _this$props2$trigger;
184
+ var _this$props4 = _this.props,
185
+ children = _this$props4.children,
186
+ _this$props4$trigger = _this$props4.trigger,
187
+ trigger = _this$props4$trigger === void 0 ? 'onChange' : _this$props4$trigger;
141
188
 
142
189
  if (trigger && (_children$props = children.props) != null && _children$props[trigger]) {
143
190
  var _children$props2;
144
191
 
145
- for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
146
- args[_key - 2] = arguments[_key];
192
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
193
+ args[_key - 1] = arguments[_key];
147
194
  }
148
195
 
149
- (_children$props2 = children.props) == null ? void 0 : _children$props2[trigger].apply(_children$props2, [_, value].concat(args));
196
+ (_children$props2 = children.props) == null ? void 0 : _children$props2[trigger].apply(_children$props2, [value].concat(args));
150
197
  }
151
198
  };
152
199
 
153
- _this.innerTriggerFunctionWithValueFirst = function (value) {
200
+ _this.innerOnInputFunction = function (_, value) {
154
201
  var _children$props3;
155
202
 
156
203
  _this.setFieldData(value);
157
204
 
158
- var _this$props3 = _this.props,
159
- children = _this$props3.children,
160
- _this$props3$trigger = _this$props3.trigger,
161
- trigger = _this$props3$trigger === void 0 ? 'onChange' : _this$props3$trigger;
162
-
163
- if (trigger && (_children$props3 = children.props) != null && _children$props3[trigger]) {
164
- var _children$props4;
165
-
166
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
167
- args[_key2 - 1] = arguments[_key2];
168
- }
205
+ var children = _this.props.children;
169
206
 
170
- (_children$props4 = children.props) == null ? void 0 : _children$props4[trigger].apply(_children$props4, [value].concat(args));
207
+ for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
208
+ args[_key2 - 2] = arguments[_key2];
171
209
  }
210
+
211
+ (_children$props3 = children.props) == null ? void 0 : _children$props3.onInput == null ? void 0 : _children$props3.onInput.apply(_children$props3, [_, value].concat(args));
172
212
  };
173
213
 
174
214
  _this.innerClearFunction = function () {
175
- var _children$props5;
215
+ var _children$props4;
176
216
 
177
217
  var children = _this.props.children;
178
218
 
179
219
  _this.setFieldData('');
180
220
 
181
- if ((_children$props5 = children.props) != null && _children$props5.onClear) {
182
- var _children$props6;
221
+ if ((_children$props4 = children.props) != null && _children$props4.onClear) {
222
+ var _children$props5;
183
223
 
184
224
  for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
185
225
  args[_key3] = arguments[_key3];
186
226
  }
187
227
 
188
- (_children$props6 = children.props) == null ? void 0 : _children$props6.onClear.apply(_children$props6, args);
228
+ (_children$props5 = children.props) == null ? void 0 : _children$props5.onClear.apply(_children$props5, args);
189
229
  }
190
230
  };
191
231
 
192
232
  _this.destroyField = function () {};
193
233
 
194
234
  if (props != null && props.initialValue && props.field) {
195
- var _setInitialValues;
196
-
197
235
  var _context$form$getInte = context.form.getInternalHooks(),
198
- setInitialValues = _context$form$getInte.setInitialValues;
236
+ setInitialValue = _context$form$getInte.setInitialValue;
199
237
 
200
- setInitialValues((_setInitialValues = {}, _setInitialValues[props.field] = props.initialValue, _setInitialValues));
238
+ setInitialValue(props.field, props.initialValue);
201
239
  }
202
240
 
203
241
  return _this;
@@ -206,8 +244,8 @@ var FormItemInner = /*#__PURE__*/function (_PureComponent) {
206
244
  var _proto = FormItemInner.prototype;
207
245
 
208
246
  _proto.componentDidMount = function componentDidMount() {
209
- var _this$context$form$ge = this.context.form.getInternalHooks(),
210
- registerField = _this$context$form$ge.registerField;
247
+ var _this$context$form$ge3 = this.context.form.getInternalHooks(),
248
+ registerField = _this$context$form$ge3.registerField;
211
249
 
212
250
  this.destroyField = registerField(this.props.field, this);
213
251
  };
@@ -217,108 +255,90 @@ var FormItemInner = /*#__PURE__*/function (_PureComponent) {
217
255
  };
218
256
 
219
257
  _proto.renderChildren = function renderChildren() {
220
- var _props,
221
- _children$type,
258
+ var _this2 = this,
259
+ _children$type2,
222
260
  _children$props7,
223
- _children$props8,
224
- _this2 = this;
225
-
226
- var _this$props4 = this.props,
227
- children = _this$props4.children,
228
- field = _this$props4.field,
229
- _this$props4$trigger = _this$props4.trigger,
230
- trigger = _this$props4$trigger === void 0 ? 'onChange' : _this$props4$trigger,
231
- _this$props4$triggerP = _this$props4.triggerPropsField,
232
- triggerPropsField = _this$props4$triggerP === void 0 ? 'value' : _this$props4$triggerP,
233
- displayType = _this$props4.displayType;
261
+ _children$props8;
262
+
263
+ var _this$props5 = this.props,
264
+ children = _this$props5.children,
265
+ field = _this$props5.field,
266
+ _this$props5$trigger = _this$props5.trigger,
267
+ trigger = _this$props5$trigger === void 0 ? 'onChange' : _this$props5$trigger,
268
+ _this$props5$triggerP = _this$props5.triggerPropsField,
269
+ triggerPropsField = _this$props5$triggerP === void 0 ? 'value' : _this$props5$triggerP,
270
+ displayType = _this$props5.displayType,
271
+ disabled = _this$props5.disabled;
234
272
  var getFieldValue = this.context.form.getFieldValue;
235
- var props = (_props = {}, _props[triggerPropsField] = getFieldValue(field), _props.disabled = this.props.disabled, _props);
236
- var childrenType = displayType || ((_children$type = children.type) == null ? void 0 : _children$type.displayName);
273
+ var childrenProps = {
274
+ disabled: disabled
275
+ }; // inject validateTriggers of rules
276
+
277
+ this.getAllRuleValidateTriggers().forEach(function (triggerName) {
278
+ childrenProps[triggerName] = function (e) {
279
+ var _children$props6, _children$props6$trig;
280
+
281
+ _this2.validateField(triggerName);
282
+
283
+ children == null ? void 0 : (_children$props6 = children.props) == null ? void 0 : (_children$props6$trig = _children$props6[triggerName]) == null ? void 0 : _children$props6$trig.call(_children$props6, e);
284
+ };
285
+ });
286
+ var childrenType = displayType || ((_children$type2 = children.type) == null ? void 0 : _children$type2.displayName);
237
287
 
238
288
  switch (childrenType) {
239
289
  case _type.FormInternalComponentType.Input:
240
290
  case _type.FormInternalComponentType.Textarea:
241
- props = {
242
- value: getFieldValue(field) || '',
243
- onInput: this.innerTriggerFunction,
244
- onClear: this.innerClearFunction,
245
- disabled: this.props.disabled
246
- };
247
- break;
248
-
249
- case _type.FormInternalComponentType.Checkbox:
250
- case _type.FormInternalComponentType.Radio:
251
- case _type.FormInternalComponentType.Slider:
252
- case _type.FormInternalComponentType.RadioGroup:
253
- case _type.FormInternalComponentType.CheckboxGroup:
254
- props = {
255
- value: getFieldValue(field),
256
- onChange: this.innerTriggerFunctionWithValueFirst,
257
- disabled: this.props.disabled
258
- };
291
+ childrenProps.value = getFieldValue(field) || '';
292
+ childrenProps.onInput = this.innerOnInputFunction;
293
+ childrenProps.onClear = this.innerClearFunction;
259
294
  break;
260
295
 
261
296
  case _type.FormInternalComponentType.DatePicker:
262
- props = {
263
- currentTs: getFieldValue(field),
264
- onChange: this.innerTriggerFunctionWithValueFirst,
265
- disabled: this.props.disabled,
266
- renderLinkedContainer: ((_children$props7 = children.props) == null ? void 0 : _children$props7.renderLinkedContainer) || function (ts, types) {
267
- return /*#__PURE__*/_react.default.createElement(_linkedContainer.DefaultDatePickerLinkedContainer, {
268
- ts: ts,
269
- types: types
270
- });
271
- }
297
+ childrenProps.currentTs = getFieldValue(field);
298
+ childrenProps.onChange = this.innerTriggerFunctionWithValueFirst;
299
+
300
+ childrenProps.renderLinkedContainer = ((_children$props7 = children.props) == null ? void 0 : _children$props7.renderLinkedContainer) || function (ts, types) {
301
+ return /*#__PURE__*/_react.default.createElement(_linkedContainer.DefaultDatePickerLinkedContainer, {
302
+ ts: ts,
303
+ types: types
304
+ });
272
305
  };
306
+
273
307
  break;
274
308
 
275
309
  case _type.FormInternalComponentType.Picker:
276
- props = {
277
- value: getFieldValue(field),
278
- onChange: this.innerTriggerFunctionWithValueFirst,
279
- disabled: this.props.disabled,
280
- renderLinkedContainer: ((_children$props8 = children.props) == null ? void 0 : _children$props8.renderLinkedContainer) || function (val) {
281
- return /*#__PURE__*/_react.default.createElement(_linkedContainer.DefaultPickerLinkedContainer, {
282
- value: val
283
- });
284
- }
310
+ childrenProps.value = getFieldValue(field) || '';
311
+ childrenProps.onChange = this.innerTriggerFunctionWithValueFirst;
312
+
313
+ childrenProps.renderLinkedContainer = ((_children$props8 = children.props) == null ? void 0 : _children$props8.renderLinkedContainer) || function (val) {
314
+ return /*#__PURE__*/_react.default.createElement(_linkedContainer.DefaultPickerLinkedContainer, {
315
+ value: val
316
+ });
285
317
  };
318
+
286
319
  break;
287
320
 
288
321
  case _type.FormInternalComponentType.Switch:
289
- props = {
290
- checked: Boolean(getFieldValue(field)),
291
- onChange: this.innerTriggerFunctionWithValueFirst,
292
- disabled: this.props.disabled
293
- };
322
+ childrenProps.checked = Boolean(getFieldValue(field));
323
+ childrenProps.onChange = this.innerTriggerFunctionWithValueFirst;
294
324
  break;
295
325
 
296
326
  case _type.FormInternalComponentType.ImagePicker:
297
- props = {
298
- images: getFieldValue(field),
299
- onChange: this.innerTriggerFunctionWithValueFirst,
300
- disabled: this.props.disabled
301
- };
327
+ childrenProps.images = getFieldValue(field);
328
+ childrenProps.onChange = this.innerTriggerFunctionWithValueFirst;
302
329
  break;
303
330
 
304
331
  default:
305
- var originTrigger = children.props[trigger]; // inject the validated result
306
-
307
- props.error = this._errors;
332
+ if (triggerPropsField) {
333
+ childrenProps[triggerPropsField] = getFieldValue(field);
334
+ } // inject the validated result
308
335
 
309
- props[trigger] = function (newValue) {
310
- _this2.setFieldData(newValue);
311
-
312
- for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
313
- args[_key4 - 1] = arguments[_key4];
314
- }
315
-
316
- originTrigger && originTrigger.apply(void 0, [newValue].concat(args));
317
- };
318
336
 
337
+ childrenProps.error = this._errors;
338
+ childrenProps[trigger] = this.innerTriggerFunctionWithValueFirst;
319
339
  }
320
340
 
321
- return /*#__PURE__*/_react.default.cloneElement(children, props);
341
+ return /*#__PURE__*/_react.default.cloneElement(children, childrenProps);
322
342
  };
323
343
 
324
344
  _proto.render = function render() {
@@ -328,6 +348,7 @@ var FormItemInner = /*#__PURE__*/function (_PureComponent) {
328
348
  return FormItemInner;
329
349
  }(_react.PureComponent);
330
350
 
351
+ exports.FormItemInner = FormItemInner;
331
352
  FormItemInner.contextType = _formItemContext.FormItemContext;
332
353
 
333
354
  var _default = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
package/cjs/form/index.js CHANGED
@@ -47,6 +47,7 @@ var Form = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
47
47
  formInstance = props.form,
48
48
  children = props.children,
49
49
  onValuesChange = props.onValuesChange,
50
+ onChange = props.onChange,
50
51
  onSubmit = props.onSubmit,
51
52
  onSubmitFailed = props.onSubmitFailed,
52
53
  disabled = props.disabled;
@@ -63,7 +64,8 @@ var Form = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
63
64
  setCallbacks({
64
65
  onValuesChange: onValuesChange,
65
66
  onSubmit: onSubmit,
66
- onSubmitFailed: onSubmitFailed
67
+ onSubmitFailed: onSubmitFailed,
68
+ onChange: onChange
67
69
  });
68
70
 
69
71
  if (!initRef.current) {
@@ -3,6 +3,6 @@ export declare function DefaultPickerLinkedContainer({ value }: {
3
3
  value: (string | number)[];
4
4
  }): JSX.Element;
5
5
  export declare function DefaultDatePickerLinkedContainer({ ts, types, }: {
6
- ts: number | [number, number];
6
+ ts?: number | [number, number];
7
7
  types: string[];
8
8
  }): JSX.Element;
@@ -45,6 +45,10 @@ function DefaultDatePickerLinkedContainer(_ref2) {
45
45
 
46
46
  var className = prefixCls + "-form-picker-link-container";
47
47
  var dateTimeStr = (0, _react.useMemo)(function () {
48
+ if (ts === undefined) {
49
+ return '';
50
+ }
51
+
48
52
  if (typeof ts === 'number') {
49
53
  return formatDateTimeStr(ts, types);
50
54
  }
@@ -567,6 +567,9 @@
567
567
  .arco-form-item-control .arco-input {
568
568
  padding: 0;
569
569
  }
570
+ .arco-form-item-control .arco-input-wrap.textarea {
571
+ padding: 0;
572
+ }
570
573
  .arco-form-item-control-wrapper {
571
574
  width: 100%;
572
575
  -webkit-box-flex: 1;
@@ -574,7 +577,7 @@
574
577
  flex: 1;
575
578
  position: relative;
576
579
  }
577
- .arco-form-item-control-wrapper .arco-input-wrap {
580
+ .arco-form-item-control-wrapper .arco-input-wrap.single-line {
578
581
  height: 0.44rem ;
579
582
  }
580
583
  .arco-form-item-message {
@@ -42,11 +42,16 @@
42
42
  .@{prefix}-input-wrap, .@{prefix}-input {
43
43
  padding: 0;
44
44
  }
45
+
46
+ .@{prefix}-input-wrap.textarea {
47
+ padding: 0;
48
+ }
49
+
45
50
  &-wrapper {
46
51
  width: 100%;
47
52
  flex: 1;
48
53
  position: relative;
49
- .@{prefix}-input-wrap {
54
+ .@{prefix}-input-wrap.single-line {
50
55
  .use-var(height, input-text-line-height);
51
56
  }
52
57
  }
@@ -2,7 +2,7 @@ import { IRules } from '@arco-design/mobile-utils';
2
2
  import { ReactNode } from 'react';
3
3
  import { Promise } from 'es6-promise';
4
4
  export declare type FieldValue = any;
5
- export declare type FieldItem = Record<string, any>;
5
+ export declare type FieldItem = Record<string, FieldValue>;
6
6
  export declare type ILayout = 'horizontal' | 'vertical' | 'inline';
7
7
  export declare enum FormInternalComponentType {
8
8
  Input = "Input",
@@ -52,6 +52,11 @@ export interface FormProps {
52
52
  * @en Callback when the form item value changes
53
53
  */
54
54
  onValuesChange?: Callbacks['onValuesChange'];
55
+ /**
56
+ * 表单项数据变化时的回调(仅用户操作表单时触发)
57
+ * @en Callback when the form item value changes (Only trigger when user operate form)
58
+ */
59
+ onChange?: Callbacks['onChange'];
55
60
  /**
56
61
  * 表单项数据变化时的回调
57
62
  * @en Callback when the form is submitted
@@ -115,6 +120,11 @@ export interface Callbacks {
115
120
  * @en Callback when the form item value changes
116
121
  */
117
122
  onValuesChange?: (changedValues: FieldValue, values: FieldValue) => void;
123
+ /**
124
+ * 表单项数据变化时的回调(仅用户操作表单时触发)
125
+ * @en Callback when the form item value changes (Only trigger when user operate form)
126
+ */
127
+ onChange?: (changedValues: FieldValue, values: FieldValue) => void;
118
128
  /**
119
129
  * 表单项数据变化时的回调
120
130
  * @en Callback when the form is submitted
@@ -134,6 +144,10 @@ export interface InternalHooks {
134
144
  registerField: (name: string, self: any) => () => void;
135
145
  setInitialValues: (values: FieldItem) => void;
136
146
  setCallbacks: (callbacks: Callbacks) => void;
147
+ getInitialValue: (fieldName: string) => FieldValue;
148
+ setInitialValue: (fieldName: string, values: FieldItem) => void;
149
+ innerSetFieldsValue: (values: FieldItem) => boolean;
150
+ innerSetFieldValue: (name: string, value: FieldValue) => boolean;
137
151
  }
138
152
  export interface IFormInstance {
139
153
  /**
@@ -183,6 +197,11 @@ export declare type InternalFormInstance = IFormInstance & {
183
197
  * @en Get internal methods
184
198
  */
185
199
  getInternalHooks: () => InternalHooks;
200
+ /**
201
+ * 注册表单组件
202
+ * @en Register Form Item component
203
+ */
204
+ registerField: (name: string, self: any) => () => void;
186
205
  };
187
206
  export interface FormRef {
188
207
  /**
@@ -371,3 +390,7 @@ export interface IFormItemInnerProps {
371
390
  */
372
391
  displayType?: FormInternalComponentType;
373
392
  }
393
+ export declare enum ValueChangeType {
394
+ Update = 0,
395
+ Reset = 1
396
+ }