@rbbtsn0w/adg 0.9.0-beta.1 → 0.9.0-dev.pr109.acb1932
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.
|
@@ -20,6 +20,7 @@ const S_BAR_END = g("└", "—");
|
|
|
20
20
|
const S_STEP_ACTIVE = g("◆", "*");
|
|
21
21
|
const S_STEP_SUBMIT = g("◇", "o");
|
|
22
22
|
const S_STEP_CANCEL = g("■", "x");
|
|
23
|
+
const S_STEP_ERROR = g("▲", "!");
|
|
23
24
|
const S_CHECK_ACTIVE = g("◻", "[•]");
|
|
24
25
|
const S_CHECK_SELECTED = g("◼", "[+]");
|
|
25
26
|
const S_CHECK_INACTIVE = g("◻", "[ ]");
|
|
@@ -59,17 +60,20 @@ export function multiselectSkills(opts) {
|
|
|
59
60
|
return pc.green(S_STEP_SUBMIT);
|
|
60
61
|
if (state === "cancel")
|
|
61
62
|
return pc.red(S_STEP_CANCEL);
|
|
63
|
+
if (state === "error")
|
|
64
|
+
return pc.yellow(S_STEP_ERROR);
|
|
62
65
|
return pc.cyan(S_STEP_ACTIVE);
|
|
63
66
|
};
|
|
64
67
|
const footer = () => pc.dim(`space ${pc.gray("toggle")} · a ${pc.gray("all")} · d ${pc.gray(showDesc ? "hide" : "show")} descriptions`);
|
|
68
|
+
const required = opts.required ?? true;
|
|
65
69
|
const prompt = new MultiSelectPrompt({
|
|
66
70
|
input: opts.input,
|
|
67
71
|
output: opts.output,
|
|
68
72
|
options: opts.options,
|
|
69
73
|
initialValues: opts.initialValues,
|
|
70
|
-
required
|
|
74
|
+
required,
|
|
71
75
|
validate(value) {
|
|
72
|
-
if (
|
|
76
|
+
if (required && Array.isArray(value) && value.length === 0) {
|
|
73
77
|
return "Please select at least one option.";
|
|
74
78
|
}
|
|
75
79
|
return undefined;
|
|
@@ -90,7 +94,10 @@ export function multiselectSkills(opts) {
|
|
|
90
94
|
showDesc,
|
|
91
95
|
loadDescription: opts.loadDescription,
|
|
92
96
|
}).join(`\n${pc.cyan(S_BAR)} `);
|
|
93
|
-
|
|
97
|
+
const errorBar = this.state === "error" && this.error
|
|
98
|
+
? `${pc.yellow(S_BAR_END)} ${pc.yellow(this.error)}\n`
|
|
99
|
+
: `${pc.cyan(S_BAR_END)}\n`;
|
|
100
|
+
return `${head}${pc.cyan(S_BAR)} ${rows}\n${pc.cyan(S_BAR)} ${footer()}\n${errorBar}`;
|
|
94
101
|
},
|
|
95
102
|
});
|
|
96
103
|
// `a` (toggle-all) is bound by MultiSelectPrompt itself; `d` is free for us.
|