@tamagui/core 1.0.0-beta.1 → 1.0.0-beta.10

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 (348) hide show
  1. package/README.md +1 -0
  2. package/dist/cjs/Tamagui.js +0 -0
  3. package/dist/cjs/Tamagui.js.map +0 -0
  4. package/dist/cjs/ThemeContext.js +0 -0
  5. package/dist/cjs/ThemeContext.js.map +0 -0
  6. package/dist/cjs/ThemeManager.js +0 -0
  7. package/dist/cjs/ThemeManager.js.map +0 -0
  8. package/dist/cjs/conf.js +0 -0
  9. package/dist/cjs/conf.js.map +0 -0
  10. package/dist/cjs/constants/constants.js +0 -0
  11. package/dist/cjs/constants/constants.js.map +0 -0
  12. package/dist/cjs/constants/platform.js +0 -0
  13. package/dist/cjs/constants/platform.js.map +0 -0
  14. package/dist/cjs/constants/rnw.js +0 -0
  15. package/dist/cjs/constants/rnw.js.map +0 -0
  16. package/dist/cjs/contexts/ButtonInsideButtonContext.js +0 -0
  17. package/dist/cjs/contexts/ButtonInsideButtonContext.js.map +0 -0
  18. package/dist/cjs/createComponent.js +34 -8
  19. package/dist/cjs/createComponent.js.map +2 -2
  20. package/dist/cjs/createFont.js +0 -0
  21. package/dist/cjs/createFont.js.map +0 -0
  22. package/dist/cjs/createShorthands.js +0 -0
  23. package/dist/cjs/createShorthands.js.map +0 -0
  24. package/dist/cjs/createTamagui.js +0 -0
  25. package/dist/cjs/createTamagui.js.map +0 -0
  26. package/dist/cjs/createTheme.js +0 -0
  27. package/dist/cjs/createTheme.js.map +0 -0
  28. package/dist/cjs/createTokens.js +0 -0
  29. package/dist/cjs/createTokens.js.map +0 -0
  30. package/dist/cjs/createVariable.js +0 -0
  31. package/dist/cjs/createVariable.js.map +0 -0
  32. package/dist/cjs/defaultComponentState.js +0 -0
  33. package/dist/cjs/defaultComponentState.js.map +0 -0
  34. package/dist/cjs/helpers/RNComponents.js +0 -0
  35. package/dist/cjs/helpers/RNComponents.js.map +0 -0
  36. package/dist/cjs/helpers/addStylesUsingClassname.js +17 -12
  37. package/dist/cjs/helpers/addStylesUsingClassname.js.map +2 -2
  38. package/dist/cjs/helpers/areEqualSets.js +0 -0
  39. package/dist/cjs/helpers/areEqualSets.js.map +0 -0
  40. package/dist/cjs/helpers/createMediaStyle.js +0 -0
  41. package/dist/cjs/helpers/createMediaStyle.js.map +0 -0
  42. package/dist/cjs/helpers/createPropMapper.js +34 -3
  43. package/dist/cjs/helpers/createPropMapper.js.map +2 -2
  44. package/dist/cjs/helpers/createShallowUpdate.js +0 -0
  45. package/dist/cjs/helpers/createShallowUpdate.js.map +0 -0
  46. package/dist/cjs/helpers/createTamaguiProvider.js +0 -0
  47. package/dist/cjs/helpers/createTamaguiProvider.js.map +0 -0
  48. package/dist/cjs/helpers/extendStaticConfig.js +0 -0
  49. package/dist/cjs/helpers/extendStaticConfig.js.map +0 -0
  50. package/dist/cjs/helpers/fixNativeShadow.js +0 -0
  51. package/dist/cjs/helpers/fixNativeShadow.js.map +0 -0
  52. package/dist/cjs/helpers/fixNativeShadow.native.js +0 -0
  53. package/dist/cjs/helpers/fixNativeShadow.native.js.map +0 -0
  54. package/dist/cjs/helpers/getButtonSize.js +45 -0
  55. package/dist/cjs/helpers/getButtonSize.js.map +7 -0
  56. package/dist/cjs/helpers/getExpandedShorthands.js +0 -0
  57. package/dist/cjs/helpers/getExpandedShorthands.js.map +0 -0
  58. package/dist/cjs/helpers/getSize.js +0 -0
  59. package/dist/cjs/helpers/getSize.js.map +0 -0
  60. package/dist/cjs/helpers/getSplitStyles.js +0 -6
  61. package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
  62. package/dist/cjs/helpers/getStylesAtomic.js +0 -0
  63. package/dist/cjs/helpers/getStylesAtomic.js.map +0 -0
  64. package/dist/cjs/helpers/getStylesAtomic.native.js +0 -0
  65. package/dist/cjs/helpers/getStylesAtomic.native.js.map +0 -0
  66. package/dist/cjs/helpers/getTextSize.js +56 -0
  67. package/dist/cjs/helpers/getTextSize.js.map +7 -0
  68. package/dist/cjs/helpers/insertStyleRule.js +1 -0
  69. package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
  70. package/dist/cjs/helpers/isObj.js +0 -0
  71. package/dist/cjs/helpers/isObj.js.map +0 -0
  72. package/dist/cjs/helpers/isTamaguiElement.js +0 -0
  73. package/dist/cjs/helpers/isTamaguiElement.js.map +0 -0
  74. package/dist/cjs/helpers/matchMedia.js +0 -0
  75. package/dist/cjs/helpers/matchMedia.js.map +0 -0
  76. package/dist/cjs/helpers/matchMedia.native.js +0 -0
  77. package/dist/cjs/helpers/matchMedia.native.js.map +0 -0
  78. package/dist/cjs/helpers/proxyThemeVariables.js +0 -0
  79. package/dist/cjs/helpers/proxyThemeVariables.js.map +0 -0
  80. package/dist/cjs/helpers/themeable.js +0 -0
  81. package/dist/cjs/helpers/themeable.js.map +0 -0
  82. package/dist/cjs/helpers/validate.js +0 -0
  83. package/dist/cjs/helpers/validate.js.map +0 -0
  84. package/dist/cjs/helpers/withStaticProperties.js +0 -0
  85. package/dist/cjs/helpers/withStaticProperties.js.map +0 -0
  86. package/dist/cjs/helpers/wrapThemeManagerContext.js +0 -0
  87. package/dist/cjs/helpers/wrapThemeManagerContext.js.map +0 -0
  88. package/dist/cjs/hooks/useConstant.js +0 -0
  89. package/dist/cjs/hooks/useConstant.js.map +0 -0
  90. package/dist/cjs/hooks/useFeatures.js +0 -0
  91. package/dist/cjs/hooks/useFeatures.js.map +0 -0
  92. package/dist/cjs/hooks/useId.js +59 -0
  93. package/dist/cjs/hooks/useId.js.map +7 -0
  94. package/dist/cjs/hooks/useIsMounted.js +0 -0
  95. package/dist/cjs/hooks/useIsMounted.js.map +0 -0
  96. package/dist/cjs/hooks/useIsTouchDevice.js +4 -4
  97. package/dist/cjs/hooks/useIsTouchDevice.js.map +2 -2
  98. package/dist/cjs/hooks/useMedia.js +0 -1
  99. package/dist/cjs/hooks/useMedia.js.map +2 -2
  100. package/dist/cjs/hooks/usePressable.js +0 -0
  101. package/dist/cjs/hooks/usePressable.js.map +0 -0
  102. package/dist/cjs/hooks/useTheme.js +0 -0
  103. package/dist/cjs/hooks/useTheme.js.map +2 -2
  104. package/dist/cjs/hooks/useUnmountEffect.js +0 -0
  105. package/dist/cjs/hooks/useUnmountEffect.js.map +0 -0
  106. package/dist/cjs/index.js +9 -6
  107. package/dist/cjs/index.js.map +2 -2
  108. package/dist/cjs/static.js +0 -0
  109. package/dist/cjs/static.js.map +0 -0
  110. package/dist/cjs/styled.js +4 -1
  111. package/dist/cjs/styled.js.map +2 -2
  112. package/dist/cjs/types-rnw.js +0 -0
  113. package/dist/cjs/types-rnw.js.map +0 -0
  114. package/dist/cjs/types.js +0 -0
  115. package/dist/cjs/types.js.map +1 -1
  116. package/dist/cjs/views/Slot.js +115 -0
  117. package/dist/cjs/views/Slot.js.map +7 -0
  118. package/dist/cjs/views/Stack.js +0 -0
  119. package/dist/cjs/views/Stack.js.map +0 -0
  120. package/dist/cjs/views/Text.js +0 -0
  121. package/dist/cjs/views/Text.js.map +0 -0
  122. package/dist/cjs/views/TextAncestorContext.js +0 -0
  123. package/dist/cjs/views/TextAncestorContext.js.map +0 -0
  124. package/dist/cjs/views/Theme.js +0 -0
  125. package/dist/cjs/views/Theme.js.map +0 -0
  126. package/dist/cjs/views/ThemeInverse.js +0 -0
  127. package/dist/cjs/views/ThemeInverse.js.map +0 -0
  128. package/dist/cjs/views/ThemeProvider.js +0 -0
  129. package/dist/cjs/views/ThemeProvider.js.map +0 -0
  130. package/dist/cjs/views/ThemeReset.js +0 -0
  131. package/dist/cjs/views/ThemeReset.js.map +0 -0
  132. package/dist/esm/Tamagui.js +0 -0
  133. package/dist/esm/Tamagui.js.map +0 -0
  134. package/dist/esm/ThemeContext.js +0 -0
  135. package/dist/esm/ThemeContext.js.map +0 -0
  136. package/dist/esm/ThemeManager.js +0 -0
  137. package/dist/esm/ThemeManager.js.map +0 -0
  138. package/dist/esm/conf.js +0 -0
  139. package/dist/esm/conf.js.map +0 -0
  140. package/dist/esm/constants/constants.js +0 -0
  141. package/dist/esm/constants/constants.js.map +0 -0
  142. package/dist/esm/constants/platform.js +0 -0
  143. package/dist/esm/constants/platform.js.map +0 -0
  144. package/dist/esm/constants/rnw.js +0 -0
  145. package/dist/esm/constants/rnw.js.map +0 -0
  146. package/dist/esm/contexts/ButtonInsideButtonContext.js +0 -0
  147. package/dist/esm/contexts/ButtonInsideButtonContext.js.map +0 -0
  148. package/dist/esm/createComponent.js +35 -13
  149. package/dist/esm/createComponent.js.map +2 -2
  150. package/dist/esm/createFont.js +0 -0
  151. package/dist/esm/createFont.js.map +0 -0
  152. package/dist/esm/createShorthands.js +0 -0
  153. package/dist/esm/createShorthands.js.map +0 -0
  154. package/dist/esm/createTamagui.js +0 -0
  155. package/dist/esm/createTamagui.js.map +0 -0
  156. package/dist/esm/createTheme.js +0 -0
  157. package/dist/esm/createTheme.js.map +0 -0
  158. package/dist/esm/createTokens.js +0 -0
  159. package/dist/esm/createTokens.js.map +0 -0
  160. package/dist/esm/createVariable.js +0 -0
  161. package/dist/esm/createVariable.js.map +0 -0
  162. package/dist/esm/defaultComponentState.js +0 -0
  163. package/dist/esm/defaultComponentState.js.map +0 -0
  164. package/dist/esm/helpers/RNComponents.js +0 -0
  165. package/dist/esm/helpers/RNComponents.js.map +0 -0
  166. package/dist/esm/helpers/addStylesUsingClassname.js +18 -13
  167. package/dist/esm/helpers/addStylesUsingClassname.js.map +2 -2
  168. package/dist/esm/helpers/areEqualSets.js +0 -0
  169. package/dist/esm/helpers/areEqualSets.js.map +0 -0
  170. package/dist/esm/helpers/createMediaStyle.js +0 -0
  171. package/dist/esm/helpers/createMediaStyle.js.map +0 -0
  172. package/dist/esm/helpers/createPropMapper.js +35 -3
  173. package/dist/esm/helpers/createPropMapper.js.map +2 -2
  174. package/dist/esm/helpers/createShallowUpdate.js +0 -0
  175. package/dist/esm/helpers/createShallowUpdate.js.map +0 -0
  176. package/dist/esm/helpers/createTamaguiProvider.js +0 -0
  177. package/dist/esm/helpers/createTamaguiProvider.js.map +0 -0
  178. package/dist/esm/helpers/extendStaticConfig.js +0 -0
  179. package/dist/esm/helpers/extendStaticConfig.js.map +0 -0
  180. package/dist/esm/helpers/fixNativeShadow.js +0 -0
  181. package/dist/esm/helpers/fixNativeShadow.js.map +0 -0
  182. package/dist/esm/helpers/fixNativeShadow.native.js +0 -0
  183. package/dist/esm/helpers/fixNativeShadow.native.js.map +0 -0
  184. package/dist/esm/helpers/getButtonSize.js +24 -0
  185. package/dist/esm/helpers/getButtonSize.js.map +7 -0
  186. package/dist/esm/helpers/getExpandedShorthands.js +0 -0
  187. package/dist/esm/helpers/getExpandedShorthands.js.map +0 -0
  188. package/dist/esm/helpers/getSize.js +0 -0
  189. package/dist/esm/helpers/getSize.js.map +0 -0
  190. package/dist/esm/helpers/getSplitStyles.js +0 -7
  191. package/dist/esm/helpers/getSplitStyles.js.map +2 -2
  192. package/dist/esm/helpers/getStylesAtomic.js +0 -0
  193. package/dist/esm/helpers/getStylesAtomic.js.map +0 -0
  194. package/dist/esm/helpers/getStylesAtomic.native.js +0 -0
  195. package/dist/esm/helpers/getStylesAtomic.native.js.map +0 -0
  196. package/dist/esm/helpers/getTextSize.js +34 -0
  197. package/dist/esm/helpers/getTextSize.js.map +7 -0
  198. package/dist/esm/helpers/insertStyleRule.js +1 -0
  199. package/dist/esm/helpers/insertStyleRule.js.map +2 -2
  200. package/dist/esm/helpers/isObj.js +0 -0
  201. package/dist/esm/helpers/isObj.js.map +0 -0
  202. package/dist/esm/helpers/isTamaguiElement.js +0 -0
  203. package/dist/esm/helpers/isTamaguiElement.js.map +0 -0
  204. package/dist/esm/helpers/matchMedia.js +0 -0
  205. package/dist/esm/helpers/matchMedia.js.map +0 -0
  206. package/dist/esm/helpers/matchMedia.native.js +0 -0
  207. package/dist/esm/helpers/matchMedia.native.js.map +0 -0
  208. package/dist/esm/helpers/proxyThemeVariables.js +0 -0
  209. package/dist/esm/helpers/proxyThemeVariables.js.map +0 -0
  210. package/dist/esm/helpers/themeable.js +0 -0
  211. package/dist/esm/helpers/themeable.js.map +0 -0
  212. package/dist/esm/helpers/validate.js +0 -0
  213. package/dist/esm/helpers/validate.js.map +0 -0
  214. package/dist/esm/helpers/withStaticProperties.js +0 -0
  215. package/dist/esm/helpers/withStaticProperties.js.map +0 -0
  216. package/dist/esm/helpers/wrapThemeManagerContext.js +0 -0
  217. package/dist/esm/helpers/wrapThemeManagerContext.js.map +0 -0
  218. package/dist/esm/hooks/useConstant.js +0 -0
  219. package/dist/esm/hooks/useConstant.js.map +0 -0
  220. package/dist/esm/hooks/useFeatures.js +0 -0
  221. package/dist/esm/hooks/useFeatures.js.map +0 -0
  222. package/dist/esm/hooks/useId.js +35 -0
  223. package/dist/esm/hooks/useId.js.map +7 -0
  224. package/dist/esm/hooks/useIsMounted.js +0 -0
  225. package/dist/esm/hooks/useIsMounted.js.map +0 -0
  226. package/dist/esm/hooks/useIsTouchDevice.js +6 -6
  227. package/dist/esm/hooks/useIsTouchDevice.js.map +2 -2
  228. package/dist/esm/hooks/useMedia.js +0 -1
  229. package/dist/esm/hooks/useMedia.js.map +2 -2
  230. package/dist/esm/hooks/usePressable.js +0 -0
  231. package/dist/esm/hooks/usePressable.js.map +0 -0
  232. package/dist/esm/hooks/useTheme.js +0 -0
  233. package/dist/esm/hooks/useTheme.js.map +2 -2
  234. package/dist/esm/hooks/useUnmountEffect.js +0 -0
  235. package/dist/esm/hooks/useUnmountEffect.js.map +0 -0
  236. package/dist/esm/index.js +9 -6
  237. package/dist/esm/index.js.map +2 -2
  238. package/dist/esm/static.js +0 -0
  239. package/dist/esm/static.js.map +0 -0
  240. package/dist/esm/styled.js +4 -1
  241. package/dist/esm/styled.js.map +2 -2
  242. package/dist/esm/types-rnw.js +0 -0
  243. package/dist/esm/types-rnw.js.map +0 -0
  244. package/dist/esm/types.js +0 -0
  245. package/dist/esm/types.js.map +0 -0
  246. package/dist/esm/views/Slot.js +63 -0
  247. package/dist/esm/views/Slot.js.map +7 -0
  248. package/dist/esm/views/Stack.js +0 -0
  249. package/dist/esm/views/Stack.js.map +0 -0
  250. package/dist/esm/views/Text.js +0 -0
  251. package/dist/esm/views/Text.js.map +0 -0
  252. package/dist/esm/views/TextAncestorContext.js +0 -0
  253. package/dist/esm/views/TextAncestorContext.js.map +0 -0
  254. package/dist/esm/views/Theme.js +0 -0
  255. package/dist/esm/views/Theme.js.map +0 -0
  256. package/dist/esm/views/ThemeInverse.js +0 -0
  257. package/dist/esm/views/ThemeInverse.js.map +0 -0
  258. package/dist/esm/views/ThemeProvider.js +0 -0
  259. package/dist/esm/views/ThemeProvider.js.map +0 -0
  260. package/dist/esm/views/ThemeReset.js +0 -0
  261. package/dist/esm/views/ThemeReset.js.map +0 -0
  262. package/dist/jsx/Tamagui.js +0 -0
  263. package/dist/jsx/ThemeContext.js +0 -0
  264. package/dist/jsx/ThemeManager.js +0 -0
  265. package/dist/jsx/conf.js +0 -0
  266. package/dist/jsx/constants/constants.js +0 -0
  267. package/dist/jsx/constants/platform.js +0 -0
  268. package/dist/jsx/constants/rnw.js +0 -0
  269. package/dist/jsx/contexts/ButtonInsideButtonContext.js +0 -0
  270. package/dist/jsx/createComponent.js +35 -13
  271. package/dist/jsx/createFont.js +0 -0
  272. package/dist/jsx/createShorthands.js +0 -0
  273. package/dist/jsx/createTamagui.js +0 -0
  274. package/dist/jsx/createTheme.js +0 -0
  275. package/dist/jsx/createTokens.js +0 -0
  276. package/dist/jsx/createVariable.js +0 -0
  277. package/dist/jsx/defaultComponentState.js +0 -0
  278. package/dist/jsx/helpers/RNComponents.js +0 -0
  279. package/dist/jsx/helpers/addStylesUsingClassname.js +18 -13
  280. package/dist/jsx/helpers/areEqualSets.js +0 -0
  281. package/dist/jsx/helpers/createMediaStyle.js +0 -0
  282. package/dist/jsx/helpers/createPropMapper.js +35 -3
  283. package/dist/jsx/helpers/createShallowUpdate.js +0 -0
  284. package/dist/jsx/helpers/createTamaguiProvider.js +0 -0
  285. package/dist/jsx/helpers/extendStaticConfig.js +0 -0
  286. package/dist/jsx/helpers/fixNativeShadow.js +0 -0
  287. package/dist/jsx/helpers/fixNativeShadow.native.js +0 -0
  288. package/dist/jsx/helpers/getButtonSize.js +23 -0
  289. package/dist/jsx/helpers/getExpandedShorthands.js +0 -0
  290. package/dist/jsx/helpers/getSize.js +0 -0
  291. package/dist/jsx/helpers/getSplitStyles.js +0 -7
  292. package/dist/jsx/helpers/getStylesAtomic.js +0 -0
  293. package/dist/jsx/helpers/getStylesAtomic.native.js +0 -0
  294. package/dist/jsx/helpers/getTextSize.js +33 -0
  295. package/dist/jsx/helpers/insertStyleRule.js +1 -0
  296. package/dist/jsx/helpers/isObj.js +0 -0
  297. package/dist/jsx/helpers/isTamaguiElement.js +0 -0
  298. package/dist/jsx/helpers/matchMedia.js +0 -0
  299. package/dist/jsx/helpers/matchMedia.native.js +0 -0
  300. package/dist/jsx/helpers/proxyThemeVariables.js +0 -0
  301. package/dist/jsx/helpers/themeable.js +0 -0
  302. package/dist/jsx/helpers/validate.js +0 -0
  303. package/dist/jsx/helpers/withStaticProperties.js +0 -0
  304. package/dist/jsx/helpers/wrapThemeManagerContext.js +0 -0
  305. package/dist/jsx/hooks/useConstant.js +0 -0
  306. package/dist/jsx/hooks/useFeatures.js +0 -0
  307. package/dist/jsx/hooks/useId.js +34 -0
  308. package/dist/jsx/hooks/useIsMounted.js +0 -0
  309. package/dist/jsx/hooks/useIsTouchDevice.js +6 -6
  310. package/dist/jsx/hooks/useMedia.js +0 -1
  311. package/dist/jsx/hooks/usePressable.js +0 -0
  312. package/dist/jsx/hooks/useTheme.js +0 -0
  313. package/dist/jsx/hooks/useUnmountEffect.js +0 -0
  314. package/dist/jsx/index.js +9 -6
  315. package/dist/jsx/static.js +0 -0
  316. package/dist/jsx/styled.js +4 -1
  317. package/dist/jsx/types-rnw.js +0 -0
  318. package/dist/jsx/types.js +0 -0
  319. package/dist/jsx/views/Slot.js +56 -0
  320. package/dist/jsx/views/Stack.js +0 -0
  321. package/dist/jsx/views/Text.js +0 -0
  322. package/dist/jsx/views/TextAncestorContext.js +0 -0
  323. package/dist/jsx/views/Theme.js +0 -0
  324. package/dist/jsx/views/ThemeInverse.js +0 -0
  325. package/dist/jsx/views/ThemeProvider.js +0 -0
  326. package/dist/jsx/views/ThemeReset.js +0 -0
  327. package/package.json +5 -5
  328. package/types/createComponent.d.ts.map +1 -1
  329. package/types/helpers/addStylesUsingClassname.d.ts.map +1 -1
  330. package/types/helpers/createPropMapper.d.ts +1 -1
  331. package/types/helpers/createPropMapper.d.ts.map +1 -1
  332. package/types/helpers/getButtonSize.d.ts +8 -0
  333. package/types/helpers/getButtonSize.d.ts.map +1 -0
  334. package/types/helpers/getSplitStyles.d.ts.map +1 -1
  335. package/types/helpers/getTextSize.d.ts +3 -0
  336. package/types/helpers/getTextSize.d.ts.map +1 -0
  337. package/types/helpers/insertStyleRule.d.ts.map +1 -1
  338. package/types/hooks/useId.d.ts +9 -0
  339. package/types/hooks/useId.d.ts.map +1 -0
  340. package/types/hooks/useMedia.d.ts.map +1 -1
  341. package/types/hooks/useTheme.d.ts.map +1 -1
  342. package/types/index.d.ts +9 -6
  343. package/types/index.d.ts.map +1 -1
  344. package/types/styled.d.ts.map +1 -1
  345. package/types/types.d.ts +20 -5
  346. package/types/types.d.ts.map +1 -1
  347. package/types/views/Slot.d.ts +9 -0
  348. package/types/views/Slot.d.ts.map +1 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/hooks/useTheme.tsx"],
