@tamagui/core 1.61.3 → 1.62.1

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.
Files changed (60) hide show
  1. package/dist/cjs/getBaseViews.js +5 -9
  2. package/dist/cjs/getBaseViews.js.map +1 -1
  3. package/dist/cjs/getBaseViews.native.js +5 -8
  4. package/dist/cjs/getBaseViews.native.js.map +1 -1
  5. package/dist/cjs/helpers/getBoundingClientRect.js +7 -13
  6. package/dist/cjs/helpers/getBoundingClientRect.js.map +1 -1
  7. package/dist/cjs/helpers/getBoundingClientRect.native.js +29 -0
  8. package/dist/cjs/helpers/getBoundingClientRect.native.js.map +6 -0
  9. package/dist/cjs/helpers/getRect.js +5 -9
  10. package/dist/cjs/helpers/getRect.js.map +1 -1
  11. package/dist/cjs/helpers/getRect.native.js +33 -0
  12. package/dist/cjs/helpers/getRect.native.js.map +6 -0
  13. package/dist/cjs/hooks/useElementLayout.js +30 -46
  14. package/dist/cjs/hooks/useElementLayout.js.map +1 -1
  15. package/dist/cjs/hooks/useElementLayout.native.js +64 -0
  16. package/dist/cjs/hooks/useElementLayout.native.js.map +6 -0
  17. package/dist/cjs/hooks/usePlatformMethods.js +9 -21
  18. package/dist/cjs/hooks/usePlatformMethods.js.map +1 -1
  19. package/dist/cjs/hooks/usePlatformMethods.native.js +37 -0
  20. package/dist/cjs/hooks/usePlatformMethods.native.js.map +6 -0
  21. package/dist/cjs/index.js +11 -60
  22. package/dist/cjs/index.js.map +1 -1
  23. package/dist/cjs/index.native.js +106 -0
  24. package/dist/cjs/index.native.js.map +6 -0
  25. package/dist/cjs/inject-styles.js +7 -15
  26. package/dist/cjs/inject-styles.js.map +1 -1
  27. package/dist/cjs/inject-styles.native.js +33 -0
  28. package/dist/cjs/inject-styles.native.js.map +6 -0
  29. package/dist/cjs/native.js +20 -0
  30. package/dist/cjs/native.js.map +6 -0
  31. package/dist/cjs/reactNativeTypes.js +3 -6
  32. package/dist/cjs/reactNativeTypes.js.map +1 -1
  33. package/dist/cjs/reactNativeTypes.native.js +15 -0
  34. package/dist/cjs/reactNativeTypes.native.js.map +6 -0
  35. package/dist/cjs/vendor/Pressability.js +6 -11
  36. package/dist/cjs/vendor/Pressability.js.map +1 -1
  37. package/dist/cjs/vendor/Pressability.native.js +6 -10
  38. package/dist/cjs/vendor/Pressability.native.js.map +1 -1
  39. package/dist/esm/helpers/getBoundingClientRect.js +2 -4
  40. package/dist/esm/helpers/getBoundingClientRect.js.map +1 -1
  41. package/dist/esm/hooks/useElementLayout.js +24 -34
  42. package/dist/esm/hooks/useElementLayout.js.map +1 -1
  43. package/dist/esm/hooks/usePlatformMethods.js +3 -9
  44. package/dist/esm/hooks/usePlatformMethods.js.map +1 -1
  45. package/dist/esm/index.js +5 -45
  46. package/dist/esm/index.js.map +1 -1
  47. package/dist/esm/inject-styles.js +2 -6
  48. package/dist/esm/inject-styles.js.map +1 -1
  49. package/dist/esm/vendor/Pressability.js +1 -2
  50. package/dist/esm/vendor/Pressability.js.map +1 -1
  51. package/dist/native.js +6559 -0
  52. package/dist/native.js.map +6 -0
  53. package/package.json +14 -6
  54. package/src/native.ts +1 -0
  55. package/types/native.d.ts +2 -0
  56. package/types/native.d.ts.map +1 -0
  57. package/dist/esm/getBaseViews.native.js +0 -11
  58. package/dist/esm/getBaseViews.native.js.map +0 -6
  59. package/dist/esm/vendor/Pressability.native.js +0 -7
  60. package/dist/esm/vendor/Pressability.native.js.map +0 -6
