@visulima/tui 1.0.8 → 2.0.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 (336) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/LICENSE.md +54 -2444
  3. package/MIGRATION-GUIDE.md +164 -0
  4. package/README.md +15 -12
  5. package/dist/components/box.d.ts +26 -27
  6. package/dist/components/canvas.d.ts +26 -31
  7. package/dist/components/canvas.js +1 -1
  8. package/dist/components/cursor.d.ts +40 -46
  9. package/dist/components/error-boundary.d.ts +16 -0
  10. package/dist/components/error-boundary.js +1 -0
  11. package/dist/components/error-overview.d.ts +6 -0
  12. package/dist/components/error-overview.js +1 -0
  13. package/dist/components/newline.d.ts +6 -8
  14. package/dist/components/spacer.d.ts +4 -4
  15. package/dist/components/static-render.d.ts +10 -42
  16. package/dist/components/static.d.ts +13 -14
  17. package/dist/components/text.d.ts +34 -48
  18. package/dist/components/transform.d.ts +7 -11
  19. package/dist/core/index.d.ts +11 -12
  20. package/dist/core/index.js +1 -1
  21. package/dist/ink/canvas/index.d.ts +24 -0
  22. package/dist/ink/canvas/index.js +1 -0
  23. package/dist/ink/hooks/use-animation.d.ts +22 -22
  24. package/dist/ink/hooks/use-app.d.ts +3 -34
  25. package/dist/ink/hooks/use-app.js +1 -1
  26. package/dist/ink/hooks/use-box-metrics.d.ts +17 -18
  27. package/dist/ink/hooks/use-clipboard.d.ts +16 -16
  28. package/dist/ink/hooks/use-color-blindness.d.ts +16 -16
  29. package/dist/ink/hooks/use-console-capture.d.ts +19 -19
  30. package/dist/ink/hooks/use-cursor.d.ts +7 -7
  31. package/dist/ink/hooks/use-focus-manager.d.ts +25 -25
  32. package/dist/ink/hooks/use-focus.d.ts +14 -18
  33. package/dist/ink/hooks/use-form.d.ts +32 -32
  34. package/dist/ink/hooks/use-hotkey.d.ts +17 -17
  35. package/dist/ink/hooks/use-input.d.ts +92 -92
  36. package/dist/ink/hooks/use-input.js +2 -2
  37. package/dist/ink/hooks/use-interval.d.ts +14 -14
  38. package/dist/ink/hooks/use-is-screen-reader-enabled.d.ts +3 -3
  39. package/dist/ink/hooks/use-key-bindings.d.ts +32 -32
  40. package/dist/ink/hooks/use-key-chord.d.ts +15 -15
  41. package/dist/ink/hooks/use-paste.d.ts +38 -38
  42. package/dist/ink/hooks/use-paste.js +1 -1
  43. package/dist/ink/hooks/use-persistent-state.d.ts +46 -46
  44. package/dist/ink/hooks/use-persistent-state.js +2 -2
  45. package/dist/ink/hooks/use-scroll-acceleration.d.ts +24 -24
  46. package/dist/ink/hooks/use-scroll-input.d.ts +15 -15
  47. package/dist/ink/hooks/use-stderr.d.ts +6 -6
  48. package/dist/ink/hooks/use-stderr.js +1 -1
  49. package/dist/ink/hooks/use-stdin.d.ts +10 -10
  50. package/dist/ink/hooks/use-stdin.js +1 -1
  51. package/dist/ink/hooks/use-stdout.d.ts +6 -6
  52. package/dist/ink/hooks/use-stdout.js +1 -1
  53. package/dist/ink/hooks/use-stopwatch.d.ts +12 -12
  54. package/dist/ink/hooks/use-terminal-palette.d.ts +11 -11
  55. package/dist/ink/hooks/use-text-buffer.d.ts +2 -2
  56. package/dist/ink/hooks/use-text-selection.d.ts +19 -20
  57. package/dist/ink/hooks/use-timeout.d.ts +11 -11
  58. package/dist/ink/hooks/use-timer.d.ts +19 -19
  59. package/dist/ink/hooks/use-window-size.d.ts +8 -8
  60. package/dist/ink/hooks/use-window-size.js +1 -1
  61. package/dist/ink/index.d.ts +110 -123
  62. package/dist/ink/index.js +1 -1
  63. package/dist/ink/mouse/use-element-position.d.ts +7 -8
  64. package/dist/ink/mouse/use-mouse-action.d.ts +1 -1
  65. package/dist/ink/mouse/use-mouse-position.d.ts +1 -1
  66. package/dist/ink/mouse/use-mouse.d.ts +1 -1
  67. package/dist/ink/mouse/use-on-mouse-click.d.ts +4 -5
  68. package/dist/ink/mouse/use-on-mouse-hover.d.ts +3 -4
  69. package/dist/ink/mouse/use-on-mouse-state.d.ts +3 -4
  70. package/dist/ink/public/cursor.d.ts +47 -0
  71. package/dist/ink/public/cursor.js +1 -0
  72. package/dist/ink/public/dom.d.ts +6 -0
  73. package/dist/ink/public/dom.js +0 -0
  74. package/dist/ink/public/highlighter.d.ts +44 -0
  75. package/dist/ink/public/highlighter.js +1 -0
  76. package/dist/ink/public/input.d.ts +14 -0
  77. package/dist/ink/public/input.js +1 -0
  78. package/dist/ink/public/styles.d.ts +4 -0
  79. package/dist/ink/public/styles.js +0 -0
  80. package/dist/ink/public/utils.d.ts +5 -0
  81. package/dist/ink/public/utils.js +1 -0
  82. package/dist/packem_chunks/devtools.js +1 -1
  83. package/dist/packem_shared/{DevTools-k6uiVzqv.js → DevTools-BxD3PYAN.js} +1 -1
  84. package/dist/packem_shared/InputParser-CiBitCva.js +2 -0
  85. package/dist/packem_shared/MouseProvider-DOcWCRVq.js +1 -0
  86. package/dist/packem_shared/{Renderer-DsskdkUd.js → Renderer-BeS49FNq.js} +1 -1
  87. package/dist/packem_shared/TuiApp-CCVaiKbf.js +1 -0
  88. package/dist/packem_shared/app-context-DTm1_XBA.js +1 -0
  89. package/dist/packem_shared/app-context.d-DMLw5Nxy.d.ts +56 -0
  90. package/dist/packem_shared/boxes-DyY_LXCi.js +1 -0
  91. package/dist/packem_shared/buffer.d-CttIC480.d.ts +67 -0
  92. package/dist/packem_shared/buildCursorOnlySequence-CerkmjWt.js +1 -0
  93. package/dist/packem_shared/clipboard.d-nDPQkZ2H.d.ts +23 -0
  94. package/dist/packem_shared/color-matrix.d-sTqnJ23h.d.ts +50 -0
  95. package/dist/packem_shared/{braille-ch3O5D7I.js → createBrailleGrid-BTOQrujS.js} +1 -1
  96. package/dist/packem_shared/createCanvasBuffer-CL6sAM-A.js +1 -0
  97. package/dist/packem_shared/{createInlineLoop-BT40Wpmx.js → createInlineLoop-DnEvE2eM.js} +1 -1
  98. package/dist/packem_shared/disposeHighlighter-D9OkrhwX.js +1 -0
  99. package/dist/packem_shared/{dom.d-B4kXbaVY.d.ts → dom.d-CLGlidfI.d.ts} +140 -154
  100. package/dist/packem_shared/formatDuration-Bdx4ZgRh.js +1 -0
  101. package/dist/packem_shared/index-Dl9I2_QH.js +75 -0
  102. package/dist/packem_shared/input.d-Bb8pWHvp.d.ts +172 -0
  103. package/dist/packem_shared/{input-utils-BSWCb4F_.js → isControlCharacter-uDgBe_32.js} +1 -1
  104. package/dist/packem_shared/load-native-root-binding-CxJnHcac.js +1 -0
  105. package/dist/packem_shared/{mouse-context.d-BfL9xGk_.d.ts → mouse-context.d-W-nszUps.d.ts} +8 -8
  106. package/dist/packem_shared/reconciler-DkwOtC5B.js +1 -0
  107. package/dist/packem_shared/render-CuCo-R-l.js +24 -0
  108. package/dist/packem_shared/{render-DFZ8NHlG.js → render-DtQd8qQq.js} +1 -1
  109. package/dist/packem_shared/render.d-DjQhFsiN.d.ts +435 -0
  110. package/dist/packem_shared/{renderToString-DwXFY8Qh.js → renderToString-B1LgWcJe.js} +1 -1
  111. package/dist/packem_shared/{renderToString-L_bpw4OQ.js → renderToString-DkTmJPaS.js} +1 -1
  112. package/dist/packem_shared/renderToken-DjiQ6dfv.js +1 -0
  113. package/dist/packem_shared/renderTreeToBuffer-BpSD0sBJ.js +2 -0
  114. package/dist/packem_shared/{renderer-k-xShm1P.js → renderer-Cs0KEr1o.js} +4 -4
  115. package/dist/packem_shared/{selection.d-CI3_p8wg.d.ts → selection.d-BSAWa4ey.d.ts} +16 -16
  116. package/dist/packem_shared/stderr-context-CR2LLec6.js +1 -0
  117. package/dist/packem_shared/stdin-context-BjMA9Sbi.js +1 -0
  118. package/dist/packem_shared/stdout-context-DAAlQct2.js +1 -0
  119. package/dist/packem_shared/styles.d-CKGQFfm4.d.ts +485 -0
  120. package/dist/packem_shared/{terminal-palette.d-D2SQjfn-.d.ts → terminal-palette.d-JbWHISW-.d.ts} +7 -7
  121. package/dist/packem_shared/utils-CVgM8kTn.js +1 -0
  122. package/dist/react/index.d.ts +160 -179
  123. package/dist/react/index.js +1 -1
  124. package/dist/testing/index.d.ts +152 -152
  125. package/dist/testing/index.js +1 -1
  126. package/index.js +52 -52
  127. package/package.json +49 -384
  128. package/dist/components/accordion.d.ts +0 -59
  129. package/dist/components/accordion.js +0 -1
  130. package/dist/components/alert.d.ts +0 -26
  131. package/dist/components/alert.js +0 -1
  132. package/dist/components/animate-presence.d.ts +0 -18
  133. package/dist/components/animate-presence.js +0 -1
  134. package/dist/components/approval-prompt.d.ts +0 -65
  135. package/dist/components/approval-prompt.js +0 -1
  136. package/dist/components/area-chart.d.ts +0 -66
  137. package/dist/components/area-chart.js +0 -1
  138. package/dist/components/badge.d.ts +0 -22
  139. package/dist/components/badge.js +0 -1
  140. package/dist/components/bar-chart.d.ts +0 -67
  141. package/dist/components/bar-chart.js +0 -1
  142. package/dist/components/big-text.d.ts +0 -81
  143. package/dist/components/big-text.js +0 -1
  144. package/dist/components/blink-dot.d.ts +0 -36
  145. package/dist/components/blink-dot.js +0 -1
  146. package/dist/components/breadcrumb.d.ts +0 -33
  147. package/dist/components/breadcrumb.js +0 -1
  148. package/dist/components/button.d.ts +0 -45
  149. package/dist/components/button.js +0 -1
  150. package/dist/components/calendar.d.ts +0 -72
  151. package/dist/components/calendar.js +0 -1
  152. package/dist/components/card.d.ts +0 -57
  153. package/dist/components/card.js +0 -1
  154. package/dist/components/checkbox.d.ts +0 -48
  155. package/dist/components/checkbox.js +0 -1
  156. package/dist/components/code.d.ts +0 -48
  157. package/dist/components/code.js +0 -2
  158. package/dist/components/collapsible.d.ts +0 -53
  159. package/dist/components/collapsible.js +0 -1
  160. package/dist/components/command-block.d.ts +0 -47
  161. package/dist/components/command-block.js +0 -4
  162. package/dist/components/command-palette.d.ts +0 -82
  163. package/dist/components/command-palette.js +0 -1
  164. package/dist/components/confirm-dialog.d.ts +0 -75
  165. package/dist/components/confirm-dialog.js +0 -1
  166. package/dist/components/confirm-input.d.ts +0 -38
  167. package/dist/components/confirm-input.js +0 -1
  168. package/dist/components/console-overlay.d.ts +0 -54
  169. package/dist/components/console-overlay.js +0 -1
  170. package/dist/components/content-switcher.d.ts +0 -57
  171. package/dist/components/content-switcher.js +0 -1
  172. package/dist/components/controlled-scroll-view.d.ts +0 -61
  173. package/dist/components/controlled-scroll-view.js +0 -1
  174. package/dist/components/date-picker.d.ts +0 -65
  175. package/dist/components/date-picker.js +0 -1
  176. package/dist/components/definition-list.d.ts +0 -44
  177. package/dist/components/definition-list.js +0 -1
  178. package/dist/components/dialog.d.ts +0 -117
  179. package/dist/components/dialog.js +0 -1
  180. package/dist/components/diff-view.d.ts +0 -85
  181. package/dist/components/diff-view.js +0 -1
  182. package/dist/components/divider.d.ts +0 -49
  183. package/dist/components/divider.js +0 -1
  184. package/dist/components/file-picker-entry.d.ts +0 -104
  185. package/dist/components/file-picker-entry.js +0 -1
  186. package/dist/components/form.d.ts +0 -81
  187. package/dist/components/form.js +0 -1
  188. package/dist/components/gauge.d.ts +0 -87
  189. package/dist/components/gauge.js +0 -1
  190. package/dist/components/gradient.d.ts +0 -42
  191. package/dist/components/gradient.js +0 -1
  192. package/dist/components/heading.d.ts +0 -33
  193. package/dist/components/heading.js +0 -1
  194. package/dist/components/heatmap.d.ts +0 -62
  195. package/dist/components/heatmap.js +0 -1
  196. package/dist/components/help.d.ts +0 -52
  197. package/dist/components/help.js +0 -1
  198. package/dist/components/histogram.d.ts +0 -62
  199. package/dist/components/histogram.js +0 -1
  200. package/dist/components/kbd.d.ts +0 -31
  201. package/dist/components/kbd.js +0 -1
  202. package/dist/components/line-chart.d.ts +0 -109
  203. package/dist/components/line-chart.js +0 -1
  204. package/dist/components/link.d.ts +0 -38
  205. package/dist/components/link.js +0 -1
  206. package/dist/components/loading-indicator.d.ts +0 -29
  207. package/dist/components/loading-indicator.js +0 -1
  208. package/dist/components/markdown.d.ts +0 -40
  209. package/dist/components/markdown.js +0 -1
  210. package/dist/components/masked-input.d.ts +0 -50
  211. package/dist/components/masked-input.js +0 -1
  212. package/dist/components/menu.d.ts +0 -78
  213. package/dist/components/menu.js +0 -1
  214. package/dist/components/message-bubble.d.ts +0 -43
  215. package/dist/components/message-bubble.js +0 -1
  216. package/dist/components/model-badge.d.ts +0 -39
  217. package/dist/components/model-badge.js +0 -1
  218. package/dist/components/multi-select.d.ts +0 -65
  219. package/dist/components/multi-select.js +0 -1
  220. package/dist/components/operation-tree.d.ts +0 -49
  221. package/dist/components/operation-tree.js +0 -1
  222. package/dist/components/option-list.d.ts +0 -47
  223. package/dist/components/option-list.js +0 -1
  224. package/dist/components/ordered-list.d.ts +0 -24
  225. package/dist/components/ordered-list.js +0 -1
  226. package/dist/components/paginator.d.ts +0 -69
  227. package/dist/components/paginator.js +0 -1
  228. package/dist/components/paragraph.d.ts +0 -38
  229. package/dist/components/paragraph.js +0 -1
  230. package/dist/components/placeholder.d.ts +0 -55
  231. package/dist/components/placeholder.js +0 -1
  232. package/dist/components/progress-bar.d.ts +0 -56
  233. package/dist/components/progress-bar.js +0 -1
  234. package/dist/components/radio-group.d.ts +0 -74
  235. package/dist/components/radio-group.js +0 -1
  236. package/dist/components/scatter-plot.d.ts +0 -35
  237. package/dist/components/scatter-plot.js +0 -1
  238. package/dist/components/scroll-bar-box.d.ts +0 -37
  239. package/dist/components/scroll-bar-box.js +0 -1
  240. package/dist/components/scroll-bar.d.ts +0 -25
  241. package/dist/components/scroll-bar.js +0 -1
  242. package/dist/components/scroll-list.d.ts +0 -20
  243. package/dist/components/scroll-list.js +0 -1
  244. package/dist/components/scroll-view.d.ts +0 -10
  245. package/dist/components/scroll-view.js +0 -1
  246. package/dist/components/search-input.d.ts +0 -55
  247. package/dist/components/search-input.js +0 -1
  248. package/dist/components/select-input-indicator.d.ts +0 -32
  249. package/dist/components/select-input-indicator.js +0 -1
  250. package/dist/components/select-input-item.d.ts +0 -41
  251. package/dist/components/select-input-item.js +0 -1
  252. package/dist/components/select-input.d.ts +0 -110
  253. package/dist/components/select-input.js +0 -1
  254. package/dist/components/shimmer-text.d.ts +0 -47
  255. package/dist/components/shimmer-text.js +0 -1
  256. package/dist/components/slider.d.ts +0 -103
  257. package/dist/components/slider.js +0 -1
  258. package/dist/components/sparkline.d.ts +0 -35
  259. package/dist/components/sparkline.js +0 -1
  260. package/dist/components/spinner.d.ts +0 -17
  261. package/dist/components/spinner.js +0 -1
  262. package/dist/components/status-line.d.ts +0 -37
  263. package/dist/components/status-line.js +0 -1
  264. package/dist/components/status-message.d.ts +0 -21
  265. package/dist/components/status-message.js +0 -1
  266. package/dist/components/stepper.d.ts +0 -48
  267. package/dist/components/stepper.js +0 -1
  268. package/dist/components/stopwatch.d.ts +0 -49
  269. package/dist/components/stopwatch.js +0 -1
  270. package/dist/components/streaming-text.d.ts +0 -46
  271. package/dist/components/streaming-text.js +0 -1
  272. package/dist/components/switch.d.ts +0 -55
  273. package/dist/components/switch.js +0 -1
  274. package/dist/components/tab.d.ts +0 -19
  275. package/dist/components/tab.js +0 -1
  276. package/dist/components/table.d.ts +0 -119
  277. package/dist/components/table.js +0 -1
  278. package/dist/components/tabs.d.ts +0 -107
  279. package/dist/components/tabs.js +0 -1
  280. package/dist/components/tag.d.ts +0 -35
  281. package/dist/components/tag.js +0 -1
  282. package/dist/components/text-input.d.ts +0 -48
  283. package/dist/components/text-input.js +0 -1
  284. package/dist/components/textarea.d.ts +0 -68
  285. package/dist/components/textarea.js +0 -2
  286. package/dist/components/timer.d.ts +0 -59
  287. package/dist/components/timer.js +0 -1
  288. package/dist/components/toast.d.ts +0 -49
  289. package/dist/components/toast.js +0 -1
  290. package/dist/components/tooltip.d.ts +0 -43
  291. package/dist/components/tooltip.js +0 -1
  292. package/dist/components/transition.d.ts +0 -74
  293. package/dist/components/transition.js +0 -1
  294. package/dist/components/tree-view-entry.d.ts +0 -357
  295. package/dist/components/tree-view-entry.js +0 -1
  296. package/dist/components/unordered-list.d.ts +0 -30
  297. package/dist/components/unordered-list.js +0 -1
  298. package/dist/ink/hooks/use-linked-scroll.d.ts +0 -49
  299. package/dist/ink/hooks/use-linked-scroll.js +0 -1
  300. package/dist/packem_shared/ControlledScrollView-Cn4byU2n.js +0 -1
  301. package/dist/packem_shared/FilePicker-BLS9nOPz.js +0 -1
  302. package/dist/packem_shared/InputParser-CtwkCbrQ.js +0 -2
  303. package/dist/packem_shared/MouseProvider-DUqQ3Eaa.js +0 -1
  304. package/dist/packem_shared/ScrollBar-qa1IzDDv.js +0 -1
  305. package/dist/packem_shared/ScrollBarBox-DchESZWv.js +0 -1
  306. package/dist/packem_shared/ScrollList-BBAnRsrC.js +0 -1
  307. package/dist/packem_shared/ScrollView-CHAo7Epj.js +0 -1
  308. package/dist/packem_shared/TreeNodeMap-cJlYqckB.js +0 -1
  309. package/dist/packem_shared/TreeView-BsvLCsf0.js +0 -1
  310. package/dist/packem_shared/TuiApp-BPL8v1i1.js +0 -1
  311. package/dist/packem_shared/app-context-BVpKlG1z.js +0 -1
  312. package/dist/packem_shared/buffer.d-EJkZr8uH.d.ts +0 -39
  313. package/dist/packem_shared/clipboard.d-D6lZTQ21.d.ts +0 -23
  314. package/dist/packem_shared/color-matrix.d-DSXLsB64.d.ts +0 -50
  315. package/dist/packem_shared/controlled-scroll-view-BVg7ywNW.js +0 -1
  316. package/dist/packem_shared/cursor-helpers.d-BONB9tky.d.ts +0 -12
  317. package/dist/packem_shared/format-time-fjoQHMxD.js +0 -1
  318. package/dist/packem_shared/input.d-CgxV2e8U.d.ts +0 -90
  319. package/dist/packem_shared/line-chart-C7CUrvVs.js +0 -1
  320. package/dist/packem_shared/load-native-root-binding-DDikxNox.js +0 -1
  321. package/dist/packem_shared/reconciler-CFyBVf7l.js +0 -1
  322. package/dist/packem_shared/render-CuQecTAs.js +0 -24
  323. package/dist/packem_shared/render.d-CBnYBDk2.d.ts +0 -417
  324. package/dist/packem_shared/renderTreeToBuffer-C8lS0lJ2.js +0 -2
  325. package/dist/packem_shared/scroll-view.d-DtpsgHLg.d.ts +0 -119
  326. package/dist/packem_shared/stderr-context-Bvnik0hL.js +0 -1
  327. package/dist/packem_shared/stdin-context-88AhuztD.js +0 -1
  328. package/dist/packem_shared/stdout-context-BnblEPez.js +0 -1
  329. package/dist/packem_shared/styles.d-cMo36xQz.d.ts +0 -396
  330. package/dist/packem_shared/token-to-elements-D6J6-P2A.js +0 -1
  331. package/dist/packem_shared/treeViewTheme-Dq3ekRAC.js +0 -1
  332. package/dist/packem_shared/useTreeView-D5ifGwG3.js +0 -1
  333. package/dist/packem_shared/useTreeViewState-BiTJakkh.js +0 -1
  334. package/dist/packem_shared/utils-Bup8lyK8.js +0 -1
  335. package/dist/packem_shared/variant-config-BJqpNo7H.js +0 -1
  336. package/dist/packem_shared/variant-config.d-D5NnrrQK.d.ts +0 -2
