@textui/core 0.6.1 → 0.8.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/app/app.d.ts.map +1 -1
- package/dist/app/app.js +8 -1
- package/dist/core/focus.d.ts.map +1 -1
- package/dist/core/focus.js +33 -3
- package/dist/core/i18n.d.ts +6 -3
- package/dist/core/i18n.d.ts.map +1 -1
- package/dist/core/i18n.js +10 -6
- package/dist/jsx/intrinsics.d.ts +23 -0
- package/dist/jsx/intrinsics.d.ts.map +1 -1
- package/dist/runtime/hooks.d.ts.map +1 -1
- package/dist/runtime/hooks.js +15 -0
- package/dist/runtime/paint.js +12 -2
- package/dist/runtime/style.d.ts +17 -7
- package/dist/runtime/style.d.ts.map +1 -1
- package/dist/runtime/style.js +66 -6
- package/dist/themes/builtin.d.ts +0 -9
- package/dist/themes/builtin.d.ts.map +1 -1
- package/dist/themes/builtin.js +101 -4
- package/dist/themes/registry.d.ts.map +1 -1
- package/dist/themes/registry.js +26 -0
- package/dist/types/focus.d.ts +11 -0
- package/dist/types/focus.d.ts.map +1 -1
- package/dist/types/i18n.d.ts +14 -3
- package/dist/types/i18n.d.ts.map +1 -1
- package/dist/types/style.d.ts +53 -14
- package/dist/types/style.d.ts.map +1 -1
- package/dist/types/theme.d.ts +37 -3
- package/dist/types/theme.d.ts.map +1 -1
- package/dist/util/text.d.ts +9 -0
- package/dist/util/text.d.ts.map +1 -1
- package/dist/util/text.js +16 -0
- package/package.json +1 -1
- package/src/app/app.ts +8 -1
- package/src/core/focus.ts +30 -3
- package/src/core/i18n.ts +10 -6
- package/src/jsx/intrinsics.ts +25 -0
- package/src/runtime/hooks.ts +15 -0
- package/src/runtime/paint.ts +11 -2
- package/src/runtime/style.ts +73 -9
- package/src/themes/builtin.ts +105 -4
- package/src/themes/registry.ts +23 -0
- package/src/types/focus.ts +8 -0
- package/src/types/i18n.ts +14 -3
- package/src/types/style.ts +85 -18
- package/src/types/theme.ts +37 -3
- package/src/util/text.ts +15 -0
package/dist/themes/builtin.js
CHANGED
|
@@ -7,6 +7,70 @@
|
|
|
7
7
|
* airy report or a workbench without a component knowing which - so the
|
|
8
8
|
* difference lives here, in border style and density, not in the catalog.
|
|
9
9
|
*/
|
|
10
|
+
/**
|
|
11
|
+
* A selection, in the two states it has.
|
|
12
|
+
*
|
|
13
|
+
* `selected` is "this is the current one" and `focus` is the same row while
|
|
14
|
+
* the component holds the keyboard, so a theme states the bright fill once and
|
|
15
|
+
* the dimmer one for everything the reader has walked away from. They were one
|
|
16
|
+
* name once - `active` meant both this and pressed - and a word that means two
|
|
17
|
+
* things gets filled with either.
|
|
18
|
+
*
|
|
19
|
+
* Both name tokens rather than colours, which is the point of the whole
|
|
20
|
+
* arrangement: retint the palette and every component that has not said
|
|
21
|
+
* otherwise moves with it, while a theme that states `components.List.focused`
|
|
22
|
+
* moves the list and leaves the table where it was.
|
|
23
|
+
*/
|
|
24
|
+
const SELECTION_FOCUSED = { bg: 'selected', fg: 'onSelected', dim: true };
|
|
25
|
+
const SELECTION_UNFOCUSED = { bg: 'active', fg: 'onActive' };
|
|
26
|
+
const SELECTION_HOVER = { bg: 'hover', fg: 'onActive' };
|
|
27
|
+
// The other way to draw a selection: reverse video, which is legible whatever
|
|
28
|
+
// a theme's own two colours are. Left beside the three above while that is
|
|
29
|
+
// decided - nothing reads them yet.
|
|
30
|
+
// const SELECTION_DEFAULT: Style = { bg: 'default', fg: 'default', inverse: true };
|
|
31
|
+
// const SELECTION_DIMMED: Style = { bg: 'default', fg: 'default', inverse: true, dim: true };
|
|
32
|
+
/**
|
|
33
|
+
* The state colours every built-in theme starts from.
|
|
34
|
+
*
|
|
35
|
+
* Stated once and spread into `dark` and `light` because a theme that
|
|
36
|
+
* extends either inherits it whole: the entries name tokens, so `console`
|
|
37
|
+
* keeps its own `selected` and gets its own fills, without restating a single
|
|
38
|
+
* component. That is also what makes them the *defaults* - a theme states
|
|
39
|
+
* `components` to differ, and says nothing here about what it does not.
|
|
40
|
+
*/
|
|
41
|
+
const STATE_STYLES = {
|
|
42
|
+
List: { selected: SELECTION_UNFOCUSED, focus: SELECTION_FOCUSED },
|
|
43
|
+
Tree: { selected: SELECTION_UNFOCUSED, focus: SELECTION_FOCUSED },
|
|
44
|
+
Table: { selected: SELECTION_UNFOCUSED, focus: SELECTION_FOCUSED },
|
|
45
|
+
// The field's own selection, over the text it covers. Same pair, same
|
|
46
|
+
// reason: a selection left visible in an unfocused field says what is on
|
|
47
|
+
// the clipboard, and saying it as loudly as the live one would put two
|
|
48
|
+
// selections on the screen.
|
|
49
|
+
TextArea: { selected: SELECTION_UNFOCUSED, focus: SELECTION_FOCUSED },
|
|
50
|
+
// A marked line is a selection. The caret line is that selection plus the
|
|
51
|
+
// keyboard, so it takes the next fill up rather than a colour of its own.
|
|
52
|
+
CodeViewer: { selected: SELECTION_UNFOCUSED, focus: SELECTION_HOVER },
|
|
53
|
+
Menu: { selected: SELECTION_UNFOCUSED, focus: SELECTION_FOCUSED },
|
|
54
|
+
// A tab is open, not selected. Dimming it when the strip does not have the
|
|
55
|
+
// keyboard would say no document is open, which is a different claim and a
|
|
56
|
+
// wrong one - so it has one state and no second.
|
|
57
|
+
//
|
|
58
|
+
// Whether a tab is *filled* is a property of the variant rather than of the
|
|
59
|
+
// state: a solid tab is, an underline one is not. So the pair is stated for
|
|
60
|
+
// the state and the fill only for the variant that has one.
|
|
61
|
+
Tabs: { selected: { fg: 'onSelected' }, 'solid.selected': SELECTION_FOCUSED },
|
|
62
|
+
// The chat rows take the same fills, and for the same reason. `ToolCallRow`
|
|
63
|
+
// and `ReasoningBlock` are selections in a transcript that the caller
|
|
64
|
+
// names, so they have `selected` and no `focus`; a `ComposerChip` lights up
|
|
65
|
+
// only while it holds the keyboard, so it has `focus` and no `selected`.
|
|
66
|
+
ToolCallRow: { selected: SELECTION_FOCUSED },
|
|
67
|
+
ReasoningBlock: { selected: SELECTION_FOCUSED },
|
|
68
|
+
ComposerChip: { focus: SELECTION_FOCUSED },
|
|
69
|
+
// A range in a document is a selection, and it keeps the colours the text
|
|
70
|
+
// under it was already drawn in - the syntax of a selection is the syntax of
|
|
71
|
+
// the code it covers.
|
|
72
|
+
Editor: { selected: { bg: 'active' } },
|
|
73
|
+
};
|
|
10
74
|
export const DARK = {
|
|
11
75
|
id: 'dark',
|
|
12
76
|
name: 'Dark',
|
|
@@ -52,6 +116,7 @@ export const DARK = {
|
|
|
52
116
|
shadow: '#010409',
|
|
53
117
|
},
|
|
54
118
|
spacing: { none: 0, xs: 0, sm: 1, md: 1, lg: 2, xl: 3 },
|
|
119
|
+
components: { ...STATE_STYLES },
|
|
55
120
|
};
|
|
56
121
|
export const LIGHT = {
|
|
57
122
|
id: 'light',
|
|
@@ -89,7 +154,7 @@ export const LIGHT = {
|
|
|
89
154
|
onWarning: '#ffffff',
|
|
90
155
|
onDanger: '#ffffff',
|
|
91
156
|
hover: '#eaeef2',
|
|
92
|
-
active: '#
|
|
157
|
+
active: '#a5bdd8',
|
|
93
158
|
selected: '#0969da',
|
|
94
159
|
focus: '#0969da',
|
|
95
160
|
disabled: '#8c959f',
|
|
@@ -98,6 +163,7 @@ export const LIGHT = {
|
|
|
98
163
|
shadow: '#d0d7de',
|
|
99
164
|
},
|
|
100
165
|
spacing: { none: 0, xs: 0, sm: 1, md: 1, lg: 2, xl: 3 },
|
|
166
|
+
components: { ...STATE_STYLES },
|
|
101
167
|
};
|
|
102
168
|
/** Dense, bordered, high contrast. Every region is a labelled box. */
|
|
103
169
|
export const CONSOLE = {
|
|
@@ -122,7 +188,9 @@ export const CONSOLE = {
|
|
|
122
188
|
//
|
|
123
189
|
// The two selection backgrounds are picked rather than derived: `selected`
|
|
124
190
|
// carries `inverted` text so it has to be light, and `active` carries
|
|
125
|
-
// `text` so it has to be dark. Same hue, opposite ends.
|
|
191
|
+
// `text` so it has to be dark. Same hue, opposite ends. `active` is what
|
|
192
|
+
// a selection looks like when the component does not have the keyboard -
|
|
193
|
+
// it is the dim end of the pair, not a pressed control.
|
|
126
194
|
primary: '#88c0d0',
|
|
127
195
|
info: '#88c0d0',
|
|
128
196
|
selected: '#6ba3b2',
|
|
@@ -166,6 +234,7 @@ export const PAPER = {
|
|
|
166
234
|
warning: '#d29922',
|
|
167
235
|
danger: '#f85149',
|
|
168
236
|
info: '#58a6ff',
|
|
237
|
+
/* ---- */
|
|
169
238
|
onAccent: '#0d1117',
|
|
170
239
|
onDefault: '#0d1117',
|
|
171
240
|
onPrimary: '#0d1117',
|
|
@@ -175,17 +244,22 @@ export const PAPER = {
|
|
|
175
244
|
onInfo: '#0d1117',
|
|
176
245
|
onWarning: '#0d1117',
|
|
177
246
|
onDanger: '#0d1117',
|
|
247
|
+
/* ---- */
|
|
178
248
|
hover: '#1f2937',
|
|
179
|
-
active: '
|
|
180
|
-
|
|
249
|
+
active: 'default',
|
|
250
|
+
onActive: '#3191ff',
|
|
251
|
+
selected: 'default',
|
|
252
|
+
onSelected: '#58a6ff',
|
|
181
253
|
focus: '#58a6ff',
|
|
182
254
|
disabled: '#484f58',
|
|
255
|
+
/* ---- */
|
|
183
256
|
scrim: '#010409',
|
|
184
257
|
cursor: 'default',
|
|
185
258
|
shadow: '#010409',
|
|
186
259
|
},
|
|
187
260
|
spacing: { none: 0, xs: 1, sm: 1, md: 2, lg: 3, xl: 4 },
|
|
188
261
|
components: {
|
|
262
|
+
...STATE_STYLES,
|
|
189
263
|
Panel: { base: { border: 'none', padding: [1, 2] } },
|
|
190
264
|
Button: { base: { padding: [0, 2] } },
|
|
191
265
|
},
|
|
@@ -255,6 +329,9 @@ export const WORKBENCH = {
|
|
|
255
329
|
hover: '#313244',
|
|
256
330
|
active: '#45475a',
|
|
257
331
|
selected: '#585b70',
|
|
332
|
+
// The selection is a mid grey, so the light text is what reads on it; the
|
|
333
|
+
// inherited `inverted` is darker than the fill and nearly disappears.
|
|
334
|
+
onSelected: '#cdd6f4',
|
|
258
335
|
focus: '#89b4fa',
|
|
259
336
|
scrim: '#11111b',
|
|
260
337
|
},
|
|
@@ -267,7 +344,12 @@ export const MONO = {
|
|
|
267
344
|
id: 'mono',
|
|
268
345
|
name: 'Monochrome',
|
|
269
346
|
appearance: 'dark',
|
|
347
|
+
// The theme's own colours are all `default`; this is what makes that true of
|
|
348
|
+
// the ones a component states for itself, which is the difference between a
|
|
349
|
+
// palette that happens to be grey and a theme with no colour in it.
|
|
350
|
+
monochrome: true,
|
|
270
351
|
border: 'ascii',
|
|
352
|
+
// border: 'none',
|
|
271
353
|
cursor: 'underline',
|
|
272
354
|
// Chosen, not downgraded to: this theme is ascii on a terminal that could
|
|
273
355
|
// draw anything, so the rule has to say so too.
|
|
@@ -308,6 +390,21 @@ export const MONO = {
|
|
|
308
390
|
cursor: 'default',
|
|
309
391
|
shadow: 'default',
|
|
310
392
|
},
|
|
393
|
+
components: {
|
|
394
|
+
List: { selected: { bold: true }, focus: { bold: true } },
|
|
395
|
+
Tree: { selected: { bold: true }, focus: { bold: true } },
|
|
396
|
+
Table: { selected: { bold: true }, focus: { bold: true } },
|
|
397
|
+
TextArea: { selected: { bold: true }, focus: { bold: true } },
|
|
398
|
+
CodeViewer: { selected: { bold: true }, focus: { bold: true } },
|
|
399
|
+
Menu: { selected: { bold: true }, focus: { bold: true } },
|
|
400
|
+
Tabs: { selected: { bold: true }, 'solid.selected': { bold: true } },
|
|
401
|
+
ToolCallRow: { selected: { bold: true } },
|
|
402
|
+
ReasoningBlock: { selected: { bold: true } },
|
|
403
|
+
ComposerChip: { focus: { bold: true } },
|
|
404
|
+
Editor: { selected: { bold: true } },
|
|
405
|
+
Panel: { base: { border: 'ascii', padding: [0, 1] } },
|
|
406
|
+
Button: { base: { padding: [0, 1] } },
|
|
407
|
+
}
|
|
311
408
|
};
|
|
312
409
|
/**
|
|
313
410
|
* Paper, after dark.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/themes/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAAE,eAAe,EAAe,aAAa,EAC3D,MAAM,mBAAmB,CAAC;AAK3B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/themes/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAAE,eAAe,EAAe,aAAa,EAC3D,MAAM,mBAAmB,CAAC;AAK3B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAsDzD,qBAAa,MAAO,YAAW,aAAa;IAC1C,OAAO,CAAC,IAAI,CAAsC;IAClD,OAAO,CAAC,KAAK,CAAoC;gBAErC,OAAO,GAAE,eAAe,EAAmB;IAIvD,QAAQ,CAAC,GAAG,EAAE,eAAe,GAAG,UAAU;IAS1C,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAK5B,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAI5C,IAAI,IAAI,eAAe,EAAE;IAIzB;;;;OAIG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,oBAAoB,GAAG,aAAa;CA6K/D;AAED,wBAAgB,YAAY,CAAC,OAAO,CAAC,EAAE,eAAe,EAAE,GAAG,MAAM,CAEhE"}
|
package/dist/themes/registry.js
CHANGED
|
@@ -13,6 +13,7 @@ const FALLBACK_COLORS = {
|
|
|
13
13
|
onDefault: 'default', onMuted: 'default',
|
|
14
14
|
onAccent: 'default', onPrimary: 'default', onSecondary: 'default',
|
|
15
15
|
onSuccess: 'default', onWarning: 'default', onDanger: 'default', onInfo: 'default',
|
|
16
|
+
onSelected: 'default', onActive: 'default',
|
|
16
17
|
hover: 'default', active: 'default', selected: 'default', focus: 'default',
|
|
17
18
|
disabled: 'default', scrim: 'default', cursor: 'default', shadow: 'default',
|
|
18
19
|
};
|
|
@@ -105,6 +106,7 @@ export class Themes {
|
|
|
105
106
|
// opts in rather than out.
|
|
106
107
|
let tableRules = 'header';
|
|
107
108
|
let density = 'normal';
|
|
109
|
+
let monochrome = false;
|
|
108
110
|
const components = {};
|
|
109
111
|
let syntaxOverrides = {};
|
|
110
112
|
for (const def of chain) {
|
|
@@ -143,10 +145,28 @@ export class Themes {
|
|
|
143
145
|
tableRules = def.tableRules;
|
|
144
146
|
if (def.density)
|
|
145
147
|
density = def.density;
|
|
148
|
+
if (def.monochrome !== undefined)
|
|
149
|
+
monochrome = def.monochrome;
|
|
146
150
|
for (const [name, variants] of Object.entries(def.components ?? {})) {
|
|
147
151
|
components[name] = { ...components[name], ...variants };
|
|
148
152
|
}
|
|
149
153
|
}
|
|
154
|
+
// What is written on a filled row, derived rather than restated.
|
|
155
|
+
//
|
|
156
|
+
// A selection background is only half a pair: `selected` carries
|
|
157
|
+
// `inverted` and `active` carries `text`. Stated as two independent
|
|
158
|
+
// colours, a theme that restates one half - `paper-light` restates
|
|
159
|
+
// `inverted`, `paper` leaves `text` as the terminal's - would take the
|
|
160
|
+
// other half from the theme it extends, or from the terminal, and a row
|
|
161
|
+
// could come out unreadable with nothing in the theme saying so.
|
|
162
|
+
//
|
|
163
|
+
// So the pair follows the theme's own values unless it says otherwise. A
|
|
164
|
+
// theme that wants a different colour on a fill states it, which is what
|
|
165
|
+
// `paper` does for `active`.
|
|
166
|
+
if (colors.onSelected === 'default')
|
|
167
|
+
colors.onSelected = colors.inverted;
|
|
168
|
+
if (colors.onActive === 'default')
|
|
169
|
+
colors.onActive = colors.text;
|
|
150
170
|
// A colourless terminal gets no colour, whatever the theme says.
|
|
151
171
|
if (caps.colorDepth === 0) {
|
|
152
172
|
for (const token of Object.keys(colors)) {
|
|
@@ -175,6 +195,7 @@ export class Themes {
|
|
|
175
195
|
id: leaf.id,
|
|
176
196
|
name: leaf.name,
|
|
177
197
|
appearance: leaf.appearance,
|
|
198
|
+
monochrome,
|
|
178
199
|
colors,
|
|
179
200
|
spacing,
|
|
180
201
|
glyphs,
|
|
@@ -186,6 +207,11 @@ export class Themes {
|
|
|
186
207
|
components,
|
|
187
208
|
syntax,
|
|
188
209
|
color(token) {
|
|
210
|
+
// A monochrome theme has no colour to give, and that has to include the
|
|
211
|
+
// literal a component states for itself - otherwise the one theme whose
|
|
212
|
+
// whole point is no colour is the one that cannot promise it.
|
|
213
|
+
if (monochrome)
|
|
214
|
+
return 'default';
|
|
189
215
|
if (token in colors)
|
|
190
216
|
return colors[token];
|
|
191
217
|
// Not a token: a literal colour passed straight through.
|
package/dist/types/focus.d.ts
CHANGED
|
@@ -22,6 +22,17 @@ export interface FocusableOptions {
|
|
|
22
22
|
id: string;
|
|
23
23
|
/** Explicit order within the scope. Unset = document order. */
|
|
24
24
|
order?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Where the focusable sits in the tree, asked each time the tab order is.
|
|
27
|
+
*
|
|
28
|
+
* `root` is the tree it is in and `path` the child index at each level
|
|
29
|
+
* below it. Left off, or answering `undefined`, the focusable is placed by
|
|
30
|
+
* when it registered.
|
|
31
|
+
*/
|
|
32
|
+
place?(): {
|
|
33
|
+
root: unknown;
|
|
34
|
+
path: number[];
|
|
35
|
+
} | undefined;
|
|
25
36
|
disabled?: boolean;
|
|
26
37
|
/** Skipped by tab, still reachable by directional navigation and click. */
|
|
27
38
|
skipTab?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focus.d.ts","sourceRoot":"","sources":["../../src/types/focus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,MAAM,cA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MAAM,CAAC;IAC5B,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,IAAI,IAAI,IAAI,CAAC;IACb,OAAO,IAAI,MAAM,GAAG,IAAI,CAAC;IACzB,+CAA+C;IAC/C,IAAI,CAAC,SAAS,EAAE,cAAc,GAAG,MAAM,GAAG,IAAI,CAAC;IAC/C,gEAAgE;IAChE,KAAK,IAAI,MAAM,EAAE,CAAC;IAClB,6DAA6D;IAC7D,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAClC,gDAAgD;IAChD,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACxC;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC;CACpC"}
|
package/dist/types/i18n.d.ts
CHANGED
|
@@ -10,14 +10,25 @@ export interface I18n {
|
|
|
10
10
|
setLocale(locale: LocaleId): void;
|
|
11
11
|
register(bundle: TranslationBundle): Disposable;
|
|
12
12
|
locales(): LocaleId[];
|
|
13
|
-
/**
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Missing keys fall back to the fallback locale, then to `fallback` (the
|
|
15
|
+
* text a component draws when nobody translated it), then to the key itself.
|
|
16
|
+
*/
|
|
17
|
+
t(key: string, values?: Record<string, unknown>, fallback?: string): string;
|
|
15
18
|
/** Intl-backed; TextUI does not reimplement formatting. */
|
|
16
19
|
number(value: number, options?: Intl.NumberFormatOptions): string;
|
|
17
20
|
date(value: Date | number, options?: Intl.DateTimeFormatOptions): string;
|
|
18
21
|
relative(value: number, unit: Intl.RelativeTimeFormatUnit): string;
|
|
19
22
|
list(items: string[], options?: Intl.ListFormatOptions): string;
|
|
20
|
-
|
|
23
|
+
/**
|
|
24
|
+
* The form the locale's plural rules pick for `count`, with `{count}` and
|
|
25
|
+
* anything the sentence needs around it.
|
|
26
|
+
*
|
|
27
|
+
* `values` carries what else the form names - a limit, a glyph, the total a
|
|
28
|
+
* count is out of - because a sentence that inflects a noun is the whole
|
|
29
|
+
* sentence and not a noun with a number in front of it.
|
|
30
|
+
*/
|
|
31
|
+
plural(count: number, forms: Record<string, string>, values?: Record<string, unknown>): string;
|
|
21
32
|
onChange(fn: (locale: LocaleId) => void): Disposable;
|
|
22
33
|
}
|
|
23
34
|
//# sourceMappingURL=i18n.d.ts.map
|
package/dist/types/i18n.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/types/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,QAAQ,CAAC;IACjB,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,IAAI;IACnB,MAAM,EAAE,QAAQ,CAAC;IACjB,SAAS,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,GAAG,UAAU,CAAC;IAChD,OAAO,IAAI,QAAQ,EAAE,CAAC;IACtB
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/types/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,QAAQ,CAAC;IACjB,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,IAAI;IACnB,MAAM,EAAE,QAAQ,CAAC;IACjB,SAAS,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,GAAG,UAAU,CAAC;IAChD,OAAO,IAAI,QAAQ,EAAE,CAAC;IACtB;;;OAGG;IACH,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5E,2DAA2D;IAC3D,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,GAAG,MAAM,CAAC;IAClE,IAAI,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,qBAAqB,GAAG,MAAM,CAAC;IACzE,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,sBAAsB,GAAG,MAAM,CAAC;IACnE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAC;IAChE;;;;;;;OAOG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC;IAC/F,QAAQ,CAAC,EAAE,EAAE,CAAC,MAAM,EAAE,QAAQ,KAAK,IAAI,GAAG,UAAU,CAAC;CACtD"}
|
package/dist/types/style.d.ts
CHANGED
|
@@ -1,12 +1,39 @@
|
|
|
1
1
|
import type { Color } from './cells.js';
|
|
2
2
|
import type { EdgeSpec } from './geometry.js';
|
|
3
3
|
/**
|
|
4
|
-
* Semantic theme tokens
|
|
5
|
-
*
|
|
6
|
-
* a
|
|
4
|
+
* Semantic theme tokens, split by the channel each one is written in.
|
|
5
|
+
*
|
|
6
|
+
* A component names a role, never a colour - which is what lets one catalog
|
|
7
|
+
* render the same under a light theme, a dark theme and a 16-colour ssh
|
|
8
|
+
* session. The role is not enough on its own, though: a token also has to be
|
|
9
|
+
* somewhere it can actually be drawn. `canvas` is a fill, `onAccent` is
|
|
10
|
+
* writing, `borderStrong` is a rule - and one union for all three is what let
|
|
11
|
+
* `fg: 'canvas'` and `border: 'onAccent'` compile, to be found by somebody
|
|
12
|
+
* looking at a frame.
|
|
13
|
+
*
|
|
14
|
+
* So each token is listed under the channels it may appear in, and `Style`
|
|
15
|
+
* takes the matching one. A token may appear in more than one - the tones are
|
|
16
|
+
* both a fill and a colour of their own - and a literal colour is the shared
|
|
17
|
+
* escape out of all three.
|
|
18
|
+
*
|
|
19
|
+
* A token missing from a list is a token that channel cannot use. Adding one
|
|
20
|
+
* is a decision about where it reads, not a convenience.
|
|
7
21
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
22
|
+
/** Colours a cell's foreground may be. */
|
|
23
|
+
export type FgColorToken = 'accent' | 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'info' | 'hover' | 'active' | 'selected' | 'focus' | 'disabled' | 'text' | 'muted' | 'subtle' | 'inverted' | 'borderSubtle' | 'cursor' | 'onDefault' | 'onMuted' | 'onAccent' | 'onPrimary' | 'onSecondary' | 'onSuccess' | 'onWarning' | 'onDanger' | 'onInfo' | 'onSelected' | 'onActive';
|
|
24
|
+
/** Colours a cell's background may be. */
|
|
25
|
+
export type BgColorToken = 'canvas' | 'surface' | 'surfaceAlt' | 'overlay' | 'hover' | 'active' | 'selected' | 'focus' | 'disabled' | 'accent' | 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'info' | 'scrim' | 'cursor' | 'shadow';
|
|
26
|
+
/** Colours a rule may be. */
|
|
27
|
+
export type BorderColorToken = 'border' | 'borderStrong' | 'borderSubtle' | 'divider' | 'accent' | 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'info' | 'hover' | 'focus' | 'muted' | 'subtle';
|
|
28
|
+
/** Every token, for the places that take a colour without saying which. */
|
|
29
|
+
export type ColorToken = FgColorToken | BgColorToken | BorderColorToken;
|
|
30
|
+
/** A foreground: an `FgColorToken`, or a literal colour. */
|
|
31
|
+
export type FgColor = FgColorToken | Color;
|
|
32
|
+
/** A background: a `BgColorToken`, or a literal colour. */
|
|
33
|
+
export type BgColor = BgColorToken | Color;
|
|
34
|
+
/** A rule: a `BorderColorToken`, or a literal colour. */
|
|
35
|
+
export type BorderColor = BorderColorToken | Color;
|
|
36
|
+
/** Anywhere a colour is accepted, any token and any literal are accepted too. */
|
|
10
37
|
export type StyleColor = ColorToken | Color;
|
|
11
38
|
export type Dimension = number | `${number}%` | 'auto';
|
|
12
39
|
export type BorderStyle = 'none' | 'single' | 'double' | 'round' | 'bold' | 'dashed' | 'ascii' | 'thick' | 'half';
|
|
@@ -62,14 +89,14 @@ export type BorderSides = {
|
|
|
62
89
|
};
|
|
63
90
|
/** A colour per edge. Unnamed edges fall back to the border's `color`. */
|
|
64
91
|
export type BorderColors = {
|
|
65
|
-
top?:
|
|
66
|
-
right?:
|
|
67
|
-
bottom?:
|
|
68
|
-
left?:
|
|
92
|
+
top?: BorderColor;
|
|
93
|
+
right?: BorderColor;
|
|
94
|
+
bottom?: BorderColor;
|
|
95
|
+
left?: BorderColor;
|
|
69
96
|
};
|
|
70
97
|
export type BorderSpec = BorderStyle | {
|
|
71
98
|
style?: BorderStyle;
|
|
72
|
-
color?:
|
|
99
|
+
color?: BorderColor;
|
|
73
100
|
/**
|
|
74
101
|
* Per-edge colour, over `color`. A corner belongs to the edge that runs
|
|
75
102
|
* through it - the top rule owns both top corners - because a cell holds
|
|
@@ -111,7 +138,7 @@ export interface Style {
|
|
|
111
138
|
* but stays legible, rather than being replaced by a rectangle of nothing.
|
|
112
139
|
* `true` uses the theme's `scrim` token; a number sets the strength.
|
|
113
140
|
*/
|
|
114
|
-
scrim?: boolean |
|
|
141
|
+
scrim?: boolean | BgColor;
|
|
115
142
|
scrimStrength?: number;
|
|
116
143
|
display?: 'flex' | 'none';
|
|
117
144
|
direction?: 'row' | 'column';
|
|
@@ -160,8 +187,8 @@ export interface Style {
|
|
|
160
187
|
overflowX?: Overflow;
|
|
161
188
|
/** Overrides `overflow` downwards. The usual scroll container. */
|
|
162
189
|
overflowY?: Overflow;
|
|
163
|
-
fg?:
|
|
164
|
-
bg?:
|
|
190
|
+
fg?: FgColor;
|
|
191
|
+
bg?: BgColor;
|
|
165
192
|
bold?: boolean;
|
|
166
193
|
dim?: boolean;
|
|
167
194
|
italic?: boolean;
|
|
@@ -175,15 +202,27 @@ export interface Style {
|
|
|
175
202
|
/** Character painted into empty cells of this box. */
|
|
176
203
|
fill?: string;
|
|
177
204
|
}
|
|
178
|
-
/**
|
|
205
|
+
/**
|
|
206
|
+
* Styles selected by interaction state. Merged over the base in this order.
|
|
207
|
+
*
|
|
208
|
+
* `selected` is "this is the current one"; `focus` is "and the keyboard is
|
|
209
|
+
* here", so a row that has both wears `focus` and a row that has only the
|
|
210
|
+
* first wears the dimmer `selected`. They are separate names because they
|
|
211
|
+
* were the same word once - `active` meant both the unfocused selection here
|
|
212
|
+
* and the pressed state in `InteractionState` - and a token that meant two
|
|
213
|
+
* things could be filled with either and looked wrong half the time.
|
|
214
|
+
*/
|
|
179
215
|
export interface StatefulStyle {
|
|
180
216
|
base?: Style;
|
|
181
217
|
focus?: Style;
|
|
182
218
|
hover?: Style;
|
|
219
|
+
/** Pressed. Never a selection. */
|
|
183
220
|
active?: Style;
|
|
184
221
|
selected?: Style;
|
|
185
222
|
disabled?: Style;
|
|
186
223
|
}
|
|
224
|
+
/** The states, in the order the last one wins. The shared vocabulary. */
|
|
225
|
+
export type StateName = 'selected' | 'hover' | 'active' | 'focus' | 'disabled';
|
|
187
226
|
export type StyleInput = Style | StatefulStyle | (Style | StatefulStyle | undefined | false)[];
|
|
188
227
|
/** Global semantic variants, available to every component that opts in. */
|
|
189
228
|
export type SemanticVariant = 'default' | 'primary' | 'secondary' | 'accent' | 'success' | 'warning' | 'danger' | 'info' | 'muted';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../src/types/style.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C
|
|
1
|
+
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../src/types/style.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C;;;;;;;;;;;;;;;;;;GAkBG;AAEH,0CAA0C;AAC1C,MAAM,MAAM,YAAY,GAEpB,QAAQ,GAAG,SAAS,GAAG,WAAW,GAClC,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,GAGzC,OAAO,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,GACtD,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,UAAU,GAExC,cAAc,GAId,QAAQ,GACR,WAAW,GAAG,SAAS,GACvB,UAAU,GAAG,WAAW,GAAG,aAAa,GACxC,WAAW,GAAG,WAAW,GAAG,UAAU,GAAG,QAAQ,GACjD,YAAY,GAAG,UAAU,CAAC;AAE9B,0CAA0C;AAC1C,MAAM,MAAM,YAAY,GACpB,QAAQ,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,GAC/C,OAAO,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,GACtD,QAAQ,GAAG,SAAS,GAAG,WAAW,GAClC,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,GAEzC,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAElC,6BAA6B;AAC7B,MAAM,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CAAC,EAAE,KAAK,CAAC;IACf,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB;AAED,yEAAyE;AACzE,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,CAAC;AAE/E,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,aAAa,GAAG,CAAC,KAAK,GAAG,aAAa,GAAG,SAAS,GAAG,KAAK,CAAC,EAAE,CAAC;AAE/F,2EAA2E;AAC3E,MAAM,MAAM,eAAe,GACvB,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAC9C,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAExD,uDAAuD;AACvD,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAEpE,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC"}
|
package/dist/types/theme.d.ts
CHANGED
|
@@ -71,6 +71,16 @@ export interface ThemeDefinition {
|
|
|
71
71
|
id: string;
|
|
72
72
|
name: string;
|
|
73
73
|
appearance: 'light' | 'dark';
|
|
74
|
+
/**
|
|
75
|
+
* Whether this theme has any colour to give.
|
|
76
|
+
*
|
|
77
|
+
* A theme's palette is its own business, but a component can state a literal
|
|
78
|
+
* colour - an ink, a chart, a hand-picked hex - and that used to come through
|
|
79
|
+
* untouched, so `mono` painted a rainbow the moment a banner asked for one.
|
|
80
|
+
* Stated, every colour resolves to the terminal's own: tokens and literals
|
|
81
|
+
* alike, which is what a theme that says it has no colour has to mean.
|
|
82
|
+
*/
|
|
83
|
+
monochrome?: boolean;
|
|
74
84
|
/** Extend another registered theme; only the differences need stating. */
|
|
75
85
|
extends?: string;
|
|
76
86
|
colors: Partial<Record<ColorToken, Color>>;
|
|
@@ -99,7 +109,16 @@ export interface ThemeDefinition {
|
|
|
99
109
|
*/
|
|
100
110
|
tableRules?: TableRules;
|
|
101
111
|
density?: Density;
|
|
102
|
-
/**
|
|
112
|
+
/**
|
|
113
|
+
* Per-component style overrides, keyed by component name then variant or
|
|
114
|
+
* state.
|
|
115
|
+
*
|
|
116
|
+
* A composite component has to name which of its boxes this is - a list row
|
|
117
|
+
* is a `box` node, and `List` is what a theme author knows it by - so the
|
|
118
|
+
* name is stated at the node with `styleAs` and the map is keyed by it.
|
|
119
|
+
* `base` is the component at rest; the rest are the variants it supports and
|
|
120
|
+
* the five states in `StateName`.
|
|
121
|
+
*/
|
|
103
122
|
components?: Record<string, Record<string, Style>>;
|
|
104
123
|
/**
|
|
105
124
|
* Colours for syntax scopes. Every scope has a default drawn from the
|
|
@@ -113,6 +132,8 @@ export interface ResolvedTheme {
|
|
|
113
132
|
id: string;
|
|
114
133
|
name: string;
|
|
115
134
|
appearance: 'light' | 'dark';
|
|
135
|
+
/** Whether every colour this theme gives back is the terminal's own. */
|
|
136
|
+
monochrome: boolean;
|
|
116
137
|
colors: Record<ColorToken, Color>;
|
|
117
138
|
spacing: ThemeSpacing;
|
|
118
139
|
glyphs: ThemeGlyphs;
|
|
@@ -124,11 +145,24 @@ export interface ResolvedTheme {
|
|
|
124
145
|
components: Record<string, Record<string, Style>>;
|
|
125
146
|
/** Every syntax scope, resolved to a colour. */
|
|
126
147
|
syntax: Record<SyntaxScope, Color>;
|
|
127
|
-
/** Resolve a token (or pass a literal colour through). */
|
|
148
|
+
/** Resolve a token (or pass a literal colour through, unless monochrome). */
|
|
128
149
|
color(token: string): Color;
|
|
129
150
|
borderChars(style?: BorderStyle): BorderChars;
|
|
130
151
|
dividerChars(style?: DividerStyle): DividerChars;
|
|
131
|
-
/**
|
|
152
|
+
/**
|
|
153
|
+
* Component style for a name and a list of names to merge over it, in the
|
|
154
|
+
* order given - later names win.
|
|
155
|
+
*
|
|
156
|
+
* The names are the component's `variant`, `tone` and `size` followed by the
|
|
157
|
+
* interaction states that are true: `selected`, `hover`, `active` (pressed),
|
|
158
|
+
* `focus` and `disabled`. So `components.List.selected` is the fill on the
|
|
159
|
+
* current row, and `components.List.focused` is the brighter one on the
|
|
160
|
+
* current row while the list has the keyboard.
|
|
161
|
+
*
|
|
162
|
+
* The order is the same one `flattenStyleInput` merges a `style` prop in, so
|
|
163
|
+
* a state stated at the node and the same state stated by the theme resolve
|
|
164
|
+
* to one answer rather than to whichever happened to be asked second.
|
|
165
|
+
*/
|
|
132
166
|
styleFor(component: string, variants?: string[]): Style;
|
|
133
167
|
}
|
|
134
168
|
export interface ThemeRegistry {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/types/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EACV,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EACtF,KAAK,EAAE,UAAU,EAAE,UAAU,EAC9B,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,mEAAmE;AACnE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,gFAAgF;IAChF,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,KA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AAC;CAChE"}
|
package/dist/util/text.d.ts
CHANGED
|
@@ -45,6 +45,15 @@ export declare function sliceColumns(text: string, start: number, width: number)
|
|
|
45
45
|
*/
|
|
46
46
|
export declare function expandTabs(text: string, tabWidth?: number): string;
|
|
47
47
|
export type TruncateSide = 'end' | 'start' | 'middle';
|
|
48
|
+
/**
|
|
49
|
+
* Fit into `width` cells, marking the cut whether or not there was one.
|
|
50
|
+
*
|
|
51
|
+
* `truncate` marks only what it had to cut, which is right for a string that
|
|
52
|
+
* has to fit a cell. A paragraph stopped by the box rather than by its own
|
|
53
|
+
* length is the other case: its last visible row may fit exactly and still not
|
|
54
|
+
* be the end of the text, and it has to say so.
|
|
55
|
+
*/
|
|
56
|
+
export declare function markCut(text: string, width: number, ellipsis?: string): string;
|
|
48
57
|
/** Fit into `width` cells, marking the cut with `ellipsis`. */
|
|
49
58
|
export declare function truncate(text: string, width: number, ellipsis?: string, side?: TruncateSide): string;
|
|
50
59
|
/** Pad to exactly `width` cells. Over-long input is returned unchanged. */
|
package/dist/util/text.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/util/text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAelD;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAM7C;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAShD;AA8ED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAsBrD;AAsBD,2CAA2C;AAC3C,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAgBhD;AAED,+EAA+E;AAC/E,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG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
|
|
283
|
+
/**
|
|
284
|
+
* Fit into `width` cells, marking the cut whether or not there was one.
|
|
285
|
+
*
|
|
286
|
+
* `truncate` marks only what it had to cut, which is right for a string that
|
|
287
|
+
* has to fit a cell. A paragraph stopped by the box rather than by its own
|
|
288
|
+
* length is the other case: its last visible row may fit exactly and still not
|
|
289
|
+
* be the end of the text, and it has to say so.
|
|
290
|
+
*/
|
|
291
|
+
export function markCut(text, width, ellipsis = '…') {
|
|
292
|
+
if (width <= 0)
|
|
293
|
+
return '';
|
|
294
|
+
const ew = stringWidth(ellipsis);
|
|
295
|
+
if (width <= ew)
|
|
296
|
+
return sliceByWidth(ellipsis, width);
|
|
297
|
+
return sliceByWidth(text, width - ew).trimEnd() + ellipsis;
|
|
298
|
+
}
|
|
283
299
|
/** Fit into `width` cells, marking the cut with `ellipsis`. */
|
|
284
300
|
export function truncate(text, width, ellipsis = '…', side = 'end') {
|
|
285
301
|
const total = stringWidth(text);
|
package/package.json
CHANGED
package/src/app/app.ts
CHANGED
|
@@ -752,8 +752,15 @@ export class App implements TextUIApp {
|
|
|
752
752
|
private stateOf(instance: Instance): InteractionState {
|
|
753
753
|
const id = typeof instance.props.id === 'string' ? instance.props.id : instance.id;
|
|
754
754
|
const focusedId = this.focus.focused();
|
|
755
|
+
// A node may state its own focus, and a row has to: the list holds the
|
|
756
|
+
// keyboard, the row is where it lands. Left to the id comparison every
|
|
757
|
+
// row in every list reads as unfocused, so "the current row" and "the
|
|
758
|
+
// current row you can type at" would be the same fill.
|
|
759
|
+
const stated = instance.props.focused;
|
|
755
760
|
return {
|
|
756
|
-
focused:
|
|
761
|
+
focused: typeof stated === 'boolean'
|
|
762
|
+
? stated
|
|
763
|
+
: focusedId === id || focusedId === `${instance.id}:focus`,
|
|
757
764
|
hovered: this.hovered === id || this.hoveredChain.has(instance),
|
|
758
765
|
active: false,
|
|
759
766
|
selected: instance.props.selected === true,
|