@hanzogui/web 7.3.2 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (347) hide show
  1. package/.turbo/turbo-build.log +2 -0
  2. package/dist/cjs/_withStableStyle.cjs +2 -2
  3. package/dist/cjs/_withStableStyle.native.js +2 -2
  4. package/dist/cjs/_withStableStyle.native.js.map +1 -1
  5. package/dist/cjs/config.cjs +18 -10
  6. package/dist/cjs/config.native.js +19 -10
  7. package/dist/cjs/config.native.js.map +1 -1
  8. package/dist/cjs/constants/constants.cjs +1 -1
  9. package/dist/cjs/constants/constants.native.js +1 -1
  10. package/dist/cjs/constants/constants.native.js.map +1 -1
  11. package/dist/cjs/createComponent.cjs +68 -28
  12. package/dist/cjs/createComponent.native.js +75 -30
  13. package/dist/cjs/createComponent.native.js.map +1 -1
  14. package/dist/cjs/createGui.cjs +1 -1
  15. package/dist/cjs/createGui.native.js +1 -1
  16. package/dist/cjs/createGui.native.js.map +1 -1
  17. package/dist/cjs/eventHandling.cjs +2 -2
  18. package/dist/cjs/eventHandling.native.js +73 -54
  19. package/dist/cjs/eventHandling.native.js.map +1 -1
  20. package/dist/cjs/helpers/createDesignSystem.cjs +2 -2
  21. package/dist/cjs/helpers/defaultAnimationDriver.cjs +1 -1
  22. package/dist/cjs/helpers/defaultAnimationDriver.native.js +1 -1
  23. package/dist/cjs/helpers/expandStyle.cjs +46 -5
  24. package/dist/cjs/helpers/expandStyle.native.js +36 -30
  25. package/dist/cjs/helpers/expandStyle.native.js.map +1 -1
  26. package/dist/cjs/helpers/getGroupPropParts.cjs +1 -1
  27. package/dist/cjs/helpers/getGroupPropParts.native.js +1 -1
  28. package/dist/cjs/helpers/getSplitStyles.cjs +76 -31
  29. package/dist/cjs/helpers/getSplitStyles.native.js +140 -85
  30. package/dist/cjs/helpers/getSplitStyles.native.js.map +1 -1
  31. package/dist/cjs/helpers/getTokenForKey.cjs +5 -5
  32. package/dist/cjs/helpers/getTokenForKey.native.js +5 -5
  33. package/dist/cjs/helpers/getTokenForKey.native.js.map +1 -1
  34. package/dist/cjs/helpers/getVariantExtras.cjs +7 -3
  35. package/dist/cjs/helpers/getVariantExtras.native.js +7 -3
  36. package/dist/cjs/helpers/getVariantExtras.native.js.map +1 -1
  37. package/dist/cjs/helpers/insertStyleRule.cjs +4 -4
  38. package/dist/cjs/helpers/insertStyleRule.native.js +3 -3
  39. package/dist/cjs/helpers/insertStyleRule.native.js.map +1 -1
  40. package/dist/cjs/helpers/mainThreadPressEvents.native.js +32 -4
  41. package/dist/cjs/helpers/mainThreadPressEvents.native.js.map +1 -1
  42. package/dist/cjs/helpers/normalizeStyle.cjs +22 -1
  43. package/dist/cjs/helpers/normalizeStyle.native.js +41 -1
  44. package/dist/cjs/helpers/normalizeStyle.native.js.map +1 -1
  45. package/dist/cjs/helpers/platformResolveValue.cjs +1 -1
  46. package/dist/cjs/helpers/platformResolveValue.native.js +1 -1
  47. package/dist/cjs/helpers/platformResolveValue.native.js.map +1 -1
  48. package/dist/cjs/helpers/pointerEvents.native.js +26 -20
  49. package/dist/cjs/helpers/pointerEvents.native.js.map +1 -1
  50. package/dist/cjs/helpers/propMapper.cjs +31 -7
  51. package/dist/cjs/helpers/propMapper.native.js +70 -20
  52. package/dist/cjs/helpers/propMapper.native.js.map +1 -1
  53. package/dist/cjs/helpers/resolveSafeArea.native.js +1 -1
  54. package/dist/cjs/helpers/resolveSafeArea.native.js.map +1 -1
  55. package/dist/cjs/helpers/styleOriginalValues.cjs +28 -0
  56. package/dist/cjs/helpers/styleOriginalValues.native.js +31 -0
  57. package/dist/cjs/helpers/styleOriginalValues.native.js.map +1 -0
  58. package/dist/cjs/helpers/styleProvenance.cjs +43 -0
  59. package/dist/cjs/helpers/styleProvenance.native.js +46 -0
  60. package/dist/cjs/helpers/styleProvenance.native.js.map +1 -0
  61. package/dist/cjs/helpers/wrapStyleTags.cjs +35 -11
  62. package/dist/cjs/helpers/wrapStyleTags.native.js.map +1 -1
  63. package/dist/cjs/hooks/getThemeProxied.cjs +1 -1
  64. package/dist/cjs/hooks/getThemeProxied.native.js +4 -4
  65. package/dist/cjs/hooks/getThemeProxied.native.js.map +1 -1
  66. package/dist/cjs/hooks/useComponentState.cjs +29 -3
  67. package/dist/cjs/hooks/useComponentState.native.js +30 -4
  68. package/dist/cjs/hooks/useComponentState.native.js.map +1 -1
  69. package/dist/cjs/hooks/useMedia.cjs +107 -42
  70. package/dist/cjs/hooks/useMedia.native.js +149 -60
  71. package/dist/cjs/hooks/useMedia.native.js.map +1 -1
  72. package/dist/cjs/hooks/useTheme.cjs +18 -5
  73. package/dist/cjs/hooks/useTheme.native.js +19 -5
  74. package/dist/cjs/hooks/useTheme.native.js.map +1 -1
  75. package/dist/cjs/hooks/useThemeState.cjs +143 -72
  76. package/dist/cjs/hooks/useThemeState.native.js +155 -74
  77. package/dist/cjs/hooks/useThemeState.native.js.map +1 -1
  78. package/dist/cjs/index.cjs +3 -0
  79. package/dist/cjs/index.native.js +3 -0
  80. package/dist/cjs/index.native.js.map +1 -1
  81. package/dist/cjs/opacityModifier.test-d.cjs +36 -0
  82. package/dist/cjs/opacityModifier.test-d.native.js +39 -0
  83. package/dist/cjs/opacityModifier.test-d.native.js.map +1 -0
  84. package/dist/cjs/styledNonStyleProps.test-d.cjs +63 -0
  85. package/dist/cjs/styledNonStyleProps.test-d.native.js +66 -0
  86. package/dist/cjs/styledNonStyleProps.test-d.native.js.map +1 -0
  87. package/dist/cjs/views/GuiProvider.cjs +2 -2
  88. package/dist/cjs/views/Text.cjs +1 -0
  89. package/dist/cjs/views/Text.native.js +1 -0
  90. package/dist/cjs/views/Text.native.js.map +1 -1
  91. package/dist/cjs/views/Theme.cjs +1 -1
  92. package/dist/cjs/views/Theme.native.js +1 -1
  93. package/dist/cjs/views/Theme.native.js.map +1 -1
  94. package/dist/esm/_withStableStyle.mjs +2 -2
  95. package/dist/esm/_withStableStyle.mjs.map +1 -1
  96. package/dist/esm/_withStableStyle.native.js +2 -2
  97. package/dist/esm/_withStableStyle.native.js.map +1 -1
  98. package/dist/esm/config.mjs +18 -11
  99. package/dist/esm/config.mjs.map +1 -1
  100. package/dist/esm/config.native.js +19 -11
  101. package/dist/esm/config.native.js.map +1 -1
  102. package/dist/esm/constants/constants.mjs +1 -1
  103. package/dist/esm/constants/constants.native.js +1 -1
  104. package/dist/esm/constants/constants.native.js.map +1 -1
  105. package/dist/esm/createComponent.mjs +74 -35
  106. package/dist/esm/createComponent.mjs.map +1 -1
  107. package/dist/esm/createComponent.native.js +90 -42
  108. package/dist/esm/createComponent.native.js.map +1 -1
  109. package/dist/esm/createGui.mjs +6 -6
  110. package/dist/esm/createGui.mjs.map +1 -1
  111. package/dist/esm/createGui.native.js +6 -6
  112. package/dist/esm/createGui.native.js.map +1 -1
  113. package/dist/esm/eventHandling.mjs +2 -2
  114. package/dist/esm/eventHandling.mjs.map +1 -1
  115. package/dist/esm/eventHandling.native.js +74 -55
  116. package/dist/esm/eventHandling.native.js.map +1 -1
  117. package/dist/esm/helpers/createDesignSystem.mjs +2 -2
  118. package/dist/esm/helpers/createDesignSystem.mjs.map +1 -1
  119. package/dist/esm/helpers/createDesignSystem.native.js +1 -2
  120. package/dist/esm/helpers/createDesignSystem.native.js.map +1 -1
  121. package/dist/esm/helpers/defaultAnimationDriver.mjs +1 -1
  122. package/dist/esm/helpers/defaultAnimationDriver.mjs.map +1 -1
  123. package/dist/esm/helpers/defaultAnimationDriver.native.js +1 -1
  124. package/dist/esm/helpers/expandStyle.mjs +47 -8
  125. package/dist/esm/helpers/expandStyle.mjs.map +1 -1
  126. package/dist/esm/helpers/expandStyle.native.js +36 -30
  127. package/dist/esm/helpers/expandStyle.native.js.map +1 -1
  128. package/dist/esm/helpers/expandStyles.mjs.map +1 -1
  129. package/dist/esm/helpers/expandStyles.native.js.map +1 -1
  130. package/dist/esm/helpers/getGroupPropParts.mjs +1 -1
  131. package/dist/esm/helpers/getGroupPropParts.mjs.map +1 -1
  132. package/dist/esm/helpers/getGroupPropParts.native.js +1 -1
  133. package/dist/esm/helpers/getSplitStyles.mjs +86 -45
  134. package/dist/esm/helpers/getSplitStyles.mjs.map +1 -1
  135. package/dist/esm/helpers/getSplitStyles.native.js +146 -98
  136. package/dist/esm/helpers/getSplitStyles.native.js.map +1 -1
  137. package/dist/esm/helpers/getThemeCSSRules.mjs +1 -1
  138. package/dist/esm/helpers/getThemeCSSRules.mjs.map +1 -1
  139. package/dist/esm/helpers/getTokenForKey.mjs +5 -5
  140. package/dist/esm/helpers/getTokenForKey.mjs.map +1 -1
  141. package/dist/esm/helpers/getTokenForKey.native.js +5 -5
  142. package/dist/esm/helpers/getTokenForKey.native.js.map +1 -1
  143. package/dist/esm/helpers/getVariantExtras.mjs +7 -3
  144. package/dist/esm/helpers/getVariantExtras.mjs.map +1 -1
  145. package/dist/esm/helpers/getVariantExtras.native.js +7 -3
  146. package/dist/esm/helpers/getVariantExtras.native.js.map +1 -1
  147. package/dist/esm/helpers/insertStyleRule.mjs +4 -6
  148. package/dist/esm/helpers/insertStyleRule.mjs.map +1 -1
  149. package/dist/esm/helpers/insertStyleRule.native.js +0 -26
  150. package/dist/esm/helpers/insertStyleRule.native.js.map +1 -1
  151. package/dist/esm/helpers/isActivePlatform.mjs.map +1 -1
  152. package/dist/esm/helpers/isActivePlatform.native.js.map +1 -1
  153. package/dist/esm/helpers/log.mjs.map +1 -1
  154. package/dist/esm/helpers/log.native.js.map +1 -1
  155. package/dist/esm/helpers/mainThreadPressEvents.native.js +32 -4
  156. package/dist/esm/helpers/mainThreadPressEvents.native.js.map +1 -1
  157. package/dist/esm/helpers/normalizeStyle.mjs +22 -1
  158. package/dist/esm/helpers/normalizeStyle.mjs.map +1 -1
  159. package/dist/esm/helpers/normalizeStyle.native.js +41 -1
  160. package/dist/esm/helpers/normalizeStyle.native.js.map +1 -1
  161. package/dist/esm/helpers/platformResolveValue.mjs +1 -1
  162. package/dist/esm/helpers/platformResolveValue.mjs.map +1 -1
  163. package/dist/esm/helpers/platformResolveValue.native.js +1 -1
  164. package/dist/esm/helpers/platformResolveValue.native.js.map +1 -1
  165. package/dist/esm/helpers/pointerEvents.native.js +26 -20
  166. package/dist/esm/helpers/pointerEvents.native.js.map +1 -1
  167. package/dist/esm/helpers/propMapper.mjs +32 -11
  168. package/dist/esm/helpers/propMapper.mjs.map +1 -1
  169. package/dist/esm/helpers/propMapper.native.js +71 -22
  170. package/dist/esm/helpers/propMapper.native.js.map +1 -1
  171. package/dist/esm/helpers/resolveSafeArea.native.js +1 -1
  172. package/dist/esm/helpers/resolveSafeArea.native.js.map +1 -1
  173. package/dist/esm/helpers/skipProps.mjs +0 -1
  174. package/dist/esm/helpers/skipProps.mjs.map +1 -1
  175. package/dist/esm/helpers/skipProps.native.js +0 -1
  176. package/dist/esm/helpers/skipProps.native.js.map +1 -1
  177. package/dist/esm/helpers/styleOriginalValues.mjs +3 -0
  178. package/dist/esm/helpers/styleOriginalValues.mjs.map +1 -0
  179. package/dist/esm/helpers/styleOriginalValues.native.js +3 -0
  180. package/dist/esm/helpers/styleOriginalValues.native.js.map +1 -0
  181. package/dist/esm/helpers/styleProvenance.mjs +16 -0
  182. package/dist/esm/helpers/styleProvenance.mjs.map +1 -0
  183. package/dist/esm/helpers/styleProvenance.native.js +16 -0
  184. package/dist/esm/helpers/styleProvenance.native.js.map +1 -0
  185. package/dist/esm/helpers/useRenderElement.mjs.map +1 -1
  186. package/dist/esm/helpers/useRenderElement.native.js.map +1 -1
  187. package/dist/esm/helpers/wrapStyleTags.mjs +35 -11
  188. package/dist/esm/helpers/wrapStyleTags.mjs.map +1 -1
  189. package/dist/esm/helpers/wrapStyleTags.native.js +0 -2
  190. package/dist/esm/helpers/wrapStyleTags.native.js.map +1 -1
  191. package/dist/esm/hooks/getThemeProxied.mjs +2 -5
  192. package/dist/esm/hooks/getThemeProxied.mjs.map +1 -1
  193. package/dist/esm/hooks/getThemeProxied.native.js +5 -5
  194. package/dist/esm/hooks/getThemeProxied.native.js.map +1 -1
  195. package/dist/esm/hooks/useComponentState.mjs +31 -5
  196. package/dist/esm/hooks/useComponentState.mjs.map +1 -1
  197. package/dist/esm/hooks/useComponentState.native.js +32 -6
  198. package/dist/esm/hooks/useComponentState.native.js.map +1 -1
  199. package/dist/esm/hooks/useMedia.mjs +108 -43
  200. package/dist/esm/hooks/useMedia.mjs.map +1 -1
  201. package/dist/esm/hooks/useMedia.native.js +150 -61
  202. package/dist/esm/hooks/useMedia.native.js.map +1 -1
  203. package/dist/esm/hooks/useTheme.mjs +18 -5
  204. package/dist/esm/hooks/useTheme.mjs.map +1 -1
  205. package/dist/esm/hooks/useTheme.native.js +19 -5
  206. package/dist/esm/hooks/useTheme.native.js.map +1 -1
  207. package/dist/esm/hooks/useThemeState.mjs +141 -70
  208. package/dist/esm/hooks/useThemeState.mjs.map +1 -1
  209. package/dist/esm/hooks/useThemeState.native.js +154 -73
  210. package/dist/esm/hooks/useThemeState.native.js.map +1 -1
  211. package/dist/esm/index.js +4 -4
  212. package/dist/esm/index.js.map +1 -1
  213. package/dist/esm/index.mjs +4 -4
  214. package/dist/esm/index.mjs.map +1 -1
  215. package/dist/esm/index.native.js +4 -4
  216. package/dist/esm/index.native.js.map +1 -1
  217. package/dist/esm/insertFont.mjs.map +1 -1
  218. package/dist/esm/insertFont.native.js +0 -1
  219. package/dist/esm/insertFont.native.js.map +1 -1
  220. package/dist/esm/opacityModifier.test-d.mjs +37 -0
  221. package/dist/esm/opacityModifier.test-d.mjs.map +1 -0
  222. package/dist/esm/opacityModifier.test-d.native.js +37 -0
  223. package/dist/esm/opacityModifier.test-d.native.js.map +1 -0
  224. package/dist/esm/styledNonStyleProps.test-d.mjs +64 -0
  225. package/dist/esm/styledNonStyleProps.test-d.mjs.map +1 -0
  226. package/dist/esm/styledNonStyleProps.test-d.native.js +64 -0
  227. package/dist/esm/styledNonStyleProps.test-d.native.js.map +1 -0
  228. package/dist/esm/views/GuiProvider.mjs +2 -2
  229. package/dist/esm/views/GuiProvider.mjs.map +1 -1
  230. package/dist/esm/views/GuiProvider.native.js +6 -6
  231. package/dist/esm/views/GuiProvider.native.js.map +1 -1
  232. package/dist/esm/views/Text.mjs +1 -0
  233. package/dist/esm/views/Text.mjs.map +1 -1
  234. package/dist/esm/views/Text.native.js +1 -0
  235. package/dist/esm/views/Text.native.js.map +1 -1
  236. package/dist/esm/views/Theme.mjs +1 -1
  237. package/dist/esm/views/Theme.mjs.map +1 -1
  238. package/dist/esm/views/Theme.native.js +1 -1
  239. package/dist/esm/views/Theme.native.js.map +1 -1
  240. package/dist/esm/views/ThemeProvider.mjs.map +1 -1
  241. package/dist/esm/views/ThemeProvider.native.js +2 -4
  242. package/dist/esm/views/ThemeProvider.native.js.map +1 -1
  243. package/inject-styles/index.cjs +2 -0
  244. package/inject-styles/index.js +2 -0
  245. package/package.json +27 -40
  246. package/src/_withStableStyle.tsx +9 -3
  247. package/src/config.ts +24 -14
  248. package/src/constants/accessibilityDirectMap.tsx +1 -1
  249. package/src/constants/constants.ts +1 -1
  250. package/src/createComponent.tsx +161 -26
  251. package/src/createGui.ts +2 -2
  252. package/src/eventHandling.native.ts +143 -52
  253. package/src/eventHandling.ts +4 -2
  254. package/src/helpers/createDesignSystem.ts +2 -2
  255. package/src/helpers/createMediaStyle.ts +1 -1
  256. package/src/helpers/defaultAnimationDriver.tsx +1 -1
  257. package/src/helpers/expandStyle.ts +108 -40
  258. package/src/helpers/getGroupPropParts.ts +1 -1
  259. package/src/helpers/getSplitStyles.tsx +178 -72
  260. package/src/helpers/getTokenForKey.ts +5 -5
  261. package/src/helpers/getVariantExtras.tsx +5 -4
  262. package/src/helpers/insertStyleRule.tsx +7 -7
  263. package/src/helpers/mainThreadPressEvents.native.ts +42 -2
  264. package/src/helpers/mergeProps.ts +1 -1
  265. package/src/helpers/normalizeStyle.ts +23 -1
  266. package/src/helpers/platformResolveValue.native.ts +4 -1
  267. package/src/helpers/platformResolveValue.ts +5 -1
  268. package/src/helpers/pointerEvents.native.ts +26 -19
  269. package/src/helpers/propMapper.ts +61 -6
  270. package/src/helpers/resolveSafeArea.native.ts +1 -1
  271. package/src/helpers/styleOriginalValues.ts +2 -0
  272. package/src/helpers/styleProvenance.ts +49 -0
  273. package/src/helpers/wrapStyleTags.tsx +63 -20
  274. package/src/hooks/getThemeProxied.ts +14 -8
  275. package/src/hooks/useComponentState.ts +56 -4
  276. package/src/hooks/useMedia.tsx +156 -43
  277. package/src/hooks/useTheme.tsx +28 -6
  278. package/src/hooks/useThemeState.ts +284 -142
  279. package/src/index.ts +9 -1
  280. package/src/interfaces/GuiComponentPropsBaseBase.tsx +2 -2
  281. package/src/opacityModifier.test-d.ts +65 -0
  282. package/src/styled.tsx +1 -1
  283. package/src/styledNonStyleProps.test-d.ts +106 -0
  284. package/src/types.tsx +120 -22
  285. package/src/views/GuiProvider.tsx +2 -2
  286. package/src/views/Text.tsx +1 -0
  287. package/src/views/Theme.tsx +4 -1
  288. package/tsconfig.json +44 -0
  289. package/tsconfig.test.json +9 -0
  290. package/types/_withStableStyle.d.ts.map +1 -1
  291. package/types/config.d.ts +3 -1
  292. package/types/config.d.ts.map +1 -1
  293. package/types/constants/constants.d.ts +1 -1
  294. package/types/constants/constants.d.ts.map +1 -1
  295. package/types/createComponent.d.ts.map +1 -1
  296. package/types/eventHandling.d.ts +2 -2
  297. package/types/eventHandling.d.ts.map +1 -1
  298. package/types/eventHandling.native.d.ts +3 -3
  299. package/types/eventHandling.native.d.ts.map +1 -1
  300. package/types/helpers/expandStyle.d.ts +2 -1
  301. package/types/helpers/expandStyle.d.ts.map +1 -1
  302. package/types/helpers/getSplitStyles.d.ts +4 -2
  303. package/types/helpers/getSplitStyles.d.ts.map +1 -1
  304. package/types/helpers/getVariantExtras.d.ts.map +1 -1
  305. package/types/helpers/mainThreadPressEvents.native.d.ts.map +1 -1
  306. package/types/helpers/normalizeStyle.d.ts.map +1 -1
  307. package/types/helpers/platformResolveValue.d.ts.map +1 -1
  308. package/types/helpers/platformResolveValue.native.d.ts.map +1 -1
  309. package/types/helpers/pointerEvents.native.d.ts.map +1 -1
  310. package/types/helpers/propMapper.d.ts.map +1 -1
  311. package/types/helpers/styleOriginalValues.d.ts +2 -0
  312. package/types/helpers/styleOriginalValues.d.ts.map +1 -0
  313. package/types/helpers/styleProvenance.d.ts +11 -0
  314. package/types/helpers/styleProvenance.d.ts.map +1 -0
  315. package/types/helpers/wrapStyleTags.d.ts +1 -1
  316. package/types/helpers/wrapStyleTags.d.ts.map +1 -1
  317. package/types/hooks/getThemeProxied.d.ts.map +1 -1
  318. package/types/hooks/useComponentState.d.ts +2 -1
  319. package/types/hooks/useComponentState.d.ts.map +1 -1
  320. package/types/hooks/useMedia.d.ts.map +1 -1
  321. package/types/hooks/useTheme.d.ts +1 -1
  322. package/types/hooks/useTheme.d.ts.map +1 -1
  323. package/types/hooks/useThemeState.d.ts +1 -1
  324. package/types/hooks/useThemeState.d.ts.map +1 -1
  325. package/types/index.d.ts +3 -3
  326. package/types/index.d.ts.map +1 -1
  327. package/types/interfaces/GuiComponentPropsBaseBase.d.ts +2 -2
  328. package/types/types.d.ts +33 -16
  329. package/types/types.d.ts.map +1 -1
  330. package/types/views/Configuration.d.ts +1 -1
  331. package/types/views/Configuration.d.ts.map +1 -1
  332. package/types/views/FontLanguage.d.ts +1 -1
  333. package/types/views/FontLanguage.native.d.ts +1 -2
  334. package/types/views/FontLanguage.native.d.ts.map +1 -1
  335. package/types/views/GuiProvider.d.ts +1 -2
  336. package/types/views/GuiProvider.d.ts.map +1 -1
  337. package/types/views/GuiRoot.d.ts +1 -1
  338. package/types/views/GuiRoot.d.ts.map +1 -1
  339. package/types/views/Slot.d.ts +1 -1
  340. package/types/views/Text.d.ts.map +1 -1
  341. package/types/views/Theme.d.ts.map +1 -1
  342. package/types/views/ThemeProvider.d.ts +1 -1
  343. package/types/views/ThemeProvider.d.ts.map +1 -1
  344. package/vitest.config.d.ts +3 -0
  345. package/vitest.config.d.ts.map +1 -0
  346. package/vitest.config.ts +14 -0
  347. package/LICENSE +0 -42
