@tamagui/use-debounce 1.135.4 → 1.135.5
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/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.native.js +42 -41
- package/dist/cjs/index.native.js.map +1 -6
- package/package.json +3 -2
- package/types/index.d.ts +0 -1
- package/types/index.d.ts.map +2 -11
package/dist/cjs/index.cjs
CHANGED
|
@@ -36,7 +36,7 @@ __export(index_exports, {
|
|
|
36
36
|
useDebounceValue: () => useDebounceValue
|
|
37
37
|
});
|
|
38
38
|
module.exports = __toCommonJS(index_exports);
|
|
39
|
-
var React = __toESM(require("react"));
|
|
39
|
+
var React = __toESM(require("react"), 1);
|
|
40
40
|
function debounce(func, wait, leading) {
|
|
41
41
|
let timeout,
|
|
42
42
|
isCancelled = !1;
|
package/dist/cjs/index.js
CHANGED
|
@@ -27,7 +27,7 @@ __export(index_exports, {
|
|
|
27
27
|
useDebounceValue: () => useDebounceValue
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(index_exports);
|
|
30
|
-
var React = __toESM(require("react"));
|
|
30
|
+
var React = __toESM(require("react"), 1);
|
|
31
31
|
function debounce(func, wait, leading) {
|
|
32
32
|
let timeout, isCancelled = !1;
|
|
33
33
|
function debounced() {
|
package/dist/cjs/index.native.js
CHANGED
|
@@ -1,26 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf,
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf,
|
|
8
|
+
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
9
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: !0
|
|
13
|
+
});
|
|
14
|
+
},
|
|
15
|
+
__copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
16
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
23
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
24
|
// file that has been converted to a CommonJS file using a Babel-
|
|
19
25
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
26
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: !0
|
|
30
|
+
}) : target, mod)),
|
|
31
|
+
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: !0
|
|
33
|
+
}), mod);
|
|
24
34
|
var index_exports = {};
|
|
25
35
|
__export(index_exports, {
|
|
26
36
|
debounce: () => debounce,
|
|
@@ -28,18 +38,19 @@ __export(index_exports, {
|
|
|
28
38
|
useDebounceValue: () => useDebounceValue
|
|
29
39
|
});
|
|
30
40
|
module.exports = __toCommonJS(index_exports);
|
|
31
|
-
var React = __toESM(require("react"));
|
|
41
|
+
var React = __toESM(require("react"), 1);
|
|
32
42
|
function debounce(func, wait, leading) {
|
|
33
|
-
var timeout,
|
|
43
|
+
var timeout,
|
|
44
|
+
isCancelled = !1;
|
|
34
45
|
function debounced() {
|
|
35
46
|
var _this = this;
|
|
36
47
|
isCancelled = !1;
|
|
37
48
|
var args = arguments;
|
|
38
|
-
leading && !timeout && func.apply(this, args), clearTimeout(timeout), timeout = setTimeout(function() {
|
|
49
|
+
leading && !timeout && func.apply(this, args), clearTimeout(timeout), timeout = setTimeout(function () {
|
|
39
50
|
timeout = null, leading || isCancelled || func.apply(_this, args), isCancelled = !1;
|
|
40
51
|
}, wait);
|
|
41
52
|
}
|
|
42
|
-
return debounced.cancel = function() {
|
|
53
|
+
return debounced.cancel = function () {
|
|
43
54
|
isCancelled = !0;
|
|
44
55
|
}, debounced;
|
|
45
56
|
}
|
|
@@ -47,40 +58,30 @@ var defaultOpts = {
|
|
|
47
58
|
leading: !1
|
|
48
59
|
};
|
|
49
60
|
function useDebounce(fn, wait) {
|
|
50
|
-
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : defaultOpts,
|
|
51
|
-
fn
|
|
52
|
-
|
|
53
|
-
return React.useEffect(function() {
|
|
54
|
-
return function() {
|
|
61
|
+
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : defaultOpts,
|
|
62
|
+
mountArgs = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : [fn],
|
|
63
|
+
dbEffect = React.useRef(null);
|
|
64
|
+
return React.useEffect(function () {
|
|
65
|
+
return function () {
|
|
55
66
|
var _dbEffect_current;
|
|
56
67
|
(_dbEffect_current = dbEffect.current) === null || _dbEffect_current === void 0 || _dbEffect_current.cancel();
|
|
57
68
|
};
|
|
58
|
-
}, []), React.useMemo(function() {
|
|
69
|
+
}, []), React.useMemo(function () {
|
|
59
70
|
return dbEffect.current = debounce(fn, wait, options.leading), dbEffect.current;
|
|
60
|
-
}, [
|
|
61
|
-
options.leading,
|
|
62
|
-
...mountArgs
|
|
63
|
-
]);
|
|
71
|
+
}, [options.leading, ...mountArgs]);
|
|
64
72
|
}
|
|
65
73
|
function useDebounceValue(val) {
|
|
66
|
-
var amt = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
var amt = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0,
|
|
75
|
+
[state, setState] = React.useState(val);
|
|
76
|
+
return React.useEffect(function () {
|
|
77
|
+
var tm = setTimeout(function () {
|
|
78
|
+
setState(function (prev) {
|
|
70
79
|
return prev === val ? prev : val;
|
|
71
80
|
});
|
|
72
81
|
}, amt);
|
|
73
|
-
return function() {
|
|
82
|
+
return function () {
|
|
74
83
|
clearTimeout(tm);
|
|
75
84
|
};
|
|
76
|
-
}, [
|
|
77
|
-
val
|
|
78
|
-
]), state;
|
|
85
|
+
}, [val]), state;
|
|
79
86
|
}
|
|
80
|
-
|
|
81
|
-
0 && (module.exports = {
|
|
82
|
-
debounce,
|
|
83
|
-
useDebounce,
|
|
84
|
-
useDebounceValue
|
|
85
|
-
});
|
|
86
|
-
//# sourceMappingURL=index.js.map
|
|
87
|
+
//# sourceMappingURL=index.native.js.map
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/index.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB;AAEhB,SAAS,SAAS,MAAM,MAAM,SAAS;AAC1C,MAAI,SACA,cAAc;AAClB,WAAS,YAAY;AACjB,QAAI,QAAQ;AACZ,kBAAc;AACd,QAAI,OAAO;AACX,IAAI,WAAW,CAAC,WACZ,KAAK,MAAM,MAAM,IAAI,GAEzB,aAAa,OAAO,GACpB,UAAU,WAAW,WAAW;AAC5B,gBAAU,MACJ,WAAW,eACb,KAAK,MAAM,OAAO,IAAI,GAE1B,cAAc;AAAA,IAClB,GAAG,IAAI;AAAA,EACX;AACA,mBAAU,SAAS,WAAW;AAC1B,kBAAc;AAAA,EAClB,GACO;AACX;AACA,IAAI,cAAc;AAAA,EACd,SAAS;AACb;AACO,SAAS,YAAY,IAAI,MAAM;AAClC,MAAI,UAAU,UAAU,SAAS,KAAK,UAAU,CAAC,MAAM,SAAS,UAAU,CAAC,IAAI,aAAa,YAAY,UAAU,SAAS,KAAK,UAAU,CAAC,MAAM,SAAS,UAAU,CAAC,IAAI;AAAA,IACrK;AAAA,EACJ,GACI,WAAW,MAAM,OAAO,IAAI;AAChC,eAAM,UAAU,WAAW;AACvB,WAAO,WAAW;AACd,UAAI;AACJ,OAAC,oBAAoB,SAAS,aAAa,QAAQ,sBAAsB,UAAkB,kBAAkB,OAAO;AAAA,IACxH;AAAA,EACJ,GAAG,CAAC,CAAC,GACE,MAAM,QAAQ,WAAW;AAC5B,oBAAS,UAAU,SAAS,IAAI,MAAM,QAAQ,OAAO,GAC9C,SAAS;AAAA,EACpB,GAAG;AAAA,IACC,QAAQ;AAAA,IACR,GAAG;AAAA,EACP,CAAC;AACL;AAIW,SAAS,iBAAiB,KAAK;AACtC,MAAI,MAAM,UAAU,SAAS,KAAK,UAAU,CAAC,MAAM,SAAS,UAAU,CAAC,IAAI,GACvE,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAS,GAAG;AAC1C,eAAM,UAAU,WAAW;AACvB,QAAI,KAAK,WAAW,WAAW;AAC3B,eAAS,SAAS,MAAM;AACpB,eAAI,SAAS,MAAY,OAClB;AAAA,MACX,CAAC;AAAA,IACL,GAAG,GAAG;AACN,WAAO,WAAW;AACd,mBAAa,EAAE;AAAA,IACnB;AAAA,EACJ,GAAG;AAAA,IACC;AAAA,EACJ,CAAC,GACM;AACX;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","__export","debounce","useDebounce","useDebounceValue","module","exports","React","__toESM","require","func","wait","leading","timeout","isCancelled","debounced","_this","args","arguments","apply","clearTimeout","setTimeout","cancel","defaultOpts","fn","options","length","mountArgs","dbEffect","useRef","useEffect","_dbEffect_current","current","useMemo"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAAA;EAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;IAAAC,KAAA;EAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,QAAA,CAAAD,aAAA;EAAAE,QAAA,EAAAA,CAAA,KAAAA,QAAA;EAAAC,WAAA,EAAAA,CAAA,KAAAA,WAAA;EAAAC,gBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAuB,GAAAX,YAAA,CAAAK,aAAA;AAQhB,IAAAO,KAAS,GAAAC,OACd,CAAAC,OACA,QACA,IAGA;AACA,SAAIP,QACAA,CAAAQ,IAAA,EAAAC,IAAA,EAAcC,OAAA;EAElB,IAAAC,OAAS;IAAAC,WAAqB;EAC5B,SAAAC,SAAcA,CAAA;IACd,IAAAC,KAAM,OAAO;IACTF,WAAW,GAAC;IAKd,IAAAG,IAAA,GAAAC,SACM;IAIRN,OAAO,KAAAC,OAAA,IAAAH,IAAA,CAAAS,KAAA,OAAAF,IAAA,GAAAG,YAAA,CAAAP,OAAA,GAAAA,OAAA,GAAAQ,UAAA;MACTR,OAAA,SAAAD,OAAA,IAAAE,WAAA,IAAAJ,IAAA,CAAAS,KAAA,CAAAH,KAAA,EAAAC,IAAA,GAAAH,WAAA;IAEA,GAAAH,IAAA;EACE;EACF,OAEOI,SAAA,CAAAO,MAAA;IACTR,WAAA;EAEA,GAAAC,SAAM;AAEC;AAWL,IAAAQ,WAAM;EAENX,OAAA;AAEI;AAAyB,SAExBT,WAEQA,CAAAqB,EAAA,EAAQb,IAAA,EACnB;EAGJ,IAAAc,OAAA,GAAAP,SAAA,CAAAQ,MAAA,QAAAR,SAAA,iBAAAA,SAAA,MAAAK,WAAA;IAAAI,SAAA,GAAAT,SAAA,CAAAQ,MAAA,QAAAR,SAAA,iBAAAA,SAAA,OAMOM,EAAA,CACL;IAAAI,QAAO,GAAOrB,KAAA,CAAAsB,MAAY,MAAM;EAEhC,OAAAtB,KAAA,CAAMuB,SAAA,CAAU,YAAM;IACpB,OAAM,YAAK;MACT,IAAAC,iBACM;MAGR,CAAGA,iBAAG,GAAAH,QAAA,CAAAI,OAAA,cAAAD,iBAAA,eAAAA,iBAAA,CAAAT,MAAA;IAEN;EACE,QAAAf,KAAA,CAAA0B,OAAe;IACjB,OAAAL,QAAA,CAAAI,OAAA,GAAA9B,QAAA,CAAAsB,EAAA,EAAAb,IAAA,EAAAc,OAAA,CAAAb,OAAA,GAAAgB,QAAA,CAAAI,OAAA;EACF,GAAG,CAGLP,OAAA,CAAAb,OAAA,E","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/use-debounce",
|
|
3
|
-
"version": "1.135.
|
|
3
|
+
"version": "1.135.5",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"types": "./types/index.d.ts",
|
|
5
6
|
"main": "dist/cjs",
|
|
6
7
|
"module": "dist/esm",
|
|
@@ -31,7 +32,7 @@
|
|
|
31
32
|
}
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
|
-
"@tamagui/build": "1.135.
|
|
35
|
+
"@tamagui/build": "1.135.5",
|
|
35
36
|
"react": "*"
|
|
36
37
|
},
|
|
37
38
|
"publishConfig": {
|
package/types/index.d.ts
CHANGED
package/types/index.d.ts.map
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"mappings": "KAEK,mBAAmB;CACtB
|
|
3
|
-
"names": [
|
|
4
|
-
"func: A",
|
|
5
|
-
"wait?: number",
|
|
6
|
-
"leading?: boolean",
|
|
7
|
-
"fn: A",
|
|
8
|
-
"wait: number",
|
|
9
|
-
"options: DebounceSettings",
|
|
10
|
-
"mountArgs: any[]",
|
|
11
|
-
"val: A"
|
|
12
|
-
],
|
|
2
|
+
"mappings": "KAEK,mBAAmB;CACtB;;AAKF,OAAO,iBAAS,SAAS,UAAU,UACjC,MAAM,GACN,eACA,oBACC,IAAI;CACL;;AA8BF,OAAO,iBAAS;CACd,WAAW,GAAG;CACd,oBAAoB,IAAI;EACtB;;EAGF,IAAI,GACJ,cACA,UAAS,kBACT,oBACC;;;;;AAmBH,OAAO,iBAAS,iBAAiB,GAAG,KAAK,GAAG,eAAU",
|
|
3
|
+
"names": [],
|
|
13
4
|
"sources": [
|
|
14
5
|
"src/index.ts"
|
|
15
6
|
],
|