@hanzogui/web 7.0.0 → 7.3.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 (246) hide show
  1. package/LICENSE +40 -19
  2. package/dist/cjs/_withStableStyle.cjs +1 -1
  3. package/dist/cjs/_withStableStyle.native.js +1 -1
  4. package/dist/cjs/config.cjs +2 -2
  5. package/dist/cjs/config.native.js +2 -2
  6. package/dist/cjs/config.native.js.map +1 -1
  7. package/dist/cjs/constants/constants.cjs +3 -3
  8. package/dist/cjs/constants/constants.native.js +3 -3
  9. package/dist/cjs/createComponent.cjs +307 -530
  10. package/dist/cjs/createComponent.native.js +265 -588
  11. package/dist/cjs/createComponent.native.js.map +1 -1
  12. package/dist/cjs/createGui.cjs +19 -48
  13. package/dist/cjs/createGui.native.js +22 -65
  14. package/dist/cjs/createGui.native.js.map +1 -1
  15. package/dist/cjs/eventHandling.native.js +19 -9
  16. package/dist/cjs/eventHandling.native.js.map +1 -1
  17. package/dist/cjs/helpers/createDesignSystem.cjs +22 -36
  18. package/dist/cjs/helpers/createDesignSystem.native.js +19 -91
  19. package/dist/cjs/helpers/createDesignSystem.native.js.map +1 -1
  20. package/dist/cjs/helpers/defaultAnimationDriver.cjs +1 -1
  21. package/dist/cjs/helpers/defaultAnimationDriver.native.js +1 -1
  22. package/dist/cjs/helpers/expandStyle.cjs +11 -74
  23. package/dist/cjs/helpers/expandStyle.native.js +29 -81
  24. package/dist/cjs/helpers/expandStyle.native.js.map +1 -1
  25. package/dist/cjs/helpers/expandStyles.cjs +2 -15
  26. package/dist/cjs/helpers/expandStyles.native.js +7 -13
  27. package/dist/cjs/helpers/expandStyles.native.js.map +1 -1
  28. package/dist/cjs/helpers/getSplitStyles.cjs +233 -557
  29. package/dist/cjs/helpers/getSplitStyles.native.js +204 -659
  30. package/dist/cjs/helpers/getSplitStyles.native.js.map +1 -1
  31. package/dist/cjs/helpers/getThemeCSSRules.cjs +8 -16
  32. package/dist/cjs/helpers/getTokenForKey.cjs +32 -54
  33. package/dist/cjs/helpers/getTokenForKey.native.js +40 -59
  34. package/dist/cjs/helpers/getTokenForKey.native.js.map +1 -1
  35. package/dist/cjs/helpers/insertStyleRule.cjs +27 -79
  36. package/dist/cjs/helpers/insertStyleRule.native.js +16 -335
  37. package/dist/cjs/helpers/insertStyleRule.native.js.map +1 -1
  38. package/dist/cjs/helpers/isActivePlatform.cjs +2 -17
  39. package/dist/cjs/helpers/isActivePlatform.native.js +2 -17
  40. package/dist/cjs/helpers/isActivePlatform.native.js.map +1 -1
  41. package/dist/cjs/helpers/log.cjs +1 -4
  42. package/dist/cjs/helpers/log.native.js +1 -6
  43. package/dist/cjs/helpers/log.native.js.map +1 -1
  44. package/dist/cjs/helpers/propMapper.cjs +37 -110
  45. package/dist/cjs/helpers/propMapper.native.js +54 -131
  46. package/dist/cjs/helpers/propMapper.native.js.map +1 -1
  47. package/dist/cjs/helpers/skipProps.cjs +3 -11
  48. package/dist/cjs/helpers/skipProps.native.js +3 -11
  49. package/dist/cjs/helpers/skipProps.native.js.map +1 -1
  50. package/dist/cjs/helpers/useRenderElement.cjs +7 -18
  51. package/dist/cjs/helpers/useRenderElement.native.js +7 -15
  52. package/dist/cjs/helpers/useRenderElement.native.js.map +1 -1
  53. package/dist/cjs/helpers/wrapStyleTags.cjs +11 -15
  54. package/dist/cjs/helpers/wrapStyleTags.native.js +3 -22
  55. package/dist/cjs/helpers/wrapStyleTags.native.js.map +1 -1
  56. package/dist/cjs/hooks/getThemeProxied.cjs +10 -54
  57. package/dist/cjs/hooks/getThemeProxied.native.js +27 -48
  58. package/dist/cjs/hooks/getThemeProxied.native.js.map +1 -1
  59. package/dist/cjs/hooks/useTheme.cjs +2 -2
  60. package/dist/cjs/hooks/useTheme.native.js +2 -2
  61. package/dist/cjs/hooks/useTheme.native.js.map +1 -1
  62. package/dist/cjs/hooks/useThemeState.cjs +66 -124
  63. package/dist/cjs/hooks/useThemeState.native.js +64 -142
  64. package/dist/cjs/hooks/useThemeState.native.js.map +1 -1
  65. package/dist/cjs/insertFont.cjs +6 -15
  66. package/dist/cjs/insertFont.native.js +7 -23
  67. package/dist/cjs/insertFont.native.js.map +1 -1
  68. package/dist/cjs/setupReactNative.cjs +4 -24
  69. package/dist/cjs/setupReactNative.native.js +5 -26
  70. package/dist/cjs/setupReactNative.native.js.map +1 -1
  71. package/dist/cjs/views/GuiProvider.cjs +4 -6
  72. package/dist/cjs/views/GuiProvider.native.js +5 -7
  73. package/dist/cjs/views/GuiProvider.native.js.map +1 -1
  74. package/dist/cjs/views/Text.cjs +11 -18
  75. package/dist/cjs/views/Text.native.js +6 -14
  76. package/dist/cjs/views/Text.native.js.map +1 -1
  77. package/dist/cjs/views/ThemeProvider.cjs +9 -11
  78. package/dist/cjs/views/ThemeProvider.native.js +3 -16
  79. package/dist/cjs/views/ThemeProvider.native.js.map +1 -1
  80. package/dist/cjs/views/View.native.js.map +1 -1
  81. package/dist/esm/_withStableStyle.mjs +1 -1
  82. package/dist/esm/_withStableStyle.mjs.map +1 -1
  83. package/dist/esm/_withStableStyle.native.js +1 -1
  84. package/dist/esm/config.mjs +2 -2
  85. package/dist/esm/config.mjs.map +1 -1
  86. package/dist/esm/config.native.js +2 -2
  87. package/dist/esm/config.native.js.map +1 -1
  88. package/dist/esm/constants/constants.mjs +3 -3
  89. package/dist/esm/constants/constants.native.js +3 -3
  90. package/dist/esm/createComponent.mjs +311 -536
  91. package/dist/esm/createComponent.mjs.map +1 -1
  92. package/dist/esm/createComponent.native.js +265 -591
  93. package/dist/esm/createComponent.native.js.map +1 -1
  94. package/dist/esm/createGui.mjs +20 -51
  95. package/dist/esm/createGui.mjs.map +1 -1
  96. package/dist/esm/createGui.native.js +24 -70
  97. package/dist/esm/createGui.native.js.map +1 -1
  98. package/dist/esm/createVariables.mjs.map +1 -1
  99. package/dist/esm/createVariables.native.js.map +1 -1
  100. package/dist/esm/eventHandling.native.js +19 -9
  101. package/dist/esm/eventHandling.native.js.map +1 -1
  102. package/dist/esm/helpers/createDesignSystem.mjs +22 -36
  103. package/dist/esm/helpers/createDesignSystem.mjs.map +1 -1
  104. package/dist/esm/helpers/createDesignSystem.native.js +18 -90
  105. package/dist/esm/helpers/createDesignSystem.native.js.map +1 -1
  106. package/dist/esm/helpers/defaultAnimationDriver.mjs +1 -1
  107. package/dist/esm/helpers/defaultAnimationDriver.mjs.map +1 -1
  108. package/dist/esm/helpers/defaultAnimationDriver.native.js +1 -1
  109. package/dist/esm/helpers/expandStyle.mjs +12 -73
  110. package/dist/esm/helpers/expandStyle.mjs.map +1 -1
  111. package/dist/esm/helpers/expandStyle.native.js +28 -80
  112. package/dist/esm/helpers/expandStyle.native.js.map +1 -1
  113. package/dist/esm/helpers/expandStyles.mjs +2 -15
  114. package/dist/esm/helpers/expandStyles.mjs.map +1 -1
  115. package/dist/esm/helpers/expandStyles.native.js +7 -13
  116. package/dist/esm/helpers/expandStyles.native.js.map +1 -1
  117. package/dist/esm/helpers/getSplitStyles.mjs +236 -560
  118. package/dist/esm/helpers/getSplitStyles.mjs.map +1 -1
  119. package/dist/esm/helpers/getSplitStyles.native.js +205 -662
  120. package/dist/esm/helpers/getSplitStyles.native.js.map +1 -1
  121. package/dist/esm/helpers/getThemeCSSRules.mjs +8 -16
  122. package/dist/esm/helpers/getThemeCSSRules.mjs.map +1 -1
  123. package/dist/esm/helpers/getTokenForKey.mjs +32 -54
  124. package/dist/esm/helpers/getTokenForKey.mjs.map +1 -1
  125. package/dist/esm/helpers/getTokenForKey.native.js +40 -59
  126. package/dist/esm/helpers/getTokenForKey.native.js.map +1 -1
  127. package/dist/esm/helpers/insertStyleRule.mjs +27 -79
  128. package/dist/esm/helpers/insertStyleRule.mjs.map +1 -1
  129. package/dist/esm/helpers/insertStyleRule.native.js +14 -333
  130. package/dist/esm/helpers/insertStyleRule.native.js.map +1 -1
  131. package/dist/esm/helpers/isActivePlatform.mjs +2 -17
  132. package/dist/esm/helpers/isActivePlatform.mjs.map +1 -1
  133. package/dist/esm/helpers/isActivePlatform.native.js +2 -17
  134. package/dist/esm/helpers/isActivePlatform.native.js.map +1 -1
  135. package/dist/esm/helpers/log.mjs +1 -4
  136. package/dist/esm/helpers/log.mjs.map +1 -1
  137. package/dist/esm/helpers/log.native.js +1 -6
  138. package/dist/esm/helpers/log.native.js.map +1 -1
  139. package/dist/esm/helpers/propMapper.mjs +37 -108
  140. package/dist/esm/helpers/propMapper.mjs.map +1 -1
  141. package/dist/esm/helpers/propMapper.native.js +54 -131
  142. package/dist/esm/helpers/propMapper.native.js.map +1 -1
  143. package/dist/esm/helpers/skipProps.mjs +3 -10
  144. package/dist/esm/helpers/skipProps.mjs.map +1 -1
  145. package/dist/esm/helpers/skipProps.native.js +2 -10
  146. package/dist/esm/helpers/skipProps.native.js.map +1 -1
  147. package/dist/esm/helpers/useRenderElement.mjs +9 -22
  148. package/dist/esm/helpers/useRenderElement.mjs.map +1 -1
  149. package/dist/esm/helpers/useRenderElement.native.js +8 -17
  150. package/dist/esm/helpers/useRenderElement.native.js.map +1 -1
  151. package/dist/esm/helpers/wrapStyleTags.mjs +11 -15
  152. package/dist/esm/helpers/wrapStyleTags.mjs.map +1 -1
  153. package/dist/esm/helpers/wrapStyleTags.native.js +1 -20
  154. package/dist/esm/helpers/wrapStyleTags.native.js.map +1 -1
  155. package/dist/esm/hooks/getThemeProxied.mjs +11 -52
  156. package/dist/esm/hooks/getThemeProxied.mjs.map +1 -1
  157. package/dist/esm/hooks/getThemeProxied.native.js +27 -48
  158. package/dist/esm/hooks/getThemeProxied.native.js.map +1 -1
  159. package/dist/esm/hooks/useTheme.mjs +2 -2
  160. package/dist/esm/hooks/useTheme.mjs.map +1 -1
  161. package/dist/esm/hooks/useTheme.native.js +2 -2
  162. package/dist/esm/hooks/useTheme.native.js.map +1 -1
  163. package/dist/esm/hooks/useThemeState.mjs +67 -124
  164. package/dist/esm/hooks/useThemeState.mjs.map +1 -1
  165. package/dist/esm/hooks/useThemeState.native.js +64 -142
  166. package/dist/esm/hooks/useThemeState.native.js.map +1 -1
  167. package/dist/esm/insertFont.mjs +7 -17
  168. package/dist/esm/insertFont.mjs.map +1 -1
  169. package/dist/esm/insertFont.native.js +7 -24
  170. package/dist/esm/insertFont.native.js.map +1 -1
  171. package/dist/esm/setupReactNative.mjs +4 -24
  172. package/dist/esm/setupReactNative.mjs.map +1 -1
  173. package/dist/esm/setupReactNative.native.js +5 -26
  174. package/dist/esm/setupReactNative.native.js.map +1 -1
  175. package/dist/esm/views/GuiProvider.mjs +4 -6
  176. package/dist/esm/views/GuiProvider.mjs.map +1 -1
  177. package/dist/esm/views/GuiProvider.native.js +5 -7
  178. package/dist/esm/views/GuiProvider.native.js.map +1 -1
  179. package/dist/esm/views/Slot.mjs.map +1 -1
  180. package/dist/esm/views/Text.mjs +11 -18
  181. package/dist/esm/views/Text.mjs.map +1 -1
  182. package/dist/esm/views/Text.native.js +5 -12
  183. package/dist/esm/views/Text.native.js.map +1 -1
  184. package/dist/esm/views/Theme.mjs.map +1 -1
  185. package/dist/esm/views/ThemeProvider.mjs +9 -11
  186. package/dist/esm/views/ThemeProvider.mjs.map +1 -1
  187. package/dist/esm/views/ThemeProvider.native.js +1 -14
  188. package/dist/esm/views/ThemeProvider.native.js.map +1 -1
  189. package/dist/esm/views/View.mjs.map +1 -1
  190. package/dist/esm/views/View.native.js.map +1 -1
  191. package/package.json +34 -22
  192. package/src/_withStableStyle.tsx +2 -2
  193. package/src/config.ts +7 -4
  194. package/src/constants/accessibilityDirectMap.tsx +1 -1
  195. package/src/constants/constants.ts +3 -3
  196. package/src/createComponent.tsx +31 -2
  197. package/src/createGui.ts +2 -2
  198. package/src/eventHandling.native.ts +31 -10
  199. package/src/helpers/createMediaStyle.ts +1 -1
  200. package/src/helpers/defaultAnimationDriver.tsx +1 -1
  201. package/src/helpers/getSplitStyles.tsx +1 -1
  202. package/src/helpers/getTokenForKey.ts +42 -29
  203. package/src/helpers/insertStyleRule.tsx +2 -2
  204. package/src/helpers/isActivePlatform.ts +5 -5
  205. package/src/helpers/mergeProps.ts +1 -1
  206. package/src/helpers/skipProps.ts +1 -1
  207. package/src/helpers/useRenderElement.tsx +4 -1
  208. package/src/hooks/useTheme.tsx +2 -2
  209. package/src/interfaces/GuiComponentPropsBaseBase.tsx +10 -4
  210. package/src/styled.tsx +2 -2
  211. package/src/types.tsx +33 -24
  212. package/src/views/View.tsx +6 -1
  213. package/types/config.d.ts.map +1 -1
  214. package/types/eventHandling.native.d.ts.map +1 -1
  215. package/types/helpers/getTokenForKey.d.ts.map +1 -1
  216. package/types/helpers/isActivePlatform.d.ts +5 -5
  217. package/types/helpers/skipProps.d.ts +1 -1
  218. package/types/helpers/useRenderElement.d.ts.map +1 -1
  219. package/types/helpers/wrapStyleTags.d.ts +1 -1
  220. package/types/helpers/wrapStyleTags.d.ts.map +1 -1
  221. package/types/interfaces/GuiComponentPropsBaseBase.d.ts +3 -3
  222. package/types/interfaces/GuiComponentPropsBaseBase.d.ts.map +1 -1
  223. package/types/styled.d.ts +1 -1
  224. package/types/types.d.ts +17 -17
  225. package/types/types.d.ts.map +1 -1
  226. package/types/views/Configuration.d.ts +1 -1
  227. package/types/views/Configuration.d.ts.map +1 -1
  228. package/types/views/FontLanguage.d.ts +1 -1
  229. package/types/views/FontLanguage.native.d.ts +2 -1
  230. package/types/views/FontLanguage.native.d.ts.map +1 -1
  231. package/types/views/GuiProvider.d.ts +2 -1
  232. package/types/views/GuiProvider.d.ts.map +1 -1
  233. package/types/views/GuiRoot.d.ts +1 -1
  234. package/types/views/GuiRoot.d.ts.map +1 -1
  235. package/types/views/Slot.d.ts +1 -1
  236. package/types/views/ThemeProvider.d.ts +1 -1
  237. package/types/views/ThemeProvider.d.ts.map +1 -1
  238. package/types/views/View.d.ts.map +1 -1
  239. package/.turbo/turbo-build.log +0 -2
  240. package/inject-styles/index.cjs +0 -2
  241. package/inject-styles/index.js +0 -2
  242. package/tsconfig.json +0 -44
  243. package/tsconfig.test.json +0 -9
  244. package/vitest.config.d.ts +0 -3
  245. package/vitest.config.d.ts.map +0 -1
  246. package/vitest.config.ts +0 -14