4
- "sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport React, { useContext, useLayoutEffect, useMemo, useRef, useState } from 'react'\n\nimport { getConfig } from '../conf'\nimport { useIsomorphicLayoutEffect } from '../constants/platform'\nimport { areEqualSets } from '../helpers/areEqualSets'\nimport { ThemeContext } from '../ThemeContext'\nimport { ThemeManager, ThemeManagerContext, emptyManager } from '../ThemeManager'\nimport { ThemeObject } from '../types'\nimport { useConstant } from './useConstant'\n\ntype UseThemeState = {\n uuid: Object\n keys: Set<string>\n isRendering: boolean\n}\n\nexport const useTheme = (\n themeName?: string | null,\n componentName?: string,\n props?: any,\n forceUpdate?: any\n): ThemeObject => {\n const { name, theme, themes, themeManager, className, didChangeTheme } = useChangeThemeEffect(\n themeName,\n componentName,\n props,\n forceUpdate\n )\n\n if (process.env.NODE_ENV === 'development') {\n if (props?.['debug'] === 'verbose') {\n console.log(' \u00BB useTheme', { themeName, componentName, name, className })\n }\n }\n\n const state = useRef() as React.MutableRefObject<UseThemeState>\n if (!state.current) {\n state.current = {\n uuid: {},\n keys: new Set(),\n isRendering: true,\n }\n }\n state.current.isRendering = true\n\n // track usage\n useIsomorphicLayoutEffect(() => {\n const st = state.current\n st.isRendering = false\n const cur = themeManager?.keys.get(st.uuid)\n if (!cur || !areEqualSets(st.keys, cur)) {\n themeManager?.track(st.uuid, st.keys)\n }\n })\n\n return useMemo(() => {\n if (!theme) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('No theme', { themeName, theme, componentName, className })\n }\n return themes[getConfig().defaultTheme || 'light' || Object.keys(themes)[0]]\n }\n return new Proxy(theme, {\n has(_, key) {\n if (typeof key === 'string') {\n if (key[0] === '$') {\n key = key.slice(1)\n }\n }\n return Reflect.has(theme, key)\n },\n get(_, key) {\n if (!name || key === '__proto__' || typeof key === 'symbol') {\n // TODO make this pattern better\n if (key === GetThemeManager) {\n if (process.env.NODE_ENV === 'development') {\n if (props['debug']) {\n // prettier-ignore\n console.log('did change', { themeName, didChangeTheme, name, componentName }, themeManager?.parentName)\n }\n }\n if (!didChangeTheme) {\n return null\n }\n // TODO\n // console.log('DID CHANGE THEME')\n return themeManager\n }\n return Reflect.get(_, key)\n }\n if (typeof key !== 'string' || key === '$typeof') {\n return Reflect.get(_, key)\n }\n if (process.env.NODE_ENV === 'development') {\n if (key === '__state') {\n return state.current\n }\n }\n if (key === 'name') {\n return name\n }\n if (key === 'className') {\n return className\n }\n if (!themeManager) {\n console.error('No themeManager')\n return\n }\n // auto convert variables to plain\n if (key[0] === '$') {\n key = key.slice(1)\n }\n const val = themeManager.getValue(key)\n if (val) {\n if (state.current.isRendering) {\n state.current.keys.add(key)\n if (process.env.NODE_ENV === 'development') {\n if (props?.['debug'] === 'verbose') {\n console.log(' \u00BB tracking theme key', key)\n }\n }\n }\n return val\n }\n // react native debuger uses toJSON\n if (process.env.NODE_ENV === 'development') {\n console.log(`No theme value \"${String(key)}\" in ${name}`)\n }\n return Reflect.get(_, key)\n },\n })\n }, [name, theme, className, didChangeTheme])\n}\n\nconst GetThemeManager = Symbol('GetThemeManager')\n\nexport const getThemeManagerIfChanged = (theme: any) => {\n return theme?.[GetThemeManager]\n}\n\nexport const useThemeName = (opts?: { parent?: true }) => {\n const parent = useContext(ThemeManagerContext)\n const [name, setName] = useState(parent?.name || '')\n\n useIsomorphicLayoutEffect(() => {\n if (!parent) return\n return parent.onChangeTheme((next, manager) => {\n const name = opts?.parent ? manager.parentName || next : next\n if (!name) return\n setName(name)\n })\n }, [parent])\n\n return name\n}\n\nexport const useDefaultThemeName = () => {\n return useContext(ThemeContext)?.defaultTheme\n}\n\nexport const useChangeThemeEffect = (\n name?: string | null,\n componentName?: string,\n props?: any,\n forceUpdateProp?: any\n) => {\n const debug = props && props['debug']\n const parentManager = useContext(ThemeManagerContext) || emptyManager\n const { themes } = useContext(ThemeContext)!\n const next = parentManager.getNextTheme({ name, componentName, themes }, props)\n const forceUpdate = forceUpdateProp || useForceUpdate()\n const themeManager = useConstant<ThemeManager | null>(() => {\n if (!next) {\n return null\n }\n return new ThemeManager(next.name, next.theme, parentManager)\n })\n\n if (typeof document !== 'undefined') {\n useLayoutEffect(() => {\n if (!themeManager) return\n if (next?.name) {\n themeManager.update(next)\n }\n return parentManager.onChangeTheme(() => {\n const next = parentManager.getNextTheme({ name, componentName, themes }, debug)\n if (!next) return\n if (themeManager.update(next)) {\n forceUpdate()\n }\n })\n }, [themes, name, componentName, debug, next?.name])\n }\n\n const didChangeTheme = next && parentManager && next.name !== parentManager.fullName\n\n return {\n ...(parentManager && {\n name: parentManager.name,\n theme: parentManager.theme,\n }),\n ...next,\n didChangeTheme,\n themes,\n themeManager,\n }\n}\n"],
5
- "mappings": ";;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAQO,MAAM,WAAW,wBACtB,WACA,eACA,OACA,gBACgB;AAChB,QAAM,EAAE,MAAM,OAAO,QAAQ,cAAc,WAAW,mBAAmB,qBACvE,WACA,eACA,OACA,WACF;AAEA,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,gCAAQ,cAAa,WAAW;AAClC,cAAQ,IAAI,mBAAgB,EAAE,WAAW,eAAe,MAAM,UAAU,CAAC;AAAA,IAC3E;AAAA,EACF;AAEA,QAAM,QAAQ,OAAO;AACrB,MAAI,CAAC,MAAM,SAAS;AAClB,UAAM,UAAU;AAAA,MACd,MAAM,CAAC;AAAA,MACP,MAAM,oBAAI,IAAI;AAAA,MACd,aAAa;AAAA,IACf;AAAA,EACF;AACA,QAAM,QAAQ,cAAc;AAG5B,4BAA0B,MAAM;AAC9B,UAAM,KAAK,MAAM;AACjB,OAAG,cAAc;AACjB,UAAM,MAAM,6CAAc,KAAK,IAAI,GAAG;AACtC,QAAI,CAAC,OAAO,CAAC,aAAa,GAAG,MAAM,GAAG,GAAG;AACvC,mDAAc,MAAM,GAAG,MAAM,GAAG;AAAA,IAClC;AAAA,EACF,CAAC;AAED,SAAO,QAAQ,MAAM;AACnB,QAAI,CAAC,OAAO;AACV,UAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,gBAAQ,KAAK,YAAY,EAAE,WAAW,OAAO,eAAe,UAAU,CAAC;AAAA,MACzE;AACA,aAAO,OAAO,UAAU,EAAE,gBAAgB;AAAA,IAC5C;AACA,WAAO,IAAI,MAAM,OAAO;AAAA,MACtB,IAAI,GAAG,KAAK;AACV,YAAI,OAAO,QAAQ,UAAU;A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AAK,OAAO,aAAa;AAAA,EAC9D,CAAC;AAED,MAAI,OAAO,aAAa,aAAa;AACnC,oBAAgB,MAAM;AACpB,UAAI,CAAC;AAAc;AACnB,UAAI,6BAAM,MAAM;AACd,qBAAa,OAAO,IAAI;AAAA,MAC1B;AACA,aAAO,cAAc,cAAc,MAAM;AACvC,cAAM,QAAO,cAAc,aAAa,EAAE,MAAM,eAAe,OAAO,GAAG,KAAK;AAC9E,YAAI,CAAC;AAAM;AACX,YAAI,aAAa,OAAO,KAAI,GAAG;AAC7B,sBAAY;AAAA,QACd;AAAA,MACF,CAAC;AAAA,IACH,GAAG,CAAC,QAAQ,MAAM,eAAe,OAAO,6BAAM,IAAI,CAAC;AAAA,EACrD;AAEA,QAAM,iBAAiB,QAAQ,iBAAiB,KAAK,SAAS,cAAc;AAE5E,SAAO;AAAA,OACD,iBAAiB;AAAA,MACnB,MAAM,cAAc;AAAA,MACpB,OAAO,cAAc;AAAA,IACvB;AAAA,OACG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF,GA9CoC;",
4
+ "sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport React, { useContext, useLayoutEffect, useMemo, useRef, useState } from 'react'\n\nimport { getConfig } from '../conf'\nimport { useIsomorphicLayoutEffect } from '../constants/platform'\nimport { areEqualSets } from '../helpers/areEqualSets'\nimport { ThemeContext } from '../ThemeContext'\nimport { ThemeManager, ThemeManagerContext, emptyManager } from '../ThemeManager'\nimport { ThemeObject } from '../types'\nimport { useConstant } from './useConstant'\n\ntype UseThemeState = {\n uuid: Object\n keys: Set<string>\n isRendering: boolean\n}\n\nexport const useTheme = (\n themeName?: string | null,\n componentName?: string,\n props?: any,\n forceUpdate?: any\n): ThemeObject => {\n const { name, theme, themes, themeManager, className, didChangeTheme } = useChangeThemeEffect(\n themeName,\n componentName,\n props,\n forceUpdate\n )\n\n if (process.env.NODE_ENV === 'development') {\n if (props?.['debug'] === 'verbose') {\n console.log(' \u00BB useTheme', { themeName, componentName, name, className })\n }\n }\n\n const state = useRef() as React.MutableRefObject<UseThemeState>\n if (!state.current) {\n state.current = {\n uuid: {},\n keys: new Set(),\n isRendering: true,\n }\n }\n state.current.isRendering = true\n\n // track usage\n useIsomorphicLayoutEffect(() => {\n const st = state.current\n st.isRendering = false\n const cur = themeManager?.keys.get(st.uuid)\n if (!cur || !areEqualSets(st.keys, cur)) {\n themeManager?.track(st.uuid, st.keys)\n }\n })\n\n return useMemo(() => {\n if (!theme) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('No theme', { themeName, theme, componentName, className })\n }\n return themes[getConfig().defaultTheme || 'light' || Object.keys(themes)[0]]\n }\n return new Proxy(theme, {\n has(_, key) {\n if (typeof key === 'string') {\n if (key[0] === '$') {\n key = key.slice(1)\n }\n }\n return Reflect.has(theme, key)\n },\n get(_, key) {\n if (!name || key === '__proto__' || typeof key === 'symbol') {\n // TODO make this pattern better\n if (key === GetThemeManager) {\n if (process.env.NODE_ENV === 'development') {\n if (props['debug']) {\n // prettier-ignore\n console.log('did change', { themeName, didChangeTheme, name, componentName }, themeManager?.parentName)\n }\n }\n if (!didChangeTheme) {\n return null\n }\n return themeManager\n }\n return Reflect.get(_, key)\n }\n if (typeof key !== 'string' || key === '$typeof') {\n return Reflect.get(_, key)\n }\n if (process.env.NODE_ENV === 'development') {\n if (key === '__state') {\n return state.current\n }\n }\n if (key === 'name') {\n return name\n }\n if (key === 'className') {\n return className\n }\n if (!themeManager) {\n console.error('No themeManager')\n return\n }\n // auto convert variables to plain\n if (key[0] === '$') {\n key = key.slice(1)\n }\n const val = themeManager.getValue(key)\n if (val) {\n if (state.current.isRendering) {\n state.current.keys.add(key)\n if (process.env.NODE_ENV === 'development') {\n if (props?.['debug'] === 'verbose') {\n console.log(' \u00BB tracking theme key', key)\n }\n }\n }\n return val\n }\n // react native debuger uses toJSON\n if (process.env.NODE_ENV === 'development') {\n console.log(`No theme value \"${String(key)}\" in ${name}`)\n }\n return Reflect.get(_, key)\n },\n })\n }, [name, theme, className, didChangeTheme])\n}\n\nconst GetThemeManager = Symbol('GetThemeManager')\n\nexport const getThemeManagerIfChanged = (theme: any) => {\n return theme?.[GetThemeManager]\n}\n\nexport const useThemeName = (opts?: { parent?: true }) => {\n const parent = useContext(ThemeManagerContext)\n const [name, setName] = useState(parent?.name || '')\n\n useIsomorphicLayoutEffect(() => {\n if (!parent) return\n return parent.onChangeTheme((next, manager) => {\n const name = opts?.parent ? manager.parentName || next : next\n if (!name) return\n setName(name)\n })\n }, [parent])\n\n return name\n}\n\nexport const useDefaultThemeName = () => {\n return useContext(ThemeContext)?.defaultTheme\n}\n\nexport const useChangeThemeEffect = (\n name?: string | null,\n componentName?: string,\n props?: any,\n forceUpdateProp?: any\n) => {\n const debug = props && props['debug']\n const parentManager = useContext(ThemeManagerContext) || emptyManager\n const { themes } = useContext(ThemeContext)!\n const next = parentManager.getNextTheme({ name, componentName, themes }, props)\n const forceUpdate = forceUpdateProp || useForceUpdate()\n const themeManager = useConstant<ThemeManager | null>(() => {\n if (!next) {\n return null\n }\n return new ThemeManager(next.name, next.theme, parentManager)\n })\n\n if (typeof document !== 'undefined') {\n useLayoutEffect(() => {\n if (!themeManager) return\n if (next?.name) {\n themeManager.update(next)\n }\n return parentManager.onChangeTheme(() => {\n const next = parentManager.getNextTheme({ name, componentName, themes }, debug)\n if (!next) return\n if (themeManager.update(next)) {\n forceUpdate()\n }\n })\n }, [themes, name, componentName, debug, next?.name])\n }\n\n const didChangeTheme = next && parentManager && next.name !== parentManager.fullName\n\n return {\n ...(parentManager && {\n name: parentManager.name,\n theme: parentManager.theme,\n }),\n ...next,\n didChangeTheme,\n themes,\n themeManager,\n }\n}\n"],
5
+ "mappings": ";;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAQO,MAAM,WAAW,wBACtB,WACA,eACA,OACA,gBACgB;AAChB,QAAM,EAAE,MAAM,OAAO,QAAQ,cAAc,WAAW,mBAAmB,qBACvE,WACA,eACA,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Y;AAAA,QACd;AAAA,MACF,CAAC;AAAA,IACH,GAAG,CAAC,QAAQ,MAAM,eAAe,OAAO,6BAAM,IAAI,CAAC;AAAA,EACrD;AAEA,QAAM,iBAAiB,QAAQ,iBAAiB,KAAK,SAAS,cAAc;AAE5E,SAAO;AAAA,OACD,iBAAiB;AAAA,MACnB,MAAM,cAAc;AAAA,MACpB,OAAO,cAAc;AAAA,IACvB;AAAA,OACG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF,GA9CoC;",
6
6
  "names": []
