@tamagui/core 1.14.1 → 1.14.3
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/helpers/getBoundingClientRect.js +33 -1
- package/dist/cjs/helpers/getBoundingClientRect.js.map +2 -2
- package/dist/cjs/helpers/getRect.js +35 -1
- package/dist/cjs/helpers/getRect.js.map +2 -2
- package/dist/cjs/hooks/useElementLayout.js +83 -1
- package/dist/cjs/hooks/useElementLayout.js.map +2 -2
- package/dist/cjs/hooks/usePlatformMethods.js +47 -1
- package/dist/cjs/hooks/usePlatformMethods.js.map +2 -2
- package/dist/cjs/index.js +163 -1
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/inject-styles.js +39 -1
- package/dist/cjs/inject-styles.js.map +2 -2
- package/dist/cjs/reactNativeTypes.js +16 -1
- package/dist/cjs/reactNativeTypes.js.map +2 -2
- package/dist/cjs/vendor/Pressability.js +31 -1
- package/dist/cjs/vendor/Pressability.js.map +2 -2
- package/dist/cjs/vendor/Pressability.native.js +31 -1
- package/dist/cjs/vendor/Pressability.native.js.map +2 -2
- package/dist/esm/helpers/getBoundingClientRect.js +9 -1
- package/dist/esm/helpers/getBoundingClientRect.js.map +2 -2
- package/dist/esm/helpers/getBoundingClientRect.mjs +9 -1
- package/dist/esm/helpers/getBoundingClientRect.mjs.map +2 -2
- package/dist/esm/helpers/getRect.js +11 -1
- package/dist/esm/helpers/getRect.js.map +2 -2
- package/dist/esm/helpers/getRect.mjs +11 -1
- package/dist/esm/helpers/getRect.mjs.map +2 -2
- package/dist/esm/hooks/useElementLayout.js +58 -1
- package/dist/esm/hooks/useElementLayout.js.map +2 -2
- package/dist/esm/hooks/useElementLayout.mjs +58 -1
- package/dist/esm/hooks/useElementLayout.mjs.map +2 -2
- package/dist/esm/hooks/usePlatformMethods.js +23 -1
- package/dist/esm/hooks/usePlatformMethods.js.map +2 -2
- package/dist/esm/hooks/usePlatformMethods.mjs +23 -1
- package/dist/esm/hooks/usePlatformMethods.mjs.map +2 -2
- package/dist/esm/index.js +144 -1
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/index.mjs +144 -1
- package/dist/esm/index.mjs.map +2 -2
- package/dist/esm/inject-styles.js +15 -1
- package/dist/esm/inject-styles.js.map +2 -2
- package/dist/esm/inject-styles.mjs +15 -1
- package/dist/esm/inject-styles.mjs.map +2 -2
- package/dist/esm/vendor/Pressability.js +6 -1
- package/dist/esm/vendor/Pressability.js.map +2 -2
- package/dist/esm/vendor/Pressability.mjs +6 -1
- package/dist/esm/vendor/Pressability.mjs.map +2 -2
- package/dist/esm/vendor/Pressability.native.js +6 -1
- package/dist/esm/vendor/Pressability.native.js.map +2 -2
- package/dist/esm/vendor/Pressability.native.mjs +6 -1
- package/dist/esm/vendor/Pressability.native.mjs.map +2 -2
- package/package.json +6 -6
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/vendor/Pressability.tsx"],
|
|
4
4
|
"sourcesContent": ["export const Pressability = {} as any\nexport const usePressability = {} as Function\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,eAAe,CAAC;AACtB,MAAM,kBAAkB,CAAC;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,32 @@
|
|
|
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 Pressability_native_exports = {};
|
|
20
|
+
__export(Pressability_native_exports, {
|
|
21
|
+
Pressability: () => Pressability,
|
|
22
|
+
usePressability: () => usePressability
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(Pressability_native_exports);
|
|
25
|
+
const Pressability = require("react-native/Libraries/Pressability/Pressability").default;
|
|
26
|
+
const usePressability = require("react-native/Libraries/Pressability/usePressability").default;
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
Pressability,
|
|
30
|
+
usePressability
|
|
31
|
+
});
|
|
2
32
|
//# sourceMappingURL=Pressability.native.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/vendor/Pressability.native.tsx"],
|
|
4
4
|
"sourcesContent": ["export const Pressability =\n require('react-native/Libraries/Pressability/Pressability').default\nexport const usePressability =\n require('react-native/Libraries/Pressability/usePressability').default\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,eACX,QAAQ,kDAAkD,EAAE;AACvD,MAAM,kBACX,QAAQ,qDAAqD,EAAE;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
const
|
|
1
|
+
const getBoundingClientRect = (node) => {
|
|
2
|
+
var _a;
|
|
3
|
+
if (!node || node.nodeType !== 1)
|
|
4
|
+
return;
|
|
5
|
+
return (_a = node.getBoundingClientRect) == null ? void 0 : _a.call(node);
|
|
6
|
+
};
|
|
7
|
+
export {
|
|
8
|
+
getBoundingClientRect
|
|
9
|
+
};
|
|
2
10
|
//# sourceMappingURL=getBoundingClientRect.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/getBoundingClientRect.tsx"],
|
|
4
4
|
"sourcesContent": ["export const getBoundingClientRect = (node: HTMLElement | null): void | DOMRect => {\n if (!node || node.nodeType !== 1) return\n return node.getBoundingClientRect?.()\n}\n"],
|
|
5
|
-
"mappings": "AAAO,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAO,MAAM,wBAAwB,CAAC,SAA6C;AAAnF;AACE,MAAI,CAAC,QAAQ,KAAK,aAAa;AAAG;AAClC,UAAO,UAAK,0BAAL;AACT;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
const
|
|
1
|
+
const getBoundingClientRect = (node) => {
|
|
2
|
+
var _a;
|
|
3
|
+
if (!node || node.nodeType !== 1)
|
|
4
|
+
return;
|
|
5
|
+
return (_a = node.getBoundingClientRect) == null ? void 0 : _a.call(node);
|
|
6
|
+
};
|
|
7
|
+
export {
|
|
8
|
+
getBoundingClientRect
|
|
9
|
+
};
|
|
2
10
|
//# sourceMappingURL=getBoundingClientRect.mjs.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/getBoundingClientRect.tsx"],
|
|
4
4
|
"sourcesContent": ["export const getBoundingClientRect = (node: HTMLElement | null): void | DOMRect => {\n if (!node || node.nodeType !== 1) return\n return node.getBoundingClientRect?.()\n}\n"],
|
|
5
|
-
"mappings": "AAAO,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAO,MAAM,wBAAwB,CAAC,SAA6C;AAAnF;AACE,MAAI,CAAC,QAAQ,KAAK,aAAa;AAAG;AAClC,UAAO,UAAK,0BAAL;AACT;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
import{getBoundingClientRect
|
|
1
|
+
import { getBoundingClientRect } from "./getBoundingClientRect";
|
|
2
|
+
const getRect = (node) => {
|
|
3
|
+
const rect = getBoundingClientRect(node);
|
|
4
|
+
if (!rect)
|
|
5
|
+
return;
|
|
6
|
+
const { x, y, top, left } = rect;
|
|
7
|
+
return { x, y, width: node.offsetWidth, height: node.offsetHeight, top, left };
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
getRect
|
|
11
|
+
};
|
|
2
12
|
//# sourceMappingURL=getRect.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/getRect.tsx"],
|
|
4
4
|
"sourcesContent": ["import { getBoundingClientRect } from './getBoundingClientRect'\n\nexport const getRect = (node: HTMLElement) => {\n const rect = getBoundingClientRect(node)\n if (!rect) return\n const { x, y, top, left } = rect\n return { x, y, width: node.offsetWidth, height: node.offsetHeight, top, left }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,SAAS,6BAA6B;AAE/B,MAAM,UAAU,CAAC,SAAsB;AAC5C,QAAM,OAAO,sBAAsB,IAAI;AACvC,MAAI,CAAC;AAAM;AACX,QAAM,EAAE,GAAG,GAAG,KAAK,KAAK,IAAI;AAC5B,SAAO,EAAE,GAAG,GAAG,OAAO,KAAK,aAAa,QAAQ,KAAK,cAAc,KAAK,KAAK;AAC/E;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
import{getBoundingClientRect
|
|
1
|
+
import { getBoundingClientRect } from "./getBoundingClientRect";
|
|
2
|
+
const getRect = (node) => {
|
|
3
|
+
const rect = getBoundingClientRect(node);
|
|
4
|
+
if (!rect)
|
|
5
|
+
return;
|
|
6
|
+
const { x, y, top, left } = rect;
|
|
7
|
+
return { x, y, width: node.offsetWidth, height: node.offsetHeight, top, left };
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
getRect
|
|
11
|
+
};
|
|
2
12
|
//# sourceMappingURL=getRect.mjs.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/getRect.tsx"],
|
|
4
4
|
"sourcesContent": ["import { getBoundingClientRect } from './getBoundingClientRect'\n\nexport const getRect = (node: HTMLElement) => {\n const rect = getBoundingClientRect(node)\n if (!rect) return\n const { x, y, top, left } = rect\n return { x, y, width: node.offsetWidth, height: node.offsetHeight, top, left }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,SAAS,6BAA6B;AAE/B,MAAM,UAAU,CAAC,SAAsB;AAC5C,QAAM,OAAO,sBAAsB,IAAI;AACvC,MAAI,CAAC;AAAM;AACX,QAAM,EAAE,GAAG,GAAG,KAAK,KAAK,IAAI;AAC5B,SAAO,EAAE,GAAG,GAAG,OAAO,KAAK,aAAa,QAAQ,KAAK,cAAc,KAAK,KAAK;AAC/E;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,59 @@
|
|
|
1
|
-
import{useIsomorphicLayoutEffect
|
|
1
|
+
import { useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
2
|
+
import { useEvent } from "@tamagui/use-event";
|
|
3
|
+
import { getBoundingClientRect } from "../helpers/getBoundingClientRect";
|
|
4
|
+
import { getRect } from "../helpers/getRect";
|
|
5
|
+
const LayoutHandlers = /* @__PURE__ */ new WeakMap();
|
|
6
|
+
let resizeObserver = null;
|
|
7
|
+
if (typeof window !== "undefined" && "ResizeObserver" in window) {
|
|
8
|
+
resizeObserver = new ResizeObserver((entries) => {
|
|
9
|
+
for (const { target } of entries) {
|
|
10
|
+
const onLayout = LayoutHandlers.get(target);
|
|
11
|
+
if (typeof onLayout !== "function")
|
|
12
|
+
return;
|
|
13
|
+
measureLayout(target, null, (x, y, width, height, left, top) => {
|
|
14
|
+
onLayout({
|
|
15
|
+
nativeEvent: {
|
|
16
|
+
layout: { x, y, width, height, left, top },
|
|
17
|
+
target
|
|
18
|
+
},
|
|
19
|
+
timeStamp: Date.now()
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
const measureLayout = (node, relativeTo, callback) => {
|
|
26
|
+
const relativeNode = relativeTo || (node == null ? void 0 : node.parentNode);
|
|
27
|
+
if (relativeNode instanceof HTMLElement) {
|
|
28
|
+
setTimeout(() => {
|
|
29
|
+
const relativeRect = getBoundingClientRect(relativeNode);
|
|
30
|
+
const { height, left, top, width } = getRect(node);
|
|
31
|
+
const x = left - relativeRect.left;
|
|
32
|
+
const y = top - relativeRect.top;
|
|
33
|
+
callback(x, y, width, height, left, top);
|
|
34
|
+
}, 0);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const idFn = () => {
|
|
38
|
+
};
|
|
39
|
+
function useElementLayout(ref, onLayout) {
|
|
40
|
+
const hasLayoutEvent = !!onLayout;
|
|
41
|
+
const onLayoutEvent = useEvent(onLayout || idFn);
|
|
42
|
+
useIsomorphicLayoutEffect(() => {
|
|
43
|
+
if (!resizeObserver || !hasLayoutEvent)
|
|
44
|
+
return;
|
|
45
|
+
const node = ref.current;
|
|
46
|
+
if (!node)
|
|
47
|
+
return;
|
|
48
|
+
LayoutHandlers.set(node, onLayoutEvent);
|
|
49
|
+
resizeObserver.observe(node);
|
|
50
|
+
return () => {
|
|
51
|
+
resizeObserver == null ? void 0 : resizeObserver.unobserve(node);
|
|
52
|
+
};
|
|
53
|
+
}, [ref, hasLayoutEvent]);
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
measureLayout,
|
|
57
|
+
useElementLayout
|
|
58
|
+
};
|
|
2
59
|
//# sourceMappingURL=useElementLayout.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useElementLayout.tsx"],
|
|
4
4
|
"sourcesContent": ["import { useIsomorphicLayoutEffect } from '@tamagui/constants'\nimport { useEvent } from '@tamagui/use-event'\nimport { RefObject } from 'react'\n\nimport { getBoundingClientRect } from '../helpers/getBoundingClientRect'\nimport { getRect } from '../helpers/getRect'\n\nconst LayoutHandlers = new WeakMap<Element, Function>()\n\nexport type LayoutValue = {\n x: number\n y: number\n width: number\n height: number\n left: number\n top: number\n}\n\nexport type LayoutEvent = {\n nativeEvent: {\n layout: LayoutValue\n target: any\n }\n timeStamp: number\n}\n\nlet resizeObserver: ResizeObserver | null = null\n\nif (typeof window !== 'undefined' && 'ResizeObserver' in window) {\n resizeObserver = new ResizeObserver((entries) => {\n for (const { target } of entries) {\n const onLayout = LayoutHandlers.get(target)\n if (typeof onLayout !== 'function') return\n measureLayout(target as HTMLElement, null, (x, y, width, height, left, top) => {\n onLayout({\n nativeEvent: {\n layout: { x, y, width, height, left, top },\n target,\n },\n timeStamp: Date.now(),\n })\n })\n }\n })\n}\n\nexport const measureLayout = (\n node: HTMLElement,\n relativeTo: HTMLElement | null,\n callback: Function\n) => {\n const relativeNode = relativeTo || node?.parentNode\n if (relativeNode instanceof HTMLElement) {\n setTimeout(() => {\n const relativeRect = getBoundingClientRect(relativeNode)!\n const { height, left, top, width } = getRect(node)!\n const x = left - relativeRect.left\n const y = top - relativeRect.top\n callback(x, y, width, height, left, top)\n }, 0)\n }\n}\n\nconst idFn = () => {}\n\nexport function useElementLayout(\n ref: RefObject<Element>,\n onLayout?: ((e: LayoutEvent) => void) | null\n) {\n const hasLayoutEvent = !!onLayout\n const onLayoutEvent = useEvent(onLayout || idFn)\n\n // Observing is done in a separate effect to avoid this effect running\n // when 'onLayout' changes.\n useIsomorphicLayoutEffect(() => {\n if (!resizeObserver || !hasLayoutEvent) return\n const node = ref.current\n if (!node) return\n LayoutHandlers.set(node, onLayoutEvent)\n resizeObserver.observe(node)\n return () => {\n resizeObserver?.unobserve(node)\n }\n }, [ref, hasLayoutEvent])\n}\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,SAAS,iCAAiC;AAC1C,SAAS,gBAAgB;AAGzB,SAAS,6BAA6B;AACtC,SAAS,eAAe;AAExB,MAAM,iBAAiB,oBAAI,QAA2B;AAmBtD,IAAI,iBAAwC;AAE5C,IAAI,OAAO,WAAW,eAAe,oBAAoB,QAAQ;AAC/D,mBAAiB,IAAI,eAAe,CAAC,YAAY;AAC/C,eAAW,EAAE,OAAO,KAAK,SAAS;AAChC,YAAM,WAAW,eAAe,IAAI,MAAM;AAC1C,UAAI,OAAO,aAAa;AAAY;AACpC,oBAAc,QAAuB,MAAM,CAAC,GAAG,GAAG,OAAO,QAAQ,MAAM,QAAQ;AAC7E,iBAAS;AAAA,UACP,aAAa;AAAA,YACX,QAAQ,EAAE,GAAG,GAAG,OAAO,QAAQ,MAAM,IAAI;AAAA,YACzC;AAAA,UACF;AAAA,UACA,WAAW,KAAK,IAAI;AAAA,QACtB,CAAC;AAAA,MACH,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH;AAEO,MAAM,gBAAgB,CAC3B,MACA,YACA,aACG;AACH,QAAM,eAAe,eAAc,6BAAM;AACzC,MAAI,wBAAwB,aAAa;AACvC,eAAW,MAAM;AACf,YAAM,eAAe,sBAAsB,YAAY;AACvD,YAAM,EAAE,QAAQ,MAAM,KAAK,MAAM,IAAI,QAAQ,IAAI;AACjD,YAAM,IAAI,OAAO,aAAa;AAC9B,YAAM,IAAI,MAAM,aAAa;AAC7B,eAAS,GAAG,GAAG,OAAO,QAAQ,MAAM,GAAG;AAAA,IACzC,GAAG,CAAC;AAAA,EACN;AACF;AAEA,MAAM,OAAO,MAAM;AAAC;AAEb,SAAS,iBACd,KACA,UACA;AACA,QAAM,iBAAiB,CAAC,CAAC;AACzB,QAAM,gBAAgB,SAAS,YAAY,IAAI;AAI/C,4BAA0B,MAAM;AAC9B,QAAI,CAAC,kBAAkB,CAAC;AAAgB;AACxC,UAAM,OAAO,IAAI;AACjB,QAAI,CAAC;AAAM;AACX,mBAAe,IAAI,MAAM,aAAa;AACtC,mBAAe,QAAQ,IAAI;AAC3B,WAAO,MAAM;AACX,uDAAgB,UAAU;AAAA,IAC5B;AAAA,EACF,GAAG,CAAC,KAAK,cAAc,CAAC;AAC1B;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,59 @@
|
|
|
1
|
-
import{useIsomorphicLayoutEffect
|
|
1
|
+
import { useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
2
|
+
import { useEvent } from "@tamagui/use-event";
|
|
3
|
+
import { getBoundingClientRect } from "../helpers/getBoundingClientRect";
|
|
4
|
+
import { getRect } from "../helpers/getRect";
|
|
5
|
+
const LayoutHandlers = /* @__PURE__ */ new WeakMap();
|
|
6
|
+
let resizeObserver = null;
|
|
7
|
+
if (typeof window !== "undefined" && "ResizeObserver" in window) {
|
|
8
|
+
resizeObserver = new ResizeObserver((entries) => {
|
|
9
|
+
for (const { target } of entries) {
|
|
10
|
+
const onLayout = LayoutHandlers.get(target);
|
|
11
|
+
if (typeof onLayout !== "function")
|
|
12
|
+
return;
|
|
13
|
+
measureLayout(target, null, (x, y, width, height, left, top) => {
|
|
14
|
+
onLayout({
|
|
15
|
+
nativeEvent: {
|
|
16
|
+
layout: { x, y, width, height, left, top },
|
|
17
|
+
target
|
|
18
|
+
},
|
|
19
|
+
timeStamp: Date.now()
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
const measureLayout = (node, relativeTo, callback) => {
|
|
26
|
+
const relativeNode = relativeTo || (node == null ? void 0 : node.parentNode);
|
|
27
|
+
if (relativeNode instanceof HTMLElement) {
|
|
28
|
+
setTimeout(() => {
|
|
29
|
+
const relativeRect = getBoundingClientRect(relativeNode);
|
|
30
|
+
const { height, left, top, width } = getRect(node);
|
|
31
|
+
const x = left - relativeRect.left;
|
|
32
|
+
const y = top - relativeRect.top;
|
|
33
|
+
callback(x, y, width, height, left, top);
|
|
34
|
+
}, 0);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const idFn = () => {
|
|
38
|
+
};
|
|
39
|
+
function useElementLayout(ref, onLayout) {
|
|
40
|
+
const hasLayoutEvent = !!onLayout;
|
|
41
|
+
const onLayoutEvent = useEvent(onLayout || idFn);
|
|
42
|
+
useIsomorphicLayoutEffect(() => {
|
|
43
|
+
if (!resizeObserver || !hasLayoutEvent)
|
|
44
|
+
return;
|
|
45
|
+
const node = ref.current;
|
|
46
|
+
if (!node)
|
|
47
|
+
return;
|
|
48
|
+
LayoutHandlers.set(node, onLayoutEvent);
|
|
49
|
+
resizeObserver.observe(node);
|
|
50
|
+
return () => {
|
|
51
|
+
resizeObserver == null ? void 0 : resizeObserver.unobserve(node);
|
|
52
|
+
};
|
|
53
|
+
}, [ref, hasLayoutEvent]);
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
measureLayout,
|
|
57
|
+
useElementLayout
|
|
58
|
+
};
|
|
2
59
|
//# sourceMappingURL=useElementLayout.mjs.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useElementLayout.tsx"],
|
|
4
4
|
"sourcesContent": ["import { useIsomorphicLayoutEffect } from '@tamagui/constants'\nimport { useEvent } from '@tamagui/use-event'\nimport { RefObject } from 'react'\n\nimport { getBoundingClientRect } from '../helpers/getBoundingClientRect'\nimport { getRect } from '../helpers/getRect'\n\nconst LayoutHandlers = new WeakMap<Element, Function>()\n\nexport type LayoutValue = {\n x: number\n y: number\n width: number\n height: number\n left: number\n top: number\n}\n\nexport type LayoutEvent = {\n nativeEvent: {\n layout: LayoutValue\n target: any\n }\n timeStamp: number\n}\n\nlet resizeObserver: ResizeObserver | null = null\n\nif (typeof window !== 'undefined' && 'ResizeObserver' in window) {\n resizeObserver = new ResizeObserver((entries) => {\n for (const { target } of entries) {\n const onLayout = LayoutHandlers.get(target)\n if (typeof onLayout !== 'function') return\n measureLayout(target as HTMLElement, null, (x, y, width, height, left, top) => {\n onLayout({\n nativeEvent: {\n layout: { x, y, width, height, left, top },\n target,\n },\n timeStamp: Date.now(),\n })\n })\n }\n })\n}\n\nexport const measureLayout = (\n node: HTMLElement,\n relativeTo: HTMLElement | null,\n callback: Function\n) => {\n const relativeNode = relativeTo || node?.parentNode\n if (relativeNode instanceof HTMLElement) {\n setTimeout(() => {\n const relativeRect = getBoundingClientRect(relativeNode)!\n const { height, left, top, width } = getRect(node)!\n const x = left - relativeRect.left\n const y = top - relativeRect.top\n callback(x, y, width, height, left, top)\n }, 0)\n }\n}\n\nconst idFn = () => {}\n\nexport function useElementLayout(\n ref: RefObject<Element>,\n onLayout?: ((e: LayoutEvent) => void) | null\n) {\n const hasLayoutEvent = !!onLayout\n const onLayoutEvent = useEvent(onLayout || idFn)\n\n // Observing is done in a separate effect to avoid this effect running\n // when 'onLayout' changes.\n useIsomorphicLayoutEffect(() => {\n if (!resizeObserver || !hasLayoutEvent) return\n const node = ref.current\n if (!node) return\n LayoutHandlers.set(node, onLayoutEvent)\n resizeObserver.observe(node)\n return () => {\n resizeObserver?.unobserve(node)\n }\n }, [ref, hasLayoutEvent])\n}\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,SAAS,iCAAiC;AAC1C,SAAS,gBAAgB;AAGzB,SAAS,6BAA6B;AACtC,SAAS,eAAe;AAExB,MAAM,iBAAiB,oBAAI,QAA2B;AAmBtD,IAAI,iBAAwC;A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|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,24 @@
|
|
|
1
|
-
import{useIsomorphicLayoutEffect
|
|
1
|
+
import { useIsomorphicLayoutEffect } from "@tamagui/web";
|
|
2
|
+
import { getRect } from "../helpers/getRect";
|
|
3
|
+
import { measureLayout } from "./useElementLayout";
|
|
4
|
+
function usePlatformMethods(hostRef) {
|
|
5
|
+
useIsomorphicLayoutEffect(() => {
|
|
6
|
+
const node = hostRef.current;
|
|
7
|
+
if (!node)
|
|
8
|
+
return;
|
|
9
|
+
node.measure = (callback) => measureLayout(node, null, callback);
|
|
10
|
+
node.measureLayout = (relativeToNode, success) => measureLayout(node, relativeToNode, success);
|
|
11
|
+
node.measureInWindow = (callback) => {
|
|
12
|
+
if (!node)
|
|
13
|
+
return;
|
|
14
|
+
setTimeout(() => {
|
|
15
|
+
const { height, left, top, width } = getRect(node);
|
|
16
|
+
callback(left, top, width, height);
|
|
17
|
+
}, 0);
|
|
18
|
+
};
|
|
19
|
+
}, [hostRef]);
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
usePlatformMethods
|
|
23
|
+
};
|
|
2
24
|
//# sourceMappingURL=usePlatformMethods.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/usePlatformMethods.ts"],
|
|
4
4
|
"sourcesContent": ["import { useIsomorphicLayoutEffect } from '@tamagui/web'\nimport { RefObject } from 'react'\n\nimport { getRect } from '../helpers/getRect'\nimport { measureLayout } from './useElementLayout'\n\n// react native compat (web only)\nexport function usePlatformMethods(hostRef: RefObject<Element>) {\n useIsomorphicLayoutEffect(() => {\n const node = hostRef.current\n if (!node) return\n // @ts-ignore\n node.measure = (callback) => measureLayout(node, null, callback)\n // @ts-ignore\n node.measureLayout = (relativeToNode, success) =>\n measureLayout(node as HTMLElement, relativeToNode, success)\n // @ts-ignore\n node.measureInWindow = (callback) => {\n if (!node) return\n setTimeout(() => {\n const { height, left, top, width } = getRect(node as HTMLElement)!\n callback(left, top, width, height)\n }, 0)\n }\n }, [hostRef])\n}\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,SAAS,iCAAiC;AAG1C,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAGvB,SAAS,mBAAmB,SAA6B;AAC9D,4BAA0B,MAAM;AAC9B,UAAM,OAAO,QAAQ;AACrB,QAAI,CAAC;AAAM;AAEX,SAAK,UAAU,CAAC,aAAa,cAAc,MAAM,MAAM,QAAQ;AAE/D,SAAK,gBAAgB,CAAC,gBAAgB,YACpC,cAAc,MAAqB,gBAAgB,OAAO;AAE5D,SAAK,kBAAkB,CAAC,aAAa;AACnC,UAAI,CAAC;AAAM;AACX,iBAAW,MAAM;AACf,cAAM,EAAE,QAAQ,MAAM,KAAK,MAAM,IAAI,QAAQ,IAAmB;AAChE,iBAAS,MAAM,KAAK,OAAO,MAAM;AAAA,MACnC,GAAG,CAAC;AAAA,IACN;AAAA,EACF,GAAG,CAAC,OAAO,CAAC;AACd;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,24 @@
|
|
|
1
|
-
import{useIsomorphicLayoutEffect
|
|
1
|
+
import { useIsomorphicLayoutEffect } from "@tamagui/web";
|
|
2
|
+
import { getRect } from "../helpers/getRect";
|
|
3
|
+
import { measureLayout } from "./useElementLayout";
|
|
4
|
+
function usePlatformMethods(hostRef) {
|
|
5
|
+
useIsomorphicLayoutEffect(() => {
|
|
6
|
+
const node = hostRef.current;
|
|
7
|
+
if (!node)
|
|
8
|
+
return;
|
|
9
|
+
node.measure = (callback) => measureLayout(node, null, callback);
|
|
10
|
+
node.measureLayout = (relativeToNode, success) => measureLayout(node, relativeToNode, success);
|
|
11
|
+
node.measureInWindow = (callback) => {
|
|
12
|
+
if (!node)
|
|
13
|
+
return;
|
|
14
|
+
setTimeout(() => {
|
|
15
|
+
const { height, left, top, width } = getRect(node);
|
|
16
|
+
callback(left, top, width, height);
|
|
17
|
+
}, 0);
|
|
18
|
+
};
|
|
19
|
+
}, [hostRef]);
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
usePlatformMethods
|
|
23
|
+
};
|
|
2
24
|
//# sourceMappingURL=usePlatformMethods.mjs.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/usePlatformMethods.ts"],
|
|
4
4
|
"sourcesContent": ["import { useIsomorphicLayoutEffect } from '@tamagui/web'\nimport { RefObject } from 'react'\n\nimport { getRect } from '../helpers/getRect'\nimport { measureLayout } from './useElementLayout'\n\n// react native compat (web only)\nexport function usePlatformMethods(hostRef: RefObject<Element>) {\n useIsomorphicLayoutEffect(() => {\n const node = hostRef.current\n if (!node) return\n // @ts-ignore\n node.measure = (callback) => measureLayout(node, null, callback)\n // @ts-ignore\n node.measureLayout = (relativeToNode, success) =>\n measureLayout(node as HTMLElement, relativeToNode, success)\n // @ts-ignore\n node.measureInWindow = (callback) => {\n if (!node) return\n setTimeout(() => {\n const { height, left, top, width } = getRect(node as HTMLElement)!\n callback(left, top, width, height)\n }, 0)\n }\n }, [hostRef])\n}\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,SAAS,iCAAiC;AAG1C,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAGvB,SAAS,mBAAmB,SAA6B;AAC9D,4BAA0B,MAAM;AAC9B,UAAM,OAAO,QAAQ;AACrB,QAAI,CAAC;AAAM;AAEX,SAAK,UAAU,CAAC,aAAa,cAAc,MAAM,MAAM,QAAQ;AAE/D,SAAK,gBAAgB,CAAC,gBAAgB,YACpC,cAAc,MAAqB,gBAAgB,OAAO;AAE5D,SAAK,kBAAkB,CAAC,aAAa;AACnC,UAAI,CAAC;AAAM;AACX,iBAAW,MAAM;AACf,cAAM,EAAE,QAAQ,MAAM,KAAK,MAAM,IAAI,QAAQ,IAAmB;AAChE,iBAAS,MAAM,KAAK,OAAO,MAAM;AAAA,MACnC,GAAG,CAAC;AAAA,IACN;AAAA,EACF,GAAG,CAAC,OAAO,CAAC;AACd;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1,145 @@
|
|
|
1
|
-
import{useResponderEvents
|
|
1
|
+
import { useResponderEvents } from "@tamagui/react-native-use-responder-events";
|
|
2
|
+
import {
|
|
3
|
+
Stack as WebStack,
|
|
4
|
+
Text as WebText,
|
|
5
|
+
composeEventHandlers,
|
|
6
|
+
isRSC,
|
|
7
|
+
mergeEvent,
|
|
8
|
+
setupHooks
|
|
9
|
+
} from "@tamagui/web";
|
|
10
|
+
import { useElementLayout } from "./hooks/useElementLayout";
|
|
11
|
+
import { usePlatformMethods } from "./hooks/usePlatformMethods";
|
|
12
|
+
import { usePressability } from "./vendor/Pressability";
|
|
13
|
+
export * from "@tamagui/web";
|
|
14
|
+
const Stack = WebStack;
|
|
15
|
+
const Text = WebText;
|
|
16
|
+
setupHooks({
|
|
17
|
+
getBaseViews() {
|
|
18
|
+
const native = require("react-native");
|
|
19
|
+
return {
|
|
20
|
+
View: native.View || native.default.View,
|
|
21
|
+
Text: native.Text || native.default.Text
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
usePropsTransform(elementType, propsIn, hostRef) {
|
|
25
|
+
const {
|
|
26
|
+
// event props
|
|
27
|
+
onMoveShouldSetResponder,
|
|
28
|
+
onMoveShouldSetResponderCapture,
|
|
29
|
+
onResponderEnd,
|
|
30
|
+
onResponderGrant,
|
|
31
|
+
onResponderMove,
|
|
32
|
+
onResponderReject,
|
|
33
|
+
onResponderRelease,
|
|
34
|
+
onResponderStart,
|
|
35
|
+
onResponderTerminate,
|
|
36
|
+
onResponderTerminationRequest,
|
|
37
|
+
onScrollShouldSetResponder,
|
|
38
|
+
onScrollShouldSetResponderCapture,
|
|
39
|
+
onSelectionChangeShouldSetResponder,
|
|
40
|
+
onSelectionChangeShouldSetResponderCapture,
|
|
41
|
+
onStartShouldSetResponder,
|
|
42
|
+
onStartShouldSetResponderCapture,
|
|
43
|
+
// android
|
|
44
|
+
collapsable,
|
|
45
|
+
focusable,
|
|
46
|
+
// deprecated,
|
|
47
|
+
accessible,
|
|
48
|
+
accessibilityDisabled,
|
|
49
|
+
onLayout,
|
|
50
|
+
hrefAttrs,
|
|
51
|
+
...viewProps
|
|
52
|
+
} = propsIn;
|
|
53
|
+
if (!isRSC) {
|
|
54
|
+
usePlatformMethods(hostRef);
|
|
55
|
+
useElementLayout(hostRef, onLayout);
|
|
56
|
+
useResponderEvents(hostRef, {
|
|
57
|
+
onMoveShouldSetResponder,
|
|
58
|
+
onMoveShouldSetResponderCapture,
|
|
59
|
+
onResponderEnd,
|
|
60
|
+
onResponderGrant,
|
|
61
|
+
onResponderMove,
|
|
62
|
+
onResponderReject,
|
|
63
|
+
onResponderRelease,
|
|
64
|
+
onResponderStart,
|
|
65
|
+
onResponderTerminate,
|
|
66
|
+
onResponderTerminationRequest,
|
|
67
|
+
onScrollShouldSetResponder,
|
|
68
|
+
onScrollShouldSetResponderCapture,
|
|
69
|
+
onSelectionChangeShouldSetResponder,
|
|
70
|
+
onSelectionChangeShouldSetResponderCapture,
|
|
71
|
+
onStartShouldSetResponder,
|
|
72
|
+
onStartShouldSetResponderCapture
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
if (viewProps.href !== void 0 && hrefAttrs !== void 0) {
|
|
76
|
+
const { download, rel, target } = hrefAttrs;
|
|
77
|
+
if (download != null) {
|
|
78
|
+
viewProps.download = download;
|
|
79
|
+
}
|
|
80
|
+
if (rel != null) {
|
|
81
|
+
viewProps.rel = rel;
|
|
82
|
+
}
|
|
83
|
+
if (typeof target === "string") {
|
|
84
|
+
viewProps.target = target.charAt(0) !== "_" ? `_${target}` : target;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (!viewProps.tabIndex) {
|
|
88
|
+
const _focusable = focusable !== void 0 ? focusable : accessible;
|
|
89
|
+
const role = viewProps.role;
|
|
90
|
+
if (_focusable === false) {
|
|
91
|
+
viewProps.tabIndex = "-1";
|
|
92
|
+
}
|
|
93
|
+
if (
|
|
94
|
+
// These native elements are focusable by default
|
|
95
|
+
elementType === "a" || elementType === "button" || elementType === "input" || elementType === "select" || elementType === "textarea"
|
|
96
|
+
) {
|
|
97
|
+
if (_focusable === false || accessibilityDisabled === true) {
|
|
98
|
+
viewProps.tabIndex = "-1";
|
|
99
|
+
}
|
|
100
|
+
} else if (
|
|
101
|
+
// These roles are made focusable by default
|
|
102
|
+
role === "button" || role === "checkbox" || role === "link" || role === "radio" || role === "textbox" || role === "switch"
|
|
103
|
+
) {
|
|
104
|
+
if (_focusable !== false) {
|
|
105
|
+
viewProps.tabIndex = "0";
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (_focusable === true) {
|
|
109
|
+
viewProps.tabIndex = "0";
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return viewProps;
|
|
113
|
+
},
|
|
114
|
+
useEvents(viewProps, events, { pseudos }, setStateShallow) {
|
|
115
|
+
if (process.env.TAMAGUI_TARGET === "native") {
|
|
116
|
+
const attachFocus = !!(pseudos == null ? void 0 : pseudos.focusStyle);
|
|
117
|
+
if (attachFocus) {
|
|
118
|
+
viewProps.onFocus = mergeEvent(viewProps.onFocus, () => {
|
|
119
|
+
setStateShallow({ focus: true });
|
|
120
|
+
});
|
|
121
|
+
viewProps.onBlur = mergeEvent(viewProps.onBlur, () => {
|
|
122
|
+
setStateShallow({ focus: false });
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
const pressability = usePressability(
|
|
126
|
+
events ? { ...events, hitSlop: viewProps.hitSlop } : {}
|
|
127
|
+
);
|
|
128
|
+
if (events == null ? void 0 : events.onPress) {
|
|
129
|
+
for (const key in pressability) {
|
|
130
|
+
const og = viewProps[key];
|
|
131
|
+
const val = pressability[key];
|
|
132
|
+
viewProps[key] = og && !dontComposePressabilityKeys[key] ? composeEventHandlers(og, val) : val;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
const dontComposePressabilityKeys = {
|
|
139
|
+
onClick: true
|
|
140
|
+
};
|
|
141
|
+
export {
|
|
142
|
+
Stack,
|
|
143
|
+
Text
|
|
144
|
+
};
|
|
2
145
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
4
|
"sourcesContent": ["import { useResponderEvents } from '@tamagui/react-native-use-responder-events'\nimport {\n StackProps,\n StackPropsBase,\n TamaguiComponent,\n TextProps,\n TextPropsBase,\n Stack as WebStack,\n Text as WebText,\n composeEventHandlers,\n isRSC,\n mergeEvent,\n setupHooks,\n} from '@tamagui/web'\nimport { RefObject } from 'react'\nimport type { Text as RNText, View as RNView } from 'react-native'\n\nimport { useElementLayout } from './hooks/useElementLayout'\nimport { usePlatformMethods } from './hooks/usePlatformMethods'\nimport type { RNTextProps, RNViewProps } from './reactNativeTypes'\nimport { usePressability } from './vendor/Pressability'\n\n// re-exports all of @tamagui/web just adds hooks\nexport * from '@tamagui/web'\n\n// adds extra types to Stack/Text:\n\nexport const Stack = WebStack as TamaguiComponent<\n StackProps & RNViewProps,\n RNView,\n StackPropsBase & RNViewProps\n>\n\nexport const Text = WebText as TamaguiComponent<\n TextProps & RNTextProps,\n RNText,\n TextPropsBase & RNTextProps\n>\n\n// setup internal hooks:\n\nsetupHooks({\n getBaseViews() {\n const native = require('react-native')\n return {\n View: native.View || native.default.View,\n Text: native.Text || native.default.Text,\n }\n },\n\n usePropsTransform(elementType, propsIn, hostRef) {\n // otherwise replicate react-native-web functionality\n const {\n // event props\n onMoveShouldSetResponder,\n onMoveShouldSetResponderCapture,\n onResponderEnd,\n onResponderGrant,\n onResponderMove,\n onResponderReject,\n onResponderRelease,\n onResponderStart,\n onResponderTerminate,\n onResponderTerminationRequest,\n onScrollShouldSetResponder,\n onScrollShouldSetResponderCapture,\n onSelectionChangeShouldSetResponder,\n onSelectionChangeShouldSetResponderCapture,\n onStartShouldSetResponder,\n onStartShouldSetResponderCapture,\n\n // android\n collapsable,\n focusable,\n\n // deprecated,\n accessible,\n accessibilityDisabled,\n\n onLayout,\n hrefAttrs,\n\n ...viewProps\n } = propsIn\n\n if (!isRSC) {\n usePlatformMethods(hostRef as RefObject<Element>)\n useElementLayout(hostRef as RefObject<Element>, onLayout as any)\n useResponderEvents(hostRef, {\n onMoveShouldSetResponder,\n onMoveShouldSetResponderCapture,\n onResponderEnd,\n onResponderGrant,\n onResponderMove,\n onResponderReject,\n onResponderRelease,\n onResponderStart,\n onResponderTerminate,\n onResponderTerminationRequest,\n onScrollShouldSetResponder,\n onScrollShouldSetResponderCapture,\n onSelectionChangeShouldSetResponder,\n onSelectionChangeShouldSetResponderCapture,\n onStartShouldSetResponder,\n onStartShouldSetResponderCapture,\n } as any)\n }\n\n // TODO move into getSplitStyles inital `if (process.env.TAMAGUI_TARGET === 'web')` block\n\n if (viewProps.href !== undefined && hrefAttrs !== undefined) {\n const { download, rel, target } = hrefAttrs\n if (download != null) {\n viewProps.download = download\n }\n if (rel != null) {\n viewProps.rel = rel\n }\n if (typeof target === 'string') {\n viewProps.target = target.charAt(0) !== '_' ? `_${target}` : target\n }\n }\n\n // FOCUS\n // \"focusable\" indicates that an element may be a keyboard tab-stop.\n // ported from RNW: TODO move into getSplitStyles\n if (!viewProps.tabIndex) {\n const _focusable = focusable !== undefined ? focusable : accessible\n const role = viewProps.role\n if (_focusable === false) {\n viewProps.tabIndex = '-1'\n }\n if (\n // These native elements are focusable by default\n elementType === 'a' ||\n elementType === 'button' ||\n elementType === 'input' ||\n elementType === 'select' ||\n elementType === 'textarea'\n ) {\n if (_focusable === false || accessibilityDisabled === true) {\n viewProps.tabIndex = '-1'\n }\n } else if (\n // These roles are made focusable by default\n role === 'button' ||\n role === 'checkbox' ||\n role === 'link' ||\n role === 'radio' ||\n role === 'textbox' ||\n role === 'switch'\n ) {\n if (_focusable !== false) {\n viewProps.tabIndex = '0'\n }\n }\n // Everything else must explicitly set the prop\n if (_focusable === true) {\n viewProps.tabIndex = '0'\n }\n }\n\n return viewProps\n },\n\n useEvents(viewProps, events, { pseudos }, setStateShallow) {\n if (process.env.TAMAGUI_TARGET === 'native') {\n const attachFocus = !!pseudos?.focusStyle\n if (attachFocus) {\n viewProps.onFocus = mergeEvent(viewProps.onFocus, () => {\n setStateShallow({ focus: true })\n })\n viewProps.onBlur = mergeEvent(viewProps.onBlur, () => {\n setStateShallow({ focus: false })\n })\n }\n\n // use Pressability to get smooth unPress when you press + hold + move out\n // only ever create once, use .configure() to update later\n const pressability = usePressability(\n events ? { ...events, hitSlop: viewProps.hitSlop } : {}\n )\n if (events?.onPress) {\n for (const key in pressability) {\n const og = viewProps[key]\n const val = pressability[key]\n viewProps[key] =\n og && !dontComposePressabilityKeys[key] ? composeEventHandlers(og, val) : val\n }\n }\n }\n },\n})\n\nconst dontComposePressabilityKeys = {\n onClick: true,\n}\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,SAAS,0BAA0B;AACnC;AAAA,EAME,SAAS;AAAA,EACT,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAIP,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AAEnC,SAAS,uBAAuB;AAGhC,cAAc;AAIP,MAAM,QAAQ;AAMd,MAAM,OAAO;AAQpB,WAAW;AAAA,EACT,eAAe;AACb,UAAM,SAAS,QAAQ,cAAc;AACrC,WAAO;AAAA,MACL,MAAM,OAAO,QAAQ,OAAO,QAAQ;AAAA,MACpC,MAAM,OAAO,QAAQ,OAAO,QAAQ;AAAA,IACtC;AAAA,EACF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