@bridgebrew/ui 0.0.0-stage → 0.1.9

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 (411) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +39 -2
  3. package/SOURCE.md +182 -0
  4. package/dist/build.js +871 -0
  5. package/dist/theme-css.js +896 -0
  6. package/dist/themes.js +69 -0
  7. package/dist/types/build/stylesheet.d.ts +31 -0
  8. package/dist/types/components/composite/command/command.d.ts +94 -0
  9. package/dist/types/components/composite/command/index.d.ts +2 -0
  10. package/dist/types/components/composite/draft-bar/draft-bar.d.ts +12 -0
  11. package/dist/types/components/composite/draft-bar/index.d.ts +2 -0
  12. package/dist/types/components/composite/image-field/image-field.d.ts +33 -0
  13. package/dist/types/components/composite/image-field/index.d.ts +2 -0
  14. package/dist/types/components/composite/list/index.d.ts +3 -0
  15. package/dist/types/components/composite/list/list-swipe.d.ts +28 -0
  16. package/dist/types/components/composite/list/list.d.ts +95 -0
  17. package/dist/types/components/composite/picker/index.d.ts +2 -0
  18. package/dist/types/components/composite/picker/picker.d.ts +44 -0
  19. package/dist/types/components/composite/prompt-field/index.d.ts +2 -0
  20. package/dist/types/components/composite/prompt-field/prompt-field.d.ts +18 -0
  21. package/dist/types/components/composite/properties/index.d.ts +2 -0
  22. package/dist/types/components/composite/properties/properties.d.ts +24 -0
  23. package/dist/types/components/composite/snooze-menu/index.d.ts +4 -0
  24. package/dist/types/components/composite/snooze-menu/presets.d.ts +36 -0
  25. package/dist/types/components/composite/snooze-menu/snooze-menu.d.ts +27 -0
  26. package/dist/types/components/composite/tag-input/index.d.ts +2 -0
  27. package/dist/types/components/composite/tag-input/tag-input.d.ts +22 -0
  28. package/dist/types/components/composite/wizard/index.d.ts +2 -0
  29. package/dist/types/components/composite/wizard/wizard.d.ts +53 -0
  30. package/dist/types/components/core/avatar/avatar.d.ts +16 -0
  31. package/dist/types/components/core/avatar/index.d.ts +2 -0
  32. package/dist/types/components/core/badge/badge.d.ts +8 -0
  33. package/dist/types/components/core/badge/index.d.ts +2 -0
  34. package/dist/types/components/core/breadcrumb/breadcrumb.d.ts +21 -0
  35. package/dist/types/components/core/breadcrumb/index.d.ts +2 -0
  36. package/dist/types/components/core/bullets/bullets.d.ts +15 -0
  37. package/dist/types/components/core/bullets/index.d.ts +2 -0
  38. package/dist/types/components/core/button/button.d.ts +14 -0
  39. package/dist/types/components/core/button/index.d.ts +2 -0
  40. package/dist/types/components/core/card/card.d.ts +16 -0
  41. package/dist/types/components/core/card/index.d.ts +2 -0
  42. package/dist/types/components/core/checkbox/checkbox.d.ts +15 -0
  43. package/dist/types/components/core/checkbox/index.d.ts +2 -0
  44. package/dist/types/components/core/cluster/cluster.d.ts +5 -0
  45. package/dist/types/components/core/cluster/index.d.ts +1 -0
  46. package/dist/types/components/core/code-block/code-block.d.ts +18 -0
  47. package/dist/types/components/core/code-block/index.d.ts +2 -0
  48. package/dist/types/components/core/collapsible/collapsible.d.ts +8 -0
  49. package/dist/types/components/core/collapsible/index.d.ts +1 -0
  50. package/dist/types/components/core/colour-picker/colour-picker.d.ts +25 -0
  51. package/dist/types/components/core/colour-picker/index.d.ts +4 -0
  52. package/dist/types/components/core/combobox/combobox.d.ts +63 -0
  53. package/dist/types/components/core/combobox/index.d.ts +2 -0
  54. package/dist/types/components/core/detail/detail.d.ts +12 -0
  55. package/dist/types/components/core/detail/index.d.ts +1 -0
  56. package/dist/types/components/core/dialog/dialog.d.ts +43 -0
  57. package/dist/types/components/core/dialog/drag.d.ts +4 -0
  58. package/dist/types/components/core/dialog/index.d.ts +2 -0
  59. package/dist/types/components/core/drop-zone/drop-zone.d.ts +23 -0
  60. package/dist/types/components/core/drop-zone/index.d.ts +2 -0
  61. package/dist/types/components/core/dropdown-menu/dropdown-menu.d.ts +78 -0
  62. package/dist/types/components/core/dropdown-menu/index.d.ts +2 -0
  63. package/dist/types/components/core/editable-field/editable-field.d.ts +42 -0
  64. package/dist/types/components/core/editable-field/index.d.ts +2 -0
  65. package/dist/types/components/core/empty-state/empty-state.d.ts +11 -0
  66. package/dist/types/components/core/empty-state/index.d.ts +2 -0
  67. package/dist/types/components/core/field/field.d.ts +31 -0
  68. package/dist/types/components/core/field/index.d.ts +2 -0
  69. package/dist/types/components/core/icon/icon-sets.d.ts +38 -0
  70. package/dist/types/components/core/icon/icon.d.ts +14 -0
  71. package/dist/types/components/core/icon/index.d.ts +2 -0
  72. package/dist/types/components/core/input/index.d.ts +4 -0
  73. package/dist/types/components/core/input/input.d.ts +22 -0
  74. package/dist/types/components/core/input/textarea.d.ts +8 -0
  75. package/dist/types/components/core/kbd/index.d.ts +2 -0
  76. package/dist/types/components/core/kbd/kbd.d.ts +7 -0
  77. package/dist/types/components/core/label/index.d.ts +2 -0
  78. package/dist/types/components/core/label/label.d.ts +13 -0
  79. package/dist/types/components/core/main-content/index.d.ts +2 -0
  80. package/dist/types/components/core/main-content/main-content.d.ts +18 -0
  81. package/dist/types/components/core/pane/index.d.ts +1 -0
  82. package/dist/types/components/core/pane/pane.d.ts +12 -0
  83. package/dist/types/components/core/pick-menu/index.d.ts +4 -0
  84. package/dist/types/components/core/pick-menu/pick-menu.d.ts +57 -0
  85. package/dist/types/components/core/pick-menu/tag-menu.d.ts +19 -0
  86. package/dist/types/components/core/popover/index.d.ts +2 -0
  87. package/dist/types/components/core/popover/popover.d.ts +22 -0
  88. package/dist/types/components/core/progress/index.d.ts +2 -0
  89. package/dist/types/components/core/progress/progress.d.ts +13 -0
  90. package/dist/types/components/core/resizable/index.d.ts +2 -0
  91. package/dist/types/components/core/resizable/resizable.d.ts +15 -0
  92. package/dist/types/components/core/resizable/use-remembered-layout.d.ts +31 -0
  93. package/dist/types/components/core/screen-link/index.d.ts +2 -0
  94. package/dist/types/components/core/screen-link/screen-link.d.ts +52 -0
  95. package/dist/types/components/core/scroll-area/index.d.ts +2 -0
  96. package/dist/types/components/core/scroll-area/scroll-area.d.ts +13 -0
  97. package/dist/types/components/core/scroll-area/steps.d.ts +5 -0
  98. package/dist/types/components/core/section/index.d.ts +2 -0
  99. package/dist/types/components/core/section/section.d.ts +16 -0
  100. package/dist/types/components/core/segment-group/index.d.ts +2 -0
  101. package/dist/types/components/core/segment-group/segment-group.d.ts +24 -0
  102. package/dist/types/components/core/select/index.d.ts +2 -0
  103. package/dist/types/components/core/select/select.d.ts +39 -0
  104. package/dist/types/components/core/skeleton/index.d.ts +2 -0
  105. package/dist/types/components/core/skeleton/skeleton.d.ts +13 -0
  106. package/dist/types/components/core/slider/index.d.ts +2 -0
  107. package/dist/types/components/core/slider/slider.d.ts +9 -0
  108. package/dist/types/components/core/sortable/index.d.ts +2 -0
  109. package/dist/types/components/core/sortable/sortable.d.ts +53 -0
  110. package/dist/types/components/core/split-view/index.d.ts +2 -0
  111. package/dist/types/components/core/split-view/split-view.d.ts +28 -0
  112. package/dist/types/components/core/status-icon/index.d.ts +2 -0
  113. package/dist/types/components/core/status-icon/status-icon.d.ts +13 -0
  114. package/dist/types/components/core/table/collapsible-rows.d.ts +7 -0
  115. package/dist/types/components/core/table/expand-toggle.d.ts +10 -0
  116. package/dist/types/components/core/table/group-header.d.ts +14 -0
  117. package/dist/types/components/core/table/index.d.ts +8 -0
  118. package/dist/types/components/core/table/table.d.ts +31 -0
  119. package/dist/types/components/core/tabs/index.d.ts +2 -0
  120. package/dist/types/components/core/tabs/tabs.d.ts +20 -0
  121. package/dist/types/components/core/tag-pill/index.d.ts +2 -0
  122. package/dist/types/components/core/tag-pill/tag-pill.d.ts +25 -0
  123. package/dist/types/components/core/thumbnail/index.d.ts +2 -0
  124. package/dist/types/components/core/thumbnail/thumbnail.d.ts +23 -0
  125. package/dist/types/components/core/toast/index.d.ts +2 -0
  126. package/dist/types/components/core/toast/toast.d.ts +88 -0
  127. package/dist/types/components/core/toggle/index.d.ts +2 -0
  128. package/dist/types/components/core/toggle/toggle.d.ts +9 -0
  129. package/dist/types/components/core/toggle-group/index.d.ts +2 -0
  130. package/dist/types/components/core/toggle-group/toggle-group.d.ts +21 -0
  131. package/dist/types/components/core/tooltip/index.d.ts +2 -0
  132. package/dist/types/components/core/tooltip/tooltip.d.ts +33 -0
  133. package/dist/types/components/layout/multi-pane/index.d.ts +4 -0
  134. package/dist/types/components/layout/multi-pane/list-detail.d.ts +17 -0
  135. package/dist/types/components/layout/multi-pane/multi-pane.d.ts +34 -0
  136. package/dist/types/components/layout/single-pane/index.d.ts +2 -0
  137. package/dist/types/components/layout/single-pane/single-pane.d.ts +11 -0
  138. package/dist/types/components/shell/app-shell/app-shell.d.ts +12 -0
  139. package/dist/types/components/shell/app-shell/index.d.ts +2 -0
  140. package/dist/types/components/shell/sidebar/index.d.ts +2 -0
  141. package/dist/types/components/shell/sidebar/sidebar-group.d.ts +45 -0
  142. package/dist/types/components/shell/sidebar/sidebar-item.d.ts +19 -0
  143. package/dist/types/components/shell/sidebar/sidebar-resize-handle.d.ts +17 -0
  144. package/dist/types/components/shell/sidebar/sidebar-tree.d.ts +42 -0
  145. package/dist/types/components/shell/sidebar/sidebar.d.ts +27 -0
  146. package/dist/types/components/template/address-book-template/address-book-template.d.ts +15 -0
  147. package/dist/types/components/template/address-book-template/index.d.ts +2 -0
  148. package/dist/types/components/template/mail-template/index.d.ts +2 -0
  149. package/dist/types/components/template/mail-template/mail-template.d.ts +11 -0
  150. package/dist/types/components/template/use-narrow.d.ts +3 -0
  151. package/dist/types/index.d.ts +149 -0
  152. package/dist/types/kit/check-rendering.d.ts +3 -0
  153. package/dist/types/kit/kit.d.ts +76 -0
  154. package/dist/types/lib/clipboard.d.ts +5 -0
  155. package/dist/types/lib/dates.d.ts +9 -0
  156. package/dist/types/lib/json.d.ts +26 -0
  157. package/dist/types/lib/keys.d.ts +15 -0
  158. package/dist/types/lib/utils.d.ts +2 -0
  159. package/dist/types/lib/view-scope.d.ts +22 -0
  160. package/dist/types/profile/profile.d.ts +34 -0
  161. package/dist/types/theme/appearance.d.ts +31 -0
  162. package/dist/types/theme/boot.d.ts +3 -0
  163. package/dist/types/theme/client-appearance-react.d.ts +3 -0
  164. package/dist/types/theme/client-appearance.d.ts +69 -0
  165. package/dist/types/theme/generate-tokens.d.ts +45 -0
  166. package/dist/types/theme/pack-themes-react.d.ts +24 -0
  167. package/dist/types/theme/palette.d.ts +111 -0
  168. package/dist/types/theme/semantic-mapping.d.ts +28 -0
  169. package/dist/types/theme/set-theme.d.ts +30 -0
  170. package/dist/types/theme/theme-colours.d.ts +14 -0
  171. package/dist/types/theme/theme-css.d.ts +3 -0
  172. package/dist/types/theme/themes.d.ts +63 -0
  173. package/dist/types/theme/wallpaper-sheet.d.ts +16 -0
  174. package/dist/types/theme/wallpaper-theme-react.d.ts +7 -0
  175. package/dist/types/theme/wallpaper-theme.d.ts +37 -0
  176. package/package.json +87 -3
  177. package/src/build/stylesheet.ts +128 -0
  178. package/src/components/composite/command/command.meta.yaml +74 -0
  179. package/src/components/composite/command/command.tsx +939 -0
  180. package/src/components/composite/command/index.ts +17 -0
  181. package/src/components/composite/draft-bar/draft-bar.meta.yaml +19 -0
  182. package/src/components/composite/draft-bar/draft-bar.tsx +57 -0
  183. package/src/components/composite/draft-bar/index.ts +2 -0
  184. package/src/components/composite/image-field/image-field.meta.yaml +69 -0
  185. package/src/components/composite/image-field/image-field.tsx +267 -0
  186. package/src/components/composite/image-field/index.ts +2 -0
  187. package/src/components/composite/list/index.ts +18 -0
  188. package/src/components/composite/list/list-swipe.tsx +163 -0
  189. package/src/components/composite/list/list.meta.yaml +238 -0
  190. package/src/components/composite/list/list.tsx +868 -0
  191. package/src/components/composite/picker/index.ts +2 -0
  192. package/src/components/composite/picker/picker.meta.yaml +103 -0
  193. package/src/components/composite/picker/picker.tsx +276 -0
  194. package/src/components/composite/prompt-field/index.ts +2 -0
  195. package/src/components/composite/prompt-field/prompt-field.meta.yaml +60 -0
  196. package/src/components/composite/prompt-field/prompt-field.tsx +81 -0
  197. package/src/components/composite/properties/index.ts +9 -0
  198. package/src/components/composite/properties/properties.meta.yaml +56 -0
  199. package/src/components/composite/properties/properties.tsx +132 -0
  200. package/src/components/composite/snooze-menu/index.ts +11 -0
  201. package/src/components/composite/snooze-menu/presets.ts +169 -0
  202. package/src/components/composite/snooze-menu/snooze-menu.meta.yaml +58 -0
  203. package/src/components/composite/snooze-menu/snooze-menu.tsx +146 -0
  204. package/src/components/composite/tag-input/index.ts +2 -0
  205. package/src/components/composite/tag-input/tag-input.meta.yaml +51 -0
  206. package/src/components/composite/tag-input/tag-input.tsx +404 -0
  207. package/src/components/composite/wizard/index.ts +2 -0
  208. package/src/components/composite/wizard/wizard.meta.yaml +73 -0
  209. package/src/components/composite/wizard/wizard.tsx +256 -0
  210. package/src/components/core/avatar/avatar.meta.yaml +71 -0
  211. package/src/components/core/avatar/avatar.tsx +92 -0
  212. package/src/components/core/avatar/index.ts +2 -0
  213. package/src/components/core/badge/badge.meta.yaml +34 -0
  214. package/src/components/core/badge/badge.tsx +23 -0
  215. package/src/components/core/badge/index.ts +2 -0
  216. package/src/components/core/breadcrumb/breadcrumb.meta.yaml +45 -0
  217. package/src/components/core/breadcrumb/breadcrumb.tsx +110 -0
  218. package/src/components/core/breadcrumb/index.ts +2 -0
  219. package/src/components/core/bullets/bullets.meta.yaml +37 -0
  220. package/src/components/core/bullets/bullets.tsx +60 -0
  221. package/src/components/core/bullets/index.ts +2 -0
  222. package/src/components/core/button/button.meta.yaml +91 -0
  223. package/src/components/core/button/button.tsx +93 -0
  224. package/src/components/core/button/index.ts +2 -0
  225. package/src/components/core/card/card.meta.yaml +94 -0
  226. package/src/components/core/card/card.tsx +54 -0
  227. package/src/components/core/card/index.ts +2 -0
  228. package/src/components/core/checkbox/checkbox.meta.yaml +59 -0
  229. package/src/components/core/checkbox/checkbox.tsx +106 -0
  230. package/src/components/core/checkbox/index.ts +2 -0
  231. package/src/components/core/cluster/cluster.meta.yaml +4 -0
  232. package/src/components/core/cluster/cluster.tsx +17 -0
  233. package/src/components/core/cluster/index.ts +1 -0
  234. package/src/components/core/code-block/code-block.meta.yaml +30 -0
  235. package/src/components/core/code-block/code-block.tsx +93 -0
  236. package/src/components/core/code-block/index.ts +2 -0
  237. package/src/components/core/collapsible/collapsible.meta.yaml +34 -0
  238. package/src/components/core/collapsible/collapsible.tsx +54 -0
  239. package/src/components/core/collapsible/index.ts +1 -0
  240. package/src/components/core/colour-picker/colour-picker.meta.yaml +52 -0
  241. package/src/components/core/colour-picker/colour-picker.tsx +314 -0
  242. package/src/components/core/colour-picker/index.ts +4 -0
  243. package/src/components/core/combobox/combobox.meta.yaml +75 -0
  244. package/src/components/core/combobox/combobox.tsx +288 -0
  245. package/src/components/core/combobox/index.ts +2 -0
  246. package/src/components/core/detail/detail.meta.yaml +13 -0
  247. package/src/components/core/detail/detail.tsx +73 -0
  248. package/src/components/core/detail/index.ts +1 -0
  249. package/src/components/core/dialog/dialog.meta.yaml +95 -0
  250. package/src/components/core/dialog/dialog.tsx +254 -0
  251. package/src/components/core/dialog/drag.ts +40 -0
  252. package/src/components/core/dialog/index.ts +25 -0
  253. package/src/components/core/drop-zone/drop-zone.meta.yaml +55 -0
  254. package/src/components/core/drop-zone/drop-zone.tsx +146 -0
  255. package/src/components/core/drop-zone/index.ts +2 -0
  256. package/src/components/core/dropdown-menu/dropdown-menu.meta.yaml +118 -0
  257. package/src/components/core/dropdown-menu/dropdown-menu.tsx +407 -0
  258. package/src/components/core/dropdown-menu/index.ts +32 -0
  259. package/src/components/core/editable-field/editable-field.meta.yaml +120 -0
  260. package/src/components/core/editable-field/editable-field.tsx +346 -0
  261. package/src/components/core/editable-field/index.ts +2 -0
  262. package/src/components/core/empty-state/empty-state.meta.yaml +21 -0
  263. package/src/components/core/empty-state/empty-state.tsx +42 -0
  264. package/src/components/core/empty-state/index.ts +2 -0
  265. package/src/components/core/field/field.meta.yaml +37 -0
  266. package/src/components/core/field/field.tsx +100 -0
  267. package/src/components/core/field/index.ts +9 -0
  268. package/src/components/core/icon/curated-names.json +107 -0
  269. package/src/components/core/icon/icon-sets.ts +109 -0
  270. package/src/components/core/icon/icon.meta.yaml +30 -0
  271. package/src/components/core/icon/icon.tsx +93 -0
  272. package/src/components/core/icon/index.ts +2 -0
  273. package/src/components/core/input/index.ts +4 -0
  274. package/src/components/core/input/input.meta.yaml +98 -0
  275. package/src/components/core/input/input.tsx +133 -0
  276. package/src/components/core/input/textarea.meta.yaml +79 -0
  277. package/src/components/core/input/textarea.tsx +63 -0
  278. package/src/components/core/kbd/index.ts +2 -0
  279. package/src/components/core/kbd/kbd.meta.yaml +12 -0
  280. package/src/components/core/kbd/kbd.tsx +29 -0
  281. package/src/components/core/label/index.ts +2 -0
  282. package/src/components/core/label/label.meta.yaml +55 -0
  283. package/src/components/core/label/label.tsx +72 -0
  284. package/src/components/core/main-content/index.ts +2 -0
  285. package/src/components/core/main-content/main-content.meta.yaml +23 -0
  286. package/src/components/core/main-content/main-content.tsx +49 -0
  287. package/src/components/core/pane/index.ts +1 -0
  288. package/src/components/core/pane/pane.meta.yaml +13 -0
  289. package/src/components/core/pane/pane.tsx +64 -0
  290. package/src/components/core/pick-menu/index.ts +4 -0
  291. package/src/components/core/pick-menu/pick-menu.meta.yaml +36 -0
  292. package/src/components/core/pick-menu/pick-menu.tsx +348 -0
  293. package/src/components/core/pick-menu/tag-menu.meta.yaml +7 -0
  294. package/src/components/core/pick-menu/tag-menu.tsx +79 -0
  295. package/src/components/core/popover/index.ts +2 -0
  296. package/src/components/core/popover/popover.meta.yaml +16 -0
  297. package/src/components/core/popover/popover.tsx +66 -0
  298. package/src/components/core/progress/index.ts +2 -0
  299. package/src/components/core/progress/progress.meta.yaml +47 -0
  300. package/src/components/core/progress/progress.tsx +56 -0
  301. package/src/components/core/resizable/index.ts +13 -0
  302. package/src/components/core/resizable/resizable.meta.yaml +110 -0
  303. package/src/components/core/resizable/resizable.tsx +125 -0
  304. package/src/components/core/resizable/use-remembered-layout.ts +261 -0
  305. package/src/components/core/screen-link/index.ts +2 -0
  306. package/src/components/core/screen-link/screen-link.meta.yaml +34 -0
  307. package/src/components/core/screen-link/screen-link.tsx +100 -0
  308. package/src/components/core/scroll-area/index.ts +2 -0
  309. package/src/components/core/scroll-area/scroll-area.meta.yaml +72 -0
  310. package/src/components/core/scroll-area/scroll-area.tsx +95 -0
  311. package/src/components/core/scroll-area/steps.tsx +72 -0
  312. package/src/components/core/section/index.ts +2 -0
  313. package/src/components/core/section/section.meta.yaml +72 -0
  314. package/src/components/core/section/section.tsx +93 -0
  315. package/src/components/core/segment-group/index.ts +2 -0
  316. package/src/components/core/segment-group/segment-group.meta.yaml +71 -0
  317. package/src/components/core/segment-group/segment-group.tsx +166 -0
  318. package/src/components/core/select/index.ts +20 -0
  319. package/src/components/core/select/select.meta.yaml +48 -0
  320. package/src/components/core/select/select.tsx +226 -0
  321. package/src/components/core/skeleton/index.ts +2 -0
  322. package/src/components/core/skeleton/skeleton.meta.yaml +50 -0
  323. package/src/components/core/skeleton/skeleton.tsx +71 -0
  324. package/src/components/core/slider/index.ts +2 -0
  325. package/src/components/core/slider/slider.meta.yaml +55 -0
  326. package/src/components/core/slider/slider.tsx +46 -0
  327. package/src/components/core/sortable/index.ts +16 -0
  328. package/src/components/core/sortable/sortable.meta.yaml +125 -0
  329. package/src/components/core/sortable/sortable.tsx +471 -0
  330. package/src/components/core/split-view/index.ts +2 -0
  331. package/src/components/core/split-view/split-view.meta.yaml +85 -0
  332. package/src/components/core/split-view/split-view.tsx +193 -0
  333. package/src/components/core/status-icon/index.ts +2 -0
  334. package/src/components/core/status-icon/status-icon.meta.yaml +64 -0
  335. package/src/components/core/status-icon/status-icon.tsx +94 -0
  336. package/src/components/core/table/collapsible-rows.tsx +30 -0
  337. package/src/components/core/table/expand-toggle.tsx +58 -0
  338. package/src/components/core/table/group-header.tsx +35 -0
  339. package/src/components/core/table/index.ts +26 -0
  340. package/src/components/core/table/table.meta.yaml +67 -0
  341. package/src/components/core/table/table.tsx +166 -0
  342. package/src/components/core/tabs/index.ts +2 -0
  343. package/src/components/core/tabs/tabs.meta.yaml +57 -0
  344. package/src/components/core/tabs/tabs.tsx +74 -0
  345. package/src/components/core/tag-pill/index.ts +2 -0
  346. package/src/components/core/tag-pill/tag-pill.meta.yaml +19 -0
  347. package/src/components/core/tag-pill/tag-pill.tsx +102 -0
  348. package/src/components/core/thumbnail/index.ts +2 -0
  349. package/src/components/core/thumbnail/thumbnail.meta.yaml +59 -0
  350. package/src/components/core/thumbnail/thumbnail.tsx +162 -0
  351. package/src/components/core/toast/index.ts +12 -0
  352. package/src/components/core/toast/toast.meta.yaml +93 -0
  353. package/src/components/core/toast/toast.tsx +763 -0
  354. package/src/components/core/toggle/index.ts +2 -0
  355. package/src/components/core/toggle/toggle.meta.yaml +53 -0
  356. package/src/components/core/toggle/toggle.tsx +44 -0
  357. package/src/components/core/toggle-group/index.ts +2 -0
  358. package/src/components/core/toggle-group/toggle-group.meta.yaml +59 -0
  359. package/src/components/core/toggle-group/toggle-group.tsx +68 -0
  360. package/src/components/core/tooltip/index.ts +7 -0
  361. package/src/components/core/tooltip/tooltip.meta.yaml +93 -0
  362. package/src/components/core/tooltip/tooltip.tsx +198 -0
  363. package/src/components/layout/multi-pane/index.ts +4 -0
  364. package/src/components/layout/multi-pane/list-detail.tsx +45 -0
  365. package/src/components/layout/multi-pane/multi-pane.meta.yaml +67 -0
  366. package/src/components/layout/multi-pane/multi-pane.tsx +158 -0
  367. package/src/components/layout/single-pane/index.ts +2 -0
  368. package/src/components/layout/single-pane/single-pane.meta.yaml +35 -0
  369. package/src/components/layout/single-pane/single-pane.tsx +48 -0
  370. package/src/components/shell/app-shell/app-shell.meta.yaml +65 -0
  371. package/src/components/shell/app-shell/app-shell.tsx +61 -0
  372. package/src/components/shell/app-shell/index.ts +2 -0
  373. package/src/components/shell/sidebar/index.ts +35 -0
  374. package/src/components/shell/sidebar/sidebar-group.tsx +254 -0
  375. package/src/components/shell/sidebar/sidebar-item.tsx +88 -0
  376. package/src/components/shell/sidebar/sidebar-resize-handle.tsx +101 -0
  377. package/src/components/shell/sidebar/sidebar-tree.tsx +325 -0
  378. package/src/components/shell/sidebar/sidebar.meta.yaml +126 -0
  379. package/src/components/shell/sidebar/sidebar.tsx +142 -0
  380. package/src/components/template/address-book-template/address-book-template.meta.yaml +22 -0
  381. package/src/components/template/address-book-template/address-book-template.tsx +201 -0
  382. package/src/components/template/address-book-template/index.ts +2 -0
  383. package/src/components/template/mail-template/index.ts +2 -0
  384. package/src/components/template/mail-template/mail-template.meta.yaml +22 -0
  385. package/src/components/template/mail-template/mail-template.tsx +731 -0
  386. package/src/components/template/use-narrow.ts +18 -0
  387. package/src/index.ts +505 -0
  388. package/src/kit/check-rendering.tsx +130 -0
  389. package/src/kit/kit.tsx +177 -0
  390. package/src/lib/clipboard.ts +27 -0
  391. package/src/lib/dates.ts +13 -0
  392. package/src/lib/json.ts +59 -0
  393. package/src/lib/keys.ts +54 -0
  394. package/src/lib/utils.ts +12 -0
  395. package/src/lib/view-scope.tsx +60 -0
  396. package/src/profile/profile.ts +238 -0
  397. package/src/theme/appearance.ts +198 -0
  398. package/src/theme/boot.ts +6 -0
  399. package/src/theme/client-appearance-react.ts +14 -0
  400. package/src/theme/client-appearance.ts +284 -0
  401. package/src/theme/generate-tokens.ts +658 -0
  402. package/src/theme/pack-themes-react.ts +107 -0
  403. package/src/theme/palette.ts +301 -0
  404. package/src/theme/semantic-mapping.ts +165 -0
  405. package/src/theme/set-theme.ts +162 -0
  406. package/src/theme/theme-colours.ts +60 -0
  407. package/src/theme/theme-css.ts +15 -0
  408. package/src/theme/themes.ts +133 -0
  409. package/src/theme/wallpaper-sheet.ts +58 -0
  410. package/src/theme/wallpaper-theme-react.ts +60 -0
  411. package/src/theme/wallpaper-theme.ts +231 -0
