@hi-ui/form 4.0.0-beta.22 → 4.0.0-beta.25
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/lib/cjs/Form.js +2 -2
- package/lib/cjs/styles/index.scss.js +1 -1
- package/lib/cjs/use-form.js +15 -13
- package/lib/esm/Form.js +2 -2
- package/lib/esm/styles/index.scss.js +2 -3
- package/lib/esm/use-form.js +17 -15
- package/lib/types/types.d.ts +15 -18
- package/lib/types/use-form.d.ts +5 -4
- package/package.json +12 -12
package/lib/cjs/Form.js
CHANGED
|
@@ -72,14 +72,14 @@ var Form = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
72
72
|
validate: formContext.submitForm,
|
|
73
73
|
reset: formContext.resetForm,
|
|
74
74
|
validateField: formContext.validateFieldState,
|
|
75
|
-
// validateFields: formContext.va,
|
|
76
75
|
setFieldValue: formContext.setFieldValue,
|
|
77
76
|
setFieldsValue: formContext.setFieldsValue,
|
|
78
77
|
getFieldValue: formContext.getFieldValue,
|
|
79
78
|
getFieldsValue: formContext.getFieldsValue,
|
|
80
79
|
getFieldError: formContext.getFieldError,
|
|
81
80
|
getFieldsError: formContext.getFieldsError,
|
|
82
|
-
clearValidates: formContext.resetErrors
|
|
81
|
+
clearValidates: formContext.resetErrors,
|
|
82
|
+
clearFieldValidate: formContext.resetFieldError
|
|
83
83
|
};
|
|
84
84
|
});
|
|
85
85
|
var providedValue = React.useMemo(function () {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
Object.defineProperty(exports, '__esModule', {
|
|
13
13
|
value: true
|
|
14
14
|
});
|
|
15
|
-
var css_248z = "
|
|
15
|
+
var css_248z = ".hi-v4-form {max-width: 100%;position: relative; }.hi-v4-form fieldset {margin: 0;padding: 0;border: 0; }.hi-v4-form fieldset + fieldset {margin-top: 16px; }.hi-v4-form legend {margin: 0 0 16px;color: var(--hi-v4-color-gray-800, #1f2937); }.hi-v4-form--placement-horizontal {display: -webkit-box;display: -ms-flexbox;display: flex;-ms-flex-wrap: wrap;flex-wrap: wrap; }.hi-v4-form--placement-horizontal .hi-v4-form-label__indent {min-height: var(--hi-v4-height-8, 32px); }.hi-v4-form-label {display: -webkit-box;display: -ms-flexbox;display: flex;font-size: var(--hi-v4-text-size-md, 0.875rem);-webkit-box-sizing: border-box;box-sizing: border-box;margin-right: 0;margin-bottom: var(--hi-v4-spacing-12, 24px); }.hi-v4-form-label__text, .hi-v4-form-label__indent {-ms-flex-negative: 0;flex-shrink: 0;-webkit-box-sizing: border-box;box-sizing: border-box;vertical-align: top;color: var(--hi-v4-color-gray-800, #1f2937);overflow-wrap: break-word; }.hi-v4-form-label__text {padding-right: var(--hi-v4-spacing-6, 12px);min-height: var(--hi-v4-height-8, 32px);line-height: var(--hi-v4-height-8, 32px); }.hi-v4-form-label--placement-left .hi-v4-form-label__text {text-align: left; }.hi-v4-form-label--placement-right .hi-v4-form-label__text {text-align: right; }.hi-v4-form-label--placement-top .hi-v4-form-label__text {height: 22px;min-height: 22px;line-height: 22px;padding-right: 0;margin-bottom: var(--hi-v4-spacing-4, 8px); }.hi-v4-form-label--required .hi-v4-form-label__text::before {margin-right: var(--hi-v4-spacing-2, 4px);content: '*';color: var(--hi-v4-color-danger-500, var(--hi-v4-color-red-500, #ff5959)); }.hi-v4-form-label--placement-top {text-align: left;-webkit-box-orient: vertical;-webkit-box-direction: normal;-ms-flex-direction: column;flex-direction: column;margin-bottom: var(--hi-v4-spacing-12, 24px);padding-right: 0; }.hi-v4-form-label__content {-webkit-box-flex: 1;-ms-flex: 1 1;flex: 1 1;position: relative;vertical-align: top;min-height: var(--hi-v4-height-8, 32px);-ms-flex-negative: 0;flex-shrink: 0; }.hi-v4-form-label__control {min-width: 1px; }.hi-v4-form-message {display: block;font-size: var(--hi-v4-text-size-md, 0.875rem);min-height: 24px;padding: 2px 0;-webkit-box-sizing: border-box;box-sizing: border-box;line-height: 20px;-webkit-transform: translateY(-10%);transform: translateY(-10%);opacity: 0;color: var(--hi-v4-color-danger-500, var(--hi-v4-color-red-500, #ff5959));-webkit-transition: all 0.3s;transition: all 0.3s; }.hi-v4-form-message--show {opacity: 1;-webkit-transform: translateY(0);transform: translateY(0); }.hi-v4-form-item {position: relative; }.hi-v4-form-item__message {position: absolute; }";
|
|
16
16
|
|
|
17
17
|
var __styleInject__ = require('style-inject/dist/style-inject.es.js')["default"];
|
|
18
18
|
|
package/lib/cjs/use-form.js
CHANGED
|
@@ -309,7 +309,6 @@ var useForm = function useForm(_a) {
|
|
|
309
309
|
*/
|
|
310
310
|
|
|
311
311
|
var setFieldValue = React.useCallback(function (field, value, shouldValidate) {
|
|
312
|
-
// @ts-ignore
|
|
313
312
|
formDispatch({
|
|
314
313
|
type: 'SET_FIELD_VALUE',
|
|
315
314
|
payload: {
|
|
@@ -318,20 +317,20 @@ var useForm = function useForm(_a) {
|
|
|
318
317
|
}
|
|
319
318
|
}); // touched 给外部控制展示,而不是当做参数暴露
|
|
320
319
|
|
|
321
|
-
var shouldValidateField =
|
|
322
|
-
validateAfterTouched ? objectUtils.getNested(formState.touched, field) && shouldValidate : shouldValidate;
|
|
320
|
+
var shouldValidateField = validateAfterTouched ? objectUtils.getNested(formState.touched, field) && shouldValidate : shouldValidate;
|
|
323
321
|
|
|
324
322
|
if (shouldValidateField) {
|
|
325
323
|
validateField(field, value);
|
|
326
324
|
}
|
|
327
325
|
}, [validateField, validateAfterTouched, formState]);
|
|
328
|
-
var setFieldsValue = React.useCallback(function (
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
326
|
+
var setFieldsValue = React.useCallback(function (fieldsState) {
|
|
327
|
+
formDispatch({
|
|
328
|
+
type: 'SET_VALUES',
|
|
329
|
+
payload: function payload(prevState) {
|
|
330
|
+
return typeAssertion.isFunction(fieldsState) ? fieldsState(prevState) : objectUtils.merge(objectUtils.clone(prevState), fieldsState);
|
|
331
|
+
}
|
|
333
332
|
});
|
|
334
|
-
}, [
|
|
333
|
+
}, []);
|
|
335
334
|
var normalizeValueFromChange = React.useCallback(function (eventOrValue, valuePropName) {
|
|
336
335
|
var nextValue = eventOrValue;
|
|
337
336
|
|
|
@@ -539,11 +538,13 @@ var useForm = function useForm(_a) {
|
|
|
539
538
|
}, [resetForm]);
|
|
540
539
|
var resetErrors = React.useCallback(function () {
|
|
541
540
|
formDispatch({
|
|
542
|
-
// TODO: reset errorMsg
|
|
543
541
|
type: 'SET_ERRORS',
|
|
544
542
|
payload: {}
|
|
545
543
|
});
|
|
546
544
|
}, []);
|
|
545
|
+
var resetFieldError = React.useCallback(function (field) {
|
|
546
|
+
setFieldError(field, '');
|
|
547
|
+
}, [setFieldError]);
|
|
547
548
|
var setFormState = React__default["default"].useCallback(function (stateOrFunc) {
|
|
548
549
|
// @ts-ignore
|
|
549
550
|
formDispatch({
|
|
@@ -609,14 +610,14 @@ var useForm = function useForm(_a) {
|
|
|
609
610
|
submitForm: submitForm,
|
|
610
611
|
resetForm: resetForm,
|
|
611
612
|
resetErrors: resetErrors,
|
|
613
|
+
resetFieldError: resetFieldError,
|
|
612
614
|
validateFieldState: validateFieldState,
|
|
613
615
|
validateValue: validateField,
|
|
614
616
|
getFieldsValue: getFieldsValue,
|
|
615
617
|
setFieldsValue: setFieldsValue,
|
|
616
618
|
getFieldsError: getFieldsError
|
|
617
619
|
});
|
|
618
|
-
};
|
|
619
|
-
|
|
620
|
+
};
|
|
620
621
|
|
|
621
622
|
function formReducer(state, action) {
|
|
622
623
|
switch (action.type) {
|
|
@@ -625,8 +626,9 @@ function formReducer(state, action) {
|
|
|
625
626
|
return Object.assign(Object.assign({}, state), nextState);
|
|
626
627
|
|
|
627
628
|
case 'SET_VALUES':
|
|
629
|
+
var nextValues = typeAssertion.isFunction(action.payload) ? action.payload(state.values) : action.payload;
|
|
628
630
|
return Object.assign(Object.assign({}, state), {
|
|
629
|
-
values:
|
|
631
|
+
values: nextValues
|
|
630
632
|
});
|
|
631
633
|
|
|
632
634
|
case 'SET_ERRORS':
|
package/lib/esm/Form.js
CHANGED
|
@@ -50,14 +50,14 @@ var Form = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
50
50
|
validate: formContext.submitForm,
|
|
51
51
|
reset: formContext.resetForm,
|
|
52
52
|
validateField: formContext.validateFieldState,
|
|
53
|
-
// validateFields: formContext.va,
|
|
54
53
|
setFieldValue: formContext.setFieldValue,
|
|
55
54
|
setFieldsValue: formContext.setFieldsValue,
|
|
56
55
|
getFieldValue: formContext.getFieldValue,
|
|
57
56
|
getFieldsValue: formContext.getFieldsValue,
|
|
58
57
|
getFieldError: formContext.getFieldError,
|
|
59
58
|
getFieldsError: formContext.getFieldsError,
|
|
60
|
-
clearValidates: formContext.resetErrors
|
|
59
|
+
clearValidates: formContext.resetErrors,
|
|
60
|
+
clearFieldValidate: formContext.resetFieldError
|
|
61
61
|
};
|
|
62
62
|
});
|
|
63
63
|
var providedValue = useMemo(function () {
|
|
@@ -7,9 +7,8 @@
|
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var __styleInject__ = require('style-inject/dist/style-inject.es.js')["default"];
|
|
10
|
+
import __styleInject__ from 'style-inject/dist/style-inject.es.js';
|
|
11
|
+
var css_248z = ".hi-v4-form {max-width: 100%;position: relative; }.hi-v4-form fieldset {margin: 0;padding: 0;border: 0; }.hi-v4-form fieldset + fieldset {margin-top: 16px; }.hi-v4-form legend {margin: 0 0 16px;color: var(--hi-v4-color-gray-800, #1f2937); }.hi-v4-form--placement-horizontal {display: -webkit-box;display: -ms-flexbox;display: flex;-ms-flex-wrap: wrap;flex-wrap: wrap; }.hi-v4-form--placement-horizontal .hi-v4-form-label__indent {min-height: var(--hi-v4-height-8, 32px); }.hi-v4-form-label {display: -webkit-box;display: -ms-flexbox;display: flex;font-size: var(--hi-v4-text-size-md, 0.875rem);-webkit-box-sizing: border-box;box-sizing: border-box;margin-right: 0;margin-bottom: var(--hi-v4-spacing-12, 24px); }.hi-v4-form-label__text, .hi-v4-form-label__indent {-ms-flex-negative: 0;flex-shrink: 0;-webkit-box-sizing: border-box;box-sizing: border-box;vertical-align: top;color: var(--hi-v4-color-gray-800, #1f2937);overflow-wrap: break-word; }.hi-v4-form-label__text {padding-right: var(--hi-v4-spacing-6, 12px);min-height: var(--hi-v4-height-8, 32px);line-height: var(--hi-v4-height-8, 32px); }.hi-v4-form-label--placement-left .hi-v4-form-label__text {text-align: left; }.hi-v4-form-label--placement-right .hi-v4-form-label__text {text-align: right; }.hi-v4-form-label--placement-top .hi-v4-form-label__text {height: 22px;min-height: 22px;line-height: 22px;padding-right: 0;margin-bottom: var(--hi-v4-spacing-4, 8px); }.hi-v4-form-label--required .hi-v4-form-label__text::before {margin-right: var(--hi-v4-spacing-2, 4px);content: '*';color: var(--hi-v4-color-danger-500, var(--hi-v4-color-red-500, #ff5959)); }.hi-v4-form-label--placement-top {text-align: left;-webkit-box-orient: vertical;-webkit-box-direction: normal;-ms-flex-direction: column;flex-direction: column;margin-bottom: var(--hi-v4-spacing-12, 24px);padding-right: 0; }.hi-v4-form-label__content {-webkit-box-flex: 1;-ms-flex: 1 1;flex: 1 1;position: relative;vertical-align: top;min-height: var(--hi-v4-height-8, 32px);-ms-flex-negative: 0;flex-shrink: 0; }.hi-v4-form-label__control {min-width: 1px; }.hi-v4-form-message {display: block;font-size: var(--hi-v4-text-size-md, 0.875rem);min-height: 24px;padding: 2px 0;-webkit-box-sizing: border-box;box-sizing: border-box;line-height: 20px;-webkit-transform: translateY(-10%);transform: translateY(-10%);opacity: 0;color: var(--hi-v4-color-danger-500, var(--hi-v4-color-red-500, #ff5959));-webkit-transition: all 0.3s;transition: all 0.3s; }.hi-v4-form-message--show {opacity: 1;-webkit-transform: translateY(0);transform: translateY(0); }.hi-v4-form-item {position: relative; }.hi-v4-form-item__message {position: absolute; }";
|
|
13
12
|
|
|
14
13
|
__styleInject__(css_248z);
|
|
15
14
|
|
package/lib/esm/use-form.js
CHANGED
|
@@ -12,9 +12,9 @@ import { __rest, __awaiter } from 'tslib';
|
|
|
12
12
|
import { stringify, parse, isValidField } from './utils/index.js';
|
|
13
13
|
import React, { useMemo, useReducer, useCallback, useRef } from 'react';
|
|
14
14
|
import { useLatestRef, useLatestCallback } from '@hi-ui/use-latest';
|
|
15
|
-
import { isArray,
|
|
15
|
+
import { isArray, isFunction, isObjectLike } from '@hi-ui/type-assertion';
|
|
16
16
|
import { callAllFuncs } from '@hi-ui/func-utils';
|
|
17
|
-
import { getNested, setNested } from '@hi-ui/object-utils';
|
|
17
|
+
import { getNested, setNested, merge, clone } from '@hi-ui/object-utils';
|
|
18
18
|
import { stopEvent } from '@hi-ui/dom-utils';
|
|
19
19
|
var EMPTY_RULES = {};
|
|
20
20
|
var EMPTY_ERRORS = {};
|
|
@@ -282,7 +282,6 @@ var useForm = function useForm(_a) {
|
|
|
282
282
|
*/
|
|
283
283
|
|
|
284
284
|
var setFieldValue = useCallback(function (field, value, shouldValidate) {
|
|
285
|
-
// @ts-ignore
|
|
286
285
|
formDispatch({
|
|
287
286
|
type: 'SET_FIELD_VALUE',
|
|
288
287
|
payload: {
|
|
@@ -291,20 +290,20 @@ var useForm = function useForm(_a) {
|
|
|
291
290
|
}
|
|
292
291
|
}); // touched 给外部控制展示,而不是当做参数暴露
|
|
293
292
|
|
|
294
|
-
var shouldValidateField =
|
|
295
|
-
validateAfterTouched ? getNested(formState.touched, field) && shouldValidate : shouldValidate;
|
|
293
|
+
var shouldValidateField = validateAfterTouched ? getNested(formState.touched, field) && shouldValidate : shouldValidate;
|
|
296
294
|
|
|
297
295
|
if (shouldValidateField) {
|
|
298
296
|
validateField(field, value);
|
|
299
297
|
}
|
|
300
298
|
}, [validateField, validateAfterTouched, formState]);
|
|
301
|
-
var setFieldsValue = useCallback(function (
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
299
|
+
var setFieldsValue = useCallback(function (fieldsState) {
|
|
300
|
+
formDispatch({
|
|
301
|
+
type: 'SET_VALUES',
|
|
302
|
+
payload: function payload(prevState) {
|
|
303
|
+
return isFunction(fieldsState) ? fieldsState(prevState) : merge(clone(prevState), fieldsState);
|
|
304
|
+
}
|
|
306
305
|
});
|
|
307
|
-
}, [
|
|
306
|
+
}, []);
|
|
308
307
|
var normalizeValueFromChange = useCallback(function (eventOrValue, valuePropName) {
|
|
309
308
|
var nextValue = eventOrValue;
|
|
310
309
|
|
|
@@ -512,11 +511,13 @@ var useForm = function useForm(_a) {
|
|
|
512
511
|
}, [resetForm]);
|
|
513
512
|
var resetErrors = useCallback(function () {
|
|
514
513
|
formDispatch({
|
|
515
|
-
// TODO: reset errorMsg
|
|
516
514
|
type: 'SET_ERRORS',
|
|
517
515
|
payload: {}
|
|
518
516
|
});
|
|
519
517
|
}, []);
|
|
518
|
+
var resetFieldError = useCallback(function (field) {
|
|
519
|
+
setFieldError(field, '');
|
|
520
|
+
}, [setFieldError]);
|
|
520
521
|
var setFormState = React.useCallback(function (stateOrFunc) {
|
|
521
522
|
// @ts-ignore
|
|
522
523
|
formDispatch({
|
|
@@ -582,14 +583,14 @@ var useForm = function useForm(_a) {
|
|
|
582
583
|
submitForm: submitForm,
|
|
583
584
|
resetForm: resetForm,
|
|
584
585
|
resetErrors: resetErrors,
|
|
586
|
+
resetFieldError: resetFieldError,
|
|
585
587
|
validateFieldState: validateFieldState,
|
|
586
588
|
validateValue: validateField,
|
|
587
589
|
getFieldsValue: getFieldsValue,
|
|
588
590
|
setFieldsValue: setFieldsValue,
|
|
589
591
|
getFieldsError: getFieldsError
|
|
590
592
|
});
|
|
591
|
-
};
|
|
592
|
-
|
|
593
|
+
};
|
|
593
594
|
|
|
594
595
|
function formReducer(state, action) {
|
|
595
596
|
switch (action.type) {
|
|
@@ -598,8 +599,9 @@ function formReducer(state, action) {
|
|
|
598
599
|
return Object.assign(Object.assign({}, state), nextState);
|
|
599
600
|
|
|
600
601
|
case 'SET_VALUES':
|
|
602
|
+
var nextValues = isFunction(action.payload) ? action.payload(state.values) : action.payload;
|
|
601
603
|
return Object.assign(Object.assign({}, state), {
|
|
602
|
-
values:
|
|
604
|
+
values: nextValues
|
|
603
605
|
});
|
|
604
606
|
|
|
605
607
|
case 'SET_ERRORS':
|
package/lib/types/types.d.ts
CHANGED
|
@@ -41,19 +41,19 @@ export declare type FormAction<T> = {
|
|
|
41
41
|
} | {
|
|
42
42
|
type: 'SET_FIELD_VALUE';
|
|
43
43
|
payload: {
|
|
44
|
-
field:
|
|
44
|
+
field: FormFieldPath;
|
|
45
45
|
value?: any;
|
|
46
46
|
};
|
|
47
47
|
} | {
|
|
48
48
|
type: 'SET_FIELD_TOUCHED';
|
|
49
49
|
payload: {
|
|
50
|
-
field:
|
|
50
|
+
field: FormFieldPath;
|
|
51
51
|
value?: boolean;
|
|
52
52
|
};
|
|
53
53
|
} | {
|
|
54
54
|
type: 'SET_FIELD_ERROR';
|
|
55
55
|
payload: {
|
|
56
|
-
field:
|
|
56
|
+
field: FormFieldPath;
|
|
57
57
|
value?: string;
|
|
58
58
|
};
|
|
59
59
|
} | {
|
|
@@ -85,41 +85,38 @@ export interface FormHelpers<T = any> {
|
|
|
85
85
|
*/
|
|
86
86
|
validate: () => Promise<T>;
|
|
87
87
|
/**
|
|
88
|
-
* 重置整个表单的验证,对应 Form.Reset中的 API
|
|
88
|
+
* 重置整个表单的验证,对应 Form.Reset中的 API,如果不知道 nextState,则重置为 initialValues
|
|
89
89
|
*/
|
|
90
|
-
reset: (
|
|
90
|
+
reset: (nextState?: Partial<FormState<any>>) => Promise<T>;
|
|
91
91
|
/**
|
|
92
92
|
* 对指定表单字段进行校验
|
|
93
93
|
*/
|
|
94
|
-
validateField: (fields
|
|
94
|
+
validateField: (fields: FormFieldPath) => Promise<T>;
|
|
95
95
|
/**
|
|
96
|
-
*
|
|
97
|
-
*/
|
|
98
|
-
validateFields: (fields?: FormFieldPath) => Promise<T>;
|
|
99
|
-
/**
|
|
100
|
-
* 设置表单的值,在异步获取的数据回显的时候,使用该方法
|
|
96
|
+
* 设置某个表单字段的值,在更新表单数据的的时候,使用该方法
|
|
101
97
|
*/
|
|
102
98
|
setFieldValue: (field: FormFieldPath, value: any) => void;
|
|
103
99
|
/**
|
|
104
100
|
* 设置多个表单的值,在异步获取的数据回显的时候,使用该方法
|
|
101
|
+
* TODO
|
|
105
102
|
*/
|
|
106
|
-
setFieldsValue: (field: Record<string, any>) => void;
|
|
103
|
+
setFieldsValue: (field: Record<string, any> | ((prevValues: Record<string, any>) => Record<string, any>)) => void;
|
|
107
104
|
/**
|
|
108
|
-
* 获取一个字段名对应的
|
|
105
|
+
* 获取一个字段名对应的 Value,返回为对应 Field 值
|
|
109
106
|
*/
|
|
110
107
|
getFieldValue: (field: FormFieldPath) => any;
|
|
111
108
|
/**
|
|
112
|
-
* 获取所有字段名对应的 Values
|
|
109
|
+
* 获取所有字段名对应的 Values 返回为字典映射数据结构
|
|
113
110
|
*/
|
|
114
111
|
getFieldsValue: () => any;
|
|
115
112
|
/**
|
|
116
|
-
*
|
|
113
|
+
* 获取一组字段名对应的 errorMessage,返回为对应 field 错误信息
|
|
117
114
|
*/
|
|
118
115
|
getFieldError: (field: FormFieldPath) => any;
|
|
119
116
|
/**
|
|
120
|
-
*
|
|
117
|
+
* 获取所有字段名对应的错误信息,返回为字典映射数据结构
|
|
121
118
|
*/
|
|
122
|
-
getFieldsError: () => any
|
|
119
|
+
getFieldsError: () => FormErrors<any>;
|
|
123
120
|
/**
|
|
124
121
|
* 移除所有表单项的校验结果
|
|
125
122
|
*/
|
|
@@ -127,7 +124,7 @@ export interface FormHelpers<T = any> {
|
|
|
127
124
|
/**
|
|
128
125
|
* 移除表单项的校验结果,传入待移除的表单项的 field 属性组成的数组
|
|
129
126
|
*/
|
|
130
|
-
|
|
127
|
+
clearFieldValidate: (fields: FormFieldPath) => void;
|
|
131
128
|
}
|
|
132
129
|
export declare type FormFieldPath = (string | number)[] | string | number;
|
|
133
130
|
export declare type FormErrorMessage = string;
|
package/lib/types/use-form.d.ts
CHANGED
|
@@ -9,21 +9,22 @@ export declare const useForm: <Values = Record<string, any>>({ initialValues, in
|
|
|
9
9
|
getFieldError: (fieldName: FormFieldPath) => any;
|
|
10
10
|
getFieldRules: (fieldName: FormFieldPath) => any;
|
|
11
11
|
getRootProps: () => {
|
|
12
|
-
onSubmit: (evt?: React.FormEvent<HTMLFormElement> | undefined) => Promise<
|
|
12
|
+
onSubmit: (evt?: React.FormEvent<HTMLFormElement> | undefined) => Promise<any>;
|
|
13
13
|
onReset: (evt?: React.FormEvent<HTMLFormElement> | undefined) => void;
|
|
14
14
|
};
|
|
15
15
|
getFieldProps: (props?: any) => any;
|
|
16
16
|
registerField: (keyOrKeys: FormFieldPath, value: FormFieldCollection<Values>) => void;
|
|
17
17
|
unregisterField: (keyOrKeys: FormFieldPath) => void;
|
|
18
|
-
submitForm: () => Promise<
|
|
18
|
+
submitForm: () => Promise<any>;
|
|
19
19
|
resetForm: (nextState?: Partial<FormState<any>> | undefined) => Promise<void>;
|
|
20
20
|
resetErrors: () => void;
|
|
21
|
+
resetFieldError: (field: FormFieldPath) => void;
|
|
21
22
|
validateFieldState: (field: FormFieldPath) => Promise<{} | undefined>;
|
|
22
23
|
validateValue: (field: FormFieldPath, value: unknown) => Promise<{} | undefined>;
|
|
23
24
|
getFieldsValue: () => any;
|
|
24
|
-
setFieldsValue: (
|
|
25
|
+
setFieldsValue: (fieldsState: Record<string, any> | Function) => void;
|
|
25
26
|
getFieldsError: () => any;
|
|
26
|
-
values:
|
|
27
|
+
values: any;
|
|
27
28
|
errors: FormErrors<unknown>;
|
|
28
29
|
touched: import("./types").FormTouched<unknown>;
|
|
29
30
|
validating: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hi-ui/form",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.25",
|
|
4
4
|
"description": "A sub-package for @hi-ui/hiui.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "HIUI <mi-hiui@xiaomi.com>",
|
|
@@ -43,17 +43,17 @@
|
|
|
43
43
|
"url": "https://github.com/XiaoMi/hiui/issues"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@hi-ui/array-utils": "^4.0.0-beta.
|
|
47
|
-
"@hi-ui/button": "^4.0.0-beta.
|
|
46
|
+
"@hi-ui/array-utils": "^4.0.0-beta.7",
|
|
47
|
+
"@hi-ui/button": "^4.0.0-beta.11",
|
|
48
48
|
"@hi-ui/classname": "^4.0.0-beta.0",
|
|
49
|
-
"@hi-ui/core-css": "^4.0.0-beta.
|
|
50
|
-
"@hi-ui/dom-utils": "^4.0.0-beta.
|
|
49
|
+
"@hi-ui/core-css": "^4.0.0-beta.5",
|
|
50
|
+
"@hi-ui/dom-utils": "^4.0.0-beta.5",
|
|
51
51
|
"@hi-ui/env": "^4.0.0-beta.0",
|
|
52
|
-
"@hi-ui/func-utils": "^4.0.0-beta.
|
|
53
|
-
"@hi-ui/locale-context": "^4.0.0-beta.
|
|
54
|
-
"@hi-ui/object-utils": "^4.0.0-beta.
|
|
55
|
-
"@hi-ui/type-assertion": "^4.0.0-beta.
|
|
56
|
-
"@hi-ui/use-latest": "^4.0.0-beta.
|
|
52
|
+
"@hi-ui/func-utils": "^4.0.0-beta.11",
|
|
53
|
+
"@hi-ui/locale-context": "^4.0.0-beta.17",
|
|
54
|
+
"@hi-ui/object-utils": "^4.0.0-beta.10",
|
|
55
|
+
"@hi-ui/type-assertion": "^4.0.0-beta.4",
|
|
56
|
+
"@hi-ui/use-latest": "^4.0.0-beta.4",
|
|
57
57
|
"async-validator": "^4.0.7"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
@@ -61,9 +61,9 @@
|
|
|
61
61
|
"react-dom": ">=16.8.6"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@hi-ui/hi-build": "^4.0.0-beta.
|
|
64
|
+
"@hi-ui/hi-build": "^4.0.0-beta.4",
|
|
65
65
|
"react": "^17.0.1",
|
|
66
66
|
"react-dom": "^17.0.1"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "674c0457e222285057bb82be5dc1ce6bf081b96c"
|
|
69
69
|
}
|