neo.mjs 8.33.0 → 8.35.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.
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='8.33.0'
23
+ * @member {String} version='8.35.0'
24
24
  */
25
- version: '8.33.0'
25
+ version: '8.35.0'
26
26
  }
27
27
 
28
28
  /**
@@ -42,15 +42,16 @@ class GridContainer extends BaseGridContainer {
42
42
  dataField: 'change',
43
43
  locale : 'en-US',
44
44
  text : 'Change',
45
- type : 'currency',
45
+ type : 'animatedCurrency',
46
46
  width : 120
47
47
  }, {
48
- cellAlign: 'right',
49
- dataField: 'value',
50
- locale : 'en-US',
51
- text : 'Value',
52
- type : 'currency',
53
- width : 120
48
+ cellAlign : 'right',
49
+ compareField: 'change',
50
+ dataField : 'value',
51
+ locale : 'en-US',
52
+ text : 'Value',
53
+ type : 'animatedCurrency',
54
+ width : 120
54
55
  }]
55
56
  }
56
57
  }
@@ -1,5 +1,6 @@
1
1
  import BaseViewport from '../../../src/container/Viewport.mjs';
2
2
  import GridContainer from './GridContainer.mjs';
3
+ import Toolbar from '../../../src/toolbar/Base.mjs';
3
4
  import ViewportController from './ViewportController.mjs';
4
5
  import ViewportStateProvider from './ViewportStateProvider.mjs';
5
6
 
@@ -18,17 +19,10 @@ class Viewport extends BaseViewport {
18
19
  * @member {Neo.controller.Component} controller=ViewportController
19
20
  */
20
21
  controller: ViewportController,
21
- /**
22
- * @member {Object[]} items
23
- */
24
- items: [{
25
- module : GridContainer,
26
- reference: 'grid'
27
- }],
28
22
  /*
29
- * @member {Object} layout={ntype:'fit'}
23
+ * @member {Object} layout={ntype:'vbox',align:'stretch'}
30
24
  */
31
- layout: {ntype: 'fit'},
25
+ layout: {ntype: 'vbox', align: 'stretch'},
32
26
  /**
33
27
  * @member {Neo.state.Provider} stateProvider=ViewportStateProvider
34
28
  */
@@ -36,7 +30,30 @@ class Viewport extends BaseViewport {
36
30
  /**
37
31
  * @member {Object} style
38
32
  */
39
- style: {padding: '2em'}
33
+ style: {padding: '1.5em'},
34
+ /**
35
+ * @member {Object[]} items
36
+ */
37
+ items: [{
38
+ module: Toolbar,
39
+ flex : 'none',
40
+ style : {marginBottom: '1.5em'},
41
+
42
+ items : [{
43
+ disabled : true,
44
+ handler : 'onStartButtonClick',
45
+ reference: 'start-button',
46
+ text : 'Start'
47
+ }, {
48
+ handler : 'onStopButtonClick',
49
+ reference: 'stop-button',
50
+ style : {marginLeft: '.3em'},
51
+ text : 'Stop'
52
+ }]
53
+ }, {
54
+ module : GridContainer,
55
+ reference: 'grid'
56
+ }]
40
57
  }
41
58
  }
42
59
 
@@ -13,6 +13,20 @@ class ViewportController extends Controller {
13
13
  className: 'Finance.view.ViewportController'
14
14
  }
15
15
 
16
+ /**
17
+ * @member {Number|null} intervalId=null
18
+ */
19
+ intervalId = null
20
+
21
+ /**
22
+ *
23
+ */
24
+ generateData() {
25
+ let me = this;
26
+
27
+ me.intervalId = setInterval(me.updateRecord.bind(me), 4)
28
+ }
29
+
16
30
  /**
17
31
  *
18
32
  */
@@ -28,7 +42,47 @@ class ViewportController extends Controller {
28
42
  })
29
43
  });
30
44
 
