gloomberb 0.20.4 → 0.20.6
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/README.md +3 -1
- package/README.zh-CN.md +1 -1
- package/bin/gloom +9 -0
- package/bin/without-bun.cjs +98 -0
- package/package.json +4 -1
- package/src/api-client/data.ts +148 -37
- package/src/api-client/hk-tenders.ts +59 -0
- package/src/api-client/index.ts +1 -0
- package/src/api-client/types/econ.ts +30 -0
- package/src/api-client/yield-curves.ts +1 -1
- package/src/app/global-shortcuts.ts +4 -1
- package/src/app/keybindings/actions.ts +6 -0
- package/src/app/keybindings/config.ts +2 -1
- package/src/app/keybindings/index.ts +1 -0
- package/src/app/keybindings/labels.ts +6 -1
- package/src/app/keybindings/resolve.ts +23 -4
- package/src/app/keybindings/terminal-keys.ts +35 -0
- package/src/app/pane-runtime/index.tsx +2 -2
- package/src/app/pane-runtime/ticker-open-runtime.ts +68 -40
- package/src/app.tsx +18 -13
- package/src/architecture/floating-promise-allowlist.json +313 -0
- package/src/architecture/ui-literals-allowlist.json +1 -1
- package/src/capabilities/chart-series.ts +27 -1
- package/src/cli/commands/keybindings.ts +5 -5
- package/src/cli/commands/market.ts +238 -57
- package/src/cli/commands/news-search.ts +81 -14
- package/src/cli/commands/overview.ts +27 -6
- package/src/cli/commands/remote.ts +16 -17
- package/src/cli/commands/system.ts +1 -1
- package/src/cli/commands/ticker.ts +3 -1
- package/src/cli/early-command.ts +2 -0
- package/src/cli/errors.ts +10 -1
- package/src/cli/fx-forward.ts +89 -7
- package/src/cli/fx-pair.ts +1 -1
- package/src/cli/fx-quote-rate.ts +23 -0
- package/src/cli/glossary.ts +19 -5
- package/src/cli/help.ts +1 -0
- package/src/cli/history-rows.ts +5 -3
- package/src/cli/index-roots.ts +5 -4
- package/src/cli/index.ts +40 -3
- package/src/cli/known-gaps.ts +38 -9
- package/src/cli/listing-arg.ts +17 -5
- package/src/cli/name-entries.ts +5 -1
- package/src/cli/not-a-ticker.ts +4 -0
- package/src/cli/options.ts +52 -3
- package/src/cli/output-file.ts +5 -3
- package/src/cli/pane-functions/catalog.ts +15 -0
- package/src/cli/pane-functions/function-help.ts +4 -4
- package/src/cli/pane-functions/headless.ts +9 -4
- package/src/cli/pane-functions/index.ts +6 -4
- package/src/cli/pane-functions/resolver.ts +2 -2
- package/src/cli/result.ts +21 -2
- package/src/cli/spreadsheet-hint.ts +7 -3
- package/src/cli/treasury-yields.ts +5 -3
- package/src/components/chart/composite/legend.tsx +40 -2
- package/src/components/command-bar/pane-settings.ts +2 -2
- package/src/components/command-bar/routes/root/results.ts +6 -2
- package/src/components/command-bar/workflow/tickers.ts +2 -2
- package/src/components/data-table/view.tsx +9 -2
- package/src/components/input-search-bar.tsx +9 -2
- package/src/components/layout/pane/header.tsx +2 -0
- package/src/components/layout/shell/pane/capture.ts +4 -1
- package/src/components/layout/status-bar.tsx +6 -1
- package/src/components/onboarding/first-run-workspace.ts +44 -2
- package/src/components/onboarding/onboarding-frame.tsx +11 -2
- package/src/components/onboarding/onboarding-keyboard.ts +16 -0
- package/src/components/onboarding/onboarding-wizard.tsx +8 -8
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +62 -1
- package/src/components/onboarding/use-onboarding-progress.ts +12 -4
- package/src/components/pane-settings-dialog/desktop.tsx +2 -2
- package/src/components/pane-settings-dialog/tui.tsx +2 -2
- package/src/components/pane-settings-dialog/value.ts +6 -0
- package/src/components/pane-settings-dialog.tsx +3 -3
- package/src/components/reader/detail-reader.tsx +4 -0
- package/src/components/ui/data-table/opentui/index.tsx +11 -4
- package/src/components/ui/data-table/opentui/model.ts +8 -6
- package/src/components/ui/data-table/types.ts +6 -1
- package/src/components/ui/index.ts +1 -1
- package/src/components/ui/page-stack-view.tsx +3 -0
- package/src/components/ui/pane-link-chip.tsx +269 -54
- package/src/components/ui/query-bar.tsx +2 -1
- package/src/components/ui/table-layout.ts +38 -1
- package/src/components/ui/tabs.tsx +97 -19
- package/src/core/state/app/layout-reducer.ts +7 -0
- package/src/core/state/app/layout.ts +44 -7
- package/src/core/state/app/state.ts +1 -1
- package/src/core/state/app/types.ts +22 -2
- package/src/docs/snapshot.json +30 -13
- package/src/market-data/depositary-pair.ts +5 -3
- package/src/market-data/market/change-basis.ts +9 -5
- package/src/market-data/market/dated-previous-close.ts +147 -17
- package/src/market-data/market/status.ts +17 -1
- package/src/market-data/quotes/contributions.ts +2 -0
- package/src/market-data/quotes/listing-enterprise-value.ts +50 -0
- package/src/plugins/builtin/alerts/metric-data.ts +15 -2
- package/src/plugins/builtin/analytics/risk-client.ts +10 -4
- package/src/plugins/builtin/analytics/risk-episodes.ts +5 -4
- package/src/plugins/builtin/analytics/risk-headless.ts +4 -2
- package/src/plugins/builtin/analytics/risk-sectors.ts +91 -0
- package/src/plugins/builtin/awards/index.tsx +1 -1
- package/src/plugins/builtin/backtest/headless.ts +1 -1
- package/src/plugins/builtin/buildout/index.tsx +1 -0
- package/src/plugins/builtin/catalysts/index.tsx +2 -2
- package/src/plugins/builtin/cds/headless.ts +4 -0
- package/src/plugins/builtin/cds/model.ts +0 -6
- package/src/plugins/builtin/chart-composer/formula.ts +16 -3
- package/src/plugins/builtin/chart-composer/headless-schema.ts +2 -0
- package/src/plugins/builtin/chart-composer/headless.ts +4 -2
- package/src/plugins/builtin/chart-composer/index.tsx +1 -0
- package/src/plugins/builtin/chart-composer/presets.ts +1 -0
- package/src/plugins/builtin/chat/content/composer.tsx +5 -4
- package/src/plugins/builtin/chat/content/index.tsx +12 -2
- package/src/plugins/builtin/chat/content/layout-metrics.ts +3 -3
- package/src/plugins/builtin/chat/content/open-targets.ts +3 -3
- package/src/plugins/builtin/chat/layout.ts +5 -2
- package/src/plugins/builtin/chat/message/pane-chip.tsx +61 -40
- package/src/plugins/builtin/chat/message/terminal.tsx +13 -15
- package/src/plugins/builtin/chat/pane-links/previews.ts +51 -5
- package/src/plugins/builtin/chat/pane-links/share-card.ts +36 -0
- package/src/plugins/builtin/cloud/askg/pane.tsx +55 -13
- package/src/plugins/builtin/cloud/askg/tool-display.ts +1 -0
- package/src/plugins/builtin/cloud/terminal-relay/redact.ts +5 -3
- package/src/plugins/builtin/commodity-balances/index.tsx +1 -0
- package/src/plugins/builtin/company-attention/index.tsx +1 -1
- package/src/plugins/builtin/company-kpis/headless.ts +3 -1
- package/src/plugins/builtin/company-kpis/index.tsx +2 -2
- package/src/plugins/builtin/cot/index.tsx +1 -1
- package/src/plugins/builtin/cpi/index.tsx +1 -1
- package/src/plugins/builtin/credit-boards/cdx-pane.tsx +20 -7
- package/src/plugins/builtin/credit-boards/client.ts +8 -0
- package/src/plugins/builtin/credit-boards/headless.ts +4 -1
- package/src/plugins/builtin/credit-boards/model.ts +58 -4
- package/src/plugins/builtin/credit-boards/series.ts +63 -6
- package/src/plugins/builtin/credit-boards/sovr-pane.tsx +3 -2
- package/src/plugins/builtin/credit-conditions/headless.ts +24 -6
- package/src/plugins/builtin/credit-conditions/index.tsx +1 -1
- package/src/plugins/builtin/credit-conditions/model.ts +12 -6
- package/src/plugins/builtin/credit-conditions/series.ts +2 -1
- package/src/plugins/builtin/crypto-board/index.tsx +1 -0
- package/src/plugins/builtin/dividend-yield/index.tsx +1 -0
- package/src/plugins/builtin/doe/index.tsx +1 -1
- package/src/plugins/builtin/earnings-calls/headless.ts +5 -1
- package/src/plugins/builtin/earnings-calls/index.tsx +1 -0
- package/src/plugins/builtin/econ/calendar-model.ts +115 -8
- package/src/plugins/builtin/econ/calendar-source.ts +7 -1
- package/src/plugins/builtin/econ/fred-catalog.ts +3 -1
- package/src/plugins/builtin/econ/index.tsx +42 -8
- package/src/plugins/builtin/econ/types.ts +3 -0
- package/src/plugins/builtin/econ-statistics/index.tsx +1 -0
- package/src/plugins/builtin/econ-statistics/pane.tsx +6 -0
- package/src/plugins/builtin/estimate-revisions/index.tsx +1 -0
- package/src/plugins/builtin/executives/index.tsx +1 -0
- package/src/plugins/builtin/filing-events/index.tsx +1 -0
- package/src/plugins/builtin/fixed-income/index.tsx +3 -0
- package/src/plugins/builtin/futures-curve/headless.ts +3 -3
- package/src/plugins/builtin/futures-curve/index.tsx +1 -1
- package/src/plugins/builtin/futures-curve/model.ts +18 -0
- package/src/plugins/builtin/fx-matrix/index.tsx +44 -14
- package/src/plugins/builtin/gpu/index.tsx +1 -1
- package/src/plugins/builtin/help/functions-table.tsx +1 -1
- package/src/plugins/builtin/help/index.tsx +11 -1
- package/src/plugins/builtin/help/keybindings-editor.tsx +7 -3
- package/src/plugins/builtin/holders/index.tsx +1 -0
- package/src/plugins/builtin/holders/report-header.ts +2 -2
- package/src/plugins/builtin/insider/index.tsx +1 -0
- package/src/plugins/builtin/iv-history/index.tsx +1 -1
- package/src/plugins/builtin/jobs/index.tsx +1 -0
- package/src/plugins/builtin/macro-day/headless.ts +27 -8
- package/src/plugins/builtin/macro-day/index.tsx +1 -1
- package/src/plugins/builtin/macro-day/model.ts +19 -3
- package/src/plugins/builtin/macro-day/pane.tsx +14 -9
- package/src/plugins/builtin/macro-day/releases.ts +25 -7
- package/src/plugins/builtin/market-valuation/index.tsx +1 -0
- package/src/plugins/builtin/market-valuation/pane.tsx +8 -0
- package/src/plugins/builtin/members/index.tsx +1 -1
- package/src/plugins/builtin/mna/index.tsx +1 -0
- package/src/plugins/builtin/news/index.tsx +1 -0
- package/src/plugins/builtin/news/wire/index.tsx +5 -1
- package/src/plugins/builtin/news/wire/news/detail-view.tsx +4 -0
- package/src/plugins/builtin/news/wire/news/list-search.ts +5 -2
- package/src/plugins/builtin/options/index.tsx +1 -0
- package/src/plugins/builtin/options-positioning/index.tsx +1 -0
- package/src/plugins/builtin/pe-band/index.tsx +1 -1
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +25 -0
- package/src/plugins/builtin/portfolio-list/cli/render.ts +20 -3
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +5 -1
- package/src/plugins/builtin/portfolio-list/headless.ts +15 -6
- package/src/plugins/builtin/power/index.tsx +1 -1
- package/src/plugins/builtin/realized-vol/index.tsx +1 -1
- package/src/plugins/builtin/research/headless-schema.ts +4 -3
- package/src/plugins/builtin/research/headless.ts +10 -4
- package/src/plugins/builtin/research/index.tsx +4 -0
- package/src/plugins/builtin/research/relative-valuation-columns.ts +145 -47
- package/src/plugins/builtin/research/relative-valuation-currency.ts +31 -0
- package/src/plugins/builtin/research/relative-valuation-headless.ts +25 -8
- package/src/plugins/builtin/research/relative-valuation-model.ts +40 -9
- package/src/plugins/builtin/research/relative-valuation-pane.tsx +3 -2
- package/src/plugins/builtin/research/relative-valuation-peers.ts +2 -2
- package/src/plugins/builtin/research-search/index.tsx +1 -0
- package/src/plugins/builtin/research-search/pane.tsx +8 -0
- package/src/plugins/builtin/revenue-breakdown/index.tsx +1 -0
- package/src/plugins/builtin/reverse-dcf/index.tsx +1 -1
- package/src/plugins/builtin/risk-factors/index.tsx +1 -0
- package/src/plugins/builtin/scanner/headless.ts +52 -13
- package/src/plugins/builtin/seasonality/index.tsx +1 -1
- package/src/plugins/builtin/sec/index.tsx +1 -0
- package/src/plugins/builtin/series-inventory.ts +1 -1
- package/src/plugins/builtin/shared/scanner-capture.ts +11 -3
- package/src/plugins/builtin/shared/series-list-detail.tsx +5 -0
- package/src/plugins/builtin/short-interest/index.tsx +1 -0
- package/src/plugins/builtin/social-mentions/index.tsx +1 -1
- package/src/plugins/builtin/supply-chain/index.tsx +1 -0
- package/src/plugins/builtin/thirteenf/api.ts +47 -4
- package/src/plugins/builtin/thirteenf/data.ts +43 -10
- package/src/plugins/builtin/thirteenf/headless.ts +55 -11
- package/src/plugins/builtin/thirteenf/model.ts +25 -9
- package/src/plugins/builtin/thirteenf/report-notes.ts +27 -6
- package/src/plugins/builtin/thirteenf/types.ts +2 -0
- package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +1 -1
- package/src/plugins/builtin/ticker-detail/data-panes/historical-prices.tsx +8 -7
- package/src/plugins/builtin/ticker-detail/data-panes/history-bars.ts +8 -5
- package/src/plugins/builtin/ticker-detail/financials/model.ts +18 -2
- package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +3 -3
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +6 -6
- package/src/plugins/builtin/ticker-detail/headless.ts +24 -17
- package/src/plugins/builtin/ticker-detail/index.tsx +4 -0
- package/src/plugins/builtin/ticker-detail/overview/model.ts +6 -4
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +6 -4
- package/src/plugins/builtin/time-sales/client.ts +9 -11
- package/src/plugins/builtin/time-sales/index.tsx +1 -1
- package/src/plugins/builtin/treasury-auctions/after.ts +267 -0
- package/src/plugins/builtin/treasury-auctions/cache.ts +54 -5
- package/src/plugins/builtin/treasury-auctions/client.ts +33 -2
- package/src/plugins/builtin/treasury-auctions/headless.ts +150 -22
- package/src/plugins/builtin/treasury-auctions/hk-headless.ts +126 -0
- package/src/plugins/builtin/treasury-auctions/hk-view.tsx +347 -0
- package/src/plugins/builtin/treasury-auctions/hk.ts +363 -0
- package/src/plugins/builtin/treasury-auctions/index.tsx +27 -4
- package/src/plugins/builtin/treasury-auctions/model.ts +264 -28
- package/src/plugins/builtin/treasury-auctions/pane.tsx +176 -41
- package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +5 -2
- package/src/plugins/builtin/treasury-auctions/types.ts +7 -1
- package/src/plugins/builtin/vol-surface/index.tsx +1 -1
- package/src/plugins/builtin/world-venue-map/index.ts +1 -0
- package/src/plugins/builtin/yield-curve/curves.ts +10 -4
- package/src/plugins/builtin/yield-curve/headless.ts +6 -2
- package/src/plugins/builtin/yield-curve/index.tsx +3 -3
- package/src/plugins/builtin/yield-curve/series.ts +10 -0
- package/src/plugins/builtin/yield-curve/world.ts +3 -1
- package/src/portfolio/collection-name.ts +22 -0
- package/src/portfolio/column-values.ts +2 -1
- package/src/public/__snapshots__/public-api.test.ts.snap +4 -0
- package/src/public/remote.ts +7 -1
- package/src/remote/client.ts +191 -11
- package/src/remote/controller-utils.ts +13 -1
- package/src/remote/controller.ts +88 -26
- package/src/remote/endpoint.ts +24 -0
- package/src/remote/form.ts +59 -4
- package/src/remote/resources.ts +44 -18
- package/src/remote/schema.ts +21 -9
- package/src/remote/secrets.ts +12 -0
- package/src/remote/semantic-tree.tsx +14 -2
- package/src/remote/server.ts +2 -1
- package/src/remote/surface.tsx +192 -0
- package/src/remote/types.ts +5 -0
- package/src/renderers/dom/data-table/frozen-column.ts +3 -1
- package/src/renderers/dom/data-table/index.tsx +27 -9
- package/src/renderers/dom/data-table/row.tsx +2 -0
- package/src/renderers/electrobun/bun/desktop/backend.ts +27 -24
- package/src/renderers/electrobun/bun/desktop/detached-windows.ts +3 -3
- package/src/renderers/electrobun/bun/desktop/snapshot-commit.ts +77 -0
- package/src/renderers/electrobun/shared/protocol.ts +4 -0
- package/src/renderers/electrobun/view/backend-rpc.ts +3 -0
- package/src/renderers/electrobun/view/desktop/window/bridge.ts +3 -0
- package/src/renderers/opentui/host.tsx +6 -0
- package/src/series/standalone.ts +2 -2
- package/src/shares/api.ts +21 -4
- package/src/shares/item.ts +73 -0
- package/src/shares/pane-item.ts +205 -0
- package/src/shares/pane.ts +4 -0
- package/src/shares/payload.ts +9 -5
- package/src/sources/gloomberb-cloud/news.ts +2 -0
- package/src/sources/gloomberb-cloud/normalizers.ts +9 -5
- package/src/sources/provider-router/cache.ts +3 -1
- package/src/sync/controller.ts +17 -2
- package/src/sync/other-window-tabs.ts +32 -1
- package/src/sync/react.ts +4 -4
- package/src/tickers/renamed-listings.ts +105 -0
- package/src/tickers/search/index.ts +103 -16
- package/src/time-series/bar-spacing.ts +33 -0
- package/src/time-series/base-series.ts +21 -3
- package/src/time-series/chart-bounds.ts +31 -0
- package/src/time-series/field-catalog.ts +17 -0
- package/src/time-series/fundamentals.ts +143 -11
- package/src/time-series/ice-credit.ts +32 -6
- package/src/time-series/resolve.ts +11 -7
- package/src/time-series/session-bar.ts +78 -9
- package/src/time-series/studies/formula.ts +53 -10
- package/src/time-series/studies/pair.ts +18 -7
- package/src/time-series/studies/units.ts +49 -2
- package/src/time-series/types.ts +12 -0
- package/src/types/desktop-window.ts +2 -0
- package/src/types/financials.ts +7 -0
- package/src/types/headless.ts +8 -0
- package/src/types/plugin-pane-settings.ts +2 -0
- package/src/types/plugin-panes.ts +22 -0
- package/src/utils/central-banks.ts +86 -1
- package/src/utils/cli-output.ts +6 -3
- package/src/utils/datetime-format.ts +12 -3
- package/src/utils/depositary-receipt.ts +28 -3
- package/src/utils/ebitda.ts +128 -0
- package/src/utils/format.ts +1 -1
- package/src/utils/fundamentals.ts +14 -0
- package/src/utils/max-drawdown.ts +97 -16
- package/src/utils/shell-word.ts +13 -0
- package/src/utils/untrusted-text.ts +29 -0
|
@@ -3,7 +3,10 @@ import { tf } from "../../i18n";
|
|
|
3
3
|
import { Box, Span, Text, TextAttributes } from "../../ui";
|
|
4
4
|
import { blendHex, colors } from "../../theme/colors";
|
|
5
5
|
import { useThemeColors } from "../../theme/theme-context";
|
|
6
|
-
import {
|
|
6
|
+
import { RADIUS } from "../../theme/ui-tokens";
|
|
7
|
+
import { displayWidth, truncateToDisplayWidth } from "../../utils/format";
|
|
8
|
+
import { wrapTextLines } from "../../utils/text-wrap";
|
|
9
|
+
import { plainUntrustedLine } from "../../utils/untrusted-text";
|
|
7
10
|
import { IconButton } from "./icon";
|
|
8
11
|
|
|
9
12
|
/**
|
|
@@ -19,14 +22,29 @@ export interface PaneLinkChipContent {
|
|
|
19
22
|
detail: string;
|
|
20
23
|
/** The lead square: the opened pane's letter, or what ties the chip to its text (a source's number, a key). */
|
|
21
24
|
icon: string;
|
|
25
|
+
/**
|
|
26
|
+
* `item` only: a line or two of what the item says, under its title. With
|
|
27
|
+
* no title it is one line: a pane's own description over its row.
|
|
28
|
+
*/
|
|
29
|
+
excerpt?: string;
|
|
30
|
+
/**
|
|
31
|
+
* `item` only: what it opens is still being read. The card keeps the room
|
|
32
|
+
* most cards take (two lines over their pane's row) with its `title` (the
|
|
33
|
+
* link) on the first, so it does not jump when the share arrives.
|
|
34
|
+
*/
|
|
35
|
+
pending?: boolean;
|
|
22
36
|
}
|
|
23
37
|
|
|
24
38
|
/**
|
|
25
39
|
* - `card`: a shared pane, two lines beside its square (or the picture its sender posted).
|
|
40
|
+
* - `item`: a shared pane and what it was on: the item's title, a line or two
|
|
41
|
+
* of it, and under them the pane it opens as the `line` chip draws it (or
|
|
42
|
+
* beside them, the picture its sender posted). As tall as what it says, with
|
|
43
|
+
* the same gap over the pane on every card.
|
|
26
44
|
* - `line`: one line, as a Wire post's story or calendar.
|
|
27
45
|
* - `inline`: the height of the line of text it is written in, as a function in a message.
|
|
28
46
|
*/
|
|
29
|
-
type PaneLinkChipVariant = "card" | "line" | "inline";
|
|
47
|
+
type PaneLinkChipVariant = "card" | "item" | "line" | "inline";
|
|
30
48
|
|
|
31
49
|
interface DomEventLike {
|
|
32
50
|
preventDefault(): void;
|
|
@@ -34,15 +52,26 @@ interface DomEventLike {
|
|
|
34
52
|
}
|
|
35
53
|
|
|
36
54
|
/**
|
|
37
|
-
* Each kind of chip keeps one height, known before anything
|
|
38
|
-
* of them never moves as they fill in.
|
|
55
|
+
* Each kind of chip but an item card keeps one height, known before anything
|
|
56
|
+
* loads, so a list of them never moves as they fill in.
|
|
39
57
|
*/
|
|
40
58
|
const PICTURE_CHIP_HEIGHT = 74;
|
|
41
59
|
const CARD_CHIP_HEIGHT = 48;
|
|
42
60
|
const LINE_CHIP_HEIGHT = 28;
|
|
61
|
+
/** At most three lines for an item's title and the excerpt under it. */
|
|
62
|
+
const ITEM_TEXT_LINES = 3;
|
|
63
|
+
/** The lines a card waiting for its share keeps: a title and a line of it, as most cards say. */
|
|
64
|
+
const PENDING_TEXT_LINES = 2;
|
|
65
|
+
const ITEM_TEXT_LINE = 17;
|
|
43
66
|
const THUMB = { width: 112, height: 64 };
|
|
67
|
+
/** As tall as an item card's content, at the shape of the picture a share posts. */
|
|
68
|
+
const ITEM_THUMB = { width: 142, height: 80 };
|
|
44
69
|
const ICON_SIZE = 38;
|
|
70
|
+
const LINE_ICON_SIZE = 18;
|
|
45
71
|
const CHIP_MAX_WIDTH = 420;
|
|
72
|
+
const LINE_PADDING = "0 10px 0 5px";
|
|
73
|
+
/** An item card's air: a picture sits as close to the frame as a card's square does. */
|
|
74
|
+
const ITEM_PADDING = "var(--gloom-space-xs) var(--gloom-space-sm)";
|
|
46
75
|
|
|
47
76
|
/** The lead square's colour, which an inline marker shares so the two read as one family. */
|
|
48
77
|
function leadSurface(panel: string, text: string, hovered = false): string {
|
|
@@ -91,10 +120,11 @@ export function DesktopPaneLinkChip({
|
|
|
91
120
|
const pressableChip = !!onOpen;
|
|
92
121
|
const lit = hovered && pressableChip;
|
|
93
122
|
const compact = variant === "line";
|
|
123
|
+
const item = variant === "item";
|
|
94
124
|
const height = compact ? LINE_CHIP_HEIGHT : picture ? PICTURE_CHIP_HEIGHT : CARD_CHIP_HEIGHT;
|
|
95
125
|
const border = lit ? themeColors.borderFocused : blendHex(themeColors.border, themeColors.bg, 0.35);
|
|
96
126
|
const surface = blendHex(themeColors.panel, themeColors.bg, lit ? 0.2 : 0.5);
|
|
97
|
-
const label = [content.title, content.detail].filter(Boolean).join(", ");
|
|
127
|
+
const label = [content.title, content.excerpt, content.detail].filter(Boolean).join(", ");
|
|
98
128
|
const pressable = pressableChip
|
|
99
129
|
? {
|
|
100
130
|
"aria-label": label || undefined,
|
|
@@ -141,14 +171,31 @@ export function DesktopPaneLinkChip({
|
|
|
141
171
|
}, content.title);
|
|
142
172
|
}
|
|
143
173
|
const showPicture = !!picture && failedUrl !== picture.url;
|
|
144
|
-
const
|
|
174
|
+
const thumb = item ? ITEM_THUMB : THUMB;
|
|
175
|
+
const square = (size: number, small: boolean, key: string) => createElement("span", {
|
|
176
|
+
key,
|
|
177
|
+
"aria-hidden": true,
|
|
178
|
+
style: {
|
|
179
|
+
width: size,
|
|
180
|
+
height: size,
|
|
181
|
+
flex: "none",
|
|
182
|
+
display: "flex",
|
|
183
|
+
alignItems: "center",
|
|
184
|
+
justifyContent: "center",
|
|
185
|
+
borderRadius: RADIUS.sm,
|
|
186
|
+
fontWeight: 600,
|
|
187
|
+
fontSize: small ? "0.86em" : "1em",
|
|
188
|
+
color: themeColors.textBright,
|
|
189
|
+
background: leadSurface(themeColors.panel, themeColors.text, item && lit),
|
|
190
|
+
},
|
|
191
|
+
}, content.icon);
|
|
145
192
|
const lead = showPicture
|
|
146
193
|
? createElement("img", {
|
|
147
194
|
key: "picture",
|
|
148
195
|
src: picture!.url,
|
|
149
196
|
alt: "",
|
|
150
|
-
width:
|
|
151
|
-
height:
|
|
197
|
+
width: thumb.width,
|
|
198
|
+
height: thumb.height,
|
|
152
199
|
loading: "lazy",
|
|
153
200
|
decoding: "async",
|
|
154
201
|
draggable: false,
|
|
@@ -157,8 +204,8 @@ export function DesktopPaneLinkChip({
|
|
|
157
204
|
onPictureError?.();
|
|
158
205
|
},
|
|
159
206
|
style: {
|
|
160
|
-
width:
|
|
161
|
-
height:
|
|
207
|
+
width: thumb.width,
|
|
208
|
+
height: thumb.height,
|
|
162
209
|
flex: "none",
|
|
163
210
|
objectFit: "cover",
|
|
164
211
|
objectPosition: "top left",
|
|
@@ -167,25 +214,10 @@ export function DesktopPaneLinkChip({
|
|
|
167
214
|
background: blendHex(themeColors.panel, themeColors.bg, 0.5),
|
|
168
215
|
},
|
|
169
216
|
})
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
width: leadSize,
|
|
175
|
-
height: leadSize,
|
|
176
|
-
flex: "none",
|
|
177
|
-
display: "flex",
|
|
178
|
-
alignItems: "center",
|
|
179
|
-
justifyContent: "center",
|
|
180
|
-
borderRadius: 3,
|
|
181
|
-
fontWeight: 600,
|
|
182
|
-
fontSize: compact ? "0.86em" : "1em",
|
|
183
|
-
color: themeColors.textBright,
|
|
184
|
-
background: leadSurface(themeColors.panel, themeColors.text),
|
|
185
|
-
},
|
|
186
|
-
}, content.icon);
|
|
187
|
-
const line = (text: string, tone: "title" | "detail") => createElement("span", {
|
|
188
|
-
key: tone,
|
|
217
|
+
// An item's square is in its line chip, under the text.
|
|
218
|
+
: item ? null : square(compact ? LINE_ICON_SIZE : ICON_SIZE, compact, "icon");
|
|
219
|
+
const line = (text: string, tone: "title" | "detail", key: string = tone) => createElement("span", {
|
|
220
|
+
key,
|
|
189
221
|
style: {
|
|
190
222
|
display: "block",
|
|
191
223
|
minWidth: 0,
|
|
@@ -197,37 +229,74 @@ export function DesktopPaneLinkChip({
|
|
|
197
229
|
fontSize: tone === "title" ? undefined : "0.92em",
|
|
198
230
|
},
|
|
199
231
|
}, text);
|
|
232
|
+
// The line chip's frame: a Wire post's story, and the pane an item card opens.
|
|
233
|
+
const lineFrame = {
|
|
234
|
+
boxSizing: "border-box",
|
|
235
|
+
display: "flex",
|
|
236
|
+
flexDirection: "row",
|
|
237
|
+
alignItems: "center",
|
|
238
|
+
gap: 6,
|
|
239
|
+
height: LINE_CHIP_HEIGHT,
|
|
240
|
+
padding: LINE_PADDING,
|
|
241
|
+
border: `1px solid ${border}`,
|
|
242
|
+
borderRadius: RADIUS.md,
|
|
243
|
+
background: surface,
|
|
244
|
+
overflow: "hidden",
|
|
245
|
+
};
|
|
200
246
|
const text = compact
|
|
201
247
|
? createElement("span", {
|
|
202
248
|
key: "text",
|
|
203
249
|
style: { display: "flex", flexDirection: "row", gap: 6, minWidth: 0, alignItems: "baseline" },
|
|
204
250
|
}, line(content.title, "title"), content.detail ? line(content.detail, "detail") : null)
|
|
205
|
-
:
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
251
|
+
: item
|
|
252
|
+
? createElement("span", {
|
|
253
|
+
key: "text",
|
|
254
|
+
"data-gloom-chip-part": "text",
|
|
255
|
+
style: { display: "flex", flexDirection: "column", minWidth: 0, flex: "1 1 auto", gap: "var(--gloom-space-xs)" },
|
|
256
|
+
},
|
|
257
|
+
itemWords(content, themeColors),
|
|
258
|
+
content.detail || content.pending
|
|
259
|
+
? createElement("span", {
|
|
260
|
+
key: "pane",
|
|
261
|
+
"data-gloom-chip-part": "pane",
|
|
262
|
+
"aria-hidden": content.pending ? true : undefined,
|
|
263
|
+
style: { ...lineFrame, alignSelf: "flex-start", maxWidth: "100%" },
|
|
264
|
+
}, square(LINE_ICON_SIZE, true, "pane-icon"), content.detail ? line(content.detail, "title", "pane-name") : null)
|
|
265
|
+
: null)
|
|
266
|
+
: createElement("span", {
|
|
267
|
+
key: "text",
|
|
268
|
+
style: { display: "flex", flexDirection: "column", justifyContent: "center", minWidth: 0, flex: "1 1 auto", gap: 1 },
|
|
269
|
+
}, line(content.title, "title"), line(content.detail, "detail"));
|
|
209
270
|
const frame = {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
271
|
+
...(compact ? {
|
|
272
|
+
...lineFrame,
|
|
273
|
+
width: "auto",
|
|
274
|
+
maxWidth: fit ? `min(100%, ${CHIP_MAX_WIDTH}px)` : "100%",
|
|
275
|
+
} : {
|
|
276
|
+
boxSizing: "border-box",
|
|
277
|
+
display: "flex",
|
|
278
|
+
flexDirection: "row",
|
|
279
|
+
alignItems: item ? "flex-start" : "center",
|
|
280
|
+
gap: 8,
|
|
281
|
+
// An item card is as tall as what it says.
|
|
282
|
+
height: item ? "auto" : height,
|
|
283
|
+
width: fit ? "auto" : `min(100%, ${CHIP_MAX_WIDTH}px)`,
|
|
284
|
+
maxWidth: fit ? `min(100%, ${CHIP_MAX_WIDTH}px)` : "100%",
|
|
285
|
+
padding: item ? ITEM_PADDING : "4px 10px 4px 4px",
|
|
286
|
+
border: `1px solid ${border}`,
|
|
287
|
+
borderRadius: 6,
|
|
288
|
+
background: surface,
|
|
289
|
+
overflow: "hidden",
|
|
290
|
+
}),
|
|
218
291
|
flex: "none",
|
|
219
292
|
margin: "2px 0",
|
|
220
|
-
padding: compact ? "0 10px 0 5px" : "4px 10px 4px 4px",
|
|
221
|
-
border: `1px solid ${border}`,
|
|
222
|
-
borderRadius: 6,
|
|
223
|
-
background: surface,
|
|
224
293
|
opacity: dimmed ? 0.6 : 1,
|
|
225
|
-
overflow: "hidden",
|
|
226
294
|
};
|
|
227
295
|
if (!onRemove) {
|
|
228
296
|
return createElement(element, { ...elementProps, ...dataAttributes, ...pressable, style: { ...frame, ...buttonReset } }, lead, text);
|
|
229
297
|
}
|
|
230
|
-
// The same chip with its x inside the frame, where a waiting image keeps its own
|
|
298
|
+
// The same chip with its x inside the frame, where a waiting image keeps its own
|
|
299
|
+
// (an item card's at its top corner, beside the title).
|
|
231
300
|
return createElement("div", { ...dataAttributes, style: { ...frame, paddingRight: 4 } },
|
|
232
301
|
createElement(element, {
|
|
233
302
|
key: "open",
|
|
@@ -237,17 +306,61 @@ export function DesktopPaneLinkChip({
|
|
|
237
306
|
...buttonReset,
|
|
238
307
|
display: "flex",
|
|
239
308
|
flexDirection: "row",
|
|
240
|
-
alignItems: "center",
|
|
309
|
+
alignItems: item ? "flex-start" : "center",
|
|
241
310
|
gap: frame.gap,
|
|
242
311
|
flex: "1 1 auto",
|
|
243
312
|
minWidth: 0,
|
|
244
|
-
height: "100%",
|
|
313
|
+
height: item ? "auto" : "100%",
|
|
245
314
|
padding: 0,
|
|
246
315
|
border: "none",
|
|
247
316
|
background: "transparent",
|
|
248
317
|
},
|
|
249
318
|
}, lead, text),
|
|
250
|
-
<IconButton key="remove" icon="close" label={tf("Remove {name}", { name: content.title })} onPress={onRemove} />);
|
|
319
|
+
<IconButton key="remove" icon="close" label={tf("Remove {name}", { name: content.title || content.detail })} onPress={onRemove} />);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* An item card's words: the title, wrapping, then the excerpt in the lines it
|
|
324
|
+
* leaves. A card with no title is its pane's description, one line; one that
|
|
325
|
+
* opens no pane (a share that is gone) is its one line of link, and one
|
|
326
|
+
* waiting for its share keeps two lines, its link muted on the first.
|
|
327
|
+
*/
|
|
328
|
+
function itemWords(content: PaneLinkChipContent, themeColors: { textBright: string; text: string; textMuted: string }) {
|
|
329
|
+
if (content.pending) {
|
|
330
|
+
return createElement("span", {
|
|
331
|
+
key: "words",
|
|
332
|
+
"data-gloom-chip-part": "words",
|
|
333
|
+
style: {
|
|
334
|
+
display: "block",
|
|
335
|
+
minWidth: 0,
|
|
336
|
+
height: ITEM_TEXT_LINE * PENDING_TEXT_LINES,
|
|
337
|
+
lineHeight: `${ITEM_TEXT_LINE}px`,
|
|
338
|
+
overflow: "hidden",
|
|
339
|
+
textOverflow: "ellipsis",
|
|
340
|
+
whiteSpace: "nowrap",
|
|
341
|
+
color: themeColors.textMuted,
|
|
342
|
+
},
|
|
343
|
+
}, content.title);
|
|
344
|
+
}
|
|
345
|
+
if (!content.title && !content.excerpt) return null;
|
|
346
|
+
const lines = content.title && content.detail ? ITEM_TEXT_LINES : 1;
|
|
347
|
+
return createElement("span", {
|
|
348
|
+
key: "words",
|
|
349
|
+
"data-gloom-chip-part": "words",
|
|
350
|
+
style: {
|
|
351
|
+
display: "-webkit-box",
|
|
352
|
+
WebkitBoxOrient: "vertical",
|
|
353
|
+
WebkitLineClamp: lines,
|
|
354
|
+
overflow: "hidden",
|
|
355
|
+
minWidth: 0,
|
|
356
|
+
lineHeight: `${ITEM_TEXT_LINE}px`,
|
|
357
|
+
maxHeight: ITEM_TEXT_LINE * lines,
|
|
358
|
+
overflowWrap: "anywhere",
|
|
359
|
+
},
|
|
360
|
+
},
|
|
361
|
+
content.title ? createElement("span", { key: "title", style: { color: themeColors.textBright, fontWeight: "var(--gloom-weight-bold)" } }, content.title) : null,
|
|
362
|
+
content.title && content.excerpt ? createElement("br", { key: "break" }) : null,
|
|
363
|
+
content.excerpt ? createElement("span", { key: "excerpt", style: { color: themeColors.text } }, content.excerpt) : null);
|
|
251
364
|
}
|
|
252
365
|
|
|
253
366
|
/** One row in the terminal: the lead square, then the title and the pane, cut to the line. */
|
|
@@ -265,10 +378,10 @@ export function TerminalPaneLinkChip({
|
|
|
265
378
|
/** Unset: the chip says what it is, in muted text, and opens nothing. */
|
|
266
379
|
onOpen?: () => void;
|
|
267
380
|
}) {
|
|
268
|
-
const icon = content.icon ? ` ${content.icon} ` : " ";
|
|
269
|
-
const text =
|
|
270
|
-
[content.title, content.detail].filter(Boolean).join(" · ")
|
|
271
|
-
Math.max(width - icon
|
|
381
|
+
const icon = content.icon ? ` ${plainUntrustedLine(content.icon)} ` : " ";
|
|
382
|
+
const text = truncateToDisplayWidth(
|
|
383
|
+
plainUntrustedLine([content.title, content.detail].filter(Boolean).join(" · ")),
|
|
384
|
+
Math.max(width - displayWidth(icon) - 1, 1),
|
|
272
385
|
);
|
|
273
386
|
const fg = selected ? selectedTextColor : onOpen ? colors.text : colors.textMuted;
|
|
274
387
|
return (
|
|
@@ -288,6 +401,108 @@ export function TerminalPaneLinkChip({
|
|
|
288
401
|
);
|
|
289
402
|
}
|
|
290
403
|
|
|
404
|
+
/** The most rows an item card's words take in the terminal, over its pane's row. */
|
|
405
|
+
const TERMINAL_ITEM_TEXT_ROWS = 2;
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* `text` wrapped to `width` terminal cells, in at most `rows` rows, the last
|
|
409
|
+
* cut with an ellipsis when it does not fit. Cells, not characters: a CJK
|
|
410
|
+
* character or an emoji takes two.
|
|
411
|
+
*/
|
|
412
|
+
function clampedRows(text: string, width: number, rows: number): string[] {
|
|
413
|
+
if (rows <= 0 || !text) return [];
|
|
414
|
+
const lines = wrapTextLines(text, width);
|
|
415
|
+
if (lines.length <= rows) return lines;
|
|
416
|
+
return [...lines.slice(0, rows - 1), truncateToDisplayWidth(lines.slice(rows - 1).join(" "), width)];
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* How an item card lays out in the terminal: as wide as its longest line, up
|
|
421
|
+
* to `width` cells, its title wrapping and its excerpt in the rows the title
|
|
422
|
+
* leaves, as on the desktop. With no title, the excerpt (a pane's own
|
|
423
|
+
* description) is one row; a card that opens no pane is its one row of link,
|
|
424
|
+
* and one waiting for its share keeps the rows most cards take, its link on
|
|
425
|
+
* the first. Every word is made plain again here: it came from another
|
|
426
|
+
* person's app, and a terminal would run an escape in it.
|
|
427
|
+
*/
|
|
428
|
+
function terminalItemCardLayout(content: PaneLinkChipContent, width: number) {
|
|
429
|
+
const title = plainUntrustedLine(content.title);
|
|
430
|
+
const excerpt = plainUntrustedLine(content.excerpt ?? "");
|
|
431
|
+
const pane = content.detail || content.pending
|
|
432
|
+
? { title: plainUntrustedLine(content.detail), detail: "", icon: plainUntrustedLine(content.icon) }
|
|
433
|
+
: null;
|
|
434
|
+
const paneWidth = pane ? (pane.icon ? displayWidth(pane.icon) + 2 : 1) + displayWidth(pane.title) + 1 : 0;
|
|
435
|
+
const cardWidth = Math.max(1, Math.min(width, Math.max(displayWidth(title), displayWidth(excerpt), paneWidth - 2) + 2));
|
|
436
|
+
const textWidth = Math.max(cardWidth - 2, 1);
|
|
437
|
+
if (content.pending) {
|
|
438
|
+
const titleRows = clampedRows(title, textWidth, 1);
|
|
439
|
+
return { cardWidth, pane, titleRows, excerptRows: Array.from({ length: TERMINAL_ITEM_TEXT_ROWS - titleRows.length }, () => "") };
|
|
440
|
+
}
|
|
441
|
+
const textRows = title && pane ? TERMINAL_ITEM_TEXT_ROWS : 1;
|
|
442
|
+
const titleRows = clampedRows(title, textWidth, textRows);
|
|
443
|
+
const excerptRows = clampedRows(excerpt, textWidth, title ? textRows - titleRows.length : 1);
|
|
444
|
+
return { cardWidth, pane, titleRows, excerptRows };
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/** The rows an item card takes in the terminal: its words, then its pane's row. */
|
|
448
|
+
export function terminalItemCardRows(content: PaneLinkChipContent, width: number): number {
|
|
449
|
+
const { pane, titleRows, excerptRows } = terminalItemCardLayout(content, width);
|
|
450
|
+
return Math.max(1, titleRows.length + excerptRows.length + (pane ? 1 : 0));
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* The `item` card in the terminal: the chip's fill as a block, with the item's
|
|
455
|
+
* title and what it says, and under them its pane as the one-row chip draws
|
|
456
|
+
* it. As tall as what it says (terminalItemCardRows).
|
|
457
|
+
*/
|
|
458
|
+
export function TerminalPaneLinkItemCard({
|
|
459
|
+
content,
|
|
460
|
+
width,
|
|
461
|
+
selected = false,
|
|
462
|
+
selectedTextColor = colors.textBright,
|
|
463
|
+
onOpen,
|
|
464
|
+
}: {
|
|
465
|
+
content: PaneLinkChipContent;
|
|
466
|
+
width: number;
|
|
467
|
+
selected?: boolean;
|
|
468
|
+
selectedTextColor?: string;
|
|
469
|
+
/** Unset: the card says what it is, in muted text, and opens nothing. */
|
|
470
|
+
onOpen?: () => void;
|
|
471
|
+
}) {
|
|
472
|
+
const { cardWidth, pane, titleRows, excerptRows } = terminalItemCardLayout(content, width);
|
|
473
|
+
const fill = leadSurface(colors.panel, colors.text);
|
|
474
|
+
const titleColor = selected ? selectedTextColor : onOpen && !content.pending ? colors.textBright : colors.textMuted;
|
|
475
|
+
const excerptColor = selected ? selectedTextColor : colors.text;
|
|
476
|
+
const rows = [
|
|
477
|
+
...titleRows.map((text) => ({ text, color: titleColor, bold: !content.pending })),
|
|
478
|
+
...excerptRows.map((text) => ({ text, color: excerptColor, bold: false })),
|
|
479
|
+
];
|
|
480
|
+
return (
|
|
481
|
+
<Box
|
|
482
|
+
flexDirection="column"
|
|
483
|
+
width={cardWidth}
|
|
484
|
+
height={terminalItemCardRows(content, width)}
|
|
485
|
+
backgroundColor={fill}
|
|
486
|
+
onMouseDown={onOpen ? (event: { preventDefault?: () => void; stopPropagation?: () => void }) => {
|
|
487
|
+
event.preventDefault?.();
|
|
488
|
+
event.stopPropagation?.();
|
|
489
|
+
onOpen();
|
|
490
|
+
} : undefined}
|
|
491
|
+
>
|
|
492
|
+
{rows.map((row, index) => (
|
|
493
|
+
<Box key={index} height={1}>
|
|
494
|
+
<Text fg={row.color} attributes={row.bold ? TextAttributes.BOLD : 0}>{` ${row.text}`}</Text>
|
|
495
|
+
</Box>
|
|
496
|
+
))}
|
|
497
|
+
{pane ? (
|
|
498
|
+
<Box height={1} flexDirection="row">
|
|
499
|
+
<TerminalPaneLinkChip content={pane} width={cardWidth} selected={selected} selectedTextColor={selectedTextColor} onOpen={onOpen} />
|
|
500
|
+
</Box>
|
|
501
|
+
) : null}
|
|
502
|
+
</Box>
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
|
|
291
506
|
/**
|
|
292
507
|
* A chip's lead square written inside a line of text: a figure's source
|
|
293
508
|
* number in an Ask Gloom answer, which opens what the chip of the same number
|
|
@@ -18,7 +18,8 @@ import { useChartViewReset } from "../chart/core/view-reset";
|
|
|
18
18
|
export interface QueryBarSearch {
|
|
19
19
|
value: string;
|
|
20
20
|
onChange: (query: string) => void;
|
|
21
|
-
|
|
21
|
+
/** Longest first: a narrow field shows the first that fits (`["filter loaded stories", "filter stories"]`). */
|
|
22
|
+
placeholder: string | readonly string[];
|
|
22
23
|
/** The pane is focused. */
|
|
23
24
|
focused: boolean;
|
|
24
25
|
/** The field owns the keyboard. */
|
|
@@ -141,6 +141,43 @@ export function tableColumnStarts(columns: readonly TableWidthColumn[], columnGa
|
|
|
141
141
|
return starts;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
/** The narrowest first column that names its row: a short ticker. A rank (`#`) or a status dot is narrower. */
|
|
145
|
+
const ROW_LABEL_MIN_WIDTH = 4;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Whether a table pins its first column while it scrolls sideways. A table
|
|
149
|
+
* that sets `freezeFirstColumn` gets what it set; one that leaves it unset
|
|
150
|
+
* pins its first column while it is too wide for its viewport (`overflows`)
|
|
151
|
+
* and that column leaves the others at least half the viewport, so scrolled
|
|
152
|
+
* right each row still says what it is (a 70-column Relative Valuation read
|
|
153
|
+
* `4.50T 23.6 11.7` with no ticker). A first column the pane draws itself
|
|
154
|
+
* (a name beside its kind, a badge) pins as drawn. A table that fits is drawn
|
|
155
|
+
* as it always was. A first column too narrow to name its row (a rank, a
|
|
156
|
+
* status dot, a star) or wider than half would leave nothing worth pinning or
|
|
157
|
+
* too little to scroll through, so it scrolls.
|
|
158
|
+
*/
|
|
159
|
+
export function tableFreezesFirstColumn({
|
|
160
|
+
freezeFirstColumn,
|
|
161
|
+
columns,
|
|
162
|
+
columnGap = 1,
|
|
163
|
+
horizontalPadding = 1,
|
|
164
|
+
viewportWidth,
|
|
165
|
+
overflows,
|
|
166
|
+
}: {
|
|
167
|
+
freezeFirstColumn: boolean | undefined;
|
|
168
|
+
columns: readonly TableWidthColumn[];
|
|
169
|
+
columnGap?: number;
|
|
170
|
+
horizontalPadding?: number;
|
|
171
|
+
viewportWidth: number;
|
|
172
|
+
overflows: boolean;
|
|
173
|
+
}): boolean {
|
|
174
|
+
if (freezeFirstColumn !== undefined) return freezeFirstColumn;
|
|
175
|
+
const first = columns[0];
|
|
176
|
+
if (!overflows || !first || columns.length < 2 || viewportWidth <= 0) return false;
|
|
177
|
+
const width = tableColumnWidth(first);
|
|
178
|
+
return width >= ROW_LABEL_MIN_WIDTH && (horizontalPadding + width + columnGap) * 2 <= viewportWidth;
|
|
179
|
+
}
|
|
180
|
+
|
|
144
181
|
/**
|
|
145
182
|
* Where a frozen board can stop: 0, each column's edge (its start just past
|
|
146
183
|
* the frozen column) and its end, the first edge that shows the last column
|
|
@@ -159,7 +196,7 @@ function frozenBoardStops(columns: readonly TableWidthColumn[], columnGap: numbe
|
|
|
159
196
|
|
|
160
197
|
/**
|
|
161
198
|
* Where a sideways step of a table too wide for its pane lands (Shift or
|
|
162
|
-
* Ctrl+Left/Right, "more
|
|
199
|
+
* Ctrl+Left/Right, "more ⇧→"): half the viewport on. With a frozen first
|
|
163
200
|
* column it stops at a column's edge, so the column beside the frozen one
|
|
164
201
|
* shows whole: half a viewport cut a column under it, and a rate too wide
|
|
165
202
|
* for what showed went blank. A column wider than half the viewport is
|