@reliverse/relinka 1.1.6 → 1.1.8

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 (121) hide show
  1. package/dist-npm/components/anykey/index.js +57 -77
  2. package/dist-npm/components/block/block.js +48 -61
  3. package/dist-npm/components/checkbox/index.js +178 -211
  4. package/dist-npm/components/confirm/confirm-main.js +85 -122
  5. package/dist-npm/components/confirm/confirm-three.js +24 -27
  6. package/dist-npm/components/confirm/index.js +36 -45
  7. package/dist-npm/components/core/Separator.js +15 -17
  8. package/dist-npm/components/core/create-prompt.js +101 -124
  9. package/dist-npm/components/core/errors.js +19 -15
  10. package/dist-npm/components/core/hook-engine.js +91 -120
  11. package/dist-npm/components/core/index.js +12 -12
  12. package/dist-npm/components/core/key.js +16 -6
  13. package/dist-npm/components/core/lines.js +45 -54
  14. package/dist-npm/components/core/make-theme.js +21 -30
  15. package/dist-npm/components/core/position.js +27 -23
  16. package/dist-npm/components/core/promise-polyfill.js +11 -14
  17. package/dist-npm/components/core/screen-manager.js +59 -74
  18. package/dist-npm/components/core/theme.js +22 -32
  19. package/dist-npm/components/core/use-effect.js +9 -15
  20. package/dist-npm/components/core/use-keypress.js +19 -23
  21. package/dist-npm/components/core/use-memo.js +10 -16
  22. package/dist-npm/components/core/use-pagination.js +33 -32
  23. package/dist-npm/components/core/use-prefix.js +40 -38
  24. package/dist-npm/components/core/use-ref.js +2 -5
  25. package/dist-npm/components/core/use-state.js +15 -23
  26. package/dist-npm/components/core/useKeyPress.js +14 -17
  27. package/dist-npm/components/core/usePromptState.js +8 -14
  28. package/dist-npm/components/core/utils.js +7 -16
  29. package/dist-npm/components/date/date.js +173 -204
  30. package/dist-npm/components/editor/index.js +71 -92
  31. package/dist-npm/components/expand/index.js +96 -124
  32. package/dist-npm/components/figures/index.js +283 -294
  33. package/dist-npm/components/input/index.js +61 -87
  34. package/dist-npm/components/input/text-main.js +97 -124
  35. package/dist-npm/components/input/text.js +24 -28
  36. package/dist-npm/components/instance/basic.js +17 -25
  37. package/dist-npm/components/instance/browser.js +14 -18
  38. package/dist-npm/components/instance/reporter/basic.js +46 -65
  39. package/dist-npm/components/instance/reporter/browser.js +44 -47
  40. package/dist-npm/components/instance/reporter/fancy.js +83 -96
  41. package/dist-npm/components/instance/shared.js +2 -2
  42. package/dist-npm/components/mono/mono.js +52 -62
  43. package/dist-npm/components/mono/monoTwo.js +35 -49
  44. package/dist-npm/components/multiselect/group-multiselect.js +55 -71
  45. package/dist-npm/components/multiselect/multi-select-two.js +97 -130
  46. package/dist-npm/components/multiselect/multi-select.js +43 -49
  47. package/dist-npm/components/multiselect/multiselect-main.d.ts +1 -0
  48. package/dist-npm/components/multiselect/multiselect-main.js +158 -145
  49. package/dist-npm/components/multiselect/num-multi-select.js +97 -130
  50. package/dist-npm/components/multiselect/num-multiselect-main.js +24 -35
  51. package/dist-npm/components/next-steps/next-steps.js +23 -25
  52. package/dist-npm/components/number/index.js +78 -112
  53. package/dist-npm/components/number/number-main.js +95 -2
  54. package/dist-npm/components/password/index.js +54 -73
  55. package/dist-npm/components/password/password-main.js +119 -2
  56. package/dist-npm/components/password/password-three.js +26 -30
  57. package/dist-npm/components/progressbar/ProgressBar.js +45 -64
  58. package/dist-npm/components/progressbar/helper.js +33 -40
  59. package/dist-npm/components/progressbar/index.js +1 -1
  60. package/dist-npm/components/prompts/create.js +29 -44
  61. package/dist-npm/components/prompts/index.d.ts +1 -0
  62. package/dist-npm/components/prompts/index.js +46 -45
  63. package/dist-npm/components/prompts/prompt.js +211 -260
  64. package/dist-npm/components/prompts/promptTwo.js +561 -605
  65. package/dist-npm/components/prompts/relinka.js +237 -295
  66. package/dist-npm/components/range/range.js +247 -294
  67. package/dist-npm/components/rawlist/index.js +87 -107
  68. package/dist-npm/components/results/results.js +31 -37
  69. package/dist-npm/components/search/index.js +148 -193
  70. package/dist-npm/components/select/index.js +148 -186
  71. package/dist-npm/components/select/num-select-main.js +27 -27
  72. package/dist-npm/components/select/num-select.js +124 -5
  73. package/dist-npm/components/select/select-key.js +24 -25
  74. package/dist-npm/components/select/select-main.d.ts +1 -0
  75. package/dist-npm/components/select/select-main.js +143 -133
  76. package/dist-npm/components/select/select-three.js +32 -36
  77. package/dist-npm/components/select/select-two.js +94 -87
  78. package/dist-npm/components/spinner/index.js +107 -136
  79. package/dist-npm/components/st-end/end.js +34 -26
  80. package/dist-npm/components/st-end/start.js +29 -15
  81. package/dist-npm/components/toggle/index.js +113 -137
  82. package/dist-npm/components/visual/animate/animate.js +53 -10
  83. package/dist-npm/components/visual/ascii-art/ascii-art.js +12 -1
  84. package/dist-npm/main.js +1 -0
  85. package/dist-npm/testing/index.js +58 -83
  86. package/dist-npm/types/general.d.ts +1 -1
  87. package/dist-npm/types/general.js +0 -1
  88. package/dist-npm/types/index.js +2 -3
  89. package/dist-npm/types/keypress.js +35 -36
  90. package/dist-npm/types/readline.js +0 -1
  91. package/dist-npm/types/relinka.js +0 -1
  92. package/dist-npm/types/utils.js +0 -1
  93. package/dist-npm/utils/box.js +135 -137
  94. package/dist-npm/utils/color.js +65 -74
  95. package/dist-npm/utils/colorize.js +124 -156
  96. package/dist-npm/utils/component.js +532 -657
  97. package/dist-npm/utils/constants.js +64 -63
  98. package/dist-npm/utils/core.js +2 -3
  99. package/dist-npm/utils/decoder.js +244 -223
  100. package/dist-npm/utils/error.js +4 -9
  101. package/dist-npm/utils/errors.js +14 -4
  102. package/dist-npm/utils/format.js +19 -24
  103. package/dist-npm/utils/keypress.js +316 -414
  104. package/dist-npm/utils/log.js +11 -15
  105. package/dist-npm/utils/mapping.js +45 -52
  106. package/dist-npm/utils/messages.js +196 -183
  107. package/dist-npm/utils/platforms.js +16 -20
  108. package/dist-npm/utils/prompt-tmp.js +235 -286
  109. package/dist-npm/utils/prompt-two.js +235 -286
  110. package/dist-npm/utils/readline.js +5 -7
  111. package/dist-npm/utils/skeleton.js +130 -170
  112. package/dist-npm/utils/stream.js +2 -2
  113. package/dist-npm/utils/string.js +44 -58
  114. package/dist-npm/utils/terminal.js +23 -34
  115. package/dist-npm/utils/tree.js +30 -41
  116. package/dist-npm/utils/types.js +0 -1
  117. package/dist-npm/utils/utils.js +8 -8
  118. package/dist-npm/utils/variants.js +36 -44
  119. package/package.json +14 -14
  120. package/dist-npm/mod.js +0 -2
  121. /package/dist-npm/{mod.d.ts → main.d.ts} +0 -0
