@outfitter/tui 0.2.0

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 (235) hide show
  1. package/README.md +250 -0
  2. package/dist/borders/index.d.ts +3 -0
  3. package/dist/borders/index.js +13 -0
  4. package/dist/box/index.d.ts +4 -0
  5. package/dist/box/index.js +10 -0
  6. package/dist/confirm.d.ts +37 -0
  7. package/dist/confirm.js +36 -0
  8. package/dist/demo/index.d.ts +77 -0
  9. package/dist/demo/index.js +142 -0
  10. package/dist/demo/registry.d.ts +6 -0
  11. package/dist/demo/registry.js +28 -0
  12. package/dist/demo/renderers/borders.d.ts +7 -0
  13. package/dist/demo/renderers/borders.js +14 -0
  14. package/dist/demo/renderers/box.d.ts +7 -0
  15. package/dist/demo/renderers/box.js +15 -0
  16. package/dist/demo/renderers/colors.d.ts +7 -0
  17. package/dist/demo/renderers/colors.js +15 -0
  18. package/dist/demo/renderers/indicators.d.ts +7 -0
  19. package/dist/demo/renderers/indicators.js +14 -0
  20. package/dist/demo/renderers/list.d.ts +7 -0
  21. package/dist/demo/renderers/list.js +16 -0
  22. package/dist/demo/renderers/markdown.d.ts +7 -0
  23. package/dist/demo/renderers/markdown.js +15 -0
  24. package/dist/demo/renderers/progress.d.ts +7 -0
  25. package/dist/demo/renderers/progress.js +14 -0
  26. package/dist/demo/renderers/spinner.d.ts +7 -0
  27. package/dist/demo/renderers/spinner.js +16 -0
  28. package/dist/demo/renderers/table.d.ts +7 -0
  29. package/dist/demo/renderers/table.js +16 -0
  30. package/dist/demo/renderers/text.d.ts +7 -0
  31. package/dist/demo/renderers/text.js +13 -0
  32. package/dist/demo/renderers/tree.d.ts +7 -0
  33. package/dist/demo/renderers/tree.js +15 -0
  34. package/dist/demo/section.d.ts +4 -0
  35. package/dist/demo/section.js +20 -0
  36. package/dist/demo/templates.d.ts +3 -0
  37. package/dist/demo/templates.js +10 -0
  38. package/dist/demo/types.d.ts +2 -0
  39. package/dist/demo/types.js +8 -0
  40. package/dist/index.d.ts +31 -0
  41. package/dist/index.js +77 -0
  42. package/dist/list/index.d.ts +3 -0
  43. package/dist/list/index.js +9 -0
  44. package/dist/preset/full.d.ts +12 -0
  45. package/dist/preset/full.js +37 -0
  46. package/dist/preset/standard.d.ts +9 -0
  47. package/dist/preset/standard.js +26 -0
  48. package/dist/prompt/confirm.d.ts +4 -0
  49. package/dist/prompt/confirm.js +9 -0
  50. package/dist/prompt/group.d.ts +4 -0
  51. package/dist/prompt/group.js +9 -0
  52. package/dist/prompt/index.d.ts +7 -0
  53. package/dist/prompt/index.js +32 -0
  54. package/dist/prompt/select.d.ts +4 -0
  55. package/dist/prompt/select.js +11 -0
  56. package/dist/prompt/text.d.ts +4 -0
  57. package/dist/prompt/text.js +11 -0
  58. package/dist/prompt/types.d.ts +3 -0
  59. package/dist/prompt/types.js +8 -0
  60. package/dist/prompt/validators.d.ts +2 -0
  61. package/dist/prompt/validators.js +8 -0
  62. package/dist/render/borders.d.ts +2 -0
  63. package/dist/render/borders.js +15 -0
  64. package/dist/render/box.d.ts +3 -0
  65. package/dist/render/box.js +20 -0
  66. package/dist/render/date.d.ts +2 -0
  67. package/dist/render/date.js +12 -0
  68. package/dist/render/format-relative.d.ts +2 -0
  69. package/dist/render/format-relative.js +8 -0
  70. package/dist/render/format.d.ts +2 -0
  71. package/dist/render/format.js +10 -0
  72. package/dist/render/heading.d.ts +3 -0
  73. package/dist/render/heading.js +11 -0
  74. package/dist/render/index.d.ts +31 -0
  75. package/dist/render/index.js +222 -0
  76. package/dist/render/indicators.d.ts +2 -0
  77. package/dist/render/indicators.js +16 -0
  78. package/dist/render/json.d.ts +2 -0
  79. package/dist/render/json.js +10 -0
  80. package/dist/render/layout.d.ts +5 -0
  81. package/dist/render/layout.js +22 -0
  82. package/dist/render/list.d.ts +2 -0
  83. package/dist/render/list.js +8 -0
  84. package/dist/render/markdown.d.ts +2 -0
  85. package/dist/render/markdown.js +8 -0
  86. package/dist/render/progress.d.ts +2 -0
  87. package/dist/render/progress.js +8 -0
  88. package/dist/render/separator.d.ts +3 -0
  89. package/dist/render/separator.js +11 -0
  90. package/dist/render/shapes.d.ts +2 -0
  91. package/dist/render/shapes.js +32 -0
  92. package/dist/render/spinner.d.ts +2 -0
  93. package/dist/render/spinner.js +12 -0
  94. package/dist/render/stack.d.ts +3 -0
  95. package/dist/render/stack.js +35 -0
  96. package/dist/render/table.d.ts +3 -0
  97. package/dist/render/table.js +9 -0
  98. package/dist/render/tree.d.ts +2 -0
  99. package/dist/render/tree.js +10 -0
  100. package/dist/render/types.d.ts +2 -0
  101. package/dist/render/types.js +1 -0
  102. package/dist/shared/@outfitter/tui-011579t8.d.ts +24 -0
  103. package/dist/shared/@outfitter/tui-06dntkse.js +146 -0
  104. package/dist/shared/@outfitter/tui-0awf316b.js +71 -0
  105. package/dist/shared/@outfitter/tui-0b85rht7.js +1 -0
  106. package/dist/shared/@outfitter/tui-0mpqnyc1.js +55 -0
  107. package/dist/shared/@outfitter/tui-1qh888th.d.ts +106 -0
  108. package/dist/shared/@outfitter/tui-1tk0kxa6.js +94 -0
  109. package/dist/shared/@outfitter/tui-1wggw2zj.d.ts +56 -0
  110. package/dist/shared/@outfitter/tui-2pwhzg55.js +123 -0
  111. package/dist/shared/@outfitter/tui-2tkva96b.d.ts +20 -0
  112. package/dist/shared/@outfitter/tui-2wfat6jb.js +22 -0
  113. package/dist/shared/@outfitter/tui-34q2aenf.d.ts +24 -0
  114. package/dist/shared/@outfitter/tui-37hjcqhb.d.ts +3 -0
  115. package/dist/shared/@outfitter/tui-3dyxg62j.d.ts +97 -0
  116. package/dist/shared/@outfitter/tui-3kza6p9k.d.ts +132 -0
  117. package/dist/shared/@outfitter/tui-43bnfxv9.js +30 -0
  118. package/dist/shared/@outfitter/tui-4yz7jcyq.js +214 -0
  119. package/dist/shared/@outfitter/tui-52ndmswq.js +23 -0
  120. package/dist/shared/@outfitter/tui-53ms1ba4.d.ts +41 -0
  121. package/dist/shared/@outfitter/tui-5dsn6d6d.js +86 -0
  122. package/dist/shared/@outfitter/tui-5pb72vf9.js +51 -0
  123. package/dist/shared/@outfitter/tui-6605wa2j.js +127 -0
  124. package/dist/shared/@outfitter/tui-6ptks7jj.js +19 -0
  125. package/dist/shared/@outfitter/tui-6svngg69.js +126 -0
  126. package/dist/shared/@outfitter/tui-733asbd8.js +37 -0
  127. package/dist/shared/@outfitter/tui-75bztyfp.d.ts +50 -0
  128. package/dist/shared/@outfitter/tui-83zaah9b.d.ts +17 -0
  129. package/dist/shared/@outfitter/tui-8ejx8gq5.d.ts +71 -0
  130. package/dist/shared/@outfitter/tui-8j1gbehy.d.ts +164 -0
  131. package/dist/shared/@outfitter/tui-8mypsnva.d.ts +74 -0
  132. package/dist/shared/@outfitter/tui-997aapz0.js +61 -0
  133. package/dist/shared/@outfitter/tui-9dbykt4g.d.ts +42 -0
  134. package/dist/shared/@outfitter/tui-9h1kdd98.d.ts +119 -0
  135. package/dist/shared/@outfitter/tui-9rj9yesd.js +118 -0
  136. package/dist/shared/@outfitter/tui-a65efhsk.d.ts +23 -0
  137. package/dist/shared/@outfitter/tui-a8nkrbds.js +1 -0
  138. package/dist/shared/@outfitter/tui-ajp1153q.d.ts +59 -0
  139. package/dist/shared/@outfitter/tui-ay1fv41j.d.ts +30 -0
  140. package/dist/shared/@outfitter/tui-azh1w4ak.js +67 -0
  141. package/dist/shared/@outfitter/tui-b14ry1j1.d.ts +53 -0
  142. package/dist/shared/@outfitter/tui-c56sxcm8.d.ts +87 -0
  143. package/dist/shared/@outfitter/tui-c6ft5w6q.d.ts +91 -0
  144. package/dist/shared/@outfitter/tui-cq7za0cz.js +62 -0
  145. package/dist/shared/@outfitter/tui-dh15zwg0.js +95 -0
  146. package/dist/shared/@outfitter/tui-esc46z2v.js +20 -0
  147. package/dist/shared/@outfitter/tui-f1mj6h6p.d.ts +2 -0
  148. package/dist/shared/@outfitter/tui-gcpz529w.js +122 -0
  149. package/dist/shared/@outfitter/tui-gqsdhmk9.d.ts +42 -0
  150. package/dist/shared/@outfitter/tui-hescagw2.js +32 -0
  151. package/dist/shared/@outfitter/tui-j2kd7eej.js +126 -0
  152. package/dist/shared/@outfitter/tui-j3bkjt2g.js +7 -0
  153. package/dist/shared/@outfitter/tui-jnn9d8cd.js +8 -0
  154. package/dist/shared/@outfitter/tui-jz5nws55.d.ts +51 -0
  155. package/dist/shared/@outfitter/tui-k3mby2kk.js +70 -0
  156. package/dist/shared/@outfitter/tui-kc4nxak0.js +20 -0
  157. package/dist/shared/@outfitter/tui-kcxv8txp.js +7 -0
  158. package/dist/shared/@outfitter/tui-kydbggmj.js +39 -0
  159. package/dist/shared/@outfitter/tui-mch672g9.js +30 -0
  160. package/dist/shared/@outfitter/tui-n9kxkdrh.js +82 -0
  161. package/dist/shared/@outfitter/tui-na4dnjpw.js +348 -0
  162. package/dist/shared/@outfitter/tui-ncaatp4j.js +25 -0
  163. package/dist/shared/@outfitter/tui-nce7fgtf.js +48 -0
  164. package/dist/shared/@outfitter/tui-ngz2fbdw.js +144 -0
  165. package/dist/shared/@outfitter/tui-nprd7g0d.js +52 -0
  166. package/dist/shared/@outfitter/tui-nr580mbv.js +272 -0
  167. package/dist/shared/@outfitter/tui-nr93tf31.d.ts +64 -0
  168. package/dist/shared/@outfitter/tui-pdwbbzwr.js +179 -0
  169. package/dist/shared/@outfitter/tui-qb07rtct.js +19 -0
  170. package/dist/shared/@outfitter/tui-qkyazctw.d.ts +36 -0
  171. package/dist/shared/@outfitter/tui-qn1rgz9v.d.ts +93 -0
  172. package/dist/shared/@outfitter/tui-qs3fhwp8.js +43 -0
  173. package/dist/shared/@outfitter/tui-r8hywf9m.d.ts +48 -0
  174. package/dist/shared/@outfitter/tui-rbbcc034.js +20 -0
  175. package/dist/shared/@outfitter/tui-rgkerz72.js +85 -0
  176. package/dist/shared/@outfitter/tui-rh52sycm.d.ts +45 -0
  177. package/dist/shared/@outfitter/tui-rr924x4z.d.ts +59 -0
  178. package/dist/shared/@outfitter/tui-rwpdjrt3.js +20 -0
  179. package/dist/shared/@outfitter/tui-rx9xq9s7.d.ts +26 -0
  180. package/dist/shared/@outfitter/tui-sk05ye6g.js +1 -0
  181. package/dist/shared/@outfitter/tui-sv2xmh3w.d.ts +26 -0
  182. package/dist/shared/@outfitter/tui-t1a9xgbd.js +111 -0
  183. package/dist/shared/@outfitter/tui-t9vd88jr.js +273 -0
  184. package/dist/shared/@outfitter/tui-tq1z78x0.js +11 -0
  185. package/dist/shared/@outfitter/tui-ts1f957s.d.ts +128 -0
  186. package/dist/shared/@outfitter/tui-ve0083wa.d.ts +61 -0
  187. package/dist/shared/@outfitter/tui-vt0wg6c4.js +54 -0
  188. package/dist/shared/@outfitter/tui-wfnnq0zq.d.ts +328 -0
  189. package/dist/shared/@outfitter/tui-x3yg0887.d.ts +223 -0
  190. package/dist/shared/@outfitter/tui-x9vvtfkk.js +20 -0
  191. package/dist/shared/@outfitter/tui-xbvz707j.js +20 -0
  192. package/dist/shared/@outfitter/tui-xbx6d4t7.js +1 -0
  193. package/dist/shared/@outfitter/tui-xph95b7h.js +67 -0
  194. package/dist/shared/@outfitter/tui-xqjx7d1f.js +135 -0
  195. package/dist/shared/@outfitter/tui-xrgrp99k.d.ts +112 -0
  196. package/dist/shared/@outfitter/tui-xzjv96ps.d.ts +300 -0
  197. package/dist/shared/@outfitter/tui-ykzs6v4v.d.ts +66 -0
  198. package/dist/shared/@outfitter/tui-yw9n5h6q.d.ts +54 -0
  199. package/dist/shared/@outfitter/tui-ywmakc6b.js +30 -0
  200. package/dist/shared/@outfitter/tui-z6nf9b9h.js +7 -0
  201. package/dist/shared/@outfitter/tui-zcspg6z6.d.ts +190 -0
  202. package/dist/shared/@outfitter/tui-zhbsnj7w.js +1 -0
  203. package/dist/streaming/ansi.d.ts +2 -0
  204. package/dist/streaming/ansi.js +8 -0
  205. package/dist/streaming/index.d.ts +4 -0
  206. package/dist/streaming/index.js +17 -0
  207. package/dist/streaming/spinner.d.ts +3 -0
  208. package/dist/streaming/spinner.js +10 -0
  209. package/dist/streaming/writer.d.ts +2 -0
  210. package/dist/streaming/writer.js +9 -0
  211. package/dist/table/index.d.ts +4 -0
  212. package/dist/table/index.js +10 -0
  213. package/dist/theme/context.d.ts +9 -0
  214. package/dist/theme/context.js +12 -0
  215. package/dist/theme/create.d.ts +8 -0
  216. package/dist/theme/create.js +10 -0
  217. package/dist/theme/index.d.ts +17 -0
  218. package/dist/theme/index.js +40 -0
  219. package/dist/theme/presets/bold.d.ts +8 -0
  220. package/dist/theme/presets/bold.js +10 -0
  221. package/dist/theme/presets/default.d.ts +8 -0
  222. package/dist/theme/presets/default.js +9 -0
  223. package/dist/theme/presets/index.d.ts +12 -0
  224. package/dist/theme/presets/index.js +22 -0
  225. package/dist/theme/presets/minimal.d.ts +8 -0
  226. package/dist/theme/presets/minimal.js +10 -0
  227. package/dist/theme/presets/rounded.d.ts +8 -0
  228. package/dist/theme/presets/rounded.js +10 -0
  229. package/dist/theme/resolve.d.ts +8 -0
  230. package/dist/theme/resolve.js +11 -0
  231. package/dist/theme/types.d.ts +7 -0
  232. package/dist/theme/types.js +1 -0
  233. package/dist/tree/index.d.ts +3 -0
  234. package/dist/tree/index.js +11 -0
  235. package/package.json +263 -0
