@inquirer/select 2.2.3 → 2.3.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.
- package/README.md +7 -0
- package/dist/cjs/index.js +12 -5
- package/dist/cjs/types/index.d.ts +1 -0
- package/dist/esm/index.mjs +12 -5
- package/dist/esm/types/index.d.mts +1 -0
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -80,9 +80,16 @@ type Theme = {
|
|
|
80
80
|
icon: {
|
|
81
81
|
cursor: string;
|
|
82
82
|
};
|
|
83
|
+
helpMode: 'always' | 'never' | 'auto';
|
|
83
84
|
};
|
|
84
85
|
```
|
|
85
86
|
|
|
87
|
+
### `theme.helpMode`
|
|
88
|
+
|
|
89
|
+
- `auto` (default): Hide the help tips after an interaction occurs.
|
|
90
|
+
- `always`: The help tips will always show and never hide.
|
|
91
|
+
- `never`: The help tips will never show.
|
|
92
|
+
|
|
86
93
|
# License
|
|
87
94
|
|
|
88
95
|
Copyright (c) 2023 Simon Boudrias (twitter: [@vaxilart](https://twitter.com/Vaxilart))<br/>
|
package/dist/cjs/index.js
CHANGED
|
@@ -12,6 +12,7 @@ const ansi_escapes_1 = __importDefault(require("ansi-escapes"));
|
|
|
12
12
|
const selectTheme = {
|
|
13
13
|
icon: { cursor: figures_1.default.pointer },
|
|
14
14
|
style: { disabled: (text) => chalk_1.default.dim(`- ${text}`) },
|
|
15
|
+
helpMode: 'auto',
|
|
15
16
|
};
|
|
16
17
|
function isSelectable(item) {
|
|
17
18
|
return !core_1.Separator.isSeparator(item) && !item.disabled;
|
|
@@ -88,10 +89,17 @@ exports.default = (0, core_1.createPrompt)((config, done) => {
|
|
|
88
89
|
}
|
|
89
90
|
});
|
|
90
91
|
const message = theme.style.message(config.message);
|
|
91
|
-
let
|
|
92
|
-
|
|
92
|
+
let helpTipTop = '';
|
|
93
|
+
let helpTipBottom = '';
|
|
94
|
+
if (theme.helpMode === 'always' ||
|
|
95
|
+
(theme.helpMode === 'auto' && firstRender.current)) {
|
|
93
96
|
firstRender.current = false;
|
|
94
|
-
|
|
97
|
+
if (items.length > pageSize) {
|
|
98
|
+
helpTipBottom = `\n${theme.style.help('(Use arrow keys to reveal more choices)')}`;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
helpTipTop = theme.style.help('(Use arrow keys)');
|
|
102
|
+
}
|
|
95
103
|
}
|
|
96
104
|
const page = (0, core_1.usePagination)({
|
|
97
105
|
items,
|
|
@@ -111,7 +119,6 @@ exports.default = (0, core_1.createPrompt)((config, done) => {
|
|
|
111
119
|
},
|
|
112
120
|
pageSize,
|
|
113
121
|
loop,
|
|
114
|
-
theme,
|
|
115
122
|
});
|
|
116
123
|
if (status === 'done') {
|
|
117
124
|
const answer = selectedChoice.name ||
|
|
@@ -122,5 +129,5 @@ exports.default = (0, core_1.createPrompt)((config, done) => {
|
|
|
122
129
|
const choiceDescription = selectedChoice.description
|
|
123
130
|
? `\n${selectedChoice.description}`
|
|
124
131
|
: ``;
|
|
125
|
-
return `${[prefix, message,
|
|
132
|
+
return `${[prefix, message, helpTipTop].filter(Boolean).join(' ')}\n${page}${choiceDescription}${helpTipBottom}${ansi_escapes_1.default.cursorHide}`;
|
|
126
133
|
});
|
package/dist/esm/index.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import ansiEscapes from 'ansi-escapes';
|
|
|
5
5
|
const selectTheme = {
|
|
6
6
|
icon: { cursor: figures.pointer },
|
|
7
7
|
style: { disabled: (text) => chalk.dim(`- ${text}`) },
|
|
8
|
+
helpMode: 'auto',
|
|
8
9
|
};
|
|
9
10
|
function isSelectable(item) {
|
|
10
11
|
return !Separator.isSeparator(item) && !item.disabled;
|
|
@@ -81,10 +82,17 @@ export default createPrompt((config, done) => {
|
|
|
81
82
|
}
|
|
82
83
|
});
|
|
83
84
|
const message = theme.style.message(config.message);
|
|
84
|
-
let
|
|
85
|
-
|
|
85
|
+
let helpTipTop = '';
|
|
86
|
+
let helpTipBottom = '';
|
|
87
|
+
if (theme.helpMode === 'always' ||
|
|
88
|
+
(theme.helpMode === 'auto' && firstRender.current)) {
|
|
86
89
|
firstRender.current = false;
|
|
87
|
-
|
|
90
|
+
if (items.length > pageSize) {
|
|
91
|
+
helpTipBottom = `\n${theme.style.help('(Use arrow keys to reveal more choices)')}`;
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
helpTipTop = theme.style.help('(Use arrow keys)');
|
|
95
|
+
}
|
|
88
96
|
}
|
|
89
97
|
const page = usePagination({
|
|
90
98
|
items,
|
|
@@ -104,7 +112,6 @@ export default createPrompt((config, done) => {
|
|
|
104
112
|
},
|
|
105
113
|
pageSize,
|
|
106
114
|
loop,
|
|
107
|
-
theme,
|
|
108
115
|
});
|
|
109
116
|
if (status === 'done') {
|
|
110
117
|
const answer = selectedChoice.name ||
|
|
@@ -115,6 +122,6 @@ export default createPrompt((config, done) => {
|
|
|
115
122
|
const choiceDescription = selectedChoice.description
|
|
116
123
|
? `\n${selectedChoice.description}`
|
|
117
124
|
: ``;
|
|
118
|
-
return `${[prefix, message,
|
|
125
|
+
return `${[prefix, message, helpTipTop].filter(Boolean).join(' ')}\n${page}${choiceDescription}${helpTipBottom}${ansiEscapes.cursorHide}`;
|
|
119
126
|
});
|
|
120
127
|
export { Separator };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inquirer/select",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "Inquirer select/list prompt",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"typings": "./dist/cjs/types/index.d.ts",
|
|
@@ -54,14 +54,14 @@
|
|
|
54
54
|
"license": "MIT",
|
|
55
55
|
"homepage": "https://github.com/SBoudrias/Inquirer.js/blob/master/packages/select/README.md",
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@inquirer/core": "^
|
|
58
|
-
"@inquirer/figures": "^1.0.
|
|
59
|
-
"@inquirer/type": "^1.
|
|
57
|
+
"@inquirer/core": "^8.0.1",
|
|
58
|
+
"@inquirer/figures": "^1.0.1",
|
|
59
|
+
"@inquirer/type": "^1.3.0",
|
|
60
60
|
"ansi-escapes": "^4.3.2",
|
|
61
61
|
"chalk": "^4.1.2"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@inquirer/testing": "^2.1.
|
|
64
|
+
"@inquirer/testing": "^2.1.17"
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|
|
67
67
|
"tsc": "yarn run tsc:esm && yarn run tsc:cjs",
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "e986c9afc26321c3448f87f55795f7d9b8a9d452"
|
|
91
91
|
}
|