@textui/widgets 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.
Files changed (120) hide show
  1. package/dist/chart/line-chart.d.ts.map +1 -1
  2. package/dist/chart/line-chart.js +3 -2
  3. package/dist/control/select.d.ts.map +1 -1
  4. package/dist/control/select.js +4 -2
  5. package/dist/control/switch.d.ts.map +1 -1
  6. package/dist/control/switch.js +7 -2
  7. package/dist/control/text-area.d.ts +2 -0
  8. package/dist/control/text-area.d.ts.map +1 -1
  9. package/dist/control/text-area.js +16 -8
  10. package/dist/data/code-viewer.d.ts +2 -0
  11. package/dist/data/code-viewer.d.ts.map +1 -1
  12. package/dist/data/code-viewer.js +9 -1
  13. package/dist/data/index.d.ts +9 -0
  14. package/dist/data/index.d.ts.map +1 -1
  15. package/dist/data/index.js +11 -4
  16. package/dist/data/list.d.ts +9 -0
  17. package/dist/data/list.d.ts.map +1 -1
  18. package/dist/data/list.js +23 -5
  19. package/dist/data/log-viewer.d.ts.map +1 -1
  20. package/dist/data/log-viewer.js +7 -2
  21. package/dist/data/markdown-view.d.ts.map +1 -1
  22. package/dist/data/markdown-view.js +6 -2
  23. package/dist/data/pagination.d.ts.map +1 -1
  24. package/dist/data/pagination.js +6 -2
  25. package/dist/data/tree.d.ts +2 -0
  26. package/dist/data/tree.d.ts.map +1 -1
  27. package/dist/data/tree.js +8 -2
  28. package/dist/display/card.d.ts.map +1 -1
  29. package/dist/display/card.js +12 -0
  30. package/dist/display/color-text.d.ts +13 -1
  31. package/dist/display/color-text.d.ts.map +1 -1
  32. package/dist/display/color-text.js +28 -6
  33. package/dist/display/error-state.d.ts.map +1 -1
  34. package/dist/display/error-state.js +4 -3
  35. package/dist/display/font-text.d.ts +72 -0
  36. package/dist/display/font-text.d.ts.map +1 -0
  37. package/dist/display/font-text.js +35 -0
  38. package/dist/display/fonts.d.ts +138 -0
  39. package/dist/display/fonts.d.ts.map +1 -0
  40. package/dist/display/fonts.js +893 -0
  41. package/dist/display/gard.d.ts +26 -0
  42. package/dist/display/gard.d.ts.map +1 -0
  43. package/dist/display/gard.js +479 -0
  44. package/dist/display/index.d.ts +3 -0
  45. package/dist/display/index.d.ts.map +1 -1
  46. package/dist/display/index.js +7 -0
  47. package/dist/display/key-value.d.ts +25 -5
  48. package/dist/display/key-value.d.ts.map +1 -1
  49. package/dist/display/key-value.js +13 -3
  50. package/dist/display/pagga.d.ts +29 -0
  51. package/dist/display/pagga.d.ts.map +1 -0
  52. package/dist/display/pagga.js +101 -0
  53. package/dist/display/pattern.d.ts +117 -0
  54. package/dist/display/pattern.d.ts.map +1 -0
  55. package/dist/display/pattern.js +257 -0
  56. package/dist/display/spinner.d.ts +2 -0
  57. package/dist/display/spinner.d.ts.map +1 -1
  58. package/dist/display/spinner.js +3 -2
  59. package/dist/form/danger-zone.d.ts.map +1 -1
  60. package/dist/form/danger-zone.js +7 -3
  61. package/dist/form/form-actions.d.ts.map +1 -1
  62. package/dist/form/form-actions.js +3 -2
  63. package/dist/navigation/menu.d.ts +2 -0
  64. package/dist/navigation/menu.d.ts.map +1 -1
  65. package/dist/navigation/menu.js +22 -8
  66. package/dist/navigation/tabs.d.ts +2 -0
  67. package/dist/navigation/tabs.d.ts.map +1 -1
  68. package/dist/navigation/tabs.js +12 -2
  69. package/dist/overlay/command-palette.d.ts.map +1 -1
  70. package/dist/overlay/command-palette.js +55 -15
  71. package/dist/overlay/dialog.d.ts +11 -0
  72. package/dist/overlay/dialog.d.ts.map +1 -1
  73. package/dist/overlay/dialog.js +24 -1
  74. package/dist/overlay/index.d.ts.map +1 -1
  75. package/dist/overlay/index.js +11 -19
  76. package/dist/overlay/path-picker.d.ts.map +1 -1
  77. package/dist/overlay/path-picker.js +19 -11
  78. package/dist/overlay/prompt-dialog.d.ts.map +1 -1
  79. package/dist/overlay/prompt-dialog.js +5 -4
  80. package/dist/panel/index.d.ts.map +1 -1
  81. package/dist/panel/index.js +8 -7
  82. package/dist/panel/resource-panel.d.ts.map +1 -1
  83. package/dist/panel/resource-panel.js +9 -5
  84. package/dist/surface/mount-view.d.ts.map +1 -1
  85. package/dist/surface/mount-view.js +3 -2
  86. package/package.json +2 -2
  87. package/src/chart/line-chart.ts +3 -2
  88. package/src/control/select.ts +4 -2
  89. package/src/control/switch.ts +9 -2
  90. package/src/control/text-area.ts +18 -7
  91. package/src/data/code-viewer.ts +10 -1
  92. package/src/data/index.ts +12 -3
  93. package/src/data/list.ts +24 -4
  94. package/src/data/log-viewer.ts +7 -1
  95. package/src/data/markdown-view.ts +10 -1
  96. package/src/data/pagination.ts +6 -2
  97. package/src/data/tree.ts +9 -2
  98. package/src/display/card.ts +12 -0
  99. package/src/display/color-text.ts +33 -10
  100. package/src/display/error-state.ts +4 -3
  101. package/src/display/font-text.tsx +94 -0
  102. package/src/display/fonts.ts +990 -0
  103. package/src/display/gard.ts +475 -0
  104. package/src/display/index.ts +7 -0
  105. package/src/display/key-value.ts +44 -6
  106. package/src/display/pagga.ts +102 -0
  107. package/src/display/pattern.tsx +427 -0
  108. package/src/display/spinner.ts +5 -2
  109. package/src/form/danger-zone.ts +7 -3
  110. package/src/form/form-actions.ts +5 -2
  111. package/src/navigation/menu.ts +23 -8
  112. package/src/navigation/tabs.ts +13 -2
  113. package/src/overlay/command-palette.ts +66 -14
  114. package/src/overlay/dialog.ts +37 -1
  115. package/src/overlay/index.ts +11 -19
  116. package/src/overlay/path-picker.ts +23 -10
  117. package/src/overlay/prompt-dialog.ts +5 -4
  118. package/src/panel/index.ts +9 -7
  119. package/src/panel/resource-panel.ts +9 -4
  120. package/src/surface/mount-view.ts +3 -2
