cli-menu-kit 0.1.26 → 0.2.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.
Files changed (78) hide show
  1. package/dist/api.d.ts +23 -5
  2. package/dist/api.js +16 -4
  3. package/dist/component-factories.d.ts +59 -0
  4. package/dist/component-factories.js +141 -0
  5. package/dist/components/display/header-v2.d.ts +13 -0
  6. package/dist/components/display/header-v2.js +43 -0
  7. package/dist/components/display/header.d.ts +40 -0
  8. package/dist/components/display/header.js +331 -18
  9. package/dist/components/display/headers.d.ts +1 -0
  10. package/dist/components/display/headers.js +15 -5
  11. package/dist/components/display/hints-v2.d.ts +10 -0
  12. package/dist/components/display/hints-v2.js +34 -0
  13. package/dist/components/display/hints.d.ts +56 -0
  14. package/dist/components/display/hints.js +81 -0
  15. package/dist/components/display/index.d.ts +4 -1
  16. package/dist/components/display/index.js +17 -1
  17. package/dist/components/display/input-prompt.d.ts +35 -0
  18. package/dist/components/display/input-prompt.js +36 -0
  19. package/dist/components/display/list.d.ts +49 -0
  20. package/dist/components/display/list.js +86 -0
  21. package/dist/components/display/messages.js +5 -5
  22. package/dist/components/display/progress.d.ts +17 -0
  23. package/dist/components/display/progress.js +18 -0
  24. package/dist/components/display/summary.js +72 -10
  25. package/dist/components/display/table.d.ts +44 -0
  26. package/dist/components/display/table.js +108 -0
  27. package/dist/components/inputs/language-input.js +8 -5
  28. package/dist/components/inputs/number-input.js +19 -14
  29. package/dist/components/inputs/text-input.js +50 -13
  30. package/dist/components/menus/boolean-menu.js +34 -20
  31. package/dist/components/menus/checkbox-menu.d.ts +2 -1
  32. package/dist/components/menus/checkbox-menu.js +35 -61
  33. package/dist/components/menus/checkbox-table-menu.d.ts +12 -0
  34. package/dist/components/menus/checkbox-table-menu.js +398 -0
  35. package/dist/components/menus/index.d.ts +1 -0
  36. package/dist/components/menus/index.js +3 -1
  37. package/dist/components/menus/radio-menu-split.d.ts +34 -0
  38. package/dist/components/menus/radio-menu-split.js +258 -0
  39. package/dist/components/menus/radio-menu-v2.d.ts +11 -0
  40. package/dist/components/menus/radio-menu-v2.js +150 -0
  41. package/dist/components/menus/radio-menu.d.ts +2 -1
  42. package/dist/components/menus/radio-menu.js +100 -134
  43. package/dist/components.js +3 -3
  44. package/dist/config/index.d.ts +5 -0
  45. package/dist/config/index.js +21 -0
  46. package/dist/config/language-config.d.ts +73 -0
  47. package/dist/config/language-config.js +157 -0
  48. package/dist/config/user-config.d.ts +83 -0
  49. package/dist/config/user-config.js +185 -0
  50. package/dist/core/colors.d.ts +24 -18
  51. package/dist/core/colors.js +74 -7
  52. package/dist/core/hint-manager.d.ts +29 -0
  53. package/dist/core/hint-manager.js +65 -0
  54. package/dist/core/renderer.d.ts +2 -1
  55. package/dist/core/renderer.js +46 -22
  56. package/dist/core/screen-manager.d.ts +54 -0
  57. package/dist/core/screen-manager.js +119 -0
  58. package/dist/core/state-manager.d.ts +27 -0
  59. package/dist/core/state-manager.js +56 -0
  60. package/dist/core/terminal.d.ts +17 -1
  61. package/dist/core/terminal.js +124 -4
  62. package/dist/core/virtual-scroll.d.ts +65 -0
  63. package/dist/core/virtual-scroll.js +120 -0
  64. package/dist/features/commands.js +23 -22
  65. package/dist/i18n/languages/en.js +4 -1
  66. package/dist/i18n/languages/zh.js +4 -1
  67. package/dist/i18n/registry.d.ts +4 -3
  68. package/dist/i18n/registry.js +12 -4
  69. package/dist/i18n/types.d.ts +3 -0
  70. package/dist/index.d.ts +7 -4
  71. package/dist/index.js +49 -4
  72. package/dist/layout.d.ts +67 -0
  73. package/dist/layout.js +86 -0
  74. package/dist/page-layout.d.ts +123 -0
  75. package/dist/page-layout.js +195 -0
  76. package/dist/types/input.types.d.ts +8 -0
  77. package/dist/types/menu.types.d.ts +61 -5
  78. package/package.json +4 -1