7
7
  }
File without changes
File without changes
package/dist/esm/index.js CHANGED
@@ -13,31 +13,34 @@ import { getHasConfigured, getConfig, getThemes, getTokens, onConfiguredOnce } f
13
13
  export * from "./constants/constants";
14
14
  export * from "./constants/platform";
15
15
  export * from "./constants/rnw";
16
+ export * from "./helpers/getButtonSize";
16
17
  export * from "./helpers/getExpandedShorthands";
17
18
  export * from "./helpers/getSize";
18
19
  export * from "./helpers/getSplitStyles";
19
20
  export * from "./helpers/getStylesAtomic";
21
+ export * from "./helpers/getTextSize";
20
22
  export * from "./helpers/isObj";
21
23
  export * from "./helpers/isTamaguiElement";
22
24
  export * from "./helpers/matchMedia";
23
25
  export * from "./helpers/themeable";
24
26
  export * from "./helpers/withStaticProperties";
25
27
  export * from "./contexts/ButtonInsideButtonContext";
26
- export * from "./hooks/useIsTouchDevice";
27
28
  export * from "./hooks/useConstant";
28
- export * from "./hooks/usePressable";
29
+ export * from "./hooks/useId";
30
+ export * from "./hooks/useIsMounted";
31
+ export * from "./hooks/useIsTouchDevice";
29
32
  export * from "./hooks/useMedia";
