@visulima/tui 1.0.0-alpha.4 → 1.0.0-alpha.6

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 (249) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/LICENSE.md +140 -0
  3. package/dist/core/index.d.ts +58 -5
  4. package/dist/ink/index.d.ts +6592 -294
  5. package/dist/ink/index.js +1 -1
  6. package/dist/packem_shared/{Histogram-cgAjY5AJ.js → Histogram-CB6XcmZW.js} +1 -1
  7. package/dist/packem_shared/input.d-Bfq7oc06.d.ts +90 -0
  8. package/dist/packem_shared/render.d-BR3gA-N8.d.ts +1257 -0
  9. package/dist/react/index.d.ts +519 -8
  10. package/dist/testing/index.d.ts +274 -135
  11. package/package.json +16 -17
  12. package/dist/core/app.d.ts +0 -50
  13. package/dist/core/cell.d.ts +0 -33
  14. package/dist/core/inline.d.ts +0 -22
  15. package/dist/core/input.d.ts +0 -18
  16. package/dist/core/native-binding.d.ts +0 -22
  17. package/dist/ink/ansi-to-cell.d.ts +0 -5
  18. package/dist/ink/ansi-tokenizer.d.ts +0 -38
  19. package/dist/ink/canvas/braille.d.ts +0 -22
  20. package/dist/ink/canvas/buffer.d.ts +0 -67
  21. package/dist/ink/clipboard.d.ts +0 -29
  22. package/dist/ink/color-matrix.d.ts +0 -49
  23. package/dist/ink/color-utils.d.ts +0 -30
  24. package/dist/ink/colorize.d.ts +0 -4
  25. package/dist/ink/components/accessibility-context.d.ts +0 -4
  26. package/dist/ink/components/accordion.d.ts +0 -52
  27. package/dist/ink/components/alert.d.ts +0 -30
  28. package/dist/ink/components/animate-presence.d.ts +0 -15
  29. package/dist/ink/components/animation-context.d.ts +0 -10
  30. package/dist/ink/components/app-context.d.ts +0 -38
  31. package/dist/ink/components/app.d.ts +0 -19
  32. package/dist/ink/components/approval-prompt.d.ts +0 -55
  33. package/dist/ink/components/area-chart.d.ts +0 -54
  34. package/dist/ink/components/background-context.d.ts +0 -5
  35. package/dist/ink/components/badge.d.ts +0 -27
  36. package/dist/ink/components/bar-chart.d.ts +0 -57
  37. package/dist/ink/components/big-text.d.ts +0 -71
  38. package/dist/ink/components/blink-dot.d.ts +0 -30
  39. package/dist/ink/components/box.d.ts +0 -58
  40. package/dist/ink/components/breadcrumb.d.ts +0 -28
  41. package/dist/ink/components/button.d.ts +0 -38
  42. package/dist/ink/components/calendar.d.ts +0 -60
  43. package/dist/ink/components/canvas.d.ts +0 -38
  44. package/dist/ink/components/card.d.ts +0 -46
  45. package/dist/ink/components/chart-utils.d.ts +0 -54
  46. package/dist/ink/components/checkbox.d.ts +0 -39
  47. package/dist/ink/components/code.d.ts +0 -46
  48. package/dist/ink/components/collapsible.d.ts +0 -43
  49. package/dist/ink/components/command-block.d.ts +0 -38
  50. package/dist/ink/components/command-palette.d.ts +0 -72
  51. package/dist/ink/components/confirm-dialog.d.ts +0 -63
  52. package/dist/ink/components/confirm-input.d.ts +0 -40
  53. package/dist/ink/components/console-overlay.d.ts +0 -52
  54. package/dist/ink/components/content-switcher.d.ts +0 -49
  55. package/dist/ink/components/cursor-context.d.ts +0 -12
  56. package/dist/ink/components/cursor.d.ts +0 -43
  57. package/dist/ink/components/date-picker.d.ts +0 -53
  58. package/dist/ink/components/definition-list.d.ts +0 -37
  59. package/dist/ink/components/dialog.d.ts +0 -93
  60. package/dist/ink/components/diff-view.d.ts +0 -71
  61. package/dist/ink/components/divider.d.ts +0 -40
  62. package/dist/ink/components/error-boundary.d.ts +0 -17
  63. package/dist/ink/components/error-overview.d.ts +0 -6
  64. package/dist/ink/components/file-picker/file-picker.d.ts +0 -58
  65. package/dist/ink/components/file-picker/types.d.ts +0 -35
  66. package/dist/ink/components/file-picker/use-file-system.d.ts +0 -16
  67. package/dist/ink/components/focus-context.d.ts +0 -17
  68. package/dist/ink/components/form.d.ts +0 -74
  69. package/dist/ink/components/gauge.d.ts +0 -75
  70. package/dist/ink/components/gradient.d.ts +0 -38
  71. package/dist/ink/components/heading.d.ts +0 -27
  72. package/dist/ink/components/heatmap.d.ts +0 -51
  73. package/dist/ink/components/help.d.ts +0 -44
  74. package/dist/ink/components/histogram.d.ts +0 -52
  75. package/dist/ink/components/kbd.d.ts +0 -27
  76. package/dist/ink/components/line-chart.d.ts +0 -94
  77. package/dist/ink/components/link.d.ts +0 -34
  78. package/dist/ink/components/loading-indicator.d.ts +0 -24
  79. package/dist/ink/components/markdown.d.ts +0 -34
  80. package/dist/ink/components/masked-input.d.ts +0 -41
  81. package/dist/ink/components/menu.d.ts +0 -70
  82. package/dist/ink/components/message-bubble.d.ts +0 -35
  83. package/dist/ink/components/model-badge.d.ts +0 -32
  84. package/dist/ink/components/multi-select.d.ts +0 -63
  85. package/dist/ink/components/newline.d.ts +0 -12
  86. package/dist/ink/components/operation-tree.d.ts +0 -46
  87. package/dist/ink/components/option-list.d.ts +0 -41
  88. package/dist/ink/components/ordered-list.d.ts +0 -30
  89. package/dist/ink/components/paginator.d.ts +0 -59
  90. package/dist/ink/components/paragraph.d.ts +0 -31
  91. package/dist/ink/components/placeholder.d.ts +0 -47
  92. package/dist/ink/components/progress-bar.d.ts +0 -51
  93. package/dist/ink/components/radio-group.d.ts +0 -62
  94. package/dist/ink/components/scatter-plot.d.ts +0 -23
  95. package/dist/ink/components/scroll/controlled-scroll-view.d.ts +0 -43
  96. package/dist/ink/components/scroll/index.d.ts +0 -10
  97. package/dist/ink/components/scroll/scroll-bar-box.d.ts +0 -15
  98. package/dist/ink/components/scroll/scroll-bar.d.ts +0 -20
  99. package/dist/ink/components/scroll/scroll-list.d.ts +0 -12
  100. package/dist/ink/components/scroll/scroll-view.d.ts +0 -98
  101. package/dist/ink/components/scroll/use-state-ref.d.ts +0 -8
  102. package/dist/ink/components/search-input.d.ts +0 -46
  103. package/dist/ink/components/select-input-indicator.d.ts +0 -36
  104. package/dist/ink/components/select-input-item.d.ts +0 -43
  105. package/dist/ink/components/select-input.d.ts +0 -96
  106. package/dist/ink/components/shimmer-text.d.ts +0 -39
  107. package/dist/ink/components/slider.d.ts +0 -92
  108. package/dist/ink/components/spacer.d.ts +0 -7
  109. package/dist/ink/components/sparkline.d.ts +0 -30
  110. package/dist/ink/components/spinner.d.ts +0 -40
  111. package/dist/ink/components/static-render.d.ts +0 -40
  112. package/dist/ink/components/static.d.ts +0 -24
  113. package/dist/ink/components/status-line.d.ts +0 -30
  114. package/dist/ink/components/status-message.d.ts +0 -26
  115. package/dist/ink/components/stderr-context.d.ts +0 -16
  116. package/dist/ink/components/stdin-context.d.ts +0 -29
  117. package/dist/ink/components/stdout-context.d.ts +0 -16
  118. package/dist/ink/components/stepper.d.ts +0 -42
  119. package/dist/ink/components/stopwatch.d.ts +0 -42
  120. package/dist/ink/components/streaming-text.d.ts +0 -38
  121. package/dist/ink/components/switch.d.ts +0 -46
  122. package/dist/ink/components/tab.d.ts +0 -25
  123. package/dist/ink/components/table.d.ts +0 -80
  124. package/dist/ink/components/tabs.d.ts +0 -104
  125. package/dist/ink/components/tag.d.ts +0 -30
  126. package/dist/ink/components/text-input.d.ts +0 -48
  127. package/dist/ink/components/text.d.ts +0 -63
  128. package/dist/ink/components/textarea.d.ts +0 -62
  129. package/dist/ink/components/timer.d.ts +0 -50
  130. package/dist/ink/components/toast.d.ts +0 -41
  131. package/dist/ink/components/tooltip.d.ts +0 -36
  132. package/dist/ink/components/transform.d.ts +0 -16
  133. package/dist/ink/components/transition.d.ts +0 -53
  134. package/dist/ink/components/tree-view/theme.d.ts +0 -24
  135. package/dist/ink/components/tree-view/tree-node-map.d.ts +0 -72
  136. package/dist/ink/components/tree-view/tree-view-node.d.ts +0 -29
  137. package/dist/ink/components/tree-view/tree-view.d.ts +0 -89
  138. package/dist/ink/components/tree-view/types.d.ts +0 -55
  139. package/dist/ink/components/tree-view/use-tree-view-state.d.ts +0 -135
  140. package/dist/ink/components/tree-view/use-tree-view.d.ts +0 -26
  141. package/dist/ink/components/unordered-list.d.ts +0 -35
  142. package/dist/ink/components/variant-config.d.ts +0 -10
  143. package/dist/ink/cursor-helpers.d.ts +0 -35
  144. package/dist/ink/data-limited-lru-map.d.ts +0 -21
  145. package/dist/ink/devtools-window-polyfill.d.ts +0 -1
  146. package/dist/ink/devtools.d.ts +0 -1
  147. package/dist/ink/dom.d.ts +0 -214
  148. package/dist/ink/get-max-width.d.ts +0 -3
  149. package/dist/ink/highlighter.d.ts +0 -28
  150. package/dist/ink/hooks/use-animation.d.ts +0 -41
  151. package/dist/ink/hooks/use-app.d.ts +0 -6
  152. package/dist/ink/hooks/use-box-metrics.d.ts +0 -58
  153. package/dist/ink/hooks/use-clipboard.d.ts +0 -29
  154. package/dist/ink/hooks/use-color-blindness.d.ts +0 -33
  155. package/dist/ink/hooks/use-console-capture.d.ts +0 -43
  156. package/dist/ink/hooks/use-cursor.d.ts +0 -12
  157. package/dist/ink/hooks/use-focus-manager.d.ts +0 -42
  158. package/dist/ink/hooks/use-focus.d.ts +0 -30
  159. package/dist/ink/hooks/use-form.d.ts +0 -70
  160. package/dist/ink/hooks/use-hotkey.d.ts +0 -37
  161. package/dist/ink/hooks/use-input.d.ts +0 -149
  162. package/dist/ink/hooks/use-interval.d.ts +0 -25
  163. package/dist/ink/hooks/use-is-screen-reader-enabled.d.ts +0 -6
  164. package/dist/ink/hooks/use-key-bindings.d.ts +0 -59
  165. package/dist/ink/hooks/use-key-chord.d.ts +0 -26
  166. package/dist/ink/hooks/use-linked-scroll.d.ts +0 -41
  167. package/dist/ink/hooks/use-paste.d.ts +0 -44
  168. package/dist/ink/hooks/use-persistent-state.d.ts +0 -56
  169. package/dist/ink/hooks/use-scroll-acceleration.d.ts +0 -47
  170. package/dist/ink/hooks/use-scroll-input.d.ts +0 -34
  171. package/dist/ink/hooks/use-stderr.d.ts +0 -6
  172. package/dist/ink/hooks/use-stdin.d.ts +0 -7
  173. package/dist/ink/hooks/use-stdout.d.ts +0 -6
  174. package/dist/ink/hooks/use-stopwatch.d.ts +0 -38
  175. package/dist/ink/hooks/use-terminal-palette.d.ts +0 -19
  176. package/dist/ink/hooks/use-text-buffer.d.ts +0 -42
  177. package/dist/ink/hooks/use-text-selection.d.ts +0 -45
  178. package/dist/ink/hooks/use-timeout.d.ts +0 -24
  179. package/dist/ink/hooks/use-timer.d.ts +0 -47
  180. package/dist/ink/hooks/use-window-size.d.ts +0 -18
  181. package/dist/ink/ime-utils.d.ts +0 -25
  182. package/dist/ink/ink.d.ts +0 -190
  183. package/dist/ink/input-parser.d.ts +0 -10
  184. package/dist/ink/input-utils.d.ts +0 -16
  185. package/dist/ink/instances.d.ts +0 -3
  186. package/dist/ink/kitty-keyboard.d.ts +0 -23
  187. package/dist/ink/layout.d.ts +0 -26
  188. package/dist/ink/log-update-native.d.ts +0 -14
  189. package/dist/ink/log-update.d.ts +0 -21
  190. package/dist/ink/measure-element.d.ts +0 -147
  191. package/dist/ink/measure-text.d.ts +0 -56
  192. package/dist/ink/mouse/ansi-parser.d.ts +0 -37
  193. package/dist/ink/mouse/constants.d.ts +0 -14
  194. package/dist/ink/mouse/fullscreen.d.ts +0 -8
  195. package/dist/ink/mouse/index.d.ts +0 -20
  196. package/dist/ink/mouse/is-intersecting.d.ts +0 -18
  197. package/dist/ink/mouse/mouse-context.d.ts +0 -36
  198. package/dist/ink/mouse/mouse-provider.d.ts +0 -11
  199. package/dist/ink/mouse/use-element-position.d.ts +0 -29
  200. package/dist/ink/mouse/use-mouse-action.d.ts +0 -7
  201. package/dist/ink/mouse/use-mouse-position.d.ts +0 -7
  202. package/dist/ink/mouse/use-mouse.d.ts +0 -7
  203. package/dist/ink/mouse/use-on-mouse-click.d.ts +0 -14
  204. package/dist/ink/mouse/use-on-mouse-hover.d.ts +0 -8
  205. package/dist/ink/mouse/use-on-mouse-state.d.ts +0 -11
  206. package/dist/ink/output.d.ts +0 -75
  207. package/dist/ink/parse-keypress.d.ts +0 -22
  208. package/dist/ink/reconciler.d.ts +0 -3
  209. package/dist/ink/region.d.ts +0 -99
  210. package/dist/ink/render-background.d.ts +0 -4
  211. package/dist/ink/render-border.d.ts +0 -4
  212. package/dist/ink/render-node-to-output.d.ts +0 -38
  213. package/dist/ink/render-scrollbar.d.ts +0 -9
  214. package/dist/ink/render-sticky.d.ts +0 -44
  215. package/dist/ink/render-to-string.d.ts +0 -37
  216. package/dist/ink/render.d.ts +0 -191
  217. package/dist/ink/renderer.d.ts +0 -17
  218. package/dist/ink/resize-observer.d.ts +0 -44
  219. package/dist/ink/sanitize-ansi.d.ts +0 -2
  220. package/dist/ink/scroll.d.ts +0 -23
  221. package/dist/ink/selection.d.ts +0 -70
  222. package/dist/ink/squash-text-nodes.d.ts +0 -18
  223. package/dist/ink/style-flags.d.ts +0 -17
  224. package/dist/ink/styled-line-factory.d.ts +0 -25
  225. package/dist/ink/styled-line-serializer.d.ts +0 -18
  226. package/dist/ink/styled-line.d.ts +0 -119
  227. package/dist/ink/styles.d.ts +0 -369
  228. package/dist/ink/terminal-palette.d.ts +0 -25
  229. package/dist/ink/text-wrap.d.ts +0 -10
  230. package/dist/ink/token-to-elements.d.ts +0 -22
  231. package/dist/ink/utils/format-time.d.ts +0 -4
  232. package/dist/ink/utils.d.ts +0 -9
  233. package/dist/ink/wrap-text.d.ts +0 -3
  234. package/dist/ink/write-synchronized.d.ts +0 -4
  235. package/dist/react/devtools.d.ts +0 -27
  236. package/dist/react/focus.d.ts +0 -39
  237. package/dist/react/hooks.d.ts +0 -238
  238. package/dist/react/layout.d.ts +0 -33
  239. package/dist/react/react.d.ts +0 -57
  240. package/dist/react/reconciler.d.ts +0 -4
  241. package/dist/react/render-to-string.d.ts +0 -21
  242. package/dist/react/renderer.d.ts +0 -2
  243. package/dist/react/scene.d.ts +0 -3
  244. package/dist/react/static.d.ts +0 -39
  245. package/dist/react/styles.d.ts +0 -83
  246. package/dist/react/text-width.d.ts +0 -20
  247. package/dist/testing/keys.d.ts +0 -89
  248. package/dist/testing/screen.d.ts +0 -35
  249. package/dist/testing/wait-for.d.ts +0 -20
