@stocksharp/trading-controls 0.1.0 → 1.1.0
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 +92 -6
- package/dist/esm/active-orders-widget.js +9 -0
- package/dist/esm/active-orders-widget.js.map +1 -1
- package/dist/esm/control-types.js +3 -0
- package/dist/esm/control-types.js.map +1 -1
- package/dist/esm/grid-menu.js +54 -0
- package/dist/esm/grid-menu.js.map +1 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/order-entry-widget.js +654 -0
- package/dist/esm/order-entry-widget.js.map +1 -0
- package/dist/esm/orderbook-depth.js +51 -0
- package/dist/esm/orderbook-depth.js.map +1 -0
- package/dist/esm/orderbook-widget.js +792 -0
- package/dist/esm/orderbook-widget.js.map +1 -0
- package/dist/esm/positions-widget.js +9 -0
- package/dist/esm/positions-widget.js.map +1 -1
- package/dist/esm/trade-history-widget.js +8 -0
- package/dist/esm/trade-history-widget.js.map +1 -1
- package/dist/esm/tradefeed-aggregator.js +58 -0
- package/dist/esm/tradefeed-aggregator.js.map +1 -0
- package/dist/esm/tradefeed-bubbles.js +131 -0
- package/dist/esm/tradefeed-bubbles.js.map +1 -0
- package/dist/esm/tradefeed-widget.js +692 -0
- package/dist/esm/tradefeed-widget.js.map +1 -0
- package/dist/esm/trading-host.js +2 -0
- package/dist/esm/trading-host.js.map +1 -1
- package/dist/esm/watchlist-widget.js +2 -0
- package/dist/esm/watchlist-widget.js.map +1 -1
- package/dist/sstradingcontrols.js +3346 -25
- package/dist/sstradingcontrols.js.map +3 -3
- package/dist/types/active-orders-widget.d.ts.map +1 -1
- package/dist/types/control-types.d.ts +3 -0
- package/dist/types/control-types.d.ts.map +1 -1
- package/dist/types/grid-menu.d.ts +4 -0
- package/dist/types/grid-menu.d.ts.map +1 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/order-entry-widget.d.ts +86 -0
- package/dist/types/order-entry-widget.d.ts.map +1 -0
- package/dist/types/orderbook-depth.d.ts +19 -0
- package/dist/types/orderbook-depth.d.ts.map +1 -0
- package/dist/types/orderbook-widget.d.ts +105 -0
- package/dist/types/orderbook-widget.d.ts.map +1 -0
- package/dist/types/positions-widget.d.ts.map +1 -1
- package/dist/types/trade-history-widget.d.ts.map +1 -1
- package/dist/types/tradefeed-aggregator.d.ts +15 -0
- package/dist/types/tradefeed-aggregator.d.ts.map +1 -0
- package/dist/types/tradefeed-bubbles.d.ts +39 -0
- package/dist/types/tradefeed-bubbles.d.ts.map +1 -0
- package/dist/types/tradefeed-widget.d.ts +78 -0
- package/dist/types/tradefeed-widget.d.ts.map +1 -0
- package/dist/types/trading-data.d.ts +22 -0
- package/dist/types/trading-data.d.ts.map +1 -1
- package/dist/types/trading-host.d.ts +8 -0
- package/dist/types/trading-host.d.ts.map +1 -1
- package/dist/types/watchlist-widget.d.ts.map +1 -1
- package/package.json +21 -2
- package/screenshots/panels.jpg +0 -0
- package/src/active-orders-widget.ts +9 -0
- package/src/control-types.ts +3 -0
- package/src/grid-menu.ts +67 -0
- package/src/index.ts +31 -0
- package/src/order-entry-widget.ts +733 -0
- package/src/orderbook-depth.ts +99 -0
- package/src/orderbook-widget.ts +896 -0
- package/src/positions-widget.ts +9 -0
- package/src/trade-history-widget.ts +8 -0
- package/src/tradefeed-aggregator.ts +95 -0
- package/src/tradefeed-bubbles.ts +194 -0
- package/src/tradefeed-widget.ts +744 -0
- package/src/trading-data.ts +168 -121
- package/src/trading-host.ts +326 -300
- package/src/watchlist-widget.ts +2 -0
- package/styles/theme.css +23 -0
- package/styles/trading-controls.css +911 -0
- package/translation-keys.json +103 -2
|
Binary file
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
import { cleanRejectReason, formatPrice, formatQty } from './formatters.js';
|
|
16
16
|
import { makeElement, makeIconButton, makePanelId, makePanelRoot } from './dom.js';
|
|
17
17
|
import { ControlTypes } from './control-types.js';
|
|
18
|
+
import { makeGridMenu } from './grid-menu.js';
|
|
18
19
|
import { TradingHost, assertHost } from './trading-host.js';
|
|
19
20
|
import type { OrderRow } from './trading-data.js';
|
|
20
21
|
import { DataGrid, GridColumn } from '@stocksharp/grids/source/data-grid';
|
|
@@ -158,6 +159,11 @@ export class ActiveOrdersWidget {
|
|
|
158
159
|
emptyText: this._host.t('NoActiveOrders'),
|
|
159
160
|
// Terminal rows are greyed out so the live ones stay visually prominent.
|
|
160
161
|
rowClass: (o) => ActiveOrdersWidget._rowClass(o),
|
|
162
|
+
contextMenu: makeGridMenu(this._host),
|
|
163
|
+
// Press to mark, drag or Shift to range, Ctrl to toggle, Ctrl+C
|
|
164
|
+
// to copy — all the grid's own; the press also claims the
|
|
165
|
+
// gesture from the browser's text selection.
|
|
166
|
+
selection: 'multi',
|
|
161
167
|
})
|
|
162
168
|
: null;
|
|
163
169
|
|
|
@@ -165,6 +171,9 @@ export class ActiveOrdersWidget {
|
|
|
165
171
|
}
|
|
166
172
|
|
|
167
173
|
dispose(): void {
|
|
174
|
+
// The grid holds document-level listeners (the copy shortcut) that
|
|
175
|
+
// outlive a removed subtree — it has to be told, not just detached.
|
|
176
|
+
this._grid?.destroy();
|
|
168
177
|
this._host.unregister(this);
|
|
169
178
|
try { this.rootEl.remove(); } catch { /* already detached */ }
|
|
170
179
|
}
|
package/src/control-types.ts
CHANGED
|
@@ -19,6 +19,9 @@ export const ControlTypes = {
|
|
|
19
19
|
ActiveOrders: 'activeOrders',
|
|
20
20
|
TradeHistory: 'tradeHistory',
|
|
21
21
|
Positions: 'positions',
|
|
22
|
+
OrderBook: 'orderbook',
|
|
23
|
+
TradeFeed: 'tradefeed',
|
|
24
|
+
OrderEntry: 'orderEntry',
|
|
22
25
|
} as const;
|
|
23
26
|
|
|
24
27
|
export type ControlType = typeof ControlTypes[keyof typeof ControlTypes];
|
package/src/grid-menu.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// The wording of the grid's context menu and its filter dialog.
|
|
2
|
+
//
|
|
3
|
+
// `@stocksharp/grids` draws the menu and speaks English by default; a control
|
|
4
|
+
// here says nothing in its own words, so every label is taken from `host.t()`
|
|
5
|
+
// and handed over through the grid's `contextMenu` option. Each blotter calls
|
|
6
|
+
// this at construction — the labels are read once per grid, which is the same
|
|
7
|
+
// lifetime as every other caption a control renders.
|
|
8
|
+
//
|
|
9
|
+
// Every key below is a literal on purpose: `translation-keys.json` is generated
|
|
10
|
+
// by scanning for them, and a computed key would be invisible to that scan and
|
|
11
|
+
// reach a user as itself.
|
|
12
|
+
import { TradingHost } from './trading-host.js';
|
|
13
|
+
import type { GridMenuOptions } from '@stocksharp/grids/source/data-grid';
|
|
14
|
+
|
|
15
|
+
/// The grid's `contextMenu` option, worded by the host. Generic over the row
|
|
16
|
+
/// type only because the option is; no label depends on it.
|
|
17
|
+
export function makeGridMenu<TRow>(host: TradingHost): GridMenuOptions<TRow> {
|
|
18
|
+
return {
|
|
19
|
+
labels: {
|
|
20
|
+
sortAsc: host.t('SortAscending'),
|
|
21
|
+
sortDesc: host.t('SortDescending'),
|
|
22
|
+
sortClear: host.t('ClearSort'),
|
|
23
|
+
hideColumn: host.t('HideColumn'),
|
|
24
|
+
showAllColumns: host.t('ShowAllColumns'),
|
|
25
|
+
groupBy: host.t('GroupByColumn'),
|
|
26
|
+
ungroup: host.t('Ungroup'),
|
|
27
|
+
filterByValue: (text) => host.t('Filter by this value: {0}', text),
|
|
28
|
+
filterRule: host.t('FilterRule'),
|
|
29
|
+
showFilters: host.t('ShowFilterRow'),
|
|
30
|
+
hideFilters: host.t('HideFilterRow'),
|
|
31
|
+
showHeader: host.t('ShowHeaderRow'),
|
|
32
|
+
hideHeader: host.t('HideHeaderRow'),
|
|
33
|
+
clearFilters: host.t('ClearFilters'),
|
|
34
|
+
copyCell: host.t('CopyCell'),
|
|
35
|
+
copyRow: host.t('CopyRow'),
|
|
36
|
+
copyRows: (count) => host.t('Copy selected rows ({0})', count),
|
|
37
|
+
exportXlsx: host.t('ExportToXlsx'),
|
|
38
|
+
},
|
|
39
|
+
filterDialog: {
|
|
40
|
+
labels: {
|
|
41
|
+
title: (header) => host.t('Filter: {0}', header),
|
|
42
|
+
apply: host.t('Apply'),
|
|
43
|
+
clear: host.t('Clear'),
|
|
44
|
+
cancel: host.t('Cancel'),
|
|
45
|
+
value: host.t('Value'),
|
|
46
|
+
and: host.t('FilterAnd'),
|
|
47
|
+
ops: {
|
|
48
|
+
contains: host.t('FilterOpContains'),
|
|
49
|
+
notContains: host.t('FilterOpNotContains'),
|
|
50
|
+
startsWith: host.t('FilterOpStartsWith'),
|
|
51
|
+
endsWith: host.t('FilterOpEndsWith'),
|
|
52
|
+
eq: host.t('FilterOpEq'),
|
|
53
|
+
ne: host.t('FilterOpNe'),
|
|
54
|
+
gt: host.t('FilterOpGt'),
|
|
55
|
+
ge: host.t('FilterOpGe'),
|
|
56
|
+
lt: host.t('FilterOpLt'),
|
|
57
|
+
le: host.t('FilterOpLe'),
|
|
58
|
+
between: host.t('FilterOpBetween'),
|
|
59
|
+
anyOf: host.t('FilterOpAnyOf'),
|
|
60
|
+
noneOf: host.t('FilterOpNoneOf'),
|
|
61
|
+
empty: host.t('FilterOpEmpty'),
|
|
62
|
+
notEmpty: host.t('FilterOpNotEmpty'),
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -50,3 +50,34 @@ export type { TradeHistoryDeps } from './trade-history-widget.js';
|
|
|
50
50
|
export { WatchlistWidget } from './watchlist-widget.js';
|
|
51
51
|
|
|
52
52
|
export type { WatchlistDeps } from './watchlist-widget.js';
|
|
53
|
+
|
|
54
|
+
export { OrderEntrySides, OrderEntryTypes, OrderEntryWidget } from './order-entry-widget.js';
|
|
55
|
+
|
|
56
|
+
export type { OrderEntryDeps, OrderEntrySide, OrderEntryType, OrderEntryValues } from './order-entry-widget.js';
|
|
57
|
+
|
|
58
|
+
export type { InstrumentSpec } from './trading-data.js';
|
|
59
|
+
|
|
60
|
+
export { OrderBookWidget } from './orderbook-widget.js';
|
|
61
|
+
|
|
62
|
+
export type { OrderBookDeps, OrderBookView } from './orderbook-widget.js';
|
|
63
|
+
|
|
64
|
+
export type { BookLevel, OrderBookFrame, QuoteLevel } from './trading-data.js';
|
|
65
|
+
|
|
66
|
+
// The palette a host answers with for the parts a control draws on a canvas,
|
|
67
|
+
// where a class name cannot reach.
|
|
68
|
+
export type { CanvasPalette } from './trading-host.js';
|
|
69
|
+
|
|
70
|
+
export { TradeFeedWidget } from './tradefeed-widget.js';
|
|
71
|
+
|
|
72
|
+
export type { TradeFeedDeps } from './tradefeed-widget.js';
|
|
73
|
+
|
|
74
|
+
// The tape's own shapes: one print as the chart reads it, and the bubble a
|
|
75
|
+
// print (or a slice of them) is drawn as. A host that renders its own view of
|
|
76
|
+
// the same feed reads these rather than reinventing the compaction.
|
|
77
|
+
export { aggregateBubbles } from './tradefeed-aggregator.js';
|
|
78
|
+
|
|
79
|
+
export type { FeedBubble, FeedTick } from './tradefeed-aggregator.js';
|
|
80
|
+
|
|
81
|
+
export { layoutBubbles } from './tradefeed-bubbles.js';
|
|
82
|
+
|
|
83
|
+
export type { BubbleAxisTick, BubbleLane, BubbleLaneShape, BubbleLayout, BubbleLayoutInput, BubbleShape } from './tradefeed-bubbles.js';
|