@tamagui/helpers 1.0.1-beta.93 → 1.0.1-beta.96
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/composeEventHandlers.js +9 -4
- package/dist/cjs/composeEventHandlers.js.map +2 -2
- package/dist/esm/composeEventHandlers.js +9 -4
- package/dist/esm/composeEventHandlers.js.map +2 -2
- package/dist/jsx/composeEventHandlers.js +9 -4
- package/dist/jsx/composeEventHandlers.js.map +2 -2
- package/package.json +2 -2
- package/src/composeEventHandlers.ts +9 -3
- package/types/composeEventHandlers.d.ts.map +1 -1
- package/types/clamp.d.ts.map +0 -1
- package/types/concatClassName.d.ts.map +0 -1
- package/types/index.d.ts.map +0 -1
- package/types/log.d.ts.map +0 -1
- package/types/simpleHash.d.ts.map +0 -1
- package/types/types.d.ts.map +0 -1
- package/types/validStyleProps.d.ts.map +0 -1
|
@@ -20,13 +20,18 @@ __export(composeEventHandlers_exports, {
|
|
|
20
20
|
composeEventHandlers: () => composeEventHandlers
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(composeEventHandlers_exports);
|
|
23
|
+
var import_react = require("react");
|
|
23
24
|
function composeEventHandlers(og, next, { checkDefaultPrevented = true } = {}) {
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
const handlers = (0, import_react.useRef)([]);
|
|
26
|
+
handlers.current[0] = og;
|
|
27
|
+
handlers.current[1] = next;
|
|
28
|
+
return (0, import_react.useCallback)(function composedEventHandler(event) {
|
|
29
|
+
const [og2, next2] = handlers.current;
|
|
30
|
+
og2 == null ? void 0 : og2(event);
|
|
26
31
|
if (!checkDefaultPrevented || !event.defaultPrevented) {
|
|
27
|
-
return
|
|
32
|
+
return next2 == null ? void 0 : next2(event);
|
|
28
33
|
}
|
|
29
|
-
};
|
|
34
|
+
}, []);
|
|
30
35
|
}
|
|
31
36
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
37
|
0 && (module.exports = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/composeEventHandlers.ts"],
|
|
4
|
-
"sourcesContent": ["import { FocusEvent } from 'react'\nimport { GestureResponderEvent } from 'react-native'\n\nexport type EventHandler<E extends Event | GestureResponderEvent | FocusEvent> = (event: E) => void\n\nexport function composeEventHandlers<E extends Event | GestureResponderEvent | FocusEvent>(\n og?: EventHandler<E>,\n next?: EventHandler<E>,\n { checkDefaultPrevented = true } = {}\n) {\n return function composedEventHandler(event: E) {\n og?.(event)\n if (!checkDefaultPrevented || !event.defaultPrevented) {\n return next?.(event)\n }\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import { FocusEvent, useCallback, useRef } from 'react'\nimport { GestureResponderEvent } from 'react-native'\n\nexport type EventHandler<E extends Event | GestureResponderEvent | FocusEvent> = (event: E) => void\n\nexport function composeEventHandlers<E extends Event | GestureResponderEvent | FocusEvent>(\n og?: EventHandler<E>,\n next?: EventHandler<E>,\n { checkDefaultPrevented = true } = {}\n) {\n const handlers = useRef<(EventHandler<E> | undefined)[]>([])\n handlers.current[0] = og\n handlers.current[1] = next\n\n // mimic upcoming react useEvent and keep it stable\n return useCallback(function composedEventHandler(event: E) {\n const [og, next] = handlers.current\n og?.(event)\n if (!checkDefaultPrevented || !event.defaultPrevented) {\n return next?.(event)\n }\n }, [])\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAgD;AAKzC,8BACL,IACA,MACA,EAAE,wBAAwB,SAAS,CAAC,GACpC;AACA,QAAM,WAAW,yBAAwC,CAAC,CAAC;AAC3D,WAAS,QAAQ,KAAK;AACtB,WAAS,QAAQ,KAAK;AAGtB,SAAO,8BAAY,8BAA8B,OAAU;AACzD,UAAM,CAAC,KAAI,SAAQ,SAAS;AAC5B,+BAAK;AACL,QAAI,CAAC,yBAAyB,CAAC,MAAM,kBAAkB;AACrD,aAAO,+BAAO;AAAA,IAChB;AAAA,EACF,GAAG,CAAC,CAAC;AACP;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
import { useCallback, useRef } from "react";
|
|
1
2
|
function composeEventHandlers(og, next, { checkDefaultPrevented = true } = {}) {
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
const handlers = useRef([]);
|
|
4
|
+
handlers.current[0] = og;
|
|
5
|
+
handlers.current[1] = next;
|
|
6
|
+
return useCallback(function composedEventHandler(event) {
|
|
7
|
+
const [og2, next2] = handlers.current;
|
|
8
|
+
og2 == null ? void 0 : og2(event);
|
|
4
9
|
if (!checkDefaultPrevented || !event.defaultPrevented) {
|
|
5
|
-
return
|
|
10
|
+
return next2 == null ? void 0 : next2(event);
|
|
6
11
|
}
|
|
7
|
-
};
|
|
12
|
+
}, []);
|
|
8
13
|
}
|
|
9
14
|
export {
|
|
10
15
|
composeEventHandlers
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/composeEventHandlers.ts"],
|
|
4
|
-
"sourcesContent": ["import { FocusEvent } from 'react'\nimport { GestureResponderEvent } from 'react-native'\n\nexport type EventHandler<E extends Event | GestureResponderEvent | FocusEvent> = (event: E) => void\n\nexport function composeEventHandlers<E extends Event | GestureResponderEvent | FocusEvent>(\n og?: EventHandler<E>,\n next?: EventHandler<E>,\n { checkDefaultPrevented = true } = {}\n) {\n return function composedEventHandler(event: E) {\n og?.(event)\n if (!checkDefaultPrevented || !event.defaultPrevented) {\n return next?.(event)\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "AAKO,8BACL,IACA,MACA,EAAE,wBAAwB,SAAS,CAAC,GACpC;AACA,SAAO,8BAA8B,OAAU;
|
|
4
|
+
"sourcesContent": ["import { FocusEvent, useCallback, useRef } from 'react'\nimport { GestureResponderEvent } from 'react-native'\n\nexport type EventHandler<E extends Event | GestureResponderEvent | FocusEvent> = (event: E) => void\n\nexport function composeEventHandlers<E extends Event | GestureResponderEvent | FocusEvent>(\n og?: EventHandler<E>,\n next?: EventHandler<E>,\n { checkDefaultPrevented = true } = {}\n) {\n const handlers = useRef<(EventHandler<E> | undefined)[]>([])\n handlers.current[0] = og\n handlers.current[1] = next\n\n // mimic upcoming react useEvent and keep it stable\n return useCallback(function composedEventHandler(event: E) {\n const [og, next] = handlers.current\n og?.(event)\n if (!checkDefaultPrevented || !event.defaultPrevented) {\n return next?.(event)\n }\n }, [])\n}\n"],
|
|
5
|
+
"mappings": "AAAA;AAKO,8BACL,IACA,MACA,EAAE,wBAAwB,SAAS,CAAC,GACpC;AACA,QAAM,WAAW,OAAwC,CAAC,CAAC;AAC3D,WAAS,QAAQ,KAAK;AACtB,WAAS,QAAQ,KAAK;AAGtB,SAAO,YAAY,8BAA8B,OAAU;AACzD,UAAM,CAAC,KAAI,SAAQ,SAAS;AAC5B,+BAAK;AACL,QAAI,CAAC,yBAAyB,CAAC,MAAM,kBAAkB;AACrD,aAAO,+BAAO;AAAA,IAChB;AAAA,EACF,GAAG,CAAC,CAAC;AACP;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
import { useCallback, useRef } from "react";
|
|
1
2
|
function composeEventHandlers(og, next, { checkDefaultPrevented = true } = {}) {
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
const handlers = useRef([]);
|
|
4
|
+
handlers.current[0] = og;
|
|
5
|
+
handlers.current[1] = next;
|
|
6
|
+
return useCallback(function composedEventHandler(event) {
|
|
7
|
+
const [og2, next2] = handlers.current;
|
|
8
|
+
og2 == null ? void 0 : og2(event);
|
|
4
9
|
if (!checkDefaultPrevented || !event.defaultPrevented) {
|
|
5
|
-
return
|
|
10
|
+
return next2 == null ? void 0 : next2(event);
|
|
6
11
|
}
|
|
7
|
-
};
|
|
12
|
+
}, []);
|
|
8
13
|
}
|
|
9
14
|
export {
|
|
10
15
|
composeEventHandlers
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/composeEventHandlers.ts"],
|
|
4
|
-
"sourcesContent": ["import { FocusEvent } from 'react'\nimport { GestureResponderEvent } from 'react-native'\n\nexport type EventHandler<E extends Event | GestureResponderEvent | FocusEvent> = (event: E) => void\n\nexport function composeEventHandlers<E extends Event | GestureResponderEvent | FocusEvent>(\n og?: EventHandler<E>,\n next?: EventHandler<E>,\n { checkDefaultPrevented = true } = {}\n) {\n return function composedEventHandler(event: E) {\n og?.(event)\n if (!checkDefaultPrevented || !event.defaultPrevented) {\n return next?.(event)\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "AAKO,8BACL,IACA,MACA,EAAE,wBAAwB,SAAS,CAAC,GACpC;AACA,SAAO,8BAA8B,OAAU;
|
|
4
|
+
"sourcesContent": ["import { FocusEvent, useCallback, useRef } from 'react'\nimport { GestureResponderEvent } from 'react-native'\n\nexport type EventHandler<E extends Event | GestureResponderEvent | FocusEvent> = (event: E) => void\n\nexport function composeEventHandlers<E extends Event | GestureResponderEvent | FocusEvent>(\n og?: EventHandler<E>,\n next?: EventHandler<E>,\n { checkDefaultPrevented = true } = {}\n) {\n const handlers = useRef<(EventHandler<E> | undefined)[]>([])\n handlers.current[0] = og\n handlers.current[1] = next\n\n // mimic upcoming react useEvent and keep it stable\n return useCallback(function composedEventHandler(event: E) {\n const [og, next] = handlers.current\n og?.(event)\n if (!checkDefaultPrevented || !event.defaultPrevented) {\n return next?.(event)\n }\n }, [])\n}\n"],
|
|
5
|
+
"mappings": "AAAA;AAKO,8BACL,IACA,MACA,EAAE,wBAAwB,SAAS,CAAC,GACpC;AACA,QAAM,WAAW,OAAwC,CAAC,CAAC;AAC3D,WAAS,QAAQ,KAAK;AACtB,WAAS,QAAQ,KAAK;AAGtB,SAAO,YAAY,8BAA8B,OAAU;AACzD,UAAM,CAAC,KAAI,SAAQ,SAAS;AAC5B,+BAAK;AACL,QAAI,CAAC,yBAAyB,CAAC,MAAM,kBAAkB;AACrD,aAAO,+BAAO;AAAA,IAChB;AAAA,EACF,GAAG,CAAC,CAAC;AACP;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/helpers",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.96",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"types": "./types/index.d.ts",
|
|
6
6
|
"main": "dist/cjs",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"clean:build": "tamagui-build clean:build"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@tamagui/build": "^1.0.1-beta.
|
|
21
|
+
"@tamagui/build": "^1.0.1-beta.96",
|
|
22
22
|
"react": "*",
|
|
23
23
|
"react-native": "*"
|
|
24
24
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FocusEvent } from 'react'
|
|
1
|
+
import { FocusEvent, useCallback, useRef } from 'react'
|
|
2
2
|
import { GestureResponderEvent } from 'react-native'
|
|
3
3
|
|
|
4
4
|
export type EventHandler<E extends Event | GestureResponderEvent | FocusEvent> = (event: E) => void
|
|
@@ -8,10 +8,16 @@ export function composeEventHandlers<E extends Event | GestureResponderEvent | F
|
|
|
8
8
|
next?: EventHandler<E>,
|
|
9
9
|
{ checkDefaultPrevented = true } = {}
|
|
10
10
|
) {
|
|
11
|
-
|
|
11
|
+
const handlers = useRef<(EventHandler<E> | undefined)[]>([])
|
|
12
|
+
handlers.current[0] = og
|
|
13
|
+
handlers.current[1] = next
|
|
14
|
+
|
|
15
|
+
// mimic upcoming react useEvent and keep it stable
|
|
16
|
+
return useCallback(function composedEventHandler(event: E) {
|
|
17
|
+
const [og, next] = handlers.current
|
|
12
18
|
og?.(event)
|
|
13
19
|
if (!checkDefaultPrevented || !event.defaultPrevented) {
|
|
14
20
|
return next?.(event)
|
|
15
21
|
}
|
|
16
|
-
}
|
|
22
|
+
}, [])
|
|
17
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composeEventHandlers.d.ts","sourceRoot":"","sources":["../src/composeEventHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"composeEventHandlers.d.ts","sourceRoot":"","sources":["../src/composeEventHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAuB,MAAM,OAAO,CAAA;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;AAEpD,oBAAY,YAAY,CAAC,CAAC,SAAS,KAAK,GAAG,qBAAqB,GAAG,UAAU,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAA;AAEnG,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,KAAK,GAAG,qBAAqB,GAAG,UAAU,EACvF,EAAE,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,EACpB,IAAI,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,EACtB,EAAE,qBAA4B,EAAE;;CAAK,WAOmB,CAAC,UAO1D"}
|
package/types/clamp.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"clamp.d.ts","sourceRoot":"","sources":["../src/clamp.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAEzE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"concatClassName.d.ts","sourceRoot":"","sources":["../src/concatClassName.ts"],"names":[],"mappings":"AAIA,wBAAgB,eAAe,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA"}
|
package/types/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,wBAAwB,CAAA;AACtC,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AACjC,cAAc,SAAS,CAAA;AACvB,cAAc,OAAO,CAAA;AACrB,cAAc,cAAc,CAAA"}
|
package/types/log.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,GAAG,YAAa,GAAG,QAG/B,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"simpleHash.d.ts","sourceRoot":"","sources":["../src/simpleHash.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,QAAS,MAAM,WAQrC,CAAA"}
|
package/types/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAA;IACrC,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,EAAE,CAAA;CAChB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validStyleProps.d.ts","sourceRoot":"","sources":["../src/validStyleProps.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;EAc9B,CAAA;AAEF,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgGzB,CAAA;AAEF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;EA2B7B,CAAA;AAEF,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGzB,CAAA;AAEF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAiB,CAAA;AAE3C,eAAO,MAAM,eAAe;;;;;;EAM1B,CAAA;AAEF,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGtB,CAAA"}
|