neo.mjs 4.6.10 → 4.6.12
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/.github/CONCEPT.md +3 -2
- package/examples/{toast → component/toast}/MainContainer.mjs +18 -17
- package/examples/{toast → component/toast}/MainContainerController.mjs +5 -5
- package/examples/{toast → component/toast}/app.mjs +1 -1
- package/examples/{toast → component/toast}/index.html +2 -2
- package/examples/component/toast/neo-config.json +7 -0
- package/examples/{toast → component/toast}/resources/highlight/CHANGES.md +0 -0
- package/examples/{toast → component/toast}/resources/highlight/LICENSE +0 -0
- package/examples/{toast → component/toast}/resources/highlight/README.md +0 -0
- package/examples/{toast → component/toast}/resources/highlight/highlight.pack.js +0 -0
- package/examples/{toast → component/toast}/resources/highlightjs-custom-dark-theme.css +0 -0
- package/examples/{toast → component/toast}/resources/highlightjs-custom-github-theme.css +0 -0
- package/package.json +2 -2
- package/resources/scss/src/form/field/CheckBox.scss +13 -15
- package/resources/scss/src/form/field/Radio.scss +0 -45
- package/resources/scss/theme-dark/form/_all.scss +0 -1
- package/resources/scss/theme-dark/form/field/CheckBox.scss +11 -5
- package/resources/scss/theme-light/form/_all.scss +0 -1
- package/resources/scss/theme-light/form/field/CheckBox.scss +11 -5
- package/src/Neo.mjs +18 -41
- package/src/component/Base.mjs +4 -6
- package/src/form/field/CheckBox.mjs +29 -38
- package/src/form/field/Radio.mjs +9 -42
- package/src/main/DomEvents.mjs +19 -21
- package/src/manager/DomEvent.mjs +4 -4
- package/src/util/Array.mjs +13 -2
- package/examples/toast/neo-config.json +0 -7
- package/resources/scss/theme-dark/form/field/Radio.scss +0 -11
- package/resources/scss/theme-light/form/field/Radio.scss +0 -11
package/.github/CONCEPT.md
CHANGED
@@ -181,8 +181,9 @@ Pros:
|
|
181
181
|
|
182
182
|
Cons:
|
183
183
|
1. neo.mjs is not using TypeScript (you could do it for your own app code, in case you want to use a build process)
|
184
|
-
2. Firefox
|
185
|
-
|
184
|
+
2. Firefox does not support JS modules inside workers yet, so the development mode only runs in Chromium (Chrome & Edge),
|
185
|
+
as well as Safari. Mozilla is actively working on it.
|
186
|
+
Of course the dist (dev&prod) versions do run fine in Firefox as well.
|
186
187
|
3. Several npm dependencies can not easily get used, since they do not use a correct ES6 import syntax (e.g. missing file names)
|
187
188
|
|
188
189
|
## No string based pseudo XML templates
|
@@ -1,20 +1,20 @@
|
|
1
|
-
import Button from '
|
2
|
-
import CheckBox from '
|
3
|
-
import Component from '
|
4
|
-
import FormContainer from '
|
1
|
+
import Button from '../../../src/button/Base.mjs';
|
2
|
+
import CheckBox from '../../../src/form/field/CheckBox.mjs';
|
3
|
+
import Component from '../../../src/component/Base.mjs';
|
4
|
+
import FormContainer from '../../../src/form/Container.mjs';
|
5
5
|
import MainContainerController from './MainContainerController.mjs';
|
6
|
-
import NumberField from '
|
7
|
-
import SelectField from '
|
8
|
-
import TextField from '
|
9
|
-
import Viewport from '
|
6
|
+
import NumberField from '../../../src/form/field/Number.mjs';
|
7
|
+
import SelectField from '../../../src/form/field/Select.mjs';
|
8
|
+
import TextField from '../../../src/form/field/Text.mjs';
|
9
|
+
import Viewport from '../../../src/container/Viewport.mjs';
|
10
10
|
|
11
11
|
/**
|
12
|
-
* @class Neo.examples.toast.MainContainer
|
12
|
+
* @class Neo.examples.component.toast.MainContainer
|
13
13
|
* @extends Neo.container.Viewport
|
14
14
|
*/
|
15
15
|
class MainContainer extends Viewport {
|
16
16
|
static getConfig() {return {
|
17
|
-
className : 'Neo.examples.toast.MainContainer',
|
17
|
+
className : 'Neo.examples.component.toast.MainContainer',
|
18
18
|
autoMount : true,
|
19
19
|
controller: MainContainerController,
|
20
20
|
layout: {ntype: 'hbox', align: 'stretch'},
|
@@ -79,12 +79,13 @@ class MainContainer extends Viewport {
|
|
79
79
|
name : 'timeout',
|
80
80
|
maxValue : 99999
|
81
81
|
}, {
|
82
|
-
module
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
82
|
+
module : CheckBox,
|
83
|
+
labelPosition: 'left',
|
84
|
+
labelText : 'Closable',
|
85
|
+
labelWidth : 70,
|
86
|
+
name : 'closable',
|
87
|
+
reference : 'closable',
|
88
|
+
style : {padding: '8px 0 10px 9px'}
|
88
89
|
}, {
|
89
90
|
module : Button,
|
90
91
|
reference: 'creation-button',
|
@@ -108,7 +109,7 @@ class MainContainer extends Viewport {
|
|
108
109
|
|
109
110
|
itemTpl: data => {
|
110
111
|
return [
|
111
|
-
{cls: 'import', innerHTML: 'import Toast from \'../../../../node_modules/neo.mjs/src/
|
112
|
+
{cls: 'import', innerHTML: 'import Toast from \'../../../../node_modules/neo.mjs/src/component/Toast.mjs\';'},
|
112
113
|
{innerHTML: 'Neo.toast({'},
|
113
114
|
{cls: 'tab', cn: [
|
114
115
|
{cls: 'grey', innerHTML: '/* mandatory */'},
|
@@ -1,17 +1,17 @@
|
|
1
|
-
import ComponentController from '
|
2
|
-
import Toast from '
|
1
|
+
import ComponentController from '../../../src/controller/Component.mjs';
|
2
|
+
import Toast from '../../../src/component/Toast.mjs';
|
3
3
|
|
4
4
|
/**
|
5
|
-
* @class Neo.examples.toast.MainContainerController
|
5
|
+
* @class Neo.examples.component.toast.MainContainerController
|
6
6
|
* @extends Neo.controller.Component
|
7
7
|
*/
|
8
8
|
class MainContainerController extends ComponentController {
|
9
9
|
static getConfig() {return {
|
10
10
|
/**
|
11
|
-
* @member {String} className='Neo.examples.toast.MainContainerController'
|
11
|
+
* @member {String} className='Neo.examples.component.toast.MainContainerController'
|
12
12
|
* @protected
|
13
13
|
*/
|
14
|
-
className: 'Neo.examples.toast.MainContainerController'
|
14
|
+
className: 'Neo.examples.component.toast.MainContainerController'
|
15
15
|
}}
|
16
16
|
|
17
17
|
/**
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<head>
|
4
4
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
5
5
|
<meta charset="UTF-8">
|
6
|
-
<title>Neo
|
6
|
+
<title>Neo Toast Component</title>
|
7
7
|
|
8
8
|
<style>
|
9
9
|
.output {
|
@@ -22,6 +22,6 @@
|
|
22
22
|
</head>
|
23
23
|
</head>
|
24
24
|
<body>
|
25
|
-
<script src="
|
25
|
+
<script src="../../../src/MicroLoader.mjs" type="module"></script>
|
26
26
|
</body>
|
27
27
|
</html>
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "neo.mjs",
|
3
|
-
"version": "4.6.
|
3
|
+
"version": "4.6.12",
|
4
4
|
"description": "The webworkers driven UI framework",
|
5
5
|
"type": "module",
|
6
6
|
"repository": {
|
@@ -47,7 +47,7 @@
|
|
47
47
|
"autoprefixer": "^10.4.13",
|
48
48
|
"chalk": "^5.2.0",
|
49
49
|
"clean-webpack-plugin": "^4.0.0",
|
50
|
-
"commander": "^
|
50
|
+
"commander": "^10.0.0",
|
51
51
|
"cssnano": "^5.1.14",
|
52
52
|
"envinfo": "^7.8.1",
|
53
53
|
"fs-extra": "^11.1.0",
|
@@ -1,30 +1,27 @@
|
|
1
1
|
.neo-checkboxfield {
|
2
2
|
.neo-checkbox-input {
|
3
|
-
|
3
|
+
display: none;
|
4
4
|
|
5
5
|
&:checked {
|
6
|
-
|
7
|
-
color
|
8
|
-
content : "\f00c";
|
9
|
-
font-weight: 900;
|
6
|
+
+.neo-checkbox-icon {
|
7
|
+
color: v(checkboxfield-color-checked);
|
10
8
|
}
|
11
9
|
}
|
12
10
|
|
13
|
-
&::after {
|
14
|
-
color : v(checkboxfield-color);
|
15
|
-
content : "\f0c8";
|
16
|
-
cursor : pointer;
|
17
|
-
display : inline-block;
|
18
|
-
font-family: "Font Awesome 5 Free";
|
19
|
-
font-size : 14px;
|
20
|
-
width : 20px;
|
21
|
-
}
|
22
|
-
|
23
11
|
&:focus {
|
24
12
|
outline : 0;
|
25
13
|
}
|
26
14
|
}
|
27
15
|
|
16
|
+
.neo-checkbox-icon {
|
17
|
+
color : v(checkboxfield-color);
|
18
|
+
cursor : pointer;
|
19
|
+
display : inline-block;
|
20
|
+
font-family: v(checkboxfield-icon-font-family);
|
21
|
+
font-size : v(checkboxfield-icon-font-size);
|
22
|
+
width : 20px;
|
23
|
+
}
|
24
|
+
|
28
25
|
.neo-checkbox-label {
|
29
26
|
color : v(textfield-label-color);
|
30
27
|
display : inline-block;
|
@@ -43,6 +40,7 @@
|
|
43
40
|
|
44
41
|
.neo-checkbox-label {
|
45
42
|
display: block;
|
43
|
+
margin : v(checkboxfield-label-top-margin);
|
46
44
|
}
|
47
45
|
}
|
48
46
|
}
|
@@ -1,48 +1,3 @@
|
|
1
1
|
.neo-radiofield {
|
2
|
-
.neo-radio-input {
|
3
|
-
appearance: none;
|
4
2
|
|
5
|
-
&:checked {
|
6
|
-
&::after {
|
7
|
-
color : v(radiofield-checked-color);
|
8
|
-
content : "\f00c";
|
9
|
-
font-weight: 900;
|
10
|
-
}
|
11
|
-
}
|
12
|
-
|
13
|
-
&::after {
|
14
|
-
color : v(radiofield-color);
|
15
|
-
content : "\f111";
|
16
|
-
cursor : pointer;
|
17
|
-
display : inline-block;
|
18
|
-
font-family: "Font Awesome 5 Free";
|
19
|
-
font-size : 14px;
|
20
|
-
width : 20px;
|
21
|
-
}
|
22
|
-
|
23
|
-
&:focus {
|
24
|
-
outline : 0;
|
25
|
-
}
|
26
|
-
}
|
27
|
-
|
28
|
-
.neo-radio-label {
|
29
|
-
color : v(textfield-label-color);
|
30
|
-
display : inline-block;
|
31
|
-
user-select: none;
|
32
|
-
}
|
33
|
-
|
34
|
-
.neo-radio-value-label {
|
35
|
-
color : v(textfield-label-color);
|
36
|
-
user-select: none;
|
37
|
-
}
|
38
|
-
|
39
|
-
&.neo-label-top {
|
40
|
-
.neo-radio-input {
|
41
|
-
margin-left: 0;
|
42
|
-
}
|
43
|
-
|
44
|
-
.neo-radio-label {
|
45
|
-
display: block;
|
46
|
-
}
|
47
|
-
}
|
48
3
|
}
|
@@ -1,11 +1,17 @@
|
|
1
1
|
$neoMap: map-merge($neoMap, (
|
2
|
-
'checkboxfield-color'
|
3
|
-
'checkboxfield-checked
|
2
|
+
'checkboxfield-color' : #eee,
|
3
|
+
'checkboxfield-color-checked' : #64B5F6,
|
4
|
+
'checkboxfield-icon-font-family': "Font Awesome 5 Free",
|
5
|
+
'checkboxfield-icon-font-size' : 14px,
|
6
|
+
'checkboxfield-label-top-margin': 0 0 3px
|
4
7
|
));
|
5
8
|
|
6
9
|
@if $useCssVars == true {
|
7
10
|
:root .neo-theme-dark { // .neo-checkboxfield
|
8
|
-
--checkboxfield-color
|
9
|
-
--checkboxfield-checked
|
11
|
+
--checkboxfield-color : #{neo(checkboxfield-color)};
|
12
|
+
--checkboxfield-color-checked : #{neo(checkboxfield-color-checked)};
|
13
|
+
--checkboxfield-icon-font-family: #{neo(checkboxfield-icon-font-family)};
|
14
|
+
--checkboxfield-icon-font-size : #{neo(checkboxfield-icon-font-size)};
|
15
|
+
--checkboxfield-label-top-margin: #{neo(checkboxfield-label-top-margin)};
|
10
16
|
}
|
11
|
-
}
|
17
|
+
}
|
@@ -1,11 +1,17 @@
|
|
1
1
|
$neoMap: map-merge($neoMap, (
|
2
|
-
'checkboxfield-color'
|
3
|
-
'checkboxfield-checked
|
2
|
+
'checkboxfield-color' : #aaa,
|
3
|
+
'checkboxfield-color-checked' : #1c60a0,
|
4
|
+
'checkboxfield-icon-font-family': '"Font Awesome 5 Free"',
|
5
|
+
'checkboxfield-icon-font-size' : 14px,
|
6
|
+
'checkboxfield-label-top-margin': 0 0 3px
|
4
7
|
));
|
5
8
|
|
6
9
|
@if $useCssVars == true {
|
7
10
|
:root .neo-theme-light { // .neo-checkboxfield
|
8
|
-
--checkboxfield-color
|
9
|
-
--checkboxfield-checked
|
11
|
+
--checkboxfield-color : #{neo(checkboxfield-color)};
|
12
|
+
--checkboxfield-color-checked : #{neo(checkboxfield-color-checked)};
|
13
|
+
--checkboxfield-icon-font-family: #{neo(checkboxfield-icon-font-family)};
|
14
|
+
--checkboxfield-icon-font-size : #{neo(checkboxfield-icon-font-size)};
|
15
|
+
--checkboxfield-label-top-margin: #{neo(checkboxfield-label-top-margin)};
|
10
16
|
}
|
11
|
-
}
|
17
|
+
}
|
package/src/Neo.mjs
CHANGED
@@ -214,48 +214,30 @@ Neo = globalThis.Neo = Object.assign({
|
|
214
214
|
/**
|
215
215
|
* @memberOf module:Neo
|
216
216
|
* @param {Object|Array|*} obj
|
217
|
-
* @param {Boolean}
|
218
|
-
* @param {Boolean}
|
217
|
+
* @param {Boolean} deep=false Set this to true in case you want to clone nested objects as well
|
218
|
+
* @param {Boolean} ignoreNeoInstances=false returns existing instances if set to true
|
219
219
|
* @returns {Object|Array|*} the cloned input
|
220
220
|
*/
|
221
221
|
clone(obj, deep=false, ignoreNeoInstances=false) {
|
222
222
|
let out;
|
223
223
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
return new Date(obj.valueOf());
|
231
|
-
}
|
232
|
-
|
233
|
-
case 'Map': {
|
234
|
-
return new Map(obj); // shallow copy
|
235
|
-
}
|
224
|
+
return {
|
225
|
+
Array : () => !deep ? [...obj] : [...obj.map(val => Neo.clone(val, deep, ignoreNeoInstances))],
|
226
|
+
Date : () => new Date(obj.valueOf()),
|
227
|
+
Map : () => new Map(obj), // shallow copy
|
228
|
+
NeoInstance: () => ignoreNeoInstances ? obj : this.cloneNeoInstance(obj),
|
229
|
+
Set : () => new Set(obj),
|
236
230
|
|
237
|
-
|
238
|
-
return ignoreNeoInstances ? obj : this.cloneNeoInstance(obj);
|
239
|
-
}
|
240
|
-
|
241
|
-
case 'Object': {
|
231
|
+
Object: () => {
|
242
232
|
out = {};
|
243
233
|
|
244
234
|
Object.entries(obj).forEach(([key, value]) => {
|
245
235
|
out[key] = !deep ? value : Neo.clone(value, deep, ignoreNeoInstances);
|
246
236
|
});
|
247
237
|
|
248
|
-
return out
|
238
|
+
return out
|
249
239
|
}
|
250
|
-
|
251
|
-
case 'Set': {
|
252
|
-
return new Set(obj); // shallow copy
|
253
|
-
}
|
254
|
-
|
255
|
-
default: {
|
256
|
-
return obj; // return all other data types
|
257
|
-
}
|
258
|
-
}
|
240
|
+
}[Neo.typeOf(obj)]?.() || obj
|
259
241
|
},
|
260
242
|
|
261
243
|
/**
|
@@ -469,23 +451,18 @@ Neo = globalThis.Neo = Object.assign({
|
|
469
451
|
return null;
|
470
452
|
}
|
471
453
|
|
472
|
-
|
473
|
-
|
454
|
+
return {
|
455
|
+
function: () => {
|
474
456
|
if (item.prototype?.constructor.isClass) {
|
475
|
-
return 'NeoClass'
|
457
|
+
return 'NeoClass'
|
476
458
|
}
|
477
|
-
|
478
|
-
|
479
|
-
}
|
480
|
-
|
481
|
-
case 'object': {
|
459
|
+
},
|
460
|
+
object: () => {
|
482
461
|
if (item.constructor.isClass && item instanceof Neo.core.Base) {
|
483
|
-
return 'NeoInstance'
|
462
|
+
return 'NeoInstance'
|
484
463
|
}
|
485
464
|
}
|
486
|
-
}
|
487
|
-
|
488
|
-
return item.constructor.name;
|
465
|
+
}[typeof item]?.() || item.constructor.name
|
489
466
|
}
|
490
467
|
}, Neo);
|
491
468
|
|
package/src/component/Base.mjs
CHANGED
@@ -1730,11 +1730,12 @@ class Base extends CoreBase {
|
|
1730
1730
|
/**
|
1731
1731
|
* Toggle a cls inside the vdomRoot of the component
|
1732
1732
|
* @param {String} value
|
1733
|
+
* @param {Boolean} [add] Use this param to enforce an add() or remove() operation.
|
1733
1734
|
*/
|
1734
|
-
toggleCls(value) {
|
1735
|
+
toggleCls(value, add) {
|
1735
1736
|
let cls = this.cls;
|
1736
1737
|
|
1737
|
-
NeoArray.toggle(cls, value);
|
1738
|
+
NeoArray.toggle(cls, value, add);
|
1738
1739
|
this.cls = cls;
|
1739
1740
|
}
|
1740
1741
|
|
@@ -1841,10 +1842,7 @@ class Base extends CoreBase {
|
|
1841
1842
|
|
1842
1843
|
opts = {
|
1843
1844
|
action: 'updateDom',
|
1844
|
-
deltas: [{
|
1845
|
-
id : id,
|
1846
|
-
style: delta
|
1847
|
-
}]
|
1845
|
+
deltas: [{id, style: delta}]
|
1848
1846
|
};
|
1849
1847
|
|
1850
1848
|
if (Neo.currentWorker.isSharedWorker) {
|
@@ -35,15 +35,18 @@ class CheckBox extends Base {
|
|
35
35
|
* @member {Boolean} checked_=false
|
36
36
|
*/
|
37
37
|
checked_: false,
|
38
|
-
/**
|
39
|
-
* True to change the checked state when clicking on the value label
|
40
|
-
* @member {Boolean} enableLabelClicks_=true
|
41
|
-
*/
|
42
|
-
enableLabelClicks_: true,
|
43
38
|
/**
|
44
39
|
* @member {Boolean} hideLabel_=false
|
45
40
|
*/
|
46
41
|
hideLabel_: false,
|
42
|
+
/**
|
43
|
+
* @member {String[]} iconCls=['far','fa-square']
|
44
|
+
*/
|
45
|
+
iconCls: ['far', 'fa-square'],
|
46
|
+
/**
|
47
|
+
* @member {String[]} iconClsChecked=['fas','fa-check']
|
48
|
+
*/
|
49
|
+
iconClsChecked: ['fas', 'fa-check'],
|
47
50
|
/**
|
48
51
|
* @member {String} inputType_='checkbox'
|
49
52
|
*/
|
@@ -82,10 +85,11 @@ class CheckBox extends Base {
|
|
82
85
|
* @member {Object} _vdom
|
83
86
|
*/
|
84
87
|
_vdom:
|
85
|
-
{cn: [
|
86
|
-
{tag: '
|
88
|
+
{tag: 'label', cn: [
|
89
|
+
{tag: 'span', cls: []},
|
87
90
|
{tag: 'input', cls: ['neo-checkbox-input']},
|
88
|
-
{tag: '
|
91
|
+
{tag: 'i', cls: ['neo-checkbox-icon']},
|
92
|
+
{tag: 'span', cls: ['neo-checkbox-value-label']}
|
89
93
|
]}
|
90
94
|
}}
|
91
95
|
|
@@ -108,9 +112,14 @@ class CheckBox extends Base {
|
|
108
112
|
* @protected
|
109
113
|
*/
|
110
114
|
afterSetChecked(value, oldValue) {
|
111
|
-
let me
|
115
|
+
let me = this,
|
116
|
+
iconCls = me.vdom.cn[2].cls;
|
112
117
|
|
113
118
|
me.vdom.cn[1].checked = value;
|
119
|
+
|
120
|
+
NeoArray.toggle(iconCls, me.iconClsChecked, value);
|
121
|
+
NeoArray.toggle(iconCls, me.iconCls, !value);
|
122
|
+
|
114
123
|
me.update();
|
115
124
|
|
116
125
|
if (oldValue !== undefined) {
|
@@ -122,25 +131,6 @@ class CheckBox extends Base {
|
|
122
131
|
}
|
123
132
|
}
|
124
133
|
|
125
|
-
/**
|
126
|
-
* Triggered after the enableLabelClicks config got changed
|
127
|
-
* @param {Boolean} value
|
128
|
-
* @param {Boolean} oldValue
|
129
|
-
* @protected
|
130
|
-
*/
|
131
|
-
afterSetEnableLabelClicks(value, oldValue) {
|
132
|
-
let me = this,
|
133
|
-
label = me.vdom.cn[2];
|
134
|
-
|
135
|
-
if (value) {
|
136
|
-
label.for = me.getInputElId();
|
137
|
-
} else {
|
138
|
-
delete label.for;
|
139
|
-
}
|
140
|
-
|
141
|
-
me.update();
|
142
|
-
}
|
143
|
-
|
144
134
|
/**
|
145
135
|
* Triggered after the hideLabel config got changed
|
146
136
|
* @param {String} value
|
@@ -164,7 +154,8 @@ class CheckBox extends Base {
|
|
164
154
|
|
165
155
|
vdom.cn[0].id = me.getLabelId();
|
166
156
|
vdom.cn[1].id = me.getInputElId();
|
167
|
-
vdom.cn[2].id = me.
|
157
|
+
vdom.cn[2].id = me.getIconElId();
|
158
|
+
vdom.cn[3].id = me.getValueLabelId();
|
168
159
|
|
169
160
|
// silent vdom update, the super call will trigger the engine
|
170
161
|
super.afterSetId(value, oldValue);
|
@@ -272,7 +263,7 @@ class CheckBox extends Base {
|
|
272
263
|
*/
|
273
264
|
afterSetValueLabelText(value, oldValue) {
|
274
265
|
let me = this,
|
275
|
-
valueLabel = me.vdom.cn[
|
266
|
+
valueLabel = me.vdom.cn[3],
|
276
267
|
showLabel = !!value; // hide the label, in case value === null || value === ''
|
277
268
|
|
278
269
|
if (showLabel) {
|
@@ -304,6 +295,13 @@ class CheckBox extends Base {
|
|
304
295
|
return this.beforeSetEnumValue(value, oldValue, 'labelPosition');
|
305
296
|
}
|
306
297
|
|
298
|
+
/**
|
299
|
+
* @returns {String}
|
300
|
+
*/
|
301
|
+
getIconElId() {
|
302
|
+
return `${this.id}__icon`;
|
303
|
+
}
|
304
|
+
|
307
305
|
/**
|
308
306
|
* @returns {String}
|
309
307
|
*/
|
@@ -333,17 +331,10 @@ class CheckBox extends Base {
|
|
333
331
|
let me = this,
|
334
332
|
checked = data.target.checked;
|
335
333
|
|
336
|
-
me._checked = checked; // silent update
|
337
|
-
|
338
334
|
// keep the vdom & vnode in sync for future updates
|
339
|
-
me.vdom.cn[1].checked = checked;
|
340
335
|
me.vnode.childNodes[me.hideLabel ? 0 : 1].attributes.checked = `${checked}`;
|
341
336
|
|
342
|
-
me.
|
343
|
-
component: me,
|
344
|
-
oldValue : !checked,
|
345
|
-
value : checked
|
346
|
-
});
|
337
|
+
me.checked = checked;
|
347
338
|
}
|
348
339
|
}
|
349
340
|
|
package/src/form/field/Radio.mjs
CHANGED
@@ -18,26 +18,17 @@ class Radio extends CheckBox {
|
|
18
18
|
*/
|
19
19
|
ntype: 'radiofield',
|
20
20
|
/**
|
21
|
-
* @member {String[]} baseCls=['neo-radiofield']
|
21
|
+
* @member {String[]} baseCls=['neo-radiofield','neo-checkboxfield']
|
22
22
|
*/
|
23
|
-
baseCls: ['neo-radiofield'],
|
23
|
+
baseCls: ['neo-radiofield', 'neo-checkboxfield'],
|
24
24
|
/**
|
25
|
-
* @member {String}
|
26
|
-
*/
|
27
|
-
inputType: 'radio',
|
28
|
-
/**
|
29
|
-
* @member {String[]} labelBaseCls=['neo-radio-label']
|
25
|
+
* @member {String[]} iconCls=['far','fa-circle']
|
30
26
|
*/
|
31
|
-
|
27
|
+
iconCls: ['far', 'fa-circle'],
|
32
28
|
/**
|
33
|
-
* @member {
|
29
|
+
* @member {String} inputType='radio'
|
34
30
|
*/
|
35
|
-
|
36
|
-
{cn: [
|
37
|
-
{tag: 'label', cls: []},
|
38
|
-
{tag: 'input', cls: ['neo-radio-input']},
|
39
|
-
{tag: 'label', cls: ['neo-radio-value-label']}
|
40
|
-
]}
|
31
|
+
inputType: 'radio'
|
41
32
|
}}
|
42
33
|
|
43
34
|
/**
|
@@ -50,18 +41,7 @@ class Radio extends CheckBox {
|
|
50
41
|
super.afterSetChecked(value, oldValue);
|
51
42
|
|
52
43
|
// update radios with the same name to be unchecked
|
53
|
-
|
54
|
-
this.uncheckGroupItems();
|
55
|
-
}
|
56
|
-
}
|
57
|
-
|
58
|
-
/**
|
59
|
-
* Gets triggered when a user checks a radio input.
|
60
|
-
* @param {Object} data
|
61
|
-
*/
|
62
|
-
onInputValueChange(data) {
|
63
|
-
super.onInputValueChange(data);
|
64
|
-
this.uncheckGroupItems();
|
44
|
+
value && this.uncheckGroupItems()
|
65
45
|
}
|
66
46
|
|
67
47
|
/**
|
@@ -79,22 +59,9 @@ class Radio extends CheckBox {
|
|
79
59
|
|
80
60
|
radios.forEach(item => {
|
81
61
|
if (item.id !== me.id && item._checked) {
|
82
|
-
item.
|
83
|
-
|
84
|
-
// keep the vdom & vnode in sync for future updates
|
85
|
-
item.vdom.cn[1].checked = false;
|
86
|
-
|
87
|
-
if (item.vnode) {
|
88
|
-
item.vnode.childNodes[me.hideLabel ? 0 : 1].attributes.checked = 'false';
|
89
|
-
}
|
90
|
-
|
91
|
-
item.fire('change', {
|
92
|
-
component: me,
|
93
|
-
oldValue : true,
|
94
|
-
value : false
|
95
|
-
});
|
62
|
+
item.checked = false;
|
96
63
|
}
|
97
|
-
})
|
64
|
+
})
|
98
65
|
}
|
99
66
|
}
|
100
67
|
|
package/src/main/DomEvents.mjs
CHANGED
@@ -171,18 +171,6 @@ class DomEvents extends Base {
|
|
171
171
|
});
|
172
172
|
}
|
173
173
|
|
174
|
-
/**
|
175
|
-
* Returns the distance between two points
|
176
|
-
* @param {Number} x1 The X position of the first point
|
177
|
-
* @param {Number} y1 The Y position of the first point
|
178
|
-
* @param {Number} x2 The X position of the second point
|
179
|
-
* @param {Number} y2 The Y position of the second point
|
180
|
-
* @returns {Number}
|
181
|
-
*/
|
182
|
-
getDistance(x1, y1, x2, y2) {
|
183
|
-
return Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);
|
184
|
-
}
|
185
|
-
|
186
174
|
/**
|
187
175
|
* Local domEvent listener
|
188
176
|
* @param {Object} event
|
@@ -246,19 +234,29 @@ class DomEvents extends Base {
|
|
246
234
|
Neo.worker.Manager.sendMessage('app', config);
|
247
235
|
}
|
248
236
|
|
237
|
+
/**
|
238
|
+
* Returns the distance between two points
|
239
|
+
* @param {Number} x1 The X position of the first point
|
240
|
+
* @param {Number} y1 The Y position of the first point
|
241
|
+
* @param {Number} x2 The X position of the second point
|
242
|
+
* @param {Number} y2 The Y position of the second point
|
243
|
+
* @returns {Number}
|
244
|
+
*/
|
245
|
+
getDistance(x1, y1, x2, y2) {
|
246
|
+
return Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);
|
247
|
+
}
|
248
|
+
|
249
249
|
/**
|
250
250
|
* @param {Object} event
|
251
251
|
* @returns {Object}
|
252
252
|
*/
|
253
253
|
getEventData(event) {
|
254
|
-
let path = event.path || event.composedPath(); // FF does not support path
|
255
|
-
|
256
254
|
return {
|
257
|
-
path :
|
255
|
+
path : event.composedPath().map(e => this.getTargetData(e)),
|
258
256
|
target : this.getTargetData(event.target),
|
259
257
|
timeStamp: event.timeStamp,
|
260
258
|
type : event.type
|
261
|
-
}
|
259
|
+
}
|
262
260
|
}
|
263
261
|
|
264
262
|
/**
|
@@ -277,7 +275,7 @@ class DomEvents extends Base {
|
|
277
275
|
keyCode,
|
278
276
|
metaKey,
|
279
277
|
shiftKey
|
280
|
-
}
|
278
|
+
}
|
281
279
|
}
|
282
280
|
|
283
281
|
/**
|
@@ -301,7 +299,7 @@ class DomEvents extends Base {
|
|
301
299
|
screenX,
|
302
300
|
screenY,
|
303
301
|
shiftKey
|
304
|
-
}
|
302
|
+
}
|
305
303
|
}
|
306
304
|
|
307
305
|
/**
|
@@ -341,7 +339,7 @@ class DomEvents extends Base {
|
|
341
339
|
width : r.width,
|
342
340
|
x : r.x,
|
343
341
|
y : r.y
|
344
|
-
})
|
342
|
+
})
|
345
343
|
}
|
346
344
|
|
347
345
|
return {
|
@@ -372,7 +370,7 @@ class DomEvents extends Base {
|
|
372
370
|
style : node.style?.cssText,
|
373
371
|
tabIndex : node.tabIndex,
|
374
372
|
tagName : node.tagName?.toLowerCase()
|
375
|
-
}
|
373
|
+
}
|
376
374
|
}
|
377
375
|
|
378
376
|
/**
|
@@ -686,7 +684,7 @@ class DomEvents extends Base {
|
|
686
684
|
action : 'domEvent',
|
687
685
|
eventName: data.type,
|
688
686
|
data
|
689
|
-
})
|
687
|
+
})
|
690
688
|
}
|
691
689
|
|
692
690
|
/**
|
package/src/manager/DomEvent.mjs
CHANGED
@@ -123,7 +123,7 @@ class DomEvent extends Base {
|
|
123
123
|
if (eventName === 'focusin' || eventName === 'focusout') {
|
124
124
|
FocusManager['on' + Neo.capitalize(eventName)]({
|
125
125
|
componentPath: path,
|
126
|
-
data
|
126
|
+
data
|
127
127
|
});
|
128
128
|
|
129
129
|
break;
|
@@ -303,14 +303,14 @@ class DomEvent extends Base {
|
|
303
303
|
listenerConfig = {
|
304
304
|
bubble : config.hasOwnProperty('bubble') ? config.bubble : opts.hasOwnProperty('bubble') ? opts.bubble : true,
|
305
305
|
delegate : config.delegate,
|
306
|
-
eventName
|
307
|
-
fn
|
306
|
+
eventName,
|
307
|
+
fn,
|
308
308
|
id : listenerId,
|
309
309
|
mounted : !config.local && globalDomEvents.includes(eventName),
|
310
310
|
originalConfig: config.originalConfig,
|
311
311
|
ownerId : config.ownerId,
|
312
312
|
priority : config.priority || 1,
|
313
|
-
scope
|
313
|
+
scope,
|
314
314
|
vnodeId : config.vnodeId
|
315
315
|
};
|
316
316
|
|
package/src/util/Array.mjs
CHANGED
@@ -115,9 +115,20 @@ class NeoArray extends Base {
|
|
115
115
|
* Removes an item from an array in case it does exist, otherwise adds it
|
116
116
|
* @param {Array} arr
|
117
117
|
* @param {*} item
|
118
|
+
* @param {Boolean} [add]
|
118
119
|
*/
|
119
|
-
static toggle(arr, item) {
|
120
|
-
|
120
|
+
static toggle(arr, item, add) {
|
121
|
+
let operation;
|
122
|
+
|
123
|
+
if (add === true) {
|
124
|
+
operation = 'add';
|
125
|
+
} else if (add === false) {
|
126
|
+
operation = 'remove';
|
127
|
+
} else {
|
128
|
+
operation = this.hasItem(arr, item) ? 'remove' : 'add';
|
129
|
+
}
|
130
|
+
|
131
|
+
this[operation](arr, item);
|
121
132
|
}
|
122
133
|
|
123
134
|
/**
|
@@ -1,11 +0,0 @@
|
|
1
|
-
$neoMap: map-merge($neoMap, (
|
2
|
-
'radiofield-color' : #eee,
|
3
|
-
'radiofield-checked-color': #64B5F6
|
4
|
-
));
|
5
|
-
|
6
|
-
@if $useCssVars == true {
|
7
|
-
:root .neo-theme-dark { // .neo-radiofield
|
8
|
-
--radiofield-color : #{neo(radiofield-color)};
|
9
|
-
--radiofield-checked-color: #{neo(radiofield-checked-color)};
|
10
|
-
}
|
11
|
-
}
|
@@ -1,11 +0,0 @@
|
|
1
|
-
$neoMap: map-merge($neoMap, (
|
2
|
-
'radiofield-color' : #aaa,
|
3
|
-
'radiofield-checked-color': #1c60a0
|
4
|
-
));
|
5
|
-
|
6
|
-
@if $useCssVars == true {
|
7
|
-
:root .neo-theme-light { // .neo-radiofield
|
8
|
-
--radiofield-color : #{neo(radiofield-color)};
|
9
|
-
--radiofield-checked-color: #{neo(radiofield-checked-color)};
|
10
|
-
}
|
11
|
-
}
|