neo.mjs 7.0.0 → 7.0.2

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='7.0.0'
23
+ * @member {String} version='7.0.2'
24
24
  */
25
- version: '7.0.0'
25
+ version: '7.0.2'
26
26
  }
27
27
 
28
28
  /**
@@ -1,4 +1,17 @@
1
1
  [
2
+ {
3
+ "author" : "Tobias Uhlig",
4
+ "authorImage" : "author_TobiasUhlig.jpeg",
5
+ "date" : "Aug 20, 2024",
6
+ "id" : 60,
7
+ "image" : "frontend-performance.png",
8
+ "name" : "Frontend Performance Love Story",
9
+ "provider" : "Medium",
10
+ "publisher" : "ITNEXT",
11
+ "selectedInto": [],
12
+ "type" : "Blog Post",
13
+ "url" : "https://itnext.io/frontend-performance-love-story-ce92302fea5f?source=friends_link&sk=ec69e9461cee5b80adb06214ebbf36b4"
14
+ },
2
15
  {
3
16
  "author" : "Tobias Uhlig",
4
17
  "authorImage" : "author_TobiasUhlig.jpeg",
@@ -111,7 +111,7 @@ class FooterContainer extends Container {
111
111
  }, {
112
112
  module: Component,
113
113
  cls : ['neo-version'],
114
- html : 'v7.0.0'
114
+ html : 'v7.0.2'
115
115
  }]
116
116
  }],
117
117
  /**
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='7.0.0'
23
+ * @member {String} version='7.0.2'
24
24
  */
25
- version: '7.0.0'
25
+ version: '7.0.2'
26
26
  }
27
27
 
