@stocksharp/trading-controls 1.4.0 → 1.5.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.
@@ -4,6 +4,8 @@ import { DataGrid, GridColumn } from '@stocksharp/grids/data-grid';
4
4
  export interface LogMonitorDeps {
5
5
  host: TradingHost;
6
6
  maxMessages?: number;
7
+ chrome?: boolean;
8
+ sources?: boolean;
7
9
  }
8
10
  export declare class LogMonitorWidget {
9
11
  static TYPE: "logMonitor";
@@ -23,12 +25,14 @@ export declare class LogMonitorWidget {
23
25
  _selected: string | null;
24
26
  _grid: DataGrid<LogMessageRow> | null;
25
27
  static create(hostEl: HTMLElement, state: Record<string, unknown>, deps: LogMonitorDeps): LogMonitorWidget;
26
- static _buildRoot(host: TradingHost): HTMLElement;
28
+ static _buildRoot(host: TradingHost, chrome: boolean, sources: boolean): HTMLElement;
27
29
  constructor(rootEl: HTMLElement, _state: Record<string, unknown>, deps: LogMonitorDeps);
28
30
  dispose(): void;
29
31
  setSources(sources: LogSourceNode[]): void;
30
32
  append(messages: LogMessageRow[]): void;
31
33
  clear(): void;
34
+ sourcesShown(): boolean;
35
+ showSources(on: boolean): void;
32
36
  select(sourceId: string | null): void;
33
37
  visible(): LogMessageRow[];
34
38
  _render(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"log-monitor-widget.d.ts","sourceRoot":"","sources":["../../src/log-monitor-widget.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAc,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAEY,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,KAAK,WAAW,EAC1E,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAG1E,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,WAAW,CAAC;IAGlB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAmBD,qBAAa,gBAAgB;IAC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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stocksharp/trading-controls",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Browser trading controls for StockSharp: order blotters, positions, trade history, watchlist and trade feed, each built against one host port and rendering its own DOM.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": {
@@ -24,6 +24,15 @@ export interface LogMonitorDeps {
24
24
  /// How many messages to keep. Older ones fall off the front. Defaults to 5000 - enough to
25
25
  /// scroll back through a session, small enough that a chatty connector cannot fill a tab.
26
26
  maxMessages?: number;
27
+ /// Whether the panel draws its own title bar and close button. Defaults to true. A host that
28
+ /// already titles the panel and closes it from elsewhere - a dock tab, say - turns this off,
29
+ /// so the title is not said twice and no button offers a close that leads somewhere else.
30
+ chrome?: boolean;
31
+ /// Whether the source tree starts out shown. Defaults to true. A consumer whose log has one
32
+ /// writer has nothing to choose between, and the fixed-width column is space the messages
33
+ /// need. This is the initial state only — the reader can bring the tree back from the grid's
34
+ /// context menu, so a session that grows a second writer is not stuck without it.
35
+ sources?: boolean;
27
36
  }
28
37
 
29
38
  const DEFAULT_MAX = 5_000;
@@ -65,7 +74,7 @@ export class LogMonitorWidget {
65
74
 
66
75
  static create(hostEl: HTMLElement, state: Record<string, unknown>, deps: LogMonitorDeps): LogMonitorWidget {
67
76
  const host = assertHost(deps?.host, 'LogMonitorWidget');
68
- const root = LogMonitorWidget._buildRoot(host);
77
+ const root = LogMonitorWidget._buildRoot(host, deps?.chrome !== false, deps?.sources !== false);
69
78
  root.id = makePanelId(LogMonitorWidget.TYPE);
70
79
  hostEl.appendChild(root);
71
80
  return new LogMonitorWidget(root, state || {}, deps);
@@ -74,13 +83,16 @@ export class LogMonitorWidget {
74
83
  // The panel's markup: a source tree, a toolbar of level toggles and a text box, and the
75
84
  // message table. The level toggles are buttons rather than checkboxes because they are read
76
85
  // as a row of states, and each carries its letter so the toolbar and the column agree.
77
- static _buildRoot(host: TradingHost): HTMLElement {
86
+ static _buildRoot(host: TradingHost, chrome: boolean, sources: boolean): HTMLElement {
78
87
  const title = host.t('LogMonitor');
79
- return makePanelRoot('log-monitor-panel', title, [
80
- makeElement('div', 'panel-header', {}, [
88
+ const header = chrome
89
+ ? [makeElement('div', 'panel-header', {}, [
81
90
  makeElement('span', '', {}, [title]),
82
91
  makeIconButton('bt-icon-btn bt-icon-cancel panel-close-btn', host.t('ClosePanel'), 'bi-x', { type: 'button' }),
83
- ]),
92
+ ])]
93
+ : [];
94
+ return makePanelRoot(`log-monitor-panel${sources ? '' : ' log-sources-off'}`, title, [
95
+ ...header,
84
96
  makeElement('div', 'panel-body log-monitor-body', {}, [
85
97
  makeElement('div', 'log-sources', { role: 'tree', 'aria-label': host.t('LogSources') }, []),
86
98
  makeElement('div', 'log-messages', {}, [
@@ -164,7 +176,16 @@ export class LogMonitorWidget {
164
176
  rowKey: (m) => String(m.id),
165
177
  emptyText: this._host.t('NoLogMessages'),
166
178
  rowClass: (m) => `log-row log-row-${m.level}`,
167
- contextMenu: makeGridMenu(this._host),
179
+ contextMenu: {
180
+ ...makeGridMenu<LogMessageRow>(this._host),
181
+ // The tree is worth its width when several things write to the log and worth
182
+ // nothing when one does, and which of those is true changes with the session.
183
+ // So it is a choice the reader makes here, next to the other column choices.
184
+ items: (_context, defaults) => [
185
+ ...defaults,
186
+ { label: this._host.t('LogSources'), checked: this.sourcesShown(), run: () => this.showSources(!this.sourcesShown()) },
187
+ ],
188
+ },
168
189
  selection: 'multi',
169
190
  })
170
191
  : null;
@@ -202,6 +223,17 @@ export class LogMonitorWidget {
202
223
  this._render();
203
224
  }
204
225
 
226
+ /// Whether the source tree is currently drawn.
227
+ sourcesShown(): boolean {
228
+ return !this.rootEl.classList.contains('log-sources-off');
229
+ }
230
+
231
+ /// Show or hide the source tree. Hiding it does not drop the filter that is set: the
232
+ /// messages stay filtered by whatever was selected, which is what the reader last asked for.
233
+ showSources(on: boolean): void {
234
+ this.rootEl.classList.toggle('log-sources-off', !on);
235
+ }
236
+
205
237
  /// Show one source's subtree, or everything when given null.
206
238
  select(sourceId: string | null): void {
207
239
  this._selected = sourceId;
@@ -1398,6 +1398,12 @@
1398
1398
  overflow: hidden;
1399
1399
  }
1400
1400
 
1401
+ /* The tree is hidden rather than dropped, so the menu can bring it back without the panel
1402
+ being rebuilt and the selection it holds surviving the round trip. */
1403
+ .log-monitor-panel.log-sources-off .log-sources {
1404
+ display: none;
1405
+ }
1406
+
1401
1407
  .log-sources {
1402
1408
  flex: 0 0 14rem;
1403
1409
  min-height: 0;