@xynogen/pix-ask 0.2.0 → 0.2.1
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 +4 -3
- package/src/frame.ts +5 -48
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xynogen/pix-ask",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "Pi tool
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "Pi tool \u2014 structured questionnaire UI (ask_user)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"scripts": {
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"typebox": "^1.1.38"
|
|
37
|
+
"typebox": "^1.1.38",
|
|
38
|
+
"@xynogen/pix-pretty": "*"
|
|
38
39
|
},
|
|
39
40
|
"peerDependencies": {
|
|
40
41
|
"@earendil-works/pi-coding-agent": "*",
|
package/src/frame.ts
CHANGED
|
@@ -1,49 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
// Re-export shared modal primitives from pix-pretty.
|
|
2
|
+
// pix-ask was the original home of frameLines/modalWidth; moved to pix-pretty
|
|
3
|
+
// so gate-overlay and confirm can share the same rounded frame style.
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const MARGIN = 4;
|
|
6
|
-
// 2 border cols + 2 padding spaces
|
|
7
|
-
const CHROME = 4;
|
|
8
|
-
|
|
9
|
-
export function modalWidth(termWidth: number): number {
|
|
10
|
-
return Math.min(MAX_WIDTH, Math.max(MIN_WIDTH, termWidth - MARGIN));
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function frameLines(opts: {
|
|
14
|
-
width: number;
|
|
15
|
-
lines: string[];
|
|
16
|
-
color: (s: string) => string;
|
|
17
|
-
bg?: (s: string) => string;
|
|
18
|
-
top?: string;
|
|
19
|
-
}): string[] {
|
|
20
|
-
const { width, lines, color, top } = opts;
|
|
21
|
-
const bg = opts.bg ?? ((s: string) => s);
|
|
22
|
-
const inner = Math.max(1, width - CHROME);
|
|
23
|
-
const dashes = "─".repeat(width - 2);
|
|
24
|
-
|
|
25
|
-
// Derive the bg OPEN sequence so we can re-assert it after any full reset
|
|
26
|
-
// (\x1b[0m) or bg reset (\x1b[49m) embedded in content — theme fg/bold spans
|
|
27
|
-
// emit \x1b[0m, which would otherwise punch transparent holes in the fill.
|
|
28
|
-
const SENTINEL = "\x00";
|
|
29
|
-
const bgOpen = bg(SENTINEL).split(SENTINEL)[0] ?? "";
|
|
30
|
-
const reassert = (s: string): string =>
|
|
31
|
-
bgOpen
|
|
32
|
-
? s.replace(/\x1b\[([0-9;]*)m/g, (seq, p: string) =>
|
|
33
|
-
p === "0" || p.split(";").includes("49") ? `${seq}${bgOpen}` : seq,
|
|
34
|
-
)
|
|
35
|
-
: s;
|
|
36
|
-
|
|
37
|
-
const row = (content: string): string => {
|
|
38
|
-
const pad = inner - visibleWidth(content);
|
|
39
|
-
const padded =
|
|
40
|
-
pad > 0 ? content + " ".repeat(pad) : truncateToWidth(content, inner);
|
|
41
|
-
return bg(`${color("│")} ${reassert(padded)} ${color("│")}`);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const out: string[] = [bg(color(`╭${dashes}╮`))];
|
|
45
|
-
if (top !== undefined) out.push(row(top));
|
|
46
|
-
for (const line of lines) out.push(row(line));
|
|
47
|
-
out.push(bg(color(`╰${dashes}╯`)));
|
|
48
|
-
return out;
|
|
49
|
-
}
|
|
5
|
+
export type { FrameOptions } from "@xynogen/pix-pretty/modal-frame";
|
|
6
|
+
export { frameLines, modalWidth } from "@xynogen/pix-pretty/modal-frame";
|