@@ -0,0 +1,475 @@
1
+ /**
2
+ * The `gard` table, transcribed.
3
+ *
4
+ * Its own module because it is 62 glyphs of somebody else's drawing and none
5
+ * of it is code - a table this size in `fonts.ts` would bury the four fonts
6
+ * that are ten lines of transform each.
7
+ *
8
+ * Two cases, digits, and a real descender: `J`, `g`, `j`, `p`, `q` and `y`
9
+ * hang below the baseline, which no other font here does. Every glyph is the
10
+ * same nine rows so they all agree where that baseline is - row six - and
11
+ * `banner` trims the blank rows off a finished line, so a line of capitals is
12
+ * five rows, one with a `g` in it is seven, and one with a digit is seven from
13
+ * the other end.
14
+ *
15
+ * **The digits are not in the same hand as the letters.** They came that way:
16
+ * a script numeral beside a pipe-and-quote capital is what the source has, and
17
+ * inventing a matching set would be replacing the font rather than
18
+ * transcribing it. What was fixed here is only where they sit - they were two
19
+ * rows lower than the letters, so `Gard 42` had its number sunk below its
20
+ * word, and the shift is the whole of the editing.
21
+ *
22
+ * Drawn in quotes, pipes, dots and slashes: no placeholder characters, and
23
+ * nothing outside ascii, so this is the one big font that needs no downgrade.
24
+ */
25
+ export const GARD: Record<string, string[]> = {
26
+ // 0: ["", " /\\\\", "|| ||", "|| ||", "|| ||", "|| ||", " \\\\/", "", ""],
27
+ // 1: ["", " /|", "/||", " ||", " ||", " ||", ",/-'", "", ""],
28
+ // 2: ["", " /\\", "( )", " //", " //", "/(", "{___", "", ""],
29
+ // 3: ["____", "` //", " //", " \\\\", " ))", " //", "/'", "", ""],
30
+ // 4: [" ,", " /|", "/ |", "__|_", "----", " |", " '-'", "", ""],
31
+ // 5: ["____", "|| `", "||_", "|/ \\", " ))", " //", " /'", "", ""],
32
+ // 6: ["", " ,/", " //", "((_-", "|| ))", "(( ||", " \\//", "", ""],
33
+ // 7: ["____", "` ||", " /,", " //", " ((", " ||", " |'", "", ""],
34
+ // 8: [" /\\\\", "|| ||", " \\ /", " /\\\\", "// \\\\", "|| ||", " \\\\/", "", ""],
35
+ // 9: ["", " /\\\\", "|| ||", "|| ||", " \\/||", " ||", " \\_/", "", ""],
36
+
37
+
38
+ 0: [
39
+ "",
40
+ "",
41
+ " .||. ",
42
+ "|| .||",
43
+ "||.'||",
44
+ "||' ||",
45
+ " '||' ",
46
+ "",
47
+ ""],
48
+ 1: [
49
+ "",
50
+ "",
51
+ " .|| ",
52
+ " ||| ",
53
+ " || ",
54
+ " || ",
55
+ " .||.",
56
+ "",
57
+ ""
58
+ ],
59
+ 2: [
60
+ "",
61
+ "",
62
+ " .||. ",
63
+ " || ||",
64
+ " ||' ",
65
+ " .|| ",
66
+ " ||||||",
67
+ "",
68
+ ""
69
+ ],
70
+ 3: [
71
+ "",
72
+ "",
73
+ ".|||.",
74
+ " ||",
75
+ " .|| ",
76
+ " ||",
77
+ "'|||'",
78
+ "",
79
+ ""
80
+ ],
81
+ 4: [
82
+ "",
83
+ "",
84
+ " .|| ",
85
+ " .||| ",
86
+ ".| || ",
87
+ "||||||",
88
+ " || ",
89
+ "", ""],
90
+ 5: [
91
+ "",
92
+ "",
93
+ "||||||",
94
+ "|| ",
95
+ "|||||.",
96
+ " ||",
97
+ "|||||'",
98
+ "", ""],
99
+ 6: ["",
100
+ "",
101
+ ".||||.",
102
+ "||' '",
103
+ "|||||.",
104
+ "|| ||",
105
+ "'||||'",
106
+ "", ""],
107
+ 7: ["",
108
+ "",
109
+ "||||||",
110
+ " ||",
111
+ " .|' ",
112
+ " || ",
113
+ " || ",
114
+ "",
115
+ ""],
116
+ 8: [
117
+ "",
118
+ "",
119
+ ".||||.",
120
+ "|| ||",
121
+ " |||| ",
122
+ "|| ||",
123
+ "'||||'",
124
+ "",
125
+ ""
126
+ ],
127
+ 9: [
128
+ "",
129
+ "",
130
+ ".||||.",
131
+ "|| ||",
132
+ "'|||||",
133
+ " ||",
134
+ "'||||'",
135
+ "", ""],
136
+ A: ["", "", " |", " |||", " | ||", " .''''|.", ".|. .||.", "", ""],
137
+ B: ["", "", "'||''|.", " || ||", " ||'''|.", " || ||", ".||...|'", "", ""],
138
+ C: ["", "", " ..|'''.|", ".|' '", "||", "'|. .", " ''|....'", "", ""],
139
+ D: ["", "", "'||''|.", " || ||", " || ||", " || ||", ".||...|'", "", ""],
140
+ E: ["", "", "'||''''|", " || .", " ||''|", " ||", ".||.....|", "", ""],
141
+ F: ["", "", "'||''''|", " || .", " ||''|", " ||", ".||.", "", ""],
142
+ G: ["", "", " ..|'''.|", ".|' '", "|| ....", "'|. ||", " ''|...'|", "", ""],
143
+ H: ["", "", "'||' '||'", " || ||", " ||''''||", " || ||", ".||. .||.", "", ""],
144
+ I: ["", "", "'||'", " ||", " ||", " ||", ".||.", "", ""],
145
+ J: ["", "",
146
+ " '||'",
147
+ " ||",
148
+ " ||",
149
+ "|| ||",
150
+ " '|||'",
151
+ "",
152
+ ""],
153
+ K: ["", "", "'||' |'", " || .'", " ||'|.", " || ||", ".||. ||.", "", ""],
154
+ L: ["", "", "'||'", " ||", " ||", " ||", ".||.....|", "", ""],
155
+ M: ["", "", "'|| ||'", " ||| |||", " |'|..'||", " | '|' ||", ".|. | .||.", "", ""],
156
+ N: ["", "", "'|. '|'", " |'| |", " | '|. |", " | |||", ".|. '|", "", ""],
157
+ O: ["", "", " ..|''||", ".|' ||", "|| ||", "'|. ||", " ''|...|'", "", ""],
158
+ P: ["", "", "'||''|.", " || ||", " ||...|'", " ||", ".||.", "", ""],
159
+ Q: ["", "", " ..|''||", ".|' ||", "|| ||", "'|. '. '|", " '|...'|.", "", ""],
160
+ R: ["", "", "'||''|.", " || ||", " ||''|'", " || |.", ".||. '|'", "", ""],
161
+ S: ["", "", " .|'''.|", " ||.. '", " ''|||.", ". '||", "|'....|'", "", ""],
162
+ T: ["", "", "|''||''|", " ||", " ||", " ||", " .||.", "", ""],
163
+ U: ["", "", "'||' '|'", " || |", " || |", " || |", " '|..'", "", ""],
164
+ V: ["", "", "'||' '|'", " '|. .'", " || |", " |||", " |", "", ""],
165
+ W: ["", "", "'|| '||' '|'", " '|. '|. .'", " || || |", " ||| |||", " | |", "", ""],
166
+ X: ["", "", "'||' '|'", " || |", " ||", " | ||", ".| ||.", "", ""],
167
+ Y: ["", "", "'||' '|'", " || |", " ||", " ||", " .||.", "", ""],
168
+ Z: ["", "", "|'''''||", " .|'", " ||", " .|'", "||......|", "", ""],
169
+ a: ["", "", "", " ....", "'' .||", ".|' ||", "'|..'|'", "", ""],
170
+ b: ["", "", "'||", " || ...", " ||' ||", " || |", " '|...'", "", ""],
171
+ c: ["", "", "", " ....", ".| ''", "||", " '|...'", "", ""],
172
+ d: ["", "", " '||", " .. ||", " .' '||", " |. ||", " '|..'||.", "", ""],
173
+ e: ["", "", "", " ....", ".|...||", "||", " '|...'", "", ""],
174
+ f: ["", "", " .'|.", ".||.", " ||", " ||", ".||.", "", ""],
175
+ g: ["", "", "", " ... .", " || ||", " |''", " '||||.", ".|....'", ""],
176
+ h: ["", "", "'||", " || ..", " ||' ||", " || ||", ".||. ||.", "", ""],
177
+ i: ["", "", " ||", "...", " ||", " ||", ".||.", "", ""],
178
+ j: ["", "", " ||", " ...", " ||", " ||", " ||", ".. |'", " ''"],
179
+ k: ["", "", "'||", " || ..", " || .'", " ||'|.", ".||. ||.", "", ""],
180
+ l: ["", "", "'||", " ||", " ||", " ||", ".||.", "", ""],
181
+ m: ["", "", "", ".. .. ..", " || || ||", " || || ||", ".|| || ||.", "", ""],
182
+ n: ["", "", "", ".. ...", " || ||", " || ||", ".||. ||.", "", ""],
183
+ o: ["", "", "", " ...", ".| '|.", "|| ||", " '|..|'", "", ""],
184
+ p: ["", "", "", "... ...", " ||' ||", " || |", " ||...'", " ||", "''''"],
185
+ q: ["", "", "", " ... .", ".' ||", "|. ||", "'|..'||", " ||", " ''''"],
186
+ r: ["", "", "", "... ..", " ||' ''", " ||", ".||.", "", ""],
187
+ s: ["", "", "", " ....", "||. '", ". '|..", "|'..|'", "", ""],
188
+ t: ["", "", " .", ".||.", " ||", " ||", " '|.'", "", ""],
189
+ u: ["", "", "", "... ...", " || ||", " || ||", " '|..'|.", "", ""],
190
+ v: ["", "", "", ".... ...", " '|. |", " '|.|", " '|", "", ""],
191
+ w: ["", "", "", "... ... ...", " || || |", " ||| |||", " | |", "", ""],
192
+ x: ["", "", "", "... ...", " '|..'", " .|.", ".| ||.", "", ""],
193
+ y: ["", "", "", ".... ...", " '|. |", " '|.|", " '|", ".. |", " ''"],
194
+ z: ["", "", "", "......", "' .|'", " .|'", "||....|", "", ""],
195
+ // Drawn to match, not transcribed: the source is letters and digits only.
196
+ // These are the marks its vocabulary of pipes, dots and quotes makes on its
197
+ // own terms - a full stop is the foot of a letter with no letter over it.
198
+ // The ornate rest of ascii is not here on purpose: imitating this hand is
199
+ // guesswork, and a stand-in that says `@` beats a shape that says nothing.
200
+ '!': ["", "", "'||'", " || ", " || ", "", ".||.", "", ""],
201
+ '"': ["", "",
202
+ ".||..||.",
203
+ " '' ''",
204
+ "", "",
205
+ "", "", ""],
206
+ '#': [
207
+ "",
208
+ "",
209
+ // " .. .. ",
210
+ // "..||..||..",
211
+ // "''||''||''",
212
+ // "..||..||..",
213
+ // "''||''||''",
214
+ " || ||",
215
+ " ||||||||||",
216
+ " || ||",
217
+ " ||||||||||",
218
+ " || ||",
219
+ "",
220
+ ""
221
+ ],
222
+ '$': [
223
+ "",
224
+ " . .",
225
+ " .||'|.|",
226
+ " |||.| '",
227
+ " '||||.",
228
+ ". | |'||",
229
+ "|'.|.||'",
230
+ " ' '",
231
+ ""],
232
+ '%': [
233
+ "",
234
+ "",
235
+ "<> / ",
236
+ " / ",
237
+ " / ",
238
+ " / ",
239
+ "/ <> ",
240
+ "",
241
+ ""
242
+ ],
243
+ '&': [
244
+ "",
245
+ "",
246
+ " /\\ ",
247
+ " \\/ ",
248
+ " /\\ , ",
249
+ "/'\\\\, ",
250
+ "| \\\\ ",
251
+ "\\\\-/\\ ",
252
+ ""
253
+ ],
254
+ "'": [
255
+ "",
256
+ "",
257
+ "'||'",
258
+ " ''",
259
+ "", "", "", "", ""],
260
+ '(': [
261
+ "",
262
+ " .",
263
+ " .|'",
264
+ " || ",
265
+ " || ",
266
+ " || ",
267
+ " '|.",
268
+ " '",
269
+ "",
270
+ ],
271
+ ')': [
272
+ "",
273
+ ". ",
274
+ "'|. ",
275
+ " || ",
276
+ " ||",
277
+ " || ",
278
+ ".|' ",
279
+ "' ",
280
+ "",
281
+ ],
282
+ '*': [
283
+ "",
284
+ "",
285
+ "",
286
+ " \\ / ",
287
+ " --*-- ",
288
+ " / \\ ",
289
+ "",
290
+ "",
291
+ "",
292
+ ],
293
+ '+': [
294
+ "",
295
+ "",
296
+ "",
297
+ " || ",
298
+ " |||||| ",
299
+ " || ",
300
+ "",
301
+ "",
302
+ "",
303
+ ],
304
+ ',': ["", "", "", "", "", "", ".||.", " ''", ""],
305
+ '-': ["", "", "", "", "......", "", "", "", ""],
306
+ '.': ["", "", "", "", "", "", ".||.", "", ""],
307
+ '/': [
308
+ "",
309
+ "",
310
+ " // ",
311
+ " // ",
312
+ " // ",
313
+ " // ",
314
+ "// ",
315
+ "",
316
+ ""
317
+ ],
318
+ ':': ["", "", "", ".||.", "", "", ".||.", "", ""],
319
+ ';': ["", "", "", ".||.", "", "", ".||.", " ''", ""],
320
+ '<': [
321
+ "",
322
+ "",
323
+ " ..",
324
+ " .||' ",
325
+ "|| ",
326
+ " '||. ",
327
+ " ''",
328
+ "",
329
+ ""
330
+ ],
331
+ '=': [
332
+ "",
333
+ "",
334
+ "",
335
+ "|||||",
336
+ " ",
337
+ "|||||",
338
+ "",
339
+ "",
340
+ ""
341
+ ],
342
+ '>': [
343
+ "",
344
+ "",
345
+ "..",
346
+ " '||.",
347
+ " ||",
348
+ " .||'",
349
+ "''",
350
+ "",
351
+ ""
352
+ ],
353
+ '?': [
354
+ "",
355
+ "",
356
+ " .|||. ",
357
+ " || ||",
358
+ " .|' ",
359
+ " || ",
360
+ " .||. ",
361
+ "",
362
+ ""
363
+ ],
364
+ '@': [
365
+ "",
366
+ "",
367
+ " .|''|.",
368
+ " || .||||",
369
+ " || || ||",
370
+ " || '|.|||",
371
+ " '|....'",
372
+ "",
373
+ ""
374
+ ],
375
+ '[': [
376
+ "",
377
+ "",
378
+ "||||",
379
+ "|| ",
380
+ "|| ",
381
+ "|| ",
382
+ "||||",
383
+ "",
384
+ ""
385
+ ],
386
+ '\\': [
387
+ "",
388
+ "",
389
+ " \\\\ ",
390
+ " \\\\ ",
391
+ " \\\\ ",
392
+ " \\\\ ",
393
+ " \\\\",
394
+ "",
395
+ ""
396
+ ],
397
+ ']': [
398
+ "",
399
+ "",
400
+ "||||",
401
+ " ||",
402
+ " || ",
403
+ " ||",
404
+ "||||",
405
+ "",
406
+ ""
407
+ ],
408
+ '^': [
409
+ "",
410
+ "",
411
+ " .||.",
412
+ ".|| ||.",
413
+ " ",
414
+ " ",
415
+ " ",
416
+ "",
417
+ ""
418
+ ],
419
+ '_': ["", "", "", "", "", "", "", "......", ""],
420
+ '`': [
421
+ "",
422
+ "",
423
+ " \\\\ ",
424
+ " '' ",
425
+ " ",
426
+ " ",
427
+ " ",
428
+ "",
429
+ ""
430
+ ],
431
+ '{': [
432
+ "",
433
+ "",
434
+ ".||",
435
+ "'|",
436
+ "||",
437
+ ".| ",
438
+ "'||",
439
+ "",
440
+ ""
441
+ ],
442
+ '|': [
443
+ "",
444
+ "",
445
+ " || ",
446
+ " || ",
447
+ " || ",
448
+ " || ",
449
+ " || ",
450
+ "",
451
+ ""
452
+ ],
453
+ '}': [
454
+ "",
455
+ "",
456
+ "||.",
457
+ " |' ",
458
+ " ||",
459
+ " |. ",
460
+ "||'",
461
+ "",
462
+ ""
463
+ ],
464
+ '~': [
465
+ "",
466
+ "",
467
+ " ",
468
+ " ",
469
+ ".''..,'",
470
+ " ",
471
+ " ",
472
+ "",
473
+ ""
474
+ ],
475
+ };
@@ -4,11 +4,13 @@ import { Badge } from './badge.js';
4
4
  import { Card } from './card.js';
