gloomberb 0.20.4 → 0.20.5
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 +2 -0
- package/bin/gloom +9 -0
- package/bin/without-bun.cjs +98 -0
- package/package.json +3 -1
- package/src/api-client/data.ts +138 -35
- package/src/api-client/types/econ.ts +12 -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/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 +78 -21
- package/src/cli/commands/news-search.ts +59 -7
- package/src/cli/commands/overview.ts +16 -1
- package/src/cli/commands/remote.ts +16 -17
- package/src/cli/commands/system.ts +1 -1
- package/src/cli/fx-forward.ts +25 -7
- package/src/cli/glossary.ts +19 -5
- package/src/cli/history-rows.ts +5 -3
- package/src/cli/known-gaps.ts +27 -1
- package/src/cli/listing-arg.ts +11 -1
- package/src/cli/name-entries.ts +5 -1
- package/src/cli/not-a-ticker.ts +4 -0
- package/src/cli/pane-functions/function-help.ts +2 -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/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/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/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 +27 -10
- package/src/market-data/depositary-pair.ts +5 -3
- package/src/market-data/market/dated-previous-close.ts +94 -15
- package/src/market-data/market/status.ts +17 -1
- 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/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/chart-composer/headless.ts +2 -1
- package/src/plugins/builtin/chart-composer/index.tsx +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/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/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 +74 -1
- package/src/plugins/builtin/econ/fred-catalog.ts +3 -1
- package/src/plugins/builtin/econ/index.tsx +1 -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 +1 -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/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 +1 -1
- 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/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.ts +10 -4
- package/src/plugins/builtin/research/index.tsx +4 -0
- 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/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/financials/model.ts +12 -0
- package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +3 -3
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +5 -5
- package/src/plugins/builtin/ticker-detail/headless.ts +18 -13
- 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 +18 -3
- package/src/plugins/builtin/treasury-auctions/client.ts +33 -2
- package/src/plugins/builtin/treasury-auctions/headless.ts +109 -19
- package/src/plugins/builtin/treasury-auctions/index.tsx +14 -4
- package/src/plugins/builtin/treasury-auctions/model.ts +256 -28
- package/src/plugins/builtin/treasury-auctions/pane.tsx +139 -28
- 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/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/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/tickers/renamed-listings.ts +105 -0
- package/src/tickers/search/index.ts +103 -16
- package/src/time-series/resolve.ts +2 -2
- package/src/types/financials.ts +1 -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/datetime-format.ts +12 -3
- package/src/utils/depositary-receipt.ts +28 -3
- package/src/utils/fundamentals.ts +14 -0
- package/src/utils/max-drawdown.ts +97 -16
- 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. */
|
|
@@ -69,6 +69,12 @@ export interface TabsProps {
|
|
|
69
69
|
paneMenu?: boolean;
|
|
70
70
|
scrollable?: boolean;
|
|
71
71
|
scrollId?: string;
|
|
72
|
+
/**
|
|
73
|
+
* The surface the strip sits on (the status bar's panel, a pane's title
|
|
74
|
+
* bar): the cells the strip draws over its tabs, the edge markers, are
|
|
75
|
+
* painted with it. The app's background by default.
|
|
76
|
+
*/
|
|
77
|
+
background?: string;
|
|
72
78
|
}
|
|
73
79
|
|
|
74
80
|
const WHEEL_DELTA_PER_CELL = 8;
|
|
@@ -93,6 +99,7 @@ function TabsView({
|
|
|
93
99
|
paneMenu = true,
|
|
94
100
|
scrollable = true,
|
|
95
101
|
scrollId,
|
|
102
|
+
background,
|
|
96
103
|
}: TabsProps) {
|
|
97
104
|
// While a chart the user moved into holds the keys, the strip draws as
|
|
98
105
|
// unfocused, so it shows where the arrows went.
|
|
@@ -124,6 +131,7 @@ function TabsView({
|
|
|
124
131
|
activePillFg: colors.selectedText,
|
|
125
132
|
closeFg: colors.textMuted,
|
|
126
133
|
addFg: colors.textMuted,
|
|
134
|
+
bg: background ?? colors.bg,
|
|
127
135
|
};
|
|
128
136
|
const handleSelect = useCallback((value: string) => {
|
|
129
137
|
navigationValueRef.current = value;
|
|
@@ -333,6 +341,7 @@ function OpenTuiTabs({
|
|
|
333
341
|
activePillFg: string;
|
|
334
342
|
closeFg: string;
|
|
335
343
|
addFg: string;
|
|
344
|
+
bg: string;
|
|
336
345
|
};
|
|
337
346
|
}) {
|
|
338
347
|
const [hoveredValue, setHoveredValue] = useState<string | null>(null);
|
|
@@ -409,12 +418,29 @@ function OpenTuiTabs({
|
|
|
409
418
|
// the viewport several times a second. Only a change of the active tab or of
|
|
410
419
|
// the strip geometry is allowed to move it.
|
|
411
420
|
const revealKey = `${activeValue ?? ""}|${tabs.map((tab, index) => `${tab.value}:${tabWidths[index]}`).join(",")}`;
|
|
412
|
-
const revealRef = useRef({ tabWidths, totalWidth, activeIndex: -1 });
|
|
421
|
+
const revealRef = useRef({ tabWidths, totalWidth, activeIndex: -1, dense });
|
|
413
422
|
revealRef.current = {
|
|
414
423
|
tabWidths,
|
|
415
424
|
totalWidth,
|
|
416
425
|
activeIndex: tabs.findIndex((tab) => tab.value === activeValue),
|
|
426
|
+
dense,
|
|
417
427
|
};
|
|
428
|
+
// Which edges of an overflowing strip hide tabs: each shows a marker, so a cut strip says there is more.
|
|
429
|
+
const [edges, setEdges] = useState<{ left: boolean; right: boolean }>({ left: false, right: false });
|
|
430
|
+
// What the markers show, read before setting them: an unchanged strip schedules no render.
|
|
431
|
+
const edgesRef = useRef(edges);
|
|
432
|
+
const updateEdges = useCallback(() => {
|
|
433
|
+
const scrollBox = scrollRef.current;
|
|
434
|
+
const viewportWidth = scrollBox?.viewport?.width || scrollBox?.width || 0;
|
|
435
|
+
const { totalWidth: stripWidth } = revealRef.current;
|
|
436
|
+
const left = scrollBox?.scrollLeft ?? 0;
|
|
437
|
+
const next = viewportWidth > 0
|
|
438
|
+
? { left: left > 0, right: left + viewportWidth < stripWidth }
|
|
439
|
+
: { left: false, right: false };
|
|
440
|
+
if (edgesRef.current.left === next.left && edgesRef.current.right === next.right) return;
|
|
441
|
+
edgesRef.current = next;
|
|
442
|
+
setEdges(next);
|
|
443
|
+
}, []);
|
|
418
444
|
// Blank cells after the last tab, so the strip can start at a tab's edge
|
|
419
445
|
// when it reveals the last ones (see revealActiveTab).
|
|
420
446
|
const [revealPad, setRevealPad] = useState(0);
|
|
@@ -423,7 +449,7 @@ function OpenTuiTabs({
|
|
|
423
449
|
const revealedRef = useRef<{ geometry: string; pendingLeft: number | null }>({ geometry: "", pendingLeft: null });
|
|
424
450
|
const revealActiveTab = useCallback(() => {
|
|
425
451
|
const scrollBox = scrollRef.current;
|
|
426
|
-
const { tabWidths: widths, totalWidth: stripWidth, activeIndex } = revealRef.current;
|
|
452
|
+
const { tabWidths: widths, totalWidth: stripWidth, activeIndex, dense: denseStrip } = revealRef.current;
|
|
427
453
|
const viewportWidth = scrollBox?.viewport?.width || scrollBox?.width || 0;
|
|
428
454
|
if (!scrollBox || activeIndex < 0 || viewportWidth <= 0) return;
|
|
429
455
|
const geometry = `${activeIndex}|${viewportWidth}|${stripWidth}|${widths.join(",")}`;
|
|
@@ -441,8 +467,11 @@ function OpenTuiTabs({
|
|
|
441
467
|
}
|
|
442
468
|
revealedRef.current = { geometry, pendingLeft: null };
|
|
443
469
|
|
|
444
|
-
|
|
445
|
-
|
|
470
|
+
// A dense tab has no blank cell before its label: a strip scrolled to it starts on the blank after the tab before,
|
|
471
|
+
// which the edge marker covers, never on the label's first letter.
|
|
472
|
+
const edge = (start: number) => (denseStrip && start > 0 ? start - 1 : start);
|
|
473
|
+
const activeLeft = edge(widths.slice(0, activeIndex).reduce((sum, width) => sum + width, 0));
|
|
474
|
+
const activeRight = widths.slice(0, activeIndex + 1).reduce((sum, width) => sum + width, 0);
|
|
446
475
|
const currentLeft = scrollBox.scrollLeft ?? 0;
|
|
447
476
|
const currentRight = currentLeft + viewportWidth;
|
|
448
477
|
const scrollToLeft = (left: number) => {
|
|
@@ -455,7 +484,7 @@ function OpenTuiTabs({
|
|
|
455
484
|
setRevealPad(pad);
|
|
456
485
|
};
|
|
457
486
|
// Where each tab starts: a strip scrolled to between two of them shows the end of a label.
|
|
458
|
-
const starts = widths.map((_, index) => widths.slice(0, index).reduce((sum, width) => sum + width, 0));
|
|
487
|
+
const starts = widths.map((_, index) => edge(widths.slice(0, index).reduce((sum, width) => sum + width, 0)));
|
|
459
488
|
const cutAtStart = currentLeft > 0 && !starts.includes(currentLeft);
|
|
460
489
|
|
|
461
490
|
if (stripWidth <= viewportWidth) {
|
|
@@ -475,11 +504,34 @@ function OpenTuiTabs({
|
|
|
475
504
|
if ((scrollBox.scrollLeft ?? 0) !== left) revealedRef.current.pendingLeft = left;
|
|
476
505
|
}
|
|
477
506
|
}, []);
|
|
478
|
-
|
|
507
|
+
const revealAndMark = useCallback(() => {
|
|
508
|
+
revealActiveTab();
|
|
509
|
+
updateEdges();
|
|
510
|
+
}, [revealActiveTab, updateEdges]);
|
|
511
|
+
useEffect(revealAndMark, [revealAndMark, revealKey]);
|
|
479
512
|
// React effects can run before a floating pane's native viewport has its
|
|
480
513
|
// new width. Retry after computed layout, preserving ScrollBox's range update.
|
|
481
|
-
useEffect(() => observeScrollBoxViewportSize(scrollRef.current,
|
|
482
|
-
useEffect(() => observeScrollBoxContentSize(scrollRef.current,
|
|
514
|
+
useEffect(() => observeScrollBoxViewportSize(scrollRef.current, revealAndMark), [revealAndMark, scrollable]);
|
|
515
|
+
useEffect(() => observeScrollBoxContentSize(scrollRef.current, revealAndMark), [revealAndMark, scrollable]);
|
|
516
|
+
|
|
517
|
+
/** Scrolls the strip a viewport's width toward an edge marker that was clicked, starting at a tab's edge. */
|
|
518
|
+
const scrollToward = (direction: -1 | 1) => {
|
|
519
|
+
const scrollBox = scrollRef.current;
|
|
520
|
+
const viewportWidth = scrollBox?.viewport?.width || scrollBox?.width || 0;
|
|
521
|
+
if (!scrollBox || viewportWidth <= 0) return;
|
|
522
|
+
const starts = tabWidths.map((_, index) => tabWidths.slice(0, index).reduce((sum, width) => sum + width, 0))
|
|
523
|
+
.map((start) => (dense && start > 0 ? start - 1 : start));
|
|
524
|
+
const current = scrollBox.scrollLeft ?? 0;
|
|
525
|
+
const maxLeft = Math.max(0, totalWidth + revealPadRef.current - viewportWidth);
|
|
526
|
+
// Right: the first tab cut at the right edge starts the strip. Left: the strip ends where it started.
|
|
527
|
+
const target = direction > 0
|
|
528
|
+
? starts.find((start, index) => start + tabWidths[index]! > current + viewportWidth) ?? maxLeft
|
|
529
|
+
: starts.findLast((start) => start <= Math.max(0, current - viewportWidth)) ?? 0;
|
|
530
|
+
const left = Math.max(0, Math.min(maxLeft, target));
|
|
531
|
+
scrollBox.scrollLeft = left;
|
|
532
|
+
scrollBox.scrollTo({ x: left, y: scrollBox.scrollTop });
|
|
533
|
+
updateEdges();
|
|
534
|
+
};
|
|
483
535
|
|
|
484
536
|
const handleMouseScroll = (event?: {
|
|
485
537
|
preventDefault?: () => void;
|
|
@@ -506,6 +558,7 @@ function OpenTuiTabs({
|
|
|
506
558
|
);
|
|
507
559
|
scrollBox.scrollLeft = nextLeft;
|
|
508
560
|
scrollBox.scrollTo({ x: nextLeft, y: scrollBox.scrollTop });
|
|
561
|
+
updateEdges();
|
|
509
562
|
};
|
|
510
563
|
|
|
511
564
|
const tabRow = (
|
|
@@ -619,18 +672,43 @@ function OpenTuiTabs({
|
|
|
619
672
|
|
|
620
673
|
if (!scrollable) return tabRow;
|
|
621
674
|
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
675
|
+
// Drawn over the strip's end cells, so showing one never narrows the strip and moves what it reveals,
|
|
676
|
+
// on the surface the strip sits on (`background`), so it reads as the strip's edge and not a tab's cell.
|
|
677
|
+
const edgeMarker = (direction: -1 | 1) => (
|
|
678
|
+
<Box
|
|
679
|
+
position="absolute"
|
|
680
|
+
top={0}
|
|
681
|
+
{...direction < 0 ? { left: 0 } : { right: 0 }}
|
|
682
|
+
width={1}
|
|
627
683
|
height={1}
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
684
|
+
zIndex={1}
|
|
685
|
+
backgroundColor={palette.bg}
|
|
686
|
+
onMouseDown={(event: TabPointerEvent) => {
|
|
687
|
+
event.preventDefault();
|
|
688
|
+
event.stopPropagation?.();
|
|
689
|
+
scrollToward(direction);
|
|
690
|
+
}}
|
|
632
691
|
>
|
|
633
|
-
{
|
|
634
|
-
</
|
|
692
|
+
<Text fg={palette.addFg}>{direction < 0 ? "‹" : "›"}</Text>
|
|
693
|
+
</Box>
|
|
694
|
+
);
|
|
695
|
+
|
|
696
|
+
return (
|
|
697
|
+
<Box width="100%" height={1}>
|
|
698
|
+
<ScrollBox
|
|
699
|
+
id={scrollId}
|
|
700
|
+
ref={scrollRef}
|
|
701
|
+
width="100%"
|
|
702
|
+
height={1}
|
|
703
|
+
scrollX
|
|
704
|
+
focusable={false}
|
|
705
|
+
horizontalScrollbarOptions={{ visible: false }}
|
|
706
|
+
onMouseScroll={handleMouseScroll}
|
|
707
|
+
>
|
|
708
|
+
{tabRow}
|
|
709
|
+
</ScrollBox>
|
|
710
|
+
{edges.left ? edgeMarker(-1) : null}
|
|
711
|
+
{edges.right ? edgeMarker(1) : null}
|
|
712
|
+
</Box>
|
|
635
713
|
);
|
|
636
714
|
}
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
removeHistoryIndex,
|
|
10
10
|
resolveTickerForPane,
|
|
11
11
|
setHistoryForIndex,
|
|
12
|
+
settleOpeningPaneHistory,
|
|
12
13
|
syncConfigActiveLayoutState,
|
|
13
14
|
withFocusedPane,
|
|
14
15
|
} from "./layout";
|
|
@@ -43,6 +44,12 @@ export function reduceLayoutAction(state: AppState, action: AppAction): AppState
|
|
|
43
44
|
};
|
|
44
45
|
}
|
|
45
46
|
|
|
47
|
+
case "SETTLE_OPENING_PANE": {
|
|
48
|
+
const currentIndex = state.config.activeLayoutIndex;
|
|
49
|
+
const entry = settleOpeningPaneHistory(historyForIndex(state.layoutHistory, currentIndex), state.config.layout, action.settlement);
|
|
50
|
+
return { ...state, layoutHistory: setHistoryForIndex(state.layoutHistory, currentIndex, entry) };
|
|
51
|
+
}
|
|
52
|
+
|
|
46
53
|
case "UNDO_LAYOUT": {
|
|
47
54
|
const currentIndex = state.config.activeLayoutIndex;
|
|
48
55
|
const entry = historyForIndex(state.layoutHistory, currentIndex);
|