cli-menu-kit 0.1.18 → 0.1.19
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.
|
@@ -12,15 +12,39 @@ const renderer_js_1 = require("../../core/renderer.js");
|
|
|
12
12
|
const colors_js_1 = require("../../core/colors.js");
|
|
13
13
|
const registry_js_1 = require("../../i18n/registry.js");
|
|
14
14
|
/**
|
|
15
|
-
* Generate hints based on menu configuration
|
|
15
|
+
* Generate hints based on menu configuration and actual options
|
|
16
16
|
*/
|
|
17
|
-
function generateHints(allowNumberKeys, allowLetterKeys) {
|
|
18
|
-
const hints = [
|
|
17
|
+
function generateHints(options, allowNumberKeys, allowLetterKeys) {
|
|
18
|
+
const hints = [];
|
|
19
|
+
// Count selectable options
|
|
20
|
+
const selectableCount = options.filter(opt => !(typeof opt === 'object' && 'type' in opt && opt.type === 'separator')).length;
|
|
21
|
+
// Only show arrow hints if there are multiple options
|
|
22
|
+
if (selectableCount > 1) {
|
|
23
|
+
hints.push((0, registry_js_1.t)('hints.arrows'));
|
|
24
|
+
}
|
|
25
|
+
// Check if there are actually number-prefixed options
|
|
19
26
|
if (allowNumberKeys) {
|
|
20
|
-
|
|
27
|
+
const hasNumberOptions = options.some(opt => {
|
|
28
|
+
if (typeof opt === 'string') {
|
|
29
|
+
return /^\d+\./.test(opt);
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
});
|
|
33
|
+
if (hasNumberOptions) {
|
|
34
|
+
hints.push((0, registry_js_1.t)('hints.numbers'));
|
|
35
|
+
}
|
|
21
36
|
}
|
|
37
|
+
// Check if there are actually letter-prefixed options
|
|
22
38
|
if (allowLetterKeys) {
|
|
23
|
-
|
|
39
|
+
const hasLetterOptions = options.some(opt => {
|
|
40
|
+
if (typeof opt === 'string') {
|
|
41
|
+
return /^[a-zA-Z]\./.test(opt);
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
});
|
|
45
|
+
if (hasLetterOptions) {
|
|
46
|
+
hints.push((0, registry_js_1.t)('hints.letters'));
|
|
47
|
+
}
|
|
24
48
|
}
|
|
25
49
|
hints.push((0, registry_js_1.t)('hints.enter'));
|
|
26
50
|
return hints;
|
|
@@ -35,7 +59,7 @@ async function showRadioMenu(config) {
|
|
|
35
59
|
// Use i18n for default prompt if not provided
|
|
36
60
|
const displayPrompt = prompt || (0, registry_js_1.t)('menus.selectPrompt');
|
|
37
61
|
// Generate hints dynamically if not provided
|
|
38
|
-
const displayHints = hints || generateHints(allowNumberKeys, allowLetterKeys);
|
|
62
|
+
const displayHints = hints || generateHints(options, allowNumberKeys, allowLetterKeys);
|
|
39
63
|
// Validate options
|
|
40
64
|
if (!options || options.length === 0) {
|
|
41
65
|
throw new Error('RadioMenu requires at least one option');
|
package/package.json
CHANGED