gloomberb 0.20.0 → 0.20.2
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 +16 -26
- package/README.zh-CN.md +21 -65
- package/package.json +1 -1
- package/patches/electrobun-devkit@2.0.5.patch +268 -8
- package/src/account/auth-model.ts +20 -1
- package/src/account/upgrade-dialog.tsx +8 -4
- package/src/api-client/askg.ts +7 -1
- package/src/api-client/auth.ts +27 -0
- package/src/api-client/catalysts.ts +2 -0
- package/src/api-client/company-kpis.ts +2 -1
- package/src/api-client/cot.ts +14 -2
- package/src/api-client/crypto-markets.ts +20 -2
- package/src/api-client/data.ts +3 -2
- package/src/api-client/earnings.ts +46 -3
- package/src/api-client/fund-facts.ts +23 -1
- package/src/api-client/futures-curve.ts +17 -0
- package/src/api-client/index.ts +4 -1
- package/src/api-client/one-tap-reasons.ts +42 -0
- package/src/api-client/perps.ts +2 -1
- package/src/api-client/request.ts +3 -1
- package/src/api-client/research-activity.ts +16 -3
- package/src/api-client/types/filings-and-calls.ts +9 -0
- package/src/api-client/types/search.ts +3 -0
- package/src/app/keybindings/chord.ts +153 -9
- package/src/app/keybindings/index.ts +1 -1
- package/src/app/keybindings/labels.ts +49 -6
- package/src/app/runtime/desktop-deeplink.ts +73 -8
- package/src/app/runtime/plugin-seed.ts +119 -0
- package/src/app/runtime/startup.ts +45 -9
- package/src/app.tsx +8 -1
- package/src/architecture/core-builtin-allowlist.json +1 -2
- package/src/architecture/pane-tabs-allowlist.json +2 -1
- package/src/architecture/shortcut-labels-allowlist.json +11 -0
- package/src/architecture/ui-literals-allowlist.json +8 -8
- package/src/brokers/broker-portfolio-sync.ts +1 -1
- package/src/cli/bank-section.ts +26 -12
- package/src/cli/board-coins.ts +38 -5
- package/src/cli/commands/crypto-hints.ts +8 -1
- package/src/cli/commands/market.ts +294 -100
- package/src/cli/commands/overview.ts +13 -6
- package/src/cli/commands/ticker.ts +73 -21
- package/src/cli/company-name-hint.ts +19 -0
- package/src/cli/desktop-pane-shot-browser.ts +47 -31
- package/src/cli/desktop-pane-shot.ts +15 -0
- package/src/cli/entry.ts +15 -4
- package/src/cli/export-source.ts +7 -1
- package/src/cli/freshness.ts +0 -16
- package/src/cli/fx-pair.ts +64 -12
- package/src/cli/fx-quote-rate.ts +144 -0
- package/src/cli/glossary.ts +30 -0
- package/src/cli/helpers.ts +4 -2
- package/src/cli/history-back-adjust.ts +122 -0
- package/src/cli/history-rows.ts +114 -10
- package/src/cli/index.ts +4 -1
- package/src/cli/known-gaps.ts +45 -3
- package/src/cli/listing-arg.ts +48 -4
- package/src/cli/name-entries.ts +25 -5
- package/src/cli/not-a-ticker.ts +26 -1
- package/src/cli/pane-functions/catalog.ts +12 -2
- package/src/cli/pane-functions/dom.ts +4 -2
- package/src/cli/pane-functions/freshness.ts +45 -29
- package/src/cli/pane-functions/headless.ts +8 -5
- package/src/cli/pane-functions/index.ts +3 -0
- package/src/cli/pane-functions/market-session.ts +14 -5
- package/src/cli/pane-functions/resolver.ts +4 -1
- package/src/cli/pane-functions/screenshot-assessment.ts +15 -3
- package/src/cli/pane-functions/screenshot-payload.ts +130 -66
- package/src/cli/pane-functions/screenshot-render.ts +14 -2
- package/src/cli/pane-functions/screenshot-types.ts +4 -0
- package/src/cli/restore-plugins.ts +164 -51
- package/src/cli/symbol-rows.ts +22 -2
- package/src/cli/ticker-resolution.ts +74 -17
- package/src/components/chart/composite/axis-overlays.tsx +13 -3
- package/src/components/chart/composite/composite-chart.tsx +8 -1
- package/src/components/chart/composite/format.ts +16 -1
- package/src/components/chart/composite/legend.tsx +4 -3
- package/src/components/chart/composite/panel-labels.ts +2 -1
- package/src/components/chart/composite/panel-surface.tsx +33 -4
- package/src/components/chart/composite/time-scale.ts +1 -1
- package/src/components/chart/composite/toolbar.tsx +8 -4
- package/src/components/chart/composite/types.ts +17 -1
- package/src/components/chart/composite/use-composite-chart-keyboard.ts +15 -5
- package/src/components/chart/composite/use-composite-viewport.ts +31 -8
- package/src/components/chart/static/scatter-chart-surface.tsx +25 -9
- package/src/components/chart-table/axis.ts +11 -0
- package/src/components/chart-table/header.tsx +10 -1
- package/src/components/chart-table/layout.ts +14 -5
- package/src/components/command-bar/assist/inventory.ts +3 -2
- package/src/components/command-bar/commands/collection-list.ts +3 -2
- package/src/components/command-bar/panel/index.tsx +13 -0
- package/src/components/command-bar/panel/layout.ts +15 -1
- package/src/components/command-bar/panel/prompt-width.ts +34 -0
- package/src/components/command-bar/panel/runtime.ts +1 -0
- package/src/components/command-bar/panel/state.ts +4 -0
- package/src/components/command-bar/panel/types.ts +2 -0
- package/src/components/command-bar/routes/root/search-providers.ts +3 -2
- package/src/components/command-bar/routes/root/search-report.ts +2 -2
- package/src/components/command-bar/workflow/ticker-listing-picker.ts +1 -0
- package/src/components/company-logo.tsx +2 -2
- package/src/components/data-table/view.tsx +11 -2
- package/src/components/feed-data-table/stack-view.tsx +20 -6
- package/src/components/feedback-dialog.tsx +3 -1
- package/src/components/form-modal/field-row.tsx +1 -1
- package/src/components/form-modal/routes.ts +1 -0
- package/src/components/index.ts +1 -1
- package/src/components/layout/header.tsx +12 -3
- package/src/components/layout/market-summary.ts +2 -1
- package/src/components/layout/pane/footer/index.tsx +9 -5
- package/src/components/layout/pane/footer/model.ts +26 -10
- package/src/components/layout/pane/footer/registration.tsx +60 -1
- package/src/components/layout/pane/header-tabs.tsx +17 -3
- package/src/components/layout/pane/header.tsx +5 -2
- package/src/components/layout/pane/pane-tabs.tsx +57 -3
- package/src/components/layout/shell/active-drag.ts +38 -30
- package/src/components/layout/shell/drag/index.ts +51 -21
- package/src/components/layout/shell/menu.ts +3 -5
- package/src/components/layout/shell/pane/actions.ts +4 -1
- package/src/components/layout/shell/pane/ask.ts +5 -2
- package/src/components/layout/status-bar.tsx +59 -54
- package/src/components/markdown-text.tsx +35 -10
- package/src/components/onboarding/first-run-workspace.ts +25 -23
- package/src/components/onboarding/onboarding-keyboard.ts +6 -1
- package/src/components/onboarding/onboarding-wizard.tsx +12 -2
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +3 -3
- package/src/components/onboarding/use-onboarding-broker-form.ts +2 -1
- package/src/components/onboarding/use-onboarding-progress.ts +11 -4
- package/src/components/onboarding/use-onboarding-upgrade.ts +3 -2
- package/src/components/onboarding/wizard-positions.ts +8 -1
- package/src/components/pane-notice-seen.ts +125 -0
- package/src/components/pane-settings-dialog/field-dialogs.tsx +2 -1
- package/src/components/pane-settings-dialog.tsx +7 -6
- package/src/components/sign-in-code-panel.tsx +3 -2
- package/src/components/speedometer-gauge/terminal.tsx +30 -9
- package/src/components/ticker/list-table-view.tsx +39 -3
- package/src/components/ui/confirm-dialog.tsx +2 -1
- package/src/components/ui/data-table/index.tsx +4 -2
- package/src/components/ui/data-table/opentui/index.tsx +15 -5
- package/src/components/ui/data-table/types.ts +8 -0
- package/src/components/ui/external-link.tsx +4 -1
- package/src/components/ui/field-grid.tsx +1 -1
- package/src/components/ui/index.ts +2 -0
- package/src/components/ui/inline-quick-add.tsx +5 -0
- package/src/components/ui/multi-select/dialog.tsx +10 -9
- package/src/components/ui/pane-link-chip.tsx +354 -0
- package/src/components/ui/query-bar.tsx +22 -13
- package/src/components/ui/ratio-bar.tsx +24 -1
- package/src/components/ui/select-button.tsx +2 -1
- package/src/components/ui/shortcut-hint.tsx +6 -3
- package/src/components/ui/table-layout.ts +81 -0
- package/src/components/ui/tabs.tsx +45 -6
- package/src/components/use-pane-notice-footer.tsx +12 -4
- package/src/core/app-service-ports.ts +1 -1
- package/src/data/plugin-state-store.ts +44 -8
- package/src/docs/snapshot.json +53 -32
- package/src/i18n/es.ts +28 -6
- package/src/i18n/ja.ts +28 -5
- package/src/i18n/ko.ts +28 -5
- package/src/i18n/zh-cn.ts +28 -5
- package/src/i18n/zh-tw.ts +28 -5
- package/src/layout/pane-manager/gridlock-inference.ts +2 -1
- package/src/layout/pane-manager/gridlock.ts +47 -2
- package/src/layout-marketplace/api.ts +1 -0
- package/src/layout-marketplace/gallery.tsx +4 -3
- package/src/layout-marketplace/linked.ts +6 -4
- package/src/layout-marketplace/model.ts +3 -2
- package/src/market-data/fund-facts.ts +7 -1
- package/src/market-data/futures-contract.ts +77 -31
- package/src/market-data/fx-closes.ts +5 -2
- package/src/market-data/hooks.tsx +23 -0
- package/src/market-data/market/change-basis.ts +92 -14
- package/src/market-data/market/format.ts +81 -13
- package/src/market-data/market/futures-week.ts +3 -1
- package/src/market-data/market/globex-day.ts +73 -0
- package/src/market-data/market/index-level.ts +10 -1
- package/src/market-data/quotes/intraday-bar.ts +1 -1
- package/src/market-data/quotes/session-split.ts +28 -0
- package/src/plugins/builtin/account-management/pane.tsx +1 -1
- package/src/plugins/builtin/analytics/account-returns.ts +1 -1
- package/src/plugins/builtin/analytics/index.tsx +10 -3
- package/src/plugins/builtin/analytics/pane-model.ts +1 -1
- package/src/plugins/builtin/analytics/risk-client.ts +4 -1
- package/src/plugins/builtin/analytics/risk-episodes.ts +422 -0
- package/src/plugins/builtin/analytics/risk-fx.ts +1 -1
- package/src/plugins/builtin/analytics/risk-headless.ts +28 -10
- package/src/plugins/builtin/analytics/risk-math.ts +1 -1
- package/src/plugins/builtin/analytics/risk-model.ts +115 -26
- package/src/plugins/builtin/analytics/risk-pane.tsx +201 -23
- package/src/plugins/builtin/analytics/sharpe-cadence.ts +1 -1
- package/src/plugins/builtin/backtest/format.ts +14 -0
- package/src/plugins/builtin/backtest/pane.tsx +3 -3
- package/src/plugins/builtin/backtest/report.ts +5 -3
- package/src/plugins/builtin/broker-manager/add-request.ts +10 -1
- package/src/plugins/builtin/broker-trading/pane.tsx +20 -2
- package/src/plugins/builtin/buildout/company/flow.tsx +5 -5
- package/src/plugins/builtin/buildout/company/model.ts +14 -2
- package/src/plugins/builtin/catalysts/detail.tsx +2 -2
- package/src/plugins/builtin/catalysts/model.ts +7 -2
- package/src/plugins/builtin/catalysts/pane.tsx +2 -2
- package/src/plugins/builtin/chart-composer/headless.ts +57 -17
- package/src/plugins/builtin/chart-composer/session-range.ts +82 -3
- package/src/plugins/builtin/chat/message/pane-chip.tsx +36 -208
- package/src/plugins/builtin/cloud/askg/answer-follow-ups.tsx +61 -0
- package/src/plugins/builtin/cloud/askg/answer-sources.tsx +102 -0
- package/src/plugins/builtin/cloud/askg/controller.ts +7 -1
- package/src/plugins/builtin/cloud/askg/host.ts +57 -0
- package/src/plugins/builtin/cloud/askg/model.ts +45 -5
- package/src/plugins/builtin/cloud/askg/pane.tsx +304 -25
- package/src/plugins/builtin/cloud/askg/protocol.ts +26 -1
- package/src/plugins/builtin/cloud/askg/sources.ts +466 -0
- package/src/plugins/builtin/cloud/one-tap/controller.ts +309 -0
- package/src/plugins/builtin/cloud/one-tap/google-identity.ts +142 -0
- package/src/plugins/builtin/cloud/one-tap/one-tap-prompt.tsx +101 -0
- package/src/plugins/builtin/cloud/plugin.tsx +7 -1
- package/src/plugins/builtin/company-kpis/client.ts +4 -3
- package/src/plugins/builtin/company-kpis/model.ts +34 -3
- package/src/plugins/builtin/correlation/compute.ts +8 -2
- package/src/plugins/builtin/correlation/headless.ts +10 -9
- package/src/plugins/builtin/correlation/history.ts +30 -0
- package/src/plugins/builtin/correlation/index.tsx +39 -167
- package/src/plugins/builtin/correlation/matrix/grid.tsx +285 -0
- package/src/plugins/builtin/correlation/matrix/model.ts +10 -10
- package/src/plugins/builtin/correlation/relationship/model.ts +3 -6
- package/src/plugins/builtin/correlation/relationship/pane.tsx +7 -9
- package/src/plugins/builtin/correlation/relationship/view-model.ts +14 -5
- package/src/plugins/builtin/cot/client.ts +8 -3
- package/src/plugins/builtin/cot/headless.ts +65 -12
- package/src/plugins/builtin/cot/pane.tsx +11 -5
- package/src/plugins/builtin/crypto-board/client.ts +6 -1
- package/src/plugins/builtin/crypto-board/defi-view.tsx +12 -1
- package/src/plugins/builtin/crypto-board/defi.ts +44 -7
- package/src/plugins/builtin/crypto-board/headless.ts +83 -12
- package/src/plugins/builtin/crypto-board/model.ts +30 -6
- package/src/plugins/builtin/crypto-board/pane.tsx +13 -2
- package/src/plugins/builtin/earnings/client.ts +40 -6
- package/src/plugins/builtin/earnings/fiscal-quarter.ts +54 -0
- package/src/plugins/builtin/earnings/headless.ts +47 -11
- package/src/plugins/builtin/earnings/history-model.ts +136 -24
- package/src/plugins/builtin/earnings/history-table.ts +42 -10
- package/src/plugins/builtin/earnings/history.tsx +23 -8
- package/src/plugins/builtin/earnings-ripple/client.ts +5 -2
- package/src/plugins/builtin/earnings-ripple/headless.ts +8 -3
- package/src/plugins/builtin/earnings-ripple/model.ts +21 -0
- package/src/plugins/builtin/earnings-ripple/pane.tsx +2 -3
- package/src/plugins/builtin/econ/index.tsx +5 -4
- package/src/plugins/builtin/econ-statistics/stats.ts +13 -5
- package/src/plugins/builtin/equity-screener/headless.ts +2 -1
- package/src/plugins/builtin/filing-events/feed.ts +56 -18
- package/src/plugins/builtin/filing-events/pane.tsx +8 -2
- package/src/plugins/builtin/futures/index.tsx +32 -10
- package/src/plugins/builtin/futures/model.ts +93 -6
- package/src/plugins/builtin/futures/returns.ts +29 -7
- package/src/plugins/builtin/futures/table.tsx +59 -17
- package/src/plugins/builtin/futures/use-front-returns.ts +32 -6
- package/src/plugins/builtin/futures-curve/client.ts +12 -2
- package/src/plugins/builtin/futures-curve/headless.ts +58 -17
- package/src/plugins/builtin/futures-curve/model.ts +111 -15
- package/src/plugins/builtin/futures-curve/pane.tsx +11 -6
- package/src/plugins/builtin/fx-matrix/amount.ts +132 -0
- package/src/plugins/builtin/fx-matrix/headless.ts +53 -13
- package/src/plugins/builtin/fx-matrix/index.tsx +205 -42
- package/src/plugins/builtin/fx-matrix/pairs.ts +10 -8
- package/src/plugins/builtin/fx-matrix/settings.ts +22 -1
- package/src/plugins/builtin/help/index.tsx +68 -61
- package/src/plugins/builtin/holders/format.ts +7 -2
- package/src/plugins/builtin/holders/pane.tsx +11 -3
- package/src/plugins/builtin/holders/report-header.ts +5 -4
- package/src/plugins/builtin/holders/report-rows.ts +4 -1
- package/src/plugins/builtin/holders/treemap.tsx +5 -3
- package/src/plugins/builtin/insider/signals-model.ts +4 -5
- package/src/plugins/builtin/ipo-calendar/headless.ts +18 -7
- package/src/plugins/builtin/ipo-calendar/listing-ipo.ts +3 -1
- package/src/plugins/builtin/ipo-calendar/model.ts +28 -8
- package/src/plugins/builtin/ipo-calendar/pane.tsx +2 -1
- package/src/plugins/builtin/kelly-sizer/headless.ts +4 -0
- package/src/plugins/builtin/perps/headless.ts +81 -19
- package/src/plugins/builtin/perps/index.tsx +3 -1
- package/src/plugins/builtin/perps/model.ts +1 -1
- package/src/plugins/builtin/perps/pane.tsx +2 -0
- package/src/plugins/builtin/portfolio-list/cell-version.ts +1 -0
- package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +20 -1
- package/src/plugins/builtin/portfolio-list/cli/import-positions.ts +260 -0
- package/src/plugins/builtin/portfolio-list/cli/period-report.ts +154 -0
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +64 -22
- package/src/plugins/builtin/portfolio-list/cli/render.ts +18 -7
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +5 -3
- package/src/plugins/builtin/portfolio-list/grid.tsx +56 -12
- package/src/plugins/builtin/portfolio-list/headless.ts +128 -0
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +42 -4
- package/src/plugins/builtin/portfolio-list/pane/period-pnl.ts +124 -0
- package/src/plugins/builtin/portfolio-list/period-pnl.ts +179 -0
- package/src/plugins/builtin/portfolio-list/positions-import/dialog.tsx +445 -0
- package/src/plugins/builtin/portfolio-list/positions-import/index.tsx +255 -0
- package/src/plugins/builtin/portfolio-list/positions-import/lookup.ts +78 -0
- package/src/plugins/builtin/portfolio-list/positions-import/read-file.ts +32 -0
- package/src/plugins/builtin/portfolio-list/quick-add/index.tsx +186 -50
- package/src/plugins/builtin/portfolio-list/quick-add/resolution.ts +118 -4
- package/src/plugins/builtin/portfolio-list/settings.ts +25 -0
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +16 -1
- package/src/plugins/builtin/portfolio-list/summary/totals.ts +7 -5
- package/src/plugins/builtin/portfolio-list/table.tsx +105 -6
- package/src/plugins/builtin/power/headless.ts +47 -9
- package/src/plugins/builtin/research/relative-valuation-model.ts +8 -3
- package/src/plugins/builtin/research-search/article.ts +12 -2
- package/src/plugins/builtin/research-search/data.ts +5 -2
- package/src/plugins/builtin/research-search/document-view.tsx +1 -1
- package/src/plugins/builtin/research-search/model.ts +47 -3
- package/src/plugins/builtin/research-search/pane.tsx +3 -2
- package/src/plugins/builtin/reverse-dcf/model.ts +7 -4
- package/src/plugins/builtin/risk-factors/headless.ts +3 -2
- package/src/plugins/builtin/risk-factors/index.tsx +2 -28
- package/src/plugins/builtin/risk-factors/lock-note.ts +58 -0
- package/src/plugins/builtin/risk-factors/pane.tsx +14 -5
- package/src/plugins/builtin/scanner/flow-model.ts +17 -13
- package/src/plugins/builtin/scanner/flow-pane.tsx +8 -9
- package/src/plugins/builtin/scanner/flow-session.ts +2 -9
- package/src/plugins/builtin/scanner/hilo-model.ts +4 -3
- package/src/plugins/builtin/sec/filing-display.tsx +0 -5
- package/src/plugins/builtin/sec/forms.ts +19 -0
- package/src/plugins/builtin/sec/fund-facts.ts +45 -11
- package/src/plugins/builtin/sec/headless.ts +37 -12
- package/src/plugins/builtin/sec/index.tsx +37 -8
- package/src/plugins/builtin/shared/earnings-calendar.ts +6 -3
- package/src/plugins/builtin/shared/earnings-report.ts +1 -1
- package/src/plugins/builtin/shared/fx-rate-freshness.ts +0 -35
- package/src/plugins/builtin/shared/pro-lock-note.ts +5 -1
- package/src/plugins/builtin/shared/use-quote-board.ts +42 -27
- package/src/plugins/builtin/supply-chain/graph-model.ts +7 -1
- package/src/plugins/builtin/supply-chain/headless.ts +20 -10
- package/src/plugins/builtin/supply-chain/model.ts +117 -20
- package/src/plugins/builtin/supply-chain/pane.tsx +22 -15
- package/src/plugins/builtin/supply-chain/row-evidence.tsx +1 -1
- package/src/plugins/builtin/ticker-detail/data-panes/returns-chart-model.ts +69 -0
- package/src/plugins/builtin/ticker-detail/data-panes/returns-chart.tsx +118 -0
- package/src/plugins/builtin/ticker-detail/data-panes/returns-model.ts +1 -1
- package/src/plugins/builtin/ticker-detail/data-panes/returns-pane.tsx +103 -40
- package/src/plugins/builtin/ticker-detail/headless-schema.ts +10 -1
- package/src/plugins/builtin/ticker-detail/headless.ts +8 -1
- package/src/plugins/builtin/ticker-detail/overview/components.tsx +2 -1
- package/src/plugins/builtin/ticker-detail/overview/model.ts +18 -8
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +11 -8
- package/src/plugins/builtin/ticker-detail/pane.tsx +95 -20
- package/src/plugins/builtin/ticker-detail/research-groups.ts +89 -0
- package/src/plugins/builtin/ticker-detail/settings.ts +4 -3
- package/src/plugins/builtin/time-sales/headless.ts +23 -7
- package/src/plugins/builtin/time-sales/index.tsx +2 -2
- package/src/plugins/builtin/volatility/charts.tsx +2 -2
- package/src/plugins/extracted-plugins.ts +49 -24
- package/src/plugins/host-resolver.ts +3 -2
- package/src/plugins/installer.ts +220 -31
- package/src/plugins/running-installs.ts +34 -0
- package/src/plugins/seed-progress.ts +72 -0
- package/src/portfolio/column-values.ts +42 -8
- package/src/portfolio/futures-positions.ts +10 -2
- package/src/portfolio/mutations.ts +4 -3
- package/src/portfolio/period-pnl.ts +119 -0
- package/src/portfolio/positions-import/describe.ts +89 -0
- package/src/portfolio/positions-import/parse.ts +682 -0
- package/src/portfolio/positions-import/plan.ts +295 -0
- package/src/{plugins/builtin/analytics/metrics.ts → portfolio/return-metrics.ts} +24 -11
- package/src/public/__snapshots__/public-api.test.ts.snap +1 -0
- package/src/react/jsx-dev-fallback.ts +62 -0
- package/src/renderers/browser/cloud-transport.ts +1 -1
- package/src/renderers/browser/config-host.ts +3 -1
- package/src/renderers/browser/deeplink-bridge.ts +8 -1
- package/src/renderers/browser/http-proxy-transport.ts +9 -2
- package/src/renderers/browser/main.tsx +2 -1
- package/src/renderers/browser/research-entry.ts +12 -0
- package/src/renderers/cloudflare/http-proxy.ts +8 -2
- package/src/renderers/cloudflare/proxy-session.ts +1 -0
- package/src/renderers/cloudflare/worker.ts +12 -3
- package/src/renderers/dom/desktop/audio-player.tsx +2 -2
- package/src/renderers/dom/desktop/controls.tsx +1 -1
- package/src/renderers/dom/desktop/dialog-actions.tsx +10 -24
- package/src/renderers/dom/desktop/icons.tsx +4 -2
- package/src/renderers/dom/desktop/query-bar.tsx +23 -19
- package/src/renderers/dom/dom-host-providers.tsx +7 -2
- package/src/renderers/dom/host/box.tsx +2 -2
- package/src/renderers/dom/host/input.tsx +13 -0
- package/src/renderers/dom/key-event.ts +1 -0
- package/src/renderers/dom/styles.css +3 -0
- package/src/renderers/electrobun/bun/context-menu/click.ts +1 -0
- package/src/renderers/electrobun/bun/desktop/backend.ts +15 -0
- package/src/renderers/electrobun/bun/desktop/capability-bridge.ts +5 -4
- package/src/renderers/electrobun/bun/desktop/host-requests.ts +19 -11
- package/src/renderers/electrobun/bun/desktop/http-fetch.ts +1 -0
- package/src/renderers/electrobun/bun/desktop/http-stream.ts +1 -1
- package/src/renderers/electrobun/bun/desktop/initialization.ts +27 -15
- package/src/renderers/electrobun/bun/desktop/install-records.ts +4 -1
- package/src/renderers/electrobun/bun/desktop/installer-folder.ts +5 -2
- package/src/renderers/electrobun/bun/desktop/macos-objc.ts +3 -1
- package/src/renderers/electrobun/bun/desktop/screen-setup-file.ts +9 -4
- package/src/renderers/electrobun/bun/desktop/update.ts +27 -13
- package/src/renderers/electrobun/bun/desktop/windows-script.ts +6 -2
- package/src/renderers/electrobun/bun/index.ts +5 -0
- package/src/renderers/electrobun/bun/window/attention.ts +1 -0
- package/src/renderers/electrobun/bun/window/boot-frame.ts +1 -0
- package/src/renderers/electrobun/bun/window/context-menu-thread.ts +84 -0
- package/src/renderers/electrobun/bun/window/create.ts +1 -0
- package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +13 -8
- package/src/renderers/electrobun/bun/window/native-call-thread.ts +224 -0
- package/src/renderers/electrobun/bun/window/native-min-size.ts +1 -1
- package/src/renderers/electrobun/bun/window/native-timing.ts +10 -0
- package/src/renderers/electrobun/bun/window/remembered-frame.ts +1 -0
- package/src/renderers/electrobun/bun/window/script-for-webview.ts +15 -0
- package/src/renderers/electrobun/bun/window/webview-script-thread.ts +82 -0
- package/src/renderers/electrobun/bun/window/windows-native.ts +3 -1
- package/src/renderers/electrobun/bun/window/windows-quit.ts +3 -1
- package/src/renderers/electrobun/shared/protocol.ts +13 -2
- package/src/renderers/electrobun/view/app-badge-host.ts +2 -1
- package/src/renderers/electrobun/view/backend-rpc.ts +7 -0
- package/src/renderers/electrobun/view/capability-subscription.ts +2 -1
- package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +7 -10
- package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +1 -1
- package/src/renderers/electrobun/view/cli-pane-shot-mutations.ts +36 -0
- package/src/renderers/electrobun/view/http-fetch.ts +2 -1
- package/src/renderers/electrobun/view/main.tsx +13 -7
- package/src/renderers/electrobun/view/remote/capability-invoker.ts +6 -3
- package/src/renderers/electrobun/view/remote/persistence.ts +63 -27
- package/src/renderers/electrobun/view/rpc-timeout.ts +1 -0
- package/src/renderers/electrobun/view/ui-host.tsx +3 -2
- package/src/renderers/electrobun/view/window-fullscreen.ts +3 -1
- package/src/renderers/opentui/browser-open.ts +2 -1
- package/src/renderers/opentui/dialog-host.tsx +1 -1
- package/src/renderers/opentui/interaction-performance.ts +3 -1
- package/src/renderers/opentui/start.tsx +5 -1
- package/src/renderers/opentui/terminal-media.ts +11 -6
- package/src/renderers/opentui/ui-host.tsx +5 -8
- package/src/shares/open.ts +22 -1
- package/src/shares/pane.ts +2 -1
- package/src/sources/gloomberb-cloud/normalizers.ts +3 -0
- package/src/sync/analytics-payload.ts +194 -0
- package/src/sync/baseline.ts +19 -9
- package/src/sync/broker-identity.ts +171 -0
- package/src/sync/broker-instances.ts +137 -0
- package/src/sync/collections-contributor.ts +173 -0
- package/src/sync/config-contributor.ts +100 -0
- package/src/sync/config-merge.ts +229 -0
- package/src/sync/controller.ts +139 -28
- package/src/sync/core-contributors.ts +8 -1583
- package/src/sync/history-memo.ts +32 -0
- package/src/sync/layout-merge.ts +259 -0
- package/src/sync/sanitize.ts +114 -0
- package/src/sync/ticker-merge.ts +208 -0
- package/src/sync/ticker-payload.ts +81 -0
- package/src/sync/types.ts +15 -1
- package/src/telemetry/attention-setting.ts +1 -1
- package/src/telemetry/stall-reports.ts +21 -4
- package/src/telemetry/usage-counts.ts +16 -0
- package/src/test-support/preload.ts +5 -0
- package/src/theme/color-utils.ts +10 -0
- package/src/theme/font-scale.ts +34 -3
- package/src/theme/series-colors.ts +44 -0
- package/src/theme/themes.ts +2 -1
- package/src/tickers/batched-lookups.ts +263 -6
- package/src/tickers/company-name-listing.ts +44 -2
- package/src/tickers/company-name.ts +7 -2
- package/src/tickers/search/upsert.ts +16 -1
- package/src/time-series/base-series.ts +18 -4
- package/src/time-series/studies/indicators.ts +3 -1
- package/src/time-series/studies/resolve.ts +1 -1
- package/src/time-series/types.ts +6 -0
- package/src/types/financials.ts +18 -0
- package/src/types/headless.ts +11 -0
- package/src/ui/host.tsx +26 -3
- package/src/ui/index.tsx +1 -0
- package/src/utils/concurrency.ts +6 -0
- package/src/utils/currency-pair.ts +56 -4
- package/src/utils/datetime-format.ts +11 -0
- package/src/utils/decimal-comma.ts +9 -6
- package/src/utils/exchanges.ts +32 -0
- package/src/utils/fundamentals.ts +41 -0
- package/src/utils/main-thread-stall.ts +21 -5
- package/src/utils/markdown.ts +4 -2
- package/src/utils/pasted-lines.ts +14 -0
- package/src/utils/perf-marks.ts +88 -9
- package/src/utils/price-window.ts +2 -1
- package/src/utils/reported-money.ts +9 -2
- package/src/utils/sec-filings.ts +17 -0
- package/src/utils/sec.ts +37 -25
- package/src/utils/shortcut-labels.ts +6 -30
- package/src/plugins/seed-notice.ts +0 -20
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
DataTableView,
|
|
5
|
+
DialogFrame,
|
|
6
|
+
FieldLabel,
|
|
7
|
+
Notice,
|
|
8
|
+
SectionHeading,
|
|
9
|
+
SegmentedControl,
|
|
10
|
+
Spinner,
|
|
11
|
+
type DataTableCell,
|
|
12
|
+
type DataTableColumn,
|
|
13
|
+
} from "../../../../components";
|
|
14
|
+
import { DialogActions } from "../../../../components/ui/dialog-actions";
|
|
15
|
+
import { fitDialogWidth } from "../../../../components/ui/frame";
|
|
16
|
+
import { t, tf } from "../../../../i18n";
|
|
17
|
+
import {
|
|
18
|
+
morePositionsLine,
|
|
19
|
+
moreSkippedLine,
|
|
20
|
+
PREVIEW_ROWS_SHOWN,
|
|
21
|
+
positionsImportCost,
|
|
22
|
+
positionsImportShares,
|
|
23
|
+
positionsImportShowsCurrency,
|
|
24
|
+
positionsImportStatus,
|
|
25
|
+
} from "../../../../portfolio/positions-import/describe";
|
|
26
|
+
import type { PositionsFile, SkippedFileRow } from "../../../../portfolio/positions-import/parse";
|
|
27
|
+
import {
|
|
28
|
+
buildPositionsImportPlan,
|
|
29
|
+
replaceRefusal,
|
|
30
|
+
summarizePositionsImport,
|
|
31
|
+
type PositionsImportMode,
|
|
32
|
+
type PositionsImportPlan,
|
|
33
|
+
type PositionsImportRow,
|
|
34
|
+
} from "../../../../portfolio/positions-import/plan";
|
|
35
|
+
import { useViewport } from "../../../../react/input";
|
|
36
|
+
import { useThemeColors } from "../../../../theme/theme-context";
|
|
37
|
+
import type { Portfolio, TickerRecord } from "../../../../types/ticker";
|
|
38
|
+
import { Box, ScrollBox, Text, useUiCapabilities, type ScrollBoxRenderable } from "../../../../ui";
|
|
39
|
+
import { useDialogKeyboard, type PromptContext } from "../../../../ui/dialog";
|
|
40
|
+
import { canonicalExchange } from "../../../../utils/exchanges";
|
|
41
|
+
import { isPlainKey } from "../../../../utils/keyboard";
|
|
42
|
+
import { wrapTextLines } from "../../../../utils/text-wrap";
|
|
43
|
+
import type { PositionSymbolLookup } from "./lookup";
|
|
44
|
+
|
|
45
|
+
/** The body's width in cells: the positions table's six columns and a name that reads. */
|
|
46
|
+
export const POSITIONS_IMPORT_DIALOG_COLUMNS = 88;
|
|
47
|
+
/** Border and padding the terminal dialog draws around its content. */
|
|
48
|
+
const TERMINAL_DIALOG_INSET = 6;
|
|
49
|
+
/** The terminal body's scrollbar and the gap before it. */
|
|
50
|
+
const TERMINAL_SCROLLBAR_COLUMNS = 2;
|
|
51
|
+
/** Rows the terminal dialog spends outside the scrolling body: frame, title, subtitle, key line, buttons. */
|
|
52
|
+
const TERMINAL_CHROME_ROWS = 4 + 3 + 2 + 2;
|
|
53
|
+
const DESKTOP_MAX_HEIGHT = "calc(100vh - 50px)";
|
|
54
|
+
|
|
55
|
+
/** Where the positions go: a new portfolio, or the existing one merged into or replaced. */
|
|
56
|
+
export type PositionsImportTarget = "new" | PositionsImportMode;
|
|
57
|
+
|
|
58
|
+
export interface PositionsImportPreview {
|
|
59
|
+
file: PositionsFile;
|
|
60
|
+
/** Where the positions come from, after "from": "the Fidelity positions export", "holdings.csv". */
|
|
61
|
+
source: string;
|
|
62
|
+
/** The portfolio a new import makes. */
|
|
63
|
+
newPortfolio: Portfolio;
|
|
64
|
+
/** A manual portfolio the import can merge into or replace, with what it holds; null offers only a new one. */
|
|
65
|
+
existing: { portfolio: Portfolio; holdings: TickerRecord[] } | null;
|
|
66
|
+
initialTarget: PositionsImportTarget;
|
|
67
|
+
baseCurrency: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** What a replace asks before it saves. */
|
|
71
|
+
export interface PositionsImportConfirmation {
|
|
72
|
+
title: string;
|
|
73
|
+
body: string[];
|
|
74
|
+
confirmLabel: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface PositionsImportDialogProps extends PromptContext<boolean> {
|
|
78
|
+
preview: PositionsImportPreview;
|
|
79
|
+
lookUp: () => Promise<PositionSymbolLookup>;
|
|
80
|
+
/** Asks before a replace removes what the portfolio holds; true goes ahead. */
|
|
81
|
+
confirm: (request: PositionsImportConfirmation) => Promise<boolean>;
|
|
82
|
+
/** Saves the plan; a throw is shown in the dialog, which stays open. */
|
|
83
|
+
commit: (plan: PositionsImportPlan, lookup: PositionSymbolLookup, target: PositionsImportTarget) => Promise<void>;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
type PositionColumn = DataTableColumn & { id: "ticker" | "name" | "shares" | "cost" | "currency" | "bought" | "status" };
|
|
87
|
+
type SkippedColumn = DataTableColumn & { id: "line" | "row" | "reason" };
|
|
88
|
+
|
|
89
|
+
function errorMessage(error: unknown): string {
|
|
90
|
+
return error instanceof Error && error.message ? error.message : t("Could not complete that action.");
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function positionsCount(count: number): string {
|
|
94
|
+
return count === 1 ? t("1 position") : tf("{count} positions", { count });
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** The line over the table: what the import does, as `portfolio import` heads its table. */
|
|
98
|
+
function planHeadline(plan: PositionsImportPlan, target: PositionsImportTarget, portfolioName: string): string {
|
|
99
|
+
const summary = summarizePositionsImport(plan);
|
|
100
|
+
const count = positionsCount(plan.rows.length);
|
|
101
|
+
if (target === "new") return tf("Creates portfolio \"{name}\" with {count}.", { name: portfolioName, count });
|
|
102
|
+
if (target === "replace" && summary.removed > 0) {
|
|
103
|
+
return tf("Replaces the holdings of \"{name}\" with {count}, removing {removed}.", { name: portfolioName, count, removed: summary.removed });
|
|
104
|
+
}
|
|
105
|
+
if (summary.updated === 0) return tf("Adds {count} to \"{name}\".", { name: portfolioName, count });
|
|
106
|
+
if (summary.added === 0) return tf("Updates {count} in \"{name}\".", { name: portfolioName, count });
|
|
107
|
+
return tf("Imports {count} into \"{name}\": {added} new, {updated} updated.", {
|
|
108
|
+
name: portfolioName, count, added: summary.added, updated: summary.updated,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function tableRows(count: number): number {
|
|
113
|
+
return count + 1;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function tickerList(tickers: readonly TickerRecord[]): string {
|
|
117
|
+
return tickers.map((ticker) => ticker.metadata.ticker).join(", ");
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function removedLine(tickers: readonly TickerRecord[]): string {
|
|
121
|
+
return tf("Removes {tickers}: not in the file.", { tickers: tickerList(tickers) });
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** A replace leaves these as they are: the file names them, on rows it could not import. */
|
|
125
|
+
function keptLine(tickers: readonly TickerRecord[]): string {
|
|
126
|
+
return tickers.length === 1
|
|
127
|
+
? tf("Keeps {ticker}: the file lists it on a skipped row.", { ticker: tickerList(tickers) })
|
|
128
|
+
: tf("Keeps {tickers}: the file lists them on a skipped row.", { tickers: tickerList(tickers) });
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** The second step of a replace: what the portfolio holds after it, and what it loses. */
|
|
132
|
+
function replaceConfirmation(plan: PositionsImportPlan, portfolioName: string, heldCount: number): PositionsImportConfirmation {
|
|
133
|
+
const held = heldCount === 1 ? t("1 ticker") : tf("{count} tickers", { count: heldCount });
|
|
134
|
+
return {
|
|
135
|
+
title: tf("Replace {name}?", { name: portfolioName }),
|
|
136
|
+
body: [
|
|
137
|
+
tf("\"{name}\" holds {held}. After the replace it holds the file's {count}.", { name: portfolioName, held, count: positionsCount(plan.rows.length) }),
|
|
138
|
+
...plan.removed.length > 0 ? [removedLine(plan.removed)] : [],
|
|
139
|
+
...plan.kept.length > 0 ? [keptLine(plan.kept)] : [],
|
|
140
|
+
],
|
|
141
|
+
confirmLabel: t("Replace"),
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* The preview of a positions import: what each of the file's positions
|
|
147
|
+
* becomes, what is left out and why, and, for a portfolio that exists,
|
|
148
|
+
* whether the file merges into it or replaces it. Nothing is saved until
|
|
149
|
+
* Import.
|
|
150
|
+
*/
|
|
151
|
+
export function PositionsImportDialog({ resolve, dialogId, preview, lookUp, confirm, commit }: PositionsImportDialogProps) {
|
|
152
|
+
const colors = useThemeColors();
|
|
153
|
+
const { nativePaneChrome: desktop } = useUiCapabilities();
|
|
154
|
+
const viewport = useViewport();
|
|
155
|
+
const scrollRef = useRef<ScrollBoxRenderable | null>(null);
|
|
156
|
+
const [lookup, setLookup] = useState<PositionSymbolLookup | null>(null);
|
|
157
|
+
const [lookupError, setLookupError] = useState<string | null>(null);
|
|
158
|
+
const [target, setTarget] = useState<PositionsImportTarget>(preview.initialTarget);
|
|
159
|
+
const [busy, setBusy] = useState(false);
|
|
160
|
+
const [confirming, setConfirming] = useState(false);
|
|
161
|
+
const [saveError, setSaveError] = useState<string | null>(null);
|
|
162
|
+
|
|
163
|
+
useEffect(() => {
|
|
164
|
+
let live = true;
|
|
165
|
+
lookUp().then(
|
|
166
|
+
(result) => { if (live) setLookup(result); },
|
|
167
|
+
(error: unknown) => { if (live) setLookupError(errorMessage(error)); },
|
|
168
|
+
);
|
|
169
|
+
return () => { live = false; };
|
|
170
|
+
}, [lookUp]);
|
|
171
|
+
|
|
172
|
+
const portfolio = target === "new" || !preview.existing ? preview.newPortfolio : preview.existing.portfolio;
|
|
173
|
+
const plan = useMemo(() => lookup ? buildPositionsImportPlan({
|
|
174
|
+
file: preview.file,
|
|
175
|
+
resolutions: lookup.resolutions,
|
|
176
|
+
portfolio,
|
|
177
|
+
holdings: target === "new" ? [] : preview.existing?.holdings ?? [],
|
|
178
|
+
mode: target === "replace" ? "replace" : "merge",
|
|
179
|
+
baseCurrency: preview.baseCurrency,
|
|
180
|
+
}) : null, [lookup, portfolio, preview, target]);
|
|
181
|
+
const heldCount = preview.existing?.holdings.length ?? 0;
|
|
182
|
+
const refusal = plan && target === "replace" ? replaceRefusal(plan) : null;
|
|
183
|
+
const ready = !!plan && plan.rows.length > 0 && !refusal && !busy && !confirming;
|
|
184
|
+
|
|
185
|
+
const submit = useCallback(async () => {
|
|
186
|
+
if (!plan || !lookup || !ready) return;
|
|
187
|
+
setSaveError(null);
|
|
188
|
+
if (target === "replace") {
|
|
189
|
+
setConfirming(true);
|
|
190
|
+
let sure = false;
|
|
191
|
+
try {
|
|
192
|
+
sure = await confirm(replaceConfirmation(plan, portfolio.name, heldCount));
|
|
193
|
+
} catch (error) {
|
|
194
|
+
setSaveError(errorMessage(error));
|
|
195
|
+
} finally {
|
|
196
|
+
setConfirming(false);
|
|
197
|
+
}
|
|
198
|
+
if (!sure) return;
|
|
199
|
+
}
|
|
200
|
+
setBusy(true);
|
|
201
|
+
try {
|
|
202
|
+
await commit(plan, lookup, target);
|
|
203
|
+
resolve(true);
|
|
204
|
+
} catch (error) {
|
|
205
|
+
setSaveError(errorMessage(error));
|
|
206
|
+
setBusy(false);
|
|
207
|
+
}
|
|
208
|
+
}, [commit, confirm, heldCount, lookup, plan, portfolio.name, ready, resolve, target]);
|
|
209
|
+
|
|
210
|
+
const scrollBy = useCallback((rows: number) => {
|
|
211
|
+
const box = scrollRef.current;
|
|
212
|
+
if (box) box.scrollTo(Math.max(0, box.scrollTop + rows));
|
|
213
|
+
}, []);
|
|
214
|
+
|
|
215
|
+
useDialogKeyboard((event) => {
|
|
216
|
+
// The replace's confirm answers its own keys.
|
|
217
|
+
if (confirming) return;
|
|
218
|
+
if (event.name === "escape") {
|
|
219
|
+
event.preventDefault();
|
|
220
|
+
event.stopPropagation();
|
|
221
|
+
if (!busy) resolve(false);
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
if (event.name === "enter" || event.name === "return") {
|
|
225
|
+
event.preventDefault();
|
|
226
|
+
event.stopPropagation();
|
|
227
|
+
void submit();
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
const page = Math.max(1, (scrollRef.current?.viewport?.height ?? 10) - 1);
|
|
231
|
+
const rows = isPlainKey(event, "down", "j") ? 1
|
|
232
|
+
: isPlainKey(event, "up", "k") ? -1
|
|
233
|
+
: isPlainKey(event, "pagedown") ? page
|
|
234
|
+
: isPlainKey(event, "pageup") ? -page
|
|
235
|
+
: 0;
|
|
236
|
+
if (!rows) return;
|
|
237
|
+
event.preventDefault();
|
|
238
|
+
event.stopPropagation();
|
|
239
|
+
scrollBy(rows);
|
|
240
|
+
}, { allowEditable: true });
|
|
241
|
+
|
|
242
|
+
const dated = !!plan?.rows.some((row) => row.dateAcquired);
|
|
243
|
+
// As PF shows the currency column: once a row is in another currency than the portfolio totals in.
|
|
244
|
+
const existingId = preview.existing?.portfolio.id;
|
|
245
|
+
const totalsCurrency = target !== "new" && preview.existing?.holdings.some((ticker) => ticker.metadata.positions.some((position) => position.portfolio === existingId))
|
|
246
|
+
? portfolio.currency ?? preview.baseCurrency
|
|
247
|
+
: null;
|
|
248
|
+
const priced = !!plan && positionsImportShowsCurrency(plan.rows, totalsCurrency);
|
|
249
|
+
const positionColumns = useMemo<PositionColumn[]>(() => [
|
|
250
|
+
{ id: "ticker", label: t("Ticker"), width: 13, align: "left" },
|
|
251
|
+
{ id: "name", label: t("Name"), width: 14, align: "left", flexGrow: 1 },
|
|
252
|
+
{ id: "shares", label: t("Shares"), width: 10, align: "right" },
|
|
253
|
+
{ id: "cost", label: t("Avg Cost"), width: 14, align: "right" },
|
|
254
|
+
...priced ? [{ id: "currency" as const, label: t("Ccy"), width: 4, align: "left" as const }] : [],
|
|
255
|
+
...dated ? [{ id: "bought" as const, label: t("Bought"), width: 11, align: "left" as const }] : [],
|
|
256
|
+
{ id: "status", label: t("Status"), width: 11, align: "left" },
|
|
257
|
+
], [dated, priced]);
|
|
258
|
+
const skippedColumns = useMemo<SkippedColumn[]>(() => [
|
|
259
|
+
{ id: "line", label: t("Line"), width: 5, align: "right" },
|
|
260
|
+
{ id: "row", label: t("Row"), width: 24, align: "left" },
|
|
261
|
+
{ id: "reason", label: t("Reason"), width: 20, align: "left", flexGrow: 1 },
|
|
262
|
+
], []);
|
|
263
|
+
|
|
264
|
+
const renderPosition = useCallback((row: PositionsImportRow, column: PositionColumn): DataTableCell => {
|
|
265
|
+
switch (column.id) {
|
|
266
|
+
// The venue says which listing the symbol went to: ASML.AS is ASML on AMS, not the NASDAQ line.
|
|
267
|
+
case "ticker": return { text: row.ticker.metadata.ticker, note: canonicalExchange(row.ticker.metadata.exchange) || undefined, color: colors.textBright };
|
|
268
|
+
case "name": return { text: row.ticker.metadata.name ?? "", color: colors.text };
|
|
269
|
+
case "shares": return { text: positionsImportShares(row), color: colors.text, value: row.shares };
|
|
270
|
+
case "cost": return { text: positionsImportCost(row), color: row.avgCost === null ? colors.textMuted : colors.text, value: row.avgCost };
|
|
271
|
+
case "currency": return { text: row.currency, color: colors.textDim };
|
|
272
|
+
case "bought": return { text: row.dateAcquired ?? "", color: colors.textDim };
|
|
273
|
+
case "status": return { text: positionsImportStatus(row), color: row.heldShares === null ? colors.positive : colors.textDim };
|
|
274
|
+
}
|
|
275
|
+
}, [colors]);
|
|
276
|
+
const renderSkipped = useCallback((row: SkippedFileRow, column: SkippedColumn): DataTableCell => {
|
|
277
|
+
switch (column.id) {
|
|
278
|
+
case "line": return { text: String(row.line), color: colors.textMuted, value: row.line };
|
|
279
|
+
case "row": return { text: row.label, color: colors.text };
|
|
280
|
+
case "reason": return { text: row.reason, color: colors.textDim };
|
|
281
|
+
}
|
|
282
|
+
}, [colors]);
|
|
283
|
+
|
|
284
|
+
const contentWidth = desktop
|
|
285
|
+
? POSITIONS_IMPORT_DIALOG_COLUMNS
|
|
286
|
+
: Math.max(20, Math.min(POSITIONS_IMPORT_DIALOG_COLUMNS, viewport.width - 2 - TERMINAL_DIALOG_INSET));
|
|
287
|
+
// The terminal's scrollbar takes the body's last column; the tables stop short of it.
|
|
288
|
+
const tableWidth = desktop ? contentWidth : contentWidth - TERMINAL_SCROLLBAR_COLUMNS;
|
|
289
|
+
const withoutCost = plan?.rows.filter((row) => row.avgCost === null).map((row) => row.ticker.metadata.ticker) ?? [];
|
|
290
|
+
const notices = plan ? [
|
|
291
|
+
...withoutCost.length > 0
|
|
292
|
+
? [tf("No cost in the file for {tickers}: set it with Set Portfolio Position after the import.", { tickers: withoutCost.join(", ") })]
|
|
293
|
+
: [],
|
|
294
|
+
...plan.rows.flatMap((row) => row.notes.map((note) => `${row.ticker.metadata.ticker}: ${note}`)),
|
|
295
|
+
...plan.removed.length > 0 && !refusal ? [removedLine(plan.removed)] : [],
|
|
296
|
+
...plan.kept.length > 0 && !refusal ? [keptLine(plan.kept)] : [],
|
|
297
|
+
] : [];
|
|
298
|
+
// A refused replace says why instead of what it would do.
|
|
299
|
+
const headline = plan && !refusal ? planHeadline(plan, target, portfolio.name) : null;
|
|
300
|
+
const status = lookupError ?? (plan && plan.rows.length === 0 ? t("None of the file's positions can be imported.") : refusal);
|
|
301
|
+
const symbolCount = preview.file.positions.length;
|
|
302
|
+
// Each table lists its first rows: a long one is drawn whole, row by row, and the rest are counted.
|
|
303
|
+
const shownPositions = plan ? plan.rows.slice(0, PREVIEW_ROWS_SHOWN) : [];
|
|
304
|
+
const morePositions = plan ? morePositionsLine(plan.rows.length) : null;
|
|
305
|
+
const shownSkipped = plan ? plan.skipped.slice(0, PREVIEW_ROWS_SHOWN) : [];
|
|
306
|
+
const moreSkipped = plan ? moreSkippedLine(plan.skipped.length) : null;
|
|
307
|
+
|
|
308
|
+
const body = (
|
|
309
|
+
<Box flexDirection="column">
|
|
310
|
+
{!plan && !lookupError && (
|
|
311
|
+
<Spinner label={symbolCount === 1 ? t("Looking up 1 symbol...") : tf("Looking up {count} symbols...", { count: symbolCount })} />
|
|
312
|
+
)}
|
|
313
|
+
{headline && <Text fg={colors.text} wrapText>{headline}</Text>}
|
|
314
|
+
{status && <Notice tone="negative">{status}</Notice>}
|
|
315
|
+
{plan && plan.rows.length > 0 && (
|
|
316
|
+
<Box flexDirection="column" height={desktop ? undefined : tableRows(shownPositions.length)} marginTop={1}>
|
|
317
|
+
<DataTableView<PositionsImportRow, PositionColumn>
|
|
318
|
+
columns={positionColumns}
|
|
319
|
+
items={shownPositions}
|
|
320
|
+
selection={{ kind: "none" }}
|
|
321
|
+
rootWidth={tableWidth}
|
|
322
|
+
rootHeight={tableRows(shownPositions.length)}
|
|
323
|
+
horizontalPadding={0}
|
|
324
|
+
virtualize={false}
|
|
325
|
+
fitRows
|
|
326
|
+
sortColumnId={null}
|
|
327
|
+
sortDirection="asc"
|
|
328
|
+
getItemKey={(row) => row.ticker.metadata.ticker}
|
|
329
|
+
renderCell={renderPosition}
|
|
330
|
+
emptyStateTitle="Nothing to import"
|
|
331
|
+
/>
|
|
332
|
+
</Box>
|
|
333
|
+
)}
|
|
334
|
+
{morePositions && <Text fg={colors.textMuted}>{morePositions}</Text>}
|
|
335
|
+
{notices.length > 0 && (
|
|
336
|
+
<Box flexDirection="column" marginTop={1}>
|
|
337
|
+
{notices.map((notice) => <Notice key={notice}>{notice}</Notice>)}
|
|
338
|
+
</Box>
|
|
339
|
+
)}
|
|
340
|
+
{plan && plan.skipped.length > 0 && (
|
|
341
|
+
<Box flexDirection="column" marginTop={1}>
|
|
342
|
+
<SectionHeading title={t("Skipped")} />
|
|
343
|
+
<Box flexDirection="column" height={desktop ? undefined : tableRows(shownSkipped.length)}>
|
|
344
|
+
<DataTableView<SkippedFileRow, SkippedColumn>
|
|
345
|
+
columns={skippedColumns}
|
|
346
|
+
items={shownSkipped}
|
|
347
|
+
selection={{ kind: "none" }}
|
|
348
|
+
rootWidth={tableWidth}
|
|
349
|
+
rootHeight={tableRows(shownSkipped.length)}
|
|
350
|
+
horizontalPadding={0}
|
|
351
|
+
virtualize={false}
|
|
352
|
+
fitRows
|
|
353
|
+
sortColumnId={null}
|
|
354
|
+
sortDirection="asc"
|
|
355
|
+
getItemKey={(row) => `${row.line}:${row.label}`}
|
|
356
|
+
renderCell={renderSkipped}
|
|
357
|
+
emptyStateTitle="Nothing skipped"
|
|
358
|
+
/>
|
|
359
|
+
</Box>
|
|
360
|
+
{moreSkipped && <Text fg={colors.textMuted}>{moreSkipped}</Text>}
|
|
361
|
+
</Box>
|
|
362
|
+
)}
|
|
363
|
+
</Box>
|
|
364
|
+
);
|
|
365
|
+
|
|
366
|
+
const targetControl = preview.existing ? (
|
|
367
|
+
<Box flexDirection="column" marginBottom={1}>
|
|
368
|
+
<Box height={1}><FieldLabel label={t("Import into")} active={!desktop} /></Box>
|
|
369
|
+
<SegmentedControl
|
|
370
|
+
accessibleLabel={t("Import into")}
|
|
371
|
+
value={target}
|
|
372
|
+
focused={!busy}
|
|
373
|
+
shortcutScope={dialogId}
|
|
374
|
+
allowEditable
|
|
375
|
+
onChange={(next) => { if (!busy) setTarget(next as PositionsImportTarget); }}
|
|
376
|
+
options={[
|
|
377
|
+
{ value: "new", label: tf("New portfolio \"{name}\"", { name: preview.newPortfolio.name }) },
|
|
378
|
+
// An empty portfolio has nothing to merge with or replace: the file goes into it.
|
|
379
|
+
...preview.existing.holdings.length === 0
|
|
380
|
+
? [{ value: "merge", label: preview.existing.portfolio.name }]
|
|
381
|
+
: [
|
|
382
|
+
{ value: "merge", label: tf("Merge into {name}", { name: preview.existing.portfolio.name }) },
|
|
383
|
+
{ value: "replace", label: tf("Replace {name}", { name: preview.existing.portfolio.name }) },
|
|
384
|
+
],
|
|
385
|
+
]}
|
|
386
|
+
/>
|
|
387
|
+
</Box>
|
|
388
|
+
) : null;
|
|
389
|
+
|
|
390
|
+
const importLabel = target === "replace" && plan && plan.rows.length > 0
|
|
391
|
+
? tf("Replace {held} with {count}", { held: heldCount, count: plan.rows.length })
|
|
392
|
+
: plan && plan.rows.length > 0 ? tf("Import {count}", { count: positionsCount(plan.rows.length) }) : t("Import");
|
|
393
|
+
const actions = (
|
|
394
|
+
<DialogActions alignEnd hints={preview.existing ? { keys: [{ key: "←→", label: "target" }] } : undefined}>
|
|
395
|
+
<Button label={t("Cancel")} variant="secondary" desktopShortcut="Esc" disabled={busy} onPress={() => resolve(false)} />
|
|
396
|
+
<Button label={importLabel} variant="primary" desktopShortcut="Enter" disabled={!ready} pending={busy} onPress={() => { void submit(); }} />
|
|
397
|
+
</DialogActions>
|
|
398
|
+
);
|
|
399
|
+
const subtitle = tf("From {source}", { source: preview.source });
|
|
400
|
+
|
|
401
|
+
if (desktop) {
|
|
402
|
+
return (
|
|
403
|
+
<Box flexDirection="column" maxHeight={DESKTOP_MAX_HEIGHT} style={{ width: fitDialogWidth(POSITIONS_IMPORT_DIALOG_COLUMNS) }}>
|
|
404
|
+
<DialogFrame title="Import Positions" subtitle={subtitle} desktopFooter={null} onClose={() => { if (!busy) resolve(false); }} shrinkable>
|
|
405
|
+
{targetControl}
|
|
406
|
+
<ScrollBox ref={scrollRef} scrollY style={{ overflowX: "hidden" }}>{body}</ScrollBox>
|
|
407
|
+
{saveError && <Box style={{ marginTop: "var(--gloom-space-sm)" }}><Notice tone="negative">{saveError}</Notice></Box>}
|
|
408
|
+
<Box style={{ marginTop: "var(--gloom-space-md)" }}>{actions}</Box>
|
|
409
|
+
</DialogFrame>
|
|
410
|
+
</Box>
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
const noticeRows = notices.reduce((sum, notice) => sum + wrapTextLines(notice, contentWidth).length, 0);
|
|
415
|
+
const bodyRows = (plan || lookupError ? 0 : 1)
|
|
416
|
+
+ (headline ? wrapTextLines(headline, contentWidth).length : 0)
|
|
417
|
+
+ (status ? wrapTextLines(status, contentWidth).length : 0)
|
|
418
|
+
+ (plan && plan.rows.length > 0 ? 1 + tableRows(shownPositions.length) + (morePositions ? 1 : 0) : 0)
|
|
419
|
+
+ (noticeRows > 0 ? 1 + noticeRows : 0)
|
|
420
|
+
+ (plan && plan.skipped.length > 0 ? 2 + tableRows(shownSkipped.length) + (moreSkipped ? 1 : 0) : 0);
|
|
421
|
+
const fixedRows = TERMINAL_CHROME_ROWS + (targetControl ? 3 : 0) + (saveError ? 1 + wrapTextLines(saveError, contentWidth).length : 0);
|
|
422
|
+
const shownRows = Math.max(1, Math.min(bodyRows, viewport.height - 2 - fixedRows));
|
|
423
|
+
const keyLine = [
|
|
424
|
+
...preview.existing ? [t("←→ target")] : [],
|
|
425
|
+
...bodyRows > shownRows ? [t("↑↓ scroll")] : [],
|
|
426
|
+
target === "replace" ? t("Enter replace") : t("Enter import"),
|
|
427
|
+
t("Esc cancel"),
|
|
428
|
+
].join(" · ");
|
|
429
|
+
return (
|
|
430
|
+
<DialogFrame title="Import Positions" subtitle={subtitle} footer={keyLine}>
|
|
431
|
+
<Box flexDirection="column" width={contentWidth}>
|
|
432
|
+
{targetControl}
|
|
433
|
+
<ScrollBox ref={scrollRef} height={shownRows} scrollY focusable={false}>{body}</ScrollBox>
|
|
434
|
+
{saveError && (
|
|
435
|
+
<>
|
|
436
|
+
<Box height={1} />
|
|
437
|
+
<Notice tone="negative">{saveError}</Notice>
|
|
438
|
+
</>
|
|
439
|
+
)}
|
|
440
|
+
<Box height={1} />
|
|
441
|
+
{actions}
|
|
442
|
+
</Box>
|
|
443
|
+
</DialogFrame>
|
|
444
|
+
);
|
|
445
|
+
}
|