@textui/widgets 0.7.0 → 0.9.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/control/text-area.d.ts +2 -0
- package/dist/control/text-area.d.ts.map +1 -1
- package/dist/control/text-area.js +16 -8
- package/dist/control/text-input.d.ts.map +1 -1
- package/dist/control/text-input.js +6 -0
- package/dist/data/code-viewer.d.ts +2 -0
- package/dist/data/code-viewer.d.ts.map +1 -1
- package/dist/data/code-viewer.js +9 -1
- package/dist/data/index.d.ts +9 -0
- package/dist/data/index.d.ts.map +1 -1
- package/dist/data/index.js +8 -2
- package/dist/data/list.d.ts +9 -0
- package/dist/data/list.d.ts.map +1 -1
- package/dist/data/list.js +20 -3
- package/dist/data/markdown-view.d.ts.map +1 -1
- package/dist/data/markdown-view.js +4 -1
- package/dist/data/pagination.d.ts.map +1 -1
- package/dist/data/pagination.js +4 -1
- package/dist/data/tree.d.ts +2 -0
- package/dist/data/tree.d.ts.map +1 -1
- package/dist/data/tree.js +8 -2
- package/dist/display/card.d.ts.map +1 -1
- package/dist/display/card.js +12 -0
- package/dist/display/color-text.d.ts +13 -1
- package/dist/display/color-text.d.ts.map +1 -1
- package/dist/display/color-text.js +28 -6
- package/dist/display/font-text.d.ts +72 -0
- package/dist/display/font-text.d.ts.map +1 -0
- package/dist/display/font-text.js +35 -0
- package/dist/display/fonts.d.ts +138 -0
- package/dist/display/fonts.d.ts.map +1 -0
- package/dist/display/fonts.js +893 -0
- package/dist/display/gard.d.ts +26 -0
- package/dist/display/gard.d.ts.map +1 -0
- package/dist/display/gard.js +479 -0
- package/dist/display/index.d.ts +3 -0
- package/dist/display/index.d.ts.map +1 -1
- package/dist/display/index.js +7 -0
- package/dist/display/key-value.d.ts +25 -5
- package/dist/display/key-value.d.ts.map +1 -1
- package/dist/display/key-value.js +13 -3
- package/dist/display/marquee.d.ts.map +1 -1
- package/dist/display/marquee.js +16 -3
- package/dist/display/pagga.d.ts +29 -0
- package/dist/display/pagga.d.ts.map +1 -0
- package/dist/display/pagga.js +101 -0
- package/dist/display/pattern.d.ts +117 -0
- package/dist/display/pattern.d.ts.map +1 -0
- package/dist/display/pattern.js +257 -0
- package/dist/display/spinner.d.ts +2 -0
- package/dist/display/spinner.d.ts.map +1 -1
- package/dist/display/spinner.js +3 -2
- package/dist/navigation/menu.d.ts +11 -0
- package/dist/navigation/menu.d.ts.map +1 -1
- package/dist/navigation/menu.js +22 -9
- package/dist/navigation/tabs.d.ts +2 -0
- package/dist/navigation/tabs.d.ts.map +1 -1
- package/dist/navigation/tabs.js +12 -2
- package/dist/overlay/command-palette.d.ts.map +1 -1
- package/dist/overlay/command-palette.js +18 -6
- package/dist/shells/workbench-shell.d.ts.map +1 -1
- package/dist/shells/workbench-shell.js +5 -1
- package/package.json +2 -2
- package/src/control/text-area.ts +18 -7
- package/src/control/text-input.ts +6 -0
- package/src/data/code-viewer.ts +10 -1
- package/src/data/index.ts +9 -2
- package/src/data/list.ts +21 -3
- package/src/data/markdown-view.ts +7 -4
- package/src/data/pagination.ts +4 -1
- package/src/data/tree.ts +9 -2
- package/src/display/card.ts +12 -0
- package/src/display/color-text.ts +33 -10
- package/src/display/font-text.tsx +94 -0
- package/src/display/fonts.ts +990 -0
- package/src/display/gard.ts +475 -0
- package/src/display/index.ts +7 -0
- package/src/display/key-value.ts +44 -6
- package/src/display/marquee.ts +15 -3
- package/src/display/pagga.ts +102 -0
- package/src/display/pattern.tsx +427 -0
- package/src/display/spinner.ts +5 -2
- package/src/navigation/menu.ts +32 -9
- package/src/navigation/tabs.ts +13 -2
- package/src/overlay/command-palette.ts +13 -2
- package/src/shells/workbench-shell.ts +5 -1
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Block fonts, and the engine that draws text in them.
|
|
3
|
+
*
|
|
4
|
+
* A font is data: a table of glyphs, a tracking and a space width. `banner()`
|
|
5
|
+
* lays a string out in one and answers with plain text, which is the shape
|
|
6
|
+
* half only - `ColorText` colours it cell by cell, and the two are deliberately
|
|
7
|
+
* separate, because a banner wants a ramp across it and prose does not.
|
|
8
|
+
* [`FontText`](font-text.tsx) is the one-liner over this: text and a font in,
|
|
9
|
+
* letters out.
|
|
10
|
+
*
|
|
11
|
+
* These ship so that component has something to draw with; the tables are data
|
|
12
|
+
* an application can replace, and `Font` is the whole contract.
|
|
13
|
+
*
|
|
14
|
+
* There is one hand-drawn table and three transforms of it, which is the other
|
|
15
|
+
* thing worth showing: a bitmap font is a grid of characters, and a grid of
|
|
16
|
+
* characters can be sheared, doubled or duplicated by ten lines of code. Every
|
|
17
|
+
* font below has both cases, because the table does.
|
|
18
|
+
*
|
|
19
|
+
* A glyph is a grid of characters. Four of them are placeholders the renderer
|
|
20
|
+
* fills in from the theme - `#` a full cell, `%` a lighter one, `^` the top
|
|
21
|
+
* half of a cell and `v` the bottom half - and every other character is drawn
|
|
22
|
+
* as itself, which is what lets `dots`, `stars` and `mini` be made of dots,
|
|
23
|
+
* stars and pipes rather than of blocks. A space is nothing. Blank columns at
|
|
24
|
+
* either edge are trimmed when a glyph is used, so the letters are
|
|
25
|
+
* proportional rather than a fixed pitch.
|
|
26
|
+
*/
|
|
27
|
+
type Grid = string[];
|
|
28
|
+
export interface Font {
|
|
29
|
+
id: string;
|
|
30
|
+
title: string;
|
|
31
|
+
/** What is different about it, for the panel under the list. */
|
|
32
|
+
note: string;
|
|
33
|
+
glyphs: Record<string, Grid>;
|
|
34
|
+
/** Columns between two letters. */
|
|
35
|
+
tracking: number;
|
|
36
|
+
/** Columns a word space takes. */
|
|
37
|
+
space: number;
|
|
38
|
+
/**
|
|
39
|
+
* Two sets of letters, or one.
|
|
40
|
+
*
|
|
41
|
+
* Everything off the five-row table has `both`, because the table does and a
|
|
42
|
+
* transform of it cannot lose a case. `mini` has one set and folds - at three
|
|
43
|
+
* rows there is no room under a cap for an x-height.
|
|
44
|
+
*/
|
|
45
|
+
cases: 'both' | 'folded';
|
|
46
|
+
/**
|
|
47
|
+
* Whether this font's glyphs are written in placeholders.
|
|
48
|
+
*
|
|
49
|
+
* The ones off the five-row table are: `#` and `%` and the two halves, filled
|
|
50
|
+
* in from the theme at paint time. The hand-drawn tables are not - they are
|
|
51
|
+
* already what they look like - and it matters, because a literal `#` in one
|
|
52
|
+
* of them would otherwise be swapped for a full block, which is how the
|
|
53
|
+
* character `#` would come out as a solid bar.
|
|
54
|
+
*/
|
|
55
|
+
placeholders?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Which row of the glyph box the letters sit on.
|
|
58
|
+
*
|
|
59
|
+
* Only needed where it is not the last one: `gard` keeps two blank rows
|
|
60
|
+
* under its baseline for the descenders, so a character drawn on the last
|
|
61
|
+
* row would hang below every letter beside it. Used for the stand-in a
|
|
62
|
+
* missing character gets, which has to land on the line like anything else.
|
|
63
|
+
*/
|
|
64
|
+
baseline?: number;
|
|
65
|
+
/**
|
|
66
|
+
* The font to draw instead where this one's characters do not exist.
|
|
67
|
+
*
|
|
68
|
+
* Only `tmplt` needs one. Every other font here is made of placeholders the
|
|
69
|
+
* theme fills in, or of characters a teletype has - box-drawing is neither,
|
|
70
|
+
* and there is no `#` to downgrade a `┏` to. So it names a stand-in of the
|
|
71
|
+
* same height rather than putting a row of question marks on the screen.
|
|
72
|
+
*/
|
|
73
|
+
fallback?: string;
|
|
74
|
+
}
|
|
75
|
+
export declare const FONTS: Font[];
|
|
76
|
+
export declare function fontAt(id: string): Font;
|
|
77
|
+
/** The font that is drawn in when a caller names none: the hand-drawn table. */
|
|
78
|
+
export declare const DEFAULT_FONT: Font;
|
|
79
|
+
/** The tallest glyph in a font, which is how many rows a line of it takes. */
|
|
80
|
+
export declare function heightOf(font: Font): number;
|
|
81
|
+
/**
|
|
82
|
+
* The four characters a glyph's placeholders are drawn in.
|
|
83
|
+
*
|
|
84
|
+
* `fill` and `shade` are theme glyphs; the two halves are not, because the
|
|
85
|
+
* theme has no name for half a cell. What they all share is that the *font*
|
|
86
|
+
* names a role and something else decides what the terminal can show - which
|
|
87
|
+
* is the rule the whole catalog follows, and the reason `half` degrades to
|
|
88
|
+
* quotes and underscores instead of putting a row of question marks on the
|
|
89
|
+
* screen that needs the banner most.
|
|
90
|
+
*/
|
|
91
|
+
export interface InkGlyphs {
|
|
92
|
+
fill: string;
|
|
93
|
+
shade: string;
|
|
94
|
+
top: string;
|
|
95
|
+
bottom: string;
|
|
96
|
+
}
|
|
97
|
+
export declare function inkGlyphs(glyphs: {
|
|
98
|
+
progressFull: string;
|
|
99
|
+
progressEmpty: string;
|
|
100
|
+
}, unicode?: boolean): InkGlyphs;
|
|
101
|
+
/** What the fonts are drawn in where nothing has said otherwise. */
|
|
102
|
+
export declare const PLAIN_GLYPHS: InkGlyphs;
|
|
103
|
+
/**
|
|
104
|
+
* Text as block letters.
|
|
105
|
+
*
|
|
106
|
+
* Newlines are lines: each one becomes its own block of rows, stacked with
|
|
107
|
+
* `lineGap` blank rows between them so two lines of banner do not read as one.
|
|
108
|
+
* A character with no glyph becomes a word space, so a missing one shows as a
|
|
109
|
+
* gap the reader can see rather than silently closing up.
|
|
110
|
+
*/
|
|
111
|
+
export declare function bannerLines(text: string, font: Font, ink?: InkGlyphs, width?: number): string[];
|
|
112
|
+
/**
|
|
113
|
+
* The same banner, one string per line.
|
|
114
|
+
*
|
|
115
|
+
* For a caller that has to place the lines itself, and the case that makes it
|
|
116
|
+
* necessary is centring: a multi-line block is centred once, as a block, so its
|
|
117
|
+
* shorter lines start at the widest line's edge and read as left-aligned. One
|
|
118
|
+
* `ColorText` per line - each `alignBlock` and `textAlign="center"` - centres
|
|
119
|
+
* every line over its own width while keeping the rows of each in step.
|
|
120
|
+
*
|
|
121
|
+
* The catch is the ink: a [`ColorText`](color-text.md) starts its ink at its
|
|
122
|
+
* own first cell, so a block drawn as several pieces restarts a `cycle` (and a
|
|
123
|
+
* `{ gradient }` measures each piece rather than the lot). That is a reason to
|
|
124
|
+
* keep one component for a continuous ramp, and this for centring.
|
|
125
|
+
*/
|
|
126
|
+
export declare function banner(text: string, font: Font, ink?: InkGlyphs, width?: number,
|
|
127
|
+
/**
|
|
128
|
+
* Blank rows between one line and the next. One by default.
|
|
129
|
+
*
|
|
130
|
+
* Counts the *empty* rows, so `0` butts two lines together and `2` leaves two
|
|
131
|
+
* rows of air. It applies to every line the block has, wrapped or written -
|
|
132
|
+
* the break between two lines of a sentence is the same break as the one
|
|
133
|
+
* between two paragraphs, which is what makes a wrapped banner read as a
|
|
134
|
+
* block of its own rather than as one long line that ran out of room.
|
|
135
|
+
*/
|
|
136
|
+
lineGap?: number): string;
|
|
137
|
+
export {};
|
|
138
|
+
//# sourceMappingURL=fonts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fonts.d.ts","sourceRoot":"","sources":["../../src/display/fonts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAMH,KAAK,IAAI,GAAG,MAAM,EAAE,CAAC;AAyerB,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC7B,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd;;;;;;OAMG;IACH,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC;IACzB;;;;;;;;OAQG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,KAAK,EAAE,IAAI,EAgHvB,CAAC;AAGF,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAEvC;AAED,g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