31
- this.getReference('grid').bulkUpdateRecords(items)
45
+ me.getReference('grid').bulkUpdateRecords(items);
46
+ me.generateData()
47
+ }
48
+
49
+ /**
50
+ * @param {Object} data
51
+ */
52
+ onStartButtonClick(data) {
53
+ let me = this,
54
+ stopButton = me.getReference('stop-button');
55
+
56
+ me.generateData();
57
+
58
+ data.component.disabled = true;
59
+ stopButton .disabled = false
60
+ }
61
+
62
+ /**
63
+ * @param {Object} data
64
+ */
65
+ onStopButtonClick(data) {
66
+ let me = this,
67
+ startButton = me.getReference('start-button');
68
+
69
+ clearInterval(me.intervalId);
70
+
71
+ data.component.disabled = true;
72
+ startButton .disabled = false
73
+ }
74
+
75
+ /**
76
+ *
77
+ */
78
+ updateRecord() {
79
+ let me = this,
80
+ store = me.getStore('companies'),
81
+ change = Math.random() * 10 - 5,
82
+ index = Math.round(Math.random() * 100), // 0 - 100
83
+ record = store.getAt(index);
84
+
85
+ record.set({change, value: record.value + change})
32
86
  }
33
87
  }
34
88
 
@@ -16,7 +16,7 @@
16
16
  "@type": "Organization",
17
17
  "name": "Neo.mjs"
18
18
  },
19
- "datePublished": "2025-03-25",
19
+ "datePublished": "2025-03-26",
20
20
  "publisher": {
21
21
  "@type": "Organization",
22
22
  "name": "Neo.mjs"
@@ -107,7 +107,7 @@ class FooterContainer extends Container {
107
107
  }, {
108
108
  module: Component,
109
109
  cls : ['neo-version'],
110
- html : 'v8.33.0'
110
+ html : 'v8.35.0'
111
111
  }]
112
112
  }],
113
113
  /**
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='8.33.0'
23
+ * @member {String} version='8.35.0'
24
24
  */
25
- version: '8.33.0'
25
+ version: '8.35.0'
26
26
  }
27
27
 
28
28
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo.mjs",
3
- "version": "8.33.0",
3
+ "version": "8.35.0",
4
4
  "description": "The webworkers driven UI framework",
5
5
  "type": "module",