@@ -1,21 +1,17 @@
1
- "use strict";
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
5
  var __export = (target, all) => {
7
6
  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") {
7
+ __defProp(target, name, { get: all[name], enumerable: !0 });
8
+ }, __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from == "object" || typeof from == "function")
12
10
  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
- }
11
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
12
  return to;
17
13
  };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
19
15
  var getBaseViews_exports = {};
20
16
  __export(getBaseViews_exports, {
21
17
  getBaseViews: () => getBaseViews
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/getBaseViews.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,SAAS,eAAe;AAE7B,SAAO;AACT;",
4
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,SAAS,eAAe;AAE7B,SAAO;AACT;",
5
5
  "names": []
6
6
  }
@@ -5,17 +5,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
6
  var __export = (target, all) => {
7
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") {
8
+ __defProp(target, name, { get: all[name], enumerable: !0 });
9
+ }, __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from == "object" || typeof from == "function")
12
11
  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
- }
12
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
13
  return to;
17
14
  };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
19
16
  var getBaseViews_native_exports = {};
20
17
  __export(getBaseViews_native_exports, {
21
18
  getBaseViews: () => getBaseViews
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/getBaseViews.native.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,SAAS,eAAe;AAC7B,QAAM,SAAS,QAAQ,cAAc;AAErC,SAAO;AAAA,IACL,MAAM,OAAO,QAAQ,OAAO,QAAQ;AAAA,IACpC,MAAM,OAAO,QAAQ,OAAO,QAAQ;AAAA,EACtC;AACF;",
4
+ "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,SAAS,eAAe;AAC7B,QAAM,SAAS,QAAQ,cAAc;AAErC,SAAO;AAAA,IACL,MAAM,OAAO,QAAQ,OAAO,QAAQ;AAAA,IACpC,MAAM,OAAO,QAAQ,OAAO,QAAQ;AAAA,EACtC;AACF;",
5
5
  "names": []
6
6
  }
@@ -1,31 +1,25 @@
1
- "use strict";
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
5
  var __export = (target, all) => {
7
6
  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") {
7
+ __defProp(target, name, { get: all[name], enumerable: !0 });
8
+ }, __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from == "object" || typeof from == "function")
12
10
  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
- }
11
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
12
  return to;
17
13
  };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
19
15
  var getBoundingClientRect_exports = {};
20
16
  __export(getBoundingClientRect_exports, {
21
17
  getBoundingClientRect: () => getBoundingClientRect
22
18
  });
23
19
  module.exports = __toCommonJS(getBoundingClientRect_exports);
24
20
  const getBoundingClientRect = (node) => {
25
- var _a;
26
- if (!node || node.nodeType !== 1)
27
- return;
28
- return (_a = node.getBoundingClientRect) == null ? void 0 : _a.call(node);
21
+ if (!(!node || node.nodeType !== 1))
22
+ return node.getBoundingClientRect?.();
29
23
  };
30
24
  // Annotate the CommonJS export names for ESM import in node:
