@valyrianjs/terminal 0.1.2 → 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.
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/primitives.d.ts +8 -3
- package/dist/primitives.d.ts.map +1 -1
- package/dist/primitives.js.map +1 -1
- package/dist/render.d.ts +1 -1
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +107 -25
- package/dist/render.js.map +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +0 -6
- package/dist/runtime.js.map +1 -1
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +135 -6
- package/dist/session.js.map +1 -1
- package/dist/types.d.ts +23 -9
- package/dist/types.d.ts.map +1 -1
- package/docs/api-reference.md +30 -25
- package/docs/cookbook.md +1 -1
- package/docs/core-concepts.md +1 -1
- package/docs/interaction-model.md +12 -2
- package/docs/primitive-gallery.md +14 -9
- package/llms-full.txt +58 -38
- package/package.json +1 -1
- package/src/index.ts +3 -0
- package/src/primitives.ts +8 -5
- package/src/render.ts +122 -25
- package/src/runtime.ts +0 -6
- package/src/session.ts +154 -6
- package/src/types.ts +27 -9
|
@@ -41,12 +41,14 @@ Supported behavior includes:
|
|
|
41
41
|
- selection with `SHIFT_LEFT`, `SHIFT_RIGHT`, and `CTRL_A`
|
|
42
42
|
- copy, cut, and paste through `CTRL_C`, `CTRL_X`, and `CTRL_V`
|
|
43
43
|
- deletion with `BACKSPACE` and `DELETE`
|
|
44
|
+
- context press through pointer context input
|
|
44
45
|
|
|
45
46
|
Main handlers:
|
|
46
47
|
|
|
47
48
|
- `onchange`
|
|
48
49
|
- `oninput`
|
|
49
50
|
- `onsubmit`
|
|
51
|
+
- `oncontextpress`
|
|
50
52
|
|
|
51
53
|
### `Editor`
|
|
52
54
|
|
|
@@ -84,8 +86,10 @@ Activation paths:
|
|
|
84
86
|
Main handlers:
|
|
85
87
|
|
|
86
88
|
- `onpress`
|
|
87
|
-
- `
|
|
88
|
-
- `
|
|
89
|
+
- `ondoublepress`
|
|
90
|
+
- `oncontextpress`
|
|
91
|
+
|
|
92
|
+
A quick second primary mouse press keeps the normal activation behavior and also emits `ondoublepress` when the handler exists. A secondary mouse press emits `oncontextpress`.
|
|
89
93
|
|
|
90
94
|
### `List`
|
|
91
95
|
|
|
@@ -97,11 +101,15 @@ Supported behavior includes:
|
|
|
97
101
|
- `DOWN` and `RIGHT` move selection down
|
|
98
102
|
- `ENTER` activates the selected row
|
|
99
103
|
- mouse hover reports row details when mouse input is connected
|
|
104
|
+
- quick primary mouse presses on the same row emit `ondoublepress`
|
|
105
|
+
- secondary mouse presses emit `oncontextpress` for the target row
|
|
100
106
|
|
|
101
107
|
Main handlers:
|
|
102
108
|
|
|
103
109
|
- `onchange`
|
|
104
110
|
- `onpress`
|
|
111
|
+
- `ondoublepress`
|
|
112
|
+
- `oncontextpress`
|
|
105
113
|
- `onhover`
|
|
106
114
|
- `onrowenter`
|
|
107
115
|
- `onrowleave`
|
|
@@ -120,12 +128,14 @@ Supported behavior includes:
|
|
|
120
128
|
- `height` as the visible viewport
|
|
121
129
|
- `highlightRows` for marking visible rows
|
|
122
130
|
- mouse hover details when mouse input is connected
|
|
131
|
+
- context press reports the target visible row
|
|
123
132
|
|
|
124
133
|
Main handlers:
|
|
125
134
|
|
|
126
135
|
- `onhover`
|
|
127
136
|
- `onrowenter`
|
|
128
137
|
- `onrowleave`
|
|
138
|
+
- `oncontextpress`
|
|
129
139
|
- `oncapturestart`
|
|
130
140
|
- `oncaptureend`
|
|
131
141
|
|
|
@@ -133,14 +133,19 @@ Use `Split` for resizable shells and master/detail layouts.
|
|
|
133
133
|
|
|
134
134
|
Use `Fixed` for headers, footers, rails, and persistent status bars.
|
|
135
135
|
|
|
136
|
-
**What it is:** A reserved region attached to an edge of
|
|
136
|
+
**What it is:** A reserved region attached to an edge of a parent frame.
|
|
137
137
|
**Use it for:** headers, footers, rails, and persistent status bars.
|
|
138
138
|
**Core props:** `position`, `size`.
|
|
139
139
|
|
|
140
|
+
Inside `Screen` or `Pane`, `Fixed` uses the parent frame. If you pass a standalone `Fixed` root to `renderTerminal()`, pass `{ cols, rows }` so it has a viewport.
|
|
141
|
+
|
|
140
142
|
**Minimal example:**
|
|
141
143
|
|
|
142
144
|
```tsx
|
|
143
|
-
<
|
|
145
|
+
<Screen>
|
|
146
|
+
<Fixed position="bottom" size={1}><Text>Ctrl+C: quit</Text></Fixed>
|
|
147
|
+
<Pane><Text>Work area</Text></Pane>
|
|
148
|
+
</Screen>
|
|
144
149
|
```
|
|
145
150
|
|
|
146
151
|
**Complete demo:** [`examples/docs/primitive-layout-shell.tsx`](../examples/docs/primitive-layout-shell.tsx). Run it with `bun examples/docs/primitive-layout-shell.tsx` and quit with `Ctrl+C`.
|
|
@@ -155,7 +160,7 @@ Use `Input` for names, filters, prompts, and short commands.
|
|
|
155
160
|
|
|
156
161
|
**What it is:** A single-line editable field.
|
|
157
162
|
**Use it for:** names, filters, prompts, and short commands.
|
|
158
|
-
**Core props:** `id`, `value`, `placeholder`, `onchange`, `oninput`, `onsubmit`.
|
|
163
|
+
**Core props:** `id`, `value`, `placeholder`, `onchange`, `oninput`, `onsubmit`, `oncontextpress`.
|
|
159
164
|
|
|
160
165
|
**Minimal example:**
|
|
161
166
|
|
|
@@ -187,7 +192,7 @@ Use `Button` for save actions, confirmations, command triggers, and app actions.
|
|
|
187
192
|
|
|
188
193
|
**What it is:** A focusable action control.
|
|
189
194
|
**Use it for:** save actions, confirmations, command triggers, and app actions.
|
|
190
|
-
**Core props:** `id`, `label`, `onpress`, `
|
|
195
|
+
**Core props:** `id`, `label`, `onpress`, `ondoublepress`, `oncontextpress`, `style`, `styles`, `state`.
|
|
191
196
|
|
|
192
197
|
**Minimal example:**
|
|
193
198
|
|
|
@@ -223,7 +228,7 @@ Use `List` for menus, choosers, command lists, and item browsers.
|
|
|
223
228
|
|
|
224
229
|
**What it is:** A focusable collection control with selection and press events.
|
|
225
230
|
**Use it for:** menus, choosers, command lists, and item browsers.
|
|
226
|
-
**Core props:** `id`, `items`, `renderItem`, `virtualized`, `onchange`, `onpress`.
|
|
231
|
+
**Core props:** `id`, `items`, `renderItem`, `virtualized`, `onchange`, `onpress`, `ondoublepress`, `oncontextpress`.
|
|
227
232
|
|
|
228
233
|
**Minimal example:**
|
|
229
234
|
|
|
@@ -291,7 +296,7 @@ Use `ScrollView` for long instructions, timelines, and scrollable panels.
|
|
|
291
296
|
|
|
292
297
|
**What it is:** A bounded viewport for child content.
|
|
293
298
|
**Use it for:** long instructions, timelines, and scrollable panels.
|
|
294
|
-
**Core props:** `id`, `height`, `highlightRows`, `pointerCapture`, row pointer events.
|
|
299
|
+
**Core props:** `id`, `height`, `highlightRows`, `pointerCapture`, `oncontextpress`, row pointer events.
|
|
295
300
|
|
|
296
301
|
**Minimal example:**
|
|
297
302
|
|
|
@@ -327,12 +332,12 @@ Use `Overlay` for command panels, dialogs, palettes, and focused chooser surface
|
|
|
327
332
|
|
|
328
333
|
**What it is:** A positioned layer over the current frame.
|
|
329
334
|
**Use it for:** command panels, dialogs, palettes, and focused chooser surfaces.
|
|
330
|
-
**Core props:** `id`, `
|
|
335
|
+
**Core props:** `id`, `margin`, `trapFocus`, `style`. `margin` is required and accepts a number, a percentage string, or `{ x, y }` with number or percentage-string values. When `Overlay` is the root passed to `renderTerminal()`, pass exact `{ cols, rows }` as the second argument so margin can resolve against terminal dimensions.
|
|
331
336
|
|
|
332
337
|
**Minimal example:**
|
|
333
338
|
|
|
334
339
|
```tsx
|
|
335
|
-
<Overlay
|
|
340
|
+
<Overlay margin={{ x: 4, y: 2 }} trapFocus><Text>Command Panel</Text></Overlay>
|
|
336
341
|
```
|
|
337
342
|
|
|
338
343
|
**Complete demo:** [`examples/docs/primitive-command-panel.tsx`](../examples/docs/primitive-command-panel.tsx). Run it with `bun examples/docs/primitive-command-panel.tsx` and quit with `Ctrl+C`.
|
|
@@ -348,7 +353,7 @@ Use `FocusScope` to keep input, lists, and actions together inside a panel.
|
|
|
348
353
|
**Minimal example:**
|
|
349
354
|
|
|
350
355
|
```tsx
|
|
351
|
-
<Overlay
|
|
356
|
+
<Overlay margin={{ x: 2, y: 2 }} trapFocus><FocusScope><Input id="query" /><List id="commands" items={commands} /></FocusScope></Overlay>
|
|
352
357
|
```
|
|
353
358
|
|
|
354
359
|
**Complete demo:** [`examples/docs/primitive-command-panel.tsx`](../examples/docs/primitive-command-panel.tsx). Run it with `bun examples/docs/primitive-command-panel.tsx` and quit with `Ctrl+C`.
|
package/llms-full.txt
CHANGED
|
@@ -530,7 +530,7 @@ Focus belongs to the `TerminalSession`; app state remains yours. `FocusScope` ca
|
|
|
530
530
|
|
|
531
531
|
## Styling and visual states
|
|
532
532
|
|
|
533
|
-
Use `theme.styles` for named recipes with hex colors, border, and padding. The default theme already gives `Button`, `Input`, and `List` app-like base, focus, selection, current, hover, loading, and disabled styles, so `<Button><Text>Ok</Text></Button>` renders as a styled control without per-instance chrome. Components still use `style` for their base recipe, `styles` to map visual states to recipes, and `state` when the app owns a visual status. Raw span serialization tokens belong to low-level renderer integrations; normal styling uses semantic styles and hex colors.
|
|
533
|
+
Use `theme.styles` for named recipes with hex colors, border, and padding. The default theme already gives `Button`, `Input`, and `List` app-like base, focus, selection, current, hover, loading, and disabled styles, so `<Button><Text>Ok</Text></Button>` renders as a styled control without per-instance chrome. When a primitive has a matching `<element>.base` recipe, the renderer applies it automatically before instance styles. Components still use `style` for their base recipe, `styles` to map visual states to recipes, and `state` when the app owns a visual status. Raw span serialization tokens belong to low-level renderer integrations; normal styling uses semantic styles and hex colors.
|
|
534
534
|
|
|
535
535
|
Related example: [`examples/docs/style-system.tsx`](../examples/docs/style-system.tsx). Run it with `bun examples/docs/style-system.tsx`, try `Tab`, `Enter`, and `W`, and quit with `Ctrl+C`.
|
|
536
536
|
|
|
@@ -756,7 +756,7 @@ function App() {
|
|
|
756
756
|
return (
|
|
757
757
|
<Screen title="Overlay recipe">
|
|
758
758
|
<Text>{state.executed ? `Executed: ${state.executed}` : "Choose a command"}</Text>
|
|
759
|
-
<Overlay
|
|
759
|
+
<Overlay margin={{ x: 2, y: 2 }} trapFocus>
|
|
760
760
|
<FocusScope>
|
|
761
761
|
<Input
|
|
762
762
|
id="query"
|
|
@@ -1101,14 +1101,19 @@ Use `Split` for resizable shells and master/detail layouts.
|
|
|
1101
1101
|
|
|
1102
1102
|
Use `Fixed` for headers, footers, rails, and persistent status bars.
|
|
1103
1103
|
|
|
1104
|
-
**What it is:** A reserved region attached to an edge of
|
|
1104
|
+
**What it is:** A reserved region attached to an edge of a parent frame.
|
|
1105
1105
|
**Use it for:** headers, footers, rails, and persistent status bars.
|
|
1106
1106
|
**Core props:** `position`, `size`.
|
|
1107
1107
|
|
|
1108
|
+
Inside `Screen` or `Pane`, `Fixed` uses the parent frame. If you pass a standalone `Fixed` root to `renderTerminal()`, pass `{ cols, rows }` so it has a viewport.
|
|
1109
|
+
|
|
1108
1110
|
**Minimal example:**
|
|
1109
1111
|
|
|
1110
1112
|
```tsx
|
|
1111
|
-
<
|
|
1113
|
+
<Screen>
|
|
1114
|
+
<Fixed position="bottom" size={1}><Text>Ctrl+C: quit</Text></Fixed>
|
|
1115
|
+
<Pane><Text>Work area</Text></Pane>
|
|
1116
|
+
</Screen>
|
|
1112
1117
|
```
|
|
1113
1118
|
|
|
1114
1119
|
**Complete demo:** [`examples/docs/primitive-layout-shell.tsx`](../examples/docs/primitive-layout-shell.tsx). Run it with `bun examples/docs/primitive-layout-shell.tsx` and quit with `Ctrl+C`.
|
|
@@ -1123,7 +1128,7 @@ Use `Input` for names, filters, prompts, and short commands.
|
|
|
1123
1128
|
|
|
1124
1129
|
**What it is:** A single-line editable field.
|
|
1125
1130
|
**Use it for:** names, filters, prompts, and short commands.
|
|
1126
|
-
**Core props:** `id`, `value`, `placeholder`, `onchange`, `oninput`, `onsubmit`.
|
|
1131
|
+
**Core props:** `id`, `value`, `placeholder`, `onchange`, `oninput`, `onsubmit`, `oncontextpress`.
|
|
1127
1132
|
|
|
1128
1133
|
**Minimal example:**
|
|
1129
1134
|
|
|
@@ -1155,7 +1160,7 @@ Use `Button` for save actions, confirmations, command triggers, and app actions.
|
|
|
1155
1160
|
|
|
1156
1161
|
**What it is:** A focusable action control.
|
|
1157
1162
|
**Use it for:** save actions, confirmations, command triggers, and app actions.
|
|
1158
|
-
**Core props:** `id`, `label`, `onpress`, `
|
|
1163
|
+
**Core props:** `id`, `label`, `onpress`, `ondoublepress`, `oncontextpress`, `style`, `styles`, `state`.
|
|
1159
1164
|
|
|
1160
1165
|
**Minimal example:**
|
|
1161
1166
|
|
|
@@ -1191,7 +1196,7 @@ Use `List` for menus, choosers, command lists, and item browsers.
|
|
|
1191
1196
|
|
|
1192
1197
|
**What it is:** A focusable collection control with selection and press events.
|
|
1193
1198
|
**Use it for:** menus, choosers, command lists, and item browsers.
|
|
1194
|
-
**Core props:** `id`, `items`, `renderItem`, `virtualized`, `onchange`, `onpress`.
|
|
1199
|
+
**Core props:** `id`, `items`, `renderItem`, `virtualized`, `onchange`, `onpress`, `ondoublepress`, `oncontextpress`.
|
|
1195
1200
|
|
|
1196
1201
|
**Minimal example:**
|
|
1197
1202
|
|
|
@@ -1259,7 +1264,7 @@ Use `ScrollView` for long instructions, timelines, and scrollable panels.
|
|
|
1259
1264
|
|
|
1260
1265
|
**What it is:** A bounded viewport for child content.
|
|
1261
1266
|
**Use it for:** long instructions, timelines, and scrollable panels.
|
|
1262
|
-
**Core props:** `id`, `height`, `highlightRows`, `pointerCapture`, row pointer events.
|
|
1267
|
+
**Core props:** `id`, `height`, `highlightRows`, `pointerCapture`, `oncontextpress`, row pointer events.
|
|
1263
1268
|
|
|
1264
1269
|
**Minimal example:**
|
|
1265
1270
|
|
|
@@ -1295,12 +1300,12 @@ Use `Overlay` for command panels, dialogs, palettes, and focused chooser surface
|
|
|
1295
1300
|
|
|
1296
1301
|
**What it is:** A positioned layer over the current frame.
|
|
1297
1302
|
**Use it for:** command panels, dialogs, palettes, and focused chooser surfaces.
|
|
1298
|
-
**Core props:** `id`, `
|
|
1303
|
+
**Core props:** `id`, `margin`, `trapFocus`, `style`. `margin` is required and accepts a number, a percentage string, or `{ x, y }` with number or percentage-string values. When `Overlay` is the root passed to `renderTerminal()`, pass exact `{ cols, rows }` as the second argument so margin can resolve against terminal dimensions.
|
|
1299
1304
|
|
|
1300
1305
|
**Minimal example:**
|
|
1301
1306
|
|
|
1302
1307
|
```tsx
|
|
1303
|
-
<Overlay
|
|
1308
|
+
<Overlay margin={{ x: 4, y: 2 }} trapFocus><Text>Command Panel</Text></Overlay>
|
|
1304
1309
|
```
|
|
1305
1310
|
|
|
1306
1311
|
**Complete demo:** [`examples/docs/primitive-command-panel.tsx`](../examples/docs/primitive-command-panel.tsx). Run it with `bun examples/docs/primitive-command-panel.tsx` and quit with `Ctrl+C`.
|
|
@@ -1316,7 +1321,7 @@ Use `FocusScope` to keep input, lists, and actions together inside a panel.
|
|
|
1316
1321
|
**Minimal example:**
|
|
1317
1322
|
|
|
1318
1323
|
```tsx
|
|
1319
|
-
<Overlay
|
|
1324
|
+
<Overlay margin={{ x: 2, y: 2 }} trapFocus><FocusScope><Input id="query" /><List id="commands" items={commands} /></FocusScope></Overlay>
|
|
1320
1325
|
```
|
|
1321
1326
|
|
|
1322
1327
|
**Complete demo:** [`examples/docs/primitive-command-panel.tsx`](../examples/docs/primitive-command-panel.tsx). Run it with `bun examples/docs/primitive-command-panel.tsx` and quit with `Ctrl+C`.
|
|
@@ -1379,12 +1384,14 @@ Supported behavior includes:
|
|
|
1379
1384
|
- selection with `SHIFT_LEFT`, `SHIFT_RIGHT`, and `CTRL_A`
|
|
1380
1385
|
- copy, cut, and paste through `CTRL_C`, `CTRL_X`, and `CTRL_V`
|
|
1381
1386
|
- deletion with `BACKSPACE` and `DELETE`
|
|
1387
|
+
- context press through pointer context input
|
|
1382
1388
|
|
|
1383
1389
|
Main handlers:
|
|
1384
1390
|
|
|
1385
1391
|
- `onchange`
|
|
1386
1392
|
- `oninput`
|
|
1387
1393
|
- `onsubmit`
|
|
1394
|
+
- `oncontextpress`
|
|
1388
1395
|
|
|
1389
1396
|
### `Editor`
|
|
1390
1397
|
|
|
@@ -1422,8 +1429,10 @@ Activation paths:
|
|
|
1422
1429
|
Main handlers:
|
|
1423
1430
|
|
|
1424
1431
|
- `onpress`
|
|
1425
|
-
- `
|
|
1426
|
-
- `
|
|
1432
|
+
- `ondoublepress`
|
|
1433
|
+
- `oncontextpress`
|
|
1434
|
+
|
|
1435
|
+
A quick second primary mouse press keeps the normal activation behavior and also emits `ondoublepress` when the handler exists. A secondary mouse press emits `oncontextpress`.
|
|
1427
1436
|
|
|
1428
1437
|
### `List`
|
|
1429
1438
|
|
|
@@ -1435,11 +1444,15 @@ Supported behavior includes:
|
|
|
1435
1444
|
- `DOWN` and `RIGHT` move selection down
|
|
1436
1445
|
- `ENTER` activates the selected row
|
|
1437
1446
|
- mouse hover reports row details when mouse input is connected
|
|
1447
|
+
- quick primary mouse presses on the same row emit `ondoublepress`
|
|
1448
|
+
- secondary mouse presses emit `oncontextpress` for the target row
|
|
1438
1449
|
|
|
1439
1450
|
Main handlers:
|
|
1440
1451
|
|
|
1441
1452
|
- `onchange`
|
|
1442
1453
|
- `onpress`
|
|
1454
|
+
- `ondoublepress`
|
|
1455
|
+
- `oncontextpress`
|
|
1443
1456
|
- `onhover`
|
|
1444
1457
|
- `onrowenter`
|
|
1445
1458
|
- `onrowleave`
|
|
@@ -1458,12 +1471,14 @@ Supported behavior includes:
|
|
|
1458
1471
|
- `height` as the visible viewport
|
|
1459
1472
|
- `highlightRows` for marking visible rows
|
|
1460
1473
|
- mouse hover details when mouse input is connected
|
|
1474
|
+
- context press reports the target visible row
|
|
1461
1475
|
|
|
1462
1476
|
Main handlers:
|
|
1463
1477
|
|
|
1464
1478
|
- `onhover`
|
|
1465
1479
|
- `onrowenter`
|
|
1466
1480
|
- `onrowleave`
|
|
1481
|
+
- `oncontextpress`
|
|
1467
1482
|
- `oncapturestart`
|
|
1468
1483
|
- `oncaptureend`
|
|
1469
1484
|
|
|
@@ -4936,9 +4951,9 @@ import { Screen, Text, mountTerminal, renderTerminal } from "@valyrianjs/termina
|
|
|
4936
4951
|
|
|
4937
4952
|
Rendering-only subpath for lower-level rendering utilities:
|
|
4938
4953
|
|
|
4939
|
-
- `renderTerminal(input): string`
|
|
4940
|
-
- `renderTerminalNode(node): string`
|
|
4941
|
-
- `renderTerminalFrame(node): TerminalFrame`
|
|
4954
|
+
- `renderTerminal(input, context?): string`
|
|
4955
|
+
- `renderTerminalNode(node, context?): string`
|
|
4956
|
+
- `renderTerminalFrame(node, context?): TerminalFrame`
|
|
4942
4957
|
|
|
4943
4958
|
Use this subpath for rendering-focused integrations that produce output without mounting an interactive session.
|
|
4944
4959
|
|
|
@@ -4948,9 +4963,9 @@ The root entrypoint exports the public primitives (`Screen`, `Box`, `View`, `Pan
|
|
|
4948
4963
|
|
|
4949
4964
|
## Main functions
|
|
4950
4965
|
|
|
4951
|
-
### `renderTerminal(input): string`
|
|
4966
|
+
### `renderTerminal(input, context?): string`
|
|
4952
4967
|
|
|
4953
|
-
Resolves the provided terminal tree and returns plain text.
|
|
4968
|
+
Resolves the provided terminal tree and returns plain text. Pass `{ cols, rows }` when the root tree uses viewport-dependent primitives such as standalone `Overlay` with `margin` or standalone `Fixed`.
|
|
4954
4969
|
|
|
4955
4970
|
Use it for:
|
|
4956
4971
|
|
|
@@ -4959,6 +4974,8 @@ Use it for:
|
|
|
4959
4974
|
- non-interactive command output
|
|
4960
4975
|
- layout checks without session state
|
|
4961
4976
|
|
|
4977
|
+
`context` accepts exact terminal dimensions as positive integers and an optional theme: `{ cols, rows, theme? }`. Mounted sessions infer dimensions from `mountTerminal()` options or the host terminal.
|
|
4978
|
+
|
|
4962
4979
|
### `mountTerminal(input, options?): TerminalSession`
|
|
4963
4980
|
|
|
4964
4981
|
Creates an interactive session around a terminal tree.
|
|
@@ -5013,7 +5030,7 @@ Theme recipes belong in `theme.styles`. Use `color`, `background`, padding, and
|
|
|
5013
5030
|
|
|
5014
5031
|
## Visual style system
|
|
5015
5032
|
|
|
5016
|
-
`theme.styles` stores named style recipes. A recipe may define color, background, padding, border, and nested visual-state recipes. The bundled default theme
|
|
5033
|
+
`theme.styles` stores named style recipes. A recipe may define color, background, padding, border, and nested visual-state recipes. The renderer applies `theme.styles.<element>.base` automatically to public primitives that have a matching `.base` recipe, before any instance `style`. The bundled default theme uses that rule for app-like core controls such as `button.base`, `button.focus`, `input.base`, `input.focus`, `input.selection`, `list.base`, `list.current`, `list.selected`, `list.hover`, and `list.empty`. Components also resolve recipes by dot path, so `style="panel.queue"` reads `theme.styles.panel.queue`. Inline style objects work too when the style belongs to one component instance.
|
|
5017
5034
|
|
|
5018
5035
|
Use `style`, `styles`, and `state` for normal component styling:
|
|
5019
5036
|
|
|
@@ -5023,7 +5040,7 @@ Use `style`, `styles`, and `state` for normal component styling:
|
|
|
5023
5040
|
|
|
5024
5041
|
Renderer-owned states come from the runtime when the renderer has the fact itself. Focus, hover, selection, current rows, and pointer capture fall in this group when the primitive supports them. App-owned state should describe product state that the app already knows. Do not mark a ready button as `loading` or an editable field as `readonly`; that teaches a lie to the UI and then the UI repeats it with confidence.
|
|
5025
5042
|
|
|
5026
|
-
Precedence: the renderer starts with the
|
|
5043
|
+
Precedence: the renderer starts with the automatic `<element>.base` recipe when the primitive has one, applies the instance `style`, then applies `styles` entries for current states in stable visual-state order. Geometry fields such as supported padding and border come from the automatic base recipe plus the instance `style` so layout, hitboxes, and cursors stay stable across focus, hover, and pressed state changes. State styles affect the rendered spans after layout; later current states override earlier visual fields when they set the same property. Inline style objects and dot path recipes use the same merge path after resolution.
|
|
5027
5044
|
|
|
5028
5045
|
Renderer notes:
|
|
5029
5046
|
|
|
@@ -5141,24 +5158,21 @@ Props:
|
|
|
5141
5158
|
- `position: "top" | "bottom" | "left" | "right"`
|
|
5142
5159
|
- `size: number`
|
|
5143
5160
|
|
|
5144
|
-
|
|
5161
|
+
Reserves stable rows or columns at a frame edge. When `Fixed` is a direct child of `Screen` or `Pane`, that parent supplies the frame and consumes the fixed region before it lays out the remaining content. When `Fixed` is rendered as the root tree passed directly to `renderTerminal()`, it is viewport-dependent and the render call must pass exact dimensions with `{ cols, rows }`. Mounted sessions get those dimensions from `mountTerminal()` options or the host terminal.
|
|
5145
5162
|
|
|
5146
5163
|
### `Overlay`
|
|
5147
5164
|
|
|
5148
5165
|
Props:
|
|
5149
5166
|
|
|
5150
|
-
- `x: number`
|
|
5151
|
-
- `y: number`
|
|
5152
|
-
- `width: number`
|
|
5153
|
-
- `height: number`
|
|
5167
|
+
- `margin: number | "<number>%" | { x: number | "<number>%"; y: number | "<number>%" }`
|
|
5154
5168
|
- shared visual props: `style`, `styles`, `state`
|
|
5155
5169
|
- `trapFocus?: boolean`
|
|
5156
5170
|
- `id?: string`
|
|
5157
5171
|
- `focusable?: boolean`
|
|
5158
5172
|
|
|
5159
|
-
Draws a clipped region over the current frame.
|
|
5173
|
+
Draws a clipped region over the current frame. `margin` sets the distance from the overlay to the frame edges; numbers use cells and percentage strings such as `"10%"` resolve per axis. Use `{ x, y }` when the two axes need different margins. `trapFocus` keeps traversal inside the overlay while it is active.
|
|
5160
5174
|
|
|
5161
|
-
Overlay
|
|
5175
|
+
Overlay calculates its size from the available frame, stays centered by its margins, and keeps app routing and pane movement in your app layer.
|
|
5162
5176
|
|
|
5163
5177
|
### `FocusScope`
|
|
5164
5178
|
|
|
@@ -5195,13 +5209,15 @@ Props:
|
|
|
5195
5209
|
- `onchange?(event)`
|
|
5196
5210
|
- `oninput?(event)`
|
|
5197
5211
|
- `onsubmit?(event)`
|
|
5212
|
+
- `oncontextpress?(event)`
|
|
5198
5213
|
|
|
5199
5214
|
Payloads:
|
|
5200
5215
|
|
|
5201
5216
|
- `TerminalInputChangeEventPayload` - `{ type: "change" | "input", id, value }`
|
|
5202
5217
|
- `TerminalInputSubmitEventPayload` - `{ type: "submit", id, value }`
|
|
5218
|
+
- `TerminalInputContextPressEventPayload` - `{ type: "contextpress", id, value, cursor, x, y }`
|
|
5203
5219
|
|
|
5204
|
-
Supports single-line editing, cursor movement, selection, copy/cut/paste, deletion, and
|
|
5220
|
+
Supports single-line editing, cursor movement, selection, copy/cut/paste, deletion, submit, and context press.
|
|
5205
5221
|
|
|
5206
5222
|
### `Editor`
|
|
5207
5223
|
|
|
@@ -5235,14 +5251,14 @@ Props:
|
|
|
5235
5251
|
- `label?: string`
|
|
5236
5252
|
- shared visual props: `style`, `styles`, `state`
|
|
5237
5253
|
- `onpress?(event)`
|
|
5238
|
-
- `
|
|
5239
|
-
- `
|
|
5254
|
+
- `ondoublepress?(event)`
|
|
5255
|
+
- `oncontextpress?(event)`
|
|
5240
5256
|
|
|
5241
5257
|
Payload:
|
|
5242
5258
|
|
|
5243
|
-
- `TerminalButtonPressEventPayload` - `{ type: "press" | "
|
|
5259
|
+
- `TerminalButtonPressEventPayload` - `{ type: "press" | "doublepress" | "contextpress", id }`
|
|
5244
5260
|
|
|
5245
|
-
Activation paths include focused `ENTER`, focused `SPACE`, `session.click(id)`, and `session.clickAt(x, y)`.
|
|
5261
|
+
Activation paths include focused `ENTER`, focused `SPACE`, `session.click(id)`, and `session.clickAt(x, y)`. A quick second primary mouse press still dispatches the normal activation path and also dispatches `ondoublepress` when present. A secondary mouse press dispatches `oncontextpress`.
|
|
5246
5262
|
|
|
5247
5263
|
### `List<T>`
|
|
5248
5264
|
|
|
@@ -5259,6 +5275,8 @@ Props:
|
|
|
5259
5275
|
- `renderItem?(item, index): string`
|
|
5260
5276
|
- `onchange?(event)`
|
|
5261
5277
|
- `onpress?(event)`
|
|
5278
|
+
- `ondoublepress?(event)`
|
|
5279
|
+
- `oncontextpress?(event)`
|
|
5262
5280
|
- `onhover?(event)`
|
|
5263
5281
|
- `onrowenter?(event)`
|
|
5264
5282
|
- `onrowleave?(event)`
|
|
@@ -5268,11 +5286,11 @@ Props:
|
|
|
5268
5286
|
Payloads:
|
|
5269
5287
|
|
|
5270
5288
|
- `TerminalListChangeEventPayload<T>` - `{ type: "change", id, index, value }`
|
|
5271
|
-
- `TerminalListPressEventPayload<T>` - `{ type: "press", id, index, value }`
|
|
5289
|
+
- `TerminalListPressEventPayload<T>` - `{ type: "press" | "doublepress" | "contextpress", id, index, value }`
|
|
5272
5290
|
- `TerminalListPointerEventPayload<T>` - `{ type: "hover" | "rowenter" | "rowleave", id, row, index, value, x, y }`
|
|
5273
5291
|
- `TerminalCaptureEventPayload` - `{ type: "capturestart" | "captureend", id, source, row, x, y }`
|
|
5274
5292
|
|
|
5275
|
-
Supports selection, activation, hover payloads, optional virtualization, and pointer capture.
|
|
5293
|
+
Supports selection, activation, double press on the same row, context press for the target row, hover payloads, optional virtualization, and pointer capture.
|
|
5276
5294
|
|
|
5277
5295
|
### `ScrollView`
|
|
5278
5296
|
|
|
@@ -5284,15 +5302,17 @@ Props:
|
|
|
5284
5302
|
- `onhover?(event)`
|
|
5285
5303
|
- `onrowenter?(event)`
|
|
5286
5304
|
- `onrowleave?(event)`
|
|
5305
|
+
- `oncontextpress?(event)`
|
|
5287
5306
|
- `oncapturestart?(event)`
|
|
5288
5307
|
- `oncaptureend?(event)`
|
|
5289
5308
|
|
|
5290
5309
|
Payloads:
|
|
5291
5310
|
|
|
5292
5311
|
- `TerminalScrollPointerEventPayload` - `{ type: "hover" | "rowenter" | "rowleave", id, row, value, x, y }`
|
|
5312
|
+
- `TerminalScrollContextPressEventPayload` - `{ type: "contextpress", id, row, value, x, y }`
|
|
5293
5313
|
- `TerminalCaptureEventPayload` - `{ type: "capturestart" | "captureend", id, source, row, x, y }`
|
|
5294
5314
|
|
|
5295
|
-
Clips vertical content and supports keyboard scrolling, highlighted rows, hover payloads, and pointer capture.
|
|
5315
|
+
Clips vertical content and supports keyboard scrolling, highlighted rows, hover payloads, context press for the target visible row, and pointer capture.
|
|
5296
5316
|
|
|
5297
5317
|
### `LogView`
|
|
5298
5318
|
|
|
@@ -5314,9 +5334,9 @@ Renders append-only logs and transcript-like panes. `followTail` keeps the visib
|
|
|
5314
5334
|
|
|
5315
5335
|
The `@valyrianjs/terminal/render` subpath exports:
|
|
5316
5336
|
|
|
5317
|
-
- `renderTerminal(input): string`
|
|
5318
|
-
- `renderTerminalNode(node): string`
|
|
5319
|
-
- `renderTerminalFrame(node): TerminalFrame`
|
|
5337
|
+
- `renderTerminal(input, context?): string`
|
|
5338
|
+
- `renderTerminalNode(node, context?): string`
|
|
5339
|
+
- `renderTerminalFrame(node, context?): TerminalFrame`
|
|
5320
5340
|
|
|
5321
5341
|
These functions are useful for render-only integrations that should not import session runtime helpers.
|
|
5322
5342
|
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -19,6 +19,7 @@ export type {
|
|
|
19
19
|
TerminalFrame,
|
|
20
20
|
TerminalHitbox,
|
|
21
21
|
TerminalInputChangeEventPayload,
|
|
22
|
+
TerminalInputContextPressEventPayload,
|
|
22
23
|
TerminalInputProps,
|
|
23
24
|
TerminalInputSubmitEventPayload,
|
|
24
25
|
TerminalKeyBinding,
|
|
@@ -46,6 +47,7 @@ export type {
|
|
|
46
47
|
TerminalRowProps,
|
|
47
48
|
TerminalScreenProps,
|
|
48
49
|
TerminalScrollPointerEventPayload,
|
|
50
|
+
TerminalScrollContextPressEventPayload,
|
|
49
51
|
TerminalScrollViewProps,
|
|
50
52
|
TerminalSemanticStyleKind,
|
|
51
53
|
TerminalSession,
|
|
@@ -89,4 +91,5 @@ export {
|
|
|
89
91
|
} from "./keymap.js";
|
|
90
92
|
export { defaultTerminalTheme, highContrastTerminalTheme, mergeTerminalTheme, resolveTerminalStyle, resolveTerminalStyleToken } from "./theme.js";
|
|
91
93
|
export { renderTerminal } from "./render.js";
|
|
94
|
+
export type { TerminalRenderContext } from "./render.js";
|
|
92
95
|
export { mountTerminal } from "./session.js";
|
package/src/primitives.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { v } from "valyrian.js";
|
|
2
2
|
|
|
3
3
|
import type {
|
|
4
|
-
AnyProps,
|
|
5
4
|
TerminalBoxProps,
|
|
6
5
|
TerminalButtonProps,
|
|
7
6
|
TerminalEditorProps,
|
|
@@ -23,10 +22,14 @@ import type {
|
|
|
23
22
|
TerminalViewProps
|
|
24
23
|
} from "./types.js";
|
|
25
24
|
|
|
26
|
-
type
|
|
25
|
+
type TerminalPrimitiveComponentProps<P> = P & { children?: any; key?: any };
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
type TerminalPrimitiveComponent<P> = (props: TerminalPrimitiveComponentProps<P>, children: any[]) => any;
|
|
28
|
+
|
|
29
|
+
type TerminalListComponent = <T>(props: TerminalPrimitiveComponentProps<TerminalListProps<T>>, children: any[]) => any;
|
|
30
|
+
|
|
31
|
+
function primitive<P>(tag: TerminalPrimitiveTag): TerminalPrimitiveComponent<P> {
|
|
32
|
+
return function TerminalPrimitive(props: TerminalPrimitiveComponentProps<P> | null | undefined, children: any[]) {
|
|
30
33
|
const nextProps = { ...(props || {}) } as Record<string, any>;
|
|
31
34
|
return v(tag, nextProps, ...children);
|
|
32
35
|
};
|
|
@@ -46,7 +49,7 @@ export const Editor = primitive<TerminalEditorProps>("terminal-editor");
|
|
|
46
49
|
export const Button = primitive<TerminalButtonProps>("terminal-button");
|
|
47
50
|
export const ScrollView = primitive<TerminalScrollViewProps>("terminal-scroll");
|
|
48
51
|
export const LogView = primitive<TerminalLogViewProps>("terminal-log-view");
|
|
49
|
-
export const List = primitive
|
|
52
|
+
export const List = primitive("terminal-list") as TerminalListComponent;
|
|
50
53
|
export const Table = primitive<TerminalTableProps>("terminal-table");
|
|
51
54
|
export const Row = primitive<TerminalRowProps>("terminal-row");
|
|
52
55
|
export const Td = primitive<TerminalTdProps>("terminal-td");
|