@multiplatform.one/components 7.64.0 → 7.65.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 (321) hide show
  1. package/dist/cjs/Kbd/index.cjs +117 -0
  2. package/dist/cjs/Kbd/index.native.js +126 -0
  3. package/dist/cjs/Kbd/index.native.js.map +1 -0
  4. package/dist/cjs/Kbd/keys.cjs +190 -0
  5. package/dist/cjs/Kbd/keys.native.js +230 -0
  6. package/dist/cjs/Kbd/keys.native.js.map +1 -0
  7. package/dist/cjs/componentColors.cjs +7 -0
  8. package/dist/cjs/componentColors.native.js +7 -0
  9. package/dist/cjs/componentColors.native.js.map +1 -1
  10. package/dist/cjs/index.cjs +1 -0
  11. package/dist/cjs/index.native.js +1 -0
  12. package/dist/cjs/index.native.js.map +1 -1
  13. package/dist/cjs/layouts/page.cjs +12 -1
  14. package/dist/cjs/layouts/page.native.js +11 -0
  15. package/dist/cjs/layouts/page.native.js.map +1 -1
  16. package/dist/esm/Accordion/index.native.js.map +1 -1
  17. package/dist/esm/AnimateHeight/index.native.js.map +1 -1
  18. package/dist/esm/Avatar/getInitials.native.js.map +1 -1
  19. package/dist/esm/Avatar/index.native.js.map +1 -1
  20. package/dist/esm/Badge/index.native.js.map +1 -1
  21. package/dist/esm/Button.native.js.map +1 -1
  22. package/dist/esm/Carousel/index.native.js.map +1 -1
  23. package/dist/esm/Chip/index.native.js.map +1 -1
  24. package/dist/esm/Collapsible.native.js.map +1 -1
  25. package/dist/esm/ContextMenu/index.native.js.map +1 -1
  26. package/dist/esm/CopyField/index.native.js.map +1 -1
  27. package/dist/esm/Dialog.native.js.map +1 -1
  28. package/dist/esm/DotIndicator/index.native.js.map +1 -1
  29. package/dist/esm/DropdownMenu/index.native.js.map +1 -1
  30. package/dist/esm/DropdownMenu/menuSettle.native.js.map +1 -1
  31. package/dist/esm/ErrorBoundary/index.native.js.map +1 -1
  32. package/dist/esm/Heading.native.js.map +1 -1
  33. package/dist/esm/Kbd/index.mjs +88 -0
  34. package/dist/esm/Kbd/index.mjs.map +1 -0
  35. package/dist/esm/Kbd/index.native.js +94 -0
  36. package/dist/esm/Kbd/index.native.js.map +1 -0
  37. package/dist/esm/Kbd/keys.mjs +162 -0
  38. package/dist/esm/Kbd/keys.mjs.map +1 -0
  39. package/dist/esm/Kbd/keys.native.js +199 -0
  40. package/dist/esm/Kbd/keys.native.js.map +1 -0
  41. package/dist/esm/Material/index.native.js.map +1 -1
  42. package/dist/esm/Meter/index.native.js.map +1 -1
  43. package/dist/esm/Meter/meter.native.js.map +1 -1
  44. package/dist/esm/OverflowRow/index.native.js.map +1 -1
  45. package/dist/esm/Pagination.native.js.map +1 -1
  46. package/dist/esm/Popover.native.js.map +1 -1
  47. package/dist/esm/ProgressSteps/index.native.js.map +1 -1
  48. package/dist/esm/Quote/index.native.js.map +1 -1
  49. package/dist/esm/ScrollView/revealFocusedField.native.js.map +1 -1
  50. package/dist/esm/Separator/index.native.js.map +1 -1
  51. package/dist/esm/Sheet.native.js.map +1 -1
  52. package/dist/esm/SheetModal/SheetHeader.native.js.map +1 -1
  53. package/dist/esm/SheetModal/detents.native.js.map +1 -1
  54. package/dist/esm/SheetModal/useSheetFrameFocus.native.js.map +1 -1
  55. package/dist/esm/Skeleton/index.native.js.map +1 -1
  56. package/dist/esm/SkipLink/index.native.js.map +1 -1
  57. package/dist/esm/SortableList/SortableHandle.native.js.map +1 -1
  58. package/dist/esm/SortableList/index.native.js.map +1 -1
  59. package/dist/esm/SortableList/useSortableRows.native.js.map +1 -1
  60. package/dist/esm/Tabs/index.native.js.map +1 -1
  61. package/dist/esm/Text.native.js.map +1 -1
  62. package/dist/esm/ThemePresetPicker/index.native.js.map +1 -1
  63. package/dist/esm/Toast/index.native.js.map +1 -1
  64. package/dist/esm/Toast/store.native.js.map +1 -1
  65. package/dist/esm/Tooltip/nativePress.native.js.map +1 -1
  66. package/dist/esm/Tooltip/tooltipShared.native.js.map +1 -1
  67. package/dist/esm/TreeSelect/index.native.js.map +1 -1
  68. package/dist/esm/TreeSelect/treeSelectModel.native.js.map +1 -1
  69. package/dist/esm/Video/PlayerChrome.native.js.map +1 -1
  70. package/dist/esm/Video/VideoFrame.native.js.map +1 -1
  71. package/dist/esm/Video/types.native.js.map +1 -1
  72. package/dist/esm/Wheel/index.native.js.map +1 -1
  73. package/dist/esm/Wizard/index.native.js.map +1 -1
  74. package/dist/esm/actions/ActionBar.native.js.map +1 -1
  75. package/dist/esm/actions/DangerSection.native.js.map +1 -1
  76. package/dist/esm/actions/DestructiveAction.native.js.map +1 -1
  77. package/dist/esm/actions/HeaderActions.native.js.map +1 -1
  78. package/dist/esm/actions/devWarn.native.js.map +1 -1
  79. package/dist/esm/actions/index.native.js.map +1 -1
  80. package/dist/esm/actions/severity.native.js.map +1 -1
  81. package/dist/esm/appShell/BottomAccessory.native.js.map +1 -1
  82. package/dist/esm/appShell/Dock.native.js.map +1 -1
  83. package/dist/esm/appShell/ScopeMenu.native.js.map +1 -1
  84. package/dist/esm/appShell/SettingsSplit.native.js.map +1 -1
  85. package/dist/esm/appShell/Springboard.native.js.map +1 -1
  86. package/dist/esm/appShell/SystemBar.native.js.map +1 -1
  87. package/dist/esm/appShell/TabBar.native.js.map +1 -1
  88. package/dist/esm/appShell/appTile.native.js.map +1 -1
  89. package/dist/esm/appShell/bottomChrome.native.js.map +1 -1
  90. package/dist/esm/appShell/index.native.js.map +1 -1
  91. package/dist/esm/charts/Axis.native.js.map +1 -1
  92. package/dist/esm/charts/BarChart.native.js.map +1 -1
  93. package/dist/esm/charts/ChartDataView.native.js.map +1 -1
  94. package/dist/esm/charts/ChartSurface.native.js.map +1 -1
  95. package/dist/esm/charts/LineChart.native.js.map +1 -1
  96. package/dist/esm/charts/PieChart.native.js.map +1 -1
  97. package/dist/esm/charts/Sparkline.native.js.map +1 -1
  98. package/dist/esm/charts/accessibility.native.js.map +1 -1
  99. package/dist/esm/charts/chartHeight.native.js.map +1 -1
  100. package/dist/esm/charts/composeChart.native.js.map +1 -1
  101. package/dist/esm/charts/index.native.js.map +1 -1
  102. package/dist/esm/charts/math.native.js.map +1 -1
  103. package/dist/esm/charts/series.native.js.map +1 -1
  104. package/dist/esm/charts/svg.native.js.map +1 -1
  105. package/dist/esm/charts/types.native.js.map +1 -1
  106. package/dist/esm/charts/useChartTheme.native.js.map +1 -1
  107. package/dist/esm/code/Code/index.native.js.map +1 -1
  108. package/dist/esm/code/CodeBlock/index.native.js.map +1 -1
  109. package/dist/esm/code/HighlightedCode/index.native.js.map +1 -1
  110. package/dist/esm/code/Highlighter/houseSyntaxTheme.native.js.map +1 -1
  111. package/dist/esm/code/Highlighter/index.native.js.map +1 -1
  112. package/dist/esm/code/Highlighter/namedGroupMatchAll.native.js.map +1 -1
  113. package/dist/esm/code/Pre/index.native.js.map +1 -1
  114. package/dist/esm/code/index.native.js.map +1 -1
  115. package/dist/esm/componentColors.mjs +7 -0
  116. package/dist/esm/componentColors.mjs.map +1 -1
  117. package/dist/esm/componentColors.native.js +7 -0
  118. package/dist/esm/componentColors.native.js.map +1 -1
  119. package/dist/esm/feedback/ConfirmDialog.native.js.map +1 -1
  120. package/dist/esm/feedback/NotifyHost.native.js.map +1 -1
  121. package/dist/esm/feedback/copy.native.js.map +1 -1
  122. package/dist/esm/feedback/index.native.js.map +1 -1
  123. package/dist/esm/feedback/notify.native.js.map +1 -1
  124. package/dist/esm/feedback/route.native.js.map +1 -1
  125. package/dist/esm/feedback/store.native.js.map +1 -1
  126. package/dist/esm/formLayouts/FormLayouts.native.js.map +1 -1
  127. package/dist/esm/formLayouts/PreferencePanel.native.js.map +1 -1
  128. package/dist/esm/formLayouts/index.native.js.map +1 -1
  129. package/dist/esm/hooks/index.native.js.map +1 -1
  130. package/dist/esm/hooks/useClipboard.native.js.map +1 -1
  131. package/dist/esm/hooks/useDocumentTitle.native.js.map +1 -1
  132. package/dist/esm/hooks/useHoldCue.native.js.map +1 -1
  133. package/dist/esm/icons/CheckRegular.native.js.map +1 -1
  134. package/dist/esm/icons/MinusRegular.native.js.map +1 -1
  135. package/dist/esm/icons/index.native.js.map +1 -1
  136. package/dist/esm/icons/lucide.native.js.map +1 -1
  137. package/dist/esm/icons/themed.native.js.map +1 -1
  138. package/dist/esm/images/Image/ImageFrame.native.js.map +1 -1
  139. package/dist/esm/images/Image/shared.native.js.map +1 -1
  140. package/dist/esm/images/Image/types.native.js.map +1 -1
  141. package/dist/esm/images/index.native.js.map +1 -1
  142. package/dist/esm/index.mjs +1 -0
  143. package/dist/esm/index.mjs.map +1 -1
  144. package/dist/esm/index.native.js +1 -0
  145. package/dist/esm/index.native.js.map +1 -1
  146. package/dist/esm/knobImmuneExports.native.js.map +1 -1
  147. package/dist/esm/layouts/AsyncBoundary.native.js.map +1 -1
  148. package/dist/esm/layouts/Debug/index.native.js.map +1 -1
  149. package/dist/esm/layouts/EmptyState.native.js.map +1 -1
  150. package/dist/esm/layouts/IdentityPlate.native.js.map +1 -1
  151. package/dist/esm/layouts/KeyboardAvoidingWrapper/behavior.native.js.map +1 -1
  152. package/dist/esm/layouts/PageTemplates.native.js.map +1 -1
  153. package/dist/esm/layouts/PaneScaffold.native.js.map +1 -1
  154. package/dist/esm/layouts/SafeAreaWrapper/insets.native.js.map +1 -1
  155. package/dist/esm/layouts/StatusDot.native.js.map +1 -1
  156. package/dist/esm/layouts/ViewSwitcher.native.js.map +1 -1
  157. package/dist/esm/layouts/attachments.native.js.map +1 -1
  158. package/dist/esm/layouts/breadcrumbs.native.js.map +1 -1
  159. package/dist/esm/layouts/index.native.js.map +1 -1
  160. package/dist/esm/layouts/page.mjs +12 -2
  161. package/dist/esm/layouts/page.mjs.map +1 -1
  162. package/dist/esm/layouts/page.native.js +12 -2
  163. package/dist/esm/layouts/page.native.js.map +1 -1
  164. package/dist/esm/layouts/pageHeadingScope.native.js.map +1 -1
  165. package/dist/esm/layouts/screenScroll.native.js.map +1 -1
  166. package/dist/esm/layouts/shellSidebarSlot.native.js.map +1 -1
  167. package/dist/esm/layouts/sidebar.native.js.map +1 -1
  168. package/dist/esm/layouts/tags.native.js.map +1 -1
  169. package/dist/esm/layouts/timeline.native.js.map +1 -1
  170. package/dist/esm/layouts/toolbar.native.js.map +1 -1
  171. package/dist/esm/shared/actionScan.native.js.map +1 -1
  172. package/dist/esm/shared/i18n.native.js.map +1 -1
  173. package/dist/esm/shared/restoreRetries.native.js.map +1 -1
  174. package/dist/esm/shared/t.native.js.map +1 -1
  175. package/dist/esm/shared/textRidesText.native.js.map +1 -1
  176. package/dist/esm/shared/useReturnFocusOnClose.native.js.map +1 -1
  177. package/dist/esm/surfaces.native.js.map +1 -1
  178. package/dist/esm/tamagui.native.js.map +1 -1
  179. package/dist/esm/testSetup.native.js.map +1 -1
  180. package/dist/esm/utils/setTinted.native.js.map +1 -1
  181. package/dist/esm/utils/unwrapText.native.js.map +1 -1
  182. package/dist/esm/views/Calendar.native.js.map +1 -1
  183. package/dist/esm/views/Dashboard.native.js.map +1 -1
  184. package/dist/esm/views/Gantt.native.js.map +1 -1
  185. package/dist/esm/views/GanttDateGrip.native.js.map +1 -1
  186. package/dist/esm/views/ImageGrid.native.js.map +1 -1
  187. package/dist/esm/views/List.native.js.map +1 -1
  188. package/dist/esm/views/Matrix.native.js.map +1 -1
  189. package/dist/esm/views/ReportBuilder.native.js.map +1 -1
  190. package/dist/esm/views/TreeView.native.js.map +1 -1
  191. package/dist/esm/views/calendarMath.native.js.map +1 -1
  192. package/dist/esm/views/ganttIntervals.native.js.map +1 -1
  193. package/dist/esm/views/ganttMath.native.js.map +1 -1
  194. package/dist/esm/views/index.native.js.map +1 -1
  195. package/dist/esm/views/kanbanDnd.native.js.map +1 -1
  196. package/dist/esm/views/matrixMath.native.js.map +1 -1
  197. package/dist/esm/views/treeViewDnd.native.js.map +1 -1
  198. package/dist/esm/views/treeViewLayout.native.js.map +1 -1
  199. package/dist/esm/views/treeViewMotion.native.js.map +1 -1
  200. package/dist/esm/views/treeViewReveal.native.js.map +1 -1
  201. package/dist/jsx/Accordion/index.native.js +1 -1
  202. package/dist/jsx/Accordion/index.native.js.map +1 -1
  203. package/dist/jsx/Carousel/index.native.js +2 -2
  204. package/dist/jsx/Carousel/index.native.js.map +1 -1
  205. package/dist/jsx/Kbd/index.mjs +88 -0
  206. package/dist/jsx/Kbd/index.mjs.map +1 -0
  207. package/dist/jsx/Kbd/index.native.js +126 -0
  208. package/dist/jsx/Kbd/index.native.js.map +1 -0
  209. package/dist/jsx/Kbd/keys.mjs +162 -0
  210. package/dist/jsx/Kbd/keys.mjs.map +1 -0
  211. package/dist/jsx/Kbd/keys.native.js +230 -0
  212. package/dist/jsx/Kbd/keys.native.js.map +1 -0
  213. package/dist/jsx/Meter/index.native.js +1 -1
  214. package/dist/jsx/Meter/index.native.js.map +1 -1
  215. package/dist/jsx/OverflowRow/index.native.js +1 -1
  216. package/dist/jsx/OverflowRow/index.native.js.map +1 -1
  217. package/dist/jsx/Pagination.native.js +1 -1
  218. package/dist/jsx/Pagination.native.js.map +1 -1
  219. package/dist/jsx/Tabs/index.native.js +1 -1
  220. package/dist/jsx/Tabs/index.native.js.map +1 -1
  221. package/dist/jsx/ThemePresetPicker/index.native.js +2 -2
  222. package/dist/jsx/ThemePresetPicker/index.native.js.map +1 -1
  223. package/dist/jsx/TreeSelect/index.native.js +1 -1
  224. package/dist/jsx/TreeSelect/index.native.js.map +1 -1
  225. package/dist/jsx/Wizard/index.native.js +2 -2
  226. package/dist/jsx/Wizard/index.native.js.map +1 -1
  227. package/dist/jsx/actions/HeaderActions.native.js +2 -2
  228. package/dist/jsx/actions/HeaderActions.native.js.map +1 -1
  229. package/dist/jsx/appShell/SettingsSplit.native.js +1 -1
  230. package/dist/jsx/appShell/SettingsSplit.native.js.map +1 -1
  231. package/dist/jsx/appShell/Springboard.native.js +1 -1
  232. package/dist/jsx/appShell/Springboard.native.js.map +1 -1
  233. package/dist/jsx/appShell/TabBar.native.js +1 -1
  234. package/dist/jsx/appShell/TabBar.native.js.map +1 -1
  235. package/dist/jsx/appShell/appTile.native.js +1 -1
  236. package/dist/jsx/appShell/appTile.native.js.map +1 -1
  237. package/dist/jsx/charts/ChartDataView.native.js +1 -1
  238. package/dist/jsx/charts/ChartDataView.native.js.map +1 -1
  239. package/dist/jsx/code/CodeBlock/index.native.js +7 -7
  240. package/dist/jsx/code/CodeBlock/index.native.js.map +1 -1
  241. package/dist/jsx/code/index.native.js +5 -5
  242. package/dist/jsx/code/index.native.js.map +1 -1
  243. package/dist/jsx/componentColors.mjs +7 -0
  244. package/dist/jsx/componentColors.mjs.map +1 -1
  245. package/dist/jsx/componentColors.native.js +7 -0
  246. package/dist/jsx/componentColors.native.js.map +1 -1
  247. package/dist/jsx/feedback/NotifyHost.native.js +1 -1
  248. package/dist/jsx/feedback/NotifyHost.native.js.map +1 -1
  249. package/dist/jsx/formLayouts/FormLayouts.native.js +1 -1
  250. package/dist/jsx/formLayouts/FormLayouts.native.js.map +1 -1
  251. package/dist/jsx/formLayouts/PreferencePanel.native.js +1 -1
  252. package/dist/jsx/formLayouts/PreferencePanel.native.js.map +1 -1
  253. package/dist/jsx/hooks/index.native.js +1 -1
  254. package/dist/jsx/hooks/index.native.js.map +1 -1
  255. package/dist/jsx/images/Image/ImageFrame.native.js +1 -1
  256. package/dist/jsx/images/Image/ImageFrame.native.js.map +1 -1
  257. package/dist/jsx/images/Image/index.native.js +1 -1
  258. package/dist/jsx/images/Image/shared.native.js +1 -1
  259. package/dist/jsx/images/Image/shared.native.js.map +1 -1
  260. package/dist/jsx/index.js +1 -0
  261. package/dist/jsx/index.js.map +1 -1
  262. package/dist/jsx/index.mjs +1 -0
  263. package/dist/jsx/index.mjs.map +1 -1
  264. package/dist/jsx/index.native.js +33 -32
  265. package/dist/jsx/index.native.js.map +1 -1
  266. package/dist/jsx/layouts/AsyncBoundary.native.js +1 -1
  267. package/dist/jsx/layouts/AsyncBoundary.native.js.map +1 -1
  268. package/dist/jsx/layouts/attachments.native.js +1 -1
  269. package/dist/jsx/layouts/attachments.native.js.map +1 -1
  270. package/dist/jsx/layouts/index.native.js +3 -3
  271. package/dist/jsx/layouts/index.native.js.map +1 -1
  272. package/dist/jsx/layouts/page.mjs +12 -2
  273. package/dist/jsx/layouts/page.mjs.map +1 -1
  274. package/dist/jsx/layouts/page.native.js +13 -2
  275. package/dist/jsx/layouts/page.native.js.map +1 -1
  276. package/dist/jsx/layouts/sidebar.native.js +1 -1
  277. package/dist/jsx/layouts/sidebar.native.js.map +1 -1
  278. package/dist/jsx/layouts/tags.native.js +2 -2
  279. package/dist/jsx/layouts/tags.native.js.map +1 -1
  280. package/dist/jsx/layouts/timeline.native.js +2 -2
  281. package/dist/jsx/layouts/timeline.native.js.map +1 -1
  282. package/dist/jsx/layouts/toolbar.native.js +1 -1
  283. package/dist/jsx/layouts/toolbar.native.js.map +1 -1
  284. package/dist/jsx/surfaces.native.js +1 -1
  285. package/dist/jsx/surfaces.native.js.map +1 -1
  286. package/dist/jsx/tamagui.native.js +1 -1
  287. package/dist/jsx/tamagui.native.js.map +1 -1
  288. package/dist/jsx/views/Calendar.native.js +1 -1
  289. package/dist/jsx/views/Calendar.native.js.map +1 -1
  290. package/dist/jsx/views/Dashboard.native.js +2 -2
  291. package/dist/jsx/views/Dashboard.native.js.map +1 -1
  292. package/dist/jsx/views/Gantt.native.js +2 -2
  293. package/dist/jsx/views/Gantt.native.js.map +1 -1
  294. package/dist/jsx/views/ImageGrid.native.js +1 -1
  295. package/dist/jsx/views/ImageGrid.native.js.map +1 -1
  296. package/dist/jsx/views/Kanban.native.js +1 -1
  297. package/dist/jsx/views/Matrix.native.js +2 -2
  298. package/dist/jsx/views/Matrix.native.js.map +1 -1
  299. package/dist/jsx/views/ReportBuilder.native.js +2 -2
  300. package/dist/jsx/views/ReportBuilder.native.js.map +1 -1
  301. package/dist/jsx/views/index.native.js +1 -1
  302. package/dist/jsx/views/index.native.js.map +1 -1
  303. package/package.json +9 -9
  304. package/src/Kbd/Kbd.spec.tsx +104 -0
  305. package/src/Kbd/Kbd.stories.tsx +114 -0
  306. package/src/Kbd/index.tsx +113 -0
  307. package/src/Kbd/keys.ts +176 -0
  308. package/src/componentColors.ts +8 -0
  309. package/src/index.ts +1 -0
  310. package/src/layouts/page.tsx +18 -0
  311. package/src/layouts/pageActionButton.spec.tsx +77 -0
  312. package/types/Kbd/index.d.ts +29 -0
  313. package/types/Kbd/index.d.ts.map +1 -0
  314. package/types/Kbd/keys.d.ts +32 -0
  315. package/types/Kbd/keys.d.ts.map +1 -0
  316. package/types/componentColors.d.ts +7 -0
  317. package/types/componentColors.d.ts.map +1 -1
  318. package/types/index.d.ts +1 -0
  319. package/types/index.d.ts.map +1 -1
  320. package/types/layouts/page.d.ts +11 -0
  321. package/types/layouts/page.d.ts.map +1 -1