31
25
  0 && (module.exports = {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/helpers/getBoundingClientRect.tsx"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,wBAAwB,CAAC,SAA6C;AAAnF;AACE,MAAI,CAAC,QAAQ,KAAK,aAAa;AAAG;AAClC,UAAO,UAAK,0BAAL;AACT;",
4
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,wBAAwB,CAAC,SAA6C;AACjF,MAAI,GAAC,QAAQ,KAAK,aAAa;AAC/B,WAAO,KAAK,wBAAwB;AACtC;",
5
5
  "names": []
6
6
  }
@@ -0,0 +1,29 @@
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: !0 });
9
+ }, __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from == "object" || typeof from == "function")
11
+ for (let key of __getOwnPropNames(from))
12
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ return to;
14
+ };
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
16
+ var getBoundingClientRect_exports = {};
17
+ __export(getBoundingClientRect_exports, {
18
+ getBoundingClientRect: () => getBoundingClientRect
19
+ });
20
+ module.exports = __toCommonJS(getBoundingClientRect_exports);
21
+ const getBoundingClientRect = (node) => {
22
+ if (!(!node || node.nodeType !== 1))
23
+ return node.getBoundingClientRect?.();
24
+ };
25
+ // Annotate the CommonJS export names for ESM import in node:
26
+ 0 && (module.exports = {
27
+ getBoundingClientRect
28
+ });
29
+ //# sourceMappingURL=getBoundingClientRect.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/helpers/getBoundingClientRect.tsx"],
4
+ "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,wBAAwB,CAAC,SAA6C;AACjF,MAAI,GAAC,QAAQ,KAAK,aAAa;AAC/B,WAAO,KAAK,wBAAwB;AACtC;",
5
+ "names": []
6
+ }
@@ -1,21 +1,17 @@
1
- "use strict";
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
5
  var __export = (target, all) => {
7
6
  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") {
7
+ __defProp(target, name, { get: all[name], enumerable: !0 });
8
+ }, __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from == "object" || typeof from == "function")
12
10
  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
- }
11
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
12
  return to;
17
13
  };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
19
15
  var getRect_exports = {};
20
16
  __export(getRect_exports, {
21
17
  getRect: () => getRect
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/helpers/getRect.tsx"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mCAAsC;AAE/B,MAAM,UAAU,CAAC,SAAsB;AAC5C,QAAM,WAAO,oDAAsB,IAAI;AACvC,MAAI,CAAC;AAAM;AACX,QAAM,EAAE,GAAG,GAAG,KAAK,KAAK,IAAI;AAC5B,SAAO,EAAE,GAAG,GAAG,OAAO,KAAK,aAAa,QAAQ,KAAK,cAAc,KAAK,KAAK;AAC/E;",
4
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mCAAsC;AAE/B,MAAM,UAAU,CAAC,SAAsB;AAC5C,QAAM,WAAO,oDAAsB,IAAI;AACvC,MAAI,CAAC;AAAM;AACX,QAAM,EAAE,GAAG,GAAG,KAAK,KAAK,IAAI;AAC5B,SAAO,EAAE,GAAG,GAAG,OAAO,KAAK,aAAa,QAAQ,KAAK,cAAc,KAAK,KAAK;AAC/E;",
5
5
  "names": []
6
6
  }
@@ -0,0 +1,33 @@
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: !0 });
9
+ }, __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from == "object" || typeof from == "function")
11
+ for (let key of __getOwnPropNames(from))
12
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ return to;
14
+ };
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
16
+ var getRect_exports = {};
17
+ __export(getRect_exports, {
18
+ getRect: () => getRect
19
+ });
20
+ module.exports = __toCommonJS(getRect_exports);
21
+ var import_getBoundingClientRect = require("./getBoundingClientRect");
22
+ const getRect = (node) => {
23
+ const rect = (0, import_getBoundingClientRect.getBoundingClientRect)(node);
24
+ if (!rect)
25
+ return;
26
+ const { x, y, top, left } = rect;
27
+ return { x, y, width: node.offsetWidth, height: node.offsetHeight, top, left };
28
+ };
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ getRect
32
+ });
33
+ //# sourceMappingURL=getRect.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/helpers/getRect.tsx"],
4
+ "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mCAAsC;AAE/B,MAAM,UAAU,CAAC,SAAsB;AAC5C,QAAM,WAAO,oDAAsB,IAAI;AACvC,MAAI,CAAC;AAAM;AACX,QAAM,EAAE,GAAG,GAAG,KAAK,KAAK,IAAI;AAC5B,SAAO,EAAE,GAAG,GAAG,OAAO,KAAK,aAAa,QAAQ,KAAK,cAAc,KAAK,KAAK;AAC/E;",
5
+ "names": []
6
+ }
@@ -1,74 +1,58 @@
1
- "use strict";
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
5
  var __export = (target, all) => {
7
6
  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") {
7
+ __defProp(target, name, { get: all[name], enumerable: !0 });
8
+ }, __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from == "object" || typeof from == "function")
12
10
  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
- }
11
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
12
  return to;
17
13
  };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
