@gloom-sh/terminal 0.20.10 → 0.20.12
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/package.json +2 -1
- package/patches/@opentui%2Fcore@0.3.2.patch +16 -0
- package/src/api-client/awards.ts +16 -0
- package/src/api-client/central-bank-rates.ts +5 -0
- package/src/api-client/data.ts +55 -2
- package/src/api-client/index.ts +18 -1
- package/src/api-client/request.ts +86 -3
- package/src/api-client/socket-connection.ts +366 -0
- package/src/api-client/socket-features.ts +75 -0
- package/src/api-client/socket-frames.ts +161 -0
- package/src/api-client/socket-listeners.ts +207 -0
- package/src/api-client/socket-quotes.ts +332 -0
- package/src/api-client/socket.ts +168 -983
- package/src/api-client/supply-chain-graph.ts +4 -2
- package/src/api-client/supply-chain.ts +8 -0
- package/src/api-client/types/econ.ts +10 -7
- package/src/api-client/types/filings-and-calls.ts +8 -0
- package/src/app/global-shortcuts.ts +2 -1
- package/src/app/keybindings/actions.ts +19 -0
- package/src/app/pane-runtime/index.tsx +18 -3
- package/src/app/pane-runtime/layout-placement.ts +63 -0
- package/src/app/pane-runtime/ticker-open-runtime.ts +10 -2
- package/src/brokers/signed-in/adapter.ts +19 -5
- package/src/brokers/signed-in/client.ts +13 -1
- package/src/brokers/signed-in/sign-in-dialog.tsx +33 -9
- package/src/capabilities/chart-series.ts +4 -1
- package/src/cli/board-coins.ts +10 -1
- package/src/cli/commands/crypto-hints.ts +3 -2
- package/src/cli/commands/fred-series.ts +0 -54
- package/src/cli/commands/market.ts +209 -31
- package/src/cli/commands/overview.ts +47 -14
- package/src/cli/commands/search.ts +37 -8
- package/src/cli/commands/ticker.ts +15 -4
- package/src/cli/desktop-pane-shot.ts +27 -2
- package/src/cli/fx-quote-rate.ts +1 -1
- package/src/cli/glossary.ts +14 -5
- package/src/cli/history-catalog-series.ts +85 -0
- package/src/cli/index.ts +1 -1
- package/src/cli/list-progress.ts +45 -0
- package/src/cli/listing-arg.ts +71 -7
- package/src/cli/name-entries.ts +8 -4
- package/src/cli/not-a-ticker.ts +2 -2
- package/src/cli/pane-functions/freshness.ts +50 -3
- package/src/cli/pane-functions/index.ts +7 -4
- package/src/cli/pane-functions/market-session.ts +66 -14
- package/src/cli/pane-functions/options.ts +5 -0
- package/src/cli/pane-functions/resolver.ts +9 -2
- package/src/cli/pane-functions/screenshot-assessment.ts +28 -3
- package/src/cli/pane-functions/screenshot-types.ts +6 -0
- package/src/cli/quote-answer.ts +49 -10
- package/src/cli/quote-list-reads.ts +87 -0
- package/src/cli/report-tables.ts +70 -13
- package/src/cli/result.ts +24 -2
- package/src/cli/symbol-list.ts +31 -4
- package/src/cli/terminal-code-hints.ts +83 -0
- package/src/cli/ticker-resolution.ts +2 -1
- package/src/cli/treasury-yields.ts +5 -0
- package/src/components/chart/native/kitty/manager.ts +2 -0
- package/src/components/chart/native/surface/manager.ts +211 -11
- package/src/components/command-bar/action-runtime.ts +2 -0
- package/src/components/command-bar/panel/index.tsx +2 -13
- package/src/components/command-bar/panel/layout.ts +1 -7
- package/src/components/command-bar/panel/runtime.ts +0 -1
- package/src/components/command-bar/panel/types.ts +0 -2
- package/src/components/command-bar/routing/launch-request.ts +2 -1
- package/src/components/command-bar/routing/navigation-state.ts +4 -2
- package/src/components/command-bar/workflow/types.ts +6 -0
- package/src/components/data-table/column-menu.tsx +89 -0
- package/src/components/data-table/sort-menu.tsx +9 -2
- package/src/components/data-table/view.tsx +33 -6
- package/src/components/form-modal/content.tsx +10 -0
- package/src/components/index.ts +1 -1
- package/src/components/layout/detached-pane-shell.tsx +3 -0
- package/src/components/layout/double-escape-close.ts +34 -3
- package/src/components/layout/floating-pane.tsx +10 -4
- package/src/components/layout/pane/cycle-order.ts +66 -2
- package/src/components/layout/pane/footer/index.tsx +25 -11
- package/src/components/layout/pane/footer/model.ts +62 -20
- package/src/components/layout/pane/header.tsx +140 -31
- package/src/components/layout/pane/sidebar.tsx +138 -20
- package/src/components/layout/pane/status-footer.ts +3 -1
- package/src/components/layout/shell/active-drag.ts +18 -13
- package/src/components/layout/shell/drag/magnets.ts +34 -18
- package/src/components/layout/shell/drag/runtime.ts +5 -0
- package/src/components/layout/shell/index.tsx +25 -0
- package/src/components/layout/shell/menu.ts +9 -0
- package/src/components/layout/shell/pane/actions.ts +36 -0
- package/src/components/layout/shell/pane/management-shortcuts.ts +27 -3
- package/src/components/layout/shell/pane-occlusion.ts +40 -0
- package/src/components/layout/shell/shortcuts.ts +17 -1
- package/src/components/layout/shell/terminal-pointer-runtime.ts +39 -6
- package/src/components/layout/shell/window-mode/index.ts +5 -16
- package/src/components/layout/shell/window-mode/overlays.tsx +3 -1
- package/src/components/market-board/index.tsx +14 -5
- package/src/components/metric-treemap/index.tsx +3 -1
- package/src/components/ticker/list-table-view.tsx +5 -0
- package/src/components/ui/button.tsx +48 -4
- package/src/components/ui/data-table/column-order.ts +180 -0
- package/src/components/ui/data-table/index.tsx +12 -1
- package/src/components/ui/data-table/opentui/index.tsx +291 -32
- package/src/components/ui/data-table/opentui/model.ts +43 -4
- package/src/components/ui/data-table/types.ts +56 -0
- package/src/components/ui/data-table/use-column-order.ts +135 -0
- package/src/components/ui/index.ts +1 -1
- package/src/components/ui/inline-quick-add.tsx +19 -3
- package/src/components/ui/list-view.tsx +11 -5
- package/src/components/ui/query-bar.tsx +16 -1
- package/src/components/ui/selection-fill.ts +39 -0
- package/src/components/ui/table-layout.ts +120 -0
- package/src/core/state/app/layout-reducer.ts +2 -1
- package/src/core/state/app/pane-choices.ts +68 -0
- package/src/core/state/app/state.ts +14 -6
- package/src/core/state/app/types.ts +8 -0
- package/src/docs/snapshot.json +3 -2
- package/src/i18n/es.ts +2 -0
- package/src/i18n/ja.ts +2 -0
- package/src/i18n/ko.ts +2 -0
- package/src/i18n/zh-cn.ts +2 -0
- package/src/i18n/zh-tw.ts +2 -0
- package/src/layout/pane-manager/dock-tree.ts +19 -0
- package/src/layout/pane-manager/index.ts +3 -0
- package/src/market-data/coordinator/index.ts +4 -3
- package/src/market-data/coordinator/quotes.ts +12 -4
- package/src/market-data/market/freshness.ts +33 -0
- package/src/market-data/market/status.ts +5 -1
- package/src/market-data/quotes/contributions.ts +10 -0
- package/src/market-data/quotes/freshness.ts +31 -0
- package/src/market-data/quotes/live-valuation.ts +32 -5
- package/src/market-data/quotes/regular-session-valuation.ts +1 -1
- package/src/market-data/quotes/resolution.ts +4 -0
- package/src/market-data/quotes/time.ts +0 -14
- package/src/plugins/builtin/account-management/index.tsx +1 -0
- package/src/plugins/builtin/awards/detail.tsx +12 -4
- package/src/plugins/builtin/awards/headless.ts +29 -8
- package/src/plugins/builtin/awards/model.ts +36 -2
- package/src/plugins/builtin/awards/pane.tsx +7 -4
- package/src/plugins/builtin/broker-manager/detail.tsx +5 -3
- package/src/plugins/builtin/broker-manager/index.tsx +7 -6
- package/src/plugins/builtin/broker-manager/model.ts +15 -6
- package/src/plugins/builtin/broker-manager/pane-actions.tsx +11 -4
- package/src/plugins/builtin/broker-manager/sign-in-end.ts +50 -19
- package/src/plugins/builtin/broker-manager/table.ts +10 -4
- package/src/plugins/builtin/broker-trading/index.tsx +1 -1
- package/src/plugins/builtin/central-bank-rates/headless.ts +6 -6
- package/src/plugins/builtin/central-bank-rates/index.tsx +1 -1
- package/src/plugins/builtin/central-bank-rates/model.ts +21 -3
- package/src/plugins/builtin/central-bank-rates/pane.tsx +15 -5
- package/src/plugins/builtin/chart-composer/headless.ts +5 -1
- package/src/plugins/builtin/chart-composer/pane.tsx +1 -0
- package/src/plugins/builtin/chat/content/handle-prompt.tsx +4 -0
- package/src/plugins/builtin/chat/controller/realtime.ts +17 -1
- package/src/plugins/builtin/chat/message/terminal.tsx +4 -1
- package/src/plugins/builtin/chat/sidebar.tsx +35 -19
- package/src/plugins/builtin/cloud/askg/pane.tsx +4 -0
- package/src/plugins/builtin/cloud/askg/tool-timeline.tsx +2 -0
- package/src/plugins/builtin/cloud/plugin.tsx +1 -0
- package/src/plugins/builtin/cloud/team/module.tsx +1 -0
- package/src/plugins/builtin/cloud/thesis/detail.tsx +9 -4
- package/src/plugins/builtin/commodity-balances/pane.tsx +13 -5
- package/src/plugins/builtin/company-kpis/model.ts +3 -3
- package/src/plugins/builtin/connections/index.ts +1 -0
- package/src/plugins/builtin/credit-boards/cdx-pane.tsx +9 -5
- package/src/plugins/builtin/credit-boards/client.ts +5 -0
- package/src/plugins/builtin/credit-boards/headless.ts +1 -6
- package/src/plugins/builtin/credit-boards/model.ts +0 -6
- package/src/plugins/builtin/credit-boards/series.ts +19 -8
- package/src/plugins/builtin/credit-boards/sovr-pane.tsx +9 -5
- package/src/plugins/builtin/crypto-etf-flows/headless.ts +23 -13
- package/src/plugins/builtin/crypto-etf-flows/pane.tsx +8 -3
- package/src/plugins/builtin/debt-maturities/headless.ts +16 -7
- package/src/plugins/builtin/debt-maturities/model.ts +9 -15
- package/src/plugins/builtin/debt-maturities/pane.tsx +9 -10
- package/src/plugins/builtin/earnings/board-model.ts +33 -4
- package/src/plugins/builtin/earnings/board.tsx +15 -3
- package/src/plugins/builtin/earnings/calendar.tsx +10 -6
- package/src/plugins/builtin/earnings/client.ts +0 -9
- package/src/plugins/builtin/earnings/headless.ts +10 -7
- package/src/plugins/builtin/earnings/history.tsx +21 -14
- package/src/plugins/builtin/earnings-calls/data.ts +24 -4
- package/src/plugins/builtin/earnings-calls/format.ts +23 -5
- package/src/plugins/builtin/earnings-calls/headless.ts +23 -3
- package/src/plugins/builtin/earnings-calls/index.tsx +1 -0
- package/src/plugins/builtin/earnings-calls/model.ts +11 -1
- package/src/plugins/builtin/earnings-calls/pane.tsx +2 -5
- package/src/plugins/builtin/econ/calendar-model.ts +27 -0
- package/src/plugins/builtin/econ/fred-catalog.ts +3 -0
- package/src/plugins/builtin/econ/index.tsx +9 -2
- package/src/plugins/builtin/econ-statistics/headless.ts +3 -1
- package/src/plugins/builtin/econ-statistics/index.tsx +1 -1
- package/src/plugins/builtin/equity-screener/live.ts +74 -18
- package/src/plugins/builtin/equity-screener/model.ts +19 -4
- package/src/plugins/builtin/equity-screener/pane.tsx +19 -14
- package/src/plugins/builtin/equity-screener/refresh-anchor.ts +45 -0
- package/src/plugins/builtin/equity-screener/results.ts +22 -2
- package/src/plugins/builtin/equity-screener/screen-check.ts +9 -3
- package/src/plugins/builtin/fear-greed/headless.ts +16 -13
- package/src/plugins/builtin/fear-greed/pane.tsx +12 -4
- package/src/plugins/builtin/filing-events/index.tsx +1 -0
- package/src/plugins/builtin/futures/index.tsx +15 -1
- package/src/plugins/builtin/futures/table.tsx +1 -1
- package/src/plugins/builtin/fx-matrix/index.tsx +32 -19
- package/src/plugins/builtin/holders/pane.tsx +30 -20
- package/src/plugins/builtin/insider/table.tsx +10 -7
- package/src/plugins/builtin/insider/tickers.tsx +1 -1
- package/src/plugins/builtin/iv-history/events.ts +5 -0
- package/src/plugins/builtin/iv-history/headless.ts +15 -9
- package/src/plugins/builtin/jobs/index.tsx +1 -0
- package/src/plugins/builtin/kelly-sizer/sections.tsx +2 -0
- package/src/plugins/builtin/macro-day/headless.ts +15 -6
- package/src/plugins/builtin/macro-day/model.ts +1 -1
- package/src/plugins/builtin/macro-day/releases.ts +25 -16
- package/src/plugins/builtin/market-movers/index.tsx +20 -8
- package/src/plugins/builtin/market-movers/model.ts +5 -0
- package/src/plugins/builtin/market-movers/session-body.tsx +2 -1
- package/src/plugins/builtin/money-markets/headless.ts +12 -2
- package/src/plugins/builtin/money-markets/pane.tsx +10 -1
- package/src/plugins/builtin/options/view.tsx +3 -0
- package/src/plugins/builtin/options-positioning/pane.tsx +1 -1
- package/src/plugins/builtin/options-scenario/pane.tsx +2 -1
- package/src/plugins/builtin/perps/cascade-tabs.tsx +2 -1
- package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +4 -31
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +19 -1
- package/src/plugins/builtin/portfolio-list/quick-add/index.tsx +22 -8
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +6 -8
- package/src/plugins/builtin/portfolio-list/table.tsx +15 -1
- package/src/plugins/builtin/rate-path/pane.tsx +2 -0
- package/src/plugins/builtin/realized-vol/headless.ts +28 -2
- package/src/plugins/builtin/revenue-breakdown/pane.tsx +2 -0
- package/src/plugins/builtin/reverse-dcf/pane.tsx +2 -1
- package/src/plugins/builtin/risk-factors/index.tsx +1 -0
- package/src/plugins/builtin/seasonality/pane.tsx +2 -1
- package/src/plugins/builtin/shared/source-footer.ts +70 -0
- package/src/plugins/builtin/short-interest/publications-pane.tsx +5 -1
- package/src/plugins/builtin/short-volume/pane.tsx +5 -1
- package/src/plugins/builtin/social-mentions/outliers.tsx +10 -1
- package/src/plugins/builtin/social-mentions/pane.tsx +7 -0
- package/src/plugins/builtin/supply-chain/client.ts +3 -1
- package/src/plugins/builtin/supply-chain/flow.tsx +25 -8
- package/src/plugins/builtin/supply-chain/graph-client.ts +1 -1
- package/src/plugins/builtin/supply-chain/graph-evidence.ts +1 -1
- package/src/plugins/builtin/supply-chain/graph-model.ts +12 -1
- package/src/plugins/builtin/supply-chain/graph-pane.tsx +9 -8
- package/src/plugins/builtin/supply-chain/graph.tsx +12 -6
- package/src/plugins/builtin/supply-chain/headless.ts +13 -7
- package/src/plugins/builtin/supply-chain/model.ts +68 -11
- package/src/plugins/builtin/supply-chain/pane.tsx +9 -6
- package/src/plugins/builtin/supply-chain/row-evidence.tsx +5 -5
- package/src/plugins/builtin/thirteenf/pane.tsx +2 -0
- package/src/plugins/builtin/ticker-detail/financials/model.ts +28 -6
- package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +26 -9
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +58 -35
- package/src/plugins/builtin/ticker-detail/overview/components.tsx +14 -1
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +2 -0
- package/src/plugins/builtin/ticker-detail/pane.tsx +48 -24
- package/src/plugins/builtin/ticker-detail/quote-footer.ts +5 -0
- package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +6 -3
- package/src/plugins/builtin/treasury-auctions/after.ts +50 -23
- package/src/plugins/builtin/treasury-auctions/cache.ts +23 -5
- package/src/plugins/builtin/treasury-auctions/headless.ts +226 -37
- package/src/plugins/builtin/treasury-auctions/hk-headless.ts +11 -5
- package/src/plugins/builtin/treasury-auctions/hk-view.tsx +27 -25
- package/src/plugins/builtin/treasury-auctions/hk.ts +60 -8
- package/src/plugins/builtin/treasury-auctions/index.tsx +3 -0
- package/src/plugins/builtin/treasury-auctions/keys.ts +27 -0
- package/src/plugins/builtin/treasury-auctions/like.ts +137 -0
- package/src/plugins/builtin/treasury-auctions/model.ts +100 -22
- package/src/plugins/builtin/treasury-auctions/pane.tsx +39 -11
- package/src/plugins/builtin/vol-surface/heat-grid.tsx +6 -3
- package/src/plugins/builtin/vol-surface/pane.tsx +7 -3
- package/src/plugins/builtin/world-indices/index.tsx +5 -1
- package/src/plugins/builtin/yield-curve/index.tsx +2 -1
- package/src/plugins/runtime/index.tsx +1 -0
- package/src/plugins/runtime/state.ts +20 -0
- package/src/portfolio/column-values.ts +8 -2
- package/src/public/__snapshots__/public-api.test.ts.snap +5 -0
- package/src/public/react.ts +7 -0
- package/src/react/auto-refresh.ts +29 -0
- package/src/renderers/browser/deeplink-bridge.ts +24 -3
- package/src/renderers/dom/data-table/column-drag.ts +147 -0
- package/src/renderers/dom/data-table/index.tsx +22 -0
- package/src/renderers/dom/data-table/row.tsx +27 -5
- package/src/renderers/dom/desktop/query-bar.tsx +229 -60
- package/src/renderers/dom/host/overflow-fade-px.ts +2 -0
- package/src/renderers/dom/host/overflow-fade.ts +1 -2
- package/src/renderers/dom/styles.css +47 -5
- package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +2 -1
- package/src/renderers/opentui/chart-surface.tsx +1 -0
- package/src/renderers/opentui/frame-hits.ts +33 -0
- package/src/renderers/opentui/host.tsx +2 -0
- package/src/renderers/opentui/native-surface.ts +14 -21
- package/src/renderers/opentui/test-utils.tsx +3 -0
- package/src/series/types.ts +2 -0
- package/src/sources/gloomberb-cloud/fred-attribution.ts +86 -0
- package/src/sources/gloomberb-cloud/index.ts +25 -1
- package/src/sources/gloomberb-cloud/normalizers.ts +22 -3
- package/src/sources/provider-errors.ts +64 -1
- package/src/sources/provider-router/batches.ts +19 -0
- package/src/sources/provider-router/index.ts +7 -1
- package/src/state/app/context/index.tsx +46 -1
- package/src/state/pane-unsent-work.ts +47 -0
- package/src/test-support/app-store.ts +24 -1
- package/src/test-support/shell-pane-keys.tsx +5 -0
- package/src/test-support/telemetry-guard.ts +83 -0
- package/src/test-support/test-env.ts +12 -0
- package/src/theme/colors.ts +17 -1
- package/src/theme/ui-tokens.ts +50 -1
- package/src/tickers/listing-venues.ts +11 -1
- package/src/tickers/search/japanese-names.json +1 -0
- package/src/tickers/search/japanese-names.ts +152 -0
- package/src/tickers/terminal-codes.ts +55 -6
- package/src/time-series/base-series.ts +3 -0
- package/src/time-series/live-quotes.ts +3 -9
- package/src/types/data-provider.ts +6 -0
- package/src/types/financials.ts +11 -0
- package/src/types/plugin-contributions.ts +7 -0
- package/src/types/plugin-panes.ts +7 -0
- package/src/ui/host.tsx +24 -0
- package/src/ui/pointer-drag.ts +11 -2
- package/src/utils/double-escape-close.ts +42 -0
- package/src/utils/fundamentals.ts +14 -3
- package/src/utils/fx-status.ts +30 -7
- package/src/utils/network-failure.ts +23 -0
- package/src/utils/share-multiples.cases.json +780 -2
- package/src/utils/share-multiples.ts +154 -24
|
@@ -54,6 +54,12 @@ export interface DataTableCell {
|
|
|
54
54
|
*/
|
|
55
55
|
valueUnit?: string;
|
|
56
56
|
content?: ReactNode;
|
|
57
|
+
/**
|
|
58
|
+
* The cells `content` takes to show whole in the terminal, where a table
|
|
59
|
+
* fits its columns to what they hold before it cuts one or pushes one out of
|
|
60
|
+
* view. Without it a drawn cell's column keeps the width the pane set.
|
|
61
|
+
*/
|
|
62
|
+
contentWidth?: number;
|
|
57
63
|
/**
|
|
58
64
|
* Artwork drawn before `text` on the desktop and the web, such as a flag.
|
|
59
65
|
* It is decoration: the terminal does not draw it, and exports, automation
|
|
@@ -99,11 +105,48 @@ export interface DataTableSectionHeader {
|
|
|
99
105
|
};
|
|
100
106
|
}
|
|
101
107
|
|
|
108
|
+
/** How a table's columns move when the reader drags a header (`DataTableProps.columnReorder`). */
|
|
109
|
+
export interface DataTableColumnReorder {
|
|
110
|
+
/** How many leading columns stay first. Unset, the first column and the narrow marks before it (`rowAnchorColumnCount`). */
|
|
111
|
+
anchored?: number;
|
|
112
|
+
/**
|
|
113
|
+
* Names this table's remembered order, for a pane that shows several
|
|
114
|
+
* tables naming their rows with the same column whose other columns
|
|
115
|
+
* differ. Unset, the id of the column that names the row (the last
|
|
116
|
+
* anchored one).
|
|
117
|
+
*/
|
|
118
|
+
key?: string;
|
|
119
|
+
/**
|
|
120
|
+
* The pane's own ordered list of the columns it shows, for a pane whose
|
|
121
|
+
* settings choose and order them (an ordered-multi-select): a drag rewrites
|
|
122
|
+
* that list instead of keeping an order of its own, so Settings and the
|
|
123
|
+
* table agree.
|
|
124
|
+
*/
|
|
125
|
+
control?: {
|
|
126
|
+
order: readonly string[];
|
|
127
|
+
/**
|
|
128
|
+
* The list the pane shows while its setting is unset. Reset Columns puts
|
|
129
|
+
* the list back in this order (without it the pane menu offers none),
|
|
130
|
+
* and a list that comes out the same is `undefined` to `onChange`.
|
|
131
|
+
*/
|
|
132
|
+
defaultOrder?: readonly string[];
|
|
133
|
+
/** The list to keep, or undefined to remove the setting, so columns later added to the defaults reach the pane. */
|
|
134
|
+
onChange: (order: string[] | undefined) => void;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
102
138
|
/** Where `scrollToIndex` puts its row: the nearest edge, the middle, or the top of the viewport. */
|
|
103
139
|
export type DataTableScrollAlign = "nearest" | "center" | "start";
|
|
104
140
|
|
|
105
141
|
interface DataTableRowState {
|
|
106
142
|
selected: boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Terminal: the selected row's pane does not have the keys, so the row sits
|
|
145
|
+
* on the quieter fill (`inactiveSelectedBg`) in its own colours. A colour a
|
|
146
|
+
* cell picks for the selection is picked for that fill
|
|
147
|
+
* (`inactiveSelectedText`).
|
|
148
|
+
*/
|
|
149
|
+
inactive?: boolean;
|
|
107
150
|
}
|
|
108
151
|
|
|
109
152
|
export interface DataTableVisibleRange {
|
|
@@ -123,6 +166,19 @@ export interface DataTableProps<
|
|
|
123
166
|
sortDirection: "asc" | "desc";
|
|
124
167
|
/** Sorts by a column. Without it the header is plain labels and ignores clicks. */
|
|
125
168
|
onHeaderClick?: (columnId: string) => void;
|
|
169
|
+
/**
|
|
170
|
+
* Dragging a header moves its column (once the press moves a few pixels or
|
|
171
|
+
* two cells; a click still sorts, on the release rather than the press),
|
|
172
|
+
* and the pane remembers the order under `pane.columnOrder`: Reset
|
|
173
|
+
* Columns in the pane menu puts the pane's own back. The columns that name
|
|
174
|
+
* the row stay first. `false` keeps the pane's order, for columns that are
|
|
175
|
+
* one ordered axis (periods, tenors, strikes) or a fixed format.
|
|
176
|
+
*/
|
|
177
|
+
columnReorder?: false | DataTableColumnReorder;
|
|
178
|
+
/** Set by `DataTable` from `columnReorder` for the renderer: moves a column to an index. Absent where the order is fixed. */
|
|
179
|
+
onColumnMove?: (columnId: string, toIndex: number) => void;
|
|
180
|
+
/** Set by `DataTable` with `onColumnMove`: the leading columns a drag neither moves nor drops before. */
|
|
181
|
+
anchoredColumns?: number;
|
|
126
182
|
headerScrollRef: RefObject<ScrollBoxRenderable | null>;
|
|
127
183
|
scrollRef: RefObject<ScrollBoxRenderable | null>;
|
|
128
184
|
syncHeaderScroll: () => void;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { useCallback, useId, useMemo, useRef } from "react";
|
|
2
|
+
import { findPaneInstance } from "../../../types/config";
|
|
3
|
+
import {
|
|
4
|
+
useAppSelector,
|
|
5
|
+
useOptionalPaneInstanceId,
|
|
6
|
+
useOptionalPaneSettingUpdater,
|
|
7
|
+
} from "../../../state/app/context";
|
|
8
|
+
import { usePaneMenuItems } from "../../layout/pane/footer/registration";
|
|
9
|
+
import {
|
|
10
|
+
COLUMN_ORDER_SETTING,
|
|
11
|
+
defaultColumnOrder,
|
|
12
|
+
moveColumnId,
|
|
13
|
+
orderColumns,
|
|
14
|
+
readColumnOrders,
|
|
15
|
+
rememberColumnOrder,
|
|
16
|
+
rowAnchorColumnCount,
|
|
17
|
+
sameIds,
|
|
18
|
+
} from "./column-order";
|
|
19
|
+
import type { DataTableColumn, DataTableColumnReorder } from "./types";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A pane's column list to write, or undefined where it is the pane's own default
|
|
23
|
+
* list, so the pane's setting goes and columns later added to its defaults still
|
|
24
|
+
* reach it.
|
|
25
|
+
*/
|
|
26
|
+
function listOrDefault(order: string[], defaultOrder: readonly string[] | undefined): string[] | undefined {
|
|
27
|
+
return defaultOrder && sameIds(order, defaultOrder) ? undefined : order;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Joins a remembered order into one string, so the selector's value only changes when the order does. */
|
|
31
|
+
const ID_SEPARATOR = "\u0000";
|
|
32
|
+
|
|
33
|
+
export interface DataTableColumnOrder<C extends DataTableColumn> {
|
|
34
|
+
/** The columns in the order the reader left them. */
|
|
35
|
+
columns: C[];
|
|
36
|
+
/** Moves a column to an index of `columns`; absent where the order is fixed. */
|
|
37
|
+
onColumnMove?: (columnId: string, toIndex: number) => void;
|
|
38
|
+
anchoredColumns: number;
|
|
39
|
+
/** The reader has changed the order: Reset Columns has something to put back. */
|
|
40
|
+
customized: boolean;
|
|
41
|
+
reset: () => void;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A table's columns in the order its pane remembers, the move a header drag
|
|
46
|
+
* makes, and Reset Columns. The order is kept in the pane's settings, so it is
|
|
47
|
+
* saved and synced with the layout, per pane; a pane whose settings already
|
|
48
|
+
* order its columns passes them as `control` and the drag rewrites those
|
|
49
|
+
* instead. With `menu`, Reset Columns goes in the pane menu while the order
|
|
50
|
+
* is the reader's own; `DataTableView` lists it with the table's sort instead.
|
|
51
|
+
*/
|
|
52
|
+
export function useDataTableColumnOrder<C extends DataTableColumn>(
|
|
53
|
+
columns: readonly C[],
|
|
54
|
+
reorder: false | DataTableColumnReorder | undefined,
|
|
55
|
+
{ menu = true }: { menu?: boolean } = {},
|
|
56
|
+
): DataTableColumnOrder<C> {
|
|
57
|
+
const paneId = useOptionalPaneInstanceId();
|
|
58
|
+
const options = reorder === false ? null : reorder ?? {};
|
|
59
|
+
const control = options?.control;
|
|
60
|
+
const anchored = Math.min(columns.length, options?.anchored ?? rowAnchorColumnCount(columns));
|
|
61
|
+
// Kept under the column that names the row, so a mark before it that comes and goes with the width keeps the order.
|
|
62
|
+
const key = options?.key ?? columns[anchored - 1]?.id ?? columns[0]?.id ?? "";
|
|
63
|
+
const enabled = options !== null && (control !== undefined || paneId !== null) && columns.length - anchored >= 2;
|
|
64
|
+
const savedText = useAppSelector((state) => {
|
|
65
|
+
if (!enabled || control || !paneId) return null;
|
|
66
|
+
const ids = readColumnOrders(findPaneInstance(state.config.layout, paneId)?.settings?.[COLUMN_ORDER_SETTING])[key];
|
|
67
|
+
return ids ? ids.join(ID_SEPARATOR) : null;
|
|
68
|
+
});
|
|
69
|
+
const controlOrder = control?.order;
|
|
70
|
+
const saved = useMemo(
|
|
71
|
+
() => controlOrder ?? (savedText === null ? undefined : savedText.split(ID_SEPARATOR)),
|
|
72
|
+
[controlOrder, savedText],
|
|
73
|
+
);
|
|
74
|
+
const ordered = useMemo(
|
|
75
|
+
() => enabled ? orderColumns(columns, saved, anchored) : columns,
|
|
76
|
+
[anchored, columns, enabled, saved],
|
|
77
|
+
);
|
|
78
|
+
const updateSetting = useOptionalPaneSettingUpdater(paneId, COLUMN_ORDER_SETTING);
|
|
79
|
+
const latest = useRef({ columns, ordered, control, key, anchored });
|
|
80
|
+
latest.current = { columns, ordered, control, key, anchored };
|
|
81
|
+
|
|
82
|
+
const onColumnMove = useCallback((columnId: string, toIndex: number) => {
|
|
83
|
+
const current = latest.current;
|
|
84
|
+
const before = current.ordered.map((column) => column.id);
|
|
85
|
+
const after = moveColumnId(before, columnId, toIndex, current.anchored);
|
|
86
|
+
if (!after) return;
|
|
87
|
+
if (current.control) {
|
|
88
|
+
// Columns the pane adds on its own and does not list (a portfolio's target weights, its CCY column) stay
|
|
89
|
+
// out of the list and are drawn where the pane puts them. So a column dropped between two of them is
|
|
90
|
+
// written beside them in the list, and once they are drawn back in their own place it can land on their
|
|
91
|
+
// other side. Accepted: they follow the pane's rules, not the reader's order.
|
|
92
|
+
const { order, defaultOrder, onChange } = current.control;
|
|
93
|
+
const listed = new Set(order);
|
|
94
|
+
onChange(listOrDefault(rememberColumnOrder(order, before, after).filter((id) => listed.has(id)), defaultOrder));
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const defaults = current.columns.map((column) => column.id);
|
|
98
|
+
updateSetting((value) => {
|
|
99
|
+
const { [current.key]: previous, ...others } = readColumnOrders(value);
|
|
100
|
+
const next = rememberColumnOrder(previous, before, after);
|
|
101
|
+
// Dragged back to the pane's own order, with no other column's place to keep, it is forgotten.
|
|
102
|
+
const forget = sameIds(after, defaults) && next.every((id) => defaults.includes(id));
|
|
103
|
+
const orders = forget ? others : { ...others, [current.key]: next };
|
|
104
|
+
return Object.keys(orders).length > 0 ? orders : undefined;
|
|
105
|
+
});
|
|
106
|
+
}, [updateSetting]);
|
|
107
|
+
|
|
108
|
+
const reset = useCallback(() => {
|
|
109
|
+
const { control: current, key: tableKey } = latest.current;
|
|
110
|
+
if (!current) {
|
|
111
|
+
// Only this table's order: another table or tab in the pane keeps its own.
|
|
112
|
+
updateSetting((value) => {
|
|
113
|
+
const { [tableKey]: _reset, ...others } = readColumnOrders(value);
|
|
114
|
+
return Object.keys(others).length > 0 ? others : undefined;
|
|
115
|
+
});
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (current.defaultOrder) current.onChange(listOrDefault(defaultColumnOrder(current.order, current.defaultOrder), current.defaultOrder));
|
|
119
|
+
}, [updateSetting]);
|
|
120
|
+
|
|
121
|
+
const customized = enabled && (control
|
|
122
|
+
? !!control.defaultOrder && !sameIds(control.order, defaultColumnOrder(control.order, control.defaultOrder))
|
|
123
|
+
: ordered !== columns);
|
|
124
|
+
usePaneMenuItems(`data-table-columns:${useId()}`, () => menu && customized
|
|
125
|
+
? [{ id: "reset-columns", label: "Reset Columns", onSelect: reset }]
|
|
126
|
+
: null, [customized, menu, reset]);
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
columns: ordered as C[],
|
|
130
|
+
onColumnMove: enabled ? onColumnMove : undefined,
|
|
131
|
+
anchoredColumns: anchored,
|
|
132
|
+
customized,
|
|
133
|
+
reset,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
@@ -3,7 +3,7 @@ export { ListView } from "./list-view";
|
|
|
3
3
|
export type { ListViewItem, ListViewProps, ListRowState } from "./list-view";
|
|
4
4
|
|
|
5
5
|
export { DataTable } from "./data-table";
|
|
6
|
-
export type { DataTableCell, DataTableColumn, DataTableProps, DataTableVisibleRange } from "./data-table";
|
|
6
|
+
export type { DataTableCell, DataTableColumn, DataTableColumnReorder, DataTableProps, DataTableVisibleRange } from "./data-table";
|
|
7
7
|
|
|
8
8
|
export { Button, terminalButtonColumns } from "./button";
|
|
9
9
|
export { Icon, IconButton, ICON_GLYPHS } from "./icon";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useMemo, type ReactNode, type RefObject } from "react";
|
|
1
|
+
import { useEffect, useMemo, type ReactNode, type RefObject } from "react";
|
|
2
2
|
import { Box, Input, Text, useUiCapabilities, type InputRenderable } from "../../ui";
|
|
3
3
|
import { colors, placeholderText } from "../../theme/colors";
|
|
4
4
|
import { Icon } from "./icon";
|
|
@@ -25,6 +25,12 @@ export interface InlineQuickAddRowProps {
|
|
|
25
25
|
joinPastedLines?: PastedLines;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/** The terminal field's scrolled window over its text; a DOM input has none. */
|
|
29
|
+
interface FieldView {
|
|
30
|
+
getViewport?(): { offsetX: number; offsetY: number; width: number; height: number };
|
|
31
|
+
setViewport?(x: number, y: number, width: number, height: number): void;
|
|
32
|
+
}
|
|
33
|
+
|
|
28
34
|
/** Shared one-row composer used by pane-native inline add flows. */
|
|
29
35
|
export function InlineQuickAddRow({
|
|
30
36
|
value,
|
|
@@ -51,11 +57,21 @@ export function InlineQuickAddRow({
|
|
|
51
57
|
// A typed query hugs its preview unless the caller asked for a wider field.
|
|
52
58
|
// The cursor and the next keystroke both need a cell: a key lands before
|
|
53
59
|
// the field widens, and with one cell to spare the input scrolled its
|
|
54
|
-
// first character out of view (OMV.VI read "MV.VI").
|
|
55
|
-
|
|
60
|
+
// first character out of view (OMV.VI read "MV.VI"). The terminal field
|
|
61
|
+
// also keeps a fifth of its width clear after the cursor, so a longer
|
|
62
|
+
// symbol needs that much more (USDTRY=X read "SDTRY=X").
|
|
63
|
+
return Math.max(minInputWidth ?? 4, Math.min(maxInputWidth, queryWidth + 2 + Math.floor(queryWidth / 4)));
|
|
56
64
|
}
|
|
57
65
|
return Math.max(minInputWidth ?? 6, Math.min(10, Math.floor(width * 0.18)));
|
|
58
66
|
}, [maxInputWidth, minInputWidth, value, width]);
|
|
67
|
+
// A field that ran out of room scrolls its text, and keeps that scroll once the text fits again: keys typed
|
|
68
|
+
// faster than the field widens left USDTRY=X reading "SDTRY=X". Text that fits shows from its first character.
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
const view = (inputRef.current as { editorView?: FieldView } | null)?.editorView;
|
|
71
|
+
const viewport = view?.getViewport?.();
|
|
72
|
+
if (!viewport || viewport.offsetX === 0 || [...value].length >= inputWidth) return;
|
|
73
|
+
view?.setViewport?.(0, viewport.offsetY, inputWidth, viewport.height);
|
|
74
|
+
}, [inputRef, inputWidth, value]);
|
|
59
75
|
const hasPreview = preview !== undefined && preview !== null;
|
|
60
76
|
const previewWidth = Math.max(4, width - inputWidth - 5);
|
|
61
77
|
const { nativePaneChrome } = useUiCapabilities();
|
|
@@ -2,7 +2,8 @@ import { useThemeColors } from "../../theme/theme-context";
|
|
|
2
2
|
import { Box, ScrollBox, Text, useUiHost } from "../../ui";
|
|
3
3
|
import { useCallback, useEffect, useRef, useState, type ComponentType, type ReactNode } from "react";
|
|
4
4
|
import { TextAttributes, type ScrollBoxRenderable } from "../../ui";
|
|
5
|
-
import { hoverBg } from "../../theme/colors";
|
|
5
|
+
import { hoverBg, inactiveSelectedText } from "../../theme/colors";
|
|
6
|
+
import { useSelectionFill } from "./selection-fill";
|
|
6
7
|
import { t } from "../../i18n";
|
|
7
8
|
import { useRemoteUiNode, useRemoteUiScope } from "../../remote/semantic-tree";
|
|
8
9
|
import { resolveRemoteListIndex } from "../../remote/semantic-helpers";
|
|
@@ -145,11 +146,15 @@ export function listCursorMove(event: KeyboardModifierEventLike, pageSize: numbe
|
|
|
145
146
|
function DefaultRow({
|
|
146
147
|
item,
|
|
147
148
|
selected,
|
|
149
|
+
lit,
|
|
148
150
|
}: {
|
|
149
151
|
item: ListViewItem;
|
|
150
152
|
selected: boolean;
|
|
153
|
+
/** The selection is the one the keys move (`useSelectionFill`); off, the row's colours are lifted to read on the quieter fill. */
|
|
154
|
+
lit: boolean;
|
|
151
155
|
}) {
|
|
152
156
|
const colors = useThemeColors();
|
|
157
|
+
const ink = (color: string) => (selected && !lit ? inactiveSelectedText(color, colors) : color);
|
|
153
158
|
if (item.kind === "heading") return <Text fg={colors.textMuted}>{t(item.label)}</Text>;
|
|
154
159
|
// The label gives way to the detail: a long label is cut with an ellipsis
|
|
155
160
|
// instead of wrapping under the row or running into the right column.
|
|
@@ -160,7 +165,7 @@ function DefaultRow({
|
|
|
160
165
|
{selected ? "\u25b8 " : " "}
|
|
161
166
|
</Text>
|
|
162
167
|
<Text
|
|
163
|
-
fg={item.color ?? (selected ? colors.text : colors.textDim)}
|
|
168
|
+
fg={ink(item.color ?? (selected ? colors.text : colors.textDim))}
|
|
164
169
|
attributes={selected ? TextAttributes.BOLD : 0}
|
|
165
170
|
wrapMode="none"
|
|
166
171
|
truncate
|
|
@@ -172,7 +177,7 @@ function DefaultRow({
|
|
|
172
177
|
</Box>
|
|
173
178
|
{item.detail && (
|
|
174
179
|
<Box flexShrink={0} paddingLeft={1}>
|
|
175
|
-
<Text fg={colors.textMuted}>{t(item.detail)}</Text>
|
|
180
|
+
<Text fg={ink(colors.textMuted)}>{t(item.detail)}</Text>
|
|
176
181
|
</Box>
|
|
177
182
|
)}
|
|
178
183
|
</Box>
|
|
@@ -212,6 +217,7 @@ export function ListView({
|
|
|
212
217
|
remoteMetadata,
|
|
213
218
|
}: ListViewProps) {
|
|
214
219
|
const colors = useThemeColors();
|
|
220
|
+
const selectionFill = useSelectionFill();
|
|
215
221
|
// Drawn inside a prompt (a dialog that lists a prompt's answers), it carries the prompt's scope.
|
|
216
222
|
const contextScope = useRemoteUiScope();
|
|
217
223
|
useRemoteUiNode({
|
|
@@ -290,7 +296,7 @@ export function ListView({
|
|
|
290
296
|
const [hoveredIndex, setHoveredIndex] = useState<number | null>(null);
|
|
291
297
|
const scrollRef = useRef<ScrollBoxRenderable>(null);
|
|
292
298
|
const baseBg = bgColor ?? colors.bg;
|
|
293
|
-
const activeBg = selectedBgColor ??
|
|
299
|
+
const activeBg = selectedBgColor ?? selectionFill.bg;
|
|
294
300
|
const rowHoverBg = hoverBgColor ?? hoverBg(colors);
|
|
295
301
|
const selectedItem = selectedIndex >= 0 ? items[selectedIndex] : undefined;
|
|
296
302
|
const activeScrollIndex = scrollIndex ?? selectedIndex;
|
|
@@ -366,7 +372,7 @@ export function ListView({
|
|
|
366
372
|
>
|
|
367
373
|
{renderRow
|
|
368
374
|
? renderRow(item, state, index)
|
|
369
|
-
: <DefaultRow item={item} selected={selected} />}
|
|
375
|
+
: <DefaultRow item={item} selected={selected} lit={selectionFill.lit || selectedBgColor !== undefined} />}
|
|
370
376
|
</Box>
|
|
371
377
|
);
|
|
372
378
|
});
|
|
@@ -61,6 +61,12 @@ export interface QueryBarSelectFilter<T extends string = string> extends QueryBa
|
|
|
61
61
|
title?: string;
|
|
62
62
|
/** Draw the options inline (one click) instead of a menu. For four or fewer short values. */
|
|
63
63
|
inline?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Inline filters: a long list that runs past the bar's edge (expiries). On
|
|
66
|
+
* the desktop it is a strip that scrolls by itself, where other inline
|
|
67
|
+
* choices fold into their menu when the bar runs short of room.
|
|
68
|
+
*/
|
|
69
|
+
scrolls?: boolean;
|
|
64
70
|
/**
|
|
65
71
|
* The options are the range a chart in this pane shows (1D, 1Y, MAX). Choosing
|
|
66
72
|
* the one already selected sends the pane's charts back to it, as `0` does
|
|
@@ -84,7 +90,7 @@ export interface QueryBarMultiFilter extends QueryBarFilterBase {
|
|
|
84
90
|
export interface QueryBarToggleFilter extends QueryBarFilterBase {
|
|
85
91
|
kind: "toggle";
|
|
86
92
|
value: boolean;
|
|
87
|
-
/** A shorter label for the terminal's single row. */
|
|
93
|
+
/** A shorter label for the terminal's single row, and for a desktop bar short of room. */
|
|
88
94
|
short?: string;
|
|
89
95
|
onChange: (value: boolean) => void;
|
|
90
96
|
/**
|
|
@@ -123,6 +129,12 @@ export interface QueryBarView<T extends string = string> {
|
|
|
123
129
|
value: T;
|
|
124
130
|
options: readonly { value: T; label: string; hint?: string; disabled?: boolean }[];
|
|
125
131
|
onChange: (value: T) => void;
|
|
132
|
+
/**
|
|
133
|
+
* What the choice is ("Interval", "Sort"): its name for a screen reader, and
|
|
134
|
+
* its menu's on the desktop when a bar short of room folds it. A chart's range
|
|
135
|
+
* is "Range" and any other unnamed view "View".
|
|
136
|
+
*/
|
|
137
|
+
label?: string;
|
|
126
138
|
/** Terminal: left/right cycle the view while this is true. */
|
|
127
139
|
focused?: boolean;
|
|
128
140
|
shortcutScope?: string;
|
|
@@ -413,6 +425,7 @@ export function QueryBar({ width, search, filters = [], view, meta, asOf: given,
|
|
|
413
425
|
id: filter.id,
|
|
414
426
|
kind: "toggle",
|
|
415
427
|
label: filter.label,
|
|
428
|
+
short: filter.short,
|
|
416
429
|
valueLabel: filter.label,
|
|
417
430
|
narrowing: isNarrowing(filter),
|
|
418
431
|
checked: filter.value,
|
|
@@ -449,6 +462,7 @@ export function QueryBar({ width, search, filters = [], view, meta, asOf: given,
|
|
|
449
462
|
valueLabel: current?.short ?? current?.label ?? String(filter.value),
|
|
450
463
|
narrowing: isNarrowing(filter),
|
|
451
464
|
inline: filter.inline === true,
|
|
465
|
+
scrolls: filter.scrolls,
|
|
452
466
|
options: filter.options.map((option) => ({
|
|
453
467
|
value: option.value,
|
|
454
468
|
label: option.label,
|
|
@@ -500,6 +514,7 @@ export function QueryBar({ width, search, filters = [], view, meta, asOf: given,
|
|
|
500
514
|
else if (view.chartRange) resetChartView();
|
|
501
515
|
},
|
|
502
516
|
start: view.start,
|
|
517
|
+
label: view.label ?? (view.chartRange ? "Range" : undefined),
|
|
503
518
|
} : undefined}
|
|
504
519
|
onClearAll={narrowingCount >= 2 ? resetAll : undefined}
|
|
505
520
|
meta={meta}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { usePaneFocused } from "../../state/app/activity";
|
|
2
|
+
import { inactiveSelectedBg, inactiveSelectedText } from "../../theme/colors";
|
|
3
|
+
import { useThemeColors } from "../../theme/theme-context";
|
|
4
|
+
import { useUiCapabilities } from "../../ui/host";
|
|
5
|
+
|
|
6
|
+
export interface SelectionFill {
|
|
7
|
+
/** The chosen row's or tile's fill. */
|
|
8
|
+
bg: string;
|
|
9
|
+
/**
|
|
10
|
+
* The keys move this selection: the selected text colour goes with the fill.
|
|
11
|
+
* Off, the row keeps its own text colours on the quieter fill.
|
|
12
|
+
*/
|
|
13
|
+
lit: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* A colour of the chosen item's own drawn on the fill: as it is under the
|
|
16
|
+
* lit selection (which draws its own text colour where it has one), lifted
|
|
17
|
+
* where it would not read on the inactive fill.
|
|
18
|
+
*/
|
|
19
|
+
ink(color: string): string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The fill of a list's, table's or grid's chosen item in the terminal: the
|
|
24
|
+
* selection in the focused pane (and outside any pane, a dialog's list), the
|
|
25
|
+
* inactive selection in a pane that does not have the keyboard, so only one
|
|
26
|
+
* pane reads as the one the arrows move. The desktop marks focus its own way,
|
|
27
|
+
* so it keeps the selection.
|
|
28
|
+
*/
|
|
29
|
+
export function useSelectionFill(): SelectionFill {
|
|
30
|
+
const colors = useThemeColors();
|
|
31
|
+
const paneFocused = usePaneFocused();
|
|
32
|
+
const { nativePaneChrome } = useUiCapabilities();
|
|
33
|
+
const lit = nativePaneChrome === true || paneFocused !== false;
|
|
34
|
+
return {
|
|
35
|
+
bg: lit ? colors.selected : inactiveSelectedBg(colors),
|
|
36
|
+
lit,
|
|
37
|
+
ink: (color) => (lit ? color : inactiveSelectedText(color, colors)),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -321,6 +321,126 @@ export function hasMeaningfulTableHorizontalOverflow(
|
|
|
321
321
|
return viewportWidth > 0 && tableWidth - viewportWidth > columnGap;
|
|
322
322
|
}
|
|
323
323
|
|
|
324
|
+
/**
|
|
325
|
+
* The columns a terminal table drew, by its body's scroll box, while
|
|
326
|
+
* `fitTableColumns` has moved them from the widths the pane set: a sideways
|
|
327
|
+
* step and the column a table opens on go by the edges the reader sees.
|
|
328
|
+
*/
|
|
329
|
+
export const drawnTableColumns = new WeakMap<object, readonly TableWidthColumn[]>();
|
|
330
|
+
|
|
331
|
+
/** Cells handed out one at a time, left to right, to the columns still short of their target. */
|
|
332
|
+
function growColumns(widths: number[], targets: readonly number[], indexes: readonly number[], extra: number): number {
|
|
333
|
+
let left = extra;
|
|
334
|
+
while (left > 0) {
|
|
335
|
+
const short = indexes.filter((index) => widths[index]! < targets[index]!);
|
|
336
|
+
if (short.length === 0) break;
|
|
337
|
+
for (const index of short) {
|
|
338
|
+
if (left <= 0) break;
|
|
339
|
+
widths[index]! += 1;
|
|
340
|
+
left -= 1;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return left;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* The terminal table's columns as wide as the room and what they hold allow,
|
|
348
|
+
* before any column is cut or pushed out of view past the right edge.
|
|
349
|
+
* `contentWidths` is the widest text each column holds now, its header aside,
|
|
350
|
+
* or null where it draws something that cannot be measured (it keeps its set
|
|
351
|
+
* width). A table whose set widths fit (to its trailing gap) and cut nothing
|
|
352
|
+
* is left as set. Otherwise every column first gives up the blank past its
|
|
353
|
+
* text, down to its header and sort mark; a column that cuts its text then
|
|
354
|
+
* takes back what it needs while room is left, and the others take back
|
|
355
|
+
* their blank, a cell at a time. A column that grows (`flexGrow`) takes what
|
|
356
|
+
* is left after that, as it always did.
|
|
357
|
+
*
|
|
358
|
+
* When even that leaves columns past the edge, as many leading columns as fit
|
|
359
|
+
* whole beside the shortest form of the hint that says more follow
|
|
360
|
+
* (`edgeHint.least`) keep the room, or beside the table's padding without a
|
|
361
|
+
* hint. Their cut text takes what it needs first; then the hint's whole form
|
|
362
|
+
* (`edgeHint.whole`), unless a last column, a few cells of it then in view,
|
|
363
|
+
* would show them as cut text instead of the hint; then their blank, up to
|
|
364
|
+
* their set widths. The others wait past the edge at their narrowest.
|
|
365
|
+
*
|
|
366
|
+
* A fit that shows no more than the set widths do (no cut text longer, no
|
|
367
|
+
* column more in view) leaves the table as set.
|
|
368
|
+
*/
|
|
369
|
+
export function fitTableColumns<C extends TableWidthColumn>(
|
|
370
|
+
columns: readonly C[],
|
|
371
|
+
contentWidths: readonly (number | null)[],
|
|
372
|
+
viewportWidth: number,
|
|
373
|
+
columnGap = 1,
|
|
374
|
+
horizontalPadding = 1,
|
|
375
|
+
edgeHint: {
|
|
376
|
+
least: number;
|
|
377
|
+
whole: number;
|
|
378
|
+
/** How many leading columns these widths show whole beside the hint, as the table draws it. */
|
|
379
|
+
shownWhole?: (columns: readonly C[]) => number;
|
|
380
|
+
} = { least: 0, whole: 0 },
|
|
381
|
+
): C[] {
|
|
382
|
+
const set = normalizeTableColumns(columns);
|
|
383
|
+
if (viewportWidth <= 0 || set.length === 0) return set;
|
|
384
|
+
const floors = set.map((column) => (column.label ? Math.min(column.width, displayWidth(column.label) + HEADER_RESERVED_WIDTH) : 1));
|
|
385
|
+
const wants = set.map((column, index) => {
|
|
386
|
+
const content = contentWidths[index];
|
|
387
|
+
return content == null ? column.width : Math.max(floors[index]!, Math.ceil(content));
|
|
388
|
+
});
|
|
389
|
+
const cut = set.flatMap((column, index) => (wants[index]! > column.width ? [index] : []));
|
|
390
|
+
const room = Math.floor(viewportWidth);
|
|
391
|
+
const overflows = hasMeaningfulTableHorizontalOverflow(getTableWidth(set, columnGap, horizontalPadding), room, columnGap);
|
|
392
|
+
if (cut.length === 0 && !overflows) return set;
|
|
393
|
+
const widths = set.map((column, index) => Math.min(column.width, wants[index]!));
|
|
394
|
+
const sized = () => set.map((column, index) => (widths[index] === column.width ? column : { ...column, width: widths[index]! }));
|
|
395
|
+
const setWidths = set.map((column) => column.width);
|
|
396
|
+
const cutGrew = (indexes: readonly number[]) => indexes.some((index) => widths[index]! > setWidths[index]!);
|
|
397
|
+
let extra = room - getTableWidth(sized(), columnGap, horizontalPadding);
|
|
398
|
+
if (extra >= 0) {
|
|
399
|
+
extra = growColumns(widths, wants, cut, extra);
|
|
400
|
+
if (!overflows && !cutGrew(cut)) return set;
|
|
401
|
+
growColumns(widths, setWidths, set.map((_, index) => index), extra);
|
|
402
|
+
return sized();
|
|
403
|
+
}
|
|
404
|
+
// Where the first `count` columns end, without the blank after the last.
|
|
405
|
+
const prefixEnd = (count: number, columns: readonly C[] = sized()) => (
|
|
406
|
+
getTableWidth(columns.slice(0, count), columnGap, horizontalPadding) - columnGap - horizontalPadding
|
|
407
|
+
);
|
|
408
|
+
const least = edgeHint.least > 0 ? edgeHint.least : horizontalPadding;
|
|
409
|
+
// What the first `count` columns keep after them: the hint, or the padding, while columns follow; after the
|
|
410
|
+
// last its padding, unless the set widths already ran into it: the table runs no further past the edge.
|
|
411
|
+
const lastTail = Math.max(0, Math.min(horizontalPadding, room - prefixEnd(set.length, set)));
|
|
412
|
+
const tail = (count: number) => (count < set.length ? least : lastTail);
|
|
413
|
+
let count = 0;
|
|
414
|
+
while (count < set.length && prefixEnd(count + 1) + tail(count + 1) <= room) count += 1;
|
|
415
|
+
if (count === 0) return sized();
|
|
416
|
+
// The columns the set widths show whole, the last one's blank past it cut or not: a fit never shows fewer.
|
|
417
|
+
const shownWhole = edgeHint.shownWhole ?? ((columns: readonly C[]) => {
|
|
418
|
+
let shown = 0;
|
|
419
|
+
while (shown < set.length && prefixEnd(shown + 1, columns) + (shown + 1 < set.length ? least : 0) <= room) shown += 1;
|
|
420
|
+
return shown;
|
|
421
|
+
});
|
|
422
|
+
const setCount = shownWhole(set);
|
|
423
|
+
if (count < setCount) return set;
|
|
424
|
+
const shown = set.slice(0, count).map((_, index) => index);
|
|
425
|
+
extra = room - tail(count) - prefixEnd(count);
|
|
426
|
+
const shownCut = cut.filter((index) => index < count);
|
|
427
|
+
extra = growColumns(widths, wants, shownCut, extra);
|
|
428
|
+
if (count === setCount && !cutGrew(shownCut)) return set;
|
|
429
|
+
if (count < set.length) {
|
|
430
|
+
// Kept for the hint's whole form, a last column after them would have that many cells in view, which text
|
|
431
|
+
// shows cut rather than leave to the hint when they reach its label (hasColumnsPastRightEdge). With more
|
|
432
|
+
// columns past it the hint shows anyway.
|
|
433
|
+
const next = set[count]!;
|
|
434
|
+
const nextInView = edgeHint.whole - columnGap - tableColumnLeadGap(sized(), count, columnGap);
|
|
435
|
+
const nextShowsText = count === set.length - 1 && (next.align ?? "left") !== "right" && nextInView >= displayWidth(next.label ?? "");
|
|
436
|
+
const wholeHint = Math.max(0, edgeHint.whole - least);
|
|
437
|
+
if (edgeHint.least > 0 && wholeHint > 0 && extra >= wholeHint && !nextShowsText) extra -= wholeHint;
|
|
438
|
+
}
|
|
439
|
+
growColumns(widths, setWidths, shown, extra);
|
|
440
|
+
const fitted = sized();
|
|
441
|
+
return cutGrew(shownCut) || shownWhole(fitted) > setCount ? fitted : set;
|
|
442
|
+
}
|
|
443
|
+
|
|
324
444
|
export function expandTableColumns<C extends TableWidthColumn>(
|
|
325
445
|
columns: readonly C[],
|
|
326
446
|
targetWidth: number,
|
|
@@ -100,7 +100,8 @@ export function reduceLayoutAction(state: AppState, action: AppAction): AppState
|
|
|
100
100
|
state.focusedPaneId,
|
|
101
101
|
);
|
|
102
102
|
const target = currentConfig.layouts[action.index]!;
|
|
103
|
-
|
|
103
|
+
// A desk opens as it was saved: nothing on it was chosen in this session yet (pane-choices.ts).
|
|
104
|
+
return withFocusedPane({ ...state, paneChoices: undefined }, {
|
|
104
105
|
...currentConfig,
|
|
105
106
|
layout: cloneLayout(target.layout),
|
|
106
107
|
activeLayoutIndex: action.index,
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { AppState, PaneRuntimeState } from "./types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Which pane-state values were chosen in this session, as opposed to restored
|
|
5
|
+
* with a workspace: a start, a desk switch, a layout or a snapshot applied
|
|
6
|
+
* brings back what an earlier session chose. A write of the key in this
|
|
7
|
+
* session, by any route (a pick in the pane, a command, a link, a plugin) and
|
|
8
|
+
* even of the value it already holds, is the user asking for it.
|
|
9
|
+
*
|
|
10
|
+
* Some choices need Gloom Cloud Pro. Restored for an account without it, the
|
|
11
|
+
* pane shows its free default instead of a wall nobody asked for
|
|
12
|
+
* (`shownPaneChoice`), and keeps the saved choice for when the plan has Pro.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const NO_CHOICES: Readonly<Record<string, true>> = {};
|
|
16
|
+
|
|
17
|
+
/** The choice key of a plugin's pane-state value (`usePluginPaneState`). */
|
|
18
|
+
export function pluginChoiceKey(pluginId: string, key: string): string {
|
|
19
|
+
return `plugin:${pluginId}:${key}`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** `state` with `keys` of `paneId` marked as chosen in this session; the same object when they already were. */
|
|
23
|
+
export function withPaneChoices(state: AppState, paneId: string, keys: Iterable<string>): AppState {
|
|
24
|
+
const current = state.paneChoices?.[paneId] ?? NO_CHOICES;
|
|
25
|
+
let next: Record<string, true> | null = null;
|
|
26
|
+
for (const key of keys) {
|
|
27
|
+
if (current[key] || next?.[key]) continue;
|
|
28
|
+
next ??= { ...current };
|
|
29
|
+
next[key] = true;
|
|
30
|
+
}
|
|
31
|
+
return next ? { ...state, paneChoices: { ...state.paneChoices, [paneId]: next } } : state;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Every key a replaced pane state holds, its plugins' values included. */
|
|
35
|
+
export function paneStateChoiceKeys(paneState: PaneRuntimeState): string[] {
|
|
36
|
+
const keys = Object.keys(paneState);
|
|
37
|
+
for (const [pluginId, values] of Object.entries(paneState.pluginState ?? {})) {
|
|
38
|
+
for (const key of Object.keys(values ?? {})) keys.push(pluginChoiceKey(pluginId, key));
|
|
39
|
+
}
|
|
40
|
+
return keys;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** `state` with every pane-state value it holds marked as chosen now. */
|
|
44
|
+
export function withAllPaneChoices(state: AppState): AppState {
|
|
45
|
+
return Object.entries(state.paneState).reduce(
|
|
46
|
+
(current, [paneId, paneState]) => withPaneChoices(current, paneId, paneStateChoiceKeys(paneState)),
|
|
47
|
+
state,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function isPaneChoice(state: AppState, paneId: string, key: string): boolean {
|
|
52
|
+
return state.paneChoices?.[paneId]?.[key] === true;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* What a pane shows for its saved `value`: the value itself, except one only
|
|
57
|
+
* Pro opens (`proOnly`) restored for an account without Pro, which shows
|
|
58
|
+
* `fallback` until the user chooses it in this session. Nothing is rewritten:
|
|
59
|
+
* the same account after upgrading, or a Pro one, gets the saved value back.
|
|
60
|
+
*/
|
|
61
|
+
export function shownPaneChoice<T>(value: T, options: {
|
|
62
|
+
chosen: boolean;
|
|
63
|
+
hasProAccess: boolean;
|
|
64
|
+
proOnly: (value: T) => boolean;
|
|
65
|
+
fallback: T;
|
|
66
|
+
}): T {
|
|
67
|
+
return options.chosen || options.hasProAccess || !options.proOnly(value) ? value : options.fallback;
|
|
68
|
+
}
|