@sheinx/hooks 3.1.7 → 3.1.8-fix.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"use-Input-able.d.ts","sourceRoot":"","sources":["use-Input-able.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;;;;EAwE3F"}
1
+ {"version":3,"file":"use-Input-able.d.ts","sourceRoot":"","sources":["use-Input-able.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;;;;EAuE3F"}
@@ -45,19 +45,18 @@ function useInputAble(props) {
45
45
  var render = (0, _useRender.useRender)(syncValue);
46
46
  var shouldUseState = delay || !control;
47
47
  var value = shouldUseState ? stateValue : valuePo;
48
- (0, _react.useEffect)(function () {
49
- if (context.timer) {
50
- clearTimeout(context.timer);
51
- context.timer = null;
52
- }
48
+ (0, _react.useLayoutEffect)(function () {
53
49
  if (delay && props.value !== stateValue) {
54
50
  changeStateValue(props.value);
51
+ } else if (context.timer) {
52
+ clearTimeout(context.timer);
53
+ context.timer = null;
55
54
  }
56
55
  }, [props.value, delay]);
57
56
  var forceDelayChange = (0, _usePersistFn.default)(function () {
58
- if (context.timer && context.delayChange) {
57
+ if (context.delayChange) context.delayChange();
58
+ if (context.timer) {
59
59
  clearTimeout(context.timer);
60
- context.delayChange();
61
60
  context.timer = null;
62
61
  context.delayChange = null;
63
62
  }
@@ -1,3 +1,10 @@
1
+ import { Draft, PatchListener } from 'immer';
1
2
  export { current } from 'immer';
2
- export declare const produce: <T>(value: T, cb: (value: T) => void) => T;
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
@@ -1 +1 @@
1
- {"version":3,"file":"immer.d.ts","sourceRoot":"","sources":["immer.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,eAAO,MAAM,OAAO,kCAAmC,IAAI,MAE1D,CAAC"}
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"}
@@ -11,14 +11,10 @@ Object.defineProperty(exports, "current", {
11
11
  });
12
12
  exports.produce = void 0;
13
13
  var _immer = require("immer");
14
- // import { produce as produce2, getSnapshot } from '@shined/reactive/vanilla';
15
-
16
- // export const produce = ((...args: any) => {
17
- // return produce2.apply(null, args);
18
- // }) as typeof produce2;
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-Input-able.d.ts","sourceRoot":"","sources":["use-Input-able.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;;;;EAwE3F"}
1
+ {"version":3,"file":"use-Input-able.d.ts","sourceRoot":"","sources":["use-Input-able.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;;;;EAuE3F"}
@@ -4,7 +4,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
4
4
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
5
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- import { useEffect, useRef, useState } from 'react';
7
+ import { useLayoutEffect, useRef, useState } from 'react';
8
8
  import { isFunc } from "../../utils/is";
9
9
  import { shallowEqual } from "../../utils/shallow-equal";
10
10
  import usePersistFn from "../use-persist-fn";
@@ -38,19 +38,18 @@ export default function useInputAble(props) {
38
38
  var render = useRender(syncValue);
39
39
  var shouldUseState = delay || !control;
40
40
  var value = shouldUseState ? stateValue : valuePo;
41
- useEffect(function () {
42
- if (context.timer) {
43
- clearTimeout(context.timer);
44
- context.timer = null;
45
- }
41
+ useLayoutEffect(function () {
46
42
  if (delay && props.value !== stateValue) {
47
43
  changeStateValue(props.value);
44
+ } else if (context.timer) {
45
+ clearTimeout(context.timer);
46
+ context.timer = null;
48
47
  }
49
48
  }, [props.value, delay]);
50
49
  var forceDelayChange = usePersistFn(function () {
51
- if (context.timer && context.delayChange) {
50
+ if (context.delayChange) context.delayChange();
51
+ if (context.timer) {
52
52
  clearTimeout(context.timer);
53
- context.delayChange();
54
53
  context.timer = null;
55
54
  context.delayChange = null;
56
55
  }
@@ -1,3 +1,10 @@
1
+ import { Draft, PatchListener } from 'immer';
1
2
  export { current } from 'immer';
2
- export declare const produce: <T>(value: T, cb: (value: T) => void) => T;
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
@@ -1 +1 @@
1
- {"version":3,"file":"immer.d.ts","sourceRoot":"","sources":["immer.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,eAAO,MAAM,OAAO,kCAAmC,IAAI,MAE1D,CAAC"}
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"}
@@ -1,13 +1,9 @@
1
- // import { produce as produce2, getSnapshot } from '@shined/reactive/vanilla';
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(value, cb) {
12
- return produce2(value, cb);
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheinx/hooks",
3
- "version": "3.1.7",
3
+ "version": "3.1.8-fix.1",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",