@@ -1,8 +1,9 @@
1
1
  import {
2
+ getPlatformDriver,
2
3
  isAndroid,
3
4
  isClient,
4
- isIos,
5
5
  isWeb,
6
+ supportsDynamicColorIOS,
6
7
  useIsomorphicLayoutEffect,
7
8
  } from '@hanzogui/constants'
8
9
  import {
@@ -72,19 +73,24 @@ import {
72
73
  } from './pseudoDescriptors'
73
74
  import { skipProps } from './skipProps'
74
75
  import { sortString } from './sortString'
76
+ import { styleOriginalValues } from './styleOriginalValues'
77
+ import { type StyleTokenProvenance, setStyleTokenProvenance } from './styleProvenance'
75
78
  import { transformsToString } from './transformsToString'
76
79
 
80
+ export { styleOriginalValues }
81
+ export { getStyleTokenProvenance, STYLE_TOKEN_PROVENANCE_KEY } from './styleProvenance'
82
+ export type { StyleTokenBinding, StyleTokenProvenance } from './styleProvenance'
83
+
77
84
  export type SplitStyles = ReturnType<typeof getSplitStyles>
78
85
 
86
+ const shouldTrackStyleTokenProvenance =
87
+ process.env.NODE_ENV === 'development' &&
88
+ process.env.GUI_ENABLE_STYLE_TOKEN_PROVENANCE === '1'
89
+
79
90
  export type SplitStyleResult = ReturnType<typeof getSplitStyles>
80
91
 
81
92
  let conf: GuiInternalConfig
82
93
 
83
- // WeakMap to track original token values for style objects
84
- // Used to preserve '$8' style tokens instead of resolved 'var(--t-space-8)'
85
- // for context prop propagation to children (issues #3670, #3676)
86
- export const styleOriginalValues = new WeakMap<object, Record<string, any>>()
87
-
88
94
  type StyleSplitter = (
89
95
  props: { [key: string]: any },
90
96
  staticConfig: StaticConfig,
@@ -155,6 +161,16 @@ function isValidStyleKey(
155
161
  return key in validStyles ? true : accept && key in accept
156
162
  }
157
163
 
164
+ function shouldSkipNativeHoverProp(key: string, isMedia: false | boolean | string) {
165
+ if (process.env.GUI_TARGET !== 'native') return false
166
+ if (getPlatformDriver()?.pseudo) return false
167
+ if (key === 'hoverStyle') return true
168
+ if (isMedia === 'group') {
169
+ return getGroupPropParts(key.slice(1)).pseudo === 'hover'
170
+ }
171
+ return false
172
+ }
173
+
158
174
  export const getSplitStyles: StyleSplitter = (
159
175
  props,
160
176
  staticConfig,
@@ -307,6 +323,18 @@ export const getSplitStyles: StyleSplitter = (
307
323
  continue
308
324
  }
309
325
 
326
+ // native: data-* attributes never become native props (they're stripped
327
+ // further down anyway), and the compiler-emitted data-disable-theme/-media
328
+ // flags are already consumed in createComponent. skip them before any per-prop
329
+ // work so they don't pay the isValidStyleKey + handling cost on the hot path.
330
+ if (
331
+ process.env.GUI_TARGET === 'native' &&
332
+ keyInit[0] === 'd' &&
333
+ keyInit.startsWith('data-')
334
+ ) {
335
+ continue
336
+ }
337
+
310
338
  if (
311
339
  process.env.NODE_ENV === 'development' &&
312
340
  (debug === 'profile' || (globalThis as any).time)
@@ -372,14 +400,20 @@ export const getSplitStyles: StyleSplitter = (
372
400
  addStyleToInsertRules(rulesToInsert, containerCSS)
373
401
  }
374
402
  }
375
- // transition prop is skipped when it's a named animation (e.g. 'quick')
376
- // but raw CSS values (from $platform-web) should pass through as style
377
- if (
378
- keyInit === 'transition' &&
379
- typeof valInit === 'string' &&
380
- !driver?.animations?.[valInit]
381
- ) {
382
- // not a known animation name, treat as raw CSS
403
+ if (keyInit === 'transition' && typeof valInit === 'string') {
404
+ const animationConfig = driver?.animations?.[valInit]
405
+ if (
406
+ animationConfig &&
407
+ driver?.outputStyle === 'css' &&
408
+ process.env.IS_STATIC === 'is_static'
409
+ ) {
410
+ // css output needs no runtime component: lower its named transition
411
+ // to ordinary css so the compiler can keep flattening.
412
+ valInit = `all ${animationConfig}`
413
+ } else if (animationConfig) {
414
+ continue
415
+ }
416
+ // unknown names are raw CSS transition values and pass through.
383
417
  } else {
384
418
  continue
385
419
  }
@@ -424,8 +458,10 @@ export const getSplitStyles: StyleSplitter = (
424
458
 
425
459
  if (keyInit === 'disabled' && valInit === true) {
426
460
  viewProps['aria-disabled'] = true
427
- // Enhance with native semantics
461
+ // isInput: Input/TextArea wrap the real <input>/<textarea> in a styleable, so
462
+ // elementType is the wrapper here - forward disabled down or it never reaches it
428
463
  if (
464
+ isInput ||
429
465
  elementType === 'button' ||
430
466
  elementType === 'form' ||
431
467
  elementType === 'input' ||
@@ -481,6 +517,10 @@ export const getSplitStyles: StyleSplitter = (
481
517
 
482
518
  const isStyleProp = isValidStyleKeyInit || isMediaOrPseudo || (isVariant && !noExpand)
483
519
 
520
+ if (shouldSkipNativeHoverProp(keyInit, isMedia)) {
521
+ continue
522
+ }
523
+
484
524
  if (isStyleProp && (asChild === 'except-style' || asChild === 'except-style-web')) {
485
525
  continue
486
526
  }
@@ -625,6 +665,10 @@ export const getSplitStyles: StyleSplitter = (
625
665
  key = normalizeGroupKey(key, groupContext)
626
666
  }
627
667
 
668
+ if (shouldSkipNativeHoverProp(key, isMedia)) {
669
+ return
670
+ }
671
+
628
672
  if (
629
673
  inlineProps?.has(key) ||
630
674
  (process.env.IS_STATIC === 'is_static' && inlineWhenUnflattened?.has(key))
@@ -875,7 +919,7 @@ export const getSplitStyles: StyleSplitter = (
875
919
  if (isThemeMedia) {
876
920
  if (
877
921
  process.env.GUI_TARGET === 'native' &&
878
- isIos &&
922
+ supportsDynamicColorIOS &&
879
923
  getSetting('fastSchemeChange')
880
924
  ) {
881
925
  // iOS will use https://reactnative.dev/docs/dynamiccolorios
@@ -948,6 +992,10 @@ export const getSplitStyles: StyleSplitter = (
948
992
  const groupPseudoKey = groupInfo.pseudo
949
993
  const groupMediaKey = groupInfo.media
950
994
 
995
+ if (process.env.GUI_TARGET === 'native' && groupPseudoKey === 'hover') {
996
+ return
997
+ }
998
+
951
999
  if (!groupState) {
952
1000
  if (process.env.NODE_ENV === 'development' && debug) {
953
1001
  log(`No parent with group prop, skipping styles: ${groupName}`)
@@ -1105,7 +1153,7 @@ export const getSplitStyles: StyleSplitter = (
1105
1153
  const nestedImportance = outerBase + importanceBump + innerBase + 1
1106
1154
 
1107
1155
  for (const subSubKey in nestedVal) {
1108
- // expand shorthands getSubStyle doesn't expand keys
1156
+ // expand shorthands, getSubStyle doesn't expand keys
1109
1157
  // inside nested $ objects (they pass through propMapper as-is)
1110
1158
  const expandedKey = shorthands[subSubKey] || subSubKey
1111
1159
  const { usedKeys } = styleState
@@ -1337,7 +1385,18 @@ export const getSplitStyles: StyleSplitter = (
1337
1385
  Object.assign(styleState.classNames, style)
1338
1386
  } else {
1339
1387
  styleState.style ||= {}
1340
- Object.assign(styleState.style, normalizeStyle(style))
1388
+ const normalized = normalizeStyle(style)
1389
+ Object.assign(styleState.style, normalized)
1390
+ if (shouldTrackStyleTokenProvenance) {
1391
+ // the literal style prop is merged last and wins: carry its own
1392
+ // token provenance forward, and clear a prior token wherever it
1393
+ // supplies a literal (e.g. style={{ color: '#fff' }} over
1394
+ // color="$color9" must stay a literal).
1395
+ const styleOriginals = styleOriginalValues.get(normalized)
1396
+ for (const k in normalized) {
1397
+ recordStyleTokenProvenance(styleState, k, styleOriginals?.[k])
1398
+ }
1399
+ }
1341
1400
  }
1342
1401
  }
1343
1402
  }
@@ -1379,6 +1438,22 @@ export const getSplitStyles: StyleSplitter = (
1379
1438
  time`split-styles-pre-result`
1380
1439
  }
1381
1440
 
1441
+ // stamp exact token provenance onto the final winning style object. on native
1442
+ // (and non-className web) this is the same identity assigned to viewProps.style,
1443
+ // so a consumer inspecting the host node's style can recover the token + theme
1444
+ // behind each resolved value without any enumerable-key or RN-output change.
1445
+ if (shouldTrackStyleTokenProvenance && styleState.style && styleState.tokenProvenance) {
1446
+ const provenance: StyleTokenProvenance = {}
1447
+ let hasProvenance = false
1448
+ for (const key in styleState.tokenProvenance) {
1449
+ provenance[key] = { token: styleState.tokenProvenance[key], theme: themeName }
1450
+ hasProvenance = true
1451
+ }
1452
+ if (hasProvenance) {
1453
+ setStyleTokenProvenance(styleState.style, provenance)
1454
+ }
1455
+ }
1456
+
1382
1457
  const result: GetStyleResult = {
1383
1458
  hasMedia,
1384
1459
  fontFamily: styleState.fontFamily,
@@ -1526,9 +1601,9 @@ function mergeStyle(
1526
1601
  return
1527
1602
  }
1528
1603
 
1529
- // Track context overrides for pseudo/media styles (issues #3670, #3676)
1530
- // When a style sets a key that's in context props, update overriddenContextProps
1531
- // so it propagates to children. Use the original token value (like '$8')
1604
+ // track context overrides for pseudo/media styles (issues #3670, #3676)
1605
+ // when a style sets a key that's in context props, update overriddenContextProps
1606
+ // so it propagates to children. use the original token value (like '$8')
1532
1607
  // instead of the resolved CSS variable (like 'var(--t-space-8)')
1533
1608
  // so children's functional variants can look up token values.
1534
1609
  const contextProps =
@@ -1560,10 +1635,32 @@ function mergeStyle(
1560
1635
  // if you dont do this you'll be passing props.transform arrays directly here and then mutating them
1561
1636
  // if theres any flatTransforms later, causing issues (mutating props is bad, in strict mode styles get borked)
1562
1637
  key === 'transform' && Array.isArray(out) ? [...out] : out
1638
+ if (shouldTrackStyleTokenProvenance) {
1639
+ // dev-tools token provenance: this write is the current winner for `key`
1640
+ // (importance-gated above), so record the token that produced it, or clear
1641
+ // a prior token when a literal wins, keeping literal-over-token exact.
1642
+ recordStyleTokenProvenance(styleState, key, originalVal)
1643
+ }
1563
1644
  }
1564
1645
  }
1565
1646
  }
1566
1647
 
1648
+ // track which token produced the winning value for a style key so the final
1649
+ // style object can expose exact provenance. only the base (painted) style is
1650
+ // tracked — pseudo/media writes flow through mergeStyle at their real importance,
1651
+ // and a literal override clears any earlier token for that key.
1652
+ function recordStyleTokenProvenance(
1653
+ styleState: GetStyleState,
1654
+ key: string,
1655
+ originalVal: any
1656
+ ) {
1657
+ if (typeof originalVal === 'string' && originalVal[0] === '$') {
1658
+ ;(styleState.tokenProvenance ||= {})[key] = originalVal
1659
+ } else if (styleState.tokenProvenance && key in styleState.tokenProvenance) {
1660
+ delete styleState.tokenProvenance[key]
1661
+ }
1662
+ }
1663
+
1567
1664
  export const getSubStyle = (
1568
1665
  styleState: GetStyleState,
1569
1666
  subKey: string,
@@ -1573,61 +1670,70 @@ export const getSubStyle = (
1573
1670
  const { staticConfig, conf, styleProps } = styleState
1574
1671
  const styleOut: TextStyle = {}
1575
1672
  let originalValues: Record<string, any> | undefined
1576
-
1577
- for (let key in styleIn) {
1578
- const val = styleIn[key]
1579
- key = conf.shorthands[key] || key
1580
-
1581
- // extract transition from pseudo-style props (e.g., hoverStyle.transition)
1582
- // store it separately for animation drivers to use for enter/exit timing
1583
- if (key === 'transition') {
1584
- styleState.pseudoTransitions ||= {}
1585
- styleState.pseudoTransitions[subKey as keyof typeof styleState.pseudoTransitions] =
1586
- val
1587
- // for CSS driver, also add transition to CSS output so native CSS transitions work
1588
- // group styles ($group-*) need !important to override inline base transition
1589
- const driver = styleState.animationDriver
1590
- if (driver?.outputStyle === 'css') {
1591
- const animationConfig = driver.animations?.[val as string]
1592
- if (animationConfig) {
1593
- const important = subKey[0] === '$' ? ' !important' : ''
1594
- styleOut['transition'] = `all ${animationConfig}${important}`
1673
+ const styleInOriginalValues = styleOriginalValues.get(styleIn)
1674
+ const parentProps = styleState.props
1675
+ styleState.props = { ...parentProps, ...styleIn }
1676
+
1677
+ try {
1678
+ for (let key in styleIn) {
1679
+ const val = styleIn[key]
1680
+ key = conf.shorthands[key] || key
1681
+
1682
+ // extract transition from pseudo-style props (e.g., hoverStyle.transition)
1683
+ // store it separately for animation drivers to use for enter/exit timing
1684
+ if (key === 'transition') {
1685
+ styleState.pseudoTransitions ||= {}
1686
+ styleState.pseudoTransitions[
1687
+ subKey as keyof typeof styleState.pseudoTransitions
1688
+ ] = val
1689
+ // for CSS driver, also add transition to CSS output so native CSS transitions work
1690
+ // group styles ($group-*) need !important to override inline base transition
1691
+ const driver = styleState.animationDriver
1692
+ if (driver?.outputStyle === 'css') {
1693
+ const animationConfig = driver.animations?.[val as string]
1694
+ if (animationConfig) {
1695
+ const important = subKey[0] === '$' ? ' !important' : ''
1696
+ styleOut['transition'] = `all ${animationConfig}${important}`
1697
+ }
1698
+ }
1699
+ // not a known animation name, pass through as raw CSS
1700
+ if (
1701
+ !styleOut['transition'] &&
1702
+ typeof val === 'string' &&
1703
+ !driver?.animations?.[val]
1704
+ ) {
1705
+ styleOut['transition'] = val
1595
1706
  }
1707
+ continue
1596
1708
  }
1597
- // not a known animation name, pass through as raw CSS
1598
- if (
1599
- !styleOut['transition'] &&
1600
- typeof val === 'string' &&
1601
- !driver?.animations?.[val]
1602
- ) {
1603
- styleOut['transition'] = val
1709
+
1710
+ const shouldSkip = !staticConfig.isHOC && key in skipProps && !styleProps.noSkip
1711
+ if (shouldSkip) {
1712
+ continue
1604
1713
  }
1605
- continue
1606
- }
1607
1714
 
1608
- const shouldSkip = !staticConfig.isHOC && key in skipProps && !styleProps.noSkip
1609
- if (shouldSkip) {
1610
- continue
1715
+ propMapper(key, val, styleState, false, (skey, sval, originalVal) => {
1716
+ // track original values for context prop propagation
1717
+ const trackedOriginalVal = styleInOriginalValues?.[skey] ?? originalVal
1718
+ if (trackedOriginalVal !== undefined) {
1719
+ originalValues ||= {}
1720
+ originalValues[skey] = trackedOriginalVal
1721
+ }
1722
+ // pseudo inside media
1723
+ if (skey in validPseudoKeys) {
1724
+ sval = getSubStyle(styleState, skey, sval, avoidMergeTransform)
1725
+ }
1726
+ if (!avoidMergeTransform && skey in stylePropsTransform) {
1727
+ mergeTransform(styleOut, skey, sval)
1728
+ } else {
1729
+ styleOut[skey] = styleProps.noNormalize
1730
+ ? sval
1731
+ : normalizeValueWithProperty(sval, key)
1732
+ }
1733
+ })
1611
1734
  }
1612
-
1613
- propMapper(key, val, styleState, false, (skey, sval, originalVal) => {
1614
- // Track original values for context prop propagation
1615
- if (originalVal !== undefined) {
1616
- originalValues ||= {}
1617
- originalValues[skey] = originalVal
1618
- }
1619
- // pseudo inside media
1620
- if (skey in validPseudoKeys) {
1621
- sval = getSubStyle(styleState, skey, sval, avoidMergeTransform)
1622
- }
1623
- if (!avoidMergeTransform && skey in stylePropsTransform) {
1624
- mergeTransform(styleOut, skey, sval)
1625
- } else {
1626
- styleOut[skey] = styleProps.noNormalize
1627
- ? sval
1628
- : normalizeValueWithProperty(sval, key)
1629
- }
1630
- })
1735
+ } finally {
1736
+ styleState.props = parentProps
1631
1737
  }
1632
1738
 
1633
1739
  if (!avoidMergeTransform) {
@@ -1680,7 +1786,7 @@ export const getSubStyle = (
1680
1786
  }
1681
1787
 
1682
1788
  // Store original values in WeakMap instead of on the object itself
1683
- if (originalValues) {
1789
+ if (originalValues && Object.keys(originalValues).length) {
1684
1790
  styleOriginalValues.set(styleOut, originalValues)
1685
1791
  }
1686
1792
 
@@ -98,12 +98,12 @@ export const getTokenForKey = (
98
98
 
99
99
  valOrVar = themeValue
100
100
  if (process.env.NODE_ENV === 'development' && styleState.debug === 'verbose') {
101
- globalThis.guiAvoidTracking = true
101
+ globalThis.hanzoguiAvoidTracking = true
102
102
  console.info(
103
103
  ` - resolving ${key} to theme value ${value} resolveAs ${resolveAs}`,
104
104
  valOrVar
105
105
  )
106
- globalThis.guiAvoidTracking = false
106
+ globalThis.hanzoguiAvoidTracking = false
107
107
  }
108
108
  hasSet = true
109
109
  } else {
@@ -150,7 +150,7 @@ export const getTokenForKey = (
150
150
  if (!didLogMissingToken) {
151
151
  didLogMissingToken = true
152
152
  console.groupCollapsed(
153
- `[gui] Warning: missing token ${key} in category ${cat} - ${value} (open for details)`
153
+ `[hanzogui] Warning: missing token ${key} in category ${cat} - ${value} (open for details)`
154
154
  )
155
155
  console.info(
156
156
  `Note: this could just be due to you not setting all the theme tokens Gui expects, which is harmless, but
@@ -192,9 +192,9 @@ export const getTokenForKey = (
192
192
  }
193
193
 
194
194
  if (process.env.NODE_ENV === 'development' && styleState.debug === 'verbose') {
195
- globalThis.guiAvoidTracking = true
195
+ globalThis.hanzoguiAvoidTracking = true
196
196
  console.info(`resolved`, resolveAs, valOrVar, out)
197
- globalThis.guiAvoidTracking = false
197
+ globalThis.hanzoguiAvoidTracking = false
198
198
  }
199
199
  return out
200
200
  }
@@ -2,11 +2,12 @@ import { getSetting } from '../config'
2
2
  import { getVariableValue } from '../createVariable'
3
3
  import type { GenericFonts, GetStyleState, LanguageContextType } from '../types'
4
4
 
5
- const cache = new WeakMap()
5
+ const cache = new WeakMap<GetStyleState, { props: GetStyleState['props']; value: any }>()
6
6
 
7
7
  export const getVariantExtras = (styleState: GetStyleState) => {
8
- if (cache.has(styleState)) {
9
- return cache.get(styleState)
8
+ const cached = cache.get(styleState)
9
+ if (cached?.props === styleState.props) {
10
+ return cached.value
10
11
  }
11
12
 
12
13
  const { props, conf, context, theme, styleProps } = styleState
@@ -39,7 +40,7 @@ export const getVariantExtras = (styleState: GetStyleState) => {
39
40
  props,
40
41
  }
41
42
 
42
- cache.set(styleState, next)
43
+ cache.set(styleState, { props, value: next })
43
44
 
44
45
  return next as any
45
46
  }
@@ -8,7 +8,7 @@ import type {
8
8
  TokensParsed,
9
9
  } from '../types'
10
10
 
11
- // only cache gui styles
11
+ // only cache hanzogui styles
12
12
  // TODO merge totalSelectorsInserted and allSelectors?
13
13
  const scannedCache = new WeakMap<CSSStyleSheet, string>()
14
14
  const totalSelectorsInserted = new Map<string, number>()
@@ -135,7 +135,7 @@ function updateSheetStyles(
135
135
  } else {
136
136
  fails++
137
137
  if (fails > bailAfter) {
138
- // conservatively bail out of non-gui sheets
138
+ // conservatively bail out of non-hanzogui sheets
139
139
  return
140
140
  }
141
141
  continue
@@ -249,7 +249,7 @@ function addThemesFromCSS(cssStyleRule: CSSStyleRule, tokens?: TokensParsed) {
249
249
  } satisfies DedupedTheme
250
250
  }
251
251
 
252
- const guiSelectorRegex = /\.tm_xxt/
252
+ const hanzoguiSelectorRegex = /\.tm_xxt/
253
253
 
254
254
  function getGuiSelector(
255
255
  rule: CSSRule | null,
@@ -259,15 +259,15 @@ function getGuiSelector(
259
259
  const text = rule.selectorText
260
260
 
261
261
  // only matches t_ starting selector chains
262
- if (text[0] === ':' && text[1] === 'r' && guiSelectorRegex.test(text)) {
262
+ if (text[0] === ':' && text[1] === 'r' && hanzoguiSelectorRegex.test(text)) {
263
263
  const id = getIdentifierFromGuiSelector(
264
264
  // next.js minifies it so its in front
265
- text.replace(guiSelectorRegex, '')
265
+ text.replace(hanzoguiSelectorRegex, '')
266
266
  )
267
267
  return collectThemes ? [id, rule, true] : [id, rule]
268
268
  }
269
269
  } else if (rule instanceof CSSMediaRule) {
270
- // gui only ever inserts 1 rule per media
270
+ // hanzogui only ever inserts 1 rule per media
271
271
  if (rule.cssRules.length > 1) return
272
272
  return getGuiSelector(rule.cssRules[0])
273
273
  }
@@ -305,7 +305,7 @@ export function insertStyleRules(rulesToInsert: RulesToInsert) {
305
305
 
306
306
  if (!sheet && document.head) {
307
307
  const styleTag = document.createElement('style')
308
- styleTag.id = '_gui-styles'
308
+ styleTag.id = '_hanzogui-styles'
309
309
  if (nonce) {
310
310
  styleTag.nonce = nonce
311
311
  }
@@ -6,6 +6,7 @@
6
6
  * long press, cancellation, and min press duration.
7
7
  */
8
8
 
9
+ import { unstable_hasExternalPressOwnership } from '@hanzogui/native'
9
10
  import { useRef } from 'react'
10
11
 
11
12
  type PressState =
@@ -20,6 +21,7 @@ interface PressRef {
20
21
  pressOutTimer: ReturnType<typeof setTimeout> | null
21
22
  longPressTimer: ReturnType<typeof setTimeout> | null
22
23
  activateTime: number
24
+ blockedByExternalOwnership: boolean
23
25
  }
24
26
 
25
27
  const DEFAULT_LONG_PRESS_DELAY = 500
@@ -39,6 +41,7 @@ export function useMainThreadPressEvents(
39
41
  pressOutTimer: null,
40
42
  longPressTimer: null,
41
43
  activateTime: 0,
44
+ blockedByExternalOwnership: false,
42
45
  }
43
46
  }
44
47
 
@@ -80,10 +83,34 @@ export function useMainThreadPressEvents(
80
83
  ref.current.longPressTimer = null
81
84
  }
82
85
 
83
- viewProps.onStartShouldSetResponder = () => !events.disabled
86
+ // user-supplied responder props (the View's raw RN gesture API) must keep
87
+ // working: blindly overwriting them here silently killed any press-hold-drag
88
+ // gesture built on onResponderMove/onResponderRelease whenever the element
89
+ // also had hover/press events. compose instead — user handler first, then
90
+ // the press synthesis.
91
+ const userStartShouldSet = viewProps.onStartShouldSetResponder
92
+ const userGrant = viewProps.onResponderGrant
93
+ const userRelease = viewProps.onResponderRelease
94
+ const userTerminate = viewProps.onResponderTerminate
95
+ const userTerminationRequest = viewProps.onResponderTerminationRequest
96
+ const userMove = viewProps.onResponderMove
97
+
98
+ viewProps.onStartShouldSetResponder = (e: any) => {
99
+ if (userStartShouldSet?.(e)) return true
100
+ return !events.disabled && !unstable_hasExternalPressOwnership()
101
+ }
84
102
 
85
103
  viewProps.onResponderGrant = (e: any) => {
86
104
  cleanup()
105
+
106
+ if (unstable_hasExternalPressOwnership()) {
107
+ ref.current.state = 'idle'
108
+ ref.current.blockedByExternalOwnership = true
109
+ return
110
+ }
111
+
112
+ userGrant?.(e)
113
+ ref.current.blockedByExternalOwnership = false
87
114
  ref.current.state = 'pressing'
88
115
 
89
116
  if (delayPressIn > 0) {
@@ -103,6 +130,14 @@ export function useMainThreadPressEvents(
103
130
  }
104
131
 
105
132
  viewProps.onResponderRelease = (e: any) => {
133
+ if (ref.current.blockedByExternalOwnership || unstable_hasExternalPressOwnership()) {
134
+ cleanup()
135
+ ref.current.blockedByExternalOwnership = false
136
+ ref.current.state = 'idle'
137
+ return
138
+ }
139
+
140
+ userRelease?.(e)
106
141
  const wasLongPressed = ref.current.state === 'longPressed'
107
142
  cleanup()
108
143
 
@@ -117,21 +152,26 @@ export function useMainThreadPressEvents(
117
152
 
118
153
  deactivate(e)
119
154
  ref.current.state = 'idle'
155
+ ref.current.blockedByExternalOwnership = false
120
156
  }
121
157
 
122
158
  viewProps.onResponderTerminate = (e: any) => {
159
+ userTerminate?.(e)
123
160
  cleanup()
124
161
  if (ref.current.state === 'active' || ref.current.state === 'longPressed') {
125
162
  deactivate(e)
126
163
  }
127
164
  ref.current.state = 'idle'
165
+ ref.current.blockedByExternalOwnership = false
128
166
  }
129
167
 
130
- viewProps.onResponderTerminationRequest = () => {
168
+ viewProps.onResponderTerminationRequest = (e: any) => {
169
+ if (userTerminationRequest) return userTerminationRequest(e)
131
170
  return events.cancelable !== false
132
171
  }
133
172
 
134
173
  viewProps.onResponderMove = (e: any) => {
174
+ userMove?.(e)
135
175
  events.onPressMove?.(e)
136
176
  }
137
177
  }
@@ -102,7 +102,7 @@ function mergeProp(
102
102
  ) {
103
103
  let val = props[key]
104
104
 
105
- // one special case - we merge gui style sub-objects
105
+ // one special case - we merge hanzogui style sub-objects
106
106
  if (
107
107
  defaultProps &&
108
108
  key in defaultProps &&
@@ -3,6 +3,7 @@ import { fixStyles } from './expandStyles'
3
3
  import { isObj } from './isObj'
4
4
  import { normalizeValueWithProperty } from './normalizeValueWithProperty'
5
5
  import { pseudoDescriptors } from './pseudoDescriptors'
6
+ import { styleOriginalValues } from './styleOriginalValues'
6
7
 
7
8
  /**
8
9
  * This is what you want to run before Object.assign() a style onto another.
@@ -14,29 +15,50 @@ import { pseudoDescriptors } from './pseudoDescriptors'
14
15
 
15
16
  export function normalizeStyle(style: Record<string, any>, disableNormalize = false) {
16
17
  const res: Record<string, any> = {}
18
+ const originalValues = styleOriginalValues.get(style)
19
+ let nextOriginalValues: Record<string, any> | undefined
17
20
 
18
21
  for (let key in style) {
19
22
  const prop = style[key]
20
23
  if (prop == null) continue
24
+ const originalValue = originalValues?.[key]
21
25
  if (
22
26
  key in pseudoDescriptors ||
23
27
  // this should capture all parent-based styles like media, group, etc
24
28
  (key[0] === '$' && isObj(prop))
25
29
  ) {
26
30
  res[key] = normalizeStyle(prop, disableNormalize)
31
+ if (originalValue !== undefined) {
32
+ nextOriginalValues ||= {}
33
+ nextOriginalValues[key] = originalValue
34
+ }
27
35
  continue
28
36
  }
29
37
  const value = disableNormalize ? prop : normalizeValueWithProperty(prop, key)
30
38
  // expand react-native shorthands
31
39
  const out = expandStyle(key, value)
32
40
  if (out) {
33
- Object.assign(res, Object.fromEntries(out))
41
+ for (const [nextKey, nextValue] of out) {
42
+ res[nextKey] = nextValue
43
+ if (originalValue !== undefined) {
44
+ nextOriginalValues ||= {}
45
+ nextOriginalValues[nextKey] = originalValue
46
+ }
47
+ }
34
48
  } else {
35
49
  res[key] = value
50
+ if (originalValue !== undefined) {
51
+ nextOriginalValues ||= {}
52
+ nextOriginalValues[key] = originalValue
53
+ }
36
54
  }
37
55
  }
38
56
 
39
57
  fixStyles(res)
40
58
 
59
+ if (nextOriginalValues) {
60
+ styleOriginalValues.set(res, nextOriginalValues)
61
+ }
62
+
41
63
  return res
42
64
  }