@@ -1,227 +1,196 @@
1
- import {Type} from '@sinclair/typebox';
2
- import {Value} from '@sinclair/typebox/value';
1
+ import { Type } from "@sinclair/typebox";
2
+ import { Value } from "@sinclair/typebox/value";
3
+ import { stdin as input, stdout as output } from "node:process";
4
+ import readline from "node:readline/promises";
5
+ import { cyanBright } from "picocolors";
3
6
  import {
4
- stdin as input,
5
- stdout as output,
6
- } from 'node:process';
7
- import readline from 'node:readline/promises';
7
+ buildRegExp,
8
+ digit,
9
+ endOfString,
10
+ repeat,
11
+ startOfString
12
+ } from "ts-regex-builder";
13
+ import { bar, fmt, msg } from "../../utils/messages.js";
8
14
  import {
9
- buildRegExp,
10
- digit,
11
- endOfString,
12
- repeat,
13
- startOfString,
14
- } from 'ts-regex-builder';
15
- import {fmt, msg} from '../../utils/messages.js';
16
- import {
17
- countLines,
18
- deleteLastLine,
19
- deleteLastLines,
20
- } from '../../utils/terminal.js';
21
-
22
- const isString = (a) => typeof a === 'string';
23
-
15
+ countLines,
16
+ deleteLastLine,
17
+ deleteLastLines
18
+ } from "../../utils/terminal.js";
24
19
  const twoDigits = repeat(digit, 2);
