@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
@@ -16,7 +16,7 @@
16
16
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
17
17
 
18
18
  _exports.__esModule = true;
19
- _exports.default = void 0;
19
+ _exports.default = _exports.FormItemInner = void 0;
20
20
  _extends2 = _interopRequireDefault(_extends2);
21
21
  _objectWithoutPropertiesLoose2 = _interopRequireDefault(_objectWithoutPropertiesLoose2);
22
22
  _inheritsLoose2 = _interopRequireDefault(_inheritsLoose2);
@@ -40,7 +40,7 @@
40
40
  _this._errors = [];
41
41
  _this._touched = false;
42
42
 
43
- _this.onValueChange = function (curValue, preValue) {
43
+ _this.onValueChange = function (curValue, preValue, info) {
44
44
  _this._touched = true;
45
45
  var shouldUpdate = _this.props.shouldUpdate;
46
46
 
@@ -52,9 +52,34 @@
52
52
  return;
53
53
  }
54
54
 
55
+ if ((info == null ? void 0 : info.changeType) === _type.ValueChangeType.Reset) {
56
+ _this.props.onValidateStatusChange({
57
+ errors: [],
58
+ warnings: [],
59
+ errorTypes: []
60
+ });
61
+
62
+ _this._errors = [];
63
+ }
64
+
55
65
  _this.forceUpdate();
56
66
  };
57
67
 
68
+ _this.getInitialValue = function () {
69
+ var _children$type, _getInitialValue;
70
+
71
+ var _this$props = _this.props,
72
+ children = _this$props.children,
73
+ displayType = _this$props.displayType;
74
+
75
+ var _this$context$form$ge = _this.context.form.getInternalHooks(),
76
+ getInitialValue = _this$context$form$ge.getInitialValue;
77
+
78
+ var childrenType = displayType || ((_children$type = children.type) == null ? void 0 : _children$type.displayName); // get user-defined initialValue or if not defined
79
+
80
+ return (_getInitialValue = getInitialValue(_this.props.field)) != null ? _getInitialValue : (0, _utils.getDefaultValueForInterComponent)(childrenType);
81
+ };
82
+
58
83
  _this.getFieldError = function () {
59
84
  return _this._errors;
60
85
  };
@@ -63,21 +88,37 @@
63
88
  return _this._touched;
64
89
  };
65
90
 
