@sheinx/hooks 3.1.6 → 3.1.8
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/components/use-form/use-form.d.ts.map +1 -1
- package/cjs/components/use-form/use-form.js +1 -1
- package/cjs/components/use-table/use-table-layout.d.ts.map +1 -1
- package/cjs/components/use-table/use-table-layout.js +6 -5
- package/cjs/utils/immer.d.ts +8 -1
- package/cjs/utils/immer.d.ts.map +1 -1
- package/cjs/utils/immer.js +6 -10
- package/esm/components/use-form/use-form.d.ts.map +1 -1
- package/esm/components/use-form/use-form.js +2 -2
- package/esm/components/use-table/use-table-layout.d.ts.map +1 -1
- package/esm/components/use-table/use-table-layout.js +6 -5
- package/esm/utils/immer.d.ts +8 -1
- package/esm/utils/immer.d.ts.map +1 -1
- package/esm/utils/immer.js +7 -11
- package/package.json +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":";
|
1
|
+
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":";AAuBA,OAAO,EAAe,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC7F,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,QAAA,MAAM,OAAO;;;;;;;;;wBAsJ8B;gBAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;aAAE;8BARzB,MAAM;oCA6CD,OAAO;;6BALb,MAAM,KAAK,KAAK,GAAG,SAAS;;oCAdrB,MAAM,EAAE;sCArEN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;;;;;;oBAmDnD;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;SAAE;0BARzB,MAAM;gCA6CD,OAAO;;yBALb,MAAM,KAAK,KAAK,GAAG,SAAS;;gCAdrB,MAAM,EAAE;kCArEN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;;CAwT7F,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
@@ -401,7 +401,7 @@ var useForm = function useForm(props) {
|
|
401
401
|
React.useEffect(function () {
|
402
402
|
context.removeLock = false;
|
403
403
|
if (props.value === context.lastValue) return;
|
404
|
-
context.value = props.value || emptyObj;
|
404
|
+
context.value = (0, _utils.deepClone)(props.value) || emptyObj;
|
405
405
|
if (initValidate && !context.resetTime) {
|
406
406
|
var keys = Object.keys(context.validateMap).filter(function (key) {
|
407
407
|
var oldValue = (0, _utils.deepGet)(context.lastValue || emptyObj, key);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-table-layout.d.ts","sourceRoot":"","sources":["use-table-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAKlE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAcrE,MAAM,WAAW,mBACf,SAAQ,IAAI,CACV,cAAc,CAAC,GAAG,CAAC,EACnB,MAAM,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,OAAO,CAC7E;IACD,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,QAAA,MAAM,cAAc,UAAW,mBAAmB;;;;;;;;;;;yBA8CX,MAAM,UAAU,MAAM;;;;;;;;
|
1
|
+
{"version":3,"file":"use-table-layout.d.ts","sourceRoot":"","sources":["use-table-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAKlE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAcrE,MAAM,WAAW,mBACf,SAAQ,IAAI,CACV,cAAc,CAAC,GAAG,CAAC,EACnB,MAAM,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,OAAO,CAC7E;IACD,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,QAAA,MAAM,cAAc,UAAW,mBAAmB;;;;;;;;;;;yBA8CX,MAAM,UAAU,MAAM;;;;;;;;CA8N5D,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
@@ -50,7 +50,7 @@ var useTableLayout = function useTableLayout(props) {
|
|
50
50
|
clientWidth: 0
|
51
51
|
}),
|
52
52
|
context = _useRef.current;
|
53
|
-
var _React$useState = _react.default.useState(
|
53
|
+
var _React$useState = _react.default.useState(undefined),
|
54
54
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
55
55
|
isScrollX = _React$useState2[0],
|
56
56
|
setIsScrollX = _React$useState2[1];
|
@@ -58,7 +58,7 @@ var useTableLayout = function useTableLayout(props) {
|
|
58
58
|
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
59
59
|
deltaXSum = _React$useState4[0],
|
60
60
|
setDeltaXSum = _React$useState4[1];
|
61
|
-
var _React$useState5 = _react.default.useState(
|
61
|
+
var _React$useState5 = _react.default.useState(undefined),
|
62
62
|
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
63
63
|
isScrollY = _React$useState6[0],
|
64
64
|
setIsScrollY = _React$useState6[1];
|
@@ -318,7 +318,8 @@ var useTableLayout = function useTableLayout(props) {
|
|
318
318
|
syncScrollWidth();
|
319
319
|
if (scrollRef.current) {
|
320
320
|
cancelFunc = (0, _element.addResizeObserver)(scrollRef.current, handleResize, {
|
321
|
-
direction: true
|
321
|
+
direction: true,
|
322
|
+
timer: 10
|
322
323
|
});
|
323
324
|
}
|
324
325
|
return function () {
|
@@ -338,8 +339,8 @@ var useTableLayout = function useTableLayout(props) {
|
|
338
339
|
}
|
339
340
|
}, [colgroup]);
|
340
341
|
return {
|
341
|
-
isScrollX: isScrollX,
|
342
|
-
isScrollY: isScrollY,
|
342
|
+
isScrollX: !!isScrollX,
|
343
|
+
isScrollY: !!isScrollY,
|
343
344
|
floatLeft: floatLeft,
|
344
345
|
floatRight: floatRight,
|
345
346
|
scrollBarWidth: scrollBarWidth,
|
package/cjs/utils/immer.d.ts
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
import { Draft, PatchListener } from 'immer';
|
1
2
|
export { current } from 'immer';
|
2
|
-
|
3
|
+
declare const NOTHING: unique symbol;
|
4
|
+
type ValidRecipeReturnType<State> = State | void | undefined | (State extends undefined ? typeof NOTHING : never);
|
5
|
+
interface IProduce {
|
6
|
+
<Base, D = Draft<Base>>(// By using a default inferred D, rather than Draft<Base> in the recipe, we can override it.
|
7
|
+
base: Base, recipe: (draft: D) => ValidRecipeReturnType<D>, listener?: PatchListener): Base;
|
8
|
+
}
|
9
|
+
export declare const produce: IProduce;
|
3
10
|
//# sourceMappingURL=immer.d.ts.map
|
package/cjs/utils/immer.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"immer.d.ts","sourceRoot":"","sources":["immer.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"immer.d.ts","sourceRoot":"","sources":["immer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,CAAC,MAAM,OAAO,EAAE,OAAO,MAAM,CAAC;AACrC,KAAK,qBAAqB,CAAC,KAAK,IAC5B,KAAK,GACL,IAAI,GACJ,SAAS,GACT,CAAC,KAAK,SAAS,SAAS,GAAG,OAAO,OAAO,GAAG,KAAK,CAAC,CAAC;AACvD,UAAU,QAAQ;IAChB,CAAC,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,EAAG,4FAA4F;IACnH,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,qBAAqB,CAAC,CAAC,CAAC,EAC9C,QAAQ,CAAC,EAAE,aAAa,GACvB,IAAI,CAAC;CACT;AAED,eAAO,MAAM,OAAO,UAGN,CAAC"}
|
package/cjs/utils/immer.js
CHANGED
@@ -11,14 +11,10 @@ Object.defineProperty(exports, "current", {
|
|
11
11
|
});
|
12
12
|
exports.produce = void 0;
|
13
13
|
var _immer = require("immer");
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
// export const current = getSnapshot;
|
21
|
-
|
22
|
-
var produce = exports.produce = function produce(value, cb) {
|
23
|
-
return (0, _immer.produce)(value, cb);
|
14
|
+
var produce = exports.produce = function produce() {
|
15
|
+
(0, _immer.setAutoFreeze)(false);
|
16
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
17
|
+
args[_key] = arguments[_key];
|
18
|
+
}
|
19
|
+
return _immer.produce.apply(null, args);
|
24
20
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":";
|
1
|
+
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":";AAuBA,OAAO,EAAe,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC7F,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,QAAA,MAAM,OAAO;;;;;;;;;wBAsJ8B;gBAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;aAAE;8BARzB,MAAM;oCA6CD,OAAO;;6BALb,MAAM,KAAK,KAAK,GAAG,SAAS;;oCAdrB,MAAM,EAAE;sCArEN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;;;;;;oBAmDnD;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;SAAE;0BARzB,MAAM;gCA6CD,OAAO;;yBALb,MAAM,KAAK,KAAK,GAAG,SAAS;;gCAdrB,MAAM,EAAE;kCArEN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;;CAwT7F,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
@@ -14,7 +14,7 @@ import usePersistFn from "../../common/use-persist-fn";
|
|
14
14
|
import { getDataAttributeName } from "../../utils/attribute";
|
15
15
|
var globalKey = '__global__&&@@';
|
16
16
|
import { current, produce } from "../../utils/immer";
|
17
|
-
import { deepGet, deepRemove, deepSet, docScroll, extractEventHandlers, isArray, isObject, shallowEqual, wrapFormError } from "../../utils";
|
17
|
+
import { deepGet, deepRemove, deepSet, docScroll, extractEventHandlers, isArray, isObject, shallowEqual, wrapFormError, deepClone } from "../../utils";
|
18
18
|
var emptyObj = {};
|
19
19
|
var useForm = function useForm(props) {
|
20
20
|
var _props$defaultValue = props.defaultValue,
|
@@ -392,7 +392,7 @@ var useForm = function useForm(props) {
|
|
392
392
|
React.useEffect(function () {
|
393
393
|
context.removeLock = false;
|
394
394
|
if (props.value === context.lastValue) return;
|
395
|
-
context.value = props.value || emptyObj;
|
395
|
+
context.value = deepClone(props.value) || emptyObj;
|
396
396
|
if (initValidate && !context.resetTime) {
|
397
397
|
var keys = Object.keys(context.validateMap).filter(function (key) {
|
398
398
|
var oldValue = deepGet(context.lastValue || emptyObj, key);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-table-layout.d.ts","sourceRoot":"","sources":["use-table-layout.tsx"],"names":[],"mappings":"AAAA,OAAO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W,mBAAmB;;;;;;;;;;;yBA8CX,MAAM,UAAU,MAAM;;;;;;;;CA8N5D,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
@@ -41,7 +41,7 @@ var useTableLayout = function useTableLayout(props) {
|
|
41
41
|
clientWidth: 0
|
42
42
|
}),
|
43
43
|
context = _useRef.current;
|
44
|
-
var _React$useState = React.useState(
|
44
|
+
var _React$useState = React.useState(undefined),
|
45
45
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
46
46
|
isScrollX = _React$useState2[0],
|
47
47
|
setIsScrollX = _React$useState2[1];
|
@@ -49,7 +49,7 @@ var useTableLayout = function useTableLayout(props) {
|
|
49
49
|
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
50
50
|
deltaXSum = _React$useState4[0],
|
51
51
|
setDeltaXSum = _React$useState4[1];
|
52
|
-
var _React$useState5 = React.useState(
|
52
|
+
var _React$useState5 = React.useState(undefined),
|
53
53
|
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
54
54
|
isScrollY = _React$useState6[0],
|
55
55
|
setIsScrollY = _React$useState6[1];
|
@@ -309,7 +309,8 @@ var useTableLayout = function useTableLayout(props) {
|
|
309
309
|
syncScrollWidth();
|
310
310
|
if (scrollRef.current) {
|
311
311
|
cancelFunc = addResizeObserver(scrollRef.current, handleResize, {
|
312
|
-
direction: true
|
312
|
+
direction: true,
|
313
|
+
timer: 10
|
313
314
|
});
|
314
315
|
}
|
315
316
|
return function () {
|
@@ -329,8 +330,8 @@ var useTableLayout = function useTableLayout(props) {
|
|
329
330
|
}
|
330
331
|
}, [colgroup]);
|
331
332
|
return {
|
332
|
-
isScrollX: isScrollX,
|
333
|
-
isScrollY: isScrollY,
|
333
|
+
isScrollX: !!isScrollX,
|
334
|
+
isScrollY: !!isScrollY,
|
334
335
|
floatLeft: floatLeft,
|
335
336
|
floatRight: floatRight,
|
336
337
|
scrollBarWidth: scrollBarWidth,
|
package/esm/utils/immer.d.ts
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
import { Draft, PatchListener } from 'immer';
|
1
2
|
export { current } from 'immer';
|
2
|
-
|
3
|
+
declare const NOTHING: unique symbol;
|
4
|
+
type ValidRecipeReturnType<State> = State | void | undefined | (State extends undefined ? typeof NOTHING : never);
|
5
|
+
interface IProduce {
|
6
|
+
<Base, D = Draft<Base>>(// By using a default inferred D, rather than Draft<Base> in the recipe, we can override it.
|
7
|
+
base: Base, recipe: (draft: D) => ValidRecipeReturnType<D>, listener?: PatchListener): Base;
|
8
|
+
}
|
9
|
+
export declare const produce: IProduce;
|
3
10
|
//# sourceMappingURL=immer.d.ts.map
|
package/esm/utils/immer.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"immer.d.ts","sourceRoot":"","sources":["immer.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"immer.d.ts","sourceRoot":"","sources":["immer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,CAAC,MAAM,OAAO,EAAE,OAAO,MAAM,CAAC;AACrC,KAAK,qBAAqB,CAAC,KAAK,IAC5B,KAAK,GACL,IAAI,GACJ,SAAS,GACT,CAAC,KAAK,SAAS,SAAS,GAAG,OAAO,OAAO,GAAG,KAAK,CAAC,CAAC;AACvD,UAAU,QAAQ;IAChB,CAAC,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,EAAG,4FAA4F;IACnH,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,qBAAqB,CAAC,CAAC,CAAC,EAC9C,QAAQ,CAAC,EAAE,aAAa,GACvB,IAAI,CAAC;CACT;AAED,eAAO,MAAM,OAAO,UAGN,CAAC"}
|
package/esm/utils/immer.js
CHANGED
@@ -1,13 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
// export const produce = ((...args: any) => {
|
4
|
-
// return produce2.apply(null, args);
|
5
|
-
// }) as typeof produce2;
|
6
|
-
|
7
|
-
// export const current = getSnapshot;
|
8
|
-
|
9
|
-
import { produce as produce2 } from 'immer';
|
1
|
+
import { produce as produce2, setAutoFreeze } from 'immer';
|
10
2
|
export { current } from 'immer';
|
11
|
-
export var produce = function produce(
|
12
|
-
|
3
|
+
export var produce = function produce() {
|
4
|
+
setAutoFreeze(false);
|
5
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
6
|
+
args[_key] = arguments[_key];
|
7
|
+
}
|
8
|
+
return produce2.apply(null, args);
|
13
9
|
};
|