@flyingrobots/bijou-tui 0.10.0 → 1.1.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 +25 -0
- package/dist/accordion.d.ts +46 -5
- package/dist/accordion.d.ts.map +1 -1
- package/dist/accordion.js +41 -5
- package/dist/accordion.js.map +1 -1
- package/dist/animate.d.ts +30 -0
- package/dist/animate.d.ts.map +1 -1
- package/dist/animate.js +33 -0
- package/dist/animate.js.map +1 -1
- package/dist/browsable-list.d.ts +67 -4
- package/dist/browsable-list.d.ts.map +1 -1
- package/dist/browsable-list.js +49 -4
- package/dist/browsable-list.js.map +1 -1
- package/dist/canvas.d.ts +13 -4
- package/dist/canvas.d.ts.map +1 -1
- package/dist/canvas.js +9 -3
- package/dist/canvas.js.map +1 -1
- package/dist/command-palette.d.ts +67 -6
- package/dist/command-palette.d.ts.map +1 -1
- package/dist/command-palette.js +67 -6
- package/dist/command-palette.js.map +1 -1
- package/dist/commands.d.ts +32 -3
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +32 -3
- package/dist/commands.js.map +1 -1
- package/dist/dag-pane.d.ts +225 -0
- package/dist/dag-pane.d.ts.map +1 -0
- package/dist/dag-pane.js +510 -0
- package/dist/dag-pane.js.map +1 -0
- package/dist/driver.d.ts +14 -0
- package/dist/driver.d.ts.map +1 -1
- package/dist/driver.js +7 -0
- package/dist/driver.js.map +1 -1
- package/dist/eventbus.d.ts +43 -6
- package/dist/eventbus.d.ts.map +1 -1
- package/dist/eventbus.js +9 -0
- package/dist/eventbus.js.map +1 -1
- package/dist/file-picker.d.ts +56 -4
- package/dist/file-picker.d.ts.map +1 -1
- package/dist/file-picker.js +52 -4
- package/dist/file-picker.js.map +1 -1
- package/dist/flex.d.ts +17 -0
- package/dist/flex.d.ts.map +1 -1
- package/dist/flex.js +106 -12
- package/dist/flex.js.map +1 -1
- package/dist/focus-area.d.ts +179 -0
- package/dist/focus-area.d.ts.map +1 -0
- package/dist/focus-area.js +261 -0
- package/dist/focus-area.js.map +1 -0
- package/dist/help.d.ts +16 -1
- package/dist/help.d.ts.map +1 -1
- package/dist/help.js +13 -0
- package/dist/help.js.map +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/inputstack.d.ts +32 -4
- package/dist/inputstack.d.ts.map +1 -1
- package/dist/inputstack.js +11 -0
- package/dist/inputstack.js.map +1 -1
- package/dist/keybindings.d.ts +106 -14
- package/dist/keybindings.d.ts.map +1 -1
- package/dist/keybindings.js +28 -2
- package/dist/keybindings.js.map +1 -1
- package/dist/keys.d.ts +24 -8
- package/dist/keys.d.ts.map +1 -1
- package/dist/keys.js +34 -9
- package/dist/keys.js.map +1 -1
- package/dist/layout.d.ts +26 -0
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +25 -1
- package/dist/layout.js.map +1 -1
- package/dist/navigable-table.d.ts +48 -4
- package/dist/navigable-table.d.ts.map +1 -1
- package/dist/navigable-table.js +44 -4
- package/dist/navigable-table.js.map +1 -1
- package/dist/overlay.d.ts +110 -3
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +87 -7
- package/dist/overlay.js.map +1 -1
- package/dist/pager.d.ts +66 -7
- package/dist/pager.d.ts.map +1 -1
- package/dist/pager.js +56 -7
- package/dist/pager.js.map +1 -1
- package/dist/panels.d.ts +55 -0
- package/dist/panels.d.ts.map +1 -1
- package/dist/panels.js +11 -0
- package/dist/panels.js.map +1 -1
- package/dist/runtime.d.ts +6 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +6 -0
- package/dist/runtime.js.map +1 -1
- package/dist/screen.d.ts +37 -3
- package/dist/screen.d.ts.map +1 -1
- package/dist/screen.js +37 -3
- package/dist/screen.js.map +1 -1
- package/dist/spring.d.ts +56 -7
- package/dist/spring.d.ts.map +1 -1
- package/dist/spring.js +44 -7
- package/dist/spring.js.map +1 -1
- package/dist/status-bar.d.ts +15 -2
- package/dist/status-bar.d.ts.map +1 -1
- package/dist/status-bar.js +9 -0
- package/dist/status-bar.js.map +1 -1
- package/dist/timeline.d.ts +68 -5
- package/dist/timeline.d.ts.map +1 -1
- package/dist/timeline.js +33 -0
- package/dist/timeline.js.map +1 -1
- package/dist/types.d.ts +86 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +27 -3
- package/dist/types.js.map +1 -1
- package/dist/viewport.d.ts +71 -11
- package/dist/viewport.d.ts.map +1 -1
- package/dist/viewport.js +79 -11
- package/dist/viewport.js.map +1 -1
- package/package.json +2 -2
package/dist/flex.js
CHANGED
|
@@ -12,13 +12,33 @@
|
|
|
12
12
|
* )
|
|
13
13
|
* ```
|
|
14
14
|
*/
|
|
15
|
+
import { makeBgFill } from '@flyingrobots/bijou';
|
|
15
16
|
import { visibleLength, clipToWidth } from './viewport.js';
|
|
16
17
|
// ---------------------------------------------------------------------------
|
|
17
18
|
// ANSI helpers
|
|
18
19
|
// ---------------------------------------------------------------------------
|
|
20
|
+
/**
|
|
21
|
+
* Compute the terminal display width of a string.
|
|
22
|
+
*
|
|
23
|
+
* @param s - Input string possibly containing ANSI escapes.
|
|
24
|
+
* @returns Number of visible terminal columns.
|
|
25
|
+
*/
|
|
19
26
|
function visualWidth(s) {
|
|
20
27
|
return visibleLength(s);
|
|
21
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Distribute available main-axis space among children.
|
|
31
|
+
*
|
|
32
|
+
* Fixed-size children (basis or auto-measured) consume space first,
|
|
33
|
+
* then remaining space is divided proportionally among flex children.
|
|
34
|
+
*
|
|
35
|
+
* @param children - Child descriptors to allocate sizes for.
|
|
36
|
+
* @param mainAxisTotal - Total available size along the main axis.
|
|
37
|
+
* @param crossAxisTotal - Total available size along the cross axis.
|
|
38
|
+
* @param gap - Gap size between children on the main axis.
|
|
39
|
+
* @param isRow - True for row direction (main axis = width), false for column.
|
|
40
|
+
* @returns Resolved children with allocated sizes.
|
|
41
|
+
*/
|
|
22
42
|
function computeSizes(children, mainAxisTotal, crossAxisTotal, gap, isRow) {
|
|
23
43
|
if (children.length === 0)
|
|
24
44
|
return [];
|
|
@@ -62,6 +82,14 @@ function computeSizes(children, mainAxisTotal, crossAxisTotal, gap, isRow) {
|
|
|
62
82
|
child,
|
|
63
83
|
}));
|
|
64
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Clamp a size value within optional min/max bounds, flooring at 0.
|
|
87
|
+
*
|
|
88
|
+
* @param size - Raw size value.
|
|
89
|
+
* @param min - Minimum allowed size (inclusive).
|
|
90
|
+
* @param max - Maximum allowed size (inclusive).
|
|
91
|
+
* @returns Clamped size, never negative.
|
|
92
|
+
*/
|
|
65
93
|
function clampSize(size, min, max) {
|
|
66
94
|
let result = size;
|
|
67
95
|
if (min !== undefined)
|
|
@@ -70,6 +98,15 @@ function clampSize(size, min, max) {
|
|
|
70
98
|
result = Math.min(result, max);
|
|
71
99
|
return Math.max(0, result);
|
|
72
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Measure the intrinsic size of static content along the main axis.
|
|
103
|
+
*
|
|
104
|
+
* Return 0 for render functions (they must use flex or basis).
|
|
105
|
+
*
|
|
106
|
+
* @param content - Static string or render function.
|
|
107
|
+
* @param isRow - True to measure width, false to measure height.
|
|
108
|
+
* @returns Measured size in the main-axis direction.
|
|
109
|
+
*/
|
|
73
110
|
function measureContent(content, isRow) {
|
|
74
111
|
if (typeof content === 'function') {
|
|
75
112
|
// Can't measure a render function — treat as 0 (must use flex or basis)
|
|
@@ -86,6 +123,14 @@ function measureContent(content, isRow) {
|
|
|
86
123
|
// ---------------------------------------------------------------------------
|
|
87
124
|
// Rendering
|
|
88
125
|
// ---------------------------------------------------------------------------
|
|
126
|
+
/**
|
|
127
|
+
* Render a child's content, invoking its render function if applicable.
|
|
128
|
+
*
|
|
129
|
+
* @param child - Child descriptor whose content to render.
|
|
130
|
+
* @param width - Allocated width in columns.
|
|
131
|
+
* @param height - Allocated height in rows.
|
|
132
|
+
* @returns Rendered content string.
|
|
133
|
+
*/
|
|
89
134
|
function renderContent(child, width, height) {
|
|
90
135
|
if (typeof child.content === 'function') {
|
|
91
136
|
return child.content(width, height);
|
|
@@ -93,8 +138,14 @@ function renderContent(child, width, height) {
|
|
|
93
138
|
return child.content;
|
|
94
139
|
}
|
|
95
140
|
/**
|
|
96
|
-
* Clip
|
|
97
|
-
*
|
|
141
|
+
* Clip or pad each content line to an exact visible width.
|
|
142
|
+
*
|
|
143
|
+
* Does NOT pad height — that is handled by {@link alignCross}.
|
|
144
|
+
*
|
|
145
|
+
* @param content - Rendered content string (newline-delimited).
|
|
146
|
+
* @param width - Target visible width in columns.
|
|
147
|
+
* @param align - Horizontal alignment for lines shorter than width. Default: 'start'.
|
|
148
|
+
* @returns Array of lines, each exactly `width` visible columns wide.
|
|
98
149
|
*/
|
|
99
150
|
function fitWidth(content, width, align = 'start') {
|
|
100
151
|
const lines = content.split('\n');
|
|
@@ -122,7 +173,15 @@ function fitWidth(content, width, align = 'start') {
|
|
|
122
173
|
});
|
|
123
174
|
}
|
|
124
175
|
/**
|
|
125
|
-
* Align content lines along the cross axis.
|
|
176
|
+
* Align content lines along the cross axis by padding with empty lines.
|
|
177
|
+
*
|
|
178
|
+
* Truncate if content exceeds `totalCrossSize`; pad otherwise.
|
|
179
|
+
*
|
|
180
|
+
* @param lines - Rendered lines to align.
|
|
181
|
+
* @param totalCrossSize - Total cross-axis size in lines (height for row layout, character width for column layout).
|
|
182
|
+
* @param align - Cross-axis alignment ('start', 'center', or 'end').
|
|
183
|
+
* @param width - Width of each empty padding line.
|
|
184
|
+
* @returns Array of exactly `totalCrossSize` lines.
|
|
126
185
|
*/
|
|
127
186
|
function alignCross(lines, totalCrossSize, align, width) {
|
|
128
187
|
if (lines.length >= totalCrossSize)
|
|
@@ -168,6 +227,10 @@ function alignCross(lines, totalCrossSize, align, width) {
|
|
|
168
227
|
* { basis: 1, content: statusLine },
|
|
169
228
|
* )
|
|
170
229
|
* ```
|
|
230
|
+
*
|
|
231
|
+
* @param options - Layout container configuration (direction, dimensions, gap).
|
|
232
|
+
* @param children - Child descriptors with content, flex factors, and constraints.
|
|
233
|
+
* @returns Composed layout string with lines joined by newlines. Empty string if no children.
|
|
171
234
|
*/
|
|
172
235
|
export function flex(options, ...children) {
|
|
173
236
|
const { direction = 'row' } = options;
|
|
@@ -175,17 +238,28 @@ export function flex(options, ...children) {
|
|
|
175
238
|
const height = Math.max(0, Math.floor(options.height));
|
|
176
239
|
const gap = Math.max(0, Math.floor(options.gap ?? 0));
|
|
177
240
|
const isRow = direction === 'row';
|
|
241
|
+
const containerBg = makeBgFill(options.bgToken, options.ctx);
|
|
178
242
|
const mainAxisTotal = isRow ? width : height;
|
|
179
243
|
const crossAxisTotal = isRow ? height : width;
|
|
180
244
|
if (children.length === 0)
|
|
181
245
|
return '';
|
|
182
246
|
const resolved = computeSizes(children, mainAxisTotal, crossAxisTotal, gap, isRow);
|
|
183
247
|
if (isRow) {
|
|
184
|
-
return renderRow(resolved, height, gap);
|
|
248
|
+
return renderRow(resolved, height, gap, containerBg, options.ctx);
|
|
185
249
|
}
|
|
186
|
-
return renderColumn(resolved, width, height, gap);
|
|
250
|
+
return renderColumn(resolved, width, height, gap, containerBg, options.ctx);
|
|
187
251
|
}
|
|
188
|
-
|
|
252
|
+
/**
|
|
253
|
+
* Compose resolved children side-by-side in a horizontal row layout.
|
|
254
|
+
*
|
|
255
|
+
* @param items - Resolved children with allocated widths.
|
|
256
|
+
* @param totalHeight - Total available height in rows.
|
|
257
|
+
* @param gap - Horizontal gap between children in columns.
|
|
258
|
+
* @param containerBg - Optional background fill function for container regions (gaps, padding).
|
|
259
|
+
* @param ctx - Bijou context, used to resolve per-child bgToken fills.
|
|
260
|
+
* @returns Composed row string with lines joined by newlines.
|
|
261
|
+
*/
|
|
262
|
+
function renderRow(items, totalHeight, gap, containerBg, ctx) {
|
|
189
263
|
// Render each child into a column of lines
|
|
190
264
|
const columns = [];
|
|
191
265
|
for (const item of items) {
|
|
@@ -194,10 +268,14 @@ function renderRow(items, totalHeight, gap) {
|
|
|
194
268
|
// In row mode, fitWidth always uses 'start' — align controls cross-axis (vertical) only
|
|
195
269
|
const widthFitted = fitWidth(rendered, childWidth);
|
|
196
270
|
const aligned = alignCross(widthFitted, totalHeight, item.child.align ?? 'start', childWidth);
|
|
197
|
-
|
|
271
|
+
// Apply per-child bg fill (overrides container bg for this region)
|
|
272
|
+
const childBg = makeBgFill(item.child.bgToken, ctx) ?? containerBg;
|
|
273
|
+
const filled = childBg ? aligned.map(childBg) : aligned;
|
|
274
|
+
columns.push(filled);
|
|
198
275
|
}
|
|
199
276
|
// Compose columns side-by-side
|
|
200
|
-
const
|
|
277
|
+
const rawSpacer = ' '.repeat(Math.max(0, gap));
|
|
278
|
+
const spacer = containerBg && gap > 0 ? containerBg(rawSpacer) : rawSpacer;
|
|
201
279
|
const rows = [];
|
|
202
280
|
for (let r = 0; r < totalHeight; r++) {
|
|
203
281
|
const parts = [];
|
|
@@ -208,7 +286,18 @@ function renderRow(items, totalHeight, gap) {
|
|
|
208
286
|
}
|
|
209
287
|
return rows.join('\n');
|
|
210
288
|
}
|
|
211
|
-
|
|
289
|
+
/**
|
|
290
|
+
* Stack resolved children vertically in a column layout.
|
|
291
|
+
*
|
|
292
|
+
* @param items - Resolved children with allocated heights.
|
|
293
|
+
* @param totalWidth - Total available width in columns.
|
|
294
|
+
* @param totalHeight - Total available height in rows.
|
|
295
|
+
* @param gap - Vertical gap between children in rows.
|
|
296
|
+
* @param containerBg - Optional background fill function for container regions (gaps, padding).
|
|
297
|
+
* @param ctx - Bijou context, used to resolve per-child bgToken fills.
|
|
298
|
+
* @returns Composed column string with lines joined by newlines.
|
|
299
|
+
*/
|
|
300
|
+
function renderColumn(items, totalWidth, totalHeight, gap, containerBg, ctx) {
|
|
212
301
|
const lines = [];
|
|
213
302
|
for (let i = 0; i < items.length; i++) {
|
|
214
303
|
const item = items[i];
|
|
@@ -216,17 +305,22 @@ function renderColumn(items, totalWidth, totalHeight, gap) {
|
|
|
216
305
|
const rendered = renderContent(item.child, totalWidth, childHeight);
|
|
217
306
|
const widthFitted = fitWidth(rendered, totalWidth, item.child.align ?? 'start');
|
|
218
307
|
const aligned = alignCross(widthFitted, childHeight, 'start', totalWidth);
|
|
219
|
-
|
|
308
|
+
// Apply per-child bg fill
|
|
309
|
+
const childBg = makeBgFill(item.child.bgToken, ctx) ?? containerBg;
|
|
310
|
+
const filled = childBg ? aligned.map(childBg) : aligned;
|
|
311
|
+
lines.push(...filled);
|
|
220
312
|
// Add gap between items
|
|
221
313
|
if (i < items.length - 1 && gap > 0) {
|
|
222
|
-
const
|
|
314
|
+
const rawSpacer = ' '.repeat(Math.max(0, totalWidth));
|
|
315
|
+
const spacer = containerBg ? containerBg(rawSpacer) : rawSpacer;
|
|
223
316
|
for (let g = 0; g < gap; g++) {
|
|
224
317
|
lines.push(spacer);
|
|
225
318
|
}
|
|
226
319
|
}
|
|
227
320
|
}
|
|
228
321
|
// Pad to fill totalHeight if needed
|
|
229
|
-
const
|
|
322
|
+
const rawEmpty = ' '.repeat(Math.max(0, totalWidth));
|
|
323
|
+
const emptyLine = containerBg ? containerBg(rawEmpty) : rawEmpty;
|
|
230
324
|
while (lines.length < totalHeight) {
|
|
231
325
|
lines.push(emptyLine);
|
|
232
326
|
}
|
package/dist/flex.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flex.js","sourceRoot":"","sources":["../src/flex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;
|
|
1
|
+
{"version":3,"file":"flex.js","sourceRoot":"","sources":["../src/flex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAOH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AA2CjD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE3D,8EAA8E;AAC9E,eAA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AAC,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YAChE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC7B,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;IACH,CAAC;IAED,oCAAoC;IACpC,MAAM,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC;IACrD,MAAM,SAAS,GAAG,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IACjE,OAAO,KAAK,CAAC,MAAM,GAAG,WAAW,EAAE,CAAC;QAClC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACxB,CAAC;IAED,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Focus area building block — a scrollable pane with a colored left gutter.
|
|
3
|
+
*
|
|
4
|
+
* Wraps `viewport()` and prepends a styled gutter character (`▎`) to each
|
|
5
|
+
* line indicating focus state: bright accent when focused, muted when unfocused.
|
|
6
|
+
*
|
|
7
|
+
* Follows the building block pattern: immutable state + pure transformers +
|
|
8
|
+
* pure render + convenience keymap factory.
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* // In TEA init:
|
|
12
|
+
* const fa = createFocusAreaState({ content, width: 60, height: 20 });
|
|
13
|
+
*
|
|
14
|
+
* // In TEA view:
|
|
15
|
+
* const output = focusArea(fa, { focused: true, ctx });
|
|
16
|
+
*
|
|
17
|
+
* // In TEA update:
|
|
18
|
+
* case 'scroll-down':
|
|
19
|
+
* return [{ ...model, fa: focusAreaScrollBy(model.fa, 1) }, []];
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
import type { BijouContext, TokenValue } from '@flyingrobots/bijou';
|
|
23
|
+
import { type ScrollState } from './viewport.js';
|
|
24
|
+
import { type KeyMap } from './keybindings.js';
|
|
25
|
+
/** Horizontal overflow behavior. */
|
|
26
|
+
export type OverflowX = 'scroll' | 'hidden';
|
|
27
|
+
/** Immutable state for the focus area widget. */
|
|
28
|
+
export interface FocusAreaState {
|
|
29
|
+
/** Full text content displayed in the focus area. */
|
|
30
|
+
readonly content: string;
|
|
31
|
+
/** Underlying scroll position state. */
|
|
32
|
+
readonly scroll: ScrollState;
|
|
33
|
+
/** Total width in columns (including gutter). */
|
|
34
|
+
readonly width: number;
|
|
35
|
+
/** Total height in rows. */
|
|
36
|
+
readonly height: number;
|
|
37
|
+
/** Horizontal overflow behavior. */
|
|
38
|
+
readonly overflowX: OverflowX;
|
|
39
|
+
}
|
|
40
|
+
/** Options for creating a new focus area state. */
|
|
41
|
+
export interface FocusAreaOptions {
|
|
42
|
+
/** Full text content to display. */
|
|
43
|
+
readonly content: string;
|
|
44
|
+
/** Total width in columns (including gutter). */
|
|
45
|
+
readonly width: number;
|
|
46
|
+
/** Total height in rows. */
|
|
47
|
+
readonly height: number;
|
|
48
|
+
/** Horizontal overflow behavior. Default: `'hidden'`. */
|
|
49
|
+
readonly overflowX?: OverflowX;
|
|
50
|
+
}
|
|
51
|
+
/** Options for rendering the focus area view. */
|
|
52
|
+
export interface FocusAreaRenderOptions {
|
|
53
|
+
/** Whether the pane is currently focused. Default: `true`. */
|
|
54
|
+
readonly focused?: boolean;
|
|
55
|
+
/** Token for the focused gutter. Default: `theme.semantic.accent`. */
|
|
56
|
+
readonly focusedGutterToken?: TokenValue;
|
|
57
|
+
/** Token for the unfocused gutter. Default: `theme.semantic.muted`. */
|
|
58
|
+
readonly unfocusedGutterToken?: TokenValue;
|
|
59
|
+
/** Show a scrollbar track on the right edge. Default: `true`. */
|
|
60
|
+
readonly showScrollbar?: boolean;
|
|
61
|
+
/** Bijou context for styling and mode detection. */
|
|
62
|
+
readonly ctx?: BijouContext;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Create initial focus area state for the given content and dimensions.
|
|
66
|
+
*
|
|
67
|
+
* The viewport width is `width - 1` to account for the gutter column.
|
|
68
|
+
* When `overflowX` is `'scroll'`, horizontal scroll bounds are computed
|
|
69
|
+
* from the widest content line.
|
|
70
|
+
*
|
|
71
|
+
* @param options - Content, width, height, and overflow for the focus area.
|
|
72
|
+
* @returns Fresh focus area state with scroll at the top-left.
|
|
73
|
+
*/
|
|
74
|
+
export declare function createFocusAreaState(options: FocusAreaOptions): FocusAreaState;
|
|
75
|
+
/**
|
|
76
|
+
* Scroll vertically by a relative amount.
|
|
77
|
+
*
|
|
78
|
+
* @param state - Current focus area state.
|
|
79
|
+
* @param dy - Relative vertical offset (positive = down).
|
|
80
|
+
* @returns Updated state with new scroll position.
|
|
81
|
+
*/
|
|
82
|
+
export declare function focusAreaScrollBy(state: FocusAreaState, dy: number): FocusAreaState;
|
|
83
|
+
/**
|
|
84
|
+
* Scroll vertically to an absolute position.
|
|
85
|
+
*
|
|
86
|
+
* @param state - Current focus area state.
|
|
87
|
+
* @param y - Absolute vertical offset (0-based).
|
|
88
|
+
* @returns Updated state with new scroll position.
|
|
89
|
+
*/
|
|
90
|
+
export declare function focusAreaScrollTo(state: FocusAreaState, y: number): FocusAreaState;
|
|
91
|
+
/**
|
|
92
|
+
* Scroll to the first line.
|
|
93
|
+
*
|
|
94
|
+
* @param state - Current focus area state.
|
|
95
|
+
* @returns Updated state scrolled to the top.
|
|
96
|
+
*/
|
|
97
|
+
export declare function focusAreaScrollToTop(state: FocusAreaState): FocusAreaState;
|
|
98
|
+
/**
|
|
99
|
+
* Scroll to the last line.
|
|
100
|
+
*
|
|
101
|
+
* @param state - Current focus area state.
|
|
102
|
+
* @returns Updated state scrolled to the bottom.
|
|
103
|
+
*/
|
|
104
|
+
export declare function focusAreaScrollToBottom(state: FocusAreaState): FocusAreaState;
|
|
105
|
+
/**
|
|
106
|
+
* Page down (one viewport height).
|
|
107
|
+
*
|
|
108
|
+
* @param state - Current focus area state.
|
|
109
|
+
* @returns Updated state advanced by one page.
|
|
110
|
+
*/
|
|
111
|
+
export declare function focusAreaPageDown(state: FocusAreaState): FocusAreaState;
|
|
112
|
+
/**
|
|
113
|
+
* Page up (one viewport height).
|
|
114
|
+
*
|
|
115
|
+
* @param state - Current focus area state.
|
|
116
|
+
* @returns Updated state moved back by one page.
|
|
117
|
+
*/
|
|
118
|
+
export declare function focusAreaPageUp(state: FocusAreaState): FocusAreaState;
|
|
119
|
+
/**
|
|
120
|
+
* Scroll horizontally by a relative amount.
|
|
121
|
+
* No-op when `overflowX` is `'hidden'`.
|
|
122
|
+
*
|
|
123
|
+
* @param state - Current focus area state.
|
|
124
|
+
* @param dx - Relative horizontal offset (positive = right).
|
|
125
|
+
* @returns Updated state with new horizontal scroll position.
|
|
126
|
+
*/
|
|
127
|
+
export declare function focusAreaScrollByX(state: FocusAreaState, dx: number): FocusAreaState;
|
|
128
|
+
/**
|
|
129
|
+
* Scroll horizontally to an absolute position.
|
|
130
|
+
* No-op when `overflowX` is `'hidden'`.
|
|
131
|
+
*
|
|
132
|
+
* @param state - Current focus area state.
|
|
133
|
+
* @param x - Absolute horizontal offset (0-based).
|
|
134
|
+
* @returns Updated state with new horizontal scroll position.
|
|
135
|
+
*/
|
|
136
|
+
export declare function focusAreaScrollToX(state: FocusAreaState, x: number): FocusAreaState;
|
|
137
|
+
/**
|
|
138
|
+
* Update content while preserving scroll position (clamped).
|
|
139
|
+
*
|
|
140
|
+
* @param state - Current focus area state.
|
|
141
|
+
* @param content - New text content to display.
|
|
142
|
+
* @returns Updated state with new content and clamped scroll position.
|
|
143
|
+
*/
|
|
144
|
+
export declare function focusAreaSetContent(state: FocusAreaState, content: string): FocusAreaState;
|
|
145
|
+
/**
|
|
146
|
+
* Render the focus area — viewport content with a colored left gutter.
|
|
147
|
+
*
|
|
148
|
+
* The gutter character (`▎`) is styled based on focus state:
|
|
149
|
+
* - Focused: `focusedGutterToken` (default: `theme.semantic.accent`)
|
|
150
|
+
* - Unfocused: `unfocusedGutterToken` (default: `theme.semantic.muted`)
|
|
151
|
+
* - Static mode: unstyled gutter
|
|
152
|
+
* - Pipe / accessible mode: no gutter (full width to content)
|
|
153
|
+
*
|
|
154
|
+
* @param state - Current focus area state.
|
|
155
|
+
* @param options - Rendering options (focus, tokens, scrollbar, ctx).
|
|
156
|
+
* @returns Rendered focus area string.
|
|
157
|
+
*/
|
|
158
|
+
export declare function focusArea(state: FocusAreaState, options?: FocusAreaRenderOptions): string;
|
|
159
|
+
/**
|
|
160
|
+
* Create a preconfigured KeyMap for focus area navigation.
|
|
161
|
+
*
|
|
162
|
+
* Arrow keys are intentionally excluded — reserved for content-specific
|
|
163
|
+
* navigation (e.g., DAG node selection).
|
|
164
|
+
*
|
|
165
|
+
* @template Msg - Application message type dispatched by key bindings.
|
|
166
|
+
* @param actions - Map of navigation actions to message values.
|
|
167
|
+
* @returns Preconfigured key map with vim-style scroll bindings.
|
|
168
|
+
*/
|
|
169
|
+
export declare function focusAreaKeyMap<Msg>(actions: {
|
|
170
|
+
scrollUp: Msg;
|
|
171
|
+
scrollDown: Msg;
|
|
172
|
+
pageUp: Msg;
|
|
173
|
+
pageDown: Msg;
|
|
174
|
+
top: Msg;
|
|
175
|
+
bottom: Msg;
|
|
176
|
+
scrollLeft?: Msg;
|
|
177
|
+
scrollRight?: Msg;
|
|
178
|
+
}): KeyMap<Msg>;
|
|
179
|
+
//# sourceMappingURL=focus-area.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus-area.d.ts","sourceRoot":"","sources":["../src/focus-area.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU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