@ryan_nookpi/pi-extension-ask-user-question 0.3.1 → 0.3.3
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/package.json +1 -1
- package/view.test.ts +2 -2
- package/view.ts +5 -5
package/package.json
CHANGED
package/view.test.ts
CHANGED
|
@@ -197,7 +197,7 @@ describe("ask-user-question/view", () => {
|
|
|
197
197
|
const submitInput = createInput({ questions: submitQuestions, answerState: createAnswerState(submitQuestions) });
|
|
198
198
|
submitInput.answerState.radioAnswers.set("radio", { value: "custom", label: "custom", wasCustom: true });
|
|
199
199
|
submitInput.answerState.checkCustom.set("check", "custom");
|
|
200
|
-
renderSubmitTab(submitInput, (text) => submitLines.push(text)
|
|
200
|
+
renderSubmitTab(submitInput, (text) => submitLines.push(text));
|
|
201
201
|
expect(submitLines.join("\n")).toContain("(직접 입력) custom");
|
|
202
202
|
|
|
203
203
|
const unansweredLines: string[] = [];
|
|
@@ -206,7 +206,7 @@ describe("ask-user-question/view", () => {
|
|
|
206
206
|
answerState: createAnswerState(submitQuestions),
|
|
207
207
|
});
|
|
208
208
|
unansweredInput.answerState.checkAnswers.delete("check");
|
|
209
|
-
renderSubmitTab(unansweredInput, (text) => unansweredLines.push(text)
|
|
209
|
+
renderSubmitTab(unansweredInput, (text) => unansweredLines.push(text));
|
|
210
210
|
expect(unansweredLines.join("\n")).toContain("(미응답)");
|
|
211
211
|
|
|
212
212
|
const output = renderForm(createInput({ currentTab: 99 }));
|
package/view.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { truncateToWidth,
|
|
1
|
+
import { truncateToWidth, wrapTextWithAnsi } from "@mariozechner/pi-tui";
|
|
2
2
|
|
|
3
3
|
import { SYM } from "./constants.ts";
|
|
4
4
|
import { allRequiredAnswered, isAnswered } from "./state.ts";
|
|
@@ -7,12 +7,12 @@ import type { RenderFormInput } from "./types.ts";
|
|
|
7
7
|
function createLineHelpers(width: number, theme: RenderFormInput["theme"]) {
|
|
8
8
|
const lines: string[] = [];
|
|
9
9
|
const maxWidth = Math.min(width, 120);
|
|
10
|
-
const add = (text: string) => lines.push(
|
|
10
|
+
const add = (text: string) => lines.push(...wrapTextWithAnsi(text, maxWidth));
|
|
11
11
|
const hr = () => add(theme.fg("accent", "─".repeat(maxWidth)));
|
|
12
12
|
return { lines, maxWidth, add, hr };
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export function renderSubmitTab(input: RenderFormInput, add: (text: string) => void
|
|
15
|
+
export function renderSubmitTab(input: RenderFormInput, add: (text: string) => void): void {
|
|
16
16
|
const { questions, answerState, theme } = input;
|
|
17
17
|
add(` ${theme.fg("accent", theme.bold("검토 및 제출"))}`);
|
|
18
18
|
add("");
|
|
@@ -41,7 +41,7 @@ export function renderSubmitTab(input: RenderFormInput, add: (text: string) => v
|
|
|
41
41
|
|
|
42
42
|
const answer = answerState.textAnswers.get(question.id)?.trim();
|
|
43
43
|
if (answer) {
|
|
44
|
-
add(` ${label} ${
|
|
44
|
+
add(` ${label} ${answer}`);
|
|
45
45
|
} else {
|
|
46
46
|
add(` ${label} ${theme.fg("warning", "(미응답)")}`);
|
|
47
47
|
}
|
|
@@ -201,7 +201,7 @@ export function renderForm(input: RenderFormInput): string[] {
|
|
|
201
201
|
renderTabBar(input, add);
|
|
202
202
|
|
|
203
203
|
if (input.questions.length > 1 && input.currentTab === input.questions.length) {
|
|
204
|
-
renderSubmitTab(input, add
|
|
204
|
+
renderSubmitTab(input, add);
|
|
205
205
|
hr();
|
|
206
206
|
return lines;
|
|
207
207
|
}
|