@nsshunt/stsui 1.3.14 → 1.3.18

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 CHANGED
@@ -1 +1,2 @@
1
- # stsui
1
+ # stsui
2
+ # Test
package/menubar.js CHANGED
@@ -2,11 +2,11 @@ var blessed = require('blessed');
2
2
 
3
3
  class MenuBar
4
4
  {
5
- #listb = null;
5
+ #listb = null;
6
6
 
7
- // options := { screen: <blessed screen>, top: <bool>, menuitems: [ { text: <string>, key: <string>, cb: <call back func> } ] }
8
- constructor(screen, options)
9
- {
7
+ // options := { screen: <blessed screen>, top: <bool>, menuitems: [ { text: <string>, key: <string>, cb: <call back func> } ] }
8
+ constructor(screen, options)
9
+ {
10
10
  let compoptions = { };
11
11
 
12
12
  if (options.top === true)
@@ -54,12 +54,12 @@ class MenuBar
54
54
  }
55
55
 
56
56
  this.#listb = blessed.listbar(compoptions);
57
- }
57
+ }
58
58
 
59
- get listbar()
60
- {
59
+ get listbar()
60
+ {
61
61
  return this.#listb;
62
- }
62
+ }
63
63
  }
64
64
 
65
65
  module.exports = { MenuBar };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nsshunt/stsui",
3
- "version": "1.3.14",
3
+ "version": "1.3.18",
4
4
  "description": "",
5
5
  "main": "stsui.js",
6
6
  "scripts": {
@@ -22,11 +22,11 @@
22
22
  },
23
23
  "homepage": "https://github.com/nsshunt/stsui#readme",
24
24
  "devDependencies": {
25
- "@babel/core": "^7.15.8",
26
- "@babel/eslint-parser": "^7.15.8",
27
- "@babel/plugin-proposal-class-properties": "^7.14.5",
28
- "@babel/plugin-proposal-private-methods": "^7.14.5",
29
- "eslint": "^8.1.0",
25
+ "@babel/core": "^7.16.0",
26
+ "@babel/eslint-parser": "^7.16.3",
27
+ "@babel/plugin-proposal-class-properties": "^7.16.0",
28
+ "@babel/plugin-proposal-private-methods": "^7.16.0",
29
+ "eslint": "^8.3.0",
30
30
  "jest": "^27.3.1"
31
31
  },
32
32
  "dependencies": {
package/stsuiframe.js CHANGED
@@ -9,16 +9,16 @@ const { v4: uuidv4 } = require('uuid');
9
9
  *
10
10
  */
11
11
  class STSUIFrame extends EventEmitter {
12
- #uiBox = {}; // { box: <<blessed box>>, boxHeader: <<blessed box>> }
13
- #screen = null;
14
- #uidata = null;
12
+ #uiBox = {}; // { box: <<blessed box>>, boxHeader: <<blessed box>> }
13
+ #screen = null;
14
+ #uidata = null;
15
15
  #cursor = 0; // panel index with the complete model data.
16
16
  #cursorInfo = null;
17
17
  #renderPanelFn = null;
18
18
  #screenHeaderText = '...';
19
19
 
20
- #minRows = 2;
21
- #minCols = 2;
20
+ #minRows = 1;
21
+ #minCols = 1;
22
22
  #minWidth = 40;
23
23
  #minHeight = 7;
24
24
 
@@ -39,12 +39,12 @@ class STSUIFrame extends EventEmitter {
39
39
  this.SetupUI();
40
40
  }
41
41
 
42
- /**
42
+ /**
43
43
  *
44
44
  * @param {number} position The index (0 based) for the panel item to be calculated
45
45
  * @returns object with top, left, width and height correctly set
46
46
  */
47
- #CalcBoxPos = (panel) => {
47
+ #CalcBoxPos = (panel) => {
48
48
  // Calculate the position and dimensions for this UI element
49
49
 
50
50
  let screenHeight = this.#screen.height;
@@ -91,7 +91,7 @@ class STSUIFrame extends EventEmitter {
91
91
  }
92
92
 
93
93
  return { top: top, left: left, width: width, height: height };
94
- }
94
+ }
95
95
 
96
96
  #UpdateUIBoxPos = (panel, uiBox) =>
97
97
  {
@@ -120,14 +120,14 @@ class STSUIFrame extends EventEmitter {
120
120
  }
121
121
  };
122
122
 
123
- /**
123
+ /**
124
124
  * ReSize the grid layout
125
125
  */
126
- #ReSize = () => {
126
+ #ReSize = () => {
127
127
  for (const [, value] of Object.entries(this.#uiBox)) {
128
128
  this.#UpdateUIBoxPos(value.box.get('panel'), value);
129
129
  }
130
- }
130
+ }
131
131
 
132
132
  #UpdatePanelPosition = (panel, row, col, uiBox) => {
133
133
  // Update the panel position within the current screen view
@@ -136,11 +136,11 @@ class STSUIFrame extends EventEmitter {
136
136
  uiBox.boxHeader.setContent(panel.panelHeader);
137
137
  }
138
138
 
139
- /**
139
+ /**
140
140
  *
141
141
  * Setup all panels
142
142
  */
143
- #SetupPanels() {
143
+ #SetupPanels() {
144
144
  let panelKeys = Object.keys(this.#uidata.panels);
145
145
 
146
146
  // Check for deleted panels
@@ -157,6 +157,8 @@ class STSUIFrame extends EventEmitter {
157
157
  }
158
158
  }
