@tamagui/react-native-web-internals 1.129.5 → 1.129.6
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/modules/useElementLayout/index.cjs +16 -59
- package/dist/cjs/modules/useElementLayout/index.js +13 -45
- package/dist/cjs/modules/useElementLayout/index.js.map +2 -2
- package/dist/cjs/modules/useElementLayout/index.native.js +14 -53
- package/dist/cjs/modules/useElementLayout/index.native.js.map +2 -2
- package/dist/esm/modules/useElementLayout/index.js +15 -37
- package/dist/esm/modules/useElementLayout/index.js.map +1 -1
- package/dist/esm/modules/useElementLayout/index.mjs +12 -44
- package/dist/esm/modules/useElementLayout/index.mjs.map +1 -1
- package/dist/esm/modules/useElementLayout/index.native.js +13 -45
- package/dist/esm/modules/useElementLayout/index.native.js.map +1 -1
- package/package.json +8 -7
- package/src/modules/useElementLayout/index.tsx +20 -85
- package/types/modules/useElementLayout/index.d.ts +2 -10
- package/types/modules/useElementLayout/index.d.ts.map +1 -1
- package/types/modules/useLayoutEffect/index.d.ts +1 -1
- package/types/modules/useLayoutEffect/index.d.ts.map +1 -1
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var
|
|
6
|
-
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __export = (target, all) => {
|
|
8
6
|
for (var name in all) __defProp(target, name, {
|
|
9
7
|
get: all[name],
|
|
@@ -17,66 +15,25 @@ var __export = (target, all) => {
|
|
|
17
15
|
});
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
-
value: mod,
|
|
27
|
-
enumerable: !0
|
|
28
|
-
}) : target, mod)),
|
|
29
|
-
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
30
|
-
value: !0
|
|
31
|
-
}), mod);
|
|
18
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
+
value: !0
|
|
20
|
+
}), mod);
|
|
32
21
|
var useElementLayout_exports = {};
|
|
33
22
|
__export(useElementLayout_exports, {
|
|
34
23
|
default: () => useElementLayout
|
|
35
24
|
});
|
|
36
25
|
module.exports = __toCommonJS(useElementLayout_exports);
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
import_useLayoutEffect = __toESM(require("../useLayoutEffect/index.cjs"));
|
|
40
|
-
const DOM_LAYOUT_HANDLER_NAME = "__reactLayoutHandler";
|
|
41
|
-
let didWarn = !import_canUseDOM.default,
|
|
42
|
-
resizeObserver = null;
|
|
43
|
-
function getResizeObserver() {
|
|
44
|
-
return import_canUseDOM.default && typeof window.ResizeObserver < "u" ? resizeObserver == null && (resizeObserver = new window.ResizeObserver(function (entries) {
|
|
45
|
-
entries.forEach(entry => {
|
|
46
|
-
const node = entry.target,
|
|
47
|
-
onLayout = node[DOM_LAYOUT_HANDLER_NAME];
|
|
48
|
-
typeof onLayout == "function" && import_UIManager.default.measure(node, (x, y, width, height, left, top) => {
|
|
49
|
-
const event = {
|
|
50
|
-
// @ts-ignore
|
|
51
|
-
nativeEvent: {
|
|
52
|
-
layout: {
|
|
53
|
-
x,
|
|
54
|
-
y,
|
|
55
|
-
width,
|
|
56
|
-
height,
|
|
57
|
-
left,
|
|
58
|
-
top
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
timeStamp: Date.now()
|
|
62
|
-
};
|
|
63
|
-
Object.defineProperty(event.nativeEvent, "target", {
|
|
64
|
-
enumerable: !0,
|
|
65
|
-
get: () => entry.target
|
|
66
|
-
}), onLayout(event);
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
})) : didWarn || process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && (console.warn("onLayout relies on ResizeObserver which is not supported by your browser. Please include a polyfill, e.g., https://github.com/que-etc/resize-observer-polyfill."), didWarn = !0), resizeObserver;
|
|
70
|
-
}
|
|
26
|
+
var import_use_element_layout = require("@tamagui/use-element-layout"),
|
|
27
|
+
import_react = require("react");
|
|
71
28
|
function useElementLayout(ref, onLayout) {
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}, [
|
|
29
|
+
const wrappedRef = (0, import_react.useMemo)(() => ({
|
|
30
|
+
current: {
|
|
31
|
+
get host() {
|
|
32
|
+
return ref.current;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}), [ref]);
|
|
36
|
+
return (0, import_react.useEffect)(() => {
|
|
37
|
+
(0, import_use_element_layout.enable)();
|
|
38
|
+
}, []), (0, import_use_element_layout.useElementLayout)(wrappedRef, onLayout);
|
|
82
39
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
5
|
var __export = (target, all) => {
|
|
7
6
|
for (var name in all)
|
|
8
7
|
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
@@ -12,54 +11,23 @@ var __export = (target, all) => {
|
|
|
12
11
|
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
12
|
return to;
|
|
14
13
|
};
|
|
15
|
-
var
|
|
16
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
21
|
-
mod
|
|
22
|
-
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
23
15
|
var useElementLayout_exports = {};
|
|
24
16
|
__export(useElementLayout_exports, {
|
|
25
17
|
default: () => useElementLayout
|
|
26
18
|
});
|
|
27
19
|
module.exports = __toCommonJS(useElementLayout_exports);
|
|
28
|
-
var
|
|
29
|
-
const DOM_LAYOUT_HANDLER_NAME = "__reactLayoutHandler";
|
|
30
|
-
let didWarn = !import_canUseDOM.default, resizeObserver = null;
|
|
31
|
-
function getResizeObserver() {
|
|
32
|
-
return import_canUseDOM.default && typeof window.ResizeObserver < "u" ? resizeObserver == null && (resizeObserver = new window.ResizeObserver(function(entries) {
|
|
33
|
-
entries.forEach((entry) => {
|
|
34
|
-
const node = entry.target, onLayout = node[DOM_LAYOUT_HANDLER_NAME];
|
|
35
|
-
typeof onLayout == "function" && import_UIManager.default.measure(node, (x, y, width, height, left, top) => {
|
|
36
|
-
const event = {
|
|
37
|
-
// @ts-ignore
|
|
38
|
-
nativeEvent: {
|
|
39
|
-
layout: { x, y, width, height, left, top }
|
|
40
|
-
},
|
|
41
|
-
timeStamp: Date.now()
|
|
42
|
-
};
|
|
43
|
-
Object.defineProperty(event.nativeEvent, "target", {
|
|
44
|
-
enumerable: !0,
|
|
45
|
-
get: () => entry.target
|
|
46
|
-
}), onLayout(event);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
})) : didWarn || process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && (console.warn(
|
|
50
|
-
"onLayout relies on ResizeObserver which is not supported by your browser. Please include a polyfill, e.g., https://github.com/que-etc/resize-observer-polyfill."
|
|
51
|
-
), didWarn = !0), resizeObserver;
|
|
52
|
-
}
|
|
20
|
+
var import_use_element_layout = require("@tamagui/use-element-layout"), import_react = require("react");
|
|
53
21
|
function useElementLayout(ref, onLayout) {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}, [
|
|
22
|
+
const wrappedRef = (0, import_react.useMemo)(() => ({
|
|
23
|
+
current: {
|
|
24
|
+
get host() {
|
|
25
|
+
return ref.current;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}), [ref]);
|
|
29
|
+
return (0, import_react.useEffect)(() => {
|
|
30
|
+
(0, import_use_element_layout.enable)();
|
|
31
|
+
}, []), (0, import_use_element_layout.useElementLayout)(wrappedRef, onLayout);
|
|
64
32
|
}
|
|
65
33
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/useElementLayout/index.tsx"],
|
|
4
|
-
"mappings": "
|
|
5
|
-
"names": ["
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAGO,wCACP,eAAmD;AAGpC,SAAR,iBACL,KACA,UACA;AAEA,QAAM,iBAAa,sBAAQ,OAClB;AAAA,IACL,SAAS;AAAA,MACP,IAAI,OAAO;AACT,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF,IACC,CAAC,GAAG,CAAC;AAER,qCAAU,MAAM;AACd,0CAAO;AAAA,EACT,GAAG,CAAC,CAAC,OAEE,0BAAAA,kBAAwB,YAAY,QAAQ;AACrD;",
|
|
5
|
+
"names": ["useTamaguiElementLayout"]
|
|
6
6
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
6
|
var __export = (target, all) => {
|
|
8
7
|
for (var name in all)
|
|
9
8
|
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
@@ -13,65 +12,27 @@ var __export = (target, all) => {
|
|
|
13
12
|
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
13
|
return to;
|
|
15
14
|
};
|
|
16
|
-
var
|
|
17
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
22
|
-
mod
|
|
23
|
-
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
24
16
|
var useElementLayout_exports = {};
|
|
25
17
|
__export(useElementLayout_exports, {
|
|
26
18
|
default: () => useElementLayout
|
|
27
19
|
});
|
|
28
20
|
module.exports = __toCommonJS(useElementLayout_exports);
|
|
29
|
-
var
|
|
30
|
-
function getResizeObserver() {
|
|
31
|
-
return import_canUseDOM.default && typeof window.ResizeObserver < "u" ? resizeObserver == null && (resizeObserver = new window.ResizeObserver(function(entries) {
|
|
32
|
-
entries.forEach(function(entry) {
|
|
33
|
-
var node = entry.target, onLayout = node[DOM_LAYOUT_HANDLER_NAME];
|
|
34
|
-
typeof onLayout == "function" && import_UIManager.default.measure(node, function(x, y, width, height, left, top) {
|
|
35
|
-
var event = {
|
|
36
|
-
// @ts-ignore
|
|
37
|
-
nativeEvent: {
|
|
38
|
-
layout: {
|
|
39
|
-
x,
|
|
40
|
-
y,
|
|
41
|
-
width,
|
|
42
|
-
height,
|
|
43
|
-
left,
|
|
44
|
-
top
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
timeStamp: Date.now()
|
|
48
|
-
};
|
|
49
|
-
Object.defineProperty(event.nativeEvent, "target", {
|
|
50
|
-
enumerable: !0,
|
|
51
|
-
get: function() {
|
|
52
|
-
return entry.target;
|
|
53
|
-
}
|
|
54
|
-
}), onLayout(event);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
})) : didWarn || process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && (console.warn("onLayout relies on ResizeObserver which is not supported by your browser. Please include a polyfill, e.g., https://github.com/que-etc/resize-observer-polyfill."), didWarn = !0), resizeObserver;
|
|
58
|
-
}
|
|
21
|
+
var import_use_element_layout = require("@tamagui/use-element-layout"), import_react = require("react");
|
|
59
22
|
function useElementLayout(ref, onLayout) {
|
|
60
|
-
var
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
]), (0, import_useLayoutEffect.default)(function() {
|
|
68
|
-
var node = ref.current;
|
|
69
|
-
return node != null && observer != null && (typeof node[DOM_LAYOUT_HANDLER_NAME] == "function" ? observer.observe(node) : observer.unobserve(node)), function() {
|
|
70
|
-
node != null && observer != null && observer.unobserve(node);
|
|
23
|
+
var wrappedRef = (0, import_react.useMemo)(function() {
|
|
24
|
+
return {
|
|
25
|
+
current: {
|
|
26
|
+
get host() {
|
|
27
|
+
return ref.current;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
71
30
|
};
|
|
72
31
|
}, [
|
|
73
|
-
ref
|
|
74
|
-
observer
|
|
32
|
+
ref
|
|
75
33
|
]);
|
|
34
|
+
return (0, import_react.useEffect)(function() {
|
|
35
|
+
(0, import_use_element_layout.enable)();
|
|
36
|
+
}, []), (0, import_use_element_layout.useElementLayout)(wrappedRef, onLayout);
|
|
76
37
|
}
|
|
77
38
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/useElementLayout/index.tsx"],
|
|
4
|
-
"mappings": "
|
|
5
|
-
"names": ["
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;;;;;gCAGO,wCACP,eAAmD;AAGpC,SAAf,iBACEA,KACAC,UAA4C;AAG5C,MAAMC,iBAAaC,sBAAQ,WAAA;AACzB,WAAO;MACLC,SAAS;QACP,IAAIC,OAAO;AACT,iBAAOL,IAAII;QACb;MACF;IACF;EACF,GAAG;IAACJ;GAAI;AAERM,qCAAU,WAAA;AACRC,0CAAAA;EACF,GAAG,CAAA,CAAE,OAEEC,0BAAAA,kBAAwBN,YAAYD,QAAAA;AAC7C;",
|
|
5
|
+
"names": ["ref", "onLayout", "wrappedRef", "useMemo", "current", "host", "useEffect", "enable", "useTamaguiElementLayout"]
|
|
6
6
|
}
|
|
@@ -1,41 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function getResizeObserver() {
|
|
7
|
-
return canUseDOM && typeof window.ResizeObserver < "u" ? resizeObserver == null && (resizeObserver = new window.ResizeObserver(function(entries) {
|
|
8
|
-
entries.forEach((entry) => {
|
|
9
|
-
const node = entry.target, onLayout = node[DOM_LAYOUT_HANDLER_NAME];
|
|
10
|
-
typeof onLayout == "function" && UIManager.measure(node, (x, y, width, height, left, top) => {
|
|
11
|
-
const event = {
|
|
12
|
-
// @ts-ignore
|
|
13
|
-
nativeEvent: {
|
|
14
|
-
layout: { x, y, width, height, left, top }
|
|
15
|
-
},
|
|
16
|
-
timeStamp: Date.now()
|
|
17
|
-
};
|
|
18
|
-
Object.defineProperty(event.nativeEvent, "target", {
|
|
19
|
-
enumerable: !0,
|
|
20
|
-
get: () => entry.target
|
|
21
|
-
}), onLayout(event);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
})) : didWarn || process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && (console.warn(
|
|
25
|
-
"onLayout relies on ResizeObserver which is not supported by your browser. Please include a polyfill, e.g., https://github.com/que-etc/resize-observer-polyfill."
|
|
26
|
-
), didWarn = !0), resizeObserver;
|
|
27
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
enable,
|
|
3
|
+
useElementLayout as useTamaguiElementLayout
|
|
4
|
+
} from "@tamagui/use-element-layout";
|
|
5
|
+
import { useEffect, useMemo } from "react";
|
|
28
6
|
function useElementLayout(ref, onLayout) {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}, [
|
|
7
|
+
const wrappedRef = useMemo(() => ({
|
|
8
|
+
current: {
|
|
9
|
+
get host() {
|
|
10
|
+
return ref.current;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}), [ref]);
|
|
14
|
+
return useEffect(() => {
|
|
15
|
+
enable();
|
|
16
|
+
}, []), useTamaguiElementLayout(wrappedRef, onLayout);
|
|
39
17
|
}
|
|
40
18
|
export {
|
|
41
19
|
useElementLayout as default
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/useElementLayout/index.tsx"],
|
|
4
|
-
"mappings": "
|
|
4
|
+
"mappings": "AAAA;AAAA,EACE;AAAA,EACA,oBAAoB;AAAA,OACf;AACP,SAAyB,WAAW,eAAe;AAGpC,SAAR,iBACL,KACA,UACA;AAEA,QAAM,aAAa,QAAQ,OAClB;AAAA,IACL,SAAS;AAAA,MACP,IAAI,OAAO;AACT,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF,IACC,CAAC,GAAG,CAAC;AAER,mBAAU,MAAM;AACd,WAAO;AAAA,EACT,GAAG,CAAC,CAAC,GAEE,wBAAwB,YAAY,QAAQ;AACrD;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -1,48 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import useLayoutEffect from "../useLayoutEffect/index.mjs";
|
|
4
|
-
const DOM_LAYOUT_HANDLER_NAME = "__reactLayoutHandler";
|
|
5
|
-
let didWarn = !canUseDOM,
|
|
6
|
-
resizeObserver = null;
|
|
7
|
-
function getResizeObserver() {
|
|
8
|
-
return canUseDOM && typeof window.ResizeObserver < "u" ? resizeObserver == null && (resizeObserver = new window.ResizeObserver(function (entries) {
|
|
9
|
-
entries.forEach(entry => {
|
|
10
|
-
const node = entry.target,
|
|
11
|
-
onLayout = node[DOM_LAYOUT_HANDLER_NAME];
|
|
12
|
-
typeof onLayout == "function" && UIManager.measure(node, (x, y, width, height, left, top) => {
|
|
13
|
-
const event = {
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
nativeEvent: {
|
|
16
|
-
layout: {
|
|
17
|
-
x,
|
|
18
|
-
y,
|
|
19
|
-
width,
|
|
20
|
-
height,
|
|
21
|
-
left,
|
|
22
|
-
top
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
timeStamp: Date.now()
|
|
26
|
-
};
|
|
27
|
-
Object.defineProperty(event.nativeEvent, "target", {
|
|
28
|
-
enumerable: !0,
|
|
29
|
-
get: () => entry.target
|
|
30
|
-
}), onLayout(event);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
})) : didWarn || process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && (console.warn("onLayout relies on ResizeObserver which is not supported by your browser. Please include a polyfill, e.g., https://github.com/que-etc/resize-observer-polyfill."), didWarn = !0), resizeObserver;
|
|
34
|
-
}
|
|
1
|
+
import { enable, useElementLayout as useTamaguiElementLayout } from "@tamagui/use-element-layout";
|
|
2
|
+
import { useEffect, useMemo } from "react";
|
|
35
3
|
function useElementLayout(ref, onLayout) {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}, [
|
|
4
|
+
const wrappedRef = useMemo(() => ({
|
|
5
|
+
current: {
|
|
6
|
+
get host() {
|
|
7
|
+
return ref.current;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}), [ref]);
|
|
11
|
+
return useEffect(() => {
|
|
12
|
+
enable();
|
|
13
|
+
}, []), useTamaguiElementLayout(wrappedRef, onLayout);
|
|
46
14
|
}
|
|
47
15
|
export { useElementLayout as default };
|
|
48
16
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["enable","useElementLayout","useTamaguiElementLayout","useEffect","useMemo","ref","onLayout","wrappedRef","current","host"],"sources":["../../../../src/modules/useElementLayout/index.tsx"],"sourcesContent":[null],"mappings":"AAAA,SACEA,MAAA,EACAC,gBAAA,IAAoBC,uBAAA,QACf;AACP,SAAyBC,SAAA,EAAWC,OAAA,QAAe;AAGpC,SAARH,iBACLI,GAAA,EACAC,QAAA,EACA;EAEA,MAAMC,UAAA,GAAaH,OAAA,CAAQ,OAClB;IACLI,OAAA,EAAS;MACP,IAAIC,KAAA,EAAO;QACT,OAAOJ,GAAA,CAAIG,OAAA;MACb;IACF;EACF,IACC,CAACH,GAAG,CAAC;EAER,OAAAF,SAAA,CAAU,MAAM;IACdH,MAAA,CAAO;EACT,GAAG,EAAE,GAEEE,uBAAA,CAAwBK,UAAA,EAAYD,QAAQ;AACrD","ignoreList":[]}
|
|
@@ -1,50 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import useLayoutEffect from "../useLayoutEffect/index.native.js";
|
|
4
|
-
var DOM_LAYOUT_HANDLER_NAME = "__reactLayoutHandler",
|
|
5
|
-
didWarn = !canUseDOM,
|
|
6
|
-
resizeObserver = null;
|
|
7
|
-
function getResizeObserver() {
|
|
8
|
-
return canUseDOM && typeof window.ResizeObserver < "u" ? resizeObserver == null && (resizeObserver = new window.ResizeObserver(function (entries) {
|
|
9
|
-
entries.forEach(function (entry) {
|
|
10
|
-
var node = entry.target,
|
|
11
|
-
onLayout = node[DOM_LAYOUT_HANDLER_NAME];
|
|
12
|
-
typeof onLayout == "function" && UIManager.measure(node, function (x, y, width, height, left, top) {
|
|
13
|
-
var event = {
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
nativeEvent: {
|
|
16
|
-
layout: {
|
|
17
|
-
x,
|
|
18
|
-
y,
|
|
19
|
-
width,
|
|
20
|
-
height,
|
|
21
|
-
left,
|
|
22
|
-
top
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
timeStamp: Date.now()
|
|
26
|
-
};
|
|
27
|
-
Object.defineProperty(event.nativeEvent, "target", {
|
|
28
|
-
enumerable: !0,
|
|
29
|
-
get: function () {
|
|
30
|
-
return entry.target;
|
|
31
|
-
}
|
|
32
|
-
}), onLayout(event);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
})) : didWarn || process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && (console.warn("onLayout relies on ResizeObserver which is not supported by your browser. Please include a polyfill, e.g., https://github.com/que-etc/resize-observer-polyfill."), didWarn = !0), resizeObserver;
|
|
36
|
-
}
|
|
1
|
+
import { enable, useElementLayout as useTamaguiElementLayout } from "@tamagui/use-element-layout";
|
|
2
|
+
import { useEffect, useMemo } from "react";
|
|
37
3
|
function useElementLayout(ref, onLayout) {
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
node != null && observer != null && observer.unobserve(node);
|
|
4
|
+
var wrappedRef = useMemo(function () {
|
|
5
|
+
return {
|
|
6
|
+
current: {
|
|
7
|
+
get host() {
|
|
8
|
+
return ref.current;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
46
11
|
};
|
|
47
|
-
}, [ref
|
|
12
|
+
}, [ref]);
|
|
13
|
+
return useEffect(function () {
|
|
14
|
+
enable();
|
|
15
|
+
}, []), useTamaguiElementLayout(wrappedRef, onLayout);
|
|
48
16
|
}
|
|
49
17
|
export { useElementLayout as default };
|
|
50
18
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["enable","useElementLayout","useTamaguiElementLayout","useEffect","useMemo","ref","onLayout","wrappedRef","current","host"],"sources":["../../../../src/modules/useElementLayout/index.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAAAA,MAAA,EAAAC,gBAAA,IAAAC,uBAAA;AAAA,SACEC,SAAA,EAAAC,OAAA;AAAA,SACAH,gBAAoBA,CAAAI,GAAA,EAAAC,QAAA;EAAA,IAAAC,UACf,GAAAH,OAAA;IACP,OAAyB;MAGVI,OAAR;QAKC,IAAAC,KAAA;UAEF,OAASJ,GAAA,CAAAG,OAAA;QACP;MACE;IAAW;EACb,GACF,CACFH,GACE,CAEJ;EACE,OAAAF,SAAO;IACTH,MAEO;EACT,QAAAE,uBAAA,CAAAK,UAAA,EAAAD,QAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/react-native-web-internals",
|
|
3
|
-
"version": "1.129.
|
|
3
|
+
"version": "1.129.6",
|
|
4
4
|
"description": "React Native for Web",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs",
|
|
@@ -31,15 +31,16 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@tamagui/normalize-css-color": "1.129.
|
|
35
|
-
"@tamagui/react-native-use-pressable": "1.129.
|
|
36
|
-
"@tamagui/react-native-use-responder-events": "1.129.
|
|
37
|
-
"@tamagui/simple-hash": "1.129.
|
|
38
|
-
"@tamagui/
|
|
34
|
+
"@tamagui/normalize-css-color": "1.129.6",
|
|
35
|
+
"@tamagui/react-native-use-pressable": "1.129.6",
|
|
36
|
+
"@tamagui/react-native-use-responder-events": "1.129.6",
|
|
37
|
+
"@tamagui/simple-hash": "1.129.6",
|
|
38
|
+
"@tamagui/use-element-layout": "1.129.6",
|
|
39
|
+
"@tamagui/web": "1.129.6",
|
|
39
40
|
"react": "*"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
|
-
"@tamagui/build": "1.129.
|
|
43
|
+
"@tamagui/build": "1.129.6"
|
|
43
44
|
},
|
|
44
45
|
"license": "MIT",
|
|
45
46
|
"tags": [
|
|
@@ -1,93 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*
|
|
8
|
-
* @flow
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type { ElementRef } from 'react'
|
|
12
|
-
|
|
1
|
+
import {
|
|
2
|
+
enable,
|
|
3
|
+
useElementLayout as useTamaguiElementLayout,
|
|
4
|
+
} from '@tamagui/use-element-layout'
|
|
5
|
+
import { type RefObject, useEffect, useMemo } from 'react'
|
|
13
6
|
import type { LayoutEvent } from '../../types'
|
|
14
|
-
import canUseDOM from '../canUseDOM'
|
|
15
|
-
import UIManager from '../UIManager/index'
|
|
16
|
-
import useLayoutEffect from '../useLayoutEffect/index'
|
|
17
|
-
|
|
18
|
-
const DOM_LAYOUT_HANDLER_NAME = '__reactLayoutHandler'
|
|
19
|
-
|
|
20
|
-
let didWarn = !canUseDOM
|
|
21
|
-
let resizeObserver = null
|
|
22
|
-
|
|
23
|
-
function getResizeObserver(): ResizeObserver | null {
|
|
24
|
-
if (canUseDOM && typeof window.ResizeObserver !== 'undefined') {
|
|
25
|
-
if (resizeObserver == null) {
|
|
26
|
-
resizeObserver = new window.ResizeObserver(function (entries) {
|
|
27
|
-
entries.forEach((entry) => {
|
|
28
|
-
const node = entry.target
|
|
29
|
-
const onLayout = node[DOM_LAYOUT_HANDLER_NAME]
|
|
30
|
-
if (typeof onLayout === 'function') {
|
|
31
|
-
// We still need to measure the view because browsers don't yet provide
|
|
32
|
-
// border-box dimensions in the entry
|
|
33
|
-
UIManager.measure(node, (x, y, width, height, left, top) => {
|
|
34
|
-
const event: LayoutEvent = {
|
|
35
|
-
// @ts-ignore
|
|
36
|
-
nativeEvent: {
|
|
37
|
-
layout: { x, y, width, height, left, top },
|
|
38
|
-
},
|
|
39
|
-
timeStamp: Date.now(),
|
|
40
|
-
}
|
|
41
|
-
Object.defineProperty(event.nativeEvent, 'target', {
|
|
42
|
-
enumerable: true,
|
|
43
|
-
get: () => entry.target,
|
|
44
|
-
})
|
|
45
|
-
onLayout(event)
|
|
46
|
-
})
|
|
47
|
-
}
|
|
48
|
-
})
|
|
49
|
-
})
|
|
50
|
-
}
|
|
51
|
-
} else if (!didWarn) {
|
|
52
|
-
if (process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'test') {
|
|
53
|
-
console.warn(
|
|
54
|
-
'onLayout relies on ResizeObserver which is not supported by your browser. ' +
|
|
55
|
-
'Please include a polyfill, e.g., https://github.com/que-etc/resize-observer-polyfill.'
|
|
56
|
-
)
|
|
57
|
-
didWarn = true
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return resizeObserver
|
|
61
|
-
}
|
|
62
7
|
|
|
63
8
|
export default function useElementLayout(
|
|
64
|
-
ref:
|
|
9
|
+
ref: RefObject<any>,
|
|
65
10
|
onLayout?: ((e: LayoutEvent) => void) | null
|
|
66
11
|
) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
12
|
+
// translates to tamagui style
|
|
13
|
+
const wrappedRef = useMemo(() => {
|
|
14
|
+
return {
|
|
15
|
+
current: {
|
|
16
|
+
get host() {
|
|
17
|
+
return ref.current
|
|
18
|
+
},
|
|
19
|
+
},
|
|
73
20
|
}
|
|
74
|
-
}, [ref
|
|
21
|
+
}, [ref])
|
|
75
22
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (typeof node[DOM_LAYOUT_HANDLER_NAME] === 'function') {
|
|
82
|
-
observer.observe(node)
|
|
83
|
-
} else {
|
|
84
|
-
observer.unobserve(node)
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return () => {
|
|
88
|
-
if (node != null && observer != null) {
|
|
89
|
-
observer.unobserve(node)
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}, [ref, observer])
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
enable()
|
|
25
|
+
}, [])
|
|
26
|
+
|
|
27
|
+
return useTamaguiElementLayout(wrappedRef, onLayout)
|
|
93
28
|
}
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Copyright (c) Nicolas Gallagher.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @flow
|
|
8
|
-
*/
|
|
9
|
-
import type { ElementRef } from 'react';
|
|
1
|
+
import { type RefObject } from 'react';
|
|
10
2
|
import type { LayoutEvent } from '../../types';
|
|
11
|
-
export default function useElementLayout(ref:
|
|
3
|
+
export default function useElementLayout(ref: RefObject<any>, onLayout?: ((e: LayoutEvent) => void) | null): void;
|
|
12
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/useElementLayout/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/useElementLayout/index.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAsB,MAAM,OAAO,CAAA;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,EACnB,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,KAAK,IAAI,CAAC,GAAG,IAAI,QAkB7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/useLayoutEffect/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC,CAAC;;;;;;;;;;GAUxB;AAMH,QAAA,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/useLayoutEffect/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC,CAAC;;;;;;;;;;GAUxB;AAMH,QAAA,MAAM,mBAAmB,wBAAsD,CAAC;AAEhF,eAAe,mBAAmB,CAAC"}
|