neo.mjs 5.1.13 → 5.1.14

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='5.1.13'
23
+ * @member {String} version='5.1.14'
24
24
  */
25
- version: '5.1.13'
25
+ version: '5.1.14'
26
26
  }
27
27
 
28
28
  /**
@@ -23,6 +23,9 @@ class SideNav extends Model {
23
23
  }, {
24
24
  name: 'isHeader',
25
25
  type: 'Boolean'
26
+ }, {
27
+ name: 'isValid',
28
+ type: 'Boolean'
26
29
  }, {
27
30
  name: 'name',
28
31
  type: 'String'
@@ -26,20 +26,6 @@ class FormContainerController extends Component {
26
26
  onPrevPageButtonClick(data) {
27
27
  this.getModel().data.activeIndex--;
28
28
  }
29
-
30
- /**
31
- * @param {Object} data
32
- */
33
- onValidatePageButtonClick(data) {
34
- let me = this,
35
- activeIndex = me.getModel().data.activeIndex,
36
- pagesContainer = me.getReference('pages-container'),
37
- activeCard = pagesContainer.items[activeIndex];
38
-
39
- console.log(`Current page: ${activeIndex + 1}`, activeCard.getValues());
40
-
41
- activeCard.validate();
42
- }
43
29
  }
44
30
 
45
31
  Neo.applyClassConfig(FormContainerController);
@@ -11,12 +11,49 @@ class SideNavList extends List {
11
11
  * @protected
12
12
  */
13
13
  className: 'Form.view.SideNavList',
14
+ /**
15
+ * @member {String[]} baseCls=['form-side-nav-list','neo-list']
16
+ * @protected
17
+ */
18
+ baseCls: ['form-side-nav-list', 'neo-list'],
14
19
  /**
15
20
  * @member {Boolean} useHeaders=true
16
21
  */
17
22
  useHeaders: true
18
23
  }
19
24
 
25
+ /**
26
+ * @param {Object} record
27
+ * @param {Number} index
28
+ * @returns {Object|Object[]|String} Either a config object to assign to the item, a vdom cn array or a html string
29
+ */
30
+ createItemContent(record, index) {
31
+ let itemText = record[this.displayField];
32
+
33
+ return record.isHeader ? itemText : [
34
+ {tag: 'i', cls: this.getIconCls(record)},
35
+ {html: itemText}
36
+ ];
37
+ }
38
+
39
+ /**
40
+ * @param {Object} record
41
+ * @returns {String[]}
42
+ */
43
+ getIconCls(record) {
44
+ let cls = ['neo-list-icon'];
45
+
46
+ if (record.isValid === true) {
47
+ return [...cls, 'neo-color-green', 'far', 'fa-circle-check'];
48
+ }
49
+
50
+ if (record.isValid === false) {
51
+ return [...cls, 'neo-color-red', 'far', 'fa-circle-xmark'];
52
+ }
53
+
54
+ return [...cls, 'neo-color-blue', 'far', 'fa-circle'];
55
+ }
56
+
20
57
  /**
21
58
  * Saves activeIndex & activeTitle into the closest view model
22
59
  * @param {String[]} items
@@ -1,7 +1,8 @@
1
- import BaseViewport from '../../../src/container/Viewport.mjs';
2
- import FormContainer from './FormContainer.mjs';
3
- import SideNavList from './SideNavList.mjs';
4
- import ViewportModel from './ViewportModel.mjs';
1
+ import BaseViewport from '../../../src/container/Viewport.mjs';
2
+ import FormContainer from './FormContainer.mjs';
3
+ import SideNavList from './SideNavList.mjs';
4
+ import ViewportController from './ViewportController.mjs';
5
+ import ViewportModel from './ViewportModel.mjs';
5
6
 
6
7
  /**
7
8
  * @class Form.view.Viewport
@@ -14,18 +15,24 @@ class Viewport extends BaseViewport {
14
15
  * @protected
15
16
  */
16
17
  className: 'Form.view.Viewport',
18
+ /**
19
+ * @member {Neo.controller.Component} controller=ViewportController
20
+ */
21
+ controller: ViewportController,
17
22
  /**
18
23
  * @member {Object[]} items
19
24
  */
