@ankhorage/surface 7.0.0 → 9.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 (498) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/dist/{surfaceColor.d.ts → constants/surfaceColor.d.ts} +0 -4
  4. package/dist/constants/surfaceColor.d.ts.map +1 -0
  5. package/dist/constants/surfaceColor.js.map +1 -0
  6. package/dist/features/app-bar/adapters/inbound/AppBar.d.ts.map +1 -1
  7. package/dist/features/app-bar/adapters/inbound/AppBar.js +1 -1
  8. package/dist/features/app-bar/adapters/inbound/AppBar.js.map +1 -1
  9. package/dist/features/badge/adapters/inbound/Badge.d.ts.map +1 -1
  10. package/dist/features/badge/adapters/inbound/Badge.js +1 -1
  11. package/dist/features/badge/adapters/inbound/Badge.js.map +1 -1
  12. package/dist/features/button/adapters/inbound/Button.d.ts.map +1 -1
  13. package/dist/features/button/adapters/inbound/Button.js +6 -6
  14. package/dist/features/button/adapters/inbound/Button.js.map +1 -1
  15. package/dist/features/button/adapters/inbound/IconButton.d.ts.map +1 -1
  16. package/dist/features/button/adapters/inbound/IconButton.js +4 -4
  17. package/dist/features/button/adapters/inbound/IconButton.js.map +1 -1
  18. package/dist/features/card/adapters/inbound/Card.d.ts.map +1 -1
  19. package/dist/features/card/adapters/inbound/Card.js +4 -4
  20. package/dist/features/card/adapters/inbound/Card.js.map +1 -1
  21. package/dist/features/font/adapters/inbound/FontProvider.d.ts +4 -0
  22. package/dist/features/font/adapters/inbound/FontProvider.d.ts.map +1 -0
  23. package/dist/features/font/adapters/inbound/FontProvider.js +16 -0
  24. package/dist/features/font/adapters/inbound/FontProvider.js.map +1 -0
  25. package/dist/features/font/adapters/inbound/FontRuntimeContext.d.ts +4 -0
  26. package/dist/features/font/adapters/inbound/FontRuntimeContext.d.ts.map +1 -0
  27. package/dist/features/font/adapters/inbound/FontRuntimeContext.js +9 -0
  28. package/dist/features/font/adapters/inbound/FontRuntimeContext.js.map +1 -0
  29. package/dist/features/font/adapters/inbound/useFontRuntime.d.ts +4 -0
  30. package/dist/features/font/adapters/inbound/useFontRuntime.d.ts.map +1 -0
  31. package/dist/features/font/adapters/inbound/useFontRuntime.js +7 -0
  32. package/dist/features/font/adapters/inbound/useFontRuntime.js.map +1 -0
  33. package/dist/features/font/public.d.ts +3 -0
  34. package/dist/features/font/public.d.ts.map +1 -0
  35. package/dist/features/font/public.js +2 -0
  36. package/dist/features/font/public.js.map +1 -0
  37. package/dist/features/form/checkbox/adapters/inbound/Checkbox.d.ts.map +1 -1
  38. package/dist/features/form/checkbox/adapters/inbound/Checkbox.js +4 -4
  39. package/dist/features/form/checkbox/adapters/inbound/Checkbox.js.map +1 -1
  40. package/dist/features/form/radio/adapters/inbound/Radio.d.ts.map +1 -1
  41. package/dist/features/form/radio/adapters/inbound/Radio.js +4 -4
  42. package/dist/features/form/radio/adapters/inbound/Radio.js.map +1 -1
  43. package/dist/features/form/switch/adapters/inbound/Switch.d.ts.map +1 -1
  44. package/dist/features/form/switch/adapters/inbound/Switch.js +4 -4
  45. package/dist/features/form/switch/adapters/inbound/Switch.js.map +1 -1
  46. package/dist/features/form/text-input/adapters/inbound/TextInput.d.ts.map +1 -1
  47. package/dist/features/form/text-input/adapters/inbound/TextInput.js +1 -1
  48. package/dist/features/form/text-input/adapters/inbound/TextInput.js.map +1 -1
  49. package/dist/features/form/text-input/utils/resolveTextInputPresentation.d.ts +1 -1
  50. package/dist/features/form/text-input/utils/resolveTextInputPresentation.d.ts.map +1 -1
  51. package/dist/features/form/text-input/utils/resolveTextInputPresentation.js.map +1 -1
  52. package/dist/features/icon/adapters/inbound/Icon.d.ts.map +1 -1
  53. package/dist/features/icon/adapters/inbound/Icon.js +2 -2
  54. package/dist/features/icon/adapters/inbound/Icon.js.map +1 -1
  55. package/dist/features/image/adapters/inbound/Image.d.ts.map +1 -1
  56. package/dist/features/image/adapters/inbound/Image.js +1 -1
  57. package/dist/features/image/adapters/inbound/Image.js.map +1 -1
  58. package/dist/features/image/utils/resolveImageStyle.d.ts +1 -1
  59. package/dist/features/image/utils/resolveImageStyle.d.ts.map +1 -1
  60. package/dist/features/image/utils/resolveImageStyle.js +1 -1
  61. package/dist/features/image/utils/resolveImageStyle.js.map +1 -1
  62. package/dist/features/layout/adapters/inbound/Grid.d.ts.map +1 -1
  63. package/dist/features/layout/adapters/inbound/Grid.js +1 -1
  64. package/dist/features/layout/adapters/inbound/Grid.js.map +1 -1
  65. package/dist/features/layout/adapters/inbound/ScrollView.d.ts.map +1 -1
  66. package/dist/features/layout/adapters/inbound/ScrollView.js +1 -1
  67. package/dist/features/layout/adapters/inbound/ScrollView.js.map +1 -1
  68. package/dist/features/layout/adapters/inbound/View.d.ts.map +1 -1
  69. package/dist/features/layout/adapters/inbound/View.js +1 -1
  70. package/dist/features/layout/adapters/inbound/View.js.map +1 -1
  71. package/dist/features/list/adapters/inbound/ListItem.d.ts.map +1 -1
  72. package/dist/features/list/adapters/inbound/ListItem.js +4 -4
  73. package/dist/features/list/adapters/inbound/ListItem.js.map +1 -1
  74. package/dist/features/modal/adapters/inbound/Modal.d.ts.map +1 -1
  75. package/dist/features/modal/adapters/inbound/Modal.js +1 -1
  76. package/dist/features/modal/adapters/inbound/Modal.js.map +1 -1
  77. package/dist/features/popover-menu/adapters/inbound/PopoverMenu.d.ts.map +1 -1
  78. package/dist/features/popover-menu/adapters/inbound/PopoverMenu.js +1 -1
  79. package/dist/features/popover-menu/adapters/inbound/PopoverMenu.js.map +1 -1
  80. package/dist/features/pressable/adapters/inbound/Pressable.d.ts +5 -0
  81. package/dist/features/pressable/adapters/inbound/Pressable.d.ts.map +1 -0
  82. package/dist/features/pressable/adapters/inbound/Pressable.js +48 -0
  83. package/dist/features/pressable/adapters/inbound/Pressable.js.map +1 -0
  84. package/dist/features/pressable/public.d.ts +3 -0
  85. package/dist/features/pressable/public.d.ts.map +1 -0
  86. package/dist/features/pressable/public.js +2 -0
  87. package/dist/features/pressable/public.js.map +1 -0
  88. package/dist/features/surface/adapters/inbound/Surface.d.ts.map +1 -1
  89. package/dist/features/surface/adapters/inbound/Surface.js +1 -1
  90. package/dist/features/surface/adapters/inbound/Surface.js.map +1 -1
  91. package/dist/features/tabs/adapters/inbound/Tab.d.ts.map +1 -1
  92. package/dist/features/tabs/adapters/inbound/Tab.js +1 -1
  93. package/dist/features/tabs/adapters/inbound/Tab.js.map +1 -1
  94. package/dist/features/theme/adapters/inbound/ThemeProvider.d.ts +4 -0
  95. package/dist/features/theme/adapters/inbound/ThemeProvider.d.ts.map +1 -0
  96. package/dist/features/theme/adapters/inbound/ThemeProvider.js +27 -0
  97. package/dist/features/theme/adapters/inbound/ThemeProvider.js.map +1 -0
  98. package/dist/features/theme/adapters/inbound/ThemeRuntimeContext.d.ts +4 -0
  99. package/dist/features/theme/adapters/inbound/ThemeRuntimeContext.d.ts.map +1 -0
  100. package/dist/features/theme/adapters/inbound/ThemeRuntimeContext.js +11 -0
  101. package/dist/features/theme/adapters/inbound/ThemeRuntimeContext.js.map +1 -0
  102. package/dist/features/theme/adapters/inbound/ThemeScope.d.ts +4 -0
  103. package/dist/features/theme/adapters/inbound/ThemeScope.d.ts.map +1 -0
  104. package/dist/features/theme/adapters/inbound/ThemeScope.js +17 -0
  105. package/dist/features/theme/adapters/inbound/ThemeScope.js.map +1 -0
  106. package/dist/features/theme/adapters/inbound/useTheme.d.ts +4 -0
  107. package/dist/features/theme/adapters/inbound/useTheme.d.ts.map +1 -0
  108. package/dist/features/theme/adapters/inbound/useTheme.js +7 -0
  109. package/dist/features/theme/adapters/inbound/useTheme.js.map +1 -0
  110. package/dist/features/theme/application/use-cases/createTheme.d.ts +5 -0
  111. package/dist/features/theme/application/use-cases/createTheme.d.ts.map +1 -0
  112. package/dist/features/theme/application/use-cases/createTheme.js +56 -0
  113. package/dist/features/theme/application/use-cases/createTheme.js.map +1 -0
  114. package/dist/features/theme/constants.d.ts +10 -0
  115. package/dist/features/theme/constants.d.ts.map +1 -0
  116. package/dist/{theme/defaultTokens.js → features/theme/constants.js} +9 -2
  117. package/dist/features/theme/constants.js.map +1 -0
  118. package/dist/{theme → features/theme/domain}/createSurfaceColorDiagnosticCollector.d.ts +1 -1
  119. package/dist/features/theme/domain/createSurfaceColorDiagnosticCollector.d.ts.map +1 -0
  120. package/dist/features/theme/domain/createSurfaceColorDiagnosticCollector.js.map +1 -0
  121. package/dist/{theme → features/theme/domain}/createSurfaceSemanticPolicy.d.ts +1 -1
  122. package/dist/features/theme/domain/createSurfaceSemanticPolicy.d.ts.map +1 -0
  123. package/dist/{theme → features/theme/domain}/createSurfaceSemanticPolicy.js +1 -1
  124. package/dist/features/theme/domain/createSurfaceSemanticPolicy.js.map +1 -0
  125. package/dist/features/theme/domain/generatePalette.d.ts +10 -0
  126. package/dist/features/theme/domain/generatePalette.d.ts.map +1 -0
  127. package/dist/{theme/colorEngine.js → features/theme/domain/generatePalette.js} +2 -10
  128. package/dist/features/theme/domain/generatePalette.js.map +1 -0
  129. package/dist/{theme → features/theme/domain}/resolveRoleSemantics.d.ts +1 -1
  130. package/dist/features/theme/domain/resolveRoleSemantics.d.ts.map +1 -0
  131. package/dist/{theme → features/theme/domain}/resolveRoleSemantics.js +1 -1
  132. package/dist/features/theme/domain/resolveRoleSemantics.js.map +1 -0
  133. package/dist/features/theme/domain/resolveSemanticColors.d.ts +4 -0
  134. package/dist/features/theme/domain/resolveSemanticColors.d.ts.map +1 -0
  135. package/dist/features/theme/domain/resolveSemanticColors.js +10 -0
  136. package/dist/features/theme/domain/resolveSemanticColors.js.map +1 -0
  137. package/dist/{theme → features/theme/domain}/resolveSurfaceSemanticModel.d.ts +1 -1
  138. package/dist/features/theme/domain/resolveSurfaceSemanticModel.d.ts.map +1 -0
  139. package/dist/features/theme/domain/resolveSurfaceSemanticModel.js.map +1 -0
  140. package/dist/features/theme/public.d.ts +3 -0
  141. package/dist/features/theme/public.d.ts.map +1 -0
  142. package/dist/features/theme/public.js +2 -0
  143. package/dist/features/theme/public.js.map +1 -0
  144. package/dist/features/theme/runtime.d.ts +5 -0
  145. package/dist/features/theme/runtime.d.ts.map +1 -0
  146. package/dist/features/theme/runtime.js +4 -0
  147. package/dist/features/theme/runtime.js.map +1 -0
  148. package/dist/{theme → features/theme/utils}/resolveGlobalTokens.d.ts +1 -1
  149. package/dist/features/theme/utils/resolveGlobalTokens.d.ts.map +1 -0
  150. package/dist/{theme → features/theme/utils}/resolveGlobalTokens.js +1 -1
  151. package/dist/features/theme/utils/resolveGlobalTokens.js.map +1 -0
  152. package/dist/{theme → features/theme/utils}/resolveHeadingTokenOverrides.d.ts +1 -1
  153. package/dist/features/theme/utils/resolveHeadingTokenOverrides.d.ts.map +1 -0
  154. package/dist/features/theme/utils/resolveHeadingTokenOverrides.js.map +1 -0
  155. package/dist/features/theme/utils/resolveNumericTokenOverrides.d.ts.map +1 -0
  156. package/dist/features/theme/utils/resolveNumericTokenOverrides.js.map +1 -0
  157. package/dist/{theme → features/theme/utils}/resolveToken.d.ts +2 -8
  158. package/dist/features/theme/utils/resolveToken.d.ts.map +1 -0
  159. package/dist/features/theme/utils/resolveToken.js +10 -0
  160. package/dist/features/theme/utils/resolveToken.js.map +1 -0
  161. package/dist/{theme → features/theme/utils}/resolveWeightTokenOverrides.d.ts +1 -1
  162. package/dist/features/theme/utils/resolveWeightTokenOverrides.d.ts.map +1 -0
  163. package/dist/{theme → features/theme/utils}/resolveWeightTokenOverrides.js +3 -5
  164. package/dist/features/theme/utils/resolveWeightTokenOverrides.js.map +1 -0
  165. package/dist/features/toast/adapters/inbound/Toast.d.ts.map +1 -1
  166. package/dist/features/toast/adapters/inbound/Toast.js +1 -1
  167. package/dist/features/toast/adapters/inbound/Toast.js.map +1 -1
  168. package/dist/features/tooltip/adapters/inbound/Tooltip.d.ts.map +1 -1
  169. package/dist/features/tooltip/adapters/inbound/Tooltip.js +1 -1
  170. package/dist/features/tooltip/adapters/inbound/Tooltip.js.map +1 -1
  171. package/dist/features/typography/adapters/inbound/Heading.d.ts +2 -2
  172. package/dist/features/typography/adapters/inbound/Heading.d.ts.map +1 -1
  173. package/dist/features/typography/adapters/inbound/Heading.js +4 -20
  174. package/dist/features/typography/adapters/inbound/Heading.js.map +1 -1
  175. package/dist/features/typography/adapters/inbound/Text.d.ts +1 -1
  176. package/dist/features/typography/adapters/inbound/Text.d.ts.map +1 -1
  177. package/dist/features/typography/adapters/inbound/Text.js +3 -20
  178. package/dist/features/typography/adapters/inbound/Text.js.map +1 -1
  179. package/dist/features/typography/utils/resolveHeadingTextStyle.d.ts +2 -2
  180. package/dist/features/typography/utils/resolveHeadingTextStyle.d.ts.map +1 -1
  181. package/dist/features/typography/utils/resolveHeadingTextStyle.js.map +1 -1
  182. package/dist/index.d.ts +11 -12
  183. package/dist/index.d.ts.map +1 -1
  184. package/dist/index.js +5 -7
  185. package/dist/index.js.map +1 -1
  186. package/dist/internal/resolvers/resolveControlSize.d.ts +1 -1
  187. package/dist/internal/resolvers/resolveControlSize.js.map +1 -1
  188. package/dist/internal/resolvers/resolveFieldPresentation.d.ts +1 -1
  189. package/dist/internal/resolvers/resolveFieldPresentation.d.ts.map +1 -1
  190. package/dist/internal/resolvers/resolveFieldPresentation.js.map +1 -1
  191. package/dist/internal/resolvers/resolveIconSize.d.ts +1 -1
  192. package/dist/internal/resolvers/resolveIconSize.js.map +1 -1
  193. package/dist/internal/resolvers/resolveInteractiveColors.d.ts +2 -2
  194. package/dist/internal/resolvers/resolveInteractiveColors.d.ts.map +1 -1
  195. package/dist/internal/resolvers/resolveInteractiveColors.js.map +1 -1
  196. package/dist/internal/resolvers/resolveSelectionControlColors.d.ts +2 -2
  197. package/dist/internal/resolvers/resolveSelectionControlColors.d.ts.map +1 -1
  198. package/dist/internal/resolvers/resolveSelectionControlColors.js.map +1 -1
  199. package/dist/internal/resolvers/resolveSurfaceColor.d.ts +2 -2
  200. package/dist/internal/resolvers/resolveSurfaceColor.d.ts.map +1 -1
  201. package/dist/internal/resolvers/resolveSurfaceColor.js.map +1 -1
  202. package/dist/internal/resolvers/resolveTextColor.d.ts +2 -2
  203. package/dist/internal/resolvers/resolveTextColor.d.ts.map +1 -1
  204. package/dist/internal/resolvers/resolveTextColor.js.map +1 -1
  205. package/dist/internal/resolvers/resolveTextStyles.d.ts +1 -1
  206. package/dist/internal/resolvers/resolveTextStyles.js.map +1 -1
  207. package/dist/types/accordion.d.ts +1 -1
  208. package/dist/types/accordion.d.ts.map +1 -1
  209. package/dist/types/accordion.js.map +1 -1
  210. package/dist/types/badge.d.ts +1 -1
  211. package/dist/types/badge.d.ts.map +1 -1
  212. package/dist/types/badge.js.map +1 -1
  213. package/dist/types/button.d.ts +4 -4
  214. package/dist/types/button.d.ts.map +1 -1
  215. package/dist/types/button.js.map +1 -1
  216. package/dist/types/checkbox.d.ts +3 -3
  217. package/dist/types/checkbox.d.ts.map +1 -1
  218. package/dist/types/checkbox.js.map +1 -1
  219. package/dist/types/font.d.ts +13 -0
  220. package/dist/types/font.d.ts.map +1 -0
  221. package/dist/types/font.js +2 -0
  222. package/dist/types/font.js.map +1 -0
  223. package/dist/types/icon.d.ts +1 -1
  224. package/dist/types/icon.d.ts.map +1 -1
  225. package/dist/types/icon.js.map +1 -1
  226. package/dist/types/image.d.ts +1 -1
  227. package/dist/types/image.d.ts.map +1 -1
  228. package/dist/types/image.js.map +1 -1
  229. package/dist/types/interactionPolicy.d.ts.map +1 -0
  230. package/dist/types/interactionPolicy.js.map +1 -0
  231. package/dist/types/layout.d.ts +1 -1
  232. package/dist/types/layout.d.ts.map +1 -1
  233. package/dist/types/layout.js.map +1 -1
  234. package/dist/types/list.d.ts +1 -1
  235. package/dist/types/list.d.ts.map +1 -1
  236. package/dist/types/list.js.map +1 -1
  237. package/dist/types/modal.d.ts +1 -1
  238. package/dist/types/modal.d.ts.map +1 -1
  239. package/dist/types/modal.js.map +1 -1
  240. package/dist/types/popover.d.ts +1 -1
  241. package/dist/types/popover.d.ts.map +1 -1
  242. package/dist/types/popover.js.map +1 -1
  243. package/dist/types/popoverMenu.d.ts +1 -1
  244. package/dist/types/popoverMenu.d.ts.map +1 -1
  245. package/dist/types/popoverMenu.js.map +1 -1
  246. package/dist/{primitives/button-base/types.d.ts → types/pressable.d.ts} +5 -5
  247. package/dist/types/pressable.d.ts.map +1 -0
  248. package/dist/types/pressable.js +2 -0
  249. package/dist/types/pressable.js.map +1 -0
  250. package/dist/types/radio.d.ts +3 -3
  251. package/dist/types/radio.d.ts.map +1 -1
  252. package/dist/types/radio.js.map +1 -1
  253. package/dist/types/surfaceColor.d.ts +6 -0
  254. package/dist/types/surfaceColor.d.ts.map +1 -0
  255. package/dist/types/surfaceColor.js +2 -0
  256. package/dist/types/surfaceColor.js.map +1 -0
  257. package/dist/types/switch.d.ts +3 -3
  258. package/dist/types/switch.d.ts.map +1 -1
  259. package/dist/types/switch.js.map +1 -1
  260. package/dist/types/tabs.d.ts +1 -1
  261. package/dist/types/tabs.d.ts.map +1 -1
  262. package/dist/types/tabs.js.map +1 -1
  263. package/dist/types/text-input.d.ts +1 -1
  264. package/dist/types/text-input.d.ts.map +1 -1
  265. package/dist/types/text-input.js.map +1 -1
  266. package/dist/{theme/types.d.ts → types/theme.d.ts} +19 -3
  267. package/dist/types/theme.d.ts.map +1 -0
  268. package/dist/types/theme.js +2 -0
  269. package/dist/types/theme.js.map +1 -0
  270. package/dist/types/toast.d.ts +2 -2
  271. package/dist/types/toast.d.ts.map +1 -1
  272. package/dist/types/toast.js.map +1 -1
  273. package/dist/types/tooltip.d.ts +1 -1
  274. package/dist/types/tooltip.d.ts.map +1 -1
  275. package/dist/types/tooltip.js.map +1 -1
  276. package/dist/types/typography.d.ts +1 -1
  277. package/dist/types/typography.d.ts.map +1 -1
  278. package/dist/types/typography.js.map +1 -1
  279. package/dist/utils/resolveSpacing.d.ts +1 -1
  280. package/dist/utils/resolveSpacing.d.ts.map +1 -1
  281. package/dist/utils/resolveSpacing.js +1 -1
  282. package/dist/utils/resolveSpacing.js.map +1 -1
  283. package/dist/utils/resolveViewStyles.d.ts +1 -1
  284. package/dist/utils/resolveViewStyles.d.ts.map +1 -1
  285. package/dist/utils/resolveViewStyles.js +1 -1
  286. package/dist/utils/resolveViewStyles.js.map +1 -1
  287. package/package.json +8 -7
  288. package/src/constants/surfaceColor.test.ts +18 -0
  289. package/src/{surfaceColor.ts → constants/surfaceColor.ts} +0 -5
  290. package/src/features/app-bar/adapters/inbound/AppBar.tsx +1 -1
  291. package/src/features/badge/adapters/inbound/Badge.tsx +1 -1
  292. package/src/features/button/adapters/inbound/Button.tsx +8 -8
  293. package/src/features/button/adapters/inbound/IconButton.tsx +4 -4
  294. package/src/features/card/adapters/inbound/Card.tsx +4 -4
  295. package/src/features/font/adapters/inbound/FontProvider.tsx +27 -0
  296. package/src/features/font/adapters/inbound/FontRuntimeContext.tsx +12 -0
  297. package/src/features/font/adapters/inbound/useFontRuntime.ts +9 -0
  298. package/src/features/font/public.ts +2 -0
  299. package/src/features/form/checkbox/adapters/inbound/Checkbox.tsx +7 -7
  300. package/src/features/form/radio/adapters/inbound/Radio.tsx +7 -7
  301. package/src/features/form/switch/adapters/inbound/Switch.tsx +4 -4
  302. package/src/features/form/text-input/adapters/inbound/TextInput.tsx +1 -1
  303. package/src/features/form/text-input/utils/resolveTextInputPresentation.ts +1 -1
  304. package/src/features/icon/adapters/inbound/Icon.tsx +2 -2
  305. package/src/features/image/adapters/inbound/Image.tsx +1 -1
  306. package/src/features/image/utils/resolveImageProps.test.ts +1 -1
  307. package/src/features/image/utils/resolveImageStyle.ts +2 -2
  308. package/src/features/layout/adapters/inbound/Grid.tsx +1 -1
  309. package/src/features/layout/adapters/inbound/ScrollView.tsx +1 -1
  310. package/src/features/layout/adapters/inbound/View.tsx +1 -1
  311. package/src/features/list/adapters/inbound/ListItem.tsx +5 -5
  312. package/src/features/modal/adapters/inbound/Modal.tsx +1 -1
  313. package/src/features/popover-menu/adapters/inbound/PopoverMenu.tsx +1 -1
  314. package/src/{primitives/button-base/ButtonBase.tsx → features/pressable/adapters/inbound/Pressable.tsx} +45 -31
  315. package/src/features/pressable/public.ts +2 -0
  316. package/src/features/surface/adapters/inbound/Surface.tsx +1 -1
  317. package/src/features/tabs/adapters/inbound/Tab.tsx +1 -1
  318. package/src/features/theme/adapters/inbound/ThemeProvider.tsx +46 -0
  319. package/src/features/theme/adapters/inbound/ThemeRuntimeContext.tsx +14 -0
  320. package/src/features/theme/adapters/inbound/ThemeScope.test.tsx +52 -0
  321. package/src/features/theme/adapters/inbound/ThemeScope.tsx +29 -0
  322. package/src/features/theme/adapters/inbound/useTheme.ts +9 -0
  323. package/src/features/theme/application/use-cases/createTheme.ts +71 -0
  324. package/src/{theme → features/theme/application/use-cases}/createThemeOverrides.test.ts +8 -9
  325. package/src/{theme → features/theme/application/use-cases}/createThemeValidation.test.ts +4 -2
  326. package/src/features/theme/constants.ts +68 -0
  327. package/src/{theme → features/theme/domain}/createSurfaceColorDiagnosticCollector.ts +4 -1
  328. package/src/{theme → features/theme/domain}/createSurfaceSemanticPolicy.ts +2 -2
  329. package/src/features/theme/domain/generatePalette.test.ts +294 -0
  330. package/src/{theme/colorEngine.ts → features/theme/domain/generatePalette.ts} +3 -30
  331. package/src/{theme → features/theme/domain}/inverseSemantics.test.ts +1 -1
  332. package/src/{theme → features/theme/domain}/resolveRoleSemantics.ts +2 -2
  333. package/src/features/theme/domain/resolveSemanticColors.ts +23 -0
  334. package/src/{theme → features/theme/domain}/resolveSurfaceSemanticModel.ts +4 -4
  335. package/src/{theme → features/theme}/public.test.ts +1 -1
  336. package/src/features/theme/public.ts +18 -0
  337. package/src/features/theme/runtime.test.ts +13 -0
  338. package/src/features/theme/runtime.ts +4 -0
  339. package/src/{theme → features/theme/utils}/resolveGlobalTokens.ts +2 -2
  340. package/src/{theme → features/theme/utils}/resolveHeadingTokenOverrides.ts +1 -1
  341. package/src/features/theme/utils/resolveToken.ts +16 -0
  342. package/src/{theme → features/theme/utils}/resolveWeightTokenOverrides.ts +12 -12
  343. package/src/features/toast/adapters/inbound/Toast.tsx +3 -3
  344. package/src/features/tooltip/adapters/inbound/Tooltip.tsx +1 -1
  345. package/src/features/typography/adapters/inbound/Heading.tsx +3 -30
  346. package/src/features/typography/adapters/inbound/Text.tsx +3 -23
  347. package/src/features/typography/utils/resolveHeadingTextStyle.test.ts +1 -1
  348. package/src/features/typography/utils/resolveHeadingTextStyle.ts +2 -2
  349. package/src/index.test.ts +13 -9
  350. package/src/index.ts +32 -17
  351. package/src/internal/resolvers/resolveControlSize.test.ts +1 -1
  352. package/src/internal/resolvers/resolveControlSize.ts +1 -1
  353. package/src/internal/resolvers/resolveFieldPresentation.ts +1 -1
  354. package/src/internal/resolvers/resolveIconSize.ts +1 -1
  355. package/src/internal/resolvers/resolveInteractiveColors.test.ts +1 -1
  356. package/src/internal/resolvers/resolveInteractiveColors.ts +2 -2
  357. package/src/internal/resolvers/resolveSelectionControlColors.test.ts +1 -1
  358. package/src/internal/resolvers/resolveSelectionControlColors.ts +2 -2
  359. package/src/internal/resolvers/resolveSurfaceColor.test.ts +1 -1
  360. package/src/internal/resolvers/resolveSurfaceColor.ts +2 -2
  361. package/src/internal/resolvers/resolveTextColor.test.ts +1 -1
  362. package/src/internal/resolvers/resolveTextColor.ts +2 -2
  363. package/src/internal/resolvers/resolveTextStyles.test.ts +1 -1
  364. package/src/internal/resolvers/resolveTextStyles.ts +1 -1
  365. package/src/structureOwnership.test.ts +16 -0
  366. package/src/types/accordion.ts +1 -1
  367. package/src/types/badge.ts +1 -1
  368. package/src/types/button.ts +4 -4
  369. package/src/types/checkbox.ts +3 -3
  370. package/src/types/font.ts +14 -0
  371. package/src/types/icon.ts +1 -1
  372. package/src/types/image.ts +1 -1
  373. package/src/types/interactionPolicy.test.ts +30 -0
  374. package/src/types/layout.ts +1 -1
  375. package/src/types/list.ts +1 -1
  376. package/src/types/modal.ts +1 -1
  377. package/src/types/popover.ts +1 -1
  378. package/src/types/popoverMenu.ts +1 -1
  379. package/src/{primitives/button-base/types.ts → types/pressable.ts} +4 -4
  380. package/src/types/radio.ts +3 -3
  381. package/src/types/surfaceColor.test.ts +18 -0
  382. package/src/types/surfaceColor.ts +11 -0
  383. package/src/types/switch.ts +3 -3
  384. package/src/types/tabs.ts +1 -1
  385. package/src/types/text-input.ts +1 -1
  386. package/src/{theme/types.ts → types/theme.ts} +22 -13
  387. package/src/types/toast.ts +2 -2
  388. package/src/types/tooltip.ts +1 -1
  389. package/src/types/typography.ts +1 -1
  390. package/src/utils/resolveSpacing.ts +2 -2
  391. package/src/utils/resolveViewStyles.test.ts +1 -1
  392. package/src/utils/resolveViewStyles.ts +2 -2
  393. package/src/webAcceptance.test.tsx +1 -1
  394. package/dist/context/FontContext.d.ts +0 -20
  395. package/dist/context/FontContext.d.ts.map +0 -1
  396. package/dist/context/FontContext.js +0 -27
  397. package/dist/context/FontContext.js.map +0 -1
  398. package/dist/context/TranslationContext.d.ts +0 -22
  399. package/dist/context/TranslationContext.d.ts.map +0 -1
  400. package/dist/context/TranslationContext.js +0 -25
  401. package/dist/context/TranslationContext.js.map +0 -1
  402. package/dist/interactionPolicy.d.ts.map +0 -1
  403. package/dist/interactionPolicy.js.map +0 -1
  404. package/dist/primitives/button-base/ButtonBase.d.ts +0 -5
  405. package/dist/primitives/button-base/ButtonBase.d.ts.map +0 -1
  406. package/dist/primitives/button-base/ButtonBase.js +0 -42
  407. package/dist/primitives/button-base/ButtonBase.js.map +0 -1
  408. package/dist/primitives/button-base/index.d.ts +0 -3
  409. package/dist/primitives/button-base/index.d.ts.map +0 -1
  410. package/dist/primitives/button-base/index.js +0 -2
  411. package/dist/primitives/button-base/index.js.map +0 -1
  412. package/dist/primitives/button-base/types.d.ts.map +0 -1
  413. package/dist/primitives/button-base/types.js +0 -2
  414. package/dist/primitives/button-base/types.js.map +0 -1
  415. package/dist/surfaceColor.d.ts.map +0 -1
  416. package/dist/surfaceColor.js.map +0 -1
  417. package/dist/theme/ThemeContext.d.ts +0 -27
  418. package/dist/theme/ThemeContext.d.ts.map +0 -1
  419. package/dist/theme/ThemeContext.js +0 -59
  420. package/dist/theme/ThemeContext.js.map +0 -1
  421. package/dist/theme/colorEngine.d.ts +0 -16
  422. package/dist/theme/colorEngine.d.ts.map +0 -1
  423. package/dist/theme/colorEngine.js.map +0 -1
  424. package/dist/theme/createSurfaceColorDiagnosticCollector.d.ts.map +0 -1
  425. package/dist/theme/createSurfaceColorDiagnosticCollector.js.map +0 -1
  426. package/dist/theme/createSurfaceSemanticPolicy.d.ts.map +0 -1
  427. package/dist/theme/createSurfaceSemanticPolicy.js.map +0 -1
  428. package/dist/theme/createTheme.d.ts +0 -5
  429. package/dist/theme/createTheme.d.ts.map +0 -1
  430. package/dist/theme/createTheme.js +0 -49
  431. package/dist/theme/createTheme.js.map +0 -1
  432. package/dist/theme/defaultTokens.d.ts +0 -3
  433. package/dist/theme/defaultTokens.d.ts.map +0 -1
  434. package/dist/theme/defaultTokens.js.map +0 -1
  435. package/dist/theme/index.d.ts +0 -3
  436. package/dist/theme/index.d.ts.map +0 -1
  437. package/dist/theme/index.js +0 -3
  438. package/dist/theme/index.js.map +0 -1
  439. package/dist/theme/public.d.ts +0 -5
  440. package/dist/theme/public.d.ts.map +0 -1
  441. package/dist/theme/public.js +0 -5
  442. package/dist/theme/public.js.map +0 -1
  443. package/dist/theme/resolveGlobalTokens.d.ts.map +0 -1
  444. package/dist/theme/resolveGlobalTokens.js.map +0 -1
  445. package/dist/theme/resolveHeadingTokenOverrides.d.ts.map +0 -1
  446. package/dist/theme/resolveHeadingTokenOverrides.js.map +0 -1
  447. package/dist/theme/resolveNumericTokenOverrides.d.ts.map +0 -1
  448. package/dist/theme/resolveNumericTokenOverrides.js.map +0 -1
  449. package/dist/theme/resolveRoleSemantics.d.ts.map +0 -1
  450. package/dist/theme/resolveRoleSemantics.js.map +0 -1
  451. package/dist/theme/resolveSurfaceSemanticModel.d.ts.map +0 -1
  452. package/dist/theme/resolveSurfaceSemanticModel.js.map +0 -1
  453. package/dist/theme/resolveToken.d.ts.map +0 -1
  454. package/dist/theme/resolveToken.js +0 -19
  455. package/dist/theme/resolveToken.js.map +0 -1
  456. package/dist/theme/resolveWeightTokenOverrides.d.ts.map +0 -1
  457. package/dist/theme/resolveWeightTokenOverrides.js.map +0 -1
  458. package/dist/theme/surfaceColorPolicy.d.ts +0 -8
  459. package/dist/theme/surfaceColorPolicy.d.ts.map +0 -1
  460. package/dist/theme/surfaceColorPolicy.js +0 -8
  461. package/dist/theme/surfaceColorPolicy.js.map +0 -1
  462. package/dist/theme/types.d.ts.map +0 -1
  463. package/dist/theme/types.js +0 -2
  464. package/dist/theme/types.js.map +0 -1
  465. package/dist/utils/deepEqual.d.ts +0 -6
  466. package/dist/utils/deepEqual.d.ts.map +0 -1
  467. package/dist/utils/deepEqual.js +0 -36
  468. package/dist/utils/deepEqual.js.map +0 -1
  469. package/dist/utils/deepMerge.d.ts +0 -6
  470. package/dist/utils/deepMerge.d.ts.map +0 -1
  471. package/dist/utils/deepMerge.js +0 -26
  472. package/dist/utils/deepMerge.js.map +0 -1
  473. package/src/context/FontContext.tsx +0 -59
  474. package/src/context/TranslationContext.tsx +0 -50
  475. package/src/interactionPolicy.test.ts +0 -86
  476. package/src/primitives/button-base/index.ts +0 -2
  477. package/src/surfaceColor.test.ts +0 -44
  478. package/src/theme/ThemeContext.tsx +0 -94
  479. package/src/theme/colorEngine.test.ts +0 -302
  480. package/src/theme/createTheme.ts +0 -60
  481. package/src/theme/defaultTokens.ts +0 -61
  482. package/src/theme/index.ts +0 -2
  483. package/src/theme/public.ts +0 -4
  484. package/src/theme/resolveToken.ts +0 -32
  485. package/src/theme/surfaceColorPolicy.ts +0 -7
  486. package/src/utils/deepEqual.ts +0 -34
  487. package/src/utils/deepMerge.test.ts +0 -113
  488. package/src/utils/deepMerge.ts +0 -29
  489. /package/dist/{surfaceColor.js → constants/surfaceColor.js} +0 -0
  490. /package/dist/{theme → features/theme/domain}/createSurfaceColorDiagnosticCollector.js +0 -0
  491. /package/dist/{theme → features/theme/domain}/resolveSurfaceSemanticModel.js +0 -0
  492. /package/dist/{theme → features/theme/utils}/resolveHeadingTokenOverrides.js +0 -0
  493. /package/dist/{theme → features/theme/utils}/resolveNumericTokenOverrides.d.ts +0 -0
  494. /package/dist/{theme → features/theme/utils}/resolveNumericTokenOverrides.js +0 -0
  495. /package/dist/{interactionPolicy.d.ts → types/interactionPolicy.d.ts} +0 -0
  496. /package/dist/{interactionPolicy.js → types/interactionPolicy.js} +0 -0
  497. /package/src/{theme → features/theme/utils}/resolveNumericTokenOverrides.ts +0 -0
  498. /package/src/{interactionPolicy.ts → types/interactionPolicy.ts} +0 -0
