@ankhorage/surface 4.2.0 → 4.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (577) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/components/field/Field.js +1 -1
  3. package/dist/components/field/Field.js.map +1 -1
  4. package/dist/components/helper-text/HelperText.js +1 -1
  5. package/dist/components/helper-text/HelperText.js.map +1 -1
  6. package/dist/components/label/Label.js +1 -1
  7. package/dist/components/label/Label.js.map +1 -1
  8. package/dist/components/list-item/ListItem.js +2 -2
  9. package/dist/components/list-item/ListItem.js.map +1 -1
  10. package/dist/components/menu/Menu.d.ts.map +1 -1
  11. package/dist/components/menu/Menu.js +4 -2
  12. package/dist/components/menu/Menu.js.map +1 -1
  13. package/dist/components/modal/Modal.d.ts.map +1 -1
  14. package/dist/components/modal/Modal.js +2 -1
  15. package/dist/components/modal/Modal.js.map +1 -1
  16. package/dist/components/switch/Switch.js +2 -2
  17. package/dist/components/switch/Switch.js.map +1 -1
  18. package/dist/components/tabs/Tab.js +2 -2
  19. package/dist/components/tabs/Tab.js.map +1 -1
  20. package/dist/components/tabs/TabList.js +1 -1
  21. package/dist/components/tabs/TabList.js.map +1 -1
  22. package/dist/components/tabs/Tabs.js +1 -1
  23. package/dist/components/tabs/Tabs.js.map +1 -1
  24. package/dist/components/textarea/Textarea.js +1 -1
  25. package/dist/components/textarea/Textarea.js.map +1 -1
  26. package/dist/components/textarea/types.d.ts +1 -1
  27. package/dist/components/textarea/types.d.ts.map +1 -1
  28. package/dist/components/textarea/types.js.map +1 -1
  29. package/dist/components/toast/Toast.d.ts.map +1 -1
  30. package/dist/components/toast/Toast.js +4 -2
  31. package/dist/components/toast/Toast.js.map +1 -1
  32. package/dist/components/toast/ToastProvider.js +1 -1
  33. package/dist/components/toast/ToastProvider.js.map +1 -1
  34. package/dist/components/tooltip/Tooltip.js +2 -2
  35. package/dist/components/tooltip/Tooltip.js.map +1 -1
  36. package/dist/examples/DocsExamples.js +6 -6
  37. package/dist/examples/DocsExamples.js.map +1 -1
  38. package/dist/features/badge/adapters/inbound/Badge.d.ts +5 -0
  39. package/dist/features/badge/adapters/inbound/Badge.d.ts.map +1 -0
  40. package/dist/features/badge/adapters/inbound/Badge.js +30 -0
  41. package/dist/features/badge/adapters/inbound/Badge.js.map +1 -0
  42. package/dist/features/badge/public.d.ts +3 -0
  43. package/dist/features/badge/public.d.ts.map +1 -0
  44. package/dist/features/badge/public.js +2 -0
  45. package/dist/features/badge/public.js.map +1 -0
  46. package/dist/{components/button → features/button/adapters/inbound}/Button.d.ts +2 -1
  47. package/dist/features/button/adapters/inbound/Button.d.ts.map +1 -0
  48. package/dist/features/button/adapters/inbound/Button.js +60 -0
  49. package/dist/features/button/adapters/inbound/Button.js.map +1 -0
  50. package/dist/{components/icon-button → features/button/adapters/inbound}/IconButton.d.ts +2 -1
  51. package/dist/features/button/adapters/inbound/IconButton.d.ts.map +1 -0
  52. package/dist/features/button/adapters/inbound/IconButton.js +33 -0
  53. package/dist/features/button/adapters/inbound/IconButton.js.map +1 -0
  54. package/dist/features/button/public.d.ts +4 -0
  55. package/dist/features/button/public.d.ts.map +1 -0
  56. package/dist/features/button/public.js +3 -0
  57. package/dist/features/button/public.js.map +1 -0
  58. package/dist/features/card/adapters/inbound/Card.d.ts +5 -0
  59. package/dist/features/card/adapters/inbound/Card.d.ts.map +1 -0
  60. package/dist/features/card/adapters/inbound/Card.js +44 -0
  61. package/dist/features/card/adapters/inbound/Card.js.map +1 -0
  62. package/dist/features/card/public.d.ts +3 -0
  63. package/dist/features/card/public.d.ts.map +1 -0
  64. package/dist/features/card/public.js +2 -0
  65. package/dist/features/card/public.js.map +1 -0
  66. package/dist/features/form/checkbox/adapters/inbound/Checkbox.d.ts +5 -0
  67. package/dist/features/form/checkbox/adapters/inbound/Checkbox.d.ts.map +1 -0
  68. package/dist/features/form/checkbox/adapters/inbound/Checkbox.js +88 -0
  69. package/dist/features/form/checkbox/adapters/inbound/Checkbox.js.map +1 -0
  70. package/dist/features/form/checkbox/public.d.ts +3 -0
  71. package/dist/features/form/checkbox/public.d.ts.map +1 -0
  72. package/dist/features/form/checkbox/public.js +2 -0
  73. package/dist/features/form/checkbox/public.js.map +1 -0
  74. package/dist/features/form/radio/adapters/inbound/Radio.d.ts +5 -0
  75. package/dist/features/form/radio/adapters/inbound/Radio.d.ts.map +1 -0
  76. package/dist/features/form/radio/adapters/inbound/Radio.js +91 -0
  77. package/dist/features/form/radio/adapters/inbound/Radio.js.map +1 -0
  78. package/dist/features/form/radio/public.d.ts +3 -0
  79. package/dist/features/form/radio/public.d.ts.map +1 -0
  80. package/dist/features/form/radio/public.js +2 -0
  81. package/dist/features/form/radio/public.js.map +1 -0
  82. package/dist/features/form/radio/utils/isRadioTextContent.d.ts +4 -0
  83. package/dist/features/form/radio/utils/isRadioTextContent.d.ts.map +1 -0
  84. package/dist/features/form/radio/utils/isRadioTextContent.js +5 -0
  85. package/dist/features/form/radio/utils/isRadioTextContent.js.map +1 -0
  86. package/dist/features/form/text-input/adapters/inbound/TextInput.d.ts +5 -0
  87. package/dist/features/form/text-input/adapters/inbound/TextInput.d.ts.map +1 -0
  88. package/dist/features/form/text-input/adapters/inbound/TextInput.js +41 -0
  89. package/dist/features/form/text-input/adapters/inbound/TextInput.js.map +1 -0
  90. package/dist/features/form/text-input/public.d.ts +3 -0
  91. package/dist/features/form/text-input/public.d.ts.map +1 -0
  92. package/dist/features/form/text-input/public.js +2 -0
  93. package/dist/features/form/text-input/public.js.map +1 -0
  94. package/dist/features/form/text-input/utils/resolveTextInputPresentation.d.ts +15 -0
  95. package/dist/features/form/text-input/utils/resolveTextInputPresentation.d.ts.map +1 -0
  96. package/dist/features/form/text-input/utils/resolveTextInputPresentation.js +56 -0
  97. package/dist/features/form/text-input/utils/resolveTextInputPresentation.js.map +1 -0
  98. package/dist/features/icon/adapters/inbound/Icon.d.ts +4 -0
  99. package/dist/features/icon/adapters/inbound/Icon.d.ts.map +1 -0
  100. package/dist/{primitives/icon → features/icon/adapters/inbound}/Icon.js +3 -3
  101. package/dist/features/icon/adapters/inbound/Icon.js.map +1 -0
  102. package/dist/features/icon/adapters/inbound/PortableIcon.d.ts +19 -0
  103. package/dist/features/icon/adapters/inbound/PortableIcon.d.ts.map +1 -0
  104. package/dist/{primitives/icon → features/icon/adapters/inbound}/PortableIcon.js +37 -43
  105. package/dist/features/icon/adapters/inbound/PortableIcon.js.map +1 -0
  106. package/dist/features/icon/constants.d.ts +2 -0
  107. package/dist/features/icon/constants.d.ts.map +1 -0
  108. package/dist/features/icon/constants.js +8 -0
  109. package/dist/features/icon/constants.js.map +1 -0
  110. package/dist/features/icon/public.d.ts +4 -0
  111. package/dist/features/icon/public.d.ts.map +1 -0
  112. package/dist/features/icon/public.js +3 -0
  113. package/dist/features/icon/public.js.map +1 -0
  114. package/dist/{primitives/image → features/image/adapters/inbound}/Image.d.ts +2 -1
  115. package/dist/features/image/adapters/inbound/Image.d.ts.map +1 -0
  116. package/dist/features/image/adapters/inbound/Image.js +28 -0
  117. package/dist/features/image/adapters/inbound/Image.js.map +1 -0
  118. package/dist/features/image/public.d.ts +3 -0
  119. package/dist/features/image/public.d.ts.map +1 -0
  120. package/dist/features/image/public.js +2 -0
  121. package/dist/features/image/public.js.map +1 -0
  122. package/dist/features/image/utils/getSourceKey.d.ts +4 -0
  123. package/dist/features/image/utils/getSourceKey.d.ts.map +1 -0
  124. package/dist/features/image/utils/getSourceKey.js +33 -0
  125. package/dist/features/image/utils/getSourceKey.js.map +1 -0
  126. package/dist/features/image/utils/normalizeSource.d.ts +5 -0
  127. package/dist/features/image/utils/normalizeSource.d.ts.map +1 -0
  128. package/dist/features/image/utils/normalizeSource.js +9 -0
  129. package/dist/features/image/utils/normalizeSource.js.map +1 -0
  130. package/dist/features/image/utils/resolveAccessibilityLabel.d.ts +4 -0
  131. package/dist/features/image/utils/resolveAccessibilityLabel.d.ts.map +1 -0
  132. package/dist/features/image/utils/resolveAccessibilityLabel.js +5 -0
  133. package/dist/features/image/utils/resolveAccessibilityLabel.js.map +1 -0
  134. package/dist/features/image/utils/resolveAlt.d.ts +4 -0
  135. package/dist/features/image/utils/resolveAlt.d.ts.map +1 -0
  136. package/dist/features/image/utils/resolveAlt.js +5 -0
  137. package/dist/features/image/utils/resolveAlt.js.map +1 -0
  138. package/dist/features/image/utils/resolveImageStyle.d.ts +6 -0
  139. package/dist/features/image/utils/resolveImageStyle.d.ts.map +1 -0
  140. package/dist/features/image/utils/resolveImageStyle.js +15 -0
  141. package/dist/features/image/utils/resolveImageStyle.js.map +1 -0
  142. package/dist/features/image/utils/resolveRenderedSource.d.ts +4 -0
  143. package/dist/features/image/utils/resolveRenderedSource.d.ts.map +1 -0
  144. package/dist/features/image/utils/resolveRenderedSource.js +7 -0
  145. package/dist/features/image/utils/resolveRenderedSource.js.map +1 -0
  146. package/dist/features/image/utils/resolveResizeMode.d.ts +5 -0
  147. package/dist/features/image/utils/resolveResizeMode.d.ts.map +1 -0
  148. package/dist/features/image/utils/resolveResizeMode.js +5 -0
  149. package/dist/features/image/utils/resolveResizeMode.js.map +1 -0
  150. package/dist/features/keyboard-avoiding-view/adapters/inbound/KeyboardAvoidingView.d.ts +5 -0
  151. package/dist/features/keyboard-avoiding-view/adapters/inbound/KeyboardAvoidingView.d.ts.map +1 -0
  152. package/dist/{layout → features/keyboard-avoiding-view/adapters/inbound}/KeyboardAvoidingView.js +2 -2
  153. package/dist/features/keyboard-avoiding-view/adapters/inbound/KeyboardAvoidingView.js.map +1 -0
  154. package/dist/features/keyboard-avoiding-view/public.d.ts +3 -0
  155. package/dist/features/keyboard-avoiding-view/public.d.ts.map +1 -0
  156. package/dist/features/keyboard-avoiding-view/public.js +2 -0
  157. package/dist/features/keyboard-avoiding-view/public.js.map +1 -0
  158. package/dist/features/layout/adapters/inbound/Box.d.ts +5 -0
  159. package/dist/features/layout/adapters/inbound/Box.d.ts.map +1 -0
  160. package/dist/{layout → features/layout/adapters/inbound}/Box.js +5 -4
  161. package/dist/features/layout/adapters/inbound/Box.js.map +1 -0
  162. package/dist/features/layout/adapters/inbound/Container.d.ts +5 -0
  163. package/dist/features/layout/adapters/inbound/Container.d.ts.map +1 -0
  164. package/dist/features/layout/adapters/inbound/Container.js +28 -0
  165. package/dist/features/layout/adapters/inbound/Container.js.map +1 -0
  166. package/dist/features/layout/adapters/inbound/Divider.d.ts +5 -0
  167. package/dist/features/layout/adapters/inbound/Divider.d.ts.map +1 -0
  168. package/dist/{layout → features/layout/adapters/inbound}/Divider.js +1 -0
  169. package/dist/features/layout/adapters/inbound/Divider.js.map +1 -0
  170. package/dist/features/layout/adapters/inbound/Grid.d.ts +5 -0
  171. package/dist/features/layout/adapters/inbound/Grid.d.ts.map +1 -0
  172. package/dist/features/layout/adapters/inbound/Grid.js +48 -0
  173. package/dist/features/layout/adapters/inbound/Grid.js.map +1 -0
  174. package/dist/features/layout/adapters/inbound/Stack.d.ts +5 -0
  175. package/dist/features/layout/adapters/inbound/Stack.d.ts.map +1 -0
  176. package/dist/{layout → features/layout/adapters/inbound}/Stack.js +4 -3
  177. package/dist/features/layout/adapters/inbound/Stack.js.map +1 -0
  178. package/dist/features/layout/public.d.ts +7 -0
  179. package/dist/features/layout/public.d.ts.map +1 -0
  180. package/dist/features/layout/public.js +6 -0
  181. package/dist/features/layout/public.js.map +1 -0
  182. package/dist/features/surface/adapters/inbound/Surface.d.ts +5 -0
  183. package/dist/features/surface/adapters/inbound/Surface.d.ts.map +1 -0
  184. package/dist/{layout → features/surface/adapters/inbound}/Surface.js +17 -28
  185. package/dist/features/surface/adapters/inbound/Surface.js.map +1 -0
  186. package/dist/features/surface/public.d.ts +3 -0
  187. package/dist/features/surface/public.d.ts.map +1 -0
  188. package/dist/features/surface/public.js +2 -0
  189. package/dist/features/surface/public.js.map +1 -0
  190. package/dist/features/typography/adapters/inbound/Heading.d.ts +5 -0
  191. package/dist/features/typography/adapters/inbound/Heading.d.ts.map +1 -0
  192. package/dist/features/typography/adapters/inbound/Heading.js +29 -0
  193. package/dist/features/typography/adapters/inbound/Heading.js.map +1 -0
  194. package/dist/{primitives/text → features/typography/adapters/inbound}/Text.d.ts +2 -1
  195. package/dist/features/typography/adapters/inbound/Text.d.ts.map +1 -0
  196. package/dist/{primitives/text → features/typography/adapters/inbound}/Text.js +18 -25
  197. package/dist/features/typography/adapters/inbound/Text.js.map +1 -0
  198. package/dist/features/typography/public.d.ts +4 -0
  199. package/dist/features/typography/public.d.ts.map +1 -0
  200. package/dist/features/typography/public.js +3 -0
  201. package/dist/features/typography/public.js.map +1 -0
  202. package/dist/features/typography/utils/resolveHeadingTextStyle.d.ts +7 -0
  203. package/dist/features/typography/utils/resolveHeadingTextStyle.d.ts.map +1 -0
  204. package/dist/features/typography/utils/resolveHeadingTextStyle.js +10 -0
  205. package/dist/features/typography/utils/resolveHeadingTextStyle.js.map +1 -0
  206. package/dist/index.d.ts +24 -22
  207. package/dist/index.d.ts.map +1 -1
  208. package/dist/index.js +12 -11
  209. package/dist/index.js.map +1 -1
  210. package/dist/layout/AppBar.d.ts +1 -1
  211. package/dist/layout/AppBar.d.ts.map +1 -1
  212. package/dist/layout/AppBar.js +1 -2
  213. package/dist/layout/AppBar.js.map +1 -1
  214. package/dist/layout/Center.d.ts +1 -1
  215. package/dist/layout/Center.d.ts.map +1 -1
  216. package/dist/layout/Center.js +1 -1
  217. package/dist/layout/Center.js.map +1 -1
  218. package/dist/layout/Inline.d.ts +1 -1
  219. package/dist/layout/Inline.d.ts.map +1 -1
  220. package/dist/layout/Inline.js +1 -1
  221. package/dist/layout/Inline.js.map +1 -1
  222. package/dist/layout/ScrollArea.d.ts +1 -1
  223. package/dist/layout/ScrollArea.d.ts.map +1 -1
  224. package/dist/layout/ScrollArea.js +1 -1
  225. package/dist/layout/ScrollArea.js.map +1 -1
  226. package/dist/layout/Spacer.d.ts +1 -1
  227. package/dist/layout/Spacer.d.ts.map +1 -1
  228. package/dist/layout/Spacer.js +1 -1
  229. package/dist/layout/Spacer.js.map +1 -1
  230. package/dist/layout/Template.d.ts +2 -2
  231. package/dist/layout/Template.d.ts.map +1 -1
  232. package/dist/layout/Template.js +2 -2
  233. package/dist/layout/Template.js.map +1 -1
  234. package/dist/layout/index.d.ts +0 -14
  235. package/dist/layout/index.d.ts.map +1 -1
  236. package/dist/layout/index.js +0 -7
  237. package/dist/layout/index.js.map +1 -1
  238. package/dist/primitives/button-base/ButtonBase.js +1 -1
  239. package/dist/primitives/button-base/ButtonBase.js.map +1 -1
  240. package/dist/primitives/button-base/types.d.ts +1 -1
  241. package/dist/primitives/button-base/types.d.ts.map +1 -1
  242. package/dist/primitives/button-base/types.js.map +1 -1
  243. package/dist/types/badge.d.ts +12 -0
  244. package/dist/types/badge.d.ts.map +1 -0
  245. package/dist/types/badge.js +2 -0
  246. package/dist/types/badge.js.map +1 -0
  247. package/dist/types/button.d.ts +25 -0
  248. package/dist/types/button.d.ts.map +1 -0
  249. package/dist/types/button.js +2 -0
  250. package/dist/types/button.js.map +1 -0
  251. package/dist/{components/card/types.d.ts → types/card.d.ts} +2 -2
  252. package/dist/types/card.d.ts.map +1 -0
  253. package/dist/types/card.js +2 -0
  254. package/dist/types/card.js.map +1 -0
  255. package/dist/{components/checkbox/types.d.ts → types/checkbox.d.ts} +4 -4
  256. package/dist/types/checkbox.d.ts.map +1 -0
  257. package/dist/types/checkbox.js +2 -0
  258. package/dist/types/checkbox.js.map +1 -0
  259. package/dist/types/icon.d.ts +66 -0
  260. package/dist/types/icon.d.ts.map +1 -0
  261. package/dist/types/icon.js +2 -0
  262. package/dist/types/icon.js.map +1 -0
  263. package/dist/{primitives/image/types.d.ts → types/image.d.ts} +3 -4
  264. package/dist/types/image.d.ts.map +1 -0
  265. package/dist/types/image.js +2 -0
  266. package/dist/types/image.js.map +1 -0
  267. package/dist/types/keyboard-avoiding-view.d.ts +4 -0
  268. package/dist/types/keyboard-avoiding-view.d.ts.map +1 -0
  269. package/dist/types/keyboard-avoiding-view.js +2 -0
  270. package/dist/types/keyboard-avoiding-view.js.map +1 -0
  271. package/dist/{layout/helpers.d.ts → types/layout.d.ts} +39 -5
  272. package/dist/types/layout.d.ts.map +1 -0
  273. package/dist/types/layout.js +2 -0
  274. package/dist/types/layout.js.map +1 -0
  275. package/dist/{components/radio/types.d.ts → types/radio.d.ts} +4 -4
  276. package/dist/types/radio.d.ts.map +1 -0
  277. package/dist/types/radio.js +2 -0
  278. package/dist/types/radio.js.map +1 -0
  279. package/dist/types/surface.d.ts +6 -0
  280. package/dist/types/surface.d.ts.map +1 -0
  281. package/dist/types/surface.js +2 -0
  282. package/dist/types/surface.js.map +1 -0
  283. package/dist/{components/text-input/types.d.ts → types/text-input.d.ts} +3 -3
  284. package/dist/types/text-input.d.ts.map +1 -0
  285. package/dist/types/text-input.js +2 -0
  286. package/dist/types/text-input.js.map +1 -0
  287. package/dist/types/typography.d.ts +29 -0
  288. package/dist/types/typography.d.ts.map +1 -0
  289. package/dist/types/typography.js +2 -0
  290. package/dist/types/typography.js.map +1 -0
  291. package/dist/utils/resolveBoxStyles.d.ts +7 -0
  292. package/dist/utils/resolveBoxStyles.d.ts.map +1 -0
  293. package/dist/utils/resolveBoxStyles.js +83 -0
  294. package/dist/utils/resolveBoxStyles.js.map +1 -0
  295. package/dist/utils/resolveSpacing.d.ts +5 -0
  296. package/dist/utils/resolveSpacing.d.ts.map +1 -0
  297. package/dist/utils/resolveSpacing.js +6 -0
  298. package/dist/utils/resolveSpacing.js.map +1 -0
  299. package/package.json +1 -1
  300. package/src/components/field/Field.tsx +1 -1
  301. package/src/components/helper-text/HelperText.tsx +1 -1
  302. package/src/components/label/Label.tsx +1 -1
  303. package/src/components/list-item/ListItem.tsx +2 -2
  304. package/src/components/menu/Menu.tsx +4 -2
  305. package/src/components/modal/Modal.tsx +2 -1
  306. package/src/components/switch/Switch.tsx +2 -2
  307. package/src/components/tabs/Tab.tsx +2 -2
  308. package/src/components/tabs/TabList.tsx +1 -1
  309. package/src/components/tabs/Tabs.tsx +1 -1
  310. package/src/components/textarea/Textarea.tsx +1 -1
  311. package/src/components/textarea/types.ts +1 -1
  312. package/src/components/toast/Toast.tsx +4 -2
  313. package/src/components/toast/ToastProvider.tsx +1 -1
  314. package/src/components/tooltip/Tooltip.tsx +2 -2
  315. package/src/examples/DocsExamples.tsx +6 -6
  316. package/src/features/badge/adapters/inbound/Badge.tsx +58 -0
  317. package/src/features/badge/public.ts +2 -0
  318. package/src/features/button/adapters/inbound/Button.tsx +159 -0
  319. package/src/features/button/adapters/inbound/IconButton.tsx +69 -0
  320. package/src/features/button/public.ts +3 -0
  321. package/src/features/card/adapters/inbound/Card.tsx +88 -0
  322. package/src/features/card/public.ts +2 -0
  323. package/src/features/form/checkbox/adapters/inbound/Checkbox.tsx +207 -0
  324. package/src/features/form/checkbox/public.ts +2 -0
  325. package/src/{components/radio → features/form/radio/adapters/inbound}/Radio.test.ts +5 -5
  326. package/src/features/form/radio/adapters/inbound/Radio.tsx +214 -0
  327. package/src/features/form/radio/public.ts +2 -0
  328. package/src/{components/radio → features/form/radio/utils}/isRadioTextContent.ts +1 -3
  329. package/src/features/form/text-input/adapters/inbound/TextInput.tsx +72 -0
  330. package/src/features/form/text-input/public.ts +2 -0
  331. package/src/features/form/text-input/utils/resolveTextInputPresentation.ts +91 -0
  332. package/src/features/icon/adapters/inbound/Icon.tsx +14 -0
  333. package/src/{primitives/icon → features/icon/adapters/inbound}/PortableIcon.tsx +41 -97
  334. package/src/{primitives/icon → features/icon/adapters/inbound}/PortableIcon.web.test.tsx +6 -10
  335. package/src/features/icon/constants.ts +9 -0
  336. package/src/features/icon/public.ts +10 -0
  337. package/src/features/image/adapters/inbound/Image.tsx +55 -0
  338. package/src/features/image/public.ts +2 -0
  339. package/src/features/image/utils/getSourceKey.ts +32 -0
  340. package/src/features/image/utils/normalizeSource.ts +12 -0
  341. package/src/features/image/utils/resolveAccessibilityLabel.ts +9 -0
  342. package/src/features/image/utils/resolveAlt.ts +9 -0
  343. package/src/{primitives/image → features/image/utils}/resolveImageProps.test.ts +10 -22
  344. package/src/features/image/utils/resolveImageStyle.ts +23 -0
  345. package/src/features/image/utils/resolveRenderedSource.ts +11 -0
  346. package/src/features/image/utils/resolveResizeMode.ts +11 -0
  347. package/src/features/keyboard-avoiding-view/adapters/inbound/KeyboardAvoidingView.tsx +9 -0
  348. package/src/features/keyboard-avoiding-view/public.ts +5 -0
  349. package/src/{layout → features/layout/adapters/inbound}/Box.tsx +7 -15
  350. package/src/features/layout/adapters/inbound/Container.tsx +43 -0
  351. package/src/{layout → features/layout/adapters/inbound}/Divider.tsx +3 -8
  352. package/src/features/layout/adapters/inbound/Grid.tsx +78 -0
  353. package/src/{layout → features/layout/adapters/inbound}/Stack.test.ts +0 -1
  354. package/src/{layout → features/layout/adapters/inbound}/Stack.tsx +6 -15
  355. package/src/features/layout/public.ts +12 -0
  356. package/src/{layout → features/surface/adapters/inbound}/Surface.tsx +24 -41
  357. package/src/features/surface/public.ts +2 -0
  358. package/src/{primitives/heading → features/typography/adapters/inbound}/Heading.tsx +35 -38
  359. package/src/{primitives/text → features/typography/adapters/inbound}/Text.tsx +25 -35
  360. package/src/features/typography/public.ts +3 -0
  361. package/src/{primitives/heading/resolveHeadingStyle.test.ts → features/typography/utils/resolveHeadingTextStyle.test.ts} +5 -12
  362. package/src/features/typography/utils/resolveHeadingTextStyle.ts +21 -0
  363. package/src/index.test.ts +58 -28
  364. package/src/index.ts +37 -26
  365. package/src/layout/AppBar.tsx +1 -2
  366. package/src/layout/Center.tsx +1 -1
  367. package/src/layout/Inline.tsx +1 -1
  368. package/src/layout/ScrollArea.tsx +2 -1
  369. package/src/layout/Spacer.tsx +2 -2
  370. package/src/layout/Template.tsx +3 -2
  371. package/src/layout/index.ts +0 -17
  372. package/src/primitives/button-base/ButtonBase.tsx +1 -1
  373. package/src/primitives/button-base/types.ts +1 -1
  374. package/src/{components/badge/types.ts → types/badge.ts} +3 -3
  375. package/src/types/button.ts +34 -0
  376. package/src/{components/card/types.ts → types/card.ts} +1 -1
  377. package/src/{components/checkbox/types.ts → types/checkbox.ts} +3 -3
  378. package/src/types/icon.ts +52 -0
  379. package/src/{primitives/image/types.ts → types/image.ts} +3 -3
  380. package/src/types/keyboard-avoiding-view.ts +6 -0
  381. package/src/types/layout.ts +96 -0
  382. package/src/{components/radio/types.ts → types/radio.ts} +3 -3
  383. package/src/types/surface.ts +7 -0
  384. package/src/{components/text-input/types.ts → types/text-input.ts} +2 -2
  385. package/src/types/typography.ts +32 -0
  386. package/src/{layout/helpers.test.ts → utils/resolveBoxStyles.test.ts} +8 -25
  387. package/src/utils/resolveBoxStyles.ts +135 -0
  388. package/src/utils/resolveSpacing.ts +11 -0
  389. package/src/webAcceptance.test.tsx +2 -3
  390. package/dist/components/badge/Badge.d.ts +0 -4
  391. package/dist/components/badge/Badge.d.ts.map +0 -1
  392. package/dist/components/badge/Badge.js +0 -30
  393. package/dist/components/badge/Badge.js.map +0 -1
  394. package/dist/components/badge/index.d.ts +0 -3
  395. package/dist/components/badge/index.d.ts.map +0 -1
  396. package/dist/components/badge/index.js +0 -2
  397. package/dist/components/badge/index.js.map +0 -1
  398. package/dist/components/badge/types.d.ts +0 -12
  399. package/dist/components/badge/types.d.ts.map +0 -1
  400. package/dist/components/badge/types.js +0 -2
  401. package/dist/components/badge/types.js.map +0 -1
  402. package/dist/components/button/Button.d.ts.map +0 -1
  403. package/dist/components/button/Button.js +0 -51
  404. package/dist/components/button/Button.js.map +0 -1
  405. package/dist/components/button/index.d.ts +0 -3
  406. package/dist/components/button/index.d.ts.map +0 -1
  407. package/dist/components/button/index.js +0 -2
  408. package/dist/components/button/index.js.map +0 -1
  409. package/dist/components/button/types.d.ts +0 -18
  410. package/dist/components/button/types.d.ts.map +0 -1
  411. package/dist/components/button/types.js +0 -2
  412. package/dist/components/button/types.js.map +0 -1
  413. package/dist/components/card/Card.d.ts +0 -4
  414. package/dist/components/card/Card.d.ts.map +0 -1
  415. package/dist/components/card/Card.js +0 -46
  416. package/dist/components/card/Card.js.map +0 -1
  417. package/dist/components/card/index.d.ts +0 -3
  418. package/dist/components/card/index.d.ts.map +0 -1
  419. package/dist/components/card/index.js +0 -2
  420. package/dist/components/card/index.js.map +0 -1
  421. package/dist/components/card/types.d.ts.map +0 -1
  422. package/dist/components/card/types.js +0 -2
  423. package/dist/components/card/types.js.map +0 -1
  424. package/dist/components/checkbox/Checkbox.d.ts +0 -4
  425. package/dist/components/checkbox/Checkbox.d.ts.map +0 -1
  426. package/dist/components/checkbox/Checkbox.js +0 -69
  427. package/dist/components/checkbox/Checkbox.js.map +0 -1
  428. package/dist/components/checkbox/index.d.ts +0 -3
  429. package/dist/components/checkbox/index.d.ts.map +0 -1
  430. package/dist/components/checkbox/index.js +0 -2
  431. package/dist/components/checkbox/index.js.map +0 -1
  432. package/dist/components/checkbox/types.d.ts.map +0 -1
  433. package/dist/components/checkbox/types.js +0 -2
  434. package/dist/components/checkbox/types.js.map +0 -1
  435. package/dist/components/icon-button/IconButton.d.ts.map +0 -1
  436. package/dist/components/icon-button/IconButton.js +0 -28
  437. package/dist/components/icon-button/IconButton.js.map +0 -1
  438. package/dist/components/icon-button/index.d.ts +0 -3
  439. package/dist/components/icon-button/index.d.ts.map +0 -1
  440. package/dist/components/icon-button/index.js +0 -2
  441. package/dist/components/icon-button/index.js.map +0 -1
  442. package/dist/components/icon-button/types.d.ts +0 -13
  443. package/dist/components/icon-button/types.d.ts.map +0 -1
  444. package/dist/components/icon-button/types.js +0 -2
  445. package/dist/components/icon-button/types.js.map +0 -1
  446. package/dist/components/radio/Radio.d.ts +0 -7
  447. package/dist/components/radio/Radio.d.ts.map +0 -1
  448. package/dist/components/radio/Radio.js +0 -75
  449. package/dist/components/radio/Radio.js.map +0 -1
  450. package/dist/components/radio/index.d.ts +0 -3
  451. package/dist/components/radio/index.d.ts.map +0 -1
  452. package/dist/components/radio/index.js +0 -2
  453. package/dist/components/radio/index.js.map +0 -1
  454. package/dist/components/radio/isRadioTextContent.d.ts +0 -6
  455. package/dist/components/radio/isRadioTextContent.d.ts.map +0 -1
  456. package/dist/components/radio/isRadioTextContent.js +0 -7
  457. package/dist/components/radio/isRadioTextContent.js.map +0 -1
  458. package/dist/components/radio/types.d.ts.map +0 -1
  459. package/dist/components/radio/types.js +0 -2
  460. package/dist/components/radio/types.js.map +0 -1
  461. package/dist/components/text-input/TextInput.d.ts +0 -4
  462. package/dist/components/text-input/TextInput.d.ts.map +0 -1
  463. package/dist/components/text-input/TextInput.js +0 -72
  464. package/dist/components/text-input/TextInput.js.map +0 -1
  465. package/dist/components/text-input/index.d.ts +0 -3
  466. package/dist/components/text-input/index.d.ts.map +0 -1
  467. package/dist/components/text-input/index.js +0 -2
  468. package/dist/components/text-input/index.js.map +0 -1
  469. package/dist/components/text-input/types.d.ts.map +0 -1
  470. package/dist/components/text-input/types.js +0 -2
  471. package/dist/components/text-input/types.js.map +0 -1
  472. package/dist/layout/Box.d.ts +0 -14
  473. package/dist/layout/Box.d.ts.map +0 -1
  474. package/dist/layout/Box.js.map +0 -1
  475. package/dist/layout/Container.d.ts +0 -11
  476. package/dist/layout/Container.d.ts.map +0 -1
  477. package/dist/layout/Container.js +0 -24
  478. package/dist/layout/Container.js.map +0 -1
  479. package/dist/layout/Divider.d.ts +0 -10
  480. package/dist/layout/Divider.d.ts.map +0 -1
  481. package/dist/layout/Divider.js.map +0 -1
  482. package/dist/layout/Grid.d.ts +0 -14
  483. package/dist/layout/Grid.d.ts.map +0 -1
  484. package/dist/layout/Grid.js +0 -51
  485. package/dist/layout/Grid.js.map +0 -1
  486. package/dist/layout/KeyboardAvoidingView.d.ts +0 -7
  487. package/dist/layout/KeyboardAvoidingView.d.ts.map +0 -1
  488. package/dist/layout/KeyboardAvoidingView.js.map +0 -1
  489. package/dist/layout/Stack.d.ts +0 -14
  490. package/dist/layout/Stack.d.ts.map +0 -1
  491. package/dist/layout/Stack.js.map +0 -1
  492. package/dist/layout/Surface.d.ts +0 -8
  493. package/dist/layout/Surface.d.ts.map +0 -1
  494. package/dist/layout/Surface.js.map +0 -1
  495. package/dist/layout/helpers.d.ts.map +0 -1
  496. package/dist/layout/helpers.js +0 -91
  497. package/dist/layout/helpers.js.map +0 -1
  498. package/dist/primitives/heading/Heading.d.ts +0 -4
  499. package/dist/primitives/heading/Heading.d.ts.map +0 -1
  500. package/dist/primitives/heading/Heading.js +0 -30
  501. package/dist/primitives/heading/Heading.js.map +0 -1
  502. package/dist/primitives/heading/index.d.ts +0 -3
  503. package/dist/primitives/heading/index.d.ts.map +0 -1
  504. package/dist/primitives/heading/index.js +0 -2
  505. package/dist/primitives/heading/index.js.map +0 -1
  506. package/dist/primitives/heading/resolveHeadingStyle.d.ts +0 -6
  507. package/dist/primitives/heading/resolveHeadingStyle.d.ts.map +0 -1
  508. package/dist/primitives/heading/resolveHeadingStyle.js +0 -9
  509. package/dist/primitives/heading/resolveHeadingStyle.js.map +0 -1
  510. package/dist/primitives/heading/types.d.ts +0 -15
  511. package/dist/primitives/heading/types.d.ts.map +0 -1
  512. package/dist/primitives/heading/types.js +0 -2
  513. package/dist/primitives/heading/types.js.map +0 -1
  514. package/dist/primitives/icon/Icon.d.ts +0 -16
  515. package/dist/primitives/icon/Icon.d.ts.map +0 -1
  516. package/dist/primitives/icon/Icon.js.map +0 -1
  517. package/dist/primitives/icon/PortableIcon.d.ts +0 -70
  518. package/dist/primitives/icon/PortableIcon.d.ts.map +0 -1
  519. package/dist/primitives/icon/PortableIcon.js.map +0 -1
  520. package/dist/primitives/icon/index.d.ts +0 -4
  521. package/dist/primitives/icon/index.d.ts.map +0 -1
  522. package/dist/primitives/icon/index.js +0 -3
  523. package/dist/primitives/icon/index.js.map +0 -1
  524. package/dist/primitives/image/Image.d.ts.map +0 -1
  525. package/dist/primitives/image/Image.js +0 -26
  526. package/dist/primitives/image/Image.js.map +0 -1
  527. package/dist/primitives/image/index.d.ts +0 -3
  528. package/dist/primitives/image/index.d.ts.map +0 -1
  529. package/dist/primitives/image/index.js +0 -2
  530. package/dist/primitives/image/index.js.map +0 -1
  531. package/dist/primitives/image/resolveImageProps.d.ts +0 -12
  532. package/dist/primitives/image/resolveImageProps.d.ts.map +0 -1
  533. package/dist/primitives/image/resolveImageProps.js +0 -67
  534. package/dist/primitives/image/resolveImageProps.js.map +0 -1
  535. package/dist/primitives/image/types.d.ts.map +0 -1
  536. package/dist/primitives/image/types.js +0 -2
  537. package/dist/primitives/image/types.js.map +0 -1
  538. package/dist/primitives/text/Text.d.ts.map +0 -1
  539. package/dist/primitives/text/Text.js.map +0 -1
  540. package/dist/primitives/text/index.d.ts +0 -3
  541. package/dist/primitives/text/index.d.ts.map +0 -1
  542. package/dist/primitives/text/index.js +0 -2
  543. package/dist/primitives/text/index.js.map +0 -1
  544. package/dist/primitives/text/types.d.ts +0 -17
  545. package/dist/primitives/text/types.d.ts.map +0 -1
  546. package/dist/primitives/text/types.js +0 -2
  547. package/dist/primitives/text/types.js.map +0 -1
  548. package/src/components/badge/Badge.tsx +0 -52
  549. package/src/components/badge/index.ts +0 -2
  550. package/src/components/button/Button.tsx +0 -98
  551. package/src/components/button/index.ts +0 -2
  552. package/src/components/button/types.ts +0 -23
  553. package/src/components/card/Card.tsx +0 -81
  554. package/src/components/card/index.ts +0 -2
  555. package/src/components/checkbox/Checkbox.tsx +0 -120
  556. package/src/components/checkbox/index.ts +0 -2
  557. package/src/components/icon-button/IconButton.tsx +0 -55
  558. package/src/components/icon-button/index.ts +0 -2
  559. package/src/components/icon-button/types.ts +0 -16
  560. package/src/components/radio/Radio.tsx +0 -124
  561. package/src/components/radio/index.ts +0 -2
  562. package/src/components/text-input/TextInput.tsx +0 -124
  563. package/src/components/text-input/index.ts +0 -2
  564. package/src/layout/Container.tsx +0 -43
  565. package/src/layout/Grid.tsx +0 -83
  566. package/src/layout/KeyboardAvoidingView.tsx +0 -16
  567. package/src/layout/helpers.ts +0 -205
  568. package/src/primitives/heading/index.ts +0 -2
  569. package/src/primitives/heading/resolveHeadingStyle.ts +0 -20
  570. package/src/primitives/heading/types.ts +0 -17
  571. package/src/primitives/icon/Icon.tsx +0 -34
  572. package/src/primitives/icon/index.ts +0 -10
  573. package/src/primitives/image/Image.tsx +0 -65
  574. package/src/primitives/image/index.ts +0 -2
  575. package/src/primitives/image/resolveImageProps.ts +0 -92
  576. package/src/primitives/text/index.ts +0 -2
  577. package/src/primitives/text/types.ts +0 -18
