gloomberb 0.20.8 → 0.20.10
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/api-client/auth.ts +6 -0
- package/src/api-client/data.ts +1 -0
- package/src/api-client/earnings.ts +15 -0
- package/src/api-client/futures-curve.ts +5 -1
- package/src/api-client/index.ts +14 -3
- package/src/api-client/types/account.ts +10 -0
- package/src/api-client/types/billing.ts +10 -0
- package/src/api-client/types/econ.ts +19 -7
- package/src/api-client/types/market.ts +7 -0
- package/src/api-client/types/screener.ts +2 -0
- package/src/cli/commands/market.ts +18 -8
- package/src/cli/commands/overview.ts +28 -7
- package/src/cli/commands/ticker.ts +40 -15
- package/src/cli/desktop-pane-shot.ts +39 -0
- package/src/cli/errors.ts +20 -3
- package/src/cli/fx-pair.ts +11 -2
- package/src/cli/history-rows.ts +34 -3
- package/src/cli/index.ts +1 -1
- package/src/cli/listing-arg.ts +51 -13
- package/src/cli/pane-functions/data.ts +3 -2
- package/src/cli/pane-functions/headless.ts +5 -2
- package/src/cli/pane-functions/index.ts +1 -0
- package/src/cli/pane-functions/resolver.ts +2 -1
- package/src/cli/pane-functions/screenshot-assessment.ts +73 -5
- package/src/cli/pane-functions/screenshot-types.ts +4 -0
- package/src/cli/symbol-cells.ts +6 -0
- package/src/cli/symbol-list.ts +14 -6
- package/src/cli/symbol-rows.ts +12 -5
- package/src/components/chart/composite/chart-layout.ts +7 -4
- package/src/components/chart/composite/composite-chart.tsx +6 -16
- package/src/components/chart/composite/toolbar.tsx +258 -82
- package/src/components/chart/composite/use-composite-chart-keyboard.ts +5 -6
- package/src/components/command-bar/list/model.ts +13 -0
- package/src/components/command-bar/routes/ticker-search/actions.ts +2 -0
- package/src/components/command-bar/routes/ticker-search/results.ts +15 -8
- package/src/components/command-bar/surface/index.tsx +10 -5
- package/src/components/command-bar/workflow/alert.ts +21 -7
- package/src/components/data-table/table-pane.ts +3 -1
- package/src/components/layout/pane/footer/model.ts +26 -1
- package/src/components/metric-treemap/heat-surface.tsx +2 -1
- package/src/components/metric-treemap/index.tsx +3 -2
- package/src/components/ui/confirm-dialog.tsx +253 -7
- package/src/components/ui/data-table/index.tsx +1 -1
- package/src/components/ui/data-table/types.ts +7 -0
- package/src/components/ui/list-view.tsx +4 -3
- package/src/components/ui/page-stack-view.tsx +24 -6
- package/src/components/ui/status.tsx +9 -6
- package/src/docs/snapshot.json +36 -0
- package/src/i18n/es.ts +12 -0
- package/src/i18n/ja.ts +12 -0
- package/src/i18n/ko.ts +12 -0
- package/src/i18n/zh-cn.ts +12 -0
- package/src/i18n/zh-tw.ts +12 -0
- package/src/market-data/futures-roll-returns.ts +226 -0
- package/src/market-data/fx-closes.ts +14 -2
- package/src/market-data/market/change-basis.ts +35 -1
- package/src/market-data/market/session-close-note.ts +41 -4
- package/src/market-data/market/status.ts +37 -0
- package/src/market-data/performance.ts +4 -1
- package/src/market-data/quotes/listing-enterprise-value.ts +8 -4
- package/src/market-data/quotes/live-valuation.ts +25 -2
- package/src/market-data/realized-volatility.ts +3 -0
- package/src/market-data/us-bond-market.ts +115 -0
- package/src/plugins/builtin/account-management/invite-row.tsx +54 -0
- package/src/plugins/builtin/account-management/keyboard.ts +3 -0
- package/src/plugins/builtin/account-management/model.ts +1 -0
- package/src/plugins/builtin/account-management/pane.tsx +51 -5
- package/src/plugins/builtin/account-management/trial-cancel.ts +32 -7
- package/src/plugins/builtin/backtest/client.ts +9 -2
- package/src/plugins/builtin/backtest/pane.tsx +1 -1
- package/src/plugins/builtin/backtest/report.ts +22 -6
- package/src/plugins/builtin/backtest/window.ts +17 -9
- package/src/plugins/builtin/cloud/askg/pane-session.ts +94 -0
- package/src/plugins/builtin/cloud/askg/pane.tsx +40 -83
- package/src/plugins/builtin/congress-trades/pane.tsx +8 -2
- package/src/plugins/builtin/correlation/compute.ts +4 -3
- package/src/plugins/builtin/correlation/headless.ts +6 -2
- package/src/plugins/builtin/correlation/index.tsx +7 -3
- package/src/plugins/builtin/correlation/matrix/model.ts +15 -1
- package/src/plugins/builtin/correlation/relationship/model.ts +15 -1
- package/src/plugins/builtin/correlation/relationship/pane.tsx +4 -2
- package/src/plugins/builtin/earnings/board-model.ts +33 -0
- package/src/plugins/builtin/earnings/board-table.ts +50 -11
- package/src/plugins/builtin/earnings/board.tsx +29 -13
- package/src/plugins/builtin/earnings/calendar.tsx +15 -3
- package/src/plugins/builtin/earnings/client.ts +4 -1
- package/src/plugins/builtin/earnings/headless.ts +27 -14
- package/src/plugins/builtin/econ/calendar-source.ts +3 -0
- package/src/plugins/builtin/futures-curve/headless.ts +4 -1
- package/src/plugins/builtin/futures-curve/model.ts +24 -0
- package/src/plugins/builtin/help/index.tsx +1 -1
- package/src/plugins/builtin/ipo-calendar/model.ts +3 -3
- package/src/plugins/builtin/iv-history/headless.ts +12 -10
- package/src/plugins/builtin/kelly-sizer/headless.ts +2 -2
- package/src/plugins/builtin/kelly-sizer/history.ts +10 -3
- package/src/plugins/builtin/kelly-sizer/pane.tsx +2 -2
- package/src/plugins/builtin/kelly-sizer/sections.tsx +1 -1
- package/src/plugins/builtin/macro-day/headless.ts +15 -5
- package/src/plugins/builtin/macro-day/model.ts +17 -4
- package/src/plugins/builtin/macro-day/releases.ts +36 -15
- package/src/plugins/builtin/market-halts/model.ts +3 -2
- package/src/plugins/builtin/market-movers/headless.ts +2 -1
- package/src/plugins/builtin/market-movers/index.tsx +3 -2
- package/src/plugins/builtin/market-movers/model.ts +75 -22
- package/src/plugins/builtin/market-movers/screener.ts +2 -1
- package/src/plugins/builtin/market-movers/table.ts +7 -5
- package/src/plugins/builtin/pe-band/model.ts +4 -0
- package/src/plugins/builtin/portfolio-list/cell-version.ts +4 -4
- package/src/plugins/builtin/portfolio-list/cli/render.ts +9 -4
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +2 -1
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +24 -7
- package/src/plugins/builtin/portfolio-list/summary/totals.ts +40 -11
- package/src/plugins/builtin/portfolio-list/table.tsx +13 -1
- package/src/plugins/builtin/realized-vol/headless.ts +11 -6
- package/src/plugins/builtin/realized-vol/model.ts +14 -6
- package/src/plugins/builtin/realized-vol/pane.tsx +2 -1
- package/src/plugins/builtin/realized-vol/settings.ts +2 -1
- package/src/plugins/builtin/research/analyst-headless.ts +9 -1
- package/src/plugins/builtin/research/analyst-pane.tsx +10 -4
- package/src/plugins/builtin/research/client.ts +25 -1
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +2 -1
- package/src/plugins/builtin/research/event-model.ts +3 -13
- package/src/plugins/builtin/research/event-sources.ts +3 -1
- package/src/plugins/builtin/seasonality/client.ts +66 -17
- package/src/plugins/builtin/seasonality/headless.ts +7 -2
- package/src/plugins/builtin/seasonality/model.ts +12 -3
- package/src/plugins/builtin/seasonality/pane.tsx +4 -2
- package/src/plugins/builtin/shared/use-quote-board.ts +28 -6
- package/src/plugins/builtin/short-interest/headless.ts +2 -0
- package/src/plugins/builtin/short-interest/publications-headless.ts +2 -0
- package/src/plugins/builtin/short-interest/watch-headless.ts +1 -0
- package/src/plugins/builtin/yield-curve/headless.ts +5 -1
- package/src/plugins/builtin/yield-curve/index.tsx +5 -0
- package/src/portfolio/column-values.ts +47 -14
- package/src/portfolio/return-metrics.ts +4 -2
- package/src/renderers/dom/desktop/controls.tsx +1 -1
- package/src/renderers/dom/host/image-surface.tsx +19 -9
- package/src/renderers/dom/host/input.tsx +4 -0
- package/src/renderers/dom/styles.css +7 -4
- package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +23 -1
- package/src/renderers/opentui/box-width.ts +30 -0
- package/src/sources/gloomberb-cloud/normalizers.ts +2 -0
- package/src/sources/provider-errors.ts +12 -0
- package/src/sources/provider-router/index.ts +12 -4
- package/src/state/pane-session.ts +145 -0
- package/src/tickers/search/home-listing.ts +44 -1
- package/src/tickers/search/index.ts +5 -2
- package/src/tickers/search/ranking.ts +7 -7
- package/src/tickers/us-listing.ts +11 -5
- package/src/time-series/base-series.ts +7 -1
- package/src/time-series/fundamentals/current-valuation.ts +8 -0
- package/src/time-series/fundamentals/series.ts +6 -0
- package/src/time-series/resolve.ts +1 -0
- package/src/types/financials.ts +36 -3
- package/src/types/headless.ts +15 -0
- package/src/ui/host.tsx +2 -0
- package/src/utils/exchanges.ts +13 -8
- package/src/utils/fundamentals.ts +49 -8
- package/src/utils/price-earnings.ts +17 -10
- package/src/utils/price-history-integrity.ts +15 -0
- package/src/utils/reason-codes.ts +79 -0
- package/src/utils/share-multiples.cases.json +889 -0
- package/src/utils/share-multiples.ts +254 -0
- package/src/utils/untrusted-text.ts +11 -0
package/src/cli/symbol-list.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { readFile } from "fs/promises";
|
|
|
2
2
|
import { fstatSync } from "fs";
|
|
3
3
|
import { splitSymbolArgLines, splitSymbolWords, stripStrayEdges, uniqueSymbols } from "./symbol-args";
|
|
4
4
|
import { foldTypedText } from "../utils/typed-text";
|
|
5
|
-
import { hasDecimalCommas, isFigure, isJunkCell, isNumberCell, protectFigureCommas, restoreFigureCommas } from "./symbol-cells";
|
|
5
|
+
import { hasDecimalCommas, isFigure, isJunkCell, isNumberCell, isSheetErrorCell, protectFigureCommas, restoreFigureCommas } from "./symbol-cells";
|
|
6
6
|
import { endsInLegalForm, readTerminalListingCode, unknownBloombergMarket } from "../tickers/terminal-codes";
|
|
7
7
|
|
|
8
8
|
/** Header cells that name a spreadsheet's symbol column, compared without case, spaces or punctuation. */
|
|
@@ -17,8 +17,9 @@ function headerKey(cell: string): string {
|
|
|
17
17
|
return cell.toLowerCase().replace(/[^\p{L}\p{N}]/gu, "");
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
/** A line starting with # or //, except a sheet's error value (`#REF!`), which is a cell named as not a symbol. */
|
|
20
21
|
function isComment(cell: string): boolean {
|
|
21
|
-
return cell.startsWith("#") || cell.startsWith("//");
|
|
22
|
+
return (cell.startsWith("#") && !isSheetErrorCell(cell)) || cell.startsWith("//");
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
/** Whether a quote mark at `index` closes a quoted cell: it is followed by a separator, a line end or the end. */
|
|
@@ -320,11 +321,18 @@ export function parseSymbolText(text: string): SymbolText {
|
|
|
320
321
|
};
|
|
321
322
|
}
|
|
322
323
|
|
|
323
|
-
/**
|
|
324
|
+
/**
|
|
325
|
+
* Cells named in a note, once each in the order first read, a repeated one
|
|
326
|
+
* with its count (`2.582,52 (3 times)`), the rest counted. Split by semicolons
|
|
327
|
+
* when one of them has a comma of its own (`2.582,52; 1.899,21`).
|
|
328
|
+
*/
|
|
324
329
|
function listCells(cells: readonly string[]): string {
|
|
325
|
-
const
|
|
326
|
-
const
|
|
327
|
-
|
|
330
|
+
const counts = new Map<string, number>();
|
|
331
|
+
for (const cell of cells) counts.set(cell, (counts.get(cell) ?? 0) + 1);
|
|
332
|
+
const distinct = [...counts];
|
|
333
|
+
const named = distinct.slice(0, IGNORED_PREVIEW).map(([cell, count]) => count > 1 ? `${cell} (${count} times)` : cell);
|
|
334
|
+
const more = distinct.length - IGNORED_PREVIEW;
|
|
335
|
+
return `${named.join(distinct.some(([cell]) => cell.includes(",")) ? "; " : ", ")}${more > 0 ? ` and ${more} more` : ""}`;
|
|
328
336
|
}
|
|
329
337
|
|
|
330
338
|
/** "the cell", "the 3 number cells": number when every one is a figure. */
|
package/src/cli/symbol-rows.ts
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
import { isUsSymbolVenue, LOOKUP_TIMEOUT_MS, movedAwayChange, tickerChangeLine, tickerChangeSymbol, type MovedTickerChange } from "../tickers/ticker-changes";
|
|
20
20
|
import { isVenueAbroad } from "../tickers/listing-fate";
|
|
21
21
|
import { serviceMarkedOtherListing } from "../tickers/company-name-listing";
|
|
22
|
-
import { sameCompany } from "../tickers/company-name";
|
|
22
|
+
import { companyNameCase, sameCompany, shortCompanyName } from "../tickers/company-name";
|
|
23
23
|
import { tickerHasListingSuffix } from "../sources/listing-symbols";
|
|
24
24
|
import { canonicalExchange, exchangeLabel, isUsListingExchange, resolveExchangeTimeZone } from "../utils/exchanges";
|
|
25
25
|
import { isCurrencyPairListing } from "../utils/fx-market-hours";
|
|
@@ -292,7 +292,7 @@ function choiceNeeded(
|
|
|
292
292
|
if (!found) return null;
|
|
293
293
|
// The line stopped trading as its company moved on (Rite Aid to RADCQ): one line says both.
|
|
294
294
|
const moved = resolution.ended ? movedAwayChange(resolution.change) : null;
|
|
295
|
-
if (moved) return { message: stoppedTradingLine(symbol, moved), successor: moved.tradesAs };
|
|
295
|
+
if (moved) return { message: stoppedTradingLine(symbol, moved, resolution.ticker.metadata.name), successor: moved.tradesAs };
|
|
296
296
|
return { message: history ? `${history.note}; ${found}` : found, successor: history?.successor ?? null };
|
|
297
297
|
}
|
|
298
298
|
|
|
@@ -315,9 +315,16 @@ function quotelessNote(resolution: CliTicker): string | null {
|
|
|
315
315
|
return resolution.noQuote ? "no quote" : null;
|
|
316
316
|
}
|
|
317
317
|
|
|
318
|
-
/**
|
|
319
|
-
|
|
320
|
-
|
|
318
|
+
/**
|
|
319
|
+
* "Chesapeake Energy (CHK) stopped trading 2024-10-02, now EXE": a symbol
|
|
320
|
+
* whose line ended as its company moved, named first by the listing's own
|
|
321
|
+
* name as its quote gives it, else by the issuer the change names, when known.
|
|
322
|
+
*/
|
|
323
|
+
function stoppedTradingLine(symbol: string, moved: MovedTickerChange, name?: string | null): string {
|
|
324
|
+
// Written as a name is, never in a feed's capitals ("CHESAPEAKE ENERGY CORP" is Chesapeake Energy).
|
|
325
|
+
const own = name?.trim() && name.trim().toUpperCase() !== symbol.toUpperCase() ? shortCompanyName(companyNameCase(name.trim())) : null;
|
|
326
|
+
const issuer = own ?? (moved.issuer ? companyNameCase(moved.issuer) : null);
|
|
327
|
+
const who = issuer ? `${issuer} (${symbol})` : symbol;
|
|
321
328
|
return `${who} stopped trading ${moved.changes[0]!.date}, now ${moved.tradesAs}`;
|
|
322
329
|
}
|
|
323
330
|
|
|
@@ -2,7 +2,7 @@ import { allocateCompositePanelHeights } from "./scene";
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* How a chart pane lays its chart out, as the user left it: the panels'
|
|
5
|
-
* heights, a panel given the whole plot, the drawing tool bar
|
|
5
|
+
* heights, a panel given the whole plot, the drawing tool bar kept open and the
|
|
6
6
|
* legend collapsed. Kept in the pane's settings beside its drawings, so it
|
|
7
7
|
* outlives a restart; a chart outside a pane keeps it while it is mounted.
|
|
8
8
|
*/
|
|
@@ -16,8 +16,11 @@ export interface ChartLayoutPrefs {
|
|
|
16
16
|
panelWeights?: Readonly<Record<string, number>>;
|
|
17
17
|
/** The panel given the whole plot while the others wait. */
|
|
18
18
|
maximizedPanelId?: string;
|
|
19
|
-
/**
|
|
20
|
-
|
|
19
|
+
/**
|
|
20
|
+
* The drawing tool bar is kept open. It is folded to the tool in hand
|
|
21
|
+
* otherwise, and opens under the pointer.
|
|
22
|
+
*/
|
|
23
|
+
toolbarPinned?: boolean;
|
|
21
24
|
/** The legend shows its first series and how many more it holds. */
|
|
22
25
|
legendCollapsed?: boolean;
|
|
23
26
|
}
|
|
@@ -35,7 +38,7 @@ export function parseChartLayoutPrefs(value: unknown): ChartLayoutPrefs {
|
|
|
35
38
|
if (weights.length > 0) layout.panelWeights = Object.fromEntries(weights);
|
|
36
39
|
}
|
|
37
40
|
if (typeof source.maximizedPanelId === "string" && source.maximizedPanelId) layout.maximizedPanelId = source.maximizedPanelId;
|
|
38
|
-
if (source.
|
|
41
|
+
if (source.toolbarPinned === true) layout.toolbarPinned = true;
|
|
39
42
|
if (source.legendCollapsed === true) layout.legendCollapsed = true;
|
|
40
43
|
return Object.keys(layout).length > 0 ? layout : NO_CHART_LAYOUT;
|
|
41
44
|
}
|
|
@@ -666,15 +666,9 @@ function ThemedCompositeChart({
|
|
|
666
666
|
const patchLayout = useCallback((patch: ChartLayoutPrefs | ((layout: ChartLayoutPrefs) => ChartLayoutPrefs)) => {
|
|
667
667
|
layoutStateRef.current.onChartLayoutChange((layout) => patchChartLayout(layout, typeof patch === "function" ? patch(layout) : patch));
|
|
668
668
|
}, []);
|
|
669
|
-
//
|
|
670
|
-
const toolInHandRef = useRef<{ armed: boolean; putDown: () => void }>({ armed: false, putDown: () => {} });
|
|
671
|
-
// Shift+T and the chevrons act on the bar as it shows: a bar open only for
|
|
672
|
-
// the tool in hand folds again, the tool put down, and stays hidden.
|
|
669
|
+
// Shift+T and the bar's own button keep it open, or let it fold to the tool in hand again.
|
|
673
670
|
const toggleToolbar = useCallback(() => {
|
|
674
|
-
|
|
675
|
-
const hidden = layoutStateRef.current.chartLayout.toolbarHidden === true && !tool.armed;
|
|
676
|
-
if (!hidden && tool.armed) tool.putDown();
|
|
677
|
-
patchLayout({ toolbarHidden: !hidden });
|
|
671
|
+
patchLayout({ toolbarPinned: layoutStateRef.current.chartLayout.toolbarPinned !== true });
|
|
678
672
|
}, [patchLayout]);
|
|
679
673
|
const toggleLegendCollapsed = useCallback(() => patchLayout((layout) => ({ legendCollapsed: !layout.legendCollapsed })), [patchLayout]);
|
|
680
674
|
const resetPanelHeights = useCallback(() => {
|
|
@@ -721,7 +715,7 @@ function ThemedCompositeChart({
|
|
|
721
715
|
const legendCollapsed = legendCollapsible && chartLayout.legendCollapsed === true;
|
|
722
716
|
const projectedPanelCount = projectedScene?.panels.length ?? 0;
|
|
723
717
|
const layoutControls = useMemo(() => ({
|
|
724
|
-
|
|
718
|
+
toolbarPinned: chartLayout.toolbarPinned === true,
|
|
725
719
|
toggleToolbar,
|
|
726
720
|
legendCollapsible,
|
|
727
721
|
legendCollapsed,
|
|
@@ -734,7 +728,7 @@ function ThemedCompositeChart({
|
|
|
734
728
|
restorePanels: resetPanelMaximized,
|
|
735
729
|
}), [
|
|
736
730
|
chartLayout.panelWeights,
|
|
737
|
-
chartLayout.
|
|
731
|
+
chartLayout.toolbarPinned,
|
|
738
732
|
layoutPanels?.length,
|
|
739
733
|
legendCollapsed,
|
|
740
734
|
legendCollapsible,
|
|
@@ -794,7 +788,6 @@ function ThemedCompositeChart({
|
|
|
794
788
|
pickDrawColor,
|
|
795
789
|
layout: layoutControls,
|
|
796
790
|
});
|
|
797
|
-
toolInHandRef.current = { armed: armedTool !== null, putDown: () => armTool(null) };
|
|
798
791
|
const pressFromPointer = useCallback(() => {
|
|
799
792
|
onPress?.();
|
|
800
793
|
activateFromPointer();
|
|
@@ -1045,9 +1038,6 @@ function ThemedCompositeChart({
|
|
|
1045
1038
|
// drawing. A chart outside a pane (a share page) keeps them.
|
|
1046
1039
|
const toolbarWanted = paneFocused !== false || armedTool !== null || pointerDragging || toolSpan !== null;
|
|
1047
1040
|
const showToolbar = interactive && navigable && toolbarWanted && plotWidth > CHART_TOOLBAR_WIDTH + 4;
|
|
1048
|
-
// Hidden, the bar folds to the button that brings it back, and opens again
|
|
1049
|
-
// while a tool picked from the keys is in hand, so the plot says which one.
|
|
1050
|
-
const toolbarFolded = showToolbar && chartLayout.toolbarHidden === true && armedTool === null;
|
|
1051
1041
|
// Bars shorter than a day carry a time of day the cursor reads out.
|
|
1052
1042
|
const intradayBars = baseScene.timeZone !== undefined || visibleSeries.some((entry) => (
|
|
1053
1043
|
!!entry.historyResolution && isIntradayResolution(entry.historyResolution)
|
|
@@ -1119,8 +1109,8 @@ function ThemedCompositeChart({
|
|
|
1119
1109
|
drawColor={drawColor}
|
|
1120
1110
|
showColors={isDrawingTool(armedTool) || !!selectedDrawingId}
|
|
1121
1111
|
levelTool={levelsEditable}
|
|
1122
|
-
|
|
1123
|
-
|
|
1112
|
+
pinned={chartLayout.toolbarPinned === true}
|
|
1113
|
+
onTogglePinned={() => {
|
|
1124
1114
|
pressFromPointer();
|
|
1125
1115
|
toggleToolbar();
|
|
1126
1116
|
}}
|
|
@@ -1,46 +1,64 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useCallback, useEffect, useRef, useState, type ReactNode } from "react";
|
|
2
|
+
import { Box, Text, useShortcutLabel, type BoxRenderable } from "../../../ui";
|
|
2
3
|
import { colors as themeColors, hoverBg } from "../../../theme/colors";
|
|
3
4
|
import { consumeChartMouseEvent, type ChartMouseEvent } from "../core/pointer";
|
|
4
5
|
import { CHART_DRAWING_COLORS, type ChartToolKind } from "./tools";
|
|
5
6
|
import { CHART_TOOLS } from "./tool-catalog";
|
|
6
7
|
|
|
7
|
-
/**
|
|
8
|
-
export const CHART_TOOLBAR_WIDTH = CHART_TOOLS.length * 3 + (CHART_TOOLS.length - 1);
|
|
8
|
+
/** The bar's tools, a gap, and the handle that opens it. */
|
|
9
|
+
export const CHART_TOOLBAR_WIDTH = CHART_TOOLS.length * 3 + (CHART_TOOLS.length - 1) + 4;
|
|
9
10
|
|
|
10
|
-
/**
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
/** How long the bar stays open once the pointer has left it. */
|
|
12
|
+
export const CHART_TOOLBAR_FOLD_DELAY_MS = 300;
|
|
13
|
+
|
|
14
|
+
const SHORTCUT = "Shift+T";
|
|
15
|
+
/** The handle's icon and its hint, in px on the desktop: together they fix its width, so it keeps it when the bar opens. */
|
|
16
|
+
const HANDLE_ICON_PX = 13;
|
|
17
|
+
const HANDLE_HINT_PX = 9;
|
|
18
|
+
const HANDLE_WIDTH = `calc(var(--gloom-space-xs) * 2 + ${HANDLE_ICON_PX + HANDLE_HINT_PX}px)`;
|
|
19
|
+
/** The hint on the folded handle: the bar opens to its right. */
|
|
20
|
+
const OPEN_CHEVRON = {
|
|
20
21
|
glyph: "\u203a",
|
|
21
22
|
icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M6 3.5 10.5 8 6 12.5" fill="none" stroke="#000" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
|
|
22
23
|
};
|
|
24
|
+
/** The handle of a bar kept open, which folds it. */
|
|
25
|
+
const FOLD_CHEVRON = {
|
|
26
|
+
glyph: "\u2039",
|
|
27
|
+
icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M10 3.5 5.5 8l4.5 4.5" fill="none" stroke="#000" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
|
|
28
|
+
};
|
|
23
29
|
|
|
24
|
-
|
|
25
|
-
|
|
30
|
+
interface PressEventLike {
|
|
31
|
+
key?: string;
|
|
32
|
+
preventDefault?: () => void;
|
|
33
|
+
stopPropagation?: () => void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** One of the chart's icon buttons: the control radius, the icon button's hover fill, a 13px icon. */
|
|
37
|
+
function ChartIconButton({
|
|
38
|
+
label,
|
|
26
39
|
active,
|
|
27
40
|
isDesktopWeb,
|
|
28
41
|
onPress,
|
|
29
42
|
role = "composite-chart-tool",
|
|
30
|
-
|
|
43
|
+
pressed,
|
|
44
|
+
expanded,
|
|
45
|
+
width,
|
|
46
|
+
children,
|
|
31
47
|
}: {
|
|
32
|
-
|
|
48
|
+
label: string;
|
|
33
49
|
active: boolean;
|
|
34
50
|
isDesktopWeb: boolean;
|
|
35
51
|
onPress: () => void;
|
|
36
52
|
role?: string;
|
|
37
|
-
/**
|
|
38
|
-
|
|
53
|
+
/** A toggle: pressed while it is the chart's tool. */
|
|
54
|
+
pressed?: boolean;
|
|
55
|
+
/** A disclosure: open while the bar shows its tools. */
|
|
56
|
+
expanded?: boolean;
|
|
57
|
+
/** The desktop button's width when it is not its icon's (CSS length). */
|
|
58
|
+
width?: string;
|
|
59
|
+
/** Terminal cells for a glyph, or the desktop's masks. */
|
|
60
|
+
children: ReactNode;
|
|
39
61
|
}) {
|
|
40
|
-
const keyLabel = useShortcutLabel();
|
|
41
|
-
const named = tool.shortcut ? `${tool.label} (${keyLabel(tool.shortcut)})` : tool.label;
|
|
42
|
-
const label = tool.hint ? `${named}. ${tool.hint}` : named;
|
|
43
|
-
const color = active ? themeColors.text : themeColors.textDim;
|
|
44
62
|
return (
|
|
45
63
|
<Box
|
|
46
64
|
flexDirection="row"
|
|
@@ -59,42 +77,128 @@ function ChartToolButton({
|
|
|
59
77
|
data-gloom-interactive="true"
|
|
60
78
|
data-gloom-role={role}
|
|
61
79
|
data-gloom-label={label}
|
|
62
|
-
data-gloom-reveal={reveal ? "hover" : undefined}
|
|
63
80
|
data-active={active ? "true" : "false"}
|
|
64
81
|
title={isDesktopWeb ? label : undefined}
|
|
65
|
-
// A tool is a toggle button: the icon button family, pressed while it is the chart's tool.
|
|
66
82
|
role={isDesktopWeb ? "button" : undefined}
|
|
67
83
|
aria-label={isDesktopWeb ? label : undefined}
|
|
68
|
-
aria-pressed={isDesktopWeb ?
|
|
84
|
+
aria-pressed={isDesktopWeb ? pressed : undefined}
|
|
85
|
+
aria-expanded={isDesktopWeb ? expanded : undefined}
|
|
86
|
+
// Focusable for assistive technology, which opens the bar with the focus.
|
|
87
|
+
// The keyboard's own way is Shift+T: the window keeps Tab for itself.
|
|
88
|
+
tabIndex={isDesktopWeb ? 0 : undefined}
|
|
89
|
+
onKeyDown={isDesktopWeb
|
|
90
|
+
? (event: PressEventLike) => {
|
|
91
|
+
if (event.key !== "Enter" && event.key !== " ") return;
|
|
92
|
+
event.preventDefault?.();
|
|
93
|
+
event.stopPropagation?.();
|
|
94
|
+
onPress();
|
|
95
|
+
}
|
|
96
|
+
: undefined}
|
|
69
97
|
// Cells size the terminal strip; the desktop chip sizes to its icon.
|
|
70
98
|
// The icon button's look: the control radius, the hover fill.
|
|
71
|
-
style={isDesktopWeb ? { width: "auto", paddingInline: "var(--gloom-space-xs)", borderRadius: "var(--gloom-radius-md)" } : undefined}
|
|
99
|
+
style={isDesktopWeb ? { width: width ?? "auto", paddingInline: "var(--gloom-space-xs)", borderRadius: "var(--gloom-radius-md)" } : undefined}
|
|
100
|
+
>
|
|
101
|
+
{children}
|
|
102
|
+
</Box>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function MaskIcon({ icon, color, size = HANDLE_ICON_PX, visible = true }: { icon: string; color: string; size?: number; visible?: boolean }) {
|
|
107
|
+
return (
|
|
108
|
+
<Box
|
|
109
|
+
flexShrink={0}
|
|
110
|
+
visible={visible}
|
|
111
|
+
style={{
|
|
112
|
+
width: size,
|
|
113
|
+
height: size,
|
|
114
|
+
backgroundColor: color,
|
|
115
|
+
maskImage: svgMaskUrl(icon),
|
|
116
|
+
WebkitMaskImage: svgMaskUrl(icon),
|
|
117
|
+
maskSize: "contain",
|
|
118
|
+
WebkitMaskSize: "contain",
|
|
119
|
+
maskRepeat: "no-repeat",
|
|
120
|
+
WebkitMaskRepeat: "no-repeat",
|
|
121
|
+
maskPosition: "center",
|
|
122
|
+
WebkitMaskPosition: "center",
|
|
123
|
+
}}
|
|
124
|
+
/>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function ChartToolButton({
|
|
129
|
+
tool,
|
|
130
|
+
active,
|
|
131
|
+
isDesktopWeb,
|
|
132
|
+
onPress,
|
|
133
|
+
}: {
|
|
134
|
+
tool: { label: string; glyph: string; icon: string; shortcut?: string; hint?: string };
|
|
135
|
+
active: boolean;
|
|
136
|
+
isDesktopWeb: boolean;
|
|
137
|
+
onPress: () => void;
|
|
138
|
+
}) {
|
|
139
|
+
const keyLabel = useShortcutLabel();
|
|
140
|
+
const named = tool.shortcut ? `${tool.label} (${keyLabel(tool.shortcut)})` : tool.label;
|
|
141
|
+
const label = tool.hint ? `${named}. ${tool.hint}` : named;
|
|
142
|
+
const color = active ? themeColors.text : themeColors.textDim;
|
|
143
|
+
return (
|
|
144
|
+
<ChartIconButton label={label} active={active} pressed={active} isDesktopWeb={isDesktopWeb} onPress={onPress}>
|
|
145
|
+
{isDesktopWeb ? <MaskIcon icon={tool.icon} color={color} /> : <Text fg={color}>{tool.glyph}</Text>}
|
|
146
|
+
</ChartIconButton>
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* The bar's one fixed button, first in it so the pointer that opened the bar
|
|
152
|
+
* is still on it. Folded, it shows the tool in hand, with a hint that it
|
|
153
|
+
* opens; open, only the chevron, which keeps the bar open or lets it fold.
|
|
154
|
+
*/
|
|
155
|
+
function ChartToolbarHandle({
|
|
156
|
+
tool,
|
|
157
|
+
armed,
|
|
158
|
+
expanded,
|
|
159
|
+
pinned,
|
|
160
|
+
isDesktopWeb,
|
|
161
|
+
onPress,
|
|
162
|
+
}: {
|
|
163
|
+
tool: { label: string; glyph: string; icon: string };
|
|
164
|
+
/** A tool is in hand, not the resting pan. */
|
|
165
|
+
armed: boolean;
|
|
166
|
+
expanded: boolean;
|
|
167
|
+
pinned: boolean;
|
|
168
|
+
isDesktopWeb: boolean;
|
|
169
|
+
onPress: () => void;
|
|
170
|
+
}) {
|
|
171
|
+
const keyLabel = useShortcutLabel();
|
|
172
|
+
const keys = keyLabel(SHORTCUT);
|
|
173
|
+
const label = expanded
|
|
174
|
+
? pinned ? `Hide drawing tools (${keys})` : `Keep drawing tools open (${keys})`
|
|
175
|
+
: `${tool.label}. Show drawing tools (${keys})`;
|
|
176
|
+
const color = armed ? themeColors.text : themeColors.textDim;
|
|
177
|
+
const chevron = pinned ? FOLD_CHEVRON : OPEN_CHEVRON;
|
|
178
|
+
return (
|
|
179
|
+
<ChartIconButton
|
|
180
|
+
label={label}
|
|
181
|
+
active={armed && !expanded}
|
|
182
|
+
expanded={expanded}
|
|
183
|
+
width={HANDLE_WIDTH}
|
|
184
|
+
isDesktopWeb={isDesktopWeb}
|
|
185
|
+
onPress={onPress}
|
|
186
|
+
role="composite-chart-toolbar-toggle"
|
|
72
187
|
>
|
|
73
188
|
{isDesktopWeb ? (
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
maskImage: svgMaskUrl(tool.icon),
|
|
81
|
-
WebkitMaskImage: svgMaskUrl(tool.icon),
|
|
82
|
-
maskSize: "contain",
|
|
83
|
-
WebkitMaskSize: "contain",
|
|
84
|
-
maskRepeat: "no-repeat",
|
|
85
|
-
WebkitMaskRepeat: "no-repeat",
|
|
86
|
-
maskPosition: "center",
|
|
87
|
-
WebkitMaskPosition: "center",
|
|
88
|
-
}}
|
|
89
|
-
/>
|
|
189
|
+
<>
|
|
190
|
+
{/* Hidden, not removed, once the bar is open: the pointer that opened it is on this icon, and a press that lands as the bar opens still reaches the button.
|
|
191
|
+
The button keeps its width, so a pointer that came in at its edge is still on it. */}
|
|
192
|
+
<MaskIcon icon={tool.icon} color={color} visible={!expanded} />
|
|
193
|
+
<MaskIcon icon={chevron.icon} color={themeColors.textDim} size={expanded ? HANDLE_ICON_PX : HANDLE_HINT_PX} />
|
|
194
|
+
</>
|
|
90
195
|
) : (
|
|
91
|
-
<Text fg={color}>{tool.glyph}</Text>
|
|
196
|
+
<Text fg={color}>{expanded ? chevron.glyph : `${tool.glyph}${chevron.glyph}`}</Text>
|
|
92
197
|
)}
|
|
93
|
-
</
|
|
198
|
+
</ChartIconButton>
|
|
94
199
|
);
|
|
95
200
|
}
|
|
96
201
|
|
|
97
|
-
|
|
98
202
|
function svgMaskUrl(svg: string): string {
|
|
99
203
|
return `url("data:image/svg+xml,${encodeURIComponent(svg)}")`;
|
|
100
204
|
}
|
|
@@ -152,8 +256,8 @@ export function ChartToolbar({
|
|
|
152
256
|
drawColor,
|
|
153
257
|
showColors,
|
|
154
258
|
levelTool,
|
|
155
|
-
|
|
156
|
-
|
|
259
|
+
pinned,
|
|
260
|
+
onTogglePinned,
|
|
157
261
|
onArmTool,
|
|
158
262
|
onPickColor,
|
|
159
263
|
}: {
|
|
@@ -165,15 +269,20 @@ export function ChartToolbar({
|
|
|
165
269
|
showColors: boolean;
|
|
166
270
|
/** The chart's levels can be edited here. */
|
|
167
271
|
levelTool: boolean;
|
|
168
|
-
/**
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
|
|
272
|
+
/** Kept open by the user. Otherwise the bar is folded to the tool in hand and opens under the pointer. */
|
|
273
|
+
pinned: boolean;
|
|
274
|
+
/** Keeps the bar open, or lets it fold again. */
|
|
275
|
+
onTogglePinned: () => void;
|
|
172
276
|
onArmTool: (tool: ChartToolKind | null) => void;
|
|
173
277
|
onPickColor: (color: string) => void;
|
|
174
278
|
}) {
|
|
279
|
+
const barRef = useRef<BoxRenderable | null>(null);
|
|
280
|
+
const { open, onHover, onLeave, onFocus, onBlur, fold } = useToolbarOpening(barRef);
|
|
281
|
+
const expanded = pinned || open;
|
|
282
|
+
const tool = CHART_TOOLS.find((entry) => entry.kind === armedTool) ?? CHART_TOOLS[0]!;
|
|
175
283
|
return (
|
|
176
284
|
<Box
|
|
285
|
+
ref={barRef}
|
|
177
286
|
position="absolute"
|
|
178
287
|
left={left}
|
|
179
288
|
top={top}
|
|
@@ -194,29 +303,37 @@ export function ChartToolbar({
|
|
|
194
303
|
}
|
|
195
304
|
: undefined}
|
|
196
305
|
data-gloom-role="composite-chart-toolbar"
|
|
197
|
-
data-
|
|
198
|
-
data-
|
|
306
|
+
data-folded={expanded ? undefined : "true"}
|
|
307
|
+
data-pinned={pinned ? "true" : undefined}
|
|
308
|
+
onMouseOver={onHover}
|
|
309
|
+
onMouseOut={onLeave}
|
|
310
|
+
onFocus={isDesktopWeb ? onFocus : undefined}
|
|
311
|
+
onBlur={isDesktopWeb ? onBlur : undefined}
|
|
199
312
|
>
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
313
|
+
<ChartToolbarHandle
|
|
314
|
+
tool={tool}
|
|
315
|
+
armed={armedTool !== null}
|
|
316
|
+
expanded={expanded}
|
|
317
|
+
pinned={pinned}
|
|
318
|
+
isDesktopWeb={isDesktopWeb}
|
|
319
|
+
onPress={() => {
|
|
320
|
+
// Pressed while the bar is open only for the pointer or the focus,
|
|
321
|
+
// it stays open; pressed while kept open, it folds now.
|
|
322
|
+
if (pinned) fold();
|
|
323
|
+
onTogglePinned();
|
|
324
|
+
}}
|
|
325
|
+
/>
|
|
326
|
+
{expanded ? CHART_TOOLS.filter((entry) => levelTool || entry.kind !== "level").map((entry) => (
|
|
210
327
|
<ChartToolButton
|
|
211
|
-
key={
|
|
212
|
-
tool={
|
|
213
|
-
active={armedTool ===
|
|
328
|
+
key={entry.kind ?? "pan"}
|
|
329
|
+
tool={entry}
|
|
330
|
+
active={armedTool === entry.kind}
|
|
214
331
|
isDesktopWeb={isDesktopWeb}
|
|
215
|
-
onPress={() => onArmTool(
|
|
332
|
+
onPress={() => onArmTool(entry.kind)}
|
|
216
333
|
/>
|
|
217
|
-
))}
|
|
334
|
+
)) : null}
|
|
218
335
|
{/* Colours only take space while something can use them. */}
|
|
219
|
-
{
|
|
336
|
+
{expanded && showColors ? CHART_DRAWING_COLORS.map((color) => (
|
|
220
337
|
<ChartColorSwatch
|
|
221
338
|
key={color}
|
|
222
339
|
color={color}
|
|
@@ -225,18 +342,77 @@ export function ChartToolbar({
|
|
|
225
342
|
onPress={() => onPickColor(color)}
|
|
226
343
|
/>
|
|
227
344
|
)) : null}
|
|
228
|
-
{/* The way to fold the bar shows under the pointer, so a chart at rest
|
|
229
|
-
draws the bar as it always has; the terminal has Shift+T and the menu. */}
|
|
230
|
-
{!folded && isDesktopWeb ? (
|
|
231
|
-
<ChartToolButton
|
|
232
|
-
tool={FOLD_BUTTON}
|
|
233
|
-
active={false}
|
|
234
|
-
isDesktopWeb={isDesktopWeb}
|
|
235
|
-
onPress={onToggleFolded}
|
|
236
|
-
role="composite-chart-toolbar-toggle"
|
|
237
|
-
reveal
|
|
238
|
-
/>
|
|
239
|
-
) : null}
|
|
240
345
|
</Box>
|
|
241
346
|
);
|
|
242
347
|
}
|
|
348
|
+
|
|
349
|
+
const TOOLBAR_SELECTOR = "[data-gloom-role=composite-chart-toolbar]";
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Whether a pointer event lies on the bar. A mouseout between two of its icons
|
|
353
|
+
* does, and is no leaving. The desktop reads the bar's own box in px; the
|
|
354
|
+
* terminal compares its cells.
|
|
355
|
+
*/
|
|
356
|
+
function pointerOnBar(bar: BoxRenderable | null, event: ChartMouseEvent): boolean {
|
|
357
|
+
const element = event.target?.closest?.(TOOLBAR_SELECTOR) as { getBoundingClientRect?: () => DOMRect } | null | undefined;
|
|
358
|
+
if (element?.getBoundingClientRect && typeof event.pixelX === "number" && typeof event.pixelY === "number") {
|
|
359
|
+
const box = element.getBoundingClientRect();
|
|
360
|
+
return event.pixelX >= box.left && event.pixelX < box.right && event.pixelY >= box.top && event.pixelY < box.bottom;
|
|
361
|
+
}
|
|
362
|
+
if (!bar || typeof event.x !== "number" || typeof event.y !== "number") return false;
|
|
363
|
+
const x = Number(bar.x);
|
|
364
|
+
const y = Number(bar.y);
|
|
365
|
+
return event.x >= x && event.x < x + Number(bar.width) && event.y >= y && event.y < y + Number(bar.height);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Whether the pointer or assistive focus has the bar open: the pointer opens it
|
|
370
|
+
* at once and keeps it open for a moment after it leaves the bar.
|
|
371
|
+
*/
|
|
372
|
+
function useToolbarOpening(bar: { current: BoxRenderable | null }) {
|
|
373
|
+
const [hovered, setHovered] = useState(false);
|
|
374
|
+
const [focused, setFocused] = useState(false);
|
|
375
|
+
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
376
|
+
const insideRef = useRef(false);
|
|
377
|
+
// Folded by a press under the pointer: it stays folded until the pointer has left the bar.
|
|
378
|
+
const foldedUnderPointerRef = useRef(false);
|
|
379
|
+
const clearTimer = useCallback(() => {
|
|
380
|
+
if (timerRef.current === null) return;
|
|
381
|
+
clearTimeout(timerRef.current);
|
|
382
|
+
timerRef.current = null;
|
|
383
|
+
}, []);
|
|
384
|
+
useEffect(() => clearTimer, [clearTimer]);
|
|
385
|
+
const onHover = useCallback(() => {
|
|
386
|
+
clearTimer();
|
|
387
|
+
insideRef.current = true;
|
|
388
|
+
if (!foldedUnderPointerRef.current) setHovered(true);
|
|
389
|
+
}, [clearTimer]);
|
|
390
|
+
const onLeave = useCallback((event: ChartMouseEvent) => {
|
|
391
|
+
// From one icon to the next, or into the gap between: still on the bar.
|
|
392
|
+
if (pointerOnBar(bar.current, event)) return;
|
|
393
|
+
clearTimer();
|
|
394
|
+
insideRef.current = false;
|
|
395
|
+
// Back within the delay, it opens: the press that folded it is over.
|
|
396
|
+
foldedUnderPointerRef.current = false;
|
|
397
|
+
timerRef.current = setTimeout(() => {
|
|
398
|
+
timerRef.current = null;
|
|
399
|
+
setHovered(false);
|
|
400
|
+
}, CHART_TOOLBAR_FOLD_DELAY_MS);
|
|
401
|
+
}, [bar, clearTimer]);
|
|
402
|
+
const fold = useCallback(() => {
|
|
403
|
+
foldedUnderPointerRef.current = insideRef.current;
|
|
404
|
+
setHovered(false);
|
|
405
|
+
setFocused(false);
|
|
406
|
+
}, []);
|
|
407
|
+
// A press focuses a button too; only focus that shows its ring (assistive technology's) opens the bar.
|
|
408
|
+
const onFocus = useCallback((event: { target?: unknown }) => {
|
|
409
|
+
const target = event.target as { matches?: (selector: string) => boolean } | null;
|
|
410
|
+
if (target?.matches?.(":focus-visible") === true) setFocused(true);
|
|
411
|
+
}, []);
|
|
412
|
+
const onBlur = useCallback((event: { currentTarget?: unknown; relatedTarget?: unknown }) => {
|
|
413
|
+
const root = event.currentTarget as { contains?: (node: unknown) => boolean } | null;
|
|
414
|
+
if (event.relatedTarget && root?.contains?.(event.relatedTarget)) return;
|
|
415
|
+
setFocused(false);
|
|
416
|
+
}, []);
|
|
417
|
+
return { open: hovered || focused, onHover, onLeave, onFocus, onBlur, fold };
|
|
418
|
+
}
|
|
@@ -64,8 +64,8 @@ export interface KeyboardToolDrag {
|
|
|
64
64
|
|
|
65
65
|
/** The chart's own layout: its tool bar, its legend and its panels' heights. */
|
|
66
66
|
export interface CompositeChartLayoutControls {
|
|
67
|
-
/** The bar is
|
|
68
|
-
|
|
67
|
+
/** The bar is kept open; otherwise it folds to the tool in hand and opens under the pointer. */
|
|
68
|
+
toolbarPinned: boolean;
|
|
69
69
|
toggleToolbar: () => void;
|
|
70
70
|
/** The legend has more than one series, so it can fold to its first. */
|
|
71
71
|
legendCollapsible: boolean;
|
|
@@ -728,8 +728,7 @@ export function useCompositeChartKeyboard({
|
|
|
728
728
|
const levelToolKeys = toolsActive && armedTool === "level" && levelsEditable;
|
|
729
729
|
const canDeleteLevel = toolsActive && levelsEditable && !!selectedLevel?.editable && !selectedLevel.draggable;
|
|
730
730
|
const pinState = pin ? pin.pinned : null;
|
|
731
|
-
|
|
732
|
-
const toolbarHidden = layout.toolbarHidden && armedTool === null;
|
|
731
|
+
const toolbarPinned = layout.toolbarPinned;
|
|
733
732
|
const {
|
|
734
733
|
legendCollapsible,
|
|
735
734
|
legendCollapsed,
|
|
@@ -811,7 +810,7 @@ export function useCompositeChartKeyboard({
|
|
|
811
810
|
if (resettable) menu.push({ id: "chart-reset", label: "Reset Zoom", accelerator: "0", onSelect: () => chartActionsRef.current.reset() });
|
|
812
811
|
menu.push({
|
|
813
812
|
id: "chart-toolbar",
|
|
814
|
-
label:
|
|
813
|
+
label: toolbarPinned ? "Hide Drawing Tools" : "Show Drawing Tools",
|
|
815
814
|
accelerator: "Shift+T",
|
|
816
815
|
onSelect: () => chartActionsRef.current.layout.toggleToolbar(),
|
|
817
816
|
});
|
|
@@ -860,7 +859,7 @@ export function useCompositeChartKeyboard({
|
|
|
860
859
|
levelsEditable,
|
|
861
860
|
toolsActive,
|
|
862
861
|
pinState,
|
|
863
|
-
|
|
862
|
+
toolbarPinned,
|
|
864
863
|
legendCollapsible,
|
|
865
864
|
legendCollapsed,
|
|
866
865
|
panelsResizable,
|