@@ -3,9 +3,9 @@ import { View as ReactNativeView } from 'react-native';
3
3
 
4
4
  import { useResponsiveRuntime } from '../../../../core/responsive';
5
5
  import { resolvePointerEvents } from '../../../../internal/resolvePointerEvents';
6
- import { useTheme } from '../../../../theme/ThemeContext';
7
6
  import type { ViewProps } from '../../../../types/layout';
8
7
  import { resolveViewStyles } from '../../../../utils/resolveViewStyles';
8
+ import { useTheme } from '../../../theme/runtime';
9
9
 
10
10
  /*** Renders the token-aware responsive Surface adapter for React Native View. */
11
11
  export function View({
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
2
 
3
- import { ButtonBase } from '../../../../primitives/button-base';
4
- import { useTheme } from '../../../../theme/ThemeContext';
5
- import type { SurfaceTheme } from '../../../../theme/types';
6
3
  import type { ListItemProps } from '../../../../types/list';
4
+ import type { SurfaceTheme } from '../../../../types/theme';
7
5
  import { View } from '../../../layout/public';
6
+ import { Pressable } from '../../../pressable/public';
7
+ import { useTheme } from '../../../theme/runtime';
8
8
  import { Text } from '../../../typography/public';
9
9
 
10
10
  /*** Renders a static or interactive list item with shared row geometry and interaction states. */
@@ -30,7 +30,7 @@ function renderInteractiveListItem(
30
30
  theme: SurfaceTheme,
31
31
  ) {
32
32
  return (
33
- <ButtonBase
33
+ <Pressable
34
34
  accessibilityLabel={props.accessibilityLabel}
35
35
  accessibilityRole="button"
36
36
  accessibilityState={{ disabled: props.disabled ?? false, selected: props.selected ?? false }}
@@ -51,7 +51,7 @@ function renderInteractiveListItem(
51
51
  testID={undefined}
52
52
  />
53
53
  )}
54
- </ButtonBase>
54
+ </Pressable>
55
55
  );
56
56
  }
57
57
 
@@ -5,10 +5,10 @@ import { FocusScope } from '../../../../internal/focus/FocusScope';
5
5
  import { Portal } from '../../../../internal/overlay/Portal';
6
6
  import { resolvePointerEvents } from '../../../../internal/resolvePointerEvents';
7
7
  import { resolveOverlayAnimation } from '../../../../internal/resolvers';
8
- import { useTheme } from '../../../../theme/ThemeContext';
9
8
  import type { ModalProps } from '../../../../types/modal';
10
9
  import { View } from '../../../layout/public';
11
10
  import { Surface } from '../../../surface/public';
11
+ import { useTheme } from '../../../theme/runtime';
12
12
 
13
13
  const boxNonePointerEvents = resolvePointerEvents('box-none');
14
14
 
@@ -3,11 +3,11 @@ import { Pressable } from 'react-native';
3
3
 
4
4
  import { FocusScope } from '../../../../internal/focus/FocusScope';
5
5
  import { useFocusManager } from '../../../../internal/focus/useFocusManager';
6
- import { useTheme } from '../../../../theme/ThemeContext';
7
6
  import type { PopoverMenuAction, PopoverMenuProps } from '../../../../types/popoverMenu';
8
7
  import { View } from '../../../layout/public';
9
8
  import { Popover } from '../../../popover/public';
10
9
  import { Surface } from '../../../surface/public';
10
+ import { useTheme } from '../../../theme/runtime';
11
11
  import { Text } from '../../../typography/public';
12
12
  import { usePopoverMenuController } from '../../composition/usePopoverMenuController';
13
13
  import { resolveNextMenuIndex } from '../../utils/resolveNextMenuIndex';
@@ -1,33 +1,22 @@
1
1
  import React from 'react';
2
- import { Platform, Pressable, type PressableStateCallbackType } from 'react-native';
2
+ import {
3
+ Platform,
4
+ Pressable as ReactNativePressable,
5
+ type PressableStateCallbackType,
6
+ } from 'react-native';
3
7
 
4
- import { useResponsiveRuntime } from '../../core/responsive';
8
+ import { useResponsiveRuntime } from '../../../../core/responsive';
5
9
  import {
6
10
  type InteractionState,
7
11
  resolveFocusRingStyles,
8
12
  resolveInteractiveState,
9
- } from '../../internal/resolvers';
10
- import { useTheme } from '../../theme/ThemeContext';
11
- import { resolveViewStyles } from '../../utils/resolveViewStyles';
12
- import type { ButtonBaseProps } from './types';
13
+ } from '../../../../internal/resolvers';
14
+ import type { PressableProps } from '../../../../types/pressable';
15
+ import { resolveViewStyles } from '../../../../utils/resolveViewStyles';
16
+ import { useTheme } from '../../../theme/runtime';
13
17
 