5
5
  import { ColorText } from './color-text.js';
6
6
  import { EmptyState } from './empty-state.js';
7
+ import { FontText } from './font-text.js';
7
8
  import { ErrorState } from './error-state.js';
8
9
  import { Heading } from './heading.js';
9
10
  import { KeyValue } from './key-value.js';
10
11
  import { Label } from './label.js';
11
12
  import { Marquee } from './marquee.js';
13
+ import { Pattern } from './pattern.js';
12
14
  import { Progress } from './progress.js';
13
15
  import { Skeleton } from './skeleton.js';
14
16
  import { Spinner } from './spinner.js';
@@ -28,11 +30,14 @@ export * from './badge.js';
28
30
  export * from './card.js';
29
31
  export * from './color-text.js';
30
32
  export * from './empty-state.js';
33
+ export * from './font-text.js';
34
+ export * from './fonts.js';
31
35
  export * from './error-state.js';
32
36
  export * from './heading.js';
33
37
  export * from './key-value.js';
34
38
  export * from './label.js';
35
39
  export * from './marquee.js';
40
+ export * from './pattern.js';
36
41
  export * from './progress.js';
37
42
  export * from './skeleton.js';
38
43
  export * from './spinner.js';
@@ -50,7 +55,9 @@ export const DISPLAY_COMPONENTS: ComponentDefinition[] = [
50
55
  { component: 'Progress', category: 'feedback', renderer: { kind: 'function', render: Progress }, role: 'progressbar', description: 'Determinate or indeterminate bar, sub-cell resolution.' },
51
56
  { component: 'Spinner', category: 'feedback', renderer: { kind: 'function', render: Spinner }, role: 'status', description: 'Animated activity indicator.' },
52
57
  { component: 'ColorText', category: 'display', renderer: { kind: 'function', render: ColorText }, description: 'Multiline text coloured cell by cell - a ramp, a palette per line, or a function.' },
58
+ { component: 'FontText', category: 'display', renderer: { kind: 'function', render: FontText }, description: 'Text drawn in a block font, one glyph table to a letter.' },
53
59
  { component: 'Marquee', category: 'display', renderer: { kind: 'function', render: Marquee }, role: 'marquee', description: 'Text too long for its box, read by sliding it while it has the cursor.' },
60
+ { component: 'Pattern', category: 'display', renderer: { kind: 'function', render: Pattern }, description: 'A tile, repeated - a texture under the children or a motif over them.' },
54
61
  { component: 'Skeleton', category: 'feedback', renderer: { kind: 'function', render: Skeleton }, description: 'Loading placeholder.' },
55
62
  { component: 'EmptyState', category: 'feedback', renderer: { kind: 'function', render: EmptyState }, description: 'Nothing here, and what to do about it.' },
56
63
  { component: 'ErrorState', category: 'feedback', renderer: { kind: 'function', render: ErrorState }, role: 'alert', description: 'A failure, with its message.' },
@@ -2,19 +2,47 @@ import type { BoxProps, SemanticVariant } from '@textui/core';
2
2
  import { defineComponent, h, stringWidth } from '@textui/core';
3
3
  import { TONE as TONE_COLOR } from '../tone.js';
4
4
 
5
+ /** Where a label or a value sits in the cells it was given. */
6
+ export type KeyValueAlign = 'left' | 'right';
7
+
8
+ export interface KeyValueItem {
9
+ label: string;
10
+ value: string;
11
+ tone?: SemanticVariant;
12
+ /** Overrides the block's `labelAlign` for this pair. */
13
+ labelAlign?: KeyValueAlign;
14
+ /** Overrides the block's `valueAlign` for this pair. */
15
+ valueAlign?: KeyValueAlign;
16
+ }
17
+
5
18
  export interface KeyValueProps extends BoxProps {
6
- items: { label: string; value: string; tone?: SemanticVariant }[];
19
+ items: KeyValueItem[];
7
20
  /** Cells reserved for labels. Computed from the longest when unset. */
8
21
  labelWidth?: number;
22
+ /**
23
+ * Cells added to the longest label when the width is computed.
24
+ *
25
+ * The column is otherwise exactly as wide as its longest label, which leaves
26
+ * the value one gap after it; room here is what makes the values read as a
27
+ * column of their own rather than as the tail of the labels. Ignored when
28
+ * `labelWidth` states the width, which is exact.
29
+ */
30
+ labelGap?: number;
31
+ /** Where a label sits in its column. `left` by default. */
32
+ labelAlign?: KeyValueAlign;
33
+ /** Where a value sits in what is left of the pair. `left` by default. */
34
+ valueAlign?: KeyValueAlign;
9
35
  columns?: number;
10
36
  }
11
37
 
12
38
  /** Structured data as aligned label/value pairs. */
13
39
  export const KeyValue = defineComponent<KeyValueProps>('KeyValue', (props) => {
14
- const { items, labelWidth, columns = 1, ...rest } = props;
15
- const width = labelWidth ?? Math.max(0, ...items.map((i) => stringWidth(i.label)));
40
+ const {
41
+ items, labelWidth, labelGap = 0, labelAlign = 'left', valueAlign = 'left', columns = 1, ...rest
42
+ } = props;
43
+ const width = labelWidth ?? Math.max(0, ...items.map((i) => stringWidth(i.label))) + labelGap;
16
44
 
17
- const rows: typeof items[] = [];
45
+ const rows: KeyValueItem[][] = [];
18
46
  for (let i = 0; i < items.length; i += columns) rows.push(items.slice(i, i + columns));
19
47
 
20
48
  return h('box', { direction: 'column', ...rest },
@@ -22,8 +50,18 @@ export const KeyValue = defineComponent<KeyValueProps>('KeyValue', (props) => {
22
50
  h('box', { key: i, direction: 'row', gap: 2 },
23
51
  ...row.map((item, j) =>
24
52
  h('box', { key: j, direction: 'row', gap: 1, flex: 1 },
25
- h('box', { width }, h('text', { content: item.label, fg: 'muted' })),
26
- h('text', { content: item.value, fg: item.tone ? TONE_COLOR[item.tone] : undefined, truncate: 'end', flex: 1 }),
53
+ h('box', { width }, h('text', {
54
+ content: item.label,
55
+ fg: 'muted',
56
+ textAlign: item.labelAlign ?? labelAlign,
57
+ })),
58
+ h('text', {
59
+ content: item.value,
60
+ fg: item.tone ? TONE_COLOR[item.tone] : undefined,
61
+ truncate: 'end',
62
+ flex: 1,
63
+ textAlign: item.valueAlign ?? valueAlign,
64
+ }),
27
65
  ),
28
66
  ),
29
67
  ),