33
+ export * from "./hooks/usePressable";
30
34
  export * from "./hooks/useTheme";
31
- export * from "./hooks/useIsMounted";
32
35
  export * from "./hooks/useUnmountEffect";
33
- export * from "@tamagui/use-force-update";
34
36
  export * from "./views/Stack";
35
37
  export * from "./views/Text";
38
+ export * from "./views/TextAncestorContext";
36
39
  export * from "./views/Theme";
37
- export * from "./views/ThemeReset";
38
40
  export * from "./views/ThemeInverse";
39
41
  export * from "./views/ThemeProvider";
40
- export * from "./views/TextAncestorContext";
42
+ export * from "./views/ThemeReset";
43
+ export * from "@tamagui/use-force-update";
41
44
  export * from "@tamagui/helpers";
42
45
  export {
43
46
  RNWTextProps,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["export * from './Tamagui'\nexport * from './createComponent'\nexport * from './createShorthands'\nexport * from './createTheme'\nexport * from './createTamagui'\nexport * from './createFont'\nexport { createTokens } from './createTokens'\nexport * from './createVariable'\nexport * from './styled'\nexport * from './types'\n// for type portability\nexport { RNWTextProps, RNWViewProps } from './types-rnw'\nexport { getHasConfigured, getConfig, getThemes, getTokens, onConfiguredOnce } from './conf'\n\nexport * from './constants/constants'\nexport * from './constants/platform'\nexport * from './constants/rnw'\n\nexport * from './helpers/getExpandedShorthands'\nexport * from './helpers/getSize'\nexport * from './helpers/getSplitStyles'\nexport * from './helpers/getStylesAtomic'\nexport * from './helpers/isObj'\nexport * from './helpers/isTamaguiElement'\nexport * from './helpers/matchMedia'\nexport * from './helpers/themeable'\nexport * from './helpers/withStaticProperties'\n\nexport * from './contexts/ButtonInsideButtonContext'\n\nexport * from './hooks/useIsTouchDevice'\nexport * from './hooks/useConstant'\nexport * from './hooks/usePressable'\nexport * from './hooks/useMedia'\nexport * from './hooks/useTheme'\nexport * from './hooks/useIsMounted'\nexport * from './hooks/useUnmountEffect'\nexport * from '@tamagui/use-force-update'\n\nexport * from './views/Stack'\nexport * from './views/Text'\nexport * from './views/Theme'\nexport * from './views/ThemeReset'\nexport * from './views/ThemeInverse'\nexport * from './views/ThemeProvider'\nexport * from './views/TextAncestorContext'\n\nexport * from '@tamagui/helpers'\n"],
5
- "mappings": "AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;",
4
+ "sourcesContent": ["export * from './Tamagui'\nexport * from './createComponent'\nexport * from './createShorthands'\nexport * from './createTheme'\nexport * from './createTamagui'\nexport * from './createFont'\nexport { createTokens } from './createTokens'\nexport * from './createVariable'\nexport * from './styled'\nexport * from './types'\n// for type portability\nexport { RNWTextProps, RNWViewProps } from './types-rnw'\nexport { getHasConfigured, getConfig, getThemes, getTokens, onConfiguredOnce } from './conf'\n\nexport * from './constants/constants'\nexport * from './constants/platform'\nexport * from './constants/rnw'\n\nexport * from './helpers/getButtonSize'\nexport * from './helpers/getExpandedShorthands'\nexport * from './helpers/getSize'\nexport * from './helpers/getSplitStyles'\nexport * from './helpers/getStylesAtomic'\nexport * from './helpers/getTextSize'\nexport * from './helpers/isObj'\nexport * from './helpers/isTamaguiElement'\nexport * from './helpers/matchMedia'\nexport * from './helpers/themeable'\nexport * from './helpers/withStaticProperties'\n\nexport * from './contexts/ButtonInsideButtonContext'\n\nexport * from './hooks/useConstant'\nexport * from './hooks/useId'\nexport * from './hooks/useIsMounted'\nexport * from './hooks/useIsTouchDevice'\nexport * from './hooks/useMedia'\nexport * from './hooks/usePressable'\nexport * from './hooks/useTheme'\nexport * from './hooks/useUnmountEffect'\n\nexport * from './views/Stack'\nexport * from './views/Text'\nexport * from './views/TextAncestorContext'\nexport * from './views/Theme'\nexport * from './views/ThemeInverse'\nexport * from './views/ThemeProvider'\nexport * from './views/ThemeReset'\n\nexport * from '@tamagui/use-force-update'\nexport * from '@tamagui/helpers'\n"],
5
+ "mappings": "AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;",
6
6
  "names": []
7
7
  }