159
159
 
160
+ let touched = { };
161
+
160
162
  for (let i=0; i < (this.#uidata.grid.cols * this.#uidata.grid.rows); i++)
161
163
  {
162
164
  let gridPos = this.#cursor + i;
@@ -244,49 +246,69 @@ class STSUIFrame extends EventEmitter {
244
246
  box.set('panel', panel);
245
247
 
246
248
  this.#uiBox[panel.id].box = box;
249
+
250
+ touched[panel.id] = true;
251
+
247
252
  } else {
253
+ //@@ need to hide previous positions
254
+ //@@ and show ones that are visible
248
255
  this.#UpdatePanelPosition(panel, row, col, this.#uiBox[panel.id]);
256
+
257
+ touched[panel.id] = true;
258
+ //this.#uiBox[panel.id].box.show();
249
259
  }
250
260
 
251
261
  // Render the uiBox with the renderPanelFn using the panel as the utility including the model
252
262
  this.#renderPanelFn(this.#uiBox[panel.id].box, panel);
253
263
  }
254
264
  }
255
- };
256
265
 
257
- get gridData() {
266
+ for (const [key, ] of Object.entries(this.#uiBox)) {
267
+ if (typeof touched[key] === 'undefined')
268
+ {
269
+ this.#uiBox[key].box.hide();
270
+ this.#uiBox[key].boxHeader.hide();
271
+ } else {
272
+ this.#uiBox[key].box.show();
273
+ this.#uiBox[key].boxHeader.show();
274
+ }
275
+ }
276
+
277
+ }
278
+
279
+ get gridData() {
258
280
  return this.#uidata;
259
- }
281
+ }
260
282
 
261
- set gridData(gridData) {
283
+ set gridData(gridData) {
262
284
  this.#uidata = gridData;
263
285
  this.#SetupPanels();
264
286
  this.UpdateCursorInfo();
265
287
  this.#screen.render();
266
- }
288
+ }
267
289
 
268
- get gridDataPanels() {
290
+ get gridDataPanels() {
269
291
  return this.#uidata.panels;
270
- }
292
+ }
271
293
 
272
- set gridDataPanels(gridDataPanels) {
294
+ set gridDataPanels(gridDataPanels) {
273
295
  this.#uidata.panels = gridDataPanels;
274
296
  this.#SetupPanels();
275
297
  this.UpdateCursorInfo();
276
298
  this.#screen.render();
277
- }
299
+ }
278
300
 
279
- // https://www.npmjs.com/package/blessed
301
+ // https://www.npmjs.com/package/blessed
280
302
 
281
- // data:= { title: <str>,
282
- // grid: { rows: <int>, cols: <int> },
283
- // menu: [ { top: <bool>, menuitems: [ { text: <string>, key: <string>, cb: <func> } ] } ]
284
- // panels: [ { id: <str>, pos: { row: <int>, col: <int>, rowSpan: <int>, colSpan: <int> }, template: <str> } ] }
285
- /**
303
+ // data:= { title: <str>,
304
+ // grid: { rows: <int>, cols: <int> },
305
+ // menu: [ { top: <bool>, menuitems: [ { text: <string>, key: <string>, cb: <func> } ] } ]
306
+ // panels: [ { id: <str>, pos: { row: <int>, col: <int>, rowSpan: <int>, colSpan: <int> }, template: <str> } ] }
307
+ /**
286
308
  *
287
309
  * @param {*} data UI Data
288
310
  */
289
- SetupUI = () => {
311
+ SetupUI = () => {
290
312
  this.DestroyUI();
291
313
 
292
314
  if (this.#screen === null) {
@@ -384,7 +406,7 @@ class STSUIFrame extends EventEmitter {
384
406
 
385
407
  // Render the screen.
386
408
  this.#screen.render();
387
- }
409
+ }
388
410
 
389
411
  UpdateCursorInfo = () =>
390
412
  {
@@ -402,6 +424,16 @@ class STSUIFrame extends EventEmitter {
402
424
  this.#screenHeader.setContent(`[ ${screenHeaderText} ]`);
403
425
  }
404
426
 
427
+ get rows()
428
+ {
429
+ return this.#uidata.grid.rows;
430
+ }
431
+
432
+ get cols()
433
+ {
434
+ return this.#uidata.grid.cols;
435
+ }
436
+
405
437
  IncRows = () =>
406
438
  {
407
439
  if (this.#screen.height / (this.#uidata.grid.rows+1) > this.#minHeight)
@@ -503,24 +535,24 @@ class STSUIFrame extends EventEmitter {
503
535
  this.emit('exit');
504
536
  }
505
537
 
506
- /**
538
+ /**
507
539
  *
508
540
  */
509
- DestroyUI = () => {
541
+ DestroyUI = () => {
510
542
  // Destroy the screen and disable UI log processing
511
543
  if (this.#screen !== null) {
512
544
  this.#uiBox = { };
513
545
  this.#screen.destroy();
514
546
  this.#screen = null;
515
547
  }
516
- }
548
+ }
517
549
 
518
- /**
550
+ /**
519
551
  * Render the screen.
520
552
  */
521
- Render = () => {
553
+ Render = () => {
522
554
  this.#screen.render();
523
- }
555
+ }
524
556
  }
525
557
 
526
558
  module.exports = { STSUIFrame };