@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
@@ -1 +1 @@
1
- {"version":3,"file":"line-chart.d.ts","sourceRoot":"","sources":["../../src/chart/line-chart.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD;;;GAGG;AACH,eAAO,MAAM,SAAS,gEA+EpB,CAAC"}
1
+ {"version":3,"file":"line-chart.d.ts","sourceRoot":"","sources":["../../src/chart/line-chart.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD;;;GAGG;AACH,eAAO,MAAM,SAAS,gEAgFpB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { defineComponent, fitTo, h, stringWidth, useTheme } from '@textui/core';
1
+ import { defineComponent, fitTo, h, stringWidth, useI18n, useTheme } from '@textui/core';
2
2
  import { TONE, bounds, resample } from './shared.js';
3
3
  /**
4
4
  * A line chart on a braille canvas: each cell holds a 2x4 dot grid, so a
@@ -6,6 +6,7 @@ import { TONE, bounds, resample } from './shared.js';
6
6
  */
7
7
  export const LineChart = defineComponent('LineChart', (props) => {
8
8
  const theme = useTheme();
9
+ const i18n = useI18n();
9
10
  const { series, min, max, chartWidth, chartHeight = 8, axis = true, area = false, format, ...rest } = props;
10
11
  const all = series.flatMap((s) => s.values);
11
12
  const [lo, hi] = bounds(all, min, max);
@@ -60,7 +61,7 @@ export const LineChart = defineComponent('LineChart', (props) => {
60
61
  const fmt = format ?? ((v) => (Number.isInteger(v) ? String(v) : v.toFixed(1)));
61
62
  const axisWidth = Math.max(stringWidth(fmt(hi)), stringWidth(fmt(lo)));
62
63
  return h('box', { direction: 'column', ...rest }, h('box', { direction: 'row', gap: 1 }, h('box', { direction: 'column', width: axisWidth, height: chartHeight, justify: 'between' }, h('text', { content: fitTo(fmt(hi), axisWidth, 'right'), fg: 'subtle' }), h('text', { content: fitTo(fmt(lo), axisWidth, 'right'), fg: 'subtle' })), chart), series.some((s) => s.label)
63
- ? h('box', { direction: 'row', gap: 2 }, ...series.map((s, i) => h('box', { key: i, direction: 'row', gap: 1 }, h('text', { content: theme.glyphs.bulletFilled, fg: TONE[s.tone ?? (i === 0 ? 'accent' : 'secondary')] }), h('text', { content: s.label ?? `series ${i + 1}`, fg: 'muted' }))))
64
+ ? h('box', { direction: 'row', gap: 2 }, ...series.map((s, i) => h('box', { key: i, direction: 'row', gap: 1 }, h('text', { content: theme.glyphs.bulletFilled, fg: TONE[s.tone ?? (i === 0 ? 'accent' : 'secondary')] }), h('text', { content: s.label ?? i18n.t('textui.lineChart.series', { n: i + 1 }, 'series {n}'), fg: 'muted' }))))
64
65
  : null);
65
66
  });
66
67
  function brailleBit(x, y) {
@@ -1 +1 @@
1
- {"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/control/select.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAiB,YAAY,EAAE,MAAM,cAAc,CAAC;AAK1E,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAY,SAAQ,QAAQ;IAC3C,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8DAA8D;IAC9D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,oCAAoC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;CACxC;AAED,eAAO,MAAM,MAAM,sCAiMjB,CAAC"}
1
+ {"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/control/select.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAiB,YAAY,EAAE,MAAM,cAAc,CAAC;AAK1E,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAY,SAAQ,QAAQ;IAC3C,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8DAA8D;IAC9D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,oCAAoC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;CACxC;AAED,eAAO,MAAM,MAAM,sCAmMjB,CAAC"}
@@ -1,11 +1,13 @@
1
- import { defineComponent, h, useApp, useEffect, useFocus, useInput, useMeasure, useState, useTheme, } from '@textui/core';
1
+ import { defineComponent, h, useApp, useEffect, useFocus, useI18n, useInput, useMeasure, useState, useTheme, } from '@textui/core';
2
2
  export const Select = defineComponent('Select', (props) => {
3
3
  const theme = useTheme();
4
+ const i18n = useI18n();
4
5
  const { options, value, onChange, label, placeholder, open: openProp, visibleRows = 6, disabled, mode = 'inline', ...rest } = props;
5
6
  const app = useApp();
6
7
  const focus = useFocus({ disabled });
7
8
  const measured = useMeasure();
8
- const empty = placeholder ?? `Select${theme.glyphs.ellipsis}`;
9
+ const empty = placeholder
10
+ ?? i18n.t('textui.select.placeholder', { ellipsis: theme.glyphs.ellipsis }, 'Select{ellipsis}');
9
11
  const [open, setOpen] = useState(openProp ?? false);
10
12
  const index = Math.max(0, options.findIndex((o) => o.value === value));
11
13
  const [highlight, setHighlight] = useState(index);
@@ -1 +1 @@
1
- {"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../src/control/switch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG7C,MAAM,WAAW,WAAY,SAAQ,QAAQ;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAChC,4DAA4D;IAC5D,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;CACpC;AAED,eAAO,MAAM,MAAM,6DA2BjB,CAAC"}
1
+ {"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../src/control/switch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG7C,MAAM,WAAW,WAAY,SAAQ,QAAQ;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAChC,4DAA4D;IAC5D,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;CACpC;AAED,eAAO,MAAM,MAAM,6DAkCjB,CAAC"}
@@ -1,6 +1,11 @@
1
- import { defineComponent, h, useFocus, useInput } from '@textui/core';
1
+ import { defineComponent, h, useFocus, useI18n, useInput } from '@textui/core';
2
2
  export const Switch = defineComponent('Switch', (props) => {
3
- const { label, value = false, onChange, labels = ['off', 'on'], disabled, ...rest } = props;
3
+ const i18n = useI18n();
4
+ const { label, value = false, onChange, disabled, ...rest } = props;
5
+ const labels = props.labels ?? [
6
+ i18n.t('textui.switch.off', undefined, 'off'),
7
+ i18n.t('textui.switch.on', undefined, 'on'),
8
+ ];
4
9
  const focus = useFocus({ disabled });
5
10
  useInput((event) => {
6
11
  if (disabled)
@@ -96,5 +96,7 @@ export interface TextAreaProps extends BoxProps {
96
96
  * is what typing is. That single fact is why an application with one of these
97
97
  * cannot have single-letter global commands, and why it does not need to.
98
98
  */
99
+ /** The name a theme styles this field's selection under. See `LIST`. */
100
+ export declare const TEXT_AREA = "TextArea";
99
101
  export declare const TextArea: (props: TextAreaProps) => import("@textui/core").RenderOutput;
100
102
  //# sourceMappingURL=text-area.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"text-area.d.ts","sourceRoot":"","sources":["../../src/control/text-area.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAwB,eAAe,EAAS,MAAM,cAAc,CAAC;AA0B3F,MAAM,WAAW,aAAc,SAAQ,QAAQ;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,gEAAgE;IAChE,QAAQ,CAAC,IAAI,IAAI,CAAC;IAClB,gEAAgE;IAChE,UAAU,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IACrC;;;;;;;OAOG;IACH,MAAM,CAAC,CAAC,IAAI,EAAE,OAAO,GAAG,KAAK,GAAG,IAAI,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yDAAyD;IACzD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B;;;;;;;;;;;;;OAaG;IACH,UAAU,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC;IACnC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;;GAgBG;AACH,wEAAwE;AACxE,eAAO,MAAM,SAAS,aAAa,CAAC;AAEpC,eAAO,MAAM,QAAQ,+DAqsBnB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { defineComponent, graphemes, h, stringWidth, useClipboard, useEffect, useFocus, useInput, useMeasure, useRef, useState, useTheme, useTicker, } from '@textui/core';
1
+ import { NO_INTERACTION, defineComponent, graphemes, h, stateVariants, stringWidth, useClipboard, useEffect, useFocus, useInput, useMeasure, useRef, useState, useTheme, useTicker, } from '@textui/core';
2
2
  /** How many edits back a field remembers. */
3
3
  const MEMORY = 200;
4
4
  /**
@@ -18,6 +18,8 @@ const MEMORY = 200;
18
18
  * is what typing is. That single fact is why an application with one of these
19
19
  * cannot have single-letter global commands, and why it does not need to.
20
20
  */
21
+ /** The name a theme styles this field's selection under. See `LIST`. */
22
+ export const TEXT_AREA = 'TextArea';
21
23
  export const TextArea = defineComponent('TextArea', (props) => {
22
24
  const { value, onChange, onSubmit, onCancel, onOverflow, onEdge, placeholder, maxRows = 6, maxLength, autoFocus, focusId, disabled, caretTone, blink = true, wrap = 'word', caretStyle, copyOnSelect = true, ...rest } = props;
23
25
  const theme = useTheme();
@@ -104,14 +106,20 @@ export const TextArea = defineComponent('TextArea', (props) => {
104
106
  /**
105
107
  * How a selected cell is drawn.
106
108
  *
107
- * The same pair a selected list row uses, and dimmer once the field loses
108
- * the keyboard: a selection left visible in an unfocused field says what is
109
- * on the clipboard, and saying it as loudly as the live one would put two
110
- * selections on the screen.
109
+ * The theme's to say, and the same pair a selected list row uses: the
110
+ * `TextArea.focused` fill while the field has the keyboard and the dimmer
111
+ * `TextArea.selected` one once it does not, because a selection left
112
+ * visible in an unfocused field says what is on the clipboard, and saying it
113
+ * as loudly as the live one would put two selections on the screen.
114
+ *
115
+ * Asked for here rather than read off a node, because the field's selection
116
+ * is painted across cells that are not themselves selected nodes.
111
117
  */
112
- const selectionStyle = focus.focused
113
- ? { bg: 'selected', fg: 'inverted' }
114
- : { bg: 'active' };
118
+ const selectionStyle = theme.styleFor(TEXT_AREA, stateVariants({
119
+ ...NO_INTERACTION,
120
+ selected: true,
121
+ focused: focus.focused,
122
+ }));
115
123
  const before = chars.slice(0, position).join('');
116
124
  const lines = value === '' ? [''] : value.split('\n');
117
125
  const caretLine = before.split('\n').length - 1;
@@ -67,5 +67,7 @@ export declare const HORIZONTAL_STEP = 4;
67
67
  * around it. And it colours by asking the registry for a highlighter, so a new
68
68
  * file type arrives coloured without this component learning what it is.
69
69
  */
70
+ /** The name a theme styles a code row under. See `LIST`. */
71
+ export declare const CODE_VIEWER = "CodeViewer";
70
72
  export declare const CodeViewer: (props: CodeViewerProps) => RenderOutput;
71
73
  //# sourceMappingURL=code-viewer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"code-viewer.d.ts","sourceRoot":"","sources":["../../src/data/code-viewer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAiB,WAAW,EAAE,MAAM,cAAc,CAAC;AAuBvF,MAAM,WAAW,eAAgB,SAAQ,QAAQ;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,qCAAqC;IACrC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,yEAAyE;IACzE,MAAM,CAAC,EAAE,WAAW,EAAE,EAAE,CAAC;IACzB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gCAAgC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yBAAyB;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,uD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CAAC;IACd,yBAAyB;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,uDAAuD;IACvD,UAAU,CAAC,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAChD,iEAAiE;IACjE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,oDAAoD;IACpD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,kBAAkB;IACjC,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;GAKG;AACH,eAAO,MAAM,eAAe,IAAI,CAAC;AAEjC;;;;;;;;GAQG;AACH,4DAA4D;AAC5D,eAAO,MAAM,WAAW,eAAe,CAAC;AAExC,eAAO,MAAM,UAAU,0CAyMrB,CAAC"}
@@ -19,6 +19,8 @@ export const HORIZONTAL_STEP = 4;
19
19
  * around it. And it colours by asking the registry for a highlighter, so a new
20
20
  * file type arrives coloured without this component learning what it is.
21
21
  */
22
+ /** The name a theme styles a code row under. See `LIST`. */
23
+ export const CODE_VIEWER = 'CodeViewer';
22
24
  export const CodeViewer = defineComponent('CodeViewer', (props) => {
23
25
  const { content, lineNumbers = true, startLine = 1, visibleRows, highlight = [], tokens, language, kind, uri, line, onLineChange, onPosition, scrollbar = true, showCaret = true, tabWidth = 4, disabled, autoFocus, ...rest } = props;
24
26
  const theme = useTheme();
@@ -158,7 +160,13 @@ export const CodeViewer = defineComponent('CodeViewer', (props) => {
158
160
  key: number,
159
161
  direction: 'row',
160
162
  height: 1,
161
- bg: marked ? 'active' : onCaret ? 'hover' : undefined,
163
+ styleAs: CODE_VIEWER,
164
+ // A marked line is a selection; the caret line is that selection with
165
+ // the keyboard on it. Both fills are the theme's - `CodeViewer.selected`
166
+ // and `CodeViewer.focused` - and both carry the colour that reads on
167
+ // the fill, so a token inside the row that states its own keeps it.
168
+ selected: marked,
169
+ focused: onCaret,
162
170
  }, lineNumbers
163
171
  ? h('text', {
164
172
  content: `${String(number).padStart(gutter)} `,
@@ -44,6 +44,15 @@ export interface TableProps<T extends object = Record<string, unknown>> extends
44
44
  /** Width below which low-priority columns start being dropped. */
45
45
  responsive?: boolean;
46
46
  }
47
+ /**
48
+ * A data table.
49
+ *
50
+ * Responsiveness is a column-priority problem, not a font-size problem: as the
51
+ * table narrows it drops the lowest-priority columns rather than squeezing
52
+ * every column until none of them is readable.
53
+ */
54
+ /** The name a theme styles a table row under. See `LIST` in `./list.js`. */
55
+ export declare const TABLE = "Table";
47
56
  /**
48
57
  * Exported with its own generic signature so a caller's row type flows into
49
58
  * `format` and `tone` - the alternative is every table taking
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/data/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAwBjG;;;;;;;GAOG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAE1B,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,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I,EAAE,CAAC,EAAE,CAAC;IACV,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC;IACrC,UAAU,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC;IACvC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,kEAAkE;IAClE,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;;;GAMG;AACH,4EAA4E;AAC5E,eAAO,MAAM,KAAK,UAAU,CAAC;AA0J7B;;;;GAIG;AACH,eAAO,MAAM,KAAK,EAAgB,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,YAAY,CAAC;AAE3F,eAAO,MAAM,eAAe,EAAE,mBAAmB,EAShD,CAAC"}
@@ -1,4 +1,4 @@
1
- import { chorded, defineComponent, fitTo, h, stringWidth, useFocus, useInput, useMeasure, useState, useTheme, } from '@textui/core';
1
+ import { chorded, defineComponent, fitTo, h, stringWidth, useFocus, useI18n, useInput, useMeasure, useState, useTheme, } from '@textui/core';
2
2
  import { EmptyState } from '../display/index.js';
3
3
  import { TONE } from '../tone.js';
4
4
  import { viewportRows } from '../viewport.js';
@@ -32,9 +32,12 @@ export * from './tree.js';
32
32
  * table narrows it drops the lowest-priority columns rather than squeezing
33
33
  * every column until none of them is readable.
34
34
  */
35
+ /** The name a theme styles a table row under. See `LIST` in `./list.js`. */
36
+ export const TABLE = 'Table';
35
37
  const TableImpl = defineComponent('Table', (props) => {
36
38
  const theme = useTheme();
37
- const { columns, rows, rowKey = 'id', selectedKey, onSelect, onActivate, visibleRows, showHeader = true, emptyMessage = 'No rows', focusable = true, responsive = true, width, ...rest } = props;
39
+ const i18n = useI18n();
40
+ const { columns, rows, rowKey = 'id', selectedKey, onSelect, onActivate, visibleRows, showHeader = true, emptyMessage = i18n.t('textui.table.empty', undefined, 'No rows'), focusable = true, responsive = true, width, ...rest } = props;
38
41
  const focus = useFocus({ disabled: !focusable });
39
42
  const measured = useMeasure();
40
43
  const [internalKey, setInternalKey] = useState(null);
@@ -152,11 +155,15 @@ const TableImpl = defineComponent('Table', (props) => {
152
155
  return h('box', {
153
156
  key,
154
157
  role: 'row',
158
+ styleAs: TABLE,
155
159
  selected: active,
160
+ // The keyboard is the table's; the row is told which row it lands on.
161
+ focused: active && focus.focused,
156
162
  direction: 'row',
157
163
  gap,
158
- bg: active && focus.focused ? 'selected' : active ? 'active' : undefined,
159
- fg: active && focus.focused ? 'inverted' : undefined,
164
+ // What the row is filled with is the theme's to say - `Table.selected`
165
+ // for the current row and `Table.focused` over it while the table has
166
+ // the keyboard - as it is for a list, a tree and a menu.
160
167
  onClick: () => {
161
168
  if (selectedKey === undefined)
162
169
  setInternalKey(key);
@@ -8,6 +8,15 @@ export interface ListItem {
8
8
  meta?: string;
9
9
  disabled?: boolean;
10
10
  }
11
+ /**
12
+ * The name a theme styles a row under.
13
+ *
14
+ * A row is a plain `box`, so without this `components.List` in a theme is a
15
+ * key nothing reads. Stated once here because the row, the tree, the table
16
+ * and the menu all fill the same two colours and a theme author comparing
17
+ * them should be reading the same four names.
18
+ */
19
+ export declare const LIST = "List";
11
20
  /** How a row stands at the moment it is asked to draw itself. */
12
21
  export interface ListItemState {
13
22
  /** The row the selection is on. */
@@ -1 +1 @@
1
- {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/data/list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAgB5E,MAAM,WAAW,QAAQ;IACvB,E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jB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;;;;;;;;;;;OAiBG;IACH,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,aAAa,GAAG,YAAY,CAAC;IACzD;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,iBAAS,QAAQ,CAAC,CAAC,SAAS,QAAQ,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,YAAY,CAwIvE;AAED,eAAO,MAAM,IAAI,EAA8E,OAAO,QAAQ,CAAC"}
package/dist/data/list.js CHANGED
@@ -1,10 +1,20 @@
1
- import { chorded, defineComponent, h, useFocus, useInput, useMeasure, useState, useTheme, } from '@textui/core';
1
+ import { chorded, defineComponent, h, useFocus, useI18n, useInput, useMeasure, useState, useTheme, } from '@textui/core';
2
2
  import { EmptyState } from '../display/index.js';
3
3
  import { TONE } from '../tone.js';
4
4
  import { viewportRows } from '../viewport.js';
5
+ /**
6
+ * The name a theme styles a row under.
7
+ *
8
+ * A row is a plain `box`, so without this `components.List` in a theme is a
9
+ * key nothing reads. Stated once here because the row, the tree, the table
10
+ * and the menu all fill the same two colours and a theme author comparing
11
+ * them should be reading the same four names.
12
+ */
13
+ export const LIST = 'List';
5
14
  function ListView(props) {
6
15
  const theme = useTheme();
7
- const { items, selectedId, onSelect, onActivate, visibleRows, emptyMessage = 'Nothing here', marker = true, focusable = true, autoFocus, focusId, renderItem, itemHeight = 1, ...rest } = props;
16
+ const i18n = useI18n();
17
+ const { items, selectedId, onSelect, onActivate, visibleRows, emptyMessage = i18n.t('textui.list.empty', undefined, 'Nothing here'), marker = true, focusable = true, autoFocus, focusId, renderItem, itemHeight = 1, ...rest } = props;
8
18
  const focus = useFocus({
9
19
  ...(focusId ? { id: focusId } : {}),
10
20
  disabled: !focusable,
@@ -104,14 +114,22 @@ function ListView(props) {
104
114
  key: item.id,
105
115
  role: 'listitem',
106
116
  label: item.label,
117
+ styleAs: LIST,
107
118
  selected: active,
119
+ // The keyboard is the list's, not the row's, so the row is told. It is
120
+ // the difference between "the current row" and "the current row you
121
+ // can type at", and a theme states the two fills separately.
122
+ focused: active && focus.focused,
108
123
  direction: 'row',
109
124
  gap: 1,
110
125
  // One background over the whole row, however many lines it draws: a
111
126
  // highlight that stopped after the first would split the row it is
112
- // highlighting in two.
113
- bg: active && focus.focused ? 'selected' : active ? 'active' : undefined,
114
- fg: item.disabled ? 'disabled' : active && focus.focused ? 'inverted' : undefined,
127
+ // highlighting in two. What it is filled with is the theme's to say -
128
+ // `List.selected` for the current row, `List.focused` over it while
129
+ // the list has the keyboard - and a background always comes with the
130
+ // colour that reads on it, which is why that pairing lives in the
131
+ // theme rather than here.
132
+ fg: item.disabled ? 'disabled' : undefined,
115
133
  onClick: () => {
116
134
  if (item.disabled)
117
135
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"log-viewer.d.ts","sourceRoot":"","sources":["../../src/data/log-viewer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAmB,MAAM,cAAc,CAAC;AAa9D,MAAM,WAAW,OAAO;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAe,SAAQ,QAAQ;IAC9C,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,kDAAkD;IAClD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uEAAuE;IACvE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc,CAAC,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;CACxC;AAMD;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,gEA8DpB,CAAC"}
1
+ {"version":3,"file":"log-viewer.d.ts","sourceRoot":"","sources":["../../src/data/log-viewer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAmB,MAAM,cAAc,CAAC;AAc9D,MAAM,WAAW,OAAO;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAe,SAAQ,QAAQ;IAC9C,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,kDAAkD;IAClD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uEAAuE;IACvE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc,CAAC,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;CACxC;AAMD;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,gEAmEpB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { chorded, defineComponent, h, useFocus, useInput, useMeasure, useState, } from '@textui/core';
1
+ import { chorded, defineComponent, h, useFocus, useI18n, useInput, useMeasure, useState, } from '@textui/core';
2
2
  import { TONE } from '../tone.js';
3
3
  import { viewportRows } from '../viewport.js';
4
4
  const LEVEL_TONE = {
@@ -13,6 +13,7 @@ const LEVEL_TONE = {
13
13
  */
14
14
  export const LogViewer = defineComponent('LogViewer', (props) => {
15
15
  const { lines, visibleRows: visibleRowsProp, follow: followProp, showTime = true, showLevel = true, onFollowChange, ...rest } = props;
16
+ const i18n = useI18n();
16
17
  const focus = useFocus({});
17
18
  const measured = useMeasure();
18
19
  const [offset, setOffset] = useState(0);
@@ -64,6 +65,10 @@ export const LogViewer = defineComponent('LogViewer', (props) => {
64
65
  fg: TONE[LEVEL_TONE[line.level] ?? 'muted'],
65
66
  })
66
67
  : null, line.source ? h('text', { content: line.source, fg: 'muted' }) : null, h('text', { content: line.message, flex: 1, truncate: 'end' }))), !follow
67
- ? h('text', { content: ' paused - end to follow', fg: 'warning', dim: true })
68
+ ? h('text', {
69
+ content: ` ${i18n.t('textui.logViewer.paused', undefined, 'paused - end to follow')}`,
70
+ fg: 'warning',
71
+ dim: true,
72
+ })
68
73
  : null);
69
74
  });
@@ -1 +1 @@
1
- {"version":3,"file":"markdown-view.d.ts","sourceRoot":"","sources":["../../src/data/markdown-view.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAA0C,MAAM,cAAc,CAAC;AAclG,MAAM,WAAW,iBAAkB,SAAQ,QAAQ;IACjD,mDAAmD;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,IAAI,CAAC,EAAE,WAAW,EAAE,CAAC;IACrB,+EAA+E;IAC/E,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1C,oEAAoE;IACpE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iEAAiE;IACjE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,mEAkLvB,CAAC"}
1
+ {"version":3,"file":"markdown-view.d.ts","sourceRoot":"","sources":["../../src/data/markdown-view.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAA0C,MAAM,cAAc,CAAC;AAelG,MAAM,WAAW,iBAAkB,SAAQ,QAAQ;IACjD,mDAAmD;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,IAAI,CAAC,EAAE,WAAW,EAAE,CAAC;IACrB,+EAA+E;IAC/E,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1C,oEAAoE;IACpE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iEAAiE;IACjE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,mEA0LvB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { defineComponent, h, layoutMarkdown, repeatToWidth, useMeasure, useMemo, useTheme, } from '@textui/core';
1
+ import { defineComponent, h, layoutMarkdown, repeatToWidth, useI18n, useMeasure, useMemo, useTheme, } from '@textui/core';
2
2
  import { CodeViewer } from './code-viewer.js';
3
3
  /**
4
4
  * Markdown, drawn into the width it was given.
@@ -19,6 +19,7 @@ export const MarkdownView = defineComponent('MarkdownView', (props) => {
19
19
  // a document with no search over it carries no extra prop per run.
20
20
  const hit = match ? { match } : {};
21
21
  const theme = useTheme();
22
+ const i18n = useI18n();
22
23
  const measured = useMeasure();
23
24
  const width = measured.width > 0 ? measured.width : 0;
24
25
  const ruled = theme.border !== 'none';
@@ -166,7 +167,10 @@ export const MarkdownView = defineComponent('MarkdownView', (props) => {
166
167
  i++;
167
168
  }
168
169
  return h('box', { role: 'document', direction: 'column', ...rest }, ...out, hidden > 0
169
- ? h('text', { content: `${theme.glyphs.ellipsis} ${hidden} more lines`, fg: 'subtle' })
170
+ ? h('text', { content: i18n.plural(hidden, {
171
+ one: i18n.t('textui.markdown.moreLines.one', undefined, '{glyph} {count} more line'),
172
+ other: i18n.t('textui.markdown.moreLines.other', undefined, '{glyph} {count} more lines'),
173
+ }, { glyph: theme.glyphs.ellipsis }), fg: 'subtle' })
170
174
  : null);
171
175
  });
172
176
  /** One `text` per run, so a bold half of a sentence stays bold after wrapping. */
@@ -1 +1 @@
1
- {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../src/data/pagination.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG7C,MAAM,WAAW,eAAgB,SAAQ,QAAQ;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,eAAO,MAAM,UAAU,iEAoBrB,CAAC"}
1
+ {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../src/data/pagination.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG7C,MAAM,WAAW,eAAgB,SAAQ,QAAQ;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,eAAO,MAAM,UAAU,iEAwBrB,CAAC"}
@@ -1,6 +1,7 @@
1
- import { defineComponent, h, useFocus, useInput, useTheme } from '@textui/core';
1
+ import { defineComponent, h, useFocus, useI18n, useInput, useTheme } from '@textui/core';
2
2
  export const Pagination = defineComponent('Pagination', (props) => {
3
3
  const theme = useTheme();
4
+ const i18n = useI18n();
4
5
  const { page, pageCount, total, onChange, ...rest } = props;
5
6
  const focus = useFocus({});
6
7
  useInput((event) => {
@@ -14,5 +15,8 @@ export const Pagination = defineComponent('Pagination', (props) => {
14
15
  }
15
16
  return false;
16
17
  }, { focusId: focus.id });
17
- return h('box', { id: focus.id, direction: 'row', gap: 1, ...rest }, h('text', { content: theme.glyphs.chevronLeft, fg: page > 1 ? 'accent' : 'disabled' }), h('text', { content: `${page} / ${pageCount}`, bold: focus.focused }), h('text', { content: theme.glyphs.chevronRight, fg: page < pageCount ? 'accent' : 'disabled' }), total !== undefined ? h('text', { content: `${total} items`, fg: 'muted' }) : null);
18
+ return h('box', { id: focus.id, direction: 'row', gap: 1, ...rest }, h('text', { content: theme.glyphs.chevronLeft, fg: page > 1 ? 'accent' : 'disabled' }), h('text', { content: `${page} / ${pageCount}`, bold: focus.focused }), h('text', { content: theme.glyphs.chevronRight, fg: page < pageCount ? 'accent' : 'disabled' }), total !== undefined ? h('text', { content: i18n.plural(total, {
19
+ one: i18n.t('textui.pagination.total.one', undefined, '{count} item'),
20
+ other: i18n.t('textui.pagination.total.other', undefined, '{count} items'),
21
+ }), fg: 'muted' }) : null);
18
22
  });
@@ -1,4 +1,6 @@
1
1
  import type { BoxProps, SemanticVariant } from '@textui/core';
2
+ /** The name a theme styles a tree row under. See `LIST`. */
3
+ export declare const TREE = "Tree";
2
4
  export interface TreeNode {
3
5
  id: string;
4
6
  label: string;
@@ -1 +1 @@
1
- {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/data/tree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAc9D,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;IACtB,6CAA6C;IAC7C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,SAAU,SAAQ,QAAQ;IACzC,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CA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AAE,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC5C,UAAU,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC9C,QAAQ,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qEAAqE;IACrE,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAmBD,eAAO,MAAM,IAAI,2DAyJf,CAAC"}
package/dist/data/tree.js CHANGED
@@ -2,6 +2,8 @@ import { chorded, defineComponent, h, useFocus, useInput, useMeasure, useTheme,
2
2
  import { usePanelState } from '../panel/index.js';
3
3
  import { TONE } from '../tone.js';
4
4
  import { viewportRows } from '../viewport.js';
5
+ /** The name a theme styles a tree row under. See `LIST`. */
6
+ export const TREE = 'Tree';
5
7
  function flatten(nodes, expanded, depth = 0, out = []) {
6
8
  for (const node of nodes) {
7
9
  const expandable = Boolean(node.hasChildren || (node.children && node.children.length > 0));
@@ -135,11 +137,15 @@ export const Tree = defineComponent('Tree', (props) => {
135
137
  key: row.node.id,
136
138
  role: 'treeitem',
137
139
  label: row.node.label,
140
+ styleAs: TREE,
138
141
  selected: active,
142
+ // The keyboard is the tree's; the row is told which row it lands on.
143
+ focused: active && focus.focused,
139
144
  direction: 'row',
140
145
  gap: 1,
141
- bg: active && focus.focused ? 'selected' : active ? 'active' : undefined,
142
- fg: active && focus.focused ? 'inverted' : undefined,
146
+ // What the row is filled with is the theme's to say - `Tree.selected`
147
+ // for the current row and `Tree.focused` over it while the tree has
148
+ // the keyboard - as it is for a list, a table and a menu.
143
149
  onClick: () => {
144
150
  if (selectedId === undefined)
145
151
  setInternalSelected(row.node.id);
@@ -1 +1 @@
1
- {"version":3,"file":"card.d.ts","sourceRoot":"","sources":["../../src/display/card.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG7C,MAAM,WAAW,SAAU,SAAQ,QAAQ;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,IAAI,2DAaf,CAAC"}
1
+ {"version":3,"file":"card.d.ts","sourceRoot":"","sources":["../../src/display/card.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG7C,MAAM,WAAW,SAAU,SAAQ,QAAQ;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,IAAI,2DAyBf,CAAC"}
@@ -4,6 +4,18 @@ export const Card = defineComponent('Card', (props) => {
4
4
  const { title, subtitle, children, ...rest } = props;
5
5
  return h('box', {
6
6
  border: theme.border,
7
+ /*
8
+ * A card is a surface, so it states a background and is opaque.
9
+ *
10
+ * A bordered box that states none is a frame around whatever is already
11
+ * there, and what is already there can be a pattern, a scrim or a
12
+ * neighbouring block - a card dropped on a pattern showed the pattern
13
+ * through its own interior, which reads as a hole rather than as something
14
+ * laid on top. `Dialog` and `CommandPalette` have always stated `overlay`
15
+ * for the same reason; this is the page-level one. `...rest` still wins, so
16
+ * a caller that wants a different colour names it.
17
+ */
18
+ bg: 'surface',
7
19
  padding: theme.density === 'compact' ? 0 : [0, 1],
8
20
  direction: 'column',
9
21
  title,
@@ -1,4 +1,4 @@
1
- import type { CellStyle, Color, RenderContext, StyleColor, TextProps } from '@textui/core';
1
+ import type { CellStyle, Color, Style, RenderContext, StyleColor, TextProps } from '@textui/core';
2
2
  /**
3
3
  * One cell, as the ink sees it.
4
4
  *
@@ -154,5 +154,17 @@ export declare function blend(a: Color, b: Color, t: number): Color;
154
154
  * Exported so a component that paints its own cells - a chart, a viewer with a
155
155
  * heat column - can take an `Ink` and mean the same thing by it.
156
156
  */
157
+ /**
158
+ * A component's own style, resolved for the state it is in.
159
+ *
160
+ * A canvas is not told what it was nested in, so a component that paints its
161
+ * own cells cannot inherit the way a `text` does: it resolves the props it was
162
+ * given against the theme, and hands the result to every cell the ink declines.
163
+ * Exported beside `painterOf` so a second painter means the same thing by it -
164
+ * `ColorText` and `Pattern` both paint their own cells and read the same way.
165
+ */
166
+ export declare function inkOwnStyle(props: Record<string, unknown>, ctx: RenderContext): Style;
167
+ /** The cell style a canvas painter starts from, given that own style. */
168
+ export declare function inkCellStyle(own: Style, ctx: RenderContext, link?: unknown): CellStyle;
157
169
  export declare function painterOf(ink: Ink | undefined, ctx: RenderContext): (cell: InkCell) => CellStyle | undefined;
158
170
  //# sourceMappingURL=color-text.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"color-text.d.ts","sourceRoot":"","sources":["../../src/display/color-text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EAAE,KAAK,EAChB,aAAa,EAAE,UAAU,EAAE,SAAS,EACrC,MAAM,cAAc,CAAC;AAOtB;;;;;;;;;GASG;AACH,MAAM,WAAW,OAAO;IACtB,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,0BAA0B;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,UAAU,EAAE,MA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ACvB,GAAG,EAAE,GAAG,GAAG,SAAS,EACpB,GAAG,EAAE,aAAa,GACjB,CAAC,IAAI,EAAE,OAAO,KAAK,SAAS,GAAG,SAAS,CA+D1C"}
@@ -45,12 +45,9 @@ export const ColorText = defineComponent('ColorText', (props) => {
45
45
  return;
46
46
  // The component's own style, resolved for the state it is in. Not the
47
47
  // inherited one - a canvas is not told what it was nested in.
48
- const own = mergeStyles(styleFromProps(props), flattenStyleInput(props.style, stateOf(ctx)));
49
- const rest = {
50
- fg: resolveColor(own.fg, ctx.theme, 'default'),
51
- attrs: attrsFromStyle(own),
52
- link: typeof props.link === 'string' ? props.link : undefined,
53
- };
48
+ const ownProps = props;
49
+ const own = inkOwnStyle(ownProps, ctx);
50
+ const rest = inkCellStyle(own, ctx, props.link);
54
51
  const cut = props.truncate ?? truncateSideOf(wrap) ?? 'end';
55
52
  const dots = ellipsis ?? ctx.theme.glyphs.ellipsis;
56
53
  const lines = linesOf(source, wrap, area).map((line) => (stringWidth(line) > area && cut !== false ? truncate(line, area, dots, cut) : line));
@@ -114,9 +111,34 @@ export function blend(a, b, t) {
114
111
  * Exported so a component that paints its own cells - a chart, a viewer with a
115
112
  * heat column - can take an `Ink` and mean the same thing by it.
116
113
  */
114
+ /**
115
+ * A component's own style, resolved for the state it is in.
116
+ *
117
+ * A canvas is not told what it was nested in, so a component that paints its
118
+ * own cells cannot inherit the way a `text` does: it resolves the props it was
119
+ * given against the theme, and hands the result to every cell the ink declines.
120
+ * Exported beside `painterOf` so a second painter means the same thing by it -
121
+ * `ColorText` and `Pattern` both paint their own cells and read the same way.
122
+ */
123
+ export function inkOwnStyle(props, ctx) {
124
+ return mergeStyles(styleFromProps(props), flattenStyleInput(props.style, stateOf(ctx)));
125
+ }
126
+ /** The cell style a canvas painter starts from, given that own style. */
127
+ export function inkCellStyle(own, ctx, link) {
128
+ return {
129
+ fg: resolveColor(own.fg, ctx.theme, 'default'),
130
+ attrs: attrsFromStyle(own),
131
+ link: typeof link === 'string' ? link : undefined,
132
+ };
133
+ }
117
134
  export function painterOf(ink, ctx) {
118
135
  if (ink === undefined)
119
136
  return () => undefined;
137
+ // A theme with no colour has no inks, and this is not only faster: a ramp
138
+ // whose stops all resolve to the terminal's own still has to be *mixed*, and
139
+ // mixing "no colour" with itself lands on black - which is a colour.
140
+ if (ctx.theme.monochrome)
141
+ return () => undefined;
120
142
  if (typeof ink === 'function') {
121
143
  return (cell) => styleOf(ink(cell, ctx), ctx);
122
144
  }
@@ -1 +1 @@
1
- {"version":3,"file":"error-state.d.ts","sourceRoot":"","sources":["../../src/display/error-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG7C,MAAM,WAAW,eAAgB,SAAQ,QAAQ;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,eAAO,MAAM,UAAU,iEAYrB,CAAC"}
1
+ {"version":3,"file":"error-state.d.ts","sourceRoot":"","sources":["../../src/display/error-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG7C,MAAM,WAAW,eAAgB,SAAQ,QAAQ;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,eAAO,MAAM,UAAU,iEAarB,CAAC"}
@@ -1,7 +1,8 @@
1
- import { defineComponent, h, useTheme } from '@textui/core';
1
+ import { defineComponent, h, useI18n, useTheme } from '@textui/core';
2
2
  export const ErrorState = defineComponent('ErrorState', (props) => {
3
3
  const theme = useTheme();
4
- const { title = 'Something went wrong', error, onRetry, ...rest } = props;
4
+ const i18n = useI18n();
5
+ const { title = i18n.t('textui.errorState.title', undefined, 'Something went wrong'), error, onRetry, ...rest } = props;
5
6
  const message = error instanceof Error ? error.message : String(error);
6
- return h('box', { role: 'alert', direction: 'column', gap: 1, padding: 1, ...rest }, h('box', { direction: 'row', gap: 1 }, h('text', { content: theme.glyphs.cross, fg: 'danger' }), h('text', { content: title, bold: true, fg: 'danger' })), h('text', { content: message, fg: 'muted', wrap: 'word' }), onRetry ? h('text', { content: 'r retry', fg: 'subtle' }) : null);
7
+ return h('box', { role: 'alert', direction: 'column', gap: 1, padding: 1, ...rest }, h('box', { direction: 'row', gap: 1 }, h('text', { content: theme.glyphs.cross, fg: 'danger' }), h('text', { content: title, bold: true, fg: 'danger' })), h('text', { content: message, fg: 'muted', wrap: 'word' }), onRetry ? h('text', { content: i18n.t('textui.errorState.retry', undefined, 'r retry'), fg: 'subtle' }) : null);
7
8
  });