@@ -0,0 +1,87 @@
1
+ import { Validator } from "./tui-8mypsnva";
2
+ import { Result } from "better-result";
3
+ /**
4
+ * Error returned when user cancels a prompt.
5
+ */
6
+ interface CancelledError {
7
+ type: "cancelled";
8
+ message: string;
9
+ }
10
+ /**
11
+ * Creates a cancelled error.
12
+ */
13
+ declare function createCancelledError(message?: string): CancelledError;
14
+ /**
15
+ * Options for text prompts.
16
+ */
17
+ interface TextPromptOptions {
18
+ /** Prompt message to display */
19
+ message: string;
20
+ /** Placeholder text */
21
+ placeholder?: string;
22
+ /** Default value */
23
+ defaultValue?: string;
24
+ /** Validation function */
25
+ validate?: Validator;
26
+ }
27
+ /**
28
+ * Options for password prompts.
29
+ */
30
+ interface PasswordPromptOptions {
31
+ /** Prompt message to display */
32
+ message: string;
33
+ /** Validation function */
34
+ validate?: Validator;
35
+ /** Mask character (default: •) */
36
+ mask?: string;
37
+ }
38
+ /**
39
+ * Options for select prompts.
40
+ */
41
+ interface SelectPromptOptions<T> {
42
+ /** Prompt message to display */
43
+ message: string;
44
+ /** Available options */
45
+ options: Array<{
46
+ value: T;
47
+ label: string;
48
+ hint?: string;
49
+ }>;
50
+ /** Initial selected index */
51
+ initialValue?: T;
52
+ /** Maximum number of items to display at once */
53
+ pageSize?: number;
54
+ }
55
+ /**
56
+ * Options for multi-select prompts.
57
+ */
58
+ interface MultiSelectPromptOptions<T> {
59
+ /** Prompt message to display */
60
+ message: string;
61
+ /** Available options */
62
+ options: Array<{
63
+ value: T;
64
+ label: string;
65
+ hint?: string;
66
+ }>;
67
+ /** Initially selected values */
68
+ initialValues?: T[];
69
+ /** Require at least one selection */
70
+ required?: boolean;
71
+ /** Maximum number of items to display at once */
72
+ pageSize?: number;
73
+ }
74
+ /**
75
+ * Options for confirm prompts.
76
+ */
77
+ interface ConfirmPromptOptions {
78
+ /** Prompt message to display */
79
+ message: string;
80
+ /** Initial value */
81
+ initialValue?: boolean;
82
+ }
83
+ /**
84
+ * Type alias for prompt results.
85
+ */
86
+ type PromptResult<T> = Promise<Result<T, CancelledError>>;
87
+ export { CancelledError, createCancelledError, TextPromptOptions, PasswordPromptOptions, SelectPromptOptions, MultiSelectPromptOptions, ConfirmPromptOptions, PromptResult };
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Spinner rendering utilities.
3
+ *
4
+ * Provides animated spinner frames for async operations with
5
+ * multiple styles and graceful degradation for non-TTY contexts.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ /**
10
+ * Available spinner animation styles.
11
+ *
12
+ * - `dots`: Braille dots animation (default, smooth)
13
+ * - `line`: Classic ASCII spinner (-\|/)
14
+ * - `arc`: Corner arc rotation
15
+ * - `circle`: Half-filled circle rotation
16
+ * - `bounce`: Bouncing dot (vertical)
17
+ * - `ping`: Bouncing dot in brackets (horizontal)
18
+ */
19
+ type SpinnerStyle = "dots" | "line" | "arc" | "circle" | "bounce" | "ping";
20
+ /**
21
+ * Spinner animation frame definition.
22
+ */
23
+ interface SpinnerFrames {
24
+ /** Array of characters to cycle through */
25
+ frames: string[];
26
+ /** Milliseconds between frame changes */
27
+ interval: number;
28
+ }
29
+ /**
30
+ * Predefined spinner animations.
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const dotsSpinner = SPINNERS.dots;
35
+ * console.log(dotsSpinner.frames[0]); // "⠋"
36
+ * console.log(dotsSpinner.interval); // 80
37
+ * ```
38
+ */
39
+ declare const SPINNERS: Record<SpinnerStyle, SpinnerFrames>;
40
+ /**
41
+ * Gets the spinner frame for a given elapsed time.
42
+ *
43
+ * Calculates which frame to display based on elapsed milliseconds
44
+ * and the spinner's interval setting. Automatically wraps around
45
+ * when the elapsed time exceeds a full cycle.
46
+ *
47
+ * @param style - The spinner style to use
48
+ * @param elapsed - Elapsed time in milliseconds since spinner started
49
+ * @returns The frame character to display
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * // Get frame at start
54
+ * getSpinnerFrame("dots", 0); // "⠋"
55
+ *
56
+ * // Get frame after 160ms
57
+ * getSpinnerFrame("dots", 160); // "⠹" (third frame)
58
+ *
59
+ * // Frames wrap around automatically
60
+ * const fullCycle = SPINNERS.dots.interval * SPINNERS.dots.frames.length;
61
+ * getSpinnerFrame("dots", fullCycle); // "⠋" (back to first)
62
+ * ```
63
+ */
64
+ declare function getSpinnerFrame(style: SpinnerStyle, elapsed: number): string;
65
+ /**
66
+ * Renders a static spinner frame with optional message.
67
+ *
68
+ * This is the non-interactive version for logging and non-TTY contexts.
69
+ * For animated spinners, use the elapsed parameter with `getSpinnerFrame()`.
70
+ *
71
+ * @param style - The spinner style to use
72
+ * @param message - Optional message to display after the spinner
73
+ * @returns Formatted spinner string
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * // Simple spinner
78
+ * console.log(renderSpinner("dots"));
79
+ * // "⠋"
80
+ *
81
+ * // Spinner with message
82
+ * console.log(renderSpinner("dots", "Loading..."));
83
+ * // "⠋ Loading..."
84
+ *
85
+ * // For logs (non-TTY)
86
+ * logger.info(renderSpinner("line", "Fetching data"));
87
+ * // "- Fetching data"
88
+ * ```
89
+ */
90
+ declare function renderSpinner(style: SpinnerStyle, message?: string): string;
91
+ export { SpinnerStyle, SpinnerFrames, SPINNERS, getSpinnerFrame, renderSpinner };
@@ -0,0 +1,62 @@
1
+ // @bun
2
+ import {
3
+ demoSection
4
+ } from "./tui-733asbd8.js";
5
+ import {
6
+ BORDER_STYLE_META,
7
+ getBorderStyles
8
+ } from "./tui-nr580mbv.js";
9
+ import {
10
+ BORDERS,
11
+ drawHorizontalLine,
12
+ init_borders
13
+ } from "./tui-2pwhzg55.js";
14
+
15
+ // packages/tui/src/demo/renderers/borders.ts
16
+ init_borders();
17
+ function renderBordersDemo(config, theme) {
18
+ const showCode = config.showCode ?? true;
19
+ const showDescriptions = config.showDescriptions ?? true;
20
+ const lines = [];
21
+ lines.push(demoSection("Border Styles"));
22
+ lines.push("");
23
+ if (showCode) {
24
+ lines.push('import { BORDERS, getBorderCharacters } from "@outfitter/tui/render";');
25
+ lines.push("");
26
+ }
27
+ const styles = getBorderStyles().filter((s) => s !== "none");
28
+ for (const style of styles) {
29
+ const meta = BORDER_STYLE_META[style];
30
+ const chars = BORDERS[style];
31
+ lines.push(`${meta.label.toUpperCase()} (${style})`);
32
+ if (showDescriptions) {
33
+ lines.push(theme.muted(meta.description));
34
+ }
35
+ lines.push("");
36
+ const width = 20;
37
+ lines.push(drawHorizontalLine(width, chars, "top"));
38
+ lines.push(`${chars.vertical}${" ".repeat(width)}${chars.vertical}`);
39
+ lines.push(`${chars.vertical}${" Content here".padEnd(width)}${chars.vertical}`);
40
+ lines.push(`${chars.vertical}${" ".repeat(width)}${chars.vertical}`);
41
+ lines.push(drawHorizontalLine(width, chars, "bottom"));
42
+ lines.push("");
43
+ }
44
+ lines.push(demoSection("Characters Reference"));
45
+ lines.push("");
46
+ for (const style of styles) {
47
+ const chars = BORDERS[style];
48
+ const meta = BORDER_STYLE_META[style];
49
+ lines.push(`${meta.label}:`);
50
+ const charDisplay = [
51
+ ` Corners: ${chars.topLeft} ${chars.topRight} ${chars.bottomLeft} ${chars.bottomRight}`,
52
+ ` Lines: ${chars.horizontal} ${chars.vertical}`,
53
+ ` T's: ${chars.topT} ${chars.bottomT} ${chars.leftT} ${chars.rightT} Cross: ${chars.cross}`
54
+ ];
55
+ lines.push(...charDisplay);
56
+ lines.push("");
57
+ }
58
+ return lines.join(`
59
+ `);
60
+ }
61
+
62
+ export { renderBordersDemo };
@@ -0,0 +1,95 @@
1
+ // @bun
2
+ import {
3
+ ANSI
4
+ } from "./tui-2wfat6jb.js";
5
+ import {
6
+ getIndicator
7
+ } from "./tui-pdwbbzwr.js";
8
+
9
+ // packages/tui/src/streaming/spinner.ts
10
+ var SPINNER_FRAMES = {
11
+ dots: ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"],
12
+ line: ["-", "\\", "|", "/"],
13
+ simple: ["\u25D0", "\u25D3", "\u25D1", "\u25D2"]
14
+ };
15
+ function createSpinner(message, options = {}) {
16
+ const stream = options.stream ?? process.stdout;
17
+ const isTTY = stream.isTTY ?? false;
18
+ const style = options.style ?? "dots";
19
+ const interval = options.interval ?? 80;
20
+ const frames = SPINNER_FRAMES[style];
21
+ let frameIndex = 0;
22
+ let currentMessage = message;
23
+ let timer = null;
24
+ let isRunning = false;
25
+ const render = () => {
26
+ if (!isTTY) {
27
+ return;
28
+ }
29
+ const frame = frames[frameIndex % frames.length];
30
+ stream.write(`${ANSI.carriageReturn}${ANSI.clearLine}${frame} ${currentMessage}`);
31
+ frameIndex++;
32
+ };
33
+ const start = () => {
34
+ if (isRunning)
35
+ return;
36
+ isRunning = true;
37
+ if (!isTTY) {
38
+ stream.write(`- ${currentMessage}
39
+ `);
40
+ return;
41
+ }
42
+ stream.write(ANSI.hideCursor);
43
+ render();
44
+ timer = setInterval(render, interval);
45
+ };
46
+ const update = (newMessage) => {
47
+ currentMessage = newMessage;
48
+ if (!isTTY) {
49
+ stream.write(`- ${currentMessage}
50
+ `);
51
+ return;
52
+ }
53
+ if (isRunning) {
54
+ render();
55
+ }
56
+ };
57
+ const stopWith = (symbol, finalMessage) => {
58
+ if (timer) {
59
+ clearInterval(timer);
60
+ timer = null;
61
+ }
62
+ const msg = finalMessage ?? currentMessage;
63
+ if (isTTY) {
64
+ stream.write(`${ANSI.carriageReturn}${ANSI.clearLine}${symbol} ${msg}
65
+ `);
66
+ stream.write(ANSI.showCursor);
67
+ } else {
68
+ stream.write(`${symbol} ${msg}
69
+ `);
70
+ }
71
+ isRunning = false;
72
+ };
73
+ const succeed = (finalMessage) => {
74
+ const symbol = getIndicator("status", "success", isTTY);
75
+ stopWith(symbol, finalMessage);
76
+ };
77
+ const fail = (finalMessage) => {
78
+ const symbol = getIndicator("status", "error", isTTY);
79
+ stopWith(symbol, finalMessage);
80
+ };
81
+ const stop = () => {
82
+ if (timer) {
83
+ clearInterval(timer);
84
+ timer = null;
85
+ }
86
+ if (isTTY && isRunning) {
87
+ stream.write(`${ANSI.carriageReturn}${ANSI.clearLine}`);
88
+ stream.write(ANSI.showCursor);
89
+ }
90
+ isRunning = false;
91
+ };
92
+ return { start, update, succeed, fail, stop };
93
+ }
94
+
95
+ export { createSpinner };
@@ -0,0 +1,20 @@
1
+ // @bun
2
+ import {
3
+ defaultTheme
4
+ } from "./tui-0mpqnyc1.js";
5
+ import {
6
+ BORDERS,
7
+ init_borders
8
+ } from "./tui-2pwhzg55.js";
9
+
10
+ // packages/tui/src/theme/presets/rounded.ts
11
+ init_borders();
12
+ var roundedTheme = {
13
+ ...defaultTheme,
14
+ name: "rounded",
15
+ border: "rounded",
16
+ borderChars: BORDERS.rounded,
17
+ treeGuide: "rounded"
18
+ };
19
+
20
+ export { roundedTheme };
@@ -0,0 +1,2 @@
1
+ import { ANSI, createTheme, Theme, Tokens } from "@outfitter/cli/colors";
2
+ export { ANSI, createTheme, Theme, Tokens };
@@ -0,0 +1,122 @@
1
+ // @bun
2
+ import {
3
+ getExample
4
+ } from "./tui-nprd7g0d.js";
5
+ import {
6
+ demoSection
7
+ } from "./tui-733asbd8.js";
8
+ import {
9
+ TREE_GUIDES,
10
+ renderTree
11
+ } from "./tui-kydbggmj.js";
12
+
13
+ // packages/tui/src/demo/renderers/tree.ts
14
+ function renderTreeDemo(config, _theme) {
15
+ const showCode = config.showCode ?? true;
16
+ const lines = [];
17
+ lines.push(demoSection("Basic Tree"));
18
+ lines.push("");
19
+ if (showCode) {
20
+ lines.push('import { renderTree } from "@outfitter/tui/tree";');
21
+ lines.push("");
22
+ }
23
+ const treeData = getExample("treeData", config.examples);
24
+ if (showCode) {
25
+ lines.push("renderTree({");
26
+ lines.push(" src: {");
27
+ lines.push(" components: { Button: null, Input: null },");
28
+ lines.push(" utils: null,");
29
+ lines.push(" },");
30
+ lines.push(" tests: null,");
31
+ lines.push("})");
32
+ lines.push("");
33
+ }
34
+ lines.push(renderTree(treeData));
35
+ lines.push("");
36
+ lines.push(demoSection("Guide Styles"));
37
+ lines.push("");
38
+ const guideDemo = {
39
+ root: {
40
+ child1: {
41
+ leaf: null
42
+ },
43
+ child2: null
44
+ }
45
+ };
46
+ const guideStyles = [
47
+ "single",
48
+ "rounded",
49
+ "heavy",
50
+ "double"
51
+ ];
52
+ for (const style of guideStyles) {
53
+ const guide = TREE_GUIDES[style];
54
+ lines.push(`${style.toUpperCase()} (fork: "${guide.fork.trim()}", end: "${guide.end.trim()}")`);
55
+ lines.push("");
56
+ lines.push(renderTree(guideDemo, { guide: style }));
57
+ lines.push("");
58
+ }
59
+ lines.push(demoSection("Max Depth"));
60
+ lines.push("");
61
+ const deepTree = {
62
+ level1: {
63
+ level2: {
64
+ level3: {
65
+ level4: null
66
+ }
67
+ }
68
+ }
69
+ };
70
+ if (showCode) {
71
+ lines.push("renderTree(tree, { maxDepth: 2 })");
72
+ lines.push("");
73
+ }
74
+ lines.push("Full tree:");
75
+ lines.push(renderTree(deepTree));
76
+ lines.push("");
77
+ lines.push("With maxDepth: 2:");
78
+ lines.push(renderTree(deepTree, { maxDepth: 2 }));
79
+ lines.push("");
80
+ lines.push(demoSection("Custom Labels"));
81
+ lines.push("");
82
+ const fileTree = {
83
+ src: {
84
+ "index.ts": null,
85
+ components: {
86
+ "Button.tsx": null
87
+ }
88
+ },
89
+ "package.json": null
90
+ };
91
+ if (showCode) {
92
+ lines.push("renderTree(tree, {");
93
+ lines.push(" renderLabel: (key, value) => {");
94
+ lines.push(" if (value && typeof value === 'object') {");
95
+ lines.push(" return `\uD83D\uDCC1 ${key}/`;");
96
+ lines.push(" }");
97
+ lines.push(" return `\uD83D\uDCC4 ${key}`;");
98
+ lines.push(" }");
99
+ lines.push("})");
100
+ lines.push("");
101
+ }
102
+ lines.push(renderTree(fileTree, {
103
+ renderLabel: (key, value) => {
104
+ if (value && typeof value === "object") {
105
+ return `\uD83D\uDCC1 ${key}/`;
106
+ }
107
+ return `\uD83D\uDCC4 ${key}`;
108
+ }
109
+ }));
110
+ lines.push("");
111
+ lines.push(demoSection("Usage Notes"));
112
+ lines.push("");
113
+ lines.push("\u2022 Objects become branches with children");
114
+ lines.push("\u2022 null values become leaf nodes (terminal)");
115
+ lines.push("\u2022 Use guide option to change visual style");
116
+ lines.push("\u2022 Use maxDepth to limit rendering depth");
117
+ lines.push("\u2022 Use renderLabel for custom node formatting");
118
+ return lines.join(`
119
+ `);
120
+ }
121
+
122
+ export { renderTreeDemo };
@@ -0,0 +1,42 @@
1
+ /**
2
+ * JSON and text rendering utilities.
3
+ *
4
+ * Simple renderers for JSON and plain text output.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ /**
9
+ * Renders data as pretty-printed JSON.
10
+ *
11
+ * Uses `JSON.stringify` with 2-space indentation.
12
+ * Suitable for displaying structured data in terminal output.
13
+ *
14
+ * @param data - Data to render as JSON
15
+ * @returns Pretty-printed JSON string
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * console.log(renderJson({ name: "test", value: 42 }));
20
+ * // {
21
+ * // "name": "test",
22
+ * // "value": 42
23
+ * // }
24
+ * ```
25
+ */
26
+ declare function renderJson(data: unknown): string;
27
+ /**
28
+ * Renders plain text unchanged.
29
+ *
30
+ * This is a pass-through function that returns the input text as-is.
31
+ * Useful as a placeholder or for consistent API across render functions.
32
+ *
33
+ * @param text - Text to render
34
+ * @returns The input text unchanged
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * renderText("Hello, World!"); // "Hello, World!"
39
+ * ```
40
+ */
41
+ declare function renderText(text: string): string;
42
+ export { renderJson, renderText };
@@ -0,0 +1,32 @@
1
+ // @bun
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __moduleCache = /* @__PURE__ */ new WeakMap;
7
+ var __toCommonJS = (from) => {
8
+ var entry = __moduleCache.get(from), desc;
9
+ if (entry)
10
+ return entry;
11
+ entry = __defProp({}, "__esModule", { value: true });
12
+ if (from && typeof from === "object" || typeof from === "function")
13
+ __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
14
+ get: () => from[key],
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ }));
17
+ __moduleCache.set(from, entry);
18
+ return entry;
19
+ };
20
+ var __export = (target, all) => {
21
+ for (var name in all)
22
+ __defProp(target, name, {
23
+ get: all[name],
24
+ enumerable: true,
25
+ configurable: true,
26
+ set: (newValue) => all[name] = () => newValue
27
+ });
28
+ };
29
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
30
+ var __require = import.meta.require;
31
+
32
+ export { __toCommonJS, __export, __esm, __require };
@@ -0,0 +1,126 @@
1
+ // @bun
2
+ import {
3
+ getExample
4
+ } from "./tui-nprd7g0d.js";
5
+ import {
6
+ demoSection
7
+ } from "./tui-733asbd8.js";
8
+ import {
9
+ LIST_STYLE_META,
10
+ getListStyles
11
+ } from "./tui-nr580mbv.js";
12
+ import {
13
+ renderList
14
+ } from "./tui-5dsn6d6d.js";
15
+
16
+ // packages/tui/src/demo/renderers/list.ts
17
+ function renderListDemo(config, theme) {
18
+ const showCode = config.showCode ?? true;
19
+ const showDescriptions = config.showDescriptions ?? true;
20
+ const lines = [];
21
+ lines.push(demoSection("List Styles"));
22
+ lines.push("");
23
+ if (showCode) {
24
+ lines.push('import { renderList } from "@outfitter/tui/render";');
25
+ lines.push("");
26
+ }
27
+ const items = getExample("listItems", config.examples);
28
+ const styles = getListStyles();
29
+ for (const style of styles) {
30
+ const meta = LIST_STYLE_META[style];
31
+ lines.push(`${meta.label.toUpperCase()} STYLE`);
32
+ if (showDescriptions) {
33
+ lines.push(theme.muted(meta.description));
34
+ }
35
+ lines.push("");
36
+ if (showCode) {
37
+ lines.push(`renderList(items, { style: "${style}" })`);
38
+ lines.push("");
39
+ }
40
+ if (style === "checkbox") {
41
+ const output = renderList(items, {
42
+ style,
43
+ checked: new Set([1])
44
+ });
45
+ lines.push(output);
46
+ } else {
47
+ const output = renderList(items, { style });
48
+ lines.push(output);
49
+ }
50
+ lines.push("");
51
+ }
52
+ lines.push(demoSection("Nested Lists"));
53
+ lines.push("");
54
+ const nestedItems = [
55
+ "Top level item",
56
+ {
57
+ text: "Parent with children",
58
+ children: ["Child one", "Child two"]
59
+ },
60
+ "Another top level"
61
+ ];
62
+ if (showCode) {
63
+ lines.push("renderList([");
64
+ lines.push(' "Top level item",');
65
+ lines.push(' { text: "Parent with children", children: ["Child one", "Child two"] },');
66
+ lines.push(' "Another top level",');
67
+ lines.push("])");
68
+ lines.push("");
69
+ }
70
+ lines.push(renderList(nestedItems));
71
+ lines.push("");
72
+ lines.push(demoSection("Numbered with Nesting"));
73
+ lines.push("");
74
+ const numberedNested = [
75
+ {
76
+ text: "First section",
77
+ children: [
78
+ {
79
+ text: "Subsection A",
80
+ children: ["Detail i", "Detail ii"]
81
+ },
82
+ "Subsection B"
83
+ ]
84
+ },
85
+ "Second section"
86
+ ];
87
+ if (showCode) {
88
+ lines.push('renderList(items, { style: "number" })');
89
+ lines.push("");
90
+ }
91
+ lines.push(renderList(numberedNested, { style: "number" }));
92
+ lines.push("");
93
+ lines.push(demoSection("Mixed Styles"));
94
+ lines.push("");
95
+ if (showDescriptions) {
96
+ lines.push(theme.muted("Use childStyle to override style for children"));
97
+ lines.push("");
98
+ }
99
+ const mixedItems = [
100
+ {
101
+ text: "Requirements",
102
+ childStyle: "bullet",
103
+ children: ["Must be fast", "Must be reliable"]
104
+ },
105
+ {
106
+ text: "Tasks",
107
+ childStyle: "checkbox",
108
+ children: [
109
+ { text: "Write tests", checked: true },
110
+ { text: "Deploy to prod", checked: false }
111
+ ]
112
+ }
113
+ ];
114
+ if (showCode) {
115
+ lines.push("renderList([");
116
+ lines.push(' { text: "Requirements", childStyle: "bullet", children: [...] },');
117
+ lines.push(' { text: "Tasks", childStyle: "checkbox", children: [...] },');
118
+ lines.push('], { style: "number" })');
119
+ lines.push("");
120
+ }
121
+ lines.push(renderList(mixedItems, { style: "number" }));
122
+ return lines.join(`
123
+ `);
124
+ }
125
+
126
+ export { renderListDemo };
@@ -0,0 +1,7 @@
1
+ // @bun
2
+ import {
3
+ init_box
4
+ } from "./tui-t9vd88jr.js";
5
+
6
+ // packages/tui/src/box/index.ts
7
+ init_box();
@@ -0,0 +1,8 @@
1
+ // @bun
2
+ // packages/tui/src/preset/standard.ts
3
+ import {
4
+ ANSI,
5
+ createTheme
6
+ } from "@outfitter/cli/colors";
7
+
8
+ export { ANSI, createTheme };