@promptctl/rich-js 0.18.0 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/anchor.d.ts +45 -0
- package/dist/core/anchor.js +39 -0
- package/dist/core/ansi.d.ts +65 -0
- package/dist/core/ansi.js +231 -0
- package/dist/core/box.d.ts +143 -0
- package/dist/core/box.js +379 -0
- package/dist/core/cells.d.ts +159 -0
- package/dist/core/cells.js +287 -0
- package/dist/core/color.d.ts +246 -0
- package/dist/core/color.js +1038 -0
- package/dist/core/console.d.ts +165 -0
- package/dist/core/console.js +527 -0
- package/dist/core/emoji.d.ts +24 -0
- package/dist/core/emoji.js +391 -0
- package/dist/core/export-html.d.ts +59 -0
- package/dist/core/export-html.js +200 -0
- package/dist/core/export-lines.d.ts +121 -0
- package/dist/core/export-lines.js +141 -0
- package/dist/core/highlighter.d.ts +33 -0
- package/dist/core/highlighter.js +124 -0
- package/dist/core/json.d.ts +27 -0
- package/dist/core/json.js +53 -0
- package/dist/core/markup.d.ts +119 -0
- package/dist/core/markup.js +731 -0
- package/dist/core/measure.d.ts +27 -0
- package/dist/core/measure.js +62 -0
- package/dist/core/oklch.d.ts +161 -0
- package/dist/core/oklch.js +312 -0
- package/dist/core/osc8.d.ts +68 -0
- package/dist/core/osc8.js +90 -0
- package/dist/core/place.d.ts +30 -0
- package/dist/core/place.js +51 -0
- package/dist/core/pretty.d.ts +144 -0
- package/dist/core/pretty.js +476 -0
- package/dist/core/protocol.d.ts +267 -0
- package/dist/core/protocol.js +163 -0
- package/dist/core/render.d.ts +84 -0
- package/dist/core/render.js +145 -0
- package/dist/core/segment.d.ts +161 -0
- package/dist/core/segment.js +492 -0
- package/dist/core/spinnerData.d.ts +12 -0
- package/dist/core/spinnerData.js +117 -0
- package/dist/core/strip.d.ts +141 -0
- package/dist/core/strip.js +305 -0
- package/dist/core/style.d.ts +169 -0
- package/dist/core/style.js +695 -0
- package/dist/core/subscription.d.ts +12 -0
- package/dist/core/subscription.js +12 -0
- package/dist/core/text.d.ts +256 -0
- package/dist/core/text.js +976 -0
- package/dist/core/wrap.d.ts +41 -0
- package/dist/core/wrap.js +127 -0
- package/dist/host/app.d.ts +121 -0
- package/dist/host/app.js +255 -0
- package/dist/host/host-environment.d.ts +26 -0
- package/dist/host/host-environment.js +44 -0
- package/dist/host/index.d.ts +5 -0
- package/dist/host/index.js +3 -0
- package/dist/host/terminal-host.d.ts +179 -0
- package/dist/host/terminal-host.js +186 -0
- package/dist/index.d.ts +91 -0
- package/dist/index.js +107 -0
- package/dist/node/prompt.d.ts +21 -0
- package/dist/node/prompt.js +30 -0
- package/dist/node/save.d.ts +17 -0
- package/dist/node/save.js +21 -0
- package/dist/node/terminal-host.d.ts +113 -0
- package/dist/node/terminal-host.js +227 -0
- package/dist/node/traceback.d.ts +37 -0
- package/dist/node/traceback.js +134 -0
- package/dist/renderables/align.d.ts +16 -0
- package/dist/renderables/align.js +33 -0
- package/dist/renderables/columns.d.ts +61 -0
- package/dist/renderables/columns.js +152 -0
- package/dist/renderables/constrain.d.ts +15 -0
- package/dist/renderables/constrain.js +37 -0
- package/dist/renderables/embed.d.ts +50 -0
- package/dist/renderables/embed.js +71 -0
- package/dist/renderables/flexStrip.d.ts +41 -0
- package/dist/renderables/flexStrip.js +200 -0
- package/dist/renderables/group.d.ts +11 -0
- package/dist/renderables/group.js +17 -0
- package/dist/renderables/layout.d.ts +92 -0
- package/dist/renderables/layout.js +312 -0
- package/dist/renderables/live.d.ts +50 -0
- package/dist/renderables/live.js +175 -0
- package/dist/renderables/markdown.d.ts +24 -0
- package/dist/renderables/markdown.js +184 -0
- package/dist/renderables/padding.d.ts +38 -0
- package/dist/renderables/padding.js +141 -0
- package/dist/renderables/panel.d.ts +116 -0
- package/dist/renderables/panel.js +307 -0
- package/dist/renderables/progress.d.ts +90 -0
- package/dist/renderables/progress.js +238 -0
- package/dist/renderables/progressBar.d.ts +31 -0
- package/dist/renderables/progressBar.js +53 -0
- package/dist/renderables/prompt.d.ts +49 -0
- package/dist/renderables/prompt.js +125 -0
- package/dist/renderables/rule.d.ts +25 -0
- package/dist/renderables/rule.js +90 -0
- package/dist/renderables/spinner.d.ts +31 -0
- package/dist/renderables/spinner.js +70 -0
- package/dist/renderables/status.d.ts +23 -0
- package/dist/renderables/status.js +60 -0
- package/dist/renderables/syntax.d.ts +35 -0
- package/dist/renderables/syntax.js +115 -0
- package/dist/renderables/table.d.ts +194 -0
- package/dist/renderables/table.js +795 -0
- package/dist/renderables/traceback.d.ts +31 -0
- package/dist/renderables/traceback.js +108 -0
- package/dist/renderables/tree.d.ts +68 -0
- package/dist/renderables/tree.js +150 -0
- package/dist/renderables/viewport.d.ts +114 -0
- package/dist/renderables/viewport.js +198 -0
- package/dist/template-bindings/color-funcs.d.ts +87 -0
- package/dist/template-bindings/color-funcs.js +217 -0
- package/dist/template-bindings/helpers.d.ts +24 -0
- package/dist/template-bindings/helpers.js +48 -0
- package/dist/template-bindings/index.d.ts +107 -0
- package/dist/template-bindings/index.js +146 -0
- package/dist/template-bindings/palette-funcs.d.ts +94 -0
- package/dist/template-bindings/palette-funcs.js +141 -0
- package/dist/template-bindings/style-funcs.d.ts +28 -0
- package/dist/template-bindings/style-funcs.js +155 -0
- package/dist/themes/buildPalette.d.ts +36 -0
- package/dist/themes/buildPalette.js +56 -0
- package/dist/themes/colorMath.d.ts +82 -0
- package/dist/themes/colorMath.js +254 -0
- package/dist/themes/colorRef.d.ts +51 -0
- package/dist/themes/colorRef.js +96 -0
- package/dist/themes/data/ansi-tables.d.ts +14 -0
- package/dist/themes/data/ansi-tables.js +49 -0
- package/dist/themes/data/atom-one-dark.d.ts +3 -0
- package/dist/themes/data/atom-one-dark.js +177 -0
- package/dist/themes/data/atom-one-light.d.ts +3 -0
- package/dist/themes/data/atom-one-light.js +177 -0
- package/dist/themes/data/catppuccin-frappe.d.ts +3 -0
- package/dist/themes/data/catppuccin-frappe.js +177 -0
- package/dist/themes/data/catppuccin-latte.d.ts +3 -0
- package/dist/themes/data/catppuccin-latte.js +177 -0
- package/dist/themes/data/catppuccin-macchiato.d.ts +3 -0
- package/dist/themes/data/catppuccin-macchiato.js +177 -0
- package/dist/themes/data/catppuccin-mocha.d.ts +3 -0
- package/dist/themes/data/catppuccin-mocha.js +177 -0
- package/dist/themes/data/cyberpunk.d.ts +17 -0
- package/dist/themes/data/cyberpunk.js +193 -0
- package/dist/themes/data/default.d.ts +3 -0
- package/dist/themes/data/default.js +160 -0
- package/dist/themes/data/dracula.d.ts +3 -0
- package/dist/themes/data/dracula.js +177 -0
- package/dist/themes/data/flexoki.d.ts +3 -0
- package/dist/themes/data/flexoki.js +177 -0
- package/dist/themes/data/gruvbox.d.ts +3 -0
- package/dist/themes/data/gruvbox.js +177 -0
- package/dist/themes/data/index.d.ts +35 -0
- package/dist/themes/data/index.js +64 -0
- package/dist/themes/data/monokai.d.ts +3 -0
- package/dist/themes/data/monokai.js +177 -0
- package/dist/themes/data/nord.d.ts +3 -0
- package/dist/themes/data/nord.js +177 -0
- package/dist/themes/data/rose-pine-dawn.d.ts +3 -0
- package/dist/themes/data/rose-pine-dawn.js +177 -0
- package/dist/themes/data/rose-pine-moon.d.ts +3 -0
- package/dist/themes/data/rose-pine-moon.js +177 -0
- package/dist/themes/data/rose-pine.d.ts +3 -0
- package/dist/themes/data/rose-pine.js +177 -0
- package/dist/themes/data/solarized-dark.d.ts +3 -0
- package/dist/themes/data/solarized-dark.js +177 -0
- package/dist/themes/data/solarized-light.d.ts +3 -0
- package/dist/themes/data/solarized-light.js +177 -0
- package/dist/themes/data/svg-export.d.ts +3 -0
- package/dist/themes/data/svg-export.js +177 -0
- package/dist/themes/data/textual-ansi.d.ts +3 -0
- package/dist/themes/data/textual-ansi.js +160 -0
- package/dist/themes/data/textual-dark.d.ts +3 -0
- package/dist/themes/data/textual-dark.js +160 -0
- package/dist/themes/data/textual-light.d.ts +3 -0
- package/dist/themes/data/textual-light.js +160 -0
- package/dist/themes/data/tokyo-night.d.ts +3 -0
- package/dist/themes/data/tokyo-night.js +177 -0
- package/dist/themes/data/types.d.ts +31 -0
- package/dist/themes/data/types.js +10 -0
- package/dist/themes/palette.d.ts +21 -0
- package/dist/themes/palette.js +28 -0
- package/dist/themes/ramp.d.ts +83 -0
- package/dist/themes/ramp.js +122 -0
- package/dist/themes/registry.d.ts +44 -0
- package/dist/themes/registry.js +94 -0
- package/dist/themes/terminalThemes.d.ts +49 -0
- package/dist/themes/terminalThemes.js +63 -0
- package/dist/themes/transpose.d.ts +87 -0
- package/dist/themes/transpose.js +138 -0
- package/dist/widgets/button.d.ts +49 -0
- package/dist/widgets/button.js +208 -0
- package/dist/widgets/checkbox.d.ts +41 -0
- package/dist/widgets/checkbox.js +157 -0
- package/dist/widgets/dropdown.d.ts +67 -0
- package/dist/widgets/dropdown.js +450 -0
- package/dist/widgets/event-router.d.ts +71 -0
- package/dist/widgets/event-router.js +629 -0
- package/dist/widgets/focus-manager.d.ts +45 -0
- package/dist/widgets/focus-manager.js +191 -0
- package/dist/widgets/hit.d.ts +64 -0
- package/dist/widgets/hit.js +113 -0
- package/dist/widgets/index.d.ts +20 -0
- package/dist/widgets/index.js +14 -0
- package/dist/widgets/slider.d.ts +57 -0
- package/dist/widgets/slider.js +270 -0
- package/dist/widgets/static-item.d.ts +34 -0
- package/dist/widgets/static-item.js +54 -0
- package/dist/widgets/text-input.d.ts +274 -0
- package/dist/widgets/text-input.js +1165 -0
- package/dist/widgets/toggle.d.ts +44 -0
- package/dist/widgets/toggle.js +180 -0
- package/dist/widgets/types.d.ts +87 -0
- package/dist/widgets/types.js +30 -0
- package/dist/widgets/widget-app.d.ts +63 -0
- package/dist/widgets/widget-app.js +199 -0
- package/dist/widgets/widget-base.d.ts +40 -0
- package/dist/widgets/widget-base.js +165 -0
- package/package.json +6 -2
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Table — tabular data with headers, borders, auto-sizing, and alignment.
|
|
3
|
+
*/
|
|
4
|
+
import { Segment } from "../core/segment.js";
|
|
5
|
+
import { Style } from "../core/style.js";
|
|
6
|
+
import { Box } from "../core/box.js";
|
|
7
|
+
import { RichText } from "../core/text.js";
|
|
8
|
+
import type { PaddingDimensions } from "./padding.js";
|
|
9
|
+
import type { Renderable, Measurable, OverflowMethod, RenderOptions } from "../core/protocol.js";
|
|
10
|
+
export interface ColumnOptions {
|
|
11
|
+
header?: string | RichText;
|
|
12
|
+
footer?: string | RichText;
|
|
13
|
+
headerStyle?: string | Style;
|
|
14
|
+
footerStyle?: string | Style;
|
|
15
|
+
style?: string | Style;
|
|
16
|
+
justify?: "left" | "center" | "right" | "full";
|
|
17
|
+
width?: number;
|
|
18
|
+
minWidth?: number;
|
|
19
|
+
maxWidth?: number;
|
|
20
|
+
ratio?: number;
|
|
21
|
+
noWrap?: boolean;
|
|
22
|
+
overflow?: OverflowMethod;
|
|
23
|
+
}
|
|
24
|
+
export declare class Column {
|
|
25
|
+
private _header;
|
|
26
|
+
private _footer;
|
|
27
|
+
headerStyle: string | Style;
|
|
28
|
+
footerStyle: string | Style;
|
|
29
|
+
style: string | Style;
|
|
30
|
+
justify: "left" | "center" | "right" | "full";
|
|
31
|
+
width: number | undefined;
|
|
32
|
+
minWidth: number | undefined;
|
|
33
|
+
maxWidth: number | undefined;
|
|
34
|
+
ratio: number | undefined;
|
|
35
|
+
noWrap: boolean;
|
|
36
|
+
overflow: OverflowMethod;
|
|
37
|
+
private _cells;
|
|
38
|
+
constructor(options?: ColumnOptions);
|
|
39
|
+
/**
|
|
40
|
+
* The two stamped cells, parsed on assignment rather than at the constructor.
|
|
41
|
+
* `Table.columns` hands out the live column and both fields are public, so a
|
|
42
|
+
* constructor-only stamp held only until the first `columns[0].footer = mine`
|
|
43
|
+
* — which installed content that had parsed no markup, still carried its
|
|
44
|
+
* `end`, and was still owned by the caller, into a slot every reader below
|
|
45
|
+
* assumes `embeddedText` has been through. [LAW:parse-dont-validate] The setter
|
|
46
|
+
* is the border, so the guarantee holds for the object's whole lifetime and
|
|
47
|
+
* the constructor is one caller of it rather than the one place it is true.
|
|
48
|
+
*
|
|
49
|
+
* Absent and empty are the same header, and the same footer.
|
|
50
|
+
* [LAW:types-are-the-program] Rich declares `footer: RenderableType = ""`, so
|
|
51
|
+
* a column always has one and `show_footer` alone decides whether it is
|
|
52
|
+
* drawn. Modelling the absence as `undefined` instead made "no column has a
|
|
53
|
+
* footer" a state the render path could ask about — and it did, skipping the
|
|
54
|
+
* row a caller had asked for. `embeddedText` already maps nothing onto empty,
|
|
55
|
+
* which is why the setters take `undefined` rather than defaulting around it.
|
|
56
|
+
*/
|
|
57
|
+
get header(): RichText;
|
|
58
|
+
set header(content: string | RichText | undefined);
|
|
59
|
+
get footer(): RichText;
|
|
60
|
+
set footer(content: string | RichText | undefined);
|
|
61
|
+
get flexible(): boolean;
|
|
62
|
+
/** @internal */
|
|
63
|
+
addCell(cell: Renderable): void;
|
|
64
|
+
/** @internal */
|
|
65
|
+
getCells(): Renderable[];
|
|
66
|
+
copy(): Column;
|
|
67
|
+
}
|
|
68
|
+
export interface TableOptions {
|
|
69
|
+
box?: Box | null;
|
|
70
|
+
title?: string | RichText;
|
|
71
|
+
caption?: string | RichText;
|
|
72
|
+
expand?: boolean;
|
|
73
|
+
showHeader?: boolean;
|
|
74
|
+
showFooter?: boolean;
|
|
75
|
+
showLines?: boolean;
|
|
76
|
+
showEdge?: boolean;
|
|
77
|
+
padding?: PaddingDimensions;
|
|
78
|
+
style?: string | Style;
|
|
79
|
+
headerStyle?: string | Style;
|
|
80
|
+
footerStyle?: string | Style;
|
|
81
|
+
borderStyle?: string | Style;
|
|
82
|
+
titleStyle?: string | Style;
|
|
83
|
+
captionStyle?: string | Style;
|
|
84
|
+
titleJustify?: "left" | "center" | "right" | "full";
|
|
85
|
+
captionJustify?: "left" | "center" | "right" | "full";
|
|
86
|
+
width?: number;
|
|
87
|
+
minWidth?: number;
|
|
88
|
+
rowStyles?: string[];
|
|
89
|
+
}
|
|
90
|
+
export declare class Table implements Renderable, Measurable {
|
|
91
|
+
private _columns;
|
|
92
|
+
private _rows;
|
|
93
|
+
readonly box: Box | null;
|
|
94
|
+
readonly title: RichText | undefined;
|
|
95
|
+
readonly caption: RichText | undefined;
|
|
96
|
+
readonly expand: boolean;
|
|
97
|
+
readonly showHeader: boolean;
|
|
98
|
+
readonly showFooter: boolean;
|
|
99
|
+
readonly showLines: boolean;
|
|
100
|
+
readonly showEdge: boolean;
|
|
101
|
+
readonly padding: [number, number, number, number];
|
|
102
|
+
readonly style: string | Style;
|
|
103
|
+
readonly headerStyle: string | Style;
|
|
104
|
+
readonly footerStyle: string | Style;
|
|
105
|
+
readonly borderStyle: string | Style;
|
|
106
|
+
readonly titleStyle: string | Style;
|
|
107
|
+
readonly captionStyle: string | Style;
|
|
108
|
+
readonly titleJustify: "left" | "center" | "right" | "full";
|
|
109
|
+
readonly captionJustify: "left" | "center" | "right" | "full";
|
|
110
|
+
readonly tableWidth: number | undefined;
|
|
111
|
+
readonly minWidth: number | undefined;
|
|
112
|
+
readonly rowStyles: string[];
|
|
113
|
+
constructor(options?: TableOptions);
|
|
114
|
+
get columns(): Column[];
|
|
115
|
+
get rowCount(): number;
|
|
116
|
+
addColumn(header?: string | RichText, options?: ColumnOptions): this;
|
|
117
|
+
addRow(...cells: unknown[]): this;
|
|
118
|
+
addSection(): this;
|
|
119
|
+
render(rawOptions: RenderOptions): Iterable<Segment>;
|
|
120
|
+
/**
|
|
121
|
+
* [LAW:one-source-of-truth] Both ends of the range are widths the geometry
|
|
122
|
+
* actually produced — the maximum from the demands as they stand, the
|
|
123
|
+
* minimum from the same layout with every column asking for a single cell.
|
|
124
|
+
* Neither end stretches or fills into an offer: both only spend cells an
|
|
125
|
+
* offer happens to leave over, and a renderable reports the width its content
|
|
126
|
+
* wants rather than the width it was offered. A declared `width` is not an
|
|
127
|
+
* offer, and the maximum reports it. Letting either in made the table measure
|
|
128
|
+
* `Infinity` against an unbounded offer, where `withBoundedWidth` needs a
|
|
129
|
+
* natural width to fall back on — an expanding table, and an empty
|
|
130
|
+
* `Table.grid()`.
|
|
131
|
+
* Neither can exceed the width offered and the tighter request cannot exceed
|
|
132
|
+
* the looser one, so the range cannot invert. Deriving the minimum from raw
|
|
133
|
+
* column and padding counts instead is what used to return
|
|
134
|
+
* `{minimum: 6, maximum: 1}` at `maxWidth: 1` — a floor above its own ceiling.
|
|
135
|
+
*/
|
|
136
|
+
measure(rawOptions: RenderOptions): {
|
|
137
|
+
minimum: number;
|
|
138
|
+
maximum: number;
|
|
139
|
+
};
|
|
140
|
+
static grid(options?: Omit<TableOptions, "box" | "showHeader" | "showEdge">): Table;
|
|
141
|
+
private _frame;
|
|
142
|
+
/**
|
|
143
|
+
* The width this table lays itself out against: what it was told to be, as a
|
|
144
|
+
* count of cells, never wider than what it was offered.
|
|
145
|
+
*
|
|
146
|
+
* [LAW:one-source-of-truth] `render` and `measure` divide the same two fields
|
|
147
|
+
* and once did it in two places. `measure` bounded the declared width by the
|
|
148
|
+
* offer and `render` preferred it outright, walking past the value
|
|
149
|
+
* `withBoundedWidth` had just resolved — so `new Table({width: Infinity})`
|
|
150
|
+
* with a `{ratio: 1}` column granted that column `UNBOUNDED` cells and threw
|
|
151
|
+
* `RangeError: Invalid string length` out of the top border, at a perfectly
|
|
152
|
+
* ordinary 80-cell offer.
|
|
153
|
+
*/
|
|
154
|
+
private _outerWidth;
|
|
155
|
+
private _geometry;
|
|
156
|
+
/**
|
|
157
|
+
* [LAW:dataflow-not-control-flow] The three ways a column can be sized —
|
|
158
|
+
* declared width, ratio, natural content — differ only in the demand they
|
|
159
|
+
* produce, and `expand` only in its `stretch`. They are resolved once, here, into uniform data, so
|
|
160
|
+
* `layoutTable` runs the same apportionment for every table and no sizing
|
|
161
|
+
* mode gets its own path through the width division.
|
|
162
|
+
*/
|
|
163
|
+
private _columnDemands;
|
|
164
|
+
/**
|
|
165
|
+
* Every cell column `index` draws, in draw order.
|
|
166
|
+
*
|
|
167
|
+
* [LAW:one-source-of-truth] The reference's `_get_cells` is the one answer to
|
|
168
|
+
* "which cells belong to this column", and both `_measure_column` and
|
|
169
|
+
* `_render` read it. Enumerating that set a second time inside the width path
|
|
170
|
+
* is how the two ends drifted: the header was measured whether or not
|
|
171
|
+
* `showHeader` drew it, and `col.footer` was never measured at all, so a
|
|
172
|
+
* footer wider than its column — a totals row, exactly — was cut to `…`.
|
|
173
|
+
* A flag is the whole membership rule; nothing here asks after content.
|
|
174
|
+
*/
|
|
175
|
+
private _columnCells;
|
|
176
|
+
/**
|
|
177
|
+
* The widest cell in a column, or `undefined` when the column has no cell to
|
|
178
|
+
* measure. Zero is a column whose cells draw nothing — a gutter asks for its
|
|
179
|
+
* padding and nothing else — and is not the same answer.
|
|
180
|
+
* [LAW:types-are-the-program]
|
|
181
|
+
*/
|
|
182
|
+
private _widestCell;
|
|
183
|
+
/**
|
|
184
|
+
* A natural width held to the column's own `minWidth`/`maxWidth`.
|
|
185
|
+
*
|
|
186
|
+
* A bound is a count of cells, read by the rule every width is read by: NaN
|
|
187
|
+
* and a negative are zero cells, so a NaN floor bounds nothing and a NaN
|
|
188
|
+
* ceiling is a ceiling of zero, as `width: NaN` is. A bare `Math.max` returns
|
|
189
|
+
* NaN instead, and the column vanishes. [LAW:one-source-of-truth]
|
|
190
|
+
*/
|
|
191
|
+
private _bounded;
|
|
192
|
+
private _renderRow;
|
|
193
|
+
private _renderTitle;
|
|
194
|
+
}
|