@tamagui/react-native-web-internals 1.130.7 → 1.131.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/StyleSheet/__tests__/compiler-createReactDOMStyle-test.cjs +1 -1
- package/dist/cjs/StyleSheet/__tests__/compiler-test.cjs +1 -1
- package/dist/cjs/StyleSheet/__tests__/dom-createOrderedCSSStyleSheet-test.cjs +1 -1
- package/dist/cjs/StyleSheet/__tests__/index-test.cjs +1 -1
- package/dist/cjs/StyleSheet/__tests__/preprocess-test.cjs +1 -1
- package/dist/cjs/StyleSheet/__tests__/validate-test.cjs +1 -1
- package/dist/cjs/StyleSheet/compiler/createReactDOMStyle.cjs +2 -2
- package/dist/cjs/StyleSheet/compiler/index.cjs +3 -3
- package/dist/cjs/StyleSheet/compiler/normalizeColor.cjs +2 -2
- package/dist/cjs/StyleSheet/compiler/normalizeValueWithProperty.cjs +2 -2
- package/dist/cjs/StyleSheet/compiler/resolveShadowValue.cjs +2 -2
- package/dist/cjs/StyleSheet/dom/createCSSStyleSheet.cjs +1 -1
- package/dist/cjs/StyleSheet/dom/index.cjs +3 -3
- package/dist/cjs/StyleSheet/preprocess.cjs +2 -2
- package/dist/cjs/index.cjs +41 -41
- package/dist/cjs/modules/AccessibilityUtil/__tests__/propsToAccessibilityComponent-test.cjs +1 -1
- package/dist/cjs/modules/AccessibilityUtil/__tests__/propsToAriaRole-test.cjs +1 -1
- package/dist/cjs/modules/AccessibilityUtil/index.cjs +3 -3
- package/dist/cjs/modules/AccessibilityUtil/propsToAccessibilityComponent.cjs +1 -1
- package/dist/cjs/modules/InteractionManager.cjs +2 -2
- package/dist/cjs/modules/Platform/__tests__/index-test.cjs +1 -1
- package/dist/cjs/modules/TextInputState/index.cjs +1 -1
- package/dist/cjs/modules/UIManager/__tests__/index-test.cjs +1 -1
- package/dist/cjs/modules/UIManager/index.cjs +11 -88
- package/dist/cjs/modules/UIManager/index.js +9 -52
- package/dist/cjs/modules/UIManager/index.js.map +2 -2
- package/dist/cjs/modules/UIManager/index.native.js +8 -57
- package/dist/cjs/modules/UIManager/index.native.js.map +2 -2
- package/dist/cjs/modules/createDOMProps/__tests__/index-test.cjs +1 -1
- package/dist/cjs/modules/createDOMProps/index.cjs +1 -1
- package/dist/cjs/modules/createEventHandle/__tests__/index-test.cjs +1 -1
- package/dist/cjs/modules/createEventHandle/index.cjs +1 -1
- package/dist/cjs/modules/dismissKeyboard/index.cjs +1 -1
- package/dist/cjs/modules/mergeRefs/__tests__/index-test.cjs +1 -1
- package/dist/cjs/modules/modality/__tests__/index-test.cjs +1 -1
- package/dist/cjs/modules/modality/index.cjs +2 -2
- package/dist/cjs/modules/multiplyStyleLengthValue/__tests__/index-test.cjs +1 -1
- package/dist/cjs/modules/normalizeColor/index.cjs +2 -2
- package/dist/cjs/modules/processColor/__tests__/index-test.cjs +1 -1
- package/dist/cjs/modules/requestIdleCallback/index.cjs +1 -1
- package/dist/cjs/modules/setValueForStyles/dangerousStyleValue.cjs +1 -1
- package/dist/cjs/modules/setValueForStyles/index.cjs +1 -1
- package/dist/cjs/modules/useEvent/__tests__/index-test.cjs +1 -1
- package/dist/cjs/modules/useEvent/index.cjs +3 -3
- package/dist/cjs/modules/useHover/__tests__/index-test.cjs +2 -2
- package/dist/cjs/modules/useHover/index.cjs +3 -3
- package/dist/cjs/modules/useLayoutEffect/index.cjs +1 -1
- package/dist/cjs/modules/useLocale/index.cjs +1 -1
- package/dist/cjs/modules/useMergeRefs/__tests__/index-test.cjs +1 -1
- package/dist/cjs/modules/useMergeRefs/index.cjs +1 -1
- package/dist/cjs/modules/usePlatformMethods/index.cjs +3 -3
- package/dist/cjs/modules/usePlatformMethods/index.js +2 -2
- package/dist/cjs/modules/usePlatformMethods/index.js.map +2 -2
- package/dist/cjs/modules/usePlatformMethods/index.native.js +2 -8
- package/dist/cjs/modules/usePlatformMethods/index.native.js.map +2 -2
- package/dist/cjs/modules/useStable/__tests__/index-test.cjs +1 -1
- package/dist/esm/modules/UIManager/index.js +7 -43
- package/dist/esm/modules/UIManager/index.js.map +1 -1
- package/dist/esm/modules/UIManager/index.mjs +7 -73
- package/dist/esm/modules/UIManager/index.mjs.map +1 -1
- package/dist/esm/modules/UIManager/index.native.js +7 -72
- package/dist/esm/modules/UIManager/index.native.js.map +1 -1
- package/dist/esm/modules/usePlatformMethods/index.js +6 -2
- package/dist/esm/modules/usePlatformMethods/index.js.map +1 -1
- package/dist/esm/modules/usePlatformMethods/index.mjs +2 -2
- package/dist/esm/modules/usePlatformMethods/index.mjs.map +1 -1
- package/dist/esm/modules/usePlatformMethods/index.native.js +2 -8
- package/dist/esm/modules/usePlatformMethods/index.native.js.map +1 -1
- package/package.json +8 -8
- package/src/modules/UIManager/index.tsx +11 -60
- package/src/modules/usePlatformMethods/index.tsx +8 -6
- package/types/modules/UIManager/index.d.ts +8 -4
- package/types/modules/UIManager/index.d.ts.map +1 -1
- package/types/modules/usePlatformMethods/index.d.ts.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["measure","measureInWindow","focusableElements","A","INPUT","SELECT","TEXTAREA","UIManager","blur","node","focus","name","nodeName","getAttribute","setAttribute","callback","measureLayout","relativeToNativeNode","onFail","onSuccess","configureNextLayoutAnimation","config","onAnimationDidEnd","setLayoutAnimationEnabledExperimental","UIManager_default"],"sources":["../../../../src/modules/UIManager/index.tsx"],"sourcesContent":[null],"mappings":"AAUA,SAASA,OAAA,EAASC,eAAA,QAAuB;AAEzC,MAAMC,iBAAA,GAAoB;IACxBC,CAAA,EAAG;IACHC,KAAA,EAAO;IACPC,MAAA,EAAQ;IACRC,QAAA,EAAU;EACZ;EAEMC,SAAA,GAAY;IAChBC,KAAKC,IAAA,EAAM;MACT,IAAI;QACFA,IAAA,CAAKD,IAAA,CAAK;MACZ,QAAc,CAEd;IACF;IAEAE,MAAMD,IAAA,EAAM;MACV,IAAI;QACF,MAAME,IAAA,GAAOF,IAAA,CAAKG,QAAA;QAIdH,IAAA,CAAKI,YAAA,CAAa,UAAU,KAAK,QAAQX,iBAAA,CAAkBS,IAAI,KAAK,QACtEF,IAAA,CAAKK,YAAA,CAAa,YAAY,IAAI,GAEpCL,IAAA,CAAKC,KAAA,CAAM;MACb,QAAc,CAEd;IACF;IAEAV,QAAQS,IAAA,EAAMM,QAAA,EAAU;MACtB,OAAOf,OAAA,CAAQS,IAAA,EAAMM,QAAQ;IAC/B;IAEAd,gBAAgBQ,IAAA,EAAMM,QAAA,EAAU;MAC9B,OAAOd,eAAA,CAAgBQ,IAAA,EAAMM,QAAQ;IACvC;IAAA;IAGA,MAAMC,cACJP,IAAA,EACAQ,oBAAA,EACAC,MAAA,EACAC,SAAA,EACA;MACA,OAAOH,aAAA,CAAcP,IAAA,EAAMQ,oBAAA,EAAsBE,SAAS;IAC5D;IAEAC,6BAA6BC,MAAA,EAAQC,iBAAA,EAAmB;MACtDA,iBAAA,CAAkB;IACpB;IAAA;IAGAC,sCAAA,EAAwC,CAAC;EAC3C;AAEA,IAAOC,iBAAA,GAAQjB,SAAA","ignoreList":[]}
|
|
@@ -1,39 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
var getRect = function (node) {
|
|
4
|
-
var {
|
|
5
|
-
x,
|
|
6
|
-
y,
|
|
7
|
-
top,
|
|
8
|
-
left
|
|
9
|
-
} = getBoundingClientRect(node),
|
|
10
|
-
width = node.offsetWidth,
|
|
11
|
-
height = node.offsetHeight;
|
|
12
|
-
return {
|
|
13
|
-
x,
|
|
14
|
-
y,
|
|
15
|
-
width,
|
|
16
|
-
height,
|
|
17
|
-
top,
|
|
18
|
-
left
|
|
19
|
-
};
|
|
20
|
-
},
|
|
21
|
-
measureLayout = function (node, relativeToNativeNode, callback) {
|
|
22
|
-
var relativeNode = relativeToNativeNode || node && node.parentNode;
|
|
23
|
-
if (node && relativeNode) {
|
|
24
|
-
var relativeRect = getBoundingClientRect(relativeNode),
|
|
25
|
-
{
|
|
26
|
-
height,
|
|
27
|
-
left,
|
|
28
|
-
top,
|
|
29
|
-
width
|
|
30
|
-
} = getRect(node),
|
|
31
|
-
x = left - relativeRect.left,
|
|
32
|
-
y = top - relativeRect.top;
|
|
33
|
-
callback(x, y, width, height, left, top);
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
focusableElements = {
|
|
1
|
+
import { measure, measureInWindow } from "@tamagui/use-element-layout";
|
|
2
|
+
var focusableElements = {
|
|
37
3
|
A: !0,
|
|
38
4
|
INPUT: !0,
|
|
39
5
|
SELECT: !0,
|
|
@@ -54,45 +20,14 @@ var getRect = function (node) {
|
|
|
54
20
|
},
|
|
55
21
|
//
|
|
56
22
|
measure(node, callback) {
|
|
57
|
-
|
|
23
|
+
return measure(node, callback);
|
|
58
24
|
},
|
|
59
25
|
measureInWindow(node, callback) {
|
|
60
|
-
|
|
61
|
-
var {
|
|
62
|
-
height,
|
|
63
|
-
left,
|
|
64
|
-
top,
|
|
65
|
-
width
|
|
66
|
-
} = getRect(node);
|
|
67
|
-
callback(left, top, width, height);
|
|
68
|
-
}, 0);
|
|
69
|
-
},
|
|
70
|
-
measureLayout(node, relativeToNativeNode, onFail, onSuccess) {
|
|
71
|
-
measureLayout(node, relativeToNativeNode, onSuccess);
|
|
26
|
+
return measureInWindow(node, callback);
|
|
72
27
|
},
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
switch (prop) {
|
|
77
|
-
case "style":
|
|
78
|
-
{
|
|
79
|
-
setValueForStyles(node, value);
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
case "class":
|
|
83
|
-
case "className":
|
|
84
|
-
{
|
|
85
|
-
node.setAttribute("class", value);
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
case "text":
|
|
89
|
-
case "value":
|
|
90
|
-
node.value = value;
|
|
91
|
-
break;
|
|
92
|
-
default:
|
|
93
|
-
node.setAttribute(prop, value);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
28
|
+
// note its flipped fail and success on purpose lol
|
|
29
|
+
async measureLayout(node, relativeToNativeNode, onFail, onSuccess) {
|
|
30
|
+
return measureLayout(node, relativeToNativeNode, onSuccess);
|
|
96
31
|
},
|
|
97
32
|
configureNextLayoutAnimation(config, onAnimationDidEnd) {
|
|
98
33
|
onAnimationDidEnd();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["measure","measureInWindow","focusableElements","A","INPUT","SELECT","TEXTAREA","UIManager","blur","node","focus","name","nodeName","getAttribute","setAttribute","callback","measureLayout","relativeToNativeNode","onFail","onSuccess","configureNextLayoutAnimation","config","onAnimationDidEnd","setLayoutAnimationEnabledExperimental"],"sources":["../../../../src/modules/UIManager/index.tsx"],"sourcesContent":[null],"mappings":"AAUA,SAASA,OAAA,EAASC,eAAA,QAAuB;AAEzC,IAAAC,iBAAM;IACJC,CAAA,EAAG;IACHC,KAAA,EAAO;IACPC,MAAA,EAAQ;IACRC,QAAA,EAAU;EACZ;EAEMC,SAAA,GAAY;IAChBC,KAAKC,IAAA,EAAM;MACT,IAAI;QACFA,IAAA,CAAKD,IAAA,CAAK;MACZ,QAAc,CAEd;IACF;IAEA;IACEE,MAAID,IAAA;MACF;QAII,IAAAE,IAAK,GAAAF,IAAA,CAAAG,QAAa;QAIxBH,IAAA,CAAAI,YAAc,wBAAAX,iBAAA,CAAAS,IAAA,aAAAF,IAAA,CAAAK,YAAA,oBAAAL,IAAA,CAAAC,KAAA;MAEd,SACF;IAEA;IACE;IACFV,QAAAS,IAAA,EAAAM,QAAA;MAEA,OAAAf,OAAgB,CAAAS,IAAA,EAAMM,QAAA,CAAU;IAC9B;IACFd,gBAAAQ,IAAA,EAAAM,QAAA;MAAA,OAAAd,eAAA,CAAAQ,IAAA,EAAAM,QAAA;IAGA;IAME;IACF,MAAAC,cAAAP,IAAA,EAAAQ,oBAAA,EAAAC,MAAA,EAAAC,SAAA;MAEA,OAAAH,aAAA,CAAAP,IAAA,EAA6BQ,oBAAQ,EAAAE,SAAmB;IACtD;IACFC,6BAAAC,MAAA,EAAAC,iBAAA;MAAAA,iBAAA;IAGA;IAAyC;IAC3CC,sCAAA,GAEA","ignoreList":[]}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
createMeasure,
|
|
3
|
+
createMeasureInWindow,
|
|
4
|
+
createMeasureLayout
|
|
5
|
+
} from "@tamagui/use-element-layout";
|
|
2
6
|
import useStable from "../useStable/index";
|
|
3
7
|
function usePlatformMethods({
|
|
4
8
|
pointerEvents,
|
|
5
9
|
style
|
|
6
10
|
}) {
|
|
7
11
|
return useStable(() => (hostNode) => {
|
|
8
|
-
hostNode != null && (hostNode.measure = (
|
|
12
|
+
hostNode != null && (hostNode.measure = createMeasure(hostNode), hostNode.measureLayout = createMeasureLayout(hostNode), hostNode.measureInWindow = createMeasureInWindow(hostNode));
|
|
9
13
|
});
|
|
10
14
|
}
|
|
11
15
|
var usePlatformMethods_default = usePlatformMethods;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/usePlatformMethods/index.tsx"],
|
|
4
|
-
"mappings": "
|
|
4
|
+
"mappings": "AASA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,OAAO,eAAe;AAMf,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA;AACF,GAG4B;AAW1B,SARY,UAAU,MAAM,CAAC,aAAkB;AAC7C,IAAI,YAAY,SACd,SAAS,UAAU,cAAc,QAAQ,GACzC,SAAS,gBAAgB,oBAAoB,QAAQ,GACrD,SAAS,kBAAkB,sBAAsB,QAAQ;AAAA,EAE7D,CAAC;AAGH;AAEA,IAAO,6BAAQ;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createMeasure, createMeasureInWindow, createMeasureLayout } from "@tamagui/use-element-layout";
|
|
2
2
|
import useStable from "../useStable/index.mjs";
|
|
3
3
|
function usePlatformMethods({
|
|
4
4
|
pointerEvents,
|
|
5
5
|
style
|
|
6
6
|
}) {
|
|
7
7
|
return useStable(() => hostNode => {
|
|
8
|
-
hostNode != null && (hostNode.measure =
|
|
8
|
+
hostNode != null && (hostNode.measure = createMeasure(hostNode), hostNode.measureLayout = createMeasureLayout(hostNode), hostNode.measureInWindow = createMeasureInWindow(hostNode));
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
var usePlatformMethods_default = usePlatformMethods;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["createMeasure","createMeasureInWindow","createMeasureLayout","useStable","usePlatformMethods","pointerEvents","style","hostNode","measure","measureLayout","measureInWindow","usePlatformMethods_default"],"sources":["../../../../src/modules/usePlatformMethods/index.tsx"],"sourcesContent":[null],"mappings":"AASA,SACEA,aAAA,EACAC,qBAAA,EACAC,mBAAA,QACK;AAEP,OAAOC,SAAA,MAAe;AAMf,SAASC,mBAAmB;EACjCC,aAAA;EACAC;AACF,GAG4B;EAW1B,OARYH,SAAA,CAAU,MAAOI,QAAA,IAAkB;IACzCA,QAAA,IAAY,SACdA,QAAA,CAASC,OAAA,GAAUR,aAAA,CAAcO,QAAQ,GACzCA,QAAA,CAASE,aAAA,GAAgBP,mBAAA,CAAoBK,QAAQ,GACrDA,QAAA,CAASG,eAAA,GAAkBT,qBAAA,CAAsBM,QAAQ;EAE7D,CAAC;AAGH;AAEA,IAAOI,0BAAA,GAAQP,kBAAA","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createMeasure, createMeasureInWindow, createMeasureLayout } from "@tamagui/use-element-layout";
|
|
2
2
|
import useStable from "../useStable/index.native.js";
|
|
3
3
|
function usePlatformMethods(param) {
|
|
4
4
|
var {
|
|
@@ -7,13 +7,7 @@ function usePlatformMethods(param) {
|
|
|
7
7
|
} = param,
|
|
8
8
|
ref = useStable(function () {
|
|
9
9
|
return function (hostNode) {
|
|
10
|
-
hostNode != null && (hostNode.measure =
|
|
11
|
-
return UIManager.measure(hostNode, callback);
|
|
12
|
-
}, hostNode.measureLayout = function (relativeToNode, success, failure) {
|
|
13
|
-
return UIManager.measureLayout(hostNode, relativeToNode, failure, success);
|
|
14
|
-
}, hostNode.measureInWindow = function (callback) {
|
|
15
|
-
return UIManager.measureInWindow(hostNode, callback);
|
|
16
|
-
});
|
|
10
|
+
hostNode != null && (hostNode.measure = createMeasure(hostNode), hostNode.measureLayout = createMeasureLayout(hostNode), hostNode.measureInWindow = createMeasureInWindow(hostNode));
|
|
17
11
|
};
|
|
18
12
|
});
|
|
19
13
|
return ref;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["createMeasure","createMeasureInWindow","createMeasureLayout","useStable","usePlatformMethods","param","pointerEvents","style","ref","hostNode","measure","measureLayout","measureInWindow","usePlatformMethods_default","default"],"sources":["../../../../src/modules/usePlatformMethods/index.tsx"],"sourcesContent":[null],"mappings":"AASA,SAAAA,aAAA,EAAAC,qBAAA,EAAAC,mBAAA;AAAA,OACEC,SAAA;AAAA,SACAC,mBAAAC,KAAA;EACA;MAAAC,aAAA;MAAAC;IAAA,IAAAF,KAAA;IAAAG,GAAA,GAAAL,SAAA;MAAA,OACK,UAAAM,QAAA;QAEPA,QAAO,QAAe,KAAAA,QAAA,CAAAC,OAAA,GAAAV,aAAA,CAAAS,QAAA,GAAAA,QAAA,CAAAE,aAAA,GAAAT,mBAAA,CAAAO,QAAA,GAAAA,QAAA,CAAAG,eAAA,GAAAX,qBAAA,CAAAQ,QAAA;MAMf;IACL;EACA,OAAAD,GAAA;AACF;AAcE,IAAAK,0BAR6B,GAAAT,kBAAkB;AAC7C,SAKFS,0BAAC,IAAAC,OAAA,EAGHV,kBAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/react-native-web-internals",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.131.0",
|
|
4
4
|
"description": "React Native for Web",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs",
|
|
@@ -31,15 +31,15 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@tamagui/normalize-css-color": "1.
|
|
35
|
-
"@tamagui/react-native-use-pressable": "1.
|
|
36
|
-
"@tamagui/react-native-use-responder-events": "1.
|
|
37
|
-
"@tamagui/simple-hash": "1.
|
|
38
|
-
"@tamagui/use-element-layout": "1.
|
|
39
|
-
"@tamagui/web": "1.
|
|
34
|
+
"@tamagui/normalize-css-color": "1.131.0",
|
|
35
|
+
"@tamagui/react-native-use-pressable": "1.131.0",
|
|
36
|
+
"@tamagui/react-native-use-responder-events": "1.131.0",
|
|
37
|
+
"@tamagui/simple-hash": "1.131.0",
|
|
38
|
+
"@tamagui/use-element-layout": "1.131.0",
|
|
39
|
+
"@tamagui/web": "1.131.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@tamagui/build": "1.
|
|
42
|
+
"@tamagui/build": "1.131.0",
|
|
43
43
|
"react": "*",
|
|
44
44
|
"react-dom": "*"
|
|
45
45
|
},
|
|
@@ -8,29 +8,7 @@
|
|
|
8
8
|
* @noflow
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import
|
|
12
|
-
import setValueForStyles from '../setValueForStyles/index'
|
|
13
|
-
|
|
14
|
-
const getRect = (node) => {
|
|
15
|
-
// Unlike the DOM's getBoundingClientRect, React Native layout measurements
|
|
16
|
-
// for "height" and "width" ignore scale transforms.
|
|
17
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/CSS_Object_Model/Determining_the_dimensions_of_elements
|
|
18
|
-
const { x, y, top, left } = getBoundingClientRect(node)!
|
|
19
|
-
const width = node.offsetWidth
|
|
20
|
-
const height = node.offsetHeight
|
|
21
|
-
return { x, y, width, height, top, left }
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const measureLayout = (node, relativeToNativeNode, callback) => {
|
|
25
|
-
const relativeNode = relativeToNativeNode || (node && node.parentNode)
|
|
26
|
-
if (node && relativeNode) {
|
|
27
|
-
const relativeRect = getBoundingClientRect(relativeNode)
|
|
28
|
-
const { height, left, top, width } = getRect(node)
|
|
29
|
-
const x = left - relativeRect.left
|
|
30
|
-
const y = top - relativeRect.top
|
|
31
|
-
callback(x, y, width, height, left, top)
|
|
32
|
-
}
|
|
33
|
-
}
|
|
11
|
+
import { measure, measureInWindow } from '@tamagui/use-element-layout'
|
|
34
12
|
|
|
35
13
|
const focusableElements = {
|
|
36
14
|
A: true,
|
|
@@ -64,48 +42,21 @@ const UIManager = {
|
|
|
64
42
|
},
|
|
65
43
|
|
|
66
44
|
measure(node, callback) {
|
|
67
|
-
|
|
45
|
+
return measure(node, callback)
|
|
68
46
|
},
|
|
69
47
|
|
|
70
48
|
measureInWindow(node, callback) {
|
|
71
|
-
|
|
72
|
-
setTimeout(() => {
|
|
73
|
-
const { height, left, top, width } = getRect(node)
|
|
74
|
-
callback(left, top, width, height)
|
|
75
|
-
}, 0)
|
|
76
|
-
}
|
|
49
|
+
return measureInWindow(node, callback)
|
|
77
50
|
},
|
|
78
51
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const value = props[prop]
|
|
90
|
-
switch (prop) {
|
|
91
|
-
case 'style': {
|
|
92
|
-
setValueForStyles(node, value)
|
|
93
|
-
break
|
|
94
|
-
}
|
|
95
|
-
case 'class':
|
|
96
|
-
case 'className': {
|
|
97
|
-
node.setAttribute('class', value)
|
|
98
|
-
break
|
|
99
|
-
}
|
|
100
|
-
case 'text':
|
|
101
|
-
case 'value':
|
|
102
|
-
// native platforms use `text` prop to replace text input value
|
|
103
|
-
node.value = value
|
|
104
|
-
break
|
|
105
|
-
default:
|
|
106
|
-
node.setAttribute(prop, value)
|
|
107
|
-
}
|
|
108
|
-
}
|
|
52
|
+
// note its flipped fail and success on purpose lol
|
|
53
|
+
async measureLayout(
|
|
54
|
+
node: HTMLElement,
|
|
55
|
+
relativeToNativeNode?: HTMLElement,
|
|
56
|
+
onFail,
|
|
57
|
+
onSuccess
|
|
58
|
+
) {
|
|
59
|
+
return measureLayout(node, relativeToNativeNode, onSuccess)
|
|
109
60
|
},
|
|
110
61
|
|
|
111
62
|
configureNextLayoutAnimation(config, onAnimationDidEnd) {
|
|
@@ -7,8 +7,12 @@
|
|
|
7
7
|
* @flow
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
import {
|
|
11
|
+
createMeasure,
|
|
12
|
+
createMeasureInWindow,
|
|
13
|
+
createMeasureLayout,
|
|
14
|
+
} from '@tamagui/use-element-layout'
|
|
10
15
|
import type { GenericStyleProp } from '../../types'
|
|
11
|
-
import UIManager from '../UIManager/index'
|
|
12
16
|
import useStable from '../useStable/index'
|
|
13
17
|
|
|
14
18
|
/**
|
|
@@ -26,11 +30,9 @@ export function usePlatformMethods({
|
|
|
26
30
|
// available to 'setNativeProps' when it is called.
|
|
27
31
|
const ref = useStable(() => (hostNode: any) => {
|
|
28
32
|
if (hostNode != null) {
|
|
29
|
-
hostNode.measure = (
|
|
30
|
-
hostNode.measureLayout = (
|
|
31
|
-
|
|
32
|
-
hostNode.measureInWindow = (callback) =>
|
|
33
|
-
UIManager.measureInWindow(hostNode, callback)
|
|
33
|
+
hostNode.measure = createMeasure(hostNode)
|
|
34
|
+
hostNode.measureLayout = createMeasureLayout(hostNode)
|
|
35
|
+
hostNode.measureInWindow = createMeasureInWindow(hostNode)
|
|
34
36
|
}
|
|
35
37
|
})
|
|
36
38
|
|
|
@@ -9,10 +9,14 @@
|
|
|
9
9
|
declare const UIManager: {
|
|
10
10
|
blur(node: any): void;
|
|
11
11
|
focus(node: any): void;
|
|
12
|
-
measure(node: any, callback: any):
|
|
13
|
-
measureInWindow(node: any, callback: any):
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
measure(node: any, callback: any): Promise<import("@tamagui/use-element-layout").LayoutValue | null>;
|
|
13
|
+
measureInWindow(node: any, callback: any): Promise<{
|
|
14
|
+
pageX: number;
|
|
15
|
+
pageY: number;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
} | null>;
|
|
19
|
+
measureLayout(node: HTMLElement, relativeToNativeNode?: HTMLElement, onFail: any, onSuccess: any): Promise<any>;
|
|
16
20
|
configureNextLayoutAnimation(config: any, onAnimationDidEnd: any): void;
|
|
17
21
|
setLayoutAnimationEnabledExperimental(): void;
|
|
18
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/UIManager/index.tsx"],"names":[],"mappings":"AACA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/UIManager/index.tsx"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAWH,QAAA,MAAM,SAAS;;;;;;;;;;wBAkCL,WAAW,yBACM,WAAW;;;CAarC,CAAA;AAED,eAAe,SAAS,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/usePlatformMethods/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/usePlatformMethods/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAGnD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,aAAa,EACb,KAAK,GACN,EAAE;IACD,KAAK,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IACjC,aAAa,CAAC,EAAE,GAAG,CAAA;CACpB,GAAG,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,CAY1B;AAED,eAAe,kBAAkB,CAAA"}
|