@reliverse/rempts 1.7.52 → 1.7.53

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 (105) hide show
  1. package/bin/libs/animate/animate-mod.d.ts +14 -0
  2. package/bin/libs/animate/animate-mod.js +60 -0
  3. package/bin/libs/anykey/anykey-mod.d.ts +12 -0
  4. package/bin/libs/anykey/anykey-mod.js +125 -0
  5. package/bin/libs/cancel/cancel.d.ts +45 -0
  6. package/bin/libs/cancel/cancel.js +72 -0
  7. package/bin/libs/confirm/confirm-alias.d.ts +2 -0
  8. package/bin/libs/confirm/confirm-alias.js +2 -0
  9. package/bin/libs/confirm/confirm-mod.d.ts +5 -0
  10. package/bin/libs/confirm/confirm-mod.js +179 -0
  11. package/bin/libs/date/date.d.ts +2 -0
  12. package/bin/libs/date/date.js +214 -0
  13. package/bin/libs/editor/editor-mod.d.ts +25 -0
  14. package/bin/libs/editor/editor-mod.js +1133 -0
  15. package/bin/libs/figures/figures-mod.d.ts +461 -0
  16. package/bin/libs/figures/figures-mod.js +285 -0
  17. package/bin/libs/group/group-mod.d.ts +33 -0
  18. package/bin/libs/group/group-mod.js +89 -0
  19. package/bin/libs/input/input-alias.d.ts +5 -0
  20. package/bin/libs/input/input-alias.js +4 -0
  21. package/bin/libs/input/input-mod.d.ts +16 -0
  22. package/bin/libs/input/input-mod.js +372 -0
  23. package/bin/libs/intro/intro-alias.d.ts +3 -0
  24. package/bin/libs/intro/intro-alias.js +3 -0
  25. package/bin/libs/intro/intro-mod.d.ts +20 -0
  26. package/bin/libs/intro/intro-mod.js +77 -0
  27. package/bin/libs/launcher/command-runner.d.ts +31 -0
  28. package/bin/libs/launcher/command-runner.js +229 -0
  29. package/bin/libs/launcher/launcher-alias.d.ts +2 -0
  30. package/bin/libs/launcher/launcher-alias.js +2 -0
  31. package/bin/libs/launcher/launcher-mod.d.ts +66 -0
  32. package/bin/libs/launcher/launcher-mod.js +975 -0
  33. package/bin/libs/launcher/launcher-types.d.ts +176 -0
  34. package/bin/libs/launcher/launcher-types.js +0 -0
  35. package/bin/libs/log/log-alias.d.ts +1 -0
  36. package/bin/libs/log/log-alias.js +2 -0
  37. package/bin/libs/msg-fmt/colors.d.ts +30 -0
  38. package/bin/libs/msg-fmt/colors.js +42 -0
  39. package/bin/libs/msg-fmt/logger.d.ts +17 -0
  40. package/bin/libs/msg-fmt/logger.js +103 -0
  41. package/bin/libs/msg-fmt/mapping.d.ts +3 -0
  42. package/bin/libs/msg-fmt/mapping.js +41 -0
  43. package/bin/libs/msg-fmt/messages.d.ts +35 -0
  44. package/bin/libs/msg-fmt/messages.js +305 -0
  45. package/bin/libs/msg-fmt/terminal.d.ts +15 -0
  46. package/bin/libs/msg-fmt/terminal.js +60 -0
  47. package/bin/libs/msg-fmt/variants.d.ts +11 -0
  48. package/bin/libs/msg-fmt/variants.js +52 -0
  49. package/bin/libs/multiselect/multiselect-alias.d.ts +2 -0
  50. package/bin/libs/multiselect/multiselect-alias.js +2 -0
  51. package/bin/libs/multiselect/multiselect-prompt.d.ts +2 -0
  52. package/bin/libs/multiselect/multiselect-prompt.js +340 -0
  53. package/bin/libs/next-steps/next-steps.d.ts +13 -0
  54. package/bin/libs/next-steps/next-steps.js +24 -0
  55. package/bin/libs/number/number-mod.d.ts +28 -0
  56. package/bin/libs/number/number-mod.js +194 -0
  57. package/bin/libs/outro/outro-alias.d.ts +3 -0
  58. package/bin/libs/outro/outro-alias.js +3 -0
  59. package/bin/libs/outro/outro-mod.d.ts +8 -0
  60. package/bin/libs/outro/outro-mod.js +55 -0
  61. package/bin/libs/reliarg/reliarg-mod.d.ts +76 -0
  62. package/bin/libs/reliarg/reliarg-mod.js +276 -0
  63. package/bin/libs/results/results.d.ts +7 -0
  64. package/bin/libs/results/results.js +27 -0
  65. package/bin/libs/select/nummultiselect-prompt.d.ts +6 -0
  66. package/bin/libs/select/nummultiselect-prompt.js +101 -0
  67. package/bin/libs/select/numselect-prompt.d.ts +7 -0
  68. package/bin/libs/select/numselect-prompt.js +111 -0
  69. package/bin/libs/select/select-alias.d.ts +9 -0
  70. package/bin/libs/select/select-alias.js +9 -0
  71. package/bin/libs/select/select-prompt.d.ts +5 -0
  72. package/bin/libs/select/select-prompt.js +308 -0
  73. package/bin/libs/select/toggle-prompt.d.ts +5 -0
  74. package/bin/libs/select/toggle-prompt.js +207 -0
  75. package/bin/libs/spinner/spinner-alias.d.ts +2 -0
  76. package/bin/libs/spinner/spinner-alias.js +2 -0
  77. package/bin/libs/spinner/spinner-mod.d.ts +106 -0
  78. package/bin/libs/spinner/spinner-mod.js +255 -0
  79. package/bin/libs/task/progress.d.ts +2 -0
  80. package/bin/libs/task/progress.js +57 -0
  81. package/bin/libs/task/task-spin.d.ts +15 -0
  82. package/bin/libs/task/task-spin.js +106 -0
  83. package/bin/libs/utils/colorize.d.ts +2 -0
  84. package/bin/libs/utils/colorize.js +122 -0
  85. package/bin/libs/utils/errors.d.ts +1 -0
  86. package/bin/libs/utils/errors.js +17 -0
  87. package/bin/libs/utils/prevent.d.ts +8 -0
  88. package/bin/libs/utils/prevent.js +62 -0
  89. package/bin/libs/utils/prompt-end.d.ts +8 -0
  90. package/bin/libs/utils/prompt-end.js +34 -0
  91. package/bin/libs/utils/stream-text.d.ts +18 -0
  92. package/bin/libs/utils/stream-text.js +137 -0
  93. package/bin/libs/utils/system.d.ts +6 -0
  94. package/bin/libs/utils/system.js +7 -0
  95. package/bin/libs/utils/validate.d.ts +21 -0
  96. package/bin/libs/utils/validate.js +17 -0
  97. package/bin/libs/visual/visual-mod.d.ts +6 -0
  98. package/bin/libs/visual/visual-mod.js +13 -0
  99. package/bin/mod.d.ts +53 -0
  100. package/bin/mod.js +107 -0
  101. package/bin/types.d.ts +371 -0
  102. package/bin/types.js +0 -0
  103. package/package.json +34 -59
  104. package/dist-npm/bin/mod.d.mts +0 -1753
  105. package/dist-npm/bin/mod.mjs +0 -6779