@@ -1,30 +0,0 @@
1
- type Input = {
2
- /**
3
- * Auto-focus this component if there's no active (focused) component right now.
4
- */
5
- autoFocus?: boolean;
6
- /**
7
- * Assign an ID to this component, so it can be programmatically focused with `focus(id)`.
8
- */
9
- id?: string;
10
- /**
11
- * Enable or disable this component's focus, while still maintaining its position in the list of focusable components.
12
- */
13
- isActive?: boolean;
14
- };
15
- type Output = {
16
- /**
17
- * Allows focusing a specific element with the provided `id`.
18
- */
19
- focus: (id: string) => void;
20
- /**
21
- * Determines whether this component is focused.
22
- */
23
- isFocused: boolean;
24
- };
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 <kbd>Tab</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;
30
- export default useFocus;
@@ -1,70 +0,0 @@
1
- export type ValidationResult = string | undefined;
2
- export type FieldValidator<V> = (value: V, values: Readonly<Record<string, unknown>>) => ValidationResult;
3
- export type FieldConfig<V = unknown> = {
4
- /**
5
- * Initial value.
6
- */
7
- readonly initialValue: V;
8
- /**
9
- * Optional validator. Return a string to indicate an error; return
10
- * `undefined` for valid.
11
- */
12
- readonly validate?: FieldValidator<V>;
13
- };
14
- export type FormSchema = Readonly<Record<string, FieldConfig<never>>>;
15
- export type FormValues<S extends Readonly<Record<string, FieldConfig>>> = {
16
- [K in keyof S]: S[K] extends FieldConfig<infer V> ? V : never;
17
- };
18
- export type UseFormOptions<S extends Readonly<Record<string, FieldConfig>>> = {
19
- /**
20
- * Field declarations.
21
- */
22
- readonly fields: S;
23
- /**
24
- * Called on submit if all fields validate.
25
- */
26
- readonly onSubmit?: (values: FormValues<S>) => void | Promise<void>;
27
- };
28
- export type UseFormResult<S extends Readonly<Record<string, FieldConfig>>> = {
29
- /**
30
- * Map of fieldName -> validation error (if any).
31
- */
32
- readonly errors: Readonly<Partial<Record<keyof S, string>>>;
33
- /**
34
- * True while the last `submit()` is in-flight.
35
- */
36
- readonly isSubmitting: boolean;
37
- /**
38
- * Reset all fields back to their initial values and clear errors / touched.
39
- */
40
- readonly reset: () => void;
41
- /**
42
- * Mark a field as touched. Useful on blur.
43
- */
44
- readonly setTouched: <K extends keyof S>(name: K, touched?: boolean) => void;
45
- /**
46
- * Update a single field.
47
- */
48
- readonly setValue: <K extends keyof S>(name: K, value: FormValues<S>[K]) => void;
49
- /**
50
- * Trigger validation and call the `onSubmit` option. Returns true if
51
- * submission succeeded (all fields valid).
52
- */
53
- readonly submit: () => Promise<boolean>;
54
- /**
55
- * Map of fieldName -> boolean. Field is considered touched after the
56
- * first `setTouched(name)` or `submit()` invocation.
57
- */
58
- readonly touched: Readonly<Partial<Record<keyof S, boolean>>>;
59
- /**
60
- * Current values.
61
- */
62
- readonly values: FormValues<S>;
63
- };
64
- /**
65
- * Minimal headless form state machine. Tracks values, touched state, errors,
66
- * and submission in-flight. Pair with `&lt;Form />` for default layout, or wire
67
- * up your own inputs directly.
68
- */
69
- declare const useForm: <S extends Readonly<Record<string, FieldConfig>>>(options: UseFormOptions<S>) => UseFormResult<S>;
70
- export default useForm;
@@ -1,37 +0,0 @@
1
- import type { Key } from "./use-input.d.ts";
2
- export type HotkeyDescriptor = {
3
- /**
4
- * Whether Ctrl must be held.
5
- */
6
- readonly ctrl?: boolean;
7
- /**
8
- * Character(s) to match after modifiers, e.g. `"s"`, `"?"`, `"k"`.
9
- * Ignored if `name` is set.
10
- */
11
- readonly input?: string;
12
- /**
13
- * Whether Meta must be held.
14
- */
15
- readonly meta?: boolean;
16
- /**
17
- * Named special key, e.g. `"escape"`, `"return"`, `"tab"`, `"upArrow"`.
18
- */
19
- readonly name?: keyof Key;
20
- /**
21
- * Whether Shift must be held.
22
- */
23
- readonly shift?: boolean;
24
- };
25
- export type UseHotkeyOptions = {
26
- /**
27
- * Disable the binding while keeping the component rendered.
28
- * @default true
29
- */
30
- readonly isActive?: boolean;
31
- };
32
- /**
33
- * Bind a keyboard shortcut to a callback. Accepts either a short string
34
- * (`"ctrl+s"`, `"?"`, `"escape"`) or a structured descriptor.
35
- */
36
- declare const useHotkey: (shortcut: HotkeyDescriptor | string, callback: () => void, options?: UseHotkeyOptions) => void;
37
- export default useHotkey;
@@ -1,149 +0,0 @@
1
- /**
2
- * Handy information about a key that was pressed.
3
- */
4
- export type Key = {
5
- /**
6
- * Backspace key was pressed.
7
- */
8
- backspace: boolean;
9
- /**
10
- * Caps Lock is active.
11
- *
12
- * Only available with kitty keyboard protocol.
13
- */
14
- capsLock: boolean;
15
- /**
16
- * Ctrl key was pressed.
17
- */
18
- ctrl: boolean;
19
- /**
20
- * Delete key was pressed.
21
- */
22
- delete: boolean;
23
- /**
24
- * Down arrow key was pressed.
25
- */
26
- downArrow: boolean;
27
- /**
28
- * End key was pressed.
29
- */
30
- end: boolean;
31
- /**
32
- * Escape key was pressed.
33
- */
34
- escape: boolean;
35
- /**
36
- * Event type for key events.
37
- *
38
- * Only available with kitty keyboard protocol.
39
- */
40
- eventType?: "press" | "repeat" | "release";
41
- /**
42
- * Home key was pressed.
43
- */
44
- home: boolean;
45
- /**
46
- * Hyper key was pressed.
47
- *
48
- * Only available with kitty keyboard protocol.
49
- */
50
- hyper: boolean;
51
- /**
52
- * Left arrow key was pressed.
53
- */
54
- leftArrow: boolean;
55
- /**
56
- * [Meta key](https://en.wikipedia.org/wiki/Meta_key) was pressed.
57
- */
58
- meta: boolean;
59
- /**
60
- * Num Lock is active.
61
- *
62
- * Only available with kitty keyboard protocol.
63
- */
64
- numLock: boolean;
65
- /**
66
- * Page Down key was pressed.
67
- */
68
- pageDown: boolean;
69
- /**
70
- * Page Up key was pressed.
71
- */
72
- pageUp: boolean;
73
- /**
74
- * Return (Enter) key was pressed.
75
- */
76
- return: boolean;
77
- /**
78
- * Right arrow key was pressed.
79
- */
80
- rightArrow: boolean;
81
- /**
82
- * Shift key was pressed.
83
- */
84
- shift: boolean;
85
- /**
86
- * Super key (Cmd on Mac, Win on Windows) was pressed.
87
- *
88
- * Only available with kitty keyboard protocol.
89
- */
90
- super: boolean;
91
- /**
92
- * Tab key was pressed.
93
- */
94
- tab: boolean;
95
- /**
96
- * Up arrow key was pressed.
97
- */
98
- upArrow: boolean;
99
- };
100
- type Handler = (input: string, key: Key) => void;
101
- type Options = {
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
- */
107
- imeEnabled?: boolean;
108
- /**
109
- * Timeout in milliseconds to wait before flushing IME composition buffer.
110
- * @default 50
111
- */
112
- imeTimeout?: number;
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
- */
117
- isActive?: boolean;
118
- };
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 'ink';
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
- declare const useInput: (inputHandler: Handler, options?: Options) => void;
149
- export default useInput;
@@ -1,25 +0,0 @@
1
- export type UseIntervalOptions = {
2
- /**
3
- * When false, the timer is paused. Flipping back to true restarts it.
4
- * @default true
5
- */
6
- readonly isActive?: boolean;
7
- };
8
- export type UseIntervalResult = {
9
- /**
10
- * Cancel the currently-running timer. The hook effect will reschedule on
11
- * the next re-render if `isActive` remains true.
12
- */
13
- readonly clear: () => void;
14
- };
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
- */
24
- declare const useInterval: (callback: () => void, interval: number, options?: UseIntervalOptions) => UseIntervalResult;
25
- export default useInterval;
@@ -1,6 +0,0 @@
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
- */
5
- declare const useIsScreenReaderEnabled: () => boolean;
6
- export default useIsScreenReaderEnabled;
@@ -1,59 +0,0 @@
1
- /**
2
- * A single key binding definition.
3
- */
4
- export type KeyBinding = {
5
- /** Human-readable description shown in Help. */
6
- readonly description: string;
7
- /**
8
- * Whether this binding is active.
9
- * @default true
10
- */
11
- readonly enabled?: boolean;
12
- /** Optional group name for organizing in the Help component's full mode. */
13
- readonly group?: string;
14
- /**
15
- * Key(s) that trigger this binding.
16
- *
17
- * A string can be:
18
- * - A single character: `"q"`, `"a"`, `" "` (space)
19
- * - A `Key` boolean field name: `"return"`, `"escape"`, `"upArrow"`, `"leftArrow"`, etc.
20
- * - A modifier combo: `"ctrl+c"`, `"meta+s"` (modifier + character)
21
- *
22
- * Provide an array to match multiple keys for the same action.
23
- */
24
- readonly key: string | ReadonlyArray<string>;
25
- };
26
- /**
27
- * A binding paired with its handler function.
28
- */
29
- export type KeyBindingHandler = {
30
- readonly binding: KeyBinding;
31
- readonly handler: () => void;
32
- };
33
- type UseKeyBindingsOptions = {
34
- /**
35
- * Whether keyboard input is captured.
36
- * @default true
37
- */
38
- readonly isActive?: boolean;
39
- };
40
- type UseKeyBindingsResult = {
41
- /** The enabled bindings, suitable for passing to the Help component. */
42
- readonly bindings: ReadonlyArray<KeyBinding>;
43
- };
44
- /**
45
- * Declarative keybinding hook. Registers multiple key bindings with handlers
46
- * and returns the enabled bindings for display in a Help component.
47
- *
48
- * ```tsx
49
- * const { bindings } = useKeyBindings([
50
- * { binding: { key: "q", description: "Quit" }, handler: () => exit() },
51
- * { binding: { key: ["upArrow", "k"], description: "Move up" }, handler: () => moveUp() },
52
- * { binding: { key: "ctrl+s", description: "Save" }, handler: () => save() },
53
- * ]);
54
- *
55
- * &lt;Help bindings={bindings} />
56
- * ```
57
- */
58
- export default function useKeyBindings(handlers: ReadonlyArray<KeyBindingHandler>, options?: UseKeyBindingsOptions): UseKeyBindingsResult;
59
- export {};
@@ -1,26 +0,0 @@
1
- export type KeyChordStep = string;
2
- export type UseKeyChordOptions = {
3
- /**
4
- * Disable the chord while keeping the component rendered.
5
- * @default true
6
- */
7
- readonly isActive?: boolean;
8
- /**
9
- * Milliseconds of silence after which the partial chord resets.
10
- * @default 1000
11
- */
12
- readonly resetAfter?: number;
13
- };
14
- /**
15
- * Invoke `callback` when the user types the given sequence of keys in order
16
- * (like Vim's `g d` or Emacs's `C-x C-s`). The chord resets automatically
17
- * after `resetAfter` ms of silence.
18
- * @param sequence Ordered list of chord steps. Each step is compared against
19
- * a canonical key token (e.g. `"g"`, `"space"`, `"ctrl+s"`).
20
- * @param callback Invoked exactly once per successful chord match. Latest
21
- * reference is captured in a ref.
22
- * @param options Optional `isActive` flag and `resetAfter` silence timeout.
23
- * @returns `void` — chord detection is wired up via `useInput` internally.
24
- */
25
- declare const useKeyChord: (sequence: ReadonlyArray<KeyChordStep>, callback: () => void, options?: UseKeyChordOptions) => void;
26
- export default useKeyChord;
@@ -1,41 +0,0 @@
1
- import type { RefObject } from "react";
2
- import type { ScrollViewRef } from "../components/scroll/scroll-view.d.ts";
3
- export type UseLinkedScrollReturn = {
4
- /**
5
- * Callback to pass to ScrollView's `onScroll` prop.
6
- * Broadcasts the scroll position to all linked instances.
7
- */
8
- onScroll: (scrollOffset: number) => void;
9
- /**
10
- * Ref to attach to the ScrollView component.
11
- * Used internally to call `scrollTo()` when other instances scroll.
12
- */
13
- ref: RefObject<ScrollViewRef | null>;
14
- };
15
- export type LinkedScrollGroup = {
16
- /**
17
- * Hook that returns a ref and onScroll callback for linking a ScrollView
18
- * to this group. Call once per ScrollView instance.
19
- */
20
- useLinkedScroll: () => UseLinkedScrollReturn;
21
- };
22
- /**
23
- * Creates a linked scroll group that synchronizes scroll position
24
- * across multiple ScrollView instances.
25
- * @example
26
- * ```tsx
27
- * const group = createLinkedScrollGroup();
28
- *
29
- * const PanelA = () => {
30
- * const { ref, onScroll } = group.useLinkedScroll();
31
- * return <ScrollView ref={ref} onScroll={onScroll}>...</ScrollView>;
32
- * };
33
- *
34
- * const PanelB = () => {
35
- * const { ref, onScroll } = group.useLinkedScroll();
36
- * return <ScrollView ref={ref} onScroll={onScroll}>...</ScrollView>;
37
- * };
38
- * ```
39
- */
40
- declare const createLinkedScrollGroup: () => LinkedScrollGroup;
41
- export default createLinkedScrollGroup;
@@ -1,44 +0,0 @@
1
- type Options = {
2
- /**
3
- * Enable or disable the paste handler. Useful when multiple components use `usePaste` and only one should be active at a time.
4
- * @default true
5
- */
6
- isActive?: boolean;
7
- };
8
- /**
9
- * A React hook that calls `handler` whenever the user pastes text in the
10
- * terminal. Bracketed paste mode (`\x1b[?2004h`) is automatically enabled while
11
- * the hook is active, so pasted text arrives as a single string rather than being
12
- * misinterpreted as individual key presses.
13
- *
14
- * `usePaste` is the dedicated API for paste blobs. `usePaste` and `useInput` can
15
- * be used together in the same component; they operate on separate event
16
- * channels, so paste content is never forwarded to `useInput` handlers while a
17
- * `usePaste` handler is active.
18
- *
19
- * If no `usePaste` handler is active, Ink still forwards bracketed paste text to
20
- * `useInput` for backward compatibility. That fallback is deprecated and will be
21
- * removed in the next major version.
22
- *
23
- * ```
24
- * import {useInput, usePaste} from 'ink';
25
- *
26
- * const MyInput = () => {
27
- * useInput((input, key) => {
28
- * // Only receives typed characters and key events, not pasted text.
29
- * if (key.return) {
30
- * // Submit
31
- * }
32
- * });
33
- *
34
- * usePaste((text) => {
35
- * // Receives the full pasted string, including newlines.
36
- * console.log('Pasted:', text);
37
- * });
38
- *
39
- * return …
40
- * };
41
- * ```
42
- */
43
- declare const usePaste: (handler: (text: string) => void, options?: Options) => void;
44
- export default usePaste;
@@ -1,56 +0,0 @@
1
- export type PersistentStorage = {
2
- /**
3
- * Return the persisted JSON-encoded string for `key`, or `undefined` if
4
- * nothing has been stored yet.
5
- */
6
- readonly read: (key: string) => string | undefined;
7
- /**
8
- * Persist `value` (a JSON-encoded string) for `key`. Errors are swallowed
9
- * by the hook so the UI keeps working in read-only environments.
10
- */
11
- readonly write: (key: string, value: string) => void;
12
- };
13
- export type UsePersistentStateOptions = {
14
- /**
15
- * Namespace used by the default file storage. Separates keys across
16
- * independent applications sharing the user's home directory.
17
- * @default "tui"
18
- */
19
- readonly namespace?: string;
20
- /**
21
- * Custom storage backend. When omitted, the default is a file on disk at
22
- * `~/.cache/visulima-tui/&lt;namespace>.json`.
23
- */
24
- readonly storage?: PersistentStorage;
25
- };
26
- /**
27
- * In-memory storage shared across all hook instances that use it. Useful in
28
- * tests and in environments without file access.
29
- */
30
- export declare const createMemoryStorage: () => PersistentStorage;
31
- /**
32
- * Default file-backed storage. Reads/writes a single JSON object per
33
- * namespace, keyed by `key`. The directory is created on first write and
34
- * updates use a temp-file + rename to avoid partial writes if the process
35
- * crashes mid-write. Errors are forwarded to `process.stderr.write` so they
36
- * are visible without crashing the UI.
37
- */
38
- export declare const createFileStorage: (namespace: string) => PersistentStorage;
39
- /**
40
- * `useState` that persists its value through the configured `storage`
41
- * backend (file on disk by default). Behaves identically to `useState` at
42
- * the call-site; the writes happen synchronously after each update.
43
- *
44
- * **Lifecycle note:** the storage backend (resolved from `options.storage`
45
- * or a fresh `createFileStorage(namespace)`) is captured once on mount and
46
- * never replaced. Mutating `options.storage` on subsequent renders has no
47
- * effect — remount the hook (e.g. via a `key` prop) if you need to swap
48
- * backends at runtime.
49
- * @param key Unique identifier within the backend namespace.
50
- * @param initialValue Value used when the backend has no entry for `key`.
51
- * @param options Optional storage backend + namespace overrides.
52
- * @returns A `[value, setValue]` tuple. Writes flush synchronously after
53
- * the React state update.
54
- */
55
- declare const usePersistentState: <T>(key: string, initialValue: T, options?: UsePersistentStateOptions) => readonly [T, (value: T | ((previous: T) => T)) => void];
56
- export default usePersistentState;
@@ -1,47 +0,0 @@
1
- export type UseScrollAccelerationOptions = {
2
- /**
3
- * Velocity multiplier per rapid scroll event.
4
- * @default 1.5
5
- */
6
- readonly acceleration?: number;
7
- /**
8
- * Velocity decay factor per tick (0-1). Lower = faster stop.
9
- * @default 0.92
10
- */
11
- readonly decayRate?: number;
12
- /**
13
- * Enable or disable acceleration.
14
- * @default true
15
- */
16
- readonly isActive?: boolean;
17
- /**
18
- * Maximum velocity in lines per tick.
19
- * @default 20
20
- */
21
- readonly maxVelocity?: number;
22
- /**
23
- * Callback invoked with the scroll delta (signed integer lines) on each tick.
24
- */
25
- readonly onScroll?: (delta: number) => void;
26
- };
27
- export type UseScrollAccelerationResult = {
28
- /** Handle a discrete scroll event (from mouse wheel or keyboard). */
29
- readonly handleScroll: (direction: "down" | "up") => void;
30
- /** Whether momentum is still active (coasting after last input). */
31
- readonly isCoasting: boolean;
32
- /** Current velocity (positive = down, negative = up). */
33
- readonly velocity: number;
34
- };
35
- /**
36
- * Hook providing scroll acceleration with momentum physics.
37
- *
38
- * ```tsx
39
- * const { handleScroll } = useScrollAcceleration({
40
- * onScroll: (delta) => scrollViewRef.current?.scrollBy(delta),
41
- * });
42
- *
43
- * useMouseAction(); // call handleScroll("up") or handleScroll("down") on scroll events
44
- * ```
45
- */
46
- declare const useScrollAcceleration: (options?: UseScrollAccelerationOptions) => UseScrollAccelerationResult;
47
- export default useScrollAcceleration;
@@ -1,34 +0,0 @@
1
- export type UseScrollInputOptions = {
2
- /**
3
- * Returns the current viewport height in lines. Called on each key event
4
- * so the value is always fresh (avoids stale-closure issues with refs).
5
- */
6
- getViewportHeight: () => number;
7
- /**
8
- * Enable or disable scroll input handling.
9
- * @default true
10
- */
11
- isActive?: boolean;
12
- /**
13
- * Scroll by a relative delta (in lines).
14
- */
15
- scrollBy: (delta: number) => void;
16
- /**
17
- * Jump to the bottom of the content.
18
- */
19
- scrollToBottom: () => void;
20
- /**
21
- * Jump to the top of the content.
22
- */
23
- scrollToTop: () => void;
24
- /**
25
- * Enable vim-style keybindings (j/k/g/G/u/d).
26
- * @default false
27
- */
28
- vimBindings?: boolean;
29
- };
30
- export type UseScrollInputReturn = {
31
- isFocused: boolean;
32
- };
33
- declare const useScrollInput: (options: UseScrollInputOptions) => UseScrollInputReturn;
34
- export default useScrollInput;
@@ -1,6 +0,0 @@
1
- import type { Props } from "../components/stderr-context.d.ts";
2
- /**
3
- * A React hook that returns the stderr stream.
4
- */
5
- declare const useStderr: () => Props;
6
- export default useStderr;
@@ -1,7 +0,0 @@
1
- import type { Props, PublicProps } from "../components/stdin-context.d.ts";
2
- /**
3
- * A React hook that returns the stdin stream and stdin-related utilities.
4
- */
5
- declare const useStdin: () => PublicProps;
6
- export declare const useStdinContext: () => Props;
7
- export default useStdin;
@@ -1,6 +0,0 @@
1
- import type { Props } from "../components/stdout-context.d.ts";
2
- /**
3
- * A React hook that returns the stdout stream where Ink renders your app.
4
- */
5
- declare const useStdout: () => Props;
6
- export default useStdout;