@@ -1,5 +1,6 @@
1
1
  import { composeRefs } from "@hanzogui/compose-refs";
2
2
  import { isClient, isServer, isWeb, useIsomorphicLayoutEffect } from "@hanzogui/constants";
3
+ import { NativeMenuContext } from "@hanzogui/native";
3
4
  import { composeEventHandlers } from "@hanzogui/helpers";
4
5
  import { isEqualShallow } from "@hanzogui/is-equal-shallow";
5
6
  import React, { useMemo } from "react";
@@ -9,7 +10,7 @@ import { ComponentContext } from "./contexts/ComponentContext.mjs";
9
10
  import { GroupContext } from "./contexts/GroupContext.mjs";
10
11
  import { didGetVariableValue, setDidGetVariableValue } from "./createVariable.mjs";
11
12
  import { defaultComponentStateMounted } from "./defaultComponentState.mjs";
12
- import { getWebEvents } from "./eventHandling.mjs";
13
+ import { getWebEvents, useEvents, wrapWithGestureDetector } from "./eventHandling.mjs";
13
14
  import { getDefaultProps } from "./helpers/getDefaultProps.mjs";
14
15
  import { resolveAnimationDriver } from "./helpers/resolveAnimationDriver.mjs";
15
16
  import { getSplitStyles, useSplitStyles } from "./helpers/getSplitStyles.mjs";