@@ -0,0 +1,104 @@
1
+ import { renderWithProviders } from "@multiplatform.one/test-utils";
2
+ import { describe, expect, it } from "vitest";
3
+ import { Kbd, chordName, resolveChord, splitChord } from "./index";
4
+
5
+ const glyphs = (input: string | string[], platform: "apple" | "other") =>
6
+ resolveChord(input, platform).map((key) => key.glyph);
7
+
8
+ describe("splitChord", () => {
9
+ it("splits a plus-joined chord and trims each key", () => {
10
+ expect(splitChord("Mod + Shift + K")).toEqual(["Mod", "Shift", "K"]);
11
+ });
12
+
13
+ it("keeps the plus key itself", () => {
14
+ expect(splitChord("Ctrl++")).toEqual(["Ctrl", "+"]);
15
+ expect(splitChord("+")).toEqual(["+"]);
16
+ });
17
+
18
+ it("splits a run of Apple modifier glyphs off the key", () => {
19
+ expect(splitChord("⇧⌘K")).toEqual(["⇧", "⌘", "K"]);
20
+ });
21
+
22
+ it("takes an array as already split and drops blanks", () => {
23
+ expect(splitChord(["mod", " ", "K"])).toEqual(["mod", "K"]);
24
+ });
25
+
26
+ it("leaves a single key alone", () => {
27
+ expect(splitChord("esc")).toEqual(["esc"]);
28
+ expect(splitChord("↑↓")).toEqual(["↑↓"]);
29
+ });
30
+ });
31
+
32
+ describe("resolveChord modifier mapping", () => {
33
+ it("draws Mod as Command on Apple and Ctrl elsewhere", () => {
34
+ expect(glyphs("Mod+K", "apple")).toEqual(["⌘", "K"]);
35
+ expect(glyphs("Mod+K", "other")).toEqual(["Ctrl", "K"]);
36
+ });
37
+
38
+ it("uses the HIG glyphs for every Apple modifier", () => {
39
+ expect(glyphs("Ctrl+Alt+Shift+Cmd+P", "apple")).toEqual(["⌃", "⌥", "⇧", "⌘", "P"]);
40
+ });
41
+
42
+ it("orders modifiers by platform whatever order they were written in", () => {
43
+ expect(glyphs("Cmd+Shift+Option+Z", "apple")).toEqual(["⌥", "⇧", "⌘", "Z"]);
44
+ expect(glyphs("Shift+Alt+Ctrl+Z", "other")).toEqual(["Ctrl", "Alt", "Shift", "Z"]);
45
+ });
46
+
47
+ it("reads Apple glyph input on other platforms", () => {
48
+ expect(glyphs("⇧⌘K", "other")).toEqual(["Meta", "Shift", "K"]);
49
+ });
50
+
51
+ it("drops a repeated modifier", () => {
52
+ expect(glyphs("Mod+Cmd+K", "apple")).toEqual(["⌘", "K"]);
53
+ });
54
+
55
+ it("maps named keys per platform and uppercases letters", () => {
56
+ expect(glyphs("Enter", "apple")).toEqual(["↩"]);
57
+ expect(glyphs("Enter", "other")).toEqual(["Enter"]);
58
+ expect(glyphs("esc", "apple")).toEqual(["esc"]);
59
+ expect(glyphs("esc", "other")).toEqual(["Esc"]);
60
+ expect(glyphs("k", "other")).toEqual(["K"]);
61
+ });
62
+
63
+ it("names every key for a screen reader", () => {
64
+ expect(chordName(resolveChord("Mod+Shift+K", "apple"))).toBe("Shift Command K");
65
+ expect(chordName(resolveChord("Mod+Shift+K", "other"))).toBe("Control Shift K");
66
+ });
67
+ });
68
+
69
+ describe("Kbd", () => {
70
+ it("renders a chord as nested kbd elements, one cap per key", () => {
71
+ const { container } = renderWithProviders(<Kbd keys="Mod+Shift+K" platform="apple" />);
72
+ const outer = container.querySelector("kbd[data-kbd-platform]");
73
+ expect(outer).toBeTruthy();
74
+ const caps = outer?.querySelectorAll("kbd[data-kbd-key]") ?? [];
75
+ expect(Array.from(caps).map((cap) => cap.textContent)).toEqual(["⇧", "⌘", "K"]);
76
+ });
77
+
78
+ it("joins caps with + on other platforms and not on Apple", () => {
79
+ const apple = renderWithProviders(<Kbd keys="Mod+K" platform="apple" />);
80
+ expect(apple.container.textContent).not.toContain("+");
81
+ apple.unmount();
82
+ const other = renderWithProviders(<Kbd keys="Mod+K" platform="other" />);
83
+ expect(other.container.textContent).toContain("Ctrl+K");
84
+ });
85
+
86
+ it("takes a single key as children", () => {
87
+ const { container } = renderWithProviders(<Kbd platform="other">esc</Kbd>);
88
+ expect(container.querySelectorAll("kbd[data-kbd-key]")).toHaveLength(1);
89
+ expect(container.textContent).toContain("Esc");
90
+ });
91
+
92
+ it("gives assistive technology the spoken chord and hides the glyphs", () => {
93
+ const { container } = renderWithProviders(<Kbd keys="Mod+S" platform="apple" />);
94
+ expect(container.textContent).toContain("Command S");
95
+ for (const cap of Array.from(container.querySelectorAll("kbd[data-kbd-key]"))) {
96
+ expect(cap.getAttribute("aria-hidden")).toBe("true");
97
+ }
98
+ });
99
+
100
+ it("renders nothing for an empty chord", () => {
101
+ const { container } = renderWithProviders(<Kbd keys="" />);
102
+ expect(container.querySelector("kbd")).toBeNull();
103
+ });
104
+ });
@@ -0,0 +1,114 @@
1
+ import type { Meta, StoryObj } from "@storybook/react-native-web-vite";
2
+ import { XStack, YStack } from "tamagui";
3
+ import { Card } from "../Card";
4
+ import { Text } from "../Text";
5
+ import { Kbd, type KbdPlatform } from "./index";
6
+
7
+ const meta: Meta<typeof Kbd> = {
8
+ title: "Components/Kbd",
9
+ component: Kbd,
10
+ parameters: {
11
+ status: { type: "beta" },
12
+ docs: {
13
+ description: {
14
+ component:
15
+ "Keyboard key cap (FZ-8008). One key or a chord. On Apple platforms it draws the HIG modifier glyphs ⌃ ⌥ ⇧ ⌘ in menu order with no separator; elsewhere Ctrl, Alt, Shift joined with +. `Mod` is ⌘ on Apple and Ctrl elsewhere. Plate, hairline edge, radius and type come from the theme.",
16
+ },
17
+ },
18
+ },
19
+ };
20
+ export default meta;
21
+
22
+ type Story = StoryObj<typeof Kbd>;
23
+
24
+ const singles = ["K", "esc", "Enter", "Tab", "Space", "Up", "Backspace"];
25
+ const chords = ["Mod+K", "Mod+Shift+P", "Ctrl+Alt+Delete", "Mod+Option+I", "Shift+Tab"];
26
+
27
+ function Sample({ platform }: { platform: KbdPlatform }) {
28
+ return (
29
+ <YStack gap="$3">
30
+ <Text fontSize="$2" color="$color11">
31
+ {platform === "apple" ? "macOS / iOS" : "Windows / Linux / Android"}
32
+ </Text>
33
+ <XStack gap="$2" flexWrap="wrap" alignItems="center">
34
+ {singles.map((key) => (
35
+ <Kbd key={key} keys={key} platform={platform} />
36
+ ))}
37
+ </XStack>
38
+ <XStack gap="$3" flexWrap="wrap" alignItems="center">
39
+ {chords.map((chord) => (
40
+ <Kbd key={chord} keys={chord} platform={platform} />
41
+ ))}
42
+ </XStack>
43
+ </YStack>
44
+ );
45
+ }
46
+
47
+ export const Default: Story = {
48
+ name: "Main",
49
+ render: () => (
50
+ <YStack gap="$5" padding="$4">
51
+ <Sample platform="apple" />
52
+ <Sample platform="other" />
53
+ </YStack>
54
+ ),
55
+ };
56
+
57
+ export const RunningPlatform: Story = {
58
+ render: () => (
59
+ <XStack gap="$3" padding="$4" alignItems="center" flexWrap="wrap">
60
+ <Kbd keys="Mod+K" />
61
+ <Kbd keys="Mod+Shift+Z" />
62
+ <Kbd>esc</Kbd>
63
+ </XStack>
64
+ ),
65
+ };
66
+
67
+ const rows: { keys: string; label: string }[] = [
68
+ { keys: "Mod+K", label: "Open the command palette" },
69
+ { keys: "Mod+S", label: "Save the open document" },
70
+ { keys: "Mod+Shift+Z", label: "Redo" },
71
+ { keys: "esc", label: "Close dialogs and menus" },
72
+ ];
73
+
74
+ export const ShortcutList: Story = {
75
+ render: () => (
76
+ <YStack padding="$4" maxWidth={560}>
77
+ <Card>
78
+ <YStack gap="$3">
79
+ {rows.map((row) => (
80
+ <XStack key={row.keys} gap="$3" alignItems="center" justifyContent="space-between">
81
+ <Text flex={1}>{row.label}</Text>
82
+ <Kbd keys={row.keys} />
83
+ </XStack>
84
+ ))}
85
+ </YStack>
86
+ </Card>
87
+ </YStack>
88
+ ),
89
+ };
90
+
91
+ export const InlineHint: Story = {
92
+ render: () => (
93
+ <XStack gap="$3" padding="$4" alignItems="center" flexWrap="wrap">
94
+ <XStack gap="$1.5" alignItems="center">
95
+ <Kbd keys="↑↓" />
96
+ <Text fontSize="$1" color="$color11">
97
+ navigate
98
+ </Text>
99
+ </XStack>
100
+ <XStack gap="$1.5" alignItems="center">
101
+ <Kbd keys="Enter" />
102
+ <Text fontSize="$1" color="$color11">
103
+ open
104
+ </Text>
105
+ </XStack>
106
+ <XStack gap="$1.5" alignItems="center">
107
+ <Kbd keys="esc" />
108
+ <Text fontSize="$1" color="$color11">
109
+ close
110
+ </Text>
111
+ </XStack>
112
+ </XStack>
113
+ ),
114
+ };
@@ -0,0 +1,113 @@
1
+ import { useResolvedKnobs } from "@multiplatform.one/theme";
2
+ import { Fragment, useMemo } from "react";
3
+ import type { GetProps } from "tamagui";
4
+ import { Text, View, VisuallyHidden, XStack, isWeb, styled } from "tamagui";
5
+ import { componentColors } from "../componentColors";
6
+ import { type KbdKey, type KbdPlatform, chordName, detectKbdPlatform, resolveChord } from "./keys";
7
+
8
+ export {
9
+ chordName,
10
+ detectKbdPlatform,
11
+ resolveChord,
12
+ splitChord,
13
+ type KbdKey,
14
+ type KbdModifier,
15
+ type KbdPlatform,
16
+ } from "./keys";
17
+
18
+ export interface KbdProps extends Omit<GetProps<typeof KbdFrame>, "children"> {
19
+ /**
20
+ * One key ("K", "esc", "Enter") or a chord: "Mod+Shift+K", ["mod", "K"],
21
+ * or Apple glyphs "⇧⌘K". `Mod` is ⌘ on Apple platforms and Ctrl elsewhere.
22
+ */
23
+ keys?: string | readonly string[];
24
+ /** Same as `keys`, for `<Kbd>esc</Kbd>`. `keys` wins when both are given. */
25
+ children?: string;
26
+ /** Which convention to draw. Defaults to the running platform. */
27
+ platform?: KbdPlatform;
28
+ }
29
+
30
+ const KbdFrame = styled(XStack, {
31
+ name: "Kbd",
32
+ alignItems: "center",
33
+ flexShrink: 0,
34
+ });
35
+
36
+ const KbdCap = styled(View, {
37
+ name: "KbdCap",
38
+ alignItems: "center",
39
+ justifyContent: "center",
40
+ minWidth: "$1",
41
+ minHeight: "$1",
42
+ paddingHorizontal: "$1.5",
43
+ backgroundColor: componentColors.keyCap.background,
44
+ });
45
+
46
+ const KbdGlyph = styled(Text, {
47
+ name: "KbdGlyph",
48
+ textAlign: "center",
49
+ fontWeight: "500",
50
+ });
51
+
52
+ /**
53
+ * A keyboard key cap, or the caps of a chord (HIG key-equivalent glyphs on
54
+ * Apple platforms, spelled-out modifiers joined with "+" elsewhere). A small
55
+ * plate one step off its ground with a hairline edge that thickens along the
56
+ * bottom, so it reads as a key and not a chip. Fill, edge, radius and type
57
+ * come from the theme, so it follows every preset in light and dark.
58
+ */
59
+ export function Kbd({ keys, children, platform, ...props }: KbdProps) {
60
+ const { knobProps } = useResolvedKnobs({ component: "Kbd" });
61
+ const resolvedPlatform = platform ?? detectKbdPlatform();
62
+ const caps = useMemo<KbdKey[]>(
63
+ () => resolveChord(keys ?? children ?? "", resolvedPlatform),
64
+ [keys, children, resolvedPlatform],
65
+ );
66
+ if (caps.length === 0) return null;
67
+
68
+ const edge = knobProps.borderRadius;
69
+ const spoken = chordName(caps);
70
+ const glyphType = {
71
+ fontFamily: knobProps.body.fontFamily,
72
+ fontSize: knobProps.textRole.caption.fontSize,
73
+ lineHeight: knobProps.textRole.caption.lineHeight,
74
+ color: knobProps.textAccentColor,
75
+ };
76
+ const joined = resolvedPlatform === "other";
77
+
78
+ return (
79
+ <KbdFrame
80
+ render="kbd"
81
+ gap={joined ? "$1" : "$0.75"}
82
+ {...(isWeb
83
+ ? undefined
84
+ : { accessible: true, accessibilityRole: "text" as const, accessibilityLabel: spoken })}
85
+ {...({ "data-kbd-platform": resolvedPlatform } as Record<string, string>)}
86
+ {...props}
87
+ >
88
+ {isWeb ? <VisuallyHidden>{spoken}</VisuallyHidden> : null}
89
+ {caps.map((cap, index) => (
90
+ <Fragment key={`${cap.glyph}-${index}`}>
91
+ {joined && index > 0 ? (
92
+ <KbdGlyph {...glyphType} aria-hidden>
93
+ +
94
+ </KbdGlyph>
95
+ ) : null}
96
+ <KbdCap
97
+ render="kbd"
98
+ aria-hidden
99
+ borderColor={edge.borderColor}
100
+ borderWidth={edge.borderWidth}
101
+ borderBottomWidth={edge.borderWidth * 2}
102
+ {...knobProps.borderRadiusNested}
103
+ {...({ "data-kbd-key": cap.name } as Record<string, string>)}
104
+ >
105
+ <KbdGlyph {...glyphType}>{cap.glyph}</KbdGlyph>
106
+ </KbdCap>
107
+ </Fragment>
108
+ ))}
109
+ </KbdFrame>
110
+ );
111
+ }
112
+
113
+ export type KbdCapProps = GetProps<typeof KbdCap>;
@@ -0,0 +1,176 @@
1
+ import { isIos } from "@multiplatform.one/platform";
2
+
3
+ /**
4
+ * Which keyboard convention a key cap draws. `apple` is macOS / iPadOS: the
5
+ * modifier glyphs and the menu order ⌃ ⌥ ⇧ ⌘ with no separator. `other` is
6
+ * Windows, Linux, ChromeOS and Android: spelled-out modifiers in the order
7
+ * Ctrl, Alt, Shift, joined with "+".
8
+ */
9
+ export type KbdPlatform = "apple" | "other";
10
+
11
+ export type KbdModifier = "ctrl" | "alt" | "shift" | "meta";
12
+
13
+ export interface KbdKey {
14
+ /** What the cap shows: a glyph on Apple ("⌘"), a word elsewhere ("Ctrl"). */
15
+ glyph: string;
16
+ /** What a screen reader says: "Command", "Control", "K". */
17
+ name: string;
18
+ /** Set for modifier keys; drives the order. */
19
+ modifier?: KbdModifier;
20
+ }
21
+
22
+ /** The running platform's convention. iOS and any Apple browser draw Apple glyphs. */
23
+ export function detectKbdPlatform(): KbdPlatform {
24
+ if (isIos) return "apple";
25
+ if (typeof navigator === "undefined") return "other";
26
+ const nav = navigator as Navigator & { userAgentData?: { platform?: string } };
27
+ const name = String(nav.userAgentData?.platform ?? nav.platform ?? "");
28
+ return /mac|iphone|ipad|ipod/i.test(name) ? "apple" : "other";
29
+ }
30
+
31
+ const modifierGlyphs: Record<string, KbdModifier> = {
32
+ "⌘": "meta",
33
+ "⌥": "alt",
34
+ "⇧": "shift",
35
+ "⌃": "ctrl",
36
+ };
37
+
38
+ const modifierAliases: Record<string, KbdModifier | "mod"> = {
39
+ mod: "mod",
40
+ cmd: "meta",
41
+ command: "meta",
42
+ meta: "meta",
43
+ super: "meta",
44
+ win: "meta",
45
+ ctrl: "ctrl",
46
+ control: "ctrl",
47
+ alt: "alt",
48
+ opt: "alt",
49
+ option: "alt",
50
+ shift: "shift",
51
+ ...modifierGlyphs,
52
+ };
53
+
54
+ const modifierLabels: Record<KbdPlatform, Record<KbdModifier, { glyph: string; name: string }>> = {
55
+ apple: {
56
+ ctrl: { glyph: "⌃", name: "Control" },
57
+ alt: { glyph: "⌥", name: "Option" },
58
+ shift: { glyph: "⇧", name: "Shift" },
59
+ meta: { glyph: "⌘", name: "Command" },
60
+ },
61
+ other: {
62
+ ctrl: { glyph: "Ctrl", name: "Control" },
63
+ alt: { glyph: "Alt", name: "Alt" },
64
+ shift: { glyph: "Shift", name: "Shift" },
65
+ meta: { glyph: "Meta", name: "Meta" },
66
+ },
67
+ };
68
+
69
+ const modifierOrder: Record<KbdPlatform, KbdModifier[]> = {
70
+ apple: ["ctrl", "alt", "shift", "meta"],
71
+ other: ["meta", "ctrl", "alt", "shift"],
72
+ };
73
+
74
+ type NamedKey = { apple: [string, string]; other: [string, string] };
75
+
76
+ const named = (apple: [string, string], other: [string, string] = apple): NamedKey => ({
77
+ apple,
78
+ other,
79
+ });
80
+
81
+ const namedKeys: Record<string, NamedKey> = {
82
+ enter: named(["↩", "Return"], ["Enter", "Enter"]),
83
+ return: named(["↩", "Return"], ["Enter", "Enter"]),
84
+ esc: named(["esc", "Escape"], ["Esc", "Escape"]),
85
+ escape: named(["esc", "Escape"], ["Esc", "Escape"]),
86
+ tab: named(["⇥", "Tab"], ["Tab", "Tab"]),
87
+ backspace: named(["⌫", "Delete"], ["Backspace", "Backspace"]),
88
+ delete: named(["⌦", "Forward Delete"], ["Del", "Delete"]),
89
+ del: named(["⌦", "Forward Delete"], ["Del", "Delete"]),
90
+ space: named(["Space", "Space"]),
91
+ up: named(["↑", "Up Arrow"]),
92
+ down: named(["↓", "Down Arrow"]),
93
+ left: named(["←", "Left Arrow"]),
94
+ right: named(["→", "Right Arrow"]),
95
+ arrowup: named(["↑", "Up Arrow"]),
96
+ arrowdown: named(["↓", "Down Arrow"]),
97
+ arrowleft: named(["←", "Left Arrow"]),
98
+ arrowright: named(["→", "Right Arrow"]),
99
+ pageup: named(["⇞", "Page Up"], ["PgUp", "Page Up"]),
100
+ pagedown: named(["⇟", "Page Down"], ["PgDn", "Page Down"]),
101
+ home: named(["↖", "Home"], ["Home", "Home"]),
102
+ end: named(["↘", "End"], ["End", "End"]),
103
+ capslock: named(["⇪", "Caps Lock"], ["Caps Lock", "Caps Lock"]),
104
+ plus: named(["+", "Plus"]),
105
+ "↩": named(["↩", "Return"], ["Enter", "Enter"]),
106
+ "↵": named(["↩", "Return"], ["Enter", "Enter"]),
107
+ "⎋": named(["esc", "Escape"], ["Esc", "Escape"]),
108
+ "⇥": named(["⇥", "Tab"], ["Tab", "Tab"]),
109
+ "⌫": named(["⌫", "Delete"], ["Backspace", "Backspace"]),
110
+ "↑": named(["↑", "Up Arrow"]),
111
+ "↓": named(["↓", "Down Arrow"]),
112
+ "←": named(["←", "Left Arrow"]),
113
+ "→": named(["→", "Right Arrow"]),
114
+ };
115
+
116
+ /**
117
+ * Split a shortcut into its keys. Accepts "Mod+Shift+K", "Ctrl++" (the plus
118
+ * key), a run of Apple glyphs "⇧⌘K", or an array that is taken as already split.
119
+ */
120
+ export function splitChord(input: string | readonly string[]): string[] {
121
+ const parts =
122
+ typeof input === "string"
123
+ ? (input.trim().match(/\+$|[^+]+/g) ?? [])
124
+ : input.map((part) => String(part));
125
+ const keys: string[] = [];
126
+ for (const raw of parts) {
127
+ const part = raw.trim();
128
+ if (!part) continue;
129
+ let rest = part;
130
+ while (rest.length > 1 && modifierGlyphs[rest[0] as string]) {
131
+ keys.push(rest[0] as string);
132
+ rest = rest.slice(1);
133
+ }
134
+ keys.push(rest);
135
+ }
136
+ return keys;
137
+ }
138
+
139
+ function resolveKey(token: string, platform: KbdPlatform): KbdKey {
140
+ const lower = token.toLowerCase();
141
+ const alias = modifierAliases[lower] ?? modifierAliases[token];
142
+ if (alias) {
143
+ const modifier = alias === "mod" ? (platform === "apple" ? "meta" : "ctrl") : alias;
144
+ return { ...modifierLabels[platform][modifier], modifier };
145
+ }
146
+ const namedKey = namedKeys[lower] ?? namedKeys[token];
147
+ if (namedKey) {
148
+ const [glyph, name] = namedKey[platform];
149
+ return { glyph, name };
150
+ }
151
+ const glyph = token.length === 1 ? token.toUpperCase() : token;
152
+ return { glyph, name: glyph };
153
+ }
154
+
155
+ /**
156
+ * Resolve a shortcut to the caps a platform draws: "Mod" becomes ⌘ on Apple
157
+ * and Ctrl elsewhere, modifiers move into the platform's order and drop
158
+ * duplicates, and the remaining keys keep the order they were given in.
159
+ */
160
+ export function resolveChord(
161
+ input: string | readonly string[],
162
+ platform: KbdPlatform = detectKbdPlatform(),
163
+ ): KbdKey[] {
164
+ const resolved = splitChord(input).map((token) => resolveKey(token, platform));
165
+ const order = modifierOrder[platform];
166
+ const modifiers = order.flatMap((modifier) => {
167
+ const hit = resolved.find((key) => key.modifier === modifier);
168
+ return hit ? [hit] : [];
169
+ });
170
+ return [...modifiers, ...resolved.filter((key) => !key.modifier)];
171
+ }
172
+
173
+ /** The text a screen reader announces for a chord: "Command Shift K". */
174
+ export function chordName(keys: readonly KbdKey[]): string {
175
+ return keys.map((key) => key.name).join(" ");
176
+ }
@@ -116,6 +116,14 @@ export const componentColors = {
116
116
  info: "$color11",
117
117
  },
