cli-menu-kit 0.1.21 → 0.1.22
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.
|
@@ -39,7 +39,7 @@ function wrapText(text, maxWidth) {
|
|
|
39
39
|
* @param config - Summary table configuration
|
|
40
40
|
*/
|
|
41
41
|
function renderSummaryTable(config) {
|
|
42
|
-
const { title, sections, width } = config;
|
|
42
|
+
const { title, titleAlign = 'center', sections, width } = config;
|
|
43
43
|
const termWidth = (0, terminal_js_2.getTerminalWidth)();
|
|
44
44
|
// Use full terminal width minus padding, or specified width
|
|
45
45
|
const boxWidth = width || Math.max(60, termWidth - 4);
|
|
@@ -51,9 +51,25 @@ function renderSummaryTable(config) {
|
|
|
51
51
|
(0, terminal_js_1.writeLine)(`│${' '.repeat(boxWidth - 2)}│`);
|
|
52
52
|
// Title if provided
|
|
53
53
|
if (title) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
let titleLine;
|
|
55
|
+
let remainingSpace;
|
|
56
|
+
if (titleAlign === 'left') {
|
|
57
|
+
titleLine = ` ${colors_js_1.colors.cyan}${title}${colors_js_1.colors.reset}`;
|
|
58
|
+
const plainTitle = title;
|
|
59
|
+
remainingSpace = boxWidth - plainTitle.length - 4;
|
|
60
|
+
}
|
|
61
|
+
else if (titleAlign === 'right') {
|
|
62
|
+
const plainTitle = title;
|
|
63
|
+
const rightPadding = contentWidth - plainTitle.length;
|
|
64
|
+
titleLine = ' '.repeat(rightPadding + 2) + colors_js_1.colors.cyan + title + colors_js_1.colors.reset;
|
|
65
|
+
remainingSpace = 2;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
// center (default)
|
|
69
|
+
const titlePadding = Math.floor((contentWidth - title.length) / 2);
|
|
70
|
+
titleLine = ' '.repeat(titlePadding + 2) + colors_js_1.colors.cyan + title + colors_js_1.colors.reset;
|
|
71
|
+
remainingSpace = boxWidth - titlePadding - title.length - 4;
|
|
72
|
+
}
|
|
57
73
|
(0, terminal_js_1.writeLine)(`│${titleLine}${' '.repeat(remainingSpace)}│`);
|
|
58
74
|
(0, terminal_js_1.writeLine)(`│${' '.repeat(boxWidth - 2)}│`);
|
|
59
75
|
}
|
package/package.json
CHANGED