@@ -38,27 +39,23 @@ const avoidReRenderKeys = /* @__PURE__ */new Set(["hover", "press", "pressIn", "
38
39
  if (typeof window !== "undefined") {
39
40
  const cancelPresses = () => {
40
41
  componentSetStates.forEach(setState => setState(prev => {
41
- if (prev.press || prev.pressIn) {
42
- return {
43
- ...prev,
44
- press: false,
45
- pressIn: false
46
- };
47
- }
42
+ if (prev.press || prev.pressIn) return {
43
+ ...prev,
44
+ press: false,
45
+ pressIn: false
46
+ };
48
47
  return prev;
49
48
  }));
50
49
  componentSetStates.clear();
51
50
  };
52
51
  const cancelTouches = () => {
53
52
  componentSetStates.forEach(setState => setState(prev => {
54
- if (prev.press || prev.pressIn || prev.hover) {
55
- return {
56
- ...prev,
57
- press: false,
58
- pressIn: false,
59
- hover: false
60
- };
61
- }
53
+ if (prev.press || prev.pressIn || prev.hover) return {
54
+ ...prev,
55
+ press: false,
56
+ pressIn: false,
57
+ hover: false
58
+ };
62
59
  return prev;
63
60
  }));
64
61
  componentSetStates.clear();
@@ -66,72 +63,66 @@ if (typeof window !== "undefined") {
66
63
  addEventListener("mouseup", cancelPresses);
67
64
  addEventListener("touchend", cancelTouches);
68
65
  addEventListener("touchcancel", cancelTouches);
69
- if (process.env.NODE_ENV === "development") {
70
- startVisualizer = () => {
71
- const devVisualizerConfig = devConfig?.visualizer;
72
- if (devVisualizerConfig && !globalThis.__guiDevVisualizer) {
73
- let show = function (val) {
74
- clearTimeout(tm);
75
- isShowing = val;
76
- debugKeyListeners?.forEach(l => l(val));
77
- if (!val && resizeListener) {
78
- window.removeEventListener("resize", resizeListener);
79
- resizeListener = null;
80
- }
81
- },
82
- cancelShow = function () {
83
- clearTimeout(tm);
84
- if (resizeListener) {
85
- window.removeEventListener("resize", resizeListener);
86
- resizeListener = null;
87
- }
88
- };
89
- globalThis.__guiDevVisualizer = true;
90
- debugKeyListeners = /* @__PURE__ */new Set();
91
- let tm;
92
- let isShowing = false;
93
- let resizeListener = null;
94
- const options = {
95
- key: "Alt",
96
- delay: 800,
97
- ...(typeof devVisualizerConfig === "object" ? devVisualizerConfig : {})
98
- };
99
- window.addEventListener("blur", () => {
100
- show(false);
101
- });
102
- window.addEventListener("keydown", ({
103
- key,
104
- metaKey,
105
- defaultPrevented
106
- }) => {
66
+ if (process.env.NODE_ENV === "development") startVisualizer = () => {
67
+ const devVisualizerConfig = devConfig?.visualizer;
68
+ if (devVisualizerConfig && !globalThis.__guiDevVisualizer) {
69
+ let show = function (val) {
107
70
  clearTimeout(tm);
108
- if (defaultPrevented) return;
109
- if (metaKey) return;
110
- if (key === options.key) {
111
- if (!resizeListener) {
112
- resizeListener = () => cancelShow();
113
- window.addEventListener("resize", resizeListener);
114
- }
115
- tm = setTimeout(() => {
116
- show(true);
117
- }, options.delay);
71
+ isShowing = val;
72
+ debugKeyListeners?.forEach(l => l(val));
73
+ if (!val && resizeListener) {
74
+ window.removeEventListener("resize", resizeListener);
75
+ resizeListener = null;
118
76
  }
119
- });
120
- window.addEventListener("keyup", ({
121
- defaultPrevented
122
- }) => {
123
- if (defaultPrevented) return;
124
- cancelShow();
125
- if (isShowing) {
126
- show(false);
77
+ },
78
+ cancelShow = function () {
79
+ clearTimeout(tm);
80
+ if (resizeListener) {
81
+ window.removeEventListener("resize", resizeListener);
82
+ resizeListener = null;
127
83
  }
128
- });
129
- }
130
- };
131
- }
84
+ };
85
+ globalThis.__guiDevVisualizer = true;
86
+ debugKeyListeners = /* @__PURE__ */new Set();
87
+ let tm;
88
+ let isShowing = false;
89
+ let resizeListener = null;
90
+ const options = {
91
+ key: "Alt",
92
+ delay: 800,
93
+ ...(typeof devVisualizerConfig === "object" ? devVisualizerConfig : {})
94
+ };
95
+ window.addEventListener("blur", () => {
96
+ show(false);
97
+ });
98
+ window.addEventListener("keydown", ({
99
+ key,
100
+ metaKey,
101
+ defaultPrevented
102
+ }) => {
103
+ clearTimeout(tm);
104
+ if (defaultPrevented) return;
105
+ if (metaKey) return;
106
+ if (key === options.key) {
107
+ if (!resizeListener) {
108
+ resizeListener = () => cancelShow();
109
+ window.addEventListener("resize", resizeListener);
110
+ }
111
+ tm = setTimeout(() => {
112
+ show(true);
113
+ }, options.delay);
114
+ }
115
+ });
116
+ window.addEventListener("keyup", ({
117
+ defaultPrevented
118
+ }) => {
119
+ if (defaultPrevented) return;
120
+ cancelShow();
121
+ if (isShowing) show(false);
122
+ });
123
+ }
124
+ };
132
125
  }
133
- let BaseText;
134
- let BaseView;
135
126
  const lastInteractionWasKeyboard = {
136
127
  value: false
137
128
  };
@@ -140,19 +131,13 @@ const lastInteractionWasTouch = {
140
131
  };
141
132
  if (isWeb && typeof document !== "undefined") {
142
133
  document.addEventListener("keydown", () => {
143
- if (!lastInteractionWasKeyboard.value) {
144
- lastInteractionWasKeyboard.value = true;
145
- }
134
+ if (!lastInteractionWasKeyboard.value) lastInteractionWasKeyboard.value = true;
146
135
  });
147
136
  document.addEventListener("mousedown", () => {
148
- if (lastInteractionWasKeyboard.value) {
149
- lastInteractionWasKeyboard.value = false;
150
- }
137
+ if (lastInteractionWasKeyboard.value) lastInteractionWasKeyboard.value = false;
151
138
  });
152
139
  document.addEventListener("mousemove", () => {
153
- if (lastInteractionWasKeyboard.value) {
154
- lastInteractionWasKeyboard.value = false;
155
- }
140
+ if (lastInteractionWasKeyboard.value) lastInteractionWasKeyboard.value = false;
156
141
  lastInteractionWasTouch.value = false;
157
142
  });
158
143
  document.addEventListener("touchstart", () => {
@@ -177,16 +162,6 @@ function createComponent(staticConfig) {
177
162
  startVisualizer = void 0;
178
163
  }
179
164
  }
180
- if (false) {
181
- if (!hasSetupBaseViews) {
182
- hasSetupBaseViews = true;
183
- const baseViews = hooks.getBaseViews?.();
184
- if (baseViews) {
185
- BaseText = baseViews.Text;
186
- BaseView = baseViews.View;
187
- }
188
- }
189
- }
190
165
  if (process.env.NODE_ENV === "test") {
191
166
  if (propsIn["data-test-renders"]) {
192
167
  propsIn["data-test-renders"]["current"] = propsIn["data-test-renders"]["current"] ?? 0;
@@ -202,80 +177,67 @@ function createComponent(staticConfig) {
202
177
  let overriddenContextProps = null;
203
178
  const componentContext = React.useContext(ComponentContext);
204
179
  const hasTextAncestor = !!(isWeb && isText ? componentContext.inText : false);
205
- const isInsideNativeMenu = false ? React.useContext(NativeMenuContext) : false;
206
180
  if (!process.env.GUI_IS_CORE_NODE && process.env.NODE_ENV === "development" && debugProp === "profile" && !time) {
207
- const timer = require("@hanzogui/timer").timer();
208
- time = timer.start();
181
+ time = require("@hanzogui/timer").timer().start();
209
182
  globalThis["time"] = time;
210
183
  }
211
- if (process.env.NODE_ENV === "development" && !time && globalThis.time) {
212
- time = globalThis.time;
213
- }
214
- if (process.env.NODE_ENV === "development" && time) time`non-tamagui time (ignore)`;
184
+ if (process.env.NODE_ENV === "development" && !time && globalThis.time) time = globalThis.time;
185
+ if (process.env.NODE_ENV === "development" && time) time`non-gui time (ignore)`;
215
186
  let props = propsIn;
216
187
  const componentName = props.componentName || staticConfig.componentName;
217
- const defaultProps = getDefaultProps(staticConfig, props.componentName);
218
- const [nextProps, overrides] = mergeComponentProps(defaultProps, styledContextValue, propsIn);
188
+ const [nextProps, overrides] = mergeComponentProps(getDefaultProps(staticConfig, props.componentName), styledContextValue, propsIn);
219
189
  props = nextProps;
220
190
  overriddenContextProps = overrides;
221
- if (process.env.NODE_ENV === "development" && isClient) {
222
- React.useEffect(() => {
223
- let node;
224
- let overlay = null;
225
- const remove = () => {
226
- if (overlay) {
227
- try {
228
- overlay.parentNode?.removeChild(overlay);
229
- overlay = null;
230
- } catch {}
231
- }
232
- };
233
- const debugVisualizerHandler = (show = false) => {
234
- node = stateRef.current.host;
235
- if (!node) return;
236
- if (show) {
237
- if (!overlay) {
238
- overlay = document.createElement("span");
239
- overlay.style.inset = "0px";
240
- overlay.style.zIndex = "1000000";
241
- overlay.style.position = "absolute";
242
- overlay.style.borderColor = "red";
243
- overlay.style.borderWidth = "1px";
244
- overlay.style.borderStyle = "dotted";
245
- }
246
- const dataAt = node.getAttribute("data-at") || "";
247
- const dataIn = node.getAttribute("data-in") || "";
248
- const tooltip = document.createElement("span");
249
- tooltip.style.position = "absolute";
250
- tooltip.style.top = "0px";
251
- tooltip.style.left = "0px";
252
- tooltip.style.padding = "3px";
253
- tooltip.style.background = "rgba(0,0,0,0.75)";
254
- tooltip.style.color = "rgba(255,255,255,1)";
255
- tooltip.style.fontSize = "12px";
256
- tooltip.style.lineHeight = "12px";
257
- tooltip.style.fontFamily = "monospace";
258
- tooltip.innerText = `${componentName || ""} ${dataAt} ${dataIn}`.trim();
259
- overlay.appendChild(tooltip);
260
- node.appendChild(overlay);
261
- } else {
262
- remove();
191
+ if (process.env.NODE_ENV === "development" && isClient) React.useEffect(() => {
192
+ let node;
193
+ let overlay = null;
194
+ const remove = () => {
195
+ if (overlay) try {
196
+ overlay.parentNode?.removeChild(overlay);
197
+ overlay = null;
198
+ } catch {}
199
+ };
200
+ const debugVisualizerHandler = (show = false) => {
201
+ node = stateRef.current.host;
202
+ if (!node) return;
203
+ if (show) {
204
+ if (!overlay) {
205
+ overlay = document.createElement("span");
206
+ overlay.style.inset = "0px";
207
+ overlay.style.zIndex = "1000000";
208
+ overlay.style.position = "absolute";
209
+ overlay.style.borderColor = "red";
210
+ overlay.style.borderWidth = "1px";
211
+ overlay.style.borderStyle = "dotted";
263
212
  }
264
- };
265
- debugKeyListeners = debugKeyListeners || /* @__PURE__ */new Set();
266
- debugKeyListeners.add(debugVisualizerHandler);
267
- return () => {
268
- remove();
269
- debugKeyListeners?.delete(debugVisualizerHandler);
270
- };
271
- }, [componentName]);
272
- }
213
+ const dataAt = node.getAttribute("data-at") || "";
214
+ const dataIn = node.getAttribute("data-in") || "";
215
+ const tooltip = document.createElement("span");
216
+ tooltip.style.position = "absolute";
217
+ tooltip.style.top = "0px";
218
+ tooltip.style.left = "0px";
219
+ tooltip.style.padding = "3px";
220
+ tooltip.style.background = "rgba(0,0,0,0.75)";
221
+ tooltip.style.color = "rgba(255,255,255,1)";
222
+ tooltip.style.fontSize = "12px";
223
+ tooltip.style.lineHeight = "12px";
224
+ tooltip.style.fontFamily = "monospace";
225
+ tooltip.innerText = `${componentName || ""} ${dataAt} ${dataIn}`.trim();
226
+ overlay.appendChild(tooltip);
227
+ node.appendChild(overlay);
228
+ } else remove();
229
+ };
230
+ debugKeyListeners = debugKeyListeners || /* @__PURE__ */new Set();
231
+ debugKeyListeners.add(debugVisualizerHandler);
232
+ return () => {
233
+ remove();
234
+ debugKeyListeners?.delete(debugVisualizerHandler);
235
+ };
236
+ }, [componentName]);
273
237
  const groupContextParent = React.useContext(GroupContext);
274
238
  const animationDriver = (() => {
275
239
  if (props.animatedBy && config) {
276
- if (config.animationDrivers) {
277
- return config.animationDrivers[props.animatedBy] ?? config.animations;
278
- }
240
+ if (config.animationDrivers) return config.animationDrivers[props.animatedBy] ?? config.animations;
279
241
  return props.animatedBy === "default" ? config.animations : null;
280
242
  }
281
243
  return resolveAnimationDriver(componentContext.animationDriver) ?? resolveAnimationDriver(config?.animations) ?? null;
@@ -302,19 +264,15 @@ function createComponent(staticConfig) {
302
264
  willBeAnimatedClient,
303
265
  startedUnhydrated
304
266
  } = componentState;
305
- if (hasAnimationProp && animationDriver?.avoidReRenders) {
306
- useIsomorphicLayoutEffect(() => {
307
- const pendingState = stateRef.current.nextState;
308
- if (pendingState) {
309
- stateRef.current.nextState = void 0;
310
- componentState.setStateShallow(pendingState);
311
- }
312
- });
313
- }
314
- const allGroupContexts = useMemo(() => {
315
- if (!groupName || props.passThrough) {
316
- return groupContextParent;
267
+ if (hasAnimationProp && animationDriver?.avoidReRenders) useIsomorphicLayoutEffect(() => {
268
+ const pendingState = stateRef.current.nextState;
269
+ if (pendingState) {
270
+ stateRef.current.nextState = void 0;
271
+ componentState.setStateShallow(pendingState);
317
272
  }
273
+ });
274
+ const allGroupContexts = useMemo(() => {
275
+ if (!groupName || props.passThrough) return groupContextParent;
318
276
  const listeners = /* @__PURE__ */new Set();
319
277
  stateRef.current.group?.listeners?.clear();
320
278
  stateRef.current.group = {
@@ -324,18 +282,14 @@ function createComponent(staticConfig) {
324
282
  },
325
283
  subscribe(cb) {
326
284
  listeners.add(cb);
327
- if (listeners.size === 1) {
328
- setStateShallow({
329
- hasDynGroupChildren: true
330
- });
331
- }
285
+ if (listeners.size === 1) setStateShallow({
286
+ hasDynGroupChildren: true
287
+ });
332
288
  return () => {
333
289
  listeners.delete(cb);
334
- if (listeners.size === 0) {
335
- setStateShallow({
336
- hasDynGroupChildren: false
337
- });
338
- }
290
+ if (listeners.size === 0) setStateShallow({
291
+ hasDynGroupChildren: false
292
+ });
339
293
  };
340
294
  }
341
295
  };
@@ -357,18 +311,11 @@ function createComponent(staticConfig) {
357
311
  let setStateShallow = componentState.setStateShallow;
358
312
  if (process.env.NODE_ENV === "development" && time) time`use-state`;
359
313
  const renderProp = props.render;
360
- const isRenderString = !Component || typeof Component === "string";
361
- const element = isWeb ? isRenderString ? renderProp || Component : Component : Component;
362
- const BaseTextComponent = BaseText || element || "span";
363
- const BaseViewComponent = BaseView || element || (hasTextAncestor ? "span" : "div");
364
- const BaseComponent = isText ? BaseTextComponent : BaseViewComponent;
314
+ const element = isWeb ? !Component || typeof Component === "string" ? renderProp || Component : Component : Component;
315
+ const BaseComponent = isText ? element || "span" : element || (hasTextAncestor ? "span" : "div");
365
316
  let elementType = BaseComponent;
366
- const isAnimatedCustomComponent = animationDriver && isAnimated && animationDriver.needsCustomComponent;
367
- if (isAnimatedCustomComponent) {
368
- elementType = animationDriver[isText ? "Text" : "View"] || elementType;
369
- }
370
- const disableThemeProp = false ? false : props["data-disable-theme"];
371
- const disableTheme = disableThemeProp || isHOC;
317
+ if (animationDriver && isAnimated && animationDriver.needsCustomComponent) elementType = animationDriver[isText ? "Text" : "View"] || elementType;
318
+ const disableTheme = props["data-disable-theme"] || isHOC;
372
319
  if (process.env.NODE_ENV === "development" && time) time`theme-props`;
373
320
  const themeStateProps = {
374
321
  componentName,
@@ -377,13 +324,8 @@ function createComponent(staticConfig) {
377
324
  debug: debugProp,
378
325
  unstyled: props.unstyled
379
326
  };
380
- if ("theme" in props) {
381
- themeStateProps.name = props.theme;
382
- }
327
+ if ("theme" in props) themeStateProps.name = props.theme;
383
328
  themeStateProps.needsUpdate = () => !!stateRef.current.isListeningToTheme;
384
- if (false) {
385
- themeStateProps.deopt = willBeAnimated;
386
- }
387
329
  if (process.env.NODE_ENV === "development") {
388
330
  if (debugProp && debugProp !== "profile") {
389
331
  const name = `${componentName || Component?.displayName || Component?.name || "[Unnamed Component]"}`;
@@ -392,19 +334,15 @@ function createComponent(staticConfig) {
392
334
  const banner = `<${name} /> ${internalID} ${dataIs ? ` ${dataIs}` : ""} ${type.trim()} (hydrated: ${isHydrated}) (unmounted: ${state.unmounted})`;
393
335
  const ch = propsIn.children;
394
336
  let childLog = typeof ch === "string" ? ch.length > 4 ? ch.slice(0, 4) + "..." : ch : "";
395
- if (childLog.length) {
396
- childLog = `(children: ${childLog})`;
397
- }
337
+ if (childLog.length) childLog = `(children: ${childLog})`;
398
338
  if (isWeb) {
399
339
  console.info(`%c ${banner}`, "background: green; color: white;");
400
- if (isServer) {
401
- log({
402
- noClass,
403
- isAnimated,
404
- isWeb,
405
- inputStyle
406
- });
407
- } else {
340
+ if (isServer) log({
341
+ noClass,
342
+ isAnimated,
343
+ isWeb,
344
+ inputStyle
345
+ });else {
408
346
  console.groupEnd();
409
347
  console.groupCollapsed(`${childLog} [inspect props, state, context \u{1F447}]`);
410
348
  log("props in:", propsIn);
@@ -458,13 +396,10 @@ ${banner}
458
396
  const mediaState = useMedia(componentContext, debugProp);
459
397
  setDidGetVariableValue(false);
460
398
  if (process.env.NODE_ENV === "development" && time) time`media`;
461
- const resolveValues =
462
- // if HOC + mounted + has animation prop, resolve as value so it passes non-variable to child
463
- isAnimated && inputStyle !== "css" || isHOC && state.unmounted == false && hasAnimationProp ? "value" : "auto";
464
399
  const styleProps = {
465
400
  mediaState,
466
401
  noClass,
467
- resolveValues,
402
+ resolveValues: isAnimated && inputStyle !== "css" || isHOC && state.unmounted == false && hasAnimationProp ? "value" : "auto",
468
403
  isExiting,
469
404
  isAnimated,
470
405
  willBeAnimated,
@@ -482,23 +417,17 @@ ${banner}
482
417
  overriddenContextProps = overriddenContextProps || {};
483
418
  overriddenContextProps[key] = splitStyles.overriddenContextProps[key];
484
419
  }
485
- if (!staticConfig.context) {
486
- contextForOverride = contextForProps;
487
- }
420
+ if (!staticConfig.context) contextForOverride = contextForProps;
488
421
  }
489
422
  }
490
423
  const groupContext = groupName ? allGroupContexts?.[groupName] || null : null;
491
- if (!isPassthrough && groupContext &&
492
- // avoids onLayout if we don't need it
493
- props.containerType !== "normal") {
424
+ if (!isPassthrough && groupContext && props.containerType !== "normal") {
494
425
  const groupState = groupContext?.state;
495
426
  if (groupState && groupState.layout === void 0) {
496
- if (splitStyles.style?.width || splitStyles.style?.height) {
497
- groupState.layout = {
498
- width: fromPx(splitStyles.style.width),
499
- height: fromPx(splitStyles.style.height)
500
- };
501
- }
427
+ if (splitStyles.style?.width || splitStyles.style?.height) groupState.layout = {
428
+ width: fromPx(splitStyles.style.width),
429
+ height: fromPx(splitStyles.style.height)
430
+ };
502
431
  }
503
432
  }
504
433
  const hasEnterExitTransition = props.transition && typeof props.transition === "object" && !Array.isArray(props.transition) && ("enter" in props.transition || "exit" in props.transition);
@@ -549,16 +478,12 @@ ${banner}
549
478
  };
550
479
  }
551
480
  componentContext.mediaEmit = componentContext.mediaEmit || (next => {
552
- for (const listener of componentContext.mediaEmitListeners) {
553
- listener(next);
554
- }
481
+ for (const listener of componentContext.mediaEmitListeners) listener(next);
555
482
  });
556
483
  stateRef.current.setStateShallow = nextOrGetNext => {
557
484
  const prev = stateRef.current.nextState || state;
558
485
  const next = typeof nextOrGetNext === "function" ? nextOrGetNext(prev) : nextOrGetNext;
559
- if (next === prev || isEqualShallow(prev, next)) {
560
- return;
561
- }
486
+ if (next === prev || isEqualShallow(prev, next)) return;
562
487
  const canAvoidReRender = Object.keys(next).every(key => avoidReRenderKeys.has(key));
563
488
  const updatedState = {
564
489
  ...prev,
@@ -577,12 +502,10 @@ ${banner}
577
502
  updateGroupListeners();
578
503
  stateRef.current.updateStyleListener?.();
579
504
  } else {
580
- if (process.env.NODE_ENV === "development" && debugProp && debugProp !== "profile") {
581
- console.info(`[\u{1F40C}] re-render`, {
582
- canAvoidReRender,
583
- next
584
- });
585
- }
505
+ if (process.env.NODE_ENV === "development" && debugProp && debugProp !== "profile") console.info(`[\u{1F40C}] re-render`, {
506
+ canAvoidReRender,
507
+ next
508
+ });
586
509
  ogSetStateShallow(next);
587
510
  }
588
511
  };
@@ -596,16 +519,12 @@ ${banner}
596
519
  splitStyles.style = splitStyles.style || {};
597
520
  splitStyles.style.opacity = 0;
598
521
  }
599
- if (splitStyles.dynamicThemeAccess != null) {
600
- stateRef.current.isListeningToTheme = splitStyles.dynamicThemeAccess;
601
- }
522
+ if (splitStyles.dynamicThemeAccess != null) stateRef.current.isListeningToTheme = splitStyles.dynamicThemeAccess;
602
523
  }
603
524
  const hasRuntimeMediaKeys = splitStyles?.hasMedia && splitStyles.hasMedia !== true;
604
525
  const shouldListenForMedia = didGetVariableValue() || hasRuntimeMediaKeys || noClass && splitStyles?.hasMedia === true;
605
526
  const mediaListeningKeys = hasRuntimeMediaKeys ? splitStyles.hasMedia : null;
606
- if (process.env.NODE_ENV === "development" && debugProp === "verbose") {
607
- console.info(`useMedia() createComponent`, shouldListenForMedia, mediaListeningKeys);
608
- }
527
+ if (process.env.NODE_ENV === "development" && debugProp === "verbose") console.info(`useMedia() createComponent`, shouldListenForMedia, mediaListeningKeys);
609
528
  setMediaShouldUpdate(componentContext, shouldListenForMedia, mediaListeningKeys);
610
529
  const {
611
530
  viewProps: viewPropsIn,
@@ -634,48 +553,33 @@ ${banner}
634
553
  onFocus,
635
554
  onBlur,
636
555
  separator,
637
- // ignore from here on out
638
556
  passThrough,
639
557
  forceStyle: _forceStyle,
640
- // @ts-ignore for next/link compat etc
641
558
  onClick,
642
559
  theme: _themeProp,
643
560
  ...nonGuiProps
644
561
  } = viewPropsIn || {};
645
562
  let viewProps = nonGuiProps;
646
- if (props.forceStyle) {
647
- viewProps.forceStyle = props.forceStyle;
648
- }
563
+ if (props.forceStyle) viewProps.forceStyle = props.forceStyle;
649
564
  if (isHOC) {
650
- if (typeof _themeProp !== "undefined") {
651
- viewProps.theme = _themeProp;
652
- }
653
- if (typeof passThrough !== "undefined") {
654
- viewProps.passThrough = passThrough;
655
- }
565
+ if (typeof _themeProp !== "undefined") viewProps.theme = _themeProp;
566
+ if (typeof passThrough !== "undefined") viewProps.passThrough = passThrough;
656
567
  }
657
568
  let animationStyles;
658
- const shouldUseAnimation =
659
- // if it supports css vars we run it on server too to get matching initial style
660
- (inputStyle === "css" ? willBeAnimatedClient : willBeAnimated) && useAnimations && !isHOC;
569
+ const shouldUseAnimation = (inputStyle === "css" ? willBeAnimatedClient : willBeAnimated) && useAnimations && !isHOC;
661
570
  let animatedRef;
662
571
  if (shouldUseAnimation) {
663
572
  const useStyleEmitter = animationDriver?.avoidReRenders ? listener => {
664
573
  stateRef.current.useStyleListener = listener;
665
574
  } : void 0;
666
575
  const effectiveTransition = resolveEffectivePseudoTransition(stateRef.current.prevPseudoState, state, splitStyles?.pseudoTransitions, props.transition);
667
- if (splitStyles) {
668
- splitStyles.effectiveTransition = effectiveTransition;
669
- }
576
+ if (splitStyles) splitStyles.effectiveTransition = effectiveTransition;
670
577
  stateRef.current.prevPseudoState = extractPseudoState(state);
671
578
  const animations = useAnimations({
672
579
  props: propsWithAnimation,
673
- // clone style to prevent animation driver mutations from leaking to viewProps
674
- // during SSR/pre-hydration (CSS driver mutates style.transition in place)
675
580
  style: isHydrated ? splitStylesStyle || {} : {
676
581
  ...splitStylesStyle
677
582
  },
678
- // @ts-ignore
679
583
  styleState: splitStyles,
680
584
  useStyleEmitter,
681
585
  presence,
@@ -688,56 +592,38 @@ ${banner}
688
592
  stateRef
689
593
  });
690
594
  if (animations) {
691
- if (animations.ref) {
692
- animatedRef = animations.ref;
693
- }
595
+ if (animations.ref) animatedRef = animations.ref;
694
596
  if (isHydrated && animations) {
695
597
  animationStyles = animations.style;
696
598
  viewProps.style = animationStyles;
697
- if (animations.className) {
698
- viewProps.className = `${state.unmounted === "should-enter" ? "t_unmounted " : ""}${viewProps.className || ""} ${animations.className}`;
699
- }
599
+ if (animations.className) viewProps.className = `${state.unmounted === "should-enter" ? "t_unmounted " : ""}${viewProps.className || ""} ${animations.className}`;
700
600
  }
701
601
  }
702
602
  if (process.env.NODE_ENV === "development" && time) time`animations`;
703
603
  }
704
- if (process.env.NODE_ENV === "development" && props.untilMeasured && !props.group) {
705
- console.warn(`You set the untilMeasured prop without setting group. This doesn't work, be sure to set untilMeasured on the parent that sets group, not the children that use the $group- prop.
604
+ if (process.env.NODE_ENV === "development" && props.untilMeasured && !props.group) console.warn(`You set the untilMeasured prop without setting group. This doesn't work, be sure to set untilMeasured on the parent that sets group, not the children that use the $group- prop.
706
605
 
707
606
  If you meant to do this, you can disable this warning - either change untilMeasured and group at the same time, or do group={conditional ? 'name' : undefined}`);
708
- }
709
607
  if (process.env.NODE_ENV === "development" && time) time`destructure`;
710
- if (!isPassthrough && groupContext &&
711
- // avoids onLayout if we don't need it
712
- props.containerType !== "normal") {
713
- nonGuiProps.onLayout = composeEventHandlers(nonGuiProps.onLayout, e => {
714
- const layout = e.nativeEvent.layout;
715
- groupContext.state.layout = layout;
716
- stateRef.current.group?.emit({
717
- layout
718
- });
719
- if (!stateRef.current.hasMeasured && props.untilMeasured === "hide") {
720
- setState(prev => ({
721
- ...prev
722
- }));
723
- }
724
- stateRef.current.hasMeasured = true;
608
+ if (!isPassthrough && groupContext && props.containerType !== "normal") nonGuiProps.onLayout = composeEventHandlers(nonGuiProps.onLayout, e => {
609
+ const layout = e.nativeEvent.layout;
610
+ groupContext.state.layout = layout;
611
+ stateRef.current.group?.emit({
612
+ layout
725
613
  });
726
- }
614
+ if (!stateRef.current.hasMeasured && props.untilMeasured === "hide") setState(prev => ({
615
+ ...prev
616
+ }));
617
+ stateRef.current.hasMeasured = true;
618
+ });
727
619
  viewProps = hooks.usePropsTransform?.(elementType, nonGuiProps, stateRef, stateRef.current.willHydrate) || nonGuiProps;
728
- if (!stateRef.current.composedRef) {
729
- stateRef.current.composedRef = composeRefs(x => stateRef.current.host = x, forwardedRef, setElementProps, animatedRef);
730
- }
620
+ if (!stateRef.current.composedRef) stateRef.current.composedRef = composeRefs(x => stateRef.current.host = x, forwardedRef, setElementProps, animatedRef);
731
621
  viewProps.ref = stateRef.current.composedRef;
732
622
  usePointerEvents(props, viewProps);
733
623
  if (process.env.NODE_ENV === "development") {
734
- if (!isReactNative && !isText && isWeb && !isHOC) {
735
- React.Children.toArray(props.children).forEach(item => {
736
- if (typeof item === "string" && item !== "\n") {
737
- console.error(`Unexpected text node: ${item}. A text node cannot be a child of a <${staticConfig.componentName || propsIn.tag || "View"}>.`, props);
738
- }
739
- });
740
- }
624
+ if (!isReactNative && !isText && isWeb && !isHOC) React.Children.toArray(props.children).forEach(item => {
625
+ if (typeof item === "string" && item !== "\n") console.error(`Unexpected text node: ${item}. A text node cannot be a child of a <${staticConfig.componentName || propsIn.tag || "View"}>.`, props);
626
+ });
741
627
  }
742
628
  if (process.env.NODE_ENV === "development" && time) time`events-hooks`;
743
629
  const unPress = () => {
@@ -746,25 +632,23 @@ If you meant to do this, you can disable this warning - either change untilMeasu
746
632
  pressIn: false
747
633
  });
748
634
  };
749
- if (process.env.NODE_ENV === "development" && isWeb) {
750
- useIsomorphicLayoutEffect(() => {
751
- if (debugProp === "verbose") {
752
- let cssStyleDeclarationToObject = function (style) {
753
- const styleObject = {};
754
- for (let i = 0; i < style.length; i++) {
755
- let prop = style[i];
756
- styleObject[prop] = style.getPropertyValue(prop);
757
- }
758
- return styleObject;
759
- };
760
- const computed = stateRef.current.host ? cssStyleDeclarationToObject(getComputedStyle(stateRef.current.host)) : {};
761
- console.groupCollapsed(`Rendered > (opacity: ${computed.opacity})`);
762
- console.warn(stateRef.current.host);
763
- console.warn(computed);
764
- console.groupEnd();
765
- }
766
- });
767
- }
635
+ if (process.env.NODE_ENV === "development" && isWeb) useIsomorphicLayoutEffect(() => {
636
+ if (debugProp === "verbose") {
637
+ let cssStyleDeclarationToObject = function (style) {
638
+ const styleObject = {};
639
+ for (let i = 0; i < style.length; i++) {
640
+ let prop = style[i];
641
+ styleObject[prop] = style.getPropertyValue(prop);
642
+ }
643
+ return styleObject;
644
+ };
645
+ const computed = stateRef.current.host ? cssStyleDeclarationToObject(getComputedStyle(stateRef.current.host)) : {};
646
+ console.groupCollapsed(`Rendered > (opacity: ${computed.opacity})`);
647
+ console.warn(stateRef.current.host);
648
+ console.warn(computed);
649
+ console.groupEnd();
650
+ }
651
+ });
768
652
  useIsomorphicLayoutEffect(() => {
769
653
  if (state.unmounted === true && hasEnterStyle) {
770
654
  setStateShallow({
@@ -825,20 +709,18 @@ If you meant to do this, you can disable this warning - either change untilMeasu
825
709
  const shouldAttach = !disabled && !props.asChild && Boolean(attachFocus || attachPress || attachHover || runtimePressStyle || runtimeHoverStyle || runtimeFocusStyle);
826
710
  const needsPressState = Boolean(hasDynamicGroupChildren || runtimePressStyle);
827
711
  if (process.env.NODE_ENV === "development" && time) time`events-setup`;
828
- if (process.env.NODE_ENV === "development" && debugProp === "verbose") {
829
- log(`\u{1FAA9} events()`, {
830
- runtimeFocusStyle,
831
- runtimePressStyle,
832
- runtimeHoverStyle,
833
- runtimeFocusVisibleStyle,
834
- attachPress,
835
- attachFocus,
836
- attachHover,
837
- shouldAttach,
838
- needsHoverState,
839
- pseudos
840
- });
841
- }
712
+ if (process.env.NODE_ENV === "development" && debugProp === "verbose") log(`\u{1FAA9} events()`, {
713
+ runtimeFocusStyle,
714
+ runtimePressStyle,
715
+ runtimeHoverStyle,
716
+ runtimeFocusVisibleStyle,
717
+ attachPress,
718
+ attachFocus,
719
+ attachHover,
720
+ shouldAttach,
721
+ needsHoverState,
722
+ pseudos
723
+ });
842
724
  const events = shouldAttach ? {
843
725
  onPressOut: attachPress ? e => {
844
726
  unPress();
@@ -848,13 +730,9 @@ If you meant to do this, you can disable this warning - either change untilMeasu
848
730
  ...((attachHover || attachPress) && {
849
731
  onMouseEnter: e => {
850
732
  const next = {};
851
- if (needsHoverState && !lastInteractionWasTouch.value) {
852
- next.hover = true;
853
- }
733
+ if (needsHoverState && !lastInteractionWasTouch.value) next.hover = true;
854
734
  if (needsPressState) {
855
- if (state.pressIn) {
856
- next.press = true;
857
- }
735
+ if (state.pressIn) next.press = true;
858
736
  }
859
737
  setStateShallow(next);
860
738
  onHoverIn?.(e);
@@ -862,9 +740,7 @@ If you meant to do this, you can disable this warning - either change untilMeasu
862
740
  },
863
741
  onMouseLeave: e => {
864
742
  const next = {};
865
- if (needsHoverState) {
866
- next.hover = false;
867
- }
743
+ if (needsHoverState) next.hover = false;
868
744
  if (needsPressState) {
869
745
  next.press = false;
870
746
  next.pressIn = false;
@@ -875,32 +751,21 @@ If you meant to do this, you can disable this warning - either change untilMeasu
875
751
  }
876
752
  }),
877
753
  onPressIn: attachPress ? e => {
878
- if (needsPressState) {
879
- setStateShallow({
880
- press: true,
881
- pressIn: true
882
- });
883
- }
754
+ if (needsPressState) setStateShallow({
755
+ press: true,
756
+ pressIn: true
757
+ });
884
758
  onPressIn?.(e);
885
759
  onMouseDown?.(e);
886
- if (isWeb) {
887
- componentSetStates.add(setState);
888
- }
760
+ if (isWeb) componentSetStates.add(setState);
889
761
  } : void 0,
890
762
  onPress: attachPress ? e => {
891
763
  unPress();
892
- if (true) {
893
- onClick?.(e);
894
- if (onPress || onClick) {
895
- e.stopPropagation();
896
- }
897
- }
764
+ onClick?.(e);
765
+ if (onPress || onClick) e.stopPropagation();
898
766
  onPress?.(e);
899
- if (true) {
900
- onLongPress?.(e);
901
- }
767
+ onLongPress?.(e);
902
768
  } : void 0,
903
- ...false,
904
769
  ...(attachFocus && {
905
770
  onFocus: e => {
906
771
  const next = {};
@@ -911,23 +776,15 @@ If you meant to do this, you can disable this warning - either change untilMeasu
911
776
  next.focusWithin = true;
912
777
  }
913
778
  if (pseudos?.focusVisibleStyle) {
914
- if (lastInteractionWasKeyboard.value) {
915
- next.focusVisible = true;
916
- } else {
917
- next.focus = true;
918
- }
919
- } else {
920
- next.focus = true;
921
- }
779
+ if (lastInteractionWasKeyboard.value) next.focusVisible = true;else next.focus = true;
780
+ } else next.focus = true;
922
781
  setStateShallow(next);
923
782
  onFocus?.(e);
924
783
  },
925
784
  onBlur: e => {
926
- if (componentContext.setParentFocusState) {
927
- componentContext.setParentFocusState({
928
- focusWithin: false
929
- });
930
- }
785
+ if (componentContext.setParentFocusState) componentContext.setParentFocusState({
786
+ focusWithin: false
787
+ });
931
788
  setStateShallow({
932
789
  focus: false,
933
790
  focusVisible: false,
@@ -937,39 +794,20 @@ If you meant to do this, you can disable this warning - either change untilMeasu
937
794
  }
938
795
  })
939
796
  } : null;
940
- if (false) {
941
- Object.assign(events, {
942
- cancelable: !viewProps.rejectResponderTermination,
943
- disabled,
944
- hitSlop: viewProps.hitSlop,
945
- delayLongPress: viewProps.delayLongPress,
946
- delayPressIn: viewProps.delayPressIn,
947
- delayPressOut: viewProps.delayPressOut,
948
- focusable: viewProps.focusable ?? true,
949
- minPressDuration: 0
950
- });
951
- }
952
- if (events && !isReactNative) {
953
- Object.assign(viewProps, getWebEvents(events));
954
- }
797
+ if (events && !isReactNative) Object.assign(viewProps, getWebEvents(events));
955
798
  if (process.env.NODE_ENV === "development" && time) time`events`;
956
- if (process.env.NODE_ENV === "development" && debugProp === "verbose") {
957
- log(`events`, {
958
- events,
959
- attachHover,
960
- attachPress
961
- });
962
- }
799
+ if (process.env.NODE_ENV === "development" && debugProp === "verbose") log(`events`, {
800
+ events,
801
+ attachHover,
802
+ attachPress
803
+ });
963
804
  const propsWithHref = props;
964
805
  const propsInWithHref = propsIn;
965
- const pressDebugDetail = props.testID ?? propsIn.testID ?? props.accessibilityLabel ?? propsIn.accessibilityLabel ?? (typeof propsWithHref.href === "string" ? propsWithHref.href : null) ?? (typeof propsInWithHref.href === "string" ? propsInWithHref.href : null);
966
- const pressDebugName = [componentName, pressDebugDetail].filter(Boolean).join(":") || null;
967
- const pressGesture = false ? useEvents(events, viewProps, stateRef, staticConfig, isHOC, isInsideNativeMenu, pressDebugName) : null;
806
+ [componentName, props.testID ?? propsIn.testID ?? props.accessibilityLabel ?? propsIn.accessibilityLabel ?? (typeof propsWithHref.href === "string" ? propsWithHref.href : null) ?? (typeof propsInWithHref.href === "string" ? propsInWithHref.href : null)].filter(Boolean).join(":");
968
807
  if (process.env.NODE_ENV === "development" && time) time`hooks`;
969
808
  if (asChild) {
970
809
  elementType = Slot;
971
- if (true) {
972
- const webStyleEvents = asChild === "web" || asChild === "except-style-web";
810
+ {
973
811
  const passEvents = getWebEvents({
974
812
  onPress,
975
813
  onLongPress,
@@ -979,27 +817,18 @@ If you meant to do this, you can disable this warning - either change untilMeasu
979
817
  onMouseDown,
980
818
  onMouseEnter,
981
819
  onMouseLeave
982
- }, webStyleEvents);
820
+ }, asChild === "web" || asChild === "except-style-web");
983
821
  Object.assign(viewProps, passEvents);
984
- } else {
985
- Object.assign(viewProps, {
986
- onPress,
987
- onLongPress
988
- });
989
822
  }
990
823
  }
991
824
  if (process.env.NODE_ENV === "development" && time) time`spaced-as-child`;
992
825
  let content;
993
- if (isPassthrough) {
994
- content = React.createElement(BaseComponent, {
995
- style: {
996
- display: "contents"
997
- }
998
- }, propsIn.children);
999
- } else {
1000
- if (hooks.useChildren) {
1001
- content = hooks.useChildren(elementType, content || children, viewProps);
826
+ if (isPassthrough) content = React.createElement(BaseComponent, {
827
+ style: {
828
+ display: "contents"
1002
829
  }
830
+ }, propsIn.children);else {
831
+ if (hooks.useChildren) content = hooks.useChildren(elementType, content || children, viewProps);
1003
832
  const isRenderPropString = typeof renderProp === "string";
1004
833
  if (renderProp && !isRenderPropString) {
1005
834
  const out = getCustomRender(renderProp, content || children, viewProps, componentState);
@@ -1009,76 +838,47 @@ If you meant to do this, you can disable this warning - either change untilMeasu
1009
838
  }
1010
839
  }
1011
840
  if (!content) {
1012
- if (isRenderPropString) {
1013
- viewProps.render === renderProp;
1014
- }
841
+ if (isRenderPropString) viewProps.render;
1015
842
  content = React.createElement(elementType, viewProps, content || children);
1016
843
  }
1017
844
  if (process.env.NODE_ENV === "development" && time) time`use-children`;
1018
845
  }
1019
- if (false) {
1020
- const isCompositeComponent = !isHOC && Component && typeof Component !== "string";
1021
- content = wrapWithGestureDetector(content, pressGesture, stateRef, isHOC, isCompositeComponent);
1022
- }
1023
846
  const ResetPresence = animationDriver?.ResetPresence;
1024
847
  const needsReset = Boolean(
1025
848
  // not when passing down to child
1026
- !asChild &&
1027
- // not when passThrough
1028
- splitStyles &&
1029
- // not when HOC
1030
- !isHOC && ResetPresence && willBeAnimated && (hasEnterStyle || presenceState));
849
+ !asChild && splitStyles && !isHOC && ResetPresence && willBeAnimated && (hasEnterStyle || presenceState));
1031
850
  const hasEverReset = stateRef.current.hasEverResetPresence;
1032
- if (needsReset && !hasEverReset) {
1033
- stateRef.current.hasEverResetPresence = true;
1034
- }
1035
- const renderReset = needsReset || hasEverReset;
1036
- if (renderReset && ResetPresence) {
1037
- content = /* @__PURE__ */jsx(ResetPresence, {
1038
- disabled: !needsReset,
1039
- children: content
1040
- });
1041
- }
851
+ if (needsReset && !hasEverReset) stateRef.current.hasEverResetPresence = true;
852
+ if ((needsReset || hasEverReset) && ResetPresence) content = /* @__PURE__ */jsx(ResetPresence, {
853
+ disabled: !needsReset,
854
+ children: content
855
+ });
1042
856
  if (process.env.NODE_ENV === "development" && time) time`create-element`;
1043
- if ("focusWithinStyle" in propsIn || pseudos?.focusWithinStyle) {
1044
- content = /* @__PURE__ */jsx(ComponentContext.Provider, {
1045
- ...componentContext,
1046
- setParentFocusState: setStateShallow,
1047
- children: content
1048
- });
1049
- }
1050
- if ("group" in props) {
1051
- content = /* @__PURE__ */jsx(GroupContext.Provider, {
1052
- value: allGroupContexts,
1053
- children: content
1054
- });
1055
- }
1056
- if (!asChild && isText && !hasTextAncestor) {
1057
- content = /* @__PURE__ */jsx(ComponentContext.Provider, {
1058
- ...componentContext,
1059
- inText: true,
1060
- children: content
1061
- });
1062
- }
857
+ if ("focusWithinStyle" in propsIn || pseudos?.focusWithinStyle) content = /* @__PURE__ */jsx(ComponentContext.Provider, {
858
+ ...componentContext,
859
+ setParentFocusState: setStateShallow,
860
+ children: content
861
+ });
862
+ if ("group" in props) content = /* @__PURE__ */jsx(GroupContext.Provider, {
863
+ value: allGroupContexts,
864
+ children: content
865
+ });
866
+ if (!asChild && isText && !hasTextAncestor) content = /* @__PURE__ */jsx(ComponentContext.Provider, {
867
+ ...componentContext,
868
+ inText: true,
869
+ children: content
870
+ });
1063
871
  if (process.env.NODE_ENV === "development" && time) time`group-context`;
1064
872
  content = disableTheme || !splitStyles ? content : getThemedChildren(themeState, content, themeStateProps, false, stateRef);
1065
873
  if (process.env.NODE_ENV === "development" && time) time`themed-children`;
1066
- if (true) {
1067
- if (isReactNative && !asChild) {
1068
- content = /* @__PURE__ */jsx("span", {
1069
- className: "_dsp_contents",
1070
- ...(!isPassthrough && isHydrated && events && getWebEvents(events)),
1071
- children: content
1072
- });
1073
- }
1074
- }
874
+ if (isReactNative && !asChild) content = /* @__PURE__ */jsx("span", {
875
+ className: "_dsp_contents",
876
+ ...(!isPassthrough && isHydrated && events && getWebEvents(events)),
877
+ children: content
878
+ });
1075
879
  if (overriddenContextProps && contextForOverride) {
1076
880
  const Provider = contextForOverride.Provider;
1077
- for (const key in styledContextValue) {
1078
- if (!(key in overriddenContextProps)) {
1079
- overriddenContextProps[key] = styledContextValue[key];
1080
- }
1081
- }
881
+ for (const key in styledContextValue) if (!(key in overriddenContextProps)) overriddenContextProps[key] = styledContextValue[key];
1082
882
  content = /* @__PURE__ */jsx(Provider, {
1083
883
  __disableMergeDefaultValues: true,
1084
884
  ...overriddenContextProps,
@@ -1086,61 +886,52 @@ If you meant to do this, you can disable this warning - either change untilMeasu
1086
886
  });
1087
887
  }
1088
888
  if (process.env.NODE_ENV === "development" && time) time`context-override`;
1089
- if (startedUnhydrated && splitStyles) {
1090
- content = /* @__PURE__ */jsxs(Fragment, {
1091
- children: [content, !isHydrated ? getStyleTags(Object.values(splitStyles.rulesToInsert)) : null]
1092
- });
1093
- }
889
+ if (startedUnhydrated && splitStyles) content = /* @__PURE__ */jsxs(Fragment, {
890
+ children: [content, !isHydrated ? getStyleTags(Object.values(splitStyles.rulesToInsert)) : null]
891
+ });
1094
892
  if (process.env.NODE_ENV === "development" && time) time`style-tags`;
1095
893
  if (process.env.NODE_ENV === "development") {
1096
894
  if (debugProp && debugProp !== "profile") {
1097
- const element2 = typeof elementType === "string" ? elementType : "Component";
1098
- const title = `render <${element2} /> (${internalID}) with props`;
895
+ const title = `render <${typeof elementType === "string" ? elementType : "Component"} /> (${internalID}) with props`;
1099
896
  if (!isWeb || !isClient) {
1100
897
  log(title);
1101
898
  log(`state: `, state);
1102
- if (isDevTools) {
1103
- log("viewProps", viewProps);
1104
- }
899
+ if (isDevTools) log("viewProps", viewProps);
1105
900
  log(`final styles:`);
1106
- for (const key in splitStylesStyle) {
1107
- log(key, splitStylesStyle[key]);
1108
- }
901
+ for (const key in splitStylesStyle) log(key, splitStylesStyle[key]);
1109
902
  } else {
1110
903
  console.groupCollapsed(title);
1111
904
  try {
1112
905
  log("viewProps", viewProps);
1113
906
  log("children", content);
1114
- if (typeof window !== "undefined") {
1115
- log({
1116
- propsIn,
1117
- props,
1118
- attachPress,
1119
- animationStyles,
1120
- classNames,
1121
- content,
1122
- elementType,
1123
- events,
1124
- isAnimated,
1125
- hasRuntimeMediaKeys,
1126
- isStringElement,
1127
- mediaListeningKeys,
1128
- pseudos,
1129
- shouldAttach,
1130
- noClass,
1131
- shouldListenForMedia,
1132
- splitStyles,
1133
- splitStylesStyle,
1134
- state,
1135
- stateRef,
1136
- staticConfig,
1137
- styleProps,
1138
- themeState,
1139
- viewProps,
1140
- willBeAnimated,
1141
- startedUnhydrated
1142
- });
1143
- }
907
+ if (typeof window !== "undefined") log({
908
+ propsIn,
909
+ props,
910
+ attachPress,
911
+ animationStyles,
912
+ classNames,
913
+ content,
914
+ elementType,
915
+ events,
916
+ isAnimated,
917
+ hasRuntimeMediaKeys,
918
+ isStringElement,
919
+ mediaListeningKeys,
920
+ pseudos,
921
+ shouldAttach,
922
+ noClass,
923
+ shouldListenForMedia,
924
+ splitStyles,
925
+ splitStylesStyle,
926
+ state,
927
+ stateRef,
928
+ staticConfig,
929
+ styleProps,
930
+ themeState,
931
+ viewProps,
932
+ willBeAnimated,
933
+ startedUnhydrated
934
+ });
1144
935
  } catch {} finally {
1145
936
  console.groupEnd();
1146
937
  }
@@ -1162,9 +953,7 @@ If you meant to do this, you can disable this warning - either change untilMeasu
1162
953
  return content;
1163
954
  });
1164
955
  function notifyGroupSubscribers(groupContext, groupEmitter, pseudo) {
1165
- if (!groupContext || !groupEmitter) {
1166
- return;
1167
- }
956
+ if (!groupContext || !groupEmitter) return;
1168
957
  const nextState = {
1169
958
  ...groupContext.state,
1170
959
  pseudo
@@ -1172,9 +961,7 @@ If you meant to do this, you can disable this warning - either change untilMeasu
1172
961
  groupEmitter.emit(nextState);
1173
962
  groupContext.state = nextState;
1174
963
  }
1175
- if (staticConfig.componentName) {
1176
- component.displayName = staticConfig.componentName;
1177
- }
964
+ if (staticConfig.componentName) component.displayName = staticConfig.componentName;
1178
965
  let res = component;
1179
966
  res = React.memo(res);
1180
967
  res.staticConfig = staticConfig;
@@ -1188,13 +975,10 @@ If you meant to do this, you can disable this warning - either change untilMeasu
1188
975
  };
1189
976
  }
1190
977
  function styleable(Component2, options) {
1191
- const skipForwardRef = typeof Component2 === "function" && Component2.length === 1;
1192
- let out = skipForwardRef ? Component2 : React.forwardRef(Component2);
978
+ let out = typeof Component2 === "function" && Component2.length === 1 ? Component2 : React.forwardRef(Component2);
1193
979
  const extendedConfig = extendStyledConfig(options?.staticConfig);
1194
980
  out = options?.disableTheme ? out : themeable(out, extendedConfig, true);
1195
- if (extendedConfig.memo || process.env.TAMAGUI_MEMOIZE_STYLEABLE) {
1196
- out = React.memo(out);
1197
- }
981
+ if (extendedConfig.memo || process.env.GUI_MEMOIZE_STYLEABLE) out = React.memo(out);
1198
982
  out.staticConfig = extendedConfig;
1199
983
  out.styleable = styleable;
1200
984
  return out;
@@ -1208,14 +992,10 @@ const fromPx = val => {
1208
992
  return 0;
1209
993
  };
1210
994
  const getCustomRender = (renderProp, content, viewProps, state) => {
1211
- if (typeof renderProp === "function") {
1212
- const out = renderProp(viewProps, state);
1213
- renderProp = getRenderElementForPlatform(out);
1214
- }
995
+ if (typeof renderProp === "function") renderProp = getRenderElementForPlatform(renderProp(viewProps, state));
1215
996
  if (renderProp) {
1216
997
  if (typeof renderProp === "object" && React.isValidElement(renderProp)) {
1217
- const renderElement = getRenderElementForPlatform(renderProp);
1218
- if (renderElement) {
998
+ if (getRenderElementForPlatform(renderProp)) {
1219
999
  const elementProps = renderProp.props;
1220
1000
  const mergedProps = elementProps ? mergeRenderElementProps(elementProps, viewProps, content) : viewProps;
1221
1001
  return {
@@ -1227,11 +1007,6 @@ const getCustomRender = (renderProp, content, viewProps, state) => {
1227
1007
  }
1228
1008
  };
1229
1009
  function getRenderElementForPlatform(potential) {
1230
- if (false) {
1231
- if (isHTMLElement(potential)) {
1232
- return;
1233
- }
1234
- }
1235
1010
  return potential;
1236
1011
  }
1237
1012
  export { componentSetStates, createComponent };