package/dist/api.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * Provides a simple, consistent API for all components
4
4
  */
5
5
  import { WizardConfig, WizardResult } from './features/wizard.js';
6
- import { RadioMenuConfig, CheckboxMenuConfig, BooleanMenuConfig, RadioMenuResult, CheckboxMenuResult, BooleanMenuResult } from './types/menu.types.js';
6
+ import { RadioMenuConfig, CheckboxMenuConfig, CheckboxTableMenuConfig, BooleanMenuConfig, RadioMenuResult, CheckboxMenuResult, CheckboxTableMenuResult, BooleanMenuResult } from './types/menu.types.js';
7
7
  import { TextInputConfig, NumberInputConfig, LanguageSelectorConfig, ModifyFieldConfig, TextInputResult, NumberInputResult, LanguageSelectorResult, ModifyFieldResult } from './types/input.types.js';
8
8
  /**
9
9
  * Unified menu API
@@ -12,15 +12,24 @@ export declare const menuAPI: {
12
12
  /**
13
13
  * Show a radio menu (single-select)
14
14
  * @param config - Menu configuration
15
+ * @param hints - Optional hints for Page Layout footer
15
16
  * @returns Promise resolving to selected option
16
17
  */
17
- radio: (config: RadioMenuConfig) => Promise<RadioMenuResult>;
18
+ radio: (config: RadioMenuConfig, hints?: string[]) => Promise<RadioMenuResult>;
18
19
  /**
19
20
  * Show a checkbox menu (multi-select)
20
21
  * @param config - Menu configuration
22
+ * @param hints - Optional hints for Page Layout footer
21
23
  * @returns Promise resolving to selected options
22
24
  */
23
- checkbox: (config: CheckboxMenuConfig) => Promise<CheckboxMenuResult>;
25
+ checkbox: (config: CheckboxMenuConfig, hints?: string[]) => Promise<CheckboxMenuResult>;
26
+ /**
27
+ * Show a checkbox table menu (multi-select with table display)
28
+ * @param config - Menu configuration
29
+ * @param hints - Optional hints for Page Layout footer
30
+ * @returns Promise resolving to selected rows
31
+ */
32
+ checkboxTable: (config: CheckboxTableMenuConfig, hints?: string[]) => Promise<CheckboxTableMenuResult>;
24
33
  /**
25
34
  * Show a boolean menu (yes/no)
26
35
  * @param config - Menu configuration
@@ -90,15 +99,24 @@ declare const _default: {
90
99
  /**
91
100
  * Show a radio menu (single-select)
92
101
  * @param config - Menu configuration
102
+ * @param hints - Optional hints for Page Layout footer
93
103
  * @returns Promise resolving to selected option
94
104
  */
95
- radio: (config: RadioMenuConfig) => Promise<RadioMenuResult>;
105
+ radio: (config: RadioMenuConfig, hints?: string[]) => Promise<RadioMenuResult>;
96
106
  /**
97
107
  * Show a checkbox menu (multi-select)
98
108
  * @param config - Menu configuration
109
+ * @param hints - Optional hints for Page Layout footer
99
110
  * @returns Promise resolving to selected options
100
111
  */