@@ -0,0 +1,159 @@
1
+ import React from 'react';
2
+ import { ActivityIndicator, View, type ViewStyle } from 'react-native';
3
+
4
+ import {
5
+ type InteractionState,
6
+ resolveButtonColors,
7
+ resolveControlSize,
8
+ resolveIconSize,
9
+ } from '../../../../internal/resolvers';
10
+ import { ButtonBase } from '../../../../primitives/button-base';
11
+ import { useTheme } from '../../../../theme/ThemeContext';
12
+ import type { SurfaceTheme } from '../../../../theme/types';
13
+ import type { ButtonProps } from '../../../../types/button';
14
+ import { Icon } from '../../../icon/public';
15
+ import { Box } from '../../../layout/public';
16
+ import { Text } from '../../../typography/public';
17
+
18
+ /*** Renders the primary Surface action control with semantic visual states. */
19
+ export function Button({
20
+ children,
21
+ variant = 'solid',
22
+ color = 'primary',
23
+ size = 'm',
24
+ disabled = false,
25
+ loading = false,
26
+ leadingIcon,
27
+ trailingIcon,
28
+ fullWidth = false,
29
+ onPress,
30
+ testID,
31
+ ...props
32
+ }: ButtonProps) {
33
+ const { theme } = useTheme();
34
+ const controlSize = resolveControlSize(theme, size);
35
+
36
+ return (
37
+ <ButtonBase
38
+ {...props}
39
+ disabled={disabled || loading}
40
+ onPress={onPress}
41
+ style={resolveButtonBaseStyle(fullWidth)}
42
+ testID={testID}
43
+ >
44
+ {(state) => (
45
+ <ButtonContent
46
+ color={color}
47
+ controlSize={controlSize}
48
+ fullWidth={fullWidth}
49
+ leadingIcon={leadingIcon}
50
+ loading={loading}
51
+ size={size}
52
+ state={state}
53
+ theme={theme}
54
+ trailingIcon={trailingIcon}
55
+ variant={variant}
56
+ >
57
+ {children}
58
+ </ButtonContent>
59
+ )}
60
+ </ButtonBase>
61
+ );
62
+ }
63
+
64
+ /*** Renders Button content after interaction colors have been resolved. */
65
+ function ButtonContent({
66
+ children,
67
+ color,
68
+ controlSize,
69
+ fullWidth,
70
+ leadingIcon,
71
+ loading,
72
+ size,
73
+ state,
74
+ theme,
75
+ trailingIcon,
76
+ variant,
77
+ }: ButtonContentProps) {
78
+ const colors = resolveButtonColors(theme, { variant, color, state });
79
+ const muted = colors.contentColor === theme.semantics.content.muted;
80
+ const iconSize = resolveIconSize(theme, size);
81
+
82
+ return (
83
+ <Box
84
+ px={controlSize.paddingHorizontal}
85
+ py={controlSize.paddingVertical}
86
+ radius={controlSize.borderRadius}
87
+ style={resolveButtonContentStyle(controlSize, colors, fullWidth, variant)}
88
+ >
89
+ {loading ? (
90
+ <ActivityIndicator color={colors.contentColor} size="small" />
91
+ ) : (
92
+ <>
93
+ {leadingIcon ? (
94
+ <View style={resolveAccessoryStyle(theme.spacing.s, 'leading')}>
95
+ <Icon {...leadingIcon} color={colors.contentColor} size={iconSize} />
96
+ </View>
97
+ ) : null}
98
+ <Text
99
+ color={muted ? undefined : color}
100
+ emphasis={muted ? 'muted' : variant === 'solid' ? 'inverse' : 'default'}
101
+ variant={controlSize.textVariant}
102
+ weight="semiBold"
103
+ >
104
+ {children}
105
+ </Text>
106
+ {trailingIcon ? (
107
+ <View style={resolveAccessoryStyle(theme.spacing.s, 'trailing')}>
108
+ <Icon {...trailingIcon} color={colors.contentColor} size={iconSize} />
109
+ </View>
110
+ ) : null}
111
+ </>
112
+ )}
113
+ </Box>
114
+ );
115
+ }
116
+
117
+ /*** Resolves the outer ButtonBase layout style. */
118
+ function resolveButtonBaseStyle(fullWidth: boolean): ViewStyle {
119
+ return { alignSelf: fullWidth ? 'stretch' : 'flex-start' };
120
+ }
121
+
122
+ /*** Resolves the themed Button content container style. */
123
+ function resolveButtonContentStyle(
124
+ controlSize: ReturnType<typeof resolveControlSize>,
125
+ colors: ReturnType<typeof resolveButtonColors>,
126
+ fullWidth: boolean,
127
+ variant: NonNullable<ButtonProps['variant']>,
128
+ ): ViewStyle {
129
+ return {
130
+ alignItems: 'center',
131
+ backgroundColor: colors.backgroundColor,
132
+ borderColor: colors.borderColor,
133
+ borderWidth: variant === 'solid' ? 0 : 1,
134
+ flexDirection: 'row',
135
+ justifyContent: 'center',
136
+ minHeight: controlSize.minHeight,
137
+ opacity: colors.opacity,
138
+ width: fullWidth ? '100%' : undefined,
139
+ };
140
+ }
141
+
142
+ /*** Resolves spacing around a leading or trailing Button icon. */
143
+ function resolveAccessoryStyle(spacing: number, position: 'leading' | 'trailing'): ViewStyle {
144
+ return position === 'leading' ? { marginRight: spacing } : { marginLeft: spacing };
145
+ }
146
+
147
+ interface ButtonContentProps {
148
+ children: ButtonProps['children'];
149
+ color: NonNullable<ButtonProps['color']>;
150
+ controlSize: ReturnType<typeof resolveControlSize>;
151
+ fullWidth: boolean;
152
+ leadingIcon: ButtonProps['leadingIcon'];
153
+ loading: boolean;
154
+ size: NonNullable<ButtonProps['size']>;
155
+ state: InteractionState;
156
+ theme: SurfaceTheme;
157
+ trailingIcon: ButtonProps['trailingIcon'];
158
+ variant: NonNullable<ButtonProps['variant']>;
159
+ }
@@ -0,0 +1,69 @@
1
+ import React from 'react';
2
+ import type { ViewStyle } from 'react-native';
3
+
4
+ import {
5
+ resolveButtonColors,
6
+ resolveControlSize,
7
+ resolveIconSize,
8
+ } from '../../../../internal/resolvers';
9
+ import { ButtonBase } from '../../../../primitives/button-base';
10
+ import { useTheme } from '../../../../theme/ThemeContext';
11
+ import type { IconButtonProps } from '../../../../types/button';
12
+ import { Icon } from '../../../icon/public';
13
+ import { Box } from '../../../layout/public';
14
+
15
+ /*** Renders a compact accessible icon-only action control. */
16
+ export function IconButton({
17
+ icon,
18
+ accessibilityLabel,
19
+ variant = 'ghost',
20
+ color = 'primary',
21
+ size = 'm',
22
+ disabled = false,
23
+ onPress,
24
+ testID,
25
+ ...props
26
+ }: IconButtonProps) {
27
+ const { theme } = useTheme();
28
+ const controlSize = resolveControlSize(theme, size);
29
+
30
+ return (
31
+ <ButtonBase
32
+ {...props}
33
+ accessibilityLabel={accessibilityLabel}
34
+ disabled={disabled}
35
+ onPress={onPress}
36
+ testID={testID}
37
+ >
38
+ {(state) => {
39
+ const colors = resolveButtonColors(theme, { color, state, variant });
40
+ return (
41
+ <Box
42
+ radius={controlSize.borderRadius}
43
+ style={resolveIconButtonStyle(controlSize, colors, variant)}
44
+ >
45
+ <Icon {...icon} color={colors.contentColor} size={resolveIconSize(theme, size)} />
46
+ </Box>
47
+ );
48
+ }}
49
+ </ButtonBase>
50
+ );
51
+ }
52
+
53
+ /*** Resolves the visual container style for an IconButton interaction state. */
54
+ function resolveIconButtonStyle(
55
+ controlSize: ReturnType<typeof resolveControlSize>,
56
+ colors: ReturnType<typeof resolveButtonColors>,
57
+ variant: NonNullable<IconButtonProps['variant']>,
58
+ ): ViewStyle {
59
+ return {
60
+ alignItems: 'center',
61
+ backgroundColor: colors.backgroundColor,
62
+ borderColor: colors.borderColor,
63
+ borderWidth: variant === 'solid' ? 0 : 1,
64
+ justifyContent: 'center',
65
+ minHeight: controlSize.minHeight,
66
+ minWidth: controlSize.minHeight,
67
+ opacity: colors.opacity,
68
+ };
69
+ }
@@ -0,0 +1,3 @@
1
+ export type { ButtonIconSpec, ButtonProps, IconButtonProps } from '../../types/button';
2
+ export { Button } from './adapters/inbound/Button';
3
+ export { IconButton } from './adapters/inbound/IconButton';
@@ -0,0 +1,88 @@
1
+ import React from 'react';
2
+ import type { ViewStyle } from 'react-native';
3
+
4
+ import { ButtonBase } from '../../../../primitives/button-base';
5
+ import { useTheme } from '../../../../theme/ThemeContext';
6
+ import type { CardProps } from '../../../../types/card';
7
+ import type { SurfaceVariant } from '../../../../types/surface';
8
+ import { Surface } from '../../../surface/public';
9
+
10
+ /*** Renders a themed content card with optional interactive press states. */
11
+ export function Card({
12
+ children,
13
+ variant = 'default',
14
+ onPress,
15
+ disabled = false,
16
+ testID,
17
+ style,
18
+ ...props
19
+ }: CardProps) {
20
+ const { theme } = useTheme();
21
+
22
+ if (!onPress) {
23
+ return (
24
+ <Surface {...props} style={style} testID={testID} variant={variant}>
25
+ {children}
26
+ </Surface>
27
+ );
28
+ }
29
+
30
+ return (
31
+ <ButtonBase accessibilityRole="button" disabled={disabled} onPress={onPress} testID={testID}>
32
+ {(state) => (
33
+ <Surface
34
+ {...props}
35
+ style={[
36
+ resolveInteractiveCardStyle(variant, state.pressed, state.hovered, state.disabled, {
37
+ active: theme.semantics.neutral.surfaceActive,
38
+ base: theme.semantics.surface.default,
39
+ hover: theme.semantics.neutral.surfaceHover,
40
+ subtle: theme.semantics.surface.subtle,
41
+ }),
42
+ style,
43
+ ]}
44
+ variant={variant}
45
+ >
46
+ {children}
47
+ </Surface>
48
+ )}
49
+ </ButtonBase>
50
+ );
51
+ }
52
+
53
+ /*** Resolves the complete interactive style for one Card state. */
54
+ function resolveInteractiveCardStyle(
55
+ variant: SurfaceVariant,
56
+ pressed: boolean,
57
+ hovered: boolean,
58
+ disabled: boolean,
59
+ backgrounds: CardBackgrounds,
60
+ ): ViewStyle {
61
+ return {
62
+ backgroundColor: resolveCardStateBackground(variant, pressed, hovered, backgrounds),
63
+ opacity: disabled ? 0.72 : 1,
64
+ };
65
+ }
66
+
67
+ /*** Resolves the interactive background for one Card variant and state. */
68
+ function resolveCardStateBackground(
69
+ variant: SurfaceVariant,
70
+ pressed: boolean,
71
+ hovered: boolean,
72
+ backgrounds: CardBackgrounds,
73
+ ) {
74
+ if (variant === 'outline') {
75
+ return pressed ? backgrounds.active : hovered ? backgrounds.hover : 'transparent';
76
+ }
77
+ if (variant === 'subtle') {
78
+ return pressed ? backgrounds.active : hovered ? backgrounds.hover : backgrounds.subtle;
79
+ }
80
+ return pressed ? backgrounds.active : hovered ? backgrounds.hover : backgrounds.base;
81
+ }
82
+
83
+ interface CardBackgrounds {
84
+ active: string;
85
+ base: string;
86
+ hover: string;
87
+ subtle: string;
88
+ }
@@ -0,0 +1,2 @@
1
+ export type { CardProps } from '../../types/card';
2
+ export { Card } from './adapters/inbound/Card';
@@ -0,0 +1,207 @@
1
+ import React from 'react';
2
+ import type { ViewStyle } from 'react-native';
3
+
4
+ import {
5
+ type InteractionState,
6
+ resolveFieldState,
7
+ resolveIndicatorSize,
8
+ resolveSelectionControlColors,
9
+ resolveSelectionControlNextChecked,
10
+ } from '../../../../../internal/resolvers';
11
+ import { useControllableState } from '../../../../../internal/useControllableState';
12
+ import { ButtonBase } from '../../../../../primitives/button-base';
13
+ import type { ButtonBaseProps } from '../../../../../primitives/button-base/types';
14
+ import { useTheme } from '../../../../../theme/ThemeContext';
15
+ import type { SurfaceTheme } from '../../../../../theme/types';
16
+ import type { CheckboxProps } from '../../../../../types/checkbox';
17
+ import { Box } from '../../../../layout/public';
18
+ import { Text } from '../../../../typography/public';
19
+
20
+ /*** Renders a controlled or uncontrolled accessible checkbox. */
21
+ export function Checkbox({
22
+ accessibilityLabel,
23
+ checked,
24
+ children,
25
+ color = 'primary',
26
+ defaultChecked = false,
27
+ disabled = false,
28
+ invalid = false,
29
+ onCheckedChange,
30
+ readOnly = false,
31
+ size = 'm',
32
+ testID,
33
+ ...buttonProps
34
+ }: CheckboxProps) {
35
+ const { theme } = useTheme();
36
+ const [isChecked, setChecked] = useControllableState<boolean>({
37
+ value: checked,
38
+ defaultValue: defaultChecked,
39
+ onChange: onCheckedChange,
40
+ });
41
+
42
+ return (
43
+ <CheckboxControl
44
+ accessibilityLabel={accessibilityLabel}
45
+ buttonProps={buttonProps}
46
+ color={color}
47
+ disabled={disabled}
48
+ invalid={invalid}
49
+ isChecked={isChecked}
50
+ readOnly={readOnly}
51
+ setChecked={setChecked}
52
+ size={size}
53
+ testID={testID}
54
+ theme={theme}
55
+ >
56
+ {children}
57
+ </CheckboxControl>
58
+ );
59
+ }
60
+
61
+ /*** Owns the checkbox interaction boundary around resolved selection content. */
62
+ function CheckboxControl({
63
+ accessibilityLabel,
64
+ buttonProps,
65
+ children,
66
+ color,
67
+ disabled,
68
+ invalid,
69
+ isChecked,
70
+ readOnly,
71
+ setChecked,
72
+ size,
73
+ testID,
74
+ theme,
75
+ }: CheckboxControlProps) {
76
+ const nextChecked = resolveSelectionControlNextChecked({
77
+ checked: isChecked,
78
+ disabled,
79
+ kind: 'checkbox',
80
+ readOnly,
81
+ });
82
+
83
+ return (
84
+ <ButtonBase
85
+ {...buttonProps}
86
+ accessibilityLabel={accessibilityLabel}
87
+ accessibilityRole="checkbox"
88
+ accessibilityState={{ checked: isChecked }}
89
+ disabled={disabled}
90
+ onPress={nextChecked === null ? undefined : () => setChecked(nextChecked)}
91
+ testID={testID}
92
+ >
93
+ {(interactionState) =>
94
+ renderCheckboxContent({
95
+ children,
96
+ color,
97
+ disabled,
98
+ interactionState,
99
+ invalid,
100
+ isChecked,
101
+ readOnly,
102
+ size,
103
+ theme,
104
+ })
105
+ }
106
+ </ButtonBase>
107
+ );
108
+ }
109
+
110
+ /*** Renders the checkbox indicator and optional label for one interaction state. */
111
+ function renderCheckboxContent(input: CheckboxContentInput) {
112
+ const { interactionState, theme } = input;
113
+ const fieldState = resolveFieldState({
114
+ disabled: input.disabled,
115
+ focused: interactionState.focused,
116
+ invalid: input.invalid,
117
+ readOnly: input.readOnly,
118
+ });
119
+ const colors = resolveSelectionControlColors(theme, {
120
+ checked: input.isChecked,
121
+ fieldState,
122
+ hovered: interactionState.hovered,
123
+ pressed: interactionState.pressed,
124
+ color: input.color,
125
+ });
126
+ const indicatorSize = resolveIndicatorSize(input.size);
127
+ const labelEmphasis = colors.labelColor === theme.semantics.content.muted ? 'muted' : 'default';
128
+ const indicatorColor = fieldState.invalid ? 'error' : input.color;
129
+
130
+ return (
131
+ <Box style={resolveSelectionRowStyle(colors.opacity)}>
132
+ <Box
133
+ radius="s"
134
+ style={resolveCheckboxIndicatorStyle(
135
+ colors.backgroundColor,
136
+ colors.borderColor,
137
+ indicatorSize.checkbox,
138
+ )}
139
+ >
140
+ {input.isChecked ? (
141
+ <Text
142
+ color={input.disabled ? undefined : indicatorColor}
143
+ emphasis={input.disabled ? 'muted' : 'inverse'}
144
+ variant="caption"
145
+ weight="bold"
146
+ >
147
+ ✓
148
+ </Text>
149
+ ) : null}
150
+ </Box>
151
+ {input.children ? (
152
+ <Box ml="s">
153
+ <Text emphasis={labelEmphasis}>{input.children}</Text>
154
+ </Box>
155
+ ) : null}
156
+ </Box>
157
+ );
158
+ }
159
+
160
+ /*** Resolves the horizontal selection-control row style. */
161
+ function resolveSelectionRowStyle(opacity: number | undefined): ViewStyle {
162
+ return { alignItems: 'center', flexDirection: 'row', opacity };
163
+ }
164
+
165
+ /*** Resolves checkbox indicator dimensions and interaction colors. */
166
+ function resolveCheckboxIndicatorStyle(
167
+ backgroundColor: string,
168
+ borderColor: string,
169
+ size: number,
170
+ ): ViewStyle {
171
+ return {
172
+ alignItems: 'center',
173
+ backgroundColor,
174
+ borderColor,
175
+ borderWidth: 1.5,
176
+ height: size,
177
+ justifyContent: 'center',
178
+ width: size,
179
+ };
180
+ }
181
+
182
+ interface CheckboxControlProps {
183
+ accessibilityLabel: CheckboxProps['accessibilityLabel'];
184
+ buttonProps: ButtonBaseProps;
185
+ children: CheckboxProps['children'];
186
+ color: NonNullable<CheckboxProps['color']>;
187
+ disabled: boolean;
188
+ invalid: boolean;
189
+ isChecked: boolean;
190
+ readOnly: boolean;
191
+ setChecked: (checked: boolean) => void;
192
+ size: NonNullable<CheckboxProps['size']>;
193
+ testID: CheckboxProps['testID'];
194
+ theme: SurfaceTheme;
195
+ }
196
+
197
+ interface CheckboxContentInput {
198
+ children: CheckboxProps['children'];
199
+ color: NonNullable<CheckboxProps['color']>;
200
+ disabled: boolean;
201
+ interactionState: InteractionState;
202
+ invalid: boolean;
203
+ isChecked: boolean;
204
+ readOnly: boolean;
205
+ size: NonNullable<CheckboxProps['size']>;
206
+ theme: SurfaceTheme;
207
+ }
@@ -0,0 +1,2 @@
1
+ export type { CheckboxProps } from '../../../types/checkbox';
2
+ export { Checkbox } from './adapters/inbound/Checkbox';
@@ -1,7 +1,7 @@
1
1
  import { expect, test } from 'bun:test';