20
25
  items: [{
21
26
  ntype: 'container',
27
+ style: {margin: '0 1em'},
22
28
  width: '300',
23
29
 
24
30
  items: [{
25
31
  flex: 'none',
26
32
  vdom: {tag: 'h1', innerHTML: 'My Form Header'}
27
33
  }, {
28
- module: SideNavList,
34
+ module : SideNavList,
35
+ reference: 'side-nav',
29
36
 
30
37
  bind: {
31
38
  headerlessActiveIndex: data => data.activeIndex,
@@ -0,0 +1,37 @@
1
+ import Component from '../../../src/controller/Component.mjs';
2
+
3
+ /**
4
+ * @class Form.view.ViewportController
5
+ * @extends Neo.controller.Component
6
+ */
7
+ class ViewportController extends Component {
8
+ static config = {
9
+ /**
10
+ * @member {String} className='Form.view.ViewportController'
11
+ * @protected
12
+ */
13
+ className: 'Form.view.ViewportController'
14
+ }
15
+
16
+ /**
17
+ * @param {Object} data
18
+ */
19
+ onValidatePageButtonClick(data) {
20
+ let me = this,
21
+ model = me.getModel(),
22
+ activeIndex = model.data.activeIndex,
23
+ pagesContainer = me.getReference('pages-container'),
24
+ store = model.getStore('sideNav'),
25
+ activeCard = pagesContainer.items[activeIndex],
26
+ listIndex = me.getReference('side-nav').getActiveIndex(activeIndex),
27
+ isValid = activeCard.validate();
28
+
29
+ console.log(`Current page: ${activeIndex + 1}`, activeCard.getValues());
30
+
31
+ store.getAt(listIndex).isValid = isValid;
32
+ }
33
+ }
34
+
35
+ Neo.applyClassConfig(ViewportController);
36
+
37
+ export default ViewportController;
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='5.1.13'
23
+ * @member {String} version='5.1.14'
24
24
  */
25
- version: '5.1.13'
25
+ version: '5.1.14'
26
26
  }
27
27
 
28
28
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo.mjs",
3
- "version": "5.1.13",
3
+ "version": "5.1.14",
4
4
  "description": "The webworkers driven UI framework",
5
5
  "type": "module",
6
6
  "repository": {
@@ -2,18 +2,18 @@
2
2
  "success": true,
3
3
 
4
4
  "data": [
5
- {"id": 1, "cardIndex": null, "isHeader": true, "name": "1. Basic data"},
6
- {"id": 2, "cardIndex": 0, "isHeader": false, "name": "Page 1"},
7
- {"id": 3, "cardIndex": 1, "isHeader": false, "name": "Page 2"},
8
- {"id": 4, "cardIndex": 2, "isHeader": false, "name": "Page 3"},
9
- {"id": 5, "cardIndex": null, "isHeader": true, "name": "2. Personal data"},
10
- {"id": 6, "cardIndex": 3, "isHeader": false, "name": "Page 4"},
11
- {"id": 7, "cardIndex": 4, "isHeader": false, "name": "Page 5"},
12
- {"id": 8, "cardIndex": 5, "isHeader": false, "name": "Page 6"},
13
- {"id": 9, "cardIndex": 6, "isHeader": false, "name": "Page 7"},
14
- {"id": 10, "cardIndex": null, "isHeader": true, "name": "3. More data"},
15
- {"id": 11, "cardIndex": 7, "isHeader": false, "name": "Page 8"},
16
- {"id": 12, "cardIndex": 8, "isHeader": false, "name": "Page 9"},
17
- {"id": 13, "cardIndex": 9, "isHeader": false, "name": "Page 10"}
5
+ {"id": 1, "cardIndex": null, "isHeader": true, "isValid": null, "name": "1. Basic data"},
6
+ {"id": 2, "cardIndex": 0, "isHeader": false, "isValid": null, "name": "Page 1"},
7
+ {"id": 3, "cardIndex": 1, "isHeader": false, "isValid": null, "name": "Page 2"},
8
+ {"id": 4, "cardIndex": 2, "isHeader": false, "isValid": null, "name": "Page 3"},
9
+ {"id": 5, "cardIndex": null, "isHeader": true, "isValid": null, "name": "2. Personal data"},
10
+ {"id": 6, "cardIndex": 3, "isHeader": false, "isValid": null, "name": "Page 4"},
11
+ {"id": 7, "cardIndex": 4, "isHeader": false, "isValid": null, "name": "Page 5"},
12
+ {"id": 8, "cardIndex": 5, "isHeader": false, "isValid": null, "name": "Page 6"},
13
+ {"id": 9, "cardIndex": 6, "isHeader": false, "isValid": null, "name": "Page 7"},
14
+ {"id": 10, "cardIndex": null, "isHeader": true, "isValid": null, "name": "3. More data"},
15
+ {"id": 11, "cardIndex": 7, "isHeader": false, "isValid": null, "name": "Page 8"},
16
+ {"id": 12, "cardIndex": 8, "isHeader": false, "isValid": null, "name": "Page 9"},
17
+ {"id": 13, "cardIndex": 9, "isHeader": false, "isValid": null, "name": "Page 10"}
18
18
  ]
19
19
  }
@@ -1,6 +1,7 @@
1
1
  .form-form-container.neo-container {
2
2
  border : 1px solid #ddd;
3
3
  border-radius: 5px;
4
+ max-width : 600px;
4
5
 
5
6
  .form-footer {
6
7
  border-top: 1px solid #ddd;
@@ -0,0 +1,31 @@
1
+ .form-side-nav-list.neo-list {
2
+ .neo-list-header {
3
+ font-weight : bold;
4
+ text-transform: uppercase;
5
+ }
6
+
7
+ .neo-list-item {
8
+ .neo-color-blue {
9
+ color: #1c60a0;
10
+ }
11
+
12
+ .neo-color-green {
13
+ color: darkgreen;
14
+ }
15
+
16
+ .neo-color-red {
17
+ color: brown;
18
+ }
19
+
20
+ .neo-list-icon {
21
+ margin-right: .5em;
22
+ }
23
+
24
+ &:not(.neo-list-header) {
25
+ align-items : center;
26
+ display : flex;
27
+ flex-direction: row;
28
+ margin-left : 18px;
29
+ }
30
+ }
31
+ }
@@ -237,12 +237,12 @@ const DefaultConfig = {
237
237
  useVdomWorker: true,
238
238
  /**
239
239
  * buildScripts/injectPackageVersion.mjs will update this value
240
- * @default '5.1.13'
240
+ * @default '5.1.14'
241
241
  * @memberOf! module:Neo
242
242
  * @name config.version
243
243
  * @type String
244
244
  */
245
- version: '5.1.13'
245
+ version: '5.1.14'
246
246
  };
247
247
 
248
248
  Object.assign(DefaultConfig, {
@@ -90,6 +90,17 @@ class DateField extends Picker {
90
90
  return this.dateSelector;
91
91
  }
92
92
 
93
+ /**
94
+ * @returns {Boolean}
95
+ */
96
+ hasContent() {
97
+ if (this.labelPosition === 'inline') {
98
+ return true;
99
+ }
100
+
101
+ return super.hasContent()
102
+ }
103
+
93
104
  /**
94
105
  * @param {Object} data
95
106
  * @protected
@@ -696,19 +696,17 @@ class Text extends Base {
696
696
  * @protected
697
697
  */
698
698
  afterSetValue(value, oldValue) {
699
- let me = this,
700
- cls = me.cls,
701
- placeholderText = me.placeholderText,
702
- hasContent = placeholderText?.length > 0 || value !== null && value.toString().length > 0,
703
- originalValue = me.originalConfig.value,
704
- isDirty = value !== originalValue && Neo.isEmpty(value) !== Neo.isEmpty(originalValue);
699
+ let me = this,
700
+ cls = me.cls,
701
+ originalValue = me.originalConfig.value,
702
+ isDirty = value !== originalValue && Neo.isEmpty(value) !== Neo.isEmpty(originalValue);
705
703
 
706
704
  me.silentVdomUpdate = true;
707
705
 
708
706
  me.getInputEl().value = value;
709
707
 
710
- NeoArray[hasContent ? 'add' : 'remove'](cls, 'neo-has-content');
711
- NeoArray[isDirty ? 'add' : 'remove'](cls, 'neo-is-dirty');
708
+ NeoArray[me.hasContent() ? 'add' : 'remove'](cls, 'neo-has-content');
709
+ NeoArray[isDirty ? 'add' : 'remove'](cls, 'neo-is-dirty');
712
710
  me.cls = cls;
713
711
 
714
712
  me.validate(); // silent
@@ -998,6 +996,15 @@ class Text extends Base {
998
996
  return this.id + '-trigger-' + type;
999
997
  }
1000
998
 
999
+ /**
1000
+ * @returns {Boolean}
1001
+ */
1002
+ hasContent() {
1003
+ let value = this.value;
1004
+
1005
+ return this.placeholderText?.length > 0 || value !== null && value.toString().length > 0
1006
+ }
1007
+
1001
1008
  /**
1002
1009
  * Finds a trigger by a given type config
1003
1010
  * @param {String} type