@gloom-sh/terminal 0.19.5 → 0.20.0
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/LICENSE +0 -4
- package/package.json +6 -5
- package/patches/@opentui%2Fcore@0.3.2.patch +86 -25
- package/patches/electrobun-devkit@2.0.5.patch +148 -0
- package/src/api-client/bond-trades.ts +59 -0
- package/src/api-client/data.ts +21 -0
- package/src/api-client/equity-screener.ts +23 -0
- package/src/api-client/index.ts +2 -0
- package/src/api-client/types/account.ts +86 -0
- package/src/api-client/types/assist.ts +32 -0
- package/src/api-client/types/auth.ts +63 -0
- package/src/api-client/types/billing.ts +54 -0
- package/src/api-client/types/chat.ts +180 -0
- package/src/api-client/types/congress.ts +107 -0
- package/src/api-client/types/credit.ts +110 -0
- package/src/api-client/types/econ.ts +158 -0
- package/src/api-client/types/equity-diagnostic.ts +73 -0
- package/src/api-client/types/filings-and-calls.ts +350 -0
- package/src/api-client/types/index.ts +25 -0
- package/src/api-client/types/jobs.ts +147 -0
- package/src/api-client/types/market.ts +122 -0
- package/src/api-client/types/news.ts +91 -0
- package/src/api-client/types/notes-and-theses.ts +172 -0
- package/src/api-client/types/quotes.ts +28 -0
- package/src/api-client/types/scanners.ts +125 -0
- package/src/api-client/types/screener.ts +65 -0
- package/src/api-client/types/search.ts +107 -0
- package/src/api-client/types/sync.ts +14 -0
- package/src/api-client/types/team-collections.ts +43 -0
- package/src/api-client/types/team-views.ts +32 -0
- package/src/api-client/types/teams.ts +135 -0
- package/src/api-client/types/ticker-data.ts +57 -0
- package/src/api-client/types/tweets.ts +59 -0
- package/src/api-client/types/world-venues.ts +23 -0
- package/src/app/pane-runtime/index.tsx +2 -0
- package/src/app/pane-runtime/plugin-bindings.ts +10 -1
- package/src/app/runtime/desktop-deeplink.ts +41 -6
- package/src/app/star-prompt/status-line.tsx +1 -1
- package/src/app.tsx +64 -23
- package/src/architecture/ui-tokens-allowlist.json +0 -8
- package/src/cli/commands/market.ts +149 -10
- package/src/cli/commands/search.ts +21 -3
- package/src/cli/commands/ticker.ts +90 -36
- package/src/cli/desktop-pane-shot-browser.ts +69 -3
- package/src/cli/glossary.ts +3 -3
- package/src/cli/known-gaps.ts +8 -0
- package/src/cli/listing-arg.ts +12 -0
- package/src/cli/pane-functions/capabilities.ts +2 -0
- package/src/cli/pane-functions/catalog.ts +25 -5
- package/src/cli/pane-functions/function-help.ts +8 -5
- package/src/cli/pane-functions/headless.ts +4 -3
- package/src/cli/pane-functions/resolver.ts +75 -2
- package/src/cli/quote-answer.ts +9 -0
- package/src/cli/symbol-list.ts +54 -2
- package/src/cli/symbol-rows.ts +14 -2
- package/src/cli/ticker-resolution.ts +89 -20
- package/src/components/chart/composite/axis-overlays.tsx +60 -27
- package/src/components/chart/composite/composite-chart.tsx +118 -63
- package/src/components/chart/composite/cursor-source.ts +111 -0
- package/src/components/chart/composite/format.ts +168 -6
- package/src/components/chart/composite/legend.tsx +8 -4
- package/src/components/chart/composite/panel-labels.ts +20 -1
- package/src/components/chart/composite/panel-surface.tsx +201 -92
- package/src/components/chart/composite/price-axis-labels.tsx +92 -46
- package/src/components/chart/composite/price-series.ts +31 -8
- package/src/components/chart/composite/scene.ts +154 -59
- package/src/components/chart/composite/series-axis-tags.tsx +4 -2
- package/src/components/chart/composite/time-axis.ts +13 -5
- package/src/components/chart/composite/time-scale.ts +211 -56
- package/src/components/chart/composite/types.ts +11 -1
- package/src/components/chart/composite/use-composite-chart-keyboard.ts +43 -14
- package/src/components/chart/curve/curve-surface.tsx +5 -2
- package/src/components/chart/curve/model.ts +4 -1
- package/src/components/chart/native/use-bitmap-metrics.ts +81 -0
- package/src/components/chart/static/series.ts +3 -0
- package/src/components/command-bar/commands/collection-list.ts +81 -0
- package/src/components/command-bar/commands/direct/index.ts +6 -0
- package/src/components/command-bar/commands/registry.ts +8 -0
- package/src/components/command-bar/layout-items/current-layout.ts +22 -1
- package/src/components/command-bar/layout-items/focused-pane.ts +22 -1
- package/src/components/command-bar/pane-templates/items.ts +19 -3
- package/src/components/command-bar/pane-templates/workflow.ts +5 -0
- package/src/components/command-bar/routes/root/results.ts +23 -3
- package/src/components/command-bar/routes/root/selection.ts +4 -2
- package/src/components/command-bar/routes/root/shortcut-feedback.ts +1 -1
- package/src/components/command-bar/routes/root/shortcut-items.ts +3 -4
- package/src/components/command-bar/routes/root/shortcuts.ts +58 -14
- package/src/components/command-bar/routes/root/ticker-first.ts +32 -0
- package/src/components/command-bar/surface/environment.ts +2 -0
- package/src/components/command-bar/view-model.ts +7 -0
- package/src/components/command-bar/workflow/ops.ts +2 -1
- package/src/components/command-bar/workflow/tickers.ts +20 -0
- package/src/components/data-table/export.ts +4 -1
- package/src/components/layout/detached-pane-shell.tsx +10 -37
- package/src/components/layout/double-escape-close.ts +90 -0
- package/src/components/layout/header.tsx +3 -2
- package/src/components/layout/market-summary.ts +6 -3
- package/src/components/layout/pane/footer/index.tsx +2 -6
- package/src/components/layout/pane/footer/model.ts +6 -12
- package/src/components/layout/shell/active-drag.ts +53 -11
- package/src/components/layout/shell/drag/magnets.ts +128 -19
- package/src/components/layout/shell/menu.ts +15 -1
- package/src/components/layout/shell/pane/actions.ts +10 -2
- package/src/components/layout/shell/pane/management-shortcuts.ts +13 -51
- package/src/components/layout/shell/ticker-link-menu.ts +12 -3
- package/src/components/layout/status-bar.tsx +24 -78
- package/src/components/layout/status-widget-space.ts +5 -5
- package/src/components/onboarding/onboarding-keyboard.ts +5 -1
- package/src/components/onboarding/onboarding-wizard.tsx +15 -4
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +9 -6
- package/src/components/onboarding/use-onboarding-progress.ts +20 -1
- package/src/components/price-sparkline/view.tsx +14 -6
- package/src/components/ticker/badge/index.tsx +8 -4
- package/src/components/ticker/badge/list.tsx +23 -7
- package/src/components/ui/column-grid.tsx +8 -2
- package/src/components/ui/data-table/index.tsx +5 -1
- package/src/components/ui/data-table/opentui/model.ts +4 -1
- package/src/components/ui/data-table/render-cell.ts +19 -0
- package/src/components/ui/delayed-mark.tsx +59 -7
- package/src/components/ui/icon.tsx +1 -8
- package/src/components/ui/menu.tsx +6 -1
- package/src/components/ui/tabs.tsx +5 -2
- package/src/core/state/app/layout.ts +18 -3
- package/src/core/state/app/state.ts +2 -0
- package/src/core/state/app/types.ts +5 -0
- package/src/data/config/layout.ts +3 -0
- package/src/data/config/store/normalize.ts +39 -4
- package/src/i18n/es.ts +13 -3
- package/src/i18n/ja.ts +13 -3
- package/src/i18n/ko.ts +13 -3
- package/src/i18n/zh-cn.ts +13 -3
- package/src/i18n/zh-tw.ts +13 -3
- package/src/layout/pane-manager/floating-placement.ts +7 -4
- package/src/layout/pane-manager/floating.ts +5 -2
- package/src/market-data/bond-funds.ts +19 -0
- package/src/market-data/futures-contract.ts +14 -3
- package/src/market-data/market/freshness.ts +18 -0
- package/src/market-data/market/status.ts +15 -2
- package/src/plugins/builtin/bond-calculator/headless.ts +2 -1
- package/src/plugins/builtin/bond-calculator/index.tsx +1 -1
- package/src/plugins/builtin/bond-calculator/model.ts +14 -5
- package/src/plugins/builtin/bond-calculator/pane.tsx +1 -1
- package/src/plugins/builtin/buildout/cells.tsx +25 -45
- package/src/plugins/builtin/buildout/detail/company.tsx +3 -3
- package/src/plugins/builtin/buildout/detail/index.tsx +1 -1
- package/src/plugins/builtin/buildout/detail/intel.tsx +4 -7
- package/src/plugins/builtin/buildout/detail/site.tsx +4 -4
- package/src/plugins/builtin/buildout/detail/ui.tsx +39 -38
- package/src/plugins/builtin/buildout/format.ts +23 -1
- package/src/plugins/builtin/buildout/model/types.ts +1 -0
- package/src/plugins/builtin/buildout/pane/index.tsx +2 -8
- package/src/plugins/builtin/buildout/table-model.ts +12 -4
- package/src/plugins/builtin/cds/headless.ts +1 -0
- package/src/plugins/builtin/cds/index.tsx +1 -1
- package/src/plugins/builtin/chat/content/composer.tsx +21 -27
- package/src/plugins/builtin/chat/content/index.tsx +31 -3
- package/src/plugins/builtin/chat/content/shortcuts.ts +4 -2
- package/src/plugins/builtin/chat/content/snapshot.ts +0 -3
- package/src/plugins/builtin/cloud/auth-actions.tsx +51 -23
- package/src/plugins/builtin/cloud/plugin.tsx +2 -0
- package/src/plugins/builtin/cloud/trial-offer-status-widget.tsx +3 -3
- package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +44 -12
- package/src/plugins/builtin/congress-trades/model.ts +2 -1
- package/src/plugins/builtin/congress-trades/pane.tsx +3 -0
- package/src/plugins/builtin/correlation/headless.ts +3 -2
- package/src/plugins/builtin/crypto-board/pane.tsx +5 -4
- package/src/plugins/builtin/custom-view/index.tsx +1 -1
- package/src/plugins/builtin/custom-view/loader.ts +85 -8
- package/src/plugins/builtin/custom-view/view-spec.ts +28 -0
- package/src/plugins/builtin/debt-maturities/headless.ts +11 -2
- package/src/plugins/builtin/debt-maturities/model.ts +66 -0
- package/src/plugins/builtin/debt-maturities/pane.tsx +23 -4
- package/src/plugins/builtin/earnings-ripple/pane.tsx +1 -1
- package/src/plugins/builtin/econ/calendar-model.ts +28 -6
- package/src/plugins/builtin/equity-screener/client.ts +1 -1
- package/src/plugins/builtin/equity-screener/criterion-editor.tsx +16 -19
- package/src/plugins/builtin/equity-screener/headless.ts +37 -3
- package/src/plugins/builtin/equity-screener/ideas.ts +67 -3
- package/src/plugins/builtin/equity-screener/model.ts +238 -27
- package/src/plugins/builtin/equity-screener/pane.tsx +88 -18
- package/src/plugins/builtin/equity-screener/screen-check.ts +7 -4
- package/src/plugins/builtin/equity-screener/watchlist.ts +33 -0
- package/src/plugins/builtin/executives/format.ts +5 -4
- package/src/plugins/builtin/executives/pane.tsx +1 -1
- package/src/plugins/builtin/futures-curve/client.ts +19 -0
- package/src/plugins/builtin/futures-curve/headless.ts +52 -13
- package/src/plugins/builtin/futures-curve/index.tsx +1 -1
- package/src/plugins/builtin/futures-curve/model.ts +77 -6
- package/src/plugins/builtin/futures-curve/pane.tsx +19 -3
- package/src/plugins/builtin/help/index.tsx +55 -1
- package/src/plugins/builtin/insider/model.ts +30 -2
- package/src/plugins/builtin/jobs/model.ts +2 -2
- package/src/plugins/builtin/macro-day/client.ts +41 -0
- package/src/plugins/builtin/macro-day/headless.ts +19 -9
- package/src/plugins/builtin/macro-day/model.ts +3 -1
- package/src/plugins/builtin/market-movers/index.tsx +4 -3
- package/src/plugins/builtin/mna/distress/headless.ts +1 -0
- package/src/plugins/builtin/mna/model.ts +2 -2
- package/src/plugins/builtin/notes/files.ts +2 -0
- package/src/plugins/builtin/notes/owner.tsx +20 -1
- package/src/plugins/builtin/notes/quick-notes-pane.tsx +22 -4
- package/src/plugins/builtin/notes/store.ts +6 -1
- package/src/plugins/builtin/perps/pane.tsx +3 -1
- package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +17 -0
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +2 -1
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +2 -1
- package/src/plugins/builtin/portfolio-list/header.tsx +1 -1
- package/src/plugins/builtin/rate-path/headless.ts +24 -10
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +29 -25
- package/src/plugins/builtin/research/event-model.ts +10 -3
- package/src/plugins/builtin/research/events-headless.ts +20 -2
- package/src/plugins/builtin/sec/fund-facts.ts +17 -1
- package/src/plugins/builtin/sec/index.tsx +1 -1
- package/src/plugins/builtin/series-inventory.ts +1 -0
- package/src/plugins/builtin/shared/earnings-report.ts +7 -2
- package/src/plugins/builtin/shared/members-menu.tsx +103 -38
- package/src/plugins/builtin/shared/use-quote-board.ts +85 -46
- package/src/plugins/builtin/short-interest/headless.ts +1 -1
- package/src/plugins/builtin/short-interest/model.ts +15 -6
- package/src/plugins/builtin/short-interest/publications-model.ts +22 -1
- package/src/plugins/builtin/short-interest/publications-pane.tsx +13 -4
- package/src/plugins/builtin/short-interest/types.ts +2 -0
- package/src/plugins/builtin/short-interest/watch-model.ts +1 -1
- package/src/plugins/builtin/thirteenf/overlap-pane.tsx +3 -0
- package/src/plugins/builtin/thirteenf/pane.tsx +3 -0
- package/src/plugins/builtin/ticker-detail/overview/model.ts +5 -3
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +4 -4
- package/src/plugins/builtin/time-sales/pane.tsx +3 -2
- package/src/plugins/builtin/trace-bonds/client.ts +7 -4
- package/src/plugins/builtin/trace-bonds/detail.tsx +198 -0
- package/src/plugins/builtin/trace-bonds/headless.ts +62 -4
- package/src/plugins/builtin/trace-bonds/history.ts +155 -0
- package/src/plugins/builtin/trace-bonds/index.tsx +1 -1
- package/src/plugins/builtin/trace-bonds/pane.tsx +64 -5
- package/src/plugins/builtin/volatility/client.ts +6 -1
- package/src/plugins/builtin/volatility/headless.ts +0 -1
- package/src/plugins/builtin/yield-curve/curves.ts +15 -0
- package/src/plugins/builtin/yield-curve/headless.ts +6 -1
- package/src/plugins/builtin/yield-curve/index.tsx +5 -8
- package/src/plugins/host-modules.ts +22 -3
- package/src/plugins/host-smoke.ts +6 -3
- package/src/plugins/installer.ts +16 -3
- package/src/plugins/plugin-names.ts +11 -2
- package/src/portfolio/collection-name.ts +19 -0
- package/src/remote/controller.ts +9 -2
- package/src/remote/schema.ts +2 -1
- package/src/renderers/browser/http-proxy-transport.ts +78 -8
- package/src/renderers/cloudflare/http-proxy.ts +73 -3
- package/src/renderers/cloudflare/proxy-session.ts +47 -24
- package/src/renderers/cloudflare/worker.ts +44 -4
- package/src/renderers/desktop/geometry.ts +279 -0
- package/src/renderers/desktop/screen-setup.ts +246 -0
- package/src/renderers/desktop/sequential-window-host.ts +179 -0
- package/src/renderers/desktop/test-utils.ts +71 -0
- package/src/renderers/desktop/window-controller.ts +433 -0
- package/src/renderers/desktop/window-host.ts +70 -0
- package/src/renderers/desktop/window-layouts.ts +630 -0
- package/src/renderers/dom/data-frames.ts +15 -4
- package/src/renderers/dom/desktop/icons.tsx +0 -2
- package/src/renderers/dom/styles.css +0 -3
- package/src/renderers/electrobun/bun/application-menu/click.ts +1 -0
- package/src/renderers/electrobun/bun/application-menu/index.ts +4 -1
- package/src/renderers/electrobun/bun/desktop/backend-requests.ts +19 -8
- package/src/renderers/electrobun/bun/desktop/backend.ts +320 -19
- package/src/renderers/electrobun/bun/desktop/detached-windows.ts +83 -61
- package/src/renderers/electrobun/bun/desktop/host-requests.ts +4 -14
- package/src/renderers/electrobun/bun/desktop/initialization.ts +30 -11
- package/src/renderers/electrobun/bun/desktop/install-records.ts +59 -0
- package/src/renderers/electrobun/bun/desktop/installer-folder.ts +208 -592
- package/src/renderers/electrobun/bun/desktop/macos-objc.ts +14 -0
- package/src/renderers/electrobun/bun/desktop/screen-setup-file.ts +55 -0
- package/src/renderers/electrobun/bun/desktop/state-broadcaster.ts +44 -8
- package/src/renderers/electrobun/bun/desktop/update.ts +1 -1
- package/src/renderers/electrobun/bun/desktop/workspace/index.ts +298 -97
- package/src/renderers/electrobun/bun/desktop/workspace/requests.ts +44 -6
- package/src/renderers/electrobun/bun/index.ts +22 -109
- package/src/renderers/electrobun/bun/window/create.ts +23 -3
- package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +306 -0
- package/src/renderers/electrobun/bun/window/events.ts +4 -4
- package/src/renderers/electrobun/bun/window/focus.ts +0 -25
- package/src/renderers/electrobun/bun/window/frame.ts +2 -1
- package/src/renderers/electrobun/bun/window/native-min-size.ts +322 -0
- package/src/renderers/electrobun/bun/window/remembered-frame.ts +4 -82
- package/src/renderers/electrobun/shared/protocol.ts +44 -2
- package/src/renderers/electrobun/view/backend-rpc.ts +16 -1
- package/src/renderers/electrobun/view/desktop/window/bridge.ts +63 -3
- package/src/renderers/electrobun/view/main.tsx +13 -7
- package/src/series/fred-argument.ts +17 -0
- package/src/sources/gloomberb-cloud/index.ts +5 -7
- package/src/sources/provider-router/batches.ts +18 -3
- package/src/sources/provider-router/financial-routes.ts +7 -1
- package/src/sources/provider-router/financials.ts +18 -4
- package/src/state/app/context/index.tsx +16 -2
- package/src/state/desktop-windows.ts +63 -0
- package/src/sync/other-window-tabs.ts +62 -0
- package/src/tickers/company-name-listing.ts +23 -3
- package/src/tickers/listing-fate.ts +147 -1
- package/src/tickers/terminal-codes.ts +5 -0
- package/src/time-series/types.ts +6 -0
- package/src/types/config.ts +10 -1
- package/src/types/data-provider.ts +14 -0
- package/src/types/desktop-window.ts +71 -2
- package/src/types/financials.ts +19 -3
- package/src/types/headless.ts +21 -0
- package/src/types/plugin.ts +6 -0
- package/src/ui/index.tsx +14 -13
- package/src/ui/same-props.ts +58 -0
- package/src/utils/cli-output.ts +33 -4
- package/src/utils/double-escape-close.ts +38 -16
- package/src/utils/format.ts +30 -5
- package/src/utils/futures-generic.ts +12 -0
- package/src/utils/http-proxy-upstream.ts +6 -2
- package/src/utils/plugin-proxy-hosts.json +0 -4
- package/src/utils/plugin-proxy-hosts.ts +22 -0
- package/src/utils/price-earnings.ts +18 -0
- package/src/utils/sec-filings.ts +7 -1
- package/patches/electrobun@1.18.1.patch +0 -633
- package/src/api-client/types.ts +0 -2441
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useRef } from "react";
|
|
1
|
+
import { memo, useEffect, useRef } from "react";
|
|
2
2
|
import { Box, ScrollBox, Span, Text, useUiCapabilities, type ScrollBoxRenderable } from "../../../ui";
|
|
3
3
|
import { colors as themeColors, hoverBg } from "../../../theme/colors";
|
|
4
4
|
import { CANONICAL_EXCHANGE_ALIASES } from "../../../utils/exchanges";
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from "./format";
|
|
15
15
|
import type { CompositeChartProps, CompositeChartScene } from "./types";
|
|
16
16
|
import { DIRECTION_MARKER, seriesColorsDirection, seriesCueCssBackground, type SeriesLineCue } from "./series-cues";
|
|
17
|
-
import { DisclosureMarker } from "../../ui/disclosure-marker";
|
|
17
|
+
import { DisclosureMarker as KitDisclosureMarker } from "../../ui/disclosure-marker";
|
|
18
18
|
|
|
19
19
|
const LEGEND_WHEEL_DELTA_PER_CELL = 8;
|
|
20
20
|
const NO_LINE_CUES: ReadonlyMap<string, SeriesLineCue> = new Map();
|
|
@@ -126,8 +126,12 @@ const DIRECTION_TRIANGLES = {
|
|
|
126
126
|
down: "polygon(0 0, 100% 0, 50% 100%)",
|
|
127
127
|
} as const;
|
|
128
128
|
|
|
129
|
+
// The legend renders with the crosshair, its values the series' at the
|
|
130
|
+
// cursor; its markers and chevron hold still, so they render only when they change.
|
|
131
|
+
const DisclosureMarker = memo(KitDisclosureMarker);
|
|
132
|
+
|
|
129
133
|
/** The legend's marker for a series on the desktop: its line as the plot strokes it, its up and down colors, or a dot. */
|
|
130
|
-
function CompositeSeriesSwatch({ series, cue, downColor = null, filled = true }: {
|
|
134
|
+
const CompositeSeriesSwatch = memo(function CompositeSeriesSwatch({ series, cue, downColor = null, filled = true }: {
|
|
131
135
|
series: ResolvedSeries;
|
|
132
136
|
cue: SeriesLineCue | null;
|
|
133
137
|
/** The down color, for a series keyed by direction: an up triangle in its color, then a down one in this. */
|
|
@@ -177,7 +181,7 @@ function CompositeSeriesSwatch({ series, cue, downColor = null, filled = true }:
|
|
|
177
181
|
data-gloom-role="composite-chart-legend-marker"
|
|
178
182
|
/>
|
|
179
183
|
);
|
|
180
|
-
}
|
|
184
|
+
});
|
|
181
185
|
|
|
182
186
|
export function CompositeLegend({
|
|
183
187
|
scene,
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { ChartSurfaceProps } from "../../../ui";
|
|
2
2
|
import type { NativeChartBitmap } from "../native/chart-rasterizer";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
axisResultCache,
|
|
5
|
+
compositeAxisTicks,
|
|
6
|
+
formatCompositeAxisValue,
|
|
7
|
+
formatCompositeCursorValue,
|
|
8
|
+
type CompositeAxisValueFormatter,
|
|
9
|
+
} from "./format";
|
|
4
10
|
import { projectCompositeValue, unprojectCompositeValue } from "./scene";
|
|
5
11
|
import type { CompositeAxisDomain, CompositeChartScene, CompositePanelScene } from "./types";
|
|
6
12
|
|
|
@@ -110,6 +116,19 @@ export function compositeAxisLabelWidth(
|
|
|
110
116
|
includeCursor: boolean,
|
|
111
117
|
): number {
|
|
112
118
|
if (!domain) return 0;
|
|
119
|
+
// With no formatter of its own the cursor reads in cursor precision, so
|
|
120
|
+
// the default formatter is not the same as no formatter.
|
|
121
|
+
const key = `${includeCursor ? "cursor" : ""}:${format ? "" : "default"}`;
|
|
122
|
+
return cachedLabelWidths(domain, format ?? formatCompositeAxisValue, key, () => axisLabelWidth(domain, format, includeCursor));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const cachedLabelWidths = axisResultCache<number>();
|
|
126
|
+
|
|
127
|
+
function axisLabelWidth(
|
|
128
|
+
domain: CompositeAxisDomain,
|
|
129
|
+
format: CompositeAxisValueFormatter | undefined,
|
|
130
|
+
includeCursor: boolean,
|
|
131
|
+
): number {
|
|
113
132
|
const ticks = compositeAxisTicks(domain, format);
|
|
114
133
|
const labels = ticks.map((tick) => tick.label);
|
|
115
134
|
if (includeCursor) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState, type ComponentProps, type ReactNode, type RefObject } from "react";
|
|
2
2
|
import {
|
|
3
3
|
Box,
|
|
4
4
|
ChartSurface,
|
|
@@ -83,6 +83,7 @@ import {
|
|
|
83
83
|
} from "./panel-gestures";
|
|
84
84
|
import { resolvePanelCrosshair, axisLabelRows, cursorAxisLabel, resolveSeriesCursorYRatio, resolveSeriesAxisTags } from "./panel-labels";
|
|
85
85
|
import type { KeyboardToolDrag } from "./use-composite-chart-keyboard";
|
|
86
|
+
import { createValueStore, useCursorScene, useValueStore, type CompositeCursorSource, type ValueStore } from "./cursor-source";
|
|
86
87
|
|
|
87
88
|
const webFrame = globalThis as typeof globalThis & {
|
|
88
89
|
requestAnimationFrame?: (callback: () => void) => number;
|
|
@@ -98,7 +99,9 @@ function pointerRow(event: ChartMouseEvent): number {
|
|
|
98
99
|
|
|
99
100
|
interface CompositePanelSurfaceProps {
|
|
100
101
|
panel: CompositePanelScene;
|
|
102
|
+
/** The chart's scene, without its cursor: the crosshair comes from `cursor`. */
|
|
101
103
|
scene: CompositeChartScene;
|
|
104
|
+
cursor: CompositeCursorSource;
|
|
102
105
|
plotWidth: number;
|
|
103
106
|
leftAxisWidth: number;
|
|
104
107
|
rightAxisWidth: number;
|
|
@@ -178,6 +181,7 @@ const PANEL_DIVIDER_STYLE = {
|
|
|
178
181
|
export function CompositePanelSurface({
|
|
179
182
|
panel,
|
|
180
183
|
scene,
|
|
184
|
+
cursor,
|
|
181
185
|
plotWidth,
|
|
182
186
|
leftAxisWidth,
|
|
183
187
|
rightAxisWidth,
|
|
@@ -222,22 +226,16 @@ export function CompositePanelSurface({
|
|
|
222
226
|
const { cellHeightPx = 18, cellWidthPx = 8, fractionalViewport = false } = useUiCapabilities();
|
|
223
227
|
const renderer = useNativeRenderer();
|
|
224
228
|
const plotRef = useRef<BoxRenderable | null>(null);
|
|
225
|
-
|
|
229
|
+
// The pointer's height over the plot, 0 at the top and 1 at the bottom. It
|
|
230
|
+
// moves with the pointer without rendering the panel: only what draws the
|
|
231
|
+
// crosshair reads it.
|
|
232
|
+
const [pointerY] = useState(() => createValueStore<number | null>(null));
|
|
226
233
|
const [toolDrag, setToolDrag] = useState<ChartToolDrag | null>(null);
|
|
227
234
|
// A pointer drag owns the plot while it lasts; otherwise a tool placed from
|
|
228
235
|
// the keyboard draws and reads out exactly like one.
|
|
229
236
|
const keyboardDrag = toolDrag ? null : keyboardToolDrag;
|
|
230
237
|
const activeDrag = toolDrag ?? keyboardDrag?.drag ?? null;
|
|
231
|
-
|
|
232
|
-
// draws a level line where otherwise only the pointer would.
|
|
233
|
-
const heldCursorYRatio = keyboardDrag ? keyboardDrag.drag.endYRatio : sharedCursor ? null : cursorYRatio;
|
|
234
|
-
const seriesCursorYRatio = useMemo(
|
|
235
|
-
() => resolveSeriesCursorYRatio(panel, scene),
|
|
236
|
-
[panel, scene],
|
|
237
|
-
);
|
|
238
|
-
const activeCursorYRatio = scene.cursorXRatio === null
|
|
239
|
-
? null
|
|
240
|
-
: heldCursorYRatio ?? seriesCursorYRatio;
|
|
238
|
+
const cursorView = { panel, cursor, pointerY, keyboardDrag, sharedCursor };
|
|
241
239
|
// The last press on bare plot, for a double press where the host does not count clicks.
|
|
242
240
|
const lastPlotPressRef = useRef<{ at: number; x: number; y: number } | null>(null);
|
|
243
241
|
const dragRef = useRef<
|
|
@@ -265,16 +263,6 @@ export function CompositePanelSurface({
|
|
|
265
263
|
const plotSpanFactor = 1 + compositeRightOffsetRatio(scene.timeScale);
|
|
266
264
|
const bitmapSize = useStaticChartBitmapSize(plotSize.width, plotSize.height);
|
|
267
265
|
const bitmap = useCompositePanelBitmap({ panel, bitmapSize, colors, isDesktopWeb, revealed: plotSize.revealed === true });
|
|
268
|
-
// The chart under the pointer draws both lines: the level line follows the
|
|
269
|
-
// pointer, and its value sits on the axes, beside each series' own tag on
|
|
270
|
-
// the desktop and the web. A keyboard or shared cursor knows its column
|
|
271
|
-
// only, so a chart following another chart's cursor draws the time line
|
|
272
|
-
// alone. A tool placed from the keyboard is the exception: its end is a level.
|
|
273
|
-
const pointerCursorYRatio = scene.cursorXRatio === null ? null : heldCursorYRatio;
|
|
274
|
-
const crosshair = useMemo(
|
|
275
|
-
() => resolvePanelCrosshair(panel, bitmap, scene, pointerCursorYRatio, colors.crosshair),
|
|
276
|
-
[bitmap, colors.crosshair, panel, pointerCursorYRatio, scene],
|
|
277
|
-
);
|
|
278
266
|
const measureDomain = useMemo(() => resolveMeasureAxisDomain(panel), [panel]);
|
|
279
267
|
const toolReadout = useMemo(() => {
|
|
280
268
|
if (!activeDrag) return null;
|
|
@@ -356,13 +344,16 @@ export function CompositePanelSurface({
|
|
|
356
344
|
() => levels && levelDomain ? projectLevels(levels.items, levelDomain, levelDraft) : NO_LEVELS,
|
|
357
345
|
[levelDomain, levelDraft, levels],
|
|
358
346
|
);
|
|
359
|
-
// Over a line a plain drag moves, and while one moves, the pointer says it
|
|
360
|
-
|
|
347
|
+
// Over a line a plain drag moves, and while one moves, the pointer says it
|
|
348
|
+
// goes up and down. Where the pointer is, the plot reads (see `PanelPlotSurface`).
|
|
349
|
+
const levelGrab = useMemo<LevelGrab>(() => {
|
|
361
350
|
if (levelDraft) return true;
|
|
362
|
-
if (!levels?.onEdit ||
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
351
|
+
if (!levels?.onEdit || onPickTime || onPickPrice || (armedTool && armedTool !== "level")) return false;
|
|
352
|
+
return (cursorYRatio) => {
|
|
353
|
+
const hit = hitTestLevel(projectedLevels, cursorYRatio, levelGrabRatio(panel.height));
|
|
354
|
+
return !!hit?.editable && !!hit.draggable;
|
|
355
|
+
};
|
|
356
|
+
}, [armedTool, levelDraft, levels?.onEdit, onPickPrice, onPickTime, panel.height, projectedLevels]);
|
|
366
357
|
// Drawings project through the time scale alone: the crosshair moving,
|
|
367
358
|
// here or on a linked chart, must not repaint the plot, which the terminal's
|
|
368
359
|
// kitty surface would upload whole again.
|
|
@@ -432,16 +423,6 @@ export function CompositePanelSurface({
|
|
|
432
423
|
selectedLevelId,
|
|
433
424
|
toolReadout?.direction,
|
|
434
425
|
]);
|
|
435
|
-
const textLines = useMemo(
|
|
436
|
-
() => isDesktopWeb || !showTextFallback
|
|
437
|
-
? []
|
|
438
|
-
: writeLevelText(
|
|
439
|
-
renderCompositePanelText(panel, plotWidth, scene.cursorXRatio, pointerCursorYRatio),
|
|
440
|
-
projectedLevels,
|
|
441
|
-
selectedLevelId,
|
|
442
|
-
),
|
|
443
|
-
[isDesktopWeb, panel, plotWidth, pointerCursorYRatio, projectedLevels, scene.cursorXRatio, selectedLevelId, showTextFallback],
|
|
444
|
-
);
|
|
445
426
|
const leftAxisLabels = useMemo(
|
|
446
427
|
() => axisLabelRows(
|
|
447
428
|
renderCompositeAxisText(panel.axes.left, panel.height, leftAxisWidth, "left", formatAxisValue),
|
|
@@ -462,17 +443,6 @@ export function CompositePanelSurface({
|
|
|
462
443
|
() => compositeAxisTickLabels(panel.axes.right, rightAxisWidth, formatAxisValue),
|
|
463
444
|
[formatAxisValue, panel, rightAxisWidth],
|
|
464
445
|
);
|
|
465
|
-
const cursorRow = activeCursorYRatio === null
|
|
466
|
-
? null
|
|
467
|
-
: Math.round(activeCursorYRatio * Math.max(panel.height - 1, 0));
|
|
468
|
-
const cursorPixelY = activeCursorYRatio === null
|
|
469
|
-
? null
|
|
470
|
-
: activeCursorYRatio * Math.max(panel.height * cellHeightPx - 1, 0);
|
|
471
|
-
// The pointer's value on the axes follows the level line it belongs to.
|
|
472
|
-
const axisCursorYRatio = isDesktopWeb ? pointerCursorYRatio : activeCursorYRatio;
|
|
473
|
-
const leftCursorLabel = cursorAxisLabel(panel, "left", axisCursorYRatio, formatAxisValue);
|
|
474
|
-
const rightCursorLabel = cursorAxisLabel(panel, "right", axisCursorYRatio, formatAxisValue);
|
|
475
|
-
const seriesAxisTags = useMemo(() => isDesktopWeb ? resolveSeriesAxisTags(panel, scene, formatAxisValue) : [], [formatAxisValue, isDesktopWeb, panel, scene]);
|
|
476
446
|
const measureReadout = useMemo(() => {
|
|
477
447
|
if (!activeDrag || !toolReadout?.summary) return null;
|
|
478
448
|
const text = toolReadout.summary;
|
|
@@ -614,15 +584,15 @@ export function CompositePanelSurface({
|
|
|
614
584
|
const nextYRatio = panel.height <= 1
|
|
615
585
|
? 0.5
|
|
616
586
|
: Math.max(0, Math.min(1, pointer.cellY / (panel.height - 1)));
|
|
617
|
-
|
|
587
|
+
pointerY.set(nextYRatio);
|
|
618
588
|
onCursorDateChange(nextDate);
|
|
619
589
|
consumeChartMouseEvent(event);
|
|
620
590
|
return true;
|
|
621
|
-
}, [onCursorDateChange, panel.height, plotPointer, scene]);
|
|
591
|
+
}, [onCursorDateChange, panel.height, plotPointer, pointerY, scene]);
|
|
622
592
|
const clearCursor = useCallback(() => {
|
|
623
|
-
|
|
593
|
+
pointerY.set(null);
|
|
624
594
|
onCursorDateChange(null);
|
|
625
|
-
}, [onCursorDateChange]);
|
|
595
|
+
}, [onCursorDateChange, pointerY]);
|
|
626
596
|
const startDrag = useCallback((event: ChartMouseEvent) => {
|
|
627
597
|
onActivate?.();
|
|
628
598
|
onPointerPress();
|
|
@@ -1196,21 +1166,19 @@ export function CompositePanelSurface({
|
|
|
1196
1166
|
) : null}
|
|
1197
1167
|
{leftAxisWidth > 0 ? (
|
|
1198
1168
|
<>
|
|
1199
|
-
<
|
|
1169
|
+
<PanelValueAxis
|
|
1170
|
+
view={cursorView}
|
|
1171
|
+
formatAxisValue={formatAxisValue}
|
|
1200
1172
|
axisLabels={leftAxisLabels}
|
|
1201
1173
|
axisTicks={leftAxisTicks}
|
|
1202
1174
|
axisWidth={leftAxisWidth}
|
|
1203
1175
|
axisSectionWidth={leftAxisWidth}
|
|
1204
1176
|
side="left"
|
|
1205
1177
|
height={panel.height}
|
|
1206
|
-
cursorRow={cursorRow}
|
|
1207
|
-
cursorPixelY={cursorPixelY}
|
|
1208
|
-
cursorLabel={leftCursorLabel}
|
|
1209
1178
|
cursorColor={colors.crosshair}
|
|
1210
1179
|
cursorBackgroundColor={colors.background}
|
|
1211
1180
|
axisColor={colors.textDim}
|
|
1212
1181
|
extraMarkers={leftAxisMarkers}
|
|
1213
|
-
seriesTags={isDesktopWeb ? seriesAxisTags.filter((tag) => tag.side === "left") : undefined}
|
|
1214
1182
|
measuredPixelHeight={plotSize.height * cellHeightPx}
|
|
1215
1183
|
gestures={leftAxisGestures}
|
|
1216
1184
|
footButton={manualSide === "left"}
|
|
@@ -1218,16 +1186,24 @@ export function CompositePanelSurface({
|
|
|
1218
1186
|
<Box width={axisGap} />
|
|
1219
1187
|
</>
|
|
1220
1188
|
) : null}
|
|
1221
|
-
<
|
|
1222
|
-
|
|
1189
|
+
<PanelPlotSurface
|
|
1190
|
+
view={cursorView}
|
|
1191
|
+
plotRef={plotRef}
|
|
1192
|
+
bitmap={bitmap}
|
|
1193
|
+
crosshairColor={colors.crosshair}
|
|
1194
|
+
textColor={colors.text}
|
|
1195
|
+
textFallback={!isDesktopWeb && showTextFallback}
|
|
1196
|
+
plotWidth={plotWidth}
|
|
1197
|
+
projectedLevels={projectedLevels}
|
|
1198
|
+
selectedLevelId={selectedLevelId}
|
|
1199
|
+
levelGrab={levelGrab}
|
|
1223
1200
|
// Its measured box on the desktop, where pointer bounds read it; CSS lays it out.
|
|
1224
1201
|
width={plotSize.width}
|
|
1225
1202
|
height={plotSize.height}
|
|
1226
1203
|
// Desktop: the width the axes leave, and the row's height.
|
|
1227
|
-
style={isDesktopWeb ?
|
|
1204
|
+
style={isDesktopWeb ? onPickPrice ? DESKTOP_PLOT_PICK_STYLE : DESKTOP_PLOT_STYLE : undefined}
|
|
1228
1205
|
flexDirection="column"
|
|
1229
1206
|
bitmaps={bitmapLayers}
|
|
1230
|
-
crosshair={crosshair}
|
|
1231
1207
|
vectors={vectors}
|
|
1232
1208
|
onMouseMove={interactive ? handleMouseMove : undefined}
|
|
1233
1209
|
onMouseDown={interactive ? navigable ? pressPlot : pressCursor : undefined}
|
|
@@ -1236,54 +1212,55 @@ export function CompositePanelSurface({
|
|
|
1236
1212
|
onMouseDragEnd={interactive && navigable ? releasePlot : undefined}
|
|
1237
1213
|
onMouseScroll={interactive && navigable ? panFromWheel : undefined}
|
|
1238
1214
|
onMouseOut={interactive ? clearCursor : undefined}
|
|
1239
|
-
cursor={interactive ?
|
|
1215
|
+
cursor={interactive ? toolDrag || !navigable || onPickTime || onPickPrice ? "crosshair" : "grab" : undefined}
|
|
1240
1216
|
data-gloom-interactive={interactive ? "true" : undefined}
|
|
1241
1217
|
data-gloom-role={COMPOSITE_PANEL_ROLE}
|
|
1242
1218
|
data-gloom-remote-kind={remoteKind}
|
|
1243
1219
|
data-gloom-label={panel.label ?? panel.id}
|
|
1244
1220
|
data-gloom-value-scale={manuallyScaled ? "manual" : undefined}
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1221
|
+
/>
|
|
1222
|
+
{projectedLevels.length > 0 ? (
|
|
1223
|
+
// A level's label leaves its value to the axis, unless the cursor's covers it there.
|
|
1224
|
+
<PanelLevelLabels view={cursorView}>
|
|
1225
|
+
{(activeCursorYRatio) => (isDesktopWeb
|
|
1226
|
+
? layoutLevelLabels(projectedLevels, plotSize.height * cellHeightPx, cellHeightPx)
|
|
1227
|
+
: fitAxisLabels(projectedLevels.filter((entry) => entry.level.label), [], (entry) => entry.yRatio * Math.max(1, panel.height - 1))
|
|
1228
|
+
).map((entry) => {
|
|
1229
|
+
const { level, yRatio } = entry;
|
|
1230
|
+
const axisWidth = levelDomain?.side === "left" ? leftAxisWidth : rightAxisWidth;
|
|
1231
|
+
const axisMarkers = levelDomain?.side === "left" ? leftAxisMarkers : rightAxisMarkers;
|
|
1232
|
+
const cursorCovers = activeCursorYRatio !== null && Math.abs(activeCursorYRatio - yRatio) * panel.height < 1;
|
|
1233
|
+
const axisVisible = !cursorCovers && (level.axisLabel?.length ?? 0) <= axisWidth && !!axisMarkers?.some((marker) => marker.id === level.id);
|
|
1234
|
+
const label = levelLabelText(level, axisVisible);
|
|
1235
|
+
const labelStyle = isDesktopWeb ? {
|
|
1236
|
+
...levelLabelStyle(entry, colors.background), left: "auto", right: (rightAxisWidth + (rightAxisWidth ? axisGap : 0) + 1) * cellWidthPx,
|
|
1237
|
+
maxWidth: Math.max(1, plotWidth - 2) * cellWidthPx,
|
|
1238
|
+
} : undefined;
|
|
1239
|
+
const labelWidth = Math.min(plotWidth - 2, label.length + 2);
|
|
1240
|
+
return <Box key={`annotation:${level.id}`} position="absolute" left={leftAxisWidth + (leftAxisWidth ? axisGap : 0) + plotWidth - labelWidth - 1} top={yRatio * Math.max(0, panel.height - 1)} height={1}
|
|
1241
|
+
width={labelWidth} flexDirection="row" justifyContent="flex-end" backgroundColor={colors.background} zIndex={20}
|
|
1242
|
+
style={labelStyle} data-gloom-role="chart-level-label">
|
|
1243
|
+
<Text fg={labelStyle?.color ?? level.color} wrapMode="none" style={isDesktopWeb ? { lineHeight: 1 } : undefined}>{label}</Text>
|
|
1244
|
+
</Box>;
|
|
1245
|
+
})}
|
|
1246
|
+
</PanelLevelLabels>
|
|
1247
|
+
) : null}
|
|
1269
1248
|
{rightAxisWidth > 0 ? (
|
|
1270
1249
|
<>
|
|
1271
1250
|
<Box width={axisGap} />
|
|
1272
|
-
<
|
|
1251
|
+
<PanelValueAxis
|
|
1252
|
+
view={cursorView}
|
|
1253
|
+
formatAxisValue={formatAxisValue}
|
|
1273
1254
|
axisLabels={rightAxisLabels}
|
|
1274
1255
|
axisTicks={rightAxisTicks}
|
|
1275
1256
|
axisWidth={rightAxisWidth}
|
|
1276
1257
|
axisSectionWidth={rightAxisWidth}
|
|
1277
1258
|
side="right"
|
|
1278
1259
|
height={panel.height}
|
|
1279
|
-
cursorRow={cursorRow}
|
|
1280
|
-
cursorPixelY={cursorPixelY}
|
|
1281
|
-
cursorLabel={rightCursorLabel}
|
|
1282
1260
|
cursorColor={colors.crosshair}
|
|
1283
1261
|
cursorBackgroundColor={colors.background}
|
|
1284
1262
|
axisColor={colors.textDim}
|
|
1285
1263
|
extraMarkers={rightAxisMarkers}
|
|
1286
|
-
seriesTags={isDesktopWeb ? seriesAxisTags.filter((tag) => tag.side === "right") : undefined}
|
|
1287
1264
|
measuredPixelHeight={plotSize.height * cellHeightPx}
|
|
1288
1265
|
gestures={rightAxisGestures}
|
|
1289
1266
|
footButton={manualSide === "right"}
|
|
@@ -1326,3 +1303,135 @@ export function CompositePanelSurface({
|
|
|
1326
1303
|
</Box>
|
|
1327
1304
|
);
|
|
1328
1305
|
}
|
|
1306
|
+
|
|
1307
|
+
/** Over a level a drag moves: always while one moves, never, or at the pointer's height. */
|
|
1308
|
+
type LevelGrab = boolean | ((cursorYRatio: number) => boolean);
|
|
1309
|
+
|
|
1310
|
+
/** What a panel's crosshair is read from: everything else in the panel holds still while it moves. */
|
|
1311
|
+
interface PanelCursorView {
|
|
1312
|
+
panel: CompositePanelScene;
|
|
1313
|
+
cursor: CompositeCursorSource;
|
|
1314
|
+
pointerY: ValueStore<number | null>;
|
|
1315
|
+
keyboardDrag: KeyboardToolDrag | null;
|
|
1316
|
+
sharedCursor: boolean;
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
/** The crosshair over a panel, read by the parts that draw it, so a pointer move renders only them. */
|
|
1320
|
+
function usePanelCursor({ panel, cursor, pointerY, keyboardDrag, sharedCursor }: PanelCursorView) {
|
|
1321
|
+
const scene = useCursorScene(cursor);
|
|
1322
|
+
const cursorYRatio = useValueStore(pointerY);
|
|
1323
|
+
// A keyboard placement's end sits at the level the user put it, so it
|
|
1324
|
+
// draws a level line where otherwise only the pointer would.
|
|
1325
|
+
const heldCursorYRatio = keyboardDrag ? keyboardDrag.drag.endYRatio : sharedCursor ? null : cursorYRatio;
|
|
1326
|
+
const seriesCursorYRatio = useMemo(
|
|
1327
|
+
() => resolveSeriesCursorYRatio(panel, scene),
|
|
1328
|
+
[panel, scene],
|
|
1329
|
+
);
|
|
1330
|
+
return {
|
|
1331
|
+
scene,
|
|
1332
|
+
cursorYRatio,
|
|
1333
|
+
activeCursorYRatio: scene.cursorXRatio === null ? null : heldCursorYRatio ?? seriesCursorYRatio,
|
|
1334
|
+
// The chart under the pointer draws both lines: the level line follows the
|
|
1335
|
+
// pointer, and its value sits on the axes, beside each series' own tag on
|
|
1336
|
+
// the desktop and the web. A keyboard or shared cursor knows its column
|
|
1337
|
+
// only, so a chart following another chart's cursor draws the time line
|
|
1338
|
+
// alone. A tool placed from the keyboard is the exception: its end is a level.
|
|
1339
|
+
pointerCursorYRatio: scene.cursorXRatio === null ? null : heldCursorYRatio,
|
|
1340
|
+
};
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
/** The plot, with the crosshair over it and, in a terminal without graphics, the text that draws both. */
|
|
1344
|
+
function PanelPlotSurface({
|
|
1345
|
+
view,
|
|
1346
|
+
plotRef,
|
|
1347
|
+
bitmap,
|
|
1348
|
+
crosshairColor,
|
|
1349
|
+
textColor,
|
|
1350
|
+
textFallback,
|
|
1351
|
+
plotWidth,
|
|
1352
|
+
projectedLevels,
|
|
1353
|
+
selectedLevelId,
|
|
1354
|
+
levelGrab,
|
|
1355
|
+
...surface
|
|
1356
|
+
}: Omit<ComponentProps<typeof ChartSurface>, "ref" | "crosshair" | "children"> & {
|
|
1357
|
+
view: PanelCursorView;
|
|
1358
|
+
plotRef: RefObject<BoxRenderable | null>;
|
|
1359
|
+
bitmap: ReturnType<typeof useCompositePanelBitmap>;
|
|
1360
|
+
crosshairColor: string;
|
|
1361
|
+
textColor: string;
|
|
1362
|
+
textFallback: boolean;
|
|
1363
|
+
plotWidth: number;
|
|
1364
|
+
projectedLevels: readonly ProjectedLevel[];
|
|
1365
|
+
selectedLevelId: string | null;
|
|
1366
|
+
levelGrab: LevelGrab;
|
|
1367
|
+
}) {
|
|
1368
|
+
const { panel } = view;
|
|
1369
|
+
const { scene, cursorYRatio, pointerCursorYRatio } = usePanelCursor(view);
|
|
1370
|
+
const crosshair = useMemo(
|
|
1371
|
+
() => resolvePanelCrosshair(panel, bitmap, scene, pointerCursorYRatio, crosshairColor),
|
|
1372
|
+
[bitmap, crosshairColor, panel, pointerCursorYRatio, scene],
|
|
1373
|
+
);
|
|
1374
|
+
const textLines = useMemo(
|
|
1375
|
+
() => textFallback
|
|
1376
|
+
? writeLevelText(
|
|
1377
|
+
renderCompositePanelText(panel, plotWidth, scene.cursorXRatio, pointerCursorYRatio),
|
|
1378
|
+
projectedLevels,
|
|
1379
|
+
selectedLevelId,
|
|
1380
|
+
)
|
|
1381
|
+
: [],
|
|
1382
|
+
[panel, plotWidth, pointerCursorYRatio, projectedLevels, scene.cursorXRatio, selectedLevelId, textFallback],
|
|
1383
|
+
);
|
|
1384
|
+
const grab = typeof levelGrab === "function" ? cursorYRatio !== null && levelGrab(cursorYRatio) : levelGrab;
|
|
1385
|
+
return (
|
|
1386
|
+
<ChartSurface
|
|
1387
|
+
ref={plotRef}
|
|
1388
|
+
{...surface}
|
|
1389
|
+
style={grab && surface.style ? DESKTOP_PLOT_LEVEL_STYLE : surface.style}
|
|
1390
|
+
cursor={grab && surface.cursor ? "ns-resize" : surface.cursor}
|
|
1391
|
+
crosshair={crosshair}
|
|
1392
|
+
>
|
|
1393
|
+
{textLines.map((line, index) => <Text key={index} fg={textColor}>{line}</Text>)}
|
|
1394
|
+
</ChartSurface>
|
|
1395
|
+
);
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
/** A value axis, with the cursor's value on it and, on the desktop, each series' value at the cursor. */
|
|
1399
|
+
function PanelValueAxis({
|
|
1400
|
+
view,
|
|
1401
|
+
formatAxisValue,
|
|
1402
|
+
side,
|
|
1403
|
+
...axis
|
|
1404
|
+
}: Omit<ComponentProps<typeof PriceAxisLabels>, "cursorRow" | "cursorPixelY" | "cursorLabel" | "seriesTags" | "side"> & {
|
|
1405
|
+
view: PanelCursorView;
|
|
1406
|
+
formatAxisValue?: CompositeAxisValueFormatter;
|
|
1407
|
+
side: CompositeAxisSide;
|
|
1408
|
+
}) {
|
|
1409
|
+
const { panel } = view;
|
|
1410
|
+
const isDesktopWeb = useUiCapabilities().nativePaneChrome === true;
|
|
1411
|
+
const { cellHeightPx = 18 } = useUiCapabilities();
|
|
1412
|
+
const { scene, activeCursorYRatio, pointerCursorYRatio } = usePanelCursor(view);
|
|
1413
|
+
// The pointer's value on the axes follows the level line it belongs to.
|
|
1414
|
+
const axisCursorYRatio = isDesktopWeb ? pointerCursorYRatio : activeCursorYRatio;
|
|
1415
|
+
const seriesTags = useMemo(
|
|
1416
|
+
() => isDesktopWeb ? resolveSeriesAxisTags(panel, scene, formatAxisValue).filter((tag) => tag.side === side) : undefined,
|
|
1417
|
+
[formatAxisValue, isDesktopWeb, panel, scene, side],
|
|
1418
|
+
);
|
|
1419
|
+
return (
|
|
1420
|
+
<PriceAxisLabels
|
|
1421
|
+
{...axis}
|
|
1422
|
+
side={side}
|
|
1423
|
+
cursorRow={activeCursorYRatio === null ? null : Math.round(activeCursorYRatio * Math.max(panel.height - 1, 0))}
|
|
1424
|
+
cursorPixelY={activeCursorYRatio === null ? null : activeCursorYRatio * Math.max(panel.height * cellHeightPx - 1, 0)}
|
|
1425
|
+
cursorLabel={cursorAxisLabel(panel, side, axisCursorYRatio, formatAxisValue)}
|
|
1426
|
+
seriesTags={seriesTags}
|
|
1427
|
+
/>
|
|
1428
|
+
);
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
/** A panel's level labels, which step aside where the cursor's label covers theirs on the axis. */
|
|
1432
|
+
function PanelLevelLabels({ view, children }: {
|
|
1433
|
+
view: PanelCursorView;
|
|
1434
|
+
children: (activeCursorYRatio: number | null) => ReactNode;
|
|
1435
|
+
}) {
|
|
1436
|
+
return <>{children(usePanelCursor(view).activeCursorYRatio)}</>;
|
|
1437
|
+
}
|