@promptctl/rich-js 0.27.0 → 0.28.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.
- package/README.md +1 -0
- package/THIRD-PARTY-NOTICES +42 -0
- package/dist/core/animation.d.ts +36 -17
- package/dist/core/animation.js +61 -37
- package/dist/core/ansi.d.ts +15 -8
- package/dist/core/ansi.js +106 -28
- package/dist/core/bidi-data.d.ts +14 -0
- package/dist/core/bidi-data.js +385 -0
- package/dist/core/bidi.d.ts +89 -0
- package/dist/core/bidi.js +615 -0
- package/dist/core/box.d.ts +9 -1
- package/dist/core/box.js +11 -0
- package/dist/core/cell-widths.d.ts +3 -2
- package/dist/core/cell-widths.js +93 -93
- package/dist/core/cells.d.ts +20 -0
- package/dist/core/cells.js +93 -5
- package/dist/core/color.d.ts +6 -7
- package/dist/core/color.js +11 -13
- package/dist/core/console.d.ts +18 -1
- package/dist/core/console.js +24 -5
- package/dist/core/control-codes.d.ts +61 -0
- package/dist/core/control-codes.js +157 -0
- package/dist/core/env.d.ts +6 -0
- package/dist/core/env.js +9 -1
- package/dist/core/export-html.js +4 -3
- package/dist/core/export-lines.d.ts +2 -0
- package/dist/core/export-lines.js +7 -3
- package/dist/core/export-svg.js +6 -5
- package/dist/core/json.js +9 -2
- package/dist/core/markup.js +4 -3
- package/dist/core/orient.d.ts +68 -0
- package/dist/core/orient.js +224 -0
- package/dist/core/osc8.d.ts +12 -5
- package/dist/core/osc8.js +14 -7
- package/dist/core/pretty.js +22 -18
- package/dist/core/protocol.d.ts +27 -6
- package/dist/core/protocol.js +14 -6
- package/dist/core/render.d.ts +8 -3
- package/dist/core/render.js +18 -5
- package/dist/core/seal.d.ts +26 -0
- package/dist/core/seal.js +75 -0
- package/dist/core/segment.d.ts +9 -1
- package/dist/core/segment.js +11 -1
- package/dist/core/style.d.ts +29 -1
- package/dist/core/style.js +41 -5
- package/dist/core/text-order.d.ts +51 -0
- package/dist/core/text-order.js +50 -0
- package/dist/core/text.d.ts +10 -0
- package/dist/core/text.js +133 -87
- package/dist/core/timeline.js +6 -6
- package/dist/core/view.d.ts +1 -1
- package/dist/core/view.js +5 -4
- package/dist/core/wrap.d.ts +24 -6
- package/dist/core/wrap.js +82 -16
- package/dist/host/app.d.ts +44 -3
- package/dist/host/app.js +111 -6
- package/dist/host/index.d.ts +3 -2
- package/dist/host/index.js +1 -0
- package/dist/host/input.d.ts +35 -2
- package/dist/host/input.js +88 -4
- package/dist/host/terminal-colors.d.ts +18 -0
- package/dist/host/terminal-colors.js +46 -0
- package/dist/host/terminal-host.d.ts +2 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.js +2 -2
- package/dist/renderables/change.d.ts +1 -3
- package/dist/renderables/change.js +4 -6
- package/dist/renderables/effect.d.ts +60 -59
- package/dist/renderables/effect.js +91 -81
- package/dist/renderables/effects.d.ts +37 -8
- package/dist/renderables/effects.js +185 -52
- package/dist/renderables/frames.d.ts +1 -10
- package/dist/renderables/frames.js +1 -16
- package/dist/renderables/glyph-effect.d.ts +12 -13
- package/dist/renderables/glyph-effect.js +34 -32
- package/dist/renderables/glyph-effects.d.ts +27 -8
- package/dist/renderables/glyph-effects.js +75 -7
- package/dist/renderables/lifecycle.d.ts +5 -7
- package/dist/renderables/lifecycle.js +6 -7
- package/dist/renderables/markdown.js +4 -2
- package/dist/renderables/panel.js +6 -4
- package/dist/renderables/progressBar.d.ts +3 -3
- package/dist/renderables/progressBar.js +16 -13
- package/dist/renderables/syntax.js +7 -2
- package/dist/renderables/table.js +2 -1
- package/dist/template-bindings/animation-funcs.d.ts +49 -18
- package/dist/template-bindings/animation-funcs.js +115 -32
- package/dist/template-bindings/index.d.ts +7 -5
- package/dist/template-bindings/index.js +8 -5
- package/dist/template-bindings/palette-funcs.d.ts +1 -1
- package/dist/template-bindings/palette-funcs.js +1 -1
- package/dist/themes/buildPalette.d.ts +3 -2
- package/dist/themes/buildPalette.js +2 -2
- package/dist/themes/data/index.js +1 -4
- package/dist/themes/data/textual-ansi.js +0 -143
- package/dist/themes/ramp.d.ts +1 -1
- package/dist/themes/ramp.js +1 -1
- package/dist/themes/registry.d.ts +6 -8
- package/dist/themes/registry.js +2 -4
- package/dist/themes/terminalThemes.d.ts +4 -11
- package/dist/themes/terminalThemes.js +31 -47
- package/dist/widgets/button.d.ts +1 -1
- package/dist/widgets/button.js +6 -6
- package/dist/widgets/checkbox.js +4 -4
- package/dist/widgets/dropdown.d.ts +1 -1
- package/dist/widgets/dropdown.js +7 -5
- package/dist/widgets/themed-widget.js +3 -3
- package/dist/widgets/toggle.d.ts +1 -1
- package/dist/widgets/toggle.js +5 -5
- package/package.json +5 -4
package/dist/themes/ramp.js
CHANGED
|
@@ -159,7 +159,7 @@ export class ColorRamp {
|
|
|
159
159
|
* [LAW:one-source-of-truth] When it next changes is `Animation.all`'s
|
|
160
160
|
* answer over the two parts; nothing here says it a second time. Whether
|
|
161
161
|
* the depth it is drawn at can show the move is decided where it is drawn
|
|
162
|
-
* (`gradient`, through `
|
|
162
|
+
* (`gradient`, through `stillWhereNothingMoves`).
|
|
163
163
|
*/
|
|
164
164
|
moving(motion) {
|
|
165
165
|
const still = Animation.constant(0);
|
|
@@ -11,15 +11,15 @@ export declare function listThemePalettes(): readonly ThemeName[];
|
|
|
11
11
|
*
|
|
12
12
|
* Synchronous: theme data is bundled at compile time via the data barrel,
|
|
13
13
|
* so no I/O happens here. The Palette itself (which requires hex-parsing
|
|
14
|
-
* ~150 vars into ColorRgba values) is
|
|
15
|
-
*
|
|
14
|
+
* ~150 vars into ColorRgba values) is cached on first request — subsequent
|
|
15
|
+
* calls for the same name return the same instance. `terminalThemes.ts` makes
|
|
16
|
+
* that request for every theme, on import.
|
|
16
17
|
*/
|
|
17
18
|
export declare function getThemePalette(name: ThemeName): Palette;
|
|
18
19
|
export declare function getThemePalette(name: string): Palette | null;
|
|
19
20
|
/**
|
|
20
21
|
* The eight base colors every theme must declare, and its ANSI table. Returned by
|
|
21
|
-
* `getThemeBaseColors` for callers
|
|
22
|
-
* need the substrate and would otherwise fill the registry cache.
|
|
22
|
+
* `getThemeBaseColors` for callers that only need the substrate.
|
|
23
23
|
*/
|
|
24
24
|
export interface ThemeBaseColors {
|
|
25
25
|
readonly name: string;
|
|
@@ -35,9 +35,7 @@ export interface ThemeBaseColors {
|
|
|
35
35
|
readonly ansi: ColorTable;
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
|
-
* Read just the eight base colors from a theme's data file.
|
|
39
|
-
* 8 hex strings, allocates no Palette, touches no cache.
|
|
40
|
-
* want a `TerminalTheme`-shaped substrate without forcing the full ~150-var
|
|
41
|
-
* palette through the registry's hydration path.
|
|
38
|
+
* Read just the eight base colors and the ANSI table from a theme's data file.
|
|
39
|
+
* Parses 8 hex strings, allocates no Palette, touches no cache.
|
|
42
40
|
*/
|
|
43
41
|
export declare function getThemeBaseColors(name: ThemeName): ThemeBaseColors;
|
package/dist/themes/registry.js
CHANGED
|
@@ -23,10 +23,8 @@ function isThemeName(name) {
|
|
|
23
23
|
return Object.hasOwn(THEMES, name);
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* Read just the eight base colors from a theme's data file.
|
|
27
|
-
* 8 hex strings, allocates no Palette, touches no cache.
|
|
28
|
-
* want a `TerminalTheme`-shaped substrate without forcing the full ~150-var
|
|
29
|
-
* palette through the registry's hydration path.
|
|
26
|
+
* Read just the eight base colors and the ANSI table from a theme's data file.
|
|
27
|
+
* Parses 8 hex strings, allocates no Palette, touches no cache.
|
|
30
28
|
*/
|
|
31
29
|
export function getThemeBaseColors(name) {
|
|
32
30
|
const data = THEMES[name];
|
|
@@ -3,17 +3,10 @@
|
|
|
3
3
|
* matching `<NAME>` export here. There is no inline-only theme; the data
|
|
4
4
|
* file is the single source of truth for every theme's hex values.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* `TerminalTheme`'s palette is derived from them, so it is not the colour the
|
|
11
|
-
* theme authored: read `getThemePalette` for that.
|
|
12
|
-
*
|
|
13
|
-
* [LAW:one-source-of-truth] Hex values live in `data/<name>.ts`. This
|
|
14
|
-
* module is a derived view that builds a `TerminalTheme` from each
|
|
15
|
-
* theme's eight base colors via `buildPalette` for the substrate palette,
|
|
16
|
-
* and from the theme's own ANSI table for the sixteen named colours.
|
|
6
|
+
* [LAW:one-source-of-truth] Hex values live in `data/<name>.ts`, and a theme's
|
|
7
|
+
* name means one palette: a constant here holds the very `Palette`
|
|
8
|
+
* `getThemePalette(name)` returns, and takes the background and foreground off
|
|
9
|
+
* it, with the theme's sixteen named colours beside it.
|
|
17
10
|
*
|
|
18
11
|
* [LAW:one-type-per-behavior] Every theme has the same shape — name,
|
|
19
12
|
* `dark` flag, full Palette in the registry, `TerminalTheme` constant
|
|
@@ -3,17 +3,10 @@
|
|
|
3
3
|
* matching `<NAME>` export here. There is no inline-only theme; the data
|
|
4
4
|
* file is the single source of truth for every theme's hex values.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* `TerminalTheme`'s palette is derived from them, so it is not the colour the
|
|
11
|
-
* theme authored: read `getThemePalette` for that.
|
|
12
|
-
*
|
|
13
|
-
* [LAW:one-source-of-truth] Hex values live in `data/<name>.ts`. This
|
|
14
|
-
* module is a derived view that builds a `TerminalTheme` from each
|
|
15
|
-
* theme's eight base colors via `buildPalette` for the substrate palette,
|
|
16
|
-
* and from the theme's own ANSI table for the sixteen named colours.
|
|
6
|
+
* [LAW:one-source-of-truth] Hex values live in `data/<name>.ts`, and a theme's
|
|
7
|
+
* name means one palette: a constant here holds the very `Palette`
|
|
8
|
+
* `getThemePalette(name)` returns, and takes the background and foreground off
|
|
9
|
+
* it, with the theme's sixteen named colours beside it.
|
|
17
10
|
*
|
|
18
11
|
* [LAW:one-type-per-behavior] Every theme has the same shape — name,
|
|
19
12
|
* `dark` flag, full Palette in the registry, `TerminalTheme` constant
|
|
@@ -25,40 +18,31 @@
|
|
|
25
18
|
* color primitives; nothing in `core/` imports back.
|
|
26
19
|
*/
|
|
27
20
|
import { TerminalTheme } from "../core/color.js";
|
|
28
|
-
import {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return new TerminalTheme(
|
|
32
|
-
primary: d.primary,
|
|
33
|
-
secondary: d.secondary,
|
|
34
|
-
accent: d.accent,
|
|
35
|
-
success: d.success,
|
|
36
|
-
warning: d.warning,
|
|
37
|
-
error: d.error,
|
|
38
|
-
background: d.bg,
|
|
39
|
-
foreground: d.fg,
|
|
40
|
-
}));
|
|
21
|
+
import { getThemeBaseColors, getThemePalette } from "./registry.js";
|
|
22
|
+
function defineTheme(name) {
|
|
23
|
+
const palette = getThemePalette(name);
|
|
24
|
+
return new TerminalTheme(palette.get("background"), palette.get("foreground"), getThemeBaseColors(name).ansi, palette);
|
|
41
25
|
}
|
|
42
|
-
export const DEFAULT_TERMINAL_THEME = defineTheme(
|
|
43
|
-
export const SVG_EXPORT_THEME = defineTheme(
|
|
44
|
-
export const MONOKAI = defineTheme(
|
|
45
|
-
export const NORD = defineTheme(
|
|
46
|
-
export const GRUVBOX = defineTheme(
|
|
47
|
-
export const DRACULA = defineTheme(
|
|
48
|
-
export const TOKYO_NIGHT = defineTheme(
|
|
49
|
-
export const FLEXOKI = defineTheme(
|
|
50
|
-
export const CYBERPUNK = defineTheme(
|
|
51
|
-
export const CATPPUCCIN_MOCHA = defineTheme(
|
|
52
|
-
export const CATPPUCCIN_LATTE = defineTheme(
|
|
53
|
-
export const CATPPUCCIN_FRAPPE = defineTheme(
|
|
54
|
-
export const CATPPUCCIN_MACCHIATO = defineTheme(
|
|
55
|
-
export const SOLARIZED_DARK = defineTheme(
|
|
56
|
-
export const SOLARIZED_LIGHT = defineTheme(
|
|
57
|
-
export const ROSE_PINE = defineTheme(
|
|
58
|
-
export const ROSE_PINE_MOON = defineTheme(
|
|
59
|
-
export const ROSE_PINE_DAWN = defineTheme(
|
|
60
|
-
export const ATOM_ONE_DARK = defineTheme(
|
|
61
|
-
export const ATOM_ONE_LIGHT = defineTheme(
|
|
62
|
-
export const TEXTUAL_DARK = defineTheme(
|
|
63
|
-
export const TEXTUAL_LIGHT = defineTheme(
|
|
64
|
-
export const TEXTUAL_ANSI = defineTheme(
|
|
26
|
+
export const DEFAULT_TERMINAL_THEME = defineTheme("default");
|
|
27
|
+
export const SVG_EXPORT_THEME = defineTheme("svg-export");
|
|
28
|
+
export const MONOKAI = defineTheme("monokai");
|
|
29
|
+
export const NORD = defineTheme("nord");
|
|
30
|
+
export const GRUVBOX = defineTheme("gruvbox");
|
|
31
|
+
export const DRACULA = defineTheme("dracula");
|
|
32
|
+
export const TOKYO_NIGHT = defineTheme("tokyo-night");
|
|
33
|
+
export const FLEXOKI = defineTheme("flexoki");
|
|
34
|
+
export const CYBERPUNK = defineTheme("cyberpunk");
|
|
35
|
+
export const CATPPUCCIN_MOCHA = defineTheme("catppuccin-mocha");
|
|
36
|
+
export const CATPPUCCIN_LATTE = defineTheme("catppuccin-latte");
|
|
37
|
+
export const CATPPUCCIN_FRAPPE = defineTheme("catppuccin-frappe");
|
|
38
|
+
export const CATPPUCCIN_MACCHIATO = defineTheme("catppuccin-macchiato");
|
|
39
|
+
export const SOLARIZED_DARK = defineTheme("solarized-dark");
|
|
40
|
+
export const SOLARIZED_LIGHT = defineTheme("solarized-light");
|
|
41
|
+
export const ROSE_PINE = defineTheme("rose-pine");
|
|
42
|
+
export const ROSE_PINE_MOON = defineTheme("rose-pine-moon");
|
|
43
|
+
export const ROSE_PINE_DAWN = defineTheme("rose-pine-dawn");
|
|
44
|
+
export const ATOM_ONE_DARK = defineTheme("atom-one-dark");
|
|
45
|
+
export const ATOM_ONE_LIGHT = defineTheme("atom-one-light");
|
|
46
|
+
export const TEXTUAL_DARK = defineTheme("textual-dark");
|
|
47
|
+
export const TEXTUAL_LIGHT = defineTheme("textual-light");
|
|
48
|
+
export const TEXTUAL_ANSI = defineTheme("textual-ansi");
|
package/dist/widgets/button.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export declare class Button extends ThemedWidget {
|
|
|
37
37
|
handleKey(event: KeyEvent): void;
|
|
38
38
|
handleMouse(event: WidgetMouseEvent): void;
|
|
39
39
|
setActive(value: boolean): void;
|
|
40
|
-
protected draw(
|
|
40
|
+
protected draw(options: RenderOptions): Iterable<Segment>;
|
|
41
41
|
measure(_options: RenderOptions): {
|
|
42
42
|
minimum: number;
|
|
43
43
|
maximum: number;
|
package/dist/widgets/button.js
CHANGED
|
@@ -49,9 +49,9 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
|
|
|
49
49
|
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
50
50
|
done = true;
|
|
51
51
|
};
|
|
52
|
+
import { labelled } from "../core/orient.js";
|
|
52
53
|
import { action } from "mobx";
|
|
53
54
|
import { observableRef } from "./observable.js";
|
|
54
|
-
import { Segment } from "../core/segment.js";
|
|
55
55
|
import { Style } from "../core/style.js";
|
|
56
56
|
import { cellLen } from "../core/cells.js";
|
|
57
57
|
import { ThemedWidget } from "./themed-widget.js";
|
|
@@ -148,14 +148,14 @@ let Button = (() => {
|
|
|
148
148
|
// --- Active mutator (the keyboard-activation microtask uses this) ---
|
|
149
149
|
setActive(value) { this.active = value; }
|
|
150
150
|
// --- Rendering ---
|
|
151
|
-
draw(
|
|
151
|
+
draw(options) {
|
|
152
152
|
// [LAW:dataflow-not-control-flow] same segment count and width every state
|
|
153
153
|
const focused = this.focused;
|
|
154
154
|
const left = focused ? "[" : " ";
|
|
155
155
|
const right = focused ? "]" : " ";
|
|
156
|
-
const
|
|
156
|
+
const drawn = (style) => labelled(`${left} `, this.label, ` ${right}`, style, options.textOrder);
|
|
157
157
|
if (this.disabled) {
|
|
158
|
-
return
|
|
158
|
+
return drawn(new Style(this.disabledInk));
|
|
159
159
|
}
|
|
160
160
|
// Active and hover share the same colour pair (full accent bg + on-accent fg).
|
|
161
161
|
// Active is differentiated by bold, not by inverting fg/bg — inversion gives
|
|
@@ -163,9 +163,9 @@ let Button = (() => {
|
|
|
163
163
|
// accents whose contrast partner depends on luminance.
|
|
164
164
|
const keys = VARIANT_KEYS[this.variant];
|
|
165
165
|
if (this.active || this.hovered) {
|
|
166
|
-
return
|
|
166
|
+
return drawn(new Style({ ...ink(this.theme, keys.hoverFg, keys.hover), bold: this.active }));
|
|
167
167
|
}
|
|
168
|
-
return
|
|
168
|
+
return drawn(new Style(ink(this.theme, keys.fg, keys.bg)));
|
|
169
169
|
}
|
|
170
170
|
measure(_options) {
|
|
171
171
|
// [LAW:one-source-of-truth] cellLen is the cell-width authority; .length
|
package/dist/widgets/checkbox.js
CHANGED
|
@@ -44,9 +44,9 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
|
|
|
44
44
|
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
45
45
|
done = true;
|
|
46
46
|
};
|
|
47
|
+
import { labelled } from "../core/orient.js";
|
|
47
48
|
import { action } from "mobx";
|
|
48
49
|
import { observableRef } from "./observable.js";
|
|
49
|
-
import { Segment } from "../core/segment.js";
|
|
50
50
|
import { Style } from "../core/style.js";
|
|
51
51
|
import { cellLen } from "../core/cells.js";
|
|
52
52
|
import { drawable } from "../core/protocol.js";
|
|
@@ -119,12 +119,12 @@ let Checkbox = (() => {
|
|
|
119
119
|
// --- Rendering ---
|
|
120
120
|
draw(options) {
|
|
121
121
|
const indicator = this.checked ? drawable(options, "✓", "x") : " ";
|
|
122
|
-
const
|
|
122
|
+
const drawn = (style) => labelled(`[${indicator}] `, this.label, "", style, options.textOrder);
|
|
123
123
|
if (this.disabled) {
|
|
124
|
-
return
|
|
124
|
+
return drawn(new Style(this.disabledInk));
|
|
125
125
|
}
|
|
126
126
|
const colors = ink(this.theme, this.checked ? "text-primary" : "foreground", "background");
|
|
127
|
-
return
|
|
127
|
+
return drawn(new Style({ ...colors, underline: this.focused }));
|
|
128
128
|
}
|
|
129
129
|
measure(_options) {
|
|
130
130
|
// [LAW:one-source-of-truth] cellLen — see button.ts.
|
|
@@ -55,7 +55,7 @@ export declare class Dropdown extends ThemedWidget implements OverlayRenderable
|
|
|
55
55
|
handleFocus(event: WidgetFocusEvent): void;
|
|
56
56
|
protected draw(options: RenderOptions): Iterable<Segment>;
|
|
57
57
|
private headerText;
|
|
58
|
-
renderOverlay(
|
|
58
|
+
renderOverlay(options: RenderOptions): Iterable<Segment> | null;
|
|
59
59
|
private renderNoMatchRow;
|
|
60
60
|
private renderOptionRow;
|
|
61
61
|
private maxLabelLen;
|
package/dist/widgets/dropdown.js
CHANGED
|
@@ -56,6 +56,7 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
|
|
|
56
56
|
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
57
57
|
done = true;
|
|
58
58
|
};
|
|
59
|
+
import { labelled } from "../core/orient.js";
|
|
59
60
|
import { action } from "mobx";
|
|
60
61
|
import { observableRef } from "./observable.js";
|
|
61
62
|
import { Segment } from "../core/segment.js";
|
|
@@ -318,7 +319,7 @@ let Dropdown = (() => {
|
|
|
318
319
|
const headerLabel = this.headerText(maxLabelLen, caret);
|
|
319
320
|
return [
|
|
320
321
|
new Segment("[", baseStyle),
|
|
321
|
-
|
|
322
|
+
...labelled("", headerLabel, ` ${arrowChar}`, baseStyle, options.textOrder),
|
|
322
323
|
new Segment("]", baseStyle),
|
|
323
324
|
];
|
|
324
325
|
}
|
|
@@ -348,18 +349,19 @@ let Dropdown = (() => {
|
|
|
348
349
|
const [filterText] = splitText(this.filter, asCellCol(filterRoom));
|
|
349
350
|
return setCellSize(" " + filterText + caret, asCellCol(maxLabelLen));
|
|
350
351
|
}
|
|
351
|
-
renderOverlay(
|
|
352
|
+
renderOverlay(options) {
|
|
352
353
|
if (!this.expanded)
|
|
353
354
|
return null;
|
|
354
355
|
const maxLabelLen = this.maxLabelLen();
|
|
355
356
|
const fopts = this.filteredOptions;
|
|
356
357
|
if (fopts.length === 0)
|
|
357
358
|
return this.renderNoMatchRow(maxLabelLen);
|
|
359
|
+
const order = options.textOrder;
|
|
358
360
|
const segments = [];
|
|
359
361
|
for (let i = 0; i < fopts.length; i++) {
|
|
360
362
|
if (i > 0)
|
|
361
363
|
segments.push(new Segment("\n"));
|
|
362
|
-
segments.push(...this.renderOptionRow(fopts[i], i, maxLabelLen));
|
|
364
|
+
segments.push(...this.renderOptionRow(fopts[i], i, maxLabelLen, order));
|
|
363
365
|
}
|
|
364
366
|
return segments;
|
|
365
367
|
}
|
|
@@ -379,7 +381,7 @@ let Dropdown = (() => {
|
|
|
379
381
|
new Segment(" ", style),
|
|
380
382
|
];
|
|
381
383
|
}
|
|
382
|
-
renderOptionRow(entry, fpos, maxLabelLen) {
|
|
384
|
+
renderOptionRow(entry, fpos, maxLabelLen, order) {
|
|
383
385
|
// Row: " " + label.padEnd(maxLabelLen) + " "
|
|
384
386
|
// Width = 1 + 1 + maxLabelLen + 1 + 1 = maxLabelLen + 4.
|
|
385
387
|
// Overlay rows are unbracketed — selection/highlight are conveyed by bg
|
|
@@ -399,7 +401,7 @@ let Dropdown = (() => {
|
|
|
399
401
|
: new Style(ink(this.theme, "foreground", "surface"));
|
|
400
402
|
return [
|
|
401
403
|
new Segment(" ", rowStyle),
|
|
402
|
-
|
|
404
|
+
...labelled("", inner, "", rowStyle, order),
|
|
403
405
|
new Segment(" ", rowStyle),
|
|
404
406
|
];
|
|
405
407
|
}
|
|
@@ -80,10 +80,10 @@ let ThemedWidget = (() => {
|
|
|
80
80
|
return new Style(ink(this.theme, "foreground", "background"));
|
|
81
81
|
}
|
|
82
82
|
// [LAW:one-source-of-truth] How every widget looks while disabled: the
|
|
83
|
-
// palette's
|
|
84
|
-
//
|
|
83
|
+
// palette's disabled text on its ground. WCAG sets no contrast floor for an
|
|
84
|
+
// inactive control, and this sits under the one for text on purpose.
|
|
85
85
|
get disabledInk() {
|
|
86
|
-
return ink(this.theme, "foreground-
|
|
86
|
+
return ink(this.theme, "foreground-disabled", "background");
|
|
87
87
|
}
|
|
88
88
|
};
|
|
89
89
|
})();
|
package/dist/widgets/toggle.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export declare class Toggle extends ThemedWidget {
|
|
|
33
33
|
constructor(options: ToggleOptions);
|
|
34
34
|
handleKey(event: KeyEvent): void;
|
|
35
35
|
handleMouse(event: WidgetMouseEvent): void;
|
|
36
|
-
protected draw(
|
|
36
|
+
protected draw(options: RenderOptions): Iterable<Segment>;
|
|
37
37
|
measure(_options: RenderOptions): {
|
|
38
38
|
minimum: number;
|
|
39
39
|
maximum: number;
|
package/dist/widgets/toggle.js
CHANGED
|
@@ -44,9 +44,9 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
|
|
|
44
44
|
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
45
45
|
done = true;
|
|
46
46
|
};
|
|
47
|
+
import { labelled } from "../core/orient.js";
|
|
47
48
|
import { action } from "mobx";
|
|
48
49
|
import { observableRef } from "./observable.js";
|
|
49
|
-
import { Segment } from "../core/segment.js";
|
|
50
50
|
import { Style } from "../core/style.js";
|
|
51
51
|
import { cellLen } from "../core/cells.js";
|
|
52
52
|
import { ThemedWidget } from "./themed-widget.js";
|
|
@@ -137,16 +137,16 @@ let Toggle = (() => {
|
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
// --- Rendering ---
|
|
140
|
-
draw(
|
|
140
|
+
draw(options) {
|
|
141
141
|
// Both indicators are exactly 5 cells: "[ON] " and "[OFF]".
|
|
142
142
|
const indicator = this.on ? "[ON] " : "[OFF]";
|
|
143
|
-
const
|
|
143
|
+
const drawn = (style) => labelled(`${indicator} `, this.label, "", style, options.textOrder);
|
|
144
144
|
if (this.disabled) {
|
|
145
|
-
return
|
|
145
|
+
return drawn(new Style(this.disabledInk));
|
|
146
146
|
}
|
|
147
147
|
const keys = VARIANT_KEYS[this.variant];
|
|
148
148
|
const colors = this.on ? ink(this.theme, keys.onFg, keys.onBg) : ink(this.theme, keys.offFg, keys.offBg);
|
|
149
|
-
return
|
|
149
|
+
return drawn(new Style({ ...colors, underline: this.focused }));
|
|
150
150
|
}
|
|
151
151
|
measure(_options) {
|
|
152
152
|
// [LAW:one-source-of-truth] cellLen — see button.ts.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptctl/rich-js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "Rich text and beautiful formatting in the terminal — a TypeScript port of Python's Rich",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -89,6 +89,7 @@
|
|
|
89
89
|
"template-bindings": "node scripts/build-demos.ts && node dist-demo/examples/rich-template-bindings/main.js",
|
|
90
90
|
"themes-and-color-studio": "node scripts/build-demos.ts && node dist-demo/examples/themes-and-color-studio/node.js",
|
|
91
91
|
"terminal-host": "node scripts/build-demos.ts && node dist-demo/examples/terminal-host/main.js",
|
|
92
|
+
"terminal-colors": "node scripts/build-demos.ts && node dist-demo/examples/terminal-colors/index.js",
|
|
92
93
|
"test:demos": "playwright test"
|
|
93
94
|
},
|
|
94
95
|
"keywords": [
|
|
@@ -123,14 +124,14 @@
|
|
|
123
124
|
"@codemirror/view": "^6.43.13",
|
|
124
125
|
"@lezer/highlight": "^1.2.5",
|
|
125
126
|
"@playwright/test": "^1.63.0",
|
|
126
|
-
"@promptctl/go-template-js": "
|
|
127
|
+
"@promptctl/go-template-js": "0.12.0",
|
|
127
128
|
"@types/markdown-it": "^14.2.0",
|
|
128
129
|
"@types/node": "^26.5.1",
|
|
129
130
|
"@types/semver": "^7.8.0",
|
|
130
131
|
"@xterm/headless": "^6.0.0",
|
|
131
132
|
"markdown-it": "^14.3.2",
|
|
132
133
|
"markdown-it-container": "^4.0.0",
|
|
133
|
-
"mobx": "
|
|
134
|
+
"mobx": "7.0.3",
|
|
134
135
|
"node-inspect-extracted": "^3.3.3",
|
|
135
136
|
"semver": "^7.8.5",
|
|
136
137
|
"strip-ansi": "^7.2.0",
|
|
@@ -141,7 +142,7 @@
|
|
|
141
142
|
"vitest": "^5.0.0"
|
|
142
143
|
},
|
|
143
144
|
"peerDependencies": {
|
|
144
|
-
"@promptctl/go-template-js": "^0.
|
|
145
|
+
"@promptctl/go-template-js": "^0.12.0",
|
|
145
146
|
"mobx": "^7.0.3"
|
|
146
147
|
},
|
|
147
148
|
"peerDependenciesMeta": {
|