@@ -1,12 +1,12 @@
1
1
  import 'node:stream';
2
- import { a as CursorPosition } from "../../packem_shared/cursor-helpers.d-BONB9tky.js";
2
+ import { CursorPosition } from "../public/cursor.js";
3
3
  /**
4
- * A React hook that returns methods to control the terminal cursor position.
5
- *
6
- * Setting a cursor position makes the cursor visible at the specified coordinates (relative to the Ink output origin). This is useful for IME (Input Method Editor) support, where the composing character is displayed at the cursor location.
7
- *
8
- * Pass `undefined` to hide the cursor.
9
- */
4
+ * A React hook that returns methods to control the terminal cursor position.
5
+ *
6
+ * Setting a cursor position makes the cursor visible at the specified coordinates (relative to the Ink output origin). This is useful for IME (Input Method Editor) support, where the composing character is displayed at the cursor location.
7
+ *
8
+ * Pass `undefined` to hide the cursor.
9
+ */
10
10
  declare const useCursor: () => {
11
11
  setCursorPosition: (position: CursorPosition | undefined) => void;
12
12
  };
@@ -15,43 +15,43 @@ type Props = {
15
15
  };
16
16
  type Output = {
17
17
  /**
18
- * The ID of the currently focused component, or `undefined` if no component is focused.
19
- * @example
20
- * ```tsx
21
- * import {Text} from '@visulima/tui/components/text';
22
- * import {useFocusManager} from '@visulima/tui/hooks/use-focus-manager';
23
- *
24
- * const Example = () => {
25
- * const {activeId} = useFocusManager();
26
- *
27
- * return <Text>Focused: {activeId ?? 'none'}</Text>;
28
- * };
29
- * ```
30
- */
18
+ * The ID of the currently focused component, or `undefined` if no component is focused.
19
+ * @example
20
+ * ```tsx
21
+ * import {Text} from '@visulima/tui/components/text';
22
+ * import {useFocusManager} from '@visulima/tui/hooks/use-focus-manager';
23
+ *
24
+ * const Example = () => {
25
+ * const {activeId} = useFocusManager();
26
+ *
27
+ * return <Text>Focused: {activeId ?? 'none'}</Text>;
28
+ * };
29
+ * ```
30
+ */
31
31
  activeId: Props["activeId"];
32
32
  /**
33
- * Disable focus management for all components. The currently active component (if there's one) will lose its focus.
34
- */
33
+ * Disable focus management for all components. The currently active component (if there's one) will lose its focus.
34
+ */
35
35
  disableFocus: Props["disableFocus"];
36
36
  /**
37
- * Enable focus management for all components.
38
- */
37
+ * Enable focus management for all components.
38
+ */
39
39
  enableFocus: Props["enableFocus"];
40
40
  /**
41
- * Switch focus to the element with provided `id`. If there's no element with that `id`, focus is not changed.
42
- */
41
+ * Switch focus to the element with provided `id`. If there's no element with that `id`, focus is not changed.
42
+ */
43
43
  focus: Props["focus"];
44
44
  /**
45
- * Switch focus to the next focusable component. If there's no active component right now, focus will be given to the first focusable component. If the active component is the last in the list of focusable components, focus will be switched to the first focusable component.
46
- */
45
+ * Switch focus to the next focusable component. If there's no active component right now, focus will be given to the first focusable component. If the active component is the last in the list of focusable components, focus will be switched to the first focusable component.
46
+ */
47
47
  focusNext: Props["focusNext"];
48
48
  /**
49
- * Switch focus to the previous focusable component. If there's no active component right now, focus will be given to the first focusable component. If the active component is the first in the list of focusable components, focus will be switched to the last focusable component.
50
- */
49
+ * Switch focus to the previous focusable component. If there's no active component right now, focus will be given to the first focusable component. If the active component is the first in the list of focusable components, focus will be switched to the last focusable component.
50
+ */
51
51
  focusPrevious: Props["focusPrevious"];
52
52
  };
53
53
  /**
54
- * A React hook that returns methods to enable or disable focus management for all components or manually switch focus to the next or previous components.
55
- */
54
+ * A React hook that returns methods to enable or disable focus management for all components or manually switch focus to the next or previous components.
55
+ */
56
56
  declare const useFocusManager: () => Output;
57
57
  export { useFocusManager as default, useFocusManager };
@@ -1,34 +1,30 @@
1
1
  type Input = {
2
2
  /**
3
- * Auto-focus this component if there's no active (focused) component right now.
4
- */
3
+ * Auto-focus this component if there's no active (focused) component right now.
4
+ */
5
5
  autoFocus?: boolean;
6
6
  /**
7
- * Assign an ID to this component, so it can be programmatically focused with `focus(id)`.
8
- */
7
+ * Assign an ID to this component, so it can be programmatically focused with `focus(id)`.
8
+ */
9
9
  id?: string;
10
10
  /**
11
- * Enable or disable this component's focus, while still maintaining its position in the list of focusable components.
12
- */
11
+ * Enable or disable this component's focus, while still maintaining its position in the list of focusable components.
12
+ */
13
13
  isActive?: boolean;
14
14
  };
15
15
  type Output = {
16
16
  /**
17
- * Allows focusing a specific element with the provided `id`.
18
- */
17
+ * Allows focusing a specific element with the provided `id`.
18
+ */
19
19
  focus: (id: string) => void;
20
20
  /**
21
- * Determines whether this component is focused.
22
- */
21
+ * Determines whether this component is focused.
22
+ */
23
23
  isFocused: boolean;
24
24
  };
25
25
  /**
26
- * A React hook that returns focus state and focus controls for the current component.
27
- * A component that uses the `useFocus` hook becomes "focusable" to Ink, so when the user presses &lt;kbd>Tab&lt;/kbd>, Ink will switch focus to this component. If there are multiple components that execute the `useFocus` hook, focus will be given to them in the order in which these components are rendered.
28
- */
29
- declare const useFocus: ({
30
- autoFocus,
31
- id: customId,
32
- isActive
33
- }?: Input) => Output;
26
+ * A React hook that returns focus state and focus controls for the current component.
27
+ * A component that uses the `useFocus` hook becomes "focusable" to Ink, so when the user presses &lt;kbd>Tab&lt;/kbd>, Ink will switch focus to this component. If there are multiple components that execute the `useFocus` hook, focus will be given to them in the order in which these components are rendered.
28
+ */
29
+ declare const useFocus: ({ autoFocus, id: customId, isActive }?: Input) => Output;
34
30
  export { useFocus as default, useFocus };
@@ -2,67 +2,67 @@ type ValidationResult = string | undefined;
2
2
  type FieldValidator<V> = (value: V, values: Readonly<Record<string, unknown>>) => ValidationResult;
3
3
  type FieldConfig<V = unknown> = {
4
4
  /**
5
- * Initial value.
6
- */
5
+ * Initial value.
6
+ */
7
7
  readonly initialValue: V;
8
8
  /**
9
- * Optional validator. Return a string to indicate an error; return
10
- * `undefined` for valid.
11
- */
9
+ * Optional validator. Return a string to indicate an error; return
10
+ * `undefined` for valid.
11
+ */
12
12
  readonly validate?: FieldValidator<V>;
13
13
  };
14
14
  type FormSchema = Readonly<Record<string, FieldConfig<never>>>;
15
- type FormValues<S extends Readonly<Record<string, FieldConfig>>> = { [K in keyof S]: S[K] extends FieldConfig<infer V> ? V : never };
15
+ type FormValues<S extends Readonly<Record<string, FieldConfig>>> = { [K in keyof S]: S[K] extends FieldConfig<infer V> ? V : never; };
16
16
  type UseFormOptions<S extends Readonly<Record<string, FieldConfig>>> = {
17
17
  /**
18
- * Field declarations.
19
- */
18
+ * Field declarations.
19
+ */
20
20
  readonly fields: S;
21
21
  /**
22
- * Called on submit if all fields validate.
23
- */
22
+ * Called on submit if all fields validate.
23
+ */
24
24
  readonly onSubmit?: (values: FormValues<S>) => void | Promise<void>;
25
25
  };
26
26
  type UseFormResult<S extends Readonly<Record<string, FieldConfig>>> = {
27
27
  /**
28
- * Map of fieldName -> validation error (if any).
29
- */
28
+ * Map of fieldName -> validation error (if any).
29
+ */
30
30
  readonly errors: Readonly<Partial<Record<keyof S, string>>>;
31
31
  /**
32
- * True while the last `submit()` is in-flight.
33
- */
32
+ * True while the last `submit()` is in-flight.
33
+ */
34
34
  readonly isSubmitting: boolean;
35
35
  /**
36
- * Reset all fields back to their initial values and clear errors / touched.
37
- */
36
+ * Reset all fields back to their initial values and clear errors / touched.
37
+ */
38
38
  readonly reset: () => void;
39
39
  /**
40
- * Mark a field as touched. Useful on blur.
41
- */
40
+ * Mark a field as touched. Useful on blur.
41
+ */
42
42
  readonly setTouched: <K extends keyof S>(name: K, touched?: boolean) => void;
43
43
  /**
44
- * Update a single field.
45
- */
44
+ * Update a single field.
45
+ */
46
46
  readonly setValue: <K extends keyof S>(name: K, value: FormValues<S>[K]) => void;
47
47
  /**
48
- * Trigger validation and call the `onSubmit` option. Returns true if
49
- * submission succeeded (all fields valid).
50
- */
48
+ * Trigger validation and call the `onSubmit` option. Returns true if
49
+ * submission succeeded (all fields valid).
50
+ */
51
51
  readonly submit: () => Promise<boolean>;
52
52
  /**
53
- * Map of fieldName -> boolean. Field is considered touched after the
54
- * first `setTouched(name)` or `submit()` invocation.
55
- */
53
+ * Map of fieldName -> boolean. Field is considered touched after the
54
+ * first `setTouched(name)` or `submit()` invocation.
55
+ */
56
56
  readonly touched: Readonly<Partial<Record<keyof S, boolean>>>;
57
57
  /**
58
- * Current values.
59
- */
58
+ * Current values.
59
+ */
60
60
  readonly values: FormValues<S>;
61
61
  };
62
62
  /**
63
- * Minimal headless form state machine. Tracks values, touched state, errors,
64
- * and submission in-flight. Pair with `&lt;Form />` for default layout, or wire
65
- * up your own inputs directly.
66
- */
63
+ * Minimal headless form state machine. Tracks values, touched state, errors,
64
+ * and submission in-flight. Pair with `&lt;Form />` for default layout, or wire
65
+ * up your own inputs directly.
66
+ */
67
67
  declare const useForm: <S extends Readonly<Record<string, FieldConfig>>>(options: UseFormOptions<S>) => UseFormResult<S>;
68
68
  export { FieldConfig, FieldValidator, FormSchema, FormValues, UseFormOptions, UseFormResult, ValidationResult, useForm as default, useForm };
@@ -1,37 +1,37 @@
1
1
  import { Key } from "./use-input.js";
2
2
  type HotkeyDescriptor = {
3
3
  /**
4
- * Whether Ctrl must be held.
5
- */
4
+ * Whether Ctrl must be held.
5
+ */
6
6
  readonly ctrl?: boolean;
7
7
  /**
8
- * Character(s) to match after modifiers, e.g. `"s"`, `"?"`, `"k"`.
9
- * Ignored if `name` is set.
10
- */
8
+ * Character(s) to match after modifiers, e.g. `"s"`, `"?"`, `"k"`.
9
+ * Ignored if `name` is set.
10
+ */
11
11
  readonly input?: string;
12
12
  /**
13
- * Whether Meta must be held.
14
- */
13
+ * Whether Meta must be held.
14
+ */
15
15
  readonly meta?: boolean;
16
16
  /**
17
- * Named special key, e.g. `"escape"`, `"return"`, `"tab"`, `"upArrow"`.
18
- */
17
+ * Named special key, e.g. `"escape"`, `"return"`, `"tab"`, `"upArrow"`.
18
+ */
19
19
  readonly name?: keyof Key;
20
20
  /**
21
- * Whether Shift must be held.
22
- */
21
+ * Whether Shift must be held.
22
+ */
23
23
  readonly shift?: boolean;
24
24
  };
25
25
  type UseHotkeyOptions = {
26
26
  /**
27
- * Disable the binding while keeping the component rendered.
28
- * @default true
29
- */
27
+ * Disable the binding while keeping the component rendered.
28
+ * @default true
29
+ */
30
30
  readonly isActive?: boolean;
31
31
  };
32
32
  /**
33
- * Bind a keyboard shortcut to a callback. Accepts either a short string
34
- * (`"ctrl+s"`, `"?"`, `"escape"`) or a structured descriptor.
35
- */
33
+ * Bind a keyboard shortcut to a callback. Accepts either a short string
34
+ * (`"ctrl+s"`, `"?"`, `"escape"`) or a structured descriptor.
35
+ */
36
36
  declare const useHotkey: (shortcut: HotkeyDescriptor | string, callback: () => void, options?: UseHotkeyOptions) => void;
37
37
  export { HotkeyDescriptor, UseHotkeyOptions, useHotkey as default, useHotkey };
@@ -1,149 +1,149 @@
1
1
  /**
2
- * Handy information about a key that was pressed.
3
- */
2
+ * Handy information about a key that was pressed.
3
+ */
4
4
  type Key = {
5
5
  /**
6
- * Backspace key was pressed.
7
- */
6
+ * Backspace key was pressed.
7
+ */
8
8
  backspace: boolean;
9
9
  /**
10
- * Caps Lock is active.
11
- *
12
- * Only available with kitty keyboard protocol.
13
- */
10
+ * Caps Lock is active.
11
+ *
12
+ * Only available with kitty keyboard protocol.
13
+ */
14
14
  capsLock: boolean;
15
15
  /**
16
- * Ctrl key was pressed.
17
- */
16
+ * Ctrl key was pressed.
17
+ */
18
18
  ctrl: boolean;
19
19
  /**
20
- * Delete key was pressed.
21
- */
20
+ * Delete key was pressed.
21
+ */
22
22
  delete: boolean;
23
23
  /**
24
- * Down arrow key was pressed.
25
- */
24
+ * Down arrow key was pressed.
25
+ */
26
26
  downArrow: boolean;
27
27
  /**
28
- * End key was pressed.
29
- */
28
+ * End key was pressed.
29
+ */
30
30
  end: boolean;
31
31
  /**
32
- * Escape key was pressed.
33
- */
32
+ * Escape key was pressed.
33
+ */
34
34
  escape: boolean;
35
35
  /**
36
- * Event type for key events.
37
- *
38
- * Only available with kitty keyboard protocol.
39
- */
36
+ * Event type for key events.
37
+ *
38
+ * Only available with kitty keyboard protocol.
39
+ */
40
40
  eventType?: "press" | "repeat" | "release";
41
41
  /**
42
- * Home key was pressed.
43
- */
42
+ * Home key was pressed.
43
+ */
44
44
  home: boolean;
45
45
  /**
46
- * Hyper key was pressed.
47
- *
48
- * Only available with kitty keyboard protocol.
49
- */
46
+ * Hyper key was pressed.
47
+ *
48
+ * Only available with kitty keyboard protocol.
49
+ */
50
50
  hyper: boolean;
51
51
  /**
52
- * Left arrow key was pressed.
53
- */
52
+ * Left arrow key was pressed.
53
+ */
54
54
  leftArrow: boolean;
55
55
  /**
56
- * [Meta key](https://en.wikipedia.org/wiki/Meta_key) was pressed.
57
- */
56
+ * [Meta key](https://en.wikipedia.org/wiki/Meta_key) was pressed.
57
+ */
58
58
  meta: boolean;
59
59
  /**
60
- * Num Lock is active.
61
- *
62
- * Only available with kitty keyboard protocol.
63
- */
60
+ * Num Lock is active.
61
+ *
62
+ * Only available with kitty keyboard protocol.
63
+ */
64
64
  numLock: boolean;
65
65
  /**
66
- * Page Down key was pressed.
67
- */
66
+ * Page Down key was pressed.
67
+ */
68
68
  pageDown: boolean;
69
69
  /**
70
- * Page Up key was pressed.
71
- */
70
+ * Page Up key was pressed.
71
+ */
72
72
  pageUp: boolean;
73
73
  /**
74
- * Return (Enter) key was pressed.
75
- */
74
+ * Return (Enter) key was pressed.
75
+ */
76
76
  return: boolean;
77
77
  /**
78
- * Right arrow key was pressed.
79
- */
78
+ * Right arrow key was pressed.
79
+ */
80
80
  rightArrow: boolean;
81
81
  /**
82
- * Shift key was pressed.
83
- */
82
+ * Shift key was pressed.
83
+ */
84
84
  shift: boolean;
85
85
  /**
86
- * Super key (Cmd on Mac, Win on Windows) was pressed.
87
- *
88
- * Only available with kitty keyboard protocol.
89
- */
86
+ * Super key (Cmd on Mac, Win on Windows) was pressed.
87
+ *
88
+ * Only available with kitty keyboard protocol.
89
+ */
90
90
  super: boolean;
91
91
  /**
92
- * Tab key was pressed.
93
- */
92
+ * Tab key was pressed.
93
+ */
94
94
  tab: boolean;
95
95
  /**
96
- * Up arrow key was pressed.
97
- */
96
+ * Up arrow key was pressed.
97
+ */
98
98
  upArrow: boolean;
99
99
  };
100
100
  type Handler = (input: string, key: Key) => void;
101
101
  type Options = {
102
102
  /**
103
- * Enable IME (Input Method Editor) composition buffering for Vietnamese, Chinese,
104
- * Japanese, Korean, and other non-ASCII input methods.
105
- * @default true
106
- */
103
+ * Enable IME (Input Method Editor) composition buffering for Vietnamese, Chinese,
104
+ * Japanese, Korean, and other non-ASCII input methods.
105
+ * @default true
106
+ */
107
107
  imeEnabled?: boolean;
108
108
  /**
109
- * Timeout in milliseconds to wait before flushing IME composition buffer.
110
- * @default 50
111
- */
109
+ * Timeout in milliseconds to wait before flushing IME composition buffer.
110
+ * @default 50
111
+ */
112
112
  imeTimeout?: number;
113
113
  /**
114
- * Enable or disable capturing of user input. Useful when there are multiple `useInput` hooks used at once to avoid handling the same input several times.
115
- * @default true
116
- */
114
+ * Enable or disable capturing of user input. Useful when there are multiple `useInput` hooks used at once to avoid handling the same input several times.
115
+ * @default true
116
+ */
117
117
  isActive?: boolean;
118
118
  };
119
119
  /**
120
- * A React hook that returns `void` and handles user input.
121
- * It's a more convenient alternative to using `StdinContext` and listening for
122
- * `data` events. The callback you pass to `useInput` is called for typed
123
- * characters and key events.
124
- *
125
- * Bracketed paste payloads belong to `usePaste`. If no `usePaste` handler is
126
- * active, Ink still forwards bracketed paste text to `useInput` for backward
127
- * compatibility, but that fallback is deprecated and will be removed in the next
128
- * major version.
129
- *
130
- * ```
131
- * import {useInput} from '@visulima/tui/hooks/use-input';
132
- *
133
- * const UserInput = () => {
134
- * useInput((input, key) => {
135
- * if (input === 'q') {
136
- * // Exit program
137
- * }
138
- *
139
- * if (key.leftArrow) {
140
- * // Left arrow key pressed
141
- * }
142
- * });
143
- *
144
- * return …
145
- * };
146
- * ```
147
- */
120
+ * A React hook that returns `void` and handles user input.
121
+ * It's a more convenient alternative to using `StdinContext` and listening for
122
+ * `data` events. The callback you pass to `useInput` is called for typed
123
+ * characters and key events.
124
+ *
125
+ * Bracketed paste payloads belong to `usePaste`. If no `usePaste` handler is
126
+ * active, Ink still forwards bracketed paste text to `useInput` for backward
127
+ * compatibility, but that fallback is deprecated and will be removed in the next
128
+ * major version.
129
+ *
130
+ * ```
131
+ * import {useInput} from '@visulima/tui/hooks/use-input';
132
+ *
133
+ * const UserInput = () => {
134
+ * useInput((input, key) => {
135
+ * if (input === 'q') {
136
+ * // Exit program
137
+ * }
138
+ *
139
+ * if (key.leftArrow) {
140
+ * // Left arrow key pressed
141
+ * }
142
+ * });
143
+ *
144
+ * return …
145
+ * };
146
+ * ```
147
+ */
148
148
  declare const useInput: (inputHandler: Handler, options?: Options) => void;
149
149
  export { Key, useInput as default, useInput };
@@ -1,2 +1,2 @@
1
- import{createRequire as $}from"node:module";import{useRef as L,useEffectEvent as _,useEffect as g}from"react";import{IMECompositionBuffer as S,isIMEInput as q}from"../../packem_shared/IMECompositionBuffer-VhC9HRCv.js";import{kittyModifiers as p}from"../../packem_shared/kittyFlags-g8ALyoCU.js";import{j as w}from"../../packem_shared/reconciler-CFyBVf7l.js";import{useStdinContext as I}from"./use-stdin.js";const C=$(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,P=e=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[a,n]=m.versions.node.split(".").map(Number);if(a>22||a===22&&n>=3||a===20&&n>=16)return m.getBuiltinModule(e)}return C(e)},{Buffer:E}=P("node:buffer"),j=/^\u001B([a-z0-9])$/i,N=/^\u001B+([ON[]|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,y={"[1~":"home","[2$":"insert","[2^":"insert","[2~":"insert","[3$":"delete","[3^":"delete","[3~":"delete","[4~":"end","[5$":"pageup","[5^":"pageup","[5~":"pageup","[6$":"pagedown","[6^":"pagedown","[6~":"pagedown","[7$":"home","[7^":"home","[7~":"home","[8$":"end","[8^":"end","[8~":"end","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[[5~":"pageup","[[6~":"pagedown","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[A":"up","[a":"up","[B":"down","[b":"down","[C":"right","[c":"right","[D":"left","[d":"left","[E":"clear","[e":"clear","[F":"end","[H":"home","[P":"f1","[Q":"f2","[R":"f3","[S":"f4","[Z":"tab",OA:"up",Oa:"up",OB:"down",Ob:"down",OC:"right",Oc:"right",OD:"left",Od:"left",OE:"clear",Oe:"clear",OF:"end",OH:"home",OP:"f1",OQ:"f2",OR:"f3",OS:"f4"},M=[...Object.values(y),"backspace"],T=e=>["[2$","[3$","[5$","[6$","[7$","[8$","[a","[b","[c","[d","[e","[Z"].includes(e),K=e=>["[2^","[3^","[5^","[6^","[7^","[8^","Oa","Ob","Oc","Od","Oe"].includes(e),B=/^\u001B\[(\d+)(?:;(\d+)(?::(\d+))?(?:;([\d:]+))?)?u$/,R=/^\u001B\[(\d+);(\d+):(\d+)([A-Z~])$/i,Z={A:"up",B:"down",C:"right",D:"left",E:"clear",F:"end",H:"home",P:"f1",Q:"f2",R:"f3",S:"f4"},D={2:"insert",3:"delete",5:"pageup",6:"pagedown",7:"home",8:"end",11:"f1",12:"f2",13:"f3",14:"f4",15:"f5",17:"f6",18:"f7",19:"f8",20:"f9",21:"f10",23:"f11",24:"f12"},v={8:"backspace",9:"tab",27:"escape",127:"backspace",57358:"capslock",57359:"scrolllock",57360:"numlock",57361:"printscreen",57362:"pause",57363:"menu",57376:"f13",57377:"f14",57378:"f15",57379:"f16",57380:"f17",57381:"f18",57382:"f19",57383:"f20",57384:"f21",57385:"f22",57386:"f23",57387:"f24",57388:"f25",57389:"f26",57390:"f27",57391:"f28",57392:"f29",57393:"f30",57394:"f31",57395:"f32",57396:"f33",57397:"f34",57398:"f35",57399:"kp0",57400:"kp1",57401:"kp2",57402:"kp3",57403:"kp4",57404:"kp5",57405:"kp6",57406:"kp7",57407:"kp8",57408:"kp9",57409:"kpdecimal",57410:"kpdivide",57411:"kpmultiply",57412:"kpsubtract",57413:"kpadd",57414:"kpenter",57415:"kpequal",57416:"kpseparator",57417:"kpleft",57418:"kpright",57419:"kpup",57420:"kpdown",57421:"kppageup",57422:"kppagedown",57423:"kphome",57424:"kpend",57425:"kpinsert",57426:"kpdelete",57427:"kpbegin",57428:"mediaplay",57429:"mediapause",57430:"mediaplaypause",57431:"mediareverse",57432:"mediastop",57433:"mediafastforward",57434:"mediarewind",57435:"mediatracknext",57436:"mediatrackprevious",57437:"mediarecord",57438:"lowervolume",57439:"raisevolume",57440:"mutevolume",57441:"leftshift",57442:"leftcontrol",57443:"leftalt",57444:"leftsuper",57445:"lefthyper",57446:"leftmeta",57447:"rightshift",57448:"rightcontrol",57449:"rightalt",57450:"rightsuper",57451:"righthyper",57452:"rightmeta",57453:"isoLevel3Shift",57454:"isoLevel5Shift"},x=e=>e>=0&&e<=1114111&&!(e>=55296&&e<=57343),b=e=>x(e)?String.fromCodePoint(e):"?";function A(e){return e===3?"release":e===2?"repeat":"press"}function O(e){return{capsLock:!!(e&p.capsLock),ctrl:!!(e&p.ctrl),hyper:!!(e&p.hyper),meta:!!(e&p.meta),numLock:!!(e&p.numLock),option:!!(e&p.alt),shift:!!(e&p.shift),super:!!(e&p.super)}}const F=e=>{const a=B.exec(e);if(!a)return null;const n=Number.parseInt(a[1],10),c=a[2]?Math.max(0,Number.parseInt(a[2],10)-1):0,t=a[3]?Number.parseInt(a[3],10):1,l=a[4];if(!x(n))return null;let s;l&&(s=l.split(":").map(d=>b(Number.parseInt(d,10))).join(""));let o,i;return n===32?(o="space",i=!0):n===13?(o="return",i=!0):v[n]?(o=v[n],i=!1):n>=1&&n<=26?(o=String.fromCodePoint(n+96),i=!1):(o=b(n).toLowerCase(),i=!0),i&&!s&&(s=b(n)),{name:o,...O(c),eventType:A(t),isKittyProtocol:!0,isPrintable:i,raw:e,sequence:e,text:s}},U=e=>{const a=R.exec(e);if(!a)return null;const n=Number.parseInt(a[1],10),c=Math.max(0,Number.parseInt(a[2],10)-1),t=Number.parseInt(a[3],10),l=a[4],s=l==="~"?D[n]:Z[l];return s?{name:s,...O(c),eventType:A(t),isKittyProtocol:!0,isPrintable:!1,raw:e,sequence:e}:null},z=(e="")=>{let a;E.isBuffer(e)?e[0]>127&&e[1]===void 0?(e[0]-=128,e=`\x1B${String(e)}`):e=String(e):e!==void 0&&typeof e!="string"?e=String(e):e||(e="");const n=F(e);if(n)return n;const c=U(e);if(c)return c;if(B.test(e))return{ctrl:!1,isKittyProtocol:!0,isPrintable:!1,meta:!1,name:"",option:!1,raw:e,sequence:e,shift:!1};const t={ctrl:!1,meta:!1,name:"",option:!1,raw:e,sequence:e,shift:!1};switch(t.sequence=t.sequence||e||t.name,e){case"\r":case"\x1B\r":{t.raw=void 0,t.name="return",t.option=e.length===2;break}case`
2
- `:{t.name="enter";break}case" ":{t.name="tab";break}case" ":case"\x1B ":{t.name="space",t.meta=e.length===2;break}case"\b":case"\x1B\b":{t.name="backspace",t.meta=e.charAt(0)==="\x1B";break}case"\x1B":case"\x1B\x1B":{t.name="escape",t.meta=e.length===2;break}case"\x1B":case"":{t.name="backspace",t.meta=e.charAt(0)==="\x1B";break}default:if(e.length===1&&e<="")t.name=String.fromCharCode(e.charCodeAt(0)+97-1),t.ctrl=!0;else if(e.length===1&&e>="0"&&e<="9")t.name="number";else if(e.length===1&&e>="a"&&e<="z")t.name=e;else if(e.length===1&&e>="A"&&e<="Z")t.name=e.toLowerCase(),t.shift=!0;else if(a=j.exec(e))t.meta=!0,t.shift=/^[A-Z]$/.test(a[1]);else if(a=N.exec(e)){const l=[...e];l[0]==="\x1B"&&l[1]==="\x1B"&&(t.option=!0);const s=[a[1],a[2],a[4],a[6]].filter(Boolean).join(""),o=(a[3]||a[5]||1)-1;t.ctrl=!!(o&4),t.meta=!!(o&10),t.shift=!!(o&1),t.code=s,t.name=y[s]??"",t.shift=T(s)||t.shift,t.ctrl=K(s)||t.ctrl}}return t},X=(e,a={})=>{const{internal_eventEmitter:n,internal_exitOnCtrlC:c,setRawMode:t,stdin:l}=I(),s=a.imeEnabled??!0,o=a.imeTimeout??50,i=L(void 0),d=_(e);g(()=>{if(s)return i.current=new S({onFlush:h=>{const u={backspace:!1,capsLock:!1,ctrl:!1,delete:!1,downArrow:!1,end:!1,escape:!1,home:!1,hyper:!1,leftArrow:!1,meta:!1,numLock:!1,pageDown:!1,pageUp:!1,return:!1,rightArrow:!1,shift:!1,super:!1,tab:!1,upArrow:!1};w.discreteUpdates(()=>{d(h,u)})},timeout:o}),()=>{i.current?.destroy(),i.current=void 0}},[s,o]),g(()=>{if(a.isActive!==!1)return t(!0),()=>{t(!1)}},[a.isActive,t]),g(()=>{if(a.isActive===!1)return;const h=u=>{if(s&&q(u)){i.current?.add(u);return}i.current?.flush();const r=z(u),k={backspace:r.name==="backspace",capsLock:r.capsLock??!1,ctrl:r.ctrl,delete:r.name==="delete",downArrow:r.name==="down",end:r.name==="end",escape:r.name==="escape",eventType:r.eventType,home:r.name==="home",hyper:r.hyper??!1,leftArrow:r.name==="left",meta:r.meta||r.option,numLock:r.numLock??!1,pageDown:r.name==="pagedown",pageUp:r.name==="pageup",return:r.name==="return",rightArrow:r.name==="right",shift:r.shift,super:r.super??!1,tab:r.name==="tab",upArrow:r.name==="up"};let f;r.isKittyProtocol?r.isPrintable?f=r.text??r.name:r.ctrl&&r.name.length===1?f=r.name:f="":r.ctrl?f=r.name:f=r.sequence,!r.isKittyProtocol&&M.includes(r.name)&&(f=""),f.startsWith("\x1B")&&(f=f.slice(1)),f.length===1&&typeof f[0]=="string"&&/[A-Z]/.test(f[0])&&(k.shift=!0),!(f==="c"&&k.ctrl&&c)&&(!r.name&&f===""||w.discreteUpdates(()=>{d(f,k)}))};return n.on("input",h),()=>{n.removeListener("input",h)}},[a.isActive,l,c,s])};export{X as default,X as useInput};
1
+ import{createRequire as $}from"node:module";import{useRef as P,useEffectEvent as q,useEffect as b,useLayoutEffect as E}from"react";import{IMECompositionBuffer as S,isIMEInput as I}from"../../packem_shared/IMECompositionBuffer-VhC9HRCv.js";import{kittyModifiers as p}from"../../packem_shared/kittyFlags-g8ALyoCU.js";import{j as w}from"../../packem_shared/reconciler-DkwOtC5B.js";import{useStdinContext as N}from"./use-stdin.js";let _;const C=e=>(_??=$(import.meta.url))(e),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,L=e=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[a,s]=m.versions.node.split(".").map(Number);if(a>22||a===22&&s>=3||a===20&&s>=16)return m.getBuiltinModule(e)}return C(e)},{Buffer:j}=L("node:buffer"),M=/^\u001B([a-z0-9])$/i,R=/^\u001B+([ON[]|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,y={"[1~":"home","[2$":"insert","[2^":"insert","[2~":"insert","[3$":"delete","[3^":"delete","[3~":"delete","[4~":"end","[5$":"pageup","[5^":"pageup","[5~":"pageup","[6$":"pagedown","[6^":"pagedown","[6~":"pagedown","[7$":"home","[7^":"home","[7~":"home","[8$":"end","[8^":"end","[8~":"end","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[[5~":"pageup","[[6~":"pagedown","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[A":"up","[a":"up","[B":"down","[b":"down","[C":"right","[c":"right","[D":"left","[d":"left","[E":"clear","[e":"clear","[F":"end","[H":"home","[P":"f1","[Q":"f2","[R":"f3","[S":"f4","[Z":"tab",OA:"up",Oa:"up",OB:"down",Ob:"down",OC:"right",Oc:"right",OD:"left",Od:"left",OE:"clear",Oe:"clear",OF:"end",OH:"home",OP:"f1",OQ:"f2",OR:"f3",OS:"f4"},T=[...Object.values(y),"backspace"],K=e=>["[2$","[3$","[5$","[6$","[7$","[8$","[a","[b","[c","[d","[e","[Z"].includes(e),Z=e=>["[2^","[3^","[5^","[6^","[7^","[8^","Oa","Ob","Oc","Od","Oe"].includes(e),B=/^\u001B\[(\d+)(?:;(\d+)(?::(\d+))?(?:;([\d:]+))?)?u$/,D=/^\u001B\[(\d+);(\d+):(\d+)([A-Z~])$/i,F={A:"up",B:"down",C:"right",D:"left",E:"clear",F:"end",H:"home",P:"f1",Q:"f2",R:"f3",S:"f4"},U={2:"insert",3:"delete",5:"pageup",6:"pagedown",7:"home",8:"end",11:"f1",12:"f2",13:"f3",14:"f4",15:"f5",17:"f6",18:"f7",19:"f8",20:"f9",21:"f10",23:"f11",24:"f12"},v={8:"backspace",9:"tab",27:"escape",127:"backspace",57358:"capslock",57359:"scrolllock",57360:"numlock",57361:"printscreen",57362:"pause",57363:"menu",57376:"f13",57377:"f14",57378:"f15",57379:"f16",57380:"f17",57381:"f18",57382:"f19",57383:"f20",57384:"f21",57385:"f22",57386:"f23",57387:"f24",57388:"f25",57389:"f26",57390:"f27",57391:"f28",57392:"f29",57393:"f30",57394:"f31",57395:"f32",57396:"f33",57397:"f34",57398:"f35",57399:"kp0",57400:"kp1",57401:"kp2",57402:"kp3",57403:"kp4",57404:"kp5",57405:"kp6",57406:"kp7",57407:"kp8",57408:"kp9",57409:"kpdecimal",57410:"kpdivide",57411:"kpmultiply",57412:"kpsubtract",57413:"kpadd",57414:"kpenter",57415:"kpequal",57416:"kpseparator",57417:"kpleft",57418:"kpright",57419:"kpup",57420:"kpdown",57421:"kppageup",57422:"kppagedown",57423:"kphome",57424:"kpend",57425:"kpinsert",57426:"kpdelete",57427:"kpbegin",57428:"mediaplay",57429:"mediapause",57430:"mediaplaypause",57431:"mediareverse",57432:"mediastop",57433:"mediafastforward",57434:"mediarewind",57435:"mediatracknext",57436:"mediatrackprevious",57437:"mediarecord",57438:"lowervolume",57439:"raisevolume",57440:"mutevolume",57441:"leftshift",57442:"leftcontrol",57443:"leftalt",57444:"leftsuper",57445:"lefthyper",57446:"leftmeta",57447:"rightshift",57448:"rightcontrol",57449:"rightalt",57450:"rightsuper",57451:"righthyper",57452:"rightmeta",57453:"isoLevel3Shift",57454:"isoLevel5Shift"},x=e=>e>=0&&e<=1114111&&!(e>=55296&&e<=57343),g=e=>x(e)?String.fromCodePoint(e):"?";function A(e){return e===3?"release":e===2?"repeat":"press"}function O(e){return{capsLock:!!(e&p.capsLock),ctrl:!!(e&p.ctrl),hyper:!!(e&p.hyper),meta:!!(e&p.meta),numLock:!!(e&p.numLock),option:!!(e&p.alt),shift:!!(e&p.shift),super:!!(e&p.super)}}const z=e=>{const a=B.exec(e);if(!a)return null;const s=Number.parseInt(a[1],10),c=a[2]?Math.max(0,Number.parseInt(a[2],10)-1):0,t=a[3]?Number.parseInt(a[3],10):1,l=a[4];if(!x(s))return null;let n;l&&(n=l.split(":").map(d=>g(Number.parseInt(d,10))).join(""));let o,i;return s===32?(o="space",i=!0):s===13?(o="return",i=!0):v[s]?(o=v[s],i=!1):s>=1&&s<=26?(o=String.fromCodePoint(s+96),i=!1):(o=g(s).toLowerCase(),i=!0),i&&!n&&(n=g(s)),{name:o,...O(c),eventType:A(t),isKittyProtocol:!0,isPrintable:i,raw:e,sequence:e,text:n}},H=e=>{const a=D.exec(e);if(!a)return null;const s=Number.parseInt(a[1],10),c=Math.max(0,Number.parseInt(a[2],10)-1),t=Number.parseInt(a[3],10),l=a[4],n=l==="~"?U[s]:F[l];return n?{name:n,...O(c),eventType:A(t),isKittyProtocol:!0,isPrintable:!1,raw:e,sequence:e}:null},Q=(e="")=>{let a;j.isBuffer(e)?e[0]>127&&e[1]===void 0?(e[0]-=128,e=`\x1B${String(e)}`):e=String(e):e!==void 0&&typeof e!="string"?e=String(e):e||(e="");const s=z(e);if(s)return s;const c=H(e);if(c)return c;if(B.test(e))return{ctrl:!1,isKittyProtocol:!0,isPrintable:!1,meta:!1,name:"",option:!1,raw:e,sequence:e,shift:!1};const t={ctrl:!1,meta:!1,name:"",option:!1,raw:e,sequence:e,shift:!1};switch(t.sequence=t.sequence||e||t.name,e){case"\r":case"\x1B\r":{t.raw=void 0,t.name="return",t.option=e.length===2;break}case`
2
+ `:{t.name="enter";break}case" ":{t.name="tab";break}case" ":case"\x1B ":{t.name="space",t.meta=e.length===2;break}case"\b":case"\x1B\b":{t.name="backspace",t.meta=e.charAt(0)==="\x1B";break}case"\x1B":case"\x1B\x1B":{t.name="escape",t.meta=e.length===2;break}case"\x1B":case"":{t.name="backspace",t.meta=e.charAt(0)==="\x1B";break}default:if(e.length===1&&e<="")t.name=String.fromCharCode(e.charCodeAt(0)+97-1),t.ctrl=!0;else if(e.length===1&&e>="0"&&e<="9")t.name="number";else if(e.length===1&&e>="a"&&e<="z")t.name=e;else if(e.length===1&&e>="A"&&e<="Z")t.name=e.toLowerCase(),t.shift=!0;else if(a=M.exec(e))t.meta=!0,t.shift=/^[A-Z]$/.test(a[1]);else if(a=R.exec(e)){const l=[...e];l[0]==="\x1B"&&l[1]==="\x1B"&&(t.option=!0);const n=[a[1],a[2],a[4],a[6]].filter(Boolean).join(""),o=(a[3]||a[5]||1)-1;t.ctrl=!!(o&4),t.meta=!!(o&10),t.shift=!!(o&1),t.code=n,t.name=y[n]??"",t.shift=K(n)||t.shift,t.ctrl=Z(n)||t.ctrl}}return t},ee=(e,a={})=>{const{internal_eventEmitter:s,internal_exitOnCtrlC:c,setRawMode:t,stdin:l}=N(),n=a.imeEnabled??!0,o=a.imeTimeout??50,i=P(void 0),d=q(e);b(()=>{if(n)return i.current=new S({onFlush:h=>{const u={backspace:!1,capsLock:!1,ctrl:!1,delete:!1,downArrow:!1,end:!1,escape:!1,home:!1,hyper:!1,leftArrow:!1,meta:!1,numLock:!1,pageDown:!1,pageUp:!1,return:!1,rightArrow:!1,shift:!1,super:!1,tab:!1,upArrow:!1};w.discreteUpdates(()=>{d(h,u)})},timeout:o}),()=>{i.current?.destroy(),i.current=void 0}},[n,o]),b(()=>{if(a.isActive!==!1)return t(!0),()=>{t(!1)}},[a.isActive,t]),E(()=>{if(a.isActive===!1)return;const h=u=>{if(n&&I(u)){i.current?.add(u);return}i.current?.flush();const r=Q(u),k={backspace:r.name==="backspace",capsLock:r.capsLock??!1,ctrl:r.ctrl,delete:r.name==="delete",downArrow:r.name==="down",end:r.name==="end",escape:r.name==="escape",eventType:r.eventType,home:r.name==="home",hyper:r.hyper??!1,leftArrow:r.name==="left",meta:r.meta||r.option,numLock:r.numLock??!1,pageDown:r.name==="pagedown",pageUp:r.name==="pageup",return:r.name==="return",rightArrow:r.name==="right",shift:r.shift,super:r.super??!1,tab:r.name==="tab",upArrow:r.name==="up"};let f;r.isKittyProtocol?r.isPrintable?f=r.text??r.name:r.ctrl&&r.name.length===1?f=r.name:f="":r.ctrl?f=r.name:f=r.sequence,!r.isKittyProtocol&&T.includes(r.name)&&(f=""),f.startsWith("\x1B")&&(f=f.slice(1)),f.length===1&&typeof f[0]=="string"&&/[A-Z]/.test(f[0])&&(k.shift=!0),!(f==="c"&&k.ctrl&&c)&&(!r.name&&f===""||w.discreteUpdates(()=>{d(f,k)}))};return s.on("input",h),()=>{s.removeListener("input",h)}},[a.isActive,l,c,n])};export{ee as default,ee as useInput};
@@ -1,25 +1,25 @@
1
1
  type UseIntervalOptions = {
2
2
  /**
3
- * When false, the timer is paused. Flipping back to true restarts it.
4
- * @default true
5
- */
3
+ * When false, the timer is paused. Flipping back to true restarts it.
4
+ * @default true
5
+ */
6
6
  readonly isActive?: boolean;
7
7
  };
8
8
  type UseIntervalResult = {
9
9
  /**
10
- * Cancel the currently-running timer. The hook effect will reschedule on
11
- * the next re-render if `isActive` remains true.
12
- */
10
+ * Cancel the currently-running timer. The hook effect will reschedule on
11
+ * the next re-render if `isActive` remains true.
12
+ */
13
13
  readonly clear: () => void;
14
14
  };
15
15
  /**
16
- * A React hook that invokes `callback` every `interval` ms. The callback
17
- * reference is captured in a ref so it always sees the latest closure; only
18
- * `interval` and `isActive` cause the timer to be rebuilt.
19
- * @param callback Invoked on every tick. Latest closure is captured in a ref.
20
- * @param interval Tick period in milliseconds. Invalid values pause the timer.
21
- * @param options Optional `isActive` flag to pause without unmounting.
22
- * @returns A stable object with a `clear()` method to cancel on demand.
23
- */
16
+ * A React hook that invokes `callback` every `interval` ms. The callback
17
+ * reference is captured in a ref so it always sees the latest closure; only
18
+ * `interval` and `isActive` cause the timer to be rebuilt.
19
+ * @param callback Invoked on every tick. Latest closure is captured in a ref.
20
+ * @param interval Tick period in milliseconds. Invalid values pause the timer.
21
+ * @param options Optional `isActive` flag to pause without unmounting.
22
+ * @returns A stable object with a `clear()` method to cancel on demand.
23
+ */
24
24
  declare const useInterval: (callback: () => void, interval: number, options?: UseIntervalOptions) => UseIntervalResult;
25
25
  export { UseIntervalOptions, UseIntervalResult, useInterval as default, useInterval };
@@ -1,6 +1,6 @@
1
1
  /**
2
- * A React hook that returns whether a screen reader is enabled.
3
- * This is useful when you want to render different output for screen readers.
4
- */
2
+ * A React hook that returns whether a screen reader is enabled.
3
+ * This is useful when you want to render different output for screen readers.
4
+ */
5
5
  declare const useIsScreenReaderEnabled: () => boolean;
6
6
  export { useIsScreenReaderEnabled as default, useIsScreenReaderEnabled };