File without changes
File without changes
@@ -5,14 +5,16 @@ import { createComponent } from "./createComponent";
5
5
  import { RNComponents } from "./helpers/RNComponents";
6
6
  function styled(Component, options, staticExtractionOptions) {
7
7
  const staticConfigProps = (() => {
8
+ var _a;
8
9
  if (options) {
9
10
  const { variants, name, defaultVariants, ...defaultProps } = options;
10
11
  if (defaultVariants) {
11
12
  Object.assign(defaultProps, defaultVariants);
12
13
  }
13
14
  const isReactNativeWeb = "staticConfig" in Component ? Component.staticConfig.isReactNativeWeb : RNComponents.has(Component);
15
+ const reactNativeWebComponent = isReactNativeWeb ? ((_a = Component["staticConfig"]) == null ? void 0 : _a.reactNativeWebComponent) || Component : null;
14
16
  const isTamagui = !isReactNativeWeb && "staticConfig" in Component;
15
- const Comp = Component;
17
+ const Comp = reactNativeWebComponent || Component;
16
18
  const isImage = !!(defaultProps.isImage || (!isTamagui ? Comp === Image : false));
17
19
  const isInput = !!(defaultProps.isInput || (!isTamagui ? Comp === TextInput : false));
18
20
  const isText = !!(defaultProps.isText || (!isTamagui ? isInput || Comp === Text : false));
@@ -27,6 +29,7 @@ function styled(Component, options, staticExtractionOptions) {
27
29
  defaultVariants,
28
30
  componentName: name,
29
31
  isReactNativeWeb,
32
+ reactNativeWebComponent,
30
33
  isInput,
31
34
  isText,
32
35
  isImage
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/styled.tsx"],
4
- "sourcesContent": ["import { Image, Text, TextInput } from 'react-native'\n\nimport { createComponent } from './createComponent'\nimport { RNComponents } from './helpers/RNComponents'\nimport {\n GetProps,\n GetVariantValues,\n MediaProps,\n PseudoProps,\n StaticConfig,\n StylableComponent,\n TamaguiComponent,\n VariantDefinitions,\n VariantSpreadFunction,\n} from './types'\n\n// TODO may be able to use this in the options?: arg below directly\nexport type StyledOptions<ParentComponent extends StylableComponent> = GetProps<ParentComponent> & {\n name?: string\n variants?: VariantDefinitions<ParentComponent> | undefined\n defaultVariants?: { [key: string]: any }\n}\n\nexport function styled<\n ParentComponent extends StylableComponent,\n Variants extends VariantDefinitions<ParentComponent> | symbol =\n | VariantDefinitions<ParentComponent>\n | symbol\n>(\n Component: ParentComponent,\n // this should be Partial<GetProps<ParentComponent>> but causes excessively deep type issues\n options?: GetProps<ParentComponent> & {\n name?: string\n variants?: Variants | undefined\n // thought i had this typed, but can't get it linked\n defaultVariants?: { [key: string]: any }\n },\n staticExtractionOptions?: Partial<StaticConfig>\n) {\n const staticConfigProps = (() => {\n if (options) {\n const { variants, name, defaultVariants, ...defaultProps } = options\n if (defaultVariants) {\n Object.assign(defaultProps, defaultVariants)\n }\n const isReactNativeWeb =\n 'staticConfig' in Component\n ? Component.staticConfig.isReactNativeWeb\n : RNComponents.has(Component)\n const isTamagui = !isReactNativeWeb && 'staticConfig' in Component\n const Comp = Component as any\n const isImage = !!(defaultProps.isImage || (!isTamagui ? Comp === Image : false))\n const isInput = !!(defaultProps.isInput || (!isTamagui ? Comp === TextInput : false))\n const isText = !!(defaultProps.isText || (!isTamagui ? isInput || Comp === Text : false))\n const conf: Partial<StaticConfig> = {\n ...staticExtractionOptions,\n ...(!isTamagui && {\n Component: Comp,\n }),\n isTamagui,\n // this type gets messed up by options?: Partial<GetProps<ParentComponent>> above\n // take away the Partial<> and it's fine\n variants,\n defaultProps,\n defaultVariants,\n componentName: name,\n isReactNativeWeb,\n isInput,\n isText,\n isImage,\n }\n return conf\n }\n return {}\n })()\n\n const component = createComponent(staticConfigProps, Component)\n\n // get parent props without pseudos and medias so we can rebuild both with new variants\n type ParentPropsBase = ParentComponent extends TamaguiComponent<any, any, infer P>\n ? P\n : GetProps<ParentComponent>\n type ParentVariants = ParentComponent extends TamaguiComponent<any, any, any, infer V> ? V : {}\n\n type OurVariants = Variants extends symbol\n ? {}\n : {\n [Key in keyof Variants]?: Variants[Key] extends VariantSpreadFunction<any, infer Val>\n ? Val\n : GetVariantValues<keyof Variants[Key]>\n }\n\n type VariantProps = Omit<ParentVariants, keyof OurVariants> & OurVariants\n type OurPropsBase = ParentPropsBase & VariantProps\n\n type Props = Variants extends void | symbol\n ? GetProps<ParentComponent>\n : // start with base props\n OurPropsBase &\n // add in media (+ pseudos nested)\n MediaProps<Partial<OurPropsBase>> &\n // add in pseudos\n PseudoProps<Partial<OurPropsBase>>\n\n return component as TamaguiComponent<\n Props,\n // TODO infer ref\n any,\n ParentPropsBase,\n ParentVariants & OurVariants\n >\n}\n\n// test types:\n// // variants\n// export const XStack = styled(Stack, {\n// flexDirection: 'row',\n// name: 'XStack',\n// variants: {\n// fullscreen: {\n// true: {},\n// },\n// elevation: {\n// '...size': (val) => ({}),\n// },\n// },\n// })\n// const InBetween = styled(XStack, {})\n// type INBVariants = typeof InBetween extends TamaguiComponent<any, any, any, infer Variants> ? Variants: never\n// const SwitchFrame = styled(InBetween, {\n// name: 'Switch',\n// tag: 'button',\n// borderRadius: 100,\n// borderWidth: 0,\n// variants: {\n// name: {\n// true: {\n// backgroundColor: 'aliceblue'\n// },\n// // 1: {\n\n// // },\n// // ':number': (val) => {\n// // return {}\n// // },\n// // \"...fontSize\": (val) => {\n// // return {}\n// // },\n// // \"...color\": (val) => {\n// // return {}\n// // }\n// }\n// },\n// defaultVariants: {\n// size: '$4',\n// },\n// })\n// const x = <XStack fullscreen />\n// const y = <XStack fullscreen />\n// const z = <SwitchFrame fullscreen name />\n\n// depth:\n// export const SizableText = styled(Stack, {\n// name: 'SizableText',\n// backgroundColor: 'red',\n// variants: {\n// size: {\n// '...fontSize': (val, { props }) => {\n// return {\n// backgroundColor: '',\n// }\n// },\n// },\n// },\n// })\n// export const Heading = styled(SizableText, {\n// tag: 'span',\n// name: 'Heading',\n// accessibilityRole: 'header',\n// size: '$8',\n// margin: 0,\n// })\n// export const Paragraph = styled(SizableText, {\n// tag: 'p',\n// margin: 10,\n// variants: {\n// another: {\n// true: {},\n// },\n// },\n// })\n// export const Paragraph2 = styled(Paragraph, {\n// tag: 'p',\n// variants: {\n// another: {\n// '...color': (val) => ({\n// backgroundColor: 'red',\n// }),\n// },\n// },\n// })\n// const a = <SizableText size=\"$10\" />\n// const b = <Paragraph size=\"$10\" another />\n// const c = <Paragraph2 size=\"$10\" another=\"aliceblue\" />\n// export const SizableText2 = styled(SizableText, {\n// })\n// const xx = <SizableText2 abc />\n// export const Paragraph = styled(SizableText, {\n// name: 'Paragraph',\n// })\n// export const Heading = styled(Paragraph, {\n// tag: 'span',\n// margin: 0,\n// })\n// export const H2 = styled(Heading, {\n// name: 'H2',\n// })\n// const x = <H2 color=\"red\" />\n"],
5
- "mappings": ";;AAAA;AAEA;AACA;AAoBO,gBAML,WAEA,SAMA,yBACA;AACA,QAAM,oBAAqB,OAAM;AAC/B,QAAI,SAAS;AACX,YAAM,EAAE,UAAU,MAAM,oBAAoB,iBAAiB;AAC7D,UAAI,iBAAiB;AACnB,eAAO,OAAO,cAAc,eAAe;AAAA,MAC7C;AACA,YAAM,mBACJ,kBAAkB,YACd,UAAU,aAAa,mBACvB,aAAa,IAAI,SAAS;AAChC,YAAM,YAAY,CAAC,oBAAoB,kBAAkB;AACzD,YAAM,OAAO;AACb,YAAM,UAAU,CAAC,CAAE,cAAa,WAAY,EAAC,YAAY,SAAS,QAAQ;AAC1E,YAAM,UAAU,CAAC,CAAE,cAAa,WAAY,EAAC,YAAY,SAAS,YAAY;AAC9E,YAAM,SAAS,CAAC,CAAE,cAAa,UAAW,EAAC,YAAY,WAAW,SAAS,OAAO;AAClF,YAAM,OAA8B;AAAA,WAC/B;AAAA,WACC,CAAC,aAAa;AAAA,UAChB,WAAW;AAAA,QACb;AAAA,QACA;AAAA,QAGA;AAAA,QACA;AAAA,QACA;AAAA,QACA,eAAe;AAAA,QACf;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AACA,aAAO;AAAA,IACT;AACA,WAAO,CAAC;AAAA,EACV,GAAG;AAEH,QAAM,YAAY,gBAAgB,mBAAmB,SAAS;AA4B9D,SAAO;AAOT;AAxFgB;",
4
+ "sourcesContent": ["import { Image, Text, TextInput } from 'react-native'\n\nimport { createComponent } from './createComponent'\nimport { RNComponents } from './helpers/RNComponents'\nimport {\n GetProps,\n GetVariantValues,\n MediaProps,\n PseudoProps,\n StaticConfig,\n StylableComponent,\n TamaguiComponent,\n VariantDefinitions,\n VariantSpreadFunction,\n} from './types'\n\n// TODO may be able to use this in the options?: arg below directly\nexport type StyledOptions<ParentComponent extends StylableComponent> = GetProps<ParentComponent> & {\n name?: string\n variants?: VariantDefinitions<ParentComponent> | undefined\n defaultVariants?: { [key: string]: any }\n}\n\nexport function styled<\n ParentComponent extends StylableComponent,\n Variants extends VariantDefinitions<ParentComponent> | symbol =\n | VariantDefinitions<ParentComponent>\n | symbol\n>(\n Component: ParentComponent,\n // this should be Partial<GetProps<ParentComponent>> but causes excessively deep type issues\n options?: GetProps<ParentComponent> & {\n name?: string\n variants?: Variants | undefined\n // thought i had this typed, but can't get it linked\n defaultVariants?: { [key: string]: any }\n },\n staticExtractionOptions?: Partial<StaticConfig>\n) {\n const staticConfigProps = (() => {\n if (options) {\n const { variants, name, defaultVariants, ...defaultProps } = options\n if (defaultVariants) {\n Object.assign(defaultProps, defaultVariants)\n }\n const isReactNativeWeb =\n 'staticConfig' in Component\n ? Component.staticConfig.isReactNativeWeb\n : RNComponents.has(Component)\n const reactNativeWebComponent = isReactNativeWeb\n ? Component['staticConfig']?.reactNativeWebComponent || Component\n : null\n const isTamagui = !isReactNativeWeb && 'staticConfig' in Component\n const Comp = reactNativeWebComponent || (Component as any)\n const isImage = !!(defaultProps.isImage || (!isTamagui ? Comp === Image : false))\n const isInput = !!(defaultProps.isInput || (!isTamagui ? Comp === TextInput : false))\n const isText = !!(defaultProps.isText || (!isTamagui ? isInput || Comp === Text : false))\n const conf: Partial<StaticConfig> = {\n ...staticExtractionOptions,\n ...(!isTamagui && {\n Component: Comp,\n }),\n isTamagui,\n // this type gets messed up by options?: Partial<GetProps<ParentComponent>> above\n // take away the Partial<> and it's fine\n variants,\n defaultProps,\n defaultVariants,\n componentName: name,\n isReactNativeWeb,\n // for nesting multiple levels of rnw styled() need keep use the OG component\n reactNativeWebComponent,\n isInput,\n isText,\n isImage,\n }\n\n return conf\n }\n return {}\n })()\n\n const component = createComponent(staticConfigProps, Component)\n\n // get parent props without pseudos and medias so we can rebuild both with new variants\n type ParentPropsBase = ParentComponent extends TamaguiComponent<any, any, infer P>\n ? P\n : GetProps<ParentComponent>\n type ParentVariants = ParentComponent extends TamaguiComponent<any, any, any, infer V> ? V : {}\n\n type OurVariants = Variants extends symbol\n ? {}\n : {\n [Key in keyof Variants]?: Variants[Key] extends VariantSpreadFunction<any, infer Val>\n ? Val\n : GetVariantValues<keyof Variants[Key]>\n }\n\n type VariantProps = Omit<ParentVariants, keyof OurVariants> & OurVariants\n type OurPropsBase = ParentPropsBase & VariantProps\n\n type Props = Variants extends void | symbol\n ? GetProps<ParentComponent>\n : // start with base props\n OurPropsBase &\n // add in media (+ pseudos nested)\n MediaProps<Partial<OurPropsBase>> &\n // add in pseudos\n PseudoProps<Partial<OurPropsBase>>\n\n return component as TamaguiComponent<\n Props,\n // TODO infer ref\n any,\n ParentPropsBase,\n ParentVariants & OurVariants\n >\n}\n\n// test types:\n// // variants\n// export const XStack = styled(Stack, {\n// flexDirection: 'row',\n// name: 'XStack',\n// variants: {\n// fullscreen: {\n// true: {},\n// },\n// elevation: {\n// '...size': (val) => ({}),\n// },\n// },\n// })\n// const InBetween = styled(XStack, {})\n// type INBVariants = typeof InBetween extends TamaguiComponent<any, any, any, infer Variants> ? Variants: never\n// const SwitchFrame = styled(InBetween, {\n// name: 'Switch',\n// tag: 'button',\n// borderRadius: 100,\n// borderWidth: 0,\n// variants: {\n// name: {\n// true: {\n// backgroundColor: 'aliceblue'\n// },\n// // 1: {\n\n// // },\n// // ':number': (val) => {\n// // return {}\n// // },\n// // \"...fontSize\": (val) => {\n// // return {}\n// // },\n// // \"...color\": (val) => {\n// // return {}\n// // }\n// }\n// },\n// defaultVariants: {\n// size: '$4',\n// },\n// })\n// const x = <XStack fullscreen />\n// const y = <XStack fullscreen />\n// const z = <SwitchFrame fullscreen name />\n\n// depth:\n// export const SizableText = styled(Stack, {\n// name: 'SizableText',\n// backgroundColor: 'red',\n// variants: {\n// size: {\n// '...fontSize': (val, { props }) => {\n// return {\n// backgroundColor: '',\n// }\n// },\n// },\n// },\n// })\n// export const Heading = styled(SizableText, {\n// tag: 'span',\n// name: 'Heading',\n// accessibilityRole: 'header',\n// size: '$8',\n// margin: 0,\n// })\n// export const Paragraph = styled(SizableText, {\n// tag: 'p',\n// margin: 10,\n// variants: {\n// another: {\n// true: {},\n// },\n// },\n// })\n// export const Paragraph2 = styled(Paragraph, {\n// tag: 'p',\n// variants: {\n// another: {\n// '...color': (val) => ({\n// backgroundColor: 'red',\n// }),\n// },\n// },\n// })\n// const a = <SizableText size=\"$10\" />\n// const b = <Paragraph size=\"$10\" another />\n// const c = <Paragraph2 size=\"$10\" another=\"aliceblue\" />\n// export const SizableText2 = styled(SizableText, {\n// })\n// const xx = <SizableText2 abc />\n// export const Paragraph = styled(SizableText, {\n// name: 'Paragraph',\n// })\n// export const Heading = styled(Paragraph, {\n// tag: 'span',\n// margin: 0,\n// })\n// export const H2 = styled(Heading, {\n// name: 'H2',\n// })\n// const x = <H2 color=\"red\" />\n"],
5
+ "mappings": ";;AAAA;AAEA;AACA;AAoBO,gBAML,WAEA,SAMA,yBACA;AACA,QAAM,oBAAqB,OAAM;AAvCnC;AAwCI,QAAI,SAAS;AACX,YAAM,EAAE,UAAU,MAAM,oBAAoB,iBAAiB;AAC7D,UAAI,iBAAiB;AACnB,eAAO,OAAO,cAAc,eAAe;AAAA,MAC7C;AACA,YAAM,mBACJ,kBAAkB,YACd,UAAU,aAAa,mBACvB,aAAa,IAAI,SAAS;AAChC,YAAM,0BAA0B,mBAC5B,iBAAU,oBAAV,mBAA2B,4BAA2B,YACtD;AACJ,YAAM,YAAY,CAAC,oBAAoB,kBAAkB;AACzD,YAAM,OAAO,2BAA4B;AACzC,YAAM,UAAU,CAAC,CAAE,cAAa,WAAY,EAAC,YAAY,SAAS,QAAQ;AAC1E,YAAM,UAAU,CAAC,CAAE,cAAa,WAAY,EAAC,YAAY,SAAS,YAAY;AAC9E,YAAM,SAAS,CAAC,CAAE,cAAa,UAAW,EAAC,YAAY,WAAW,SAAS,OAAO;AAClF,YAAM,OAA8B;AAAA,WAC/B;AAAA,WACC,CAAC,aAAa;AAAA,UAChB,WAAW;AAAA,QACb;AAAA,QACA;AAAA,QAGA;AAAA,QACA;AAAA,QACA;AAAA,QACA,eAAe;AAAA,QACf;AAAA,QAEA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAEA,aAAO;AAAA,IACT;AACA,WAAO,CAAC;AAAA,EACV,GAAG;AAEH,QAAM,YAAY,gBAAgB,mBAAmB,SAAS;AA4B9D,SAAO;AAOT;AA9FgB;",
6
6
  "names": []
7
7
  }
File without changes
File without changes
package/dist/esm/types.js CHANGED
File without changes
File without changes
@@ -0,0 +1,63 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { composeRefs } from "@tamagui/compose-refs";
4
+ import * as React from "react";
5
+ const Slot = React.forwardRef((props, forwardedRef) => {
6
+ const { children, ...slotProps } = props;
7
+ if (React.Children.toArray(children).some(isSlottable)) {
8
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, React.Children.map(children, (child) => {
9
+ return isSlottable(child) ? /* @__PURE__ */ React.createElement(SlotClone, {
10
+ ...slotProps,
11
+ ref: forwardedRef
12
+ }, child.props.children) : child;
13
+ }));
14
+ }
15
+ return /* @__PURE__ */ React.createElement(SlotClone, {
16
+ ...slotProps,
17
+ ref: forwardedRef
18
+ }, children);
19
+ });
20
+ Slot.displayName = "Slot";
21
+ const SlotClone = React.forwardRef((props, forwardedRef) => {
22
+ const { children, ...slotProps } = props;
23
+ if (React.isValidElement(children)) {
24
+ return React.cloneElement(children, {
25
+ ...mergeProps(slotProps, children.props),
26
+ ref: composeRefs(forwardedRef, children.ref)
27
+ });
28
+ }
29
+ return React.Children.count(children) > 1 ? React.Children.only(null) : null;
30
+ });
31
+ SlotClone.displayName = "SlotClone";
32
+ const Slottable = /* @__PURE__ */ __name(({ children }) => {
33
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
34
+ }, "Slottable");
35
+ function isSlottable(child) {
36
+ return React.isValidElement(child);
37
+ }
38
+ __name(isSlottable, "isSlottable");
39
+ function mergeProps(slotProps, childProps) {
40
+ const overrideProps = { ...childProps };
41
+ for (const propName in childProps) {
42
+ const slotPropValue = slotProps[propName];
43
+ const childPropValue = childProps[propName];
44
+ const isHandler = /^on[A-Z]/.test(propName);
45
+ if (isHandler) {
46
+ overrideProps[propName] = (...args) => {
47
+ childPropValue == null ? void 0 : childPropValue(...args);
48
+ slotPropValue == null ? void 0 : slotPropValue(...args);
49
+ };
50
+ } else if (propName === "style") {
51
+ overrideProps[propName] = { ...slotPropValue, ...childPropValue };
52
+ } else if (propName === "className") {
53
+ overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
54
+ }
55
+ }
56
+ return { ...slotProps, ...overrideProps };
57
+ }
58
+ __name(mergeProps, "mergeProps");
59
+ export {
60
+ Slot,
61
+ Slottable
62
+ };
63
+ //# sourceMappingURL=Slot.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/views/Slot.tsx"],
4
+ "sourcesContent": ["// via radix\n\nimport { composeRefs } from '@tamagui/compose-refs'\nimport * as React from 'react'\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * -----------------------------------------------------------------------------------------------*/\n\nexport type SlotProps = {\n children?: React.ReactNode\n}\n\nexport const Slot = React.forwardRef<HTMLElement, SlotProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props\n\n if (React.Children.toArray(children).some(isSlottable)) {\n return (\n <>\n {React.Children.map(children, (child) => {\n return isSlottable(child) ? (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {child.props.children}\n </SlotClone>\n ) : (\n child\n )\n })}\n </>\n )\n }\n\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {children}\n </SlotClone>\n )\n})\n\nSlot.displayName = 'Slot'\n\n/* -------------------------------------------------------------------------------------------------\n * SlotClone\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SlotCloneProps {\n children: React.ReactNode\n}\n\nconst SlotClone = React.forwardRef<any, SlotCloneProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props\n\n if (React.isValidElement(children)) {\n return React.cloneElement(children, {\n ...mergeProps(slotProps, children.props),\n ref: composeRefs(forwardedRef, (children as any).ref),\n })\n }\n\n return React.Children.count(children) > 1 ? React.Children.only(null) : null\n})\n\nSlotClone.displayName = 'SlotClone'\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * -----------------------------------------------------------------------------------------------*/\n\nexport const Slottable = ({ children }: { children: React.ReactNode }) => {\n return <>{children}</>\n}\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype AnyProps = Record<string, any>\n\nfunction isSlottable(child: React.ReactNode): child is React.ReactElement {\n return React.isValidElement(child)\n}\n\nfunction mergeProps(slotProps: AnyProps, childProps: AnyProps) {\n // all child props should override\n const overrideProps = { ...childProps }\n\n for (const propName in childProps) {\n const slotPropValue = slotProps[propName]\n const childPropValue = childProps[propName]\n\n const isHandler = /^on[A-Z]/.test(propName)\n // if it's a handler, modify the override by composing the base handler\n if (isHandler) {\n overrideProps[propName] = (...args: unknown[]) => {\n childPropValue?.(...args)\n slotPropValue?.(...args)\n }\n }\n // if it's `style`, we merge them\n else if (propName === 'style') {\n overrideProps[propName] = { ...slotPropValue, ...childPropValue }\n } else if (propName === 'className') {\n overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(' ')\n }\n }\n\n return { ...slotProps, ...overrideProps }\n}\n"],
5
+ "mappings": ";;AAEA;AACA;AAUO,MAAM,OAAO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AAa,SAAS;AAC7B,oBAAc,YAAY,KAAK,kBAAkB,eAAe;AAAA,IAClE,WAAW,aAAa,aAAa;AACnC,oBAAc,YAAY,CAAC,eAAe,cAAc,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAAA,IACpF;AAAA,EACF;AAEA,SAAO,KAAK,cAAc,cAAc;AAC1C;AAzBS;",
6
+ "names": []
7
+ }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/dist/jsx/conf.js CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -16,21 +16,20 @@ import React, {
16
16
  import { StyleSheet, Text, View } from "react-native";
17
17
  import { onConfiguredOnce } from "./conf";
18
18
  import { stackDefaultStyles } from "./constants/constants";
19
- import { isAndroid, isTouchDevice, isWeb, useIsomorphicLayoutEffect } from "./constants/platform";
19
+ import { isAndroid, isWeb, useIsomorphicLayoutEffect } from "./constants/platform";
20
20
  import { rnw } from "./constants/rnw";
21
21
  import { isVariable } from "./createVariable";
22
22
  import { createShallowUpdate } from "./helpers/createShallowUpdate";
23
23
  import { extendStaticConfig, parseStaticConfig } from "./helpers/extendStaticConfig";
24
- import {
25
- insertSplitStyles,
26
- useSplitStyles
27
- } from "./helpers/getSplitStyles";
24
+ import { insertSplitStyles, useSplitStyles } from "./helpers/getSplitStyles";
28
25
  import { getAllSelectors } from "./helpers/insertStyleRule";
29
26
  import { proxyThemeVariables } from "./helpers/proxyThemeVariables";
30
27
  import { wrapThemeManagerContext } from "./helpers/wrapThemeManagerContext";
31
28
  import { useFeatures } from "./hooks/useFeatures";
29
+ import { useIsTouchDevice } from "./hooks/useIsTouchDevice";
32
30
  import { usePressable } from "./hooks/usePressable";
33
31
  import { getThemeManagerIfChanged, useTheme } from "./hooks/useTheme";
32
+ import { Slot } from "./views/Slot";
34
33
  import { TextAncestorContext } from "./views/TextAncestorContext";
35
34
  React["keep"];
36
35
  const defaultComponentState = {
@@ -47,6 +46,14 @@ if (typeof document !== "undefined") {
47
46
  mouseUps.forEach((x) => x());
48
47
  mouseUps.clear();
49
48
  });
49
+ document.addEventListener("touchend", () => {
50
+ mouseUps.forEach((x) => x());
51
+ mouseUps.clear();
52
+ });
53
+ document.addEventListener("touchcancel", () => {
54
+ mouseUps.forEach((x) => x());
55
+ mouseUps.clear();
56
+ });
50
57
  }
51
58
  function mergeShorthands({ defaultProps }, { shorthands }) {
52
59
  for (const key in defaultProps) {
@@ -71,6 +78,7 @@ function createComponent(configIn, ParentComponent) {
71
78
  let avoidClasses = true;
72
79
  let defaultNativeStyle;
73
80
  let defaultNativeStyleSheet;
81
+ let tamaguiDefaultProps;
74
82
  let initialSplitStyles;
75
83
  function addPseudoToStyles(styles, name, pseudos) {
76
84
  const pseudoStyle = pseudos[name];
@@ -86,11 +94,12 @@ function createComponent(configIn, ParentComponent) {
86
94
  __name(addPseudoToStyles, "addPseudoToStyles");
87
95
  const component = forwardRef((props, forwardedRef) => {
88
96
  var _a, _b, _c, _d;
97
+ props = tamaguiDefaultProps && !props.asChild ? { ...tamaguiDefaultProps, ...props } : props;
89
98
  const { Component, componentName, isText, isZStack } = staticConfig;
90
99
  if (process.env.NODE_ENV === "development") {
91
100
  if (props["debug"]) {
92
101
  console.warn(staticConfig.componentName || (Component == null ? void 0 : Component.displayName) || (Component == null ? void 0 : Component.name) || "[Unnamed Component]", "debug on");
93
- console.log("props in:", props);
102
+ console.log("props in:", props, Object.keys(props));
94
103
  if (props["debug"] === "break")
95
104
  debugger;
96
105
  }
@@ -100,7 +109,7 @@ function createComponent(configIn, ParentComponent) {
100
109
  const [state, set_] = useState(defaultComponentState);
101
110
  const setStateShallow = createShallowUpdate(set_);
102
111
  const shouldAvoidClasses = !!(props.animation && avoidClasses);
103
- const splitStyles = useSplitStyles(props, staticConfig, theme, shouldAvoidClasses ? { ...state, noClassNames: true, resolveVariablesAs: "value" } : state, shouldAvoidClasses ? null : initialSplitStyles.classNames);
112
+ const splitStyles = useSplitStyles(props, staticConfig, theme, shouldAvoidClasses ? { ...state, noClassNames: true, resolveVariablesAs: "value" } : state, shouldAvoidClasses || props.asChild ? null : initialSplitStyles.classNames);
104
113
  const { viewProps: viewPropsIn, pseudos, medias, style, classNames } = splitStyles;
105
114
  const useAnimations = (_a = tamaguiConfig.animations) == null ? void 0 : _a.useAnimations;
106
115
  const isAnimated = !!(useAnimations && props.animation);
@@ -119,6 +128,7 @@ function createComponent(configIn, ParentComponent) {
119
128
  const {
120
129
  tag,
121
130
  hitSlop,
131
+ asChild,
122
132
  children,
123
133
  pointerEvents,
124
134
  onPress,
@@ -202,7 +212,7 @@ function createComponent(configIn, ParentComponent) {
202
212
  if (accessibilityRole)
203
213
  viewProps.accessibilityRole = accessibilityRole;
204
214
  }
205
- if (isWeb) {
215
+ if (isWeb && !asChild) {
206
216
  rnw.useResponderEvents(hostRef, {
207
217
  onMoveShouldSetResponder,
208
218
  onMoveShouldSetResponderCapture,
@@ -306,10 +316,11 @@ function createComponent(configIn, ParentComponent) {
306
316
  }
307
317
  const initialPseudos = initialSplitStyles.pseudos;
308
318
  const attachPress = !!(pseudos && pseudos.pressStyle || initialPseudos && initialPseudos.pressStyle || onPress || onPressOut || onPressIn || onClick);
309
- const isHoverable = isWeb && !isTouchDevice;
319
+ const isTouch = useIsTouchDevice();
320
+ const isHoverable = isWeb && !isTouch;
310
321
  const attachHover = isHoverable && !!(pseudos && pseudos.hoverStyle || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave);
311
322
  const pressEventKey = isStringElement ? "onClick" : "onPress";
312
- const shouldAttach = attachPress || attachHover || "pressStyle" in props || "onPress" in props || "onPressIn" in props || "onPressOut" in props || isWeb && ("hoverStyle" in props || "onHoverIn" in props || "onHoverOut" in props || "onMouseEnter" in props || "onMouseLeave" in props);
323
+ const shouldAttach = !asChild && (attachPress || attachHover || "pressStyle" in props || "onPress" in props || "onPressIn" in props || "onPressOut" in props || isWeb && ("hoverStyle" in props || "onHoverIn" in props || "onHoverOut" in props || "onMouseEnter" in props || "onMouseLeave" in props));
313
324
  const unPress = useCallback(() => {
314
325
  if (!internal.current.isMounted)
315
326
  return;
@@ -364,15 +375,18 @@ function createComponent(configIn, ParentComponent) {
364
375
  });
365
376
  onPressIn == null ? void 0 : onPressIn(e);
366
377
  onMouseDown == null ? void 0 : onMouseDown(e);
378
+ if (isWeb) {
379
+ mouseUps.add(unPress);
380
+ }
367
381
  } : null,
368
382
  [pressEventKey]: attachPress ? (e) => {
383
+ onClick == null ? void 0 : onClick(e);
369
384
  onPress == null ? void 0 : onPress(e);
370
385
  unPress();
371
386
  onPressOut == null ? void 0 : onPressOut(e);
372
- onClick == null ? void 0 : onClick(e);
373
387
  } : null
374
388
  } : null;
375
- let childEls = !children ? children : wrapThemeManagerContext(spacedChildren({
389
+ const childEls = !children || asChild ? children : wrapThemeManagerContext(spacedChildren({
376
390
  children,
377
391
  space,
378
392
  flexDirection: props.flexDirection || ((_b = staticConfig.defaultProps) == null ? void 0 : _b.flexDirection),
@@ -412,6 +426,11 @@ function createComponent(configIn, ParentComponent) {
412
426
  Object.assign(viewProps, events);
413
427
  }
414
428
  }
429
+ if (asChild) {
430
+ ViewComponent = Slot;
431
+ const onlyChild = React.Children.only(children);
432
+ Object.assign(viewProps, onlyChild.props);
433
+ }
415
434
  content = createElement(ViewComponent, viewProps, childEls);
416
435
  if (isWeb && events && attachHover) {
417
436
  content = <span className="tui_Hoverable" style={{
@@ -462,10 +481,13 @@ function createComponent(configIn, ParentComponent) {
462
481
  defaultNativeStyleSheet = StyleSheet.create({
463
482
  base: defaultNativeStyle
464
483
  });
465
- component.defaultProps = {
484
+ const defaults = {
466
485
  ...viewProps,
467
486
  ...component.defaultProps
468
487
  };
488
+ if (Object.keys(defaults).length) {
489
+ tamaguiDefaultProps = defaults;
490
+ }
469
491
  if (process.env.NODE_ENV === "development" && ((_d = staticConfig.defaultProps) == null ? void 0 : _d.debug)) {
470
492
  if (process.env.IS_STATIC !== "is_static") {
471
493
  console.log(`\u{1F41B} [${staticConfig.componentName || "Component"}]`, {
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,24 +1,29 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { useInsertionEffect, useLayoutEffect } from "react";
3
+ import { useInsertionEffect } from "react";
4
4
  import { getStylesAtomic } from "./getStylesAtomic";
5
5
  import { insertStyleRule, updateInsertedCache } from "./insertStyleRule";
6
6
  let added = /* @__PURE__ */ new Set();
7
- const effect = useInsertionEffect || useLayoutEffect;
8
7
  function useStylesAsClassname(styles, disable = false, debug = false) {
9
- const insertions = [];
10
- const className = addStylesUsingClassname(disable ? [] : styles, debug, (identifier, rules) => {
11
- for (const rule of rules) {
12
- insertions.push({ identifier, rule });
13
- updateInsertedCache(identifier, rule);
14
- }
15
- });
16
- effect(() => {
8
+ if (!useInsertionEffect) {
9
+ return addStylesUsingClassname(disable ? styles : [], debug);
10
+ } else {
11
+ const insertions = [];
12
+ const className = addStylesUsingClassname(disable ? [] : styles, debug, (identifier, rules) => {
13
+ for (const rule of rules) {
14
+ insertions.push({ identifier, rule });
15
+ }
16
+ });
17
17
  for (const { identifier, rule } of insertions) {
18
- insertStyleRule(identifier, rule);
18
+ updateInsertedCache(identifier, rule);
19
19
  }
20
- }, [className]);
21
- return className;
20
+ useInsertionEffect(() => {
21
+ for (const { identifier, rule } of insertions) {
22
+ insertStyleRule(identifier, rule);
23
+ }
24
+ });
25
+ return className;
26
+ }
22
27
  }
23
28
  __name(useStylesAsClassname, "useStylesAsClassname");
24
29
  function addStylesUsingClassname(styles, debug = false, onAdd) {
File without changes
File without changes