@reliverse/relinka 1.1.4 → 1.1.5

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.
@@ -10,7 +10,6 @@ export async function confirmPrompt(options) {
10
10
  defaultValue,
11
11
  schema,
12
12
  titleColor = "cyanBright",
13
- answerColor = "none",
14
13
  titleTypography = "bold",
15
14
  titleVariant,
16
15
  content,
@@ -70,7 +70,6 @@ export async function datePrompt(options) {
70
70
  defaultValue,
71
71
  schema,
72
72
  titleColor = "cyanBright",
73
- answerColor = "none",
74
73
  titleTypography = "bold",
75
74
  titleVariant,
76
75
  content,
@@ -113,7 +112,7 @@ export async function datePrompt(options) {
113
112
  msg({
114
113
  type: "M_MIDDLE",
115
114
  title: ` ${defaultValue}`,
116
- titleColor: answerColor
115
+ titleColor: "none"
117
116
  });
118
117
  }
119
118
  if (!Value.Check(dateFormatSchema, answer)) {
@@ -15,7 +15,6 @@ export async function textPrompt(options) {
15
15
  defaultValue = "",
16
16
  schema,
17
17
  titleColor = "cyanBright",
18
- answerColor = "none",
19
18
  titleTypography = "bold",
20
19
  titleVariant,
21
20
  content,
@@ -23,11 +22,14 @@ export async function textPrompt(options) {
23
22
  contentTypography,
24
23
  contentVariant,
25
24
  borderColor = "viceGradient",
26
- variantOptions
25
+ variantOptions,
26
+ placeholder
27
27
  } = options;
28
28
  const rl = readline.createInterface({ input, output });
29
29
  let linesToDelete = 0;
30
30
  let errorMessage = "";
31
+ let currentInput = "";
32
+ let showPlaceholder = true;
31
33
  while (true) {
32
34
  if (linesToDelete > 0) {
33
35
  deleteLastLines(linesToDelete);
@@ -44,14 +46,23 @@ export async function textPrompt(options) {
44
46
  contentVariant,
45
47
  borderColor,
46
48
  hint,
49
+ placeholder: showPlaceholder ? placeholder : void 0,
47
50
  variantOptions,
48
51
  errorMessage
49
52
  });
50
53
  const questionLines = countLines(question);
51
54
  const prompt = await rl.question(question);
55
+ currentInput = prompt.trim();
56
+ if (showPlaceholder && currentInput !== "") {
57
+ showPlaceholder = false;
58
+ deleteLastLine();
59
+ deleteLastLine();
60
+ msg({ type: "M_MIDDLE", title: ` ${currentInput}` });
61
+ }
52
62
  linesToDelete = questionLines + 1;
53
- const answer = prompt.trim() || defaultValue;
54
- if (prompt.trim() === "" && defaultValue !== "") {
63
+ const answer = currentInput || defaultValue;
64
+ if (currentInput === "" && defaultValue !== "") {
65
+ deleteLastLine();
55
66
  deleteLastLine();
56
67
  const defaultMsg = fmt({
57
68
  type: "M_MIDDLE",
@@ -15,7 +15,6 @@ export async function multiselectPrompt(options) {
15
15
  schema,
16
16
  defaultValue,
17
17
  titleColor = "cyanBright",
18
- answerColor = "none",
19
18
  titleTypography = "bold",
20
19
  titleVariant,
21
20
  hint,
@@ -74,7 +73,7 @@ ${formattedBar} `;
74
73
  msg({
75
74
  type: "M_MIDDLE",
76
75
  title: ` ${Array.isArray(defaultValue) ? defaultValue.join(", ") : defaultValue}`,
77
- titleColor: answerColor
76
+ titleColor: "none"
78
77
  });
79
78
  msg({ type: "M_NEWLINE" });
80
79
  return defaultValue;
@@ -15,7 +15,6 @@ export async function numMultiSelectPrompt(options) {
15
15
  schema,
16
16
  defaultValue,
17
17
  titleColor = "cyanBright",
18
- answerColor = "none",
19
18
  titleTypography = "bold",
20
19
  titleVariant,
21
20
  hint,
@@ -74,7 +73,7 @@ ${formattedBar} `;
74
73
  msg({
75
74
  type: "M_MIDDLE",
76
75
  title: ` ${Array.isArray(defaultValue) ? defaultValue.join(", ") : defaultValue}`,
77
- titleColor: answerColor
76
+ titleColor: "none"
78
77
  });
79
78
  msg({ type: "M_NEWLINE" });
80
79
  return defaultValue;
@@ -3,7 +3,6 @@ export async function nextStepsPrompt(options) {
3
3
  const {
4
4
  title,
5
5
  titleColor = "cyanBright",
6
- answerColor = "none",
7
6
  titleVariant,
8
7
  titleTypography = "bold",
9
8
  content,
@@ -15,7 +15,6 @@ export async function numberPrompt(options) {
15
15
  defaultValue,
16
16
  schema,
17
17
  titleColor = "cyanBright",
18
- answerColor = "none",
19
18
  titleTypography = "bold",
20
19
  titleVariant,
21
20
  content,
@@ -12,7 +12,6 @@ export async function passwordPrompt(options) {
12
12
  schema,
13
13
  defaultValue,
14
14
  titleColor = "cyanBright",
15
- answerColor = "none",
16
15
  titleTypography = "bold",
17
16
  titleVariant,
18
17
  content,
@@ -16,7 +16,6 @@ export async function numSelectPrompt(options) {
16
16
  defaultValue,
17
17
  schema,
18
18
  titleColor = "cyanBright",
19
- answerColor = "none",
20
19
  titleTypography = "bold",
21
20
  titleVariant,
22
21
  content,
@@ -83,7 +82,7 @@ ${formattedBar} `
83
82
  msg({
84
83
  type: "M_MIDDLE",
85
84
  title: ` ${defaultValue}`,
86
- titleColor: answerColor
85
+ titleColor: "none"
87
86
  });
88
87
  }
89
88
  const num = Number(answer);
@@ -11,7 +11,6 @@ export async function selectPrompt(options) {
11
11
  defaultValue,
12
12
  schema,
13
13
  titleColor = "cyanBright",
14
- answerColor = "none",
15
14
  titleTypography = "bold"
16
15
  } = options;
17
16
  if (schema) {
@@ -1,2 +1,2 @@
1
1
  import type { PromptOptions } from "../../types/general.js";
2
- export declare function endPrompt({ title, titleColor, answerColor, titleTypography, titleVariant, titleAnimation, titleAnimationDelay, border, borderColor, }: PromptOptions): Promise<void>;
2
+ export declare function endPrompt({ title, titleColor, titleTypography, titleVariant, titleAnimation, titleAnimationDelay, border, borderColor, }: PromptOptions): Promise<void>;
@@ -3,7 +3,6 @@ import { msg } from "../../utils/messages.js";
3
3
  export async function endPrompt({
4
4
  title,
5
5
  titleColor = "cyanBright",
6
- answerColor = "none",
7
6
  titleTypography = "bold",
8
7
  titleVariant,
9
8
  titleAnimation,
@@ -1,2 +1,2 @@
1
1
  import type { PromptOptions } from "../../types/general.js";
2
- export declare function startPrompt({ title, titleColor, answerColor, titleTypography, titleVariant, borderColor, clearConsole, }: PromptOptions): Promise<void>;
2
+ export declare function startPrompt({ title, titleColor, titleTypography, titleVariant, borderColor, clearConsole, }: PromptOptions): Promise<void>;
@@ -2,7 +2,6 @@ import { msg } from "../../utils/messages.js";
2
2
  export async function startPrompt({
3
3
  title,
4
4
  titleColor = "cyanBright",
5
- answerColor = "none",
6
5
  titleTypography = "bold",
7
6
  titleVariant,
8
7
  borderColor = "viceGradient",
@@ -37,6 +37,7 @@ export type FmtMsgOptions = {
37
37
  errorMessage?: string;
38
38
  addNewLineBefore?: boolean;
39
39
  addNewLineAfter?: boolean;
40
+ placeholder?: string;
40
41
  };
41
42
  export type RequiredPromptOptions = {
42
43
  id: string;
@@ -54,6 +55,7 @@ export type OptionalPromptOptions<T extends TSchema = any> = {
54
55
  contentTypography?: TypographyName;
55
56
  contentVariant?: Variant;
56
57
  hint?: string;
58
+ placeholder?: string;
57
59
  validate?: (value: any) => boolean | string | Promise<boolean | string>;
58
60
  defaultValue?: string | string[] | number | boolean;
59
61
  defaultColor?: ColorName;
@@ -69,7 +71,6 @@ export type OptionalPromptOptions<T extends TSchema = any> = {
69
71
  borderColor?: ColorName;
70
72
  clearConsole?: boolean;
71
73
  additionalLinesToDelete?: number;
72
- answerColor?: ColorName;
73
74
  hintColor?: ColorName;
74
75
  hints?: string[];
75
76
  required?: boolean;
@@ -1,4 +1,4 @@
1
- import { greenBright, redBright } from "picocolors";
1
+ import { greenBright, redBright, dim } from "picocolors";
2
2
  import { colorMap, typographyMap } from "../utils/mapping.js";
3
3
  import { isUnicodeSupported } from "../utils/platforms.js";
4
4
  import { variantMap } from "../utils/variants.js";
@@ -90,7 +90,7 @@ ${formattedBar}`,
90
90
  M_GENERAL: {
91
91
  symbol: "",
92
92
  prefix: greenBright(symbols.step_active),
93
- suffix: "",
93
+ suffix: opts.placeholder ? dim(opts.placeholder) + "\n" + formattedBar + " " : "",
94
94
  newLineBefore: opts.addNewLineBefore ?? false,
95
95
  newLineAfter: opts.addNewLineAfter ?? true
96
96
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reliverse/relinka",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "type": "module",
5
5
  "description": "@reliverse/relinka is a powerful library that enables seamless, typesafe, and resilient prompts for command-line applications. Crafted with simplicity and elegance, it provides developers with an intuitive and robust way to build interactive CLIs.",
6
6
  "scripts": {