101
- checkbox: (config: CheckboxMenuConfig) => Promise<CheckboxMenuResult>;
112
+ checkbox: (config: CheckboxMenuConfig, hints?: string[]) => Promise<CheckboxMenuResult>;
113
+ /**
114
+ * Show a checkbox table menu (multi-select with table display)
115
+ * @param config - Menu configuration
116
+ * @param hints - Optional hints for Page Layout footer
117
+ * @returns Promise resolving to selected rows
118
+ */
119
+ checkboxTable: (config: CheckboxTableMenuConfig, hints?: string[]) => Promise<CheckboxTableMenuResult>;
102
120
  /**
103
121
  * Show a boolean menu (yes/no)
104
122
  * @param config - Menu configuration
package/dist/api.js CHANGED
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.wizardAPI = exports.inputAPI = exports.menuAPI = void 0;
8
8
  const radio_menu_js_1 = require("./components/menus/radio-menu.js");
9
9
  const checkbox_menu_js_1 = require("./components/menus/checkbox-menu.js");
10
+ const checkbox_table_menu_js_1 = require("./components/menus/checkbox-table-menu.js");
10
11
  const boolean_menu_js_1 = require("./components/menus/boolean-menu.js");
11
12
  const text_input_js_1 = require("./components/inputs/text-input.js");
12
13
  const number_input_js_1 = require("./components/inputs/number-input.js");
@@ -20,18 +21,29 @@ exports.menuAPI = {
20
21
  /**
21
22
  * Show a radio menu (single-select)
22
23
  * @param config - Menu configuration
24
+ * @param hints - Optional hints for Page Layout footer
23
25
  * @returns Promise resolving to selected option
24
26
  */
