@tamagui/core 1.13.3 → 1.14.0
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 +1 -33
- package/dist/cjs/helpers/getBoundingClientRect.js.map +2 -2
- package/dist/cjs/helpers/getRect.js +1 -35
- package/dist/cjs/helpers/getRect.js.map +2 -2
- package/dist/cjs/hooks/useElementLayout.js +1 -83
- package/dist/cjs/hooks/useElementLayout.js.map +2 -2
- package/dist/cjs/hooks/usePlatformMethods.js +1 -47
- package/dist/cjs/hooks/usePlatformMethods.js.map +2 -2
- package/dist/cjs/index.js +1 -163
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/inject-styles.js +1 -39
- package/dist/cjs/inject-styles.js.map +2 -2
- package/dist/cjs/reactNativeTypes.js +1 -16
- package/dist/cjs/reactNativeTypes.js.map +2 -2
- package/dist/cjs/vendor/Pressability.js +1 -31
- package/dist/cjs/vendor/Pressability.js.map +2 -2
- package/dist/cjs/vendor/Pressability.native.js +1 -31
- package/dist/cjs/vendor/Pressability.native.js.map +2 -2
- package/dist/esm/helpers/getBoundingClientRect.js +1 -9
- package/dist/esm/helpers/getBoundingClientRect.js.map +2 -2
- package/dist/esm/helpers/getBoundingClientRect.mjs +1 -9
- package/dist/esm/helpers/getBoundingClientRect.mjs.map +2 -2
- package/dist/esm/helpers/getRect.js +1 -11
- package/dist/esm/helpers/getRect.js.map +2 -2
- package/dist/esm/helpers/getRect.mjs +1 -11
- package/dist/esm/helpers/getRect.mjs.map +2 -2
- package/dist/esm/hooks/useElementLayout.js +1 -58
- package/dist/esm/hooks/useElementLayout.js.map +2 -2
- package/dist/esm/hooks/useElementLayout.mjs +1 -58
- package/dist/esm/hooks/useElementLayout.mjs.map +2 -2
- package/dist/esm/hooks/usePlatformMethods.js +1 -23
- package/dist/esm/hooks/usePlatformMethods.js.map +2 -2
- package/dist/esm/hooks/usePlatformMethods.mjs +1 -23
- package/dist/esm/hooks/usePlatformMethods.mjs.map +2 -2
- package/dist/esm/index.js +1 -144
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/index.mjs +1 -144
- package/dist/esm/index.mjs.map +2 -2
- package/dist/esm/inject-styles.js +1 -15
- package/dist/esm/inject-styles.js.map +2 -2
- package/dist/esm/inject-styles.mjs +1 -15
- package/dist/esm/inject-styles.mjs.map +2 -2
- package/dist/esm/vendor/Pressability.js +1 -6
- package/dist/esm/vendor/Pressability.js.map +2 -2
- package/dist/esm/vendor/Pressability.mjs +1 -6
- package/dist/esm/vendor/Pressability.mjs.map +2 -2
- package/dist/esm/vendor/Pressability.native.js +1 -6
- package/dist/esm/vendor/Pressability.native.js.map +2 -2
- package/dist/esm/vendor/Pressability.native.mjs +1 -6
- 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": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,EAAA,oBAAAC,IAAA,eAAAC,EAAAJ,GAAO,MAAME,EAAe,CAAC,EAChBC,EAAkB,CAAC",
|
|
6
|
+
"names": ["Pressability_exports", "__export", "Pressability", "usePressability", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,32 +1,2 @@
|
|
|
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
|
-
});
|
|
1
|
+
"use strict";var i=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var o=Object.prototype.hasOwnProperty;var b=(r,e)=>{for(var s in e)i(r,s,{get:e[s],enumerable:!0})},c=(r,e,s,u)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of l(e))!o.call(r,t)&&t!==s&&i(r,t,{get:()=>e[t],enumerable:!(u=a(e,t))||u.enumerable});return r};var d=r=>c(i({},"__esModule",{value:!0}),r);var p={};b(p,{Pressability:()=>f,usePressability:()=>n});module.exports=d(p);const f=require("react-native/Libraries/Pressability/Pressability").default,n=require("react-native/Libraries/Pressability/usePressability").default;0&&(module.exports={Pressability,usePressability});
|
|
32
2
|
//# 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": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,EAAA,oBAAAC,IAAA,eAAAC,EAAAJ,GAAO,MAAME,EACX,QAAQ,kDAAkD,EAAE,QACjDC,EACX,QAAQ,qDAAqD,EAAE",
|
|
6
|
+
"names": ["Pressability_native_exports", "__export", "Pressability", "usePressability", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
const
|
|
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
|
-
};
|
|
1
|
+
const i=t=>{var e;if(!(!t||t.nodeType!==1))return(e=t.getBoundingClientRect)==null?void 0:e.call(t)};export{i as getBoundingClientRect};
|
|
10
2
|
//# 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,MAAMA,EAAyBC,GAA6C,CAAnF,IAAAC,EACE,GAAI,GAACD,GAAQA,EAAK,WAAa,GAC/B,OAAOC,EAAAD,EAAK,wBAAL,YAAAC,EAAA,KAAAD,EACT",
|
|
6
|
+
"names": ["getBoundingClientRect", "node", "_a"]
|
|
7
7
|
}
|
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
const
|
|
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
|
-
};
|
|
1
|
+
const i=t=>{var e;if(!(!t||t.nodeType!==1))return(e=t.getBoundingClientRect)==null?void 0:e.call(t)};export{i as getBoundingClientRect};
|
|
10
2
|
//# 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,MAAMA,EAAyBC,GAA6C,CAAnF,IAAAC,EACE,GAAI,GAACD,GAAQA,EAAK,WAAa,GAC/B,OAAOC,EAAAD,EAAK,wBAAL,YAAAC,EAAA,KAAAD,EACT",
|
|
6
|
+
"names": ["getBoundingClientRect", "node", "_a"]
|
|
7
7
|
}
|
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
import
|
|
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
|
-
};
|
|
1
|
+
import{getBoundingClientRect as n}from"./getBoundingClientRect";const g=t=>{const e=n(t);if(!e)return;const{x:i,y:o,top:r,left:f}=e;return{x:i,y:o,width:t.offsetWidth,height:t.offsetHeight,top:r,left:f}};export{g as getRect};
|
|
12
2
|
//# 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,OAAS,yBAAAA,MAA6B,0BAE/B,MAAMC,EAAWC,GAAsB,CAC5C,MAAMC,EAAOH,EAAsBE,CAAI,EACvC,GAAI,CAACC,EAAM,OACX,KAAM,CAAE,EAAAC,EAAG,EAAAC,EAAG,IAAAC,EAAK,KAAAC,CAAK,EAAIJ,EAC5B,MAAO,CAAE,EAAAC,EAAG,EAAAC,EAAG,MAAOH,EAAK,YAAa,OAAQA,EAAK,aAAc,IAAAI,EAAK,KAAAC,CAAK,CAC/E",
|
|
6
|
+
"names": ["getBoundingClientRect", "getRect", "node", "rect", "x", "y", "top", "left"]
|
|
7
7
|
}
|
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
import
|
|
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
|
-
};
|
|
1
|
+
import{getBoundingClientRect as n}from"./getBoundingClientRect";const g=t=>{const e=n(t);if(!e)return;const{x:i,y:o,top:r,left:f}=e;return{x:i,y:o,width:t.offsetWidth,height:t.offsetHeight,top:r,left:f}};export{g as getRect};
|
|
12
2
|
//# 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,OAAS,yBAAAA,MAA6B,0BAE/B,MAAMC,EAAWC,GAAsB,CAC5C,MAAMC,EAAOH,EAAsBE,CAAI,EACvC,GAAI,CAACC,EAAM,OACX,KAAM,CAAE,EAAAC,EAAG,EAAAC,EAAG,IAAAC,EAAK,KAAAC,CAAK,EAAIJ,EAC5B,MAAO,CAAE,EAAAC,EAAG,EAAAC,EAAG,MAAOH,EAAK,YAAa,OAAQA,EAAK,aAAc,IAAAI,EAAK,KAAAC,CAAK,CAC/E",
|
|
6
|
+
"names": ["getBoundingClientRect", "getRect", "node", "rect", "x", "y", "top", "left"]
|
|
7
7
|
}
|
|
@@ -1,59 +1,2 @@
|
|
|
1
|
-
import
|
|
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
|
-
};
|
|
1
|
+
import{useIsomorphicLayoutEffect as p}from"@tamagui/constants";import{useEvent as y}from"@tamagui/use-event";import{getBoundingClientRect as v}from"../helpers/getBoundingClientRect";import{getRect as E}from"../helpers/getRect";const l=new WeakMap;let u=null;typeof window<"u"&&"ResizeObserver"in window&&(u=new ResizeObserver(t=>{for(const{target:n}of t){const o=l.get(n);if(typeof o!="function")return;L(n,null,(r,e,m,i,a,s)=>{o({nativeEvent:{layout:{x:r,y:e,width:m,height:i,left:a,top:s},target:n},timeStamp:Date.now()})})}}));const L=(t,n,o)=>{const r=n||(t==null?void 0:t.parentNode);r instanceof HTMLElement&&setTimeout(()=>{const e=v(r),{height:m,left:i,top:a,width:s}=E(t),c=i-e.left,f=a-e.top;o(c,f,s,m,i,a)},0)},b=()=>{};function H(t,n){const o=!!n,r=y(n||b);p(()=>{if(!u||!o)return;const e=t.current;if(e)return l.set(e,r),u.observe(e),()=>{u==null||u.unobserve(e)}},[t,o])}export{L as measureLayout,H as useElementLayout};
|
|
59
2
|
//# 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,OAAS,6BAAAA,MAAiC,qBAC1C,OAAS,YAAAC,MAAgB,qBAGzB,OAAS,yBAAAC,MAA6B,mCACtC,OAAS,WAAAC,MAAe,qBAExB,MAAMC,EAAiB,IAAI,QAmB3B,IAAIC,EAAwC,KAExC,OAAO,OAAW,KAAe,mBAAoB,SACvDA,EAAiB,IAAI,eAAgBC,GAAY,CAC/C,SAAW,CAAE,OAAAC,CAAO,IAAKD,EAAS,CAChC,MAAME,EAAWJ,EAAe,IAAIG,CAAM,EAC1C,GAAI,OAAOC,GAAa,WAAY,OACpCC,EAAcF,EAAuB,KAAM,CAACG,EAAGC,EAAGC,EAAOC,EAAQC,EAAMC,IAAQ,CAC7EP,EAAS,CACP,YAAa,CACX,OAAQ,CAAE,EAAAE,EAAG,EAAAC,EAAG,MAAAC,EAAO,OAAAC,EAAQ,KAAAC,EAAM,IAAAC,CAAI,EACzC,OAAAR,CACF,EACA,UAAW,KAAK,IAAI,CACtB,CAAC,CACH,CAAC,CACH,CACF,CAAC,GAGI,MAAME,EAAgB,CAC3BO,EACAC,EACAC,IACG,CACH,MAAMC,EAAeF,IAAcD,GAAA,YAAAA,EAAM,YACrCG,aAAwB,aAC1B,WAAW,IAAM,CACf,MAAMC,EAAelB,EAAsBiB,CAAY,EACjD,CAAE,OAAAN,EAAQ,KAAAC,EAAM,IAAAC,EAAK,MAAAH,CAAM,EAAIT,EAAQa,CAAI,EAC3CN,EAAII,EAAOM,EAAa,KACxBT,EAAII,EAAMK,EAAa,IAC7BF,EAASR,EAAGC,EAAGC,EAAOC,EAAQC,EAAMC,CAAG,CACzC,EAAG,CAAC,CAER,EAEMM,EAAO,IAAM,CAAC,EAEb,SAASC,EACdC,EACAf,EACA,CACA,MAAMgB,EAAiB,CAAC,CAAChB,EACnBiB,EAAgBxB,EAASO,GAAYa,CAAI,EAI/CrB,EAA0B,IAAM,CAC9B,GAAI,CAACK,GAAkB,CAACmB,EAAgB,OACxC,MAAMR,EAAOO,EAAI,QACjB,GAAKP,EACL,OAAAZ,EAAe,IAAIY,EAAMS,CAAa,EACtCpB,EAAe,QAAQW,CAAI,EACpB,IAAM,CACXX,GAAA,MAAAA,EAAgB,UAAUW,EAC5B,CACF,EAAG,CAACO,EAAKC,CAAc,CAAC,CAC1B",
|
|
6
|
+
"names": ["useIsomorphicLayoutEffect", "useEvent", "getBoundingClientRect", "getRect", "LayoutHandlers", "resizeObserver", "entries", "target", "onLayout", "measureLayout", "x", "y", "width", "height", "left", "top", "node", "relativeTo", "callback", "relativeNode", "relativeRect", "idFn", "useElementLayout", "ref", "hasLayoutEvent", "onLayoutEvent"]
|
|
7
7
|
}
|
|
@@ -1,59 +1,2 @@
|
|
|
1
|
-
import
|
|
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
|
-
};
|
|
1
|
+
import{useIsomorphicLayoutEffect as p}from"@tamagui/constants";import{useEvent as y}from"@tamagui/use-event";import{getBoundingClientRect as v}from"../helpers/getBoundingClientRect";import{getRect as E}from"../helpers/getRect";const l=new WeakMap;let u=null;typeof window<"u"&&"ResizeObserver"in window&&(u=new ResizeObserver(t=>{for(const{target:n}of t){const o=l.get(n);if(typeof o!="function")return;L(n,null,(r,e,m,i,a,s)=>{o({nativeEvent:{layout:{x:r,y:e,width:m,height:i,left:a,top:s},target:n},timeStamp:Date.now()})})}}));const L=(t,n,o)=>{const r=n||(t==null?void 0:t.parentNode);r instanceof HTMLElement&&setTimeout(()=>{const e=v(r),{height:m,left:i,top:a,width:s}=E(t),c=i-e.left,f=a-e.top;o(c,f,s,m,i,a)},0)},b=()=>{};function H(t,n){const o=!!n,r=y(n||b);p(()=>{if(!u||!o)return;const e=t.current;if(e)return l.set(e,r),u.observe(e),()=>{u==null||u.unobserve(e)}},[t,o])}export{L as measureLayout,H as useElementLayout};
|
|
59
2
|
//# 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,OAAS,6BAAAA,MAAiC,qBAC1C,OAAS,YAAAC,MAAgB,qBAGzB,OAAS,yBAAAC,MAA6B,mCACtC,OAAS,WAAAC,MAAe,qBAExB,MAAMC,EAAiB,IAAI,QAmB3B,IAAIC,EAAwC,KAExC,OAAO,OAAW,KAAe,mBAAoB,SACvDA,EAAiB,IAAI,eAAgBC,GAAY,CAC/C,SAAW,CAAE,OAAAC,CAAO,IAAKD,EAAS,CAChC,MAAME,EAAWJ,EAAe,IAAIG,CAAM,EAC1C,GAAI,OAAOC,GAAa,WAAY,OACpCC,EAAcF,EAAuB,KAAM,CAACG,EAAGC,EAAGC,EAAOC,EAAQC,EAAMC,IAAQ,CAC7EP,EAAS,CACP,YAAa,CACX,OAAQ,CAAE,EAAAE,EAAG,EAAAC,EAAG,MAAAC,EAAO,OAAAC,EAAQ,KAAAC,EAAM,IAAAC,CAAI,EACzC,OAAAR,CACF,EACA,UAAW,KAAK,IAAI,CACtB,CAAC,CACH,CAAC,CACH,CACF,CAAC,GAGI,MAAME,EAAgB,CAC3BO,EACAC,EACAC,IACG,CACH,MAAMC,EAAeF,IAAcD,GAAA,YAAAA,EAAM,YACrCG,aAAwB,aAC1B,WAAW,IAAM,CACf,MAAMC,EAAelB,EAAsBiB,CAAY,EACjD,CAAE,OAAAN,EAAQ,KAAAC,EAAM,IAAAC,EAAK,MAAAH,CAAM,EAAIT,EAAQa,CAAI,EAC3CN,EAAII,EAAOM,EAAa,KACxBT,EAAII,EAAMK,EAAa,IAC7BF,EAASR,EAAGC,EAAGC,EAAOC,EAAQC,EAAMC,CAAG,CACzC,EAAG,CAAC,CAER,EAEMM,EAAO,IAAM,CAAC,EAEb,SAASC,EACdC,EACAf,EACA,CACA,MAAMgB,EAAiB,CAAC,CAAChB,EACnBiB,EAAgBxB,EAASO,GAAYa,CAAI,EAI/CrB,EAA0B,IAAM,CAC9B,GAAI,CAACK,GAAkB,CAACmB,EAAgB,OACxC,MAAMR,EAAOO,EAAI,QACjB,GAAKP,EACL,OAAAZ,EAAe,IAAIY,EAAMS,CAAa,EACtCpB,EAAe,QAAQW,CAAI,EACpB,IAAM,CACXX,GAAA,MAAAA,EAAgB,UAAUW,EAC5B,CACF,EAAG,CAACO,EAAKC,CAAc,CAAC,CAC1B",
|
|
6
|
+
"names": ["useIsomorphicLayoutEffect", "useEvent", "getBoundingClientRect", "getRect", "LayoutHandlers", "resizeObserver", "entries", "target", "onLayout", "measureLayout", "x", "y", "width", "height", "left", "top", "node", "relativeTo", "callback", "relativeNode", "relativeRect", "idFn", "useElementLayout", "ref", "hasLayoutEvent", "onLayoutEvent"]
|
|
7
7
|
}
|
|
@@ -1,24 +1,2 @@
|
|
|
1
|
-
import
|
|
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
|
-
};
|
|
1
|
+
import{useIsomorphicLayoutEffect as i}from"@tamagui/web";import{getRect as s}from"../helpers/getRect";import{measureLayout as m}from"./useElementLayout";function d(r){i(()=>{const e=r.current;e&&(e.measure=t=>m(e,null,t),e.measureLayout=(t,o)=>m(e,t,o),e.measureInWindow=t=>{e&&setTimeout(()=>{const{height:o,left:u,top:n,width:f}=s(e);t(u,n,f,o)},0)})},[r])}export{d as usePlatformMethods};
|
|
24
2
|
//# 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,OAAS,6BAAAA,MAAiC,eAG1C,OAAS,WAAAC,MAAe,qBACxB,OAAS,iBAAAC,MAAqB,qBAGvB,SAASC,EAAmBC,EAA6B,CAC9DJ,EAA0B,IAAM,CAC9B,MAAMK,EAAOD,EAAQ,QAChBC,IAELA,EAAK,QAAWC,GAAaJ,EAAcG,EAAM,KAAMC,CAAQ,EAE/DD,EAAK,cAAgB,CAACE,EAAgBC,IACpCN,EAAcG,EAAqBE,EAAgBC,CAAO,EAE5DH,EAAK,gBAAmBC,GAAa,CAC9BD,GACL,WAAW,IAAM,CACf,KAAM,CAAE,OAAAI,EAAQ,KAAAC,EAAM,IAAAC,EAAK,MAAAC,CAAM,EAAIX,EAAQI,CAAmB,EAChEC,EAASI,EAAMC,EAAKC,EAAOH,CAAM,CACnC,EAAG,CAAC,CACN,EACF,EAAG,CAACL,CAAO,CAAC,CACd",
|
|
6
|
+
"names": ["useIsomorphicLayoutEffect", "getRect", "measureLayout", "usePlatformMethods", "hostRef", "node", "callback", "relativeToNode", "success", "height", "left", "top", "width"]
|
|
7
7
|
}
|
|
@@ -1,24 +1,2 @@
|
|
|
1
|
-
import
|
|
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
|
-
};
|
|
1
|
+
import{useIsomorphicLayoutEffect as i}from"@tamagui/web";import{getRect as s}from"../helpers/getRect";import{measureLayout as m}from"./useElementLayout";function d(r){i(()=>{const e=r.current;e&&(e.measure=t=>m(e,null,t),e.measureLayout=(t,o)=>m(e,t,o),e.measureInWindow=t=>{e&&setTimeout(()=>{const{height:o,left:u,top:n,width:f}=s(e);t(u,n,f,o)},0)})},[r])}export{d as usePlatformMethods};
|
|
24
2
|
//# 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,OAAS,6BAAAA,MAAiC,eAG1C,OAAS,WAAAC,MAAe,qBACxB,OAAS,iBAAAC,MAAqB,qBAGvB,SAASC,EAAmBC,EAA6B,CAC9DJ,EAA0B,IAAM,CAC9B,MAAMK,EAAOD,EAAQ,QAChBC,IAELA,EAAK,QAAWC,GAAaJ,EAAcG,EAAM,KAAMC,CAAQ,EAE/DD,EAAK,cAAgB,CAACE,EAAgBC,IACpCN,EAAcG,EAAqBE,EAAgBC,CAAO,EAE5DH,EAAK,gBAAmBC,GAAa,CAC9BD,GACL,WAAW,IAAM,CACf,KAAM,CAAE,OAAAI,EAAQ,KAAAC,EAAM,IAAAC,EAAK,MAAAC,CAAM,EAAIX,EAAQI,CAAmB,EAChEC,EAASI,EAAMC,EAAKC,EAAOH,CAAM,CACnC,EAAG,CAAC,CACN,EACF,EAAG,CAACL,CAAO,CAAC,CACd",
|
|
6
|
+
"names": ["useIsomorphicLayoutEffect", "getRect", "measureLayout", "usePlatformMethods", "hostRef", "node", "callback", "relativeToNode", "success", "height", "left", "top", "width"]
|
|
7
7
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,145 +1,2 @@
|
|
|
1
|
-
import
|
|
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
|
-
};
|
|
1
|
+
import{useResponderEvents as w}from"@tamagui/react-native-use-responder-events";import{Stack as B,Text as I,composeEventHandlers as A,isRSC as M,mergeEvent as S,setupHooks as j}from"@tamagui/web";import{useElementLayout as F}from"./hooks/useElementLayout";import{usePlatformMethods as _}from"./hooks/usePlatformMethods";import{usePressability as G}from"./vendor/Pressability";export*from"@tamagui/web";const Y=B,Z=I;j({getBaseViews(){const e=require("react-native");return{View:e.View||e.default.View,Text:e.Text||e.default.Text}},usePropsTransform(e,n,r){const{onMoveShouldSetResponder:i,onMoveShouldSetResponderCapture:f,onResponderEnd:c,onResponderGrant:a,onResponderMove:l,onResponderReject:p,onResponderRelease:m,onResponderStart:x,onResponderTerminate:b,onResponderTerminationRequest:T,onScrollShouldSetResponder:h,onScrollShouldSetResponderCapture:P,onSelectionChangeShouldSetResponder:k,onSelectionChangeShouldSetResponderCapture:C,onStartShouldSetResponder:g,onStartShouldSetResponderCapture:y,collapsable:q,focusable:d,accessible:N,accessibilityDisabled:V,onLayout:E,hrefAttrs:R,...o}=n;if(M||(_(r),F(r,E),w(r,{onMoveShouldSetResponder:i,onMoveShouldSetResponderCapture:f,onResponderEnd:c,onResponderGrant:a,onResponderMove:l,onResponderReject:p,onResponderRelease:m,onResponderStart:x,onResponderTerminate:b,onResponderTerminationRequest:T,onScrollShouldSetResponder:h,onScrollShouldSetResponderCapture:P,onSelectionChangeShouldSetResponder:k,onSelectionChangeShouldSetResponderCapture:C,onStartShouldSetResponder:g,onStartShouldSetResponderCapture:y})),o.href!==void 0&&R!==void 0){const{download:s,rel:t,target:u}=R;s!=null&&(o.download=s),t!=null&&(o.rel=t),typeof u=="string"&&(o.target=u.charAt(0)!=="_"?`_${u}`:u)}if(!o.tabIndex){const s=d!==void 0?d:N,t=o.role;s===!1&&(o.tabIndex="-1"),e==="a"||e==="button"||e==="input"||e==="select"||e==="textarea"?(s===!1||V===!0)&&(o.tabIndex="-1"):(t==="button"||t==="checkbox"||t==="link"||t==="radio"||t==="textbox"||t==="switch")&&s!==!1&&(o.tabIndex="0"),s===!0&&(o.tabIndex="0")}return o},useEvents(e,n,{pseudos:r},i){if(process.env.TAMAGUI_TARGET==="native"){!!(r!=null&&r.focusStyle)&&(e.onFocus=S(e.onFocus,()=>{i({focus:!0})}),e.onBlur=S(e.onBlur,()=>{i({focus:!1})}));const c=G(n?{...n,hitSlop:e.hitSlop}:{});if(n!=null&&n.onPress)for(const a in c){const l=e[a],p=c[a];e[a]=l&&!O[a]?A(l,p):p}}}});const O={onClick:!0};export{Y as Stack,Z as Text};
|
|
145
2
|
//# 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": "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",
|
|
6
|
+
"names": ["useResponderEvents", "WebStack", "WebText", "composeEventHandlers", "isRSC", "mergeEvent", "setupHooks", "useElementLayout", "usePlatformMethods", "usePressability", "Stack", "Text", "native", "elementType", "propsIn", "hostRef", "onMoveShouldSetResponder", "onMoveShouldSetResponderCapture", "onResponderEnd", "onResponderGrant", "onResponderMove", "onResponderReject", "onResponderRelease", "onResponderStart", "onResponderTerminate", "onResponderTerminationRequest", "onScrollShouldSetResponder", "onScrollShouldSetResponderCapture", "onSelectionChangeShouldSetResponder", "onSelectionChangeShouldSetResponderCapture", "onStartShouldSetResponder", "onStartShouldSetResponderCapture", "collapsable", "focusable", "accessible", "accessibilityDisabled", "onLayout", "hrefAttrs", "viewProps", "download", "rel", "target", "_focusable", "role", "events", "pseudos", "setStateShallow", "pressability", "key", "og", "val", "dontComposePressabilityKeys"]
|
|
7
7
|
}
|