@sheinx/hooks 3.4.1 → 3.4.2-beta.2
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/cjs/components/use-table/use-table-virtual.d.ts.map +1 -1
- package/cjs/components/use-table/use-table-virtual.js +0 -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/esm/components/use-table/use-table-virtual.d.ts.map +1 -1
- package/esm/components/use-table/use-table-virtual.js +0 -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-table-virtual.d.ts","sourceRoot":"","sources":["use-table-virtual.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,UAAU,oBAAoB;IAC5B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,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FzE,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
@@ -283,8 +283,6 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
283
283
|
}, [startIndex]);
|
284
284
|
(0, _react.useEffect)(function () {
|
285
285
|
// 数据变化的时候清空掉 preIndex, 如果之前有缓存的index, setRowHeight 会有问题
|
286
|
-
setTop(0);
|
287
|
-
setStartIndex(0);
|
288
286
|
return function () {
|
289
287
|
context.preIndex = null;
|
290
288
|
};
|
@@ -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
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-table-virtual.d.ts","sourceRoot":"","sources":["use-table-virtual.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,UAAU,oBAAoB;IAC5B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;CACnC;AACD,QAAA,MAAM,eAAe,UAAW,oBAAoB;;;;;;;oBAqLpC,MAAM;mBACP,MAAM;WACd,MAAM;gBACD,MAAM;kBACJ,OAAO;;0BAzFuB,MAAM,UAAU,MAAM;0BAxBtB,MAAM,QAAQ,MAAM;2BAqJnB,MAAM,aAAa,MAAM,IAAI;
|
1
|
+
{"version":3,"file":"use-table-virtual.d.ts","sourceRoot":"","sources":["use-table-virtual.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,UAAU,oBAAoB;IAC5B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;CACnC;AACD,QAAA,MAAM,eAAe,UAAW,oBAAoB;;;;;;;oBAqLpC,MAAM;mBACP,MAAM;WACd,MAAM;gBACD,MAAM;kBACJ,OAAO;;0BAzFuB,MAAM,UAAU,MAAM;0BAxBtB,MAAM,QAAQ,MAAM;2BAqJnB,MAAM,aAAa,MAAM,IAAI;CA4FzE,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
@@ -277,8 +277,6 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
277
277
|
}, [startIndex]);
|
278
278
|
useEffect(function () {
|
279
279
|
// 数据变化的时候清空掉 preIndex, 如果之前有缓存的index, setRowHeight 会有问题
|
280
|
-
setTop(0);
|
281
|
-
setStartIndex(0);
|
282
280
|
return function () {
|
283
281
|
context.preIndex = null;
|
284
282
|
};
|