@@ -0,0 +1,939 @@
1
+ import * as React from "react";
2
+
3
+ import { cn } from "../../../lib/utils";
4
+ import { KEY_LABELS, formatKeys, isComposing } from "../../../lib/keys";
5
+ import { Kbd } from "../../core/kbd";
6
+ import { noAutofill } from "../../core/input/input";
7
+ import { Dialog, DialogContent } from "../../core/dialog";
8
+ import { dropdownMenuItemVariants } from "../../core/dropdown-menu";
9
+ import { Badge } from "../../core/badge";
10
+ import { Icon } from "../../core/icon";
11
+ import { ScrollArea } from "../../core/scroll-area";
12
+
13
+ // research-033 slice 2: a screen's commands, their keys, the ⌘K menu and the
14
+ // key hints shown while ⌘ is held. A CommandScope is a provider: the screen's
15
+ // components register their commands with useCommands while they are mounted,
16
+ // wrap their buttons in KeyHint, and CommandScope renders the CommandMenu.
17
+ //
18
+ // Keys are written: a single key ("L", "Enter", "Escape", "Backspace"),
19
+ // modifiers then a key joined by "+" ("Shift+J", "Meta+Backspace",
20
+ // "Meta+Enter"), or a two-key sequence separated by a space ("G P"). Letters
21
+ // match KeyboardEvent.key case-insensitively; "Meta" matches metaKey OR
22
+ // ctrlKey; Shift must match exactly for letters written with Shift and must be
23
+ // absent otherwise. ⌘K is Bridge's reserved key a screen may declare to the
24
+ // shell; while focused the scope listens for it itself.
25
+
26
+ interface Command {
27
+ /** Unique among its siblings: a sequence and the menu find the live command again by its id path. */
28
+ id: string;
29
+ label: string;
30
+ keys?: string;
31
+ group?: string;
32
+ /** `where`: the ⌘K menu's ↵ with a modifier on a `placeable` command (research-034): ⌘↵ beside, ⌥↵ a new desk, ⇧↵
33
+ * floating, ⇧⌘↵ maximized; none: here. */
34
+ run: (where?: Placement) => void;
35
+ disabled?: boolean;
36
+ children?: Command[];
37
+ /** An icon name of the kit's set (`Icon`), drawn before the label in the ⌘K menu. */
38
+ icon?: string;
39
+ /** A second line under the label (a session's node and time, a window's desk). */
40
+ description?: string;
41
+ /** Going somewhere (a screen, a workspace, a window) rather than doing something: left out after `>`. */
42
+ navigation?: boolean;
43
+ /** A source's search answered it (its content matched, maybe not its label): listed whatever is typed. */
44
+ found?: boolean;
45
+ /** Opens something a window can show: ↵'s modifiers choose where (`run`'s `where`). */
46
+ placeable?: boolean;
47
+ }
48
+
49
+ /** Where ⌘K opens a placeable command (research-034). */
50
+ type Placement = "beside" | "desk" | "float" | "max";
51
+ /** ↵'s (or a click's) modifiers as a placement: ⌘ (Ctrl) beside, ⌥ a new desk, ⇧ floating, ⇧⌘ maximized. */
52
+ function placementOf(event: {
53
+ metaKey: boolean;
54
+ ctrlKey: boolean;
55
+ altKey: boolean;
56
+ shiftKey: boolean;
57
+ }) {
58
+ const mod = event.metaKey || event.ctrlKey;
59
+ if (mod && event.shiftKey && !event.altKey) return "max" as const;
60
+ if (mod && !event.shiftKey && !event.altKey) return "beside" as const;
61
+ if (event.altKey && !mod && !event.shiftKey) return "desk" as const;
62
+ if (event.shiftKey && !mod && !event.altKey) return "float" as const;
63
+ return undefined;
64
+ }
65
+
66
+ interface CommandScopeProps {
67
+ /** The scope handles keys (and shows hints) only while its window/screen is focused. */
68
+ active: boolean;
69
+ /** "hold" (default): hints show while ⌘ is held; "always": whenever active (a user setting). */
70
+ hints?: "hold" | "always";
71
+ /** What the commands act on now (the open record's name, "2 selected"), a chip above the ⌘K search. */
72
+ subject?: string;
73
+ children?: React.ReactNode;
74
+ }
75
+
76
+ // --- Key parsing and matching ---
77
+
78
+ interface Chord {
79
+ key: string;
80
+ meta: boolean;
81
+ ctrl: boolean;
82
+ shift: boolean;
83
+ alt: boolean;
84
+ }
85
+
86
+ interface KeyedCommand {
87
+ command: Command;
88
+ chords: Chord[];
89
+ path: string[];
90
+ }
91
+
92
+ function parseChordKeys(keys: string): Chord[] {
93
+ return keys
94
+ .trim()
95
+ .split(/\s+/)
96
+ .map((part) => {
97
+ const tokens = part.split("+");
98
+ const key = tokens.pop() ?? "";
99
+ const modifiers = new Set(tokens);
100
+ return {
101
+ key,
102
+ meta: modifiers.has("Meta"),
103
+ ctrl: modifiers.has("Ctrl"),
104
+ shift: modifiers.has("Shift"),
105
+ alt: modifiers.has("Alt"),
106
+ };
107
+ });
108
+ }
109
+
110
+ function chordMatches(chord: Chord, event: KeyboardEvent): boolean {
111
+ if (chord.key.toLowerCase() !== event.key.toLowerCase()) return false;
112
+ if (chord.meta) {
113
+ if (!(event.metaKey || event.ctrlKey)) return false;
114
+ } else if (chord.ctrl) {
115
+ if (!event.ctrlKey) return false;
116
+ } else if (event.metaKey || event.ctrlKey) {
117
+ return false;
118
+ }
119
+ // A symbol with no case ("/", "?") may need Shift to be typed (AZERTY's "/" is Shift+:), so Shift is not asked.
120
+ const caseless = chord.key.length === 1 && chord.key.toLowerCase() === chord.key.toUpperCase();
121
+ if (chord.shift !== event.shiftKey && !(caseless && !chord.shift)) return false;
122
+ if (chord.alt !== event.altKey) return false;
123
+ return true;
124
+ }
125
+
126
+ function collectKeyedCommands(commands: Command[]): KeyedCommand[] {
127
+ const out: KeyedCommand[] = [];
128
+ const walk = (list: Command[], prefix: string[]) => {
129
+ for (const command of list) {
130
+ const path = [...prefix, command.id];
131
+ if (command.keys) out.push({ command, chords: parseChordKeys(command.keys), path });
132
+ if (command.children) walk(command.children, path);
133
+ }
134
+ };
135
+ walk(commands, []);
136
+ return out;
137
+ }
138
+
139
+ /** The live command a stored id path names, or undefined if it is gone. */
140
+ function resolveCommand(commands: Command[], path: string[]): Command | undefined {
141
+ let list = commands;
142
+ let command: Command | undefined;
143
+ for (const id of path) {
144
+ command = list.find((candidate) => candidate.id === id);
145
+ if (!command) return undefined;
146
+ list = command.children ?? [];
147
+ }
148
+ return command;
149
+ }
150
+
151
+ const MODIFIER_KEYS = new Set(["Meta", "Control", "Alt", "Shift", "CapsLock"]);
152
+
153
+ function isEditable(target: EventTarget | null): boolean {
154
+ const el = target as HTMLElement | null;
155
+ if (!el || typeof el.tagName !== "string") return false;
156
+ if (el.isContentEditable) return true;
157
+ const tag = el.tagName;
158
+ return tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT";
159
+ }
160
+
161
+ function isEditableFromTarget(target: EventTarget | null): boolean {
162
+ if (isEditable(target)) return true;
163
+ const el = target as HTMLElement | null;
164
+ if (el && typeof el.closest === "function" && el.closest('[contenteditable="true"]')) return true;
165
+ return false;
166
+ }
167
+
168
+ function isPressable(target: EventTarget | null): boolean {
169
+ const el = target as HTMLElement | null;
170
+ return (
171
+ typeof el?.closest === "function" && el.closest("button, a[href], [role='button']") !== null
172
+ );
173
+ }
174
+
175
+ // --- Command registry (a CommandScope's mutable store of live registrations) ---
176
+
177
+ type CommandGetter = () => Command[];
178
+
179
+ interface CommandRegistry {
180
+ register: (getter: CommandGetter) => () => void;
181
+ /** Tells subscribers the registered commands changed (a screen re-rendered them, a subject changed). */
182
+ changed: () => void;
183
+ all: () => Command[];
184
+ subscribe: (listener: () => void) => () => void;
185
+ getVersion: () => number;
186
+ }
187
+
188
+ const CommandRegistryContext = React.createContext<CommandRegistry | null>(null);
189
+
190
+ /** What a focused screen's commands are, for a palette drawn above every screen (research-034: Bridge's `commands`
191
+ * plugin): its commands as they are now, what they act on, and a change. */
192
+ interface CommandSource {
193
+ /** How many scopes it sits in (0: none): the innermost speaks for the focused screen. */
194
+ depth: number;
195
+ /** Not a screen's: a workspace plugin's commands for anywhere in its workspace ("New contact"), or Bridge's own (the
196
+ * shell's, the rail's); listed after the focused screen's, the workspace's first. None: the focused screen's. */
197
+ level?: "workspace" | "bridge";
198
+ /** The plugin it comes from (its key): a workspace's plugins are listed in the workspace's own order. */
199
+ owner?: string;
200
+ /** Its content searched (research-034's universal search): the records answering `query` as commands (a contact
201
+ * to open), asked while the user types; `signal` aborts a search a newer one replaced. */
202
+ search?: (query: string, signal: AbortSignal) => Promise<Command[]>;
203
+ commands: () => Command[];
204
+ subject: () => string | undefined;
205
+ subscribe: (listener: () => void) => () => void;
206
+ }
207
+ /** Where an active CommandScope hands its commands instead of opening its own ⌘K menu (the page's shell provides it
208
+ * from Bridge's `commands` plugin); none: each scope opens its own. */
209
+ interface CommandHost {
210
+ register: (source: CommandSource) => () => void;
211
+ }
212
+ const CommandHostContext = React.createContext<CommandHost | null>(null);
213
+ const ScopeDepthContext = React.createContext(0);
214
+ /** Provides a CommandHost to every CommandScope below. */
215
+ const CommandHostProvider = CommandHostContext.Provider;
216
+ const HintsVisibleContext = React.createContext(false);
217
+
218
+ /** Register the calling component's commands while it is mounted. The latest
219
+ * array wins; they are removed when it unmounts. */
220
+ function useCommands(commands: Command[]): void {
221
+ const registry = React.useContext(CommandRegistryContext);
222
+ const latest = React.useRef(commands);
223
+ latest.current = commands;
224
+ React.useEffect(() => {
225
+ if (!registry) return;
226
+ const getter: CommandGetter = () => latest.current;
227
+ return registry.register(getter);
228
+ }, [registry]);
229
+ // An open menu (the scope's or a host's) shows the commands as this render made them: told only when what it shows
230
+ // changed (a render's new `run`s are read live when chosen), so a listener that re-renders the screen never loops.
231
+ const shown = JSON.stringify(commands, (key: string, value: unknown) =>
232
+ key === "run" ? undefined : value,
233
+ );
234
+ const lastShown = React.useRef(shown);
235
+ React.useEffect(() => {
236
+ if (lastShown.current === shown) return;
237
+ lastShown.current = shown;
238
+ registry?.changed();
239
+ });
240
+ }
241
+
242
+ /** The commands registered in the nearest CommandScope (its screen's and its extensions'), as they are now: for a menu
243
+ * listing what acts on a target (a row's right-click shows the selection's commands, extensions' included). */
244
+ function useScopeCommands(): Command[] {
245
+ const registry = React.useContext(CommandRegistryContext);
246
+ // Re-rendered as commands are registered, removed or changed (an extension's mounting after the menu opened); read
247
+ // on each render, never memoized: a render's new `run`s change no version.
248
+ React.useSyncExternalStore(
249
+ registry?.subscribe ?? noSubscribe,
250
+ registry?.getVersion ?? noVersion,
251
+ registry?.getVersion ?? noVersion,
252
+ );
253
+ return registry?.all() ?? [];
254
+ }
255
+ const noSubscribe = () => () => {};
256
+ const noVersion = () => 0;
257
+
258
+ // --- Sequence state ---
259
+
260
+ interface PendingCandidate {
261
+ path: string[];
262
+ next: number;
263
+ }
264
+
265
+ interface PendingSequence {
266
+ candidates: PendingCandidate[];
267
+ timer: number | null;
268
+ }
269
+
270
+ const HINT_DELAY = 350;
271
+ const SEQUENCE_TIMEOUT = 1000;
272
+
273
+ function clearPending(pendingRef: React.RefObject<PendingSequence | null>): void {
274
+ const pending = pendingRef.current;
275
+ if (pending?.timer != null) window.clearTimeout(pending.timer);
276
+ pendingRef.current = null;
277
+ }
278
+
279
+ function setPending(
280
+ pendingRef: React.RefObject<PendingSequence | null>,
281
+ candidates: PendingCandidate[],
282
+ ): void {
283
+ clearPending(pendingRef);
284
+ const timer = window.setTimeout(() => {
285
+ pendingRef.current = null;
286
+ }, SEQUENCE_TIMEOUT);
287
+ pendingRef.current = { candidates, timer };
288
+ }
289
+
290
+ function matchCommands(
291
+ event: KeyboardEvent,
292
+ registry: CommandRegistry,
293
+ pendingRef: React.RefObject<PendingSequence | null>,
294
+ ): void {
295
+ const pending = pendingRef.current;
296
+ if (pending) {
297
+ clearPending(pendingRef);
298
+ const live = registry.all();
299
+ const survivors: PendingCandidate[] = [];
300
+ let resolved: Command | null = null;
301
+ for (const candidate of pending.candidates) {
302
+ // Re-resolve the live command: a re-registered one runs as it is now.
303
+ const command = resolveCommand(live, candidate.path);
304
+ if (!command) continue;
305
+ const chords = command.keys ? parseChordKeys(command.keys) : [];
306
+ const chord = chords[candidate.next];
307
+ if (!chord || !chordMatches(chord, event)) continue;
308
+ if (candidate.next + 1 >= chords.length) {
309
+ resolved = command;
310
+ break;
311
+ }
312
+ survivors.push({ path: candidate.path, next: candidate.next + 1 });
313
+ }
314
+ if (resolved) {
315
+ event.preventDefault();
316
+ if (!resolved.disabled) resolved.run();
317
+ return;
318
+ }
319
+ if (survivors.length > 0) {
320
+ event.preventDefault();
321
+ setPending(pendingRef, survivors);
322
+ return;
323
+ }
324
+ // Otherwise fall through: this key may start a fresh sequence.
325
+ }
326
+
327
+ const candidates = collectKeyedCommands(registry.all());
328
+ const completes: KeyedCommand[] = [];
329
+ const partials: PendingCandidate[] = [];
330
+ for (const entry of candidates) {
331
+ const chord = entry.chords[0];
332
+ if (!chord || !chordMatches(chord, event)) continue;
333
+ if (entry.chords.length === 1) completes.push(entry);
334
+ else partials.push({ path: entry.path, next: 1 });
335
+ }
336
+ if (completes.length > 0) {
337
+ const chosen = completes.find((entry) => !entry.command.disabled) ?? completes[0];
338
+ event.preventDefault();
339
+ if (chosen && !chosen.command.disabled) chosen.command.run();
340
+ return;
341
+ }
342
+ if (partials.length > 0) {
343
+ event.preventDefault();
344
+ setPending(pendingRef, partials);
345
+ }
346
+ }
347
+
348
+ // --- CommandScope (the provider) ---
349
+
350
+ function useCommandRegistry(): CommandRegistry {
351
+ return React.useMemo(() => {
352
+ const getters = new Set<CommandGetter>();
353
+ const listeners = new Set<() => void>();
354
+ let version = 0;
355
+ const emit = () => {
356
+ version += 1;
357
+ for (const listener of listeners) listener();
358
+ };
359
+ return {
360
+ changed: emit,
361
+ register(getter: CommandGetter) {
362
+ getters.add(getter);
363
+ emit();
364
+ return () => {
365
+ getters.delete(getter);
366
+ emit();
367
+ };
368
+ },
369
+ all() {
370
+ const out: Command[] = [];
371
+ for (const get of getters) out.push(...get());
372
+ return out;
373
+ },
374
+ subscribe(listener: () => void) {
375
+ listeners.add(listener);
376
+ return () => {
377
+ listeners.delete(listener);
378
+ };
379
+ },
380
+ getVersion() {
381
+ return version;
382
+ },
383
+ };
384
+ }, []);
385
+ }
386
+
387
+ function CommandScope({ active, hints = "hold", subject, children }: CommandScopeProps) {
388
+ const registry = useCommandRegistry();
389
+ const host = React.useContext(CommandHostContext);
390
+ const depth = React.useContext(ScopeDepthContext);
391
+ const hostRef = React.useRef(host);
392
+ hostRef.current = host;
393
+ const subjectRef = React.useRef(subject);
394
+ subjectRef.current = subject;
395
+ // With a host, the focused scope's commands are the host's to list (its ⌘K); the scope still matches their keys.
396
+ React.useEffect(() => {
397
+ if (!active || !host) return;
398
+ return host.register({
399
+ depth,
400
+ commands: registry.all,
401
+ subject: () => subjectRef.current,
402
+ subscribe: registry.subscribe,
403
+ });
404
+ }, [active, host, registry, depth]);
405
+ React.useEffect(() => registry.changed(), [registry, subject]);
406
+ const [open, setOpen] = React.useState(false);
407
+ const [holdHints, setHoldHints] = React.useState(false);
408
+ const openRef = React.useRef(open);
409
+ openRef.current = open;
410
+ const hintTimerRef = React.useRef<number | null>(null);
411
+ const pendingRef = React.useRef<PendingSequence | null>(null);
412
+ const scopeRef = React.useRef<HTMLDivElement | null>(null);
413
+
414
+ React.useEffect(() => {
415
+ if (!active) {
416
+ setOpen(false);
417
+ setHoldHints(false);
418
+ }
419
+ }, [active]);
420
+
421
+ React.useEffect(() => {
422
+ if (!active) return;
423
+
424
+ const clearHintTimer = () => {
425
+ if (hintTimerRef.current != null) {
426
+ window.clearTimeout(hintTimerRef.current);
427
+ hintTimerRef.current = null;
428
+ }
429
+ };
430
+ const hideHints = () => {
431
+ clearHintTimer();
432
+ setHoldHints(false);
433
+ };
434
+ const showHintsLater = () => {
435
+ clearHintTimer();
436
+ hintTimerRef.current = window.setTimeout(() => {
437
+ hintTimerRef.current = null;
438
+ setHoldHints(true);
439
+ }, HINT_DELAY);
440
+ };
441
+
442
+ const onKeyDown = (event: KeyboardEvent) => {
443
+ if (event.key === "Meta" && !event.shiftKey && !event.altKey && !event.ctrlKey) {
444
+ showHintsLater();
445
+ } else {
446
+ hideHints();
447
+ }
448
+
449
+ // The scope is active (its window focused): a key is its own unless it was typed in another scope, or in a
450
+ // dialog or menu portalled elsewhere (the ⌘K menu itself, portalled too, has its own handlers). Focus left in
451
+ // the sidebar or on the window's frame still reaches it.
452
+ const target = event.target instanceof Element ? event.target : null;
453
+ const owner = target?.closest(
454
+ '[data-slot="command-scope"], [role="dialog"], [role="alertdialog"], [role="menu"]',
455
+ );
456
+ if (owner && !scopeRef.current?.contains(owner)) return;
457
+
458
+ if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k") {
459
+ // Nested active scopes: the inner listener runs first and prevents
460
+ // default; this one then leaves the menu to it. A host draws ⌘K itself.
461
+ if (event.defaultPrevented || event.isComposing || hostRef.current) return;
462
+ event.preventDefault();
463
+ setOpen(true);
464
+ return;
465
+ }
466
+
467
+ if (MODIFIER_KEYS.has(event.key)) return;
468
+ if (event.defaultPrevented || event.isComposing) return;
469
+ if (isEditableFromTarget(event.target)) return;
470
+ // Enter and Space on a button or a link press it.
471
+ if ((event.key === "Enter" || event.key === " ") && isPressable(event.target)) return;
472
+ if (openRef.current) return;
473
+
474
+ matchCommands(event, registry, pendingRef);
475
+ };
476
+
477
+ const onKeyUp = (event: KeyboardEvent) => {
478
+ if (event.key === "Meta") hideHints();
479
+ };
480
+ const onBlur = () => hideHints();
481
+
482
+ document.addEventListener("keydown", onKeyDown);
483
+ document.addEventListener("keyup", onKeyUp);
484
+ window.addEventListener("blur", onBlur);
485
+ return () => {
486
+ document.removeEventListener("keydown", onKeyDown);
487
+ document.removeEventListener("keyup", onKeyUp);
488
+ window.removeEventListener("blur", onBlur);
489
+ clearHintTimer();
490
+ clearPending(pendingRef);
491
+ };
492
+ }, [active, registry]);
493
+
494
+ const showHints = active && (hints === "always" || holdHints);
495
+
496
+ return (
497
+ <CommandRegistryContext.Provider value={registry}>
498
+ <HintsVisibleContext.Provider value={showHints}>
499
+ <div ref={scopeRef} data-slot="command-scope" style={{ display: "contents" }}>
500
+ <ScopeDepthContext.Provider value={depth + 1}>{children}</ScopeDepthContext.Provider>
501
+ </div>
502
+ {active && open && !host ? (
503
+ <CommandMenu registry={registry} subject={subject} onClose={() => setOpen(false)} />
504
+ ) : null}
505
+ </HintsVisibleContext.Provider>
506
+ </CommandRegistryContext.Provider>
507
+ );
508
+ }
509
+
510
+ // --- KeyHint (its child unchanged, plus a badge while hints are visible) ---
511
+
512
+ interface KeyHintProps {
513
+ keys: string;
514
+ children: React.ReactNode;
515
+ }
516
+
517
+ function KeyHint({ keys, children }: KeyHintProps) {
518
+ const visible = React.useContext(HintsVisibleContext);
519
+ return (
520
+ <span data-slot="key-hint-wrapper" className="relative inline-flex">
521
+ {children}
522
+ {visible ? (
523
+ <span
524
+ data-slot="key-hint"
525
+ aria-hidden="true"
526
+ className="pointer-events-none absolute -right-1.5 -top-1.5 inline-flex items-center bg-foreground text-background text-[10px] leading-none rounded-full px-1.5 py-0.5"
527
+ >
528
+ {formatKeys(keys)}
529
+ </span>
530
+ ) : null}
531
+ </span>
532
+ );
533
+ }
534
+
535
+ // --- CommandMenu (the ⌘K palette) ---
536
+
537
+ interface MenuEntry {
538
+ key: string;
539
+ label: string;
540
+ command: Command;
541
+ /** The command's id path in the registry, for re-resolving it live. */
542
+ path: string[];
543
+ }
544
+
545
+ interface MenuGroup {
546
+ group: string | null;
547
+ entries: MenuEntry[];
548
+ }
549
+
550
+ /** A chosen parent, kept as a menu page: its command and its id path. */
551
+ interface MenuPage {
552
+ command: Command;
553
+ path: string[];
554
+ }
555
+
556
+ /** Every whitespace-separated word of `search` appears in `text`, case-insensitive. */
557
+ function matchesWords(text: string, search: string): boolean {
558
+ const haystack = text.toLowerCase();
559
+ return search
560
+ .trim()
561
+ .toLowerCase()
562
+ .split(/\s+/)
563
+ .filter(Boolean)
564
+ .every((word) => haystack.includes(word));
565
+ }
566
+
567
+ /** How well `label` answers `query` (T3 Code's: exact 3, a prefix 2, contained 1; 0: only the words, the group's too). */
568
+ function scoreOf(label: string, query: string): number {
569
+ const text = label.toLowerCase();
570
+ const asked = query.trim().toLowerCase();
571
+ if (!asked) return 0;
572
+ if (text === asked) return 3;
573
+ if (text.startsWith(asked)) return 2;
574
+ return text.includes(asked) ? 1 : 0;
575
+ }
576
+
577
+ function buildEntries(commands: Command[], page: MenuPage | null, search: string): MenuEntry[] {
578
+ // `>`: actions only (research-034), the rest of the search as usual.
579
+ const actions = search.trimStart().startsWith(">");
580
+ const query = (actions ? search.trimStart().slice(1) : search).trim();
581
+ if (actions && !page) commands = commands.filter((command) => !command.navigation);
582
+ if (page) {
583
+ // The page as registered now: a re-registered parent shows its new children.
584
+ const live = resolveCommand(commands, page.path) ?? page.command;
585
+ return (live.children ?? [])
586
+ .filter((child) => !query || matchesWords(child.label, query))
587
+ .map((child) => ({
588
+ key: [...page.path, child.id].join("/"),
589
+ label: child.label,
590
+ command: child,
591
+ path: [...page.path, child.id],
592
+ }));
593
+ }
594
+ if (!query) {
595
+ return commands.map((command) => ({
596
+ key: command.id,
597
+ label: command.label,
598
+ command,
599
+ path: [command.id],
600
+ }));
601
+ }
602
+ const entries: MenuEntry[] = [];
603
+ for (const command of commands) {
604
+ // The group's words count too: "admin status" finds Admin's Status. A search's answer is listed as it came.
605
+ if (
606
+ command.found ||
607
+ matchesWords(`${command.group ?? ""} ${command.label} ${command.description ?? ""}`, query)
608
+ ) {
609
+ entries.push({ key: command.id, label: command.label, command, path: [command.id] });
610
+ }
611
+ for (const child of command.children ?? []) {
612
+ const path = [command.id, child.id];
613
+ const label = `${command.label} › ${child.label}`;
614
+ if (matchesWords(label, query)) {
615
+ entries.push({ key: path.join("/"), label, command: child, path });
616
+ }
617
+ }
618
+ }
619
+ return entries;
620
+ }
621
+
622
+ function groupEntries(entries: MenuEntry[], search = ""): MenuGroup[] {
623
+ // One heading per group, in the order groups first appear (commands of a group registered apart stay together).
624
+ const groups = new Map<string | null, MenuEntry[]>();
625
+ for (const entry of entries) {
626
+ const group = entry.command.group ?? null;
627
+ groups.set(group, [...(groups.get(group) ?? []), entry]);
628
+ }
629
+ const listed = [...groups].map(([group, grouped]) => ({ group, entries: grouped }));
630
+ // Searching: the best answers first, within a group and among groups (stable: ties keep their order).
631
+ const query = search.trimStart().replace(/^>/, "");
632
+ if (!query.trim()) return listed;
633
+ const score = (entry: MenuEntry) => scoreOf(entry.label, query);
634
+ for (const group of listed) group.entries.sort((a, b) => score(b) - score(a));
635
+ const best = (group: MenuGroup) => Math.max(...group.entries.map(score));
636
+ return listed.sort((a, b) => best(b) - best(a));
637
+ }
638
+
639
+ function firstEnabledIndex(entries: MenuEntry[]): number {
640
+ const index = entries.findIndex((entry) => !entry.command.disabled);
641
+ return index >= 0 ? index : 0;
642
+ }
643
+
644
+ interface CommandMenuProps {
645
+ registry: CommandRegistry;
646
+ subject?: string | undefined;
647
+ onClose: () => void;
648
+ /** `false`: closing gives the focus back to nothing (the desktop app gives it to the page the palette was over). */
649
+ finalFocus?: boolean | undefined;
650
+ /** The search typed, as it changes (a host searches its sources' content with it). */
651
+ onSearch?: ((search: string) => void) | undefined;
652
+ /** A window manager is there: the footer says ↵'s modifiers on a placeable command. */
653
+ placements?: boolean | undefined;
654
+ }
655
+
656
+ /** A command's keys as keycaps, one per key ("⌘", "⌫"). */
657
+ function Keycaps({ keys }: { keys: string }) {
658
+ const caps = keys
659
+ .trim()
660
+ .split(/\s+/)
661
+ .flatMap((step) => step.split("+").map((token) => KEY_LABELS[token] ?? token));
662
+ return (
663
+ <span className="ml-auto flex gap-[3px] pl-4">
664
+ {caps.map((cap, index) => (
665
+ <Kbd key={index}>{cap}</Kbd>
666
+ ))}
667
+ </span>
668
+ );
669
+ }
670
+
671
+ function CommandMenu({
672
+ registry,
673
+ subject,
674
+ onClose,
675
+ finalFocus,
676
+ onSearch,
677
+ placements,
678
+ }: CommandMenuProps) {
679
+ const [search, setSearch] = React.useState("");
680
+ const [pages, setPages] = React.useState<MenuPage[]>([]);
681
+ const [highlight, setHighlight] = React.useState(0);
682
+
683
+ // Re-render when a screen registers or removes commands: the entries are
684
+ // always rebuilt from the live registry, never a snapshot.
685
+ const version = React.useSyncExternalStore(
686
+ registry.subscribe,
687
+ registry.getVersion,
688
+ registry.getVersion,
689
+ );
690
+ const commands = React.useMemo(() => registry.all(), [registry, version]);
691
+
692
+ const page = pages.length > 0 ? (pages[pages.length - 1] ?? null) : null;
693
+ const pageKey = pages.map((entry) => entry.path.join("/")).join("|");
694
+
695
+ const entries = React.useMemo(
696
+ // In the order shown: grouped, so the arrows move as the eye reads.
697
+ () =>
698
+ groupEntries(buildEntries(commands, page, search), search).flatMap((group) => group.entries),
699
+ [commands, page, search],
700
+ );
701
+
702
+ // A new search or page starts the highlight over; an unrelated re-render keeps
703
+ // it (entries are rebuilt every render, so we key on what actually changed).
704
+ React.useEffect(() => {
705
+ setHighlight(0);
706
+ }, [search, pageKey]);
707
+ const searched = React.useRef(onSearch);
708
+ searched.current = onSearch;
709
+ React.useEffect(() => {
710
+ if (!page) searched.current?.(search);
711
+ }, [search, page]);
712
+
713
+ const activeIndex = React.useMemo(() => {
714
+ if (entries.length === 0) return -1;
715
+ const current = entries[highlight];
716
+ if (current && !current.command.disabled) return highlight;
717
+ return firstEnabledIndex(entries);
718
+ }, [entries, highlight]);
719
+
720
+ const groups = React.useMemo(() => groupEntries(entries, search), [entries, search]);
721
+
722
+ // Base UI's dialog popup stops arrow keys' propagation at the popup, so
723
+ // navigation is handled on the DialogContent (the popup), not on the
724
+ // document. Keys arriving back-to-back (ArrowDown then Enter) must see each
725
+ // other's effect, so the handler reads refs rather than render closures.
726
+ const entriesRef = React.useRef(entries);
727
+ entriesRef.current = entries;
728
+ const activeIndexRef = React.useRef(activeIndex);
729
+ activeIndexRef.current = activeIndex;
730
+ const searchRef = React.useRef(search);
731
+ searchRef.current = search;
732
+ const pagesRef = React.useRef(pages);
733
+ pagesRef.current = pages;
734
+
735
+ const idBase = React.useId();
736
+ const listboxId = `${idBase}-listbox`;
737
+ const optionId = (index: number) => `${idBase}-opt-${index}`;
738
+
739
+ // Keep the highlighted option in view as the cursor moves.
740
+ React.useEffect(() => {
741
+ if (activeIndex < 0) return;
742
+ document.getElementById(optionId(activeIndex))?.scrollIntoView?.({ block: "nearest" });
743
+ }, [activeIndex, entries]);
744
+
745
+ const choose = React.useCallback(
746
+ (entry: MenuEntry | undefined, where?: Placement) => {
747
+ if (!entry) return;
748
+ // Re-resolve against the live registry: run only a command that still
749
+ // exists and is not disabled now.
750
+ const command = resolveCommand(registry.all(), entry.path);
751
+ if (!command || command.disabled) return;
752
+ if (command.children && command.children.length > 0) {
753
+ setPages((prev) => [...prev, { command, path: entry.path }]);
754
+ setSearch("");
755
+ return;
756
+ }
757
+ command.run(command.placeable ? where : undefined);
758
+ onClose();
759
+ },
760
+ [onClose, registry],
761
+ );
762
+
763
+ const move = React.useCallback((delta: number) => {
764
+ const list = entriesRef.current;
765
+ if (list.length === 0) return;
766
+ const start = activeIndexRef.current < 0 ? 0 : activeIndexRef.current;
767
+ let next = start;
768
+ for (let step = 0; step < list.length; step += 1) {
769
+ next = (next + delta + list.length) % list.length;
770
+ const candidate = list[next];
771
+ if (candidate && !candidate.command.disabled) {
772
+ activeIndexRef.current = next;
773
+ setHighlight(next);
774
+ return;
775
+ }
776
+ }
777
+ }, []);
778
+
779
+ const onContentKeyDown = (event: React.KeyboardEvent) => {
780
+ // An Enter (or any key) confirming an input method's composition is not ours.
781
+ if (isComposing(event)) return;
782
+ if (event.key === "ArrowDown") {
783
+ event.preventDefault();
784
+ move(1);
785
+ } else if (event.key === "ArrowUp") {
786
+ event.preventDefault();
787
+ move(-1);
788
+ } else if (event.key === "Enter") {
789
+ event.preventDefault();
790
+ choose(entriesRef.current[activeIndexRef.current], placementOf(event));
791
+ } else if (
792
+ event.key === "Backspace" &&
793
+ searchRef.current === "" &&
794
+ pagesRef.current.length > 0
795
+ ) {
796
+ event.preventDefault();
797
+ setPages((prev) => prev.slice(0, -1));
798
+ }
799
+ };
800
+
801
+ return (
802
+ <Dialog
803
+ open
804
+ onOpenChange={(next) => {
805
+ if (!next) onClose();
806
+ }}
807
+ >
808
+ <DialogContent
809
+ aria-label="Commands"
810
+ {...(finalFocus !== undefined && { finalFocus })}
811
+ className="top-[12vh] w-[620px] max-w-[92vw] translate-y-0" // high on the screen, as the mockup (not centred)
812
+ onKeyDown={onContentKeyDown}
813
+ >
814
+ <div className="flex min-h-0 flex-col">
815
+ {subject ? (
816
+ <div className="flex px-3 pt-2.5">
817
+ <Badge data-slot="command-subject">{subject}</Badge>
818
+ </div>
819
+ ) : null}
820
+ <div className="flex h-11 items-center border-b border-border px-3.5">
821
+ <input
822
+ className="w-full flex-1 border-0 bg-transparent p-0 font-sans text-[15px] text-foreground outline-none placeholder:text-placeholder"
823
+ autoFocus
824
+ value={search}
825
+ onChange={(event) => setSearch(event.target.value)}
826
+ placeholder="Type a command or search… (> for actions only)"
827
+ aria-label="Search commands"
828
+ role="combobox"
829
+ aria-expanded="true"
830
+ aria-controls={listboxId}
831
+ aria-autocomplete="list"
832
+ aria-activedescendant={activeIndex >= 0 ? optionId(activeIndex) : undefined}
833
+ autoComplete={noAutofill}
834
+ spellCheck={false}
835
+ />
836
+ </div>
837
+ {/* The kit's scroll, not the browser's; a row never wider than the list (no sideways scroll). */}
838
+ <ScrollArea className="flex min-h-0 flex-col" viewportClassName="max-h-[360px]">
839
+ <div
840
+ id={listboxId}
841
+ role="listbox"
842
+ aria-label="Commands"
843
+ className="flex min-w-0 flex-col p-1"
844
+ >
845
+ {groups.map((group, groupIndex) => (
846
+ <React.Fragment key={group.group ?? `group-${groupIndex}`}>
847
+ {group.group ? (
848
+ <div
849
+ data-slot="command-group"
850
+ className="px-2 pt-1.5 pb-0.5 text-xs font-medium text-muted"
851
+ >
852
+ {group.group}
853
+ </div>
854
+ ) : null}
855
+ {group.entries.map((entry) => {
856
+ const index = entries.indexOf(entry);
857
+ const isActive = index === activeIndex;
858
+ return (
859
+ <div
860
+ key={entry.key}
861
+ id={optionId(index)}
862
+ role="option"
863
+ aria-selected={isActive}
864
+ aria-disabled={entry.command.disabled || undefined}
865
+ data-highlighted={isActive || undefined}
866
+ // The whole text on hover: a long label or description is cut on its row.
867
+ title={
868
+ entry.command.description
869
+ ? `${entry.label} — ${entry.command.description}`
870
+ : entry.label
871
+ }
872
+ className={cn(
873
+ dropdownMenuItemVariants(),
874
+ // The item's w-full plus its padding would overflow the list (no global border-box here).
875
+ "w-auto min-h-9 min-w-0", // the mockup's 36 px rows (min-h: h-md is not merged away); never wider than the list
876
+ entry.command.disabled && "aria-disabled:opacity-50",
877
+ )}
878
+ onClick={(event) => choose(entry, placementOf(event))}
879
+ onMouseMove={() => {
880
+ if (!entry.command.disabled) setHighlight(index);
881
+ }}
882
+ >
883
+ {entry.command.icon ? (
884
+ <Icon
885
+ name={entry.command.icon}
886
+ size={16}
887
+ className="shrink-0 text-muted"
888
+ />
889
+ ) : null}
890
+ {/* One line: the label, then its description, quieter, cut first when room runs out. */}
891
+ <span className="flex min-w-0 flex-1 items-baseline gap-2 overflow-hidden">
892
+ <span className="max-w-full shrink-0 truncate">{entry.label}</span>
893
+ {entry.command.description ? (
894
+ <span className="min-w-0 truncate text-xs text-muted">
895
+ {entry.command.description}
896
+ </span>
897
+ ) : null}
898
+ </span>
899
+ {entry.command.keys ? <Keycaps keys={entry.command.keys} /> : null}
900
+ </div>
901
+ );
902
+ })}
903
+ </React.Fragment>
904
+ ))}
905
+ {entries.length === 0 ? (
906
+ <div className="px-2 py-2 text-sm text-muted">No command</div>
907
+ ) : null}
908
+ </div>
909
+ </ScrollArea>
910
+ <div
911
+ data-slot="command-footer"
912
+ className="flex gap-3 border-t border-border px-3.5 py-1.5 text-[11px] text-muted"
913
+ >
914
+ <span>↑↓ move</span>
915
+ <span>↵ run</span>
916
+ <span>Esc close</span>
917
+ <span>&gt; actions only</span>
918
+ <span className="ml-auto">
919
+ {placements && entries[activeIndex]?.command.placeable
920
+ ? "⌘↵ beside · ⌥↵ new desk · ⇧↵ float · ⇧⌘↵ full"
921
+ : "Shortcuts work without opening this menu"}
922
+ </span>
923
+ </div>
924
+ </div>
925
+ </DialogContent>
926
+ </Dialog>
927
+ );
928
+ }
929
+
930
+ export {
931
+ CommandScope,
932
+ useCommands,
933
+ useScopeCommands,
934
+ KeyHint,
935
+ CommandMenu,
936
+ CommandHostProvider,
937
+ formatKeys,
938
+ };
939
+ export type { Command, CommandScopeProps, CommandHost, CommandSource, CommandRegistry, Placement };