19
15
  var useElementLayout_exports = {};
20
16
  __export(useElementLayout_exports, {
21
17
  measureLayout: () => measureLayout,
22
18
  useElementLayout: () => useElementLayout
23
19
  });
24
20
  module.exports = __toCommonJS(useElementLayout_exports);
25
- var import_constants = require("@tamagui/constants");
26
- var import_getBoundingClientRect = require("../helpers/getBoundingClientRect");
27
- var import_getRect = require("../helpers/getRect");
21
+ var import_constants = require("@tamagui/constants"), import_getBoundingClientRect = require("../helpers/getBoundingClientRect"), import_getRect = require("../helpers/getRect");
28
22
  const LayoutHandlers = /* @__PURE__ */ new WeakMap();
29
23
  let resizeObserver = null;
30
- if (typeof window !== "undefined" && "ResizeObserver" in window) {
31
- resizeObserver = new ResizeObserver((entries) => {
32
- for (const { target } of entries) {
33
- const onLayout = LayoutHandlers.get(target);
34
- if (typeof onLayout !== "function")
35
- return;
36
- measureLayout(target, null, (x, y, width, height, left, top) => {
37
- onLayout({
38
- nativeEvent: {
39
- layout: { x, y, width, height, left, top },
40
- target
41
- },
42
- timeStamp: Date.now()
43
- });
24
+ typeof window < "u" && "ResizeObserver" in window && (resizeObserver = new ResizeObserver((entries) => {
25
+ for (const { target } of entries) {
26
+ const onLayout = LayoutHandlers.get(target);
27
+ if (typeof onLayout != "function")
28
+ return;
29
+ measureLayout(target, null, (x, y, width, height, left, top) => {
30
+ onLayout({
31
+ nativeEvent: {
32
+ layout: { x, y, width, height, left, top },
33
+ target
34
+ },
35
+ timeStamp: Date.now()
44
36
  });
45
- }
46
- });
47
- }
48
- const measureLayout = (node, relativeTo, callback) => {
49
- const relativeNode = relativeTo || (node == null ? void 0 : node.parentNode);
50
- if (relativeNode instanceof HTMLElement) {
51
- setTimeout(() => {
52
- const relativeRect = (0, import_getBoundingClientRect.getBoundingClientRect)(relativeNode);
53
- const { height, left, top, width } = (0, import_getRect.getRect)(node);
54
- const x = left - relativeRect.left;
55
- const y = top - relativeRect.top;
56
- callback(x, y, width, height, left, top);
57
- }, 0);
37
+ });
58
38
  }
39
+ }));
40
+ const measureLayout = (node, relativeTo, callback) => {
41
+ const relativeNode = relativeTo || node?.parentNode;
42
+ relativeNode instanceof HTMLElement && setTimeout(() => {
43
+ const relativeRect = (0, import_getBoundingClientRect.getBoundingClientRect)(relativeNode), { height, left, top, width } = (0, import_getRect.getRect)(node), x = left - relativeRect.left, y = top - relativeRect.top;
44
+ callback(x, y, width, height, left, top);
45
+ }, 0);
59
46
  };
60
47
  function useElementLayout(ref, onLayout) {
61
48
  (0, import_constants.useIsomorphicLayoutEffect)(() => {
62
49
  if (!resizeObserver || !onLayout)
63
50
  return;
64
51
  const node = ref.current;
65
- if (!node)
66
- return;
67
- LayoutHandlers.set(node, onLayout);
68
- resizeObserver.observe(node);
69
- return () => {
70
- resizeObserver == null ? void 0 : resizeObserver.unobserve(node);
71
- };
52
+ if (node)
53
+ return LayoutHandlers.set(node, onLayout), resizeObserver.observe(node), () => {
54
+ resizeObserver?.unobserve(node);
55
+ };
72
56
  }, [ref, onLayout]);
73
57
  }
74
58
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/hooks/useElementLayout.tsx"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA0C;AAI1C,mCAAsC;AACtC,qBAAwB;AAExB,MAAM,iBAAiB,oBAAI,QAA2B;AAmBtD,IAAI,iBAAwC;AAE5C,IAAI,OAAO,WAAW,eAAe,oBAAoB,QAAQ;AAC/D,mBAAiB,IAAI,eAAe,CAAC,YAAY;AAC/C,eAAW,EAAE,OAAO,KAAK,SAAS;AAChC,YAAM,WAAW,eAAe,IAAI,MAAM;AAC1C,UAAI,OAAO,aAAa;AAAY;AACpC,oBAAc,QAAuB,MAAM,CAAC,GAAG,GAAG,OAAO,QAAQ,MAAM,QAAQ;AAC7E,iBAAS;AAAA,UACP,aAAa;AAAA,YACX,QAAQ,EAAE,GAAG,GAAG,OAAO,QAAQ,MAAM,IAAI;AAAA,YACzC;AAAA,UACF;AAAA,UACA,WAAW,KAAK,IAAI;AAAA,QACtB,CAAC;AAAA,MACH,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH;AAEO,MAAM,gBAAgB,CAC3B,MACA,YACA,aACG;AACH,QAAM,eAAe,eAAc,6BAAM;AACzC,MAAI,wBAAwB,aAAa;AACvC,eAAW,MAAM;AACf,YAAM,mBAAe,oDAAsB,YAAY;AACvD,YAAM,EAAE,QAAQ,MAAM,KAAK,MAAM,QAAI,wBAAQ,IAAI;AACjD,YAAM,IAAI,OAAO,aAAa;AAC9B,YAAM,IAAI,MAAM,aAAa;AAC7B,eAAS,GAAG,GAAG,OAAO,QAAQ,MAAM,GAAG;AAAA,IACzC,GAAG,CAAC;AAAA,EACN;AACF;AAEO,SAAS,iBACd,KACA,UACA;AACA,kDAA0B,MAAM;AAC9B,QAAI,CAAC,kBAAkB,CAAC;AAAU;AAClC,UAAM,OAAO,IAAI;AACjB,QAAI,CAAC;AAAM;AACX,mBAAe,IAAI,MAAM,QAAQ;AACjC,mBAAe,QAAQ,IAAI;AAC3B,WAAO,MAAM;AACX,uDAAgB,UAAU;AAAA,IAC5B;AAAA,EACF,GAAG,CAAC,KAAK,QAAQ,CAAC;AACpB;",
4
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA0C,+BAI1C,+BAAsC,6CACtC,iBAAwB;AAExB,MAAM,iBAAiB,oBAAI,QAA2B;AAmBtD,IAAI,iBAAwC;AAExC,OAAO,SAAW,OAAe,oBAAoB,WACvD,iBAAiB,IAAI,eAAe,CAAC,YAAY;AAC/C,aAAW,EAAE,OAAO,KAAK,SAAS;AAChC,UAAM,WAAW,eAAe,IAAI,MAAM;AAC1C,QAAI,OAAO,YAAa;AAAY;AACpC,kBAAc,QAAuB,MAAM,CAAC,GAAG,GAAG,OAAO,QAAQ,MAAM,QAAQ;AAC7E,eAAS;AAAA,QACP,aAAa;AAAA,UACX,QAAQ,EAAE,GAAG,GAAG,OAAO,QAAQ,MAAM,IAAI;AAAA,UACzC;AAAA,QACF;AAAA,QACA,WAAW,KAAK,IAAI;AAAA,MACtB,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AACF,CAAC;AAGI,MAAM,gBAAgB,CAC3B,MACA,YACA,aACG;AACH,QAAM,eAAe,cAAc,MAAM;AACzC,EAAI,wBAAwB,eAC1B,WAAW,MAAM;AACf,UAAM,mBAAe,oDAAsB,YAAY,GACjD,EAAE,QAAQ,MAAM,KAAK,MAAM,QAAI,wBAAQ,IAAI,GAC3C,IAAI,OAAO,aAAa,MACxB,IAAI,MAAM,aAAa;AAC7B,aAAS,GAAG,GAAG,OAAO,QAAQ,MAAM,GAAG;AAAA,EACzC,GAAG,CAAC;AAER;AAEO,SAAS,iBACd,KACA,UACA;AACA,kDAA0B,MAAM;AAC9B,QAAI,CAAC,kBAAkB,CAAC;AAAU;AAClC,UAAM,OAAO,IAAI;AACjB,QAAK;AACL,4BAAe,IAAI,MAAM,QAAQ,GACjC,eAAe,QAAQ,IAAI,GACpB,MAAM;AACX,wBAAgB,UAAU,IAAI;AAAA,MAChC;AAAA,EACF,GAAG,CAAC,KAAK,QAAQ,CAAC;AACpB;",
5
5
  "names": []
6
6
  }
@@ -0,0 +1,64 @@
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: !0 });
9
+ }, __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from == "object" || typeof from == "function")
11
+ for (let key of __getOwnPropNames(from))
12
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ return to;
14
+ };
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
16
+ var useElementLayout_exports = {};
17
+ __export(useElementLayout_exports, {
18
+ measureLayout: () => measureLayout,
19
+ useElementLayout: () => useElementLayout
20
+ });
21
+ module.exports = __toCommonJS(useElementLayout_exports);
22
+ var import_constants = require("@tamagui/constants"), import_getBoundingClientRect = require("../helpers/getBoundingClientRect"), import_getRect = require("../helpers/getRect");
23
+ const LayoutHandlers = /* @__PURE__ */ new WeakMap();
24
+ let resizeObserver = null;
25
+ typeof window < "u" && "ResizeObserver" in window && (resizeObserver = new ResizeObserver((entries) => {
26
+ for (const { target } of entries) {
27
+ const onLayout = LayoutHandlers.get(target);
28
+ if (typeof onLayout != "function")
29
+ return;
30
+ measureLayout(target, null, (x, y, width, height, left, top) => {
31
+ onLayout({
32
+ nativeEvent: {
33
+ layout: { x, y, width, height, left, top },
34
+ target
35
+ },
36
+ timeStamp: Date.now()
37
+ });
38
+ });
39
+ }
40
+ }));
41
+ const measureLayout = (node, relativeTo, callback) => {
42
+ const relativeNode = relativeTo || node?.parentNode;
43
+ relativeNode instanceof HTMLElement && setTimeout(() => {
44
+ const relativeRect = (0, import_getBoundingClientRect.getBoundingClientRect)(relativeNode), { height, left, top, width } = (0, import_getRect.getRect)(node), x = left - relativeRect.left, y = top - relativeRect.top;
45
+ callback(x, y, width, height, left, top);
46
+ }, 0);
47
+ };
48
+ function useElementLayout(ref, onLayout) {
49
+ (0, import_constants.useIsomorphicLayoutEffect)(() => {
50
+ if (!resizeObserver || !onLayout)
51
+ return;
52
+ const node = ref.current;
53
+ if (node)
54
+ return LayoutHandlers.set(node, onLayout), resizeObserver.observe(node), () => {
55
+ resizeObserver?.unobserve(node);
56
+ };
57
+ }, [ref, onLayout]);
58
+ }
59
+ // Annotate the CommonJS export names for ESM import in node:
60
+ 0 && (module.exports = {
61
+ measureLayout,
62
+ useElementLayout
63
+ });
64
+ //# sourceMappingURL=useElementLayout.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/hooks/useElementLayout.tsx"],
4
+ "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA0C,+BAI1C,+BAAsC,6CACtC,iBAAwB;AAExB,MAAM,iBAAiB,oBAAI,QAA2B;AAmBtD,IAAI,iBAAwC;AAExC,OAAO,SAAW,OAAe,oBAAoB,WACvD,iBAAiB,IAAI,eAAe,CAAC,YAAY;AAC/C,aAAW,EAAE,OAAO,KAAK,SAAS;AAChC,UAAM,WAAW,eAAe,IAAI,MAAM;AAC1C,QAAI,OAAO,YAAa;AAAY;AACpC,kBAAc,QAAuB,MAAM,CAAC,GAAG,GAAG,OAAO,QAAQ,MAAM,QAAQ;AAC7E,eAAS;AAAA,QACP,aAAa;AAAA,UACX,QAAQ,EAAE,GAAG,GAAG,OAAO,QAAQ,MAAM,IAAI;AAAA,UACzC;AAAA,QACF;AAAA,QACA,WAAW,KAAK,IAAI;AAAA,MACtB,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AACF,CAAC;AAGI,MAAM,gBAAgB,CAC3B,MACA,YACA,aACG;AACH,QAAM,eAAe,cAAc,MAAM;AACzC,EAAI,wBAAwB,eAC1B,WAAW,MAAM;AACf,UAAM,mBAAe,oDAAsB,YAAY,GACjD,EAAE,QAAQ,MAAM,KAAK,MAAM,QAAI,wBAAQ,IAAI,GAC3C,IAAI,OAAO,aAAa,MACxB,IAAI,MAAM,aAAa;AAC7B,aAAS,GAAG,GAAG,OAAO,QAAQ,MAAM,GAAG;AAAA,EACzC,GAAG,CAAC;AAER;AAEO,SAAS,iBACd,KACA,UACA;AACA,kDAA0B,MAAM;AAC9B,QAAI,CAAC,kBAAkB,CAAC;AAAU;AAClC,UAAM,OAAO,IAAI;AACjB,QAAK;AACL,4BAAe,IAAI,MAAM,QAAQ,GACjC,eAAe,QAAQ,IAAI,GACpB,MAAM;AACX,wBAAgB,UAAU,IAAI;AAAA,MAChC;AAAA,EACF,GAAG,CAAC,KAAK,QAAQ,CAAC;AACpB;",
5
+ "names": []
6
+ }
@@ -1,44 +1,32 @@
1
- "use strict";
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
5
  var __export = (target, all) => {
7
6
  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") {
7
+ __defProp(target, name, { get: all[name], enumerable: !0 });
8
+ }, __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from == "object" || typeof from == "function")
12
10
  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
