hedgequantx 1.1.1

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.
@@ -0,0 +1,48 @@
1
+ /**
2
+ * UI Module Exports
3
+ */
4
+
5
+ const { detectDevice, getDevice, getSeparator } = require('./device');
6
+ const {
7
+ getLogoWidth,
8
+ visibleLength,
9
+ centerText,
10
+ padText,
11
+ drawBoxHeader,
12
+ drawBoxFooter,
13
+ drawBoxRow,
14
+ drawBoxSeparator,
15
+ printLogo
16
+ } = require('./box');
17
+ const {
18
+ getColWidths,
19
+ draw2ColHeader,
20
+ draw2ColRow,
21
+ draw2ColRowRaw,
22
+ draw2ColSeparator,
23
+ fmtRow
24
+ } = require('./table');
25
+
26
+ module.exports = {
27
+ // Device
28
+ detectDevice,
29
+ getDevice,
30
+ getSeparator,
31
+ // Box
32
+ getLogoWidth,
33
+ visibleLength,
34
+ centerText,
35
+ padText,
36
+ drawBoxHeader,
37
+ drawBoxFooter,
38
+ drawBoxRow,
39
+ drawBoxSeparator,
40
+ printLogo,
41
+ // Table
42
+ getColWidths,
43
+ draw2ColHeader,
44
+ draw2ColRow,
45
+ draw2ColRowRaw,
46
+ draw2ColSeparator,
47
+ fmtRow
48
+ };
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Table Drawing Utilities (2-column layout)
3
+ */
4
+
5
+ const chalk = require('chalk');
6
+ const { getLogoWidth, visibleLength, centerText, padText } = require('./box');
7
+
8
+ /**
9
+ * Calculate column widths for 2-column layout
10
+ */
11
+ const getColWidths = (boxWidth) => {
12
+ const innerWidth = boxWidth - 2;
13
+ const col1 = Math.floor((innerWidth - 1) / 2);
14
+ const col2 = innerWidth - 1 - col1;
15
+ return { col1, col2, innerWidth };
16
+ };
17
+
18
+ /**
19
+ * Draw 2-column header with titles
20
+ */
21
+ const draw2ColHeader = (title1, title2, boxWidth) => {
22
+ const { col1, col2 } = getColWidths(boxWidth);
23
+ const h1 = centerText(title1, col1);
24
+ const h2 = centerText(title2, col2);
25
+ console.log(chalk.cyan('\u2551') + chalk.cyan.bold(h1) + chalk.cyan('\u2502') + chalk.cyan.bold(h2) + chalk.cyan('\u2551'));
26
+ console.log(chalk.cyan('\u2560') + chalk.cyan('\u2500'.repeat(col1)) + chalk.cyan('\u253C') + chalk.cyan('\u2500'.repeat(col2)) + chalk.cyan('\u2563'));
27
+ };
28
+
29
+ /**
30
+ * Draw 2-column data row with label:value pairs
31
+ */
32
+ const draw2ColRow = (label1, value1, label2, value2, boxWidth) => {
33
+ const { col1, col2 } = getColWidths(boxWidth);
34
+ const labelWidth = 18;
35
+
36
+ let c1Content = ' ' + (label1 || '').padEnd(labelWidth) + (value1 || '');
37
+ c1Content = padText(c1Content, col1);
38
+
39
+ let c2Content = ' ' + (label2 || '').padEnd(labelWidth) + (value2 || '');
40
+ c2Content = padText(c2Content, col2);
41
+
42
+ console.log(chalk.cyan('\u2551') + c1Content + chalk.cyan('\u2502') + c2Content + chalk.cyan('\u2551'));
43
+ };
44
+
45
+ /**
46
+ * Draw 2-column row with raw content
47
+ */
48
+ const draw2ColRowRaw = (content1, content2, boxWidth) => {
49
+ const { col1, col2 } = getColWidths(boxWidth);
50
+ const c1 = padText(content1 || '', col1);
51
+ const c2 = padText(content2 || '', col2);
52
+ console.log(chalk.cyan('\u2551') + c1 + chalk.cyan('\u2502') + c2 + chalk.cyan('\u2551'));
53
+ };
54
+
55
+ /**
56
+ * Draw separator between 2-column sections
57
+ */
58
+ const draw2ColSeparator = (boxWidth) => {
59
+ const { col1, col2 } = getColWidths(boxWidth);
60
+ console.log(chalk.cyan('\u2560') + chalk.cyan('\u2550'.repeat(col1)) + chalk.cyan('\u256A') + chalk.cyan('\u2550'.repeat(col2)) + chalk.cyan('\u2563'));
61
+ };
62
+
63
+ /**
64
+ * Format a row with label and value, padded to column width
65
+ */
66
+ const fmtRow = (label, value, colWidth) => {
67
+ const labelStr = ' ' + label.padEnd(18);
68
+ const valueVisible = (value || '').toString().replace(/\x1b\[[0-9;]*m/g, '');
69
+ const totalVisible = labelStr.length + valueVisible.length;
70
+ const padding = Math.max(0, colWidth - totalVisible);
71
+ return chalk.white(labelStr) + value + ' '.repeat(padding);
72
+ };
73
+
74
+ module.exports = {
75
+ getColWidths,
76
+ draw2ColHeader,
77
+ draw2ColRow,
78
+ draw2ColRowRaw,
79
+ draw2ColSeparator,
80
+ fmtRow
81
+ };