25
20
  const fourDigits = repeat(digit, 4);
26
- const separatorDot = '.';
27
- const separatorSlash = '/';
28
-
21
+ const separatorDot = ".";
22
+ const separatorSlash = "/";
29
23
  const regexDDMMYYYY = buildRegExp([
30
- startOfString,
31
- twoDigits,
32
- separatorDot,
33
- twoDigits,
34
- separatorDot,
35
- fourDigits,
36
- endOfString,
24
+ startOfString,
25
+ twoDigits,
26
+
27
+ separatorDot,
28
+ twoDigits,
29
+
30
+ separatorDot,
31
+ fourDigits,
32
+
33
+ endOfString
37
34
  ]);
38
-
39
35
  const regexMMDDYYYY = buildRegExp([
40
- startOfString,
41
- twoDigits,
42
- separatorSlash,
43
- twoDigits,
44
- separatorSlash,
45
- fourDigits,
46
- endOfString,
36
+ startOfString,
37
+ twoDigits,
38
+
39
+ separatorSlash,
40
+ twoDigits,
41
+
42
+ separatorSlash,
43
+ fourDigits,
44
+
45
+ endOfString
47
46
  ]);
48
-
49
47
  const regexYYYYMMDD = buildRegExp([
50
- startOfString,
51
- fourDigits,
52
- separatorDot,
53
- twoDigits,
54
- separatorDot,
55
- twoDigits,
56
- endOfString,
48
+ startOfString,
49
+ fourDigits,
50
+
51
+ separatorDot,
52
+ twoDigits,
53
+
54
+ separatorDot,
55
+ twoDigits,
56
+
57
+ endOfString
57
58
  ]);
58
-
59
59
  const dateFormatSchema = Type.Union([
60
- Type.RegExp(regexDDMMYYYY, {
61
- description: 'DD.MM.YYYY',
62
- }),
63
- Type.RegExp(regexMMDDYYYY, {
64
- description: 'MM/DD/YYYY',
65
- }),
66
- Type.RegExp(regexYYYYMMDD, {
67
- description: 'YYYY.MM.DD',
68
- }),
60
+ Type.RegExp(regexDDMMYYYY, { description: "DD.MM.YYYY" }),
61
+ Type.RegExp(regexMMDDYYYY, { description: "MM/DD/YYYY" }),
62
+ Type.RegExp(regexYYYYMMDD, { description: "YYYY.MM.DD" })
69
63
  ]);
