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.
Files changed (316) hide show
  1. package/README.md +3 -1
  2. package/README.zh-CN.md +1 -1
  3. package/bin/gloom +9 -0
  4. package/bin/without-bun.cjs +98 -0
  5. package/package.json +4 -1
  6. package/src/api-client/data.ts +148 -37
  7. package/src/api-client/hk-tenders.ts +59 -0
  8. package/src/api-client/index.ts +1 -0
  9. package/src/api-client/types/econ.ts +30 -0
  10. package/src/api-client/yield-curves.ts +1 -1
  11. package/src/app/global-shortcuts.ts +4 -1
  12. package/src/app/keybindings/actions.ts +6 -0
  13. package/src/app/keybindings/config.ts +2 -1
  14. package/src/app/keybindings/index.ts +1 -0
  15. package/src/app/keybindings/labels.ts +6 -1
  16. package/src/app/keybindings/resolve.ts +23 -4
  17. package/src/app/keybindings/terminal-keys.ts +35 -0
  18. package/src/app/pane-runtime/index.tsx +2 -2
  19. package/src/app/pane-runtime/ticker-open-runtime.ts +68 -40
  20. package/src/app.tsx +18 -13
  21. package/src/architecture/floating-promise-allowlist.json +313 -0
  22. package/src/architecture/ui-literals-allowlist.json +1 -1
  23. package/src/capabilities/chart-series.ts +27 -1
  24. package/src/cli/commands/keybindings.ts +5 -5
  25. package/src/cli/commands/market.ts +238 -57
  26. package/src/cli/commands/news-search.ts +81 -14
  27. package/src/cli/commands/overview.ts +27 -6
  28. package/src/cli/commands/remote.ts +16 -17
  29. package/src/cli/commands/system.ts +1 -1
  30. package/src/cli/commands/ticker.ts +3 -1
  31. package/src/cli/early-command.ts +2 -0
  32. package/src/cli/errors.ts +10 -1
  33. package/src/cli/fx-forward.ts +89 -7
  34. package/src/cli/fx-pair.ts +1 -1
  35. package/src/cli/fx-quote-rate.ts +23 -0
  36. package/src/cli/glossary.ts +19 -5
  37. package/src/cli/help.ts +1 -0
  38. package/src/cli/history-rows.ts +5 -3
  39. package/src/cli/index-roots.ts +5 -4
  40. package/src/cli/index.ts +40 -3
  41. package/src/cli/known-gaps.ts +38 -9
  42. package/src/cli/listing-arg.ts +17 -5
  43. package/src/cli/name-entries.ts +5 -1
  44. package/src/cli/not-a-ticker.ts +4 -0
  45. package/src/cli/options.ts +52 -3
  46. package/src/cli/output-file.ts +5 -3
  47. package/src/cli/pane-functions/catalog.ts +15 -0
  48. package/src/cli/pane-functions/function-help.ts +4 -4
  49. package/src/cli/pane-functions/headless.ts +9 -4
  50. package/src/cli/pane-functions/index.ts +6 -4
  51. package/src/cli/pane-functions/resolver.ts +2 -2
  52. package/src/cli/result.ts +21 -2
  53. package/src/cli/spreadsheet-hint.ts +7 -3
  54. package/src/cli/treasury-yields.ts +5 -3
  55. package/src/components/chart/composite/legend.tsx +40 -2
  56. package/src/components/command-bar/pane-settings.ts +2 -2
  57. package/src/components/command-bar/routes/root/results.ts +6 -2
  58. package/src/components/command-bar/workflow/tickers.ts +2 -2
  59. package/src/components/data-table/view.tsx +9 -2
  60. package/src/components/input-search-bar.tsx +9 -2
  61. package/src/components/layout/pane/header.tsx +2 -0
  62. package/src/components/layout/shell/pane/capture.ts +4 -1
  63. package/src/components/layout/status-bar.tsx +6 -1
  64. package/src/components/onboarding/first-run-workspace.ts +44 -2
  65. package/src/components/onboarding/onboarding-frame.tsx +11 -2
  66. package/src/components/onboarding/onboarding-keyboard.ts +16 -0
  67. package/src/components/onboarding/onboarding-wizard.tsx +8 -8
  68. package/src/components/onboarding/portfolio-step/positions-panel.tsx +62 -1
  69. package/src/components/onboarding/use-onboarding-progress.ts +12 -4
  70. package/src/components/pane-settings-dialog/desktop.tsx +2 -2
  71. package/src/components/pane-settings-dialog/tui.tsx +2 -2
  72. package/src/components/pane-settings-dialog/value.ts +6 -0
  73. package/src/components/pane-settings-dialog.tsx +3 -3
  74. package/src/components/reader/detail-reader.tsx +4 -0
  75. package/src/components/ui/data-table/opentui/index.tsx +11 -4
  76. package/src/components/ui/data-table/opentui/model.ts +8 -6
  77. package/src/components/ui/data-table/types.ts +6 -1
  78. package/src/components/ui/index.ts +1 -1
  79. package/src/components/ui/page-stack-view.tsx +3 -0
  80. package/src/components/ui/pane-link-chip.tsx +269 -54
  81. package/src/components/ui/query-bar.tsx +2 -1
  82. package/src/components/ui/table-layout.ts +38 -1
  83. package/src/components/ui/tabs.tsx +97 -19
  84. package/src/core/state/app/layout-reducer.ts +7 -0
  85. package/src/core/state/app/layout.ts +44 -7
  86. package/src/core/state/app/state.ts +1 -1
  87. package/src/core/state/app/types.ts +22 -2
  88. package/src/docs/snapshot.json +30 -13
  89. package/src/market-data/depositary-pair.ts +5 -3
  90. package/src/market-data/market/change-basis.ts +9 -5
  91. package/src/market-data/market/dated-previous-close.ts +147 -17
  92. package/src/market-data/market/status.ts +17 -1
  93. package/src/market-data/quotes/contributions.ts +2 -0
  94. package/src/market-data/quotes/listing-enterprise-value.ts +50 -0
  95. package/src/plugins/builtin/alerts/metric-data.ts +15 -2
  96. package/src/plugins/builtin/analytics/risk-client.ts +10 -4
  97. package/src/plugins/builtin/analytics/risk-episodes.ts +5 -4
  98. package/src/plugins/builtin/analytics/risk-headless.ts +4 -2
  99. package/src/plugins/builtin/analytics/risk-sectors.ts +91 -0
  100. package/src/plugins/builtin/awards/index.tsx +1 -1
  101. package/src/plugins/builtin/backtest/headless.ts +1 -1
  102. package/src/plugins/builtin/buildout/index.tsx +1 -0
  103. package/src/plugins/builtin/catalysts/index.tsx +2 -2
  104. package/src/plugins/builtin/cds/headless.ts +4 -0
  105. package/src/plugins/builtin/cds/model.ts +0 -6
  106. package/src/plugins/builtin/chart-composer/formula.ts +16 -3
  107. package/src/plugins/builtin/chart-composer/headless-schema.ts +2 -0
  108. package/src/plugins/builtin/chart-composer/headless.ts +4 -2
  109. package/src/plugins/builtin/chart-composer/index.tsx +1 -0
  110. package/src/plugins/builtin/chart-composer/presets.ts +1 -0
  111. package/src/plugins/builtin/chat/content/composer.tsx +5 -4
  112. package/src/plugins/builtin/chat/content/index.tsx +12 -2
  113. package/src/plugins/builtin/chat/content/layout-metrics.ts +3 -3
  114. package/src/plugins/builtin/chat/content/open-targets.ts +3 -3
  115. package/src/plugins/builtin/chat/layout.ts +5 -2
  116. package/src/plugins/builtin/chat/message/pane-chip.tsx +61 -40
  117. package/src/plugins/builtin/chat/message/terminal.tsx +13 -15
  118. package/src/plugins/builtin/chat/pane-links/previews.ts +51 -5
  119. package/src/plugins/builtin/chat/pane-links/share-card.ts +36 -0
  120. package/src/plugins/builtin/cloud/askg/pane.tsx +55 -13
  121. package/src/plugins/builtin/cloud/askg/tool-display.ts +1 -0
  122. package/src/plugins/builtin/cloud/terminal-relay/redact.ts +5 -3
  123. package/src/plugins/builtin/commodity-balances/index.tsx +1 -0
  124. package/src/plugins/builtin/company-attention/index.tsx +1 -1
  125. package/src/plugins/builtin/company-kpis/headless.ts +3 -1
  126. package/src/plugins/builtin/company-kpis/index.tsx +2 -2
  127. package/src/plugins/builtin/cot/index.tsx +1 -1
  128. package/src/plugins/builtin/cpi/index.tsx +1 -1
  129. package/src/plugins/builtin/credit-boards/cdx-pane.tsx +20 -7
  130. package/src/plugins/builtin/credit-boards/client.ts +8 -0
  131. package/src/plugins/builtin/credit-boards/headless.ts +4 -1
  132. package/src/plugins/builtin/credit-boards/model.ts +58 -4
  133. package/src/plugins/builtin/credit-boards/series.ts +63 -6
  134. package/src/plugins/builtin/credit-boards/sovr-pane.tsx +3 -2
  135. package/src/plugins/builtin/credit-conditions/headless.ts +24 -6
  136. package/src/plugins/builtin/credit-conditions/index.tsx +1 -1
  137. package/src/plugins/builtin/credit-conditions/model.ts +12 -6
  138. package/src/plugins/builtin/credit-conditions/series.ts +2 -1
  139. package/src/plugins/builtin/crypto-board/index.tsx +1 -0
  140. package/src/plugins/builtin/dividend-yield/index.tsx +1 -0
  141. package/src/plugins/builtin/doe/index.tsx +1 -1
  142. package/src/plugins/builtin/earnings-calls/headless.ts +5 -1
  143. package/src/plugins/builtin/earnings-calls/index.tsx +1 -0
  144. package/src/plugins/builtin/econ/calendar-model.ts +115 -8
  145. package/src/plugins/builtin/econ/calendar-source.ts +7 -1
  146. package/src/plugins/builtin/econ/fred-catalog.ts +3 -1
  147. package/src/plugins/builtin/econ/index.tsx +42 -8
  148. package/src/plugins/builtin/econ/types.ts +3 -0
  149. package/src/plugins/builtin/econ-statistics/index.tsx +1 -0
  150. package/src/plugins/builtin/econ-statistics/pane.tsx +6 -0
  151. package/src/plugins/builtin/estimate-revisions/index.tsx +1 -0
  152. package/src/plugins/builtin/executives/index.tsx +1 -0
  153. package/src/plugins/builtin/filing-events/index.tsx +1 -0
  154. package/src/plugins/builtin/fixed-income/index.tsx +3 -0
  155. package/src/plugins/builtin/futures-curve/headless.ts +3 -3
  156. package/src/plugins/builtin/futures-curve/index.tsx +1 -1
  157. package/src/plugins/builtin/futures-curve/model.ts +18 -0
  158. package/src/plugins/builtin/fx-matrix/index.tsx +44 -14
  159. package/src/plugins/builtin/gpu/index.tsx +1 -1
  160. package/src/plugins/builtin/help/functions-table.tsx +1 -1
  161. package/src/plugins/builtin/help/index.tsx +11 -1
  162. package/src/plugins/builtin/help/keybindings-editor.tsx +7 -3
  163. package/src/plugins/builtin/holders/index.tsx +1 -0
  164. package/src/plugins/builtin/holders/report-header.ts +2 -2
  165. package/src/plugins/builtin/insider/index.tsx +1 -0
  166. package/src/plugins/builtin/iv-history/index.tsx +1 -1
  167. package/src/plugins/builtin/jobs/index.tsx +1 -0
  168. package/src/plugins/builtin/macro-day/headless.ts +27 -8
  169. package/src/plugins/builtin/macro-day/index.tsx +1 -1
  170. package/src/plugins/builtin/macro-day/model.ts +19 -3
  171. package/src/plugins/builtin/macro-day/pane.tsx +14 -9
  172. package/src/plugins/builtin/macro-day/releases.ts +25 -7
  173. package/src/plugins/builtin/market-valuation/index.tsx +1 -0
  174. package/src/plugins/builtin/market-valuation/pane.tsx +8 -0
  175. package/src/plugins/builtin/members/index.tsx +1 -1
  176. package/src/plugins/builtin/mna/index.tsx +1 -0
  177. package/src/plugins/builtin/news/index.tsx +1 -0
  178. package/src/plugins/builtin/news/wire/index.tsx +5 -1
  179. package/src/plugins/builtin/news/wire/news/detail-view.tsx +4 -0
  180. package/src/plugins/builtin/news/wire/news/list-search.ts +5 -2
  181. package/src/plugins/builtin/options/index.tsx +1 -0
  182. package/src/plugins/builtin/options-positioning/index.tsx +1 -0
  183. package/src/plugins/builtin/pe-band/index.tsx +1 -1
  184. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +25 -0
  185. package/src/plugins/builtin/portfolio-list/cli/render.ts +20 -3
  186. package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +5 -1
  187. package/src/plugins/builtin/portfolio-list/headless.ts +15 -6
  188. package/src/plugins/builtin/power/index.tsx +1 -1
  189. package/src/plugins/builtin/realized-vol/index.tsx +1 -1
  190. package/src/plugins/builtin/research/headless-schema.ts +4 -3
  191. package/src/plugins/builtin/research/headless.ts +10 -4
  192. package/src/plugins/builtin/research/index.tsx +4 -0
  193. package/src/plugins/builtin/research/relative-valuation-columns.ts +145 -47
  194. package/src/plugins/builtin/research/relative-valuation-currency.ts +31 -0
  195. package/src/plugins/builtin/research/relative-valuation-headless.ts +25 -8
  196. package/src/plugins/builtin/research/relative-valuation-model.ts +40 -9
  197. package/src/plugins/builtin/research/relative-valuation-pane.tsx +3 -2
  198. package/src/plugins/builtin/research/relative-valuation-peers.ts +2 -2
  199. package/src/plugins/builtin/research-search/index.tsx +1 -0
  200. package/src/plugins/builtin/research-search/pane.tsx +8 -0
  201. package/src/plugins/builtin/revenue-breakdown/index.tsx +1 -0
  202. package/src/plugins/builtin/reverse-dcf/index.tsx +1 -1
  203. package/src/plugins/builtin/risk-factors/index.tsx +1 -0
  204. package/src/plugins/builtin/scanner/headless.ts +52 -13
  205. package/src/plugins/builtin/seasonality/index.tsx +1 -1
  206. package/src/plugins/builtin/sec/index.tsx +1 -0
  207. package/src/plugins/builtin/series-inventory.ts +1 -1
  208. package/src/plugins/builtin/shared/scanner-capture.ts +11 -3
  209. package/src/plugins/builtin/shared/series-list-detail.tsx +5 -0
  210. package/src/plugins/builtin/short-interest/index.tsx +1 -0
  211. package/src/plugins/builtin/social-mentions/index.tsx +1 -1
  212. package/src/plugins/builtin/supply-chain/index.tsx +1 -0
  213. package/src/plugins/builtin/thirteenf/api.ts +47 -4
  214. package/src/plugins/builtin/thirteenf/data.ts +43 -10
  215. package/src/plugins/builtin/thirteenf/headless.ts +55 -11
  216. package/src/plugins/builtin/thirteenf/model.ts +25 -9
  217. package/src/plugins/builtin/thirteenf/report-notes.ts +27 -6
  218. package/src/plugins/builtin/thirteenf/types.ts +2 -0
  219. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +1 -1
  220. package/src/plugins/builtin/ticker-detail/data-panes/historical-prices.tsx +8 -7
  221. package/src/plugins/builtin/ticker-detail/data-panes/history-bars.ts +8 -5
  222. package/src/plugins/builtin/ticker-detail/financials/model.ts +18 -2
  223. package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +3 -3
  224. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +6 -6
  225. package/src/plugins/builtin/ticker-detail/headless.ts +24 -17
  226. package/src/plugins/builtin/ticker-detail/index.tsx +4 -0
  227. package/src/plugins/builtin/ticker-detail/overview/model.ts +6 -4
  228. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +6 -4
  229. package/src/plugins/builtin/time-sales/client.ts +9 -11
  230. package/src/plugins/builtin/time-sales/index.tsx +1 -1
  231. package/src/plugins/builtin/treasury-auctions/after.ts +267 -0
  232. package/src/plugins/builtin/treasury-auctions/cache.ts +54 -5
  233. package/src/plugins/builtin/treasury-auctions/client.ts +33 -2
  234. package/src/plugins/builtin/treasury-auctions/headless.ts +150 -22
  235. package/src/plugins/builtin/treasury-auctions/hk-headless.ts +126 -0
  236. package/src/plugins/builtin/treasury-auctions/hk-view.tsx +347 -0
  237. package/src/plugins/builtin/treasury-auctions/hk.ts +363 -0
  238. package/src/plugins/builtin/treasury-auctions/index.tsx +27 -4
  239. package/src/plugins/builtin/treasury-auctions/model.ts +264 -28
  240. package/src/plugins/builtin/treasury-auctions/pane.tsx +176 -41
  241. package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +5 -2
  242. package/src/plugins/builtin/treasury-auctions/types.ts +7 -1
  243. package/src/plugins/builtin/vol-surface/index.tsx +1 -1
  244. package/src/plugins/builtin/world-venue-map/index.ts +1 -0
  245. package/src/plugins/builtin/yield-curve/curves.ts +10 -4
  246. package/src/plugins/builtin/yield-curve/headless.ts +6 -2
  247. package/src/plugins/builtin/yield-curve/index.tsx +3 -3
  248. package/src/plugins/builtin/yield-curve/series.ts +10 -0
  249. package/src/plugins/builtin/yield-curve/world.ts +3 -1
  250. package/src/portfolio/collection-name.ts +22 -0
  251. package/src/portfolio/column-values.ts +2 -1
  252. package/src/public/__snapshots__/public-api.test.ts.snap +4 -0
  253. package/src/public/remote.ts +7 -1
  254. package/src/remote/client.ts +191 -11
  255. package/src/remote/controller-utils.ts +13 -1
  256. package/src/remote/controller.ts +88 -26
  257. package/src/remote/endpoint.ts +24 -0
  258. package/src/remote/form.ts +59 -4
  259. package/src/remote/resources.ts +44 -18
  260. package/src/remote/schema.ts +21 -9
  261. package/src/remote/secrets.ts +12 -0
  262. package/src/remote/semantic-tree.tsx +14 -2
  263. package/src/remote/server.ts +2 -1
  264. package/src/remote/surface.tsx +192 -0
  265. package/src/remote/types.ts +5 -0
  266. package/src/renderers/dom/data-table/frozen-column.ts +3 -1
  267. package/src/renderers/dom/data-table/index.tsx +27 -9
  268. package/src/renderers/dom/data-table/row.tsx +2 -0
  269. package/src/renderers/electrobun/bun/desktop/backend.ts +27 -24
  270. package/src/renderers/electrobun/bun/desktop/detached-windows.ts +3 -3
  271. package/src/renderers/electrobun/bun/desktop/snapshot-commit.ts +77 -0
  272. package/src/renderers/electrobun/shared/protocol.ts +4 -0
  273. package/src/renderers/electrobun/view/backend-rpc.ts +3 -0
  274. package/src/renderers/electrobun/view/desktop/window/bridge.ts +3 -0
  275. package/src/renderers/opentui/host.tsx +6 -0
  276. package/src/series/standalone.ts +2 -2
  277. package/src/shares/api.ts +21 -4
  278. package/src/shares/item.ts +73 -0
  279. package/src/shares/pane-item.ts +205 -0
  280. package/src/shares/pane.ts +4 -0
  281. package/src/shares/payload.ts +9 -5
  282. package/src/sources/gloomberb-cloud/news.ts +2 -0
  283. package/src/sources/gloomberb-cloud/normalizers.ts +9 -5
  284. package/src/sources/provider-router/cache.ts +3 -1
  285. package/src/sync/controller.ts +17 -2
  286. package/src/sync/other-window-tabs.ts +32 -1
  287. package/src/sync/react.ts +4 -4
  288. package/src/tickers/renamed-listings.ts +105 -0
  289. package/src/tickers/search/index.ts +103 -16
  290. package/src/time-series/bar-spacing.ts +33 -0
  291. package/src/time-series/base-series.ts +21 -3
  292. package/src/time-series/chart-bounds.ts +31 -0
  293. package/src/time-series/field-catalog.ts +17 -0
  294. package/src/time-series/fundamentals.ts +143 -11
  295. package/src/time-series/ice-credit.ts +32 -6
  296. package/src/time-series/resolve.ts +11 -7
  297. package/src/time-series/session-bar.ts +78 -9
  298. package/src/time-series/studies/formula.ts +53 -10
  299. package/src/time-series/studies/pair.ts +18 -7
  300. package/src/time-series/studies/units.ts +49 -2
  301. package/src/time-series/types.ts +12 -0
  302. package/src/types/desktop-window.ts +2 -0
  303. package/src/types/financials.ts +7 -0
  304. package/src/types/headless.ts +8 -0
  305. package/src/types/plugin-pane-settings.ts +2 -0
  306. package/src/types/plugin-panes.ts +22 -0
  307. package/src/utils/central-banks.ts +86 -1
  308. package/src/utils/cli-output.ts +6 -3
  309. package/src/utils/datetime-format.ts +12 -3
  310. package/src/utils/depositary-receipt.ts +28 -3
  311. package/src/utils/ebitda.ts +128 -0
  312. package/src/utils/format.ts +1 -1
  313. package/src/utils/fundamentals.ts +14 -0
  314. package/src/utils/max-drawdown.ts +97 -16
  315. package/src/utils/shell-word.ts +13 -0
  316. 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 { truncateWithEllipsis } from "../../utils/text-wrap";
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 loads, so a list
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 leadSize = compact ? 18 : ICON_SIZE;
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: THUMB.width,
151
- height: THUMB.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: THUMB.width,
161
- height: THUMB.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
- : createElement("span", {
171
- key: "icon",
172
- "aria-hidden": true,
173
- style: {
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
- : createElement("span", {
206
- key: "text",
207
- style: { display: "flex", flexDirection: "column", justifyContent: "center", minWidth: 0, flex: "1 1 auto", gap: 1 },
208
- }, line(content.title, "title"), line(content.detail, "detail"));
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
- boxSizing: "border-box",
211
- display: "flex",
212
- flexDirection: "row",
213
- alignItems: "center",
214
- gap: compact ? 6 : 8,
215
- height,
216
- width: compact || fit ? "auto" : `min(100%, ${CHIP_MAX_WIDTH}px)`,
217
- maxWidth: fit ? `min(100%, ${CHIP_MAX_WIDTH}px)` : "100%",
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 = truncateWithEllipsis(
270
- [content.title, content.detail].filter(Boolean).join(" · ").replace(/\s+/g, " ").trim(),
271
- Math.max(width - icon.length - 1, 1),
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
- placeholder: string;
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 →"): half the viewport on. With a frozen first
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