@tamagui/core 1.129.5 → 1.129.6-1751237024118

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 (61) hide show
  1. package/dist/cjs/index.cjs +15 -9
  2. package/dist/cjs/index.js +11 -7
  3. package/dist/cjs/index.js.map +2 -2
  4. package/dist/cjs/index.native.js +15 -7
  5. package/dist/cjs/index.native.js.map +2 -2
  6. package/dist/esm/index.js +15 -5
  7. package/dist/esm/index.js.map +1 -1
  8. package/dist/esm/index.mjs +11 -6
  9. package/dist/esm/index.mjs.map +1 -1
  10. package/dist/esm/index.native.js +13 -6
  11. package/dist/esm/index.native.js.map +1 -1
  12. package/dist/native.js +427 -356
  13. package/dist/native.js.map +3 -3
  14. package/dist/test.native.js +407 -335
  15. package/dist/test.native.js.map +3 -3
  16. package/package.json +9 -8
  17. package/src/index.tsx +19 -3
  18. package/types/index.d.ts +3 -2
  19. package/types/index.d.ts.map +1 -1
  20. package/dist/cjs/helpers/getBoundingClientRect.cjs +0 -41
  21. package/dist/cjs/helpers/getBoundingClientRect.js +0 -39
  22. package/dist/cjs/helpers/getBoundingClientRect.js.map +0 -6
  23. package/dist/cjs/helpers/getBoundingClientRect.native.js +0 -48
  24. package/dist/cjs/helpers/getBoundingClientRect.native.js.map +0 -6
  25. package/dist/cjs/helpers/getRect.cjs +0 -44
  26. package/dist/cjs/helpers/getRect.js +0 -27
  27. package/dist/cjs/helpers/getRect.js.map +0 -6
  28. package/dist/cjs/helpers/getRect.native.js +0 -39
  29. package/dist/cjs/helpers/getRect.native.js.map +0 -6
  30. package/dist/cjs/hooks/useElementLayout.cjs +0 -203
  31. package/dist/cjs/hooks/useElementLayout.js +0 -152
  32. package/dist/cjs/hooks/useElementLayout.js.map +0 -6
  33. package/dist/cjs/hooks/useElementLayout.native.js +0 -185
  34. package/dist/cjs/hooks/useElementLayout.native.js.map +0 -6
  35. package/dist/esm/helpers/getBoundingClientRect.js +0 -23
  36. package/dist/esm/helpers/getBoundingClientRect.js.map +0 -6
  37. package/dist/esm/helpers/getBoundingClientRect.mjs +0 -17
  38. package/dist/esm/helpers/getBoundingClientRect.mjs.map +0 -1
  39. package/dist/esm/helpers/getBoundingClientRect.native.js +0 -24
  40. package/dist/esm/helpers/getBoundingClientRect.native.js.map +0 -1
  41. package/dist/esm/helpers/getRect.js +0 -11
  42. package/dist/esm/helpers/getRect.js.map +0 -6
  43. package/dist/esm/helpers/getRect.mjs +0 -21
  44. package/dist/esm/helpers/getRect.mjs.map +0 -1
  45. package/dist/esm/helpers/getRect.native.js +0 -22
  46. package/dist/esm/helpers/getRect.native.js.map +0 -1
  47. package/dist/esm/hooks/useElementLayout.js +0 -140
  48. package/dist/esm/hooks/useElementLayout.js.map +0 -6
  49. package/dist/esm/hooks/useElementLayout.mjs +0 -175
  50. package/dist/esm/hooks/useElementLayout.mjs.map +0 -1
  51. package/dist/esm/hooks/useElementLayout.native.js +0 -189
  52. package/dist/esm/hooks/useElementLayout.native.js.map +0 -1
  53. package/src/helpers/getBoundingClientRect.tsx +0 -30
  54. package/src/helpers/getRect.tsx +0 -8
  55. package/src/hooks/useElementLayout.tsx +0 -292
  56. package/types/helpers/getBoundingClientRect.d.ts +0 -3
  57. package/types/helpers/getBoundingClientRect.d.ts.map +0 -1
  58. package/types/helpers/getRect.d.ts +0 -9
  59. package/types/helpers/getRect.d.ts.map +0 -1
  60. package/types/hooks/useElementLayout.d.ts +0 -26
  61. package/types/hooks/useElementLayout.d.ts.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/core",
