neo.mjs 4.0.74 → 4.0.75

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.
@@ -143,7 +143,7 @@ if (programOpts.info) {
143
143
  isDrop = programOpts.drop,
144
144
  isSingleton = singleton === 'yes',
145
145
  startDate = new Date(),
146
- baseFileName, baseType, classFolder, configName, file, folderDelta, importName, importPath, index, ns, root, rootLowerCase, viewFile;
146
+ baseType, classFolder, configName, file, folderDelta, importName, importPath, index, ns, root, rootLowerCase, viewFile;
147
147
 
148
148
  if (className.endsWith('.mjs')) {
149
149
  className = className.slice(0, -4);
@@ -162,8 +162,8 @@ if (programOpts.info) {
162
162
  if (isDrop === true) {
163
163
  ns = [];
164
164
 
165
- let pathInfo = path.parse(cwd),
166
- sep = path.sep,
165
+ let pathInfo = path.parse(cwd),
166
+ sep = path.sep,
167
167
  baseName, loc = baseName = '',
168
168
  tmpNs;
169
169
 
@@ -226,89 +226,18 @@ if (programOpts.info) {
226
226
  folderDelta = ns.length + 2;
227
227
  }
228
228
 
229
- fs.mkdirpSync(classFolder);
230
-
231
- baseFileName = baseClass.split('.').pop();
232
-
233
- if (baseFileName === file) {
234
- baseFileName = baseClass.split('.');
235
- baseFileName = baseFileName.map(e => capitalize(e)).join('');
236
- }
237
-
238
- fs.writeFileSync(path.join(classFolder, file + '.mjs'), createContent({
229
+ createClass({
239
230
  baseClass,
240
- baseFileName,
241
231
  className,
242
232
  isSingleton,
243
233
  file,
244
234
  folderDelta,
245
235
  ns,
246
236
  root
247
- }));
248
-
249
- switch(baseClass) {
250
- case 'controller.Component': {
251
- baseType = 'Neo.controller.Component';
252
- configName = 'controller';
253
- importName = file;
254
- importPath = `./${importName}.mjs`;
255
- index = file.indexOf('Controller');
256
-
257
- if (index > 0) {
258
- viewFile = path.join(classFolder, file.substr(0, index) + '.mjs');
259
-
260
- if (fs.existsSync(viewFile)) {
261
- adjustView({baseType, configName, importName, importPath, viewFile});
262
- }
263
- }
264
- break;
265
- }
266
-
267
- case 'data.Store': {
268
- baseType = 'Neo.data.Model';
269
- configName = 'model';
270
- importName = className.replace('.store.', '.model.');
271
-
272
- if (importName.endsWith('ies')) {
273
- importName.replace(new RegExp('ies$'), 'y')
274
- } else {
275
- importName = importName.slice(0, -1);
276
- }
277
-
278
- viewFile = importName.split('.');
279
- viewFile.shift();
280
-
281
- importPath = `../${viewFile.join('/')}.mjs`;
282
- viewFile = path.join(classFolder, importPath);
283
-
284
- // checking for the data.Model file
285
- if (fs.existsSync(viewFile)) {
286
- // adjusting the data.Store file
287
- viewFile = path.join(classFolder, file + '.mjs');
288
- importName = importName.split('.');
289
- importName = importName.pop();
290
-
291
- adjustView({baseType, configName, importName, importPath, viewFile});
292
- }
293
- break;
294
- }
295
-
296
- case 'model.Component': {
297
- baseType = 'Neo.model.Component';
298
- configName = 'model';
299
- importName = file;
300
- importPath = `./${importName}.mjs`;
301
- index = file.indexOf('Model');
302
-
303
- if (index > 0) {
304
- viewFile = path.join(classFolder, file.substr(0, index) + '.mjs');
237
+ });
305
238
 
306
- if (fs.existsSync(viewFile)) {
307
- adjustView({baseType, configName, importName, importPath, viewFile});
308
- }
309
- }
310
- break;
311
- }
239
+ if (baseClass === 'data.Model') {
240
+ // todo: add a question for auto-generating a matching store
312
241
  }
313
242
  }
314
243
 
@@ -490,6 +419,113 @@ if (programOpts.info) {
490
419
  return typeof value === 'string' && value[0].toUpperCase() + value.slice(1);
491
420
  }
492
421
 
422
+ /**
423
+ * @param {Object} opts
424
+ * @param {String} opts.baseClass
425
+ * @param {String} opts.className
426
+ * @param {Boolean} opts.isSingleton
427
+ * @param {String} opts.file
428
+ * @param {Number} opts.folderDelta
429
+ * @param {String[]} opts.ns
430
+ * @param {String} opts.root
431
+ */
432
+ function createClass(opts) {
433
+ let {
434
+ baseClass,
435
+ className,
436
+ isSingleton,
437
+ file,
438
+ folderDelta,
439
+ ns,
440
+ root
441
+ } = opts, baseFileName;
442
+
443
+ fs.mkdirpSync(classFolder);
444
+
445
+ baseFileName = baseClass.split('.').pop();
446
+
447
+ if (baseFileName === file) {
448
+ baseFileName = baseClass.split('.');
449
+ baseFileName = baseFileName.map(e => capitalize(e)).join('');
450
+ }
451
+
452
+ fs.writeFileSync(path.join(classFolder, file + '.mjs'), createContent({
453
+ baseClass,
454
+ baseFileName,
455
+ className,
456
+ isSingleton,
457
+ file,
458
+ folderDelta,
459
+ ns,
460
+ root
461
+ }));
462
+
463
+ switch(baseClass) {
464
+ case 'controller.Component': {
465
+ baseType = 'Neo.controller.Component';
466
+ configName = 'controller';
467
+ importName = file;
468
+ importPath = `./${importName}.mjs`;
469
+ index = file.indexOf('Controller');
470
+
471
+ if (index > 0) {
472
+ viewFile = path.join(classFolder, file.substr(0, index) + '.mjs');
473
+
474
+ if (fs.existsSync(viewFile)) {
475
+ adjustView({baseType, configName, importName, importPath, viewFile});
476
+ }
477
+ }
478
+ break;
479
+ }
480
+
481
+ case 'data.Store': {
482
+ baseType = 'Neo.data.Model';
483
+ configName = 'model';
484
+ importName = className.replace('.store.', '.model.');
485
+
486
+ if (importName.endsWith('ies')) {
487
+ importName.replace(new RegExp('ies$'), 'y')
488
+ } else {
489
+ importName = importName.slice(0, -1);
490
+ }
491
+
492
+ viewFile = importName.split('.');
493
+ viewFile.shift();
494
+
495
+ importPath = `../${viewFile.join('/')}.mjs`;
496
+ viewFile = path.join(classFolder, importPath);
497
+
498
+ // checking for the data.Model file
499
+ if (fs.existsSync(viewFile)) {
500
+ // adjusting the data.Store file
501
+ viewFile = path.join(classFolder, file + '.mjs');
502
+ importName = importName.split('.');
503
+ importName = importName.pop();
504
+
505
+ adjustView({baseType, configName, importName, importPath, viewFile});
506
+ }
507
+ break;
508
+ }
509
+
510
+ case 'model.Component': {
511
+ baseType = 'Neo.model.Component';
512
+ configName = 'model';
513
+ importName = file;
514
+ importPath = `./${importName}.mjs`;
515
+ index = file.indexOf('Model');
516
+
517
+ if (index > 0) {
518
+ viewFile = path.join(classFolder, file.substr(0, index) + '.mjs');
519
+
520
+ if (fs.existsSync(viewFile)) {
521
+ adjustView({baseType, configName, importName, importPath, viewFile});
522
+ }
523
+ }
524
+ break;
525
+ }
526
+ }
527
+ }
528
+
493
529
  /**
494
530
  * Creates the content of the neo-class .mjs file
495
531
  * @param {Object} opts
@@ -0,0 +1,54 @@
1
+ import CheckBox from '../../../src/form/field/CheckBox.mjs';
2
+ import Carousel from '../../../src/component/Carousel.mjs';
3
+ import ConfigurationViewport from '../../ConfigurationViewport.mjs';
4
+ import RangeField from '../../../src/form/field/Range.mjs';
5
+
6
+ /**
7
+ * @class Neo.examples.component.carousel.MainContainer
8
+ * @extends Neo.examples.ConfigurationViewport
9
+ */
10
+ class MainContainer extends ConfigurationViewport {
11
+ static getConfig() {return {
12
+ className: 'Neo.examples.component.carousel.MainContainer',
13
+ autoMount: true,
14
+ layout : {ntype: 'hbox', align: 'stretch'}
15
+ }}
16
+
17
+ createConfigurationComponents() {
18
+ let me = this;
19
+
20
+ return [{
21
+ module : CheckBox,
22
+ checked : me.exampleComponent.autoRun,
23
+ labelText: 'autoRun',
24
+ listeners: {change: me.onConfigChange.bind(me, 'autoRun')}
25
+ }, {
26
+ module : RangeField,
27
+ labelText : 'height',
28
+ listeners : {change: me.onConfigChange.bind(me, 'height')},
29
+ maxValue : 800,
30
+ minValue : 200,
31
+ stepSize : 1,
32
+ value : me.exampleComponent.height
33
+ }, {
34
+ module : RangeField,
35
+ labelText : 'width',
36
+ listeners : {change: me.onConfigChange.bind(me, 'width')},
37
+ maxValue : 800,
38
+ minValue : 200,
39
+ stepSize : 1,
40
+ value : me.exampleComponent.width
41
+ }];
42
+ }
43
+
44
+ createExampleComponent() {
45
+ return Neo.create(Carousel, {
46
+ height: 500,
47
+ width : 500
48
+ });
49
+ }
50
+ }
51
+
52
+ Neo.applyClassConfig(MainContainer);
53
+
54
+ export default MainContainer;
@@ -0,0 +1,6 @@
1
+ import MainContainer from './MainContainer.mjs';
2
+
3
+ export const onStart = () => Neo.app({
4
+ mainView: MainContainer,
5
+ name : 'Neo.examples.component.carousel'
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>Neo Carousel</title>
7
+ </head>
8
+ <body>
9
+ <script src="../../../src/MicroLoader.mjs" type="module"></script>
10
+ </body>
11
+ </html>
@@ -0,0 +1,6 @@
1
+ {
2
+ "appPath" : "examples/component/carousel/app.mjs",
3
+ "basePath" : "../../../",
4
+ "environment": "development",
5
+ "mainPath" : "./Main.mjs"
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo.mjs",
3
- "version": "4.0.74",
3
+ "version": "4.0.75",
4
4
  "description": "The webworkers driven UI framework",
5
5
  "type": "module",
6
6
  "repository": {
@@ -3,7 +3,6 @@ import Component from './Base.mjs';
3
3
  import Store from '../data/Store.mjs';
4
4
  import TaskManager from '../manager/Task.mjs';
5
5
 
6
-
7
6
  /**
8
7
  * @class Neo.component.Carousel
9
8
  * @extends Neo.component.Base
@@ -107,26 +106,27 @@ class Carousel extends Component {
107
106
 
108
107
  /**
109
108
  * Triggered after autoRun config got changed
110
- * @param {boolean|integer} value
109
+ * @param {Boolean|Number} value
110
+ * @param {Boolean|Number} oldValue
111
111
  * @protected
112
112
  */
113
113
  afterSetAutoRun(value, oldValue) {
114
- let me = this;
114
+ if (value) {
115
+ let me = this,
116
+ vdom = me._vdom;
115
117
 
116
- if(!value) return;
117
-
118
- TaskManager.start({
119
- id: this.id,
120
- interval: value,
121
- run: function() {
122
- me.onCarouselBtnClick('forward');
123
- }
124
- });
118
+ TaskManager.start({
119
+ id : me.id,
120
+ interval: value,
121
+ run : function () {
122
+ me.onCarouselBtnClick('forward');
123
+ }
124
+ });
125
125
 
126
- let vdom = this._vdom;
127
- vdom.cn[0].cn[0].removeDom = true;
126
+ vdom.cn[0].cn[0].removeDom = true;
128
127
 
129
- this._vdom = vdom;
128
+ me._vdom = vdom;
129
+ }
130
130
  }
131
131
 
132
132
  /**
@@ -148,18 +148,21 @@ class Carousel extends Component {
148
148
 
149
149
  /**
150
150
  * Ensure the itemTpl is setup correctly to match a valid JSON
151
- * @param {String} value
151
+ * @param {String|null} value
152
+ * @param {String|null} oldValue
152
153
  * @returns {String}
153
154
  * @protected
154
155
  */
155
- beforeSetItemTpl(value) {
156
- let itemTpl = value.replaceAll('\'', '"');
156
+ beforeSetItemTpl(value, oldValue) {
157
+ if (value) {
158
+ value = value.replaceAll('\'', '"');
157
159
 
158
- itemTpl = itemTpl.replace(/(\w+:)|(\w+ :)/g, function(matchedStr) {
159
- return `"${matchedStr.substring(0, matchedStr.length - 1)}":`;
160
- });
160
+ value = value.replace(/(\w+:)|(\w+ :)/g, function(matchedStr) {
161
+ return `"${matchedStr.substring(0, matchedStr.length - 1)}":`;
162
+ });
163
+ }
161
164
 
162
- return itemTpl;
165
+ return value;
163
166
  }
164
167
 
165
168
  /**
@@ -33,12 +33,7 @@ class Base extends CoreBase {
33
33
  construct(config) {
34
34
  super.construct(config);
35
35
 
36
- let me = this,
37
- currentHash = HashHistory.first();
38
-
39
- currentHash && me.onHashChange(currentHash, null);
40
-
41
- HashHistory.on('change', me.onHashChange, me);
36
+ HashHistory.on('change', this.onHashChange, this);
42
37
  }
43
38
 
44
39
  /**
@@ -58,6 +53,17 @@ class Base extends CoreBase {
58
53
  onHashChange(value, oldValue) {
59
54
 
60
55
  }
56
+
57
+ /**
58
+ *
59
+ */
60
+ onConstructed() {
61
+ let currentHash = HashHistory.first();
62
+
63
+ currentHash && this.onHashChange(currentHash, null);
64
+
65
+ super.onConstructed();
66
+ }
61
67
  }
62
68
 
63
69
  Neo.applyClassConfig(Base);