neo.mjs 4.0.73 → 4.0.76
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/buildScripts/createClass.mjs +114 -78
- package/examples/component/carousel/MainContainer.mjs +54 -0
- package/examples/component/carousel/app.mjs +6 -0
- package/examples/component/carousel/index.html +11 -0
- package/examples/component/carousel/neo-config.json +6 -0
- package/package.json +1 -1
- package/src/component/Base.mjs +15 -13
- package/src/component/Carousel.mjs +25 -22
- package/src/controller/Base.mjs +11 -0
- package/src/util/HashHistory.mjs +2 -7
@@ -143,7 +143,7 @@ if (programOpts.info) {
|
|
143
143
|
isDrop = programOpts.drop,
|
144
144
|
isSingleton = singleton === 'yes',
|
145
145
|
startDate = new Date(),
|
146
|
-
|
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
|
166
|
-
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
|
-
|
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
|
-
|
307
|
-
|
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,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>
|
package/package.json
CHANGED
package/src/component/Base.mjs
CHANGED
@@ -1567,22 +1567,24 @@ class Base extends CoreBase {
|
|
1567
1567
|
|
1568
1568
|
// keep the vnode parent tree in sync
|
1569
1569
|
ComponentManager.getParents(me).forEach((component, index) => {
|
1570
|
-
if (
|
1571
|
-
if (
|
1572
|
-
|
1573
|
-
|
1570
|
+
if (component._vnode) {
|
1571
|
+
if (!me.vnode) {
|
1572
|
+
if (index === 0 && !VNodeUtil.removeChildVnode(component.vnode, me.id)) {
|
1573
|
+
// This can fail, in case the vnode is already removed (not an issue, better safe than sorry)
|
1574
|
+
// console.warn('syncVnodeTree: Could not remove the parent vnode for', me.id, component);
|
1575
|
+
}
|
1574
1576
|
}
|
1575
|
-
}
|
1576
1577
|
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1578
|
+
// check for dynamically rendered components which get inserted into the component tree
|
1579
|
+
else if (index === 0 && me.vnode.outerHTML) {
|
1580
|
+
// console.log('dyn item', me.vnode, me.parentIndex);
|
1581
|
+
component.vnode.childNodes.splice(me.parentIndex || 0, 0, me.vnode);
|
1582
|
+
}
|
1582
1583
|
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1584
|
+
else if (!VNodeUtil.replaceChildVnode(component.vnode, me.vnode.id, me.vnode)) {
|
1585
|
+
// todo: can happen for dynamically inserted container items
|
1586
|
+
// console.warn('syncVnodeTree: Could not replace the parent vnode for', me.vnode.id, component);
|
1587
|
+
}
|
1586
1588
|
}
|
1587
1589
|
});
|
1588
1590
|
|
@@ -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 {
|
109
|
+
* @param {Boolean|Number} value
|
110
|
+
* @param {Boolean|Number} oldValue
|
111
111
|
* @protected
|
112
112
|
*/
|
113
113
|
afterSetAutoRun(value, oldValue) {
|
114
|
-
|
114
|
+
if (value) {
|
115
|
+
let me = this,
|
116
|
+
vdom = me._vdom;
|
115
117
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
}
|
124
|
-
});
|
118
|
+
TaskManager.start({
|
119
|
+
id : me.id,
|
120
|
+
interval: value,
|
121
|
+
run : function () {
|
122
|
+
me.onCarouselBtnClick('forward');
|
123
|
+
}
|
124
|
+
});
|
125
125
|
|
126
|
-
|
127
|
-
vdom.cn[0].cn[0].removeDom = true;
|
126
|
+
vdom.cn[0].cn[0].removeDom = true;
|
128
127
|
|
129
|
-
|
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
|
-
|
156
|
+
beforeSetItemTpl(value, oldValue) {
|
157
|
+
if (value) {
|
158
|
+
value = value.replaceAll('\'', '"');
|
157
159
|
|
158
|
-
|
159
|
-
|
160
|
-
|
160
|
+
value = value.replace(/(\w+:)|(\w+ :)/g, function(matchedStr) {
|
161
|
+
return `"${matchedStr.substring(0, matchedStr.length - 1)}":`;
|
162
|
+
});
|
163
|
+
}
|
161
164
|
|
162
|
-
return
|
165
|
+
return value;
|
163
166
|
}
|
164
167
|
|
165
168
|
/**
|
package/src/controller/Base.mjs
CHANGED
@@ -53,6 +53,17 @@ class Base extends CoreBase {
|
|
53
53
|
onHashChange(value, oldValue) {
|
54
54
|
|
55
55
|
}
|
56
|
+
|
57
|
+
/**
|
58
|
+
*
|
59
|
+
*/
|
60
|
+
onConstructed() {
|
61
|
+
let currentHash = HashHistory.first();
|
62
|
+
|
63
|
+
currentHash && this.onHashChange(currentHash, null);
|
64
|
+
|
65
|
+
super.onConstructed();
|
66
|
+
}
|
56
67
|
}
|
57
68
|
|
58
69
|
Neo.applyClassConfig(Base);
|
package/src/util/HashHistory.mjs
CHANGED
@@ -22,11 +22,6 @@ class HashHistory extends Base {
|
|
22
22
|
* @protected
|
23
23
|
*/
|
24
24
|
className: 'Neo.util.HashHistory',
|
25
|
-
/**
|
26
|
-
* @member {String} ntype='hash-history'
|
27
|
-
* @protected
|
28
|
-
*/
|
29
|
-
ntype: 'hash-history',
|
30
25
|
/**
|
31
26
|
* @member {Boolean} singleton=true
|
32
27
|
* @protected
|
@@ -71,10 +66,10 @@ class HashHistory extends Base {
|
|
71
66
|
stack.unshift(data);
|
72
67
|
|
73
68
|
if (stack.length > me.maxItems) {
|
74
|
-
stack.
|
69
|
+
stack.pop();
|
75
70
|
}
|
76
71
|
|
77
|
-
me.fire('change', data, stack[1]);
|
72
|
+
me.fire('change', data, stack[1] || null);
|
78
73
|
}
|
79
74
|
}
|
80
75
|
|