2
2
  import React from 'react';
3
3
 
4
- import { isRadioTextContent } from './isRadioTextContent';
4
+ import { isRadioTextContent } from '../../utils/isRadioTextContent';
5
5
 
6
6
  test('classifies only primitive labels for the built-in text presentation', () => {
7
7
  expect(isRadioTextContent('Option')).toBe(true);
@@ -11,10 +11,10 @@ test('classifies only primitive labels for the built-in text presentation', () =
11
11
  });
12
12
 
13
13
  test('Radio preserves one radio interaction boundary and renders structured content directly', async () => {
14
- const source = await Bun.file('src/components/radio/Radio.tsx').text();
15
-
14
+ const source = await Bun.file(new URL('./Radio.tsx', import.meta.url)).text();
16
15
  expect(source).toContain('accessibilityRole="radio"');
17
16
  expect(source).toContain('accessibilityState={{ checked: isChecked }}');
18
- expect(source).toContain('const isTextContent = isRadioTextContent(children);');
19
- expect(source).toMatch(/isTextContent \? <Text[^>]*>\{children\}<\/Text> : children/);
17
+ expect(source).toContain('isRadioTextContent(input.children)');
18
+ expect(source).toContain('<Text emphasis={labelEmphasis}>{input.children}</Text>');
19
+ expect(source).toMatch(/:\s*\(\s*input\.children\s*\)/);
20
20
  });