@tamagui/use-event 1.14.0 → 1.14.2
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.js +19 -1
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/useEvent.js +34 -1
- package/dist/cjs/useEvent.js.map +2 -2
- package/dist/cjs/useGet.js +44 -1
- package/dist/cjs/useGet.js.map +2 -2
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +2 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/useEvent.js +10 -1
- package/dist/esm/useEvent.js.map +2 -2
- package/dist/esm/useEvent.mjs +10 -1
- package/dist/esm/useEvent.mjs.map +2 -2
- package/dist/esm/useGet.js +20 -1
- package/dist/esm/useGet.js.map +2 -2
- package/dist/esm/useGet.mjs +20 -1
- package/dist/esm/useGet.mjs.map +2 -2
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -1,2 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var src_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(src_exports);
|
|
18
|
+
__reExport(src_exports, require("./useEvent"), module.exports);
|
|
19
|
+
__reExport(src_exports, require("./useGet"), module.exports);
|
|
2
20
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
4
|
"sourcesContent": ["export * from './useEvent'\nexport * from './useGet'\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,uBAAd;AACA,wBAAc,qBADd;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/dist/cjs/useEvent.js
CHANGED
|
@@ -1,2 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var useEvent_exports = {};
|
|
20
|
+
__export(useEvent_exports, {
|
|
21
|
+
useEvent: () => useEvent
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useEvent_exports);
|
|
24
|
+
var import_useGet = require("./useGet");
|
|
25
|
+
function useEvent(callback) {
|
|
26
|
+
return (0, import_useGet.useGet)(callback, defaultValue, true);
|
|
27
|
+
}
|
|
28
|
+
const defaultValue = () => {
|
|
29
|
+
throw new Error("Cannot call an event handler while rendering.");
|
|
30
|
+
};
|
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
useEvent
|
|
34
|
+
});
|
|
2
35
|
//# sourceMappingURL=useEvent.js.map
|
package/dist/cjs/useEvent.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useEvent.ts"],
|
|
4
4
|
"sourcesContent": ["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"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAuB;AAIhB,SAAS,SAAgC,UAAiB;AAC/D,aAAO,sBAAO,UAAU,cAAc,IAAI;AAC5C;AAEA,MAAM,eAAe,MAAM;AACzB,QAAM,IAAI,MAAM,+CAA+C;AACjE;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/dist/cjs/useGet.js
CHANGED
|
@@ -1,2 +1,45 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var useGet_exports = {};
|
|
20
|
+
__export(useGet_exports, {
|
|
21
|
+
useGet: () => useGet
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useGet_exports);
|
|
24
|
+
var import_react = require("react");
|
|
25
|
+
const isWeb = process.env.TAMAGUI_TARGET === "web";
|
|
26
|
+
const isClient = typeof window !== "undefined";
|
|
27
|
+
const useIsomorphicLayoutEffect = !isWeb || isClient ? import_react.useLayoutEffect : import_react.useEffect;
|
|
28
|
+
function useGet(currentValue, initialValue, forwardToFunction) {
|
|
29
|
+
const curRef = (0, import_react.useRef)(initialValue ?? currentValue);
|
|
30
|
+
useIsomorphicLayoutEffect(() => {
|
|
31
|
+
curRef.current = currentValue;
|
|
32
|
+
});
|
|
33
|
+
return (0, import_react.useCallback)(
|
|
34
|
+
forwardToFunction ? (...args) => {
|
|
35
|
+
var _a;
|
|
36
|
+
return (_a = curRef.current) == null ? void 0 : _a.apply(null, args);
|
|
37
|
+
} : () => curRef.current,
|
|
38
|
+
[]
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
+
0 && (module.exports = {
|
|
43
|
+
useGet
|
|
44
|
+
});
|
|
2
45
|
//# sourceMappingURL=useGet.js.map
|
package/dist/cjs/useGet.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useGet.ts"],
|
|
4
4
|
"sourcesContent": ["import { useCallback, useEffect, useLayoutEffect, useRef } from 'react'\n\nconst isWeb = process.env.TAMAGUI_TARGET === 'web'\nconst isClient = typeof window !== 'undefined'\nconst useIsomorphicLayoutEffect = !isWeb || isClient ? useLayoutEffect : useEffect\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 = useRef<any>(initialValue ?? currentValue)\n useIsomorphicLayoutEffect(() => {\n curRef.current = currentValue\n })\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useCallback(\n forwardToFunction\n ? (...args) => curRef.current?.apply(null, args)\n : () => curRef.current,\n [],\n )\n}\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAgE;AAEhE,MAAM,QAAQ,QAAQ,IAAI,mBAAmB;AAC7C,MAAM,WAAW,OAAO,WAAW;AACnC,MAAM,4BAA4B,CAAC,SAAS,WAAW,+BAAkB;AAIlE,SAAS,OACd,cACA,cACA,mBACS;AACT,QAAM,aAAS,qBAAY,gBAAgB,YAAY;AACvD,4BAA0B,MAAM;AAC9B,WAAO,UAAU;AAAA,EACnB,CAAC;AAED,aAAO;AAAA,IACL,oBACI,IAAI,SAAM;AApBlB;AAoBqB,0BAAO,YAAP,mBAAgB,MAAM,MAAM;AAAA,QACzC,MAAM,OAAO;AAAA,IACjB,CAAC;AAAA,EACH;AACF;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
package/dist/esm/index.mjs
CHANGED
package/dist/esm/index.mjs.map
CHANGED
package/dist/esm/useEvent.js
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
import{useGet
|
|
1
|
+
import { useGet } from "./useGet";
|
|
2
|
+
function useEvent(callback) {
|
|
3
|
+
return useGet(callback, defaultValue, true);
|
|
4
|
+
}
|
|
5
|
+
const defaultValue = () => {
|
|
6
|
+
throw new Error("Cannot call an event handler while rendering.");
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
useEvent
|
|
10
|
+
};
|
|
2
11
|
//# sourceMappingURL=useEvent.js.map
|
package/dist/esm/useEvent.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useEvent.ts"],
|
|
4
4
|
"sourcesContent": ["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"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,SAAS,cAAc;AAIhB,SAAS,SAAgC,UAAiB;AAC/D,SAAO,OAAO,UAAU,cAAc,IAAI;AAC5C;AAEA,MAAM,eAAe,MAAM;AACzB,QAAM,IAAI,MAAM,+CAA+C;AACjE;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/dist/esm/useEvent.mjs
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
import{useGet
|
|
1
|
+
import { useGet } from "./useGet";
|
|
2
|
+
function useEvent(callback) {
|
|
3
|
+
return useGet(callback, defaultValue, true);
|
|
4
|
+
}
|
|
5
|
+
const defaultValue = () => {
|
|
6
|
+
throw new Error("Cannot call an event handler while rendering.");
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
useEvent
|
|
10
|
+
};
|
|
2
11
|
//# sourceMappingURL=useEvent.mjs.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useEvent.ts"],
|
|
4
4
|
"sourcesContent": ["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"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,SAAS,cAAc;AAIhB,SAAS,SAAgC,UAAiB;AAC/D,SAAO,OAAO,UAAU,cAAc,IAAI;AAC5C;AAEA,MAAM,eAAe,MAAM;AACzB,QAAM,IAAI,MAAM,+CAA+C;AACjE;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/dist/esm/useGet.js
CHANGED
|
@@ -1,2 +1,21 @@
|
|
|
1
|
-
import{useCallback
|
|
1
|
+
import { useCallback, useEffect, useLayoutEffect, useRef } from "react";
|
|
2
|
+
const isWeb = process.env.TAMAGUI_TARGET === "web";
|
|
3
|
+
const isClient = typeof window !== "undefined";
|
|
4
|
+
const useIsomorphicLayoutEffect = !isWeb || isClient ? useLayoutEffect : useEffect;
|
|
5
|
+
function useGet(currentValue, initialValue, forwardToFunction) {
|
|
6
|
+
const curRef = useRef(initialValue ?? currentValue);
|
|
7
|
+
useIsomorphicLayoutEffect(() => {
|
|
8
|
+
curRef.current = currentValue;
|
|
9
|
+
});
|
|
10
|
+
return useCallback(
|
|
11
|
+
forwardToFunction ? (...args) => {
|
|
12
|
+
var _a;
|
|
13
|
+
return (_a = curRef.current) == null ? void 0 : _a.apply(null, args);
|
|
14
|
+
} : () => curRef.current,
|
|
15
|
+
[]
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
useGet
|
|
20
|
+
};
|
|
2
21
|
//# sourceMappingURL=useGet.js.map
|
package/dist/esm/useGet.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useGet.ts"],
|
|
4
4
|
"sourcesContent": ["import { useCallback, useEffect, useLayoutEffect, useRef } from 'react'\n\nconst isWeb = process.env.TAMAGUI_TARGET === 'web'\nconst isClient = typeof window !== 'undefined'\nconst useIsomorphicLayoutEffect = !isWeb || isClient ? useLayoutEffect : useEffect\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 = useRef<any>(initialValue ?? currentValue)\n useIsomorphicLayoutEffect(() => {\n curRef.current = currentValue\n })\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useCallback(\n forwardToFunction\n ? (...args) => curRef.current?.apply(null, args)\n : () => curRef.current,\n [],\n )\n}\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,SAAS,aAAa,WAAW,iBAAiB,cAAc;AAEhE,MAAM,QAAQ,QAAQ,IAAI,mBAAmB;AAC7C,MAAM,WAAW,OAAO,WAAW;AACnC,MAAM,4BAA4B,CAAC,SAAS,WAAW,kBAAkB;AAIlE,SAAS,OACd,cACA,cACA,mBACS;AACT,QAAM,SAAS,OAAY,gBAAgB,YAAY;AACvD,4BAA0B,MAAM;AAC9B,WAAO,UAAU;AAAA,EACnB,CAAC;AAED,SAAO;AAAA,IACL,oBACI,IAAI,SAAM;AApBlB;AAoBqB,0BAAO,YAAP,mBAAgB,MAAM,MAAM;AAAA,QACzC,MAAM,OAAO;AAAA,IACjB,CAAC;AAAA,EACH;AACF;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/dist/esm/useGet.mjs
CHANGED
|
@@ -1,2 +1,21 @@
|
|
|
1
|
-
import{useCallback
|
|
1
|
+
import { useCallback, useEffect, useLayoutEffect, useRef } from "react";
|
|
2
|
+
const isWeb = process.env.TAMAGUI_TARGET === "web";
|
|
3
|
+
const isClient = typeof window !== "undefined";
|
|
4
|
+
const useIsomorphicLayoutEffect = !isWeb || isClient ? useLayoutEffect : useEffect;
|
|
5
|
+
function useGet(currentValue, initialValue, forwardToFunction) {
|
|
6
|
+
const curRef = useRef(initialValue ?? currentValue);
|
|
7
|
+
useIsomorphicLayoutEffect(() => {
|
|
8
|
+
curRef.current = currentValue;
|
|
9
|
+
});
|
|
10
|
+
return useCallback(
|
|
11
|
+
forwardToFunction ? (...args) => {
|
|
12
|
+
var _a;
|
|
13
|
+
return (_a = curRef.current) == null ? void 0 : _a.apply(null, args);
|
|
14
|
+
} : () => curRef.current,
|
|
15
|
+
[]
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
useGet
|
|
20
|
+
};
|
|
2
21
|
//# sourceMappingURL=useGet.mjs.map
|
package/dist/esm/useGet.mjs.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useGet.ts"],
|
|
4
4
|
"sourcesContent": ["import { useCallback, useEffect, useLayoutEffect, useRef } from 'react'\n\nconst isWeb = process.env.TAMAGUI_TARGET === 'web'\nconst isClient = typeof window !== 'undefined'\nconst useIsomorphicLayoutEffect = !isWeb || isClient ? useLayoutEffect : useEffect\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 = useRef<any>(initialValue ?? currentValue)\n useIsomorphicLayoutEffect(() => {\n curRef.current = currentValue\n })\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useCallback(\n forwardToFunction\n ? (...args) => curRef.current?.apply(null, args)\n : () => curRef.current,\n [],\n )\n}\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,SAAS,aAAa,WAAW,iBAAiB,cAAc;AAEhE,MAAM,QAAQ,QAAQ,IAAI,mBAAmB;AAC7C,MAAM,WAAW,OAAO,WAAW;AACnC,MAAM,4BAA4B,CAAC,SAAS,WAAW,kBAAkB;AAIlE,SAAS,OACd,cACA,cACA,mBACS;AACT,QAAM,SAAS,OAAY,gBAAgB,YAAY;AACvD,4BAA0B,MAAM;AAC9B,WAAO,UAAU;AAAA,EACnB,CAAC;AAED,SAAO;AAAA,IACL,oBACI,IAAI,SAAM;AApBlB;AAoBqB,0BAAO,YAAP,mBAAgB,MAAM,MAAM;AAAA,QACzC,MAAM,OAAO;AAAA,IACjB,CAAC;AAAA,EACH;AACF;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/use-event",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.2",
|
|
4
4
|
"types": "./types/index.d.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"clean:build": "tamagui-build clean:build"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@tamagui/build": "1.14.
|
|
21
|
+
"@tamagui/build": "1.14.2",
|
|
22
22
|
"react": "^18.2.0"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|