28
28
  /**
@@ -60,6 +60,7 @@ class CountryGallery extends Gallery {
60
60
  createItem(vdomItem, record, index) {
61
61
  let me = this,
62
62
  cls = ['neo-gallery-item', 'image-wrap', 'view', 'neo-transition-1000'],
63
+ fn = CountryGallery.formatNumber,
63
64
  style = {height: (me.itemHeight - 70) + 'px', width: me.itemWidth + 'px'};
64
65
 
65
66
  return {cls, id: me.getItemVnodeId(record[me.keyProperty]), tabIndex: '-1', cn: [
@@ -72,24 +73,24 @@ class CountryGallery extends Gallery {
72
73
  {tag: 'table', cls: ['neo-content-table'], cn: [
73
74
  {tag: 'tr', cn: [
74
75
  {tag: 'td', html: 'Cases'},
75
- {tag: 'td', cls: ['neo-align-right'], html: record.cases},
76
+ {tag: 'td', cls: ['neo-align-right'], html: fn(record.cases)},
76
77
  {tag: 'td', style: {width: '100%'}},
77
78
  {tag: 'td', html: 'Cases today'},
78
- {tag: 'td', cls: ['neo-align-right'], html: record.todayCases}
79
+ {tag: 'td', cls: ['neo-align-right'], html: fn(record.todayCases)}
79
80
  ]},
80
81
  {tag: 'tr', cn: [
81
82
  {tag: 'td', html: 'Deaths'},
82
- {tag: 'td', cls: ['neo-align-right', 'neo-content-deaths'], html: record.deaths},
83
+ {tag: 'td', cls: ['neo-align-right', 'neo-content-deaths'], html: fn(record.deaths)},
83
84
  {tag: 'td', style: {width: '100%'}},
84
85
  {tag: 'td', html: 'Deaths today'},
85
- {tag: 'td', cls: ['neo-align-right', 'neo-content-deaths'], html: record.todayDeaths}
86
+ {tag: 'td', cls: ['neo-align-right', 'neo-content-deaths'], html: fn(record.todayDeaths)}
86
87
  ]},
87
88
  {tag: 'tr', cn: [
88
89
  {tag: 'td', html: 'Recovered'},
89
- {tag: 'td', cls: ['neo-align-right', 'neo-content-recovered'], html: record.recovered},
90
+ {tag: 'td', cls: ['neo-align-right', 'neo-content-recovered'], html: fn(record.recovered)},
90
91
  {tag: 'td', style: {width: '100%'}},
91
92
  {tag: 'td', html: 'Critical'},
92
- {tag: 'td', cls: ['neo-align-right', 'neo-content-critical'], html: record.critical}
93
+ {tag: 'td', cls: ['neo-align-right', 'neo-content-critical'], html: fn(record.critical)}
93
94
  ]}
94
95
  ]}
95
96
  ]}
@@ -97,6 +98,14 @@ class CountryGallery extends Gallery {
97
98
  ]}
98
99
  }
99
100
 
101
+ /**
102
+ * @param {Number} value
103
+ * @returns {String}
104
+ */
105
+ static formatNumber(value) {
106
+ return value.toLocaleString()
107
+ }
108
+
100
109
  /**
101
110
  * @param {String} name
102
111
  * @returns {String} url
@@ -0,0 +1,317 @@
1
+ import BaseViewport from '../../../src/container/Viewport.mjs';
2
+ import CountryGallery from './CountryGallery.mjs';
3
+ import Panel from '../../../src/container/Panel.mjs';
4
+ import RangeField from '../../../src/form/field/Range.mjs';
5
+ import ViewportController from './ViewportController.mjs';
6
+
7
+ /**
8
+ * @class Neo.examples.component.coronaGallery.Viewport
9
+ * @extends Neo.container.Viewport
10
+ */
11
+ class Viewport extends BaseViewport {
12
+ static config = {
13
+ /**
14
+ * @member {String} className='Neo.examples.component.coronaGallery.Viewport'
15
+ * @protected
16
+ */
17
+ className: 'Neo.examples.component.coronaGallery.Viewport',
18
+ /**
19
+ * @member {String[]} baseCls=['neo-gallery-viewport','neo-viewport']
20
+ */
21
+ baseCls: ['neo-gallery-viewport', 'neo-viewport'],
22
+ /**
23
+ * @member {Neo.controller.Component} controller=ViewportController
24
+ */
25
+ controller: ViewportController,
26
+ /**
27
+ * @member {Neo.component.Gallery|null} gallery=null
28
+ */
29
+ gallery: null,
30
+ /**
31
+ * @member {Object|null} galleryConfig=null
32
+ */
33
+ galleryConfig: null,
34
+ /**
35
+ * @member {Object|null} layout={ntype: 'hbox', align: 'stretch'}
36
+ */
37
+ layout: {ntype: 'hbox', align: 'stretch'},
38
+ /**
39
+ * @member {Boolean} showGitHubStarButton_=true
40
+ */
41
+ showGitHubStarButton_: true,
42
+ /**
43
+ * @member {Object[]} items
44
+ */
45
+ items: [{
46
+ ntype : 'container',
47
+ flex : 1,
48
+ layout: 'fit',
49
+ style : {position: 'relative'},
50
+
51
+ items : [{
52
+ ntype: 'component',
53
+ html : 'DeltaUpdates / s: <span id="neo-delta-updates"></span>',
54
+ style: {
55
+ position: 'absolute',
56
+ right : '150px',
57
+ top : '25px',
58
+ width : '200px',
59
+ zIndex : 1
60
+ }
61
+ }, {
62
+ ntype : 'component',
63
+ html : '<a class="github-button" href="https://github.com/neomjs/neo" data-size="large" data-show-count="true" aria-label="Star neomjs/neo on GitHub">Star</a>',
64
+ reference: 'github-button',
65
+
66
+ style: {
67
+ position: 'absolute',
68
+ right : '20px',
69
+ top : '20px',
70
+ zIndex : 1
71
+ }
72
+ }]
73
+ }, {
74
+ ntype : 'panel',
75
+ cls : ['neo-controls-panel', 'neo-panel', 'neo-container'],
76
+ layout : {ntype: 'vbox', align: 'stretch'},
77
+ reference: 'controls-panel',
78
+ style : {backgroundColor: '#2b2b2b'},
79
+ width : 260,
80
+
81
+ containerConfig: {
82
+ style: {overflowY: 'scroll'}
83
+ },
84
+
85
+ headers: [{
86
+ dock: 'top',
87
+ items: [{
88
+ ntype: 'button',
89
+ text : 'X',
90
+ handler: function() {
91
+ const panel = this.up('panel'),
92
+ expand = panel.width === 40;
93
+
94
+ panel.width = expand ? 250 : 40;
95
+ this.text = expand ? 'X' : '+';
96
+ }
97
+ }, {
98
+ ntype: 'label',
99
+ text : 'Gallery Controls'
100
+ }]
101
+ }],
102
+
103
+ itemDefaults: {
104
+ flex : '0 1 auto',
105
+ labelWidth : '110px',
106
+ style : {padding: '10px'},
107
+ useInputEvent: true
108
+ },
109
+
110
+ items: [{
111
+ module : RangeField,
112
+ labelText: 'Translate X',
113
+ maxValue : 5000,
114
+ minValue : 0,
115
+ name : 'translateX',
116
+ value : 0,
117
+ listeners: {
118
+ change : 'onRangefieldChange',
119
+ mounted: 'onRangefieldMounted'
120
+ }
121
+ }, {
122
+ module : RangeField,
123
+ labelText: 'Translate Y',
124
+ maxValue : 1500,
125
+ minValue : -1500,
126
+ name : 'translateY',
127
+ value : 0,
128
+ listeners: {
129
+ change: 'onRangefieldChange'
130
+ }
131
+ }, {
132
+ module : RangeField,
133
+ labelText: 'Translate Z',
134
+ maxValue : 550,
135
+ minValue : -4500,
136
+ name : 'translateZ',
137
+ value : 0,
138
+ listeners: {
139
+ change : 'onRangefieldChange',
140
+ mounted: 'onRangefieldMounted'
141
+ }
142
+ }, {
143
+ module : RangeField,
144
+ labelText: 'Amount Rows',
145
+ maxValue : 15,
146
+ minValue : 1,
147
+ name : 'amountRows',
148
+ value : 3,
149
+ listeners: {
150
+ change: 'onRangefieldChange'
151
+ }
152
+ }, {
153
+ ntype : 'button',
154
+ handler: 'onOrderButtonClick',
155
+ text : 'Order by Row',
156
+ style : {margin: '20px'}
157
+ }, {
158
+ ntype: 'label',
159
+ text : 'Sort By:'
160
+ }, {
161
+ ntype : 'container',
162
+ layout: {ntype: 'hbox', align: 'stretch'},
163
+ style : {minHeight: '134px', padding: '0'},
164
+
165
+ items : [{
166
+ ntype : 'container',
167
+ layout: {ntype: 'vbox', align: 'stretch'},
168
+
169
+ itemDefaults: {
170
+ ntype : 'button',
171
+ handler: 'onSortButtonClick'
172
+ },
173
+
174
+ items: [{
175
+ field: 'cases',
176
+ text : 'Cases',
177
+ style: {margin: '10px', marginTop: '0'}
178
+ }, {
179
+ field: 'deaths',
180
+ text : 'Deaths',
181
+ style: {margin: '10px', marginBottom: '10px', marginTop: 0}
182
+ }, {
183
+ field: 'country',
184
+ text : 'Country',
185
+ style: {margin: '10px', marginTop: 0}
186
+ }, {
187
+ field: 'recovered',
188
+ text : 'Recovered',
189
+ style: {margin: '10px', marginTop: 0}
190
+ }]
191
+ }, {
192
+ ntype : 'container',
193
+ layout: {ntype: 'vbox', align: 'stretch'},
194
+
195
+ itemDefaults: {
196
+ ntype : 'button',
197
+ handler: 'onSortButtonClick'
198
+ },
199
+
200
+ items: [{
201
+ field: 'todayCases',
202
+ text : 'Cases today',
203
+ style: {margin: '10px', marginTop: '0'}
204
+ }, {
205
+ field: 'todayDeaths',
206
+ text : 'Deaths today',
207
+ style: {margin: '10px', marginBottom: '10px', marginTop: 0}
208
+ }, {
209
+ field: 'critical',
210
+ text : 'Critical',
211
+ style: {margin: '10px', marginBottom: '43px', marginTop: 0}
212
+ }]
213
+ }]
214
+ }, {
215
+ ntype: 'label',
216
+ text : [
217
+ '<b>Navigation Concept</b>',
218
+ '<p>You can use the Arrow Keys to walk through the items.</p>'
219
+ ].join(''),
220
+
221
+ style: {
222
+ backgroundColor: '#323232',
223
+ color : '#ddd',
224
+ fontSize : '13px',
225
+ margin : '10px',
226
+ padding : '10px',
227
+ whiteSpace : 'normal'
228
+ }
229
+ }, {
230
+ ntype: 'label',
231
+ cls : ['neo-link-color'],
232
+ text : [
233
+ '<b>Attribution</b>',
234
+ '<p>App created with <a href="https://github.com/neomjs/neo">neo.mjs</a>.</p>',
235
+ '<p>Data provided by <a href="https://github.com/disease-sh/API">disease-sh/API</a>.</p>',
236
+ '<p>Country Flag Icons made by <a href="https://www.flaticon.com/authors/freepik" title="Freepik">Freepik</a> from <a href="https://www.flaticon.com/" title="Flaticon"> www.flaticon.com</a>.</p>'
237
+ ].join(''),
238
+
239
+ style: {
240
+ backgroundColor: '#323232',
241
+ color : '#ddd',
242
+ fontSize : '13px',
243
+ margin : '10px',
244
+ padding : '10px',
245
+ whiteSpace : 'normal'
246
+ }
247
+ }]
248
+ }]
249
+ }
250
+
251
+ /**
252
+ * @param {Object} config
253
+ */
254
+ construct(config) {
255
+ super.construct(config);
256
+
257
+ let me = this,
258
+ url = 'https://disease.sh/v3/covid-19/countries';
259
+
260
+ me.gallery = Neo.create({
261
+ module : CountryGallery,
262
+ appName : me.appName,
263
+ parentId : me.id,
264
+ reference: 'gallery',
265
+ ...me.galleryConfig
266
+ });
267
+
268
+ me.items[0].items.unshift(me.gallery);
269
+
270
+ fetch(url)
271
+ .then(response => response.json())
272
+ .catch(err => console.log('Can’t access ' + url, err))
273
+ .then(data => me.addStoreItems(data));
274
+
275
+ Neo.Main.setNeoConfig({
276
+ key : 'renderCountDeltas',
277
+ value : true,
278
+ windowId: me.windowId
279
+ });
280
+
281
+ if (me.showGitHubStarButton) {
282
+ me.on('mounted', () => {
283
+ Neo.main.DomAccess.addScript({
284
+ async: true,
285
+ defer: true,
286
+ src : 'https://buttons.github.io/buttons.js'
287
+ })
288
+ })
289
+ }
290
+ }
291
+
292
+ /**
293
+ * @param {Object[]} data
294
+ */
295
+ addStoreItems(data) {
296
+ this.getStore().data = data
297
+ }
298
+
299
+ /**
300
+ * @returns {Neo.data.Store}
301
+ */
302
+ getStore() {
303
+ return this.items[0].items[0].store
304
+ }
305
+
306
+ /**
307
+ * Triggered after the showGitHubStarButton config got changed
308
+ * @param {Boolean} value
309
+ * @param {Boolean} oldValue
310
+ * @protected
311
+ */
312
+ afterSetShowGitHubStarButton(value, oldValue) {
313
+ this.getItem('github-button').hidden = !value
314
+ }
315
+ }
316
+
317
+ export default Neo.setupClass(Viewport);
@@ -0,0 +1,88 @@
1
+ import Controller from '../../../src/controller/Component.mjs';
2
+
3
+ /**
4
+ * @class Neo.examples.component.coronaGallery.ViewportController
5
+ * @extends Neo.controller.Component
6
+ */
7
+ class ViewportController extends Controller {
8
+ static config = {
9
+ /**
10
+ * @member {String} className='Neo.examples.component.coronaGallery.ViewportController'
11
+ * @protected
12
+ */
13
+ className: 'Neo.examples.component.coronaGallery.ViewportController',
14
+ /**
15
+ * @member {Neo.component.Gallery|null} gallery_=null
16
+ * @protected
17
+ */
18
+ gallery_: null
19
+ }
20
+
21
+ /**
22
+ * Triggered when accessing the gallery config
23
+ * @param {Neo.component.Gallery|null} value
24
+ * @protected
25
+ */
26
+ beforeGetGallery(value) {
27
+ if (!value) {
28
+ this._gallery = value = this.getReference('gallery');
29
+ }
30
+
31
+ return value;
32
+ }
33
+
34
+ /**
35
+ * {Object} data
36
+ */
37
+ onCollapseButtonClick(data) {
38
+ const panel = this.getReference('controls-panel'),
39
+ expand = panel.width === 40;
40
+
41
+ panel.width = expand ? 250 : 40;
42
+
43
+ data.component.text = expand ? 'X' : '+';
44
+ }
45
+
46
+ /**
47
+ * @param {Object} data
48
+ */
49
+ onOrderButtonClick(data) {
50
+ const gallery = this.gallery,
51
+ orderByRow = !gallery.orderByRow;
52
+
53
+ data.component.text = orderByRow === true ? 'Order By Column' : 'Order by Row';
54
+
55
+ gallery.orderByRow = orderByRow;
56
+ }
57
+
58
+ /**
59
+ * @param {Object} data
60
+ */
61
+ onRangefieldChange(data) {
62
+ this.gallery[data.component.name] = data.value
63
+ }
64
+
65
+ /**
66
+ * @param {String} id
67
+ */
68
+ onRangefieldMounted(id) {
69
+ const field = Neo.getComponent(id);
70
+
71
+ this.gallery.on('change' + Neo.capitalize(field.name), function(value) {
72
+ value = Math.min(Math.max(value, field.minValue), field.maxValue);
73
+ field.value = value
74
+ })
75
+ }
76
+
77
+ /**
78
+ * @param {Object} data
79
+ */
80
+ onSortButtonClick(data) {
81
+ this.gallery.store.sorters = [{
82
+ property : data.component.field,
83
+ direction: 'DESC'
84
+ }]
85
+ }
86
+ }
87
+
88
+ export default Neo.setupClass(ViewportController);
@@ -1,6 +1,6 @@
1
- import MainContainer from './MainContainer.mjs';
1
+ import Viewport from './Viewport.mjs';
2
2
 
