lite-questionnaire 1.0.5 → 1.0.6
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/core.ts +1 -0
- package/index.ts +11 -3
- package/input.ts +1 -1
- package/package.json +1 -1
- package/render.ts +2 -1
package/core.ts
CHANGED
|
@@ -183,6 +183,7 @@ export class Core {
|
|
|
183
183
|
* 优先检查持久化答案;没有答案时再检查当前 UI 草稿/默认值。
|
|
184
184
|
*/
|
|
185
185
|
hasAnyValue(q: FlatQuestion, state?: QuestionUIState): boolean {
|
|
186
|
+
if (q.id === "__lq_notes__") return true;
|
|
186
187
|
const answer = this.answers.get(q.id);
|
|
187
188
|
if (this.answerHasValue(answer)) return true;
|
|
188
189
|
|
package/index.ts
CHANGED
|
@@ -14,7 +14,7 @@ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
|
14
14
|
import { Type } from "typebox";
|
|
15
15
|
import { Editor, type EditorTheme, Text, truncateToWidth } from "@earendil-works/pi-tui";
|
|
16
16
|
import { Core } from "./core";
|
|
17
|
-
import type { Answer, CancelledResult, QuestionnaireParams, QuestionnaireResult } from "./types";
|
|
17
|
+
import type { Answer, CancelledResult, QuestionnaireParams, QuestionnaireResult, Question } from "./types";
|
|
18
18
|
import {
|
|
19
19
|
panelTop,
|
|
20
20
|
panelBottom,
|
|
@@ -177,8 +177,16 @@ export default function questionnaire(pi: ExtensionAPI) {
|
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
const core = new Core();
|
|
180
|
-
|
|
181
|
-
|
|
180
|
+
const notesQuestion: Question = {
|
|
181
|
+
id: "__lq_notes__",
|
|
182
|
+
label: "备注",
|
|
183
|
+
prompt: "有什么需要补充说明的吗?",
|
|
184
|
+
type: "text",
|
|
185
|
+
placeholder: "输入备注内容(可选)...",
|
|
186
|
+
};
|
|
187
|
+
const allQuestions = [...input.questions, notesQuestion];
|
|
188
|
+
core.init(allQuestions);
|
|
189
|
+
const originalQuestions = allQuestions;
|
|
182
190
|
const snapshotKey = questionnaireKey(originalQuestions);
|
|
183
191
|
const snapshot = loadSnapshot(
|
|
184
192
|
ctx.sessionManager.getBranch() as Array<{ type: string; customType?: string; data?: unknown }>,
|
package/input.ts
CHANGED
package/package.json
CHANGED
package/render.ts
CHANGED
|
@@ -108,7 +108,7 @@ export function renderTabBar(
|
|
|
108
108
|
// 提交 Tab
|
|
109
109
|
const isSubmit = core.isSubmitTab();
|
|
110
110
|
const allDone = core.allAnswered();
|
|
111
|
-
let submitText = " ✓
|
|
111
|
+
let submitText = " ✓ 提交 ";
|
|
112
112
|
if (isSubmit) {
|
|
113
113
|
submitText = theme.bg("selectedBg", allDone ? theme.fg("success", submitText) : theme.fg("text", submitText));
|
|
114
114
|
} else if (allDone) {
|
|
@@ -190,6 +190,7 @@ export function renderSubmitPage(
|
|
|
190
190
|
|
|
191
191
|
for (const q of core.questions) {
|
|
192
192
|
const answer = core.answers.get(q.id);
|
|
193
|
+
if (q.id === "__lq_notes__" && !answer) continue;
|
|
193
194
|
if (!answer) {
|
|
194
195
|
lines.push(` ⚠ ${theme.fg("error", q.label)}: ${theme.fg("dim", "(未回答)")}`);
|
|
195
196
|
} else if ('text' in answer) {
|