cli-menu-kit 0.1.26 → 0.2.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.
- package/dist/api.d.ts +23 -5
- package/dist/api.js +16 -4
- package/dist/component-factories.d.ts +59 -0
- package/dist/component-factories.js +141 -0
- package/dist/components/display/header-v2.d.ts +13 -0
- package/dist/components/display/header-v2.js +43 -0
- package/dist/components/display/hints-v2.d.ts +10 -0
- package/dist/components/display/hints-v2.js +34 -0
- package/dist/components/display/hints.d.ts +56 -0
- package/dist/components/display/hints.js +81 -0
- package/dist/components/display/index.d.ts +3 -0
- package/dist/components/display/index.js +15 -1
- package/dist/components/display/input-prompt.d.ts +35 -0
- package/dist/components/display/input-prompt.js +36 -0
- package/dist/components/display/list.d.ts +49 -0
- package/dist/components/display/list.js +86 -0
- package/dist/components/display/table.d.ts +42 -0
- package/dist/components/display/table.js +107 -0
- package/dist/components/menus/boolean-menu.js +2 -1
- package/dist/components/menus/checkbox-menu.d.ts +2 -1
- package/dist/components/menus/checkbox-menu.js +30 -59
- package/dist/components/menus/checkbox-table-menu.d.ts +12 -0
- package/dist/components/menus/checkbox-table-menu.js +395 -0
- package/dist/components/menus/index.d.ts +1 -0
- package/dist/components/menus/index.js +3 -1
- package/dist/components/menus/radio-menu-split.d.ts +33 -0
- package/dist/components/menus/radio-menu-split.js +248 -0
- package/dist/components/menus/radio-menu-v2.d.ts +11 -0
- package/dist/components/menus/radio-menu-v2.js +150 -0
- package/dist/components/menus/radio-menu.d.ts +2 -1
- package/dist/components/menus/radio-menu.js +60 -123
- package/dist/core/hint-manager.d.ts +29 -0
- package/dist/core/hint-manager.js +65 -0
- package/dist/core/renderer.d.ts +2 -1
- package/dist/core/renderer.js +22 -6
- package/dist/core/screen-manager.d.ts +54 -0
- package/dist/core/screen-manager.js +119 -0
- package/dist/core/state-manager.d.ts +27 -0
- package/dist/core/state-manager.js +56 -0
- package/dist/core/terminal.d.ts +4 -1
- package/dist/core/terminal.js +37 -4
- package/dist/core/virtual-scroll.d.ts +65 -0
- package/dist/core/virtual-scroll.js +120 -0
- package/dist/i18n/languages/en.js +4 -1
- package/dist/i18n/languages/zh.js +4 -1
- package/dist/i18n/registry.d.ts +4 -3
- package/dist/i18n/registry.js +12 -4
- package/dist/i18n/types.d.ts +3 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.js +30 -4
- package/dist/layout.d.ts +68 -0
- package/dist/layout.js +134 -0
- package/dist/page-layout.d.ts +92 -0
- package/dist/page-layout.js +156 -0
- package/dist/types/menu.types.d.ts +57 -5
- package/package.json +1 -1
- package/dist/types/layout.types.d.ts +0 -56
- package/dist/types/layout.types.js +0 -36
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
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hints Component - New Architecture Version
|
|
3
|
+
* Returns string arrays and listens to HintManager
|
|
4
|
+
*/
|
|
5
|
+
import { Component } from '../../layout.js';
|
|
6
|
+
export declare function createHintsComponentV2(hints: string[]): Component;
|
|
7
|
+
/**
|
|
8
|
+
* Create a dynamic hints component that listens to HintManager
|
|
9
|
+
*/
|
|
10
|
+
export declare function createDynamicHintsComponent(): Component;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Hints Component - New Architecture Version
|
|
4
|
+
* Returns string arrays and listens to HintManager
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.createHintsComponentV2 = createHintsComponentV2;
|
|
8
|
+
exports.createDynamicHintsComponent = createDynamicHintsComponent;
|
|
9
|
+
const layout_js_1 = require("../../layout.js");
|
|
10
|
+
const colors_js_1 = require("../../core/colors.js");
|
|
11
|
+
function createHintsComponentV2(hints) {
|
|
12
|
+
return {
|
|
13
|
+
type: 'hints',
|
|
14
|
+
regionId: 'footerHints',
|
|
15
|
+
render: (rect) => {
|
|
16
|
+
// Join hints with separator
|
|
17
|
+
const hintsText = hints.join(' • ');
|
|
18
|
+
return [`${colors_js_1.colors.dim}${hintsText}${colors_js_1.colors.reset}`];
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Create a dynamic hints component that listens to HintManager
|
|
24
|
+
*/
|
|
25
|
+
function createDynamicHintsComponent() {
|
|
26
|
+
return {
|
|
27
|
+
type: 'hints',
|
|
28
|
+
regionId: 'footerHints',
|
|
29
|
+
render: (rect) => {
|
|
30
|
+
const currentHint = layout_js_1.hintManager.current();
|
|
31
|
+
return [currentHint ? `${colors_js_1.colors.dim}${currentHint}${colors_js_1.colors.reset}` : ''];
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hints Component
|
|
3
|
+
* Displays operation hints at the bottom of the page
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Hints configuration
|
|
7
|
+
*/
|
|
8
|
+
export interface HintsConfig {
|
|
9
|
+
hints: string[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Standard hint types
|
|
13
|
+
*/
|
|
14
|
+
export declare const HintTypes: {
|
|
15
|
+
/** Arrow keys navigation */
|
|
16
|
+
readonly ARROWS: () => string;
|
|
17
|
+
/** Number keys selection */
|
|
18
|
+
readonly NUMBERS: () => string;
|
|
19
|
+
/** Letter keys selection */
|
|
20
|
+
readonly LETTERS: () => string;
|
|
21
|
+
/** Space key toggle */
|
|
22
|
+
readonly SPACE: () => string;
|
|
23
|
+
/** Enter key confirm */
|
|
24
|
+
readonly ENTER: () => string;
|
|
25
|
+
/** Escape key cancel */
|
|
26
|
+
readonly ESC: () => string;
|
|
27
|
+
/** Select all */
|
|
28
|
+
readonly SELECT_ALL: () => string;
|
|
29
|
+
/** Invert selection */
|
|
30
|
+
readonly INVERT: () => string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Generate hints for menu interactions
|
|
34
|
+
*/
|
|
35
|
+
export declare function generateMenuHints(options: {
|
|
36
|
+
hasMultipleOptions?: boolean;
|
|
37
|
+
allowNumberKeys?: boolean;
|
|
38
|
+
allowLetterKeys?: boolean;
|
|
39
|
+
allowSelectAll?: boolean;
|
|
40
|
+
allowInvert?: boolean;
|
|
41
|
+
}): string[];
|
|
42
|
+
/**
|
|
43
|
+
* Generate hints for input interactions
|
|
44
|
+
*/
|
|
45
|
+
export declare function generateInputHints(): string[];
|
|
46
|
+
/**
|
|
47
|
+
* Render hints component
|
|
48
|
+
* @param config - Hints configuration
|
|
49
|
+
*/
|
|
50
|
+
export declare function renderHintsComponent(config: HintsConfig): void;
|
|
51
|
+
/**
|
|
52
|
+
* Create hints component (factory function)
|
|
53
|
+
* @param hints - Array of hint strings
|
|
54
|
+
* @returns Hints configuration
|
|
55
|
+
*/
|
|
56
|
+
export declare function createHints(hints: string[]): HintsConfig;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Hints Component
|
|
4
|
+
* Displays operation hints at the bottom of the page
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.HintTypes = void 0;
|
|
8
|
+
exports.generateMenuHints = generateMenuHints;
|
|
9
|
+
exports.generateInputHints = generateInputHints;
|
|
10
|
+
exports.renderHintsComponent = renderHintsComponent;
|
|
11
|
+
exports.createHints = createHints;
|
|
12
|
+
const renderer_js_1 = require("../../core/renderer.js");
|
|
13
|
+
const registry_js_1 = require("../../i18n/registry.js");
|
|
14
|
+
/**
|
|
15
|
+
* Standard hint types
|
|
16
|
+
*/
|
|
17
|
+
exports.HintTypes = {
|
|
18
|
+
/** Arrow keys navigation */
|
|
19
|
+
ARROWS: () => (0, registry_js_1.t)('hints.arrows'),
|
|
20
|
+
/** Number keys selection */
|
|
21
|
+
NUMBERS: () => (0, registry_js_1.t)('hints.numbers'),
|
|
22
|
+
/** Letter keys selection */
|
|
23
|
+
LETTERS: () => (0, registry_js_1.t)('hints.letters'),
|
|
24
|
+
/** Space key toggle */
|
|
25
|
+
SPACE: () => (0, registry_js_1.t)('hints.space'),
|
|
26
|
+
/** Enter key confirm */
|
|
27
|
+
ENTER: () => (0, registry_js_1.t)('hints.enter'),
|
|
28
|
+
/** Escape key cancel */
|
|
29
|
+
ESC: () => 'Esc Cancel',
|
|
30
|
+
/** Select all */
|
|
31
|
+
SELECT_ALL: () => (0, registry_js_1.t)('hints.selectAll'),
|
|
32
|
+
/** Invert selection */
|
|
33
|
+
INVERT: () => (0, registry_js_1.t)('hints.invert')
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Generate hints for menu interactions
|
|
37
|
+
*/
|
|
38
|
+
function generateMenuHints(options) {
|
|
39
|
+
const hints = [];
|
|
40
|
+
if (options.hasMultipleOptions) {
|
|
41
|
+
hints.push(exports.HintTypes.ARROWS());
|
|
42
|
+
}
|
|
43
|
+
if (options.allowNumberKeys) {
|
|
44
|
+
hints.push(exports.HintTypes.NUMBERS());
|
|
45
|
+
}
|
|
46
|
+
if (options.allowLetterKeys) {
|
|
47
|
+
hints.push(exports.HintTypes.LETTERS());
|
|
48
|
+
}
|
|
49
|
+
if (options.allowSelectAll) {
|
|
50
|
+
hints.push(exports.HintTypes.SELECT_ALL());
|
|
51
|
+
}
|
|
52
|
+
if (options.allowInvert) {
|
|
53
|
+
hints.push(exports.HintTypes.INVERT());
|
|
54
|
+
}
|
|
55
|
+
hints.push(exports.HintTypes.ENTER());
|
|
56
|
+
return hints;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Generate hints for input interactions
|
|
60
|
+
*/
|
|
61
|
+
function generateInputHints() {
|
|
62
|
+
return [exports.HintTypes.ENTER(), exports.HintTypes.ESC()];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Render hints component
|
|
66
|
+
* @param config - Hints configuration
|
|
67
|
+
*/
|
|
68
|
+
function renderHintsComponent(config) {
|
|
69
|
+
if (!config.hints || config.hints.length === 0) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
(0, renderer_js_1.renderHints)(config.hints);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Create hints component (factory function)
|
|
76
|
+
* @param hints - Array of hint strings
|
|
77
|
+
* @returns Hints configuration
|
|
78
|
+
*/
|
|
79
|
+
function createHints(hints) {
|
|
80
|
+
return { hints };
|
|
81
|
+
}
|
|
@@ -7,3 +7,6 @@ export { renderProgressIndicator, renderStageHeader, renderStageSeparator, creat
|
|
|
7
7
|
export { renderMessage, showSuccess, showError, showWarning, showInfo, showQuestion, createMessage } from './messages.js';
|
|
8
8
|
export { renderSummaryTable, createSummaryTable, createSimpleSummary } from './summary.js';
|
|
9
9
|
export { renderHeader, type HeaderConfig } from './header.js';
|
|
10
|
+
export { renderHintsComponent, createHints, generateMenuHints, generateInputHints, HintTypes, type HintsConfig } from './hints.js';
|
|
11
|
+
export { renderTable, createTable, type TableConfig, type TableColumn } from './table.js';
|
|
12
|
+
export { renderList, createList, createBulletList, createNumberedList, type ListConfig, type ListItem } from './list.js';
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Exports all display component functions
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.renderHeader = exports.createSimpleSummary = exports.createSummaryTable = exports.renderSummaryTable = exports.createMessage = exports.showQuestion = exports.showInfo = exports.showWarning = exports.showError = exports.showSuccess = exports.renderMessage = exports.createStageSeparator = exports.createStageHeader = exports.createProgressIndicator = exports.renderStageSeparator = exports.renderStageHeader = exports.renderProgressIndicator = exports.createAsciiHeader = exports.createSectionHeader = exports.createSimpleHeader = exports.renderAsciiHeader = exports.renderSectionHeader = exports.renderSimpleHeader = void 0;
|
|
7
|
+
exports.createNumberedList = exports.createBulletList = exports.createList = exports.renderList = exports.createTable = exports.renderTable = exports.HintTypes = exports.generateInputHints = exports.generateMenuHints = exports.createHints = exports.renderHintsComponent = exports.renderHeader = exports.createSimpleSummary = exports.createSummaryTable = exports.renderSummaryTable = exports.createMessage = exports.showQuestion = exports.showInfo = exports.showWarning = exports.showError = exports.showSuccess = exports.renderMessage = exports.createStageSeparator = exports.createStageHeader = exports.createProgressIndicator = exports.renderStageSeparator = exports.renderStageHeader = exports.renderProgressIndicator = exports.createAsciiHeader = exports.createSectionHeader = exports.createSimpleHeader = exports.renderAsciiHeader = exports.renderSectionHeader = exports.renderSimpleHeader = void 0;
|
|
8
8
|
var headers_js_1 = require("./headers.js");
|
|
9
9
|
Object.defineProperty(exports, "renderSimpleHeader", { enumerable: true, get: function () { return headers_js_1.renderSimpleHeader; } });
|
|
10
10
|
Object.defineProperty(exports, "renderSectionHeader", { enumerable: true, get: function () { return headers_js_1.renderSectionHeader; } });
|
|
@@ -33,3 +33,17 @@ Object.defineProperty(exports, "createSummaryTable", { enumerable: true, get: fu
|
|
|
33
33
|
Object.defineProperty(exports, "createSimpleSummary", { enumerable: true, get: function () { return summary_js_1.createSimpleSummary; } });
|
|
34
34
|
var header_js_1 = require("./header.js");
|
|
35
35
|
Object.defineProperty(exports, "renderHeader", { enumerable: true, get: function () { return header_js_1.renderHeader; } });
|
|
36
|
+
var hints_js_1 = require("./hints.js");
|
|
37
|
+
Object.defineProperty(exports, "renderHintsComponent", { enumerable: true, get: function () { return hints_js_1.renderHintsComponent; } });
|
|
38
|
+
Object.defineProperty(exports, "createHints", { enumerable: true, get: function () { return hints_js_1.createHints; } });
|
|
39
|
+
Object.defineProperty(exports, "generateMenuHints", { enumerable: true, get: function () { return hints_js_1.generateMenuHints; } });
|
|
40
|
+
Object.defineProperty(exports, "generateInputHints", { enumerable: true, get: function () { return hints_js_1.generateInputHints; } });
|
|
41
|
+
Object.defineProperty(exports, "HintTypes", { enumerable: true, get: function () { return hints_js_1.HintTypes; } });
|
|
42
|
+
var table_js_1 = require("./table.js");
|
|
43
|
+
Object.defineProperty(exports, "renderTable", { enumerable: true, get: function () { return table_js_1.renderTable; } });
|
|
44
|
+
Object.defineProperty(exports, "createTable", { enumerable: true, get: function () { return table_js_1.createTable; } });
|
|
45
|
+
var list_js_1 = require("./list.js");
|
|
46
|
+
Object.defineProperty(exports, "renderList", { enumerable: true, get: function () { return list_js_1.renderList; } });
|
|
47
|
+
Object.defineProperty(exports, "createList", { enumerable: true, get: function () { return list_js_1.createList; } });
|
|
48
|
+
Object.defineProperty(exports, "createBulletList", { enumerable: true, get: function () { return list_js_1.createBulletList; } });
|
|
49
|
+
Object.defineProperty(exports, "createNumberedList", { enumerable: true, get: function () { return list_js_1.createNumberedList; } });
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Input Prompt Component
|
|
3
|
+
* Factory function to create input prompt configuration
|
|
4
|
+
*/
|
|
5
|
+
export interface InputPromptConfig {
|
|
6
|
+
/** Prompt text to display */
|
|
7
|
+
prompt: string;
|
|
8
|
+
/** Default value */
|
|
9
|
+
defaultValue?: string;
|
|
10
|
+
/** Allow empty input */
|
|
11
|
+
allowEmpty?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Create an input prompt component configuration
|
|
15
|
+
* Returns a configuration object that can be used in footer.input
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const inputConfig = createInputPromptComponent({
|
|
20
|
+
* prompt: '请输入名称',
|
|
21
|
+
* defaultValue: '',
|
|
22
|
+
* allowEmpty: false
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* await renderPage({
|
|
26
|
+
* header: {...},
|
|
27
|
+
* mainArea: {...},
|
|
28
|
+
* footer: {
|
|
29
|
+
* input: inputConfig,
|
|
30
|
+
* hints: ['Enter 确认', 'Esc 取消']
|
|
31
|
+
* }
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function createInputPromptComponent(config: InputPromptConfig): InputPromptConfig;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Input Prompt Component
|
|
4
|
+
* Factory function to create input prompt configuration
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.createInputPromptComponent = createInputPromptComponent;
|
|
8
|
+
/**
|
|
9
|
+
* Create an input prompt component configuration
|
|
10
|
+
* Returns a configuration object that can be used in footer.input
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const inputConfig = createInputPromptComponent({
|
|
15
|
+
* prompt: '请输入名称',
|
|
16
|
+
* defaultValue: '',
|
|
17
|
+
* allowEmpty: false
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* await renderPage({
|
|
21
|
+
* header: {...},
|
|
22
|
+
* mainArea: {...},
|
|
23
|
+
* footer: {
|
|
24
|
+
* input: inputConfig,
|
|
25
|
+
* hints: ['Enter 确认', 'Esc 取消']
|
|
26
|
+
* }
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
function createInputPromptComponent(config) {
|
|
31
|
+
return {
|
|
32
|
+
prompt: config.prompt,
|
|
33
|
+
defaultValue: config.defaultValue,
|
|
34
|
+
allowEmpty: config.allowEmpty ?? false
|
|
35
|
+
};
|
|
36
|
+
}
|