@tamagui/use-event 2.0.0-rc.4 → 2.0.0-rc.40
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 +7 -5
- package/dist/cjs/index.native.js +7 -5
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/useEvent.cjs +13 -11
- package/dist/cjs/useEvent.native.js +13 -11
- package/dist/cjs/useEvent.native.js.map +1 -1
- package/dist/cjs/useGet.cjs +30 -26
- package/dist/cjs/useGet.native.js +34 -28
- package/dist/cjs/useGet.native.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -6
- package/dist/esm/useEvent.mjs +1 -1
- package/dist/esm/useEvent.mjs.map +1 -1
- package/dist/esm/useEvent.native.js +1 -1
- package/dist/esm/useEvent.native.js.map +1 -1
- package/dist/esm/useGet.mjs +5 -3
- package/dist/esm/useGet.mjs.map +1 -1
- package/dist/esm/useGet.native.js +9 -5
- package/dist/esm/useGet.native.js.map +1 -1
- package/package.json +6 -11
- package/src/useGet.ts +11 -2
- package/types/index.d.ts.map +2 -2
- package/types/useEvent.d.ts.map +2 -2
- package/types/useGet.d.ts.map +4 -4
- package/dist/cjs/index.js +0 -16
- package/dist/cjs/index.js.map +0 -6
- package/dist/cjs/useEvent.js +0 -27
- package/dist/cjs/useEvent.js.map +0 -6
- package/dist/cjs/useGet.js +0 -38
- package/dist/cjs/useGet.js.map +0 -6
- package/dist/esm/useEvent.js +0 -11
- package/dist/esm/useEvent.js.map +0 -6
- package/dist/esm/useGet.js +0 -15
- package/dist/esm/useGet.js.map +0 -6
package/dist/cjs/index.cjs
CHANGED
|
@@ -3,15 +3,17 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
7
8
|
get: () => from[key],
|
|
8
9
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
9
10
|
});
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
13
15
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
14
|
-
value:
|
|
16
|
+
value: true
|
|
15
17
|
}), mod);
|
|
16
18
|
var index_exports = {};
|
|
17
19
|
module.exports = __toCommonJS(index_exports);
|
package/dist/cjs/index.native.js
CHANGED
|
@@ -5,15 +5,17 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __copyProps = (to, from, except, desc) => {
|
|
8
|
-
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
9
10
|
get: () => from[key],
|
|
10
11
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
11
12
|
});
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
17
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
16
|
-
value:
|
|
18
|
+
value: true
|
|
17
19
|
}), mod);
|
|
18
20
|
var index_exports = {};
|
|
19
21
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__copyProps","to","from","except","desc","key","call","get","enumerable","__reExport","target","mod","secondTarget","__toCommonJS","value","index_exports","module","exports","require"],"sources":["index.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, \"default\"), secondTarget && __copyProps(secondTarget, mod, \"default\"));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar index_exports = {};\nmodule.exports = __toCommonJS(index_exports);\n__reExport(index_exports, require(\"./useEvent\"), module.exports);\n__reExport(index_exports, require(\"./useGet\"), module.exports);\n//# sourceMappingURL=index.js.map\n"],"mappings":"AAAA,YAAY;;AACZ,IAAIA,SAAS,GAAGC,MAAM,CAACC,cAAc;AACrC,IAAIC,gBAAgB,GAAGF,MAAM,CAACG,wBAAwB;AACtD,IAAIC,iBAAiB,GAAGJ,MAAM,CAACK,mBAAmB;AAClD,IAAIC,YAAY,GAAGN,MAAM,CAACO,SAAS,CAACC,cAAc;AAClD,IAAIC,WAAW,GAAGA,CAACC,EAAE,EAAEC,IAAI,EAAEC,MAAM,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OwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
14
|
get: () => from[key],
|
|
14
15
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
18
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value:
|
|
21
|
+
value: true
|
|
20
22
|
}), mod);
|
|
21
23
|
var useEvent_exports = {};
|
|
22
24
|
__export(useEvent_exports, {
|
|
@@ -25,7 +27,7 @@ __export(useEvent_exports, {
|
|
|
25
27
|
module.exports = __toCommonJS(useEvent_exports);
|
|
26
28
|
var import_useGet = require("./useGet.cjs");
|
|
27
29
|
function useEvent(callback) {
|
|
28
|
-
return (0, import_useGet.useGet)(callback, defaultValue,
|
|
30
|
+
return (0, import_useGet.useGet)(callback, defaultValue, true);
|
|
29
31
|
}
|
|
30
32
|
const defaultValue = () => {
|
|
31
33
|
throw new Error("Cannot call an event handler while rendering.");
|
|
@@ -5,20 +5,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value:
|
|
23
|
+
value: true
|
|
22
24
|
}), mod);
|
|
23
25
|
var useEvent_exports = {};
|
|
24
26
|
__export(useEvent_exports, {
|
|
@@ -27,7 +29,7 @@ __export(useEvent_exports, {
|
|
|
27
29
|
module.exports = __toCommonJS(useEvent_exports);
|
|
28
30
|
var import_useGet = require("./useGet.native.js");
|
|
29
31
|
function useEvent(callback) {
|
|
30
|
-
return (0, import_useGet.useGet)(callback, defaultValue,
|
|
32
|
+
return (0, import_useGet.useGet)(callback, defaultValue, true);
|
|
31
33
|
}
|
|
32
34
|
var defaultValue = function () {
|
|
33
35
|
throw new Error("Cannot call an event handler while rendering.");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toCommonJS","mod","value","useEvent_exports","useEvent","module","exports","import_useGet","require","callback","useGet","defaultValue","Error"],"sources":["useEvent.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar useEvent_exports = {};\n__export(useEvent_exports, {\n useEvent: () => useEvent\n});\nmodule.exports = __toCommonJS(useEvent_exports);\nvar import_useGet = require(\"./useGet\");\nfunction useEvent(callback) {\n return (0, import_useGet.useGet)(callback, defaultValue, true);\n}\nvar defaultValue = function() {\n throw new Error(\"Cannot call an event handler while rendering.\");\n};\n//# sourceMappingURL=useEvent.js.map\n"],"mappings":"AAAA,YAAY;;AACZ,IAAIA,SAAS,GAAGC,MAAM,CAACC,cAAc;AACrC,IAAIC,gBAAgB,GAAGF,MAAM,CAACG,wBAAwB;AACtD,IAAIC,iBAAiB,GAAGJ,MAAM,CAACK,mBAAmB;AAClD,IAAIC,YAAY,GAAGN,MAAM,CAACO,SAAS,CAACC,cAAc;AAClD,IAAIC,QAAQ,GAAGA,CAACC,MAAM,EAAEC,GAAG,KAAK;EAC9B,KAAK,IAAIC,IAAI,IAAID,GAAG,EAClBZ,SAAS,CAACW,MAAM,EAAEE,IAAI,EAAE;IAAEC,GAAG,EAAEF,GAAG,CAACC,IAAI,CAAC;IAAEE,UAAU,EAAE;EAAK,CAAC,CAAC;AACjE,CAAC;A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]}
|
package/dist/cjs/useGet.cjs
CHANGED
|
@@ -2,43 +2,47 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
6
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
32
34
|
var useGet_exports = {};
|
|
33
35
|
__export(useGet_exports, {
|
|
34
36
|
useGet: () => useGet
|
|
35
37
|
});
|
|
36
38
|
module.exports = __toCommonJS(useGet_exports);
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
+
var React = __toESM(require("react"), 1);
|
|
40
|
+
const isServer = typeof window === "undefined";
|
|
41
|
+
const useIsomorphicInsertionEffect = isServer ? React.useEffect : React.useInsertionEffect || React.useLayoutEffect;
|
|
39
42
|
function useGet(currentValue, initialValue, forwardToFunction) {
|
|
40
43
|
const curRef = React.useRef(initialValue ?? currentValue);
|
|
41
|
-
|
|
44
|
+
useIsomorphicInsertionEffect(() => {
|
|
42
45
|
curRef.current = currentValue;
|
|
43
|
-
})
|
|
46
|
+
});
|
|
47
|
+
return React.useCallback(forwardToFunction ? (...args) => curRef.current?.apply(null, args) : () => curRef.current, []);
|
|
44
48
|
}
|
|
@@ -4,46 +4,52 @@ var __create = Object.create;
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
8
|
-
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __export = (target, all) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
18
|
get: () => from[key],
|
|
18
19
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
20
|
});
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
22
24
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
+
value: mod,
|
|
31
|
+
enumerable: true
|
|
32
|
+
}) : target, mod));
|
|
33
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
+
value: true
|
|
35
|
+
}), mod);
|
|
34
36
|
var useGet_exports = {};
|
|
35
37
|
__export(useGet_exports, {
|
|
36
38
|
useGet: () => useGet
|
|
37
39
|
});
|
|
38
40
|
module.exports = __toCommonJS(useGet_exports);
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
+
var React = __toESM(require("react"), 1);
|
|
42
|
+
var isServer = typeof window === "undefined";
|
|
43
|
+
var useIsomorphicInsertionEffect = isServer ? React.useEffect : React.useInsertionEffect || React.useLayoutEffect;
|
|
41
44
|
function useGet(currentValue, initialValue, forwardToFunction) {
|
|
42
|
-
var curRef = React.useRef(initialValue
|
|
43
|
-
|
|
45
|
+
var curRef = React.useRef(initialValue !== null && initialValue !== void 0 ? initialValue : currentValue);
|
|
46
|
+
useIsomorphicInsertionEffect(function () {
|
|
44
47
|
curRef.current = currentValue;
|
|
45
|
-
})
|
|
46
|
-
|
|
48
|
+
});
|
|
49
|
+
return React.useCallback(forwardToFunction ? function () {
|
|
50
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
51
|
+
args[_key] = arguments[_key];
|
|
52
|
+
}
|
|
47
53
|
var _curRef_current;
|
|
48
54
|
return (_curRef_current = curRef.current) === null || _curRef_current === void 0 ? void 0 : _curRef_current.apply(null, args);
|
|
49
55
|
} : function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toESM","mod","isNodeMode","__esModule","value","__toCommonJS","useGet_exports","useGet","module","exports","React","require","isServer","window","useIsomorphicInsertionEffect","useEffect","useInsertionEffect","useLayoutEffect","currentValue","initialValue","forwardToFunction","curRef","useRef","current","useCallback","_len","arguments","length","args","Array","_key","_curRef_current","apply"],"sources":["useGet.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar useGet_exports = {};\n__export(useGet_exports, {\n useGet: () => useGet\n});\nmodule.exports = __toCommonJS(useGet_exports);\nvar React = __toESM(require(\"react\"), 1);\nvar isServer = typeof window === \"undefined\";\nvar useIsomorphicInsertionEffect = isServer ? React.useEffect : React.useInsertionEffect || React.useLayoutEffect;\nfunction useGet(currentValue, initialValue, forwardToFunction) {\n var curRef = React.useRef(initialValue !== null && initialValue !== void 0 ? initialValue : currentValue);\n useIsomorphicInsertionEffect(function() {\n curRef.current = currentValue;\n });\n return React.useCallback(forwardToFunction ? function() {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n var _curRef_current;\n return (_curRef_current = curRef.current) === null || _curRef_current === void 0 ? void 0 : _curRef_current.apply(null, args);\n } : function() {\n return curRef.current;\n }, []);\n}\n//# sourceMappingURL=useGet.js.map\n"],"mappings":"AAAA,YAAY;;AACZ,IAAIA,QAAQ,GAAGC,MAAM,CAACC,MAAM;AAC5B,IAAIC,SAAS,GAAGF,MAAM,CAACG,cAAc;AACrC,IAAIC,gBAAgB,GAAGJ,MAAM,CAACK,wBAAwB;AACtD,IAAIC,iBAAiB,GAAGN,MAAM,CAACO,mBAAmB;AAClD,IA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I,CAAC,GAAGJ,SAAS,CAACI,IAAI,CAAC;IAC9B;IACA,IAAIC,eAAe;IACnB,OAAO,CAACA,eAAe,GAAGV,MAAM,CAACE,OAAO,MAAM,IAAI,IAAIQ,eAAe,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAGA,eAAe,CAACC,KAAK,CAAC,IAAI,EAAEJ,IAAI,CAAC;EAC/H,CAAC,GAAG,YAAW;IACb,OAAOP,MAAM,CAACE,OAAO;EACvB,CAAC,EAAE,EAAE,CAAC;AACR","ignoreList":[]}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./useEvent";
|
|
2
|
-
export * from "./useGet";
|
|
1
|
+
export * from "./useEvent.mjs";
|
|
2
|
+
export * from "./useGet.mjs";
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
package/dist/esm/useEvent.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useGet","useEvent","callback","defaultValue","Error"],"sources":["../../src/useEvent.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAA,QAAc;AAIhB,SAASC,SAAgCC,QAAA,EAAiB;EAC/D,OAAOF,MAAA,CAAOE,QAAA,EAAUC,YAAA,EAAc,
|
|
1
|
+
{"version":3,"names":["useGet","useEvent","callback","defaultValue","Error"],"sources":["../../src/useEvent.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAA,QAAc;AAIhB,SAASC,SAAgCC,QAAA,EAAiB;EAC/D,OAAOF,MAAA,CAAOE,QAAA,EAAUC,YAAA,EAAc,IAAI;AAC5C;AAEA,MAAMA,YAAA,GAAeA,CAAA,KAAM;EACzB,MAAM,IAAIC,KAAA,CAAM,+CAA+C;AACjE","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useGet } from "./useGet.native.js";
|
|
2
2
|
function useEvent(callback) {
|
|
3
|
-
return useGet(callback, defaultValue,
|
|
3
|
+
return useGet(callback, defaultValue, true);
|
|
4
4
|
}
|
|
5
5
|
var defaultValue = function () {
|
|
6
6
|
throw new Error("Cannot call an event handler while rendering.");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useGet","useEvent","callback","defaultValue","Error"],"sources":["../../src/useEvent.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAA,QAAc;AAIhB,SAASC,SAAgCC,QAAA,EAAiB;EAC/D,OAAOF,MAAA,CAAOE,QAAA,EAAUC,YAAA,EAAc,
|
|
1
|
+
{"version":3,"names":["useGet","useEvent","callback","defaultValue","Error"],"sources":["../../src/useEvent.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAA,QAAc;AAIhB,SAASC,SAAgCC,QAAA,EAAiB;EAC/D,OAAOF,MAAA,CAAOE,QAAA,EAAUC,YAAA,EAAc,IAAI;AAC5C;AAEA,IAAAA,YAAM,YAAAA,CAAA,EAAqB;EACzB,MAAM,IAAIC,KAAA,CAAM,+CAA+C;AACjE","ignoreList":[]}
|
package/dist/esm/useGet.mjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
2
1
|
import * as React from "react";
|
|
2
|
+
const isServer = typeof window === "undefined";
|
|
3
|
+
const useIsomorphicInsertionEffect = isServer ? React.useEffect : React.useInsertionEffect || React.useLayoutEffect;
|
|
3
4
|
function useGet(currentValue, initialValue, forwardToFunction) {
|
|
4
5
|
const curRef = React.useRef(initialValue ?? currentValue);
|
|
5
|
-
|
|
6
|
+
useIsomorphicInsertionEffect(() => {
|
|
6
7
|
curRef.current = currentValue;
|
|
7
|
-
})
|
|
8
|
+
});
|
|
9
|
+
return React.useCallback(forwardToFunction ? (...args) => curRef.current?.apply(null, args) : () => curRef.current, []);
|
|
8
10
|
}
|
|
9
11
|
export { useGet };
|
|
10
12
|
//# sourceMappingURL=useGet.mjs.map
|
package/dist/esm/useGet.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["React","isServer","window","useIsomorphicInsertionEffect","useEffect","useInsertionEffect","useLayoutEffect","useGet","currentValue","initialValue","forwardToFunction","curRef","useRef","current","useCallback","args","apply"],"sources":["../../src/useGet.ts"],"sourcesContent":[null],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAEvB,MAAMC,QAAA,GAAW,OAAOC,MAAA,KAAW;AAMnC,MAAMC,4BAAA,GAA+BF,QAAA,GACjCD,KAAA,CAAMI,SAAA,GACNJ,KAAA,CAAMK,kBAAA,IAAsBL,KAAA,CAAMM,eAAA;AAI/B,SAASC,OACdC,YAAA,EACAC,YAAA,EACAC,iBAAA,EACS;EACT,MAAMC,MAAA,GAASX,KAAA,CAAMY,MAAA,CAAYH,YAAA,IAAgBD,YAAY;EAC7DL,4BAAA,CAA6B,MAAM;IACjCQ,MAAA,CAAOE,OAAA,GAAUL,YAAA;EACnB,CAAC;EAED,OAAOR,KAAA,CAAMc,WAAA,CACXJ,iBAAA,GACI,IAAIK,IAAA,KAASJ,MAAA,CAAOE,OAAA,EAASG,KAAA,CAAM,MAAMD,IAAI,IAC7C,MAAMJ,MAAA,CAAOE,OAAA,EACjB,EACF;AACF","ignoreList":[]}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
2
1
|
import * as React from "react";
|
|
2
|
+
var isServer = typeof window === "undefined";
|
|
3
|
+
var useIsomorphicInsertionEffect = isServer ? React.useEffect : React.useInsertionEffect || React.useLayoutEffect;
|
|
3
4
|
function useGet(currentValue, initialValue, forwardToFunction) {
|
|
4
|
-
var curRef = React.useRef(initialValue
|
|
5
|
-
|
|
5
|
+
var curRef = React.useRef(initialValue !== null && initialValue !== void 0 ? initialValue : currentValue);
|
|
6
|
+
useIsomorphicInsertionEffect(function () {
|
|
6
7
|
curRef.current = currentValue;
|
|
7
|
-
})
|
|
8
|
-
|
|
8
|
+
});
|
|
9
|
+
return React.useCallback(forwardToFunction ? function () {
|
|
10
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
11
|
+
args[_key] = arguments[_key];
|
|
12
|
+
}
|
|
9
13
|
var _curRef_current;
|
|
10
14
|
return (_curRef_current = curRef.current) === null || _curRef_current === void 0 ? void 0 : _curRef_current.apply(null, args);
|
|
11
15
|
} : function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["React","isServer","window","useIsomorphicInsertionEffect","useEffect","useInsertionEffect","useLayoutEffect","useGet","currentValue","initialValue","forwardToFunction","curRef","useRef","current","useCallback","_len","arguments","length","args","Array","_key","_curRef_current"],"sources":["../../src/useGet.ts"],"sourcesContent":[null],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAEvB,IAAAC,QAAM,UAAWC,MAAO,gBAAW;AAMnC,IAAAC,4BAAM,GAAAF,QAA+B,GAAAD,KACjC,CAAAI,SAAM,GAAAJ,KACN,CAAAK,kBAAM,IAAAL,KAAsB,CAAAM,eAAM;AAI/B,SAASC,OACdC,YAAA,EACAC,YAAA,EACAC,iBAAA,EACS;EACT,IAAAC,MAAM,GAAAX,KAAS,CAAAY,MAAM,CAAAH,YAAY,SAAgB,IAAAA,YAAY,cAAAA,YAAA,GAAAD,YAAA;EAC7DL,4BAAA,CAA6B,YAAM;IACjCQ,MAAA,CAAOE,OAAA,GAAUL,YAAA;EACnB,CAAC;EAED,OAAOR,KAAA,CAAMc,WAAA,CAAAJ,iBAAA;IACX,SAAAK,IAAA,GAAAC,SACQ,CAAAC,MAAA,EAASC,IAAA,GAAO,IAAAC,KAAS,CAAAJ,IAAM,GAAAK,IAAM,GAAI,GAAAA,IAC7C,GAAML,IAAA,EAAAK,IAAO;MAChBF,IAAA,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;IACH;IACF,IAAAC,eAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/use-event",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.40",
|
|
4
4
|
"files": [
|
|
5
5
|
"src",
|
|
6
6
|
"types",
|
|
@@ -15,15 +15,12 @@
|
|
|
15
15
|
"./package.json": "./package.json",
|
|
16
16
|
".": {
|
|
17
17
|
"types": "./types/index.d.ts",
|
|
18
|
-
"react-native":
|
|
19
|
-
|
|
20
|
-
"import": "./dist/esm/index.native.js",
|
|
21
|
-
"require": "./dist/cjs/index.native.js"
|
|
22
|
-
},
|
|
18
|
+
"react-native": "./dist/esm/index.native.js",
|
|
19
|
+
"browser": "./dist/esm/index.mjs",
|
|
23
20
|
"module": "./dist/esm/index.mjs",
|
|
24
21
|
"import": "./dist/esm/index.mjs",
|
|
25
22
|
"require": "./dist/cjs/index.cjs",
|
|
26
|
-
"default": "./dist/
|
|
23
|
+
"default": "./dist/esm/index.mjs"
|
|
27
24
|
}
|
|
28
25
|
},
|
|
29
26
|
"publishConfig": {
|
|
@@ -35,11 +32,9 @@
|
|
|
35
32
|
"clean": "tamagui-build clean",
|
|
36
33
|
"clean:build": "tamagui-build clean:build"
|
|
37
34
|
},
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"@tamagui/constants": "2.0.0-rc.4"
|
|
40
|
-
},
|
|
35
|
+
"dependencies": {},
|
|
41
36
|
"devDependencies": {
|
|
42
|
-
"@tamagui/build": "2.0.0-rc.
|
|
37
|
+
"@tamagui/build": "2.0.0-rc.40",
|
|
43
38
|
"react": ">=19"
|
|
44
39
|
},
|
|
45
40
|
"peerDependencies": {
|
package/src/useGet.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import { useIsomorphicLayoutEffect } from '@tamagui/constants'
|
|
2
1
|
import * as React from 'react'
|
|
3
2
|
|
|
3
|
+
const isServer = typeof window === 'undefined'
|
|
4
|
+
|
|
5
|
+
// Use useInsertionEffect on the client to ensure the ref is updated before any
|
|
6
|
+
// useLayoutEffect reads the returned callback. This fixes a React 19 timing
|
|
7
|
+
// issue where a consumer's useLayoutEffect could fire before this ref update,
|
|
8
|
+
// causing stale values. Falls back to useLayoutEffect for React < 18.3.
|
|
9
|
+
const useIsomorphicInsertionEffect = isServer
|
|
10
|
+
? React.useEffect
|
|
11
|
+
: React.useInsertionEffect || React.useLayoutEffect
|
|
12
|
+
|
|
4
13
|
// keeps a reference to the current value easily
|
|
5
14
|
|
|
6
15
|
export function useGet<A>(
|
|
@@ -9,7 +18,7 @@ export function useGet<A>(
|
|
|
9
18
|
forwardToFunction?: boolean
|
|
10
19
|
): () => A {
|
|
11
20
|
const curRef = React.useRef<any>(initialValue ?? currentValue)
|
|
12
|
-
|
|
21
|
+
useIsomorphicInsertionEffect(() => {
|
|
13
22
|
curRef.current = currentValue
|
|
14
23
|
})
|
|
15
24
|
|
package/types/index.d.ts.map
CHANGED
package/types/useEvent.d.ts.map
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/useEvent.ts"
|
|
6
6
|
],
|
|
7
|
+
"version": 3,
|
|
7
8
|
"sourcesContent": [
|
|
8
9
|
"import { useGet } from './useGet'\n\ntype AnyFunction = (...args: any[]) => any\n\nexport function useEvent<T extends AnyFunction>(callback?: T): T {\n return useGet(callback, defaultValue, true) as T\n}\n\nconst defaultValue = () => {\n throw new Error('Cannot call an event handler while rendering.')\n}\n"
|
|
9
|
-
]
|
|
10
|
-
"version": 3
|
|
10
|
+
]
|
|
11
11
|
}
|
package/types/useGet.d.ts.map
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"mappings": "
|
|
2
|
+
"mappings": "AAcA,OAAO,iBAAS,OAAO,GACrB,cAAc,GACd,oBACA,oCACO",
|
|
3
3
|
"names": [],
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/useGet.ts"
|
|
6
6
|
],
|
|
7
|
+
"version": 3,
|
|
7
8
|
"sourcesContent": [
|
|
8
|
-
"import
|
|
9
|
-
]
|
|
10
|
-
"version": 3
|
|
9
|
+
"import * as React from 'react'\n\nconst isServer = typeof window === 'undefined'\n\n// Use useInsertionEffect on the client to ensure the ref is updated before any\n// useLayoutEffect reads the returned callback. This fixes a React 19 timing\n// issue where a consumer's useLayoutEffect could fire before this ref update,\n// causing stale values. Falls back to useLayoutEffect for React < 18.3.\nconst useIsomorphicInsertionEffect = isServer\n ? React.useEffect\n : React.useInsertionEffect || React.useLayoutEffect\n\n// keeps a reference to the current value easily\n\nexport function useGet<A>(\n currentValue: A,\n initialValue?: any,\n forwardToFunction?: boolean\n): () => A {\n const curRef = React.useRef<any>(initialValue ?? currentValue)\n useIsomorphicInsertionEffect(() => {\n curRef.current = currentValue\n })\n\n return React.useCallback(\n forwardToFunction\n ? (...args) => curRef.current?.apply(null, args)\n : () => curRef.current,\n []\n )\n}\n"
|
|
10
|
+
]
|
|
11
11
|
}
|
package/dist/cjs/index.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
7
|
-
for (let key of __getOwnPropNames(from))
|
|
8
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
|
-
return to;
|
|
10
|
-
}, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
11
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
12
|
-
var index_exports = {};
|
|
13
|
-
module.exports = __toCommonJS(index_exports);
|
|
14
|
-
__reExport(index_exports, require("./useEvent"), module.exports);
|
|
15
|
-
__reExport(index_exports, require("./useGet"), module.exports);
|
|
16
|
-
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
DELETED
package/dist/cjs/useEvent.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var useEvent_exports = {};
|
|
16
|
-
__export(useEvent_exports, {
|
|
17
|
-
useEvent: () => useEvent
|
|
18
|
-
});
|
|
19
|
-
module.exports = __toCommonJS(useEvent_exports);
|
|
20
|
-
var import_useGet = require("./useGet");
|
|
21
|
-
function useEvent(callback) {
|
|
22
|
-
return (0, import_useGet.useGet)(callback, defaultValue, !0);
|
|
23
|
-
}
|
|
24
|
-
const defaultValue = () => {
|
|
25
|
-
throw new Error("Cannot call an event handler while rendering.");
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=useEvent.js.map
|
package/dist/cjs/useEvent.js.map
DELETED
package/dist/cjs/useGet.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
return to;
|
|
14
|
-
};
|
|
15
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
21
|
-
mod
|
|
22
|
-
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
23
|
-
var useGet_exports = {};
|
|
24
|
-
__export(useGet_exports, {
|
|
25
|
-
useGet: () => useGet
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(useGet_exports);
|
|
28
|
-
var import_constants = require("@tamagui/constants"), React = __toESM(require("react"), 1);
|
|
29
|
-
function useGet(currentValue, initialValue, forwardToFunction) {
|
|
30
|
-
const curRef = React.useRef(initialValue ?? currentValue);
|
|
31
|
-
return (0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
32
|
-
curRef.current = currentValue;
|
|
33
|
-
}), React.useCallback(
|
|
34
|
-
forwardToFunction ? (...args) => curRef.current?.apply(null, args) : () => curRef.current,
|
|
35
|
-
[]
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=useGet.js.map
|
package/dist/cjs/useGet.js.map
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/useGet.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA0C,+BAC1C,QAAuB;AAIhB,SAAS,OACd,cACA,cACA,mBACS;AACT,QAAM,SAAS,MAAM,OAAY,gBAAgB,YAAY;AAC7D,yDAA0B,MAAM;AAC9B,WAAO,UAAU;AAAA,EACnB,CAAC,GAEM,MAAM;AAAA,IACX,oBACI,IAAI,SAAS,OAAO,SAAS,MAAM,MAAM,IAAI,IAC7C,MAAM,OAAO;AAAA,IACjB,CAAC;AAAA,EACH;AACF;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
package/dist/esm/useEvent.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { useGet } from "./useGet";
|
|
2
|
-
function useEvent(callback) {
|
|
3
|
-
return useGet(callback, defaultValue, !0);
|
|
4
|
-
}
|
|
5
|
-
const defaultValue = () => {
|
|
6
|
-
throw new Error("Cannot call an event handler while rendering.");
|
|
7
|
-
};
|
|
8
|
-
export {
|
|
9
|
-
useEvent
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=useEvent.js.map
|
package/dist/esm/useEvent.js.map
DELETED
package/dist/esm/useGet.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
function useGet(currentValue, initialValue, forwardToFunction) {
|
|
4
|
-
const curRef = React.useRef(initialValue ?? currentValue);
|
|
5
|
-
return useIsomorphicLayoutEffect(() => {
|
|
6
|
-
curRef.current = currentValue;
|
|
7
|
-
}), React.useCallback(
|
|
8
|
-
forwardToFunction ? (...args) => curRef.current?.apply(null, args) : () => curRef.current,
|
|
9
|
-
[]
|
|
10
|
-
);
|
|
11
|
-
}
|
|
12
|
-
export {
|
|
13
|
-
useGet
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=useGet.js.map
|
package/dist/esm/useGet.js.map
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/useGet.ts"],
|
|
4
|
-
"mappings": "AAAA,SAAS,iCAAiC;AAC1C,YAAY,WAAW;AAIhB,SAAS,OACd,cACA,cACA,mBACS;AACT,QAAM,SAAS,MAAM,OAAY,gBAAgB,YAAY;AAC7D,mCAA0B,MAAM;AAC9B,WAAO,UAAU;AAAA,EACnB,CAAC,GAEM,MAAM;AAAA,IACX,oBACI,IAAI,SAAS,OAAO,SAAS,MAAM,MAAM,IAAI,IAC7C,MAAM,OAAO;AAAA,IACjB,CAAC;AAAA,EACH;AACF;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|