@sheinx/hooks 3.4.0 → 3.4.2-beta.1
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/components/use-form/use-form-control/use-form-control.d.ts.map +1 -1
- package/cjs/components/use-form/use-form-control/use-form-control.js +1 -1
- package/cjs/components/use-form/use-form.d.ts +2 -0
- package/cjs/components/use-form/use-form.d.ts.map +1 -1
- package/cjs/components/use-form/use-form.js +5 -2
- package/esm/components/use-form/use-form-control/use-form-control.d.ts.map +1 -1
- package/esm/components/use-form/use-form-control/use-form-control.js +1 -1
- package/esm/components/use-form/use-form.d.ts +2 -0
- package/esm/components/use-form/use-form.d.ts.map +1 -1
- package/esm/components/use-form/use-form.js +5 -2
- package/package.json +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form-control.d.ts","sourceRoot":"","sources":["use-form-control.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAyB/D,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC;;kBAmHpC,CAAC,YAAY,GAAG,EAAE;;;;;
|
1
|
+
{"version":3,"file":"use-form-control.d.ts","sourceRoot":"","sources":["use-form-control.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAyB/D,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC;;kBAmHpC,CAAC,YAAY,GAAG,EAAE;;;;;EAiDrD"}
|
@@ -201,7 +201,7 @@ function useFormControl(props) {
|
|
201
201
|
}
|
202
202
|
}
|
203
203
|
};
|
204
|
-
}, [name]);
|
204
|
+
}, [name === null || name === void 0 ? void 0 : name.toString()]);
|
205
205
|
(0, _react.useEffect)(function () {
|
206
206
|
updateError((0, _is.isArray)(name) ? name.join('|') : name, error);
|
207
207
|
}, [error]);
|
@@ -12,6 +12,7 @@ declare const useForm: <T extends ObjectType>(props: UseFormProps<T>) => {
|
|
12
12
|
[key: string]: any;
|
13
13
|
}, option?: {
|
14
14
|
validate?: boolean;
|
15
|
+
names?: string[];
|
15
16
|
}) => void;
|
16
17
|
getValue: (name?: string) => unknown;
|
17
18
|
submit: (withValidate?: boolean) => void;
|
@@ -30,6 +31,7 @@ declare const useForm: <T extends ObjectType>(props: UseFormProps<T>) => {
|
|
30
31
|
[key: string]: any;
|
31
32
|
}, option?: {
|
32
33
|
validate?: boolean;
|
34
|
+
names?: string[];
|
33
35
|
}) => void;
|
34
36
|
getValue: (name?: string) => unknown;
|
35
37
|
submit: (withValidate?: boolean) => void;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":";AAyBA,OAAO,
|
1
|
+
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":";AAyBA,OAAO,EAEL,aAAa,EACb,YAAY,EACZ,gBAAgB,EAGjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,QAAA,MAAM,OAAO;;;;;;;;;wBAyKC;gBAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;gBAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;aAAE;8BAVd,MAAM;oCAgED,OAAO;;6BAfb,MAAM,KAAK,KAAK,GAAG,SAAS;;oCAdrB,MAAM,EAAE;sCAhFN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;qCA4I5D,MAAM;gCAzCE,MAAM,SAAS,MAAM,UAAU,KAAK;gCAKpC,MAAM,SAAS,MAAM;;;;;;oBAjDjD;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;SAAE;0BAVd,MAAM;gCAgED,OAAO;;yBAfb,MAAM,KAAK,KAAK,GAAG,SAAS;;gCAdrB,MAAM,EAAE;kCAhFN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;iCA4I5D,MAAM;4BAzCE,MAAM,SAAS,MAAM,UAAU,KAAK;4BAKpC,MAAM,SAAS,MAAM;;CA+P9D,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
@@ -192,12 +192,15 @@ var useForm = function useForm(props) {
|
|
192
192
|
validate: false
|
193
193
|
};
|
194
194
|
onChange(function (draft) {
|
195
|
-
Object.keys(vals)
|
195
|
+
var values = Object.keys(vals);
|
196
|
+
// 针对 name 为数组模式,如 datepicker 的 name={['startTime', 'endTime']} 时,前者校验可能需要依赖后者,因此需要提前将后者数据整合至 draft 用于多字段整合校验
|
197
|
+
var nextDraft = Object.assign({}, (0, _immer.current)(draft), vals);
|
198
|
+
values.forEach(function (key) {
|
196
199
|
(0, _utils.deepSet)(draft, key, vals[key], deepSetOptions);
|
197
200
|
if (option.validate) {
|
198
201
|
var _context$validateMap$;
|
199
202
|
(_context$validateMap$ = context.validateMap[key]) === null || _context$validateMap$ === void 0 || _context$validateMap$.forEach(function (validate) {
|
200
|
-
validate(key, vals[key],
|
203
|
+
validate(key, vals[key], nextDraft);
|
201
204
|
});
|
202
205
|
}
|
203
206
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form-control.d.ts","sourceRoot":"","sources":["use-form-control.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAyB/D,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC;;kBAmHpC,CAAC,YAAY,GAAG,EAAE;;;;;
|
1
|
+
{"version":3,"file":"use-form-control.d.ts","sourceRoot":"","sources":["use-form-control.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAyB/D,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC;;kBAmHpC,CAAC,YAAY,GAAG,EAAE;;;;;EAiDrD"}
|
@@ -192,7 +192,7 @@ export default function useFormControl(props) {
|
|
192
192
|
}
|
193
193
|
}
|
194
194
|
};
|
195
|
-
}, [name]);
|
195
|
+
}, [name === null || name === void 0 ? void 0 : name.toString()]);
|
196
196
|
useEffect(function () {
|
197
197
|
updateError(isArray(name) ? name.join('|') : name, error);
|
198
198
|
}, [error]);
|
@@ -12,6 +12,7 @@ declare const useForm: <T extends ObjectType>(props: UseFormProps<T>) => {
|
|
12
12
|
[key: string]: any;
|
13
13
|
}, option?: {
|
14
14
|
validate?: boolean;
|
15
|
+
names?: string[];
|
15
16
|
}) => void;
|
16
17
|
getValue: (name?: string) => unknown;
|
17
18
|
submit: (withValidate?: boolean) => void;
|
@@ -30,6 +31,7 @@ declare const useForm: <T extends ObjectType>(props: UseFormProps<T>) => {
|
|
30
31
|
[key: string]: any;
|
31
32
|
}, option?: {
|
32
33
|
validate?: boolean;
|
34
|
+
names?: string[];
|
33
35
|
}) => void;
|
34
36
|
getValue: (name?: string) => unknown;
|
35
37
|
submit: (withValidate?: boolean) => void;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":";AAyBA,OAAO,
|
1
|
+
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":";AAyBA,OAAO,EAEL,aAAa,EACb,YAAY,EACZ,gBAAgB,EAGjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,QAAA,MAAM,OAAO;;;;;;;;;wBAyKC;gBAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;gBAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;aAAE;8BAVd,MAAM;oCAgED,OAAO;;6BAfb,MAAM,KAAK,KAAK,GAAG,SAAS;;oCAdrB,MAAM,EAAE;sCAhFN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;qCA4I5D,MAAM;gCAzCE,MAAM,SAAS,MAAM,UAAU,KAAK;gCAKpC,MAAM,SAAS,MAAM;;;;;;oBAjDjD;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;SAAE;0BAVd,MAAM;gCAgED,OAAO;;yBAfb,MAAM,KAAK,KAAK,GAAG,SAAS;;gCAdrB,MAAM,EAAE;kCAhFN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;iCA4I5D,MAAM;4BAzCE,MAAM,SAAS,MAAM,UAAU,KAAK;4BAKpC,MAAM,SAAS,MAAM;;CA+P9D,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
@@ -183,12 +183,15 @@ var useForm = function useForm(props) {
|
|
183
183
|
validate: false
|
184
184
|
};
|
185
185
|
onChange(function (draft) {
|
186
|
-
Object.keys(vals)
|
186
|
+
var values = Object.keys(vals);
|
187
|
+
// 针对 name 为数组模式,如 datepicker 的 name={['startTime', 'endTime']} 时,前者校验可能需要依赖后者,因此需要提前将后者数据整合至 draft 用于多字段整合校验
|
188
|
+
var nextDraft = Object.assign({}, current(draft), vals);
|
189
|
+
values.forEach(function (key) {
|
187
190
|
deepSet(draft, key, vals[key], deepSetOptions);
|
188
191
|
if (option.validate) {
|
189
192
|
var _context$validateMap$;
|
190
193
|
(_context$validateMap$ = context.validateMap[key]) === null || _context$validateMap$ === void 0 || _context$validateMap$.forEach(function (validate) {
|
191
|
-
validate(key, vals[key],
|
194
|
+
validate(key, vals[key], nextDraft);
|
192
195
|
});
|
193
196
|
}
|
194
197
|
});
|