118
118
 
119
+ /**
120
+ * Kbd key cap: a plate one ramp step off the page ground, so a key reads as
121
+ * a raised cap on a page, a card or a sheet in both schemes.
122
+ */
123
+ keyCap: {
124
+ background: "$color2",
125
+ },
126
+
119
127
  /** Separator/divider tokens */
120
128
  divider: "$borderColor",
121
129
 
package/src/index.ts CHANGED
@@ -16,6 +16,7 @@ export type {
16
16
  export * from "./Badge";
17
17
  export * from "./Carousel";
18
18
  export * from "./Chip";
19
+ export * from "./Kbd";
19
20
  export * from "./CopyField";
20
21
  export * from "./DotIndicator";
21
22
  export * from "./DropdownMenu";
@@ -24,6 +24,7 @@ import {
24
24
  resolvePageTitleScale,
25
25
  Surface,
26
26
  transitionProps,
27
+ useAccentOnSurface,
27
28
  useLayoutSizeClass,
28
29
  useResolvedKnobs,
29
30
  type PageTitleScale,
@@ -757,3 +758,20 @@ export function PageMenuButton(props: Omit<ButtonProps, "children" | "icon">) {
757
758
  );
758
759
  }
759
760
  PageMenuButton.iconOnly = true;
761
+
762
+ export interface PageActionButtonProps extends Omit<ButtonProps, "children" | "accent"> {
763
+ /** What the action does, read by assistive tech: the glyph has no label. */
764
+ "aria-label": string;
765
+ }
766
+
767
+ /**
768
+ * The page's primary action in its top bar (LC-128), such as a list's New:
769
+ * the back control's recipe and hit area with its glyph in the accent ink,
770
+ * and no fill (LC-172, the iOS bar button item). A filled accent disc in a
771
+ * bar reads as a second, heavier title.
772
+ */
773
+ export function PageActionButton(props: PageActionButtonProps) {
774
+ const control = useTopBarControl();
775
+ const ink = useAccentOnSurface();
776
+ return <Button {...control} color={ink} data-top-bar-control="action" {...props} />;
777
+ }
@@ -0,0 +1,77 @@
1
+ /**
2
+ * @vitest-environment jsdom
3
+ *
4
+ * LC-128 / LC-172 (FZ-7974): a page's primary action in its top bar is a
5
+ * plain glyph in the accent ink, the iOS bar button item. It paints no fill
6
+ * and no disc, so it never reads as a black circle on a grey or white bar,
7
+ * and it keeps the top-bar controls' 44pt press target. jsdom cascades no
8
+ * Tamagui CSS, so this reads the atomic classes the frame asks for.
9
+ */
10
+ import { renderWithProviders } from "@multiplatform.one/test-utils";
11
+ import { Surface } from "@multiplatform.one/theme";
12
+ import { Button } from "@multiplatform.one/forms";
13
+ import { PlusIcon } from "@phosphor-icons/react";
14
+ import { cleanup, screen } from "@testing-library/react";
15
+ import { afterEach, describe, expect, it } from "vitest";
16
+ import { PageActionButton, PageMenuButton } from "./page";
17
+
18
+ afterEach(cleanup);
19
+
20
+ function rest(el: HTMLElement, prefix: string): string[] {
21
+ return Array.from(el.classList).filter(
22
+ (c) => c.startsWith(prefix) && !/^_[a-z]+-0(hover|active|focus|press)/.test(c),
23
+ );
24
+ }
25
+
26
+ function renderBar() {
27
+ renderWithProviders(
28
+ <Surface bar>
29
+ <PageActionButton icon={PlusIcon} aria-label="New Item" />
30
+ <PageMenuButton />
31
+ <Button accent circular icon={PlusIcon} aria-label="Filled" />
32
+ </Surface>,
33
+ );
34
+ return {
35
+ action: screen.getByLabelText("New Item"),
36
+ menu: screen.getByLabelText("More actions"),
37
+ filled: screen.getByLabelText("Filled"),
38
+ };
39
+ }
40
+
41
+ describe("PageActionButton (LC-128, LC-172)", () => {
42
+ it("paints no fill and no edge at rest", () => {
43
+ const { action, filled } = renderBar();
44
+ expect(action.getAttribute("data-top-bar-control")).toBe("action");
45
+ expect(rest(action, "_bg-")).toEqual(["_bg-transparent"]);
46
+ expect(action.className).toMatch(/_btc-transparent\b/);
47
+ // The filled accent disc it replaces paints the accent background.
48
+ expect(rest(filled, "_bg-")).toEqual(["_bg-background"]);
49
+ });
50
+
51
+ it("is not a disc and not the filled primary CTA", () => {
52
+ const { action } = renderBar();
53
+ expect(action.getAttribute("data-radius-part")).toBeNull();
54
+ expect(action.getAttribute("data-mp-action-role")).toBeNull();
55
+ expect(action.className).not.toMatch(/_btlr-100000px\b/);
56
+ });
57
+
58
+ it("inks its glyph with the accent and keeps the back control's recipe", () => {
59
+ const { action, menu } = renderBar();
60
+ // The glyph is currentColor: the frame's colour is the accent ink on the
61
+ // bar. The "…" beside it takes the bar tint too (LC-145, FZ-7993).
62
+ expect(rest(action, "_col-")).toHaveLength(1);
63
+ expect(rest(menu, "_col-")).toHaveLength(1);
64
+ expect(action.querySelector("svg")?.getAttribute("fill")).toBe("currentColor");
65
+ expect(action.getAttribute("data-size-token")).toBe(menu.getAttribute("data-size-token"));
66
+ expect(action.getAttribute("data-mp-button-height")).toBe(
67
+ menu.getAttribute("data-mp-button-height"),
68
+ );
69
+ });
70
+
71
+ it("keeps a 44pt press target", () => {
72
+ const { action } = renderBar();
73
+ const height = Number(action.getAttribute("data-mp-button-height"));
74
+ const slop = Number(action.getAttribute("data-mp-press-slop") ?? 0);
75
+ expect(height + 2 * slop).toBeGreaterThanOrEqual(44);
76
+ });
77
+ });
@@ -0,0 +1,29 @@
1
+ import type { GetProps } from "tamagui";
2
+ import { type KbdPlatform } from "./keys";
3
+ export { chordName, detectKbdPlatform, resolveChord, splitChord, type KbdKey, type KbdModifier, type KbdPlatform, } from "./keys";
4
+ export interface KbdProps extends Omit<GetProps<typeof KbdFrame>, "children"> {
5
+ /**
6
+ * One key ("K", "esc", "Enter") or a chord: "Mod+Shift+K", ["mod", "K"],
7
+ * or Apple glyphs "⇧⌘K". `Mod` is ⌘ on Apple platforms and Ctrl elsewhere.
8
+ */
9
+ keys?: string | readonly string[];
10
+ /** Same as `keys`, for `<Kbd>esc</Kbd>`. `keys` wins when both are given. */
11
+ children?: string;
12
+ /** Which convention to draw. Defaults to the running platform. */
13
+ platform?: KbdPlatform;
14
+ }
15
+ declare const KbdFrame: import("tamagui").TamaguiComponent<import("@tamagui/web").TamaDefer, import("tamagui").TamaguiElement, import("@tamagui/core").RNTamaguiViewNonStyleProps, import("@tamagui/web").StackStyleBase, {
16
+ elevation?: number | import("tamagui").SizeTokens | undefined;
17
+ fullscreen?: boolean | undefined;
18
+ }, import("@tamagui/web").StaticConfigPublic>;
19
+ declare const KbdCap: import("tamagui").TamaguiComponent<import("@tamagui/web").TamaDefer, import("tamagui").TamaguiElement, import("@tamagui/core").RNTamaguiViewNonStyleProps, import("@tamagui/web").StackStyleBase, {}, import("@tamagui/web").StaticConfigPublic>;
20
+ /**
21
+ * A keyboard key cap, or the caps of a chord (HIG key-equivalent glyphs on
22
+ * Apple platforms, spelled-out modifiers joined with "+" elsewhere). A small
23
+ * plate one step off its ground with a hairline edge that thickens along the
24
+ * bottom, so it reads as a key and not a chip. Fill, edge, radius and type
25
+ * come from the theme, so it follows every preset in light and dark.
26
+ */
27
+ export declare function Kbd({ keys, children, platform, ...props }: KbdProps): import("react/jsx-runtime").JSX.Element | null;
28
+ export type KbdCapProps = GetProps<typeof KbdCap>;
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Kbd/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGxC,OAAO,EAAe,KAAK,WAAW,EAA8C,MAAM,QAAQ,CAAC;AAEnG,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,KAAK,MAAM,EACX,KAAK,WAAW,EAChB,KAAK,WAAW,GACjB,MAAM,QAAQ,CAAC;AAEhB,MAAM,WAAW,QAAS,SAAQ,IAAI,CAAC,QAAQ,CAAC,OAAO,QAAQ,CAAC,EAAE,UAAU,CAAC;IAC3E;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;IAClC,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,WAAW,CAAC;CACxB;AAED,QAAA,MAAM,QAAQ;;;6CAIZ,CAAC;AAEH,QAAA,MAAM,MAAM,kPAQV,CAAC;AAQH;;;;;;GAMG;AACH,wBAAgB,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,QAAQ,kDAoDnE;AAED,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,MAAM,CAAC,CAAC"}