6
6
  "repository": {
@@ -1,5 +1,5 @@
1
1
  @keyframes grid-animated-cell {
2
- 50% {background-color:var(--button-ripple-background-color);}
2
+ 50% {background-color: var(--button-ripple-background-color);}
3
3
  }
4
4
 
5
5
  .neo-grid-container {
@@ -0,0 +1,25 @@
1
+ @keyframes grid-animated-cell-negative {
2
+ 50% {background-color: darkred;}
3
+ }
4
+
5
+ @keyframes grid-animated-cell-positive {
6
+ 50% {background-color: darkgreen}
7
+ }
8
+
9
+ .neo-grid-container {
10
+ .neo-grid-row, .neo-grid-row.neo-even {
11
+ .neo-grid-cell {
12
+ &.neo-animated-negative {
13
+ animation-name : grid-animated-cell-negative;
14
+ animation-duration : .4s;
15
+ animation-timing-function: ease-in-out;
16
+ }
17
+
18
+ &.neo-animated-positive {
19
+ animation-name : grid-animated-cell-positive;
20
+ animation-duration : .4s;
21
+ animation-timing-function: ease-in-out;
22
+ }
23
+ }
24
+ }
25
+ }
@@ -263,12 +263,12 @@ const DefaultConfig = {
263
263
  useVdomWorker: true,
264
264
  /**
265
265
  * buildScripts/injectPackageVersion.mjs will update this value
266
- * @default '8.33.0'
266
+ * @default '8.35.0'
267
267
  * @memberOf! module:Neo
268
268
  * @name config.version
269
269
  * @type String
270
270
  */
271
- version: '8.33.0'
271
+ version: '8.35.0'
272
272
  };
273
273
 
274
274
  Object.assign(DefaultConfig, {
@@ -19,12 +19,13 @@ class GridContainer extends BaseContainer {
19
19
  * @static
20
20
  */
21
21
  static columnTypes = {
22
- animatedChange: column.AnimatedChange,
23
- column : column.Base,
24
- component : column.Component,
25
- currency : column.Currency,
26
- index : column.Index,
27
- progress : column.Progress
22
+ animatedChange : column.AnimatedChange,
23
+ animatedCurrency: column.AnimatedCurrency,
24
+ column : column.Base,
25
+ component : column.Component,
26
+ currency : column.Currency,
27
+ index : column.Index,
28
+ progress : column.Progress
28
29
  }
29
30
  /**
30
31
  * @member {Object} delayable
@@ -0,0 +1,87 @@
1
+ import AnimatedChange from './AnimatedChange.mjs';
2
+
3
+ /**
4
+ * @class Neo.grid.column.AnimatedCurrency
5
+ * @extends Neo.grid.column.AnimatedChange
6
+ */
7
+ class AnimatedCurrency extends AnimatedChange {
8
+ static config = {
9
+ /**
10
+ * @member {String} className='Neo.grid.column.AnimatedCurrency'
11
+ * @protected
12
+ */
13
+ className: 'Neo.grid.column.AnimatedCurrency',
14
+ /**
15
+ * @member {String} type='animatedCurrency'
16
+ * @protected
17
+ */
18
+ type: 'animatedCurrency',
19
+ /**
20
+ * Set a different record field to base the change on.
21
+ * Defaults this.dataField
22
+ * @member {String|null} compareField=null
23
+ */
24
+ compareField: null,
25
+ /**
26
+ * @member {String} currency='USD'
27
+ */
28
+ currency: 'USD',
29
+ /**
30
+ * @member {String} locale='default'
31
+ */
32
+ locale: 'default'
33
+ }
34
+
35
+ /**
36
+ * @member {Intl.NumberFormat|null} formatter=null
37
+ */
38
+ formatter = null
39
+
40
+ /**
41
+ * @param {Object} config
42
+ */
43
+ construct(config) {
44
+ super.construct(config);
45
+ this.createFormatter()
46
+ }
47
+
48
+ /**
49
+ * @param {Object} data
50
+ * @param {Neo.button.Base} data.column
51
+ * @param {Number} data.columnIndex
52
+ * @param {String} data.dataField
53
+ * @param {Neo.grid.Container} data.gridContainer
54
+ * @param {Object} data.record
55
+ * @param {Number} data.rowIndex
56
+ * @param {Neo.data.Store} data.store
57
+ * @param {Number|String} data.value
58
+ * @returns {*}
59
+ */
60
+ cellRenderer({value}) {
61
+ if (value === null || value === undefined) {
62
+ return ''
63
+ }
64
+
65
+ return this.formatter.format(value)
66
+ }
67
+
68
+ /**
69
+ *
70
+ */
71
+ createFormatter() {
72
+ let me = this;
73
+
74
+ me.formatter = new Intl.NumberFormat(me.locale, {style: 'currency', currency: me.currency})
75
+ }
76
+
77
+ /**
78
+ * Override as needed for dynamic record-based animation classes
79
+ * @param {Record} record
80
+ * @returns {String}
81
+ */
82
+ getAnimationCls(record) {
83
+ return record[this.compareField || this.dataField] < 0 ? 'neo-animated-negative' : 'neo-animated-positive'
84
+ }
85
+ }
86
+
87
+ export default Neo.setupClass(AnimatedCurrency);
@@ -1,8 +1,9 @@
1
- import AnimatedChange from './AnimatedChange.mjs';
2
- import Base from './Base.mjs';
3
- import Component from './Component.mjs';
4
- import Currency from './Currency.mjs';
5
- import Index from './Index.mjs';
6
- import Progress from './Progress.mjs';
1
+ import AnimatedChange from './AnimatedChange.mjs';
2
+ import AnimatedCurrency from './AnimatedCurrency.mjs';
3
+ import Base from './Base.mjs';
4
+ import Component from './Component.mjs';
5
+ import Currency from './Currency.mjs';
6
+ import Index from './Index.mjs';
7
+ import Progress from './Progress.mjs';
7
8
 
8
- export {AnimatedChange, Base, Component, Currency, Index, Progress};
9
+ export {AnimatedChange, AnimatedCurrency, Base, Component, Currency, Index, Progress};