pi-extension-utils 0.5.1 → 0.5.2
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.
|
@@ -72,7 +72,12 @@ export interface PaneOverlaySplitOptions {
|
|
|
72
72
|
export interface PaneCollapseOptions {
|
|
73
73
|
key?: string;
|
|
74
74
|
collapsedWidth?: number;
|
|
75
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Legend/divider label for the collapse toggle. A function receives the
|
|
77
|
+
* current collapsed state so the hint can read e.g. "hide sidebar" when open
|
|
78
|
+
* and "open sidebar" when collapsed.
|
|
79
|
+
*/
|
|
80
|
+
label?: string | ((collapsed: boolean) => string);
|
|
76
81
|
}
|
|
77
82
|
export interface PaneOverlayOptions<T = unknown, Row = unknown> {
|
|
78
83
|
primary: PrimaryPaneOptions<Row>;
|
package/dist/src/pane/overlay.js
CHANGED
|
@@ -89,6 +89,10 @@ export function paneOverlay(options) {
|
|
|
89
89
|
let finished = false;
|
|
90
90
|
let focus = "primary";
|
|
91
91
|
let collapsed = false;
|
|
92
|
+
const collapseLabel = (fallback) => {
|
|
93
|
+
const label = collapse?.label;
|
|
94
|
+
return typeof label === "function" ? label(collapsed) : (label ?? fallback);
|
|
95
|
+
};
|
|
92
96
|
let leftFraction = split.initialFraction ?? 0.5;
|
|
93
97
|
let lastRenderWidth = 80;
|
|
94
98
|
let lastSelectedKey;
|
|
@@ -339,7 +343,7 @@ export function paneOverlay(options) {
|
|
|
339
343
|
if (!collapsed)
|
|
340
344
|
entries.push({ key: "[/]", label: "resize" });
|
|
341
345
|
if (collapse)
|
|
342
|
-
entries.push({ key: collapseKey, label:
|
|
346
|
+
entries.push({ key: collapseKey, label: collapseLabel("collapse") });
|
|
343
347
|
for (const action of customActions) {
|
|
344
348
|
if (action.showInLegend === false)
|
|
345
349
|
continue;
|
|
@@ -453,10 +457,16 @@ export function paneOverlay(options) {
|
|
|
453
457
|
: primaryRows.length > primaryHeight
|
|
454
458
|
? formatScrollInfo(primaryState.scrollOffset, Math.max(0, primaryRows.length - primaryHeight), { style: "position" })
|
|
455
459
|
: "");
|
|
456
|
-
const
|
|
457
|
-
|
|
460
|
+
const detailFooterBase = resolveValue(options.detail.footer, ctx) ??
|
|
461
|
+
(detailRows.length > detailHeight
|
|
458
462
|
? formatScrollInfo(detailState.scrollOffset, Math.max(0, detailRows.length - detailHeight), { style: "position" })
|
|
459
463
|
: "");
|
|
464
|
+
// When the primary pane is collapsed its legend (and the collapse hint with
|
|
465
|
+
// it) disappears, so the user can't see how to reopen it. Surface the
|
|
466
|
+
// reopen hint in the always-visible detail footer instead.
|
|
467
|
+
const detailFooterText = collapsed && collapse
|
|
468
|
+
? [`${collapseKey} ${collapseLabel("expand")}`, detailFooterBase].filter(Boolean).join(" \u00b7 ")
|
|
469
|
+
: detailFooterBase;
|
|
460
470
|
const bottomPrimary = titledBottomSegment(chromeTheme, primaryWidth, primaryFooterText, focus === "primary");
|
|
461
471
|
const bottomDetail = titledBottomSegment(chromeTheme, detailWidth, detailFooterText, focus === "detail");
|
|
462
472
|
const bottomBorder = primaryWidth === 0
|
|
@@ -474,7 +484,7 @@ export function paneOverlay(options) {
|
|
|
474
484
|
primaryCell = infoLines[row - infoStart - 1] ?? "";
|
|
475
485
|
}
|
|
476
486
|
else if (legendPlacement === "primary" && row === legendStart && legendLines.length > 0) {
|
|
477
|
-
primaryCell = flatRule(chromeTheme, collapse
|
|
487
|
+
primaryCell = flatRule(chromeTheme, collapse ? collapseLabel("actions") : "actions", primaryWidth);
|
|
478
488
|
}
|
|
479
489
|
if (legendPlacement === "primary" && row > legendStart) {
|
|
480
490
|
const legendIndex = row - legendStart - 1;
|