3
3
  export const onStart = () => Neo.app({
4
- mainView: MainContainer,
4
+ mainView: Viewport,
5
5
  name : 'Neo.examples.component.coronaGallery'
6
6
  });
@@ -0,0 +1,47 @@
1
+ import BaseViewport from '../coronaGallery/Viewport.mjs';
2
+ import ViewportController from './ViewportController.mjs';
3
+
4
+ /**
5
+ * @class Neo.examples.component.multiWindowCoronaGallery.Viewport
6
+ * @extends Neo.examples.component.coronaGallery.Viewport
7
+ */
8
+ class Viewport extends BaseViewport {
9
+ static config = {
10
+ /**
11
+ * @member {String} className='Neo.examples.component.multiWindowCoronaGallery.Viewport'
12
+ * @protected
13
+ */
14
+ className: 'Neo.examples.component.multiWindowCoronaGallery.Viewport',
15
+ /**
16
+ * @member {String[]} cls=['multi-window-helix-viewport']
17
+ */
18
+ cls: ['multi-window-helix-viewport'],
19
+ /**
20
+ * @member {Neo.controller.Component} controller=ViewportController
21
+ */
22
+ controller: ViewportController
23
+ }
24
+
25
+ /**
26
+ * @param {Object} config
27
+ */
28
+ construct(config) {
29
+ super.construct(config);
30
+
31
+ this.getItem('controls-panel').headers = [{
32
+ dock : 'top',
33
+ reference: 'header-toolbar',
34
+
35
+ items: [{
36
+ ntype: 'label',
37
+ cls : ['neo-panel-header-text', 'neo-label'],
38
+ text : 'Gallery Controls'
39
+ }, '->', {
40
+ handler: 'onMaximiseButtonClick',
41
+ iconCls: 'far fa-window-maximize'
42
+ }]
43
+ }]
44
+ }
45
+ }
46
+
47
+ export default Neo.setupClass(Viewport);
@@ -0,0 +1,128 @@
1
+ import Controller from '../coronaGallery/ViewportController.mjs';
2
+
3
+ /**
4
+ * @class Neo.examples.component.multiWindowCoronaGallery.ViewportController
5
+ * @extends Neo.examples.component.coronaGallery.ViewportController
6
+ */
7
+ class ViewportController extends Controller {
8
+ static config = {
9
+ /**
10
+ * @member {String} className='Neo.examples.component.multiWindowCoronaGallery.ViewportController'
11
+ * @protected
12
+ */
13
+ className: 'Neo.examples.component.multiWindowCoronaGallery.ViewportController'
14
+ }
15
+
16
+ /**
17
+ * @member {String[]} connectedApps=[]
18
+ */
19
+ connectedApps = []
20
+
21
+ /**
22
+ *
23
+ */
24
+ async createPopupWindow() {
25
+ let me = this,
26
+ {windowId} = me,
27
+ {config, windowConfigs} = Neo,
28
+ {environment} = config,
29
+ firstWindowId = parseInt(Object.keys(windowConfigs)[0]),
30
+ {basePath} = windowConfigs[firstWindowId],
31
+ widget = me.getReference('controls-panel'),
32
+ winData = await Neo.Main.getWindowData({windowId}),
33
+ rect = await me.component.getDomRect(widget.id),
34
+ {height, left, top, width} = rect;
35
+
36
+ if (environment !== 'development') {
37
+ basePath = `${basePath + environment}/`
38
+ }
39
+
40
+ height -= 62; // popup header in Chrome
41
+ left += (width + winData.screenLeft);
42
+ top += (winData.outerHeight - winData.innerHeight + winData.screenTop);
43
+
44
+ /*
45
+ * For this demo, the url './childapp/' would be sufficient.
46
+ * However, we also want to open it from within apps/portal.
47
+ *
48
+ * We match the basePath to the firstWindowId,
49
+ * assuming the first connected window is the (main) one which we want to be in charge.
50
+ */
51
+ await Neo.Main.windowOpen({
52
+ url : basePath + 'examples/component/multiWindowCoronaGallery/childapp/',
53
+ windowFeatures: `height=${height},left=${left},top=${top},width=${width}`,
54
+ windowId : firstWindowId,
55
+ windowName : 'GalleryControls'
56
+ })
57
+ }
58
+
59
+ /**
60
+ * @param {Object} data
61
+ * @param {String} data.appName
62
+ * @param {Number} data.windowId
63
+ */
64
+ async onAppConnect(data) {
65
+ let me = this,
66
+ {appName} = data;
67
+
68
+ if (appName === 'GalleryControls') {
69
+ let controlsPanel = me.getReference('controls-panel'),
70
+ {mainView} = Neo.apps[appName];
71
+
72
+ me.connectedApps.push(appName);
73
+
74
+ controlsPanel.parent.remove(controlsPanel, false);
75
+
76
+ this.getReference('header-toolbar').hidden = true;
77
+
78
+ mainView.add(controlsPanel)
79
+ }
80
+ }
81
+
82
+ /**
83
+ * @param {Object} data
84
+ * @param {String} data.appName
85
+ * @param {Number} data.windowId
86
+ */
87
+ async onAppDisconnect(data) {
88
+ let me = this,
89
+ {appName, windowId} = data;
90
+
91
+ if (appName === 'GalleryControls') {
92
+ let controlsPanel = me.getReference('controls-panel');
93
+
94
+ controlsPanel.parent.remove(controlsPanel, false);
95
+
96
+ me.getReference('header-toolbar').hidden = false;
97
+
98
+ me.component.add(controlsPanel)
99
+ }
100
+ // Close popup windows when closing or reloading the main window
101
+ else if (appName === 'Neo.examples.component.multiWindowCoronaGallery') {console.log('close', me.connectedApps);
102
+ Neo.Main.windowClose({names: me.connectedApps, windowId})
103
+ }
104
+ }
105
+ /**
106
+ *
107
+ */
108
+ onConstructed() {
109
+ super.onConstructed();
110
+
111
+ let me = this;
112
+
113
+ Neo.currentWorker.on({
114
+ connect : me.onAppConnect,
115
+ disconnect: me.onAppDisconnect,
116
+ scope : me
117
+ })
118
+ }
119
+
120
+ /**
121
+ * @param {Object} data
122
+ */
123
+ async onMaximiseButtonClick(data) {
124
+ await this.createPopupWindow()
125
+ }
126
+ }
127
+
128
+ export default Neo.setupClass(ViewportController);
@@ -0,0 +1,6 @@
1
+ import Viewport from './Viewport.mjs';
2
+
3
+ export const onStart = () => Neo.app({
4
+ mainView: Viewport,
5
+ name : 'Neo.examples.component.multiWindowCoronaGallery'
6
+ });
@@ -0,0 +1,21 @@
1
+ import BaseViewport from '../../../../src/container/Viewport.mjs';
2
+
3
+ /**
4
+ * @class Neo.examples.component.multiWindowCoronaGallery.childapp.Viewport
5
+ * @extends Neo.container.Viewport
6
+ */
7
+ class Viewport extends BaseViewport {
8
+ static config = {
9
+ /**
10
+ * @member {String} className='Neo.examples.component.multiWindowCoronaGallery.childapp.Viewport'
11
+ * @protected
12
+ */
13
+ className: 'Neo.examples.component.multiWindowCoronaGallery.childapp.Viewport',
14
+ /**
15
+ * @member {Object} layout={ntype:'fit'}
16
+ */
17
+ layout: {ntype: 'fit'}
18
+ }
19
+ }
20
+
21
+ export default Neo.setupClass(Viewport);
@@ -0,0 +1,6 @@
1
+ import Viewport from './Viewport.mjs';
2
+
3
+ export const onStart = () => Neo.app({
4
+ mainView: Viewport,
5
+ name : 'GalleryControls'
6
+ });
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE HTML>
2
+ <html>
3
+ <head>
4
+ <meta name="viewport" content="width=device-width, initial-scale=1">
5
+ <meta charset="UTF-8">
6
+ <title>Gallery Controls</title>
7
+ </head>
8
+ <body>
9
+ <script src="../../../../src/MicroLoader.mjs" type="module"></script>
10
+ </body>
11
+ </html>
@@ -0,0 +1,9 @@
1
+ {
2
+ "appPath" : "examples/component/multiWindowCoronaGallery/childapp/app.mjs",
3
+ "basePath" : "../../../../",
4
+ "environment" : "development",
5
+ "mainPath" : "./Main.mjs",
6
+ "mainThreadAddons": ["Stylesheet"],
7
+ "themes" : ["neo-theme-dark"],
8
+ "useSharedWorkers": true
9
+ }
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE HTML>
2
+ <html>
3
+ <head>
4
+ <meta name="viewport" content="width=device-width, initial-scale=1">
5
+ <meta charset="UTF-8">
6
+ <title>Neo Multi-Window Corona Gallery</title>
7
+ </head>
8
+ <body>
9
+ <script src="../../../src/MicroLoader.mjs" type="module"></script>
10
+ </body>
11
+ </html>
@@ -0,0 +1,8 @@
1
+ {
2
+ "appPath" : "examples/component/multiWindowCoronaGallery/app.mjs",
3
+ "basePath" : "../../../",
4
+ "environment" : "development",
5
+ "mainPath" : "./Main.mjs",
6
+ "themes" : ["neo-theme-dark"],
7
+ "useSharedWorkers" : true
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo.mjs",
3
- "version": "7.0.0",
3
+ "version": "7.0.2",
4
4
  "description": "The webworkers driven UI framework",
5
5
  "type": "module",
6
6
  "repository": {
@@ -262,12 +262,12 @@ const DefaultConfig = {
262
262
  useVdomWorker: true,
263
263
  /**
264
264
  * buildScripts/injectPackageVersion.mjs will update this value
265
- * @default '7.0.0'
265
+ * @default '7.0.2'
266
266
  * @memberOf! module:Neo
267
267
  * @name config.version
268
268
  * @type String
269
269
  */
270
- version: '7.0.0'
270
+ version: '7.0.2'
271
271
  };
272
272
 
273
273
  Object.assign(DefaultConfig, {
@@ -1,377 +0,0 @@
1
- import CountryGallery from './CountryGallery.mjs';
2
- import Panel from '../../../src/container/Panel.mjs';
3
- import RangeField from '../../../src/form/field/Range.mjs';
4
- import Viewport from '../../../src/container/Viewport.mjs';
5
-
6
- /**
7
- * @class Neo.examples.component.coronaGallery.MainContainer
8
- * @extends Neo.container.Viewport
9
- */
10
- class MainContainer extends Viewport {
11
- static config = {
12
- /**
13
- * @member {String} className='Neo.examples.component.coronaGallery.MainContainer'
14
- * @protected
15
- */
16
- className: 'Neo.examples.component.coronaGallery.MainContainer',
17
- /**
18
- * @member {String[]} baseCls=['neo-gallery-maincontainer','neo-viewport']
19
- */
20
- baseCls: ['neo-gallery-maincontainer', 'neo-viewport'],
21
- /**
22
- * @member {Neo.component.Gallery|null} gallery=null
23
- */
24
- gallery: null,
25
- /**
26
- * @member {Object|null} galleryConfig=null
27
- */
28
- galleryConfig: null,
29
- /**
30
- * @member {Object|null} layout={ntype: 'hbox', align: 'stretch'}
31
- */
32
- layout: {ntype: 'hbox', align: 'stretch'},
33
- /**
34
- * @member {Boolean} showGitHubStarButton=true
35
- */
36
- showGitHubStarButton: true,
37
- /**
38
- * @member {Object[]} items
39
- */
40
- items: [{
41
- ntype : 'container',
42
- flex : 1,
43
- layout: 'fit',
44
- style : {position: 'relative'},
45
-
46
- items : [{
47
- ntype: 'component',
48
- html : 'DeltaUpdates / s: <span id="neo-delta-updates"></span>',
49
- style: {
50
- position: 'absolute',
51
- right : '150px',
52
- top : '25px',
53
- width : '200px',
54
- zIndex : 1
55
- }
56
- }, {
57
- ntype: 'component',
58
- html : '<a class="github-button" href="https://github.com/neomjs/neo" data-size="large" data-show-count="true" aria-label="Star neomjs/neo on GitHub">Star</a>',
59
- style: {
60
- position: 'absolute',
61
- right : '20px',
62
- top : '20px',
63
- zIndex : 1
64
- }
65
- }]
66
- }, {
67
- ntype : 'panel',
68
- cls : ['neo-controls-panel', 'neo-panel', 'neo-container'],
69
- layout: {ntype: 'vbox', align: 'stretch'},
70
- style : {backgroundColor: '#2b2b2b'},
71
- width : 260,
72
-
73
- containerConfig: {
74
- style: {overflowY: 'scroll'}
75
- },
76
-
77
- headers: [{
78
- dock: 'top',
79
- items: [{
80
- ntype: 'button',
81
- text : 'X',
82
- handler: function() {
83
- const panel = this.up('panel'),
84
- expand = panel.width === 40;
85
-
86
- panel.width = expand ? 250 : 40;
87
- this.text = expand ? 'X' : '+';
88
- }
89
- }, {
90
- ntype: 'label',
91
- text : 'Gallery Controls'
92
- }]
93
- }],
94
-
95
- itemDefaults: {
96
- ntype : 'rangefield',
97
- flex : '0 1 auto',
98
- labelWidth : '110px',
99
- style : {padding: '10px'},
100
- useInputEvent: true,
101
-
102
- listeners: {
103
- change: function(data) {
104
- if (this.name === 'opacity') {
105
- data.value /= 100;
106
- }
107
- Neo.get('neo-gallery-1')[this.name] = data.value;
108
- }
109
- }
110
- },
111
-
112
- items: [{
113
- labelText: 'Translate X',
114
- maxValue : 5000,
115
- minValue : 0,
116
- name : 'translateX',
117
- value : 0,
118
- listeners: {
119
- change: function(data) {
120
- Neo.get('neo-gallery-1')[this.name] = data.value;
121
- },
122
- mounted: function(fieldId) {
123
- let field = Neo.get(fieldId);
124
-
125
- Neo.get('neo-gallery-1').on('changeTranslateX', function(value) {
126
- value = Math.min(Math.max(value, this.minValue), this.maxValue);
127
- this.value = value;
128
- }, field);
129
- }
130
- }
131
- }, {
132
- labelText: 'Translate Y',
133
- maxValue : 1500,
134
- minValue : -1500,
135
- name : 'translateY',
136
- value : 0
137
- }, {
138
- labelText: 'Translate Z',
139
- maxValue : 550,
140
- minValue : -4500,
141
- name : 'translateZ',
142
- value : 0,
143
- listeners: {
144
- change: function(data) {
145
- Neo.get('neo-gallery-1')[this.name] = data.value;
146
- },
147
- mounted: function(fieldId) {
148
- let field = Neo.get(fieldId);
149
-
150
- Neo.get('neo-gallery-1').on('changeTranslateZ', function(value) {
151
- value = Math.min(Math.max(value, this.minValue), this.maxValue);
152
- this.value = value;
153
- }, field);
154
- }
155
- }
156
- }, {
157
- labelText: 'Amount Rows',
158
- maxValue : 15,
159
- minValue : 1,
160
- name : 'amountRows',
161
- value : 3
162
- }, {
163
- ntype : 'button',
164
- text : 'Order by Row',
165
- listeners : {},
166
- style : {margin: '20px'},
167
- domListeners: {
168
- click: function() {
169
- const gallery = Neo.get('neo-gallery-1'),
170
- orderByRow = !gallery.orderByRow;
171
-
172
- this.text = orderByRow === true ? 'Order By Column' : 'Order by Row';
173
-
174
- gallery.orderByRow = orderByRow;
175
- }
176
- }
177
- }, {
178
- ntype: 'label',
179
- text : 'Sort By:'
180
- }, {
181
- ntype : 'container',
182
- layout: {ntype: 'hbox', align: 'stretch'},
183
- style : {minHeight: '134px', padding: '0'},
184
-
185
- items : [{
186
- ntype : 'container',
187
- layout: {ntype: 'vbox', align: 'stretch'},
188
- items : [{
189
- ntype : 'button',
190
- text : 'Cases',
191
- listeners: {},
192
- style : {margin: '10px', marginTop: '0'},
193
-
194
- domListeners: {
195
- click: function() {
196
- Neo.get('neo-gallery-1').store.sorters = [{
197
- property : 'cases',
198
- direction: 'DESC'
199
- }];
200
- }
201
- }
202
- }, {
203
- ntype : 'button',
204
- text : 'Deaths',
205
- listeners: {},
206
- style : {margin: '10px', marginBottom: '10px', marginTop: 0},
207
-
208
- domListeners: {
209
- click: function() {
210
- Neo.get('neo-gallery-1').store.sorters = [{
211
- property : 'deaths',
212
- direction: 'DESC'
213
- }];
214
- }
215
- }
216
- }, {
217
- ntype : 'button',
218
- text : 'Country',
219
- listeners: {},
220
- style : {margin: '10px', marginTop: 0},
221
-
222
- domListeners: {
223
- click: function() {
224
- Neo.get('neo-gallery-1').store.sorters = [{
225
- property : 'country',
226
- direction: 'ASC'
227
- }];
228
- }
229
- }
230
- }, {
231
- ntype : 'button',
232
- text : 'Recovered',
233
- listeners: {},
234
- style : {margin: '10px', marginTop: 0},
235
-
236
- domListeners: {
237
- click: function() {
238
- Neo.get('neo-gallery-1').store.sorters = [{
239
- property : 'recovered',
240
- direction: 'ASC'
241
- }];
242
- }
243
- }
244
- }]
245
- }, {
246
- ntype : 'container',
247
- layout: {ntype: 'vbox', align: 'stretch'},
248
- items : [{
249
- ntype : 'button',
250
- text : 'Cases today',
251
- listeners: {},
252
- style : {margin: '10px', marginTop: '0'},
253
-
254
- domListeners: {
255
- click: function() {
256
- Neo.get('neo-gallery-1').store.sorters = [{
257
- property : 'todayCases',
258
- direction: 'DESC'
259
- }];
260
- }
261
- }
262
- }, {
263
- ntype : 'button',
264
- text : 'Deaths today',
265
- listeners: {},
266
- style : {margin: '10px', marginBottom: '10px', marginTop: 0},
267
-
268
- domListeners: {
269
- click: function() {
270
- Neo.get('neo-gallery-1').store.sorters = [{
271
- property : 'todayDeaths',
272
- direction: 'DESC'
273
- }];
274
- }
275
- }
276
- }, {
277
- ntype : 'button',
278
- text : 'Critical',
279
- listeners: {},
280
- style: {margin: '10px', marginBottom: '43px', marginTop: 0},
281
-
282
- domListeners: {
283
- click: function() {
284
- Neo.get('neo-gallery-1').store.sorters = [{
285
- property : 'critical',
286
- direction: 'DESC'
287
- }];
288
- }
289
- }
290
- }]
291
- }]
292
- }, {
293
- ntype: 'label',
294
- text : [
295
- '<b>Navigation Concept</b>',
296
- '<p>You can use the Arrow Keys to walk through the items.</p>'
297
- ].join(''),
298
-
299
- style: {
300
- backgroundColor: '#323232',
301
- color : '#ddd',
302
- fontSize : '13px',
303
- margin : '10px',
304
- padding : '10px',
305
- whiteSpace : 'normal'
306
- }
307
- }, {
308
- ntype: 'label',
309
- cls : ['neo-link-color'],
310
- text : [
311
- '<b>Attribution</b>',
312
- '<p>App created with <a href="https://github.com/neomjs/neo">neo.mjs</a>.</p>',
313
- '<p>Data provided by <a href="https://github.com/disease-sh/API">disease-sh/API</a>.</p>',
314
- '<p>Country Flag Icons made by <a href="https://www.flaticon.com/authors/freepik" title="Freepik">Freepik</a> from <a href="https://www.flaticon.com/" title="Flaticon"> www.flaticon.com</a>.</p>'
315
- ].join(''),
316
-
317
- style: {
318
- backgroundColor: '#323232',
319
- color : '#ddd',
320
- fontSize : '13px',
321
- margin : '10px',
322
- padding : '10px',
323
- whiteSpace : 'normal'
324
- }
325
- }]
326
- }]
327
- }
328
-
329
- /**
330
- * @param {Object} config
331
- */
332
- construct(config) {
333
- super.construct(config);
334
-
335
- let me = this,
336
- url = 'https://disease.sh/v3/covid-19/countries';
337
-
338
- me.gallery = Neo.create({
339
- module: CountryGallery,
340
- id : 'neo-gallery-1',
341
- ...me.galleryConfig
342
- });
343
-
344
- me.items[0].items.unshift(me.gallery);
345
-
346
- fetch(url)
347
- .then(response => response.json())
348
- .catch(err => console.log('Can’t access ' + url, err))
349
- .then(data => me.addStoreItems(data));
350
-
351
- if (me.showGitHubStarButton) {
352
- me.on('mounted', () => {
353
- Neo.main.DomAccess.addScript({
354
- async: true,
355
- defer: true,
356
- src : 'https://buttons.github.io/buttons.js'
357
- })
358
- })
359
- }
360
- }
361
-
362
- /**
363
- * @param {Object[]} data
364
- */
365
- addStoreItems(data) {
366
- this.getStore().data = data
367
- }
368
-
369
- /**
370
- * @returns {Neo.data.Store}
371
- */
372
- getStore() {
373
- return this.items[0].items[0].store
374
- }
375
- }
376
-
377
- export default Neo.setupClass(MainContainer);