@@ -0,0 +1,305 @@
1
+ import { re } from "@reliverse/relico";
2
+ import { relinka } from "@reliverse/relinka";
3
+ import { isUnicodeSupported } from "@reliverse/runtime";
4
+ import wrapAnsi from "wrap-ansi";
5
+ import { colorMap, typographyMap } from "./mapping.js";
6
+ import { deleteLastLines, getExactTerminalWidth, getTerminalWidth } from "./terminal.js";
7
+ import { isValidVariant, variantMap } from "./variants.js";
8
+ const unicode = isUnicodeSupported();
9
+ const u = (c, fallback) => unicode ? c : fallback;
10
+ export const symbols = {
11
+ pointer: u("\u{1F449}", ">"),
12
+ start: u("\u256D", "*"),
13
+ middle: u("\u2502", "|"),
14
+ end: u("\u2570", "*"),
15
+ line: u("\u2500", "\u2014"),
16
+ corner_top_right: u("\u256D", "*"),
17
+ step_active: u("\u25C6", "\u2666"),
18
+ step_error: u("\u{1F5F4}", "x"),
19
+ info: u("\u2139", "i"),
20
+ log: u("\u2502", "|"),
21
+ success: u("\u2705", "\u2713"),
22
+ warn: u("\u26A0", "!"),
23
+ error: u("\u274C", "x")
24
+ };
25
+ function wrapThenStyle(input, wrap, typographyName, colorName, variantName, borderColor) {
26
+ if (!input) return "";
27
+ const width = getTerminalWidth();
28
+ const wrappedText = wrap ? wrapAnsi(input, width, { hard: false, trim: true }) : input;
29
+ return wrappedText.split("\n").map((line) => applyStyles(line, colorName, typographyName, variantName, borderColor)).join("\n");
30
+ }
31
+ function applyStyles(text, colorName, typographyName, variantName, borderColor) {
32
+ let styledText = text;
33
+ if (variantName && isValidVariant(variantName)) {
34
+ styledText = variantMap[variantName]([styledText], void 0, borderColor).toString();
35
+ return styledText;
36
+ }
37
+ if (colorName && colorMap[colorName]) {
38
+ styledText = colorMap[colorName](styledText);
39
+ }
40
+ if (typographyName && typographyMap[typographyName]) {
41
+ styledText = typographyMap[typographyName](styledText);
42
+ }
43
+ return styledText;
44
+ }
45
+ export const bar = ({ borderColor = "dim" } = {}) => {
46
+ if (borderColor.endsWith("Gradient")) {
47
+ relinka(
48
+ "error",
49
+ "Gradient colors are not supported for bars. Please use a solid color instead."
50
+ );
51
+ return colorMap.dim(symbols.middle);
52
+ }
53
+ return colorMap[borderColor](symbols.middle);
54
+ };
55
+ function countLines(text) {
56
+ return text.split("\n").length;
57
+ }
58
+ function getColoredSymbol(customSymbol, symbolName, symbolColor) {
59
+ if (customSymbol) {
60
+ return symbolColor && colorMap[symbolColor] ? colorMap[symbolColor](customSymbol) : customSymbol;
61
+ }
62
+ if (symbolName && symbols[symbolName]) {
63
+ return symbolColor && colorMap[symbolColor] ? colorMap[symbolColor](symbols[symbolName]) : symbols[symbolName];
64
+ }
65
+ return;
66
+ }
67
+ function formatTitle(opts, borderTwoSpaces, borderError) {
68
+ let formattedTitle = "";
69
+ if (!opts.title) return formattedTitle;
70
+ const wrappedOrStyledTitle = wrapThenStyle(
71
+ opts.title,
72
+ opts.wrapTitle ?? true,
73
+ opts.titleTypography ?? "bold",
74
+ opts.titleColor ?? "cyan",
75
+ opts.titleVariant,
76
+ opts.borderColor
77
+ );
78
+ formattedTitle += wrappedOrStyledTitle;
79
+ if (opts.hint) {
80
+ const hintColor = opts.hintPlaceholderColor ?? "blue";
81
+ const wrappedHint = wrapThenStyle(
82
+ opts.hint,
83
+ opts.wrapTitle ?? true,
84
+ // same wrap logic as title by default
85
+ opts.hintTypography ?? "italic",
86
+ hintColor,
87
+ void 0,
88
+ opts.borderColor
89
+ );
90
+ formattedTitle += `
91
+ ${borderTwoSpaces}${wrappedHint}`;
92
+ }
93
+ if (opts.placeholder && opts.type === "M_GENERAL") {
94
+ const placeHolderColor = opts.hintPlaceholderColor ?? "blue";
95
+ formattedTitle += `
96
+ ${borderTwoSpaces}${colorMap[placeHolderColor](opts.placeholder)}`;
97
+ }
98
+ if (opts.errorMessage) {
99
+ const formattedError = applyStyles(
100
+ opts.errorMessage,
101
+ "red",
102
+ "bold",
103
+ void 0,
104
+ opts.borderColor
105
+ );
106
+ formattedTitle += `
107
+ ${borderError} ${formattedError}`;
108
+ }
109
+ return formattedTitle;
110
+ }
111
+ function formatContent(opts) {
112
+ if (!opts.content) return "";
113
+ return wrapThenStyle(
114
+ opts.content,
115
+ opts.wrapContent ?? true,
116
+ opts.contentTypography ?? "italic",
117
+ opts.contentColor ?? "dim",
118
+ opts.contentVariant,
119
+ opts.borderColor
120
+ );
121
+ }
122
+ export function fmt(opts) {
123
+ if (!opts.borderColor) {
124
+ opts.borderColor = "dim";
125
+ }
126
+ const borderColored = applyStyles(symbols.middle, opts.borderColor);
127
+ const borderError = applyStyles(symbols.middle, "red");
128
+ const borderTwoSpaces = `${borderColored} `;
129
+ const prefixStartLine = opts.borderColor ? colorMap[opts.borderColor](symbols.start + symbols.line) : symbols.start + symbols.line;
130
+ const prefixEndLine = opts.borderColor ? colorMap[opts.borderColor](symbols.end + symbols.line) : symbols.end + symbols.line;
131
+ const lineLength = opts.horizontalLineLength === 0 ? getExactTerminalWidth() - 3 : opts.horizontalLineLength ?? getExactTerminalWidth() - 3;
132
+ const suffixStartLine = opts.borderColor ? colorMap[opts.borderColor](`${symbols.line.repeat(lineLength)}\u22B1`) : `${symbols.line.repeat(lineLength)}\u22B1`;
133
+ const suffixEndLine = opts.borderColor ? colorMap[opts.borderColor](`${symbols.line.repeat(lineLength)}\u22B1`) : `${symbols.line.repeat(lineLength)}\u22B1`;
134
+ const computedSymbol = getColoredSymbol(opts.customSymbol, opts.symbol, opts.symbolColor) ?? re.green(symbols.step_active);
135
+ const MESSAGE_CONFIG_MAP = {
136
+ M_NULL: {
137
+ symbol: "",
138
+ prefix: borderTwoSpaces,
139
+ suffix: "",
140
+ newLineBefore: opts.addNewLineBefore ?? false,
141
+ newLineAfter: opts.addNewLineAfter ?? false
142
+ },
143
+ M_BAR: {
144
+ symbol: "",
145
+ prefix: "",
146
+ suffix: "",
147
+ newLineBefore: false,
148
+ newLineAfter: false
149
+ },
150
+ M_INFO_NULL: {
151
+ symbol: "",
152
+ prefix: borderTwoSpaces,
153
+ suffix: "",
154
+ newLineBefore: opts.addNewLineBefore ?? false,
155
+ newLineAfter: opts.addNewLineAfter ?? false
156
+ },
157
+ M_START: {
158
+ symbol: "",
159
+ prefix: "",
160
+ suffix: `
161
+ ${borderTwoSpaces}`,
162
+ newLineBefore: opts.addNewLineBefore ?? false,
163
+ newLineAfter: opts.addNewLineAfter ?? false
164
+ },
165
+ M_MIDDLE: {
166
+ symbol: "",
167
+ prefix: borderTwoSpaces,
168
+ suffix: "",
169
+ newLineBefore: opts.addNewLineBefore ?? false,
170
+ newLineAfter: opts.addNewLineAfter ?? false
171
+ },
172
+ M_GENERAL: {
173
+ symbol: computedSymbol,
174
+ prefix: borderTwoSpaces,
175
+ suffix: "",
176
+ newLineBefore: opts.addNewLineBefore ?? false,
177
+ newLineAfter: opts.addNewLineAfter ?? false
178
+ },
179
+ M_GENERAL_NULL: {
180
+ symbol: "",
181
+ prefix: borderTwoSpaces,
182
+ suffix: opts.placeholder ? colorMap[opts.hintPlaceholderColor ?? "blue"](opts.placeholder) : "",
183
+ newLineBefore: opts.addNewLineBefore ?? false,
184
+ newLineAfter: opts.addNewLineAfter ?? false
185
+ },
186
+ M_INFO: {
187
+ symbol: computedSymbol || re.green(symbols.info),
188
+ prefix: borderTwoSpaces,
189
+ suffix: "",
190
+ newLineBefore: opts.addNewLineBefore ?? false,
191
+ newLineAfter: opts.addNewLineAfter ?? true
192
+ },
193
+ M_ERROR: {
194
+ symbol: computedSymbol || re.redBright(symbols.step_error),
195
+ prefix: borderTwoSpaces,
196
+ suffix: "",
197
+ newLineBefore: opts.addNewLineBefore ?? false,
198
+ newLineAfter: opts.addNewLineAfter ?? false
199
+ },
200
+ M_ERROR_NULL: {
201
+ symbol: "",
202
+ prefix: borderTwoSpaces,
203
+ suffix: "",
204
+ newLineBefore: opts.addNewLineBefore ?? false,
205
+ newLineAfter: opts.addNewLineAfter ?? false
206
+ },
207
+ M_END: {
208
+ symbol: "",
209
+ prefix: "",
210
+ suffix: "",
211
+ newLineBefore: opts.addNewLineBefore ?? false,
212
+ newLineAfter: opts.addNewLineAfter ?? false
213
+ },
214
+ M_NEWLINE: {
215
+ symbol: "",
216
+ prefix: borderTwoSpaces,
217
+ suffix: "",
218
+ newLineBefore: opts.addNewLineBefore ?? false,
219
+ newLineAfter: opts.addNewLineAfter ?? false
220
+ }
221
+ };
222
+ const config = MESSAGE_CONFIG_MAP[opts.type];
223
+ if (!config) {
224
+ throw new Error(`Invalid message type: ${opts.type}`);
225
+ }
226
+ const { symbol, suffix, newLineBefore, newLineAfter } = config;
227
+ const finalTitle = formatTitle(opts, borderTwoSpaces, borderError);
228
+ const finalContent = formatContent(opts);
229
+ let text = "";
230
+ if (opts.type === "M_BAR") {
231
+ text = bar({ borderColor: opts.borderColor });
232
+ } else {
233
+ text = [finalTitle, finalContent].filter(Boolean).join("\n");
234
+ }
235
+ const fullText = [
236
+ newLineBefore ? `
237
+ ${borderTwoSpaces}` : "",
238
+ text,
239
+ newLineAfter ? `
240
+ ${borderTwoSpaces}` : "",
241
+ suffix
242
+ ].filter(Boolean).join("");
243
+ const lines = fullText.split("\n").map((line, index) => {
244
+ if (opts.type === "M_START") {
245
+ if (index === 0) {
246
+ return `${prefixStartLine} ${line} ${suffixStartLine}`;
247
+ }
248
+ if (index === 1) {
249
+ return borderTwoSpaces;
250
+ }
251
+ }
252
+ if (opts.type === "M_END" && opts.border && index === 0) {
253
+ if (!opts.title) return "";
254
+ return `${bar({ borderColor: opts.borderColor ?? "dim" })} ${line}`;
255
+ }
256
+ if (!line.trim() || line.includes(symbols.middle)) {
257
+ return line;
258
+ }
259
+ if (index === 0 && symbol) {
260
+ return `${symbol} ${line}`;
261
+ }
262
+ return `${config.prefix}${line}`;
263
+ });
264
+ if (opts.type === "M_END" && opts.border) {
265
+ lines.push(`${prefixEndLine}${suffixEndLine}
266
+ `);
267
+ }
268
+ const finalText = lines.join("\n");
269
+ const lineCount = countLines(finalText);
270
+ return { text: finalText, lineCount };
271
+ }
272
+ const printedLineStack = [];
273
+ export function msg(opts) {
274
+ const { text, lineCount } = fmt(opts);
275
+ if (opts.type === "M_BAR" && opts.noNewLine) {
276
+ process.stdout.write(text);
277
+ } else {
278
+ process.stdout.write(`${text}
279
+ `);
280
+ }
281
+ printedLineStack.push(opts.type === "M_BAR" && opts.noNewLine ? lineCount : lineCount + 1);
282
+ }
283
+ export function msgUndo(count = 1) {
284
+ for (let i = 0; i < count; i++) {
285
+ const linesToDelete = printedLineStack.pop();
286
+ if (typeof linesToDelete === "number" && linesToDelete > 0) {
287
+ deleteLastLines(linesToDelete);
288
+ }
289
+ }
290
+ }
291
+ export function msgUndoAll() {
292
+ while (printedLineStack.length > 0) {
293
+ const linesToDelete = printedLineStack.pop();
294
+ if (typeof linesToDelete === "number" && linesToDelete > 0) {
295
+ deleteLastLines(linesToDelete);
296
+ }
297
+ }
298
+ }
299
+ export function printLineBar(text, indent = 2) {
300
+ if (text === "") {
301
+ relinka("log", re.dim("\u2502"));
302
+ } else {
303
+ relinka("log", `${re.dim("\u2502")}${" ".repeat(indent)}${text}`);
304
+ }
305
+ }
@@ -0,0 +1,15 @@
1
+ export declare function getTerminalHeight(): number;
2
+ export declare function getExactTerminalWidth(): number;
3
+ export declare function getTerminalWidth(terminalWidth?: number): number;
4
+ /**
5
+ * Force line returns at specific width. This function is ANSI code friendly and it'll
6
+ * ignore invisible codes during width calculation.
7
+ * @param {string} content
8
+ * @return {string}
9
+ */
10
+ export declare function breakLines(content: string, terminalWidth?: number): string;
11
+ export declare function removeCursor(): void;
12
+ export declare function restoreCursor(): void;
13
+ export declare function deleteLastLine(): void;
14
+ export declare function deleteLastLines(count: number): void;
15
+ export declare function countLines(text: string): number;
@@ -0,0 +1,60 @@
1
+ import { relinka } from "@reliverse/relinka";
2
+ import ansiEscapes from "ansi-escapes";
3
+ import { cursor } from "sisteransi";
4
+ import terminalSize from "terminal-size";
5
+ import wrapAnsi from "wrap-ansi";
6
+ export function getTerminalHeight() {
7
+ return terminalSize().rows ?? 24;
8
+ }
9
+ export function getExactTerminalWidth() {
10
+ return terminalSize().columns ?? 80;
11
+ }
12
+ export function getTerminalWidth(terminalWidth = 0) {
13
+ if (terminalWidth === 0) {
14
+ terminalWidth = getExactTerminalWidth();
15
+ }
16
+ if (terminalWidth > 150) {
17
+ return terminalWidth - 40;
18
+ }
19
+ if (terminalWidth > 120) {
20
+ return terminalWidth - 30;
21
+ }
22
+ if (terminalWidth > 100) {
23
+ return terminalWidth - 20;
24
+ }
25
+ return terminalWidth;
26
+ }
27
+ export function breakLines(content, terminalWidth = 0) {
28
+ if (terminalWidth === 0) {
29
+ terminalWidth = getTerminalWidth();
30
+ }
31
+ return content.split("\n").flatMap(
32
+ (line) => wrapAnsi(line, terminalWidth, { trim: false, hard: true }).split("\n").map((str) => str.trimEnd())
33
+ ).join("\n");
34
+ }
35
+ export function removeCursor() {
36
+ process.stdout.write(cursor.hide);
37
+ }
38
+ export function restoreCursor() {
39
+ process.stdout.write(cursor.show);
40
+ }
41
+ export function deleteLastLine() {
42
+ process.stdout.write(ansiEscapes.cursorUp(1) + ansiEscapes.eraseLine);
43
+ }
44
+ export function deleteLastLines(count) {
45
+ if (count <= 0) {
46
+ relinka("error", "Count is less than or equal to 0. Nothing to delete.");
47
+ return;
48
+ }
49
+ process.stdout.write(ansiEscapes.eraseLines(count));
50
+ }
51
+ export function countLines(text) {
52
+ const adjustedWidth = getTerminalWidth();
53
+ const lines = text.split("\n");
54
+ let lineCount = 0;
55
+ for (const line of lines) {
56
+ const wrapped = wrapAnsi(line, adjustedWidth, { hard: true });
57
+ lineCount += wrapped.split("\n").length;
58
+ }
59
+ return lineCount;
60
+ }
@@ -0,0 +1,11 @@
1
+ import type { ColorName, VariantName } from "../../types";
2
+ export declare const variantMap: {
3
+ doubleBox: typeof createDoubleBox;
4
+ };
5
+ type ValidVariant = keyof typeof variantMap;
6
+ export declare function isValidVariant(variant: string | undefined): variant is ValidVariant;
7
+ export declare function applyVariant(lines: string[] | string, variant?: VariantName, options?: {
8
+ limit?: number;
9
+ }, borderColor?: ColorName): Promise<string>;
10
+ declare function createDoubleBox(lines: string[], limit?: number, borderColor?: ColorName): string;
11
+ export {};
@@ -0,0 +1,52 @@
1
+ import { colorMap } from "./mapping.js";
2
+ export const variantMap = {
3
+ // box: createBox,
4
+ doubleBox: createDoubleBox
5
+ // banner: createBanner,
6
+ // underline: createUnderline,
7
+ };
8
+ export function isValidVariant(variant) {
9
+ return variant !== void 0 && variant !== "none" && variant in variantMap;
10
+ }
11
+ export async function applyVariant(lines, variant, options, borderColor) {
12
+ const linesArray = Array.isArray(lines) ? lines : [lines];
13
+ switch (variant) {
14
+ // case "box":
15
+ // return createBox(linesArray, options?.limit);
16
+ case "doubleBox":
17
+ return createDoubleBox(linesArray, options?.limit, borderColor);
18
+ // case "banner":
19
+ // return createBanner(linesArray);
20
+ // case "underline":
21
+ // return createUnderline(linesArray);
22
+ default:
23
+ return linesArray.join("\n");
24
+ }
25
+ }
26
+ function createDoubleBox(lines, limit, borderColor) {
27
+ const processedLines = processLines(lines, limit);
28
+ const maxLength = Math.max(...processedLines.map((line) => line.length));
29
+ const indentation = "";
30
+ if (borderColor === void 0) {
31
+ borderColor = "dim";
32
+ }
33
+ const topBorder = borderColor ? colorMap[borderColor](`${"\u2550".repeat(maxLength)}\u2557`) : `${"\u2550".repeat(maxLength)}\u2557`;
34
+ const bottomBorder = borderColor ? colorMap[borderColor](`${indentation}\u255A${"\u2550".repeat(maxLength + 2)}\u255D`) : `${indentation}\u255A${"\u2550".repeat(maxLength + 2)}\u255D`;
35
+ const middle = processedLines.map((line, index) => {
36
+ const lineIndentation = index === 0 ? indentation : `${indentation} `;
37
+ return `${lineIndentation}${borderColor ? colorMap[borderColor]("\u2551") : "\u2551"} ${colorMap[borderColor](line.padEnd(maxLength))} ${borderColor ? colorMap[borderColor]("\u2551") : "\u2551"}`;
38
+ }).join("\n");
39
+ return `${topBorder}
40
+ ${middle}
41
+ ${bottomBorder}`;
42
+ }
43
+ function processLines(lines, limit) {
44
+ const linesArray = Array.isArray(lines) ? lines : [lines];
45
+ return linesArray.map((line) => {
46
+ let truncatedLine = line;
47
+ if (limit && line.length > limit) {
48
+ truncatedLine = `${line.slice(0, limit - 3)}...`;
49
+ }
50
+ return truncatedLine.padEnd(limit || truncatedLine.length);
51
+ });
52
+ }
@@ -0,0 +1,2 @@
1
+ import type { MultiselectPromptParams } from "../../types";
2
+ export declare const multiselect: <T extends string>(params: MultiselectPromptParams<T>) => Promise<T[]>;
@@ -0,0 +1,2 @@
1
+ import { multiselectPrompt } from "../multiselect/multiselect-prompt.js";
2
+ export const multiselect = multiselectPrompt;
@@ -0,0 +1,2 @@
1
+ import type { MultiselectPromptParams } from "../../types";
2
+ export declare function multiselectPrompt<T extends string>(params: MultiselectPromptParams<T>): Promise<T[]>;