@inquirer/demo 0.5.5 → 0.6.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/demos/input.mjs +2 -3
- package/demos/loader.mjs +27 -0
- package/index.mjs +3 -0
- package/package.json +5 -4
package/demos/input.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as url from 'node:url';
|
|
2
|
-
import
|
|
2
|
+
import pc from 'picocolors';
|
|
3
3
|
import { input } from '@inquirer/prompts';
|
|
4
4
|
|
|
5
5
|
const hexRegEx = /(\d|[a-f])/gim;
|
|
@@ -19,8 +19,7 @@ const demo = async () => {
|
|
|
19
19
|
answer = await input({
|
|
20
20
|
message: 'Enter an hex color?',
|
|
21
21
|
transformer(value = '', { isFinal }) {
|
|
22
|
-
|
|
23
|
-
return isFinal ? color.underline(value) : color(value);
|
|
22
|
+
return isFinal ? pc.underline(value) : value;
|
|
24
23
|
},
|
|
25
24
|
validate: (value = '') => isHex(value) || 'Pass a valid hex value',
|
|
26
25
|
});
|
package/demos/loader.mjs
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as url from 'node:url';
|
|
2
|
+
import { createPrompt, useKeypress, usePrefix, isEnterKey } from '@inquirer/core';
|
|
3
|
+
|
|
4
|
+
const loader = createPrompt((config, done) => {
|
|
5
|
+
const prefix = usePrefix({ isLoading: true });
|
|
6
|
+
|
|
7
|
+
useKeypress((key) => {
|
|
8
|
+
if (isEnterKey(key)) {
|
|
9
|
+
done();
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
return `${prefix} Press enter to exit`;
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const demo = async () => {
|
|
17
|
+
await loader();
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
if (import.meta.url.startsWith('file:')) {
|
|
21
|
+
const modulePath = url.fileURLToPath(import.meta.url);
|
|
22
|
+
if (process.argv[1] === modulePath) {
|
|
23
|
+
demo();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default demo;
|
package/index.mjs
CHANGED
|
@@ -10,6 +10,7 @@ import passwordDemo from './demos/password.mjs';
|
|
|
10
10
|
import rawlistDemo from './demos/rawlist.mjs';
|
|
11
11
|
import selectDemo from './demos/select.mjs';
|
|
12
12
|
import timeoutDemo from './demos/timeout.mjs';
|
|
13
|
+
import loaderDemo from './demos/loader.mjs';
|
|
13
14
|
|
|
14
15
|
const demos = {
|
|
15
16
|
checkbox: checkboxDemo,
|
|
@@ -21,6 +22,7 @@ const demos = {
|
|
|
21
22
|
rawlist: rawlistDemo,
|
|
22
23
|
select: selectDemo,
|
|
23
24
|
timeout: timeoutDemo,
|
|
25
|
+
loader: loaderDemo,
|
|
24
26
|
};
|
|
25
27
|
|
|
26
28
|
async function askNextDemo() {
|
|
@@ -45,6 +47,7 @@ async function askNextDemo() {
|
|
|
45
47
|
message: 'Which demo do you want to run?',
|
|
46
48
|
choices: [
|
|
47
49
|
{ name: 'Default value after timeout', value: 'timeout' },
|
|
50
|
+
{ name: 'Loader', value: 'loader' },
|
|
48
51
|
{ name: 'Go back', value: 'back' },
|
|
49
52
|
],
|
|
50
53
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inquirer/demo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=18"
|
|
6
6
|
},
|
|
@@ -61,12 +61,13 @@
|
|
|
61
61
|
"license": "MIT",
|
|
62
62
|
"homepage": "https://github.com/SBoudrias/Inquirer.js",
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@inquirer/
|
|
65
|
-
"
|
|
64
|
+
"@inquirer/core": "^8.2.4",
|
|
65
|
+
"@inquirer/prompts": "^5.0.7",
|
|
66
|
+
"picocolors": "^1.0.1"
|
|
66
67
|
},
|
|
67
68
|
"publishConfig": {
|
|
68
69
|
"access": "public"
|
|
69
70
|
},
|
|
70
71
|
"sideEffects": false,
|
|
71
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "d5f62c6ee3e671f7d1b776b85d43781869d70918"
|
|
72
73
|
}
|