66
- _this.validateField = function () {
91
+ _this.getAllRuleValidateTriggers = function () {
92
+ var _this$props$rules;
93
+
94
+ return ((_this$props$rules = _this.props.rules) == null ? void 0 : _this$props$rules.map(function (rule) {
95
+ return rule.validateTrigger;
96
+ }).flat().filter(function (v) {
97
+ return !!v;
98
+ })) || [];
99
+ };
100
+
101
+ _this.validateField = function (validateTrigger) {
67
102
  var validateMessages = _this.context.validateMessages;
68
103
  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) {
104
+ var _this$props2 = _this.props,
105
+ field = _this$props2.field,
106
+ rules = _this$props2.rules,
107
+ onValidateStatusChange = _this$props2.onValidateStatusChange;
108
+ var value = getFieldValue(field); // rules: if validateTrigger is not defined, all rules will be validated
109
+ // if validateTrigger is defined, only rules with validateTrigger or without rule.validateTrigger will be validated
110
+
111
+ var curRules = validateTrigger ? rules == null ? void 0 : rules.filter(function (rule) {
112
+ var triggerList = [].concat(rule.validateTrigger || validateTrigger);
113
+ return triggerList.includes(validateTrigger);
114
+ }) : rules;
115
+
116
+ if (curRules != null && curRules.length && field) {
76
117
  var _Validator;
77
118
 
78
119
  var fieldDom = _this.props.getFormItemRef();
79
120
 
80
- var fieldValidator = new _mobileUtils.Validator((_Validator = {}, _Validator[field] = rules, _Validator), {
121
+ var fieldValidator = new _mobileUtils.Validator((_Validator = {}, _Validator[field] = curRules, _Validator), {
81
122
  validateMessages: validateMessages
82
123
  });
83
124
  return new _es6Promise.Promise(function (resolve) {
@@ -116,82 +157,79 @@
116
157
  };
117
158
 
118
159
  _this.setFieldData = function (value) {
119
- var field = _this.props.field;
120
- var setFieldValue = _this.context.form.setFieldValue;
121
- setFieldValue(field, value);
160
+ var _this$props3 = _this.props,
161
+ field = _this$props3.field,
162
+ _this$props3$trigger = _this$props3.trigger,
163
+ trigger = _this$props3$trigger === void 0 ? 'onChange' : _this$props3$trigger;
164
+
165
+ var _this$context$form$ge2 = _this.context.form.getInternalHooks(),
166
+ innerSetFieldValue = _this$context$form$ge2.innerSetFieldValue;
122
167
 
123
- _this.validateField();
168
+ innerSetFieldValue(field, value);
169
+
170
+ _this.validateField(trigger);
124
171
  };
125
172
 
126
- _this.innerTriggerFunction = function (_, value) {
173
+ _this.innerTriggerFunctionWithValueFirst = function (value) {
127
174
  var _children$props;
128
175
 
129
176
  _this.setFieldData(value);
130
177
 
131
- var _this$props2 = _this.props,
132
- children = _this$props2.children,
133
- _this$props2$trigger = _this$props2.trigger,
134
- trigger = _this$props2$trigger === void 0 ? 'onChange' : _this$props2$trigger;
178
+ var _this$props4 = _this.props,
179
+ children = _this$props4.children,
180
+ _this$props4$trigger = _this$props4.trigger,
181
+ trigger = _this$props4$trigger === void 0 ? 'onChange' : _this$props4$trigger;
135
182
 
136
183
  if (trigger && (_children$props = children.props) != null && _children$props[trigger]) {
137
184
  var _children$props2;
138
185
 
139
- for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
140
- args[_key - 2] = arguments[_key];
186
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
187
+ args[_key - 1] = arguments[_key];
141
188
  }
142
189
 
143
- (_children$props2 = children.props) == null ? void 0 : _children$props2[trigger].apply(_children$props2, [_, value].concat(args));
190
+ (_children$props2 = children.props) == null ? void 0 : _children$props2[trigger].apply(_children$props2, [value].concat(args));
144
191
  }
145
192
  };
146
193
 
147
- _this.innerTriggerFunctionWithValueFirst = function (value) {
194
+ _this.innerOnInputFunction = function (_, value) {
148
195
  var _children$props3;
149
196
 
150
197
  _this.setFieldData(value);
151
198
 
152
- var _this$props3 = _this.props,
153
- children = _this$props3.children,
154
- _this$props3$trigger = _this$props3.trigger,
155
- trigger = _this$props3$trigger === void 0 ? 'onChange' : _this$props3$trigger;
156
-
157
- if (trigger && (_children$props3 = children.props) != null && _children$props3[trigger]) {
158
- var _children$props4;
159
-
160
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
161
- args[_key2 - 1] = arguments[_key2];
162
- }
199
+ var children = _this.props.children;
163
200
 
164
- (_children$props4 = children.props) == null ? void 0 : _children$props4[trigger].apply(_children$props4, [value].concat(args));
201
+ for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
202
+ args[_key2 - 2] = arguments[_key2];
165
203
  }
204
+
205
+ (_children$props3 = children.props) == null ? void 0 : _children$props3.onInput == null ? void 0 : _children$props3.onInput.apply(_children$props3, [_, value].concat(args));
166
206
  };
167
207
 
168
208
  _this.innerClearFunction = function () {
169
- var _children$props5;
209
+ var _children$props4;
170
210
 
171
211
  var children = _this.props.children;
172
212
 
173
213
  _this.setFieldData('');
174
214
 
175
- if ((_children$props5 = children.props) != null && _children$props5.onClear) {
176
- var _children$props6;
215
+ if ((_children$props4 = children.props) != null && _children$props4.onClear) {
216
+ var _children$props5;
177
217
 
178
218
  for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
179
219
  args[_key3] = arguments[_key3];
180
220
  }
181
221
 
182
- (_children$props6 = children.props) == null ? void 0 : _children$props6.onClear.apply(_children$props6, args);
222
+ (_children$props5 = children.props) == null ? void 0 : _children$props5.onClear.apply(_children$props5, args);
183
223
  }
184
224
  };
185
225
 
186
226
  _this.destroyField = function () {};
187
227
 
188
228
  if (props != null && props.initialValue && props.field) {
189
- var _setInitialValues;
190
-
191
229
  var _context$form$getInte = context.form.getInternalHooks(),
192
- setInitialValues = _context$form$getInte.setInitialValues;
230
+ setInitialValue = _context$form$getInte.setInitialValue;
193
231
 
194
- setInitialValues((_setInitialValues = {}, _setInitialValues[props.field] = props.initialValue, _setInitialValues));
232
+ setInitialValue(props.field, props.initialValue);
195
233
  }
196
234
 
197
235
  return _this;
@@ -200,8 +238,8 @@
200
238
  var _proto = FormItemInner.prototype;
201
239
 
202
240
  _proto.componentDidMount = function componentDidMount() {
203
- var _this$context$form$ge = this.context.form.getInternalHooks(),
204
- registerField = _this$context$form$ge.registerField;
241
+ var _this$context$form$ge3 = this.context.form.getInternalHooks(),
242
+ registerField = _this$context$form$ge3.registerField;
205
243
 
206
244
  this.destroyField = registerField(this.props.field, this);
207
245
  };
@@ -211,108 +249,90 @@
211
249
  };
212
250
 
213
251
  _proto.renderChildren = function renderChildren() {
214
- var _props,
215
- _children$type,
252
+ var _this2 = this,
253
+ _children$type2,
216
254
  _children$props7,
217
- _children$props8,
218
- _this2 = this;
219
-
220
- var _this$props4 = this.props,
221
- children = _this$props4.children,
222
- field = _this$props4.field,
223
- _this$props4$trigger = _this$props4.trigger,
224
- trigger = _this$props4$trigger === void 0 ? 'onChange' : _this$props4$trigger,
225
- _this$props4$triggerP = _this$props4.triggerPropsField,
226
- triggerPropsField = _this$props4$triggerP === void 0 ? 'value' : _this$props4$triggerP,
227
- displayType = _this$props4.displayType;
255
+ _children$props8;
256
+
257
+ var _this$props5 = this.props,
258
+ children = _this$props5.children,
259
+ field = _this$props5.field,
260
+ _this$props5$trigger = _this$props5.trigger,
261
+ trigger = _this$props5$trigger === void 0 ? 'onChange' : _this$props5$trigger,
262
+ _this$props5$triggerP = _this$props5.triggerPropsField,
263
+ triggerPropsField = _this$props5$triggerP === void 0 ? 'value' : _this$props5$triggerP,
264
+ displayType = _this$props5.displayType,
265
+ disabled = _this$props5.disabled;
228
266
  var getFieldValue = this.context.form.getFieldValue;
229
- var props = (_props = {}, _props[triggerPropsField] = getFieldValue(field), _props.disabled = this.props.disabled, _props);
230
- var childrenType = displayType || ((_children$type = children.type) == null ? void 0 : _children$type.displayName);
267
+ var childrenProps = {
268
+ disabled: disabled
269
+ }; // inject validateTriggers of rules
270
+
271
+ this.getAllRuleValidateTriggers().forEach(function (triggerName) {
272
+ childrenProps[triggerName] = function (e) {
273
+ var _children$props6, _children$props6$trig;
274
+
275
+ _this2.validateField(triggerName);
276
+
277
+ 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);
278
+ };
279
+ });
280
+ var childrenType = displayType || ((_children$type2 = children.type) == null ? void 0 : _children$type2.displayName);
231
281
 
232
282
  switch (childrenType) {
233
283
  case _type.FormInternalComponentType.Input:
234
284
  case _type.FormInternalComponentType.Textarea:
235
- props = {
236
- value: getFieldValue(field) || '',
237
- onInput: this.innerTriggerFunction,
238
- onClear: this.innerClearFunction,
239
- disabled: this.props.disabled
240
- };
241
- break;
242
-
243
- case _type.FormInternalComponentType.Checkbox:
244
- case _type.FormInternalComponentType.Radio:
245
- case _type.FormInternalComponentType.Slider:
246
- case _type.FormInternalComponentType.RadioGroup:
247
- case _type.FormInternalComponentType.CheckboxGroup:
248
- props = {
249
- value: getFieldValue(field),
250
- onChange: this.innerTriggerFunctionWithValueFirst,
251
- disabled: this.props.disabled
252
- };
285
+ childrenProps.value = getFieldValue(field) || '';
286
+ childrenProps.onInput = this.innerOnInputFunction;
287
+ childrenProps.onClear = this.innerClearFunction;
253
288
  break;
254
289
 
255
290
  case _type.FormInternalComponentType.DatePicker:
256
- props = {
257
- currentTs: getFieldValue(field),
258
- onChange: this.innerTriggerFunctionWithValueFirst,
259
- disabled: this.props.disabled,
260
- renderLinkedContainer: ((_children$props7 = children.props) == null ? void 0 : _children$props7.renderLinkedContainer) || function (ts, types) {
261
- return /*#__PURE__*/_react.default.createElement(_linkedContainer.DefaultDatePickerLinkedContainer, {
262
- ts: ts,
263
- types: types
264
- });
265
- }
291
+ childrenProps.currentTs = getFieldValue(field);
292
+ childrenProps.onChange = this.innerTriggerFunctionWithValueFirst;
293
+
294
+ childrenProps.renderLinkedContainer = ((_children$props7 = children.props) == null ? void 0 : _children$props7.renderLinkedContainer) || function (ts, types) {
295
+ return /*#__PURE__*/_react.default.createElement(_linkedContainer.DefaultDatePickerLinkedContainer, {
296
+ ts: ts,
297
+ types: types
298
+ });
266
299
  };
300
+
267
301
  break;
268
302
 
269
303
  case _type.FormInternalComponentType.Picker:
270
- props = {
271
- value: getFieldValue(field),
272
- onChange: this.innerTriggerFunctionWithValueFirst,
273
- disabled: this.props.disabled,
274
- renderLinkedContainer: ((_children$props8 = children.props) == null ? void 0 : _children$props8.renderLinkedContainer) || function (val) {
275
- return /*#__PURE__*/_react.default.createElement(_linkedContainer.DefaultPickerLinkedContainer, {
276
- value: val
277
- });
278
- }
304
+ childrenProps.value = getFieldValue(field) || '';
305
+ childrenProps.onChange = this.innerTriggerFunctionWithValueFirst;
306
+
307
+ childrenProps.renderLinkedContainer = ((_children$props8 = children.props) == null ? void 0 : _children$props8.renderLinkedContainer) || function (val) {
308
+ return /*#__PURE__*/_react.default.createElement(_linkedContainer.DefaultPickerLinkedContainer, {
309
+ value: val
310
+ });
279
311
  };
312
+
280
313
  break;
281
314
 
282
315
  case _type.FormInternalComponentType.Switch:
283
- props = {
284
- checked: Boolean(getFieldValue(field)),
285
- onChange: this.innerTriggerFunctionWithValueFirst,
286
- disabled: this.props.disabled
287
- };
316
+ childrenProps.checked = Boolean(getFieldValue(field));
317
+ childrenProps.onChange = this.innerTriggerFunctionWithValueFirst;
288
318
  break;
289
319
 
290
320
  case _type.FormInternalComponentType.ImagePicker:
291
- props = {
292
- images: getFieldValue(field),
293
- onChange: this.innerTriggerFunctionWithValueFirst,
294
- disabled: this.props.disabled
295
- };
321
+ childrenProps.images = getFieldValue(field);
322
+ childrenProps.onChange = this.innerTriggerFunctionWithValueFirst;
296
323
  break;
297
324
 
298
325
  default:
299
- var originTrigger = children.props[trigger]; // inject the validated result
300
-
301
- props.error = this._errors;
326
+ if (triggerPropsField) {
327
+ childrenProps[triggerPropsField] = getFieldValue(field);
328
+ } // inject the validated result
302
329
 
303
- props[trigger] = function (newValue) {
304
- _this2.setFieldData(newValue);
305
-
306
- for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
307
- args[_key4 - 1] = arguments[_key4];
308
- }
309
-
310
- originTrigger && originTrigger.apply(void 0, [newValue].concat(args));
311
- };
312
330
 
331
+ childrenProps.error = this._errors;
332
+ childrenProps[trigger] = this.innerTriggerFunctionWithValueFirst;
313
333
  }
314
334
 
315
- return /*#__PURE__*/_react.default.cloneElement(children, props);
335
+ return /*#__PURE__*/_react.default.cloneElement(children, childrenProps);
316
336
  };
317
337
 
318
338
  _proto.render = function render() {
@@ -322,6 +342,7 @@
322
342
  return FormItemInner;
323
343
  }(_react.PureComponent);
324
344
 
345
+ _exports.FormItemInner = FormItemInner;
325
346
  FormItemInner.contextType = _formItemContext.FormItemContext;
326
347
 
327
348
  var _default = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
package/umd/form/index.js CHANGED
@@ -46,6 +46,7 @@
46
46
  formInstance = props.form,
47
47
  children = props.children,
48
48
  onValuesChange = props.onValuesChange,
49
+ onChange = props.onChange,
49
50
  onSubmit = props.onSubmit,
50
51
  onSubmitFailed = props.onSubmitFailed,
51
52
  disabled = props.disabled;
@@ -62,7 +63,8 @@
62
63
  setCallbacks({
63
64
  onValuesChange: onValuesChange,
64
65
  onSubmit: onSubmit,
65
- onSubmitFailed: onSubmitFailed
66
+ onSubmitFailed: onSubmitFailed,
67
+ onChange: onChange
66
68
  });
67
69
 
68
70
  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;
@@ -50,6 +50,10 @@
50
50
 
51
51
  var className = prefixCls + "-form-picker-link-container";
52
52
  var dateTimeStr = (0, _react.useMemo)(function () {
53
+ if (ts === undefined) {
54
+ return '';
55
+ }
56
+
53
57
  if (typeof ts === 'number') {
54
58
  return formatDateTimeStr(ts, types);
55
59
  }
@@ -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
+ }
package/umd/form/type.js CHANGED
@@ -14,7 +14,7 @@
14
14
  "use strict";
15
15
 
16
16
  _exports.__esModule = true;
17
- _exports.ValidateStatus = _exports.FormInternalComponentType = void 0;
17
+ _exports.ValueChangeType = _exports.ValidateStatus = _exports.FormInternalComponentType = void 0;
18
18
  // 注意:自动识别form关联组件的依据,请勿轻易改变代码结构
19
19
  // Notice: Automatically identify the basis of the associated component of the form, DO NOT change the code structure.
20
20
  var FormInternalComponentType;
@@ -46,4 +46,12 @@
46
46
  ValidateStatus["Validating"] = "validating";
47
47
  ValidateStatus["Success"] = "success";
48
48
  })(ValidateStatus || (_exports.ValidateStatus = ValidateStatus = {}));
49
+
50
+ var ValueChangeType;
51
+ _exports.ValueChangeType = ValueChangeType;
52
+
53
+ (function (ValueChangeType) {
54
+ ValueChangeType[ValueChangeType["Update"] = 0] = "Update";
55
+ ValueChangeType[ValueChangeType["Reset"] = 1] = "Reset";
56
+ })(ValueChangeType || (_exports.ValueChangeType = ValueChangeType = {}));
49
57
  });
@@ -1,18 +1,3 @@
1
- import { IFormInstance } from './type';
2
- export declare const defaultFormDataMethods: {
3
- getFieldValue: (name: any) => any;
4
- getFieldsValue: (_names: any) => {};
5
- getFieldError: (_name: any) => never[];
6
- setFieldValue: (_name: any, _value: any) => boolean;
7
- setFieldsValue: (_values: any) => boolean;
8
- registerField: (_name: any, _self: any) => () => void;
9
- resetFields: any;
10
- validateFields: any;
11
- submit: any;
12
- getInternalHooks: () => {
13
- registerField: any;
14
- setInitialValues: any;
15
- setCallbacks: any;
16
- };
17
- };
1
+ import { IFormInstance, InternalFormInstance } from './type';
2
+ export declare const defaultFormDataMethods: InternalFormInstance;
18
3
  export default function useForm(form?: IFormInstance): IFormInstance[];