@xynogen/pix-pretty 1.7.26 → 1.7.27
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/src/gate-overlay.test.ts +20 -1
- package/src/gate-overlay.ts +2 -2
package/package.json
CHANGED
package/src/gate-overlay.test.ts
CHANGED
|
@@ -27,7 +27,10 @@ interface Wired {
|
|
|
27
27
|
* the SelectList keys; simpler: we expose the live component so the test can
|
|
28
28
|
* call its handlers. We do the latter via the captured component ref.
|
|
29
29
|
*/
|
|
30
|
-
function makeUI(
|
|
30
|
+
function makeUI(
|
|
31
|
+
onReady: (comp: Wired, finish: (v: unknown) => void) => void,
|
|
32
|
+
onOptions?: (options: unknown) => void,
|
|
33
|
+
): OverlayUI {
|
|
31
34
|
return {
|
|
32
35
|
custom: async <T>(
|
|
33
36
|
cb: (
|
|
@@ -36,7 +39,9 @@ function makeUI(onReady: (comp: Wired, finish: (v: unknown) => void) => void): O
|
|
|
36
39
|
kb: unknown,
|
|
37
40
|
done: (v: T) => void,
|
|
38
41
|
) => Wired,
|
|
42
|
+
options?: unknown,
|
|
39
43
|
): Promise<T | undefined> => {
|
|
44
|
+
onOptions?.(options);
|
|
40
45
|
let resolved: T | undefined;
|
|
41
46
|
const done = (v: T) => {
|
|
42
47
|
resolved = v;
|
|
@@ -55,6 +60,20 @@ const ENTER = "\r";
|
|
|
55
60
|
const DOWN = "\x1b[B";
|
|
56
61
|
|
|
57
62
|
describe("showOverlay — confirm mode", () => {
|
|
63
|
+
test("caps overlay at 80% of terminal height", async () => {
|
|
64
|
+
let options: unknown;
|
|
65
|
+
await showOverlay(
|
|
66
|
+
makeUI(
|
|
67
|
+
(comp) => comp.handleInput(ENTER),
|
|
68
|
+
(value) => {
|
|
69
|
+
options = value;
|
|
70
|
+
},
|
|
71
|
+
),
|
|
72
|
+
{ mode: "confirm", title: "T" },
|
|
73
|
+
);
|
|
74
|
+
expect(options).toEqual({ overlay: true, overlayOptions: { maxHeight: "80%" } });
|
|
75
|
+
});
|
|
76
|
+
|
|
58
77
|
test("selecting the approve choice (first) returns approved", async () => {
|
|
59
78
|
const result = await showOverlay(
|
|
60
79
|
makeUI((comp) => {
|
package/src/gate-overlay.ts
CHANGED
|
@@ -100,7 +100,7 @@ export interface OverlayUI {
|
|
|
100
100
|
kb: unknown,
|
|
101
101
|
done: (v: T) => void,
|
|
102
102
|
) => OverlayComponent,
|
|
103
|
-
opts?: { overlay?: boolean },
|
|
103
|
+
opts?: { overlay?: boolean; overlayOptions?: { maxHeight?: number | `${number}%` } },
|
|
104
104
|
): Promise<T | undefined>;
|
|
105
105
|
}
|
|
106
106
|
|
|
@@ -355,7 +355,7 @@ export function showOverlay(ui: OverlayUI, config: OverlayConfig): Promise<Overl
|
|
|
355
355
|
},
|
|
356
356
|
};
|
|
357
357
|
},
|
|
358
|
-
{ overlay: true },
|
|
358
|
+
{ overlay: true, overlayOptions: { maxHeight: "80%" } },
|
|
359
359
|
).then((result) => {
|
|
360
360
|
resolve(result ?? { action: "denied" });
|
|
361
361
|
});
|