- }
11
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
12
  return to;
17
13
  };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
19
15
  var usePlatformMethods_exports = {};
20
16
  __export(usePlatformMethods_exports, {
21
17
  usePlatformMethods: () => usePlatformMethods
22
18
  });
23
19
  module.exports = __toCommonJS(usePlatformMethods_exports);
24
- var import_web = require("@tamagui/web");
25
- var import_getRect = require("../helpers/getRect");
26
- var import_useElementLayout = require("./useElementLayout");
20
+ var import_web = require("@tamagui/web"), import_getRect = require("../helpers/getRect"), import_useElementLayout = require("./useElementLayout");
27
21
  function usePlatformMethods(hostRef) {
28
22
  (0, import_web.useIsomorphicLayoutEffect)(() => {
29
23
  const node = hostRef.current;
30
- if (!node)
31
- return;
32
- node.measure = (callback) => (0, import_useElementLayout.measureLayout)(node, null, callback);
33
- node.measureLayout = (relativeToNode, success) => (0, import_useElementLayout.measureLayout)(node, relativeToNode, success);
34
- node.measureInWindow = (callback) => {
35
- if (!node)
36
- return;
37
- setTimeout(() => {
24
+ node && (node.measure = (callback) => (0, import_useElementLayout.measureLayout)(node, null, callback), node.measureLayout = (relativeToNode, success) => (0, import_useElementLayout.measureLayout)(node, relativeToNode, success), node.measureInWindow = (callback) => {
25
+ node && setTimeout(() => {
38
26
  const { height, left, top, width } = (0, import_getRect.getRect)(node);
39
27
  callback(left, top, width, height);
40
28
  }, 0);
41
- };
29
+ });
42
30
  }, [hostRef]);
43
31
  }
44
32
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/hooks/usePlatformMethods.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAA0C;AAG1C,qBAAwB;AACxB,8BAA8B;AAGvB,SAAS,mBAAmB,SAA6B;AAC9D,4CAA0B,MAAM;AAC9B,UAAM,OAAO,QAAQ;AACrB,QAAI,CAAC;AAAM;AAEX,SAAK,UAAU,CAAC,iBAAa,uCAAc,MAAM,MAAM,QAAQ;AAE/D,SAAK,gBAAgB,CAAC,gBAAgB,gBACpC,uCAAc,MAAqB,gBAAgB,OAAO;AAE5D,SAAK,kBAAkB,CAAC,aAAa;AACnC,UAAI,CAAC;AAAM;AACX,iBAAW,MAAM;AACf,cAAM,EAAE,QAAQ,MAAM,KAAK,MAAM,QAAI,wBAAQ,IAAmB;AAChE,iBAAS,MAAM,KAAK,OAAO,MAAM;AAAA,MACnC,GAAG,CAAC;AAAA,IACN;AAAA,EACF,GAAG,CAAC,OAAO,CAAC;AACd;",
4
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAA0C,yBAG1C,iBAAwB,+BACxB,0BAA8B;AAGvB,SAAS,mBAAmB,SAA6B;AAC9D,4CAA0B,MAAM;AAC9B,UAAM,OAAO,QAAQ;AACrB,IAAK,SAEL,KAAK,UAAU,CAAC,iBAAa,uCAAc,MAAM,MAAM,QAAQ,GAE/D,KAAK,gBAAgB,CAAC,gBAAgB,gBACpC,uCAAc,MAAqB,gBAAgB,OAAO,GAE5D,KAAK,kBAAkB,CAAC,aAAa;AACnC,MAAK,QACL,WAAW,MAAM;AACf,cAAM,EAAE,QAAQ,MAAM,KAAK,MAAM,QAAI,wBAAQ,IAAmB;AAChE,iBAAS,MAAM,KAAK,OAAO,MAAM;AAAA,MACnC,GAAG,CAAC;AAAA,IACN;AAAA,EACF,GAAG,CAAC,OAAO,CAAC;AACd;",
5
5
  "names": []
6
6
  }
@@ -0,0 +1,37 @@
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: !0 });
9
+ }, __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from == "object" || typeof from == "function")
11
+ for (let key of __getOwnPropNames(from))
12
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ return to;
14
+ };
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
16
+ var usePlatformMethods_exports = {};
17
+ __export(usePlatformMethods_exports, {
18
+ usePlatformMethods: () => usePlatformMethods
19
+ });
20
+ module.exports = __toCommonJS(usePlatformMethods_exports);
21
+ var import_web = require("@tamagui/web"), import_getRect = require("../helpers/getRect"), import_useElementLayout = require("./useElementLayout");
22
+ function usePlatformMethods(hostRef) {
23
+ (0, import_web.useIsomorphicLayoutEffect)(() => {
24
+ const node = hostRef.current;
25
+ node && (node.measure = (callback) => (0, import_useElementLayout.measureLayout)(node, null, callback), node.measureLayout = (relativeToNode, success) => (0, import_useElementLayout.measureLayout)(node, relativeToNode, success), node.measureInWindow = (callback) => {
26
+ node && setTimeout(() => {
27
+ const { height, left, top, width } = (0, import_getRect.getRect)(node);
28
+ callback(left, top, width, height);
29
+ }, 0);
30
+ });
31
+ }, [hostRef]);
32
+ }
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ usePlatformMethods
36
+ });
37
+ //# sourceMappingURL=usePlatformMethods.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/hooks/usePlatformMethods.ts"],
4
+ "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAA0C,yBAG1C,iBAAwB,+BACxB,0BAA8B;AAGvB,SAAS,mBAAmB,SAA6B;AAC9D,4CAA0B,MAAM;AAC9B,UAAM,OAAO,QAAQ;AACrB,IAAK,SAEL,KAAK,UAAU,CAAC,iBAAa,uCAAc,MAAM,MAAM,QAAQ,GAE/D,KAAK,gBAAgB,CAAC,gBAAgB,gBACpC,uCAAc,MAAqB,gBAAgB,OAAO,GAE5D,KAAK,kBAAkB,CAAC,aAAa;AACnC,MAAK,QACL,WAAW,MAAM;AACf,cAAM,EAAE,QAAQ,MAAM,KAAK,MAAM,QAAI,wBAAQ,IAAmB;AAChE,iBAAS,MAAM,KAAK,OAAO,MAAM;AAAA,MACnC,GAAG,CAAC;AAAA,IACN;AAAA,EACF,GAAG,CAAC,OAAO,CAAC;AACd;",
5
+ "names": []
6
+ }