neo.mjs 4.0.38 → 4.0.41
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/watchThemes.mjs +95 -0
- package/package.json +7 -6
- package/resources/scss/src/button/Base.scss +1 -1
- package/resources/scss/src/component/Carousel.scss +70 -0
- package/src/component/Base.mjs +88 -0
- package/src/component/Carousel.mjs +266 -0
- package/src/container/Base.mjs +16 -22
- package/src/container/Panel.mjs +2 -2
- package/src/form/Container.mjs +2 -4
- package/src/form/Fieldset.mjs +6 -8
- package/src/table/Container.mjs +7 -0
- package/src/table/header/Toolbar.mjs +0 -8
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import autoprefixer from 'autoprefixer';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import postcss from 'postcss';
|
|
6
|
+
import sass from 'sass';
|
|
7
|
+
|
|
8
|
+
let cwd = process.cwd(),
|
|
9
|
+
requireJson = path => JSON.parse(fs.readFileSync((path))),
|
|
10
|
+
packageJson = requireJson(path.resolve(cwd, 'package.json')),
|
|
11
|
+
neoPath = packageJson.name === 'neo.mjs' ? './' : './node_modules/neo.mjs/',
|
|
12
|
+
mixinPath = path.resolve(neoPath, 'resources/scss/mixins/_all.scss'),
|
|
13
|
+
scssPath = path.resolve(cwd, 'resources/scss');
|
|
14
|
+
|
|
15
|
+
if (path.sep === '\\') {
|
|
16
|
+
mixinPath = mixinPath.replace(/\\/g, '/');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
fs.watch(scssPath, {
|
|
20
|
+
recursive: true
|
|
21
|
+
}, (eventType, filename) => {
|
|
22
|
+
if (filename.endsWith('.scss')) {
|
|
23
|
+
switch (eventType) {
|
|
24
|
+
case 'change': {
|
|
25
|
+
buildFile(filename);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
function buildFile(filename) {
|
|
32
|
+
console.log('start processing', filename);
|
|
33
|
+
|
|
34
|
+
let filePath = path.join(scssPath, filename),
|
|
35
|
+
destPath = path.join(cwd, 'dist/development/css', filename.replace('.scss', '.css')),
|
|
36
|
+
startDate = new Date(),
|
|
37
|
+
data, map;
|
|
38
|
+
|
|
39
|
+
data = [
|
|
40
|
+
`@use "sass:map";`,
|
|
41
|
+
`@use "sass:math";`,
|
|
42
|
+
`$neoMap: ();`,
|
|
43
|
+
`$useCssVars: true;`,
|
|
44
|
+
`@import "${mixinPath}";`
|
|
45
|
+
].join('');
|
|
46
|
+
|
|
47
|
+
fs.readFile(filePath).then(content => {
|
|
48
|
+
let result = sass.renderSync({
|
|
49
|
+
data : data + content.toString(),
|
|
50
|
+
outFile : destPath,
|
|
51
|
+
sourceMap : true,
|
|
52
|
+
sourceMapEmbed: false
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
map = result.map?.toString();
|
|
56
|
+
|
|
57
|
+
if (map) {
|
|
58
|
+
// https://github.com/neomjs/neo/issues/1970
|
|
59
|
+
map = JSON.parse(map);
|
|
60
|
+
|
|
61
|
+
let filenameSlash = filename;
|
|
62
|
+
|
|
63
|
+
if (path.sep === '\\') {
|
|
64
|
+
filenameSlash = filenameSlash.replace(/\\/g, '/');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let len = filenameSlash.split('/').length,
|
|
68
|
+
src = `/scss/${filenameSlash}`,
|
|
69
|
+
i = 0;
|
|
70
|
+
|
|
71
|
+
for (; i < len; i++) {
|
|
72
|
+
src = '../' + src;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
map.sources = [src];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
postcss([autoprefixer]).process(result.css, {
|
|
79
|
+
from: filePath,
|
|
80
|
+
to : destPath,
|
|
81
|
+
map : {
|
|
82
|
+
prev: map && JSON.stringify(map)
|
|
83
|
+
}
|
|
84
|
+
}).then(result => {
|
|
85
|
+
fs.writeFileSync(destPath, result.css, () => true);
|
|
86
|
+
|
|
87
|
+
if (result.map) {
|
|
88
|
+
fs.writeFileSync(result.opts.to + '.map', result.map.toString());
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const processTime = (Math.round((new Date - startDate) * 100) / 100000).toFixed(2);
|
|
92
|
+
console.log('Updated file:', (chalk.blue(`${processTime}s`)), destPath);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neo.mjs",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.41",
|
|
4
4
|
"description": "The webworkers driven UI framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
"create-app": "node ./buildScripts/createApp.mjs",
|
|
17
17
|
"generate-docs-json": "node ./buildScripts/docs/jsdocx.mjs",
|
|
18
18
|
"server-start": "webpack serve -c ./buildScripts/webpack/webpack.server.config.mjs --open",
|
|
19
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
19
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
20
|
+
"watch-themes": "node ./buildScripts/watchThemes.mjs"
|
|
20
21
|
},
|
|
21
22
|
"keywords": [
|
|
22
23
|
"javascript",
|
|
@@ -41,7 +42,7 @@
|
|
|
41
42
|
"chalk": "^5.0.1",
|
|
42
43
|
"clean-webpack-plugin": "^4.0.0",
|
|
43
44
|
"commander": "^9.3.0",
|
|
44
|
-
"cssnano": "^5.1.
|
|
45
|
+
"cssnano": "^5.1.11",
|
|
45
46
|
"envinfo": "^7.8.1",
|
|
46
47
|
"fs-extra": "^10.1.0",
|
|
47
48
|
"highlightjs-line-numbers.js": "^2.8.0",
|
|
@@ -49,10 +50,10 @@
|
|
|
49
50
|
"neo-jsdoc": "^1.0.1",
|
|
50
51
|
"neo-jsdoc-x": "^1.0.4",
|
|
51
52
|
"postcss": "^8.4.14",
|
|
52
|
-
"sass": "^1.52.
|
|
53
|
-
"webpack": "^5.
|
|
53
|
+
"sass": "^1.52.2",
|
|
54
|
+
"webpack": "^5.73.0",
|
|
54
55
|
"webpack-cli": "^4.9.2",
|
|
55
|
-
"webpack-dev-server": "4.9.
|
|
56
|
+
"webpack-dev-server": "4.9.2",
|
|
56
57
|
"webpack-hook-plugin": "^1.0.7",
|
|
57
58
|
"webpack-node-externals": "^3.0.0"
|
|
58
59
|
},
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CAROUSEL TRANSFORM
|
|
3
|
+
*/
|
|
4
|
+
.neo-carousel {
|
|
5
|
+
/**
|
|
6
|
+
* VARS
|
|
7
|
+
*/
|
|
8
|
+
--neo-carousel-translate-x: 0;
|
|
9
|
+
--neo-carousel-translate-y: 0;
|
|
10
|
+
--neo-carousel-transition-timing: cubic-bezier(.4,0,.2,1);
|
|
11
|
+
--neo-carousel-duration: .7s;
|
|
12
|
+
|
|
13
|
+
.neo-carousel-inner {
|
|
14
|
+
position: relative;
|
|
15
|
+
overflow: hidden;
|
|
16
|
+
|
|
17
|
+
.neo-carousel-item {
|
|
18
|
+
transition-timing-function: var(--neo-carousel-transition-timing);
|
|
19
|
+
transition-duration: var(--neo-carousel-duration);
|
|
20
|
+
transition-property: all;
|
|
21
|
+
z-index: 10;
|
|
22
|
+
inset: 0;
|
|
23
|
+
position: absolute;
|
|
24
|
+
transform: translate(var(--neo-carousel-translate-x), var(--neo-carousel-translate-y));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.neo-carousel--translate-x-full{
|
|
30
|
+
--neo-carousel-translate-x: -100%;
|
|
31
|
+
transform: translate(var(--neo-carousel-translate-x),var(--neo-carousel-translate-y));
|
|
32
|
+
}
|
|
33
|
+
.neo-carousel-translate-x-0{
|
|
34
|
+
--neo-carousel-translate-x: 0;
|
|
35
|
+
transform: translate(var(--neo-carousel-translate-x),var(--neo-carousel-translate-y));
|
|
36
|
+
}
|
|
37
|
+
.neo-carousel-translate-x-full{
|
|
38
|
+
--neo-carousel-translate-x: 100%;
|
|
39
|
+
transform: translate(var(--neo-carousel-translate-x),var(--neo-carousel-translate-y));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* BASE STYLING
|
|
44
|
+
*/
|
|
45
|
+
.neo-carousel {
|
|
46
|
+
padding: 15px;
|
|
47
|
+
height: 14rem;
|
|
48
|
+
background: var(--container-background-color);
|
|
49
|
+
|
|
50
|
+
.neo-carousel-btn-bar {
|
|
51
|
+
text-align: end;
|
|
52
|
+
|
|
53
|
+
.neo-carousel-btn {
|
|
54
|
+
padding: 15px;
|
|
55
|
+
font-size: 18px;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
.neo-carousel-inner {
|
|
59
|
+
border-radius: 5px;
|
|
60
|
+
height: 9rem;
|
|
61
|
+
overflow: hidden;
|
|
62
|
+
background-color: var(--button-active-color);
|
|
63
|
+
color: var(--button-background-color);
|
|
64
|
+
|
|
65
|
+
.neo-carousel-item {
|
|
66
|
+
height: 9rem;
|
|
67
|
+
padding: 15px;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
package/src/component/Base.mjs
CHANGED
|
@@ -147,6 +147,12 @@ class Base extends CoreBase {
|
|
|
147
147
|
* @member {Number|String|null} height_=null
|
|
148
148
|
*/
|
|
149
149
|
height_: null,
|
|
150
|
+
/**
|
|
151
|
+
* Used for hide and show and defines if the component
|
|
152
|
+
* should use css visibility:'hidden' or vdom:removeDom
|
|
153
|
+
* @member {'visible', 'remove'} hiddenType='visible'
|
|
154
|
+
*/
|
|
155
|
+
hiddenType: 'visible',
|
|
150
156
|
/**
|
|
151
157
|
* The top level innerHTML of the component
|
|
152
158
|
* @member {String|null} html_=null
|
|
@@ -402,6 +408,17 @@ class Base extends CoreBase {
|
|
|
402
408
|
}
|
|
403
409
|
}
|
|
404
410
|
|
|
411
|
+
/**
|
|
412
|
+
* Add a new cls to the vdomRoot
|
|
413
|
+
* @param {String} value
|
|
414
|
+
*/
|
|
415
|
+
addCls(value) {
|
|
416
|
+
let cls = this.cls;
|
|
417
|
+
|
|
418
|
+
NeoArray.add(cls, value);
|
|
419
|
+
this.cls = cls;
|
|
420
|
+
}
|
|
421
|
+
|
|
405
422
|
/**
|
|
406
423
|
* Either a string like 'color: red; background-color: blue;'
|
|
407
424
|
* or an object containing style attributes
|
|
@@ -1061,6 +1078,36 @@ class Base extends CoreBase {
|
|
|
1061
1078
|
return this.vnode;
|
|
1062
1079
|
}
|
|
1063
1080
|
|
|
1081
|
+
/**
|
|
1082
|
+
* Hide the component.
|
|
1083
|
+
* hiddenType: 'visible' uses css visibility.
|
|
1084
|
+
* hiddenType: 'remove' uses vdom removeDom.
|
|
1085
|
+
* If hiddenType 'remove' you can pass a timeout for custom css class hiding.
|
|
1086
|
+
* @param {Number} timeout
|
|
1087
|
+
*/
|
|
1088
|
+
hide(timeout) {
|
|
1089
|
+
let me = this,
|
|
1090
|
+
doRemove = me.hiddenType !== 'visible';
|
|
1091
|
+
|
|
1092
|
+
if (doRemove) {
|
|
1093
|
+
let removeFn = function() {
|
|
1094
|
+
let vdom = me.vdom;
|
|
1095
|
+
vdom.removeDom = true;
|
|
1096
|
+
me.vdom = vdom;
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
if (timeout) {
|
|
1100
|
+
setTimeout(removeFn, timeout);
|
|
1101
|
+
} else {
|
|
1102
|
+
removeFn();
|
|
1103
|
+
}
|
|
1104
|
+
} else {
|
|
1105
|
+
let style = me.style;
|
|
1106
|
+
style.visibility = 'hidden';
|
|
1107
|
+
me.style = style;
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1064
1111
|
/**
|
|
1065
1112
|
*
|
|
1066
1113
|
*/
|
|
@@ -1282,6 +1329,17 @@ class Base extends CoreBase {
|
|
|
1282
1329
|
});
|
|
1283
1330
|
}
|
|
1284
1331
|
|
|
1332
|
+
/**
|
|
1333
|
+
* Remove a cls from the vdomRoot
|
|
1334
|
+
* @param {String} value
|
|
1335
|
+
*/
|
|
1336
|
+
removeCls(value) {
|
|
1337
|
+
let cls = this.cls;
|
|
1338
|
+
|
|
1339
|
+
NeoArray.remove(cls, value);
|
|
1340
|
+
this.cls = cls;
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1285
1343
|
/**
|
|
1286
1344
|
* @param {Array|Object} value
|
|
1287
1345
|
*/
|
|
@@ -1404,6 +1462,26 @@ class Base extends CoreBase {
|
|
|
1404
1462
|
return this.set(values, true);
|
|
1405
1463
|
}
|
|
1406
1464
|
|
|
1465
|
+
/**
|
|
1466
|
+
* Show the component.
|
|
1467
|
+
* hiddenType: 'visible' uses css visibility.
|
|
1468
|
+
* hiddenType: 'remove' uses vdom removeDom.
|
|
1469
|
+
*/
|
|
1470
|
+
show() {
|
|
1471
|
+
let me = this,
|
|
1472
|
+
doAdd = me.hiddenType !== 'visible';
|
|
1473
|
+
|
|
1474
|
+
if (doAdd) {
|
|
1475
|
+
let vdom = me.vdom;
|
|
1476
|
+
vdom.removeDom = false;
|
|
1477
|
+
me.vdom = vdom;
|
|
1478
|
+
} else {
|
|
1479
|
+
let style = me.style;
|
|
1480
|
+
style.visibility = 'visible';
|
|
1481
|
+
me.style = style;
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1407
1485
|
/**
|
|
1408
1486
|
* Placeholder method for util.VDom.syncVdomIds to allow overriding (disabling) it
|
|
1409
1487
|
* @param {Neo.vdom.VNode} [vnode=this.vnode]
|
|
@@ -1473,7 +1551,17 @@ class Base extends CoreBase {
|
|
|
1473
1551
|
let end = performance.now();
|
|
1474
1552
|
console.log('syncVnodeTree', me.id, end - start);
|
|
1475
1553
|
}
|
|
1554
|
+
}
|
|
1476
1555
|
|
|
1556
|
+
/**
|
|
1557
|
+
* Toggle a cls inside the vdomRoot of the component
|
|
1558
|
+
* @param {String} value
|
|
1559
|
+
*/
|
|
1560
|
+
toggleCls(value) {
|
|
1561
|
+
let cls = this.cls;
|
|
1562
|
+
|
|
1563
|
+
NeoArray.toggle(cls, value);
|
|
1564
|
+
this.cls = cls;
|
|
1477
1565
|
}
|
|
1478
1566
|
|
|
1479
1567
|
/**
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import ClassSystemUtil from '../util/ClassSystem.mjs';
|
|
2
|
+
import Component from './Base.mjs';
|
|
3
|
+
import Store from '../data/Store.mjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @class Neo.component.Carousel
|
|
7
|
+
* @extends Neo.component.Base
|
|
8
|
+
*/
|
|
9
|
+
class Carousel extends Component {
|
|
10
|
+
/**
|
|
11
|
+
* Defines the currently visible item in the middle
|
|
12
|
+
* This gets updated everytime a button is clicked to reflect the current order
|
|
13
|
+
* @member {Number} itemIndex=1
|
|
14
|
+
*/
|
|
15
|
+
itemIndex = 1
|
|
16
|
+
/**
|
|
17
|
+
* Defines the order of the item in the carousel
|
|
18
|
+
* This gets updated everytime a button is clicked to reflect the current order
|
|
19
|
+
* @member {String[]} positionArray
|
|
20
|
+
*/
|
|
21
|
+
positionArray = ['neo-carousel--translate-x-full', 'neo-carousel-translate-x-0', 'neo-carousel-translate-x-full']
|
|
22
|
+
|
|
23
|
+
static getConfig() {return {
|
|
24
|
+
/**
|
|
25
|
+
* @member {String} className='Neo.component.Carousel'
|
|
26
|
+
* @protected
|
|
27
|
+
*/
|
|
28
|
+
className: 'Neo.component.Carousel',
|
|
29
|
+
/**
|
|
30
|
+
* @member {String} ntype='carousel'
|
|
31
|
+
* @protected
|
|
32
|
+
*/
|
|
33
|
+
ntype: 'carousel',
|
|
34
|
+
/**
|
|
35
|
+
* @member {String[]} cls=['neo-carousel']
|
|
36
|
+
*/
|
|
37
|
+
cls : ['neo-carousel'],
|
|
38
|
+
/**
|
|
39
|
+
* Custom cls added to each item
|
|
40
|
+
* This is only a single string
|
|
41
|
+
*
|
|
42
|
+
* @member {String|null} itemCls=null
|
|
43
|
+
*/
|
|
44
|
+
itemCls: null,
|
|
45
|
+
/**
|
|
46
|
+
* Template for each item
|
|
47
|
+
* The format is the same as for literals,
|
|
48
|
+
* but it is a string instead of surrounding "`"
|
|
49
|
+
* @member {String|null} tpl=null
|
|
50
|
+
* @example
|
|
51
|
+
* record = {foo: ... , bar: ...}
|
|
52
|
+
* "[{cls: 'css-foo-class', html: '${foo}'}, {html: '${baa}'}]"
|
|
53
|
+
*/
|
|
54
|
+
itemTpl_: null,
|
|
55
|
+
/**
|
|
56
|
+
* Store to be used.
|
|
57
|
+
*
|
|
58
|
+
* @member {Neo.data.Store|null} store=null
|
|
59
|
+
*/
|
|
60
|
+
store_: null,
|
|
61
|
+
/**
|
|
62
|
+
* @member {Object} _vdom
|
|
63
|
+
*/
|
|
64
|
+
_vdom:
|
|
65
|
+
{cn: [
|
|
66
|
+
{cls: ['neo-carousel'], cn: [
|
|
67
|
+
{cls: ['neo-carousel-btn-bar'], cn: [
|
|
68
|
+
{tag: 'a', 'data-carouselaction': 'back', cls: ['neo-carousel-btn', 'fa', 'fa-chevron-left']},
|
|
69
|
+
{tag: 'a', 'data-carouselaction': 'forward', cls: ['neo-carousel-btn', 'fa', 'fa-chevron-right']}
|
|
70
|
+
]},
|
|
71
|
+
{cls: ['neo-carousel-inner'], cn: []}
|
|
72
|
+
]}
|
|
73
|
+
]}
|
|
74
|
+
}}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @param {Object} config
|
|
78
|
+
*/
|
|
79
|
+
construct(config) {
|
|
80
|
+
super.construct(config);
|
|
81
|
+
|
|
82
|
+
let me = this,
|
|
83
|
+
domListeners = me.domListeners;
|
|
84
|
+
|
|
85
|
+
domListeners.push({
|
|
86
|
+
click: {
|
|
87
|
+
fn : me.onCarouselBtnClick,
|
|
88
|
+
delegate: '.neo-carousel-btn',
|
|
89
|
+
scope : me
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
me.domListeners = domListeners;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Triggered after the store config got changed
|
|
98
|
+
* @param {Neo.data.Store|Object|null} value
|
|
99
|
+
* @param {Neo.data.Store|null} oldValue
|
|
100
|
+
* @protected
|
|
101
|
+
*/
|
|
102
|
+
afterSetStore(value, oldValue) {
|
|
103
|
+
let me = this;
|
|
104
|
+
|
|
105
|
+
value?.on({
|
|
106
|
+
load : 'onStoreLoad',
|
|
107
|
+
scope: me
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
value?.getCount() > 0 && me.onStoreLoad();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Ensure the itemTpl is setup correctly to match a valid JSON
|
|
115
|
+
* @param {String} value
|
|
116
|
+
* @returns {String}
|
|
117
|
+
* @protected
|
|
118
|
+
*/
|
|
119
|
+
beforeSetItemTpl(value) {
|
|
120
|
+
let itemTpl = value.replaceAll('\'', '"');
|
|
121
|
+
|
|
122
|
+
itemTpl = itemTpl.replace(/(\w+:)|(\w+ :)/g, function(matchedStr) {
|
|
123
|
+
return `"${matchedStr.substring(0, matchedStr.length - 1)}":`;
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
return itemTpl;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Triggered before the store config gets changed.
|
|
131
|
+
* @param {Neo.data.Store|Object|null} value
|
|
132
|
+
* @param {Neo.data.Store|null} oldValue
|
|
133
|
+
* @returns {Neo.data.Store}
|
|
134
|
+
* @protected
|
|
135
|
+
*/
|
|
136
|
+
beforeSetStore(value, oldValue) {
|
|
137
|
+
oldValue?.destroy();
|
|
138
|
+
return ClassSystemUtil.beforeSetInstance(value, Store);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Create the initial three items and add them to the vdom
|
|
143
|
+
*/
|
|
144
|
+
createBaseItems() {
|
|
145
|
+
let me = this,
|
|
146
|
+
vdom = me._vdom,
|
|
147
|
+
itemRoot = me.#getItemRoot(),
|
|
148
|
+
items = [],
|
|
149
|
+
i = 0;
|
|
150
|
+
|
|
151
|
+
for (i; i < 3; i++) {
|
|
152
|
+
items.push(me.createItem(i, i));
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
itemRoot.cn = items;
|
|
156
|
+
me.vdom = vdom;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Everytime we rotate we create items
|
|
161
|
+
* @param {Number} recordIndex - index inside store
|
|
162
|
+
* @param {Number} positionIndex - based on positionArray
|
|
163
|
+
* @returns {Object}
|
|
164
|
+
*/
|
|
165
|
+
createItem(recordIndex, positionIndex) {
|
|
166
|
+
let me = this,
|
|
167
|
+
itemCls = me.itemCls,
|
|
168
|
+
positionArray = me.positionArray,
|
|
169
|
+
store = me.store,
|
|
170
|
+
data = store.getAt(recordIndex),
|
|
171
|
+
itemTpl = me.#formatTpl(me.itemTpl, data),
|
|
172
|
+
|
|
173
|
+
newItem = {
|
|
174
|
+
cls: [positionArray[positionIndex], 'neo-carousel-item'],
|
|
175
|
+
cn : itemTpl,
|
|
176
|
+
recordIndex
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
itemCls && newItem.cls.push(itemCls);
|
|
180
|
+
|
|
181
|
+
return newItem;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Rotate the three items and fill in a new record
|
|
186
|
+
* @param {Object} event
|
|
187
|
+
* @param {Object} event.target - clicked button
|
|
188
|
+
*/
|
|
189
|
+
onCarouselBtnClick(event) {
|
|
190
|
+
let me = this,
|
|
191
|
+
action = event.target.data.carouselaction,
|
|
192
|
+
store = me.store,
|
|
193
|
+
countItems = store.getCount(),
|
|
194
|
+
vdom = me.vdom,
|
|
195
|
+
index = me.itemIndex,
|
|
196
|
+
positionArray = me.positionArray,
|
|
197
|
+
root = me.#getItemRoot(),
|
|
198
|
+
newRecordIndex, positionCls, recordIndex, vdomCls;
|
|
199
|
+
|
|
200
|
+
if (action === 'forward') {
|
|
201
|
+
vdomCls = 'neo-carousel-translate-x-full';
|
|
202
|
+
index = index + 2
|
|
203
|
+
newRecordIndex = index % countItems;
|
|
204
|
+
|
|
205
|
+
me.itemIndex = newRecordIndex - 1;
|
|
206
|
+
positionArray = me.#arrayRotate(positionArray, -1);
|
|
207
|
+
} else {
|
|
208
|
+
vdomCls = 'neo-carousel--translate-x-full';
|
|
209
|
+
index = index - 2;
|
|
210
|
+
newRecordIndex = index < 0 ? (countItems + index) : index;
|
|
211
|
+
|
|
212
|
+
me.itemIndex = newRecordIndex + 1;
|
|
213
|
+
positionArray = me.#arrayRotate(positionArray, 1);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
me.positionArray = positionArray;
|
|
217
|
+
|
|
218
|
+
root.cn = root.cn.map(function(cn, mappingIndex) {
|
|
219
|
+
positionCls = positionArray[mappingIndex];
|
|
220
|
+
recordIndex = cn.recordIndex;
|
|
221
|
+
|
|
222
|
+
cn.cls.shift();
|
|
223
|
+
cn.cls.unshift(positionCls);
|
|
224
|
+
|
|
225
|
+
// Update new Record
|
|
226
|
+
if (positionCls === vdomCls) {
|
|
227
|
+
recordIndex = newRecordIndex;
|
|
228
|
+
cn = me.createItem(recordIndex, mappingIndex);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return cn;
|
|
232
|
+
})
|
|
233
|
+
|
|
234
|
+
me.vdom = vdom;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* As soon as the store is loaded we want to
|
|
239
|
+
* - create the three items
|
|
240
|
+
* - fill the first three records
|
|
241
|
+
*/
|
|
242
|
+
onStoreLoad() {
|
|
243
|
+
this.createBaseItems();
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* HELPERS
|
|
248
|
+
*/
|
|
249
|
+
#getItemRoot() {
|
|
250
|
+
return this.vdom.cn[0].cn[1];
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
#arrayRotate(arr, n) {
|
|
254
|
+
return n ? [...arr.slice(n, arr.length), ...arr.slice(0, n)] : arr;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
#formatTpl(tpl, record) {
|
|
258
|
+
let resultStr = tpl.replace(/\$\{[^\}]+\}/g, (m) => record[m.slice(2, -1).trim()]);
|
|
259
|
+
|
|
260
|
+
return JSON.parse(resultStr);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
Neo.applyClassConfig(Carousel);
|
|
265
|
+
|
|
266
|
+
export default Carousel;
|
package/src/container/Base.mjs
CHANGED
|
@@ -254,13 +254,13 @@ class Base extends Component {
|
|
|
254
254
|
* @protected
|
|
255
255
|
*/
|
|
256
256
|
createItems() {
|
|
257
|
-
let me
|
|
258
|
-
items
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
257
|
+
let me = this,
|
|
258
|
+
items = me._items,
|
|
259
|
+
itemsRoot = me.getVdomItemsRoot(),
|
|
260
|
+
layout = me.layout,
|
|
261
|
+
vdom = me.vdom;
|
|
262
262
|
|
|
263
|
-
|
|
263
|
+
itemsRoot.cn = [];
|
|
264
264
|
|
|
265
265
|
items.forEach((item, index) => {
|
|
266
266
|
items[index] = item = me.createItem(item, index);
|
|
@@ -269,7 +269,7 @@ class Base extends Component {
|
|
|
269
269
|
layout.applyChildAttributes(item, index);
|
|
270
270
|
}
|
|
271
271
|
|
|
272
|
-
|
|
272
|
+
itemsRoot.cn.push(item.vdom);
|
|
273
273
|
});
|
|
274
274
|
|
|
275
275
|
me.vdom = vdom;
|
|
@@ -316,7 +316,7 @@ class Base extends Component {
|
|
|
316
316
|
* @returns {Object} The new vdom items root
|
|
317
317
|
*/
|
|
318
318
|
getVdomItemsRoot() {
|
|
319
|
-
return this.
|
|
319
|
+
return this.getVdomRoot();
|
|
320
320
|
}
|
|
321
321
|
|
|
322
322
|
/**
|
|
@@ -377,7 +377,7 @@ class Base extends Component {
|
|
|
377
377
|
|
|
378
378
|
me.items = items;
|
|
379
379
|
|
|
380
|
-
|
|
380
|
+
me.getVdomItemsRoot().cn.splice(index, 0, item.vdom);
|
|
381
381
|
}
|
|
382
382
|
|
|
383
383
|
if (silent) {
|
|
@@ -385,8 +385,8 @@ class Base extends Component {
|
|
|
385
385
|
} else {
|
|
386
386
|
me.promiseVdomUpdate().then(() => {
|
|
387
387
|
me.fire('insert', {
|
|
388
|
-
index
|
|
389
|
-
item
|
|
388
|
+
index,
|
|
389
|
+
item
|
|
390
390
|
});
|
|
391
391
|
});
|
|
392
392
|
}
|
|
@@ -427,9 +427,7 @@ class Base extends Component {
|
|
|
427
427
|
let me = this,
|
|
428
428
|
item = me.items[fromIndex];
|
|
429
429
|
|
|
430
|
-
|
|
431
|
-
me.switchItems(toIndex, fromIndex);
|
|
432
|
-
}
|
|
430
|
+
fromIndex !== toIndex && me.switchItems(toIndex, fromIndex);
|
|
433
431
|
|
|
434
432
|
return item;
|
|
435
433
|
}
|
|
@@ -502,20 +500,16 @@ class Base extends Component {
|
|
|
502
500
|
let me = this,
|
|
503
501
|
items = me.items,
|
|
504
502
|
vdom = me.vdom,
|
|
505
|
-
|
|
503
|
+
item;
|
|
506
504
|
|
|
507
505
|
if (index >= items.length) {
|
|
508
506
|
Neo.warn('Container.removeAt: index >= items.length. ' + me.id);
|
|
509
507
|
} else {
|
|
510
508
|
item = items[index];
|
|
511
509
|
|
|
512
|
-
// console.log('remove item', item.id);
|
|
513
|
-
|
|
514
510
|
items.splice(index, 1);
|
|
515
511
|
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
cn.splice(index, 1);
|
|
512
|
+
me.getVdomItemsRoot().cn.splice(index, 1);
|
|
519
513
|
|
|
520
514
|
me[silent && !destroyItem ? '_vdom' : 'vdom'] = vdom;
|
|
521
515
|
|
|
@@ -548,8 +542,8 @@ class Base extends Component {
|
|
|
548
542
|
item2Index = Neo.isNumber(item2id) ? item2id : me.indexOf(item2id),
|
|
549
543
|
vdom = me.vdom;
|
|
550
544
|
|
|
551
|
-
NeoArray.move(me.items,
|
|
552
|
-
NeoArray.move(me.getVdomItemsRoot(), item2Index, item1Index);
|
|
545
|
+
NeoArray.move(me.items, item2Index, item1Index);
|
|
546
|
+
NeoArray.move(me.getVdomItemsRoot().cn, item2Index, item1Index);
|
|
553
547
|
|
|
554
548
|
me.vdom = vdom;
|
|
555
549
|
}
|
package/src/container/Panel.mjs
CHANGED
|
@@ -132,7 +132,7 @@ class Panel extends Container {
|
|
|
132
132
|
config = {
|
|
133
133
|
ntype : 'container',
|
|
134
134
|
flex : 1,
|
|
135
|
-
items
|
|
135
|
+
items,
|
|
136
136
|
itemDefaults: me.itemDefaults,
|
|
137
137
|
...containerConfig
|
|
138
138
|
};
|
|
@@ -155,7 +155,7 @@ class Panel extends Container {
|
|
|
155
155
|
config = {
|
|
156
156
|
ntype : 'container',
|
|
157
157
|
flex : 1,
|
|
158
|
-
items
|
|
158
|
+
items,
|
|
159
159
|
itemDefaults: me.itemDefaults,
|
|
160
160
|
...containerConfig
|
|
161
161
|
};
|
package/src/form/Container.mjs
CHANGED
|
@@ -24,7 +24,7 @@ class Container extends BaseContainer {
|
|
|
24
24
|
*/
|
|
25
25
|
cls: ['neo-form-container'],
|
|
26
26
|
/**
|
|
27
|
-
* @member {Object} vdom={tag: 'form',cn:
|
|
27
|
+
* @member {Object} vdom={tag: 'form',cn:[],onsubmit:'return false;'}
|
|
28
28
|
*/
|
|
29
29
|
vdom:
|
|
30
30
|
{tag: 'form', cn: [], onsubmit: 'return false;'}
|
|
@@ -57,9 +57,7 @@ class Container extends BaseContainer {
|
|
|
57
57
|
fields = [];
|
|
58
58
|
|
|
59
59
|
children.forEach(item => {
|
|
60
|
-
|
|
61
|
-
fields.push(item);
|
|
62
|
-
}
|
|
60
|
+
item instanceof BaseField && fields.push(item);
|
|
63
61
|
});
|
|
64
62
|
|
|
65
63
|
return fields;
|
package/src/form/Fieldset.mjs
CHANGED
|
@@ -189,9 +189,7 @@ class Fieldset extends Container {
|
|
|
189
189
|
onConstructed() {
|
|
190
190
|
super.onConstructed();
|
|
191
191
|
|
|
192
|
-
|
|
193
|
-
this.afterSetCollapsed(true, false);
|
|
194
|
-
}
|
|
192
|
+
this.collapsed && this.afterSetCollapsed(true, false);
|
|
195
193
|
}
|
|
196
194
|
|
|
197
195
|
/**
|
|
@@ -221,16 +219,16 @@ class Fieldset extends Container {
|
|
|
221
219
|
} else {
|
|
222
220
|
if (me.legend) {
|
|
223
221
|
me.legend.setSilent({
|
|
224
|
-
iconCls
|
|
225
|
-
text
|
|
222
|
+
iconCls,
|
|
223
|
+
text: title
|
|
226
224
|
});
|
|
227
225
|
|
|
228
226
|
delete me.legend.vdom.reomveDom;
|
|
229
227
|
} else {
|
|
230
228
|
me.legend = me.insert(0, {
|
|
231
|
-
module
|
|
232
|
-
iconCls
|
|
233
|
-
text
|
|
229
|
+
module: Legend,
|
|
230
|
+
iconCls,
|
|
231
|
+
text : title,
|
|
234
232
|
...me.legendConfig
|
|
235
233
|
});
|
|
236
234
|
}
|
package/src/table/Container.mjs
CHANGED
|
@@ -357,6 +357,13 @@ class Container extends BaseContainer {
|
|
|
357
357
|
return this.vdom.cn[0];
|
|
358
358
|
}
|
|
359
359
|
|
|
360
|
+
/**
|
|
361
|
+
* @returns {Object[]} The new vdom items root
|
|
362
|
+
*/
|
|
363
|
+
getVdomItemsRoot() {
|
|
364
|
+
return this.vdom.cn[0];
|
|
365
|
+
}
|
|
366
|
+
|
|
360
367
|
/**
|
|
361
368
|
* @returns {Neo.table.View}
|
|
362
369
|
*/
|
|
@@ -128,14 +128,6 @@ class Toolbar extends BaseToolbar {
|
|
|
128
128
|
return 'base';
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
/**
|
|
132
|
-
* Specify a different vdom items root if needed (useful in case this container uses a wrapper node).
|
|
133
|
-
* @returns {Object} The new vdom items root
|
|
134
|
-
*/
|
|
135
|
-
getVdomItemsRoot() {
|
|
136
|
-
return this.vdom.cn[0].cn;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
131
|
/**
|
|
140
132
|
* Specify a different vdom root if needed to apply the top level style attributes on a different level.
|
|
141
133
|
* Make sure to use getVnodeRoot() as well, to keep the vdom & vnode trees in sync.
|