70
-
71
64
  export async function datePrompt(options) {
72
- const {
73
- title,
74
- dateFormat,
75
- dateKind,
76
- hint,
77
- validate,
78
- defaultValue,
79
- schema,
80
- titleColor = 'cyanBright',
81
- titleTypography = 'bold',
65
+ const {
66
+ title,
67
+ dateFormat,
68
+ dateKind,
69
+ hint,
70
+ validate,
71
+ defaultValue,
72
+ schema,
73
+ titleColor = "cyanBright",
74
+ titleTypography = "bold",
75
+ titleVariant,
76
+ content,
77
+ contentColor,
78
+ contentTypography,
79
+ contentVariant,
80
+ borderColor = "viceGradient",
81
+ variantOptions
82
+ } = options;
83
+ const rl = readline.createInterface({ input, output });
84
+ const formattedBar = bar({ borderColor });
85
+ let linesToDelete = 0;
86
+ let errorMessage = "";
87
+ try {
88
+ while (true) {
89
+ if (linesToDelete > 0) {
90
+ deleteLastLines(linesToDelete);
91
+ }
92
+ const questionText = fmt({
93
+ type: errorMessage !== "" ? "M_ERROR_NULL" : "M_GENERAL_NULL",
94
+ title: `${title} [Format: ${dateFormat}]`,
95
+ titleColor,
96
+ titleTypography,
82
97
  titleVariant,
83
98
  content,
84
99
  contentColor,
85
100
  contentTypography,
86
101
  contentVariant,
87
- borderColor = 'viceGradient',
102
+ borderColor,
103
+ hint,
88
104
  variantOptions,
89
- } = options;
90
-
91
- const rl = readline.createInterface({
92
- input,
93
- output,
94
- });
95
- let linesToDelete = 0;
96
- let errorMessage = '';
97
-
98
- try {
99
- while (true) {
100
- if (linesToDelete > 0) {
101
- deleteLastLines(linesToDelete);
102
- }
103
-
104
- const questionText = fmt({
105
- type: errorMessage !== '' ? 'M_ERROR' : 'M_GENERAL',
106
- title: `${title} [Format: ${dateFormat}]`,
107
- titleColor,
108
- titleTypography,
109
- titleVariant,
110
- content,
111
- contentColor,
112
- contentTypography,
113
- contentVariant,
114
- borderColor,
115
- hint,
116
- variantOptions,
117
- errorMessage,
118
- addNewLineBefore: false,
119
- });
120
-
121
- const questionLines = countLines(questionText);
122
-
123
- linesToDelete = questionLines + 1;
124
- msg({
125
- type: 'M_GENERAL',
126
- title: questionText,
127
- });
128
- const answer = (await rl.question('> ')).trim() || defaultValue;
129
-
130
- if (answer === defaultValue && defaultValue) {
131
- deleteLastLine();
132
- msg({
133
- type: 'M_MIDDLE',
134
- title: ` ${defaultValue}`,
135
- titleColor: 'none',
136
- });
137
- }
138
-
139
- if (!Value.Check(dateFormatSchema, answer)) {
140
- errorMessage = `Please enter a valid date in ${dateFormat} format.`;
141
- msg({
142
- type: 'M_ERROR',
143
- title: errorMessage,
144
- });
145
- continue;
146
- }
147
-
148
- let matchedFormat = null;
149
-
150
- if (regexDDMMYYYY.test(answer)) {
151
- matchedFormat = 'DD.MM.YYYY';
152
- } else if (regexMMDDYYYY.test(answer)) {
153
- matchedFormat = 'MM/DD/YYYY';
154
- } else if (regexYYYYMMDD.test(answer)) {
155
- matchedFormat = 'YYYY.MM.DD';
156
- }
157
-
158
-
159
- if (dateKind === 'birthday' && matchedFormat) {
160
- const parts = answer.split(/[./-]/);
161
- let date;
162
-
163
- if (matchedFormat === 'DD.MM.YYYY') {
164
- date = new Date(Number(parts[2]), Number(parts[1]) - 1, Number(parts[0]));
165
- } else if (matchedFormat === 'MM/DD/YYYY') {
166
- date = new Date(Number(parts[2]), Number(parts[0]) - 1, Number(parts[1]));
167
- } else if (matchedFormat === 'YYYY.MM.DD') {
168
- date = new Date(Number(parts[0]), Number(parts[1]) - 1, Number(parts[2]));
169
- } else {
170
- date = new Date(answer);
171
- }
172
-
173
-
174
- if (isNaN(date.getTime()) || date.getFullYear() < 1900 || date > new Date()) {
175
- errorMessage = 'Please enter a valid birthday date (e.g., 14.09.1999).';
176
- msg({
177
- type: 'M_ERROR',
178
- title: errorMessage,
179
- });
180
- continue;
181
- }
182
- }
183
-
184
- let isValid = true;
185
-
186
- errorMessage = '';
187
- if (schema) {
188
- isValid = Value.Check(schema, answer);
189
- if (!isValid) {
190
- const errors = Value.Errors(schema, answer);
191
-
192
- errorMessage = errors[0]?.message ?? 'Invalid input.';
193
- msg({
194
- type: 'M_ERROR',
195
- title: errorMessage,
196
- });
197
- continue;
198
- }
199
- }
200
-
201
- if (validate && isValid) {
202
- const validation = await validate(answer);
203
-
204
- if (!validation) {
205
- isValid = false;
206
- errorMessage = isString(validation) ? validation : 'Invalid input.';
207
- msg({
208
- type: 'M_ERROR',
209
- title: errorMessage,
210
- });
211
- continue;
212
- }
213
- }
214
-
215
- if (isValid) {
216
- msg({
217
- type: 'M_NEWLINE',
218
- title: '',
219
- });
220
- rl.close();
221
- return answer;
222
- }
105
+ errorMessage,
106
+ addNewLineBefore: false
107
+ });
108
+ const questionLines = countLines(questionText);
109
+ linesToDelete = questionLines + 1;
110
+ msg({ type: errorMessage !== "" ? "M_ERROR" : "M_GENERAL", title: questionText });
111
+ deleteLastLine();
112
+ deleteLastLine();
113
+ const answer = (await rl.question(`${cyanBright(">")} `)).trim() || defaultValue;
114
+ if (answer === defaultValue && defaultValue) {
115
+ deleteLastLine();
116
+ msg({
117
+ type: "M_MIDDLE",
118
+ title: ` ${defaultValue}`,
119
+ titleColor: "none"
120
+ });
121
+ }
122
+ if (!Value.Check(dateFormatSchema, answer)) {
123
+ deleteLastLine();
124
+ deleteLastLine();
125
+ errorMessage = `Please enter a valid date in ${dateFormat} format.`;
126
+ msg({ type: "M_ERROR", title: errorMessage });
127
+ continue;
128
+ }
129
+ let matchedFormat = null;
130
+ if (regexDDMMYYYY.test(answer)) {
131
+ matchedFormat = "DD.MM.YYYY";
132
+ } else if (regexMMDDYYYY.test(answer)) {
133
+ matchedFormat = "MM/DD/YYYY";
134
+ } else if (regexYYYYMMDD.test(answer)) {
135
+ matchedFormat = "YYYY.MM.DD";
136
+ }
137
+ if (dateKind === "birthday" && matchedFormat) {
138
+ const parts = answer.split(/[./-]/);
139
+ let date;
140
+ if (matchedFormat === "DD.MM.YYYY") {
141
+ date = new Date(
142
+ Number(parts[2]),
143
+ Number(parts[1]) - 1,
144
+ Number(parts[0])
145
+ );
146
+ } else if (matchedFormat === "MM/DD/YYYY") {
147
+ date = new Date(
148
+ Number(parts[2]),
149
+ Number(parts[0]) - 1,
150
+ Number(parts[1])
151
+ );
152
+ } else if (matchedFormat === "YYYY.MM.DD") {
153
+ date = new Date(
154
+ Number(parts[0]),
155
+ Number(parts[1]) - 1,
156
+ Number(parts[2])
157
+ );
158
+ } else {
159
+ date = new Date(answer);
160
+ }
161
+ if (isNaN(date.getTime()) || date.getFullYear() < 1900 || date > new Date()) {
162
+ errorMessage = "Please enter a valid birthday date (e.g., 14.09.1999).";
163
+ msg({ type: "M_ERROR", title: errorMessage });
164
+ continue;
165
+ }
166
+ }
167
+ let isValid = true;
168
+ errorMessage = "";
169
+ if (schema) {
170
+ isValid = Value.Check(schema, answer);
171
+ if (!isValid) {
172
+ const errors = [...Value.Errors(schema, answer)];
173
+ errorMessage = errors[0]?.message ?? "Invalid input.";
174
+ msg({ type: "M_ERROR", title: errorMessage });
175
+ continue;
176
+ }
177
+ }
178
+ if (validate && isValid) {
179
+ const validation = await validate(answer);
180
+ if (validation !== true) {
181
+ isValid = false;
182
+ errorMessage = typeof validation === "string" ? validation : "Invalid input.";
183
+ msg({ type: "M_ERROR", title: errorMessage });
184
+ continue;
223
185
  }
224
- } finally {
186
+ }
187
+ if (isValid) {
188
+ msg({ type: "M_NEWLINE", title: "" });
225
189
  rl.close();
190
+ return answer;
191
+ }
226
192
  }
193
+ } finally {
194
+ rl.close();
195
+ }
227
196
  }
@@ -1,99 +1,78 @@
1
- import {editAsync} from 'external-editor';
2
- import {AsyncResource} from 'node:async_hooks';
1
+ import { editAsync } from "external-editor";
2
+ import { AsyncResource } from "node:async_hooks";
3
3
  import {
4
- createPrompt,
5
- useEffect,
6
- useState,
7
- useKeypress,
8
- usePrefix,
9
- isEnterKey,
10
- makeTheme,
11
- } from '../../components/core/index.js';
12
-
4
+ createPrompt,
5
+ useEffect,
6
+ useState,
7
+ useKeypress,
8
+ usePrefix,
9
+ isEnterKey,
10
+ makeTheme
11
+ } from "../../components/core/index.js";
13
12
  export default createPrompt((config, done) => {
14
- const {
15
- waitForUseInput = true,
16
- file: {postfix = config.postfix ?? '.txt', ...fileProps} = {},
17
- validate = () => true,
18
- } = config;
19
-
20
- const theme = makeTheme(config.theme);
21
- const [status, setStatus] = useState('idle');
22
- const [value, setValue] = useState(config.default || '');
23
- const [errorMsg, setError] = useState();
24
- const prefix = usePrefix({
25
- status,
26
- theme,
27
- });
28
-
29
- function startEditor(rl) {
30
- rl.pause();
31
- const editCallback = AsyncResource.bind(async (error2, answer) => {
32
- rl.resume();
33
- if (error2) {
34
- setError(error2.toString());
35
- } else {
36
- setStatus('loading');
37
- const isValid = await validate(answer);
38
-
39
- if (isValid) {
40
- setError(void 0);
41
- setStatus('done');
42
- done(answer);
43
- } else {
44
- setValue(answer);
45
- setError(isValid || 'You must provide a valid value');
46
- setStatus('idle');
47
- }
48
- }
49
- });
50
-
51
- editAsync(value, (error2, answer) => void editCallback(error2, answer), {
52
- postfix,
53
- ...fileProps,
54
- });
55
- }
56
-
57
- useEffect((rl) => {
58
- if (!waitForUseInput) {
59
- startEditor(rl);
60
- }
61
- }, []);
62
- useKeypress((key, rl) => {
63
- if (status !== 'idle') {
64
- return;
65
- }
66
-
67
- if (isEnterKey(key)) {
68
- startEditor(rl);
13
+ const {
14
+ waitForUseInput = true,
15
+ file: { postfix = config.postfix ?? ".txt", ...fileProps } = {},
16
+ validate = () => true
17
+ } = config;
18
+ const theme = makeTheme(config.theme);
19
+ const [status, setStatus] = useState("idle");
20
+ const [value, setValue] = useState(config.default || "");
21
+ const [errorMsg, setError] = useState();
22
+ const prefix = usePrefix({ status, theme });
23
+ function startEditor(rl) {
24
+ rl.pause();
25
+ const editCallback = AsyncResource.bind(
26
+ async (error2, answer) => {
27
+ rl.resume();
28
+ if (error2) {
29
+ setError(error2.toString());
30
+ } else {
31
+ setStatus("loading");
32
+ const isValid = await validate(answer);
33
+ if (isValid === true) {
34
+ setError(void 0);
35
+ setStatus("done");
36
+ done(answer);
37
+ } else {
38
+ setValue(answer);
39
+ setError(isValid || "You must provide a valid value");
40
+ setStatus("idle");
41
+ }
69
42
  }
43
+ }
44
+ );
45
+ editAsync(value, (error2, answer) => void editCallback(error2, answer), {
46
+ postfix,
47
+ ...fileProps
70
48
  });
71
- const message = theme.style.message(config.message, status);
72
- let helpTip = '';
73
-
74
- if (status === 'loading') {
75
- helpTip = theme.style.help('Received');
76
- } else if (status === 'idle') {
77
- const enterKey = theme.style.key('enter');
78
-
79
- helpTip = theme.style.help(`Press ${enterKey} to launch your preferred editor.`);
49
+ }
50
+ useEffect((rl) => {
51
+ if (!waitForUseInput) {
52
+ startEditor(rl);
53
+ }
54
+ }, []);
55
+ useKeypress((key, rl) => {
56
+ if (status !== "idle") {
57
+ return;
80
58
  }
81
-
82
-
83
- let error = '';
84
-
85
- if (errorMsg) {
86
- error = theme.style.error(errorMsg);
59
+ if (isEnterKey(key)) {
60
+ startEditor(rl);
87
61
  }
88
-
89
- return [
90
- [
91
- prefix,
92
- message,
93
- helpTip,
94
- ]
95
- .filter(Boolean)
96
- .join(' '),
97
- error,
98
- ];
62
+ });
63
+ const message = theme.style.message(config.message, status);
64
+ let helpTip = "";
65
+ if (status === "loading") {
66
+ helpTip = theme.style.help("Received");
67
+ } else if (status === "idle") {
68
+ const enterKey = theme.style.key("enter");
69
+ helpTip = theme.style.help(
70
+ `Press ${enterKey} to launch your preferred editor.`
71
+ );
72
+ }
73
+ let error = "";
74
+ if (errorMsg) {
75
+ error = theme.style.error(errorMsg);
76
+ }
77
+ return [[prefix, message, helpTip].filter(Boolean).join(" "), error];
99
78
  });