3
- "version": "1.129.5",
3
+ "version": "1.129.6-1751237024118",
4
4
  "source": "src/index.tsx",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
@@ -35,15 +35,16 @@
35
35
  "native-test.d.ts"
36
36
  ],
37
37
  "dependencies": {
38
- "@tamagui/react-native-media-driver": "1.129.5",
39
- "@tamagui/react-native-use-pressable": "1.129.5",
40
- "@tamagui/react-native-use-responder-events": "1.129.5",
41
- "@tamagui/use-event": "1.129.5",
42
- "@tamagui/web": "1.129.5"
38
+ "@tamagui/react-native-media-driver": "1.129.6-1751237024118",
39
+ "@tamagui/react-native-use-pressable": "1.129.6-1751237024118",
40
+ "@tamagui/react-native-use-responder-events": "1.129.6-1751237024118",
41
+ "@tamagui/use-element-layout": "1.129.6-1751237024118",
42
+ "@tamagui/use-event": "1.129.6-1751237024118",
43
+ "@tamagui/web": "1.129.6-1751237024118"
43
44
  },
44
45
  "devDependencies": {
45
- "@tamagui/build": "1.129.5",
46
- "@tamagui/react-native-web-lite": "1.129.5",
46
+ "@tamagui/build": "1.129.6-1751237024118",
47
+ "@tamagui/react-native-web-lite": "1.129.6-1751237024118",
47
48
  "@testing-library/react": "^16.1.0",
48
49
  "csstype": "^3.0.10",
49
50
  "react": "*",
package/src/index.tsx CHANGED
@@ -6,6 +6,7 @@ import type {
6
6
  TamaDefer,
7
7
  TamaguiComponent,
8
8
  TamaguiElement,
9
+ TamaguiProviderProps,
9
10
  TamaguiTextElement,
10
11
  TextNonStyleProps,
11
12
  TextProps,
@@ -13,19 +14,25 @@ import type {
13
14
  } from '@tamagui/web'
14
15
  import {
15
16
  Stack as WebStack,
17
+ TamaguiProvider as WebTamaguiProvider,
16
18
  Text as WebText,
17
19
  View as WebView,
18
20
  composeEventHandlers,
19
21
  createTamagui as createTamaguiWeb,
20
22
  setupHooks,
23
+ useIsomorphicLayoutEffect,
21
24
  } from '@tamagui/web'
22
25
  import React from 'react'
23
26
 
27
+ import {
28
+ enable,
29
+ getRect,
30
+ measureLayout,
31
+ useElementLayout,
32
+ } from '@tamagui/use-element-layout'
24
33
  import { addNativeValidStyles } from './addNativeValidStyles'
25
34
  import { createOptimizedView } from './createOptimizedView'
26
35
  import { getBaseViews } from './getBaseViews'
27
- import { getRect } from './helpers/getRect'
28
- import { measureLayout, useElementLayout } from './hooks/useElementLayout'
29
36
  import type { RNTextProps, RNViewProps } from './reactNativeTypes'
30
37
  import { usePressability } from './vendor/Pressability'
31
38
 
@@ -34,7 +41,7 @@ export {
34
41
  getElementLayoutEvent,
35
42
  setOnLayoutStrategy,
36
43
  type LayoutEvent,
37
- } from './hooks/useElementLayout'
44
+ } from '@tamagui/use-element-layout'
38
45
 
39
46
  // add newer style props based on react native version
40
47
  addNativeValidStyles()
@@ -73,6 +80,15 @@ export * from '@tamagui/web'
73
80
  // see https://discord.com/channels/909986013848412191/1146150253490348112/1146150253490348112
74
81
  export * from './reactNativeTypes'
75
82
 
83
+ // adds useElementLayout enable
84
+ export const TamaguiProvider = (props: TamaguiProviderProps) => {
85
+ useIsomorphicLayoutEffect(() => {
86
+ enable()
87
+ }, [])
88
+
89
+ return <WebTamaguiProvider {...props} />
90
+ }
91
+
76
92
  // automate using the react native media driver
77
93
  export const createTamagui: typeof createTamaguiWeb = (conf) => {
78
94
  if (process.env.TAMAGUI_TARGET === 'native') {
package/types/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import type { StackNonStyleProps, StackStyleBase, TamaDefer, TamaguiComponent, TamaguiElement, TamaguiTextElement, TextNonStyleProps, TextProps, TextStylePropsBase } from '@tamagui/web';
1
+ import type { StackNonStyleProps, StackStyleBase, TamaDefer, TamaguiComponent, TamaguiElement, TamaguiProviderProps, TamaguiTextElement, TextNonStyleProps, TextProps, TextStylePropsBase } from '@tamagui/web';
2
2
  import { createTamagui as createTamaguiWeb } from '@tamagui/web';
3
3
  import type { RNTextProps, RNViewProps } from './reactNativeTypes';
4
- export { getElementLayoutEvent, setOnLayoutStrategy, type LayoutEvent, } from './hooks/useElementLayout';
4
+ export { getElementLayoutEvent, setOnLayoutStrategy, type LayoutEvent, } from '@tamagui/use-element-layout';
5
5
  type RNExclusiveViewProps = Omit<RNViewProps, keyof StackNonStyleProps>;
6
6
  export interface RNTamaguiViewNonStyleProps extends StackNonStyleProps, RNExclusiveViewProps {
7
7
  }
@@ -12,6 +12,7 @@ export interface RNTamaguiTextNonStyleProps extends TextNonStyleProps, RNExclusi
12
12
  type RNTamaguiText = TamaguiComponent<TamaDefer, TamaguiTextElement, RNTamaguiTextNonStyleProps, TextStylePropsBase, {}>;
13
13
  export * from '@tamagui/web';
14
14
  export * from './reactNativeTypes';
15
+ export declare const TamaguiProvider: (props: TamaguiProviderProps) => import("react/jsx-runtime").JSX.Element;
15
16
  export declare const createTamagui: typeof createTamaguiWeb;
16
17
  export declare const View: RNTamaguiView;
17
18
  export declare const Stack: RNTamaguiView;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,kBAAkB,EAClB,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,SAAS,EACT,kBAAkB,EACnB,MAAM,cAAc,CAAA;AACrB,OAAO,EAKL,aAAa,IAAI,gBAAgB,EAElC,MAAM,cAAc,CAAA;AAQrB,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAIlE,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,KAAK,WAAW,GACjB,MAAM,0BAA0B,CAAA;AAOjC,KAAK,oBAAoB,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,kBAAkB,CAAC,CAAA;AACvE,MAAM,WAAW,0BACf,SAAQ,kBAAkB,EACxB,oBAAoB;CAAG;AAE3B,KAAK,aAAa,GAAG,gBAAgB,CACnC,SAAS,EACT,cAAc,EACd,0BAA0B,EAC1B,cAAc,EACd,EAAE,CACH,CAAA;AAED,KAAK,oBAAoB,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,SAAS,CAAC,CAAA;AAC9D,MAAM,WAAW,0BACf,SAAQ,iBAAiB,EACvB,oBAAoB;CAAG;AAE3B,KAAK,aAAa,GAAG,gBAAgB,CACnC,SAAS,EACT,kBAAkB,EAClB,0BAA0B,EAC1B,kBAAkB,EAClB,EAAE,CACH,CAAA;AAGD,cAAc,cAAc,CAAA;AAG5B,cAAc,oBAAoB,CAAA;AAGlC,eAAO,MAAM,aAAa,EAAE,OAAO,gBAOlC,CAAA;AAmLD,eAAO,MAAM,IAAI,EAAqB,aAAa,CAAA;AACnD,eAAO,MAAM,KAAK,EAAsB,aAAa,CAAA;AACrD,eAAO,MAAM,IAAI,EAAqB,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,kBAAkB,EAClB,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,SAAS,EACT,kBAAkB,EACnB,MAAM,cAAc,CAAA;AACrB,OAAO,EAML,aAAa,IAAI,gBAAgB,EAGlC,MAAM,cAAc,CAAA;AAYrB,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAIlE,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,KAAK,WAAW,GACjB,MAAM,6BAA6B,CAAA;AAOpC,KAAK,oBAAoB,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,kBAAkB,CAAC,CAAA;AACvE,MAAM,WAAW,0BACf,SAAQ,kBAAkB,EACxB,oBAAoB;CAAG;AAE3B,KAAK,aAAa,GAAG,gBAAgB,CACnC,SAAS,EACT,cAAc,EACd,0BAA0B,EAC1B,cAAc,EACd,EAAE,CACH,CAAA;AAED,KAAK,oBAAoB,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,SAAS,CAAC,CAAA;AAC9D,MAAM,WAAW,0BACf,SAAQ,iBAAiB,EACvB,oBAAoB;CAAG;AAE3B,KAAK,aAAa,GAAG,gBAAgB,CACnC,SAAS,EACT,kBAAkB,EAClB,0BAA0B,EAC1B,kBAAkB,EAClB,EAAE,CACH,CAAA;AAGD,cAAc,cAAc,CAAA;AAG5B,cAAc,oBAAoB,CAAA;AAGlC,eAAO,MAAM,eAAe,GAAI,OAAO,oBAAoB,4CAM1D,CAAA;AAGD,eAAO,MAAM,aAAa,EAAE,OAAO,gBAOlC,CAAA;AAmLD,eAAO,MAAM,IAAI,EAAqB,aAAa,CAAA;AACnD,eAAO,MAAM,KAAK,EAAsB,aAAa,CAAA;AACrD,eAAO,MAAM,IAAI,EAAqB,aAAa,CAAA"}
@@ -1,41 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
- get: () => from[key],
14
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
- });
16
- return to;
17
- };
18
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
20
- }), mod);
21
- var getBoundingClientRect_exports = {};
22
- __export(getBoundingClientRect_exports, {
23
- getBoundingClientRect: () => getBoundingClientRect,
24
- getBoundingClientRectAsync: () => getBoundingClientRectAsync
25
- });
26
- module.exports = __toCommonJS(getBoundingClientRect_exports);
27
- const getBoundingClientRect = node => {
28
- if (!(!node || node.nodeType !== 1)) return node.getBoundingClientRect?.();
29
- },
30
- getBoundingClientRectAsync = element => new Promise(resolve => {
31
- let didFallback = !1;
32
- function fallbackToSync() {
33
- didFallback = !0, resolve(getBoundingClientRect(element));
34
- }
35
- const tm = setTimeout(fallbackToSync, 32);
36
- new IntersectionObserver((entries, ob) => {
37
- clearTimeout(tm), ob.disconnect(), didFallback || resolve(entries[0]?.boundingClientRect);
38
- }, {
39
- threshold: 1e-4
40
- }).observe(element);
41
- });
@@ -1,39 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
8
- }, __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from == "object" || typeof from == "function")
10
- for (let key of __getOwnPropNames(from))
11
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
15
- var getBoundingClientRect_exports = {};
16
- __export(getBoundingClientRect_exports, {
17
- getBoundingClientRect: () => getBoundingClientRect,
18
- getBoundingClientRectAsync: () => getBoundingClientRectAsync
19
- });
20
- module.exports = __toCommonJS(getBoundingClientRect_exports);
21
- const getBoundingClientRect = (node) => {
22
- if (!(!node || node.nodeType !== 1))
23
- return node.getBoundingClientRect?.();
24
- }, getBoundingClientRectAsync = (element) => new Promise((resolve) => {
25
- let didFallback = !1;
26
- function fallbackToSync() {
27
- didFallback = !0, resolve(getBoundingClientRect(element));
28
- }
29
- const tm = setTimeout(fallbackToSync, 32);
30
- new IntersectionObserver(
31
- (entries, ob) => {
32
- clearTimeout(tm), ob.disconnect(), didFallback || resolve(entries[0]?.boundingClientRect);
33
- },
34
- {
35
- threshold: 1e-4
36
- }
37
- ).observe(element);
38
- });
39
- //# sourceMappingURL=getBoundingClientRect.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/helpers/getBoundingClientRect.tsx"],
4
- "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,wBAAwB,CAAC,SAAkD;AACtF,MAAI,GAAC,QAAQ,KAAK,aAAa;AAC/B,WAAO,KAAK,wBAAwB;AACtC,GAEa,6BAA6B,CACxC,YAEO,IAAI,QAAQ,CAAC,YAAY;AAC9B,MAAI,cAAc;AAClB,WAAS,iBAAiB;AACxB,kBAAc,IACd,QAAQ,sBAAsB,OAAO,CAAC;AAAA,EACxC;AACA,QAAM,KAAK,WAAW,gBAAgB,EAAE;AAaxC,EAZiB,IAAI;AAAA,IACnB,CAAC,SAAS,OAAO;AACf,mBAAa,EAAE,GACf,GAAG,WAAW,GACT,eACH,QAAQ,QAAQ,CAAC,GAAG,kBAAkB;AAAA,IAE1C;AAAA,IACA;AAAA,MACE,WAAW;AAAA,IACb;AAAA,EACF,EACS,QAAQ,OAAO;AAC1B,CAAC;",
5
- "names": []
6
- }
@@ -1,48 +0,0 @@
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
- getBoundingClientRectAsync: () => getBoundingClientRectAsync
20
- });
21
- module.exports = __toCommonJS(getBoundingClientRect_exports);
22
- var getBoundingClientRect = function(node) {
23
- var _node_getBoundingClientRect;
24
- if (!(!node || node.nodeType !== 1))
25
- return (_node_getBoundingClientRect = node.getBoundingClientRect) === null || _node_getBoundingClientRect === void 0 ? void 0 : _node_getBoundingClientRect.call(node);
26
- }, getBoundingClientRectAsync = function(element) {
27
- return new Promise(function(resolve) {
28
- var didFallback = !1;
29
- function fallbackToSync() {
30
- didFallback = !0, resolve(getBoundingClientRect(element));
31
- }
32
- var tm = setTimeout(fallbackToSync, 32), observer = new IntersectionObserver(function(entries, ob) {
33
- if (clearTimeout(tm), ob.disconnect(), !didFallback) {
34
- var _entries_;
35
- resolve((_entries_ = entries[0]) === null || _entries_ === void 0 ? void 0 : _entries_.boundingClientRect);
36
- }
37
- }, {
38
- threshold: 1e-4
39
- });
40
- observer.observe(element);
41
- });
42
- };
43
- // Annotate the CommonJS export names for ESM import in node:
44
- 0 && (module.exports = {
45
- getBoundingClientRect,
46
- getBoundingClientRectAsync
47
- });
48
- //# sourceMappingURL=getBoundingClientRect.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/helpers/getBoundingClientRect.tsx"],
4
- "mappings": ";;;;;;;;;;;;;;;AAAA;;;;;;AAAO,IAAMA,wBAAwB,SAACC,MAAAA;MAE7BA;AADP,MAAI,GAACA,QAAQA,KAAKC,aAAa;AAC/B,YAAOD,8BAAAA,KAAKD,2BAAqB,QAA1BC,gCAAAA,SAAAA,SAAAA,4BAAAA,KAAAA,IAAAA;AACT,GAEaE,6BAA6B,SACxCC,SAAAA;AAEA,SAAO,IAAIC,QAAQ,SAACC,SAAAA;AAClB,QAAIC,cAAc;AAClB,aAASC,iBAAAA;AACPD,oBAAc,IACdD,QAAQN,sBAAsBI,OAAAA,CAAAA;IAChC;AACA,QAAMK,KAAKC,WAAWF,gBAAgB,EAAA,GAChCG,WAAW,IAAIC,qBACnB,SAACC,SAASC,IAAAA;AAGR,UAFAC,aAAaN,EAAAA,GACbK,GAAGE,WAAU,GACT,CAACT,aAAa;YACRM;AAARP,iBAAQO,YAAAA,QAAQ,CAAA,OAAE,QAAVA,cAAAA,SAAAA,SAAAA,UAAYI,kBAAkB;MACxC;IACF,GACA;MACEC,WAAW;IACb,CAAA;AAEFP,aAASQ,QAAQf,OAAAA;EACnB,CAAA;AACF;",
5
- "names": ["getBoundingClientRect", "node", "nodeType", "getBoundingClientRectAsync", "element", "Promise", "resolve", "didFallback", "fallbackToSync", "tm", "setTimeout", "observer", "IntersectionObserver", "entries", "ob", "clearTimeout", "disconnect", "boundingClientRect", "threshold", "observe"]
6
- }
@@ -1,44 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
- get: () => from[key],
14
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
- });
16
- return to;
17
- };
18
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
20
- }), mod);
21
- var getRect_exports = {};
22
- __export(getRect_exports, {
23
- getRect: () => getRect
24
- });
25
- module.exports = __toCommonJS(getRect_exports);
26
- var import_getBoundingClientRect = require("./getBoundingClientRect.cjs");
27
- const getRect = node => {
28
- const rect = (0, import_getBoundingClientRect.getBoundingClientRect)(node);
29
- if (!rect) return;
30
- const {
31
- x,
32
- y,
33
- top,
34
- left
35
- } = rect;
36
- return {
37
- x,
38
- y,
39
- width: node.offsetWidth,
40
- height: node.offsetHeight,
41
- top,
42
- left
43
- };
44
- };
@@ -1,27 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
8
- }, __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from == "object" || typeof from == "function")
10
- for (let key of __getOwnPropNames(from))
11
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
15
- var getRect_exports = {};
16
- __export(getRect_exports, {
17
- getRect: () => getRect
18
- });
19
- module.exports = __toCommonJS(getRect_exports);
20
- var import_getBoundingClientRect = require("./getBoundingClientRect");
21
- const getRect = (node) => {
22
- const rect = (0, import_getBoundingClientRect.getBoundingClientRect)(node);
23
- if (!rect) return;
24
- const { x, y, top, left } = rect;
25
- return { x, y, width: node.offsetWidth, height: node.offsetHeight, top, left };
26
- };
27
- //# sourceMappingURL=getRect.js.map
@@ -1,6 +0,0 @@
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,KAAM;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,39 +0,0 @@
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"), getRect = function(node) {
22
- var rect = (0, import_getBoundingClientRect.getBoundingClientRect)(node);
23
- if (rect) {
24
- var { x, y, top, left } = rect;
25
- return {
26
- x,
27
- y,
28
- width: node.offsetWidth,
29
- height: node.offsetHeight,
30
- top,
31
- left
32
- };
33
- }
34
- };
35
- // Annotate the CommonJS export names for ESM import in node:
36
- 0 && (module.exports = {
37
- getRect
38
- });
39
- //# sourceMappingURL=getRect.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/helpers/getRect.tsx"],
4
- "mappings": ";;;;;;;;;;;;;;;AAAA;;;;;mCAAsC,oCAEzBA,UAAU,SAACC,MAAAA;AACtB,MAAMC,WAAOC,oDAAsBF,IAAAA;AACnC,MAAKC,MACL;QAAM,EAAEE,GAAGC,GAAGC,KAAKC,KAAI,IAAKL;AAC5B,WAAO;MAAEE;MAAGC;MAAGG,OAAOP,KAAKQ;MAAaC,QAAQT,KAAKU;MAAcL;MAAKC;IAAK;;AAC/E;",
5
- "names": ["getRect", "node", "rect", "getBoundingClientRect", "x", "y", "top", "left", "width", "offsetWidth", "height", "offsetHeight"]
6
- }
@@ -1,203 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
- get: () => from[key],
14
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
- });
16
- return to;
17
- };
18
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
20
- }), mod);
21
- var useElementLayout_exports = {};
22
- __export(useElementLayout_exports, {
23
- getElementLayoutEvent: () => getElementLayoutEvent,
24
- getElementLayoutEventAsync: () => getElementLayoutEventAsync,
25
- measureLayout: () => measureLayout,
26
- measureLayoutAsync: () => measureLayoutAsync,
27
- setOnLayoutStrategy: () => setOnLayoutStrategy,
28
- useElementLayout: () => useElementLayout
29
- });
30
- module.exports = __toCommonJS(useElementLayout_exports);
31
- var import_constants = require("@tamagui/constants"),
32
- import_web = require("@tamagui/web");
33
- const LayoutHandlers = /* @__PURE__ */new WeakMap(),
34
- Nodes = /* @__PURE__ */new Set();
35
- let strategy = "async";
36
- function setOnLayoutStrategy(state) {
37
- strategy = state;
38
- }
39
- const NodeRectCache = /* @__PURE__ */new WeakMap(),
40
- ParentRectCache = /* @__PURE__ */new WeakMap(),
41
- DebounceTimers = /* @__PURE__ */new WeakMap(),
42
- LastChangeTime = /* @__PURE__ */new WeakMap(),
43
- rAF = typeof window < "u" ? window.requestAnimationFrame : void 0,
44
- DEBOUNCE_DELAY = 32;
45
- if (import_constants.isClient) if (rAF) {
46
- let layoutOnAnimationFrame = function () {
47
- const now = Date.now(),
48
- timeSinceLastFrame = now - lastFrameAt;
49
- lastFrameAt = now, strategy !== "off" && (timeSinceLastFrame > 16.67 * numDroppedFramesUntilPause || Nodes.forEach(updateLayoutIfChanged)), rAF(layoutOnAnimationFrame);
50
- },
51
- avoidUpdates = !0;
52
- const queuedUpdates = /* @__PURE__ */new Map();
53
- let lastFrameAt = Date.now();
54
- const numDroppedFramesUntilPause = 2;
55
- (0, import_web.___onDidFinishClientRender)(() => {
56
- avoidUpdates = !1, queuedUpdates && (queuedUpdates.forEach(cb => cb()), queuedUpdates.clear());
57
- });
58
- async function updateLayoutIfChanged(node) {
59
- const nodeRect = node.getBoundingClientRect(),
60
- parentNode = node.parentElement,
61
- parentRect = parentNode?.getBoundingClientRect(),
62
- onLayout = LayoutHandlers.get(node);
63
- if (typeof onLayout != "function") return;
64
- const cachedRect = NodeRectCache.get(node),
65
- cachedParentRect = parentNode ? NodeRectCache.get(parentNode) : null;
66
- if (!cachedRect ||
67
- // has changed one rect
68
- !(0, import_web.isEqualShallow)(cachedRect, nodeRect) && (!cachedParentRect || !(0, import_web.isEqualShallow)(cachedParentRect, parentRect))) if (NodeRectCache.set(node, nodeRect), parentRect && parentNode && ParentRectCache.set(parentNode, parentRect), avoidUpdates) {
69
- const event = getElementLayoutEvent(node);
70
- queuedUpdates.set(node, () => onLayout(event));
71
- } else if (strategy === "async") {
72
- const now = Date.now();
73
- LastChangeTime.set(node, now);
74
- const existingTimer = DebounceTimers.get(node);
75
- existingTimer && clearTimeout(existingTimer);
76
- const timer = setTimeout(async () => {
77
- const lastChange = LastChangeTime.get(node) || 0,
78
- timeSinceChange = Date.now() - lastChange;
79
- if (timeSinceChange >= DEBOUNCE_DELAY) {
80
- const event = await getElementLayoutEventAsync(node);
81
- onLayout(event), DebounceTimers.delete(node);
82
- } else {
83
- const remainingDelay = DEBOUNCE_DELAY - timeSinceChange,
84
- newTimer = setTimeout(async () => {
85
- const event = await getElementLayoutEventAsync(node);
86
- onLayout(event), DebounceTimers.delete(node);
87
- }, remainingDelay);
88
- DebounceTimers.set(node, newTimer);
89
- }
90
- }, DEBOUNCE_DELAY);
91
- DebounceTimers.set(node, timer);
92
- } else {
93
- const event = getElementLayoutEvent(node);
94
- onLayout(event);
95
- }
96
- }
97
- rAF(layoutOnAnimationFrame);
98
- } else process.env.NODE_ENV === "development" && console.warn("No requestAnimationFrame - please polyfill for onLayout to work correctly");
99
- const getElementLayoutEvent = target => {
100
- let res = null;
101
- if (measureLayout(target, null, (x, y, width, height, left, top) => {
102
- res = {
103
- nativeEvent: {
104
- layout: {
105
- x,
106
- y,
107
- width,
108
- height,
109
- left,
110
- top
111
- },
112
- target
113
- },
114
- timeStamp: Date.now()
115
- };
116
- }), !res) throw new Error("\u203C\uFE0F");
117
- return res;
118
- },
119
- measureLayout = (node, relativeTo, callback) => {
120
- const relativeNode = relativeTo || node?.parentElement;
121
- if (relativeNode instanceof HTMLElement) {
122
- const nodeDim = node.getBoundingClientRect(),
123
- relativeNodeDim = relativeNode.getBoundingClientRect();
124
- if (relativeNodeDim && nodeDim) {
125
- const {
126
- x,
127
- y,
128
- width,
129
- height,
130
- left,
131
- top
132
- } = getRelativeDimensions(nodeDim, relativeNodeDim);
133
- callback(x, y, width, height, left, top);
134
- }
135
- }
136
- },
137
- getElementLayoutEventAsync = async target => {
138
- let res = null;
139
- if (await measureLayoutAsync(target, null, (x, y, width, height, left, top) => {
140
- res = {
141
- nativeEvent: {
142
- layout: {
143
- x,
144
- y,
145
- width,
146
- height,
147
- left,
148
- top
149
- },
150
- target
151
- },
152
- timeStamp: Date.now()
153
- };
154
- }), !res) throw new Error("\u203C\uFE0F");
155
- return res;
156
- },
157
- measureLayoutAsync = async (node, relativeTo, callback) => {
158
- const relativeNode = relativeTo || node?.parentElement;
159
- if (relativeNode instanceof HTMLElement) {
160
- const [nodeDim, relativeNodeDim] = await Promise.all([node.getBoundingClientRect(), relativeNode.getBoundingClientRect()]);
161
- if (relativeNodeDim && nodeDim) {
162
- const {
163
- x,
164
- y,
165
- width,
166
- height,
167
- left,
168
- top
169
- } = getRelativeDimensions(nodeDim, relativeNodeDim);
170
- callback(x, y, width, height, left, top);
171
- }
172
- }
173
- },
174
- getRelativeDimensions = (a, b) => {
175
- const {
176
- height,
177
- left,
178
- top,
179
- width
180
- } = a,
181
- x = left - b.left,
182
- y = top - b.top;
183
- return {
184
- x,
185
- y,
186
- width,
187
- height,
188
- left,
189
- top
190
- };
191
- };
192
- function useElementLayout(ref, onLayout) {
193
- const node = ref.current?.host;
194
- node && onLayout && LayoutHandlers.set(node, onLayout), (0, import_constants.useIsomorphicLayoutEffect)(() => {
195
- if (!onLayout) return;
196
- const node2 = ref.current?.host;
197
- if (node2) return LayoutHandlers.set(node2, onLayout), Nodes.add(node2), onLayout(getElementLayoutEvent(node2)), () => {
198
- Nodes.delete(node2), LayoutHandlers.delete(node2), NodeRectCache.delete(node2);
199
- const timer = DebounceTimers.get(node2);
200
- timer && (clearTimeout(timer), DebounceTimers.delete(node2)), LastChangeTime.delete(node2);
201
- };
202
- }, [ref, !!onLayout]);
203
- }