25
- radio: (config) => {
26
- return (0, radio_menu_js_1.showRadioMenu)(config);
27
+ radio: (config, hints) => {
28
+ return (0, radio_menu_js_1.showRadioMenu)(config, hints);
27
29
  },
28
30
  /**
29
31
  * Show a checkbox menu (multi-select)
30
32
  * @param config - Menu configuration
33
+ * @param hints - Optional hints for Page Layout footer
31
34
  * @returns Promise resolving to selected options
32
35
  */
33
- checkbox: (config) => {
34
- return (0, checkbox_menu_js_1.showCheckboxMenu)(config);
36
+ checkbox: (config, hints) => {
37
+ return (0, checkbox_menu_js_1.showCheckboxMenu)(config, hints);
38
+ },
39
+ /**
40
+ * Show a checkbox table menu (multi-select with table display)
41
+ * @param config - Menu configuration
42
+ * @param hints - Optional hints for Page Layout footer
43
+ * @returns Promise resolving to selected rows
44
+ */
45
+ checkboxTable: (config, hints) => {
46
+ return (0, checkbox_table_menu_js_1.showCheckboxTableMenu)(config, hints);
35
47
  },
36
48
  /**
37
49
  * Show a boolean menu (yes/no)
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Component Factories
3
+ *
4
+ * Factory functions to create common components
5
+ * These are helper functions to simplify component creation
6
+ *
7
+ * NOTE: These are legacy factories that need to be updated to return string arrays
8
+ * For now, they are kept for backward compatibility but will be deprecated
9
+ */
10
+ import type { HeaderConfig } from './components/display/header.js';
11
+ import type { TableConfig } from './components/display/table.js';
12
+ import type { ListConfig } from './components/display/list.js';
13
+ import type { SummaryTableConfig } from './types/display.types.js';
14
+ import type { RadioMenuConfig } from './types/menu.types.js';
15
+ /**
16
+ * Create a full header component (with ASCII art)
17
+ * LEGACY: Returns void, needs update to return string[]
18
+ */
19
+ export declare function createFullHeaderComponent(config: HeaderConfig): any;
20
+ /**
21
+ * Create a simple header component
22
+ * LEGACY: Returns void, needs update to return string[]
23
+ */
24
+ export declare function createSimpleHeaderComponent(text: string): any;
25
+ /**
26
+ * Create a section header component
27
+ * LEGACY: Returns void, needs update to return string[]
28
+ */
29
+ export declare function createSectionHeaderComponent(text: string, width?: number): any;
30
+ /**
31
+ * Create a hints component
32
+ * LEGACY: Returns void, needs update to return string[]
33
+ */
34
+ export declare function createHintsComponent(hints: string[]): any;
35
+ /**
36
+ * Create a table component
37
+ * LEGACY: Returns void, needs update to return string[]
38
+ */
39
+ export declare function createTableComponent(config: TableConfig): any;
40
+ /**
41
+ * Create a list component
42
+ * LEGACY: Returns void, needs update to return string[]
43
+ */
44
+ export declare function createListComponent(config: ListConfig): any;
45
+ /**
46
+ * Create a summary table component
47
+ * LEGACY: Returns void, needs update to return string[]
48
+ */
49
+ export declare function createSummaryTableComponent(config: SummaryTableConfig): any;
50
+ /**
51
+ * Export input prompt component creator
52
+ */
53
+ export { createInputPromptComponent } from './components/display/input-prompt.js';
54
+ /**
55
+ * Create an interactive menu component (radio menu)
56
+ * Separates rendering and interaction for proper Page Layout integration
57
+ * LEGACY: Needs update to use new architecture
58
+ */
59
+ export declare function createRadioMenuComponent(config: RadioMenuConfig, onResult: (result: any) => void | Promise<void>): any;
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ /**
3
+ * Component Factories
4
+ *
5
+ * Factory functions to create common components
6
+ * These are helper functions to simplify component creation
7
+ *
8
+ * NOTE: These are legacy factories that need to be updated to return string arrays
9
+ * For now, they are kept for backward compatibility but will be deprecated
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.createInputPromptComponent = void 0;
13
+ exports.createFullHeaderComponent = createFullHeaderComponent;
14
+ exports.createSimpleHeaderComponent = createSimpleHeaderComponent;
15
+ exports.createSectionHeaderComponent = createSectionHeaderComponent;
16
+ exports.createHintsComponent = createHintsComponent;
17
+ exports.createTableComponent = createTableComponent;
18
+ exports.createListComponent = createListComponent;
19
+ exports.createSummaryTableComponent = createSummaryTableComponent;
20
+ exports.createRadioMenuComponent = createRadioMenuComponent;
21
+ const header_js_1 = require("./components/display/header.js");
22
+ const headers_js_1 = require("./components/display/headers.js");
23
+ const renderer_js_1 = require("./core/renderer.js");
24
+ const table_js_1 = require("./components/display/table.js");
25
+ const list_js_1 = require("./components/display/list.js");
26
+ const summary_js_1 = require("./components/display/summary.js");
27
+ const radio_menu_split_js_1 = require("./components/menus/radio-menu-split.js");
28
+ /**
29
+ * Create a full header component (with ASCII art)
30
+ * LEGACY: Returns void, needs update to return string[]
31
+ */
32
+ function createFullHeaderComponent(config) {
33
+ return {
34
+ type: 'full-header',
35
+ regionId: 'header',
36
+ render: () => (0, header_js_1.renderHeader)(config),
37
+ config
38
+ };
39
+ }
40
+ /**
41
+ * Create a simple header component
42
+ * LEGACY: Returns void, needs update to return string[]
43
+ */
44
+ function createSimpleHeaderComponent(text) {
45
+ return {
46
+ type: 'simple-header',
47
+ regionId: 'header',
48
+ render: () => (0, headers_js_1.renderSimpleHeader)(text),
49
+ config: { text }
50
+ };
51
+ }
52
+ /**
53
+ * Create a section header component
54
+ * LEGACY: Returns void, needs update to return string[]
55
+ */
56
+ function createSectionHeaderComponent(text, width) {
57
+ return {
58
+ type: 'section-header',
59
+ regionId: 'header',
60
+ render: () => (0, headers_js_1.renderSectionHeader)(text, width || 50),
61
+ config: { text, width }
62
+ };
63
+ }
64
+ /**
65
+ * Create a hints component
66
+ * LEGACY: Returns void, needs update to return string[]
67
+ */
68
+ function createHintsComponent(hints) {
69
+ return {
70
+ type: 'hints',
71
+ regionId: 'footerHints',
72
+ render: () => (0, renderer_js_1.renderHints)(hints),
73
+ config: { hints }
74
+ };
75
+ }
76
+ /**
77
+ * Create a table component
78
+ * LEGACY: Returns void, needs update to return string[]
79
+ */
80
+ function createTableComponent(config) {
81
+ return {
82
+ type: 'table',
83
+ regionId: 'main',
84
+ render: () => (0, table_js_1.renderTable)(config),
85
+ config
86
+ };
87
+ }
88
+ /**
89
+ * Create a list component
90
+ * LEGACY: Returns void, needs update to return string[]
91
+ */
92
+ function createListComponent(config) {
93
+ return {
94
+ type: 'list',
95
+ regionId: 'main',
96
+ render: () => (0, list_js_1.renderList)(config),
97
+ config
98
+ };
99
+ }
100
+ /**
101
+ * Create a summary table component
102
+ * LEGACY: Returns void, needs update to return string[]
103
+ */
104
+ function createSummaryTableComponent(config) {
105
+ return {
106
+ type: 'summary-table',
107
+ regionId: 'main',
108
+ render: () => (0, summary_js_1.renderSummaryTable)(config),
109
+ config
110
+ };
111
+ }
112
+ /**
113
+ * Export input prompt component creator
114
+ */
115
+ var input_prompt_js_1 = require("./components/display/input-prompt.js");
116
+ Object.defineProperty(exports, "createInputPromptComponent", { enumerable: true, get: function () { return input_prompt_js_1.createInputPromptComponent; } });
117
+ /**
118
+ * Create an interactive menu component (radio menu)
119
+ * Separates rendering and interaction for proper Page Layout integration
120
+ * LEGACY: Needs update to use new architecture
121
+ */
122
+ function createRadioMenuComponent(config, onResult) {
123
+ let menuState = null;
124
+ return {
125
+ type: 'radio-menu',
126
+ regionId: 'main',
127
+ render: () => {
128
+ // Render menu UI (non-blocking)
129
+ menuState = (0, radio_menu_split_js_1.renderRadioMenuUI)(config);
130
+ },
131
+ interact: async () => {
132
+ // Wait for user input (blocking)
133
+ if (!menuState) {
134
+ throw new Error('Menu must be rendered before interaction');
135
+ }
136
+ const result = await (0, radio_menu_split_js_1.waitForRadioMenuInput)(menuState);
137
+ await onResult(result);
138
+ },
139
+ config
140
+ };
141
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Full Header Component - New Architecture Version
3
+ * Returns string arrays instead of writing to stdout
4
+ */
5
+ import { Component } from '../../layout.js';
6
+ export interface FullHeaderConfig {
7
+ asciiArt: string[];
8
+ title: string;
9
+ description?: string;
10
+ version?: string;
11
+ url?: string;
12
+ }
13
+ export declare function createFullHeaderComponentV2(config: FullHeaderConfig): Component;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ /**
3
+ * Full Header Component - New Architecture Version
4
+ * Returns string arrays instead of writing to stdout
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.createFullHeaderComponentV2 = createFullHeaderComponentV2;
8
+ const colors_js_1 = require("../../core/colors.js");
9
+ function createFullHeaderComponentV2(config) {
10
+ return {
11
+ type: 'full-header',
12
+ regionId: 'header',
13
+ render: (rect) => {
14
+ const lines = [];
15
+ // ASCII Art
16
+ config.asciiArt.forEach(line => {
17
+ lines.push(`${colors_js_1.colors.cyan}${line}${colors_js_1.colors.reset}`);
18
+ });
19
+ // Empty line
20
+ lines.push('');
21
+ // Title and description
22
+ const titleLine = config.version
23
+ ? `${colors_js_1.colors.bold}${config.title}${colors_js_1.colors.reset} ${colors_js_1.colors.dim}v${config.version}${colors_js_1.colors.reset}`
24
+ : `${colors_js_1.colors.bold}${config.title}${colors_js_1.colors.reset}`;
25
+ lines.push(titleLine);
26
+ if (config.description) {
27
+ lines.push(`${colors_js_1.colors.dim}${config.description}${colors_js_1.colors.reset}`);
28
+ }
29
+ if (config.url) {
30
+ lines.push(`${colors_js_1.colors.dim}${config.url}${colors_js_1.colors.reset}`);
31
+ }
32
+ // Separator
33
+ lines.push('');
34
+ lines.push(`${colors_js_1.colors.dim}${'─'.repeat(Math.min(rect.width, 80))}${colors_js_1.colors.reset}`);
35
+ // Fill remaining lines to match rect height
36
+ while (lines.length < rect.height) {
37
+ lines.push('');
38
+ }
39
+ return lines;
40
+ },
41
+ config
42
+ };
43
+ }
@@ -2,16 +2,39 @@
2
2
  * Header component for CLI applications
3
3
  * Displays ASCII art, title, description, version and URL
4
4
  */
5
+ type FigletSize = 'small' | 'medium' | 'large';
5
6
  /**
6
7
  * Header configuration
7
8
  */
8
9
  export interface HeaderConfig {
9
10
  /** ASCII art lines (array of strings) */
10
11
  asciiArt?: string[];
12
+ /** Generate ASCII art from figlet text (overrides asciiArt when provided) */
13
+ figletText?: string;
14
+ /** Figlet font name (raw figlet name, e.g. "ANSI Shadow", "Standard", "Block") */
15
+ figletFont?: string;
16
+ /** Figlet size preset (default: medium) */
17
+ figletSize?: FigletSize;
18
+ /** Scale figlet output (1-4, default: 1) */
19
+ figletScale?: number;
20
+ /** Optional vertical scale override (0.4-4) */
21
+ figletScaleY?: number;
11
22
  /** Application title */
12
23
  title?: string;
24
+ /** Optional explicit color for title line */
25
+ titleColor?: string;
26
+ /** Optional ANSI start color for title gradient */
27
+ titleGradientStart?: string;
28
+ /** Optional ANSI end color for title gradient */
29
+ titleGradientEnd?: string;
13
30
  /** Application description */
14
31
  description?: string;
32
+ /** Optional explicit color for description line */
33
+ descriptionColor?: string;
34
+ /** Optional ANSI start color for description gradient */
35
+ descriptionGradientStart?: string;
36
+ /** Optional ANSI end color for description gradient */
37
+ descriptionGradientEnd?: string;
15
38
  /** Version number */
16
39
  version?: string;
17
40
  /** Project URL */
@@ -20,11 +43,28 @@ export interface HeaderConfig {
20
43
  menuTitle?: string;
21
44
  /** Box width (default: 60) */
22
45
  boxWidth?: number;
46
+ /** Toggle outer border box (default: true) */
47
+ showBoxBorder?: boolean;
48
+ /** Fill header box content area background (default: false) */
49
+ fillBox?: boolean;
50
+ /** ANSI background color for box fill (default: bgBlack) */
51
+ fillBoxColor?: string;
52
+ /** Optional ANSI background gradient start color for box fill */
53
+ fillBoxGradientStart?: string;
54
+ /** Optional ANSI background gradient end color for box fill */
55
+ fillBoxGradientEnd?: string;
23
56
  /** Header color (default: cyan) */
24
57
  color?: string;
58
+ /** Optional explicit color for ASCII art/logo lines */
59
+ asciiArtColor?: string;
60
+ /** Optional ANSI start color for ASCII art gradient */
61
+ asciiArtGradientStart?: string;
62
+ /** Optional ANSI end color for ASCII art gradient */
63
+ asciiArtGradientEnd?: string;
25
64
  }
26
65
  /**
27
66
  * Render a boxed header with ASCII art, title, and description
28
67
  * @param config - Header configuration
29
68
  */
30
69
  export declare function renderHeader(config: HeaderConfig): void;
70
+ export {};