14
- /*** Resolves one Pressable state into the canonical Surface interaction state. */
15
- function getInteractionState(
16
- pressableState: PressableStateCallbackType,
17
- hovered: boolean,
18
- focused: boolean,
19
- disabled: boolean,
20
- ): InteractionState {
21
- return resolveInteractiveState({
22
- pressed: pressableState.pressed,
23
- hovered,
24
- focused,
25
- disabled,
26
- });
27
- }
28
-
29
- /*** Renders the low-level token-aware Pressable boundary shared by Surface controls. */
30
- export function ButtonBase({
18
+ /*** Renders the token-aware Surface adapter for React Native Pressable. */
19
+ export function Pressable({
31
20
  children,
32
21
  disabled = false,
33
22
  interactionPolicy = 'enabled',
@@ -39,17 +28,18 @@ export function ButtonBase({
39
28
  style,
40
29
  testID,
41
30
  ...props
42
- }: ButtonBaseProps) {
31
+ }: PressableProps) {
43
32
  const { theme } = useTheme();
44
33
  const { breakpoint } = useResponsiveRuntime();
45
34
  const [hovered, setHovered] = React.useState(false);
46
35
  const [focused, setFocused] = React.useState(false);
47
36
  const isWeb = Platform.OS === 'web';
48
37
  const resolvedViewStyles = resolveViewStyles(theme, breakpoint, props);
49
- const passive = interactionPolicy === 'passive';
38
+ const pressHandlers = resolvePressHandlers(interactionPolicy, onPress, onLongPress);
50
39
 
51
40
  return (
52
- <Pressable
41
+ <ReactNativePressable
42
+ {...pressHandlers}
53
43
  accessibilityLabel={accessibilityLabel}
54
44
  accessibilityRole={accessibilityRole}
55
45
  accessibilityState={{ ...accessibilityState, disabled }}
@@ -60,10 +50,8 @@ export function ButtonBase({
60
50
  }}
61
51
  onHoverIn={isWeb ? () => setHovered(true) : undefined}
62
52
  onHoverOut={isWeb ? () => setHovered(false) : undefined}
63
- onLongPress={passive ? undefined : onLongPress}
64
- onPress={passive ? undefined : onPress}
65
53
  style={(pressableState) => {
66
- const state = getInteractionState(pressableState, hovered, focused, disabled);
54
+ const state = resolveInteractionState(pressableState, hovered, focused, disabled);
67
55
  return [
68
56
  resolvedViewStyles,
69
57
  resolveFocusRingStyles(theme.semantics.border.focus, state.focused, isWeb),
@@ -73,9 +61,35 @@ export function ButtonBase({
73
61
  testID={testID}
74
62
  >
75
63
  {(pressableState) => {
76
- const state = getInteractionState(pressableState, hovered, focused, disabled);
64
+ const state = resolveInteractionState(pressableState, hovered, focused, disabled);
77
65
  return typeof children === 'function' ? children(state) : children;
78
66
  }}
79
- </Pressable>
67
+ </ReactNativePressable>
80
68
  );
81
69
  }
70
+
71
+ /*** Resolves press handlers according to the shared interaction policy. */
72
+ function resolvePressHandlers(
73
+ interactionPolicy: PressableProps['interactionPolicy'],
74
+ onPress: PressableProps['onPress'],
75
+ onLongPress: PressableProps['onLongPress'],
76
+ ) {
77
+ return interactionPolicy === 'passive'
78
+ ? { onLongPress: undefined, onPress: undefined }
79
+ : { onLongPress, onPress };
80
+ }
81
+
82
+ /*** Resolves one native Pressable state into the canonical Surface interaction state. */
83
+ function resolveInteractionState(
84
+ pressableState: PressableStateCallbackType,
85
+ hovered: boolean,
86
+ focused: boolean,
87
+ disabled: boolean,
88
+ ): InteractionState {
89
+ return resolveInteractiveState({
90
+ pressed: pressableState.pressed,
91
+ hovered,
92
+ focused,
93
+ disabled,
94
+ });
95
+ }
@@ -0,0 +1,2 @@
1
+ export type { PressableProps } from '../../types/pressable';
2
+ export { Pressable } from './adapters/inbound/Pressable';
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
2
  import type { ViewStyle } from 'react-native';
3
3
 
4
- import { useTheme } from '../../../../theme/ThemeContext';
5
4
  import type { SurfaceProps, SurfaceVariant } from '../../../../types/surface';
6
5
  import { View } from '../../../layout/public';
6
+ import { useTheme } from '../../../theme/runtime';
7
7
 
8
8
  /*** Renders a themed content surface with semantic elevation and border variants. */
9
9
  export function Surface({ variant = 'default', radius = 'm', style, ...props }: SurfaceProps) {
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
2
  import { Pressable, type ViewStyle } from 'react-native';
3
3
 
4
- import { useTheme } from '../../../../theme/ThemeContext';
5
4
  import type { TabProps } from '../../../../types/tabs';
6
5
  import { View } from '../../../layout/public';
6
+ import { useTheme } from '../../../theme/runtime';
7
7
  import { Text } from '../../../typography/public';
8
8
  import { useTabRegistration } from '../../composition/useTabRegistration';
9
9
  import { useTabsContext } from '../../composition/useTabsContext';
@@ -0,0 +1,46 @@
1
+ import type { ThemeConfig } from '@ankhorage/contracts';
2
+ import { deepMerge } from '@ankhorage/utility/object';
3
+ import { useMemo, useState } from 'react';
4
+
5
+ import { ResponsiveProvider } from '../../../../core/responsive/ResponsiveProvider';
6
+ import { OverlayProvider } from '../../../../internal/overlay/OverlayProvider';
7
+ import type { ThemeProviderProps, ThemeRuntime } from '../../../../types/theme';
8
+ import { useFontRuntime } from '../../../font/adapters/inbound/useFontRuntime';
9
+ import { createTheme } from '../../application/use-cases/createTheme';
10
+ import { ThemeRuntimeContext } from './ThemeRuntimeContext';
11
+
12
+ /*** Install the app-level Surface theme together with global responsive and overlay runtime. */
13
+ export function ThemeProvider({
14
+ children,
15
+ initialConfig,
16
+ initialMode = 'light',
17
+ }: ThemeProviderProps) {
18
+ const defaultTheme = useMemo(() => createTheme(), []);
19
+ const [config, setConfig] = useState<ThemeConfig>(() =>
20
+ initialConfig ? deepMerge(defaultTheme.config, initialConfig) : defaultTheme.config,
21
+ );
22
+ const [mode, setMode] = useState(initialMode);
23
+ const { activeFontId } = useFontRuntime();
24
+
25
+ const theme = useMemo(
26
+ () => createTheme(config, mode, activeFontId),
27
+ [activeFontId, config, mode],
28
+ );
29
+ const value = useMemo<ThemeRuntime>(
30
+ () => ({
31
+ theme,
32
+ mode,
33
+ setThemeConfig: (nextConfig) => setConfig((previous) => deepMerge(previous, nextConfig)),
34
+ setMode,
35
+ }),
36
+ [mode, theme],
37
+ );
38
+
39
+ return (
40
+ <ResponsiveProvider>
41
+ <ThemeRuntimeContext value={value}>
42
+ <OverlayProvider>{children}</OverlayProvider>
43
+ </ThemeRuntimeContext>
44
+ </ResponsiveProvider>
45
+ );
46
+ }
@@ -0,0 +1,14 @@
1
+ import { createContext } from 'react';
2
+
3
+ import type { ThemeRuntime } from '../../../../types/theme';
4
+ import { createTheme } from '../../application/use-cases/createTheme';
5
+
6
+ const defaultTheme = createTheme();
7
+
8
+ /*** Holds the active Surface theme runtime for component consumption. */
9
+ export const ThemeRuntimeContext = createContext<ThemeRuntime>({
10
+ theme: defaultTheme,
11
+ mode: 'light',
12
+ setThemeConfig: () => undefined,
13
+ setMode: () => undefined,
14
+ });
@@ -0,0 +1,52 @@
1
+ import { expect, test } from 'bun:test';
2
+ import { renderToStaticMarkup } from 'react-dom/server';
3
+
4
+ import type { ThemeRuntime } from '../../../../types/theme';
5
+ import { createTheme } from '../../application/use-cases/createTheme';
6
+ import { ThemeRuntimeContext } from './ThemeRuntimeContext';
7
+ import { ThemeScope } from './ThemeScope';
8
+ import { useTheme } from './useTheme';
9
+
10
+ function ThemeProbe() {
11
+ const { mode, theme } = useTheme();
12
+ return <span>{`${theme.config.id}:${mode}:${theme.colorDiagnostics.mode}`}</span>;
13
+ }
14
+
15
+ const parentRuntime: ThemeRuntime = {
16
+ theme: createTheme(),
17
+ mode: 'light',
18
+ setThemeConfig: () => undefined,
19
+ setMode: () => undefined,
20
+ };
21
+
22
+ test('overrides mode without mutating the parent theme runtime', () => {
23
+ const markup = renderToStaticMarkup(
24
+ <ThemeRuntimeContext value={parentRuntime}>
25
+ <ThemeProbe />
26
+ <ThemeScope mode="dark">
27
+ <ThemeProbe />
28
+ </ThemeScope>
29
+ <ThemeProbe />
30
+ </ThemeRuntimeContext>,
31
+ );
32
+
33
+ expect(markup).toContain('default:light:light');
34
+ expect(markup).toContain('default:dark:dark');
35
+ expect(markup.match(/default:light:light/g)).toHaveLength(2);
36
+ });
37
+
38
+ test('deep-merges a nested config override while preserving the parent config', () => {
39
+ const markup = renderToStaticMarkup(
40
+ <ThemeRuntimeContext value={parentRuntime}>
41
+ <ThemeProbe />
42
+ <ThemeScope themeConfig={{ id: 'scoped' }}>
43
+ <ThemeProbe />
44
+ </ThemeScope>
45
+ <ThemeProbe />
46
+ </ThemeRuntimeContext>,
47
+ );
48
+
49
+ expect(markup).toContain('scoped:light:light');
50
+ expect(markup.match(/default:light:light/g)).toHaveLength(2);
51
+ expect(parentRuntime.theme.config.id).toBe('default');
52
+ });
@@ -0,0 +1,29 @@
1
+ import { deepMerge } from '@ankhorage/utility/object';
2
+ import { useMemo } from 'react';
3
+
4
+ import type { ThemeRuntime, ThemeScopeProps } from '../../../../types/theme';
5
+ import { useFontRuntime } from '../../../font/adapters/inbound/useFontRuntime';
6
+ import { createTheme } from '../../application/use-cases/createTheme';
7
+ import { ThemeRuntimeContext } from './ThemeRuntimeContext';
8
+ import { useTheme } from './useTheme';
9
+
10
+ /*** Apply a nested Surface theme or mode override without remounting app-level providers. */
11
+ export function ThemeScope({ children, themeConfig, mode }: ThemeScopeProps) {
12
+ const parent = useTheme();
13
+ const { activeFontId } = useFontRuntime();
14
+ const scopedMode = mode ?? parent.mode;
15
+ const scopedConfig = useMemo(
16
+ () => (themeConfig ? deepMerge(parent.theme.config, themeConfig) : parent.theme.config),
17
+ [parent.theme.config, themeConfig],
18
+ );
19
+ const theme = useMemo(
20
+ () => createTheme(scopedConfig, scopedMode, activeFontId),
21
+ [activeFontId, scopedConfig, scopedMode],
22
+ );
23
+ const value = useMemo<ThemeRuntime>(
24
+ () => ({ ...parent, theme, mode: scopedMode }),
25
+ [parent, scopedMode, theme],
26
+ );
27
+
28
+ return <ThemeRuntimeContext value={value}>{children}</ThemeRuntimeContext>;
29
+ }
@@ -0,0 +1,9 @@
1
+ import { use } from 'react';
2
+
3
+ import type { ThemeRuntime } from '../../../../types/theme';
4
+ import { ThemeRuntimeContext } from './ThemeRuntimeContext';
5
+
6
+ /*** Read the active Surface theme runtime. */
7
+ export function useTheme(): ThemeRuntime {
8
+ return use(ThemeRuntimeContext);
9
+ }
@@ -0,0 +1,71 @@
1
+ import type { ThemeConfig } from '@ankhorage/contracts';
2
+
3
+ import type { FontWeight, SurfaceTheme } from '../../../../types/theme';
4
+ import { generatePalette } from '../../domain/generatePalette';
5
+ import { resolveGlobalTokens } from '../../utils/resolveGlobalTokens';
6
+
7
+ const DEFAULT_CONFIG: ThemeConfig = {
8
+ id: 'default',
9
+ name: 'Default',
10
+ light: { primaryColor: '#3B82F6', harmony: 'monochromatic' },
11
+ dark: { primaryColor: '#3B82F6', harmony: 'monochromatic' },
12
+ };
13
+
14
+ /*** Resolve canonical persisted theme source into the complete Surface runtime theme. */
15
+ export function createTheme(
16
+ config: ThemeConfig = DEFAULT_CONFIG,
17
+ mode: 'light' | 'dark' = 'light',
18
+ activeFontId?: string | null,
19
+ ): SurfaceTheme {
20
+ const { colors, swatches, semantics, colorDiagnostics } = generatePalette(config, mode);
21
+ const baseTheme: SurfaceTheme = {
22
+ ...resolveGlobalTokens(config.tokens),
23
+ colors,
24
+ swatches,
25
+ semantics,
26
+ colorDiagnostics,
27
+ config,
28
+ };
29
+ return activeFontId ? withActiveFont(baseTheme, activeFontId) : baseTheme;
30
+ }
31
+
32
+ /*** Return a theme with generated module font-family names without mutating the base theme. */
33
+ function withActiveFont(theme: SurfaceTheme, activeFontId: string): SurfaceTheme {
34
+ const familyName = toPascalCase(activeFontId);
35
+ return {
36
+ ...theme,
37
+ typography: {
38
+ ...theme.typography,
39
+ fonts: {
40
+ normal: createFontMap(theme.typography.fonts.normal, familyName, 'Regular'),
41
+ italic: createFontMap(theme.typography.fonts.italic, familyName, 'Italic'),
42
+ },
43
+ },
44
+ };
45
+ }
46
+
47
+ function createFontMap(
48
+ fallback: Record<FontWeight, string | undefined>,
49
+ familyName: string,
50
+ style: 'Regular' | 'Italic',
51
+ ): Record<FontWeight, string | undefined> {
52
+ return {
53
+ ...fallback,
54
+ '100': `${familyName}_100${style}`,
55
+ '200': `${familyName}_200${style}`,
56
+ '300': `${familyName}_300${style}`,
57
+ '400': `${familyName}_400${style}`,
58
+ '500': `${familyName}_500${style}`,
59
+ '600': `${familyName}_600${style}`,
60
+ '700': `${familyName}_700${style}`,
61
+ '800': `${familyName}_800${style}`,
62
+ '900': `${familyName}_900${style}`,
63
+ };
64
+ }
65
+
66
+ function toPascalCase(value: string): string {
67
+ return value
68
+ .split(/[- ]+/)
69
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
70
+ .join('');
71
+ }
@@ -1,12 +1,14 @@
1
1
  import type { ThemeConfig } from '@ankhorage/contracts';
2
2
  import { describe, expect, it } from 'bun:test';
3
3
 
4
- import { createTheme, DEFAULT_CONFIG, DEFAULT_TOKENS } from './createTheme';
4
+ import { DEFAULT_TOKENS } from '../../constants';
5
+ import { createTheme } from './createTheme';
6
+
7
+ const defaultConfig = createTheme().config;
5
8
 
6
9
  describe('createTheme authored global tokens', () => {
7
10
  it('preserves defaults when no authored overrides exist', () => {
8
- const theme = createTheme(DEFAULT_CONFIG);
9
-
11
+ const theme = createTheme(defaultConfig);
10
12
  expect(theme.spacing).toEqual(DEFAULT_TOKENS.spacing);
11
13
  expect(theme.radii).toEqual(DEFAULT_TOKENS.radii);
12
14
  expect(theme.typography.sizes).toEqual(DEFAULT_TOKENS.typography.sizes);
@@ -16,7 +18,7 @@ describe('createTheme authored global tokens', () => {
16
18
 
17
19
  it('merges authored global tokens without copying omitted defaults into config', () => {
18
20
  const config: ThemeConfig = {
19
- ...DEFAULT_CONFIG,
21
+ ...defaultConfig,
20
22
  tokens: {
21
23
  spacing: { m: 18, hero: 64 },
22
24
  radii: { l: 20, pill: 999 },
@@ -28,9 +30,7 @@ describe('createTheme authored global tokens', () => {
28
30
  shadows: { soft: 3, floating: 12 },
29
31
  },
30
32
  };
31
-
32
33
  const theme = createTheme(config);
33
-
34
34
  expect(theme.spacing).toMatchObject({ xs: 4, m: 18, hero: 64 });
35
35
  expect(theme.radii).toMatchObject({ m: 8, l: 20, pill: 999 });
36
36
  expect(theme.typography.sizes).toMatchObject({ s: 14, m: 17, display: 44 });
@@ -41,9 +41,8 @@ describe('createTheme authored global tokens', () => {
41
41
  });
42
42
 
43
43
  it('keeps module-derived font families isolated per resolved theme', () => {
44
- const withFont = createTheme(DEFAULT_CONFIG, 'light', 'source-sans');
45
- const withoutFont = createTheme(DEFAULT_CONFIG);
46
-
44
+ const withFont = createTheme(defaultConfig, 'light', 'source-sans');
45
+ const withoutFont = createTheme(defaultConfig);
47
46
  expect(withFont.typography.fonts.normal['400']).toBe('SourceSans_400Regular');
48
47
  expect(withoutFont.typography.fonts.normal['400']).toBeUndefined();
49
48
  expect(DEFAULT_TOKENS.typography.fonts.normal['400']).toBeUndefined();
@@ -1,7 +1,9 @@
1
1
  import type { ThemeConfig, ThemeGlobalTokenOverrides } from '@ankhorage/contracts';
2
2
  import { describe, expect, it } from 'bun:test';
3
3
 
4
- import { createTheme, DEFAULT_CONFIG } from './createTheme';
4
+ import { createTheme } from './createTheme';
5
+
6
+ const defaultConfig = createTheme().config;
5
7
 
6
8
  describe('createTheme token validation', () => {
7
9
  it('rejects negative or non-finite numeric tokens', () => {
@@ -46,5 +48,5 @@ describe('createTheme token validation', () => {
46
48
  });
47
49
 
48
50
  function withTokens(tokens: ThemeGlobalTokenOverrides): ThemeConfig {
49
- return { ...DEFAULT_CONFIG, tokens };
51
+ return { ...defaultConfig, tokens };
50
52
  }
@@ -0,0 +1,68 @@
1
+ import type { FontWeight, ThemeTokens } from '../../types/theme';
2
+
3
+ const EMPTY_FONT_MAP: Record<FontWeight, string | undefined> = {
4
+ '100': undefined,
5
+ '200': undefined,
6
+ '300': undefined,
7
+ '400': undefined,
8
+ '500': undefined,
9
+ '600': undefined,
10
+ '700': undefined,
11
+ '800': undefined,
12
+ '900': undefined,
13
+ bold: undefined,
14
+ normal: undefined,
15
+ };
16
+
17
+ const DEFAULT_TOKENS: Omit<ThemeTokens, 'colors' | 'swatches' | 'semantics' | 'colorDiagnostics'> =
18
+ {
19
+ spacing: { none: 0, xs: 4, s: 8, m: 16, l: 24, xl: 32, xxl: 48 },
20
+ radii: { none: 0, s: 4, m: 8, l: 16, full: 9999 },
21
+ typography: {
22
+ headings: {
23
+ 1: { size: 32, lineHeight: 40, weight: 'bold' },
24
+ 2: { size: 24, lineHeight: 32, weight: 'bold' },
25
+ 3: { size: 20, lineHeight: 28, weight: 'bold' },
26
+ 4: { size: 18, lineHeight: 24, weight: 'semiBold' },
27
+ 5: { size: 16, lineHeight: 22, weight: 'semiBold' },
28
+ 6: { size: 14, lineHeight: 20, weight: 'semiBold' },
29
+ },
30
+ sizes: {
31
+ xs: 12,
32
+ s: 14,
33
+ m: 16,
34
+ l: 18,
35
+ xl: 20,
36
+ xxl: 24,
37
+ '3xl': 30,
38
+ h1: 32,
39
+ h2: 24,
40
+ h3: 20,
41
+ h4: 18,
42
+ h5: 16,
43
+ h6: 14,
44
+ },
45
+ weights: {
46
+ thin: '100',
47
+ extraLight: '200',
48
+ light: '300',
49
+ regular: '400',
50
+ medium: '500',
51
+ semiBold: '600',
52
+ bold: '700',
53
+ extraBold: '800',
54
+ black: '900',
55
+ },
56
+ fonts: { normal: { ...EMPTY_FONT_MAP }, italic: { ...EMPTY_FONT_MAP } },
57
+ },
58
+ shadows: { soft: 2, medium: 4, hard: 8 },
59
+ };
60
+
61
+ export const SURFACE_COLOR_POLICY = {
62
+ disabledContrast: 3,
63
+ surfaceSeparation: 1.05,
64
+ textContrast: 4.5,
65
+ uiContrast: 3,
66
+ } as const;
67
+
68
+ export { DEFAULT_TOKENS };
@@ -11,7 +11,10 @@ import {
11
11
  selectColorSwatchStep,
12
12
  } from '@ankhorage/color-theory';
13
13
 
14
- import type { SurfaceColorSelectionDiagnostic, SurfaceContrastDiagnostic } from './types';
14
+ import type {
15
+ SurfaceColorSelectionDiagnostic,
16
+ SurfaceContrastDiagnostic,
17
+ } from '../../../types/theme';
15
18
 
16
19
  /** Collect deterministic Color Theory evidence while Surface resolves semantic colors. */
17
20
  export function createSurfaceColorDiagnosticCollector() {
@@ -8,13 +8,13 @@ import type {
8
8
  } from '@ankhorage/color-theory';
9
9
  import { parseHexColorOrThrow } from '@ankhorage/color-theory';
10
10
 
11
- import { SURFACE_COLOR_POLICY } from './surfaceColorPolicy';
12
11
  import type {
13
12
  ContentSemantics,
14
13
  NeutralSemantics,
15
14
  SurfaceContrastDiagnostic,
16
15
  SurfaceSemantics,
17
- } from './types';
16
+ } from '../../../types/theme';
17
+ import { SURFACE_COLOR_POLICY } from '../constants';
18
18
 
19
19
  type ResolvedSemanticColors = Record<SemanticColorToken, HexColor>;
20
20