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

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 +15 -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-CNIzVQTh.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 +15 -16
  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,62 +0,0 @@
1
- /**
2
- * Multi-line text input component for Ink.
3
- *
4
- * Provides a full-featured textarea with cursor navigation, selection,
5
- * clipboard support, undo/redo, and viewport scrolling.
6
- */
7
- import type { ReactElement } from "react";
8
- export type Props = {
9
- /** @default "" */
10
- readonly defaultValue?: string;
11
- /**
12
- * When true, all input is ignored and text is dimmed.
13
- * @default false
14
- */
15
- readonly isDisabled?: boolean;
16
- /**
17
- * When true, the component responds to keyboard input.
18
- * @default true
19
- */
20
- readonly isFocused?: boolean;
21
- /**
22
- * Maximum visible rows before viewport scrolling kicks in.
23
- * When set, the textarea will grow from `rows` to `maxRows` before scrolling.
24
- */
25
- readonly maxRows?: number;
26
- /**
27
- * Fires on every edit with the updated text.
28
- */
29
- readonly onChange?: (value: string) => void;
30
- /**
31
- * Fires when the user presses Meta+Enter or Ctrl+Enter.
32
- */
33
- readonly onSubmit?: (value: string) => void;
34
- /**
35
- * Greyed-out text shown when the textarea is empty.
36
- */
37
- readonly placeholder?: string;
38
- /**
39
- * Number of visible rows (viewport height).
40
- * @default 5
41
- */
42
- readonly rows?: number;
43
- /**
44
- * Show line numbers in the left gutter.
45
- * @default false
46
- */
47
- readonly showLineNumbers?: boolean;
48
- /**
49
- * Number of spaces inserted for a Tab key press.
50
- * @default 2
51
- */
52
- readonly tabSize?: number;
53
- };
54
- /**
55
- * A multi-line text input with cursor navigation, selection, clipboard, undo/redo,
56
- * paste support, and viewport scrolling.
57
- *
58
- * ```tsx
59
- * <Textarea defaultValue="Hello\nWorld" rows={10} onChange={setValue} onSubmit={handleSubmit} />
60
- * ```
61
- */
62
- export default function Textarea({ defaultValue, isDisabled, isFocused, maxRows, onChange, onSubmit, placeholder, rows, showLineNumbers, tabSize, }: Props): ReactElement;
@@ -1,50 +0,0 @@
1
- import type { ReactElement, Ref } from "react";
2
- import type { UseTimerResult } from "../hooks/use-timer.d.ts";
3
- export type TimerRef = Omit<UseTimerResult, "isFinished" | "isRunning" | "remaining">;
4
- export type Props = {
5
- /**
6
- * Whether to start the timer immediately.
7
- * @default false
8
- */
9
- readonly autoStart?: boolean;
10
- /**
11
- * Make the rendered text bold.
12
- */
13
- readonly bold?: boolean;
14
- /**
15
- * Text color for the rendered time.
16
- */
17
- readonly color?: string;
18
- /**
19
- * Total countdown duration in milliseconds.
20
- */
21
- readonly duration: number;
22
- /**
23
- * Custom formatter for the remaining time.
24
- * Receives remaining milliseconds, returns a display string.
25
- * @default formatDuration (MM:SS or HH:MM:SS)
26
- */
27
- readonly format?: (remaining: number) => string;
28
- /**
29
- * Tick interval in milliseconds.
30
- * @default 1000
31
- */
32
- readonly interval?: number;
33
- /**
34
- * Called once when the timer reaches zero.
35
- */
36
- readonly onTimeout?: () => void;
37
- readonly ref?: Ref<TimerRef>;
38
- };
39
- /**
40
- * A countdown timer component.
41
- *
42
- * Exposes `start`, `stop`, `toggle`, and `reset` methods via ref.
43
- *
44
- * ```tsx
45
- * const ref = useRef&lt;TimerRef>(null);
46
- * &lt;Timer ref={ref} duration={60_000} autoStart />
47
- * ```
48
- */
49
- declare const Timer: ({ autoStart, bold, color, duration, format, interval, onTimeout, ref }: Props) => ReactElement;
50
- export default Timer;
@@ -1,41 +0,0 @@
1
- import type { ReactElement, ReactNode } from "react";
2
- import type { Variant } from "./variant-config.d.ts";
3
- export type ToastVariant = Variant;
4
- export type Props = {
5
- /**
6
- * Toast body.
7
- */
8
- readonly children: ReactNode;
9
- /**
10
- * Milliseconds to display before auto-dismissing. Use `0` to disable.
11
- * @default 4000
12
- */
13
- readonly duration?: number;
14
- /**
15
- * Called after the toast dismisses itself.
16
- */
17
- readonly onDismiss?: () => void;
18
- /**
19
- * Optional title rendered before the body.
20
- */
21
- readonly title?: string;
22
- /**
23
- * Visual variant determining the icon and border color.
24
- * @default "info"
25
- */
26
- readonly variant?: ToastVariant;
27
- /**
28
- * Manually control visibility. When provided, `duration` is ignored.
29
- */
30
- readonly visible?: boolean;
31
- /**
32
- * Optional width override.
33
- */
34
- readonly width?: number;
35
- };
36
- /**
37
- * Ephemeral notification. Disappears automatically after `duration` ms.
38
- * @param props See {@link Props}.
39
- * @returns A bordered `ReactElement` while visible; `null` once dismissed.
40
- */
41
- export default function Toast({ children, duration, onDismiss, title, variant, visible, width }: Props): ReactElement | null;
@@ -1,36 +0,0 @@
1
- import type { AnsiColors } from "@visulima/colorize";
2
- import type { ReactElement, ReactNode } from "react";
3
- import type { LiteralUnion } from "type-fest";
4
- export type TooltipPlacement = "bottom" | "left" | "right" | "top";
5
- export type Props = {
6
- /**
7
- * The element the tooltip is attached to.
8
- */
9
- readonly children: ReactNode;
10
- /**
11
- * Border color.
12
- * @default "gray"
13
- */
14
- readonly color?: LiteralUnion<AnsiColors, string>;
15
- /**
16
- * Tooltip body content.
17
- */
18
- readonly content: ReactNode;
19
- /**
20
- * Controls whether the tooltip is rendered.
21
- * @default true
22
- */
23
- readonly isVisible?: boolean;
24
- /**
25
- * Relative position. Terminal rendering does not support floating layers,
26
- * so the tooltip is placed inline next to (or above / below) the anchor.
27
- * @default "right"
28
- */
29
- readonly placement?: TooltipPlacement;
30
- };
31
- /**
32
- * Renders supplementary text next to an anchor. Because terminals don't have
33
- * a floating-layer concept, the tooltip lives inline in the layout. Hide it
34
- * by toggling `isVisible`.
35
- */
36
- export default function Tooltip({ children, color, content, isVisible, placement }: Props): ReactElement;
@@ -1,16 +0,0 @@
1
- import type { ReactElement, ReactNode } from "react";
2
- export type Props = {
3
- /**
4
- * Screen-reader-specific text to output. If this is set, all children will be ignored.
5
- */
6
- readonly accessibilityLabel?: string;
7
- readonly children?: ReactNode;
8
- /**
9
- * Function that transforms children output. It accepts children and must return transformed children as well. Note that when children use `&lt;Text>` styling props (e.g. `color`, `bold`), the string will contain ANSI escape codes.
10
- */
11
- readonly transform: (children: string, index: number) => string;
12
- };
13
- /**
14
- * Transform a string representation of React components before they're written to output. For example, you might want to apply a gradient to text, add a clickable link, or create some text effects. These use cases can't accept React nodes as input; they expect a string. That's what the &lt;Transform> component does: it gives you an output string of its child components and lets you transform it in any way.
15
- */
16
- export default function Transform({ accessibilityLabel, children, transform }: Props): ReactElement | null;
@@ -1,53 +0,0 @@
1
- import type { ReactElement, ReactNode } from "react";
2
- export type TransitionPreset = "fade" | "reveal" | "slide-down" | "slide-left" | "slide-right" | "slide-up";
3
- export type TransitionPhase = "entered" | "entering" | "exited" | "exiting";
4
- export type Props = {
5
- /**
6
- * Content to animate.
7
- */
8
- readonly children: ReactNode;
9
- /**
10
- * For slide presets, how many characters of offset to animate across.
11
- * For the `reveal` preset, the maximum row count to scale through.
12
- * @default 4
13
- */
14
- readonly distance?: number;
15
- /**
16
- * Duration of both enter and exit transitions, in milliseconds.
17
- * @default 240
18
- */
19
- readonly duration?: number;
20
- /**
21
- * Called once the exit animation finishes (i.e. the component has fully
22
- * transitioned out). AnimatePresence uses this to unmount the wrapper.
23
- */
24
- readonly onExit?: () => void;
25
- /**
26
- * Animation preset controlling how the content appears/disappears.
27
- * @default "fade"
28
- */
29
- readonly preset?: TransitionPreset;
30
- /**
31
- * Controls the target phase. `true` drives towards `entered`, `false`
32
- * drives towards `exited`. Flip the value to trigger animation.
33
- * @default true
34
- */
35
- readonly show?: boolean;
36
- /**
37
- * Tick interval in milliseconds. Lower values yield smoother animation
38
- * at the cost of CPU.
39
- * @default 30
40
- */
41
- readonly tickInterval?: number;
42
- };
43
- type TransitionComponent = ((props: Props) => ReactElement | null) & {
44
- isAnimatable: true;
45
- };
46
- /**
47
- * Static marker used by `AnimatePresence` to recognize Transition children
48
- * even when the consumer hasn't explicitly passed a `show` prop. Consumers
49
- * can apply the same marker to their own wrappers (`MyWrapper.isAnimatable
50
- * = true`) to opt them into animation orchestration.
51
- */
52
- declare const TransitionWithMarker: TransitionComponent;
53
- export default TransitionWithMarker;
@@ -1,24 +0,0 @@
1
- import type { Props as BoxProps } from "../box.d.ts";
2
- import type { Props as TextProps } from "../text.d.ts";
3
- type StyleFunctionProps = {
4
- readonly depth?: number;
5
- readonly hasChildren?: boolean;
6
- readonly isExpanded?: boolean;
7
- readonly isFocused?: boolean;
8
- readonly isLoading?: boolean;
9
- readonly isSelected?: boolean;
10
- };
11
- declare const theme: {
12
- styles: {
13
- container: () => BoxProps;
14
- expandIndicator: (_props: StyleFunctionProps) => TextProps;
15
- focusIndicator: () => TextProps;
16
- indent: ({ depth }: StyleFunctionProps) => BoxProps;
17
- label: ({ isFocused, isSelected }: StyleFunctionProps) => TextProps;
18
- loadingIndicator: () => TextProps;
19
- node: ({ isFocused }: StyleFunctionProps) => BoxProps;
20
- selectedIndicator: () => TextProps;
21
- };
22
- };
23
- export { theme };
24
- export type Theme = typeof theme;
@@ -1,72 +0,0 @@
1
- import type { TreeNode } from "./types.d.ts";
2
- /**
3
- * A flattened representation of a tree node with navigation links.
4
- */
5
- export type FlatNode<T = Record<string, unknown>> = {
6
- /** Ordered list of direct children IDs. */
7
- readonly childrenIds: ReadonlyArray<string>;
8
- /** Depth in the tree (0 for roots). */
9
- readonly depth: number;
10
- /** Index in the flattened DFS order (across ALL nodes, not just visible). */
11
- readonly flatIndex: number;
12
- /** Whether this node has children. */
13
- readonly hasChildren: boolean;
14
- /** Next sibling's ID, or undefined. */
15
- readonly nextSiblingId: string | undefined;
16
- /** The original tree node. */
17
- readonly node: TreeNode<T>;
18
- /** Parent's id, or undefined if root. */
19
- readonly parentId: string | undefined;
20
- /** Previous sibling's ID, or undefined. */
21
- readonly previousSiblingId: string | undefined;
22
- /** Total number of siblings (including this node). */
23
- readonly siblingCount: number;
24
- /** Zero-based index among siblings. */
25
- readonly siblingIndex: number;
26
- };
27
- /**
28
- * A flattened map of all tree nodes built via DFS traversal.
29
- * Stores parent/child/sibling links for O(1) navigation.
30
- */
31
- export declare class TreeNodeMap<T = Record<string, unknown>> {
32
- /** All node IDs in DFS order. */
33
- readonly orderedIds: string[];
34
- /** Root-level node IDs. */
35
- readonly rootIds: string[];
36
- /** Map from node ID to FlatNode. */
37
- private readonly map;
38
- constructor(data: TreeNode<T>[]);
39
- /**
40
- * Iterate over all entries.
41
- */
42
- entries(): IterableIterator<[string, FlatNode<T>]>;
43
- /**
44
- * Get a flat node by ID.
45
- */
46
- get(id: string): FlatNode<T> | undefined;
47
- /**
48
- * Total number of nodes in the tree.
49
- */
50
- get size(): number;
51
- /**
52
- * Given a set of expanded node IDs, return the ordered list of
53
- * VISIBLE node IDs (i.e., a node is visible if all its ancestors
54
- * are expanded).
55
- *
56
- * Uses iterative DFS, skipping collapsed subtrees.
57
- */
58
- getVisibleIds(expandedIds: ReadonlySet<string>): string[];
59
- /**
60
- * Check if a node is a descendant of another node.
61
- */
62
- isDescendantOf(nodeId: string, ancestorId: string): boolean;
63
- /**
64
- * Insert dynamically-loaded children under a parent node.
65
- * Returns a new TreeNodeMap (immutable operation).
66
- *
67
- * Rebuilds the full tree from the current map state (not the original
68
- * input data), so successive calls for different parents are safe.
69
- */
70
- withChildren(parentId: string, children: TreeNode<T>[]): TreeNodeMap<T>;
71
- private buildFromData;
72
- }
@@ -1,29 +0,0 @@
1
- /**
2
- * TreeViewNode renders a single node in the tree with focus indicator,
3
- * indentation, expand/collapse indicator, label, and selection state.
4
- *
5
- * Ported from ink-tree-view by John Costa.
6
- * @see https://github.com/costajohnt/ink-tree-view
7
- *
8
- * MIT License
9
- * Copyright (c) John Costa
10
- */
11
- import type { ReactElement } from "react";
12
- import type { Theme } from "./theme.d.ts";
13
- import type { SelectionMode, TreeNode, TreeNodeState } from "./types.d.ts";
14
- type Props<T = Record<string, unknown>> = {
15
- readonly isScreenReaderEnabled: boolean;
16
- readonly node: TreeNode<T>;
17
- readonly nodeState: TreeNodeState;
18
- readonly selectionMode: SelectionMode;
19
- readonly siblingCount: number;
20
- readonly siblingPosition: number;
21
- readonly styles: Theme["styles"];
22
- };
23
- export declare function buildNodeAriaLabel(label: string, nodeState: TreeNodeState, siblingPosition: number, siblingCount: number): string;
24
- export declare function buildNodeAriaState(nodeState: TreeNodeState, selectionMode: SelectionMode): {
25
- expanded?: boolean;
26
- selected?: boolean;
27
- } | undefined;
28
- export declare function TreeViewNode<T>({ isScreenReaderEnabled, node, nodeState, selectionMode, siblingCount, siblingPosition, styles }: Props<T>): ReactElement;
29
- export {};
@@ -1,89 +0,0 @@
1
- /**
2
- * TreeView component for terminal UIs with keyboard navigation,
3
- * expand/collapse, single/multi selection, async children loading,
4
- * and viewport virtualization.
5
- *
6
- * Ported from ink-tree-view by John Costa.
7
- * @see https://github.com/costajohnt/ink-tree-view
8
- *
9
- * MIT License
10
- * Copyright (c) John Costa
11
- */
12
- import type { ReactElement, ReactNode } from "react";
13
- import type { AsyncChildrenFunction, SelectionMode, TreeNode, TreeNodeRendererProps } from "./types.d.ts";
14
- export type Props<T = Record<string, unknown>> = {
15
- /**
16
- * Accessible label for the tree container.
17
- * Useful when multiple tree views are on screen.
18
- * @default "Tree view"
19
- */
20
- readonly ariaLabel?: string;
21
- /**
22
- * The tree data. Array of root-level nodes.
23
- *
24
- * **Important:** Must be referentially stable across renders (e.g. stored
25
- * in state or wrapped in `useMemo`). Passing a new array reference on
26
- * every render will reset focus, expansion, and selection state.
27
- */
28
- readonly data: TreeNode<T>[];
29
- /**
30
- * Set of node IDs that are expanded by default.
31
- * If not provided, all nodes start collapsed.
32
- */
33
- readonly defaultExpanded?: ReadonlySet<string> | "all";
34
- /**
35
- * Set of node IDs that are selected by default.
36
- */
37
- readonly defaultSelected?: ReadonlySet<string>;
38
- /**
39
- * When disabled, user input is ignored.
40
- * @default false
41
- */
42
- readonly isDisabled?: boolean;
43
- /**
44
- * Async function to load children on demand.
45
- */
46
- readonly loadChildren?: AsyncChildrenFunction<T>;
47
- /** Called when expanded set changes. */
48
- readonly onExpandChange?: (expandedIds: ReadonlySet<string>) => void;
49
- /** Called when the focused node changes. */
50
- readonly onFocusChange?: (nodeId: string) => void;
51
- /**
52
- * Called when `loadChildren` rejects. Receives the node ID and error.
53
- */
54
- readonly onLoadError?: (nodeId: string, error: Error) => void;
55
- /** Called when selection changes. */
56
- readonly onSelectChange?: (selectedIds: ReadonlySet<string>) => void;
57
- /**
58
- * Custom node renderer. Receives node + state, returns Ink JSX.
59
- */
60
- readonly renderNode?: (props: TreeNodeRendererProps<T>) => ReactNode;
61
- /**
62
- * Selection mode.
63
- * - "none": No selection behavior (default).
64
- * - "single": One node can be selected at a time.
65
- * - "multiple": Multiple nodes can be selected (checkboxes shown).
66
- * @default "none"
67
- */
68
- readonly selectionMode?: SelectionMode;
69
- /**
70
- * Number of visible nodes in the viewport (for virtualization).
71
- * @default Infinity (no virtualization)
72
- */
73
- readonly visibleNodeCount?: number;
74
- };
75
- /**
76
- * Renders an interactive tree view with keyboard navigation.
77
- *
78
- * ```tsx
79
- * &lt;TreeView
80
- * data={[
81
- * { id: "1", label: "Root", children: [
82
- * { id: "1.1", label: "Child" },
83
- * ]},
84
- * ]}
85
- * defaultExpanded="all"
86
- * />
87
- * ```
88
- */
89
- export declare function TreeView<T = Record<string, unknown>>({ ariaLabel, data, defaultExpanded, defaultSelected, isDisabled, loadChildren, onExpandChange, onFocusChange, onLoadError, onSelectChange, renderNode, selectionMode, visibleNodeCount, }: Props<T>): ReactElement;
@@ -1,55 +0,0 @@
1
- /**
2
- * A single node in the tree. Generic over the user's data shape.
3
- * The `id` field MUST be unique across the entire tree.
4
- */
5
- export type TreeNode<T = Record<string, unknown>> = {
6
- /** Child nodes. Undefined or empty array means leaf node. */
7
- readonly children?: TreeNode<T>[];
8
- /** Arbitrary user data attached to this node. */
9
- readonly data?: T;
10
- /** Unique identifier for this node. Used as the key for all lookups. */
11
- readonly id: string;
12
- /**
13
- * Explicitly marks this node as a parent that can have children loaded
14
- * asynchronously via `loadChildren`. When true, the node shows an expand
15
- * indicator even if `children` is empty or undefined, and expanding it
16
- * triggers the `loadChildren` callback.
17
- */
18
- readonly isParent?: boolean;
19
- /** Display label. Used by the default renderer. */
20
- readonly label: string;
21
- };
22
- /**
23
- * For async/lazy loading: a function that resolves children on demand.
24
- */
25
- export type AsyncChildrenFunction<T = Record<string, unknown>> = (node: TreeNode<T>) => Promise<TreeNode<T>[]>;
26
- /**
27
- * State passed to custom renderers and theme functions.
28
- */
29
- export type TreeNodeState = {
30
- /** Depth of this node in the tree (root = 0). */
31
- readonly depth: number;
32
- /** Whether this node has children (or a lazy loader). */
33
- readonly hasChildren: boolean;
34
- /** Whether this node is expanded (children visible). */
35
- readonly isExpanded: boolean;
36
- /** Whether this node is currently focused (cursor is on it). */
37
- readonly isFocused: boolean;
38
- /** Whether children are currently loading (async mode). */
39
- readonly isLoading: boolean;
40
- /** Whether this node is selected (in select/multi-select mode). */
41
- readonly isSelected: boolean;
42
- };
43
- /**
44
- * Props received by a custom node renderer.
45
- */
46
- export type TreeNodeRendererProps<T = Record<string, unknown>> = {
47
- /** The tree node data. */
48
- readonly node: TreeNode<T>;
49
- /** Current state of this node. */
50
- readonly state: TreeNodeState;
51
- };
52
- /**
53
- * Selection mode for the tree view.
54
- */
55
- export type SelectionMode = "multiple" | "none" | "single";
@@ -1,135 +0,0 @@
1
- import { TreeNodeMap } from "./tree-node-map.d.ts";
2
- import type { SelectionMode, TreeNode, TreeNodeState } from "./types.d.ts";
3
- export type State<T> = {
4
- expandedIds: Set<string>;
5
- focusedId: string | undefined;
6
- loadingIds: Set<string>;
7
- nodeMap: TreeNodeMap<T>;
8
- previousExpandedIds: Set<string>;
9
- previousSelectedIds: Set<string>;
10
- selectedIds: Set<string>;
11
- selectionMode: SelectionMode;
12
- viewportFromIndex: number;
13
- viewportToIndex: number;
14
- /** O(1) lookup from node ID to index in visibleIds. */
15
- visibleIdIndex: Map<string, number>;
16
- visibleIds: string[];
17
- visibleNodeCount: number;
18
- };
19
- export type Action<T> = {
20
- nodeId: string;
21
- type: "collapse-node";
22
- } | {
23
- nodeId: string;
24
- type: "expand-node";
25
- } | {
26
- nodeId: string;
27
- type: "set-children-error";
28
- } | {
29
- children: TreeNode<T>[];
30
- parentId: string;
31
- type: "insert-children";
32
- } | {
33
- isLoading: boolean;
34
- nodeId: string;
35
- type: "set-loading";
36
- } | {
37
- state: State<T>;
38
- type: "reset";
39
- } | {
40
- type: "collapse";
41
- } | {
42
- type: "collapse-all";
43
- } | {
44
- type: "expand";
45
- } | {
46
- type: "expand-all";
47
- } | {
48
- type: "focus-first";
49
- } | {
50
- type: "focus-first-child";
51
- } | {
52
- type: "focus-last";
53
- } | {
54
- type: "focus-next";
55
- } | {
56
- type: "focus-parent";
57
- } | {
58
- type: "focus-previous";
59
- } | {
60
- type: "select";
61
- } | {
62
- type: "toggle-expanded";
63
- };
64
- export declare function reducer<T>(state: State<T>, action: Action<T>): State<T>;
65
- export type CreateDefaultStateProps<T> = {
66
- data: TreeNode<T>[];
67
- defaultExpanded?: ReadonlySet<string> | "all";
68
- defaultSelected?: ReadonlySet<string>;
69
- selectionMode: SelectionMode;
70
- visibleNodeCount: number;
71
- };
72
- export declare function createDefaultState<T>({ data, defaultExpanded, defaultSelected, selectionMode, visibleNodeCount }: CreateDefaultStateProps<T>): State<T>;
73
- export type UseTreeViewStateProps<T = Record<string, unknown>> = {
74
- /** The tree data. Array of root-level nodes. */
75
- readonly data: TreeNode<T>[];
76
- /**
77
- * Set of node IDs that are expanded by default.
78
- * If not provided, all nodes start collapsed.
79
- */
80
- readonly defaultExpanded?: ReadonlySet<string> | "all";
81
- /**
82
- * Set of node IDs that are selected by default.
83
- */
84
- readonly defaultSelected?: ReadonlySet<string>;
85
- /** Called when expanded set changes. */
86
- readonly onExpandChange?: (expandedIds: ReadonlySet<string>) => void;
87
- /** Called when the focused node changes. */
88
- readonly onFocusChange?: (nodeId: string) => void;
89
- /** Called when selection changes. */
90
- readonly onSelectChange?: (selectedIds: ReadonlySet<string>) => void;
91
- /**
92
- * Selection mode.
93
- * @default "none"
94
- */
95
- readonly selectionMode?: SelectionMode;
96
- /**
97
- * Number of visible nodes in the viewport (for virtualization).
98
- * @default Infinity
99
- */
100
- readonly visibleNodeCount?: number;
101
- };
102
- export type TreeViewState<T = Record<string, unknown>> = {
103
- readonly collapse: () => void;
104
- readonly collapseAll: () => void;
105
- readonly collapseNode: (nodeId: string) => void;
106
- readonly expand: () => void;
107
- readonly expandAll: () => void;
108
- readonly expandedIds: ReadonlySet<string>;
109
- readonly expandNode: (nodeId: string) => void;
110
- readonly focusedId: string | undefined;
111
- readonly focusFirst: () => void;
112
- readonly focusFirstChild: () => void;
113
- readonly focusLast: () => void;
114
- readonly focusNext: () => void;
115
- readonly focusParent: () => void;
116
- readonly focusPrevious: () => void;
117
- readonly hasScrollDown: boolean;
118
- readonly hasScrollUp: boolean;
119
- readonly insertChildren: (parentId: string, children: TreeNode<T>[]) => void;
120
- readonly loadingIds: ReadonlySet<string>;
121
- readonly nodeMap: TreeNodeMap<T>;
122
- readonly select: () => void;
123
- readonly selectedIds: ReadonlySet<string>;
124
- readonly setChildrenError: (nodeId: string) => void;
125
- readonly setLoading: (nodeId: string, isLoading: boolean) => void;
126
- readonly toggleExpanded: () => void;
127
- readonly viewportFromIndex: number;
128
- readonly viewportNodes: {
129
- node: TreeNode<T>;
130
- state: TreeNodeState;
131
- }[];
132
- readonly viewportToIndex: number;
133
- readonly visibleCount: number;
134
- };
135
- export declare function useTreeViewState<T = Record<string, unknown>>({ data, defaultExpanded, defaultSelected, onExpandChange, onFocusChange, onSelectChange, selectionMode, visibleNodeCount, }: UseTreeViewStateProps<T>): TreeViewState<T>;